root / branches / v2_0_0_prep / extensions / extEditing / src / com / iver / cit / gvsig / gui / cad / tools / smc / ComplexSelectionCADToolContext.java @ 26243
History | View | Annotate | Download (42.4 KB)
1 |
|
---|---|
2 |
//
|
3 |
// Vicente Caballero Navarro
|
4 |
|
5 |
|
6 |
package com.iver.cit.gvsig.gui.cad.tools.smc; |
7 |
|
8 |
import com.iver.cit.gvsig.gui.cad.tools.ComplexSelectionCADTool; |
9 |
import java.awt.event.InputEvent; |
10 |
import com.iver.andami.PluginServices; |
11 |
|
12 |
public final class ComplexSelectionCADToolContext |
13 |
extends statemap.FSMContext
|
14 |
{ |
15 |
//---------------------------------------------------------------
|
16 |
// Member methods.
|
17 |
//
|
18 |
|
19 |
public ComplexSelectionCADToolContext(ComplexSelectionCADTool owner)
|
20 |
{ |
21 |
super();
|
22 |
|
23 |
_owner = owner; |
24 |
setState(Selection.FirstPoint); |
25 |
Selection.FirstPoint.Entry(this);
|
26 |
} |
27 |
|
28 |
public void addOption(String s) |
29 |
{ |
30 |
_transition = "addOption";
|
31 |
getState().addOption(this, s);
|
32 |
_transition = "";
|
33 |
return;
|
34 |
} |
35 |
|
36 |
public void addPoint(double pointX, double pointY, InputEvent event) |
37 |
{ |
38 |
_transition = "addPoint";
|
39 |
getState().addPoint(this, pointX, pointY, event);
|
40 |
_transition = "";
|
41 |
return;
|
42 |
} |
43 |
|
44 |
public void addValue(double d) |
45 |
{ |
46 |
_transition = "addValue";
|
47 |
getState().addValue(this, d);
|
48 |
_transition = "";
|
49 |
return;
|
50 |
} |
51 |
|
52 |
public ComplexSelectionCADToolState getState()
|
53 |
throws statemap.StateUndefinedException
|
54 |
{ |
55 |
if (_state == null) |
56 |
{ |
57 |
throw(
|
58 |
new statemap.StateUndefinedException());
|
59 |
} |
60 |
|
61 |
return ((ComplexSelectionCADToolState) _state);
|
62 |
} |
63 |
|
64 |
protected ComplexSelectionCADTool getOwner()
|
65 |
{ |
66 |
return (_owner);
|
67 |
} |
68 |
|
69 |
//---------------------------------------------------------------
|
70 |
// Member data.
|
71 |
//
|
72 |
|
73 |
transient private ComplexSelectionCADTool _owner; |
74 |
|
75 |
//---------------------------------------------------------------
|
76 |
// Inner classes.
|
77 |
//
|
78 |
|
79 |
public static abstract class ComplexSelectionCADToolState |
80 |
extends statemap.State
|
81 |
{ |
82 |
//-----------------------------------------------------------
|
83 |
// Member methods.
|
84 |
//
|
85 |
|
86 |
protected ComplexSelectionCADToolState(String name, int id) |
87 |
{ |
88 |
super (name, id);
|
89 |
} |
90 |
|
91 |
protected void Entry(ComplexSelectionCADToolContext context) {} |
92 |
protected void Exit(ComplexSelectionCADToolContext context) {} |
93 |
|
94 |
protected void addOption(ComplexSelectionCADToolContext context, String s) |
95 |
{ |
96 |
Default(context); |
97 |
} |
98 |
|
99 |
protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event) |
100 |
{ |
101 |
Default(context); |
102 |
} |
103 |
|
104 |
protected void addValue(ComplexSelectionCADToolContext context, double d) |
105 |
{ |
106 |
Default(context); |
107 |
} |
108 |
|
109 |
protected void Default(ComplexSelectionCADToolContext context) |
110 |
{ |
111 |
throw (
|
112 |
new statemap.TransitionUndefinedException(
|
113 |
"State: " +
|
114 |
context.getState().getName() + |
115 |
", Transition: " +
|
116 |
context.getTransition())); |
117 |
} |
118 |
|
119 |
//-----------------------------------------------------------
|
120 |
// Member data.
|
121 |
//
|
122 |
} |
123 |
|
124 |
/* package */ static abstract class Selection |
125 |
{ |
126 |
//-----------------------------------------------------------
|
127 |
// Member methods.
|
128 |
//
|
129 |
|
130 |
//-----------------------------------------------------------
|
131 |
// Member data.
|
132 |
//
|
133 |
|
134 |
//-------------------------------------------------------
|
135 |
// Statics.
|
136 |
//
|
137 |
/* package */ static Selection_Default.Selection_FirstPoint FirstPoint; |
138 |
/* package */ static Selection_Default.Selection_SecondPoint SecondPoint; |
139 |
/* package */ static Selection_Default.Selection_WithSelectedFeatures WithSelectedFeatures; |
140 |
/* package */ static Selection_Default.Selection_WithHandlers WithHandlers; |
141 |
/* package */ static Selection_Default.Selection_SecondPointOutRectangle SecondPointOutRectangle; |
142 |
/* package */ static Selection_Default.Selection_SecondPointCircle SecondPointCircle; |
143 |
/* package */ static Selection_Default.Selection_NextPointPolygon NextPointPolygon; |
144 |
private static Selection_Default Default; |
145 |
|
146 |
static
|
147 |
{ |
148 |
FirstPoint = new Selection_Default.Selection_FirstPoint("Selection.FirstPoint", 0); |
149 |
SecondPoint = new Selection_Default.Selection_SecondPoint("Selection.SecondPoint", 1); |
150 |
WithSelectedFeatures = new Selection_Default.Selection_WithSelectedFeatures("Selection.WithSelectedFeatures", 2); |
151 |
WithHandlers = new Selection_Default.Selection_WithHandlers("Selection.WithHandlers", 3); |
152 |
SecondPointOutRectangle = new Selection_Default.Selection_SecondPointOutRectangle("Selection.SecondPointOutRectangle", 4); |
153 |
SecondPointCircle = new Selection_Default.Selection_SecondPointCircle("Selection.SecondPointCircle", 5); |
154 |
NextPointPolygon = new Selection_Default.Selection_NextPointPolygon("Selection.NextPointPolygon", 6); |
155 |
Default = new Selection_Default("Selection.Default", -1); |
156 |
} |
157 |
|
158 |
} |
159 |
|
160 |
protected static class Selection_Default |
161 |
extends ComplexSelectionCADToolState
|
162 |
{ |
163 |
//-----------------------------------------------------------
|
164 |
// Member methods.
|
165 |
//
|
166 |
|
167 |
protected Selection_Default(String name, int id) |
168 |
{ |
169 |
super (name, id);
|
170 |
} |
171 |
|
172 |
protected void addOption(ComplexSelectionCADToolContext context, String s) |
173 |
{ |
174 |
ComplexSelectionCADTool ctxt = context.getOwner(); |
175 |
|
176 |
if (s.equals(PluginServices.getText(this,"cancel"))) |
177 |
{ |
178 |
boolean loopbackFlag =
|
179 |
context.getState().getName().equals( |
180 |
Selection.FirstPoint.getName()); |
181 |
|
182 |
if (loopbackFlag == false) |
183 |
{ |
184 |
(context.getState()).Exit(context); |
185 |
} |
186 |
|
187 |
context.clearState(); |
188 |
try
|
189 |
{ |
190 |
ctxt.end(); |
191 |
} |
192 |
finally
|
193 |
{ |
194 |
context.setState(Selection.FirstPoint); |
195 |
|
196 |
if (loopbackFlag == false) |
197 |
{ |
198 |
(context.getState()).Entry(context); |
199 |
} |
200 |
|
201 |
} |
202 |
} |
203 |
else
|
204 |
{ |
205 |
boolean loopbackFlag =
|
206 |
context.getState().getName().equals( |
207 |
Selection.FirstPoint.getName()); |
208 |
|
209 |
if (loopbackFlag == false) |
210 |
{ |
211 |
(context.getState()).Exit(context); |
212 |
} |
213 |
|
214 |
context.clearState(); |
215 |
try
|
216 |
{ |
217 |
ctxt.throwOptionException(PluginServices.getText(this,"incorrect_option"), s); |
218 |
} |
219 |
finally
|
220 |
{ |
221 |
context.setState(Selection.FirstPoint); |
222 |
|
223 |
if (loopbackFlag == false) |
224 |
{ |
225 |
(context.getState()).Entry(context); |
226 |
} |
227 |
|
228 |
} |
229 |
} |
230 |
|
231 |
return;
|
232 |
} |
233 |
|
234 |
protected void addValue(ComplexSelectionCADToolContext context, double d) |
235 |
{ |
236 |
ComplexSelectionCADTool ctxt = context.getOwner(); |
237 |
|
238 |
boolean loopbackFlag =
|
239 |
context.getState().getName().equals( |
240 |
Selection.FirstPoint.getName()); |
241 |
|
242 |
if (loopbackFlag == false) |
243 |
{ |
244 |
(context.getState()).Exit(context); |
245 |
} |
246 |
|
247 |
context.clearState(); |
248 |
try
|
249 |
{ |
250 |
ctxt.throwValueException(PluginServices.getText(this,"incorrect_value"), d); |
251 |
} |
252 |
finally
|
253 |
{ |
254 |
context.setState(Selection.FirstPoint); |
255 |
|
256 |
if (loopbackFlag == false) |
257 |
{ |
258 |
(context.getState()).Entry(context); |
259 |
} |
260 |
|
261 |
} |
262 |
return;
|
263 |
} |
264 |
|
265 |
protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event) |
266 |
{ |
267 |
ComplexSelectionCADTool ctxt = context.getOwner(); |
268 |
|
269 |
boolean loopbackFlag =
|
270 |
context.getState().getName().equals( |
271 |
Selection.FirstPoint.getName()); |
272 |
|
273 |
if (loopbackFlag == false) |
274 |
{ |
275 |
(context.getState()).Exit(context); |
276 |
} |
277 |
|
278 |
context.clearState(); |
279 |
try
|
280 |
{ |
281 |
ctxt.throwPointException(PluginServices.getText(this,"incorrect_point"), pointX, pointY); |
282 |
} |
283 |
finally
|
284 |
{ |
285 |
context.setState(Selection.FirstPoint); |
286 |
|
287 |
if (loopbackFlag == false) |
288 |
{ |
289 |
(context.getState()).Entry(context); |
290 |
} |
291 |
|
292 |
} |
293 |
return;
|
294 |
} |
295 |
|
296 |
//-----------------------------------------------------------
|
297 |
// Inner classse.
|
298 |
//
|
299 |
|
300 |
|
301 |
private static final class Selection_FirstPoint |
302 |
extends Selection_Default
|
303 |
{ |
304 |
//-------------------------------------------------------
|
305 |
// Member methods.
|
306 |
//
|
307 |
|
308 |
private Selection_FirstPoint(String name, int id) |
309 |
{ |
310 |
super (name, id);
|
311 |
} |
312 |
|
313 |
protected void Entry(ComplexSelectionCADToolContext context) |
314 |
{ |
315 |
ComplexSelectionCADTool ctxt = context.getOwner(); |
316 |
|
317 |
ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+ |
318 |
PluginServices.getText(this,"cad.or")+" "+ |
319 |
PluginServices.getText(this,"circle")+ |
320 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+ |
321 |
PluginServices.getText(this,"out_rectangle")+ |
322 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+ |
323 |
PluginServices.getText(this,"polygon")+ |
324 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+ |
325 |
PluginServices.getText(this,"cross_polygon")+ |
326 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+ |
327 |
"#"+PluginServices.getText(this,"out_polygon")+ |
328 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+ |
329 |
PluginServices.getText(this,"cross_circle")+ |
330 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+ |
331 |
PluginServices.getText(this,"out_circle")+ |
332 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]"); |
333 |
ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
334 |
return;
|
335 |
} |
336 |
|
337 |
protected void addOption(ComplexSelectionCADToolContext context, String s) |
338 |
{ |
339 |
ComplexSelectionCADTool ctxt = context.getOwner(); |
340 |
|
341 |
ComplexSelectionCADToolState endState = context.getState(); |
342 |
|
343 |
context.clearState(); |
344 |
try
|
345 |
{ |
346 |
ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+ |
347 |
PluginServices.getText(this,"cad.or")+" "+ |
348 |
PluginServices.getText(this,"circle")+ |
349 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+ |
350 |
PluginServices.getText(this,"out_rectangle")+ |
351 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"], "+ |
352 |
PluginServices.getText(this,"polygon")+ |
353 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+ |
354 |
PluginServices.getText(this,"cross_polygon")+ |
355 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+ |
356 |
"#"+PluginServices.getText(this,"out_polygon")+ |
357 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+ |
358 |
PluginServices.getText(this,"cross_circle")+ |
359 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+ |
360 |
PluginServices.getText(this,"out_circle")+ |
361 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]"); |
362 |
ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
363 |
ctxt.addOption(s); |
364 |
} |
365 |
finally
|
366 |
{ |
367 |
context.setState(endState); |
368 |
} |
369 |
return;
|
370 |
} |
371 |
|
372 |
protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event) |
373 |
{ |
374 |
ComplexSelectionCADTool ctxt = context.getOwner(); |
375 |
|
376 |
if (ctxt.getType().equals(PluginServices.getText(this,"out_rectangle"))) |
377 |
{ |
378 |
|
379 |
(context.getState()).Exit(context); |
380 |
context.clearState(); |
381 |
try
|
382 |
{ |
383 |
ctxt.setQuestion(PluginServices.getText(this,"insert_second_point_selection")); |
384 |
ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
385 |
ctxt.addPoint(pointX, pointY, event); |
386 |
} |
387 |
finally
|
388 |
{ |
389 |
context.setState(Selection.SecondPointOutRectangle); |
390 |
(context.getState()).Entry(context); |
391 |
} |
392 |
} |
393 |
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"))) |
394 |
{ |
395 |
|
396 |
(context.getState()).Exit(context); |
397 |
context.clearState(); |
398 |
try
|
399 |
{ |
400 |
ctxt.setQuestion(PluginServices.getText(this,"insert_second_point_selection")); |
401 |
ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
402 |
ctxt.addPoint(pointX, pointY, event); |
403 |
} |
404 |
finally
|
405 |
{ |
406 |
context.setState(Selection.SecondPointCircle); |
407 |
(context.getState()).Entry(context); |
408 |
} |
409 |
} |
410 |
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"))) |
411 |
{ |
412 |
|
413 |
(context.getState()).Exit(context); |
414 |
context.clearState(); |
415 |
try
|
416 |
{ |
417 |
ctxt.setQuestion(PluginServices.getText(this,"insert_next_point_selection_or_end_polygon")+ |
418 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.end")+"]"); |
419 |
ctxt.setDescription(new String[]{"end_polygon", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
420 |
ctxt.addPoint(pointX, pointY, event); |
421 |
} |
422 |
finally
|
423 |
{ |
424 |
context.setState(Selection.NextPointPolygon); |
425 |
(context.getState()).Entry(context); |
426 |
} |
427 |
} |
428 |
else if (ctxt.getType().equals(PluginServices.getText(this,"simple")) && ctxt.selectFeatures(pointX,pointY, event) && ctxt.getNextState().equals("Selection.SecondPoint")) |
429 |
{ |
430 |
|
431 |
(context.getState()).Exit(context); |
432 |
context.clearState(); |
433 |
try
|
434 |
{ |
435 |
ctxt.setQuestion(PluginServices.getText(this,"insert_second_point_selection")); |
436 |
ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
437 |
ctxt.addPoint(pointX, pointY, event); |
438 |
} |
439 |
finally
|
440 |
{ |
441 |
context.setState(Selection.SecondPoint); |
442 |
(context.getState()).Entry(context); |
443 |
} |
444 |
} else
|
445 |
{ |
446 |
super.addPoint(context, pointX, pointY, event);
|
447 |
} |
448 |
|
449 |
return;
|
450 |
} |
451 |
|
452 |
//-------------------------------------------------------
|
453 |
// Member data.
|
454 |
//
|
455 |
} |
456 |
|
457 |
private static final class Selection_SecondPoint |
458 |
extends Selection_Default
|
459 |
{ |
460 |
//-------------------------------------------------------
|
461 |
// Member methods.
|
462 |
//
|
463 |
|
464 |
private Selection_SecondPoint(String name, int id) |
465 |
{ |
466 |
super (name, id);
|
467 |
} |
468 |
|
469 |
protected void addOption(ComplexSelectionCADToolContext context, String s) |
470 |
{ |
471 |
ComplexSelectionCADTool ctxt = context.getOwner(); |
472 |
|
473 |
|
474 |
(context.getState()).Exit(context); |
475 |
context.clearState(); |
476 |
try
|
477 |
{ |
478 |
ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+ |
479 |
PluginServices.getText(this,"cad.or")+" "+ |
480 |
PluginServices.getText(this,"circle")+ |
481 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+ |
482 |
PluginServices.getText(this,"out_rectangle")+ |
483 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+ |
484 |
PluginServices.getText(this,"polygon")+ |
485 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+ |
486 |
PluginServices.getText(this,"cross_polygon")+ |
487 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+ |
488 |
"#"+PluginServices.getText(this,"out_polygon")+ |
489 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+ |
490 |
PluginServices.getText(this,"cross_circle")+ |
491 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+ |
492 |
PluginServices.getText(this,"out_circle")+ |
493 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]"); |
494 |
ctxt.setDescription(new String[]{"end_polygon", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
495 |
ctxt.setType(s); |
496 |
} |
497 |
finally
|
498 |
{ |
499 |
context.setState(Selection.FirstPoint); |
500 |
(context.getState()).Entry(context); |
501 |
} |
502 |
return;
|
503 |
} |
504 |
|
505 |
protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event) |
506 |
{ |
507 |
ComplexSelectionCADTool ctxt = context.getOwner(); |
508 |
|
509 |
if (ctxt.selectWithSecondPoint(pointX,pointY, event) > 0) |
510 |
{ |
511 |
|
512 |
(context.getState()).Exit(context); |
513 |
context.clearState(); |
514 |
try
|
515 |
{ |
516 |
ctxt.setQuestion(PluginServices.getText(this,"select_handlers")); |
517 |
ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
518 |
ctxt.addPoint(pointX, pointY, event); |
519 |
ctxt.end(); |
520 |
} |
521 |
finally
|
522 |
{ |
523 |
context.setState(Selection.WithSelectedFeatures); |
524 |
(context.getState()).Entry(context); |
525 |
} |
526 |
} |
527 |
else
|
528 |
{ |
529 |
|
530 |
(context.getState()).Exit(context); |
531 |
context.clearState(); |
532 |
try
|
533 |
{ |
534 |
ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+ |
535 |
PluginServices.getText(this,"cad.or")+" "+ |
536 |
PluginServices.getText(this,"circle")+ |
537 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+ |
538 |
PluginServices.getText(this,"out_rectangle")+ |
539 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+ |
540 |
PluginServices.getText(this,"polygon")+ |
541 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+ |
542 |
PluginServices.getText(this,"cross_polygon")+ |
543 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+ |
544 |
"#"+PluginServices.getText(this,"out_polygon")+ |
545 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+ |
546 |
PluginServices.getText(this,"cross_circle")+ |
547 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+ |
548 |
PluginServices.getText(this,"out_circle")+ |
549 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]"); |
550 |
ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
551 |
ctxt.addPoint(pointX, pointY, event); |
552 |
} |
553 |
finally
|
554 |
{ |
555 |
context.setState(Selection.FirstPoint); |
556 |
(context.getState()).Entry(context); |
557 |
} |
558 |
} |
559 |
|
560 |
return;
|
561 |
} |
562 |
|
563 |
//-------------------------------------------------------
|
564 |
// Member data.
|
565 |
//
|
566 |
} |
567 |
|
568 |
private static final class Selection_WithSelectedFeatures |
569 |
extends Selection_Default
|
570 |
{ |
571 |
//-------------------------------------------------------
|
572 |
// Member methods.
|
573 |
//
|
574 |
|
575 |
private Selection_WithSelectedFeatures(String name, int id) |
576 |
{ |
577 |
super (name, id);
|
578 |
} |
579 |
|
580 |
protected void addOption(ComplexSelectionCADToolContext context, String s) |
581 |
{ |
582 |
ComplexSelectionCADTool ctxt = context.getOwner(); |
583 |
|
584 |
|
585 |
(context.getState()).Exit(context); |
586 |
context.clearState(); |
587 |
try
|
588 |
{ |
589 |
ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+ |
590 |
PluginServices.getText(this,"cad.or")+" "+ |
591 |
PluginServices.getText(this,"circle")+ |
592 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+ |
593 |
PluginServices.getText(this,"out_rectangle")+ |
594 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+ |
595 |
PluginServices.getText(this,"polygon")+ |
596 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+ |
597 |
PluginServices.getText(this,"cross_polygon")+ |
598 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+ |
599 |
"#"+PluginServices.getText(this,"out_polygon")+ |
600 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+ |
601 |
PluginServices.getText(this,"cross_circle")+ |
602 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+ |
603 |
PluginServices.getText(this,"out_circle")+ |
604 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]"); |
605 |
ctxt.setDescription(new String[]{"end_polygon", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
606 |
ctxt.setType(s); |
607 |
} |
608 |
finally
|
609 |
{ |
610 |
context.setState(Selection.FirstPoint); |
611 |
(context.getState()).Entry(context); |
612 |
} |
613 |
return;
|
614 |
} |
615 |
|
616 |
protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event) |
617 |
{ |
618 |
ComplexSelectionCADTool ctxt = context.getOwner(); |
619 |
|
620 |
if (ctxt.selectHandlers(pointX, pointY, event)>0) |
621 |
{ |
622 |
|
623 |
(context.getState()).Exit(context); |
624 |
context.clearState(); |
625 |
try
|
626 |
{ |
627 |
ctxt.setQuestion(PluginServices.getText(this,"insert_destination_point")); |
628 |
ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
629 |
ctxt.addPoint(pointX, pointY, event); |
630 |
} |
631 |
finally
|
632 |
{ |
633 |
context.setState(Selection.WithHandlers); |
634 |
(context.getState()).Entry(context); |
635 |
} |
636 |
} |
637 |
else if (ctxt.selectFeatures(pointX,pointY, event) && ctxt.getNextState().equals("Selection.WithSelectedFeatures")) |
638 |
{ |
639 |
ComplexSelectionCADToolState endState = context.getState(); |
640 |
|
641 |
context.clearState(); |
642 |
try
|
643 |
{ |
644 |
ctxt.setQuestion(PluginServices.getText(this,"select_handlers")); |
645 |
ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
646 |
ctxt.addPoint(pointX, pointY, event); |
647 |
} |
648 |
finally
|
649 |
{ |
650 |
context.setState(endState); |
651 |
} |
652 |
} |
653 |
else
|
654 |
{ |
655 |
|
656 |
(context.getState()).Exit(context); |
657 |
context.clearState(); |
658 |
try
|
659 |
{ |
660 |
ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+ |
661 |
PluginServices.getText(this,"cad.or")+" "+ |
662 |
PluginServices.getText(this,"circle")+ |
663 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+ |
664 |
PluginServices.getText(this,"out_rectangle")+ |
665 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+ |
666 |
PluginServices.getText(this,"polygon")+ |
667 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+ |
668 |
PluginServices.getText(this,"cross_polygon")+ |
669 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+ |
670 |
"#"+PluginServices.getText(this,"out_polygon")+ |
671 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+ |
672 |
PluginServices.getText(this,"cross_circle")+ |
673 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+ |
674 |
PluginServices.getText(this,"out_circle")+ |
675 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]"); |
676 |
ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
677 |
ctxt.addPoint(pointX, pointY, event); |
678 |
} |
679 |
finally
|
680 |
{ |
681 |
context.setState(Selection.FirstPoint); |
682 |
(context.getState()).Entry(context); |
683 |
} |
684 |
} |
685 |
|
686 |
return;
|
687 |
} |
688 |
|
689 |
//-------------------------------------------------------
|
690 |
// Member data.
|
691 |
//
|
692 |
} |
693 |
|
694 |
private static final class Selection_WithHandlers |
695 |
extends Selection_Default
|
696 |
{ |
697 |
//-------------------------------------------------------
|
698 |
// Member methods.
|
699 |
//
|
700 |
|
701 |
private Selection_WithHandlers(String name, int id) |
702 |
{ |
703 |
super (name, id);
|
704 |
} |
705 |
|
706 |
protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event) |
707 |
{ |
708 |
ComplexSelectionCADTool ctxt = context.getOwner(); |
709 |
|
710 |
|
711 |
(context.getState()).Exit(context); |
712 |
context.clearState(); |
713 |
try
|
714 |
{ |
715 |
ctxt.setQuestion(PluginServices.getText(this,"select_handlers")); |
716 |
ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
717 |
ctxt.addPoint(pointX, pointY, event); |
718 |
ctxt.refresh(); |
719 |
} |
720 |
finally
|
721 |
{ |
722 |
context.setState(Selection.WithSelectedFeatures); |
723 |
(context.getState()).Entry(context); |
724 |
} |
725 |
return;
|
726 |
} |
727 |
|
728 |
//-------------------------------------------------------
|
729 |
// Member data.
|
730 |
//
|
731 |
} |
732 |
|
733 |
private static final class Selection_SecondPointOutRectangle |
734 |
extends Selection_Default
|
735 |
{ |
736 |
//-------------------------------------------------------
|
737 |
// Member methods.
|
738 |
//
|
739 |
|
740 |
private Selection_SecondPointOutRectangle(String name, int id) |
741 |
{ |
742 |
super (name, id);
|
743 |
} |
744 |
|
745 |
protected void addOption(ComplexSelectionCADToolContext context, String s) |
746 |
{ |
747 |
ComplexSelectionCADTool ctxt = context.getOwner(); |
748 |
|
749 |
|
750 |
(context.getState()).Exit(context); |
751 |
context.clearState(); |
752 |
try
|
753 |
{ |
754 |
ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+ |
755 |
PluginServices.getText(this,"cad.or")+" "+ |
756 |
PluginServices.getText(this,"circle")+ |
757 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+ |
758 |
PluginServices.getText(this,"out_rectangle")+ |
759 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+ |
760 |
PluginServices.getText(this,"polygon")+ |
761 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+ |
762 |
PluginServices.getText(this,"cross_polygon")+ |
763 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+ |
764 |
"#"+PluginServices.getText(this,"out_polygon")+ |
765 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+ |
766 |
PluginServices.getText(this,"cross_circle")+ |
767 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+ |
768 |
PluginServices.getText(this,"out_circle")+ |
769 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]"); |
770 |
ctxt.setDescription(new String[]{"end_polygon", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
771 |
ctxt.setType(s); |
772 |
} |
773 |
finally
|
774 |
{ |
775 |
context.setState(Selection.FirstPoint); |
776 |
(context.getState()).Entry(context); |
777 |
} |
778 |
return;
|
779 |
} |
780 |
|
781 |
protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event) |
782 |
{ |
783 |
ComplexSelectionCADTool ctxt = context.getOwner(); |
784 |
|
785 |
if (ctxt.selectWithSecondPointOutRectangle(pointX,pointY, event) > 0) |
786 |
{ |
787 |
|
788 |
(context.getState()).Exit(context); |
789 |
context.clearState(); |
790 |
try
|
791 |
{ |
792 |
ctxt.setQuestion(PluginServices.getText(this,"select_handlers")); |
793 |
ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
794 |
ctxt.addPoint(pointX, pointY, event); |
795 |
ctxt.end(); |
796 |
} |
797 |
finally
|
798 |
{ |
799 |
context.setState(Selection.WithSelectedFeatures); |
800 |
(context.getState()).Entry(context); |
801 |
} |
802 |
} |
803 |
else
|
804 |
{ |
805 |
|
806 |
(context.getState()).Exit(context); |
807 |
context.clearState(); |
808 |
try
|
809 |
{ |
810 |
ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+ |
811 |
PluginServices.getText(this,"cad.or")+" "+ |
812 |
PluginServices.getText(this,"circle")+ |
813 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+ |
814 |
PluginServices.getText(this,"out_rectangle")+ |
815 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+ |
816 |
PluginServices.getText(this,"polygon")+ |
817 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+ |
818 |
PluginServices.getText(this,"cross_polygon")+ |
819 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+ |
820 |
"#"+PluginServices.getText(this,"out_polygon")+ |
821 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+ |
822 |
PluginServices.getText(this,"cross_circle")+ |
823 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+ |
824 |
PluginServices.getText(this,"out_circle")+ |
825 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]"); |
826 |
ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
827 |
ctxt.addPoint(pointX, pointY, event); |
828 |
} |
829 |
finally
|
830 |
{ |
831 |
context.setState(Selection.FirstPoint); |
832 |
(context.getState()).Entry(context); |
833 |
} |
834 |
} |
835 |
|
836 |
return;
|
837 |
} |
838 |
|
839 |
//-------------------------------------------------------
|
840 |
// Member data.
|
841 |
//
|
842 |
} |
843 |
|
844 |
private static final class Selection_SecondPointCircle |
845 |
extends Selection_Default
|
846 |
{ |
847 |
//-------------------------------------------------------
|
848 |
// Member methods.
|
849 |
//
|
850 |
|
851 |
private Selection_SecondPointCircle(String name, int id) |
852 |
{ |
853 |
super (name, id);
|
854 |
} |
855 |
|
856 |
protected void addOption(ComplexSelectionCADToolContext context, String s) |
857 |
{ |
858 |
ComplexSelectionCADTool ctxt = context.getOwner(); |
859 |
|
860 |
|
861 |
(context.getState()).Exit(context); |
862 |
context.clearState(); |
863 |
try
|
864 |
{ |
865 |
ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+ |
866 |
PluginServices.getText(this,"cad.or")+" "+ |
867 |
PluginServices.getText(this,"circle")+ |
868 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+ |
869 |
PluginServices.getText(this,"out_rectangle")+ |
870 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+ |
871 |
PluginServices.getText(this,"polygon")+ |
872 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+ |
873 |
PluginServices.getText(this,"cross_polygon")+ |
874 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+ |
875 |
"#"+PluginServices.getText(this,"out_polygon")+ |
876 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+ |
877 |
PluginServices.getText(this,"cross_circle")+ |
878 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+ |
879 |
PluginServices.getText(this,"out_circle")+ |
880 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]"); |
881 |
ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
882 |
ctxt.setType(s); |
883 |
} |
884 |
finally
|
885 |
{ |
886 |
context.setState(Selection.FirstPoint); |
887 |
(context.getState()).Entry(context); |
888 |
} |
889 |
return;
|
890 |
} |
891 |
|
892 |
protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event) |
893 |
{ |
894 |
ComplexSelectionCADTool ctxt = context.getOwner(); |
895 |
|
896 |
if (ctxt.selectWithCircle(pointX,pointY, event) > 0) |
897 |
{ |
898 |
|
899 |
(context.getState()).Exit(context); |
900 |
context.clearState(); |
901 |
try
|
902 |
{ |
903 |
ctxt.setQuestion(PluginServices.getText(this,"select_handlers")); |
904 |
ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
905 |
ctxt.addPoint(pointX, pointY, event); |
906 |
ctxt.end(); |
907 |
} |
908 |
finally
|
909 |
{ |
910 |
context.setState(Selection.WithSelectedFeatures); |
911 |
(context.getState()).Entry(context); |
912 |
} |
913 |
} |
914 |
else
|
915 |
{ |
916 |
|
917 |
(context.getState()).Exit(context); |
918 |
context.clearState(); |
919 |
try
|
920 |
{ |
921 |
ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+ |
922 |
PluginServices.getText(this,"cad.or")+" "+ |
923 |
PluginServices.getText(this,"circle")+ |
924 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+ |
925 |
PluginServices.getText(this,"out_rectangle")+ |
926 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+ |
927 |
PluginServices.getText(this,"polygon")+ |
928 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+ |
929 |
PluginServices.getText(this,"cross_polygon")+ |
930 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+ |
931 |
"#"+PluginServices.getText(this,"out_polygon")+ |
932 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+ |
933 |
PluginServices.getText(this,"cross_circle")+ |
934 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+ |
935 |
PluginServices.getText(this,"out_circle")+ |
936 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]"); |
937 |
ctxt.setDescription(new String[]{"out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
938 |
ctxt.addPoint(pointX, pointY, event); |
939 |
} |
940 |
finally
|
941 |
{ |
942 |
context.setState(Selection.FirstPoint); |
943 |
(context.getState()).Entry(context); |
944 |
} |
945 |
} |
946 |
|
947 |
return;
|
948 |
} |
949 |
|
950 |
//-------------------------------------------------------
|
951 |
// Member data.
|
952 |
//
|
953 |
} |
954 |
|
955 |
private static final class Selection_NextPointPolygon |
956 |
extends Selection_Default
|
957 |
{ |
958 |
//-------------------------------------------------------
|
959 |
// Member methods.
|
960 |
//
|
961 |
|
962 |
private Selection_NextPointPolygon(String name, int id) |
963 |
{ |
964 |
super (name, id);
|
965 |
} |
966 |
|
967 |
protected void addOption(ComplexSelectionCADToolContext context, String s) |
968 |
{ |
969 |
ComplexSelectionCADTool ctxt = context.getOwner(); |
970 |
|
971 |
|
972 |
(context.getState()).Exit(context); |
973 |
context.clearState(); |
974 |
try
|
975 |
{ |
976 |
ctxt.setQuestion(PluginServices.getText(this,"insert_point")+" "+ |
977 |
PluginServices.getText(this,"cad.or")+" "+ |
978 |
PluginServices.getText(this,"circle")+ |
979 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.introcircle")+"], "+ |
980 |
PluginServices.getText(this,"out_rectangle")+ |
981 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle")+"], "+ |
982 |
PluginServices.getText(this,"polygon")+ |
983 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon")+"], "+ |
984 |
PluginServices.getText(this,"cross_polygon")+ |
985 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon")+"], "+"\n"+ |
986 |
"#"+PluginServices.getText(this,"out_polygon")+ |
987 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon")+"], "+ |
988 |
PluginServices.getText(this,"cross_circle")+ |
989 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle")+"], "+ |
990 |
PluginServices.getText(this,"out_circle")+ |
991 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.outcircle")+"]"); |
992 |
ctxt.setDescription(new String[]{"end_polygon", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
993 |
ctxt.addOption(s); |
994 |
} |
995 |
finally
|
996 |
{ |
997 |
context.setState(Selection.FirstPoint); |
998 |
(context.getState()).Entry(context); |
999 |
} |
1000 |
return;
|
1001 |
} |
1002 |
|
1003 |
protected void addPoint(ComplexSelectionCADToolContext context, double pointX, double pointY, InputEvent event) |
1004 |
{ |
1005 |
ComplexSelectionCADTool ctxt = context.getOwner(); |
1006 |
|
1007 |
ComplexSelectionCADToolState endState = context.getState(); |
1008 |
|
1009 |
context.clearState(); |
1010 |
try
|
1011 |
{ |
1012 |
ctxt.setQuestion(PluginServices.getText(this,"insert_next_point_selection_or_end_polygon")+ |
1013 |
"["+PluginServices.getText(this,"ComplexSelectionCADTool.end")+"]"); |
1014 |
ctxt.setDescription(new String[]{"end_polygon", "out_rectangle", "inside_polygon", "cross_polygon", "out_polygon", "inside_circle", "cross_circle", "out_circle", "select_all", "cancel"}); |
1015 |
ctxt.addPoint(pointX, pointY, event); |
1016 |
} |
1017 |
finally
|
1018 |
{ |
1019 |
context.setState(endState); |
1020 |
} |
1021 |
return;
|
1022 |
} |
1023 |
|
1024 |
//-------------------------------------------------------
|
1025 |
// Member data.
|
1026 |
//
|
1027 |
} |
1028 |
|
1029 |
//-----------------------------------------------------------
|
1030 |
// Member data.
|
1031 |
//
|
1032 |
} |
1033 |
} |