Statistics
| Revision:

root / trunk / extensions / extCAD / src / com / iver / cit / gvsig / gui / cad / tools / smc / ComplexSelectionCADToolContext.java @ 5735

History | View | Annotate | Download (31.7 KB)

1

    
2
//
3
// Vicente Caballero Navarro
4

    
5

    
6
package com.iver.cit.gvsig.gui.cad.tools.smc;
7

    
8
import com.iver.cit.gvsig.gui.cad.tools.ComplexSelectionCADTool;
9
import com.iver.cit.gvsig.fmap.layers.FBitSet;
10
import java.awt.event.InputEvent;
11
import com.iver.andami.PluginServices;
12

    
13
public final class ComplexSelectionCADToolContext
14
    extends statemap.FSMContext
15
{
16
//---------------------------------------------------------------
17
// Member methods.
18
//
19

    
20
    public ComplexSelectionCADToolContext(ComplexSelectionCADTool owner)
21
    {
22
        super();
23

    
24
        _owner = owner;
25
        setState(Selection.FirstPoint);
26
        Selection.FirstPoint.Entry(this);
27
    }
28

    
29
    public void addOption(String s)
30
    {
31
        _transition = "addOption";
32
        getState().addOption(this, s);
33
        _transition = "";
34
        return;
35
    }
36

    
37
    public void addPoint(double pointX, double pointY, InputEvent event)
38
    {
39
        _transition = "addPoint";
40
        getState().addPoint(this, pointX, pointY, event);
41
        _transition = "";
42
        return;
43
    }
44

    
45
    public void addValue(double d)
46
    {
47
        _transition = "addValue";
48
        getState().addValue(this, d);
49
        _transition = "";
50
        return;
51
    }
52

    
53
    public ComplexSelectionCADToolState getState()
54
        throws statemap.StateUndefinedException
55
    {
56
        if (_state == null)
57
        {
58
            throw(
59
                new statemap.StateUndefinedException());
60
        }
61

    
62
        return ((ComplexSelectionCADToolState) _state);
63
    }
64

    
65
    protected ComplexSelectionCADTool getOwner()
66
    {
67
        return (_owner);
68
    }
69

    
70
//---------------------------------------------------------------
71
// Member data.
72
//
73

    
74
    transient private ComplexSelectionCADTool _owner;
75

    
76
//---------------------------------------------------------------
77
// Inner classes.
78
//
79

    
80
    public static abstract class ComplexSelectionCADToolState
81
        extends statemap.State
82
    {
83
    //-----------------------------------------------------------
84
    // Member methods.
85
    //
86

    
87
        protected ComplexSelectionCADToolState(String name, int id)
88
        {
89
            super (name, id);
90
        }
91

    
92
        protected void Entry(ComplexSelectionCADToolContext context) {}
93
        protected void Exit(ComplexSelectionCADToolContext context) {}
94

    
95
        protected void addOption(ComplexSelectionCADToolContext context, String s)
96
        {
97
            Default(context);
98
        }
99

    
100
        protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event)
101
        {
102
            Default(context);
103
        }
104

    
105
        protected void addValue(ComplexSelectionCADToolContext context, double d)
106
        {
107
            Default(context);
108
        }
109

    
110
        protected void Default(ComplexSelectionCADToolContext context)
111
        {
112
            throw (
113
                new statemap.TransitionUndefinedException(
114
                    "State: " +
115
                    context.getState().getName() +
116
                    ", Transition: " +
117
                    context.getTransition()));
118
        }
119

    
120
    //-----------------------------------------------------------
121
    // Member data.
122
    //
123
    }
124

    
125
    /* package */ static abstract class Selection
126
    {
127
    //-----------------------------------------------------------
128
    // Member methods.
129
    //
130

    
131
    //-----------------------------------------------------------
132
    // Member data.
133
    //
134

    
135
        //-------------------------------------------------------
136
        // Statics.
137
        //
138
        /* package */ static Selection_Default.Selection_FirstPoint FirstPoint;
139
        /* package */ static Selection_Default.Selection_SecondPoint SecondPoint;
140
        /* package */ static Selection_Default.Selection_WithSelectedFeatures WithSelectedFeatures;
141
        /* package */ static Selection_Default.Selection_WithHandlers WithHandlers;
142
        /* package */ static Selection_Default.Selection_SecondPointOutRectangle SecondPointOutRectangle;
143
        /* package */ static Selection_Default.Selection_SecondPointCircle SecondPointCircle;
144
        /* package */ static Selection_Default.Selection_NextPointPolygon NextPointPolygon;
145
        private static Selection_Default Default;
146

    
147
        static
148
        {
149
            FirstPoint = new Selection_Default.Selection_FirstPoint("Selection.FirstPoint", 0);
150
            SecondPoint = new Selection_Default.Selection_SecondPoint("Selection.SecondPoint", 1);
151
            WithSelectedFeatures = new Selection_Default.Selection_WithSelectedFeatures("Selection.WithSelectedFeatures", 2);
152
            WithHandlers = new Selection_Default.Selection_WithHandlers("Selection.WithHandlers", 3);
153
            SecondPointOutRectangle = new Selection_Default.Selection_SecondPointOutRectangle("Selection.SecondPointOutRectangle", 4);
154
            SecondPointCircle = new Selection_Default.Selection_SecondPointCircle("Selection.SecondPointCircle", 5);
155
            NextPointPolygon = new Selection_Default.Selection_NextPointPolygon("Selection.NextPointPolygon", 6);
156
            Default = new Selection_Default("Selection.Default", -1);
157
        }
158

    
159
    }
160

    
161
    protected static class Selection_Default
162
        extends ComplexSelectionCADToolState
163
    {
164
    //-----------------------------------------------------------
165
    // Member methods.
166
    //
167

    
168
        protected Selection_Default(String name, int id)
169
        {
170
            super (name, id);
171
        }
172

    
173
        protected void addOption(ComplexSelectionCADToolContext context, String s)
174
        {
175
            ComplexSelectionCADTool ctxt = context.getOwner();
176

    
177
            if (s.equals(PluginServices.getText(this,"cancel")))
178
            {
179
                boolean loopbackFlag =
180
                    context.getState().getName().equals(
181
                        Selection.FirstPoint.getName());
182

    
183
                if (loopbackFlag == false)
184
                {
185
                    (context.getState()).Exit(context);
186
                }
187

    
188
                context.clearState();
189
                try
190
                {
191
                    ctxt.end();
192
                }
193
                finally
194
                {
195
                    context.setState(Selection.FirstPoint);
196

    
197
                    if (loopbackFlag == false)
198
                    {
199
                        (context.getState()).Entry(context);
200
                    }
201

    
202
                }
203
            }
204
            else
205
            {
206
                boolean loopbackFlag =
207
                    context.getState().getName().equals(
208
                        Selection.FirstPoint.getName());
209

    
210
                if (loopbackFlag == false)
211
                {
212
                    (context.getState()).Exit(context);
213
                }
214

    
215
                context.clearState();
216
                try
217
                {
218
                    ctxt.throwOptionException(PluginServices.getText(this,"incorrect_option"), s);
219
                }
220
                finally
221
                {
222
                    context.setState(Selection.FirstPoint);
223

    
224
                    if (loopbackFlag == false)
225
                    {
226
                        (context.getState()).Entry(context);
227
                    }
228

    
229
                }
230
            }
231

    
232
            return;
233
        }
234

    
235
        protected void addValue(ComplexSelectionCADToolContext context, double d)
236
        {
237
            ComplexSelectionCADTool ctxt = context.getOwner();
238

    
239
            boolean loopbackFlag =
240
                context.getState().getName().equals(
241
                    Selection.FirstPoint.getName());
242

    
243
            if (loopbackFlag == false)
244
            {
245
                (context.getState()).Exit(context);
246
            }
247

    
248
            context.clearState();
249
            try
250
            {
251
                ctxt.throwValueException(PluginServices.getText(this,"incorrect_value"), d);
252
            }
253
            finally
254
            {
255
                context.setState(Selection.FirstPoint);
256

    
257
                if (loopbackFlag == false)
258
                {
259
                    (context.getState()).Entry(context);
260
                }
261

    
262
            }
263
            return;
264
        }
265

    
266
        protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event)
267
        {
268
            ComplexSelectionCADTool ctxt = context.getOwner();
269

    
270
            boolean loopbackFlag =
271
                context.getState().getName().equals(
272
                    Selection.FirstPoint.getName());
273

    
274
            if (loopbackFlag == false)
275
            {
276
                (context.getState()).Exit(context);
277
            }
278

    
279
            context.clearState();
280
            try
281
            {
282
                ctxt.throwPointException(PluginServices.getText(this,"incorrect_point"), pointX, pointY);
283
            }
284
            finally
285
            {
286
                context.setState(Selection.FirstPoint);
287

    
288
                if (loopbackFlag == false)
289
                {
290
                    (context.getState()).Entry(context);
291
                }
292

    
293
            }
294
            return;
295
        }
296

    
297
    //-----------------------------------------------------------
298
    // Inner classse.
299
    //
300

    
301

    
302
        private static final class Selection_FirstPoint
303
            extends Selection_Default
304
        {
305
        //-------------------------------------------------------
306
        // Member methods.
307
        //
308

    
309
            private Selection_FirstPoint(String name, int id)
310
            {
311
                super (name, id);
312
            }
313

    
314
            protected void Entry(ComplexSelectionCADToolContext context)
315
            {
316
                ComplexSelectionCADTool ctxt = context.getOwner();
317

    
318
                ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection_or_types"));
319
                ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
320
                return;
321
            }
322

    
323
            protected void addOption(ComplexSelectionCADToolContext context, String s)
324
            {
325
                ComplexSelectionCADTool ctxt = context.getOwner();
326

    
327
                ComplexSelectionCADToolState endState = context.getState();
328

    
329
                context.clearState();
330
                try
331
                {
332
                    ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection_or_types"));
333
                    ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
334
                    ctxt.addOption(s);
335
                }
336
                finally
337
                {
338
                    context.setState(endState);
339
                }
340
                return;
341
            }
342

    
343
            protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event)
344
            {
345
                ComplexSelectionCADTool ctxt = context.getOwner();
346

    
347
                if (ctxt.getType().equals(PluginServices.getText(this,"out_rectangle")))
348
                {
349

    
350
                    (context.getState()).Exit(context);
351
                    context.clearState();
352
                    try
353
                    {
354
                        ctxt.setQuestion(PluginServices.getText(this,"insert_second_point_selection"));
355
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
356
                        ctxt.addPoint(pointX, pointY, event);
357
                    }
358
                    finally
359
                    {
360
                        context.setState(Selection.SecondPointOutRectangle);
361
                        (context.getState()).Entry(context);
362
                    }
363
                }
364
                else if (ctxt.getType().equals(PluginServices.getText(this,"inside_circle")) || ctxt.getType().equals(PluginServices.getText(this,"cross_circle")) || ctxt.getType().equals(PluginServices.getText(this,"out_circle")))
365
                {
366

    
367
                    (context.getState()).Exit(context);
368
                    context.clearState();
369
                    try
370
                    {
371
                        ctxt.setQuestion(PluginServices.getText(this,"insert_second_point_selection"));
372
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
373
                        ctxt.addPoint(pointX, pointY, event);
374
                    }
375
                    finally
376
                    {
377
                        context.setState(Selection.SecondPointCircle);
378
                        (context.getState()).Entry(context);
379
                    }
380
                }
381
                else if (ctxt.getType().equals(PluginServices.getText(this,"inside_polygon")) || ctxt.getType().equals(PluginServices.getText(this,"cross_polygon")) || ctxt.getType().equals(PluginServices.getText(this,"out_polygon")))
382
                {
383

    
384
                    (context.getState()).Exit(context);
385
                    context.clearState();
386
                    try
387
                    {
388
                        ctxt.setQuestion(PluginServices.getText(this,"insert_next_point_selection_or_end_polygon"));
389
                        ctxt.setDescription(new String[]{"end_polygon", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
390
                        ctxt.addPoint(pointX, pointY, event);
391
                    }
392
                    finally
393
                    {
394
                        context.setState(Selection.NextPointPolygon);
395
                        (context.getState()).Entry(context);
396
                    }
397
                }
398
                else if (ctxt.getType().equals(PluginServices.getText(this,"simple")) && ctxt.selectFeatures(pointX,pointY, event) && ctxt.getNextState().equals("Selection.SecondPoint"))
399
                {
400

    
401
                    (context.getState()).Exit(context);
402
                    context.clearState();
403
                    try
404
                    {
405
                        ctxt.setQuestion(PluginServices.getText(this,"insert_second_point_selection"));
406
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
407
                        ctxt.addPoint(pointX, pointY, event);
408
                    }
409
                    finally
410
                    {
411
                        context.setState(Selection.SecondPoint);
412
                        (context.getState()).Entry(context);
413
                    }
414
                }                else
415
                {
416
                    super.addPoint(context, pointX, pointY, event);
417
                }
418

    
419
                return;
420
            }
421

    
422
        //-------------------------------------------------------
423
        // Member data.
424
        //
425
        }
426

    
427
        private static final class Selection_SecondPoint
428
            extends Selection_Default
429
        {
430
        //-------------------------------------------------------
431
        // Member methods.
432
        //
433

    
434
            private Selection_SecondPoint(String name, int id)
435
            {
436
                super (name, id);
437
            }
438

    
439
            protected void addOption(ComplexSelectionCADToolContext context, String s)
440
            {
441
                ComplexSelectionCADTool ctxt = context.getOwner();
442

    
443

    
444
                (context.getState()).Exit(context);
445
                context.clearState();
446
                try
447
                {
448
                    ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection_or_types"));
449
                    ctxt.setDescription(new String[]{"end_polygon", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
450
                    ctxt.setType(s);
451
                }
452
                finally
453
                {
454
                    context.setState(Selection.FirstPoint);
455
                    (context.getState()).Entry(context);
456
                }
457
                return;
458
            }
459

    
460
            protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event)
461
            {
462
                ComplexSelectionCADTool ctxt = context.getOwner();
463

    
464
                if (ctxt.selectWithSecondPoint(pointX,pointY, event) > 0)
465
                {
466

    
467
                    (context.getState()).Exit(context);
468
                    context.clearState();
469
                    try
470
                    {
471
                        ctxt.setQuestion(PluginServices.getText(this,"select_handlers"));
472
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
473
                        ctxt.addPoint(pointX, pointY, event);
474
                        ctxt.end();
475
                    }
476
                    finally
477
                    {
478
                        context.setState(Selection.WithSelectedFeatures);
479
                        (context.getState()).Entry(context);
480
                    }
481
                }
482
                else
483
                {
484

    
485
                    (context.getState()).Exit(context);
486
                    context.clearState();
487
                    try
488
                    {
489
                        ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection_or_types"));
490
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
491
                        ctxt.addPoint(pointX, pointY, event);
492
                    }
493
                    finally
494
                    {
495
                        context.setState(Selection.FirstPoint);
496
                        (context.getState()).Entry(context);
497
                    }
498
                }
499

    
500
                return;
501
            }
502

    
503
        //-------------------------------------------------------
504
        // Member data.
505
        //
506
        }
507

    
508
        private static final class Selection_WithSelectedFeatures
509
            extends Selection_Default
510
        {
511
        //-------------------------------------------------------
512
        // Member methods.
513
        //
514

    
515
            private Selection_WithSelectedFeatures(String name, int id)
516
            {
517
                super (name, id);
518
            }
519

    
520
            protected void addOption(ComplexSelectionCADToolContext context, String s)
521
            {
522
                ComplexSelectionCADTool ctxt = context.getOwner();
523

    
524

    
525
                (context.getState()).Exit(context);
526
                context.clearState();
527
                try
528
                {
529
                    ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection_or_types"));
530
                    ctxt.setDescription(new String[]{"end_polygon", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
531
                    ctxt.setType(s);
532
                }
533
                finally
534
                {
535
                    context.setState(Selection.FirstPoint);
536
                    (context.getState()).Entry(context);
537
                }
538
                return;
539
            }
540

    
541
            protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event)
542
            {
543
                ComplexSelectionCADTool ctxt = context.getOwner();
544

    
545
                if (ctxt.selectHandlers(pointX, pointY, event)>0)
546
                {
547

    
548
                    (context.getState()).Exit(context);
549
                    context.clearState();
550
                    try
551
                    {
552
                        ctxt.setQuestion(PluginServices.getText(this,"insert_destination_point"));
553
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
554
                        ctxt.addPoint(pointX, pointY, event);
555
                    }
556
                    finally
557
                    {
558
                        context.setState(Selection.WithHandlers);
559
                        (context.getState()).Entry(context);
560
                    }
561
                }
562
                else if (ctxt.selectFeatures(pointX,pointY, event) && ctxt.getNextState().equals("Selection.WithSelectedFeatures"))
563
                {
564
                    ComplexSelectionCADToolState endState = context.getState();
565

    
566
                    context.clearState();
567
                    try
568
                    {
569
                        ctxt.setQuestion(PluginServices.getText(this,"select_handlers"));
570
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
571
                        ctxt.addPoint(pointX, pointY, event);
572
                    }
573
                    finally
574
                    {
575
                        context.setState(endState);
576
                    }
577
                }
578
                else
579
                {
580

    
581
                    (context.getState()).Exit(context);
582
                    context.clearState();
583
                    try
584
                    {
585
                        ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection_or_types"));
586
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
587
                        ctxt.addPoint(pointX, pointY, event);
588
                    }
589
                    finally
590
                    {
591
                        context.setState(Selection.FirstPoint);
592
                        (context.getState()).Entry(context);
593
                    }
594
                }
595

    
596
                return;
597
            }
598

    
599
        //-------------------------------------------------------
600
        // Member data.
601
        //
602
        }
603

    
604
        private static final class Selection_WithHandlers
605
            extends Selection_Default
606
        {
607
        //-------------------------------------------------------
608
        // Member methods.
609
        //
610

    
611
            private Selection_WithHandlers(String name, int id)
612
            {
613
                super (name, id);
614
            }
615

    
616
            protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event)
617
            {
618
                ComplexSelectionCADTool ctxt = context.getOwner();
619

    
620

    
621
                (context.getState()).Exit(context);
622
                context.clearState();
623
                try
624
                {
625
                    ctxt.setQuestion(PluginServices.getText(this,"select_handlers"));
626
                    ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
627
                    ctxt.addPoint(pointX, pointY, event);
628
                    ctxt.refresh();
629
                }
630
                finally
631
                {
632
                    context.setState(Selection.WithSelectedFeatures);
633
                    (context.getState()).Entry(context);
634
                }
635
                return;
636
            }
637

    
638
        //-------------------------------------------------------
639
        // Member data.
640
        //
641
        }
642

    
643
        private static final class Selection_SecondPointOutRectangle
644
            extends Selection_Default
645
        {
646
        //-------------------------------------------------------
647
        // Member methods.
648
        //
649

    
650
            private Selection_SecondPointOutRectangle(String name, int id)
651
            {
652
                super (name, id);
653
            }
654

    
655
            protected void addOption(ComplexSelectionCADToolContext context, String s)
656
            {
657
                ComplexSelectionCADTool ctxt = context.getOwner();
658

    
659

    
660
                (context.getState()).Exit(context);
661
                context.clearState();
662
                try
663
                {
664
                    ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection_or_types"));
665
                    ctxt.setDescription(new String[]{"end_polygon", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
666
                    ctxt.setType(s);
667
                }
668
                finally
669
                {
670
                    context.setState(Selection.FirstPoint);
671
                    (context.getState()).Entry(context);
672
                }
673
                return;
674
            }
675

    
676
            protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event)
677
            {
678
                ComplexSelectionCADTool ctxt = context.getOwner();
679

    
680
                if (ctxt.selectWithSecondPointOutRectangle(pointX,pointY, event) > 0)
681
                {
682

    
683
                    (context.getState()).Exit(context);
684
                    context.clearState();
685
                    try
686
                    {
687
                        ctxt.setQuestion(PluginServices.getText(this,"select_handlers"));
688
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
689
                        ctxt.addPoint(pointX, pointY, event);
690
                        ctxt.end();
691
                    }
692
                    finally
693
                    {
694
                        context.setState(Selection.WithSelectedFeatures);
695
                        (context.getState()).Entry(context);
696
                    }
697
                }
698
                else
699
                {
700

    
701
                    (context.getState()).Exit(context);
702
                    context.clearState();
703
                    try
704
                    {
705
                        ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection_or_types"));
706
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
707
                        ctxt.addPoint(pointX, pointY, event);
708
                    }
709
                    finally
710
                    {
711
                        context.setState(Selection.FirstPoint);
712
                        (context.getState()).Entry(context);
713
                    }
714
                }
715

    
716
                return;
717
            }
718

    
719
        //-------------------------------------------------------
720
        // Member data.
721
        //
722
        }
723

    
724
        private static final class Selection_SecondPointCircle
725
            extends Selection_Default
726
        {
727
        //-------------------------------------------------------
728
        // Member methods.
729
        //
730

    
731
            private Selection_SecondPointCircle(String name, int id)
732
            {
733
                super (name, id);
734
            }
735

    
736
            protected void addOption(ComplexSelectionCADToolContext context, String s)
737
            {
738
                ComplexSelectionCADTool ctxt = context.getOwner();
739

    
740

    
741
                (context.getState()).Exit(context);
742
                context.clearState();
743
                try
744
                {
745
                    ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection_or_types"));
746
                    ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
747
                    ctxt.setType(s);
748
                }
749
                finally
750
                {
751
                    context.setState(Selection.FirstPoint);
752
                    (context.getState()).Entry(context);
753
                }
754
                return;
755
            }
756

    
757
            protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event)
758
            {
759
                ComplexSelectionCADTool ctxt = context.getOwner();
760

    
761
                if (ctxt.selectWithCircle(pointX,pointY, event) > 0)
762
                {
763

    
764
                    (context.getState()).Exit(context);
765
                    context.clearState();
766
                    try
767
                    {
768
                        ctxt.setQuestion(PluginServices.getText(this,"select_handlers"));
769
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
770
                        ctxt.addPoint(pointX, pointY, event);
771
                        ctxt.end();
772
                    }
773
                    finally
774
                    {
775
                        context.setState(Selection.WithSelectedFeatures);
776
                        (context.getState()).Entry(context);
777
                    }
778
                }
779
                else
780
                {
781

    
782
                    (context.getState()).Exit(context);
783
                    context.clearState();
784
                    try
785
                    {
786
                        ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection_or_types"));
787
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
788
                        ctxt.addPoint(pointX, pointY, event);
789
                    }
790
                    finally
791
                    {
792
                        context.setState(Selection.FirstPoint);
793
                        (context.getState()).Entry(context);
794
                    }
795
                }
796

    
797
                return;
798
            }
799

    
800
        //-------------------------------------------------------
801
        // Member data.
802
        //
803
        }
804

    
805
        private static final class Selection_NextPointPolygon
806
            extends Selection_Default
807
        {
808
        //-------------------------------------------------------
809
        // Member methods.
810
        //
811

    
812
            private Selection_NextPointPolygon(String name, int id)
813
            {
814
                super (name, id);
815
            }
816

    
817
            protected void addOption(ComplexSelectionCADToolContext context, String s)
818
            {
819
                ComplexSelectionCADTool ctxt = context.getOwner();
820

    
821

    
822
                (context.getState()).Exit(context);
823
                context.clearState();
824
                try
825
                {
826
                    ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection_or_types"));
827
                    ctxt.setDescription(new String[]{"end_polygon", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
828
                    ctxt.addOption(s);
829
                }
830
                finally
831
                {
832
                    context.setState(Selection.FirstPoint);
833
                    (context.getState()).Entry(context);
834
                }
835
                return;
836
            }
837

    
838
            protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event)
839
            {
840
                ComplexSelectionCADTool ctxt = context.getOwner();
841

    
842
                ComplexSelectionCADToolState endState = context.getState();
843

    
844
                context.clearState();
845
                try
846
                {
847
                    ctxt.setQuestion(PluginServices.getText(this,"insert_next_point_selection_or_end_polygon"));
848
                    ctxt.setDescription(new String[]{"end_polygon", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
849
                    ctxt.addPoint(pointX, pointY, event);
850
                }
851
                finally
852
                {
853
                    context.setState(endState);
854
                }
855
                return;
856
            }
857

    
858
        //-------------------------------------------------------
859
        // Member data.
860
        //
861
        }
862

    
863
    //-----------------------------------------------------------
864
    // Member data.
865
    //
866
    }
867
}