Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extEditing / src / org / gvsig / editing / gui / cad / tools / SelectionCADTool.java @ 29616

History | View | Annotate | Download (19.1 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 org.gvsig.editing.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.geom.Point2D;
49
import java.util.ArrayList;
50

    
51
import org.gvsig.andami.PluginServices;
52
import org.gvsig.andami.messages.NotificationManager;
53
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel;
54
import org.gvsig.editing.CADExtension;
55
import org.gvsig.editing.gui.cad.DefaultCADTool;
56
import org.gvsig.editing.gui.cad.exception.CommandException;
57
import org.gvsig.editing.gui.cad.tools.smc.SelectionCADToolContext;
58
import org.gvsig.editing.gui.cad.tools.smc.SelectionCADToolContext.SelectionCADToolState;
59
import org.gvsig.editing.layers.VectorialLayerEdited;
60
import org.gvsig.fmap.dal.exception.DataException;
61
import org.gvsig.fmap.dal.exception.ReadException;
62
import org.gvsig.fmap.dal.feature.DisposableIterator;
63
import org.gvsig.fmap.dal.feature.EditableFeature;
64
import org.gvsig.fmap.dal.feature.Feature;
65
import org.gvsig.fmap.dal.feature.FeatureSet;
66
import org.gvsig.fmap.dal.feature.FeatureStore;
67
import org.gvsig.fmap.dal.feature.exception.NeedEditingModeException;
68
import org.gvsig.fmap.geom.Geometry;
69
import org.gvsig.fmap.geom.handler.Handler;
70
import org.gvsig.fmap.geom.operation.Draw;
71
import org.gvsig.fmap.geom.operation.DrawOperationContext;
72
import org.gvsig.fmap.geom.operation.GeometryOperationException;
73
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
74
import org.gvsig.fmap.geom.primitive.GeneralPathX;
75
import org.gvsig.fmap.mapcontext.MapContext;
76
import org.gvsig.fmap.mapcontext.ViewPort;
77
import org.gvsig.fmap.mapcontext.layers.FLayer;
78
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
79
import org.gvsig.fmap.mapcontrol.MapControl;
80

    
81

    
82
/**
83
 * DOCUMENT ME!
84
 *
85
 * @author Vicente Caballero Navarro
86
 */
87
public class SelectionCADTool extends DefaultCADTool {
88
//        public static int tolerance = 4;
89

    
90
        protected SelectionCADToolContext _fsm;
91

    
92
        protected Point2D firstPoint;
93

    
94
        protected String nextState;
95
// Registros de los que se ha seleccionado alg?n handler.
96
        protected ArrayList rowselectedHandlers=new ArrayList();
97
        protected String type=PluginServices.getText(this,"simple");
98
//        protected ArrayList pointsPolygon=new ArrayList();
99

    
100
        protected boolean multipleSelection=false;
101
        /**
102
         * Crea un nuevo SelectionCADTool.
103
         */
104
        public SelectionCADTool() {
105
        }
106
        /**
107
         * M?todo de incio, para poner el c?digo de todo lo que se requiera de una
108
         * carga previa a la utilizaci?n de la herramienta.
109
         */
110
        public void init() {
111
                _fsm = new SelectionCADToolContext(this);
112
                setNextTool("selection");
113
                setType(PluginServices.getText(this,"simple"));
114
        }
115

    
116
        /*
117
         * (non-Javadoc)
118
         *
119
         * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet,
120
         *      double, double)
121
         */
122
        public void transition(double x, double y, InputEvent event) {
123
                System.out.println("TRANSICION DESDE ESTADO " + _fsm.getState()
124
                                + " x= " + x + " y=" + y);
125
                try{
126
                _fsm.addPoint(x, y, event);
127
                }catch (Exception e) {
128
                        init();
129
                        PluginServices.getMDIManager().restoreCursor();
130
                }
131
                System.out.println("ESTADO ACTUAL: " + getStatus());
132

    
133
                // ESTO LO QUITO POR AHORA, PERO PUEDE QUE LO NECESITEMOS VOLVER A PONER.
134
                // Lo he quitado porque cuando seleccionas algo con CAD, molesta que
135
                // te hagan un redibujado.
136
                FLyrVect lv=(FLyrVect)((VectorialLayerEdited)CADExtension.getEditionManager().getActiveLayerEdited()).getLayer();
137
                //lv.getSource().getRecordset().getSelectionSupport().fireSelectionEvents();
138
                org.gvsig.andami.ui.mdiManager.IWindow[] views = PluginServices.getMDIManager().getAllWindows();
139

    
140
                for (int i=0 ; i<views.length ; i++){
141
                        if (views[i] instanceof FeatureTableDocumentPanel){
142
                                FeatureTableDocumentPanel table=(FeatureTableDocumentPanel)views[i];
143
                                if (table.getModel().getAssociatedLayer()!=null && table.getModel().getAssociatedLayer().equals(lv)) {
144
                                        table.updateSelection();
145
                                }
146
                        }
147
                }
148
        }
149

    
150
        /*
151
         * (non-Javadoc)
152
         *
153
         * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet,
154
         *      double)
155
         */
156
        public void transition(double d) {
157
                _fsm.addValue(d);
158
        }
159

    
160
        /*
161
         * (non-Javadoc)
162
         *
163
         * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet,
164
         *      java.lang.String)
165
         */
166
        public void transition(String s) throws CommandException {
167
                if (!super.changeCommand(s)){
168
                        _fsm.addOption(s);
169
            }
170
        }
171

    
172
        public String getNextState() {
173
                return nextState;
174
        }
175

    
176
        protected void pointDoubleClick(MapContext map) throws ReadException {
177
                FLayer[] actives = map
178
           .getLayers().getActives();
179
//        for (int i=0; i < actives.length; i++){
180
//            if (actives[i] instanceof FLyrAnnotation && actives[i].isEditing()) {
181
//                FLyrAnnotation lyrAnnotation = (FLyrAnnotation) actives[i];
182
//                       lyrAnnotation.setSelectedEditing();
183
//                       lyrAnnotation.setInEdition(lyrAnnotation.getRecordset().getSelection().nextSetBit(0));
184
//                       FLabel fl=lyrAnnotation.getLabel(lyrAnnotation.getInEdition());
185
//                       if (fl!=null){
186
//                               View vista=(View)PluginServices.getMDIManager().getActiveWindow();
187
//                                       TextFieldEdit tfe=new TextFieldEdit(lyrAnnotation);
188
//                                tfe.show(vista.getMapControl().getViewPort().fromMapPoint(fl.getOrig()),vista.getMapControl());
189
//                               }
190
//            }
191
//        }
192
}
193
        /**
194
         * Equivale al transition del prototipo pero sin pasarle como par? metro el
195
         * editableFeatureSource que ya estar? creado.
196
         *
197
         * @param selection
198
         *            Bitset con las geometr?as que est?n seleccionadas.
199
         * @param x
200
         *            par?metro x del punto que se pase en esta transici?n.
201
         * @param y
202
         *            par?metro y del punto que se pase en esta transici?n.
203
         */
204
        public void addPoint(double x, double y, InputEvent event) {
205
//                if (event!=null && ((MouseEvent)event).getClickCount()==2){
206
//                        try {
207
//                                pointDoubleClick((MapControl)event.getComponent());
208
//                        } catch (ReadException e) {
209
//                                NotificationManager.addError(e.getMessage(),e);
210
//                        }
211
//                        return;
212
//                }
213
                SelectionCADToolState actualState = (SelectionCADToolState) _fsm
214
                .getPreviousState();
215
                String status = actualState.getName();
216
                System.out.println("PREVIOUSSTATE =" + status); // + "ESTADO ACTUAL: " +
217
                // _fsm.getState());
218
                VectorialLayerEdited vle = getVLE();
219
                FeatureStore featureStore=null;
220
                DisposableIterator iterator = null;
221
                try {
222
                        featureStore = vle.getFeatureStore();
223

    
224
                        ArrayList selectedHandler = vle.getSelectedHandler();
225
                        FeatureSet selection = (FeatureSet) featureStore.getSelection();// vle.getSelectedRow();
226
                        System.out.println("STATUS ACTUAL = " + _fsm.getTransition());
227
                        if (status.equals("Selection.FirstPoint")) {
228
                                firstPoint = new Point2D.Double(x, y);
229
                                // pointsPolygon.add(firstPoint);
230
                        } else if (status.equals("Selection.SecondPoint")) {
231
                        } else if (status.equals("Selection.WithFeatures")) {
232
                        } else if (status.equals("Selection.WithHandlers")) {
233
                                String description = PluginServices.getText(this,
234
                                "move_handlers");
235
                                featureStore.beginEditingGroup(description);
236
                                try {
237
                                        iterator = selection.iterator();
238
                                        while (iterator.hasNext()) {
239
                                                Feature feature = (Feature) iterator.next();
240
                                                // }
241
                                                // for (int i = 0; i < selectedRow.size(); i++) {
242
                                                // IRowEdited row = (IRowEdited) selectedRow.get(i);
243
                                                // IFeature feat = (IFeature)
244
                                                // row.getLinkedRow().cloneRow();
245
                                                Geometry ig = feature.getDefaultGeometry()
246
                                                                .cloneGeometry();
247
                                                // if (vea instanceof AnnotationEditableAdapter) {
248
                                                // // Movemos la geometr?a
249
                                                // UtilFunctions.moveGeom(ig, x -
250
                                                // firstPoint.getX(), y - firstPoint.getY());
251
                                                // }else {
252
                                                // Movemos los handlers que hemos seleccionado
253
                                                // previamente dentro del m?todo select()
254
                                                Handler[] handlers = ig
255
                                                                .getHandlers(Geometry.SELECTHANDLER);
256
                                                for (int k = 0; k < selectedHandler.size(); k++) {
257
                                                        Handler h = (Handler) selectedHandler.get(k);
258
                                                        for (int j = 0; j < handlers.length; j++) {
259
                                                                if (h.getPoint().equals(handlers[j].getPoint())) {
260
                                                                        handlers[j].set(x, y);
261
                                                                }
262
                                                        }
263
                                                }
264
                                                // }
265
                                                EditableFeature eFeature = feature.getEditable();
266
                                                eFeature.setGeometry(featureStore
267
                                                                .getDefaultFeatureType()
268
                                                                .getDefaultGeometryAttributeName(), ig);
269
                                                featureStore.update(eFeature);
270
                                                // modifyFeature(feature, feature);
271
                                                // selectedRowsAux.add(new
272
                                                // DefaultRowEdited(feat,IRowEdited.STATUS_MODIFIED,row.getIndex()));
273
                                        }
274
                                        firstPoint = new Point2D.Double(x, y);
275
                                        // vle.setSelectionCache(VectorialLayerEdited.SAVEPREVIOUS,
276
                                        // selectedRowsAux);
277
                                        // clearSelection();
278
                                        // selectedRow.addAll(selectedRowsAux);
279

    
280
                                } finally {
281
                                        featureStore.endEditingGroup();
282
                                }
283
                        }
284
                } catch (DataException e) {
285
                        // TODO Auto-generated catch block
286
                        e.printStackTrace();
287
                } finally {
288
                        if (iterator != null) {
289
                                iterator.dispose();
290
                        }
291
                }
292
        }
293

    
294
        /**
295
         * Receives second point
296
         * @param x
297
         * @param y
298
         * @return numFeatures selected
299
         */
300
        public long selectWithSecondPoint(double x, double y, InputEvent event) {
301
                VectorialLayerEdited vle = getVLE();
302
                PluginServices.getMDIManager().setWaitCursor();
303
                vle.selectWithSecondPoint(x,y);
304
                FeatureSet selection=null;
305
                try {
306
                        selection = (FeatureSet)vle.getFeatureStore().getSelection();
307
                        PluginServices.getMDIManager().restoreCursor();
308
                        long countSel=selection.getSize();
309
                        if (countSel > 0) {
310
                                nextState = "Selection.WithSelectedFeatures";
311
                        } else {
312
                                nextState = "Selection.FirstPoint";
313
                        }
314
                        return countSel;
315
                } catch (ReadException e) {
316
                        e.printStackTrace();
317
                        return 0;
318
                } catch (DataException e) {
319
                        e.printStackTrace();
320
                        return 0;
321
                }
322
        }
323

    
324
        /**
325
         * M?todo para dibujar la lo necesario para el estado en el que nos
326
         * encontremos.
327
         *
328
         * @param g
329
         *            Graphics sobre el que dibujar.
330
         * @param selectedGeometries
331
         *            BitSet con las geometr?as seleccionadas.
332
         * @param x
333
         *            par?metro x del punto que se pase para dibujar.
334
         * @param y
335
         *            par?metro x del punto que se pase para dibujar.
336
         */
337
        public void drawOperation(Graphics g, double x, double y) {
338
                SelectionCADToolState actualState = _fsm.getState();
339
                String status = actualState.getName();
340
                VectorialLayerEdited vle = getVLE();
341
                if (vle == null) {
342
                        return;
343
                }
344
                ArrayList selectedHandler = vle.getSelectedHandler();
345
                ViewPort vp=vle.getLayer().getMapContext().getViewPort();
346
                if (status.equals("Selection.SecondPoint")) {
347
                        // Dibuja el rect?ngulo de selecci?n
348
                        GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD,
349
                                        4);
350
                        elShape.moveTo(firstPoint.getX(), firstPoint.getY());
351
                        elShape.lineTo(x, firstPoint.getY());
352
                        elShape.lineTo(x, y);
353
                        elShape.lineTo(firstPoint.getX(), y);
354
                        elShape.lineTo(firstPoint.getX(), firstPoint.getY());
355
                        DrawOperationContext doc=new DrawOperationContext();
356
                        doc.setGraphics((Graphics2D)g);
357
                        doc.setViewPort(vp);
358
                        doc.setSymbol(DefaultCADTool.geometrySelectSymbol);
359
                try {
360
                        createCurve(elShape).cloneGeometry().invokeOperation(Draw.CODE,doc);
361
                        } catch (GeometryOperationNotSupportedException e) {
362
                                e.printStackTrace();
363
                        } catch (GeometryOperationException e) {
364
                                e.printStackTrace();
365
                        }
366
//                        geomFactory.createPolyline2D(elShape).draw((Graphics2D) g,
367
//                                        vp,
368
//                                        DefaultCADTool.geometrySelectSymbol);
369
                        Image img = vle.getSelectionImage();
370
                g.drawImage(img, 0, 0, null);
371
                return;
372
                }else if (status.equals("Selection.WithHandlers")) {
373
                        // Movemos los handlers que hemos seleccionado
374
                        // previamente dentro del m?todo select()
375
                        double xPrev=0;
376
                        double yPrev=0;
377
                        for (int k = 0; k < selectedHandler.size(); k++) {
378
                                Handler h = (Handler)selectedHandler.get(k);
379
                                xPrev=h.getPoint().getX();
380
                                yPrev=h.getPoint().getY();
381
                                h.set(x, y);
382
                        }
383
                        // Y una vez movidos los v?rtices (handles)
384
                        // redibujamos la nueva geometr?a.
385
                        for (int i = 0; i < rowselectedHandlers.size(); i++) {
386
                                Feature feature=(Feature)rowselectedHandlers.get(i);
387
//                                IRowEdited rowEd = (IRowEdited) rowselectedHandlers.get(i);
388
//                                IGeometry geom = ((IFeature) rowEd.getLinkedRow())
389
//                                                .getGeometry().cloneGeometry();
390
                                Geometry geom=(feature.getDefaultGeometry()).cloneGeometry();
391
                                g.setColor(Color.gray);
392
                                DrawOperationContext doc=new DrawOperationContext();
393
                            doc.setGraphics((Graphics2D)g);
394
                            doc.setViewPort(vp);
395
                            doc.setSymbol(DefaultCADTool.axisReferencesSymbol);
396
                    try {
397
                                        geom.invokeOperation(Draw.CODE,doc);
398
                                } catch (GeometryOperationNotSupportedException e) {
399
                                        e.printStackTrace();
400
                                } catch (GeometryOperationException e) {
401
                                        e.printStackTrace();
402
                                }
403
                        }
404
                        for (int k = 0; k < selectedHandler.size(); k++) {
405
                                Handler h = (Handler)selectedHandler.get(k);
406
                                h.set(xPrev, yPrev);
407
                        }
408
                        return;
409
                }else{
410
                        if (!vle.getLayer().isVisible()) {
411
                                return;
412
                        }
413
                        try{
414
                        Image imgSel = vle.getSelectionImage();
415
                if (imgSel!=null) {
416
                                g.drawImage(imgSel, 0, 0, null);
417
                        }
418
                Image imgHand = vle.getHandlersImage();
419
                if (imgHand!=null) {
420
                                g.drawImage(imgHand, 0, 0, null);
421
                        }
422
                        }catch (Exception e) {
423
                        }
424
                }
425
        }
426

    
427
        /**
428
         * Add a diferent option.
429
         *
430
         * @param sel
431
         *            DOCUMENT ME!
432
         * @param s
433
         *            Diferent option.
434
         */
435
        public void addOption(String s) {
436
                SelectionCADToolState actualState = (SelectionCADToolState) _fsm
437
                                .getPreviousState();
438
                String status = actualState.getName();
439
                System.out.println("PREVIOUSSTATE =" + status); // + "ESTADO ACTUAL: " +
440
                // _fsm.getState());
441
                System.out.println("STATUS ACTUAL = " + _fsm.getTransition());
442
                if (s.equals(PluginServices.getText(this,"cancel"))){
443
                        init();
444
                        return;
445
                }
446
                if (status.equals("Selection.FirstPoint")) {
447
                        setType(s);
448
                        return;
449
                }
450
                init();
451
        }
452

    
453

    
454

    
455

    
456
        /*
457
         * (non-Javadoc)
458
         *
459
         * @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double)
460
         */
461
        public void addValue(double d) {
462
        }
463

    
464
        public String getStatus() {
465
                try {
466
                        SelectionCADToolState actualState = (SelectionCADToolState) _fsm
467
                                        .getPreviousState();
468
                        String status = actualState.getName();
469

    
470
                        return status;
471
                } catch (NullPointerException e) {
472
                        return "Selection.FirstPoint";
473
                }
474
        }
475

    
476

    
477

    
478
        public void end() {
479
                if (!getNextTool().equals("selection")) {
480
                        CADExtension.setCADTool(getNextTool(),false);
481
                }
482
        }
483

    
484
        public String getName() {
485
                return PluginServices.getText(this,"selection_");
486
        }
487

    
488
        public boolean selectFeatures(double x, double y, InputEvent event) {
489
                SelectionCADToolState actualState = _fsm
490
                                .getState();
491

    
492
                String status = actualState.getName();
493
                VectorialLayerEdited vle = getVLE();
494
                multipleSelection=event.isControlDown();
495

    
496
                if ((status.equals("Selection.FirstPoint"))
497
                                || (status.equals("Selection.WithSelectedFeatures"))) {
498
                        PluginServices.getMDIManager().setWaitCursor();
499
                        firstPoint = new Point2D.Double(x, y);
500
                        try {
501
                                vle.getFeatureStore().beginEditingGroup(getName());
502
                                vle.selectWithPoint(x,y,multipleSelection);
503
                                vle.getFeatureStore().endEditingGroup();
504
                        } catch (NeedEditingModeException e) {
505
                                NotificationManager.showMessageError(getName(), e);
506
                        } catch (ReadException e) {
507
                                NotificationManager.showMessageError(getName(), e);
508
                        }
509
                        PluginServices.getMDIManager().restoreCursor();
510
                }
511
                FeatureSet selection=null;
512
                try {
513
                        selection = (FeatureSet)vle.getFeatureStore().getSelection();
514

    
515
//                ArrayList selectedRow = vle.getSelectedRow();
516
                long countSel=selection.getSize();
517
                if (countSel > 0) {
518
                        nextState = "Selection.WithSelectedFeatures";
519
                        return true;
520
                } else {
521
                        {
522
                                nextState = "Selection.SecondPoint";
523
                                return true;
524
                        }
525
                }
526
                } catch (ReadException e) {
527
                        e.printStackTrace();
528
                        return false;
529
                } catch (DataException e) {
530
                        e.printStackTrace();
531
                        return false;
532
                }
533
        }
534

    
535
        public int selectHandlers(double x, double y, InputEvent event) {
536
                Point2D auxPoint = new Point2D.Double(x, y);
537

    
538
                VectorialLayerEdited vle = getVLE();
539
                ArrayList selectedHandler = vle.getSelectedHandler();
540
                FeatureSet selection=null;
541
                DisposableIterator iterator = null;
542
                try {
543
                        selection = (FeatureSet)vle.getFeatureStore().getSelection();
544

    
545
                        // ArrayList selectedRow = vle.getSelectedRow();
546
                        long countSel = selection.getSize();
547
                        System.out.println("DENTRO DE selectHandlers. selectedRow.size= "
548
                                        + countSel);
549
                        selectedHandler.clear();
550

    
551
                        // Se comprueba si se pincha en una gemometr?a
552
                        PluginServices.getMDIManager().setWaitCursor();
553

    
554
                        double tam = getCadToolAdapter().getMapControl().getViewPort()
555
                                        .toMapDistance(MapControl.tolerance);
556

    
557
                        Handler[] handlers = null;
558
                        rowselectedHandlers.clear();
559
                        iterator = selection.iterator();
560
                        while (iterator.hasNext()) {
561
                                Feature feature = (Feature) iterator.next();
562

    
563
                                // }
564
                                // for (int i = 0; i < selectedRow.size(); i++) {
565
                                // IRowEdited rowEd = (IRowEdited) selectedRow.get(i);
566
                                //
567
                                // IFeature fea = (IFeature) rowEd.getLinkedRow();
568
                                handlers = (feature.getDefaultGeometry())
569
                                                .getHandlers(Geometry.SELECTHANDLER);
570
                                // y miramos los handlers de cada entidad seleccionada
571
                                double min = tam;
572
                                // int hSel = -1;
573

    
574
                                for (int j = 0; j < handlers.length; j++) {
575
                                        Point2D handlerPoint = handlers[j].getPoint();
576
                                        double distance = auxPoint.distance(handlerPoint);
577
                                        if (distance <= min) {
578
                                                min = distance;
579
                                                // hSel = j;
580
                                                selectedHandler.add(handlers[j]);
581
                                                rowselectedHandlers.add(feature);
582
                                        }
583
                                }
584
                        }
585
                        PluginServices.getMDIManager().restoreCursor();
586
                } catch (DataException e) {
587
                        // TODO Auto-generated catch block
588
                        e.printStackTrace();
589
                } finally {
590
                        if (iterator != null) {
591
                                iterator.dispose();
592
                        }
593
                }
594

    
595
                int numHandlesSelected = selectedHandler.size();
596

    
597
                /*
598
                 * if (numHandlesSelected == 0) selectFeatures(x,y);
599
                 */
600

    
601
                return numHandlesSelected;
602
        }
603

    
604
        public String getType() {
605
                return type;
606
        }
607

    
608
        public void setType(String type) {
609
                if (type.equals("S") || type.equals("s")){
610
                        this.type=PluginServices.getText(this,"simple");
611
                }else{
612
                        this.type = type;
613
                }
614
//                pointsPolygon.clear();
615
        }
616

    
617
        public String toString() {
618
                return "_selection";
619
        }
620
        public void multipleSelection(boolean b) {
621
                multipleSelection=b;
622

    
623
        }
624

    
625
}