svn-gvsig-desktop / branches / pilotoDWG / applications / appgvSIG / src / com / iver / cit / gvsig / gui / cad / automaton / Simetria.java @ 1498
History | View | Annotate | Download (4.12 KB)
1 |
package com.iver.cit.gvsig.gui.cad.automaton; |
---|---|
2 |
|
3 |
public class Simetria implements com.iver.fsac.Automaton{ |
4 |
private int previousStatus = com.iver.fsac.Automaton.FINISHED; |
5 |
private int status = 0; |
6 |
|
7 |
public void initialize() { |
8 |
status = 0;
|
9 |
} |
10 |
|
11 |
public int transition(String label){ |
12 |
switch (status){
|
13 |
|
14 |
case -1: |
15 |
|
16 |
break;
|
17 |
|
18 |
case 0: |
19 |
|
20 |
if ("punto".equalsIgnoreCase(label)){ |
21 |
previousStatus = status; |
22 |
status = 1;
|
23 |
|
24 |
return com.iver.fsac.Automaton.TRANSITION_SUCCESS;
|
25 |
} |
26 |
|
27 |
if ("cancel".equalsIgnoreCase(label)){ |
28 |
previousStatus = status; |
29 |
status = -1;
|
30 |
|
31 |
return com.iver.fsac.Automaton.AUTOMATON_FINISHED;
|
32 |
} |
33 |
|
34 |
break;
|
35 |
|
36 |
case 1: |
37 |
|
38 |
if ("punto".equalsIgnoreCase(label)){ |
39 |
previousStatus = status; |
40 |
status = 1;
|
41 |
|
42 |
return com.iver.fsac.Automaton.TRANSITION_SUCCESS;
|
43 |
} |
44 |
|
45 |
if ("aceptar".equalsIgnoreCase(label)){ |
46 |
previousStatus = status; |
47 |
status = 2;
|
48 |
|
49 |
return com.iver.fsac.Automaton.TRANSITION_SUCCESS;
|
50 |
} |
51 |
|
52 |
if ("cancel".equalsIgnoreCase(label)){ |
53 |
previousStatus = status; |
54 |
status = -1;
|
55 |
|
56 |
return com.iver.fsac.Automaton.AUTOMATON_FINISHED;
|
57 |
} |
58 |
|
59 |
break;
|
60 |
|
61 |
case 2: |
62 |
|
63 |
if ("punto".equalsIgnoreCase(label)){ |
64 |
previousStatus = status; |
65 |
status = 3;
|
66 |
|
67 |
return com.iver.fsac.Automaton.TRANSITION_SUCCESS;
|
68 |
} |
69 |
|
70 |
if ("cancel".equalsIgnoreCase(label)){ |
71 |
previousStatus = status; |
72 |
status = -1;
|
73 |
|
74 |
return com.iver.fsac.Automaton.AUTOMATON_FINISHED;
|
75 |
} |
76 |
|
77 |
break;
|
78 |
|
79 |
case 3: |
80 |
|
81 |
if ("punto".equalsIgnoreCase(label)){ |
82 |
previousStatus = status; |
83 |
status = 4;
|
84 |
|
85 |
return com.iver.fsac.Automaton.TRANSITION_SUCCESS;
|
86 |
} |
87 |
|
88 |
if ("cancel".equalsIgnoreCase(label)){ |
89 |
previousStatus = status; |
90 |
status = -1;
|
91 |
|
92 |
return com.iver.fsac.Automaton.AUTOMATON_FINISHED;
|
93 |
} |
94 |
|
95 |
break;
|
96 |
|
97 |
case 4: |
98 |
|
99 |
if ("boolean".equalsIgnoreCase(label)){ |
100 |
previousStatus = status; |
101 |
status = 5;
|
102 |
|
103 |
return com.iver.fsac.Automaton.TRANSITION_SUCCESS;
|
104 |
} |
105 |
|
106 |
if ("cancel".equalsIgnoreCase(label)){ |
107 |
previousStatus = status; |
108 |
status = -1;
|
109 |
|
110 |
return com.iver.fsac.Automaton.AUTOMATON_FINISHED;
|
111 |
} |
112 |
|
113 |
break;
|
114 |
|
115 |
case 5: |
116 |
|
117 |
if ("cancel".equalsIgnoreCase(label)){ |
118 |
previousStatus = status; |
119 |
status = -1;
|
120 |
|
121 |
return com.iver.fsac.Automaton.AUTOMATON_FINISHED;
|
122 |
} |
123 |
|
124 |
break;
|
125 |
|
126 |
} |
127 |
|
128 |
return com.iver.fsac.Automaton.TRANSITION_FAILED;
|
129 |
} |
130 |
|
131 |
public int getPreviousStatus(){ |
132 |
return previousStatus;
|
133 |
} |
134 |
|
135 |
public int getStatus(){ |
136 |
return status;
|
137 |
} |
138 |
|
139 |
public boolean checkState(char c){ |
140 |
|
141 |
if (status == -1){ |
142 |
return "".indexOf(c) != -1; |
143 |
} |
144 |
|
145 |
if (status == 0){ |
146 |
return "".indexOf(c) != -1; |
147 |
} |
148 |
|
149 |
if (status == 1){ |
150 |
return "".indexOf(c) != -1; |
151 |
} |
152 |
|
153 |
if (status == 2){ |
154 |
return "".indexOf(c) != -1; |
155 |
} |
156 |
|
157 |
if (status == 3){ |
158 |
return "".indexOf(c) != -1; |
159 |
} |
160 |
|
161 |
if (status == 4){ |
162 |
return "".indexOf(c) != -1; |
163 |
} |
164 |
|
165 |
if (status == 5){ |
166 |
return "".indexOf(c) != -1; |
167 |
} |
168 |
|
169 |
|
170 |
return false; |
171 |
} |
172 |
|
173 |
public String[] getCurrentTransitions(){ |
174 |
|
175 |
if (status == -1){ |
176 |
return new String[]{}; |
177 |
} |
178 |
|
179 |
if (status == 0){ |
180 |
return new String[]{"punto", "cancel"}; |
181 |
} |
182 |
|
183 |
if (status == 1){ |
184 |
return new String[]{"punto", "aceptar", "cancel"}; |
185 |
} |
186 |
|
187 |
if (status == 2){ |
188 |
return new String[]{"punto", "cancel"}; |
189 |
} |
190 |
|
191 |
if (status == 3){ |
192 |
return new String[]{"punto", "cancel"}; |
193 |
} |
194 |
|
195 |
if (status == 4){ |
196 |
return new String[]{"boolean", "cancel"}; |
197 |
} |
198 |
|
199 |
if (status == 5){ |
200 |
return new String[]{"cancel"}; |
201 |
} |
202 |
|
203 |
|
204 |
throw new RuntimeException("Bug!"); |
205 |
} |
206 |
|
207 |
public String[] getCurrentTransitionDescriptions(){ |
208 |
|
209 |
if (status == -1){ |
210 |
return new String[]{}; |
211 |
} |
212 |
|
213 |
if (status == 0){ |
214 |
return new String[]{null, null}; |
215 |
} |
216 |
|
217 |
if (status == 1){ |
218 |
return new String[]{null, null, null}; |
219 |
} |
220 |
|
221 |
if (status == 2){ |
222 |
return new String[]{null, null}; |
223 |
} |
224 |
|
225 |
if (status == 3){ |
226 |
return new String[]{null, null}; |
227 |
} |
228 |
|
229 |
if (status == 4){ |
230 |
return new String[]{null, null}; |
231 |
} |
232 |
|
233 |
if (status == 5){ |
234 |
return new String[]{null}; |
235 |
} |
236 |
|
237 |
|
238 |
throw new RuntimeException("Bug!"); |
239 |
} |
240 |
} |