root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / FPointIterator.java @ 38563
History | View | Annotate | Download (3.08 KB)
1 | 305 | fjp | /*
|
---|---|---|---|
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 | 1136 | vcaballero | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
8 | 1100 | fjp | *
|
9 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
10 | *
|
||
11 | * This program is free software; you can redistribute it and/or
|
||
12 | * modify it under the terms of the GNU General Public License
|
||
13 | * as published by the Free Software Foundation; either version 2
|
||
14 | * of the License, or (at your option) any later version.
|
||
15 | *
|
||
16 | * This program is distributed in the hope that it will be useful,
|
||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
19 | * GNU General Public License for more details.
|
||
20 | *
|
||
21 | * You should have received a copy of the GNU General Public License
|
||
22 | * along with this program; if not, write to the Free Software
|
||
23 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
24 | *
|
||
25 | * For more information, contact:
|
||
26 | *
|
||
27 | * Generalitat Valenciana
|
||
28 | * Conselleria d'Infraestructures i Transport
|
||
29 | * Av. Blasco Ib??ez, 50
|
||
30 | * 46010 VALENCIA
|
||
31 | * SPAIN
|
||
32 | *
|
||
33 | * +34 963862235
|
||
34 | * gvsig@gva.es
|
||
35 | * www.gvsig.gva.es
|
||
36 | *
|
||
37 | * or
|
||
38 | *
|
||
39 | * IVER T.I. S.A
|
||
40 | * Salamanca 50
|
||
41 | * 46005 Valencia
|
||
42 | * Spain
|
||
43 | *
|
||
44 | * +34 963163400
|
||
45 | * dac@iver.es
|
||
46 | */
|
||
47 | 305 | fjp | package com.iver.cit.gvsig.fmap.core; |
48 | |||
49 | import java.awt.geom.AffineTransform; |
||
50 | import java.awt.geom.PathIterator; |
||
51 | import java.awt.geom.Point2D; |
||
52 | |||
53 | 1005 | vcaballero | |
54 | 305 | fjp | /**
|
55 | 1005 | vcaballero | * (Sacado de GT2)
|
56 | 305 | fjp | *
|
57 | 1005 | vcaballero | * @author FJP
|
58 | 305 | fjp | */
|
59 | 1136 | vcaballero | public class FPointIterator extends GeneralPathXIterator { |
60 | 1005 | vcaballero | /** Transform applied on the coordinates during iteration */
|
61 | private AffineTransform at; |
||
62 | 305 | fjp | |
63 | 1005 | vcaballero | /** The point we are going to provide when asked for coordinates */
|
64 | private Point2D p; |
||
65 | 305 | fjp | |
66 | 1005 | vcaballero | /** True when the point has been read once */
|
67 | private boolean done; |
||
68 | 305 | fjp | |
69 | 1005 | vcaballero | /**
|
70 | * Creates a new PointIterator object.
|
||
71 | *
|
||
72 | * @param p The polygon
|
||
73 | * @param at The affine transform applied to coordinates during iteration
|
||
74 | */
|
||
75 | public FPointIterator(Point2D p, AffineTransform at) { |
||
76 | 1136 | vcaballero | super(new GeneralPathX()); |
77 | 1005 | vcaballero | if (at == null) { |
78 | at = new AffineTransform(); |
||
79 | } |
||
80 | 305 | fjp | |
81 | 1005 | vcaballero | this.at = at;
|
82 | this.p = p;
|
||
83 | done = false;
|
||
84 | } |
||
85 | 305 | fjp | |
86 | 1005 | vcaballero | /**
|
87 | * Return the winding rule for determining the interior of the path.
|
||
88 | *
|
||
89 | * @return <code>WIND_EVEN_ODD</code> by default.
|
||
90 | */
|
||
91 | public int getWindingRule() { |
||
92 | return PathIterator.WIND_EVEN_ODD; |
||
93 | } |
||
94 | 305 | fjp | |
95 | 1005 | vcaballero | /**
|
96 | * @see java.awt.geom.PathIterator#next()
|
||
97 | */
|
||
98 | public void next() { |
||
99 | done = true;
|
||
100 | } |
||
101 | 305 | fjp | |
102 | 1005 | vcaballero | /**
|
103 | * @see java.awt.geom.PathIterator#isDone()
|
||
104 | */
|
||
105 | public boolean isDone() { |
||
106 | return done;
|
||
107 | } |
||
108 | 305 | fjp | |
109 | 1005 | vcaballero | /**
|
110 | * @see java.awt.geom.PathIterator#currentSegment(double[])
|
||
111 | */
|
||
112 | public int currentSegment(double[] coords) { |
||
113 | coords[0] = p.getX();
|
||
114 | coords[1] = p.getY();
|
||
115 | at.transform(coords, 0, coords, 0, 1); |
||
116 | 305 | fjp | |
117 | 1005 | vcaballero | return PathIterator.SEG_MOVETO; |
118 | } |
||
119 | |||
120 | 305 | fjp | /* (non-Javadoc)
|
121 | * @see java.awt.geom.PathIterator#currentSegment(float[])
|
||
122 | */
|
||
123 | public int currentSegment(float[] coords) { |
||
124 | 1005 | vcaballero | coords[0] = (float) p.getX(); |
125 | coords[1] = (float) p.getY(); |
||
126 | at.transform(coords, 0, coords, 0, 1); |
||
127 | 305 | fjp | |
128 | 1005 | vcaballero | return PathIterator.SEG_MOVETO; |
129 | 305 | fjp | } |
130 | } |