Revision 43510 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/tools/Behavior/PolylineBehavior.java
PolylineBehavior.java | ||
---|---|---|
27 | 27 |
import java.awt.event.MouseEvent; |
28 | 28 |
import java.awt.geom.Point2D; |
29 | 29 |
import java.util.ArrayList; |
30 |
import java.util.List; |
|
31 |
import org.gvsig.fmap.geom.Geometry; |
|
32 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
33 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
30 | 34 |
|
31 |
import org.gvsig.fmap.geom.primitive.GeneralPathX;
|
|
35 |
import org.gvsig.fmap.geom.primitive.Line;
|
|
32 | 36 |
import org.gvsig.fmap.mapcontrol.MapControlDrawer; |
33 | 37 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
34 | 38 |
import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent; |
... | ... | |
48 | 52 |
/** |
49 | 53 |
* The abscissa coordinate of all vertexes of the polyline. |
50 | 54 |
*/ |
51 |
protected ArrayList arrayX = new ArrayList(); //<Double>
|
|
55 |
protected List<Double> arrayX = new ArrayList<>();
|
|
52 | 56 |
|
53 | 57 |
/** |
54 | 58 |
* The ordinate coordinate of all vertexes of the polyline. |
55 | 59 |
*/ |
56 |
protected ArrayList arrayY = new ArrayList(); //<Double>
|
|
60 |
protected List<Double> arrayY = new ArrayList<>();
|
|
57 | 61 |
|
58 | 62 |
/** |
59 | 63 |
* Determines if user is setting the vertexes (with one click of the button 1 of the mouse), or not. |
... | ... | |
159 | 163 |
* @param mapControlDrawer |
160 | 164 |
*/ |
161 | 165 |
protected void drawPolyLine(MapControlDrawer mapControlDrawer) { |
162 |
GeneralPathX polyline = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, arrayX.size()); |
|
163 |
|
|
164 |
polyline.moveTo(((Double) arrayX.get(0)).doubleValue(), |
|
165 |
((Double) arrayY.get(0)).doubleValue()); |
|
166 |
|
|
167 |
for (int index = 0; index < arrayX.size(); index++) { |
|
168 |
polyline.lineTo(((Double) arrayX.get(index)).doubleValue(),((Double) arrayY.get(index)).doubleValue()); |
|
169 |
} |
|
170 |
|
|
171 |
mapControlDrawer.draw(createLineString(polyline)); |
|
166 |
|
|
167 |
// GeneralPathX polyline = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, arrayX.size()); |
|
168 |
// |
|
169 |
// polyline.moveTo(((Double) arrayX.get(0)).doubleValue(), |
|
170 |
// ((Double) arrayY.get(0)).doubleValue()); |
|
171 |
// |
|
172 |
// for (int index = 0; index < arrayX.size(); index++) { |
|
173 |
// polyline.lineTo(((Double) arrayX.get(index)).doubleValue(),((Double) arrayY.get(index)).doubleValue()); |
|
174 |
// } |
|
175 |
try { |
|
176 |
Line line = geomManager.createLine(Geometry.SUBTYPES.GEOM2D); |
|
177 |
for (int index = 0; index < arrayX.size(); index++) { |
|
178 |
line.addVertex(arrayX.get(index),arrayY.get(index)); |
|
179 |
} |
|
180 |
mapControlDrawer.draw(line); |
|
181 |
} catch (Exception ex) { |
|
182 |
LOG.warn("Can't draw polyline",ex); |
|
183 |
} |
|
172 | 184 |
} |
173 | 185 |
|
174 | 186 |
/** |
Also available in: Unified diff