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