Revision 5207 trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/smc/SelectionCADToolContext.java

View differences:

SelectionCADToolContext.java
126 126
        /* package */ static Selection_Default.Selection_SecondPoint SecondPoint;
127 127
        /* package */ static Selection_Default.Selection_WithSelectedFeatures WithSelectedFeatures;
128 128
        /* package */ static Selection_Default.Selection_WithHandlers WithHandlers;
129
        /* package */ static Selection_Default.Selection_SecondPointOutRectangle SecondPointOutRectangle;
130
        /* package */ static Selection_Default.Selection_SecondPointCircle SecondPointCircle;
131
        /* package */ static Selection_Default.Selection_NextPointPolygon NextPointPolygon;
132 129
        private static Selection_Default Default;
133 130

  
134 131
        static
......
137 134
            SecondPoint = new Selection_Default.Selection_SecondPoint("Selection.SecondPoint", 1);
138 135
            WithSelectedFeatures = new Selection_Default.Selection_WithSelectedFeatures("Selection.WithSelectedFeatures", 2);
139 136
            WithHandlers = new Selection_Default.Selection_WithHandlers("Selection.WithHandlers", 3);
140
            SecondPointOutRectangle = new Selection_Default.Selection_SecondPointOutRectangle("Selection.SecondPointOutRectangle", 4);
141
            SecondPointCircle = new Selection_Default.Selection_SecondPointCircle("Selection.SecondPointCircle", 5);
142
            NextPointPolygon = new Selection_Default.Selection_NextPointPolygon("Selection.NextPointPolygon", 6);
143 137
            Default = new Selection_Default("Selection.Default", -1);
144 138
        }
145 139

  
......
217 211
            {
218 212
                SelectionCADTool ctxt = context.getOwner();
219 213

  
220
                ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection_or_types"));
221
                ctxt.setDescription(new String[]{"simple", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
214
                ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection"));
215
                ctxt.setDescription(new String[]{"cancel"});
222 216
                return;
223 217
            }
224 218

  
......
231 225
                context.clearState();
232 226
                try
233 227
                {
234
                    ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection_or_types"));
235
                    ctxt.setDescription(new String[]{"simple", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
228
                    ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection"));
229
                    ctxt.setDescription(new String[]{"cancel"});
236 230
                    ctxt.addOption(s);
237 231
                }
238 232
                finally
......
246 240
            {
247 241
                SelectionCADTool ctxt = context.getOwner();
248 242

  
249
                if (ctxt.getType().equals(PluginServices.getText(this,"out_rectangle")))
243
                if (ctxt.getType().equals(PluginServices.getText(this,"simple")) && ctxt.selectFeatures(pointX,pointY, event) && ctxt.getNextState().equals("Selection.SecondPoint"))
250 244
                {
251 245

  
252 246
                    (context.getState()).Exit(context);
253 247
                    context.clearState();
254 248
                    try
255 249
                    {
256
                        ctxt.setQuestion(PluginServices.getText(this,"insert_second_point_selection"));
257
                        ctxt.setDescription(new String[]{"simple", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
250
                        ctxt.setQuestion(PluginServices.getText(this,"insert_second_point"));
251
                        ctxt.setDescription(new String[]{"cancel"});
258 252
                        ctxt.addPoint(pointX, pointY, event);
259 253
                    }
260 254
                    finally
261 255
                    {
262
                        context.setState(Selection.SecondPointOutRectangle);
263
                        (context.getState()).Entry(context);
264
                    }
265
                }
266
                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")))
267
                {
268

  
269
                    (context.getState()).Exit(context);
270
                    context.clearState();
271
                    try
272
                    {
273
                        ctxt.setQuestion(PluginServices.getText(this,"insert_second_point_selection"));
274
                        ctxt.setDescription(new String[]{"simple", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
275
                        ctxt.addPoint(pointX, pointY, event);
276
                    }
277
                    finally
278
                    {
279
                        context.setState(Selection.SecondPointCircle);
280
                        (context.getState()).Entry(context);
281
                    }
282
                }
283
                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")))
284
                {
285

  
286
                    (context.getState()).Exit(context);
287
                    context.clearState();
288
                    try
289
                    {
290
                        ctxt.setQuestion(PluginServices.getText(this,"insert_next_point_selection_or_end_polygon"));
291
                        ctxt.setDescription(new String[]{"end_polygon", "simple", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
292
                        ctxt.addPoint(pointX, pointY, event);
293
                    }
294
                    finally
295
                    {
296
                        context.setState(Selection.NextPointPolygon);
297
                        (context.getState()).Entry(context);
298
                    }
299
                }
300
                else if (ctxt.getType().equals(PluginServices.getText(this,"simple")) && ctxt.selectFeatures(pointX,pointY, event) && ctxt.getNextState().equals("Selection.SecondPoint"))
301
                {
302

  
303
                    (context.getState()).Exit(context);
304
                    context.clearState();
305
                    try
306
                    {
307
                        ctxt.setQuestion(PluginServices.getText(this,"insert_second_point_selection"));
308
                        ctxt.setDescription(new String[]{"simple", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
309
                        ctxt.addPoint(pointX, pointY, event);
310
                    }
311
                    finally
312
                    {
313 256
                        context.setState(Selection.SecondPoint);
314 257
                        (context.getState()).Entry(context);
315 258
                    }
......
322 265
                    try
323 266
                    {
324 267
                        ctxt.setQuestion(PluginServices.getText(this,"select_handlers"));
325
                        ctxt.setDescription(new String[]{"simple", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
268
                        ctxt.setDescription(new String[]{"cancel"});
326 269
                        ctxt.addPoint(pointX, pointY, event);
327 270
                        ctxt.end();
328 271
                    }
......
365 308
                context.clearState();
366 309
                try
367 310
                {
368
                    ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection_or_types"));
369
                    ctxt.setDescription(new String[]{"end_polygon", "simple", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
311
                    ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection"));
312
                    ctxt.setDescription(new String[]{"cancel"});
370 313
                    ctxt.setType(s);
371 314
                }
372 315
                finally
......
389 332
                    try
390 333
                    {
391 334
                        ctxt.setQuestion(PluginServices.getText(this,"select_handlers"));
392
                        ctxt.setDescription(new String[]{"simple", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
335
                        ctxt.setDescription(new String[]{"cancel"});
393 336
                        ctxt.addPoint(pointX, pointY, event);
394 337
                        ctxt.end();
395 338
                    }
......
406 349
                    context.clearState();
407 350
                    try
408 351
                    {
409
                        ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection_or_types"));
410
                        ctxt.setDescription(new String[]{"simple", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
352
                        ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection"));
353
                        ctxt.setDescription(new String[]{"cancel"});
411 354
                        ctxt.addPoint(pointX, pointY, event);
412 355
                    }
413 356
                    finally
......
446 389
                context.clearState();
447 390
                try
448 391
                {
449
                    ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection_or_types"));
450
                    ctxt.setDescription(new String[]{"end_polygon", "simple", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
392
                    ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection"));
393
                    ctxt.setDescription(new String[]{"cancel"});
451 394
                    ctxt.setType(s);
452 395
                }
453 396
                finally
......
470 413
                    try
471 414
                    {
472 415
                        ctxt.setQuestion(PluginServices.getText(this,"insert_destination_point"));
473
                        ctxt.setDescription(new String[]{"simple", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
416
                        ctxt.setDescription(new String[]{"cancel"});
474 417
                        ctxt.addPoint(pointX, pointY, event);
475 418
                    }
476 419
                    finally
......
487 430
                    try
488 431
                    {
489 432
                        ctxt.setQuestion(PluginServices.getText(this,"select_handlers"));
490
                        ctxt.setDescription(new String[]{"simple", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
433
                        ctxt.setDescription(new String[]{"cancel"});
491 434
                        ctxt.addPoint(pointX, pointY, event);
492 435
                    }
493 436
                    finally
......
502 445
                    context.clearState();
503 446
                    try
504 447
                    {
505
                        ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection_or_types"));
506
                        ctxt.setDescription(new String[]{"simple", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
448
                        ctxt.setQuestion(PluginServices.getText(this,"insert_point_selection"));
449
                        ctxt.setDescription(new String[]{"cancel"});
507 450
                        ctxt.addPoint(pointX, pointY, event);
508 451
                    }
509 452
                    finally
......
543 486
                try
544 487
                {
545 488
                    ctxt.setQuestion(PluginServices.getText(this,"select_handlers"));
546
                    ctxt.setDescription(new String[]{"simple", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
489
                    ctxt.setDescription(new String[]{"cancel"});
547 490
                    ctxt.addPoint(pointX, pointY, event);
548 491
                    ctxt.refresh();
549 492
                }
......
560 503
        //
561 504
        }
562 505

  
563
        private static final class Selection_SecondPointOutRectangle
564
            extends Selection_Default
565
        {
566
        //-------------------------------------------------------
567
        // Member methods.
568
        //
569

  
570
            private Selection_SecondPointOutRectangle(String name, int id)
571
            {
572
                super (name, id);
573
            }
574

  
575
            protected void addOption(SelectionCADToolContext context, String s)
576
            {
577
                SelectionCADTool ctxt = context.getOwner();
578

  
579

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

  
596
            protected void addPoint(SelectionCADToolContext context, double pointX, double pointY, InputEvent event)
597
            {
598
                SelectionCADTool ctxt = context.getOwner();
599

  
600
                if (ctxt.selectWithSecondPointOutRectangle(pointX,pointY, event) > 0)
601
                {
602

  
603
                    (context.getState()).Exit(context);
604
                    context.clearState();
605
                    try
606
                    {
607
                        ctxt.setQuestion(PluginServices.getText(this,"select_handlers"));
608
                        ctxt.setDescription(new String[]{"simple", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
609
                        ctxt.addPoint(pointX, pointY, event);
610
                        ctxt.end();
611
                    }
612
                    finally
613
                    {
614
                        context.setState(Selection.WithSelectedFeatures);
615
                        (context.getState()).Entry(context);
616
                    }
617
                }
618
                else
619
                {
620

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

  
636
                return;
637
            }
638

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

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

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

  
656
            protected void addOption(SelectionCADToolContext context, String s)
657
            {
658
                SelectionCADTool ctxt = context.getOwner();
659

  
660

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

  
677
            protected void addPoint(SelectionCADToolContext context, double pointX, double pointY, InputEvent event)
678
            {
679
                SelectionCADTool ctxt = context.getOwner();
680

  
681
                if (ctxt.selectWithCircle(pointX,pointY, event) > 0)
682
                {
683

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

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

  
717
                return;
718
            }
719

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

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

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

  
737
            protected void addOption(SelectionCADToolContext context, String s)
738
            {
739
                SelectionCADTool ctxt = context.getOwner();
740

  
741

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

  
758
            protected void addPoint(SelectionCADToolContext context, double pointX, double pointY, InputEvent event)
759
            {
760
                SelectionCADTool ctxt = context.getOwner();
761

  
762
                SelectionCADToolState endState = context.getState();
763

  
764
                context.clearState();
765
                try
766
                {
767
                    ctxt.setQuestion(PluginServices.getText(this,"insert_next_selection_or_end_polygon"));
768
                    ctxt.setDescription(new String[]{"end_polygon", "simple", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"});
769
                    ctxt.addPoint(pointX, pointY, event);
770
                }
771
                finally
772
                {
773
                    context.setState(endState);
774
                }
775
                return;
776
            }
777

  
778
        //-------------------------------------------------------
779
        // Member data.
780
        //
781
        }
782

  
783 506
    //-----------------------------------------------------------
784 507
    // Member data.
785 508
    //

Also available in: Unified diff