root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / FPointIterator.java @ 1005
History | View | Annotate | Download (1.85 KB)
1 |
/*
|
---|---|
2 |
* Created on 25-nov-2004
|
3 |
*
|
4 |
* TODO To change the template for this generated file go to
|
5 |
* Window - Preferences - Java - Code Generation - Code and Comments
|
6 |
*/
|
7 |
package com.iver.cit.gvsig.fmap.core; |
8 |
|
9 |
import java.awt.geom.AffineTransform; |
10 |
import java.awt.geom.PathIterator; |
11 |
import java.awt.geom.Point2D; |
12 |
|
13 |
|
14 |
/**
|
15 |
* (Sacado de GT2)
|
16 |
*
|
17 |
* @author FJP
|
18 |
*/
|
19 |
public class FPointIterator implements PathIterator { |
20 |
/** Transform applied on the coordinates during iteration */
|
21 |
private AffineTransform at; |
22 |
|
23 |
/** The point we are going to provide when asked for coordinates */
|
24 |
private Point2D p; |
25 |
|
26 |
/** True when the point has been read once */
|
27 |
private boolean done; |
28 |
|
29 |
/**
|
30 |
* Creates a new PointIterator object.
|
31 |
*
|
32 |
* @param p The polygon
|
33 |
* @param at The affine transform applied to coordinates during iteration
|
34 |
*/
|
35 |
public FPointIterator(Point2D p, AffineTransform at) { |
36 |
if (at == null) { |
37 |
at = new AffineTransform(); |
38 |
} |
39 |
|
40 |
this.at = at;
|
41 |
this.p = p;
|
42 |
done = false;
|
43 |
} |
44 |
|
45 |
/**
|
46 |
* Return the winding rule for determining the interior of the path.
|
47 |
*
|
48 |
* @return <code>WIND_EVEN_ODD</code> by default.
|
49 |
*/
|
50 |
public int getWindingRule() { |
51 |
return PathIterator.WIND_EVEN_ODD; |
52 |
} |
53 |
|
54 |
/**
|
55 |
* @see java.awt.geom.PathIterator#next()
|
56 |
*/
|
57 |
public void next() { |
58 |
done = true;
|
59 |
} |
60 |
|
61 |
/**
|
62 |
* @see java.awt.geom.PathIterator#isDone()
|
63 |
*/
|
64 |
public boolean isDone() { |
65 |
return done;
|
66 |
} |
67 |
|
68 |
/**
|
69 |
* @see java.awt.geom.PathIterator#currentSegment(double[])
|
70 |
*/
|
71 |
public int currentSegment(double[] coords) { |
72 |
coords[0] = p.getX();
|
73 |
coords[1] = p.getY();
|
74 |
at.transform(coords, 0, coords, 0, 1); |
75 |
|
76 |
return PathIterator.SEG_MOVETO; |
77 |
} |
78 |
|
79 |
/* (non-Javadoc)
|
80 |
* @see java.awt.geom.PathIterator#currentSegment(float[])
|
81 |
*/
|
82 |
public int currentSegment(float[] coords) { |
83 |
coords[0] = (float) p.getX(); |
84 |
coords[1] = (float) p.getY(); |
85 |
at.transform(coords, 0, coords, 0, 1); |
86 |
|
87 |
return PathIterator.SEG_MOVETO; |
88 |
} |
89 |
} |