Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extCAD / sm / PolygonCADTool.sm @ 18368

History | View | Annotate | Download (3.02 KB)

1
// -*- tab-width: 4; -*-
2

    
3
%{
4
//
5
// Vicente Caballero Navarro
6
%}
7

    
8
%start Polygon::NumberOrCenterPoint
9
%class PolygonCADTool
10
%package com.iver.cit.gvsig.gui.cad.tools.smc
11
%import com.iver.cit.gvsig.gui.cad.tools.PolygonCADTool
12
%import java.awt.event.InputEvent
13
%import com.iver.andami.PluginServices
14

    
15
%map Polygon
16
%%
17
// A task begins life in suspended animation.
18

    
19
NumberOrCenterPoint
20

    
21
	Entry {
22
		setQuestion(
23
		PluginServices.getText(this,"insert_number_sides"));
24
		setDescription(new String[]{"cancel"});
25
		}
26
	Exit{
27
		}
28

    
29
	{
30
		addValue(d:double)
31
			[d<3]
32
			NumberOrCenterPoint{
33
				throwValueException(PluginServices.getText(this,"num_lados_insuficiente"),d);
34
			}
35
		addValue(d:double)
36
			[d>2]
37
			CenterPoint {
38
				setQuestion(PluginServices.getText(this,"insert_central_point_polygon"));
39
				setDescription(new String[]{"cancel"});
40
				addValue(d);
41
				}
42
		addPoint( pointX:double,pointY:double,event:InputEvent)
43
			OptionOrRadiusOrPoint {
44
				setQuestion(
45
					PluginServices.getText(this,"into_circle")+" "+
46
					"["+PluginServices.getText(this,"PolygonCADTool.into_circle")+"]"+
47
	    			PluginServices.getText(this,"cad.or")+" "+
48
	    			PluginServices.getText(this,"circumscribed")+
49
	   				"["+PluginServices.getText(this,"PolygonCADTool.circumscribed")+"]");
50
				setDescription(new String[]{"into_circle","circumscribed","cancel"});
51
				addPoint( pointX,pointY,event);
52
				}
53

    
54
	}
55
CenterPoint{
56
	addPoint( pointX:double,pointY:double,event:InputEvent)
57
		OptionOrRadiusOrPoint {
58
			setQuestion(
59
				PluginServices.getText(this,"into_circle")+" "+
60
				"["+PluginServices.getText(this,"PolygonCADTool.into_circle")+"]"+
61
	    		PluginServices.getText(this,"cad.or")+" "+
62
	    		PluginServices.getText(this,"circumscribed")+
63
	   			"["+PluginServices.getText(this,"PolygonCADTool.circumscribed")+"]");
64
			setDescription(new String[]{"into_circle","circumscribed","cancel"});
65
			addPoint( pointX,pointY,event);
66
			}
67
}
68
OptionOrRadiusOrPoint{
69
	addOption(s:String)
70
		[!s.equals(PluginServices.getText(this,"cancel"))]
71
		RadiusOrPoint {
72
			setQuestion(PluginServices.getText(this,"insert_radius"));
73
			setDescription(new String[]{"cancel"});
74
			addOption(s);
75
			}
76
	addValue(d:double)
77
		NumberOrCenterPoint{
78
			addValue(d);
79
			}
80
	addPoint( pointX:double,pointY:double,event:InputEvent)
81
		NumberOrCenterPoint {
82
			addPoint( pointX,pointY,event);
83
			}
84
}
85
RadiusOrPoint{
86
	addPoint( pointX:double,pointY:double,event:InputEvent)
87
		NumberOrCenterPoint {
88
			addPoint( pointX,pointY,event);
89
			}
90
	addValue(d:double)
91
		NumberOrCenterPoint{
92
			addValue(d);
93
			}
94
}
95

    
96
Default
97
{
98
	addOption(s:String)
99
		[s.equals(PluginServices.getText(this,"cancel"))]
100
		NumberOrCenterPoint{
101
			end();
102
			}
103
	addOption(s:String)
104
		NumberOrCenterPoint{
105
			throwOptionException(PluginServices.getText(this,"incorrect_option"),s);
106
			}
107
	addValue(d:double)
108
		NumberOrCenterPoint{
109
			throwValueException(PluginServices.getText(this,"incorrect_value"),d);
110
			}
111
	addPoint(pointX:double,pointY:double,event:InputEvent)
112
		NumberOrCenterPoint{
113
			throwPointException(PluginServices.getText(this,"incorrect_point"),pointX,pointY);
114
			}
115
}
116
%%