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/Point2DM.java
Point2DM.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; |
29 | 32 |
import org.gvsig.fmap.geom.jts.MCoordinate; |
30 |
import org.gvsig.fmap.geom.jts.utils.JTSUtils; |
|
33 |
import org.gvsig.fmap.geom.jts.gputils.DefaultGeneralPathX; |
|
34 |
import org.gvsig.fmap.geom.jts.gputils.GeneralPathXIterator; |
|
35 |
import org.gvsig.fmap.geom.jts.util.JTSUtils; |
|
36 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
31 | 37 |
import org.gvsig.fmap.geom.type.GeometryType; |
32 | 38 |
|
33 | 39 |
/** |
... | ... | |
126 | 132 |
this.coordinate = coordinate; |
127 | 133 |
} |
128 | 134 |
|
135 |
/* |
|
136 |
* (non-Javadoc) |
|
137 |
* |
|
138 |
* @see org.gvsig.fmap.geom.Geometry#getGeneralPath() |
|
139 |
*/ |
|
140 |
public GeneralPathX getGeneralPath() { |
|
141 |
return new DefaultGeneralPathX(new PointIterator(null),false,0); |
|
142 |
} |
|
143 |
|
|
144 |
/* |
|
145 |
* (non-Javadoc) |
|
146 |
* |
|
147 |
* @see |
|
148 |
* org.gvsig.fmap.geom.Geometry#getPathIterator(java.awt.geom.AffineTransform |
|
149 |
* ) |
|
150 |
*/ |
|
151 |
public PathIterator getPathIterator(AffineTransform at) { |
|
152 |
PointIterator pi = new PointIterator(at); |
|
153 |
return pi; |
|
154 |
} |
|
155 |
|
|
156 |
public class PointIterator extends GeneralPathXIterator { |
|
157 |
/** Transform applied on the coordinates during iteration */ |
|
158 |
private AffineTransform at; |
|
159 |
|
|
160 |
/** True when the point has been read once */ |
|
161 |
private boolean done; |
|
162 |
|
|
163 |
/** |
|
164 |
* Creates a new PointIterator object. |
|
165 |
* |
|
166 |
* @param p The polygon |
|
167 |
* @param at The affine transform applied to coordinates during iteration |
|
168 |
*/ |
|
169 |
public PointIterator(AffineTransform at) { |
|
170 |
super(new GeneralPathX()); |
|
171 |
if (at == null) { |
|
172 |
at = new AffineTransform(); |
|
173 |
} |
|
174 |
|
|
175 |
this.at = at; |
|
176 |
done = false; |
|
177 |
} |
|
178 |
|
|
179 |
/** |
|
180 |
* Return the winding rule for determining the interior of the path. |
|
181 |
* |
|
182 |
* @return <code>WIND_EVEN_ODD</code> by default. |
|
183 |
*/ |
|
184 |
public int getWindingRule() { |
|
185 |
return PathIterator.WIND_EVEN_ODD; |
|
186 |
} |
|
187 |
|
|
188 |
/** |
|
189 |
* @see java.awt.geom.PathIterator#next() |
|
190 |
*/ |
|
191 |
public void next() { |
|
192 |
done = true; |
|
193 |
} |
|
194 |
|
|
195 |
/** |
|
196 |
* @see java.awt.geom.PathIterator#isDone() |
|
197 |
*/ |
|
198 |
public boolean isDone() { |
|
199 |
return done; |
|
200 |
} |
|
201 |
|
|
202 |
/** |
|
203 |
* @see java.awt.geom.PathIterator#currentSegment(double[]) |
|
204 |
*/ |
|
205 |
public int currentSegment(double[] coords) { |
|
206 |
coords[0] = getX(); |
|
207 |
coords[1] = getY(); |
|
208 |
at.transform(coords, 0, coords, 0, 1); |
|
209 |
|
|
210 |
return PathIterator.SEG_MOVETO; |
|
211 |
} |
|
212 |
|
|
213 |
/* (non-Javadoc) |
|
214 |
* @see java.awt.geom.PathIterator#currentSegment(float[]) |
|
215 |
*/ |
|
216 |
public int currentSegment(float[] coords) { |
|
217 |
coords[0] = (float) getX(); |
|
218 |
coords[1] = (float) getY(); |
|
219 |
at.transform(coords, 0, coords, 0, 1); |
|
220 |
|
|
221 |
return PathIterator.SEG_MOVETO; |
|
222 |
} |
|
223 |
} |
|
224 |
|
|
225 |
|
|
129 | 226 |
} |
Also available in: Unified diff