Revision 42267 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/primitive/point/Point2D.java
Point2D.java | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 |
package org.gvsig.fmap.geom.jts.primitive.point; |
24 | 24 |
|
25 |
import java.awt.geom.AffineTransform; |
|
26 |
import java.awt.geom.PathIterator; |
|
27 |
|
|
25 | 28 |
import com.vividsolutions.jts.geom.Coordinate; |
26 | 29 |
|
27 | 30 |
import org.gvsig.fmap.geom.Geometry; |
28 | 31 |
import org.gvsig.fmap.geom.GeometryLocator; |
32 |
import org.gvsig.fmap.geom.jts.gputils.DefaultGeneralPathX; |
|
33 |
import org.gvsig.fmap.geom.jts.gputils.GeneralPathXIterator; |
|
34 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
29 | 35 |
import org.gvsig.fmap.geom.type.GeometryType; |
30 | 36 |
|
31 | 37 |
/** |
... | ... | |
107 | 113 |
public void setJTSCoordinate(Coordinate coordinate) { |
108 | 114 |
this.coordinate = coordinate; |
109 | 115 |
} |
116 |
|
|
117 |
/* |
|
118 |
* (non-Javadoc) |
|
119 |
* |
|
120 |
* @see org.gvsig.fmap.geom.Geometry#getGeneralPath() |
|
121 |
*/ |
|
122 |
public GeneralPathX getGeneralPath() { |
|
123 |
return new DefaultGeneralPathX(new PointIterator(null),false,0); |
|
124 |
} |
|
125 |
|
|
126 |
/* |
|
127 |
* (non-Javadoc) |
|
128 |
* |
|
129 |
* @see |
|
130 |
* org.gvsig.fmap.geom.Geometry#getPathIterator(java.awt.geom.AffineTransform |
|
131 |
* ) |
|
132 |
*/ |
|
133 |
public PathIterator getPathIterator(AffineTransform at) { |
|
134 |
PointIterator pi = new PointIterator(at); |
|
135 |
return pi; |
|
136 |
} |
|
137 |
|
|
138 |
|
|
139 |
public class PointIterator extends GeneralPathXIterator { |
|
140 |
/** Transform applied on the coordinates during iteration */ |
|
141 |
private AffineTransform at; |
|
142 |
|
|
143 |
/** True when the point has been read once */ |
|
144 |
private boolean done; |
|
145 |
|
|
146 |
/** |
|
147 |
* Creates a new PointIterator object. |
|
148 |
* |
|
149 |
* @param p The polygon |
|
150 |
* @param at The affine transform applied to coordinates during iteration |
|
151 |
*/ |
|
152 |
public PointIterator(AffineTransform at) { |
|
153 |
super(new GeneralPathX()); |
|
154 |
if (at == null) { |
|
155 |
at = new AffineTransform(); |
|
156 |
} |
|
157 |
|
|
158 |
this.at = at; |
|
159 |
done = false; |
|
160 |
} |
|
161 |
|
|
162 |
/** |
|
163 |
* Return the winding rule for determining the interior of the path. |
|
164 |
* |
|
165 |
* @return <code>WIND_EVEN_ODD</code> by default. |
|
166 |
*/ |
|
167 |
public int getWindingRule() { |
|
168 |
return PathIterator.WIND_EVEN_ODD; |
|
169 |
} |
|
170 |
|
|
171 |
/** |
|
172 |
* @see java.awt.geom.PathIterator#next() |
|
173 |
*/ |
|
174 |
public void next() { |
|
175 |
done = true; |
|
176 |
} |
|
177 |
|
|
178 |
/** |
|
179 |
* @see java.awt.geom.PathIterator#isDone() |
|
180 |
*/ |
|
181 |
public boolean isDone() { |
|
182 |
return done; |
|
183 |
} |
|
184 |
|
|
185 |
/** |
|
186 |
* @see java.awt.geom.PathIterator#currentSegment(double[]) |
|
187 |
*/ |
|
188 |
public int currentSegment(double[] coords) { |
|
189 |
coords[0] = getX(); |
|
190 |
coords[1] = getY(); |
|
191 |
at.transform(coords, 0, coords, 0, 1); |
|
192 |
|
|
193 |
return PathIterator.SEG_MOVETO; |
|
194 |
} |
|
195 |
|
|
196 |
/* (non-Javadoc) |
|
197 |
* @see java.awt.geom.PathIterator#currentSegment(float[]) |
|
198 |
*/ |
|
199 |
public int currentSegment(float[] coords) { |
|
200 |
coords[0] = (float) getX(); |
|
201 |
coords[1] = (float) getY(); |
|
202 |
at.transform(coords, 0, coords, 0, 1); |
|
203 |
|
|
204 |
return PathIterator.SEG_MOVETO; |
|
205 |
} |
|
206 |
} |
|
207 |
|
|
110 | 208 |
} |
Also available in: Unified diff