Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.symbology / org.gvsig.symbology.lib / org.gvsig.symbology.lib.impl / src / test / java / org / gvsig / symbology / fmap / mapcontext / rendering / TestCartographicSupportForSymbol.java @ 47476

History | View | Annotate | Download (23 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.symbology.fmap.mapcontext.rendering;
25

    
26
import java.awt.Dimension;
27
import java.awt.geom.Rectangle2D;
28
import java.util.ArrayList;
29
import java.util.Random;
30
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
31
import org.gvsig.fmap.geom.GeometryLocator;
32
import org.gvsig.fmap.geom.GeometryManager;
33
import org.gvsig.fmap.geom.exception.CreateGeometryException;
34
import org.gvsig.fmap.geom.primitive.Envelope;
35
import org.gvsig.fmap.geom.primitive.Point;
36
import org.gvsig.fmap.mapcontext.MapContext;
37
import org.gvsig.fmap.mapcontext.MapContextLocator;
38
import org.gvsig.fmap.mapcontext.ViewPort;
39
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport;
40
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
41
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager;
42
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.AbstractSymbolTestCase;
43
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.SimpleFillSymbolTest;
44
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.SimpleLineSymbolTest;
45
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.SimpleMarkerSymbolTest;
46
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol;
47
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol;
48
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol;
49
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
50
import org.gvsig.utils.IPersistence;
51
import org.gvsig.utils.NotExistInXMLEntity;
52
import org.gvsig.utils.XMLEntity;
53
import org.gvsig.utils.XMLException;
54
import org.slf4j.Logger;
55
import org.slf4j.LoggerFactory;
56

    
57

    
58
/**
59
 *
60
 * @author jaume dominguez faus - jaume.dominguez@iver.es
61
 */
62
public class TestCartographicSupportForSymbol extends AbstractLibraryAutoInitTestCase {
63
        private static GeometryManager geomManager;        
64
        private static final Logger logger = LoggerFactory.getLogger(TestCartographicSupportForSymbol.class);
65
        
66
        /**
67
         * Geodesic vertex of the Micalet in Valencia (Spain) in <b>EPSG:23030</b>
68
         */
69
        public static Point valenciaUTM30 = null;
70

    
71
        /**
72
         * Geodesic vertex of the Micalet in Valencia (Spain) in <b>EPSG:4326</b>
73
         */
74
        public static Point valenciaGeo = null;
75

    
76
        public SymbolManager manager = MapContextLocator.getSymbolManager();
77
        /**
78
         * Extent that covers the whole Comunitat Valenciana in  <b>EPSG:23030</b>
79
         */
80
        public static final Rectangle2D TEST_UTM30_EXTENT = new Rectangle2D.Double();
81
        static {
82
                TEST_UTM30_EXTENT.setFrameFromDiagonal(
83
                                4191037.369934333,
84
                                626674.7454557443,
85

    
86
                                4519266.460824658,
87
                                797903.2656794232
88
                );
89
        }
90
        /**
91
         * Extent that covers the whole Comunitat Valenciana in  <b>EPSG:4326</b>
92
         */
93

    
94
        public static final Rectangle2D TEST_GEO_EXTENT = new Rectangle2D.Double();
95
        static {
96
                TEST_GEO_EXTENT.setFrameFromDiagonal(
97

    
98
                                -  (1 + (31/60) + (28.09/3600)),        // Western egde
99
                                37 + (50/60) + (48.05/3600),                // Southern edge
100

    
101
                                0 + (31/60) + (1.85/3600),                // Eastern edge
102
                                40 + (47/60) + (21.36/3600)                // Northern edge
103

    
104
                );
105
        }
106

    
107
        public static final Rectangle2D TEST_EXTENT = new Rectangle2D.Double(
108
                        4191037.369934333,
109
                        626674.7454557443,
110

    
111
                        4519266.460824658 - 4191037.369934333,
112
                        797903.2656794232 -  626674.7454557443
113
        );
114
        private static ArrayList symbolsToTest; //<AbstractSymbolTestCase>
115
        private ArrayList csSymbols; //<CartographicSupport>
116

    
117
        /**
118
         * Acceptable pixel tolerance error. 1 pixel of error is accetable since it is probably due to
119
         * the java.awt.Graphics
120
         */
121
        private static final double TOL = 1;
122

    
123
        double zooms[] = new double[] {
124
                        1,
125
                        2,
126
                        1.2,
127
                        10,
128
                        0.5
129
        };
130

    
131
        @Override
132
        protected void doSetUp() throws Exception {        
133
                geomManager = GeometryLocator.getGeometryManager();
134
                try {
135
                        valenciaUTM30 = geomManager.createPoint(725846.080, 4373022.720, SUBTYPES.GEOM2D);
136
                        valenciaGeo = geomManager.createPoint(- (0+ 22/60 +  27.919/3600), 39 + 28/60 + 35.4276/3600, SUBTYPES.GEOM2D);
137
                } catch (CreateGeometryException e) {
138
                        // TODO Auto-generated catch block
139
                        logger.warn("Can't create points", e);
140
                }                
141
        
142
                addSymbolTest(new SimpleFillSymbolTest());
143
                addSymbolTest(new SimpleLineSymbolTest());
144
                addSymbolTest(new SimpleMarkerSymbolTest());
145

    
146
                init();
147
        }
148

    
149
        protected void init() {
150

    
151
                // take the symbols added to the TestISymbol test
152
                ISymbol[] symbols = getNewSymbolInstances();
153

    
154
                csSymbols = new ArrayList(); //<CartographicSupport>
155
            for (ISymbol symbol : symbols) {
156
                if (symbol instanceof CartographicSupport) {
157
                    csSymbols.add((CartographicSupport) symbol);
158
                }
159
            }
160
        }
161

    
162
        public static void addSymbolTest(AbstractSymbolTestCase symbolTestClass) {
163
                if (symbolsToTest == null) symbolsToTest = new ArrayList(); //<AbstractSymbolTestCase>
164
                symbolsToTest.add(symbolTestClass);
165
        }
166

    
167
        public static ISymbol[] getNewSymbolInstances() {
168
                ISymbol[] symbols = new ISymbol[symbolsToTest.size()];
169
                for (int i = 0; i < symbols.length; i++) {
170
                        symbols[i] = (ISymbol)((AbstractSymbolTestCase)symbolsToTest.get(i)).newInstance();
171
                }
172
                return symbols;
173
        }
174

    
175

    
176
        public void testSymbolUnitDefinition() {
177
                for (int i = 0; i < csSymbols.size(); i++) {
178
                        CartographicSupport symbol = (CartographicSupport)csSymbols.get(i);
179

    
180
                        int aRandomUnit = new Random().nextInt(7);
181

    
182

    
183
                        symbol.setUnit(aRandomUnit);
184
                        XMLEntity xml=null;
185
                        try {
186
                                xml = ((IPersistence) symbol).getXMLEntity();
187
                        } catch (XMLException e) {
188
                                logger.warn("Can't get XMLEntity", e);
189
                        }
190
                        String name = symbol.getClass().getName().substring(
191
                                        symbol.getClass().getName().lastIndexOf('.')+1,
192
                                        symbol.getClass().getName().length());
193

    
194
                        try {
195
                                assertTrue( ((ISymbol) symbol).getClass().getName()+" does not declare units correctly",
196
                                                symbol.getUnit() == xml.getIntProperty("unit"));
197
                        } catch (NotExistInXMLEntity neiXMLEx) {
198
                                fail(((ISymbol) symbol).getClass().getName()+ " does not declare field attribute in its XMLEntity");
199
                        }
200
                        symbol.setUnit(5);
201
                        try {
202
                                assertTrue( ((ISymbol) symbol).getClass().getName()+" does not apply changes to symbol",symbol.getUnit()== 5);
203
                                assertTrue( ((ISymbol) symbol).getClass().getName()+" does not declare units correctly",
204
                                                5 == ((IPersistence) symbol).getXMLEntity().getIntProperty("unit"));
205
                        } catch (Exception neiXMLEx) {
206
                                fail(((ISymbol) symbol).getClass().getName()+ " does not declare field attribute in its XMLEntity");
207
                        }
208
                }
209

    
210
        }
211

    
212

    
213
        public void testSymbolReferenceSystemDefinition() {
214
                for (int i = 0; i < csSymbols.size(); i++) {
215
                        CartographicSupport symbol = (CartographicSupport)csSymbols.get(i);
216
                        XMLEntity xml=null;
217
                        try {
218
                                xml = ((IPersistence) symbol).getXMLEntity();
219
                        } catch (XMLException e) {
220
                            logger.warn("Can't get XMLEntity.", e);
221
                        }
222
                        String name = symbol.getClass().getName().substring(
223
                                        symbol.getClass().getName().lastIndexOf('.')+1,
224
                                        symbol.getClass().getName().length());
225
                        try {
226
                                assertTrue( ((ISymbol) symbol).getClass().getName()+" does not declare units correctly",
227
                                                symbol.getReferenceSystem() == xml.getIntProperty("referenceSystem"));
228
                        } catch (NotExistInXMLEntity neiXMLEx) {
229
                                fail(((ISymbol) symbol).getClass().getName()+ " does not declare referenceSystem field attribute in its XMLEntity");
230
                        }
231
                        symbol.setReferenceSystem(CartographicSupport.PAPER);
232
                        try {
233
                                assertTrue( ((ISymbol) symbol).getClass().getName()+" does not apply changes to symbol",symbol.getReferenceSystem()== CartographicSupport.PAPER);
234
                                assertTrue( ((ISymbol) symbol).getClass().getName()+" does not declare referenceSystem correctly",
235
                                                CartographicSupport.PAPER == ((IPersistence) symbol).getXMLEntity().getIntProperty("referenceSystem"));
236
                        } catch (Exception neiXMLEx) {
237
                                fail(((ISymbol) symbol).getClass().getName()+ " does not declare referenceSystem field attribute in its XMLEntity ("+name+")");
238
                        }
239

    
240
                        symbol.setReferenceSystem(CartographicSupport.WORLD);
241
                        try {
242
                                assertTrue( ((ISymbol) symbol).getClass().getName()+" does not apply changes to symbol",symbol.getReferenceSystem()== CartographicSupport.WORLD);
243
                                assertTrue( ((ISymbol) symbol).getClass().getName()+" does not declare referenceSystem correctly",
244
                                                CartographicSupport.WORLD == ((IPersistence) symbol).getXMLEntity().getIntProperty("referenceSystem"));
245
                        } catch (Exception neiXMLEx) {
246
                                fail(((ISymbol) symbol).getClass().getName()+ " does not declare referenceSystem field attribute in its XMLEntity");
247
                        }
248

    
249
                }
250
        }
251

    
252

    
253
        public void testDegreesUnits_MapReferenceSystem() throws Exception {
254
                for (int j = 0; j < csSymbols.size(); j++) {
255
                        CartographicSupport symbol = (CartographicSupport)csSymbols.get(j);
256

    
257
                        MapContext mc = AllTests.newMapContext(AllTests.TEST_DEFAULT_PROJECTION);
258
                        ViewPort viewPort = mc.getViewPort();
259

    
260
                        int unit = 8;
261
                        Dimension dim = new Dimension(600, 600);
262
                        viewPort.setImageSize(dim);
263

    
264

    
265
                        /*
266
                         * will test with several extents but in the same map image size, so
267
                         * the scale issue is exercised as well.
268
                         */
269
                        for (int i = 0; i < zooms.length; i++) {
270
                                Envelope extent = geomManager.createEnvelope(-30, -30,dim.getWidth()/zooms[i]-30, dim.getHeight()/zooms[i]-30, SUBTYPES.GEOM2D);
271

    
272
                                viewPort.setMapUnits(unit);
273
                                viewPort.setEnvelope(extent);
274

    
275

    
276
                                String name = ((IPersistence) symbol).getClassName().substring(
277
                                                ((IPersistence) symbol).getClassName().lastIndexOf('.')+1,
278
                                                ((IPersistence) symbol).getClassName().length());
279

    
280
                                CartographicSupport csSym = (CartographicSupport) symbol;
281
                                csSym.setReferenceSystem(CartographicSupport.WORLD);
282
                                double size = 30;
283

    
284
                                csSym.setUnit(unit);
285

    
286

    
287

    
288
                                if (symbol instanceof IMarkerSymbol) {
289

    
290
                                        IMarkerSymbol markerSym = (IMarkerSymbol) symbol;
291
                                        markerSym.setSize(size);
292
                                        csSym.setCartographicContext(
293
                                            viewPort,
294
                                            viewPort.getDPI(),
295
                                            geomManager.createPoint(
296
                                                    viewPort.getAdjustedExtent().getCenter(0),
297
                                                    viewPort.getAdjustedExtent().getCenter(1),
298
                                                    SUBTYPES.GEOM2D
299
                                            ));
300
                                        double mySize = csSym.toCartographicUnits(size); //.getSize();
301
                                        assertTrue("The Symbol '"+name+"' failed computing cartographic size. " +
302
                                                        "It returned "+mySize+" when expecting "+
303
                                                        size+"*"+zooms[i]+"="+size*zooms[i],  Math.abs(mySize-size*zooms[i]) <= TOL );
304
                                }
305

    
306
                                if (symbol instanceof ILineSymbol) {
307

    
308
                                        ILineSymbol lineSym = (ILineSymbol) symbol;
309
                                        lineSym.setLineWidth(size);
310
                                        csSym.setCartographicContext(
311
                                            viewPort,
312
                                            viewPort.getDPI(),
313
                                            geomManager.createPoint(
314
                                                    viewPort.getAdjustedExtent().getCenter(0),
315
                                                    viewPort.getAdjustedExtent().getCenter(1),
316
                                                    SUBTYPES.GEOM2D
317
                                            ));
318
                                        double mySize = csSym.toCartographicUnits(lineSym.getLineStyle().getLineWidth());
319
                                        assertTrue("The Symbol '"+name+"' failed computing cartographic size. " +
320
                                                        "It returned "+mySize+" when expecting "+
321
                                                        size+"*"+zooms[i]+"="+size*zooms[i], Math.abs(mySize-size*zooms[i]) <= TOL );
322
                                }
323

    
324
                                if (symbol instanceof IFillSymbol) {
325
                                        // this tests if symbol applies the cartographic support to its
326
                                        // outline, since is the only thing that may be resized
327
                                        IFillSymbol fillSym = (IFillSymbol) symbol;
328
                                        if (fillSym.getOutline() == null) {
329
                                                fillSym.setOutline((ILineSymbol) manager.createSymbol(ILineSymbol.SYMBOL_NAME));
330
                                        }
331

    
332
                                        fillSym.getOutline().setLineWidth(size);
333

    
334
                                        csSym.setCartographicContext(
335
                                            viewPort,
336
                                            viewPort.getDPI(),
337
                                            geomManager.createPoint(
338
                                                    viewPort.getAdjustedExtent().getCenter(0),
339
                                                    viewPort.getAdjustedExtent().getCenter(1),
340
                                                    SUBTYPES.GEOM2D
341
                                            ));
342
                                        double mySize = csSym.toCartographicUnits(fillSym.getOutline().getLineStyle().getLineWidth());
343
                                        assertTrue("The Symbol '"+name+"' failed computing cartographic size. " +
344
                                                        "It returned "+mySize+" when expecting "+
345
                                                        size+"*"+zooms[i]+"="+size*zooms[i], Math.abs(mySize-size*zooms[i]) <= TOL );
346
                                }
347

    
348
                        }
349
                }
350
        }
351

    
352

    
353
        public void testKilometersUnits_MapReferenceSystem() throws Exception {
354
                for (int j = 0; j < csSymbols.size(); j++) {
355
                        CartographicSupport symbol = (CartographicSupport)csSymbols.get(j);
356
                        MapContext mc = AllTests.newMapContext(AllTests.TEST_DEFAULT_MERCATOR_PROJECTION);
357
                        ViewPort viewPort = mc.getViewPort();
358

    
359
                        int unit = 0;
360
                        Dimension dim = new Dimension(60, 60);
361
                        viewPort.setImageSize(dim);
362

    
363

    
364
                        /*
365
                         * will test with several extents but in the same map image size, so
366
                         * the scale issue is exercised as well.
367
                         */
368
                        for (int i = 0; i < zooms.length; i++) {
369
                                Envelope extent = geomManager.createEnvelope(-30, -30, dim.getWidth()/zooms[i]-30, dim.getHeight()/zooms[i]-30, SUBTYPES.GEOM2D);
370

    
371
                                viewPort.setMapUnits(unit);
372
                                viewPort.setEnvelope(extent);
373

    
374

    
375
                                String name = ((IPersistence) symbol).getClassName().substring(
376
                                                ((IPersistence) symbol).getClassName().lastIndexOf('.')+1,
377
                                                ((IPersistence) symbol).getClassName().length());
378

    
379
                                CartographicSupport csSym = (CartographicSupport) symbol;
380
                                csSym.setReferenceSystem(CartographicSupport.WORLD);
381
                                double size = 30;
382

    
383
                                csSym.setUnit(unit);
384

    
385

    
386

    
387

    
388
                                if (symbol instanceof IMarkerSymbol) {
389

    
390
                                        IMarkerSymbol markerSym = (IMarkerSymbol) symbol;
391
                                        markerSym.setSize(size);
392
                                        csSym.setCartographicContext(
393
                                            viewPort,
394
                                            viewPort.getDPI(),
395
                                            geomManager.createPoint(
396
                                                    viewPort.getAdjustedExtent().getCenter(0),
397
                                                    viewPort.getAdjustedExtent().getCenter(1),
398
                                                    SUBTYPES.GEOM2D
399
                                            ));
400
                                        
401
                                        double mySize = csSym.toCartographicUnits(size);
402
                                        assertTrue("The Symbol '"+name+"' failed computing cartographic size. " +
403
                                                        "It returned "+mySize+" when expecting "+
404
                                                        size+"*"+zooms[i]+"="+size*zooms[i],  Math.abs(mySize-size*zooms[i]) <= TOL );
405
                                }
406

    
407
                                if (symbol instanceof ILineSymbol) {
408

    
409
                                        ILineSymbol lineSym = (ILineSymbol) symbol;
410
                                        lineSym.setLineWidth(size);
411
                                        csSym.setCartographicContext(
412
                                            viewPort,
413
                                            viewPort.getDPI(),
414
                                            geomManager.createPoint(
415
                                                    viewPort.getAdjustedExtent().getCenter(0),
416
                                                    viewPort.getAdjustedExtent().getCenter(1),
417
                                                    SUBTYPES.GEOM2D
418
                                            ));
419
                                        double mySize = csSym.toCartographicUnits(lineSym.getLineStyle().getLineWidth());
420
                                        
421
                                        assertTrue("The Symbol '"+name+"' failed computing cartographic size. " +
422
                                                        "It returned "+mySize+" when expecting "+
423
                                                        size+"*"+zooms[i]+"="+size*zooms[i], Math.abs(mySize-size*zooms[i]) <= TOL );
424
                                }
425

    
426
                                if (symbol instanceof IFillSymbol) {
427
                                        // this tests if symbol applies the cartographic support to its
428
                                        // outline, since is the only thing that may be resized
429
                                        IFillSymbol fillSym = (IFillSymbol) symbol;
430
                                        if (fillSym.getOutline() == null) {
431
                                                fillSym.setOutline((ILineSymbol) manager.createSymbol(
432
                                                                                ILineSymbol.SYMBOL_NAME));
433
                                        }
434

    
435
                                        fillSym.getOutline().setLineWidth(size);
436

    
437
                                        csSym.setCartographicContext(
438
                                            viewPort,
439
                                            viewPort.getDPI(),
440
                                            geomManager.createPoint(
441
                                                    viewPort.getAdjustedExtent().getCenter(0),
442
                                                    viewPort.getAdjustedExtent().getCenter(1),
443
                                                    SUBTYPES.GEOM2D
444
                                            ));
445

    
446
                                        double mySize = csSym.toCartographicUnits(fillSym.getOutline().getLineStyle().getLineWidth());
447
                                        assertTrue("The Symbol '"+name+"' failed computing cartographic size. " +
448
                                                        "It returned "+mySize+" when expecting "+
449
                                                        size+"*"+zooms[i]+"="+size*zooms[i], Math.abs(mySize-size*zooms[i]) <= TOL );
450
                                }
451

    
452
                        }
453
                }
454

    
455
        }
456

    
457
        public void testMapInKilometersSymbolInMeters_MapReferenceSystem() throws Exception {
458
                for (int j = 0; j < csSymbols.size(); j++) {
459
                        CartographicSupport symbol = (CartographicSupport)csSymbols.get(j);
460

    
461
                        MapContext mc = AllTests.newMapContext(AllTests.TEST_DEFAULT_MERCATOR_PROJECTION);
462
                        ViewPort viewPort = mc.getViewPort();
463

    
464
                        int mapUnit = 0;
465
                        int symbolUnit = 1;
466
                        Dimension dim = new Dimension(60, 60);
467
                        viewPort.setImageSize(dim);
468

    
469

    
470
                        /*
471
                         * will test with several extents but in the same map image size, so
472
                         * the scale issue is exercised as well.
473
                         */
474
                        for (int i = 0; i < zooms.length; i++) {
475
                                Envelope extent = geomManager.createEnvelope(-30, -30, dim.getWidth()/zooms[i]-30, dim.getHeight()/zooms[i]-30, SUBTYPES.GEOM2D);
476
                                viewPort.setMapUnits(mapUnit);
477
                                viewPort.setEnvelope(extent);
478
                                double size = 30;
479

    
480

    
481
                                String name = ((IPersistence) symbol).getClassName().substring(
482
                                                ((IPersistence) symbol).getClassName().lastIndexOf('.')+1,
483
                                                ((IPersistence) symbol).getClassName().length());
484

    
485

    
486
                                CartographicSupport csSym = (CartographicSupport) symbol;
487
                                csSym.setReferenceSystem(CartographicSupport.WORLD);
488

    
489
                                csSym.setUnit(symbolUnit);
490

    
491
                                if (symbol instanceof IMarkerSymbol) {
492

    
493
                                        IMarkerSymbol markerSym = (IMarkerSymbol) symbol;
494
                                        markerSym.setSize(size*MapContext.CHANGEM[mapUnit]); // 30m*1000 = 30 km
495
                                        csSym.setCartographicContext(
496
                                            viewPort,
497
                                            viewPort.getDPI(),
498
                                            geomManager.createPoint(
499
                                                    viewPort.getAdjustedExtent().getCenter(0),
500
                                                    viewPort.getAdjustedExtent().getCenter(1),
501
                                                    SUBTYPES.GEOM2D
502
                                            ));
503
                                        double mySize = csSym.toCartographicUnits(size);
504
                                        assertTrue("The Symbol '"+name+"' failed computing cartographic size. " +
505
                                                        "It returned "+mySize+" when expecting "+
506
                                                        size+"*"+zooms[i]+"="+size*zooms[i],  Math.abs(mySize-size*zooms[i]) <= TOL );
507
                                }
508

    
509
                                if (symbol instanceof ILineSymbol) {
510

    
511
                                        ILineSymbol lineSym = (ILineSymbol) symbol;
512
                                        lineSym.setLineWidth(size*MapContext.CHANGEM[mapUnit]); // 30m*1000 = 30 km
513
                                        csSym.setCartographicContext(
514
                                            viewPort,
515
                                            viewPort.getDPI(),
516
                                            geomManager.createPoint(
517
                                                    viewPort.getAdjustedExtent().getCenter(0),
518
                                                    viewPort.getAdjustedExtent().getCenter(1),
519
                                                    SUBTYPES.GEOM2D
520
                                            ));
521
                                        double mySize = csSym.toCartographicUnits(lineSym.getLineStyle().getLineWidth());
522
                                        assertTrue("The Symbol '"+name+"' failed computing cartographic size. " +
523
                                                        "It returned "+mySize+" when expecting "+
524
                                                        size+"*"+zooms[i]+"="+size*zooms[i], Math.abs(mySize-size*zooms[i]) <= TOL );
525
                                }
526

    
527
                                if (symbol instanceof IFillSymbol) {
528
                                        // this tests if symbol applies the cartographic support to its
529
                                        // outline, since is the only thing that may be resized
530
                                        IFillSymbol fillSym = (IFillSymbol) symbol;
531
                                        if (fillSym.getOutline() == null) {
532
                                                fillSym.setOutline((ILineSymbol) manager.createSymbol(
533
                                                                                ILineSymbol.SYMBOL_NAME));
534
                                        }
535

    
536
                                        fillSym.getOutline().setLineWidth(size*MapContext.CHANGEM[mapUnit]);
537

    
538
                                        csSym.setCartographicContext(
539
                                            viewPort,
540
                                            viewPort.getDPI(),
541
                                            geomManager.createPoint(
542
                                                    viewPort.getAdjustedExtent().getCenter(0),
543
                                                    viewPort.getAdjustedExtent().getCenter(1),
544
                                                    SUBTYPES.GEOM2D
545
                                            ));
546
                                        double mySize = csSym.toCartographicUnits(fillSym.getOutline().getLineStyle().getLineWidth());
547
                                        assertTrue("The Symbol '"+name+"' failed computing cartographic size. " +
548
                                                        "It returned "+mySize+" when expecting "+
549
                                                        size+"*"+zooms[i]+"="+size*zooms[i], Math.abs(mySize-size*zooms[i]) <= TOL );
550
                                }
551

    
552
                        }
553
                }
554
        }
555

    
556
}