Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extEditing / src / com / iver / cit / gvsig / gui / cad / tools / SelectionCADTool.java @ 27270

History | View | Annotate | Download (19 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.geom.Point2D;
49
import java.util.ArrayList;
50
import java.util.Iterator;
51

    
52
import org.gvsig.fmap.dal.exception.DataException;
53
import org.gvsig.fmap.dal.exception.ReadException;
54
import org.gvsig.fmap.dal.feature.EditableFeature;
55
import org.gvsig.fmap.dal.feature.Feature;
56
import org.gvsig.fmap.dal.feature.FeatureSet;
57
import org.gvsig.fmap.dal.feature.FeatureStore;
58
import org.gvsig.fmap.dal.feature.exception.NeedEditingModeException;
59
import org.gvsig.fmap.geom.Geometry;
60
import org.gvsig.fmap.geom.handler.Handler;
61
import org.gvsig.fmap.geom.operation.Draw;
62
import org.gvsig.fmap.geom.operation.DrawOperationContext;
63
import org.gvsig.fmap.geom.operation.GeometryOperationException;
64
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
65
import org.gvsig.fmap.geom.primitive.GeneralPathX;
66
import org.gvsig.fmap.mapcontext.MapContext;
67
import org.gvsig.fmap.mapcontext.ViewPort;
68
import org.gvsig.fmap.mapcontext.layers.FLayer;
69
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
70
import org.gvsig.fmap.mapcontrol.MapControl;
71
import org.gvsig.project.document.table.gui.FeatureTableDocumentPanel;
72

    
73
import com.iver.andami.PluginServices;
74
import com.iver.andami.messages.NotificationManager;
75
import com.iver.cit.gvsig.CADExtension;
76
import com.iver.cit.gvsig.gui.cad.DefaultCADTool;
77
import com.iver.cit.gvsig.gui.cad.exception.CommandException;
78
import com.iver.cit.gvsig.gui.cad.tools.smc.SelectionCADToolContext;
79
import com.iver.cit.gvsig.gui.cad.tools.smc.SelectionCADToolContext.SelectionCADToolState;
80
import com.iver.cit.gvsig.layers.VectorialLayerEdited;
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
                com.iver.andami.ui.mdiManager.IWindow[] views = (com.iver.andami.ui.mdiManager.IWindow[]) 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
         * (non-Javadoc)
151
         *
152
         * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet,
153
         *      double)
154
         */
155
        public void transition(double d) {
156
                _fsm.addValue(d);
157
        }
158

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

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

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

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

    
269
                        featureStore.endEditingGroup();
270
                }
271
                } catch (ReadException e) {
272
                        // TODO Auto-generated catch block
273
                        e.printStackTrace();
274
                } catch (NeedEditingModeException e) {
275
                        // TODO Auto-generated catch block
276
                        e.printStackTrace();
277
                } catch (DataException e) {
278
                        // TODO Auto-generated catch block
279
                        e.printStackTrace();
280
                }
281
        }
282

    
283
        /**
284
         * Receives second point
285
         * @param x
286
         * @param y
287
         * @return numFeatures selected
288
         */
289
        public long selectWithSecondPoint(double x, double y, InputEvent event) {
290
                VectorialLayerEdited vle = getVLE();
291
                PluginServices.getMDIManager().setWaitCursor();
292
                vle.selectWithSecondPoint(x,y);
293
                FeatureSet selection=null;
294
                try {
295
                        selection = (FeatureSet)vle.getFeatureStore().getSelection();
296
                        PluginServices.getMDIManager().restoreCursor();
297
                        long countSel=selection.getSize();
298
                        if (countSel > 0) {
299
                                nextState = "Selection.WithSelectedFeatures";
300
                        } else
301
                                nextState = "Selection.FirstPoint";
302
                        return countSel;
303
                } catch (ReadException e) {
304
                        e.printStackTrace();
305
                        return 0;
306
                } catch (DataException e) {
307
                        e.printStackTrace();
308
                        return 0;
309
                }
310
        }
311

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

    
410
        /**
411
         * Add a diferent option.
412
         *
413
         * @param sel
414
         *            DOCUMENT ME!
415
         * @param s
416
         *            Diferent option.
417
         */
418
        public void addOption(String s) {
419
                SelectionCADToolState actualState = (SelectionCADToolState) _fsm
420
                                .getPreviousState();
421
                String status = actualState.getName();
422
                System.out.println("PREVIOUSSTATE =" + status); // + "ESTADO ACTUAL: " +
423
                // _fsm.getState());
424
                System.out.println("STATUS ACTUAL = " + _fsm.getTransition());
425
                if (s.equals(PluginServices.getText(this,"cancel"))){
426
                        init();
427
                        return;
428
                }
429
                if (status.equals("Selection.FirstPoint")) {
430
                        setType(s);
431
                        return;
432
                }
433
                init();
434
        }
435

    
436

    
437

    
438

    
439
        /*
440
         * (non-Javadoc)
441
         *
442
         * @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double)
443
         */
444
        public void addValue(double d) {
445
        }
446

    
447
        public String getStatus() {
448
                try {
449
                        SelectionCADToolState actualState = (SelectionCADToolState) _fsm
450
                                        .getPreviousState();
451
                        String status = actualState.getName();
452

    
453
                        return status;
454
                } catch (NullPointerException e) {
455
                        return "Selection.FirstPoint";
456
                }
457
        }
458

    
459

    
460

    
461
        public void end() {
462
                if (!getNextTool().equals("selection"))
463
                        CADExtension.setCADTool(getNextTool(),false);
464
        }
465

    
466
        public String getName() {
467
                return PluginServices.getText(this,"selection_");
468
        }
469

    
470
        public boolean selectFeatures(double x, double y, InputEvent event) {
471
                SelectionCADToolState actualState = (SelectionCADToolState) _fsm
472
                                .getState();
473

    
474
                String status = actualState.getName();
475
                VectorialLayerEdited vle = getVLE();
476
                multipleSelection=event.isControlDown();
477

    
478
                if ((status.equals("Selection.FirstPoint"))
479
                                || (status.equals("Selection.WithSelectedFeatures"))) {
480
                        PluginServices.getMDIManager().setWaitCursor();
481
                        firstPoint = new Point2D.Double(x, y);
482
                        try {
483
                                vle.getFeatureStore().beginEditingGroup(getName());
484
                                vle.selectWithPoint(x,y,multipleSelection);
485
                                vle.getFeatureStore().endEditingGroup();
486
                        } catch (NeedEditingModeException e) {
487
                                NotificationManager.showMessageError(getName(), e);
488
                        } catch (ReadException e) {
489
                                NotificationManager.showMessageError(getName(), e);
490
                        }
491
                        PluginServices.getMDIManager().restoreCursor();
492
                }
493
                FeatureSet selection=null;
494
                try {
495
                        selection = (FeatureSet)vle.getFeatureStore().getSelection();
496

    
497
//                ArrayList selectedRow = vle.getSelectedRow();
498
                long countSel=selection.getSize();
499
                if (countSel > 0) {
500
                        nextState = "Selection.WithSelectedFeatures";
501
                        return true;
502
                } else {
503
                        {
504
                                nextState = "Selection.SecondPoint";
505
                                return true;
506
                        }
507
                }
508
                } catch (ReadException e) {
509
                        e.printStackTrace();
510
                        return false;
511
                } catch (DataException e) {
512
                        e.printStackTrace();
513
                        return false;
514
                }
515
        }
516

    
517
        public int selectHandlers(double x, double y, InputEvent event) {
518
                Point2D auxPoint = new Point2D.Double(x, y);
519

    
520
                VectorialLayerEdited vle = getVLE();
521
                ArrayList selectedHandler = vle.getSelectedHandler();
522
                FeatureSet selection=null;
523
                try {
524
                        selection = (FeatureSet)vle.getFeatureStore().getSelection();
525

    
526
//                ArrayList selectedRow = vle.getSelectedRow();
527
                long countSel=selection.getSize();
528
                System.out.println("DENTRO DE selectHandlers. selectedRow.size= "
529
                                + countSel);
530
                selectedHandler.clear();
531

    
532
                // Se comprueba si se pincha en una gemometr?a
533
                PluginServices.getMDIManager().setWaitCursor();
534

    
535
                double tam = getCadToolAdapter().getMapControl().getViewPort()
536
                                .toMapDistance(MapControl.tolerance);
537

    
538
                Handler[] handlers = null;
539
                rowselectedHandlers.clear();
540
                Iterator iterator=selection.iterator();
541
                while (iterator.hasNext()) {
542
                        Feature feature = (Feature) iterator.next();
543

    
544
//                }
545
//                for (int i = 0; i < selectedRow.size(); i++) {
546
//                        IRowEdited rowEd = (IRowEdited) selectedRow.get(i);
547
//
548
//                        IFeature fea = (IFeature) rowEd.getLinkedRow();
549
                        handlers = ((Geometry)feature.getDefaultGeometry()).getHandlers(Geometry.SELECTHANDLER);
550
                        // y miramos los handlers de cada entidad seleccionada
551
                        double min = tam;
552
                        // int hSel = -1;
553

    
554
                        for (int j = 0; j < handlers.length; j++) {
555
                                Point2D handlerPoint = handlers[j].getPoint();
556
                                double distance = auxPoint.distance(handlerPoint);
557
                                if (distance <= min) {
558
                                        min = distance;
559
                                        // hSel = j;
560
                                        selectedHandler.add(handlers[j]);
561
                                        rowselectedHandlers.add(feature);
562
                                }
563
                        }
564
                }
565
                PluginServices.getMDIManager().restoreCursor();
566
                } catch (ReadException e) {
567
                        // TODO Auto-generated catch block
568
                        e.printStackTrace();
569
                } catch (DataException e) {
570
                        // TODO Auto-generated catch block
571
                        e.printStackTrace();
572
                }
573
                int numHandlesSelected = selectedHandler.size();
574

    
575
                /*
576
                 * if (numHandlesSelected == 0) selectFeatures(x,y);
577
                 */
578

    
579
                return numHandlesSelected;
580
        }
581

    
582
        public String getType() {
583
                return type;
584
        }
585

    
586
        public void setType(String type) {
587
                if (type.equals("S") || type.equals("s")){
588
                        this.type=PluginServices.getText(this,"simple");
589
                }else{
590
                        this.type = type;
591
                }
592
//                pointsPolygon.clear();
593
        }
594

    
595
        public String toString() {
596
                return "_selection";
597
        }
598
        public void multipleSelection(boolean b) {
599
                multipleSelection=b;
600

    
601
        }
602

    
603
}