001: /*
002: * Geotools2 - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002, Geotools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: */
017: package org.geotools.renderer.shape;
018:
019: import java.awt.geom.AffineTransform;
020: import java.awt.geom.PathIterator;
021:
022: import junit.framework.TestCase;
023:
024: import org.geotools.data.shapefile.shp.ShapeType;
025:
026: import com.vividsolutions.jts.geom.Envelope;
027:
028: /**
029: * Tests MultiPointShape class
030: *
031: * @author jeichar
032: * @since 2.1.x
033: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/shapefile-renderer/src/test/java/org/geotools/renderer/shape/MultiPointShapeTest.java $
034: */
035: public class MultiPointShapeTest extends TestCase {
036:
037: /**
038: * Class under test for PathIterator getPathIterator(AffineTransform)
039: */
040: public void testGetPathIteratorAffineTransform() {
041: double[] coord1 = new double[] { 0.0, 0.0 };
042: double[] coord2 = new double[] { 0.0, 15.0 };
043: double[] coord3 = new double[] { 15.0, 15.0 };
044: double[] coord4 = new double[] { 15.0, 0.0 };
045: double[] coord5 = new double[] { 0.0, 10.0 };
046: double[] coord6 = new double[] { 10.0, 15.0 };
047: double[][] coords = new double[][] { coord1, coord2, coord3,
048: coord4, coord5, coord6 };
049:
050: SimpleGeometry geom = new SimpleGeometry(ShapeType.MULTIPOINT,
051: new double[][] { coord1 }, new Envelope(0, 15, 0, 15));
052:
053: MultiPointShape shape = new MultiPointShape(geom);
054:
055: PathIterator i = shape.getPathIterator(new AffineTransform());
056: double[] tmp = new double[6];
057: int result = i.currentSegment(tmp);
058: assertFalse(i.isDone());
059: assertEquals(coord1[0], tmp[0], 0.001);
060: assertEquals(coord1[1], tmp[1], 0.001);
061: assertEquals(PathIterator.SEG_MOVETO, result);
062:
063: i.next();
064:
065: assertTrue(i.isDone());
066:
067: geom = new SimpleGeometry(ShapeType.MULTIPOINT, coords,
068: new Envelope(0, 15, 0, 15));
069:
070: shape = new MultiPointShape(geom);
071:
072: i = shape.getPathIterator(new AffineTransform());
073: tmp = new double[6];
074: result = i.currentSegment(tmp);
075: assertFalse(i.isDone());
076: assertEquals(coord1[0], tmp[0], 0.001);
077: assertEquals(coord1[1], tmp[1], 0.001);
078: assertEquals(PathIterator.SEG_MOVETO, result);
079:
080: i.next();
081:
082: tmp = new double[6];
083: result = i.currentSegment(tmp);
084:
085: assertFalse(i.isDone());
086: assertEquals(coord2[0], tmp[0], 0.001);
087: assertEquals(coord2[1], tmp[1], 0.001);
088: assertEquals(PathIterator.SEG_MOVETO, result);
089:
090: i.next();
091:
092: tmp = new double[6];
093: result = i.currentSegment(tmp);
094:
095: assertFalse(i.isDone());
096: assertEquals(coord3[0], tmp[0], 0.001);
097: assertEquals(coord3[1], tmp[1], 0.001);
098: assertEquals(PathIterator.SEG_MOVETO, result);
099:
100: i.next();
101:
102: tmp = new double[6];
103: result = i.currentSegment(tmp);
104:
105: assertFalse(i.isDone());
106: assertEquals(coord4[0], tmp[0], 0.001);
107: assertEquals(coord4[1], tmp[1], 0.001);
108: assertEquals(PathIterator.SEG_MOVETO, result);
109:
110: i.next();
111:
112: tmp = new double[6];
113: result = i.currentSegment(tmp);
114:
115: assertFalse(i.isDone());
116: assertEquals(coord5[0], tmp[0], 0.001);
117: assertEquals(coord5[1], tmp[1], 0.001);
118: assertEquals(PathIterator.SEG_MOVETO, result);
119:
120: i.next();
121:
122: tmp = new double[6];
123: result = i.currentSegment(tmp);
124:
125: assertFalse(i.isDone());
126: assertEquals(coord6[0], tmp[0], 0.001);
127: assertEquals(coord6[1], tmp[1], 0.001);
128: assertEquals(PathIterator.SEG_MOVETO, result);
129:
130: i.next();
131: assertTrue(i.isDone());
132: }
133:
134: }
|