Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extEditing / src / com / iver / cit / gvsig / gui / cad / tools / PolylineCADTool.java @ 27026

History | View | Annotate | Download (22.6 KB)

1
/* 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
package com.iver.cit.gvsig.gui.cad.tools;
42

    
43
import java.awt.Graphics;
44
import java.awt.Graphics2D;
45
import java.awt.Image;
46
import java.awt.event.InputEvent;
47
import java.awt.event.MouseEvent;
48
import java.awt.geom.Point2D;
49
import java.util.ArrayList;
50

    
51
import org.gvsig.fmap.dal.exception.ReadException;
52
import org.gvsig.fmap.geom.Geometry;
53
import org.gvsig.fmap.geom.aggregate.MultiPrimitive;
54
import org.gvsig.fmap.geom.aggregate.impl.BaseMultiPrimitive;
55
import org.gvsig.fmap.geom.handler.Handler;
56
import org.gvsig.fmap.geom.operation.Draw;
57
import org.gvsig.fmap.geom.operation.DrawOperationContext;
58
import org.gvsig.fmap.geom.operation.GeometryOperationException;
59
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
60
import org.gvsig.fmap.geom.primitive.GeneralPathX;
61
import org.gvsig.fmap.geom.util.Converter;
62
import org.gvsig.fmap.geom.util.UtilFunctions;
63
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
64

    
65
import com.iver.andami.PluginServices;
66
import com.iver.andami.messages.NotificationManager;
67
import com.iver.cit.gvsig.gui.cad.DefaultCADTool;
68
import com.iver.cit.gvsig.gui.cad.exception.CommandException;
69
import com.iver.cit.gvsig.gui.cad.tools.smc.PolylineCADToolContext;
70
import com.iver.cit.gvsig.gui.cad.tools.smc.PolylineCADToolContext.PolylineCADToolState;
71
import com.iver.cit.gvsig.layers.VectorialLayerEdited;
72

    
73

    
74
/**
75
 * DOCUMENT ME!
76
 *
77
 * @author Vicente Caballero Navarro
78
 */
79
public class PolylineCADTool extends DefaultCADTool {
80
        protected PolylineCADToolContext _fsm;
81
        protected Point2D firstPoint;
82
        protected Point2D antPoint;
83
        protected Point2D antantPoint;
84
        protected Point2D antCenter;
85
        protected Point2D antInter;
86
        protected ArrayList list = new ArrayList();
87
        protected boolean close=false;
88
        protected GeneralPathX gpx = null;
89
        
90
    /**
91
     * Crea un nuevo PolylineCADTool.
92
     */
93
    public PolylineCADTool() {
94

    
95
    }
96

    
97
    /**
98
     * M?todo de incio, para poner el c?digo de todo lo que se requiera de una
99
     * carga previa a la utilizaci?n de la herramienta.
100
     */
101
    public void init() {
102
        _fsm = new PolylineCADToolContext(this);
103
    }
104
    public Geometry getGeometry() {
105
                Geometry[] geoms = (Geometry[]) list.toArray(new Geometry[0]);
106
                MultiPrimitive fgc = createMultiPrimitive(geoms);
107
                // No queremos guardar FGeometryCollections:
108
                GeneralPathX gp = new GeneralPathX();
109
                gp.append(fgc.getPathIterator(null, Converter.FLATNESS), true);
110
                Geometry newGeom = createCurve(gp);
111
                return newGeom;
112
        }
113
    public int getLinesCount() {
114
            return list.size();
115
    }
116
    public boolean isPolygonLayer(){
117
            try {
118
                        return (((FLyrVect)getVLE().getLayer()).getShapeType()==Geometry.TYPES.SURFACE);
119
                } catch (ReadException e) {
120
                        return false;
121
                }
122
    }
123
    public void endGeometry() {
124
            if (gpx==null) {
125
                    gpx=new GeneralPathX();
126
                    Geometry[] geoms = (Geometry[]) list.toArray(new Geometry[0]);
127
                    MultiPrimitive fgc = createMultiPrimitive(geoms);
128
                    // No queremos guardar FGeometryCollections:
129
                    gpx.append(fgc.getPathIterator(null,Converter.FLATNESS), true);
130
            }
131
        try {
132
                         if (((FLyrVect)getVLE().getLayer()).getShapeType()==Geometry.TYPES.SURFACE && !close){
133
                                 closeGeometry();
134
                         }
135
                 } catch (ReadException e) {
136
                         NotificationManager.addError(e.getMessage(),e);
137
                }
138

    
139
        Geometry newGeom = null;
140
        int type=getCadToolAdapter().getActiveLayerType();
141
        if (type==Geometry.TYPES.SURFACE){
142
                newGeom = createSurface(gpx);
143
        }else{
144
                newGeom = createCurve(gpx);
145
        }
146
        insertGeometry(newGeom);
147
        _fsm = new PolylineCADToolContext(this);
148
        list.clear();
149
        clearTemporalCache();
150
        close=false;
151
        gpx=null;
152
        antantPoint=antCenter=antInter=antPoint=firstPoint=null;
153
    }
154
    public void closeGeometry(){
155
            if (gpx==null) {
156
                    gpx=new GeneralPathX();
157
                    Geometry[] geoms = (Geometry[]) list.toArray(new Geometry[0]);
158
                    MultiPrimitive fgc = createMultiPrimitive(geoms);
159
                    // No queremos guardar FGeometryCollections:
160
                    gpx.append(fgc.getPathIterator(null,Converter.FLATNESS), true);
161
            }
162
            close=true;
163
            gpx.closePath();
164
    }
165
    /* (non-Javadoc)
166
     * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double, double)
167
     */
168
    public void transition(double x, double y, InputEvent event) {
169
        _fsm.addPoint(x, y, event);
170
    }
171

    
172
    /* (non-Javadoc)
173
     * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double)
174
     */
175
    public void transition(double d) {
176
        _fsm.addValue(d);
177
    }
178

    
179
    /* (non-Javadoc)
180
     * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, java.lang.String)
181
     */
182
    public void transition(String s) throws CommandException {
183
        if (!super.changeCommand(s)){
184
            _fsm.addOption(s);
185
        }
186
    }
187

    
188
    /**
189
     * Equivale al transition del prototipo pero sin pasarle como par?metro el
190
     * editableFeatureSource que ya estar? creado.
191
     *
192
     * @param sel Bitset con las geometr?as que est?n seleccionadas.
193
     * @param x par?metro x del punto que se pase en esta transici?n.
194
     * @param y par?metro y del punto que se pase en esta transici?n.
195
     */
196
    public void addPoint(double x, double y,InputEvent event) {
197
        PolylineCADToolState actualState = (PolylineCADToolState) _fsm.getPreviousState();
198
        String status = actualState.getName();
199
        if (status.equals("Polyline.NextPointOrArcOrClose") || status.equals("Polyline.FirstPoint")) {
200

    
201
           if (firstPoint == null) {
202
               firstPoint = new Point2D.Double(x, y);
203
           }
204
                Point2D point = new Point2D.Double(x, y);
205

    
206
            if (antPoint != null) {
207
                GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD,
208
                        2);
209
                elShape.moveTo(antPoint.getX(), antPoint.getY());
210
                elShape.lineTo(point.getX(), point.getY());
211
                Geometry geom= createCurve(elShape);
212
                list.add(geom);
213
                addTemporalCache(geom);
214
            }
215
            if (antPoint==null)
216
                    antPoint = (Point2D)firstPoint.clone();
217

    
218
            if (antPoint != null) {
219
                antantPoint = antPoint;
220
            }
221

    
222
            antPoint = point;
223
        } else if (status.equals("Polyline.NextPointOrLineOrClose")) {
224
            Point2D point = new Point2D.Double(x, y);
225
            Point2D lastp = antPoint; //(Point2D)points.get(i-1);
226

    
227
            if (antantPoint == null) {
228
                antantPoint = new Point2D.Double(lastp.getX() +
229
                        (point.getX() / 2), lastp.getY() + (point.getY() / 2));
230
            }
231

    
232
            if (((point.getY() == lastp.getY()) &&
233
                    (point.getX() < lastp.getX())) ||
234
                    ((point.getX() == lastp.getX()) &&
235
                    (point.getY() < lastp.getY()))) {
236
            } else {
237
                if (point.getX() == lastp.getX()) {
238
                    point = new Point2D.Double(point.getX() + 0.00000001,
239
                            point.getY());
240
                } else if (point.getY() == lastp.getY()) {
241
                    point = new Point2D.Double(point.getX(),
242
                            point.getY() + 0.00000001);
243
                }
244

    
245
                if (point.getX() == antantPoint.getX()) {
246
                    point = new Point2D.Double(point.getX() + 0.00000001,
247
                            point.getY());
248
                } else if (point.getY() == antantPoint.getY()) {
249
                    point = new Point2D.Double(point.getX(),
250
                            point.getY() + 0.00000001);
251
                }
252

    
253
                if (!(list.size() > 0) ||
254
                        (((Geometry) list.get(list.size() - 1)).getType() == Geometry.TYPES.CURVE)) {
255
                    Point2D[] ps1 = UtilFunctions.getPerpendicular(antantPoint,
256
                            lastp, lastp);
257
                    Point2D mediop = new Point2D.Double((point.getX() +
258
                            lastp.getX()) / 2, (point.getY() + lastp.getY()) / 2);
259
                    Point2D[] ps2 = UtilFunctions.getPerpendicular(lastp,
260
                            point, mediop);
261
                    Point2D interp = UtilFunctions.getIntersection(ps1[0],
262
                            ps1[1], ps2[0], ps2[1]);
263
                    antInter = interp;
264

    
265
                    double radio = interp.distance(lastp);
266

    
267
                    if (UtilFunctions.isLowAngle(antantPoint, lastp, interp,
268
                                point)) {
269
                        radio = -radio;
270
                    }
271

    
272
                    Point2D centerp = UtilFunctions.getPoint(interp, mediop,
273
                            radio);
274
                    antCenter = centerp;
275

    
276
                    Geometry ig = createArc(lastp, centerp, point);
277

    
278
                    if (ig != null) {
279
                        list.add(ig);
280
                        addTemporalCache(ig);
281
                    }
282
                } else {
283
                    Point2D[] ps1 = UtilFunctions.getPerpendicular(lastp,
284
                            antInter, lastp);
285
                    double a1 = UtilFunctions.getAngle(ps1[0], ps1[1]);
286
                    double a2 = UtilFunctions.getAngle(ps1[1], ps1[0]);
287
                    double angle = UtilFunctions.getAngle(antCenter, lastp);
288
                    Point2D ini1 = null;
289
                    Point2D ini2 = null;
290

    
291
                    if (UtilFunctions.absoluteAngleDistance(angle, a1) > UtilFunctions.absoluteAngleDistance(
292
                                angle, a2)) {
293
                        ini1 = ps1[0];
294
                        ini2 = ps1[1];
295
                    } else {
296
                        ini1 = ps1[1];
297
                        ini2 = ps1[0];
298
                    }
299

    
300
                    Point2D unit = UtilFunctions.getUnitVector(ini1, ini2);
301
                    Point2D correct = new Point2D.Double(lastp.getX() +
302
                            unit.getX(), lastp.getY() + unit.getY());
303
                    Point2D[] ps = UtilFunctions.getPerpendicular(lastp,
304
                            correct, lastp);
305
                    Point2D mediop = new Point2D.Double((point.getX() +
306
                            lastp.getX()) / 2, (point.getY() + lastp.getY()) / 2);
307
                    Point2D[] ps2 = UtilFunctions.getPerpendicular(lastp,
308
                            point, mediop);
309
                    Point2D interp = UtilFunctions.getIntersection(ps[0],
310
                            ps[1], ps2[0], ps2[1]);
311
                    antInter = interp;
312

    
313
                    double radio = interp.distance(lastp);
314

    
315
                    if (UtilFunctions.isLowAngle(correct, lastp, interp, point)) {
316
                        radio = -radio;
317
                    }
318

    
319
                    Point2D centerp = UtilFunctions.getPoint(interp, mediop,
320
                            radio);
321
                    antCenter = centerp;
322
                    Geometry geom=createArc(lastp, centerp, point);
323
                    list.add(geom);
324
                    addTemporalCache(geom);
325
                }
326

    
327
                antantPoint = antPoint;
328
                antPoint = point;
329
            }
330
        }
331
    }
332

    
333
    /**
334
     * M?todo para dibujar la lo necesario para el estado en el que nos
335
     * encontremos.
336
     *
337
     * @param g Graphics sobre el que dibujar.
338
     * @param selectedGeometries BitSet con las geometr?as seleccionadas.
339
     * @param x par?metro x del punto que se pase para dibujar.
340
     * @param y par?metro x del punto que se pase para dibujar.
341
     */
342
    public void drawOperation(Graphics g, double x,
343
        double y) {
344
        PolylineCADToolState actualState = _fsm.getState();
345
        String status = actualState.getName();
346

    
347
        if (status.equals("Polyline.NextPointOrArcOrClose") || status.equals("Polyline.FirstPoint")) {
348
            for (int i = 0; i < list.size(); i++) {
349
                    DrawOperationContext doc=new DrawOperationContext();
350
                            doc.setGraphics((Graphics2D)g);
351
                            doc.setViewPort(getCadToolAdapter().getMapControl().getViewPort());
352
                            doc.setSymbol(DefaultCADTool.geometrySelectSymbol);
353
                    try {
354
                            ((Geometry) list.get(i)).cloneGeometry().invokeOperation(Draw.CODE,doc);
355
                                } catch (GeometryOperationNotSupportedException e) {
356
                                        e.printStackTrace();
357
                                } catch (GeometryOperationException e) {
358
                                        e.printStackTrace();
359
                                }
360
//                ((Geometry) list.get(i)).cloneGeometry().draw((Graphics2D) g,
361
//                    getCadToolAdapter().getMapControl().getViewPort(),
362
//                     DefaultCADTool.geometrySelectSymbol);
363
            }
364
            if (antPoint!=null)
365
                    drawLine((Graphics2D) g, antPoint, new Point2D.Double(x, y),DefaultCADTool.geometrySelectSymbol);
366

    
367
        } else if ((status.equals("Polyline.NextPointOrLineOrClose"))) {
368
            for (int i = 0; i < list.size(); i++) {
369
                    DrawOperationContext doc=new DrawOperationContext();
370
                            doc.setGraphics((Graphics2D)g);
371
                            doc.setViewPort(getCadToolAdapter().getMapControl().getViewPort());
372
                            doc.setSymbol(DefaultCADTool.geometrySelectSymbol);
373
                    try {
374
                            ((Geometry) list.get(i)).cloneGeometry().invokeOperation(Draw.CODE,doc);
375
                                } catch (GeometryOperationNotSupportedException e) {
376
                                        e.printStackTrace();
377
                                } catch (GeometryOperationException e) {
378
                                        e.printStackTrace();
379
                                }
380
//                ((Geometry) list.get(i)).cloneGeometry().draw((Graphics2D) g,
381
//                    getCadToolAdapter().getMapControl().getViewPort(),
382
//                     DefaultCADTool.geometrySelectSymbol);
383
            }
384

    
385
            Point2D point = new Point2D.Double(x, y);
386
            Point2D lastp = antPoint;
387

    
388
            if (!(list.size() > 0) ||
389
                    (((Geometry) list.get(list.size() - 1)).getType() == Geometry.TYPES.CURVE)) {
390
                if (antantPoint == null) {
391
                    drawArc(point, lastp,
392
                        new Point2D.Double(lastp.getX() + (point.getX() / 2),
393
                            lastp.getY() + (point.getY() / 2)), g);
394
                } else {
395
                    drawArc(point, lastp, antantPoint, g);
396
                }
397
            } else {
398
                if (antInter != null) {
399
                    Point2D[] ps1 = UtilFunctions.getPerpendicular(lastp,
400
                            antInter, lastp);
401
                    double a1 = UtilFunctions.getAngle(ps1[0], ps1[1]);
402
                    double a2 = UtilFunctions.getAngle(ps1[1], ps1[0]);
403
                    double angle = UtilFunctions.getAngle(antCenter, lastp);
404
                    Point2D ini1 = null;
405
                    Point2D ini2 = null;
406

    
407
                    if (UtilFunctions.absoluteAngleDistance(angle, a1) > UtilFunctions.absoluteAngleDistance(
408
                                angle, a2)) {
409
                        ini1 = ps1[0];
410
                        ini2 = ps1[1];
411
                    } else {
412
                        ini1 = ps1[1];
413
                        ini2 = ps1[0];
414
                    }
415

    
416
                    Point2D unit = UtilFunctions.getUnitVector(ini1, ini2);
417
                    Point2D correct = new Point2D.Double(lastp.getX() +
418
                            unit.getX(), lastp.getY() + unit.getY());
419
                    drawArc(point, lastp, correct, g);
420
                }
421
            }
422
        }
423
        try {
424
                        if (((FLyrVect)getVLE().getLayer()).getShapeType()==Geometry.TYPES.SURFACE && !list.isEmpty()){
425
                                Handler handler1=((Geometry) list.get(0)).getHandlers(Geometry.SELECTHANDLER)[0];
426
                                GeneralPathX gpx=new GeneralPathX();
427
                                gpx.moveTo(x,y);
428
                                Point2D p1=handler1.getPoint();
429
                                gpx.lineTo(p1.getX(),p1.getY());
430
                                DrawOperationContext doc=new DrawOperationContext();
431
                            doc.setGraphics((Graphics2D)g);
432
                            doc.setViewPort(getCadToolAdapter().getMapControl().getViewPort());
433
                            doc.setSymbol(DefaultCADTool.geometrySelectSymbol);
434
                    try {
435
                            createCurve(gpx).invokeOperation(Draw.CODE,doc);
436
                                } catch (GeometryOperationNotSupportedException e) {
437
                                        e.printStackTrace();
438
                                } catch (GeometryOperationException e) {
439
                                        e.printStackTrace();
440
                                }
441
//                                geomFactory.createPolyline2D(gpx).draw((Graphics2D) g,
442
//                                    getCadToolAdapter().getMapControl().getViewPort(),
443
//                                     DefaultCADTool.geometrySelectSymbol);
444
                        }
445
                        VectorialLayerEdited vle=getVLE();
446
                        if (!vle.getLayer().isVisible())
447
                                return;
448
                        try{
449
                                Image imgSel = vle.getSelectionImage();
450
                                if (imgSel!=null)
451
                                        g.drawImage(imgSel, 0, 0, null);
452
                                Image imgHand = vle.getHandlersImage();
453
                                if (imgHand!=null)
454
                                        g.drawImage(imgHand, 0, 0, null);
455
                        }catch (Exception e) {
456
                        }
457
                } catch (ReadException e) {
458
                        e.printStackTrace();
459
                }
460
    }
461

    
462
    /**
463
     * Dibuja el arco sobre el graphics.
464
     *
465
     * @param point Puntero del rat?n.
466
     * @param lastp ?ltimo punto de la polilinea.
467
     * @param antp Punto antepenultimo.
468
     * @param g Graphics sobre el que se dibuja.
469
     */
470
    private void drawArc(Point2D point, Point2D lastp, Point2D antp, Graphics g) {
471
        if (((point.getY() == lastp.getY()) && (point.getX() < lastp.getX())) ||
472
                ((point.getX() == lastp.getX()) &&
473
                (point.getY() < lastp.getY()))) {
474
        } else {
475
            if (point.getX() == lastp.getX()) {
476
                point = new Point2D.Double(point.getX() + 0.00000001,
477
                        point.getY());
478
            } else if (point.getY() == lastp.getY()) {
479
                point = new Point2D.Double(point.getX(),
480
                        point.getY() + 0.00000001);
481
            }
482

    
483
            if (point.getX() == antp.getX()) {
484
                point = new Point2D.Double(point.getX() + 0.00000001,
485
                        point.getY());
486
            } else if (point.getY() == antp.getY()) {
487
                point = new Point2D.Double(point.getX(),
488
                        point.getY() + 0.00000001);
489
            }
490

    
491
            Point2D[] ps1 = UtilFunctions.getPerpendicular(lastp, antp, lastp);
492
            Point2D mediop = new Point2D.Double((point.getX() + lastp.getX()) / 2,
493
                    (point.getY() + lastp.getY()) / 2);
494
            Point2D[] ps2 = UtilFunctions.getPerpendicular(lastp, point, mediop);
495
            Point2D interp = UtilFunctions.getIntersection(ps1[0], ps1[1],
496
                    ps2[0], ps2[1]);
497

    
498
            double radio = interp.distance(lastp);
499

    
500
            if (UtilFunctions.isLowAngle(antp, lastp, interp, point)) {
501
                radio = -radio;
502
            }
503

    
504
            Point2D centerp = UtilFunctions.getPoint(interp, mediop, radio);
505

    
506
            drawLine((Graphics2D) g, lastp, point,DefaultCADTool.geometrySelectSymbol);
507

    
508
            Geometry ig = createArc(lastp, centerp, point);
509

    
510
            if (ig != null) {
511
                    DrawOperationContext doc=new DrawOperationContext();
512
                            doc.setGraphics((Graphics2D)g);
513
                            doc.setViewPort(getCadToolAdapter().getMapControl().getViewPort());
514
                            doc.setSymbol(DefaultCADTool.geometrySelectSymbol);
515
                    try {
516
                            ig.invokeOperation(Draw.CODE,doc);
517
                                } catch (GeometryOperationNotSupportedException e) {
518
                                        e.printStackTrace();
519
                                } catch (GeometryOperationException e) {
520
                                        e.printStackTrace();
521
                                }
522
//                ig.draw((Graphics2D) g,
523
//                    getCadToolAdapter().getMapControl().getViewPort(),
524
//                      DefaultCADTool.axisReferencesSymbol);
525
            }
526
        }
527
    }
528

    
529
    /**
530
     * Add a diferent option.
531
     *
532
     * @param sel DOCUMENT ME!
533
     * @param s Diferent option.
534
     */
535
    public void addOption(String s) {
536
            /*       PolylineCADToolState actualState = (PolylineCADToolState) _fsm.getPreviousState();
537
        String status = actualState.getName();
538

539
        if (status.equals("Polyline.NextPointOrArcOrClose")) {
540
            if (s.equals("A") || s.equals("a") || s.equals(PluginServices.getText(this,"inter_arc"))) {
541
                //Arco
542
            } else if (s.equals("C") || s.equals("c")) {
543
                GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, 2);
544
                elShape.moveTo(antPoint.getX(), antPoint.getY());
545
                elShape.lineTo(firstPoint.getX(), firstPoint.getY());
546
                list.add(ShapeFactory.createPolyline2D(elShape));
547
                //closeGeometry();
548
            }
549
        } else if (status.equals("Polyline.NextPointOrLineOrClose")) {
550
            if (s.equals("N") || s.equals("n") || s.equals(PluginServices.getText(this,"inter_line"))) {
551
                //L?nea
552
            } else if (s.equals("C") || s.equals("c")) {
553
                GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, 2);
554
                elShape.moveTo(antPoint.getX(), antPoint.getY());
555
                elShape.lineTo(firstPoint.getX(), firstPoint.getY());
556
                list.add(ShapeFactory.createPolyline2D(elShape));
557
                //closeGeometry();
558
            }
559
        }
560
  */
561
    }
562

    
563
    /* (non-Javadoc)
564
     * @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double)
565
     */
566
    public void addValue(double d) {
567
    }
568

    
569
    public void cancel(){
570
        //endGeometry();
571
        list.clear();
572
        clearTemporalCache();
573
        antantPoint=antCenter=antInter=antPoint=firstPoint=null;
574
    }
575

    
576
    public void end() {
577
        /* CADExtension.setCADTool("polyline");
578
        PluginServices.getMainFrame().setSelectedTool("POLYLINE"); */
579
    }
580

    
581
    public String getName() {
582
        return PluginServices.getText(this,"polyline_");
583
    }
584

    
585
    public String toString() {
586
        return "_polyline";
587
    }
588
    public boolean isApplicable(int shapeType) {
589
        switch (shapeType) {
590
        case Geometry.TYPES.POINT:
591
        case Geometry.TYPES.MULTIPOINT:
592
            return false;
593
        }
594
        return true;
595
    }
596

    
597
        public void endTransition(double x, double y, MouseEvent event) {
598
                _fsm.endPoint(x, y, event);
599
        }
600
}