Statistics
| Revision:

svn-gvsig-desktop / branches / gvSIG_CAD / applications / appgvSIG / src / com / iver / cit / gvsig / gui / cad / automaton / Circulo.java @ 3513

History | View | Annotate | Download (5.05 KB)

1
package com.iver.cit.gvsig.gui.cad.automaton;
2

    
3
public class Circulo 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 ("3P".equalsIgnoreCase(label)){
28
                                        previousStatus = status;
29
                                        status = 2;
30
                                        
31
                                        return com.iver.fsac.Automaton.TRANSITION_SUCCESS;
32
                                }
33
                                
34
                                if ("cancel".equalsIgnoreCase(label)){
35
                                        previousStatus = status;
36
                                        status = -1;
37
                                        
38
                                        return com.iver.fsac.Automaton.AUTOMATON_FINISHED;
39
                                }
40
                                
41
                                break;
42
                
43
                        case 1:
44
                                
45
                                if ("numero".equalsIgnoreCase(label)){
46
                                        previousStatus = status;
47
                                        status = 6;
48
                                        
49
                                        return com.iver.fsac.Automaton.TRANSITION_SUCCESS;
50
                                }
51
                                
52
                                if ("punto".equalsIgnoreCase(label)){
53
                                        previousStatus = status;
54
                                        status = 7;
55
                                        
56
                                        return com.iver.fsac.Automaton.TRANSITION_SUCCESS;
57
                                }
58
                                
59
                                if ("cancel".equalsIgnoreCase(label)){
60
                                        previousStatus = status;
61
                                        status = -1;
62
                                        
63
                                        return com.iver.fsac.Automaton.AUTOMATON_FINISHED;
64
                                }
65
                                
66
                                break;
67
                
68
                        case 2:
69
                                
70
                                if ("punto".equalsIgnoreCase(label)){
71
                                        previousStatus = status;
72
                                        status = 3;
73
                                        
74
                                        return com.iver.fsac.Automaton.TRANSITION_SUCCESS;
75
                                }
76
                                
77
                                if ("cancel".equalsIgnoreCase(label)){
78
                                        previousStatus = status;
79
                                        status = -1;
80
                                        
81
                                        return com.iver.fsac.Automaton.AUTOMATON_FINISHED;
82
                                }
83
                                
84
                                break;
85
                
86
                        case 3:
87
                                
88
                                if ("punto".equalsIgnoreCase(label)){
89
                                        previousStatus = status;
90
                                        status = 4;
91
                                        
92
                                        return com.iver.fsac.Automaton.TRANSITION_SUCCESS;
93
                                }
94
                                
95
                                if ("cancel".equalsIgnoreCase(label)){
96
                                        previousStatus = status;
97
                                        status = -1;
98
                                        
99
                                        return com.iver.fsac.Automaton.AUTOMATON_FINISHED;
100
                                }
101
                                
102
                                break;
103
                
104
                        case 4:
105
                                
106
                                if ("punto".equalsIgnoreCase(label)){
107
                                        previousStatus = status;
108
                                        status = 5;
109
                                        
110
                                        return com.iver.fsac.Automaton.TRANSITION_SUCCESS;
111
                                }
112
                                
113
                                if ("cancel".equalsIgnoreCase(label)){
114
                                        previousStatus = status;
115
                                        status = -1;
116
                                        
117
                                        return com.iver.fsac.Automaton.AUTOMATON_FINISHED;
118
                                }
119
                                
120
                                break;
121
                
122
                        case 5:
123
                                
124
                                if ("cancel".equalsIgnoreCase(label)){
125
                                        previousStatus = status;
126
                                        status = -1;
127
                                        
128
                                        return com.iver.fsac.Automaton.AUTOMATON_FINISHED;
129
                                }
130
                                
131
                                break;
132
                
133
                        case 6:
134
                                
135
                                if ("cancel".equalsIgnoreCase(label)){
136
                                        previousStatus = status;
137
                                        status = -1;
138
                                        
139
                                        return com.iver.fsac.Automaton.AUTOMATON_FINISHED;
140
                                }
141
                                
142
                                break;
143
                
144
                        case 7:
145
                                
146
                                if ("cancel".equalsIgnoreCase(label)){
147
                                        previousStatus = status;
148
                                        status = -1;
149
                                        
150
                                        return com.iver.fsac.Automaton.AUTOMATON_FINISHED;
151
                                }
152
                                
153
                                break;
154
                
155
                }
156
                
157
                return com.iver.fsac.Automaton.TRANSITION_FAILED;
158
        }
159
        
160
        public int getPreviousStatus(){
161
                return previousStatus;
162
        }
163
        
164
        public int getStatus(){
165
                return status;
166
        }
167
        
168
        public boolean checkState(char c){
169
                
170
                if (status == -1){
171
                        return "".indexOf(c) != -1;
172
                }
173
                
174
                if (status == 0){
175
                        return "".indexOf(c) != -1;
176
                }
177
                
178
                if (status == 1){
179
                        return "".indexOf(c) != -1;
180
                }
181
                
182
                if (status == 2){
183
                        return "".indexOf(c) != -1;
184
                }
185
                
186
                if (status == 3){
187
                        return "".indexOf(c) != -1;
188
                }
189
                
190
                if (status == 4){
191
                        return "".indexOf(c) != -1;
192
                }
193
                
194
                if (status == 5){
195
                        return "".indexOf(c) != -1;
196
                }
197
                
198
                if (status == 6){
199
                        return "".indexOf(c) != -1;
200
                }
201
                
202
                if (status == 7){
203
                        return "".indexOf(c) != -1;
204
                }
205
                
206
                
207
                return false;
208
        }
209
        
210
        public String[] getCurrentTransitions(){
211
                
212
                if (status == -1){
213
                        return new String[]{};
214
                }
215
                
216
                if (status == 0){
217
                        return new String[]{"punto", "3P", "cancel"};
218
                }
219
                
220
                if (status == 1){
221
                        return new String[]{"numero", "punto", "cancel"};
222
                }
223
                
224
                if (status == 2){
225
                        return new String[]{"punto", "cancel"};
226
                }
227
                
228
                if (status == 3){
229
                        return new String[]{"punto", "cancel"};
230
                }
231
                
232
                if (status == 4){
233
                        return new String[]{"punto", "cancel"};
234
                }
235
                
236
                if (status == 5){
237
                        return new String[]{"cancel"};
238
                }
239
                
240
                if (status == 6){
241
                        return new String[]{"cancel"};
242
                }
243
                
244
                if (status == 7){
245
                        return new String[]{"cancel"};
246
                }
247
                
248
                
249
                throw new RuntimeException("Bug!");
250
        }
251
        
252
        public String[] getCurrentTransitionDescriptions(){
253
                
254
                if (status == -1){
255
                        return new String[]{};
256
                }
257
                
258
                if (status == 0){
259
                        return new String[]{null, null, "Cancelar"};
260
                }
261
                
262
                if (status == 1){
263
                        return new String[]{null, null, "Cancelar"};
264
                }
265
                
266
                if (status == 2){
267
                        return new String[]{null, "Cancelar"};
268
                }
269
                
270
                if (status == 3){
271
                        return new String[]{null, "Cancelar"};
272
                }
273
                
274
                if (status == 4){
275
                        return new String[]{null, "Cancelar"};
276
                }
277
                
278
                if (status == 5){
279
                        return new String[]{"Cancelar"};
280
                }
281
                
282
                if (status == 6){
283
                        return new String[]{"Cancelar"};
284
                }
285
                
286
                if (status == 7){
287
                        return new String[]{"Cancelar"};
288
                }
289
                
290
                
291
                throw new RuntimeException("Bug!");
292
        }
293
}