01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2004-2006, Geotools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or (at your option) any later version.
10: *
11: * This library 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 GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.geometry.jts;
17:
18: import java.awt.geom.AffineTransform;
19:
20: import com.vividsolutions.jts.geom.Point;
21:
22: /**
23: * A path iterator for the LiteShape class, specialized to iterate over Point objects.
24: *
25: * @author Andrea Aime
26: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/geometry/jts/PointIterator.java $
27: */
28: public final class PointIterator extends AbstractLiteIterator {
29: /** Transform applied on the coordinates during iteration */
30: private AffineTransform at;
31:
32: /** The point we are going to provide when asked for coordinates */
33: private Point point;
34:
35: /** True when the point has been read once */
36: private boolean done;
37:
38: /**
39: * Creates a new PointIterator object.
40: *
41: * @param point The point
42: * @param at The affine transform applied to coordinates during iteration
43: */
44: public PointIterator(Point point, AffineTransform at) {
45: if (at == null) {
46: at = new AffineTransform();
47: }
48:
49: this .at = at;
50: this .point = point;
51: done = false;
52: }
53:
54: /**
55: * Return the winding rule for determining the interior of the path.
56: *
57: * @return <code>WIND_EVEN_ODD</code> by default.
58: */
59: public int getWindingRule() {
60: return WIND_EVEN_ODD;
61: }
62:
63: /**
64: * @see java.awt.geom.PathIterator#next()
65: */
66: public void next() {
67: done = true;
68: }
69:
70: /**
71: * @see java.awt.geom.PathIterator#isDone()
72: */
73: public boolean isDone() {
74: return done;
75: }
76:
77: /**
78: * @see java.awt.geom.PathIterator#currentSegment(double[])
79: */
80: public int currentSegment(double[] coords) {
81: coords[0] = point.getX();
82: coords[1] = point.getY();
83: at.transform(coords, 0, coords, 0, 1);
84:
85: return SEG_MOVETO;
86: }
87:
88: }
|