root / branches / Mobile_Compatible_Hito_1 / libFMap / src / es / prodevelop / gvsig / mobile / fmap / core / FPointIterator.java @ 21606
History | View | Annotate | Download (3.57 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 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
8 |
*
|
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 |
/************************************************
|
48 |
* *
|
49 |
* Modfied By: *
|
50 |
* Prodevelop Integraci?n de Tecnolog?as SL *
|
51 |
* Conde Salvatierra de ?lava , 34-10 *
|
52 |
* 46004 Valencia *
|
53 |
* Spain *
|
54 |
* *
|
55 |
* +34 963 510 612 *
|
56 |
* +34 963 510 968 *
|
57 |
* gis@prodevelop.es *
|
58 |
* http://www.prodevelop.es *
|
59 |
* *
|
60 |
* gvSIG Mobile Team 2006 *
|
61 |
* *
|
62 |
************************************************/
|
63 |
|
64 |
package es.prodevelop.gvsig.mobile.fmap.core; |
65 |
|
66 |
import java.awt.geom.AffineTransform; |
67 |
import java.awt.geom.PathIterator; |
68 |
import java.awt.geom.Point2D; |
69 |
|
70 |
|
71 |
/**
|
72 |
* (Sacado de GT2)
|
73 |
*
|
74 |
* @author FJP
|
75 |
*/
|
76 |
public class FPointIterator extends GeneralPathXIterator { |
77 |
/** Transform applied on the coordinates during iteration */
|
78 |
private AffineTransform at; |
79 |
|
80 |
/** The point we are going to provide when asked for coordinates */
|
81 |
private Point2D p; |
82 |
|
83 |
/** True when the point has been read once */
|
84 |
private boolean done; |
85 |
|
86 |
/**
|
87 |
* Creates a new PointIterator object.
|
88 |
*
|
89 |
* @param p The polygon
|
90 |
* @param at The affine transform applied to coordinates during iteration
|
91 |
*/
|
92 |
public FPointIterator(Point2D p, AffineTransform at) { |
93 |
super(new GeneralPathX()); |
94 |
if (at == null) { |
95 |
at = new AffineTransform(); |
96 |
} |
97 |
|
98 |
this.at = at;
|
99 |
this.p = p;
|
100 |
done = false;
|
101 |
} |
102 |
|
103 |
/**
|
104 |
* Return the winding rule for determining the interior of the path.
|
105 |
*
|
106 |
* @return <code>WIND_EVEN_ODD</code> by default.
|
107 |
*/
|
108 |
public int getWindingRule() { |
109 |
return PathIterator.WIND_EVEN_ODD; |
110 |
} |
111 |
|
112 |
/**
|
113 |
* @see java.awt.geom.PathIterator#next()
|
114 |
*/
|
115 |
public void next() { |
116 |
done = true;
|
117 |
} |
118 |
|
119 |
/**
|
120 |
* @see java.awt.geom.PathIterator#isDone()
|
121 |
*/
|
122 |
public boolean isDone() { |
123 |
return done;
|
124 |
} |
125 |
|
126 |
/**
|
127 |
* @see java.awt.geom.PathIterator#currentSegment(double[])
|
128 |
*/
|
129 |
public int currentSegment(double[] coords) { |
130 |
coords[0] = p.getX();
|
131 |
coords[1] = p.getY();
|
132 |
at.transform(coords, 0, coords, 0, 1); |
133 |
|
134 |
return PathIterator.SEG_MOVETO; |
135 |
} |
136 |
|
137 |
/* (non-Javadoc)
|
138 |
* @see java.awt.geom.PathIterator#currentSegment(float[])
|
139 |
*/
|
140 |
public int currentSegment(float[] coords) { |
141 |
coords[0] = (float) p.getX(); |
142 |
coords[1] = (float) p.getY(); |
143 |
at.transform(coords, 0, coords, 0, 1); |
144 |
|
145 |
return PathIterator.SEG_MOVETO; |
146 |
} |
147 |
} |