Statistics
| Revision:

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

History | View | Annotate | Download (23 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.GeometryFactory;
54
import org.gvsig.fmap.geom.GeometryLocator;
55
import org.gvsig.fmap.geom.aggregate.BaseMultiPrimitive;
56
import org.gvsig.fmap.geom.aggregate.BaseMultiPrimitive2D;
57
import org.gvsig.fmap.geom.handler.Handler;
58
import org.gvsig.fmap.geom.operation.Draw;
59
import org.gvsig.fmap.geom.operation.DrawOperationContext;
60
import org.gvsig.fmap.geom.operation.GeometryOperationException;
61
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
62
import org.gvsig.fmap.geom.primitive.GeneralPathX;
63
import org.gvsig.fmap.geom.util.Converter;
64
import org.gvsig.fmap.geom.util.UtilFunctions;
65
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
66

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

    
75

    
76
/**
77
 * DOCUMENT ME!
78
 *
79
 * @author Vicente Caballero Navarro
80
 */
81
public class PolylineCADTool extends DefaultCADTool {
82
        private PolylineCADToolContext _fsm;
83
    private Point2D firstPoint;
84
    private Point2D antPoint;
85
    private Point2D antantPoint;
86
    private Point2D antCenter;
87
    private Point2D antInter;
88
    private ArrayList list = new ArrayList();
89
        private boolean close=false;
90
        private GeneralPathX gpx = null;
91
        private GeometryFactory geomFactory = GeometryLocator.getGeometryManager().getGeometryFactory();
92

    
93
    /**
94
     * Crea un nuevo PolylineCADTool.
95
     */
96
    public PolylineCADTool() {
97

    
98
    }
99

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

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

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

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

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

    
204
           if (firstPoint == null) {
205
               firstPoint = new Point2D.Double(x, y);
206
           }
207
                Point2D point = new Point2D.Double(x, y);
208

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

    
221
            if (antPoint != null) {
222
                antantPoint = antPoint;
223
            }
224

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

    
230
            if (antantPoint == null) {
231
                antantPoint = new Point2D.Double(lastp.getX() +
232
                        (point.getX() / 2), lastp.getY() + (point.getY() / 2));
233
            }
234

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

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

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

    
268
                    double radio = interp.distance(lastp);
269

    
270
                    if (UtilFunctions.isLowAngle(antantPoint, lastp, interp,
271
                                point)) {
272
                        radio = -radio;
273
                    }
274

    
275
                    Point2D centerp = UtilFunctions.getPoint(interp, mediop,
276
                            radio);
277
                    antCenter = centerp;
278

    
279
                    Geometry ig = geomFactory.createArc(lastp, centerp, point);
280

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

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

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

    
316
                    double radio = interp.distance(lastp);
317

    
318
                    if (UtilFunctions.isLowAngle(correct, lastp, interp, point)) {
319
                        radio = -radio;
320
                    }
321

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

    
330
                antantPoint = antPoint;
331
                antPoint = point;
332
            }
333
        }
334
    }
335

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

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

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

    
388
            Point2D point = new Point2D.Double(x, y);
389
            Point2D lastp = antPoint;
390

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

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

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

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

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

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

    
501
            double radio = interp.distance(lastp);
502

    
503
            if (UtilFunctions.isLowAngle(antp, lastp, interp, point)) {
504
                radio = -radio;
505
            }
506

    
507
            Point2D centerp = UtilFunctions.getPoint(interp, mediop, radio);
508

    
509
            drawLine((Graphics2D) g, lastp, point,DefaultCADTool.geometrySelectSymbol);
510

    
511
            Geometry ig = geomFactory.createArc(lastp, centerp, point);
512

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

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

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

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

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

    
579
    public void end() {
580
        /* CADExtension.setCADTool("polyline");
581
        PluginServices.getMainFrame().setSelectedTool("POLYLINE"); */
582
    }
583

    
584
    public String getName() {
585
        return PluginServices.getText(this,"polyline_");
586
    }
587

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

    
600
        public void endTransition(double x, double y, MouseEvent event) {
601
                _fsm.endPoint(x, y, event);
602
        }
603
}