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 MultiLineShape 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/MultiLineShapeTest.java $
034: */
035: public class MultiLineShapeTest 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, 10.0, 10.0, 15.0,
042: 0.0 };
043: double[] coord2 = new double[] { 0.0, 15.0, 10.0, 15.0, 15.0,
044: 15.0 };
045: double[][] coords = new double[][] { coord1, coord2 };
046:
047: SimpleGeometry geom = new SimpleGeometry(ShapeType.ARC, coords,
048: new Envelope(0, 15, 0, 15));
049:
050: MultiLineShape shape = new MultiLineShape(geom);
051:
052: PathIterator i = shape.getPathIterator(new AffineTransform());
053: double[] tmp = new double[6];
054: int result = i.currentSegment(tmp);
055: assertFalse(i.isDone());
056: assertEquals(0.0, tmp[0], 0.001);
057: assertEquals(0.0, tmp[1], 0.001);
058: assertEquals(PathIterator.SEG_MOVETO, result);
059:
060: i.next();
061:
062: tmp = new double[6];
063: result = i.currentSegment(tmp);
064:
065: assertFalse(i.isDone());
066: assertEquals(10.0, tmp[0], 0.001);
067: assertEquals(10.0, tmp[1], 0.001);
068: assertEquals(PathIterator.SEG_LINETO, result);
069:
070: i.next();
071:
072: tmp = new double[6];
073: result = i.currentSegment(tmp);
074:
075: assertFalse(i.isDone());
076: assertEquals(15.0, tmp[0], 0.001);
077: assertEquals(0.0, tmp[1], 0.001);
078: assertEquals(PathIterator.SEG_LINETO, result);
079:
080: i.next();
081:
082: tmp = new double[6];
083: result = i.currentSegment(tmp);
084:
085: assertFalse(i.isDone());
086: assertEquals(0.0, tmp[0], 0.001);
087: assertEquals(15.0, 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(10.0, tmp[0], 0.001);
097: assertEquals(15.0, tmp[1], 0.001);
098: assertEquals(PathIterator.SEG_LINETO, result);
099:
100: i.next();
101:
102: tmp = new double[6];
103: result = i.currentSegment(tmp);
104:
105: assertFalse(i.isDone());
106: assertEquals(15.0, tmp[0], 0.001);
107: assertEquals(15.0, tmp[1], 0.001);
108: assertEquals(PathIterator.SEG_LINETO, result);
109:
110: i.next();
111: assertTrue(i.isDone());
112: }
113:
114: }
|