svn-gvsig-desktop / trunk / extensions / extCAD / src / com / iver / cit / gvsig / gui / cad / tools / PolylineCADTool.java @ 6043
History | View | Annotate | Download (19.3 KB)
1 | 3765 | caballero | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Ib??ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | 3782 | caballero | package com.iver.cit.gvsig.gui.cad.tools; |
42 | |||
43 | 3832 | caballero | import java.awt.Graphics; |
44 | import java.awt.Graphics2D; |
||
45 | 4313 | fjp | import java.awt.event.InputEvent; |
46 | 3832 | caballero | import java.awt.geom.Point2D; |
47 | import java.util.ArrayList; |
||
48 | |||
49 | 5747 | fjp | import org.apache.log4j.Logger; |
50 | |||
51 | 4584 | caballero | import com.iver.andami.PluginServices; |
52 | 3782 | caballero | import com.iver.cit.gvsig.fmap.core.FGeometryCollection; |
53 | import com.iver.cit.gvsig.fmap.core.FShape; |
||
54 | import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
||
55 | import com.iver.cit.gvsig.fmap.core.IGeometry; |
||
56 | import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
||
57 | 5747 | fjp | import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
58 | 3782 | caballero | import com.iver.cit.gvsig.fmap.edition.UtilFunctions; |
59 | import com.iver.cit.gvsig.gui.cad.CADTool; |
||
60 | 3832 | caballero | import com.iver.cit.gvsig.gui.cad.DefaultCADTool; |
61 | 5735 | caballero | import com.iver.cit.gvsig.gui.cad.exception.CommandException; |
62 | 3782 | caballero | import com.iver.cit.gvsig.gui.cad.tools.smc.PolylineCADToolContext; |
63 | import com.iver.cit.gvsig.gui.cad.tools.smc.PolylineCADToolContext.PolylineCADToolState; |
||
64 | 5747 | fjp | import com.vividsolutions.jts.geom.Geometry; |
65 | 3782 | caballero | |
66 | |||
67 | /**
|
||
68 | * DOCUMENT ME!
|
||
69 | *
|
||
70 | * @author Vicente Caballero Navarro
|
||
71 | */
|
||
72 | 3765 | caballero | public class PolylineCADTool extends DefaultCADTool { |
73 | 5747 | fjp | private static Logger logger = Logger.getLogger(PolylineCADTool.class.getName()); |
74 | 3765 | caballero | private PolylineCADToolContext _fsm;
|
75 | private Point2D firstPoint; |
||
76 | private Point2D antPoint; |
||
77 | private Point2D antantPoint; |
||
78 | private Point2D antCenter; |
||
79 | 3782 | caballero | private Point2D antInter; |
80 | private ArrayList list = new ArrayList(); |
||
81 | |||
82 | /**
|
||
83 | 3765 | caballero | * Crea un nuevo PolylineCADTool.
|
84 | */
|
||
85 | public PolylineCADTool() {
|
||
86 | 3883 | caballero | |
87 | 3765 | caballero | } |
88 | |||
89 | /**
|
||
90 | * M?todo de incio, para poner el c?digo de todo lo que se requiera de una
|
||
91 | * carga previa a la utilizaci?n de la herramienta.
|
||
92 | */
|
||
93 | public void init() { |
||
94 | 5170 | caballero | _fsm = new PolylineCADToolContext(this); |
95 | 3765 | caballero | } |
96 | |||
97 | 3883 | caballero | public void endGeometry() { |
98 | 5170 | caballero | IGeometry[] geoms = (IGeometry[]) list.toArray(new IGeometry[0]); |
99 | 3846 | caballero | FGeometryCollection fgc = new FGeometryCollection(geoms);
|
100 | 5880 | fjp | /* try {
|
101 | if (getVLE().getVEA().getShapeType()==FShape.POLYGON){
|
||
102 | GeneralPathX gpx=new GeneralPathX();
|
||
103 | gpx.moveTo(antPoint.getX(),antPoint.getY());
|
||
104 | gpx.lineTo(firstPoint.getX(),firstPoint.getY());
|
||
105 | IGeometry line=ShapeFactory.createPolyline2D(gpx);
|
||
106 | fgc.addGeometry(line);
|
||
107 | }
|
||
108 | } catch (DriverIOException e) {
|
||
109 | e.printStackTrace();
|
||
110 | } */
|
||
111 | |||
112 | // No queremos guardar FGeometryCollections:
|
||
113 | GeneralPathX gp = new GeneralPathX();
|
||
114 | gp.append(fgc.getPathIterator(null), true); |
||
115 | IGeometry newGeom = ShapeFactory.createPolyline2D(gp); |
||
116 | 6034 | fjp | // if (gp.isClosed())
|
117 | // {
|
||
118 | // gp.ensureOrientation(false); // Poligono exterior.
|
||
119 | // // Voy a testear que se puede convertir a JTS:
|
||
120 | // IGeometry gAux = ShapeFactory.createPolygon2D(gp);
|
||
121 | // Geometry jtsG = gAux.toJTSGeometry();
|
||
122 | // logger.debug("A punto de escribir " + jtsG.toText());
|
||
123 | // try {
|
||
124 | // int shapeType = getVLE().getVEA().getShapeType();
|
||
125 | // if ((shapeType ==FShape.POLYGON) || (shapeType == FShape.MULTI)) {
|
||
126 | // newGeom = gAux;
|
||
127 | // }
|
||
128 | // } catch (DriverIOException e) {
|
||
129 | // // TODO Auto-generated catch block
|
||
130 | // e.printStackTrace();
|
||
131 | // return;
|
||
132 | // }
|
||
133 | //
|
||
134 | // }
|
||
135 | //
|
||
136 | 5880 | fjp | addGeometry(newGeom); |
137 | 3782 | caballero | _fsm = new PolylineCADToolContext(this); |
138 | 3883 | caballero | list.clear(); |
139 | antantPoint=antCenter=antInter=antPoint=firstPoint=null;
|
||
140 | 3765 | caballero | } |
141 | 3883 | caballero | public void closeGeometry(){ |
142 | 5170 | caballero | GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD,
|
143 | 2);
|
||
144 | elShape.moveTo(antPoint.getX(), antPoint.getY()); |
||
145 | elShape.lineTo(firstPoint.getX(), firstPoint.getY()); |
||
146 | 3765 | caballero | |
147 | 5170 | caballero | list.add(ShapeFactory.createPolyline2D(elShape)); |
148 | 5747 | fjp | |
149 | 5945 | caballero | |
150 | 5170 | caballero | // list.add(ShapeFactory.createPolyline2D(elShape));
|
151 | 5880 | fjp | |
152 | 3883 | caballero | } |
153 | 3765 | caballero | /* (non-Javadoc)
|
154 | 3782 | caballero | * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double, double)
|
155 | */
|
||
156 | 4313 | fjp | public void transition(double x, double y, InputEvent event) { |
157 | 4324 | caballero | _fsm.addPoint(x, y, event); |
158 | 3765 | caballero | } |
159 | |||
160 | /* (non-Javadoc)
|
||
161 | 3782 | caballero | * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double)
|
162 | */
|
||
163 | 3832 | caballero | public void transition(double d) { |
164 | 5735 | caballero | _fsm.addValue(d); |
165 | 3782 | caballero | } |
166 | 3765 | caballero | |
167 | 3782 | caballero | /* (non-Javadoc)
|
168 | * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, java.lang.String)
|
||
169 | */
|
||
170 | 5735 | caballero | public void transition(String s) throws CommandException { |
171 | 5170 | caballero | if (!super.changeCommand(s)){ |
172 | _fsm.addOption(s); |
||
173 | } |
||
174 | 3782 | caballero | } |
175 | |||
176 | 3765 | caballero | /**
|
177 | * Equivale al transition del prototipo pero sin pasarle como par?metro el
|
||
178 | * editableFeatureSource que ya estar? creado.
|
||
179 | *
|
||
180 | * @param sel Bitset con las geometr?as que est?n seleccionadas.
|
||
181 | * @param x par?metro x del punto que se pase en esta transici?n.
|
||
182 | * @param y par?metro y del punto que se pase en esta transici?n.
|
||
183 | */
|
||
184 | 4365 | caballero | public void addPoint(double x, double y,InputEvent event) { |
185 | 5170 | caballero | PolylineCADToolState actualState = (PolylineCADToolState) _fsm.getPreviousState(); |
186 | 3765 | caballero | String status = actualState.getName();
|
187 | 3782 | caballero | |
188 | 5945 | caballero | // if (status.equals("Polyline.FirstPoint")) {
|
189 | // antPoint = new Point2D.Double(x, y);
|
||
190 | //
|
||
191 | // if (firstPoint == null) {
|
||
192 | // firstPoint = (Point2D) antPoint.clone();
|
||
193 | // }
|
||
194 | // } else
|
||
195 | if (status.equals("Polyline.NextPointOrArcOrClose") || status.equals("Polyline.FirstPoint")) { |
||
196 | if (antPoint==null) |
||
197 | antPoint = new Point2D.Double(x, y); |
||
198 | if (firstPoint == null) { |
||
199 | firstPoint = (Point2D) antPoint.clone();
|
||
200 | } |
||
201 | Point2D point = new Point2D.Double(x, y); |
||
202 | 3782 | caballero | |
203 | if (antPoint != null) { |
||
204 | GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD,
|
||
205 | 2);
|
||
206 | elShape.moveTo(antPoint.getX(), antPoint.getY()); |
||
207 | elShape.lineTo(point.getX(), point.getY()); |
||
208 | 5170 | caballero | list.add(ShapeFactory.createPolyline2D(elShape)); |
209 | 3978 | caballero | |
210 | 3782 | caballero | } |
211 | 3765 | caballero | |
212 | 3782 | caballero | if (antPoint != null) { |
213 | antantPoint = antPoint; |
||
214 | } |
||
215 | 3765 | caballero | |
216 | 3782 | caballero | antPoint = point; |
217 | 3978 | caballero | } else if (status.equals("Polyline.NextPointOrLineOrClose")) { |
218 | 3782 | caballero | Point2D point = new Point2D.Double(x, y); |
219 | Point2D lastp = antPoint; //(Point2D)points.get(i-1); |
||
220 | 3765 | caballero | |
221 | 3782 | caballero | if (antantPoint == null) { |
222 | antantPoint = new Point2D.Double(lastp.getX() + |
||
223 | (point.getX() / 2), lastp.getY() + (point.getY() / 2)); |
||
224 | } |
||
225 | 3765 | caballero | |
226 | 3782 | caballero | if (((point.getY() == lastp.getY()) &&
|
227 | (point.getX() < lastp.getX())) || |
||
228 | ((point.getX() == lastp.getX()) && |
||
229 | (point.getY() < lastp.getY()))) { |
||
230 | } else {
|
||
231 | if (point.getX() == lastp.getX()) {
|
||
232 | point = new Point2D.Double(point.getX() + 0.00000001, |
||
233 | point.getY()); |
||
234 | } else if (point.getY() == lastp.getY()) { |
||
235 | point = new Point2D.Double(point.getX(), |
||
236 | point.getY() + 0.00000001);
|
||
237 | } |
||
238 | 3765 | caballero | |
239 | 3782 | caballero | if (point.getX() == antantPoint.getX()) {
|
240 | point = new Point2D.Double(point.getX() + 0.00000001, |
||
241 | point.getY()); |
||
242 | } else if (point.getY() == antantPoint.getY()) { |
||
243 | point = new Point2D.Double(point.getX(), |
||
244 | point.getY() + 0.00000001);
|
||
245 | } |
||
246 | 3765 | caballero | |
247 | 3782 | caballero | if (!(list.size() > 0) || |
248 | (((IGeometry) list.get(list.size() - 1)).getGeometryType() == FShape.LINE)) {
|
||
249 | Point2D[] ps1 = UtilFunctions.getPerpendicular(antantPoint, |
||
250 | lastp, lastp); |
||
251 | Point2D mediop = new Point2D.Double((point.getX() + |
||
252 | lastp.getX()) / 2, (point.getY() + lastp.getY()) / 2); |
||
253 | Point2D[] ps2 = UtilFunctions.getPerpendicular(lastp, |
||
254 | point, mediop); |
||
255 | Point2D interp = UtilFunctions.getIntersection(ps1[0], |
||
256 | ps1[1], ps2[0], ps2[1]); |
||
257 | antInter = interp; |
||
258 | 3765 | caballero | |
259 | 3782 | caballero | double radio = interp.distance(lastp);
|
260 | 3765 | caballero | |
261 | 3782 | caballero | if (UtilFunctions.isLowAngle(antantPoint, lastp, interp,
|
262 | point)) { |
||
263 | radio = -radio; |
||
264 | } |
||
265 | 3765 | caballero | |
266 | 3782 | caballero | Point2D centerp = UtilFunctions.getPoint(interp, mediop,
|
267 | radio); |
||
268 | antCenter = centerp; |
||
269 | 3765 | caballero | |
270 | 3782 | caballero | IGeometry ig = ShapeFactory.createArc(lastp, centerp, point); |
271 | 3765 | caballero | |
272 | 3782 | caballero | if (ig != null) { |
273 | list.add(ig); |
||
274 | } |
||
275 | } else {
|
||
276 | Point2D[] ps1 = UtilFunctions.getPerpendicular(lastp, |
||
277 | antInter, lastp); |
||
278 | double a1 = UtilFunctions.getAngle(ps1[0], ps1[1]); |
||
279 | double a2 = UtilFunctions.getAngle(ps1[1], ps1[0]); |
||
280 | double angle = UtilFunctions.getAngle(antCenter, lastp);
|
||
281 | Point2D ini1 = null; |
||
282 | Point2D ini2 = null; |
||
283 | 3765 | caballero | |
284 | 3782 | caballero | if (UtilFunctions.absoluteAngleDistance(angle, a1) > UtilFunctions.absoluteAngleDistance(
|
285 | angle, a2)) { |
||
286 | ini1 = ps1[0];
|
||
287 | ini2 = ps1[1];
|
||
288 | } else {
|
||
289 | ini1 = ps1[1];
|
||
290 | ini2 = ps1[0];
|
||
291 | } |
||
292 | 3765 | caballero | |
293 | 3782 | caballero | Point2D unit = UtilFunctions.getUnitVector(ini1, ini2);
|
294 | Point2D correct = new Point2D.Double(lastp.getX() + |
||
295 | unit.getX(), lastp.getY() + unit.getY()); |
||
296 | Point2D[] ps = UtilFunctions.getPerpendicular(lastp, |
||
297 | correct, lastp); |
||
298 | Point2D mediop = new Point2D.Double((point.getX() + |
||
299 | lastp.getX()) / 2, (point.getY() + lastp.getY()) / 2); |
||
300 | Point2D[] ps2 = UtilFunctions.getPerpendicular(lastp, |
||
301 | point, mediop); |
||
302 | Point2D interp = UtilFunctions.getIntersection(ps[0], |
||
303 | ps[1], ps2[0], ps2[1]); |
||
304 | antInter = interp; |
||
305 | 3765 | caballero | |
306 | 3782 | caballero | double radio = interp.distance(lastp);
|
307 | 3765 | caballero | |
308 | 3782 | caballero | if (UtilFunctions.isLowAngle(correct, lastp, interp, point)) {
|
309 | radio = -radio; |
||
310 | } |
||
311 | 3765 | caballero | |
312 | 3782 | caballero | Point2D centerp = UtilFunctions.getPoint(interp, mediop,
|
313 | radio); |
||
314 | antCenter = centerp; |
||
315 | list.add(ShapeFactory.createArc(lastp, centerp, point)); |
||
316 | } |
||
317 | 3765 | caballero | |
318 | 3782 | caballero | antantPoint = antPoint; |
319 | antPoint = point; |
||
320 | } |
||
321 | 3765 | caballero | } |
322 | } |
||
323 | |||
324 | /**
|
||
325 | * M?todo para dibujar la lo necesario para el estado en el que nos
|
||
326 | * encontremos.
|
||
327 | *
|
||
328 | * @param g Graphics sobre el que dibujar.
|
||
329 | * @param selectedGeometries BitSet con las geometr?as seleccionadas.
|
||
330 | * @param x par?metro x del punto que se pase para dibujar.
|
||
331 | * @param y par?metro x del punto que se pase para dibujar.
|
||
332 | */
|
||
333 | 3832 | caballero | public void drawOperation(Graphics g, double x, |
334 | 3765 | caballero | double y) {
|
335 | 3883 | caballero | PolylineCADToolState actualState = ((PolylineCADToolContext)_fsm).getState(); |
336 | 3765 | caballero | String status = actualState.getName();
|
337 | |||
338 | 5945 | caballero | if (status.equals("Polyline.NextPointOrArcOrClose") || status.equals("Polyline.FirstPoint")) { |
339 | 3782 | caballero | for (int i = 0; i < list.size(); i++) { |
340 | ((IGeometry) list.get(i)).cloneGeometry().draw((Graphics2D) g,
|
||
341 | getCadToolAdapter().getMapControl().getViewPort(), |
||
342 | 3997 | fjp | CADTool.drawingSymbol); |
343 | 3782 | caballero | } |
344 | 5945 | caballero | if (antPoint!=null) |
345 | drawLine((Graphics2D) g, antPoint, new Point2D.Double(x, y)); |
||
346 | 3765 | caballero | |
347 | 3978 | caballero | } else if ((status.equals("Polyline.NextPointOrLineOrClose"))) { |
348 | 3782 | caballero | for (int i = 0; i < list.size(); i++) { |
349 | ((IGeometry) list.get(i)).cloneGeometry().draw((Graphics2D) g,
|
||
350 | getCadToolAdapter().getMapControl().getViewPort(), |
||
351 | 3997 | fjp | CADTool.drawingSymbol); |
352 | 3782 | caballero | } |
353 | 3765 | caballero | |
354 | 3782 | caballero | Point2D point = new Point2D.Double(x, y); |
355 | Point2D lastp = antPoint;
|
||
356 | 3765 | caballero | |
357 | 3782 | caballero | if (!(list.size() > 0) || |
358 | (((IGeometry) list.get(list.size() - 1)).getGeometryType() == FShape.LINE)) {
|
||
359 | if (antantPoint == null) { |
||
360 | drawArc(point, lastp, |
||
361 | new Point2D.Double(lastp.getX() + (point.getX() / 2), |
||
362 | lastp.getY() + (point.getY() / 2)), g);
|
||
363 | } else {
|
||
364 | drawArc(point, lastp, antantPoint, g); |
||
365 | } |
||
366 | } else {
|
||
367 | if (antInter != null) { |
||
368 | Point2D[] ps1 = UtilFunctions.getPerpendicular(lastp, |
||
369 | antInter, lastp); |
||
370 | double a1 = UtilFunctions.getAngle(ps1[0], ps1[1]); |
||
371 | double a2 = UtilFunctions.getAngle(ps1[1], ps1[0]); |
||
372 | double angle = UtilFunctions.getAngle(antCenter, lastp);
|
||
373 | Point2D ini1 = null; |
||
374 | Point2D ini2 = null; |
||
375 | 3765 | caballero | |
376 | 3782 | caballero | if (UtilFunctions.absoluteAngleDistance(angle, a1) > UtilFunctions.absoluteAngleDistance(
|
377 | angle, a2)) { |
||
378 | ini1 = ps1[0];
|
||
379 | ini2 = ps1[1];
|
||
380 | } else {
|
||
381 | ini1 = ps1[1];
|
||
382 | ini2 = ps1[0];
|
||
383 | } |
||
384 | 3765 | caballero | |
385 | 3782 | caballero | Point2D unit = UtilFunctions.getUnitVector(ini1, ini2);
|
386 | Point2D correct = new Point2D.Double(lastp.getX() + |
||
387 | unit.getX(), lastp.getY() + unit.getY()); |
||
388 | drawArc(point, lastp, correct, g); |
||
389 | } |
||
390 | } |
||
391 | } |
||
392 | 3765 | caballero | } |
393 | 3782 | caballero | |
394 | 3765 | caballero | /**
|
395 | 3782 | caballero | * Dibuja el arco sobre el graphics.
|
396 | *
|
||
397 | * @param point Puntero del rat?n.
|
||
398 | * @param lastp ?ltimo punto de la polilinea.
|
||
399 | * @param antp Punto antepenultimo.
|
||
400 | * @param g Graphics sobre el que se dibuja.
|
||
401 | */
|
||
402 | private void drawArc(Point2D point, Point2D lastp, Point2D antp, Graphics g) { |
||
403 | if (((point.getY() == lastp.getY()) && (point.getX() < lastp.getX())) ||
|
||
404 | ((point.getX() == lastp.getX()) && |
||
405 | (point.getY() < lastp.getY()))) { |
||
406 | } else {
|
||
407 | if (point.getX() == lastp.getX()) {
|
||
408 | point = new Point2D.Double(point.getX() + 0.00000001, |
||
409 | point.getY()); |
||
410 | } else if (point.getY() == lastp.getY()) { |
||
411 | point = new Point2D.Double(point.getX(), |
||
412 | point.getY() + 0.00000001);
|
||
413 | } |
||
414 | 3765 | caballero | |
415 | 3782 | caballero | if (point.getX() == antp.getX()) {
|
416 | point = new Point2D.Double(point.getX() + 0.00000001, |
||
417 | point.getY()); |
||
418 | } else if (point.getY() == antp.getY()) { |
||
419 | point = new Point2D.Double(point.getX(), |
||
420 | point.getY() + 0.00000001);
|
||
421 | } |
||
422 | 3765 | caballero | |
423 | 3782 | caballero | Point2D[] ps1 = UtilFunctions.getPerpendicular(lastp, antp, lastp); |
424 | Point2D mediop = new Point2D.Double((point.getX() + lastp.getX()) / 2, |
||
425 | (point.getY() + lastp.getY()) / 2);
|
||
426 | Point2D[] ps2 = UtilFunctions.getPerpendicular(lastp, point, mediop); |
||
427 | Point2D interp = UtilFunctions.getIntersection(ps1[0], ps1[1], |
||
428 | ps2[0], ps2[1]); |
||
429 | 3765 | caballero | |
430 | 3782 | caballero | double radio = interp.distance(lastp);
|
431 | 3765 | caballero | |
432 | 3782 | caballero | if (UtilFunctions.isLowAngle(antp, lastp, interp, point)) {
|
433 | radio = -radio; |
||
434 | } |
||
435 | 3765 | caballero | |
436 | 3782 | caballero | Point2D centerp = UtilFunctions.getPoint(interp, mediop, radio);
|
437 | 3765 | caballero | |
438 | 3782 | caballero | drawLine((Graphics2D) g, lastp, point);
|
439 | 3765 | caballero | |
440 | 3782 | caballero | IGeometry ig = ShapeFactory.createArc(lastp, centerp, point); |
441 | 3765 | caballero | |
442 | 3782 | caballero | if (ig != null) { |
443 | ig.draw((Graphics2D) g,
|
||
444 | getCadToolAdapter().getMapControl().getViewPort(), |
||
445 | CADTool.modifySymbol); |
||
446 | } |
||
447 | } |
||
448 | 3765 | caballero | } |
449 | |||
450 | /**
|
||
451 | * Add a diferent option.
|
||
452 | *
|
||
453 | 3782 | caballero | * @param sel DOCUMENT ME!
|
454 | 3765 | caballero | * @param s Diferent option.
|
455 | */
|
||
456 | 3832 | caballero | public void addOption(String s) { |
457 | 5395 | caballero | /* PolylineCADToolState actualState = (PolylineCADToolState) _fsm.getPreviousState();
|
458 | 3765 | caballero | String status = actualState.getName();
|
459 | 3782 | caballero | |
460 | 3978 | caballero | if (status.equals("Polyline.NextPointOrArcOrClose")) {
|
461 | 5170 | caballero | if (s.equals("A") || s.equals("a") || s.equals(PluginServices.getText(this,"inter_arc"))) {
|
462 | 3782 | caballero | //Arco
|
463 | } else if (s.equals("C") || s.equals("c")) {
|
||
464 | 5170 | caballero | GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, 2);
|
465 | 3846 | caballero | elShape.moveTo(antPoint.getX(), antPoint.getY());
|
466 | elShape.lineTo(firstPoint.getX(), firstPoint.getY());
|
||
467 | list.add(ShapeFactory.createPolyline2D(elShape));
|
||
468 | 5170 | caballero | //closeGeometry();
|
469 | 3765 | caballero | }
|
470 | 3978 | caballero | } else if (status.equals("Polyline.NextPointOrLineOrClose")) {
|
471 | 5170 | caballero | if (s.equals("N") || s.equals("n") || s.equals(PluginServices.getText(this,"inter_line"))) {
|
472 | 3782 | caballero | //L?nea
|
473 | } else if (s.equals("C") || s.equals("c")) {
|
||
474 | 5170 | caballero | GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, 2);
|
475 | 3846 | caballero | elShape.moveTo(antPoint.getX(), antPoint.getY());
|
476 | elShape.lineTo(firstPoint.getX(), firstPoint.getY());
|
||
477 | list.add(ShapeFactory.createPolyline2D(elShape));
|
||
478 | //closeGeometry();
|
||
479 | 3782 | caballero | }
|
480 | 3765 | caballero | }
|
481 | 5395 | caballero | */
|
482 | 3765 | caballero | } |
483 | |||
484 | /* (non-Javadoc)
|
||
485 | * @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double)
|
||
486 | */
|
||
487 | 3832 | caballero | public void addValue(double d) { |
488 | 3765 | caballero | } |
489 | 3883 | caballero | |
490 | public void cancel(){ |
||
491 | 5395 | caballero | //endGeometry();
|
492 | 5170 | caballero | list.clear(); |
493 | antantPoint=antCenter=antInter=antPoint=firstPoint=null;
|
||
494 | 3883 | caballero | } |
495 | 4002 | fjp | |
496 | 5170 | caballero | public void end() { |
497 | /* CADExtension.setCADTool("polyline");
|
||
498 | PluginServices.getMainFrame().setSelectedTool("POLYLINE"); */
|
||
499 | } |
||
500 | 4118 | caballero | |
501 | 5170 | caballero | public String getName() { |
502 | return PluginServices.getText(this,"polyline_"); |
||
503 | } |
||
504 | 4892 | caballero | |
505 | 5170 | caballero | public String toString() { |
506 | return "_polyline"; |
||
507 | } |
||
508 | public boolean isApplicable(int shapeType) { |
||
509 | switch (shapeType) {
|
||
510 | case FShape.POINT:
|
||
511 | 6024 | caballero | case FShape.MULTIPOINT:
|
512 | 5170 | caballero | return false; |
513 | } |
||
514 | return true; |
||
515 | } |
||
516 | 3765 | caballero | } |