root / trunk / extensions / extCAD / src / com / iver / cit / gvsig / gui / cad / tools / smc / SelectionCADToolContext.java @ 4892
History | View | Annotate | Download (29.8 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.SelectionCADTool; |
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 SelectionCADToolContext |
14 |
extends statemap.FSMContext
|
15 |
{ |
16 |
//---------------------------------------------------------------
|
17 |
// Member methods.
|
18 |
//
|
19 |
|
20 |
public SelectionCADToolContext(SelectionCADTool 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 SelectionCADToolState getState()
|
46 |
throws statemap.StateUndefinedException
|
47 |
{ |
48 |
if (_state == null) |
49 |
{ |
50 |
throw(
|
51 |
new statemap.StateUndefinedException());
|
52 |
} |
53 |
|
54 |
return ((SelectionCADToolState) _state);
|
55 |
} |
56 |
|
57 |
protected SelectionCADTool getOwner()
|
58 |
{ |
59 |
return (_owner);
|
60 |
} |
61 |
|
62 |
//---------------------------------------------------------------
|
63 |
// Member data.
|
64 |
//
|
65 |
|
66 |
transient private SelectionCADTool _owner; |
67 |
|
68 |
//---------------------------------------------------------------
|
69 |
// Inner classes.
|
70 |
//
|
71 |
|
72 |
public static abstract class SelectionCADToolState |
73 |
extends statemap.State
|
74 |
{ |
75 |
//-----------------------------------------------------------
|
76 |
// Member methods.
|
77 |
//
|
78 |
|
79 |
protected SelectionCADToolState(String name, int id) |
80 |
{ |
81 |
super (name, id);
|
82 |
} |
83 |
|
84 |
protected void Entry(SelectionCADToolContext context) {} |
85 |
protected void Exit(SelectionCADToolContext context) {} |
86 |
|
87 |
protected void addOption(SelectionCADToolContext context, String s) |
88 |
{ |
89 |
Default(context); |
90 |
} |
91 |
|
92 |
protected void addPoint(SelectionCADToolContext context, double pointX, double pointY, InputEvent event) |
93 |
{ |
94 |
Default(context); |
95 |
} |
96 |
|
97 |
protected void Default(SelectionCADToolContext context) |
98 |
{ |
99 |
throw (
|
100 |
new statemap.TransitionUndefinedException(
|
101 |
"State: " +
|
102 |
context.getState().getName() + |
103 |
", Transition: " +
|
104 |
context.getTransition())); |
105 |
} |
106 |
|
107 |
//-----------------------------------------------------------
|
108 |
// Member data.
|
109 |
//
|
110 |
} |
111 |
|
112 |
/* package */ static abstract class Selection |
113 |
{ |
114 |
//-----------------------------------------------------------
|
115 |
// Member methods.
|
116 |
//
|
117 |
|
118 |
//-----------------------------------------------------------
|
119 |
// Member data.
|
120 |
//
|
121 |
|
122 |
//-------------------------------------------------------
|
123 |
// Statics.
|
124 |
//
|
125 |
/* package */ static Selection_Default.Selection_FirstPoint FirstPoint; |
126 |
/* package */ static Selection_Default.Selection_SecondPoint SecondPoint; |
127 |
/* package */ static Selection_Default.Selection_WithSelectedFeatures WithSelectedFeatures; |
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 |
private static Selection_Default Default; |
133 |
|
134 |
static
|
135 |
{ |
136 |
FirstPoint = new Selection_Default.Selection_FirstPoint("Selection.FirstPoint", 0); |
137 |
SecondPoint = new Selection_Default.Selection_SecondPoint("Selection.SecondPoint", 1); |
138 |
WithSelectedFeatures = new Selection_Default.Selection_WithSelectedFeatures("Selection.WithSelectedFeatures", 2); |
139 |
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 |
Default = new Selection_Default("Selection.Default", -1); |
144 |
} |
145 |
|
146 |
} |
147 |
|
148 |
protected static class Selection_Default |
149 |
extends SelectionCADToolState
|
150 |
{ |
151 |
//-----------------------------------------------------------
|
152 |
// Member methods.
|
153 |
//
|
154 |
|
155 |
protected Selection_Default(String name, int id) |
156 |
{ |
157 |
super (name, id);
|
158 |
} |
159 |
|
160 |
protected void addOption(SelectionCADToolContext context, String s) |
161 |
{ |
162 |
SelectionCADTool ctxt = context.getOwner(); |
163 |
|
164 |
if (s.equals(PluginServices.getText(this,"cancel"))) |
165 |
{ |
166 |
boolean loopbackFlag =
|
167 |
context.getState().getName().equals( |
168 |
Selection.FirstPoint.getName()); |
169 |
|
170 |
if (loopbackFlag == false) |
171 |
{ |
172 |
(context.getState()).Exit(context); |
173 |
} |
174 |
|
175 |
context.clearState(); |
176 |
try
|
177 |
{ |
178 |
ctxt.end(); |
179 |
} |
180 |
finally
|
181 |
{ |
182 |
context.setState(Selection.FirstPoint); |
183 |
|
184 |
if (loopbackFlag == false) |
185 |
{ |
186 |
(context.getState()).Entry(context); |
187 |
} |
188 |
|
189 |
} |
190 |
} |
191 |
else
|
192 |
{ |
193 |
super.addOption(context, s);
|
194 |
} |
195 |
|
196 |
return;
|
197 |
} |
198 |
|
199 |
//-----------------------------------------------------------
|
200 |
// Inner classse.
|
201 |
//
|
202 |
|
203 |
|
204 |
private static final class Selection_FirstPoint |
205 |
extends Selection_Default
|
206 |
{ |
207 |
//-------------------------------------------------------
|
208 |
// Member methods.
|
209 |
//
|
210 |
|
211 |
private Selection_FirstPoint(String name, int id) |
212 |
{ |
213 |
super (name, id);
|
214 |
} |
215 |
|
216 |
protected void Entry(SelectionCADToolContext context) |
217 |
{ |
218 |
SelectionCADTool ctxt = context.getOwner(); |
219 |
|
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"}); |
222 |
return;
|
223 |
} |
224 |
|
225 |
protected void addOption(SelectionCADToolContext context, String s) |
226 |
{ |
227 |
SelectionCADTool ctxt = context.getOwner(); |
228 |
|
229 |
SelectionCADToolState endState = context.getState(); |
230 |
|
231 |
context.clearState(); |
232 |
try
|
233 |
{ |
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"}); |
236 |
ctxt.addOption(s); |
237 |
} |
238 |
finally
|
239 |
{ |
240 |
context.setState(endState); |
241 |
} |
242 |
return;
|
243 |
} |
244 |
|
245 |
protected void addPoint(SelectionCADToolContext context, double pointX, double pointY, InputEvent event) |
246 |
{ |
247 |
SelectionCADTool ctxt = context.getOwner(); |
248 |
|
249 |
if (ctxt.getType().equals(PluginServices.getText(this,"out_rectangle"))) |
250 |
{ |
251 |
|
252 |
(context.getState()).Exit(context); |
253 |
context.clearState(); |
254 |
try
|
255 |
{ |
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"}); |
258 |
ctxt.addPoint(pointX, pointY, event); |
259 |
} |
260 |
finally
|
261 |
{ |
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 |
context.setState(Selection.SecondPoint); |
314 |
(context.getState()).Entry(context); |
315 |
} |
316 |
} |
317 |
else if (ctxt.getType().equals(PluginServices.getText(this,"simple")) && ctxt.getNextState().equals("Selection.WithSelectedFeatures")) |
318 |
{ |
319 |
|
320 |
(context.getState()).Exit(context); |
321 |
context.clearState(); |
322 |
try
|
323 |
{ |
324 |
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"}); |
326 |
ctxt.addPoint(pointX, pointY, event); |
327 |
ctxt.end(); |
328 |
} |
329 |
finally
|
330 |
{ |
331 |
context.setState(Selection.WithSelectedFeatures); |
332 |
(context.getState()).Entry(context); |
333 |
} |
334 |
} else
|
335 |
{ |
336 |
super.addPoint(context, pointX, pointY, event);
|
337 |
} |
338 |
|
339 |
return;
|
340 |
} |
341 |
|
342 |
//-------------------------------------------------------
|
343 |
// Member data.
|
344 |
//
|
345 |
} |
346 |
|
347 |
private static final class Selection_SecondPoint |
348 |
extends Selection_Default
|
349 |
{ |
350 |
//-------------------------------------------------------
|
351 |
// Member methods.
|
352 |
//
|
353 |
|
354 |
private Selection_SecondPoint(String name, int id) |
355 |
{ |
356 |
super (name, id);
|
357 |
} |
358 |
|
359 |
protected void addOption(SelectionCADToolContext context, String s) |
360 |
{ |
361 |
SelectionCADTool ctxt = context.getOwner(); |
362 |
|
363 |
|
364 |
(context.getState()).Exit(context); |
365 |
context.clearState(); |
366 |
try
|
367 |
{ |
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"}); |
370 |
ctxt.setType(s); |
371 |
} |
372 |
finally
|
373 |
{ |
374 |
context.setState(Selection.FirstPoint); |
375 |
(context.getState()).Entry(context); |
376 |
} |
377 |
return;
|
378 |
} |
379 |
|
380 |
protected void addPoint(SelectionCADToolContext context, double pointX, double pointY, InputEvent event) |
381 |
{ |
382 |
SelectionCADTool ctxt = context.getOwner(); |
383 |
|
384 |
if (ctxt.selectWithSecondPoint(pointX,pointY, event) > 0) |
385 |
{ |
386 |
|
387 |
(context.getState()).Exit(context); |
388 |
context.clearState(); |
389 |
try
|
390 |
{ |
391 |
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"}); |
393 |
ctxt.addPoint(pointX, pointY, event); |
394 |
ctxt.end(); |
395 |
} |
396 |
finally
|
397 |
{ |
398 |
context.setState(Selection.WithSelectedFeatures); |
399 |
(context.getState()).Entry(context); |
400 |
} |
401 |
} |
402 |
else
|
403 |
{ |
404 |
|
405 |
(context.getState()).Exit(context); |
406 |
context.clearState(); |
407 |
try
|
408 |
{ |
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"}); |
411 |
ctxt.addPoint(pointX, pointY, event); |
412 |
} |
413 |
finally
|
414 |
{ |
415 |
context.setState(Selection.FirstPoint); |
416 |
(context.getState()).Entry(context); |
417 |
} |
418 |
} |
419 |
|
420 |
return;
|
421 |
} |
422 |
|
423 |
//-------------------------------------------------------
|
424 |
// Member data.
|
425 |
//
|
426 |
} |
427 |
|
428 |
private static final class Selection_WithSelectedFeatures |
429 |
extends Selection_Default
|
430 |
{ |
431 |
//-------------------------------------------------------
|
432 |
// Member methods.
|
433 |
//
|
434 |
|
435 |
private Selection_WithSelectedFeatures(String name, int id) |
436 |
{ |
437 |
super (name, id);
|
438 |
} |
439 |
|
440 |
protected void addOption(SelectionCADToolContext context, String s) |
441 |
{ |
442 |
SelectionCADTool ctxt = context.getOwner(); |
443 |
|
444 |
|
445 |
(context.getState()).Exit(context); |
446 |
context.clearState(); |
447 |
try
|
448 |
{ |
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"}); |
451 |
ctxt.setType(s); |
452 |
} |
453 |
finally
|
454 |
{ |
455 |
context.setState(Selection.FirstPoint); |
456 |
(context.getState()).Entry(context); |
457 |
} |
458 |
return;
|
459 |
} |
460 |
|
461 |
protected void addPoint(SelectionCADToolContext context, double pointX, double pointY, InputEvent event) |
462 |
{ |
463 |
SelectionCADTool ctxt = context.getOwner(); |
464 |
|
465 |
if (ctxt.selectHandlers(pointX, pointY, event)>0) |
466 |
{ |
467 |
|
468 |
(context.getState()).Exit(context); |
469 |
context.clearState(); |
470 |
try
|
471 |
{ |
472 |
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"}); |
474 |
ctxt.addPoint(pointX, pointY, event); |
475 |
} |
476 |
finally
|
477 |
{ |
478 |
context.setState(Selection.WithHandlers); |
479 |
(context.getState()).Entry(context); |
480 |
} |
481 |
} |
482 |
else if (ctxt.selectFeatures(pointX,pointY, event) && ctxt.getNextState().equals("Selection.WithSelectedFeatures")) |
483 |
{ |
484 |
SelectionCADToolState endState = context.getState(); |
485 |
|
486 |
context.clearState(); |
487 |
try
|
488 |
{ |
489 |
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"}); |
491 |
ctxt.addPoint(pointX, pointY, event); |
492 |
} |
493 |
finally
|
494 |
{ |
495 |
context.setState(endState); |
496 |
} |
497 |
} |
498 |
else
|
499 |
{ |
500 |
|
501 |
(context.getState()).Exit(context); |
502 |
context.clearState(); |
503 |
try
|
504 |
{ |
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"}); |
507 |
ctxt.addPoint(pointX, pointY, event); |
508 |
} |
509 |
finally
|
510 |
{ |
511 |
context.setState(Selection.FirstPoint); |
512 |
(context.getState()).Entry(context); |
513 |
} |
514 |
} |
515 |
|
516 |
return;
|
517 |
} |
518 |
|
519 |
//-------------------------------------------------------
|
520 |
// Member data.
|
521 |
//
|
522 |
} |
523 |
|
524 |
private static final class Selection_WithHandlers |
525 |
extends Selection_Default
|
526 |
{ |
527 |
//-------------------------------------------------------
|
528 |
// Member methods.
|
529 |
//
|
530 |
|
531 |
private Selection_WithHandlers(String name, int id) |
532 |
{ |
533 |
super (name, id);
|
534 |
} |
535 |
|
536 |
protected void addPoint(SelectionCADToolContext context, double pointX, double pointY, InputEvent event) |
537 |
{ |
538 |
SelectionCADTool ctxt = context.getOwner(); |
539 |
|
540 |
|
541 |
(context.getState()).Exit(context); |
542 |
context.clearState(); |
543 |
try
|
544 |
{ |
545 |
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"}); |
547 |
ctxt.addPoint(pointX, pointY, event); |
548 |
ctxt.refresh(); |
549 |
} |
550 |
finally
|
551 |
{ |
552 |
context.setState(Selection.WithSelectedFeatures); |
553 |
(context.getState()).Entry(context); |
554 |
} |
555 |
return;
|
556 |
} |
557 |
|
558 |
//-------------------------------------------------------
|
559 |
// Member data.
|
560 |
//
|
561 |
} |
562 |
|
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 |
//-----------------------------------------------------------
|
784 |
// Member data.
|
785 |
//
|
786 |
} |
787 |
} |