Statistics
| Revision:

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

History | View | Annotate | Download (19.2 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.Color;
44
import java.awt.Graphics;
45
import java.awt.Graphics2D;
46
import java.awt.Image;
47
import java.awt.event.InputEvent;
48
import java.awt.event.MouseEvent;
49
import java.awt.geom.Point2D;
50
import java.util.ArrayList;
51

    
52
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
53
import com.iver.andami.PluginServices;
54
import com.iver.andami.messages.NotificationManager;
55
import com.iver.cit.gvsig.CADExtension;
56
import com.iver.cit.gvsig.fmap.MapControl;
57
import com.iver.cit.gvsig.fmap.ViewPort;
58
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
59
import com.iver.cit.gvsig.fmap.core.Handler;
60
import com.iver.cit.gvsig.fmap.core.IFeature;
61
import com.iver.cit.gvsig.fmap.core.IGeometry;
62
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
63
import com.iver.cit.gvsig.fmap.edition.DefaultRowEdited;
64
import com.iver.cit.gvsig.fmap.edition.IRowEdited;
65
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter;
66
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
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.ComplexSelectionCADToolContext;
70
import com.iver.cit.gvsig.gui.cad.tools.smc.ComplexSelectionCADToolContext.ComplexSelectionCADToolState;
71
import com.iver.cit.gvsig.layers.VectorialLayerEdited;
72
import com.iver.cit.gvsig.project.documents.table.gui.Table;
73

    
74
/**
75
 * DOCUMENT ME!
76
 *
77
 * @author Vicente Caballero Navarro
78
 */
79
public class ComplexSelectionCADTool extends SelectionCADTool {
80
        //public final static int tolerance = 4;
81

    
82
        private ComplexSelectionCADToolContext _fsm;
83

    
84
        //private Point2D firstPoint;
85

    
86
        //private Point2D lastPoint;
87

    
88

    
89

    
90
        //private String nextState;
91
// Registros de los que se ha sleccionado alg?n handler.
92
        //private ArrayList rowselectedHandlers=new ArrayList();
93
        //private String type=PluginServices.getText(this,"inside_circle");
94
        //private ArrayList pointsPolygon=new ArrayList();
95
        /**
96
         * Crea un nuevo ComplexSelectionCADTool.
97
         */
98
        public ComplexSelectionCADTool() {
99
                type=PluginServices.getText(this,"inside_circle");
100
        }
101

    
102
        /**
103
         * M?todo de incio, para poner el c?digo de todo lo que se requiera de una
104
         * carga previa a la utilizaci?n de la herramienta.
105
         */
106
        public void init() {
107
                _fsm = new ComplexSelectionCADToolContext(this);
108
                setNextTool("complex_selection");
109

    
110
                setType(PluginServices.getText(this,"inside_circle"));
111
        }
112

    
113
        /**
114
         * Equivale al transition del prototipo pero sin pasarle como par? metro el
115
         * editableFeatureSource que ya estar? creado.
116
         *
117
         * @param selection
118
         *            Bitset con las geometr?as que est?n seleccionadas.
119
         * @param x
120
         *            par?metro x del punto que se pase en esta transici?n.
121
         * @param y
122
         *            par?metro y del punto que se pase en esta transici?n.
123
         */
124
        public void addPoint(double x, double y, InputEvent event) {
125
                if (event!=null && ((MouseEvent)event).getClickCount()==2){
126
                        try {
127
                                pointDoubleClick((MapControl)event.getComponent());
128
                        } catch (ReadDriverException e) {
129
                                NotificationManager.addError(e.getMessage(),e);
130
                        }
131
                        return;
132
                }
133
                ComplexSelectionCADToolState actualState = (ComplexSelectionCADToolState) _fsm
134
                                .getPreviousState();
135
                String status = actualState.getName();
136
                System.out.println("PREVIOUSSTATE =" + status); // + "ESTADO ACTUAL: " +
137
                                                                                                                // _fsm.getState());
138
                VectorialLayerEdited vle = getVLE();
139
                VectorialEditableAdapter vea=vle.getVEA();
140
                ArrayList selectedHandler = vle.getSelectedHandler();
141
                ArrayList selectedRow = vle.getSelectedRow();
142
                System.out.println("STATUS ACTUAL = " + _fsm.getTransition());
143
                if (status.equals("Selection.FirstPoint")) {
144
                        firstPoint=new Point2D.Double(x,y);
145
                        pointsPolygon.add(firstPoint);
146
                } else if (status.equals("Selection.SecondPoint")) {
147
                } else if (status.equals("Selection.WithFeatures")) {
148
                } else if (status.equals("Selection.WithHandlers")) {
149
                        vea.startComplexRow();
150
                        ArrayList selectedRowsAux=new ArrayList();
151
                        for (int i = 0; i < selectedRow.size(); i++) {
152
                                IRowEdited row = (IRowEdited) selectedRow.get(i);
153
                                IFeature feat = (IFeature) row.getLinkedRow().cloneRow();
154
                                IGeometry ig = feat.getGeometry();
155
                                // Movemos los handlers que hemos seleccionado
156
                                // previamente dentro del m?todo select()
157
                                Handler[] handlers=ig.getHandlers(IGeometry.SELECTHANDLER);
158
                                for (int k = 0; k < selectedHandler.size(); k++) {
159
                                        Handler h = (Handler)selectedHandler.get(k);
160
                                        for (int j=0;j<handlers.length;j++) {
161
                                                if (h.getPoint().equals(handlers[j].getPoint()))
162
                                                        handlers[j].set(x,y);
163
                                        }
164
                                }
165

    
166
                                modifyFeature(row.getIndex(), feat);
167
                                selectedRowsAux.add(new DefaultRowEdited(feat,IRowEdited.STATUS_MODIFIED,row.getIndex()));
168
                        }
169
                        firstPoint=new Point2D.Double(x,y);
170
                        vle.setSelectionCache(VectorialLayerEdited.SAVEPREVIOUS, selectedRowsAux);
171
                                String description=PluginServices.getText(this,"move_handlers");
172
                                vea.endComplexRow(description);
173
                }else if (status.equals("Selection.NextPointPolygon")) {
174
                        pointsPolygon.add(new Point2D.Double(x,y));
175
                }
176
        }
177

    
178
        /**
179
         * Receives second point
180
         * @param x
181
         * @param y
182
         * @return numFeatures selected
183
         */
184
        public int selectWithSecondPointOutRectangle(double x, double y, InputEvent event) {
185
                Point2D lastPoint=new Point2D.Double(x,y);
186
                GeneralPathX gpx=new GeneralPathX();
187
                gpx.moveTo(firstPoint.getX(),firstPoint.getY());
188
                gpx.lineTo(lastPoint.getX(),firstPoint.getY());
189
                gpx.lineTo(lastPoint.getX(),lastPoint.getY());
190
                gpx.lineTo(firstPoint.getX(),lastPoint.getY());
191
                gpx.closePath();
192
                IGeometry rectangle=ShapeFactory.createPolygon2D(gpx);
193
                return selectWithPolygon(rectangle);
194
        }
195
        /**
196
         * Receives second point
197
         * @param x
198
         * @param y
199
         * @return numFeatures selected
200
         */
201
        public int selectWithCircle(double x, double y, InputEvent event) {
202
                IGeometry circle=ShapeFactory.createCircle(firstPoint,new Point2D.Double(x,y));
203
                return selectWithPolygon(circle);
204
        }
205
        public int selectWithPolygon(IGeometry polygon) {
206
                VectorialLayerEdited vle = getVLE();
207
                PluginServices.getMDIManager().setWaitCursor();
208

    
209
                if (getType().equals(PluginServices.getText(this,"inside_circle")) || getType().equals(PluginServices.getText(this,"inside_polygon"))) {
210
                        vle.selectInsidePolygon(polygon);
211
                } else if (getType().equals(PluginServices.getText(this,"cross_circle")) || getType().equals(PluginServices.getText(this,"cross_polygon"))) {
212
                        vle.selectCrossPolygon(polygon);
213
                } else if (getType().equals(PluginServices.getText(this,"out_circle")) || getType().equals(PluginServices.getText(this,"out_polygon")) || getType().equals(PluginServices.getText(this,"out_rectangle"))) {
214
                        vle.selectOutPolygon(polygon);
215
                }
216
                ArrayList selectedRow = vle.getSelectedRow();
217
                PluginServices.getMDIManager().restoreCursor();
218
                if (selectedRow.size() > 0) {
219
                        nextState = "Selection.WithSelectedFeatures";
220
                        end();
221
                } else
222
                        nextState = "Selection.FirstPoint";
223
                return selectedRow.size();
224
        }
225

    
226
        /**
227
         * M?todo para dibujar la lo necesario para el estado en el que nos
228
         * encontremos.
229
         *
230
         * @param g
231
         *            Graphics sobre el que dibujar.
232
         * @param selectedGeometries
233
         *            BitSet con las geometr?as seleccionadas.
234
         * @param x
235
         *            par?metro x del punto que se pase para dibujar.
236
         * @param y
237
         *            par?metro x del punto que se pase para dibujar.
238
         */
239
        public void drawOperation(Graphics g, double x, double y) {
240
                ComplexSelectionCADToolState actualState = _fsm.getState();
241
                String status = actualState.getName();
242
                VectorialLayerEdited vle = getVLE();
243
                ArrayList selectedHandler = vle.getSelectedHandler();
244
                ViewPort vp=vle.getLayer().getMapContext().getViewPort();
245
                if (status.equals("Selection.SecondPoint") || status.equals("Selection.SecondPointOutRectangle")) {
246
                        // Dibuja el rect?ngulo de selecci?n
247
                        GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD,
248
                                        4);
249
                        elShape.moveTo(firstPoint.getX(), firstPoint.getY());
250
                        elShape.lineTo(x, firstPoint.getY());
251
                        elShape.lineTo(x, y);
252
                        elShape.lineTo(firstPoint.getX(), y);
253
                        elShape.lineTo(firstPoint.getX(), firstPoint.getY());
254
                        ShapeFactory.createPolyline2D(elShape).draw((Graphics2D) g,
255
                                        vp,
256
                                        DefaultCADTool.geometrySelectSymbol);
257
                        Image img = vle.getSelectionImage();
258
                g.drawImage(img, 0, 0, null);
259
                return;
260
                }if (status.equals("Selection.SecondPointCircle")) {
261
                        IGeometry circle=ShapeFactory.createCircle(firstPoint,new Point2D.Double(x,y));
262
                        GeneralPathX gpx=new GeneralPathX();
263
                        gpx.append(circle.getInternalShape(),true);
264
                        IGeometry circleSel=ShapeFactory.createPolyline2D(gpx);
265
                        // Dibuja el c?rculo de selecci?n
266
                        circleSel.draw((Graphics2D) g,
267
                                        vp,
268
                                        DefaultCADTool.geometrySelectSymbol);
269
                        Image img = vle.getSelectionImage();
270
                g.drawImage(img, 0, 0, null);
271
                return;
272
                }else if (status.equals("Selection.NextPointPolygon")) {
273
                        // Dibuja el pol?gono de selecci?n
274
                        IGeometry polygon=getGeometryPolygon(new Point2D.Double(x,y));
275
                        polygon.draw((Graphics2D) g,
276
                                        vp,
277
                                        DefaultCADTool.geometrySelectSymbol);
278
                        Image img = vle.getSelectionImage();
279
                g.drawImage(img, 0, 0, null);
280
                return;
281
                }else if (status.equals("Selection.WithHandlers")) {
282
                        // Movemos los handlers que hemos seleccionado
283
                        // previamente dentro del m?todo select()
284
                        double xPrev=0;
285
                        double yPrev=0;
286
                        for (int k = 0; k < selectedHandler.size(); k++) {
287
                                Handler h = (Handler)selectedHandler.get(k);
288
                                xPrev=h.getPoint().getX();
289
                                yPrev=h.getPoint().getY();
290
                                h.set(x, y);
291
                        }
292
                        // Y una vez movidos los v?rtices (handles)
293
                        // redibujamos la nueva geometr?a.
294
                        for (int i = 0; i < rowselectedHandlers.size(); i++) {
295
                                IRowEdited rowEd = (IRowEdited) rowselectedHandlers.get(i);
296
                                IGeometry geom = ((IFeature) rowEd.getLinkedRow())
297
                                                .getGeometry().cloneGeometry();
298
                                g.setColor(Color.gray);
299
                                geom.draw((Graphics2D) g, vp, DefaultCADTool.axisReferencesSymbol);
300
                        }
301
                        for (int k = 0; k < selectedHandler.size(); k++) {
302
                                Handler h = (Handler)selectedHandler.get(k);
303
                                h.set(xPrev, yPrev);
304
                        }
305
                        return;
306
                }else{
307
                        if (!vle.getLayer().isVisible())
308
                                return;
309
                        try{
310
                        Image imgSel = vle.getSelectionImage();
311
                if (imgSel!=null)
312
                        g.drawImage(imgSel, 0, 0, null);
313
                Image imgHand = vle.getHandlersImage();
314
                if (imgHand!=null)
315
                        g.drawImage(imgHand, 0, 0, null);
316
                        }catch (Exception e) {
317
                        }
318
                }
319
        }
320

    
321
        /**
322
         * Add a diferent option.
323
         *
324
         * @param sel
325
         *            DOCUMENT ME!
326
         * @param s
327
         *            Diferent option.
328
         */
329
        public void addOption(String s) {
330
                ComplexSelectionCADToolState actualState = (ComplexSelectionCADToolState) _fsm
331
                                .getPreviousState();
332
                String status = actualState.getName();
333
                System.out.println("PREVIOUSSTATE =" + status); // + "ESTADO ACTUAL: " +
334
                // _fsm.getState());
335
                System.out.println("STATUS ACTUAL = " + _fsm.getTransition());
336
                if (s.equals(PluginServices.getText(this,"cancel"))){
337
                        init();
338
                        return;
339
                }else if (s.equals(PluginServices.getText(this,"select_all"))){
340
                        selectAll();
341
                        init();
342
                        return;
343
                }
344
                if (status.equals("Selection.FirstPoint")) {
345
                        setType(s);
346
                        return;
347
                }else if (status.equals("Selection.NextPointPolygon")){
348
                        if (s.equals(PluginServices.getText(this,"end_polygon")) || s.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.end"))) {
349
                        IGeometry polygon=getGeometryPolygon(null);
350
                        GeneralPathX gpx=new GeneralPathX();
351
                        gpx.append(polygon,true);
352
                        if (gpx.isCCW()) {
353
                                gpx.flip();
354
                                polygon=ShapeFactory.createPolygon2D(gpx);
355
                        }
356
                        selectWithPolygon(polygon);
357
                        pointsPolygon.clear();
358
                        setType(PluginServices.getText(this,"inside_circle"));
359
                        return;
360
                        }
361
                }
362
                init();
363
        }
364
        private int selectAll() {
365
                VectorialLayerEdited vle = getVLE();
366
                PluginServices.getMDIManager().setWaitCursor();
367
                vle.selectAll();
368
                ArrayList selectedRow = vle.getSelectedRow();
369
                PluginServices.getMDIManager().restoreCursor();
370
                if (selectedRow.size() > 0) {
371
                        nextState = "Selection.WithSelectedFeatures";
372
                } else
373
                        nextState = "Selection.FirstPoint";
374
                end();
375
                return selectedRow.size();
376
        }
377

    
378
        private IGeometry getGeometryPolygon(Point2D p) {
379
                Point2D[] points = (Point2D[]) pointsPolygon.toArray(new Point2D[0]);
380
                GeneralPathX gpx = new GeneralPathX();
381
                for (int i = 0; i < points.length; i++) {
382
                        if (i == 0) {
383
                                gpx.moveTo(points[i].getX(), points[i].getY());
384
                        } else {
385
                                gpx.lineTo(points[i].getX(), points[i].getY());
386
                        }
387
                }
388
                if (p!=null){
389
                        gpx.lineTo(p.getX(),p.getY());
390
                        gpx.closePath();
391
                        IGeometry polyline = ShapeFactory.createPolyline2D(gpx);
392
                        return polyline;
393
                }
394
                gpx.closePath();
395
                IGeometry polygon = ShapeFactory.createPolygon2D(gpx);
396
                return polygon;
397
        }
398

    
399
        /*
400
         * (non-Javadoc)
401
         *
402
         * @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double)
403
         */
404
        public void addValue(double d) {
405
        }
406

    
407
        public void end() {
408
                if (!getNextTool().equals("complex_selection"))
409
                        CADExtension.setCADTool(getNextTool(),false);
410
        }
411

    
412
        public String getName() {
413
                return PluginServices.getText(this,"complex_selection_");
414
        }
415

    
416
        public boolean selectFeatures(double x, double y, InputEvent event) {
417
                ComplexSelectionCADToolState actualState =_fsm
418
                                .getState();
419

    
420
                String status = actualState.getName();
421
                VectorialLayerEdited vle = getVLE();
422

    
423

    
424
                if ((status.equals("Selection.FirstPoint"))
425
                                || (status.equals("Selection.WithSelectedFeatures"))) {
426
                        PluginServices.getMDIManager().setWaitCursor();
427
                        firstPoint = new Point2D.Double(x, y);
428
                        vle.selectWithPoint(x,y,multipleSelection);
429
                        PluginServices.getMDIManager().restoreCursor();
430
                }
431
                ArrayList selectedRow = vle.getSelectedRow();
432
                if (selectedRow.size() > 0) {
433
                        nextState = "Selection.WithSelectedFeatures";
434
                        return true;
435
                } else {
436
                        {
437
                                nextState = "Selection.SecondPoint";
438
                                return true;
439
                        }
440
                }
441
        }
442

    
443
        public int selectHandlers(double x, double y, InputEvent event) {
444
                Point2D auxPoint = new Point2D.Double(x, y);
445

    
446
                VectorialLayerEdited vle = getVLE();
447
                ArrayList selectedHandler = vle.getSelectedHandler();
448
                ArrayList selectedRow = vle.getSelectedRow();
449
                System.out.println("DENTRO DE selectHandlers. selectedRow.size= "
450
                                + selectedRow.size());
451
                selectedHandler.clear();
452

    
453
                // Se comprueba si se pincha en una gemometr?a
454
                PluginServices.getMDIManager().setWaitCursor();
455

    
456
                double tam = getCadToolAdapter().getMapControl().getViewPort()
457
                                .toMapDistance(tolerance);
458

    
459
                Handler[] handlers = null;
460
                rowselectedHandlers.clear();
461
                for (int i = 0; i < selectedRow.size(); i++) {
462
                        IRowEdited rowEd = (IRowEdited) selectedRow.get(i);
463

    
464
                        IFeature fea = (IFeature) rowEd.getLinkedRow();
465
                        handlers = fea.getGeometry().getHandlers(IGeometry.SELECTHANDLER);
466
                        // y miramos los handlers de cada entidad seleccionada
467
                        double min = tam;
468
                        // int hSel = -1;
469

    
470
                        for (int j = 0; j < handlers.length; j++) {
471
                                Point2D handlerPoint = handlers[j].getPoint();
472
                                double distance = auxPoint.distance(handlerPoint);
473
                                if (distance <= min) {
474
                                        min = distance;
475
                                        // hSel = j;
476
                                        selectedHandler.add(handlers[j]);
477
                                        rowselectedHandlers.add(rowEd);
478
                                }
479
                        }
480
                }
481
                PluginServices.getMDIManager().restoreCursor();
482

    
483
                int numHandlesSelected = selectedHandler.size();
484

    
485
                /*
486
                 * if (numHandlesSelected == 0) selectFeatures(x,y);
487
                 */
488

    
489
                return numHandlesSelected;
490
        }
491

    
492
        public String getType() {
493
                return type;
494
        }
495

    
496
        public void setType(String type) {
497
                if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle"))){
498
                        this.type=PluginServices.getText(this,"out_rectangle");
499
                }else if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon"))){
500
                        this.type=PluginServices.getText(this,"inside_polygon");
501
                }else if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon"))){
502
                        this.type=PluginServices.getText(this,"cross_polygon");
503
                }else if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon"))){
504
                        this.type=PluginServices.getText(this,"out_polygon");
505
                }else if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.introcircle"))){
506
                        this.type=PluginServices.getText(this,"inside_circle");
507
                }else if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle"))){
508
                        this.type=PluginServices.getText(this,"cross_circle");
509
                }else if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.outcircle"))){
510
                        this.type=PluginServices.getText(this,"out_circle");
511
                }else if (type.equals(PluginServices.getText(this,"select_all"))){
512
                        selectAll();
513
                        init();
514
                }else{
515
                        this.type = type;
516
                }
517
                pointsPolygon.clear();
518
        }
519
        /*
520
         * (non-Javadoc)
521
         *
522
         * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet,
523
         *      double, double)
524
         */
525
        public void transition(double x, double y, InputEvent event) {
526
                System.out.println("TRANSICION DESDE ESTADO " + _fsm.getState()
527
                                + " x= " + x + " y=" + y);
528
                try{
529
                _fsm.addPoint(x, y, event);
530
                }catch (Exception e) {
531
                        init();
532
                }
533
                System.out.println("ESTADO ACTUAL: " + getStatus());
534

    
535
                FLyrVect lv=(FLyrVect)((VectorialLayerEdited)CADExtension.getEditionManager().getActiveLayerEdited()).getLayer();
536
                com.iver.andami.ui.mdiManager.IWindow[] views = PluginServices.getMDIManager().getAllWindows();
537

    
538
                for (int i=0 ; i<views.length ; i++){
539
                        if (views[i] instanceof Table){
540
                                Table table=(Table)views[i];
541
                                if (table.getModel().getAssociatedTable()!=null && table.getModel().getAssociatedTable().equals(lv))
542
                                        table.updateSelection();
543
                        }
544
                }
545
        }
546
        public String getStatus() {
547
                try {
548
                        ComplexSelectionCADToolState actualState = (ComplexSelectionCADToolState) _fsm
549
                                        .getPreviousState();
550
                        String status = actualState.getName();
551

    
552
                        return status;
553
                } catch (NullPointerException e) {
554
                        return "Selection.FirstPoint";
555
                }
556
        }
557
        /*
558
         * (non-Javadoc)
559
         *
560
         * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet,
561
         *      java.lang.String)
562
         */
563
        public void transition(String s) throws CommandException {
564
                if (!super.changeCommand(s)){
565

    
566
                        _fsm.addOption(s);
567

    
568
            }
569
        }
570
        /*
571
         * (non-Javadoc)
572
         *
573
         * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet,
574
         *      double)
575
         */
576
        public void transition(double d) {
577
                _fsm.addValue(d);
578
        }
579

    
580
        public String toString() {
581
                return "_complex_selection";
582
        }
583
        public String getNextState() {
584
                return nextState;
585
        }
586

    
587
}