Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extCAD / src / com / iver / cit / gvsig / gui / cad / tools / SelectionCADTool.java @ 5166

History | View | Annotate | Download (19.4 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.io.IOException;
51
import java.util.ArrayList;
52

    
53
import com.hardcode.driverManager.DriverLoadException;
54
import com.iver.andami.PluginServices;
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.core.v02.FLabel;
64
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
65
import com.iver.cit.gvsig.fmap.edition.IRowEdited;
66
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter;
67
import com.iver.cit.gvsig.fmap.layers.FLayer;
68
import com.iver.cit.gvsig.fmap.layers.FLyrAnnotation;
69
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
70
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
71
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent;
72
import com.iver.cit.gvsig.gui.View;
73
import com.iver.cit.gvsig.gui.Panels.TextFieldEdit;
74
import com.iver.cit.gvsig.gui.cad.CADTool;
75
import com.iver.cit.gvsig.gui.cad.DefaultCADTool;
76
import com.iver.cit.gvsig.gui.cad.tools.smc.SelectionCADToolContext;
77
import com.iver.cit.gvsig.gui.cad.tools.smc.SelectionCADToolContext.SelectionCADToolState;
78
import com.iver.cit.gvsig.layers.VectorialLayerEdited;
79

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

    
88
        private SelectionCADToolContext _fsm;
89

    
90
        private Point2D firstPoint;
91

    
92
        //private Point2D lastPoint;
93

    
94

    
95

    
96
        private String nextState;
97
// Registros de los que se ha sleccionado alg?n handler.
98
        private ArrayList rowselectedHandlers=new ArrayList();
99
        private String type=PluginServices.getText(this,"simple");
100
        private ArrayList pointsPolygon=new ArrayList();
101
        /**
102
         * Crea un nuevo LineCADTool.
103
         */
104
        public SelectionCADTool() {
105
        }
106

    
107
        /**
108
         * M?todo de incio, para poner el c?digo de todo lo que se requiera de una
109
         * carga previa a la utilizaci?n de la herramienta.
110
         */
111
        public void init() {
112
                _fsm = new SelectionCADToolContext(this);
113
                setNextTool("selection");
114

    
115
                setType(PluginServices.getText(this,"simple"));
116
        }
117

    
118
        /*
119
         * (non-Javadoc)
120
         *
121
         * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet,
122
         *      double, double)
123
         */
124
        public void transition(double x, double y, InputEvent event) {
125
                System.out.println("TRANSICION DESDE ESTADO " + _fsm.getState()
126
                                + " x= " + x + " y=" + y);
127
                _fsm.addPoint(x, y, event);
128
                System.out.println("ESTADO ACTUAL: " + getStatus());
129
                /* FLyrVect lv=(FLyrVect)((VectorialLayerEdited)CADExtension.getEditionManager().getActiveLayerEdited()).getLayer();
130
                lv.getSource().getRecordset().getSelectionSupport().fireSelectionEvents(); */
131
        }
132

    
133
        /*
134
         * (non-Javadoc)
135
         *
136
         * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet,
137
         *      double)
138
         */
139
        public void transition(double d) {
140
                // _fsm.addValue(sel,d);
141
        }
142

    
143
        /*
144
         * (non-Javadoc)
145
         *
146
         * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet,
147
         *      java.lang.String)
148
         */
149
        public void transition(String s) {
150
                if (!super.changeCommand(s)){
151
                    _fsm.addOption(s);
152
            }
153
        }
154

    
155
        public String getNextState() {
156
                return nextState;
157
        }
158

    
159
        private void pointDoubleClick(MapControl map) {
160
                try {
161
                        FLayer[] actives = map.getMapContext()
162
            .getLayers().getActives();
163
            for (int i=0; i < actives.length; i++){
164
                if (actives[i] instanceof FLyrAnnotation && actives[i].isEditing()) {
165
                    FLyrAnnotation lyrAnnotation = (FLyrAnnotation) actives[i];
166

    
167
                            lyrAnnotation.setSelectedEditing();
168
                            lyrAnnotation.setInEdition(lyrAnnotation.getRecordset().getSelection().nextSetBit(0));
169
                            FLabel fl=lyrAnnotation.getLabel(lyrAnnotation.getInEdition());
170
                                        if (fl!=null){
171

    
172
                                                View vista=(View)PluginServices.getMDIManager().getActiveView();
173
                                                TextFieldEdit tfe=new TextFieldEdit(lyrAnnotation);
174

    
175
                                                tfe.show(vista.getMapControl().getViewPort().fromMapPoint(fl.getOrig()),vista.getMapControl());
176
                                        }
177
                }
178
            }
179

    
180
                } catch (DriverLoadException e) {
181
                        e.printStackTrace();
182
                } catch (com.iver.cit.gvsig.fmap.DriverException e) {
183
                        e.printStackTrace();
184
                }
185

    
186
}
187
        /**
188
         * Equivale al transition del prototipo pero sin pasarle como par? metro el
189
         * editableFeatureSource que ya estar? creado.
190
         *
191
         * @param selection
192
         *            Bitset con las geometr?as que est?n seleccionadas.
193
         * @param x
194
         *            par?metro x del punto que se pase en esta transici?n.
195
         * @param y
196
         *            par?metro y del punto que se pase en esta transici?n.
197
         */
198
        public void addPoint(double x, double y, InputEvent event) {
199
                if (((MouseEvent)event).getClickCount()==2){
200
                        pointDoubleClick((MapControl)event.getComponent());
201
                        return;
202
                }
203
                SelectionCADToolState actualState = (SelectionCADToolState) _fsm
204
                                .getPreviousState();
205
                String status = actualState.getName();
206
                System.out.println("PREVIOUSSTATE =" + status); // + "ESTADO ACTUAL: " +
207
                                                                                                                // _fsm.getState());
208
                VectorialLayerEdited vle = getVLE();
209
                VectorialEditableAdapter vea=vle.getVEA();
210
                ArrayList selectedHandler = vle.getSelectedHandler();
211
                ArrayList selectedRow = vle.getSelectedRow();
212
                System.out.println("STATUS ACTUAL = " + _fsm.getTransition());
213
                if (status.equals("Selection.FirstPoint")) {
214
                        firstPoint=new Point2D.Double(x,y);
215
                        pointsPolygon.add(firstPoint);
216
                } else if (status.equals("Selection.SecondPoint")) {
217
                } else if (status.equals("Selection.WithFeatures")) {
218
                } else if (status.equals("Selection.WithHandlers")) {
219
                        vea.startComplexRow();
220
                        for (int i = 0; i < selectedRow.size(); i++) {
221
                                IRowEdited row = (IRowEdited) selectedRow.get(i);
222
                                // Movemos los handlers que hemos seleccionado
223
                                // previamente dentro del m?todo select()
224
                                for (int k = 0; k < selectedHandler.size(); k++) {
225
                                        Handler h = (Handler) selectedHandler.get(k);
226
                                        h.set(x, y);
227
                                }
228

    
229
                                modifyFeature(row.getIndex(), (IFeature) row.getLinkedRow().cloneRow());
230
                        }
231
                        try {
232
                                vea.endComplexRow();
233
                        } catch (IOException e) {
234
                                e.printStackTrace();
235
                        } catch (DriverIOException e) {
236
                                e.printStackTrace();
237
                        }
238
                }else if (status.equals("Selection.NextPointPolygon")) {
239
                        pointsPolygon.add(new Point2D.Double(x,y));
240
                }
241
        }
242

    
243
        /**
244
         * Receives second point
245
         * @param x
246
         * @param y
247
         * @return numFeatures selected
248
         */
249
        public int selectWithSecondPoint(double x, double y, InputEvent event) {
250
                VectorialLayerEdited vle = getVLE();
251
                PluginServices.getMDIManager().setWaitCursor();
252
                vle.selectWithSecondPoint(x,y);
253
                ArrayList selectedRow = vle.getSelectedRow();
254
                PluginServices.getMDIManager().restoreCursor();
255
                if (selectedRow.size() > 0) {
256
                        nextState = "Selection.WithSelectedFeatures";
257
                } else
258
                        nextState = "Selection.FirstPoint";
259
                return selectedRow.size();
260
        }
261
        /**
262
         * Receives second point
263
         * @param x
264
         * @param y
265
         * @return numFeatures selected
266
         */
267
        public int selectWithSecondPointOutRectangle(double x, double y, InputEvent event) {
268
                Point2D lastPoint=new Point2D.Double(x,y);
269
                GeneralPathX gpx=new GeneralPathX();
270
                gpx.moveTo(firstPoint.getX(),firstPoint.getY());
271
                gpx.lineTo(lastPoint.getX(),firstPoint.getY());
272
                gpx.lineTo(lastPoint.getX(),lastPoint.getY());
273
                gpx.lineTo(firstPoint.getX(),lastPoint.getY());
274
                gpx.closePath();
275
                IGeometry rectangle=ShapeFactory.createPolygon2D(gpx);
276
                return selectWithPolygon(rectangle);
277
//                VectorialLayerEdited vle = getVLE();
278
//                PluginServices.getMDIManager().setWaitCursor();
279
//                vle.selectWithSecondPointOutRectangle(firstPoint,x,y);
280
//                ArrayList selectedRow = vle.getSelectedRow();
281
//                PluginServices.getMDIManager().restoreCursor();
282
//                if (selectedRow.size() > 0) {
283
//                        nextState = "Selection.WithSelectedFeatures";
284
//                } else
285
//                        nextState = "Selection.FirstPoint";
286
//                return selectedRow.size();
287
        }
288
        /**
289
         * Receives second point
290
         * @param x
291
         * @param y
292
         * @return numFeatures selected
293
         */
294
        public int selectWithCircle(double x, double y, InputEvent event) {
295
                IGeometry circle=ShapeFactory.createCircle(firstPoint,new Point2D.Double(x,y));
296
                return selectWithPolygon(circle);
297
        }
298
        public int selectWithPolygon(IGeometry polygon) {
299
                VectorialLayerEdited vle = getVLE();
300
                PluginServices.getMDIManager().setWaitCursor();
301

    
302
                if (getType().equals(PluginServices.getText(this,"inside_circle")) || getType().equals(PluginServices.getText(this,"inside_polygon"))) {
303
                        vle.selectInsidePolygon(polygon);
304
                } else if (getType().equals(PluginServices.getText(this,"cross_circle")) || getType().equals(PluginServices.getText(this,"cross_polygon"))) {
305
                        vle.selectCrossPolygon(polygon);
306
                } else if (getType().equals(PluginServices.getText(this,"out_circle")) || getType().equals(PluginServices.getText(this,"out_polygon")) || getType().equals(PluginServices.getText(this,"out_rectangle"))) {
307
                        vle.selectOutPolygon(polygon);
308
                }
309
                ArrayList selectedRow = vle.getSelectedRow();
310
                PluginServices.getMDIManager().restoreCursor();
311
                if (selectedRow.size() > 0) {
312
                        nextState = "Selection.WithSelectedFeatures";
313
                        end();
314
                } else
315
                        nextState = "Selection.FirstPoint";
316
                return selectedRow.size();
317
        }
318

    
319
        /**
320
         * M?todo para dibujar la lo necesario para el estado en el que nos
321
         * encontremos.
322
         *
323
         * @param g
324
         *            Graphics sobre el que dibujar.
325
         * @param selectedGeometries
326
         *            BitSet con las geometr?as seleccionadas.
327
         * @param x
328
         *            par?metro x del punto que se pase para dibujar.
329
         * @param y
330
         *            par?metro x del punto que se pase para dibujar.
331
         */
332
        public void drawOperation(Graphics g, double x, double y) {
333
                SelectionCADToolState actualState = _fsm.getState();
334
                String status = actualState.getName();
335
                VectorialLayerEdited vle = getVLE();
336
                ArrayList selectedHandler = vle.getSelectedHandler();
337
                ViewPort vp=vle.getLayer().getFMap().getViewPort();
338
                if (status.equals("Selection.SecondPoint") || status.equals("Selection.SecondPointOutRectangle")) {
339
                        // Dibuja el rect?ngulo de selecci?n
340
                        GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD,
341
                                        4);
342
                        elShape.moveTo(firstPoint.getX(), firstPoint.getY());
343
                        elShape.lineTo(x, firstPoint.getY());
344
                        elShape.lineTo(x, y);
345
                        elShape.lineTo(firstPoint.getX(), y);
346
                        elShape.lineTo(firstPoint.getX(), firstPoint.getY());
347
                        ShapeFactory.createPolyline2D(elShape).draw((Graphics2D) g,
348
                                        vp,
349
                                        CADTool.selectSymbol);
350
                        Image img = vle.getSelectionImage();
351
                g.drawImage(img, 0, 0, null);
352
                return;
353
                }if (status.equals("Selection.SecondPointCircle")) {
354
                        // Dibuja el c?rculo de selecci?n
355
                        ShapeFactory.createCircle(firstPoint,new Point2D.Double(x,y)).draw((Graphics2D) g,
356
                                        vp,
357
                                        CADTool.selectSymbol);
358
                        Image img = vle.getSelectionImage();
359
                g.drawImage(img, 0, 0, null);
360
                return;
361
                }else if (status.equals("Selection.NextPointPolygon")) {
362
                        // Dibuja el pol?gono de selecci?n
363
                        IGeometry polygon=getGeometryPolygon(new Point2D.Double(x,y));
364
                        polygon.draw((Graphics2D) g,
365
                                        vp,
366
                                        CADTool.selectSymbol);
367
                        Image img = vle.getSelectionImage();
368
                g.drawImage(img, 0, 0, null);
369
                return;
370
                }else if (status.equals("Selection.WithHandlers")) {
371
                        // Movemos los handlers que hemos seleccionado
372
                        // previamente dentro del m?todo select()
373
                        for (int k = 0; k < selectedHandler.size(); k++) {
374
                                Handler h = (Handler) selectedHandler.get(k);
375
                                h.set(x, y);
376
                        }
377
                        // Y una vez movidos los v?rtices (handles)
378
                        // redibujamos la nueva geometr?a.
379
                        for (int i = 0; i < rowselectedHandlers.size(); i++) {
380
                                IRowEdited rowEd = (IRowEdited) rowselectedHandlers.get(i);
381
                                IGeometry geom = ((IFeature) rowEd.getLinkedRow())
382
                                                .getGeometry().cloneGeometry();
383
                                g.setColor(Color.gray);
384
                                geom.draw((Graphics2D) g, vp, CADTool.modifySymbol);
385
                        }
386
                        return;
387
                }else{
388
                        try{
389
                        Image imgSel = vle.getSelectionImage();
390
                if (imgSel!=null)
391
                        g.drawImage(imgSel, 0, 0, null);
392
                Image imgHand = vle.getHandlersImage();
393
                if (imgHand!=null)
394
                        g.drawImage(imgHand, 0, 0, null);
395
                        }catch (Exception e) {
396
                        }
397
                }
398
        }
399

    
400
        /**
401
         * Add a diferent option.
402
         *
403
         * @param sel
404
         *            DOCUMENT ME!
405
         * @param s
406
         *            Diferent option.
407
         */
408
        public void addOption(String s) {
409
                SelectionCADToolState actualState = (SelectionCADToolState) _fsm
410
                                .getPreviousState();
411
                String status = actualState.getName();
412
                System.out.println("PREVIOUSSTATE =" + status); // + "ESTADO ACTUAL: " +
413
                // _fsm.getState());
414
                System.out.println("STATUS ACTUAL = " + _fsm.getTransition());
415
                if (s.equals(PluginServices.getText(this,"cancel"))){
416
                        init();
417
                        return;
418
                }else if (s.equals(PluginServices.getText(this,"select_all"))){
419
                        selectAll();
420
                        init();
421
                        return;
422
                }
423
                if (status.equals("Selection.FirstPoint")) {
424
                        setType(s);
425
                }else if (status.equals("Selection.NextPointPolygon")){
426
                        if (s.equals(PluginServices.getText(this,"end_polygon")) || s.equals("E") || s.equals("e")) {
427
                        IGeometry polygon=getGeometryPolygon(null);
428
                        selectWithPolygon(polygon);
429
                        pointsPolygon.clear();
430
                        setType(PluginServices.getText(this,"simple"));
431
                        }
432
                }
433
        }
434
        private int selectAll() {
435
                VectorialLayerEdited vle = getVLE();
436
                PluginServices.getMDIManager().setWaitCursor();
437
                vle.selectAll();
438
                ArrayList selectedRow = vle.getSelectedRow();
439
                PluginServices.getMDIManager().restoreCursor();
440
                if (selectedRow.size() > 0) {
441
                        nextState = "Selection.WithSelectedFeatures";
442
                } else
443
                        nextState = "Selection.FirstPoint";
444
                end();
445
                return selectedRow.size();
446
        }
447

    
448
        private IGeometry getGeometryPolygon(Point2D p) {
449
                Point2D[] points = (Point2D[]) pointsPolygon.toArray(new Point2D[0]);
450
                GeneralPathX gpx = new GeneralPathX();
451
                for (int i = 0; i < points.length; i++) {
452
                        if (i == 0) {
453
                                gpx.moveTo(points[i].getX(), points[i].getY());
454
                        } else {
455
                                gpx.lineTo(points[i].getX(), points[i].getY());
456
                        }
457
                }
458
                if (p!=null){
459
                        gpx.lineTo(p.getX(),p.getY());
460
                        gpx.closePath();
461
                        IGeometry polyline = ShapeFactory.createPolyline2D(gpx);
462
                        return polyline;
463
                }
464
                gpx.closePath();
465
                IGeometry polygon = ShapeFactory.createPolygon2D(gpx);
466
                return polygon;
467
        }
468

    
469
        /*
470
         * (non-Javadoc)
471
         *
472
         * @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double)
473
         */
474
        public void addValue(double d) {
475
        }
476

    
477
        public String getStatus() {
478
                try {
479
                        SelectionCADToolState actualState = (SelectionCADToolState) _fsm
480
                                        .getPreviousState();
481
                        String status = actualState.getName();
482

    
483
                        return status;
484
                } catch (NullPointerException e) {
485
                        return "Selection.FisrtPoint";
486
                }
487
        }
488

    
489

    
490

    
491
        public void end() {
492
                if (!getNextTool().equals("selection"))
493
                        CADExtension.setCADTool(getNextTool(),false);
494
        }
495

    
496
        public String getName() {
497
                return PluginServices.getText(this,"selection_");
498
        }
499

    
500
        public boolean selectFeatures(double x, double y, InputEvent event) {
501
                SelectionCADToolState actualState = (SelectionCADToolState) _fsm
502
                                .getState();
503

    
504
                String status = actualState.getName();
505
                VectorialLayerEdited vle = getVLE();
506

    
507

    
508
                if ((status.equals("Selection.FirstPoint"))
509
                                || (status.equals("Selection.WithSelectedFeatures"))) {
510
                        PluginServices.getMDIManager().setWaitCursor();
511
                        firstPoint = new Point2D.Double(x, y);
512
                        vle.selectWithPoint(x,y);
513
                        PluginServices.getMDIManager().restoreCursor();
514
                }
515
                ArrayList selectedRow = vle.getSelectedRow();
516
                if (selectedRow.size() > 0) {
517
                        nextState = "Selection.WithSelectedFeatures";
518
                        return true;
519
                } else {
520
                        {
521
                                nextState = "Selection.SecondPoint";
522
                                return true;
523
                        }
524
                }
525
        }
526

    
527
        public int selectHandlers(double x, double y, InputEvent event) {
528
                Point2D auxPoint = new Point2D.Double(x, y);
529

    
530
                VectorialLayerEdited vle = getVLE();
531
                ArrayList selectedHandler = vle.getSelectedHandler();
532
                ArrayList selectedRow = vle.getSelectedRow();
533
                System.out.println("DENTRO DE selectHandlers. selectedRow.size= "
534
                                + selectedRow.size());
535
                selectedHandler.clear();
536

    
537
                // Se comprueba si se pincha en una gemometr?a
538
                PluginServices.getMDIManager().setWaitCursor();
539

    
540
                double tam = getCadToolAdapter().getMapControl().getViewPort()
541
                                .toMapDistance(tolerance);
542

    
543
                Handler[] handlers = null;
544
                rowselectedHandlers.clear();
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 = fea.getGeometry().getHandlers(IGeometry.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(rowEd);
562
                                }
563
                        }
564
                }
565
                PluginServices.getMDIManager().restoreCursor();
566

    
567
                int numHandlesSelected = selectedHandler.size();
568

    
569
                /*
570
                 * if (numHandlesSelected == 0) selectFeatures(x,y);
571
                 */
572

    
573
                return numHandlesSelected;
574
        }
575

    
576
        public String getType() {
577
                return type;
578
        }
579

    
580
        public void setType(String type) {
581
                if (type.equals("S") || type.equals("s")){
582
                        this.type=PluginServices.getText(this,"simple");
583
                }else if (type.equals("OR") || type.equals("or")){
584
                        this.type=PluginServices.getText(this,"out_rectangle");
585
                }else if (type.equals("IP") || type.equals("ip")){
586
                        this.type=PluginServices.getText(this,"inside_polygon");
587
                }else if (type.equals("CP") || type.equals("cp")){
588
                        this.type=PluginServices.getText(this,"cross_polygon");
589
                }else if (type.equals("OP") || type.equals("op")){
590
                        this.type=PluginServices.getText(this,"out_polygon");
591
                }else if (type.equals("IC") || type.equals("ic")){
592
                        this.type=PluginServices.getText(this,"inside_circle");
593
                }else if (type.equals("CC") || type.equals("cc")){
594
                        this.type=PluginServices.getText(this,"cross_circle");
595
                }else if (type.equals("OC") || type.equals("oc")){
596
                        this.type=PluginServices.getText(this,"cross_circle");
597
                }else if (type.equals(PluginServices.getText(this,"select_all"))){
598
                        selectAll();
599
                        init();
600
                }else{
601
                        this.type = type;
602
                }
603
                pointsPolygon.clear();
604
        }
605

    
606
        public String toString() {
607
                return "_selection";
608
        }
609
}