svn-gvsig-desktop / tags / v1_0_2_Build_900 / extensions / extCAD / src / com / iver / cit / gvsig / gui / cad / tools / PolylineCADTool.java @ 10562
History | View | Annotate | Download (19.2 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 | 6714 | caballero | import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
58 | 5747 | fjp | import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
59 | 3782 | caballero | import com.iver.cit.gvsig.fmap.edition.UtilFunctions; |
60 | import com.iver.cit.gvsig.gui.cad.CADTool; |
||
61 | 3832 | caballero | import com.iver.cit.gvsig.gui.cad.DefaultCADTool; |
62 | 5735 | caballero | import com.iver.cit.gvsig.gui.cad.exception.CommandException; |
63 | 3782 | caballero | import com.iver.cit.gvsig.gui.cad.tools.smc.PolylineCADToolContext; |
64 | import com.iver.cit.gvsig.gui.cad.tools.smc.PolylineCADToolContext.PolylineCADToolState; |
||
65 | |||
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 | 6161 | caballero | private boolean close=false; |
82 | 3782 | caballero | |
83 | /**
|
||
84 | 3765 | caballero | * Crea un nuevo PolylineCADTool.
|
85 | */
|
||
86 | public PolylineCADTool() {
|
||
87 | 3883 | caballero | |
88 | 3765 | caballero | } |
89 | |||
90 | /**
|
||
91 | * M?todo de incio, para poner el c?digo de todo lo que se requiera de una
|
||
92 | * carga previa a la utilizaci?n de la herramienta.
|
||
93 | */
|
||
94 | public void init() { |
||
95 | 5170 | caballero | _fsm = new PolylineCADToolContext(this); |
96 | 3765 | caballero | } |
97 | |||
98 | 3883 | caballero | public void endGeometry() { |
99 | 9443 | caballero | try {
|
100 | if (getVLE().getVEA().getShapeType()==FShape.POLYGON && !close){
|
||
101 | closeGeometry(); |
||
102 | } |
||
103 | } catch (DriverIOException e) {
|
||
104 | e.printStackTrace(); |
||
105 | } |
||
106 | IGeometry[] geoms = (IGeometry[]) list.toArray(new IGeometry[0]); |
||
107 | 3846 | caballero | FGeometryCollection fgc = new FGeometryCollection(geoms);
|
108 | 5880 | fjp | |
109 | 9443 | caballero | |
110 | 5880 | fjp | // No queremos guardar FGeometryCollections:
|
111 | GeneralPathX gp = new GeneralPathX();
|
||
112 | 7072 | caballero | gp.append(fgc.getPathIterator(null,FConverter.FLATNESS), true); |
113 | 5880 | fjp | IGeometry newGeom = ShapeFactory.createPolyline2D(gp); |
114 | 6034 | fjp | // if (gp.isClosed())
|
115 | // {
|
||
116 | // gp.ensureOrientation(false); // Poligono exterior.
|
||
117 | // // Voy a testear que se puede convertir a JTS:
|
||
118 | // IGeometry gAux = ShapeFactory.createPolygon2D(gp);
|
||
119 | // Geometry jtsG = gAux.toJTSGeometry();
|
||
120 | // logger.debug("A punto de escribir " + jtsG.toText());
|
||
121 | // try {
|
||
122 | // int shapeType = getVLE().getVEA().getShapeType();
|
||
123 | // if ((shapeType ==FShape.POLYGON) || (shapeType == FShape.MULTI)) {
|
||
124 | // newGeom = gAux;
|
||
125 | // }
|
||
126 | // } catch (DriverIOException e) {
|
||
127 | // // TODO Auto-generated catch block
|
||
128 | // e.printStackTrace();
|
||
129 | // return;
|
||
130 | // }
|
||
131 | //
|
||
132 | // }
|
||
133 | //
|
||
134 | 5880 | fjp | addGeometry(newGeom); |
135 | 3782 | caballero | _fsm = new PolylineCADToolContext(this); |
136 | 3883 | caballero | list.clear(); |
137 | 9443 | caballero | close=false;
|
138 | 3883 | caballero | antantPoint=antCenter=antInter=antPoint=firstPoint=null;
|
139 | 3765 | caballero | } |
140 | 3883 | caballero | public void closeGeometry(){ |
141 | 6161 | caballero | close=true;
|
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 | 6071 | caballero | |
197 | 5945 | caballero | if (firstPoint == null) { |
198 | 6071 | caballero | firstPoint = new Point2D.Double(x, y); |
199 | 5945 | caballero | } |
200 | Point2D point = new Point2D.Double(x, y); |
||
201 | 3782 | caballero | |
202 | if (antPoint != null) { |
||
203 | GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD,
|
||
204 | 2);
|
||
205 | elShape.moveTo(antPoint.getX(), antPoint.getY()); |
||
206 | elShape.lineTo(point.getX(), point.getY()); |
||
207 | 5170 | caballero | list.add(ShapeFactory.createPolyline2D(elShape)); |
208 | 3978 | caballero | |
209 | 3782 | caballero | } |
210 | 6071 | caballero | if (antPoint==null) |
211 | antPoint = (Point2D)firstPoint.clone();
|
||
212 | 3765 | caballero | |
213 | 3782 | caballero | if (antPoint != null) { |
214 | antantPoint = antPoint; |
||
215 | } |
||
216 | 3765 | caballero | |
217 | 3782 | caballero | antPoint = point; |
218 | 3978 | caballero | } else if (status.equals("Polyline.NextPointOrLineOrClose")) { |
219 | 3782 | caballero | Point2D point = new Point2D.Double(x, y); |
220 | Point2D lastp = antPoint; //(Point2D)points.get(i-1); |
||
221 | 3765 | caballero | |
222 | 3782 | caballero | if (antantPoint == null) { |
223 | antantPoint = new Point2D.Double(lastp.getX() + |
||
224 | (point.getX() / 2), lastp.getY() + (point.getY() / 2)); |
||
225 | } |
||
226 | 3765 | caballero | |
227 | 3782 | caballero | if (((point.getY() == lastp.getY()) &&
|
228 | (point.getX() < lastp.getX())) || |
||
229 | ((point.getX() == lastp.getX()) && |
||
230 | (point.getY() < lastp.getY()))) { |
||
231 | } else {
|
||
232 | if (point.getX() == lastp.getX()) {
|
||
233 | point = new Point2D.Double(point.getX() + 0.00000001, |
||
234 | point.getY()); |
||
235 | } else if (point.getY() == lastp.getY()) { |
||
236 | point = new Point2D.Double(point.getX(), |
||
237 | point.getY() + 0.00000001);
|
||
238 | } |
||
239 | 3765 | caballero | |
240 | 3782 | caballero | if (point.getX() == antantPoint.getX()) {
|
241 | point = new Point2D.Double(point.getX() + 0.00000001, |
||
242 | point.getY()); |
||
243 | } else if (point.getY() == antantPoint.getY()) { |
||
244 | point = new Point2D.Double(point.getX(), |
||
245 | point.getY() + 0.00000001);
|
||
246 | } |
||
247 | 3765 | caballero | |
248 | 3782 | caballero | if (!(list.size() > 0) || |
249 | (((IGeometry) list.get(list.size() - 1)).getGeometryType() == FShape.LINE)) {
|
||
250 | Point2D[] ps1 = UtilFunctions.getPerpendicular(antantPoint, |
||
251 | lastp, lastp); |
||
252 | Point2D mediop = new Point2D.Double((point.getX() + |
||
253 | lastp.getX()) / 2, (point.getY() + lastp.getY()) / 2); |
||
254 | Point2D[] ps2 = UtilFunctions.getPerpendicular(lastp, |
||
255 | point, mediop); |
||
256 | Point2D interp = UtilFunctions.getIntersection(ps1[0], |
||
257 | ps1[1], ps2[0], ps2[1]); |
||
258 | antInter = interp; |
||
259 | 3765 | caballero | |
260 | 3782 | caballero | double radio = interp.distance(lastp);
|
261 | 3765 | caballero | |
262 | 3782 | caballero | if (UtilFunctions.isLowAngle(antantPoint, lastp, interp,
|
263 | point)) { |
||
264 | radio = -radio; |
||
265 | } |
||
266 | 3765 | caballero | |
267 | 3782 | caballero | Point2D centerp = UtilFunctions.getPoint(interp, mediop,
|
268 | radio); |
||
269 | antCenter = centerp; |
||
270 | 3765 | caballero | |
271 | 3782 | caballero | IGeometry ig = ShapeFactory.createArc(lastp, centerp, point); |
272 | 3765 | caballero | |
273 | 3782 | caballero | if (ig != null) { |
274 | list.add(ig); |
||
275 | } |
||
276 | } else {
|
||
277 | Point2D[] ps1 = UtilFunctions.getPerpendicular(lastp, |
||
278 | antInter, lastp); |
||
279 | double a1 = UtilFunctions.getAngle(ps1[0], ps1[1]); |
||
280 | double a2 = UtilFunctions.getAngle(ps1[1], ps1[0]); |
||
281 | double angle = UtilFunctions.getAngle(antCenter, lastp);
|
||
282 | Point2D ini1 = null; |
||
283 | Point2D ini2 = null; |
||
284 | 3765 | caballero | |
285 | 3782 | caballero | if (UtilFunctions.absoluteAngleDistance(angle, a1) > UtilFunctions.absoluteAngleDistance(
|
286 | angle, a2)) { |
||
287 | ini1 = ps1[0];
|
||
288 | ini2 = ps1[1];
|
||
289 | } else {
|
||
290 | ini1 = ps1[1];
|
||
291 | ini2 = ps1[0];
|
||
292 | } |
||
293 | 3765 | caballero | |
294 | 3782 | caballero | Point2D unit = UtilFunctions.getUnitVector(ini1, ini2);
|
295 | Point2D correct = new Point2D.Double(lastp.getX() + |
||
296 | unit.getX(), lastp.getY() + unit.getY()); |
||
297 | Point2D[] ps = UtilFunctions.getPerpendicular(lastp, |
||
298 | correct, lastp); |
||
299 | Point2D mediop = new Point2D.Double((point.getX() + |
||
300 | lastp.getX()) / 2, (point.getY() + lastp.getY()) / 2); |
||
301 | Point2D[] ps2 = UtilFunctions.getPerpendicular(lastp, |
||
302 | point, mediop); |
||
303 | Point2D interp = UtilFunctions.getIntersection(ps[0], |
||
304 | ps[1], ps2[0], ps2[1]); |
||
305 | antInter = interp; |
||
306 | 3765 | caballero | |
307 | 3782 | caballero | double radio = interp.distance(lastp);
|
308 | 3765 | caballero | |
309 | 3782 | caballero | if (UtilFunctions.isLowAngle(correct, lastp, interp, point)) {
|
310 | radio = -radio; |
||
311 | } |
||
312 | 3765 | caballero | |
313 | 3782 | caballero | Point2D centerp = UtilFunctions.getPoint(interp, mediop,
|
314 | radio); |
||
315 | antCenter = centerp; |
||
316 | list.add(ShapeFactory.createArc(lastp, centerp, point)); |
||
317 | } |
||
318 | 3765 | caballero | |
319 | 3782 | caballero | antantPoint = antPoint; |
320 | antPoint = point; |
||
321 | } |
||
322 | 3765 | caballero | } |
323 | } |
||
324 | |||
325 | /**
|
||
326 | * M?todo para dibujar la lo necesario para el estado en el que nos
|
||
327 | * encontremos.
|
||
328 | *
|
||
329 | * @param g Graphics sobre el que dibujar.
|
||
330 | * @param selectedGeometries BitSet con las geometr?as seleccionadas.
|
||
331 | * @param x par?metro x del punto que se pase para dibujar.
|
||
332 | * @param y par?metro x del punto que se pase para dibujar.
|
||
333 | */
|
||
334 | 3832 | caballero | public void drawOperation(Graphics g, double x, |
335 | 3765 | caballero | double y) {
|
336 | 3883 | caballero | PolylineCADToolState actualState = ((PolylineCADToolContext)_fsm).getState(); |
337 | 3765 | caballero | String status = actualState.getName();
|
338 | |||
339 | 5945 | caballero | if (status.equals("Polyline.NextPointOrArcOrClose") || status.equals("Polyline.FirstPoint")) { |
340 | 3782 | caballero | for (int i = 0; i < list.size(); i++) { |
341 | ((IGeometry) list.get(i)).cloneGeometry().draw((Graphics2D) g,
|
||
342 | getCadToolAdapter().getMapControl().getViewPort(), |
||
343 | 3997 | fjp | CADTool.drawingSymbol); |
344 | 3782 | caballero | } |
345 | 5945 | caballero | if (antPoint!=null) |
346 | drawLine((Graphics2D) g, antPoint, new Point2D.Double(x, y)); |
||
347 | 3765 | caballero | |
348 | 3978 | caballero | } else if ((status.equals("Polyline.NextPointOrLineOrClose"))) { |
349 | 3782 | caballero | for (int i = 0; i < list.size(); i++) { |
350 | ((IGeometry) list.get(i)).cloneGeometry().draw((Graphics2D) g,
|
||
351 | getCadToolAdapter().getMapControl().getViewPort(), |
||
352 | 3997 | fjp | CADTool.drawingSymbol); |
353 | 3782 | caballero | } |
354 | 3765 | caballero | |
355 | 3782 | caballero | Point2D point = new Point2D.Double(x, y); |
356 | Point2D lastp = antPoint;
|
||
357 | 3765 | caballero | |
358 | 3782 | caballero | if (!(list.size() > 0) || |
359 | (((IGeometry) list.get(list.size() - 1)).getGeometryType() == FShape.LINE)) {
|
||
360 | if (antantPoint == null) { |
||
361 | drawArc(point, lastp, |
||
362 | new Point2D.Double(lastp.getX() + (point.getX() / 2), |
||
363 | lastp.getY() + (point.getY() / 2)), g);
|
||
364 | } else {
|
||
365 | drawArc(point, lastp, antantPoint, g); |
||
366 | } |
||
367 | } else {
|
||
368 | if (antInter != null) { |
||
369 | Point2D[] ps1 = UtilFunctions.getPerpendicular(lastp, |
||
370 | antInter, lastp); |
||
371 | double a1 = UtilFunctions.getAngle(ps1[0], ps1[1]); |
||
372 | double a2 = UtilFunctions.getAngle(ps1[1], ps1[0]); |
||
373 | double angle = UtilFunctions.getAngle(antCenter, lastp);
|
||
374 | Point2D ini1 = null; |
||
375 | Point2D ini2 = null; |
||
376 | 3765 | caballero | |
377 | 3782 | caballero | if (UtilFunctions.absoluteAngleDistance(angle, a1) > UtilFunctions.absoluteAngleDistance(
|
378 | angle, a2)) { |
||
379 | ini1 = ps1[0];
|
||
380 | ini2 = ps1[1];
|
||
381 | } else {
|
||
382 | ini1 = ps1[1];
|
||
383 | ini2 = ps1[0];
|
||
384 | } |
||
385 | 3765 | caballero | |
386 | 3782 | caballero | Point2D unit = UtilFunctions.getUnitVector(ini1, ini2);
|
387 | Point2D correct = new Point2D.Double(lastp.getX() + |
||
388 | unit.getX(), lastp.getY() + unit.getY()); |
||
389 | drawArc(point, lastp, correct, g); |
||
390 | } |
||
391 | } |
||
392 | } |
||
393 | 3765 | caballero | } |
394 | 3782 | caballero | |
395 | 3765 | caballero | /**
|
396 | 3782 | caballero | * Dibuja el arco sobre el graphics.
|
397 | *
|
||
398 | * @param point Puntero del rat?n.
|
||
399 | * @param lastp ?ltimo punto de la polilinea.
|
||
400 | * @param antp Punto antepenultimo.
|
||
401 | * @param g Graphics sobre el que se dibuja.
|
||
402 | */
|
||
403 | private void drawArc(Point2D point, Point2D lastp, Point2D antp, Graphics g) { |
||
404 | if (((point.getY() == lastp.getY()) && (point.getX() < lastp.getX())) ||
|
||
405 | ((point.getX() == lastp.getX()) && |
||
406 | (point.getY() < lastp.getY()))) { |
||
407 | } else {
|
||
408 | if (point.getX() == lastp.getX()) {
|
||
409 | point = new Point2D.Double(point.getX() + 0.00000001, |
||
410 | point.getY()); |
||
411 | } else if (point.getY() == lastp.getY()) { |
||
412 | point = new Point2D.Double(point.getX(), |
||
413 | point.getY() + 0.00000001);
|
||
414 | } |
||
415 | 3765 | caballero | |
416 | 3782 | caballero | if (point.getX() == antp.getX()) {
|
417 | point = new Point2D.Double(point.getX() + 0.00000001, |
||
418 | point.getY()); |
||
419 | } else if (point.getY() == antp.getY()) { |
||
420 | point = new Point2D.Double(point.getX(), |
||
421 | point.getY() + 0.00000001);
|
||
422 | } |
||
423 | 3765 | caballero | |
424 | 3782 | caballero | Point2D[] ps1 = UtilFunctions.getPerpendicular(lastp, antp, lastp); |
425 | Point2D mediop = new Point2D.Double((point.getX() + lastp.getX()) / 2, |
||
426 | (point.getY() + lastp.getY()) / 2);
|
||
427 | Point2D[] ps2 = UtilFunctions.getPerpendicular(lastp, point, mediop); |
||
428 | Point2D interp = UtilFunctions.getIntersection(ps1[0], ps1[1], |
||
429 | ps2[0], ps2[1]); |
||
430 | 3765 | caballero | |
431 | 3782 | caballero | double radio = interp.distance(lastp);
|
432 | 3765 | caballero | |
433 | 3782 | caballero | if (UtilFunctions.isLowAngle(antp, lastp, interp, point)) {
|
434 | radio = -radio; |
||
435 | } |
||
436 | 3765 | caballero | |
437 | 3782 | caballero | Point2D centerp = UtilFunctions.getPoint(interp, mediop, radio);
|
438 | 3765 | caballero | |
439 | 3782 | caballero | drawLine((Graphics2D) g, lastp, point);
|
440 | 3765 | caballero | |
441 | 3782 | caballero | IGeometry ig = ShapeFactory.createArc(lastp, centerp, point); |
442 | 3765 | caballero | |
443 | 3782 | caballero | if (ig != null) { |
444 | ig.draw((Graphics2D) g,
|
||
445 | getCadToolAdapter().getMapControl().getViewPort(), |
||
446 | CADTool.modifySymbol); |
||
447 | } |
||
448 | } |
||
449 | 3765 | caballero | } |
450 | |||
451 | /**
|
||
452 | * Add a diferent option.
|
||
453 | *
|
||
454 | 3782 | caballero | * @param sel DOCUMENT ME!
|
455 | 3765 | caballero | * @param s Diferent option.
|
456 | */
|
||
457 | 3832 | caballero | public void addOption(String s) { |
458 | 5395 | caballero | /* PolylineCADToolState actualState = (PolylineCADToolState) _fsm.getPreviousState();
|
459 | 3765 | caballero | String status = actualState.getName();
|
460 | 3782 | caballero | |
461 | 3978 | caballero | if (status.equals("Polyline.NextPointOrArcOrClose")) {
|
462 | 5170 | caballero | if (s.equals("A") || s.equals("a") || s.equals(PluginServices.getText(this,"inter_arc"))) {
|
463 | 3782 | caballero | //Arco
|
464 | } else if (s.equals("C") || s.equals("c")) {
|
||
465 | 5170 | caballero | GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, 2);
|
466 | 3846 | caballero | elShape.moveTo(antPoint.getX(), antPoint.getY());
|
467 | elShape.lineTo(firstPoint.getX(), firstPoint.getY());
|
||
468 | list.add(ShapeFactory.createPolyline2D(elShape));
|
||
469 | 5170 | caballero | //closeGeometry();
|
470 | 3765 | caballero | }
|
471 | 3978 | caballero | } else if (status.equals("Polyline.NextPointOrLineOrClose")) {
|
472 | 5170 | caballero | if (s.equals("N") || s.equals("n") || s.equals(PluginServices.getText(this,"inter_line"))) {
|
473 | 3782 | caballero | //L?nea
|
474 | } else if (s.equals("C") || s.equals("c")) {
|
||
475 | 5170 | caballero | GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, 2);
|
476 | 3846 | caballero | elShape.moveTo(antPoint.getX(), antPoint.getY());
|
477 | elShape.lineTo(firstPoint.getX(), firstPoint.getY());
|
||
478 | list.add(ShapeFactory.createPolyline2D(elShape));
|
||
479 | //closeGeometry();
|
||
480 | 3782 | caballero | }
|
481 | 3765 | caballero | }
|
482 | 5395 | caballero | */
|
483 | 3765 | caballero | } |
484 | |||
485 | /* (non-Javadoc)
|
||
486 | * @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double)
|
||
487 | */
|
||
488 | 3832 | caballero | public void addValue(double d) { |
489 | 3765 | caballero | } |
490 | 3883 | caballero | |
491 | public void cancel(){ |
||
492 | 5395 | caballero | //endGeometry();
|
493 | 5170 | caballero | list.clear(); |
494 | antantPoint=antCenter=antInter=antPoint=firstPoint=null;
|
||
495 | 3883 | caballero | } |
496 | 4002 | fjp | |
497 | 5170 | caballero | public void end() { |
498 | /* CADExtension.setCADTool("polyline");
|
||
499 | PluginServices.getMainFrame().setSelectedTool("POLYLINE"); */
|
||
500 | } |
||
501 | 4118 | caballero | |
502 | 5170 | caballero | public String getName() { |
503 | return PluginServices.getText(this,"polyline_"); |
||
504 | } |
||
505 | 4892 | caballero | |
506 | 5170 | caballero | public String toString() { |
507 | return "_polyline"; |
||
508 | } |
||
509 | public boolean isApplicable(int shapeType) { |
||
510 | switch (shapeType) {
|
||
511 | case FShape.POINT:
|
||
512 | 6024 | caballero | case FShape.MULTIPOINT:
|
513 | 5170 | caballero | return false; |
514 | } |
||
515 | return true; |
||
516 | } |
||
517 | 3765 | caballero | } |