Statistics
| Revision:

root / trunk / extensions / extCAD / src / com / iver / cit / gvsig / gui / cad / tools / smc / SelectionCADToolContext.java @ 3832

History | View | Annotate | Download (9.12 KB)

1

    
2
//
3
// Vicente Caballero Navarro
4

    
5

    
6
package com.iver.cit.gvsig.gui.cad.tools.smc;
7

    
8
import com.iver.cit.gvsig.gui.cad.tools.SelectionCADTool;
9
import com.iver.cit.gvsig.fmap.layers.FBitSet;
10

    
11
public final class SelectionCADToolContext
12
    extends statemap.FSMContext
13
{
14
//---------------------------------------------------------------
15
// Member methods.
16
//
17

    
18
    public SelectionCADToolContext(SelectionCADTool owner)
19
    {
20
        super();
21

    
22
        _owner = owner;
23
        setState(ExecuteMap.Initial);
24
        ExecuteMap.Initial.Entry(this);
25
    }
26

    
27
    public void addPoint(double pointX, double pointY)
28
    {
29
        _transition = "addPoint";
30
        getState().addPoint(this, pointX, pointY);
31
        _transition = "";
32
        return;
33
    }
34

    
35
    public SelectionCADToolState getState()
36
        throws statemap.StateUndefinedException
37
    {
38
        if (_state == null)
39
        {
40
            throw(
41
                new statemap.StateUndefinedException());
42
        }
43

    
44
        return ((SelectionCADToolState) _state);
45
    }
46

    
47
    protected SelectionCADTool getOwner()
48
    {
49
        return (_owner);
50
    }
51

    
52
//---------------------------------------------------------------
53
// Member data.
54
//
55

    
56
    transient private SelectionCADTool _owner;
57

    
58
//---------------------------------------------------------------
59
// Inner classes.
60
//
61

    
62
    public static abstract class SelectionCADToolState
63
        extends statemap.State
64
    {
65
    //-----------------------------------------------------------
66
    // Member methods.
67
    //
68

    
69
        protected SelectionCADToolState(String name, int id)
70
        {
71
            super (name, id);
72
        }
73

    
74
        protected void Entry(SelectionCADToolContext context) {}
75
        protected void Exit(SelectionCADToolContext context) {}
76

    
77
        protected void addPoint(SelectionCADToolContext context, double pointX, double pointY)
78
        {
79
            Default(context);
80
        }
81

    
82
        protected void Default(SelectionCADToolContext context)
83
        {
84
            throw (
85
                new statemap.TransitionUndefinedException(
86
                    "State: " +
87
                    context.getState().getName() +
88
                    ", Transition: " +
89
                    context.getTransition()));
90
        }
91

    
92
    //-----------------------------------------------------------
93
    // Member data.
94
    //
95
    }
96

    
97
    /* package */ static abstract class ExecuteMap
98
    {
99
    //-----------------------------------------------------------
100
    // Member methods.
101
    //
102

    
103
    //-----------------------------------------------------------
104
    // Member data.
105
    //
106

    
107
        //-------------------------------------------------------
108
        // Statics.
109
        //
110
        /* package */ static ExecuteMap_Default.ExecuteMap_Initial Initial;
111
        /* package */ static ExecuteMap_Default.ExecuteMap_First First;
112
        /* package */ static ExecuteMap_Default.ExecuteMap_Second Second;
113
        /* package */ static ExecuteMap_Default.ExecuteMap_Third Third;
114
        /* package */ static ExecuteMap_Default.ExecuteMap_Fourth Fourth;
115
        private static ExecuteMap_Default Default;
116

    
117
        static
118
        {
119
            Initial = new ExecuteMap_Default.ExecuteMap_Initial("ExecuteMap.Initial", 0);
120
            First = new ExecuteMap_Default.ExecuteMap_First("ExecuteMap.First", 1);
121
            Second = new ExecuteMap_Default.ExecuteMap_Second("ExecuteMap.Second", 2);
122
            Third = new ExecuteMap_Default.ExecuteMap_Third("ExecuteMap.Third", 3);
123
            Fourth = new ExecuteMap_Default.ExecuteMap_Fourth("ExecuteMap.Fourth", 4);
124
            Default = new ExecuteMap_Default("ExecuteMap.Default", -1);
125
        }
126

    
127
    }
128

    
129
    protected static class ExecuteMap_Default
130
        extends SelectionCADToolState
131
    {
132
    //-----------------------------------------------------------
133
    // Member methods.
134
    //
135

    
136
        protected ExecuteMap_Default(String name, int id)
137
        {
138
            super (name, id);
139
        }
140

    
141
    //-----------------------------------------------------------
142
    // Inner classse.
143
    //
144

    
145

    
146
        private static final class ExecuteMap_Initial
147
            extends ExecuteMap_Default
148
        {
149
        //-------------------------------------------------------
150
        // Member methods.
151
        //
152

    
153
            private ExecuteMap_Initial(String name, int id)
154
            {
155
                super (name, id);
156
            }
157

    
158
            protected void Entry(SelectionCADToolContext context)
159
            {
160
                SelectionCADTool ctxt = context.getOwner();
161

    
162
                ctxt.init();
163
                ctxt.setQuestion("Precise punto del rect?ngulo de selecci?n");
164
                return;
165
            }
166

    
167
            protected void addPoint(SelectionCADToolContext context, double pointX, double pointY)
168
            {
169
                SelectionCADTool ctxt = context.getOwner();
170

    
171

    
172
                (context.getState()).Exit(context);
173
                context.clearState();
174
                try
175
                {
176
                    ctxt.setQuestion("Precise segundo punto del rect?ngulo de seleccion");
177
                    ctxt.addPoint(pointX, pointY);
178
                }
179
                finally
180
                {
181
                    context.setState(ExecuteMap.First);
182
                    (context.getState()).Entry(context);
183
                }
184
                return;
185
            }
186

    
187
        //-------------------------------------------------------
188
        // Member data.
189
        //
190
        }
191

    
192
        private static final class ExecuteMap_First
193
            extends ExecuteMap_Default
194
        {
195
        //-------------------------------------------------------
196
        // Member methods.
197
        //
198

    
199
            private ExecuteMap_First(String name, int id)
200
            {
201
                super (name, id);
202
            }
203

    
204
            protected void addPoint(SelectionCADToolContext context, double pointX, double pointY)
205
            {
206
                SelectionCADTool ctxt = context.getOwner();
207

    
208

    
209
                (context.getState()).Exit(context);
210
                context.clearState();
211
                try
212
                {
213
                    ctxt.setQuestion("Precise punto de estiramiento");
214
                    ctxt.addPoint(pointX, pointY);
215
                }
216
                finally
217
                {
218
                    context.setState(ExecuteMap.Second);
219
                    (context.getState()).Entry(context);
220
                }
221
                return;
222
            }
223

    
224
        //-------------------------------------------------------
225
        // Member data.
226
        //
227
        }
228

    
229
        private static final class ExecuteMap_Second
230
            extends ExecuteMap_Default
231
        {
232
        //-------------------------------------------------------
233
        // Member methods.
234
        //
235

    
236
            private ExecuteMap_Second(String name, int id)
237
            {
238
                super (name, id);
239
            }
240

    
241
            protected void addPoint(SelectionCADToolContext context, double pointX, double pointY)
242
            {
243
                SelectionCADTool ctxt = context.getOwner();
244

    
245

    
246
                (context.getState()).Exit(context);
247
                context.clearState();
248
                try
249
                {
250
                    ctxt.setQuestion("Precise punto de estiramiento");
251
                    ctxt.addPoint(pointX, pointY);
252
                }
253
                finally
254
                {
255
                    context.setState(ExecuteMap.Third);
256
                    (context.getState()).Entry(context);
257
                }
258
                return;
259
            }
260

    
261
        //-------------------------------------------------------
262
        // Member data.
263
        //
264
        }
265

    
266
        private static final class ExecuteMap_Third
267
            extends ExecuteMap_Default
268
        {
269
        //-------------------------------------------------------
270
        // Member methods.
271
        //
272

    
273
            private ExecuteMap_Third(String name, int id)
274
            {
275
                super (name, id);
276
            }
277

    
278
            protected void addPoint(SelectionCADToolContext context, double pointX, double pointY)
279
            {
280
                SelectionCADTool ctxt = context.getOwner();
281

    
282

    
283
                (context.getState()).Exit(context);
284
                context.clearState();
285
                try
286
                {
287
                    ctxt.setQuestion("Precise punto de estiramiento");
288
                    ctxt.addPoint(pointX, pointY);
289
                    ctxt.end();
290
                    ctxt.refresh();
291
                }
292
                finally
293
                {
294
                    context.setState(ExecuteMap.Fourth);
295
                    (context.getState()).Entry(context);
296
                }
297
                return;
298
            }
299

    
300
        //-------------------------------------------------------
301
        // Member data.
302
        //
303
        }
304

    
305
        private static final class ExecuteMap_Fourth
306
            extends ExecuteMap_Default
307
        {
308
        //-------------------------------------------------------
309
        // Member methods.
310
        //
311

    
312
            private ExecuteMap_Fourth(String name, int id)
313
            {
314
                super (name, id);
315
            }
316

    
317
        //-------------------------------------------------------
318
        // Member data.
319
        //
320
        }
321

    
322
    //-----------------------------------------------------------
323
    // Member data.
324
    //
325
    }
326
}