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