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