Statistics
| Revision:

root / trunk / extensions / extCAD / src / com / iver / cit / gvsig / gui / cad / tools / PolylineCADTool.java @ 28763

History | View | Annotate | Download (20.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 17984 vcaballero
import java.awt.event.MouseEvent;
47 3832 caballero
import java.awt.geom.Point2D;
48
import java.util.ArrayList;
49
50 10626 caballero
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
51 4584 caballero
import com.iver.andami.PluginServices;
52 12739 caballero
import com.iver.andami.messages.NotificationManager;
53 3782 caballero
import com.iver.cit.gvsig.fmap.core.FGeometryCollection;
54
import com.iver.cit.gvsig.fmap.core.FShape;
55
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
56 15603 vcaballero
import com.iver.cit.gvsig.fmap.core.Handler;
57 3782 caballero
import com.iver.cit.gvsig.fmap.core.IGeometry;
58
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
59 6714 caballero
import com.iver.cit.gvsig.fmap.core.v02.FConverter;
60 3782 caballero
import com.iver.cit.gvsig.fmap.edition.UtilFunctions;
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 23993 vcaballero
        protected PolylineCADToolContext _fsm;
74
    protected Point2D firstPoint;
75
    protected Point2D antPoint;
76
    protected Point2D antantPoint;
77
    protected Point2D antCenter;
78
    protected Point2D antInter;
79
    protected ArrayList list = new ArrayList();
80
        protected boolean close=false;
81
        protected GeneralPathX gpx = null;
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 11434 caballero
    public IGeometry getGeometry() {
98
                IGeometry[] geoms = (IGeometry[]) list.toArray(new IGeometry[0]);
99
                FGeometryCollection fgc = new FGeometryCollection(geoms);
100
                // No queremos guardar FGeometryCollections:
101
                GeneralPathX gp = new GeneralPathX();
102
                gp.append(fgc.getPathIterator(null, FConverter.FLATNESS), true);
103
                IGeometry newGeom = ShapeFactory.createPolyline2D(gp);
104
                return newGeom;
105
        }
106 13561 caballero
    public int getLinesCount() {
107
            return list.size();
108
    }
109 17619 vcaballero
    public boolean isPolygonLayer(){
110
            try {
111
                        return (getVLE().getVEA().getShapeType()==FShape.POLYGON);
112
                } catch (ReadDriverException e) {
113
                        return false;
114
                }
115
    }
116 3883 caballero
    public void endGeometry() {
117 10427 caballero
            if (gpx==null) {
118
                    gpx=new GeneralPathX();
119
                    IGeometry[] geoms = (IGeometry[]) list.toArray(new IGeometry[0]);
120
                    FGeometryCollection fgc = new FGeometryCollection(geoms);
121
                    // No queremos guardar FGeometryCollections:
122
                    gpx.append(fgc.getPathIterator(null,FConverter.FLATNESS), true);
123
            }
124
        try {
125 9399 caballero
                         if (getVLE().getVEA().getShapeType()==FShape.POLYGON && !close){
126
                                 closeGeometry();
127
                         }
128 10626 caballero
                 } catch (ReadDriverException e) {
129 12739 caballero
                         NotificationManager.addError(e.getMessage(),e);
130 10626 caballero
                }
131 5880 fjp
132 12297 caballero
        IGeometry newGeom = null;
133
        int type=getCadToolAdapter().getActiveLayerType();
134
        if (type==FShape.POLYGON){
135
                newGeom = ShapeFactory.createPolygon2D(gpx);
136
        }else{
137
                newGeom = ShapeFactory.createPolyline2D(gpx);
138
        }
139 5880 fjp
        addGeometry(newGeom);
140 3782 caballero
        _fsm = new PolylineCADToolContext(this);
141 3883 caballero
        list.clear();
142 13561 caballero
        clearTemporalCache();
143 9399 caballero
        close=false;
144 10427 caballero
        gpx=null;
145 3883 caballero
        antantPoint=antCenter=antInter=antPoint=firstPoint=null;
146 3765 caballero
    }
147 3883 caballero
    public void closeGeometry(){
148 10427 caballero
            if (gpx==null) {
149
                    gpx=new GeneralPathX();
150
                    IGeometry[] geoms = (IGeometry[]) list.toArray(new IGeometry[0]);
151
                    FGeometryCollection fgc = new FGeometryCollection(geoms);
152
                    // No queremos guardar FGeometryCollections:
153
                    gpx.append(fgc.getPathIterator(null,FConverter.FLATNESS), true);
154
            }
155 6161 caballero
            close=true;
156 10427 caballero
            gpx.closePath();
157 3883 caballero
    }
158 3765 caballero
    /* (non-Javadoc)
159 3782 caballero
     * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double, double)
160
     */
161 4313 fjp
    public void transition(double x, double y, InputEvent event) {
162 4324 caballero
        _fsm.addPoint(x, y, event);
163 3765 caballero
    }
164
165
    /* (non-Javadoc)
166 3782 caballero
     * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double)
167
     */
168 3832 caballero
    public void transition(double d) {
169 5735 caballero
        _fsm.addValue(d);
170 3782 caballero
    }
171 3765 caballero
172 3782 caballero
    /* (non-Javadoc)
173
     * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, java.lang.String)
174
     */
175 5735 caballero
    public void transition(String s) throws CommandException {
176 5170 caballero
        if (!super.changeCommand(s)){
177
            _fsm.addOption(s);
178
        }
179 3782 caballero
    }
180
181 3765 caballero
    /**
182
     * Equivale al transition del prototipo pero sin pasarle como par?metro el
183
     * editableFeatureSource que ya estar? creado.
184
     *
185
     * @param sel Bitset con las geometr?as que est?n seleccionadas.
186
     * @param x par?metro x del punto que se pase en esta transici?n.
187
     * @param y par?metro y del punto que se pase en esta transici?n.
188
     */
189 4365 caballero
    public void addPoint(double x, double y,InputEvent event) {
190 5170 caballero
        PolylineCADToolState actualState = (PolylineCADToolState) _fsm.getPreviousState();
191 3765 caballero
        String status = actualState.getName();
192 5945 caballero
        if (status.equals("Polyline.NextPointOrArcOrClose") || status.equals("Polyline.FirstPoint")) {
193 6071 caballero
194 5945 caballero
           if (firstPoint == null) {
195 6071 caballero
               firstPoint = new Point2D.Double(x, y);
196 5945 caballero
           }
197
                Point2D point = new Point2D.Double(x, y);
198 3782 caballero
199
            if (antPoint != null) {
200
                GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD,
201
                        2);
202
                elShape.moveTo(antPoint.getX(), antPoint.getY());
203
                elShape.lineTo(point.getX(), point.getY());
204 13561 caballero
                IGeometry geom=ShapeFactory.createPolyline2D(elShape);
205
                list.add(geom);
206
                addTemporalCache(geom);
207 3782 caballero
            }
208 6071 caballero
            if (antPoint==null)
209
                    antPoint = (Point2D)firstPoint.clone();
210 3765 caballero
211 3782 caballero
            if (antPoint != null) {
212
                antantPoint = antPoint;
213
            }
214 3765 caballero
215 3782 caballero
            antPoint = point;
216 3978 caballero
        } else if (status.equals("Polyline.NextPointOrLineOrClose")) {
217 3782 caballero
            Point2D point = new Point2D.Double(x, y);
218
            Point2D lastp = antPoint; //(Point2D)points.get(i-1);
219 3765 caballero
220 3782 caballero
            if (antantPoint == null) {
221
                antantPoint = new Point2D.Double(lastp.getX() +
222
                        (point.getX() / 2), lastp.getY() + (point.getY() / 2));
223
            }
224 3765 caballero
225 3782 caballero
            if (((point.getY() == lastp.getY()) &&
226
                    (point.getX() < lastp.getX())) ||
227
                    ((point.getX() == lastp.getX()) &&
228
                    (point.getY() < lastp.getY()))) {
229
            } else {
230
                if (point.getX() == lastp.getX()) {
231
                    point = new Point2D.Double(point.getX() + 0.00000001,
232
                            point.getY());
233
                } else if (point.getY() == lastp.getY()) {
234
                    point = new Point2D.Double(point.getX(),
235
                            point.getY() + 0.00000001);
236
                }
237 3765 caballero
238 3782 caballero
                if (point.getX() == antantPoint.getX()) {
239
                    point = new Point2D.Double(point.getX() + 0.00000001,
240
                            point.getY());
241
                } else if (point.getY() == antantPoint.getY()) {
242
                    point = new Point2D.Double(point.getX(),
243
                            point.getY() + 0.00000001);
244
                }
245 3765 caballero
246 3782 caballero
                if (!(list.size() > 0) ||
247
                        (((IGeometry) list.get(list.size() - 1)).getGeometryType() == FShape.LINE)) {
248
                    Point2D[] ps1 = UtilFunctions.getPerpendicular(antantPoint,
249
                            lastp, lastp);
250
                    Point2D mediop = new Point2D.Double((point.getX() +
251
                            lastp.getX()) / 2, (point.getY() + lastp.getY()) / 2);
252
                    Point2D[] ps2 = UtilFunctions.getPerpendicular(lastp,
253
                            point, mediop);
254
                    Point2D interp = UtilFunctions.getIntersection(ps1[0],
255
                            ps1[1], ps2[0], ps2[1]);
256
                    antInter = interp;
257 3765 caballero
258 3782 caballero
                    double radio = interp.distance(lastp);
259 3765 caballero
260 3782 caballero
                    if (UtilFunctions.isLowAngle(antantPoint, lastp, interp,
261
                                point)) {
262
                        radio = -radio;
263
                    }
264 3765 caballero
265 3782 caballero
                    Point2D centerp = UtilFunctions.getPoint(interp, mediop,
266
                            radio);
267
                    antCenter = centerp;
268 3765 caballero
269 3782 caballero
                    IGeometry ig = ShapeFactory.createArc(lastp, centerp, point);
270 3765 caballero
271 3782 caballero
                    if (ig != null) {
272
                        list.add(ig);
273 13561 caballero
                        addTemporalCache(ig);
274 3782 caballero
                    }
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 13561 caballero
                    IGeometry geom=ShapeFactory.createArc(lastp, centerp, point);
316
                    list.add(geom);
317
                    addTemporalCache(geom);
318 3782 caballero
                }
319 3765 caballero
320 3782 caballero
                antantPoint = antPoint;
321
                antPoint = point;
322
            }
323 3765 caballero
        }
324
    }
325
326
    /**
327
     * M?todo para dibujar la lo necesario para el estado en el que nos
328
     * encontremos.
329
     *
330
     * @param g Graphics sobre el que dibujar.
331
     * @param selectedGeometries BitSet con las geometr?as seleccionadas.
332
     * @param x par?metro x del punto que se pase para dibujar.
333
     * @param y par?metro x del punto que se pase para dibujar.
334
     */
335 3832 caballero
    public void drawOperation(Graphics g, double x,
336 3765 caballero
        double y) {
337 10427 caballero
        PolylineCADToolState actualState = _fsm.getState();
338 3765 caballero
        String status = actualState.getName();
339
340 5945 caballero
        if (status.equals("Polyline.NextPointOrArcOrClose") || status.equals("Polyline.FirstPoint")) {
341 3782 caballero
            for (int i = 0; i < list.size(); i++) {
342
                ((IGeometry) list.get(i)).cloneGeometry().draw((Graphics2D) g,
343
                    getCadToolAdapter().getMapControl().getViewPort(),
344 11437 caballero
                     DefaultCADTool.geometrySelectSymbol);
345 3782 caballero
            }
346 5945 caballero
            if (antPoint!=null)
347 11437 caballero
                    drawLine((Graphics2D) g, antPoint, new Point2D.Double(x, y),DefaultCADTool.geometrySelectSymbol);
348 3765 caballero
349 3978 caballero
        } else if ((status.equals("Polyline.NextPointOrLineOrClose"))) {
350 3782 caballero
            for (int i = 0; i < list.size(); i++) {
351
                ((IGeometry) list.get(i)).cloneGeometry().draw((Graphics2D) g,
352
                    getCadToolAdapter().getMapControl().getViewPort(),
353 11437 caballero
                     DefaultCADTool.geometrySelectSymbol);
354 3782 caballero
            }
355 3765 caballero
356 3782 caballero
            Point2D point = new Point2D.Double(x, y);
357
            Point2D lastp = antPoint;
358 3765 caballero
359 3782 caballero
            if (!(list.size() > 0) ||
360
                    (((IGeometry) list.get(list.size() - 1)).getGeometryType() == FShape.LINE)) {
361
                if (antantPoint == null) {
362
                    drawArc(point, lastp,
363
                        new Point2D.Double(lastp.getX() + (point.getX() / 2),
364
                            lastp.getY() + (point.getY() / 2)), g);
365
                } else {
366
                    drawArc(point, lastp, antantPoint, g);
367
                }
368
            } else {
369
                if (antInter != null) {
370
                    Point2D[] ps1 = UtilFunctions.getPerpendicular(lastp,
371
                            antInter, lastp);
372
                    double a1 = UtilFunctions.getAngle(ps1[0], ps1[1]);
373
                    double a2 = UtilFunctions.getAngle(ps1[1], ps1[0]);
374
                    double angle = UtilFunctions.getAngle(antCenter, lastp);
375
                    Point2D ini1 = null;
376
                    Point2D ini2 = null;
377 3765 caballero
378 3782 caballero
                    if (UtilFunctions.absoluteAngleDistance(angle, a1) > UtilFunctions.absoluteAngleDistance(
379
                                angle, a2)) {
380
                        ini1 = ps1[0];
381
                        ini2 = ps1[1];
382
                    } else {
383
                        ini1 = ps1[1];
384
                        ini2 = ps1[0];
385
                    }
386 3765 caballero
387 3782 caballero
                    Point2D unit = UtilFunctions.getUnitVector(ini1, ini2);
388
                    Point2D correct = new Point2D.Double(lastp.getX() +
389
                            unit.getX(), lastp.getY() + unit.getY());
390
                    drawArc(point, lastp, correct, g);
391
                }
392
            }
393
        }
394 15603 vcaballero
        try {
395
                        if (getVLE().getVEA().getShapeType()==FShape.POLYGON && !list.isEmpty()){
396
                                Handler handler1=((IGeometry) list.get(0)).getHandlers(IGeometry.SELECTHANDLER)[0];
397
                                GeneralPathX gpx=new GeneralPathX();
398
                                gpx.moveTo(x,y);
399
                                Point2D p1=handler1.getPoint();
400
                                gpx.lineTo(p1.getX(),p1.getY());
401
                                ShapeFactory.createPolyline2D(gpx).draw((Graphics2D) g,
402
                                    getCadToolAdapter().getMapControl().getViewPort(),
403
                                     DefaultCADTool.geometrySelectSymbol);
404
                        }
405
                } catch (ReadDriverException e) {
406
                        e.printStackTrace();
407
                }
408 3765 caballero
    }
409 3782 caballero
410 3765 caballero
    /**
411 3782 caballero
     * Dibuja el arco sobre el graphics.
412
     *
413
     * @param point Puntero del rat?n.
414
     * @param lastp ?ltimo punto de la polilinea.
415
     * @param antp Punto antepenultimo.
416
     * @param g Graphics sobre el que se dibuja.
417
     */
418
    private void drawArc(Point2D point, Point2D lastp, Point2D antp, Graphics g) {
419
        if (((point.getY() == lastp.getY()) && (point.getX() < lastp.getX())) ||
420
                ((point.getX() == lastp.getX()) &&
421
                (point.getY() < lastp.getY()))) {
422
        } else {
423
            if (point.getX() == lastp.getX()) {
424
                point = new Point2D.Double(point.getX() + 0.00000001,
425
                        point.getY());
426
            } else if (point.getY() == lastp.getY()) {
427
                point = new Point2D.Double(point.getX(),
428
                        point.getY() + 0.00000001);
429
            }
430 3765 caballero
431 3782 caballero
            if (point.getX() == antp.getX()) {
432
                point = new Point2D.Double(point.getX() + 0.00000001,
433
                        point.getY());
434
            } else if (point.getY() == antp.getY()) {
435
                point = new Point2D.Double(point.getX(),
436
                        point.getY() + 0.00000001);
437
            }
438 3765 caballero
439 3782 caballero
            Point2D[] ps1 = UtilFunctions.getPerpendicular(lastp, antp, lastp);
440
            Point2D mediop = new Point2D.Double((point.getX() + lastp.getX()) / 2,
441
                    (point.getY() + lastp.getY()) / 2);
442
            Point2D[] ps2 = UtilFunctions.getPerpendicular(lastp, point, mediop);
443
            Point2D interp = UtilFunctions.getIntersection(ps1[0], ps1[1],
444
                    ps2[0], ps2[1]);
445 3765 caballero
446 3782 caballero
            double radio = interp.distance(lastp);
447 3765 caballero
448 3782 caballero
            if (UtilFunctions.isLowAngle(antp, lastp, interp, point)) {
449
                radio = -radio;
450
            }
451 3765 caballero
452 3782 caballero
            Point2D centerp = UtilFunctions.getPoint(interp, mediop, radio);
453 3765 caballero
454 11437 caballero
            drawLine((Graphics2D) g, lastp, point,DefaultCADTool.geometrySelectSymbol);
455 3765 caballero
456 3782 caballero
            IGeometry ig = ShapeFactory.createArc(lastp, centerp, point);
457 3765 caballero
458 3782 caballero
            if (ig != null) {
459
                ig.draw((Graphics2D) g,
460
                    getCadToolAdapter().getMapControl().getViewPort(),
461 11437 caballero
                      DefaultCADTool.axisReferencesSymbol);
462 3782 caballero
            }
463
        }
464 3765 caballero
    }
465
466
    /**
467
     * Add a diferent option.
468
     *
469 3782 caballero
     * @param sel DOCUMENT ME!
470 3765 caballero
     * @param s Diferent option.
471
     */
472 3832 caballero
    public void addOption(String s) {
473 5395 caballero
            /*       PolylineCADToolState actualState = (PolylineCADToolState) _fsm.getPreviousState();
474 3765 caballero
        String status = actualState.getName();
475 3782 caballero

476 3978 caballero
        if (status.equals("Polyline.NextPointOrArcOrClose")) {
477 5170 caballero
            if (s.equals("A") || s.equals("a") || s.equals(PluginServices.getText(this,"inter_arc"))) {
478 3782 caballero
                //Arco
479
            } else if (s.equals("C") || s.equals("c")) {
480 5170 caballero
                GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, 2);
481 3846 caballero
                elShape.moveTo(antPoint.getX(), antPoint.getY());
482
                elShape.lineTo(firstPoint.getX(), firstPoint.getY());
483
                list.add(ShapeFactory.createPolyline2D(elShape));
484 5170 caballero
                //closeGeometry();
485 3765 caballero
            }
486 3978 caballero
        } else if (status.equals("Polyline.NextPointOrLineOrClose")) {
487 5170 caballero
            if (s.equals("N") || s.equals("n") || s.equals(PluginServices.getText(this,"inter_line"))) {
488 3782 caballero
                //L?nea
489
            } else if (s.equals("C") || s.equals("c")) {
490 5170 caballero
                GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, 2);
491 3846 caballero
                elShape.moveTo(antPoint.getX(), antPoint.getY());
492
                elShape.lineTo(firstPoint.getX(), firstPoint.getY());
493
                list.add(ShapeFactory.createPolyline2D(elShape));
494
                //closeGeometry();
495 3782 caballero
            }
496 3765 caballero
        }
497 5395 caballero
  */
498 3765 caballero
    }
499
500
    /* (non-Javadoc)
501
     * @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double)
502
     */
503 3832 caballero
    public void addValue(double d) {
504 3765 caballero
    }
505 3883 caballero
506
    public void cancel(){
507 5395 caballero
        //endGeometry();
508 5170 caballero
        list.clear();
509 13561 caballero
        clearTemporalCache();
510 5170 caballero
        antantPoint=antCenter=antInter=antPoint=firstPoint=null;
511 3883 caballero
    }
512 4002 fjp
513 5170 caballero
    public void end() {
514
        /* CADExtension.setCADTool("polyline");
515
        PluginServices.getMainFrame().setSelectedTool("POLYLINE"); */
516
    }
517 4118 caballero
518 5170 caballero
    public String getName() {
519
        return PluginServices.getText(this,"polyline_");
520
    }
521 4892 caballero
522 5170 caballero
    public String toString() {
523
        return "_polyline";
524
    }
525
    public boolean isApplicable(int shapeType) {
526
        switch (shapeType) {
527
        case FShape.POINT:
528 6024 caballero
        case FShape.MULTIPOINT:
529 5170 caballero
            return false;
530
        }
531
        return true;
532
    }
533 17984 vcaballero
534
        public void endTransition(double x, double y, MouseEvent event) {
535
                _fsm.endPoint(x, y, event);
536
        }
537 3765 caballero
}