root / branches / v2_0_0_prep / extensions / extEditing / src / org / gvsig / editing / gui / cad / tools / smc / PolylineCADToolContext.java @ 29685
History | View | Annotate | Download (26.2 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.PolylineCADTool; |
12 |
|
13 |
|
14 |
public final class PolylineCADToolContext |
15 |
extends statemap.FSMContext
|
16 |
{ |
17 |
//---------------------------------------------------------------
|
18 |
// Member methods.
|
19 |
//
|
20 |
|
21 |
public PolylineCADToolContext(PolylineCADTool owner)
|
22 |
{ |
23 |
super();
|
24 |
|
25 |
_owner = owner; |
26 |
setState(Polyline.FirstPoint); |
27 |
Polyline.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 void endPoint(double pointX, double pointY, InputEvent event) |
55 |
{ |
56 |
_transition = "endPoint";
|
57 |
getState().endPoint(this, pointX, pointY, event);
|
58 |
_transition = "";
|
59 |
return;
|
60 |
} |
61 |
|
62 |
public PolylineCADToolState getState()
|
63 |
throws statemap.StateUndefinedException
|
64 |
{ |
65 |
if (_state == null) |
66 |
{ |
67 |
throw(
|
68 |
new statemap.StateUndefinedException());
|
69 |
} |
70 |
|
71 |
return ((PolylineCADToolState) _state);
|
72 |
} |
73 |
|
74 |
protected PolylineCADTool getOwner()
|
75 |
{ |
76 |
return (_owner);
|
77 |
} |
78 |
|
79 |
//---------------------------------------------------------------
|
80 |
// Member data.
|
81 |
//
|
82 |
|
83 |
transient private PolylineCADTool _owner; |
84 |
|
85 |
//---------------------------------------------------------------
|
86 |
// Inner classes.
|
87 |
//
|
88 |
|
89 |
public static abstract class PolylineCADToolState |
90 |
extends statemap.State
|
91 |
{ |
92 |
//-----------------------------------------------------------
|
93 |
// Member methods.
|
94 |
//
|
95 |
|
96 |
protected PolylineCADToolState(String name, int id) |
97 |
{ |
98 |
super (name, id);
|
99 |
} |
100 |
|
101 |
protected void Entry(PolylineCADToolContext context) {} |
102 |
protected void Exit(PolylineCADToolContext context) {} |
103 |
|
104 |
protected void addOption(PolylineCADToolContext context, String s) |
105 |
{ |
106 |
Default(context); |
107 |
} |
108 |
|
109 |
protected void addPoint(PolylineCADToolContext context, double pointX, double pointY, InputEvent event) |
110 |
{ |
111 |
Default(context); |
112 |
} |
113 |
|
114 |
protected void addValue(PolylineCADToolContext context, double d) |
115 |
{ |
116 |
Default(context); |
117 |
} |
118 |
|
119 |
protected void endPoint(PolylineCADToolContext context, double pointX, double pointY, InputEvent event) |
120 |
{ |
121 |
Default(context); |
122 |
} |
123 |
|
124 |
protected void Default(PolylineCADToolContext context) |
125 |
{ |
126 |
throw (
|
127 |
new statemap.TransitionUndefinedException(
|
128 |
"State: " +
|
129 |
context.getState().getName() + |
130 |
", Transition: " +
|
131 |
context.getTransition())); |
132 |
} |
133 |
|
134 |
//-----------------------------------------------------------
|
135 |
// Member data.
|
136 |
//
|
137 |
} |
138 |
|
139 |
/* package */ static abstract class Polyline |
140 |
{ |
141 |
//-----------------------------------------------------------
|
142 |
// Member methods.
|
143 |
//
|
144 |
|
145 |
//-----------------------------------------------------------
|
146 |
// Member data.
|
147 |
//
|
148 |
|
149 |
//-------------------------------------------------------
|
150 |
// Statics.
|
151 |
//
|
152 |
/* package */ static Polyline_Default.Polyline_FirstPoint FirstPoint; |
153 |
/* package */ static Polyline_Default.Polyline_NextPointOrArcOrClose NextPointOrArcOrClose; |
154 |
/* package */ static Polyline_Default.Polyline_NextPointOrLineOrClose NextPointOrLineOrClose; |
155 |
private static Polyline_Default Default; |
156 |
|
157 |
static
|
158 |
{ |
159 |
FirstPoint = new Polyline_Default.Polyline_FirstPoint("Polyline.FirstPoint", 0); |
160 |
NextPointOrArcOrClose = new Polyline_Default.Polyline_NextPointOrArcOrClose("Polyline.NextPointOrArcOrClose", 1); |
161 |
NextPointOrLineOrClose = new Polyline_Default.Polyline_NextPointOrLineOrClose("Polyline.NextPointOrLineOrClose", 2); |
162 |
Default = new Polyline_Default("Polyline.Default", -1); |
163 |
} |
164 |
|
165 |
} |
166 |
|
167 |
protected static class Polyline_Default |
168 |
extends PolylineCADToolState
|
169 |
{ |
170 |
//-----------------------------------------------------------
|
171 |
// Member methods.
|
172 |
//
|
173 |
|
174 |
protected Polyline_Default(String name, int id) |
175 |
{ |
176 |
super (name, id);
|
177 |
} |
178 |
|
179 |
protected void addOption(PolylineCADToolContext context, String s) |
180 |
{ |
181 |
PolylineCADTool ctxt = context.getOwner(); |
182 |
|
183 |
if (s.equals(PluginServices.getText(this,"cancel"))) |
184 |
{ |
185 |
boolean loopbackFlag =
|
186 |
context.getState().getName().equals( |
187 |
Polyline.FirstPoint.getName()); |
188 |
|
189 |
if (loopbackFlag == false) |
190 |
{ |
191 |
(context.getState()).Exit(context); |
192 |
} |
193 |
|
194 |
context.clearState(); |
195 |
try
|
196 |
{ |
197 |
ctxt.cancel(); |
198 |
} |
199 |
finally
|
200 |
{ |
201 |
context.setState(Polyline.FirstPoint); |
202 |
|
203 |
if (loopbackFlag == false) |
204 |
{ |
205 |
(context.getState()).Entry(context); |
206 |
} |
207 |
|
208 |
} |
209 |
} |
210 |
else if (s.equals("")) |
211 |
{ |
212 |
boolean loopbackFlag =
|
213 |
context.getState().getName().equals( |
214 |
Polyline.FirstPoint.getName()); |
215 |
|
216 |
if (loopbackFlag == false) |
217 |
{ |
218 |
(context.getState()).Exit(context); |
219 |
} |
220 |
|
221 |
context.clearState(); |
222 |
try
|
223 |
{ |
224 |
ctxt.endGeometry(); |
225 |
} |
226 |
finally
|
227 |
{ |
228 |
context.setState(Polyline.FirstPoint); |
229 |
|
230 |
if (loopbackFlag == false) |
231 |
{ |
232 |
(context.getState()).Entry(context); |
233 |
} |
234 |
|
235 |
} |
236 |
} |
237 |
else
|
238 |
{ |
239 |
boolean loopbackFlag =
|
240 |
context.getState().getName().equals( |
241 |
Polyline.FirstPoint.getName()); |
242 |
|
243 |
if (loopbackFlag == false) |
244 |
{ |
245 |
(context.getState()).Exit(context); |
246 |
} |
247 |
|
248 |
context.clearState(); |
249 |
try
|
250 |
{ |
251 |
ctxt.throwOptionException(PluginServices.getText(this,"incorrect_option"), s); |
252 |
} |
253 |
finally
|
254 |
{ |
255 |
context.setState(Polyline.FirstPoint); |
256 |
|
257 |
if (loopbackFlag == false) |
258 |
{ |
259 |
(context.getState()).Entry(context); |
260 |
} |
261 |
|
262 |
} |
263 |
} |
264 |
|
265 |
return;
|
266 |
} |
267 |
|
268 |
protected void addValue(PolylineCADToolContext context, double d) |
269 |
{ |
270 |
PolylineCADTool ctxt = context.getOwner(); |
271 |
|
272 |
boolean loopbackFlag =
|
273 |
context.getState().getName().equals( |
274 |
Polyline.FirstPoint.getName()); |
275 |
|
276 |
if (loopbackFlag == false) |
277 |
{ |
278 |
(context.getState()).Exit(context); |
279 |
} |
280 |
|
281 |
context.clearState(); |
282 |
try
|
283 |
{ |
284 |
ctxt.throwValueException(PluginServices.getText(this,"incorrect_value"), d); |
285 |
} |
286 |
finally
|
287 |
{ |
288 |
context.setState(Polyline.FirstPoint); |
289 |
|
290 |
if (loopbackFlag == false) |
291 |
{ |
292 |
(context.getState()).Entry(context); |
293 |
} |
294 |
|
295 |
} |
296 |
return;
|
297 |
} |
298 |
|
299 |
protected void addPoint(PolylineCADToolContext context, double pointX, double pointY, InputEvent event) |
300 |
{ |
301 |
PolylineCADTool ctxt = context.getOwner(); |
302 |
|
303 |
boolean loopbackFlag =
|
304 |
context.getState().getName().equals( |
305 |
Polyline.FirstPoint.getName()); |
306 |
|
307 |
if (loopbackFlag == false) |
308 |
{ |
309 |
(context.getState()).Exit(context); |
310 |
} |
311 |
|
312 |
context.clearState(); |
313 |
try
|
314 |
{ |
315 |
ctxt.throwPointException(PluginServices.getText(this,"incorrect_point"), pointX, pointY); |
316 |
} |
317 |
finally
|
318 |
{ |
319 |
context.setState(Polyline.FirstPoint); |
320 |
|
321 |
if (loopbackFlag == false) |
322 |
{ |
323 |
(context.getState()).Entry(context); |
324 |
} |
325 |
|
326 |
} |
327 |
return;
|
328 |
} |
329 |
|
330 |
protected void endPoint(PolylineCADToolContext context, double pointX, double pointY, InputEvent event) |
331 |
{ |
332 |
PolylineCADTool ctxt = context.getOwner(); |
333 |
|
334 |
boolean loopbackFlag =
|
335 |
context.getState().getName().equals( |
336 |
Polyline.FirstPoint.getName()); |
337 |
|
338 |
if (loopbackFlag == false) |
339 |
{ |
340 |
(context.getState()).Exit(context); |
341 |
} |
342 |
|
343 |
context.clearState(); |
344 |
try
|
345 |
{ |
346 |
ctxt.addPoint(pointX, pointY, event); |
347 |
ctxt.endGeometry(); |
348 |
} |
349 |
finally
|
350 |
{ |
351 |
context.setState(Polyline.FirstPoint); |
352 |
|
353 |
if (loopbackFlag == false) |
354 |
{ |
355 |
(context.getState()).Entry(context); |
356 |
} |
357 |
|
358 |
} |
359 |
return;
|
360 |
} |
361 |
|
362 |
//-----------------------------------------------------------
|
363 |
// Inner classse.
|
364 |
//
|
365 |
|
366 |
|
367 |
private static final class Polyline_FirstPoint |
368 |
extends Polyline_Default
|
369 |
{ |
370 |
//-------------------------------------------------------
|
371 |
// Member methods.
|
372 |
//
|
373 |
|
374 |
private Polyline_FirstPoint(String name, int id) |
375 |
{ |
376 |
super (name, id);
|
377 |
} |
378 |
|
379 |
protected void Entry(PolylineCADToolContext context) |
380 |
{ |
381 |
PolylineCADTool ctxt = context.getOwner(); |
382 |
|
383 |
ctxt.setQuestion(PluginServices.getText(this,"insert_first_point")); |
384 |
ctxt.setDescription(new String[]{"cancel"}); |
385 |
return;
|
386 |
} |
387 |
|
388 |
protected void addPoint(PolylineCADToolContext context, double pointX, double pointY, InputEvent event) |
389 |
{ |
390 |
PolylineCADTool ctxt = context.getOwner(); |
391 |
|
392 |
if (ctxt.isPolygonLayer())
|
393 |
{ |
394 |
|
395 |
(context.getState()).Exit(context); |
396 |
context.clearState(); |
397 |
try
|
398 |
{ |
399 |
ctxt.setQuestion(PluginServices.getText(this,"insert_next_point")+", "+ |
400 |
PluginServices.getText(this,"arc")+ |
401 |
"["+PluginServices.getText(this,"PolylineCADTool.arc")+"], "+ |
402 |
PluginServices.getText(this,"cad.or")+" "+ |
403 |
PluginServices.getText(this,"end")+ |
404 |
"["+PluginServices.getText(this,"PolylineCADTool.end")+"]"); |
405 |
ctxt.setDescription(new String[]{"inter_arc", "terminate", "cancel"}); |
406 |
ctxt.addPoint(pointX, pointY, event); |
407 |
} |
408 |
finally
|
409 |
{ |
410 |
context.setState(Polyline.NextPointOrArcOrClose); |
411 |
(context.getState()).Entry(context); |
412 |
} |
413 |
} |
414 |
else
|
415 |
{ |
416 |
|
417 |
(context.getState()).Exit(context); |
418 |
context.clearState(); |
419 |
try
|
420 |
{ |
421 |
ctxt.setQuestion(PluginServices.getText(this,"insert_next_point")+", "+ |
422 |
PluginServices.getText(this,"arc")+ |
423 |
"["+PluginServices.getText(this,"PolylineCADTool.arc")+"], "+ |
424 |
PluginServices.getText(this,"close_polyline")+ |
425 |
"["+PluginServices.getText(this,"PolylineCADTool.close_polyline")+"], "+ |
426 |
PluginServices.getText(this,"cad.or")+" "+ |
427 |
PluginServices.getText(this,"end")+ |
428 |
"["+PluginServices.getText(this,"PolylineCADTool.end")+"]"); |
429 |
ctxt.setDescription(new String[]{"inter_arc", "close_polyline", "terminate", "cancel"}); |
430 |
ctxt.addPoint(pointX, pointY, event); |
431 |
} |
432 |
finally
|
433 |
{ |
434 |
context.setState(Polyline.NextPointOrArcOrClose); |
435 |
(context.getState()).Entry(context); |
436 |
} |
437 |
} |
438 |
|
439 |
return;
|
440 |
} |
441 |
|
442 |
//-------------------------------------------------------
|
443 |
// Member data.
|
444 |
//
|
445 |
} |
446 |
|
447 |
private static final class Polyline_NextPointOrArcOrClose |
448 |
extends Polyline_Default
|
449 |
{ |
450 |
//-------------------------------------------------------
|
451 |
// Member methods.
|
452 |
//
|
453 |
|
454 |
private Polyline_NextPointOrArcOrClose(String name, int id) |
455 |
{ |
456 |
super (name, id);
|
457 |
} |
458 |
|
459 |
protected void addOption(PolylineCADToolContext context, String s) |
460 |
{ |
461 |
PolylineCADTool ctxt = context.getOwner(); |
462 |
|
463 |
if (ctxt.isPolygonLayer() && (s.equalsIgnoreCase(PluginServices.getText(this,"PolylineCADTool.arc")) || s.equals(PluginServices.getText(this,"inter_arc")))) |
464 |
{ |
465 |
|
466 |
(context.getState()).Exit(context); |
467 |
context.clearState(); |
468 |
try
|
469 |
{ |
470 |
ctxt.setQuestion(PluginServices.getText(this,"insert_next_point")+", "+ |
471 |
PluginServices.getText(this,"line")+ |
472 |
"["+PluginServices.getText(this,"PolylineCADTool.line")+"], "+ |
473 |
PluginServices.getText(this,"cad.or")+" "+ |
474 |
PluginServices.getText(this,"end")+ |
475 |
"["+PluginServices.getText(this,"PolylineCADTool.end")+"]"); |
476 |
ctxt.setDescription(new String[]{"inter_line", "terminate", "cancel"}); |
477 |
ctxt.addOption(s); |
478 |
} |
479 |
finally
|
480 |
{ |
481 |
context.setState(Polyline.NextPointOrLineOrClose); |
482 |
(context.getState()).Entry(context); |
483 |
} |
484 |
} |
485 |
else if (s.equalsIgnoreCase(PluginServices.getText(this,"PolylineCADTool.arc")) || s.equals(PluginServices.getText(this,"inter_arc"))) |
486 |
{ |
487 |
|
488 |
(context.getState()).Exit(context); |
489 |
context.clearState(); |
490 |
try
|
491 |
{ |
492 |
ctxt.setQuestion(PluginServices.getText(this,"insert_next_point")+", "+ |
493 |
PluginServices.getText(this,"line")+ |
494 |
"["+PluginServices.getText(this,"PolylineCADTool.line")+"], "+ |
495 |
PluginServices.getText(this,"close_polyline")+ |
496 |
"["+PluginServices.getText(this,"PolylineCADTool.close_polyline")+"], "+ |
497 |
PluginServices.getText(this,"cad.or")+" "+ |
498 |
PluginServices.getText(this,"end")+ |
499 |
"["+PluginServices.getText(this,"PolylineCADTool.end")+"]"); |
500 |
ctxt.setDescription(new String[]{"inter_line", "close_polyline", "terminate", "cancel"}); |
501 |
ctxt.addOption(s); |
502 |
} |
503 |
finally
|
504 |
{ |
505 |
context.setState(Polyline.NextPointOrLineOrClose); |
506 |
(context.getState()).Entry(context); |
507 |
} |
508 |
} |
509 |
else if (s.equalsIgnoreCase(PluginServices.getText(this,"PolylineCADTool.close_polyline")) || s.equals(PluginServices.getText(this,"close_polyline"))) |
510 |
{ |
511 |
|
512 |
(context.getState()).Exit(context); |
513 |
context.clearState(); |
514 |
try
|
515 |
{ |
516 |
ctxt.addOption(s); |
517 |
ctxt.closeGeometry(); |
518 |
ctxt.endGeometry(); |
519 |
ctxt.end(); |
520 |
} |
521 |
finally
|
522 |
{ |
523 |
context.setState(Polyline.FirstPoint); |
524 |
(context.getState()).Entry(context); |
525 |
} |
526 |
} |
527 |
else if ((s.equalsIgnoreCase(PluginServices.getText(this,"PolylineCADTool.end")) || s.equals(PluginServices.getText(this,"terminate"))) && ctxt.getLinesCount()!=0 ) |
528 |
{ |
529 |
|
530 |
(context.getState()).Exit(context); |
531 |
context.clearState(); |
532 |
try
|
533 |
{ |
534 |
ctxt.addOption(s); |
535 |
ctxt.endGeometry(); |
536 |
ctxt.end(); |
537 |
} |
538 |
finally
|
539 |
{ |
540 |
context.setState(Polyline.FirstPoint); |
541 |
(context.getState()).Entry(context); |
542 |
} |
543 |
} |
544 |
else if (!s.equals(PluginServices.getText(this,"cancel"))) |
545 |
{ |
546 |
|
547 |
// No actions.
|
548 |
} else
|
549 |
{ |
550 |
super.addOption(context, s);
|
551 |
} |
552 |
|
553 |
return;
|
554 |
} |
555 |
|
556 |
protected void addPoint(PolylineCADToolContext context, double pointX, double pointY, InputEvent event) |
557 |
{ |
558 |
PolylineCADTool ctxt = context.getOwner(); |
559 |
|
560 |
if (ctxt.isPolygonLayer())
|
561 |
{ |
562 |
PolylineCADToolState endState = context.getState(); |
563 |
|
564 |
context.clearState(); |
565 |
try
|
566 |
{ |
567 |
ctxt.setQuestion(PluginServices.getText(this,"insert_next_point")+", "+ |
568 |
PluginServices.getText(this,"arc")+ |
569 |
"["+PluginServices.getText(this,"PolylineCADTool.arc")+"], "+ |
570 |
PluginServices.getText(this,"cad.or")+" "+ |
571 |
PluginServices.getText(this,"end")+ |
572 |
"["+PluginServices.getText(this,"PolylineCADTool.end")+"]"); |
573 |
ctxt.setDescription(new String[]{"inter_arc", "terminate", "cancel"}); |
574 |
ctxt.addPoint(pointX, pointY, event); |
575 |
} |
576 |
finally
|
577 |
{ |
578 |
context.setState(endState); |
579 |
} |
580 |
} |
581 |
else
|
582 |
{ |
583 |
PolylineCADToolState endState = context.getState(); |
584 |
|
585 |
context.clearState(); |
586 |
try
|
587 |
{ |
588 |
ctxt.setQuestion(PluginServices.getText(this,"insert_next_point")+", "+ |
589 |
PluginServices.getText(this,"arc")+ |
590 |
"["+PluginServices.getText(this,"PolylineCADTool.arc")+"], "+ |
591 |
PluginServices.getText(this,"close_polyline")+ |
592 |
"["+PluginServices.getText(this,"PolylineCADTool.close_polyline")+"], "+ |
593 |
PluginServices.getText(this,"cad.or")+" "+ |
594 |
PluginServices.getText(this,"end")+ |
595 |
"["+PluginServices.getText(this,"PolylineCADTool.end")+"]"); |
596 |
ctxt.setDescription(new String[]{"inter_arc", "close_polyline", "terminate", "cancel"}); |
597 |
ctxt.addPoint(pointX, pointY, event); |
598 |
} |
599 |
finally
|
600 |
{ |
601 |
context.setState(endState); |
602 |
} |
603 |
} |
604 |
|
605 |
return;
|
606 |
} |
607 |
|
608 |
//-------------------------------------------------------
|
609 |
// Member data.
|
610 |
//
|
611 |
} |
612 |
|
613 |
private static final class Polyline_NextPointOrLineOrClose |
614 |
extends Polyline_Default
|
615 |
{ |
616 |
//-------------------------------------------------------
|
617 |
// Member methods.
|
618 |
//
|
619 |
|
620 |
private Polyline_NextPointOrLineOrClose(String name, int id) |
621 |
{ |
622 |
super (name, id);
|
623 |
} |
624 |
|
625 |
protected void addOption(PolylineCADToolContext context, String s) |
626 |
{ |
627 |
PolylineCADTool ctxt = context.getOwner(); |
628 |
|
629 |
if (ctxt.isPolygonLayer() && (s.equalsIgnoreCase(PluginServices.getText(this,"PolylineCADTool.line")) || s.equals(PluginServices.getText(this,"inter_line")))) |
630 |
{ |
631 |
|
632 |
(context.getState()).Exit(context); |
633 |
context.clearState(); |
634 |
try
|
635 |
{ |
636 |
ctxt.setQuestion(PluginServices.getText(this,"insert_next_point")+", "+ |
637 |
PluginServices.getText(this,"arc")+ |
638 |
"["+PluginServices.getText(this,"PolylineCADTool.arc")+"], "+ |
639 |
PluginServices.getText(this,"cad.or")+" "+ |
640 |
PluginServices.getText(this,"end")+ |
641 |
"["+PluginServices.getText(this,"PolylineCADTool.end")+"]"); |
642 |
ctxt.setDescription(new String[]{"inter_arc", "terminate", "cancel"}); |
643 |
ctxt.addOption(s); |
644 |
} |
645 |
finally
|
646 |
{ |
647 |
context.setState(Polyline.NextPointOrArcOrClose); |
648 |
(context.getState()).Entry(context); |
649 |
} |
650 |
} |
651 |
else if (s.equalsIgnoreCase(PluginServices.getText(this,"PolylineCADTool.line")) || s.equals(PluginServices.getText(this,"inter_line"))) |
652 |
{ |
653 |
|
654 |
(context.getState()).Exit(context); |
655 |
context.clearState(); |
656 |
try
|
657 |
{ |
658 |
ctxt.setQuestion(PluginServices.getText(this,"insert_next_point")+", "+ |
659 |
PluginServices.getText(this,"arc")+ |
660 |
"["+PluginServices.getText(this,"PolylineCADTool.arc")+"], "+ |
661 |
PluginServices.getText(this,"close_polyline")+ |
662 |
"["+PluginServices.getText(this,"PolylineCADTool.close_polyline")+"], "+ |
663 |
PluginServices.getText(this,"cad.or")+" "+ |
664 |
PluginServices.getText(this,"end")+ |
665 |
"["+PluginServices.getText(this,"PolylineCADTool.end")+"]"); |
666 |
ctxt.setDescription(new String[]{"inter_arc", "close_polyline", "terminate", "cancel"}); |
667 |
ctxt.addOption(s); |
668 |
} |
669 |
finally
|
670 |
{ |
671 |
context.setState(Polyline.NextPointOrArcOrClose); |
672 |
(context.getState()).Entry(context); |
673 |
} |
674 |
} |
675 |
else if (s.equalsIgnoreCase(PluginServices.getText(this,"PolylineCADTool.close_polyline")) || s.equals(PluginServices.getText(this,"close_polyline"))) |
676 |
{ |
677 |
|
678 |
(context.getState()).Exit(context); |
679 |
context.clearState(); |
680 |
try
|
681 |
{ |
682 |
ctxt.addOption(s); |
683 |
ctxt.closeGeometry(); |
684 |
ctxt.endGeometry(); |
685 |
ctxt.end(); |
686 |
} |
687 |
finally
|
688 |
{ |
689 |
context.setState(Polyline.FirstPoint); |
690 |
(context.getState()).Entry(context); |
691 |
} |
692 |
} |
693 |
else if ((s.equalsIgnoreCase(PluginServices.getText(this,"PolylineCADTool.end")) || s.equals(PluginServices.getText(this,"terminate"))) && ctxt.getLinesCount()!=0) |
694 |
{ |
695 |
|
696 |
(context.getState()).Exit(context); |
697 |
context.clearState(); |
698 |
try
|
699 |
{ |
700 |
ctxt.addOption(s); |
701 |
ctxt.endGeometry(); |
702 |
ctxt.end(); |
703 |
} |
704 |
finally
|
705 |
{ |
706 |
context.setState(Polyline.FirstPoint); |
707 |
(context.getState()).Entry(context); |
708 |
} |
709 |
} |
710 |
else if (!s.equals(PluginServices.getText(this,"cancel"))) |
711 |
{ |
712 |
|
713 |
// No actions.
|
714 |
} else
|
715 |
{ |
716 |
super.addOption(context, s);
|
717 |
} |
718 |
|
719 |
return;
|
720 |
} |
721 |
|
722 |
protected void addPoint(PolylineCADToolContext context, double pointX, double pointY, InputEvent event) |
723 |
{ |
724 |
PolylineCADTool ctxt = context.getOwner(); |
725 |
|
726 |
if (ctxt.isPolygonLayer())
|
727 |
{ |
728 |
PolylineCADToolState endState = context.getState(); |
729 |
|
730 |
context.clearState(); |
731 |
try
|
732 |
{ |
733 |
ctxt.setQuestion(PluginServices.getText(this,"insert_next_point")+", "+ |
734 |
PluginServices.getText(this,"line")+ |
735 |
"["+PluginServices.getText(this,"PolylineCADTool.line")+"], "+ |
736 |
PluginServices.getText(this,"cad.or")+" "+ |
737 |
PluginServices.getText(this,"end")+ |
738 |
"["+PluginServices.getText(this,"PolylineCADTool.end")+"]"); |
739 |
ctxt.setDescription(new String[]{"inter_line", "terminate", "cancel"}); |
740 |
ctxt.addPoint(pointX, pointY, event); |
741 |
} |
742 |
finally
|
743 |
{ |
744 |
context.setState(endState); |
745 |
} |
746 |
} |
747 |
else
|
748 |
{ |
749 |
PolylineCADToolState endState = context.getState(); |
750 |
|
751 |
context.clearState(); |
752 |
try
|
753 |
{ |
754 |
ctxt.setQuestion(PluginServices.getText(this,"insert_next_point")+", "+ |
755 |
PluginServices.getText(this,"line")+ |
756 |
"["+PluginServices.getText(this,"PolylineCADTool.line")+"], "+ |
757 |
PluginServices.getText(this,"close_polyline")+ |
758 |
"["+PluginServices.getText(this,"PolylineCADTool.close_polyline")+"], "+ |
759 |
PluginServices.getText(this,"cad.or")+" "+ |
760 |
PluginServices.getText(this,"end")+ |
761 |
"["+PluginServices.getText(this,"PolylineCADTool.end")+"]"); |
762 |
ctxt.setDescription(new String[]{"inter_line", "close_polyline", "terminate", "cancel"}); |
763 |
ctxt.addPoint(pointX, pointY, event); |
764 |
} |
765 |
finally
|
766 |
{ |
767 |
context.setState(endState); |
768 |
} |
769 |
} |
770 |
|
771 |
return;
|
772 |
} |
773 |
|
774 |
//-------------------------------------------------------
|
775 |
// Member data.
|
776 |
//
|
777 |
} |
778 |
|
779 |
//-----------------------------------------------------------
|
780 |
// Member data.
|
781 |
//
|
782 |
} |
783 |
} |