Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extCAD / src / com / iver / cit / gvsig / gui / cad / tools / smc / ComplexSelectionCADToolContext.java @ 10626

History | View | Annotate | Download (42.2 KB)

1

    
2
//
3
// Vicente Caballero Navarro
4

    
5

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

    
8
import java.awt.event.InputEvent;
9

    
10
import com.iver.andami.PluginServices;
11
import com.iver.cit.gvsig.gui.cad.tools.ComplexSelectionCADTool;
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")+" "+
319
            PluginServices.getText(this,"cad.or")+" "+
320
            PluginServices.getText(this,"circle")+
321
            "["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+
322
            PluginServices.getText(this,"out_rectangle")+
323
            "["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+
324
            PluginServices.getText(this,"polygon")+
325
            "["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+
326
            PluginServices.getText(this,"cross_polygon")+
327
                   "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+
328
            "#"+PluginServices.getText(this,"out_polygon")+
329
                   "["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+
330
            PluginServices.getText(this,"cross_circle")+
331
                   "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+
332
                PluginServices.getText(this,"out_circle")+
333
                   "["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]");
334
                ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
335
                return;
336
            }
337

    
338
            protected void addOption(ComplexSelectionCADToolContext context, String s)
339
            {
340
                ComplexSelectionCADTool ctxt = context.getOwner();
341

    
342
                ComplexSelectionCADToolState endState = context.getState();
343

    
344
                context.clearState();
345
                try
346
                {
347
                    ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+
348
                    PluginServices.getText(this,"cad.or")+" "+
349
                    PluginServices.getText(this,"circle")+
350
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+
351
                    PluginServices.getText(this,"out_rectangle")+
352
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"], "+
353
                    PluginServices.getText(this,"polygon")+
354
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+
355
                    PluginServices.getText(this,"cross_polygon")+
356
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+
357
                    "#"+PluginServices.getText(this,"out_polygon")+
358
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+
359
                    PluginServices.getText(this,"cross_circle")+
360
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+
361
                        PluginServices.getText(this,"out_circle")+
362
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]");
363
                    ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
364
                    ctxt.addOption(s);
365
                }
366
                finally
367
                {
368
                    context.setState(endState);
369
                }
370
                return;
371
            }
372

    
373
            protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event)
374
            {
375
                ComplexSelectionCADTool ctxt = context.getOwner();
376

    
377
                if (ctxt.getType().equals(PluginServices.getText(this,"out_rectangle")))
378
                {
379

    
380
                    (context.getState()).Exit(context);
381
                    context.clearState();
382
                    try
383
                    {
384
                        ctxt.setQuestion(PluginServices.getText(this,"insert_second_point_selection"));
385
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
386
                        ctxt.addPoint(pointX, pointY, event);
387
                    }
388
                    finally
389
                    {
390
                        context.setState(Selection.SecondPointOutRectangle);
391
                        (context.getState()).Entry(context);
392
                    }
393
                }
394
                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")))
395
                {
396

    
397
                    (context.getState()).Exit(context);
398
                    context.clearState();
399
                    try
400
                    {
401
                        ctxt.setQuestion(PluginServices.getText(this,"insert_second_point_selection"));
402
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
403
                        ctxt.addPoint(pointX, pointY, event);
404
                    }
405
                    finally
406
                    {
407
                        context.setState(Selection.SecondPointCircle);
408
                        (context.getState()).Entry(context);
409
                    }
410
                }
411
                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")))
412
                {
413

    
414
                    (context.getState()).Exit(context);
415
                    context.clearState();
416
                    try
417
                    {
418
                        ctxt.setQuestion(PluginServices.getText(this,"insert_next_point_selection_or_end_polygon")+
419
                "["+PluginServices.getText(this,"ComplexSelectionCADTool.end")+"]");
420
                        ctxt.setDescription(new String[]{"end_polygon", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
421
                        ctxt.addPoint(pointX, pointY, event);
422
                    }
423
                    finally
424
                    {
425
                        context.setState(Selection.NextPointPolygon);
426
                        (context.getState()).Entry(context);
427
                    }
428
                }
429
                else if (ctxt.getType().equals(PluginServices.getText(this,"simple")) && ctxt.selectFeatures(pointX,pointY, event) && ctxt.getNextState().equals("Selection.SecondPoint"))
430
                {
431

    
432
                    (context.getState()).Exit(context);
433
                    context.clearState();
434
                    try
435
                    {
436
                        ctxt.setQuestion(PluginServices.getText(this,"insert_second_point_selection"));
437
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
438
                        ctxt.addPoint(pointX, pointY, event);
439
                    }
440
                    finally
441
                    {
442
                        context.setState(Selection.SecondPoint);
443
                        (context.getState()).Entry(context);
444
                    }
445
                }                else
446
                {
447
                    super.addPoint(context, pointX, pointY, event);
448
                }
449

    
450
                return;
451
            }
452

    
453
        //-------------------------------------------------------
454
        // Member data.
455
        //
456
        }
457

    
458
        private static final class Selection_SecondPoint
459
            extends Selection_Default
460
        {
461
        //-------------------------------------------------------
462
        // Member methods.
463
        //
464

    
465
            private Selection_SecondPoint(String name, int id)
466
            {
467
                super (name, id);
468
            }
469

    
470
            protected void addOption(ComplexSelectionCADToolContext context, String s)
471
            {
472
                ComplexSelectionCADTool ctxt = context.getOwner();
473

    
474

    
475
                (context.getState()).Exit(context);
476
                context.clearState();
477
                try
478
                {
479
                    ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+
480
                    PluginServices.getText(this,"cad.or")+" "+
481
                    PluginServices.getText(this,"circle")+
482
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+
483
                    PluginServices.getText(this,"out_rectangle")+
484
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+
485
                    PluginServices.getText(this,"polygon")+
486
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+
487
                    PluginServices.getText(this,"cross_polygon")+
488
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+
489
                    "#"+PluginServices.getText(this,"out_polygon")+
490
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+
491
                    PluginServices.getText(this,"cross_circle")+
492
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+
493
                        PluginServices.getText(this,"out_circle")+
494
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]");
495
                    ctxt.setDescription(new String[]{"end_polygon", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
496
                    ctxt.setType(s);
497
                }
498
                finally
499
                {
500
                    context.setState(Selection.FirstPoint);
501
                    (context.getState()).Entry(context);
502
                }
503
                return;
504
            }
505

    
506
            protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event)
507
            {
508
                ComplexSelectionCADTool ctxt = context.getOwner();
509

    
510
                if (ctxt.selectWithSecondPoint(pointX,pointY, event) > 0)
511
                {
512

    
513
                    (context.getState()).Exit(context);
514
                    context.clearState();
515
                    try
516
                    {
517
                        ctxt.setQuestion(PluginServices.getText(this,"select_handlers"));
518
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
519
                        ctxt.addPoint(pointX, pointY, event);
520
                        ctxt.end();
521
                    }
522
                    finally
523
                    {
524
                        context.setState(Selection.WithSelectedFeatures);
525
                        (context.getState()).Entry(context);
526
                    }
527
                }
528
                else
529
                {
530

    
531
                    (context.getState()).Exit(context);
532
                    context.clearState();
533
                    try
534
                    {
535
                        ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+
536
                    PluginServices.getText(this,"cad.or")+" "+
537
                    PluginServices.getText(this,"circle")+
538
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+
539
                    PluginServices.getText(this,"out_rectangle")+
540
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+
541
                    PluginServices.getText(this,"polygon")+
542
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+
543
                    PluginServices.getText(this,"cross_polygon")+
544
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+
545
                    "#"+PluginServices.getText(this,"out_polygon")+
546
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+
547
                    PluginServices.getText(this,"cross_circle")+
548
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+
549
                        PluginServices.getText(this,"out_circle")+
550
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]");
551
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
552
                        ctxt.addPoint(pointX, pointY, event);
553
                    }
554
                    finally
555
                    {
556
                        context.setState(Selection.FirstPoint);
557
                        (context.getState()).Entry(context);
558
                    }
559
                }
560

    
561
                return;
562
            }
563

    
564
        //-------------------------------------------------------
565
        // Member data.
566
        //
567
        }
568

    
569
        private static final class Selection_WithSelectedFeatures
570
            extends Selection_Default
571
        {
572
        //-------------------------------------------------------
573
        // Member methods.
574
        //
575

    
576
            private Selection_WithSelectedFeatures(String name, int id)
577
            {
578
                super (name, id);
579
            }
580

    
581
            protected void addOption(ComplexSelectionCADToolContext context, String s)
582
            {
583
                ComplexSelectionCADTool ctxt = context.getOwner();
584

    
585

    
586
                (context.getState()).Exit(context);
587
                context.clearState();
588
                try
589
                {
590
                    ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+
591
                    PluginServices.getText(this,"cad.or")+" "+
592
                    PluginServices.getText(this,"circle")+
593
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+
594
                    PluginServices.getText(this,"out_rectangle")+
595
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+
596
                    PluginServices.getText(this,"polygon")+
597
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+
598
                    PluginServices.getText(this,"cross_polygon")+
599
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+
600
                    "#"+PluginServices.getText(this,"out_polygon")+
601
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+
602
                    PluginServices.getText(this,"cross_circle")+
603
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+
604
                        PluginServices.getText(this,"out_circle")+
605
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]");
606
                    ctxt.setDescription(new String[]{"end_polygon", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
607
                    ctxt.setType(s);
608
                }
609
                finally
610
                {
611
                    context.setState(Selection.FirstPoint);
612
                    (context.getState()).Entry(context);
613
                }
614
                return;
615
            }
616

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

    
621
                if (ctxt.selectHandlers(pointX, pointY, event)>0)
622
                {
623

    
624
                    (context.getState()).Exit(context);
625
                    context.clearState();
626
                    try
627
                    {
628
                        ctxt.setQuestion(PluginServices.getText(this,"insert_destination_point"));
629
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
630
                        ctxt.addPoint(pointX, pointY, event);
631
                    }
632
                    finally
633
                    {
634
                        context.setState(Selection.WithHandlers);
635
                        (context.getState()).Entry(context);
636
                    }
637
                }
638
                else if (ctxt.selectFeatures(pointX,pointY, event) && ctxt.getNextState().equals("Selection.WithSelectedFeatures"))
639
                {
640
                    ComplexSelectionCADToolState endState = context.getState();
641

    
642
                    context.clearState();
643
                    try
644
                    {
645
                        ctxt.setQuestion(PluginServices.getText(this,"select_handlers"));
646
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
647
                        ctxt.addPoint(pointX, pointY, event);
648
                    }
649
                    finally
650
                    {
651
                        context.setState(endState);
652
                    }
653
                }
654
                else
655
                {
656

    
657
                    (context.getState()).Exit(context);
658
                    context.clearState();
659
                    try
660
                    {
661
                        ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+
662
                    PluginServices.getText(this,"cad.or")+" "+
663
                    PluginServices.getText(this,"circle")+
664
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+
665
                    PluginServices.getText(this,"out_rectangle")+
666
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+
667
                    PluginServices.getText(this,"polygon")+
668
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+
669
                    PluginServices.getText(this,"cross_polygon")+
670
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+
671
                    "#"+PluginServices.getText(this,"out_polygon")+
672
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+
673
                    PluginServices.getText(this,"cross_circle")+
674
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+
675
                        PluginServices.getText(this,"out_circle")+
676
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]");
677
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
678
                        ctxt.addPoint(pointX, pointY, event);
679
                    }
680
                    finally
681
                    {
682
                        context.setState(Selection.FirstPoint);
683
                        (context.getState()).Entry(context);
684
                    }
685
                }
686

    
687
                return;
688
            }
689

    
690
        //-------------------------------------------------------
691
        // Member data.
692
        //
693
        }
694

    
695
        private static final class Selection_WithHandlers
696
            extends Selection_Default
697
        {
698
        //-------------------------------------------------------
699
        // Member methods.
700
        //
701

    
702
            private Selection_WithHandlers(String name, int id)
703
            {
704
                super (name, id);
705
            }
706

    
707
            protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event)
708
            {
709
                ComplexSelectionCADTool ctxt = context.getOwner();
710

    
711

    
712
                (context.getState()).Exit(context);
713
                context.clearState();
714
                try
715
                {
716
                    ctxt.setQuestion(PluginServices.getText(this,"select_handlers"));
717
                    ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
718
                    ctxt.addPoint(pointX, pointY, event);
719
                    ctxt.refresh();
720
                }
721
                finally
722
                {
723
                    context.setState(Selection.WithSelectedFeatures);
724
                    (context.getState()).Entry(context);
725
                }
726
                return;
727
            }
728

    
729
        //-------------------------------------------------------
730
        // Member data.
731
        //
732
        }
733

    
734
        private static final class Selection_SecondPointOutRectangle
735
            extends Selection_Default
736
        {
737
        //-------------------------------------------------------
738
        // Member methods.
739
        //
740

    
741
            private Selection_SecondPointOutRectangle(String name, int id)
742
            {
743
                super (name, id);
744
            }
745

    
746
            protected void addOption(ComplexSelectionCADToolContext context, String s)
747
            {
748
                ComplexSelectionCADTool ctxt = context.getOwner();
749

    
750

    
751
                (context.getState()).Exit(context);
752
                context.clearState();
753
                try
754
                {
755
                    ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+
756
                    PluginServices.getText(this,"cad.or")+" "+
757
                    PluginServices.getText(this,"circle")+
758
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+
759
                    PluginServices.getText(this,"out_rectangle")+
760
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+
761
                    PluginServices.getText(this,"polygon")+
762
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+
763
                    PluginServices.getText(this,"cross_polygon")+
764
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+
765
                    "#"+PluginServices.getText(this,"out_polygon")+
766
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+
767
                    PluginServices.getText(this,"cross_circle")+
768
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+
769
                        PluginServices.getText(this,"out_circle")+
770
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]");
771
                    ctxt.setDescription(new String[]{"end_polygon", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
772
                    ctxt.setType(s);
773
                }
774
                finally
775
                {
776
                    context.setState(Selection.FirstPoint);
777
                    (context.getState()).Entry(context);
778
                }
779
                return;
780
            }
781

    
782
            protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event)
783
            {
784
                ComplexSelectionCADTool ctxt = context.getOwner();
785

    
786
                if (ctxt.selectWithSecondPointOutRectangle(pointX,pointY, event) > 0)
787
                {
788

    
789
                    (context.getState()).Exit(context);
790
                    context.clearState();
791
                    try
792
                    {
793
                        ctxt.setQuestion(PluginServices.getText(this,"select_handlers"));
794
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
795
                        ctxt.addPoint(pointX, pointY, event);
796
                        ctxt.end();
797
                    }
798
                    finally
799
                    {
800
                        context.setState(Selection.WithSelectedFeatures);
801
                        (context.getState()).Entry(context);
802
                    }
803
                }
804
                else
805
                {
806

    
807
                    (context.getState()).Exit(context);
808
                    context.clearState();
809
                    try
810
                    {
811
                        ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+
812
                    PluginServices.getText(this,"cad.or")+" "+
813
                    PluginServices.getText(this,"circle")+
814
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+
815
                    PluginServices.getText(this,"out_rectangle")+
816
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+
817
                    PluginServices.getText(this,"polygon")+
818
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+
819
                    PluginServices.getText(this,"cross_polygon")+
820
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+
821
                    "#"+PluginServices.getText(this,"out_polygon")+
822
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+
823
                    PluginServices.getText(this,"cross_circle")+
824
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+
825
                        PluginServices.getText(this,"out_circle")+
826
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]");
827
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
828
                        ctxt.addPoint(pointX, pointY, event);
829
                    }
830
                    finally
831
                    {
832
                        context.setState(Selection.FirstPoint);
833
                        (context.getState()).Entry(context);
834
                    }
835
                }
836

    
837
                return;
838
            }
839

    
840
        //-------------------------------------------------------
841
        // Member data.
842
        //
843
        }
844

    
845
        private static final class Selection_SecondPointCircle
846
            extends Selection_Default
847
        {
848
        //-------------------------------------------------------
849
        // Member methods.
850
        //
851

    
852
            private Selection_SecondPointCircle(String name, int id)
853
            {
854
                super (name, id);
855
            }
856

    
857
            protected void addOption(ComplexSelectionCADToolContext context, String s)
858
            {
859
                ComplexSelectionCADTool ctxt = context.getOwner();
860

    
861

    
862
                (context.getState()).Exit(context);
863
                context.clearState();
864
                try
865
                {
866
                    ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+
867
                    PluginServices.getText(this,"cad.or")+" "+
868
                    PluginServices.getText(this,"circle")+
869
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+
870
                    PluginServices.getText(this,"out_rectangle")+
871
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+
872
                    PluginServices.getText(this,"polygon")+
873
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+
874
                    PluginServices.getText(this,"cross_polygon")+
875
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+
876
                    "#"+PluginServices.getText(this,"out_polygon")+
877
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+
878
                    PluginServices.getText(this,"cross_circle")+
879
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+
880
                        PluginServices.getText(this,"out_circle")+
881
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]");
882
                    ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
883
                    ctxt.setType(s);
884
                }
885
                finally
886
                {
887
                    context.setState(Selection.FirstPoint);
888
                    (context.getState()).Entry(context);
889
                }
890
                return;
891
            }
892

    
893
            protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event)
894
            {
895
                ComplexSelectionCADTool ctxt = context.getOwner();
896

    
897
                if (ctxt.selectWithCircle(pointX,pointY, event) > 0)
898
                {
899

    
900
                    (context.getState()).Exit(context);
901
                    context.clearState();
902
                    try
903
                    {
904
                        ctxt.setQuestion(PluginServices.getText(this,"select_handlers"));
905
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
906
                        ctxt.addPoint(pointX, pointY, event);
907
                        ctxt.end();
908
                    }
909
                    finally
910
                    {
911
                        context.setState(Selection.WithSelectedFeatures);
912
                        (context.getState()).Entry(context);
913
                    }
914
                }
915
                else
916
                {
917

    
918
                    (context.getState()).Exit(context);
919
                    context.clearState();
920
                    try
921
                    {
922
                        ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+
923
                    PluginServices.getText(this,"cad.or")+" "+
924
                    PluginServices.getText(this,"circle")+
925
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+
926
                    PluginServices.getText(this,"out_rectangle")+
927
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+
928
                    PluginServices.getText(this,"polygon")+
929
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+
930
                    PluginServices.getText(this,"cross_polygon")+
931
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+
932
                    "#"+PluginServices.getText(this,"out_polygon")+
933
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+
934
                    PluginServices.getText(this,"cross_circle")+
935
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+
936
                        PluginServices.getText(this,"out_circle")+
937
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]");
938
                        ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
939
                        ctxt.addPoint(pointX, pointY, event);
940
                    }
941
                    finally
942
                    {
943
                        context.setState(Selection.FirstPoint);
944
                        (context.getState()).Entry(context);
945
                    }
946
                }
947

    
948
                return;
949
            }
950

    
951
        //-------------------------------------------------------
952
        // Member data.
953
        //
954
        }
955

    
956
        private static final class Selection_NextPointPolygon
957
            extends Selection_Default
958
        {
959
        //-------------------------------------------------------
960
        // Member methods.
961
        //
962

    
963
            private Selection_NextPointPolygon(String name, int id)
964
            {
965
                super (name, id);
966
            }
967

    
968
            protected void addOption(ComplexSelectionCADToolContext context, String s)
969
            {
970
                ComplexSelectionCADTool ctxt = context.getOwner();
971

    
972

    
973
                (context.getState()).Exit(context);
974
                context.clearState();
975
                try
976
                {
977
                    ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+
978
                    PluginServices.getText(this,"cad.or")+" "+
979
                    PluginServices.getText(this,"circle")+
980
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+
981
                    PluginServices.getText(this,"out_rectangle")+
982
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+
983
                    PluginServices.getText(this,"polygon")+
984
                    "["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+
985
                    PluginServices.getText(this,"cross_polygon")+
986
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+
987
                    "#"+PluginServices.getText(this,"out_polygon")+
988
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+
989
                    PluginServices.getText(this,"cross_circle")+
990
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+
991
                        PluginServices.getText(this,"out_circle")+
992
                           "["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]");
993
                    ctxt.setDescription(new String[]{"end_polygon", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
994
                    ctxt.addOption(s);
995
                }
996
                finally
997
                {
998
                    context.setState(Selection.FirstPoint);
999
                    (context.getState()).Entry(context);
1000
                }
1001
                return;
1002
            }
1003

    
1004
            protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event)
1005
            {
1006
                ComplexSelectionCADTool ctxt = context.getOwner();
1007

    
1008
                ComplexSelectionCADToolState endState = context.getState();
1009

    
1010
                context.clearState();
1011
                try
1012
                {
1013
                    ctxt.setQuestion(PluginServices.getText(this,"insert_next_point_selection_or_end_polygon")+
1014
                "["+PluginServices.getText(this,"ComplexSelectionCADTool.end")+"]");
1015
                    ctxt.setDescription(new String[]{"end_polygon", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
1016
                    ctxt.addPoint(pointX, pointY, event);
1017
                }
1018
                finally
1019
                {
1020
                    context.setState(endState);
1021
                }
1022
                return;
1023
            }
1024

    
1025
        //-------------------------------------------------------
1026
        // Member data.
1027
        //
1028
        }
1029

    
1030
    //-----------------------------------------------------------
1031
    // Member data.
1032
    //
1033
    }
1034
}