Statistics
| Revision:

root / trunk / extensions / extCAD / sm / PolygonCADTool.sm @ 5730

History | View | Annotate | Download (2.53 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(PluginServices.getText(this,"into_circle_or_circumscribed"));
45
				setDescription(new String[]{"into_circle","circumscribed","cancel"});
46
				addPoint( pointX,pointY,event);
47
				}
48

    
49
	}
50
CenterPoint{
51
	addPoint( pointX:double,pointY:double,event:InputEvent)
52
		OptionOrRadiusOrPoint {
53
			setQuestion(PluginServices.getText(this,"into_circle_or_circumscribed"));
54
			setDescription(new String[]{"into_circle","circumscribed","cancel"});
55
			addPoint( pointX,pointY,event);
56
			}
57
}
58
OptionOrRadiusOrPoint{
59
	addOption(s:String)
60
		RadiusOrPoint {
61
			setQuestion(PluginServices.getText(this,"insert_radius"));
62
			setDescription(new String[]{"cancel"});
63
			addOption(s);
64
			}
65
	addValue(d:double)
66
		NumberOrCenterPoint{
67
			addValue(d);
68
			end();
69
			}
70
	addPoint( pointX:double,pointY:double,event:InputEvent)
71
		NumberOrCenterPoint {
72
			addPoint( pointX,pointY,event);
73
			end();
74
			}
75
}
76
RadiusOrPoint{
77
	addPoint( pointX:double,pointY:double,event:InputEvent)
78
		NumberOrCenterPoint {
79
			addPoint( pointX,pointY,event);
80
			end();
81
			}
82
	addValue(d:double)
83
		NumberOrCenterPoint{
84
			addValue(d);
85
			end();
86
			}
87
}
88

    
89
Default
90
{
91
	addOption(s:String)
92
		[s.equals(PluginServices.getText(this,"cancel"))]
93
		NumberOrCenterPoint{
94
			end();
95
			}
96
	addOption(s:String)
97
		NumberOrCenterPoint{
98
			throwOptionException(PluginServices.getText(this,"incorrect_option"),s);
99
			}
100
	addValue(d:double)
101
		NumberOrCenterPoint{
102
			throwValueException(PluginServices.getText(this,"incorrect_value"),d);
103
			}
104
	addPoint(pointX:double,pointY:double,event:InputEvent)
105
		NumberOrCenterPoint{
106
			throwPointException(PluginServices.getText(this,"incorrect_point"),pointX,pointY);
107
			}
108
}
109
%%