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/AbstractPoint.java
AbstractPoint.java | ||
---|---|---|
37 | 37 |
import org.gvsig.fmap.geom.handler.FinalHandler; |
38 | 38 |
import org.gvsig.fmap.geom.handler.Handler; |
39 | 39 |
import org.gvsig.fmap.geom.jts.gputils.DefaultGeneralPathX; |
40 |
import org.gvsig.fmap.geom.jts.gputils.GeneralPathXIterator; |
|
41 | 40 |
import org.gvsig.fmap.geom.jts.primitive.AbstractPrimitive; |
42 | 41 |
import org.gvsig.fmap.geom.jts.primitive.Envelope2D; |
43 |
import org.gvsig.fmap.geom.jts.utils.JTSUtils;
|
|
42 |
import org.gvsig.fmap.geom.jts.util.JTSUtils; |
|
44 | 43 |
import org.gvsig.fmap.geom.primitive.Envelope; |
45 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
46 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
47 | 44 |
|
48 | 45 |
/** |
49 | 46 |
* @author fdiaz |
... | ... | |
60 | 57 |
/** |
61 | 58 |
* |
62 | 59 |
*/ |
63 |
protected AbstractPoint(int subtype) { |
|
64 |
super(Geometry.TYPES.POINT, subtype); |
|
65 |
} |
|
60 |
protected AbstractPoint(int subtype) { |
|
61 |
super(Geometry.TYPES.POINT, subtype); |
|
62 |
} |
|
63 |
|
|
66 | 64 |
/** |
67 | 65 |
* |
68 | 66 |
*/ |
... | ... | |
186 | 184 |
* @see org.gvsig.fmap.geom.primitive.Point#toPoints() |
187 | 185 |
*/ |
188 | 186 |
public MultiPoint toPoints() throws GeometryException { |
189 |
//FIXME: Cuando este disponible el Multipoint |
|
187 |
// FIXME: Cuando este disponible el Multipoint
|
|
190 | 188 |
// TODO Auto-generated method stub |
191 | 189 |
return null; |
192 | 190 |
} |
... | ... | |
256 | 254 |
* @see org.gvsig.fmap.geom.Geometry#getShape(java.awt.geom.AffineTransform) |
257 | 255 |
*/ |
258 | 256 |
public Shape getShape(AffineTransform affineTransform) { |
259 |
return new DefaultGeneralPathX(new PointIterator(affineTransform));
|
|
257 |
return new DefaultGeneralPathX(getPathIterator(affineTransform), false, 0);
|
|
260 | 258 |
} |
261 | 259 |
|
262 | 260 |
/* |
... | ... | |
265 | 263 |
* @see org.gvsig.fmap.geom.Geometry#getShape() |
266 | 264 |
*/ |
267 | 265 |
public Shape getShape() { |
268 |
return new DefaultGeneralPathX(new PointIterator(null));
|
|
266 |
return new DefaultGeneralPathX(getPathIterator(null), false, 0);
|
|
269 | 267 |
} |
270 | 268 |
|
271 |
|
|
272 |
|
|
273 | 269 |
/* |
274 | 270 |
* (non-Javadoc) |
275 | 271 |
* |
... | ... | |
284 | 280 |
/* |
285 | 281 |
* (non-Javadoc) |
286 | 282 |
* |
287 |
* @see |
|
288 |
* org.gvsig.fmap.geom.Geometry#getPathIterator(java.awt.geom.AffineTransform |
|
289 |
* ) |
|
290 |
*/ |
|
291 |
public PathIterator getPathIterator(AffineTransform at) { |
|
292 |
PointIterator pi = new PointIterator(at); |
|
293 |
return pi; |
|
294 |
} |
|
295 |
|
|
296 |
/* |
|
297 |
* (non-Javadoc) |
|
298 |
* |
|
299 |
* @see org.gvsig.fmap.geom.Geometry#getGeneralPath() |
|
300 |
*/ |
|
301 |
public GeneralPathX getGeneralPath() { |
|
302 |
return new DefaultGeneralPathX(new PointIterator(null)); |
|
303 |
} |
|
304 |
|
|
305 |
|
|
306 |
public class PointIterator extends GeneralPathXIterator { |
|
307 |
/** Transform applied on the coordinates during iteration */ |
|
308 |
private AffineTransform at; |
|
309 |
|
|
310 |
/** True when the point has been read once */ |
|
311 |
private boolean done; |
|
312 |
|
|
313 |
/** |
|
314 |
* Creates a new PointIterator object. |
|
315 |
* |
|
316 |
* @param p The polygon |
|
317 |
* @param at The affine transform applied to coordinates during iteration |
|
318 |
*/ |
|
319 |
public PointIterator(AffineTransform at) { |
|
320 |
super(new GeneralPathX()); |
|
321 |
if (at == null) { |
|
322 |
at = new AffineTransform(); |
|
323 |
} |
|
324 |
|
|
325 |
this.at = at; |
|
326 |
done = false; |
|
327 |
} |
|
328 |
|
|
329 |
/** |
|
330 |
* Return the winding rule for determining the interior of the path. |
|
331 |
* |
|
332 |
* @return <code>WIND_EVEN_ODD</code> by default. |
|
333 |
*/ |
|
334 |
public int getWindingRule() { |
|
335 |
return PathIterator.WIND_EVEN_ODD; |
|
336 |
} |
|
337 |
|
|
338 |
/** |
|
339 |
* @see java.awt.geom.PathIterator#next() |
|
340 |
*/ |
|
341 |
public void next() { |
|
342 |
done = true; |
|
343 |
} |
|
344 |
|
|
345 |
/** |
|
346 |
* @see java.awt.geom.PathIterator#isDone() |
|
347 |
*/ |
|
348 |
public boolean isDone() { |
|
349 |
return done; |
|
350 |
} |
|
351 |
|
|
352 |
/** |
|
353 |
* @see java.awt.geom.PathIterator#currentSegment(double[]) |
|
354 |
*/ |
|
355 |
public int currentSegment(double[] coords) { |
|
356 |
coords[0] = getX(); |
|
357 |
coords[1] = getY(); |
|
358 |
at.transform(coords, 0, coords, 0, 1); |
|
359 |
|
|
360 |
return PathIterator.SEG_MOVETO; |
|
361 |
} |
|
362 |
|
|
363 |
/* (non-Javadoc) |
|
364 |
* @see java.awt.geom.PathIterator#currentSegment(float[]) |
|
365 |
*/ |
|
366 |
public int currentSegment(float[] coords) { |
|
367 |
coords[0] = (float) getX(); |
|
368 |
coords[1] = (float) getY(); |
|
369 |
at.transform(coords, 0, coords, 0, 1); |
|
370 |
|
|
371 |
return PathIterator.SEG_MOVETO; |
|
372 |
} |
|
373 |
} |
|
374 |
|
|
375 |
|
|
376 |
/* |
|
377 |
* (non-Javadoc) |
|
378 |
* |
|
379 | 283 |
* @see org.gvsig.fmap.geom.Geometry#getHandlers(int) |
380 | 284 |
*/ |
381 | 285 |
public Handler[] getHandlers(int type) { |
... | ... | |
401 | 305 |
} |
402 | 306 |
|
403 | 307 |
public Envelope getEnvelope() { |
404 |
//TOCRY: En alg?n momento habr? que probar qu? ocurre en gvSIG si esto devuelve lo que deber?a |
|
308 |
// TOCRY: En alg?n momento habr? que probar qu? ocurre en gvSIG si esto |
|
309 |
// devuelve lo que deber?a |
|
405 | 310 |
return new Envelope2D(this.getX() - 0.01, this.getY() - 0.01, this.getX() + 0.02, this.getY() + 0.02); |
406 | 311 |
} |
407 | 312 |
} |
Also available in: Unified diff