Revision 6044
trunk/extensions/extCAD/sm/StretchCADTool.sm | ||
---|---|---|
1 |
// -*- tab-width: 4; -*- |
|
2 |
|
|
3 |
%{ |
|
4 |
// |
|
5 |
// Vicente Caballero Navarro |
|
6 |
%} |
|
7 |
|
|
8 |
%start Stretch::SelFirstPoint |
|
9 |
%class StretchCADTool |
|
10 |
%package com.iver.cit.gvsig.gui.cad.tools.smc |
|
11 |
%import com.iver.cit.gvsig.gui.cad.tools.StretchCADTool |
|
12 |
%import java.awt.event.InputEvent |
|
13 |
%import com.iver.andami.PluginServices |
|
14 |
|
|
15 |
%map Stretch |
|
16 |
%% |
|
17 |
// A task begins life in suspended animation. |
|
18 |
|
|
19 |
SelFirstPoint |
|
20 |
Entry { |
|
21 |
selection(); |
|
22 |
setQuestion( |
|
23 |
PluginServices.getText(this,"insert_selection_point")); |
|
24 |
setDescription(new String[]{"cancel"}); |
|
25 |
|
|
26 |
} |
|
27 |
Exit{ |
|
28 |
} |
|
29 |
|
|
30 |
{ |
|
31 |
addPoint( pointX:double,pointY:double,event:InputEvent) |
|
32 |
SelLastPoint { |
|
33 |
setQuestion(PluginServices.getText(this,"insert_selection_last_point")); |
|
34 |
setDescription(new String[]{"cancel"}); |
|
35 |
addPoint( pointX,pointY,event); |
|
36 |
} |
|
37 |
} |
|
38 |
SelLastPoint{ |
|
39 |
addPoint( pointX:double,pointY:double,event:InputEvent) |
|
40 |
MoveFirstPoint { |
|
41 |
setQuestion(PluginServices.getText(this,"insert_move_first_point")); |
|
42 |
setDescription(new String[]{"cancel"}); |
|
43 |
addPoint( pointX,pointY,event); |
|
44 |
} |
|
45 |
} |
|
46 |
MoveFirstPoint{ |
|
47 |
addPoint( pointX:double,pointY:double,event:InputEvent) |
|
48 |
MoveLastPoint { |
|
49 |
setQuestion(PluginServices.getText(this,"insert_move_last_point")); |
|
50 |
setDescription(new String[]{"cancel"}); |
|
51 |
addPoint( pointX,pointY,event); |
|
52 |
} |
|
53 |
} |
|
54 |
MoveLastPoint{ |
|
55 |
addPoint( pointX:double,pointY:double,event:InputEvent) |
|
56 |
SelFirstPoint { |
|
57 |
setQuestion(PluginServices.getText(this,"insert_selection_point")); |
|
58 |
setDescription(new String[]{"cancel"}); |
|
59 |
addPoint( pointX,pointY,event); |
|
60 |
end(); |
|
61 |
} |
|
62 |
} |
|
63 |
Default |
|
64 |
{ |
|
65 |
addOption(s:String) |
|
66 |
[s.equals(PluginServices.getText(this,"cancel"))] |
|
67 |
SelFirstPoint{ |
|
68 |
end(); |
|
69 |
} |
|
70 |
addOption(s:String) |
|
71 |
SelFirstPoint{ |
|
72 |
throwOptionException(PluginServices.getText(this,"incorrect_option"),s); |
|
73 |
} |
|
74 |
addValue(d:double) |
|
75 |
SelFirstPoint{ |
|
76 |
throwValueException(PluginServices.getText(this,"incorrect_value"),d); |
|
77 |
} |
|
78 |
addPoint(pointX:double,pointY:double,event:InputEvent) |
|
79 |
SelFirstPoint{ |
|
80 |
throwPointException(PluginServices.getText(this,"incorrect_point"),pointX,pointY); |
|
81 |
} |
|
82 |
} |
|
83 |
%% |
|
0 | 84 |
trunk/extensions/extCAD/config/config.xml | ||
---|---|---|
214 | 214 |
<selectable-tool icon="images/InternalPolygon.png" action-command="_internalpolygon" tooltip="internal_polygon" group="vista"/> |
215 | 215 |
</tool-bar> |
216 | 216 |
</extension> |
217 |
<extension class-name="com.iver.cit.gvsig.StretchExtension" |
|
218 |
description="Extensi?n encargada de estirar geometr?as en una capa en edici?n." |
|
219 |
active="true"> |
|
220 |
<menu text="geometry/modify/stretch" action-command="_stretch" icon="images/Stretch.png"/> |
|
221 |
<tool-bar name="modificar"> |
|
222 |
<selectable-tool icon="images/Stretch.png" action-command="_stretch" tooltip="stretch" group="vista"/> |
|
223 |
</tool-bar> |
|
224 |
</extension> |
|
217 | 225 |
<extension class-name="com.iver.cit.gvsig.ComplexSelectionGeometryExtension" |
218 | 226 |
description="Extensi?n encargada de la selecci?n compleja de geometr?as." |
219 | 227 |
active="true"> |
trunk/extensions/extCAD/config/text.properties | ||
---|---|---|
69 | 69 |
insert_last_point_reference=Precise punto final recta referencia |
70 | 70 |
insert_last_point_scale=Precise punto final recta escala |
71 | 71 |
insert_length_or_point=Insertar longitud o punto |
72 |
insert_move_first_point=Insertar el primer punto de movimiento |
|
73 |
insert_move_last_point=Insertar el segundo punto de movimiento |
|
72 | 74 |
insert_next_point_arc_or_close=Insertar siguiente punto, Arco[A] o Cerrar[C] |
73 | 75 |
insert_next_point_line_or_close=Insertar punto siguiente, Linea[N] o Cerrar[C] |
74 | 76 |
insert_next_point_selection_or_end_polygon=Insertar siguiente punto o finalizar pol\u00EDgono de selecci\u00F3n[E] |
... | ... | |
88 | 90 |
insert_second_point_angle=Insertar segundo punto o \u00E1ngulo |
89 | 91 |
insert_second_point_move=Precisar segundo punto del desplazamiento |
90 | 92 |
insert_second_point_selection=Precise segundo punto del rect\u00E1ngulo de selecci\u00F3n |
93 |
insert_selection_last_point=Insertar esquina opuesta del rect?ngulo de selecci?n |
|
94 |
insert_selection_point=Insertar punto de selecci?n |
|
91 | 95 |
insert_third_point=Insertar tercer punto |
92 | 96 |
insertar=insertar |
93 | 97 |
inside_circle=Dentro de la circunferencia |
... | ... | |
159 | 163 |
start_edition=Comenzar edici\u00F3n |
160 | 164 |
stop_edition=Terminar edici\u00F3n |
161 | 165 |
stretch=Estirar |
166 |
stretch_=ESTIRAR |
|
162 | 167 |
suprimir_objetos_origen=?Suprimir objetos de origen?Si[S] o No[N] |N| |
163 | 168 |
symmetry=Simetr\u00EDa |
164 | 169 |
symmetry_=SIMETR?A |
trunk/extensions/extCAD/config/text_en.properties | ||
---|---|---|
54 | 54 |
insert_last_point_reference=Insert end of reference line |
55 | 55 |
insert_last_point_scale=Insert end of scale line |
56 | 56 |
insert_length_or_point=Insert length or point |
57 |
insert_move_first_point=Insert first point to move |
|
58 |
insert_move_last_point=Insert second point to move |
|
57 | 59 |
insert_next_point_arc_or_close=Insert next point, Arc [A] or Close [C] |
58 | 60 |
insert_next_point_line_or_close=Insert next point, Line [N] or Close [C] |
59 | 61 |
insert_next_point_selection_or_end_polygon=Insert next point or finish selection polygon [E] |
... | ... | |
69 | 71 |
insert_radius_or_second_point=Insert radius or second point |
70 | 72 |
insert_reference_point_or_factor=Insert origin or Reference Line or Scale Factor [F] |
71 | 73 |
insert_rotation_angle=Insert rotation angle |
74 |
insert_selection_last_point=Insert opposed corner of the selection rectangle |
|
75 |
insert_selection_point=Insert selection point |
|
72 | 76 |
insert_second_point=Insert second point |
73 | 77 |
insert_second_point_angle=Insert second point or angle |
74 | 78 |
insert_second_point_move=Insert second point for move |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/smc/MultiPointCADToolContext.java | ||
---|---|---|
345 | 345 |
context.clearState(); |
346 | 346 |
try |
347 | 347 |
{ |
348 |
ctxt.setQuestion(PluginServices.getText(this,"insert_point")); |
|
348 |
ctxt.setQuestion(PluginServices.getText(this,"insert_point_or_end"));
|
|
349 | 349 |
ctxt.setDescription(new String[]{"cancel", "end"}); |
350 | 350 |
ctxt.addPoint(pointX, pointY, event); |
351 | 351 |
} |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/smc/StretchCADToolContext.java | ||
---|---|---|
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.StretchCADTool; |
|
9 |
import java.awt.event.InputEvent; |
|
10 |
import com.iver.andami.PluginServices; |
|
11 |
|
|
12 |
public final class StretchCADToolContext |
|
13 |
extends statemap.FSMContext |
|
14 |
{ |
|
15 |
//--------------------------------------------------------------- |
|
16 |
// Member methods. |
|
17 |
// |
|
18 |
|
|
19 |
public StretchCADToolContext(StretchCADTool owner) |
|
20 |
{ |
|
21 |
super(); |
|
22 |
|
|
23 |
_owner = owner; |
|
24 |
setState(Stretch.SelFirstPoint); |
|
25 |
Stretch.SelFirstPoint.Entry(this); |
|
26 |
} |
|
27 |
|
|
28 |
public void addOption(String s) |
|
29 |
{ |
|
30 |
_transition = "addOption"; |
|
31 |
getState().addOption(this, s); |
|
32 |
_transition = ""; |
|
33 |
return; |
|
34 |
} |
|
35 |
|
|
36 |
public void addPoint(double pointX, double pointY, InputEvent event) |
|
37 |
{ |
|
38 |
_transition = "addPoint"; |
|
39 |
getState().addPoint(this, pointX, pointY, event); |
|
40 |
_transition = ""; |
|
41 |
return; |
|
42 |
} |
|
43 |
|
|
44 |
public void addValue(double d) |
|
45 |
{ |
|
46 |
_transition = "addValue"; |
|
47 |
getState().addValue(this, d); |
|
48 |
_transition = ""; |
|
49 |
return; |
|
50 |
} |
|
51 |
|
|
52 |
public StretchCADToolState getState() |
|
53 |
throws statemap.StateUndefinedException |
|
54 |
{ |
|
55 |
if (_state == null) |
|
56 |
{ |
|
57 |
throw( |
|
58 |
new statemap.StateUndefinedException()); |
|
59 |
} |
|
60 |
|
|
61 |
return ((StretchCADToolState) _state); |
|
62 |
} |
|
63 |
|
|
64 |
protected StretchCADTool getOwner() |
|
65 |
{ |
|
66 |
return (_owner); |
|
67 |
} |
|
68 |
|
|
69 |
//--------------------------------------------------------------- |
|
70 |
// Member data. |
|
71 |
// |
|
72 |
|
|
73 |
transient private StretchCADTool _owner; |
|
74 |
|
|
75 |
//--------------------------------------------------------------- |
|
76 |
// Inner classes. |
|
77 |
// |
|
78 |
|
|
79 |
public static abstract class StretchCADToolState |
|
80 |
extends statemap.State |
|
81 |
{ |
|
82 |
//----------------------------------------------------------- |
|
83 |
// Member methods. |
|
84 |
// |
|
85 |
|
|
86 |
protected StretchCADToolState(String name, int id) |
|
87 |
{ |
|
88 |
super (name, id); |
|
89 |
} |
|
90 |
|
|
91 |
protected void Entry(StretchCADToolContext context) {} |
|
92 |
protected void Exit(StretchCADToolContext context) {} |
|
93 |
|
|
94 |
protected void addOption(StretchCADToolContext context, String s) |
|
95 |
{ |
|
96 |
Default(context); |
|
97 |
} |
|
98 |
|
|
99 |
protected void addPoint(StretchCADToolContext context, double pointX, double pointY, InputEvent event) |
|
100 |
{ |
|
101 |
Default(context); |
|
102 |
} |
|
103 |
|
|
104 |
protected void addValue(StretchCADToolContext context, double d) |
|
105 |
{ |
|
106 |
Default(context); |
|
107 |
} |
|
108 |
|
|
109 |
protected void Default(StretchCADToolContext context) |
|
110 |
{ |
|
111 |
throw ( |
|
112 |
new statemap.TransitionUndefinedException( |
|
113 |
"State: " + |
|
114 |
context.getState().getName() + |
|
115 |
", Transition: " + |
|
116 |
context.getTransition())); |
|
117 |
} |
|
118 |
|
|
119 |
//----------------------------------------------------------- |
|
120 |
// Member data. |
|
121 |
// |
|
122 |
} |
|
123 |
|
|
124 |
/* package */ static abstract class Stretch |
|
125 |
{ |
|
126 |
//----------------------------------------------------------- |
|
127 |
// Member methods. |
|
128 |
// |
|
129 |
|
|
130 |
//----------------------------------------------------------- |
|
131 |
// Member data. |
|
132 |
// |
|
133 |
|
|
134 |
//------------------------------------------------------- |
|
135 |
// Statics. |
|
136 |
// |
|
137 |
/* package */ static Stretch_Default.Stretch_SelFirstPoint SelFirstPoint; |
|
138 |
/* package */ static Stretch_Default.Stretch_SelLastPoint SelLastPoint; |
|
139 |
/* package */ static Stretch_Default.Stretch_MoveFirstPoint MoveFirstPoint; |
|
140 |
/* package */ static Stretch_Default.Stretch_MoveLastPoint MoveLastPoint; |
|
141 |
private static Stretch_Default Default; |
|
142 |
|
|
143 |
static |
|
144 |
{ |
|
145 |
SelFirstPoint = new Stretch_Default.Stretch_SelFirstPoint("Stretch.SelFirstPoint", 0); |
|
146 |
SelLastPoint = new Stretch_Default.Stretch_SelLastPoint("Stretch.SelLastPoint", 1); |
|
147 |
MoveFirstPoint = new Stretch_Default.Stretch_MoveFirstPoint("Stretch.MoveFirstPoint", 2); |
|
148 |
MoveLastPoint = new Stretch_Default.Stretch_MoveLastPoint("Stretch.MoveLastPoint", 3); |
|
149 |
Default = new Stretch_Default("Stretch.Default", -1); |
|
150 |
} |
|
151 |
|
|
152 |
} |
|
153 |
|
|
154 |
protected static class Stretch_Default |
|
155 |
extends StretchCADToolState |
|
156 |
{ |
|
157 |
//----------------------------------------------------------- |
|
158 |
// Member methods. |
|
159 |
// |
|
160 |
|
|
161 |
protected Stretch_Default(String name, int id) |
|
162 |
{ |
|
163 |
super (name, id); |
|
164 |
} |
|
165 |
|
|
166 |
protected void addOption(StretchCADToolContext context, String s) |
|
167 |
{ |
|
168 |
StretchCADTool ctxt = context.getOwner(); |
|
169 |
|
|
170 |
if (s.equals(PluginServices.getText(this,"cancel"))) |
|
171 |
{ |
|
172 |
boolean loopbackFlag = |
|
173 |
context.getState().getName().equals( |
|
174 |
Stretch.SelFirstPoint.getName()); |
|
175 |
|
|
176 |
if (loopbackFlag == false) |
|
177 |
{ |
|
178 |
(context.getState()).Exit(context); |
|
179 |
} |
|
180 |
|
|
181 |
context.clearState(); |
|
182 |
try |
|
183 |
{ |
|
184 |
ctxt.end(); |
|
185 |
} |
|
186 |
finally |
|
187 |
{ |
|
188 |
context.setState(Stretch.SelFirstPoint); |
|
189 |
|
|
190 |
if (loopbackFlag == false) |
|
191 |
{ |
|
192 |
(context.getState()).Entry(context); |
|
193 |
} |
|
194 |
|
|
195 |
} |
|
196 |
} |
|
197 |
else |
|
198 |
{ |
|
199 |
boolean loopbackFlag = |
|
200 |
context.getState().getName().equals( |
|
201 |
Stretch.SelFirstPoint.getName()); |
|
202 |
|
|
203 |
if (loopbackFlag == false) |
|
204 |
{ |
|
205 |
(context.getState()).Exit(context); |
|
206 |
} |
|
207 |
|
|
208 |
context.clearState(); |
|
209 |
try |
|
210 |
{ |
|
211 |
ctxt.throwOptionException(PluginServices.getText(this,"incorrect_option"), s); |
|
212 |
} |
|
213 |
finally |
|
214 |
{ |
|
215 |
context.setState(Stretch.SelFirstPoint); |
|
216 |
|
|
217 |
if (loopbackFlag == false) |
|
218 |
{ |
|
219 |
(context.getState()).Entry(context); |
|
220 |
} |
|
221 |
|
|
222 |
} |
|
223 |
} |
|
224 |
|
|
225 |
return; |
|
226 |
} |
|
227 |
|
|
228 |
protected void addValue(StretchCADToolContext context, double d) |
|
229 |
{ |
|
230 |
StretchCADTool ctxt = context.getOwner(); |
|
231 |
|
|
232 |
boolean loopbackFlag = |
|
233 |
context.getState().getName().equals( |
|
234 |
Stretch.SelFirstPoint.getName()); |
|
235 |
|
|
236 |
if (loopbackFlag == false) |
|
237 |
{ |
|
238 |
(context.getState()).Exit(context); |
|
239 |
} |
|
240 |
|
|
241 |
context.clearState(); |
|
242 |
try |
|
243 |
{ |
|
244 |
ctxt.throwValueException(PluginServices.getText(this,"incorrect_value"), d); |
|
245 |
} |
|
246 |
finally |
|
247 |
{ |
|
248 |
context.setState(Stretch.SelFirstPoint); |
|
249 |
|
|
250 |
if (loopbackFlag == false) |
|
251 |
{ |
|
252 |
(context.getState()).Entry(context); |
|
253 |
} |
|
254 |
|
|
255 |
} |
|
256 |
return; |
|
257 |
} |
|
258 |
|
|
259 |
protected void addPoint(StretchCADToolContext context, double pointX, double pointY, InputEvent event) |
|
260 |
{ |
|
261 |
StretchCADTool ctxt = context.getOwner(); |
|
262 |
|
|
263 |
boolean loopbackFlag = |
|
264 |
context.getState().getName().equals( |
|
265 |
Stretch.SelFirstPoint.getName()); |
|
266 |
|
|
267 |
if (loopbackFlag == false) |
|
268 |
{ |
|
269 |
(context.getState()).Exit(context); |
|
270 |
} |
|
271 |
|
|
272 |
context.clearState(); |
|
273 |
try |
|
274 |
{ |
|
275 |
ctxt.throwPointException(PluginServices.getText(this,"incorrect_point"), pointX, pointY); |
|
276 |
} |
|
277 |
finally |
|
278 |
{ |
|
279 |
context.setState(Stretch.SelFirstPoint); |
|
280 |
|
|
281 |
if (loopbackFlag == false) |
|
282 |
{ |
|
283 |
(context.getState()).Entry(context); |
|
284 |
} |
|
285 |
|
|
286 |
} |
|
287 |
return; |
|
288 |
} |
|
289 |
|
|
290 |
//----------------------------------------------------------- |
|
291 |
// Inner classse. |
|
292 |
// |
|
293 |
|
|
294 |
|
|
295 |
private static final class Stretch_SelFirstPoint |
|
296 |
extends Stretch_Default |
|
297 |
{ |
|
298 |
//------------------------------------------------------- |
|
299 |
// Member methods. |
|
300 |
// |
|
301 |
|
|
302 |
private Stretch_SelFirstPoint(String name, int id) |
|
303 |
{ |
|
304 |
super (name, id); |
|
305 |
} |
|
306 |
|
|
307 |
protected void Entry(StretchCADToolContext context) |
|
308 |
{ |
|
309 |
StretchCADTool ctxt = context.getOwner(); |
|
310 |
|
|
311 |
ctxt.selection(); |
|
312 |
ctxt.setQuestion(PluginServices.getText(this,"insert_selection_point")); |
|
313 |
ctxt.setDescription(new String[]{"cancel"}); |
|
314 |
return; |
|
315 |
} |
|
316 |
|
|
317 |
protected void addPoint(StretchCADToolContext context, double pointX, double pointY, InputEvent event) |
|
318 |
{ |
|
319 |
StretchCADTool ctxt = context.getOwner(); |
|
320 |
|
|
321 |
|
|
322 |
(context.getState()).Exit(context); |
|
323 |
context.clearState(); |
|
324 |
try |
|
325 |
{ |
|
326 |
ctxt.setQuestion(PluginServices.getText(this,"insert_selection_last_point")); |
|
327 |
ctxt.setDescription(new String[]{"cancel"}); |
|
328 |
ctxt.addPoint(pointX, pointY, event); |
|
329 |
} |
|
330 |
finally |
|
331 |
{ |
|
332 |
context.setState(Stretch.SelLastPoint); |
|
333 |
(context.getState()).Entry(context); |
|
334 |
} |
|
335 |
return; |
|
336 |
} |
|
337 |
|
|
338 |
//------------------------------------------------------- |
|
339 |
// Member data. |
|
340 |
// |
|
341 |
} |
|
342 |
|
|
343 |
private static final class Stretch_SelLastPoint |
|
344 |
extends Stretch_Default |
|
345 |
{ |
|
346 |
//------------------------------------------------------- |
|
347 |
// Member methods. |
|
348 |
// |
|
349 |
|
|
350 |
private Stretch_SelLastPoint(String name, int id) |
|
351 |
{ |
|
352 |
super (name, id); |
|
353 |
} |
|
354 |
|
|
355 |
protected void addPoint(StretchCADToolContext context, double pointX, double pointY, InputEvent event) |
|
356 |
{ |
|
357 |
StretchCADTool ctxt = context.getOwner(); |
|
358 |
|
|
359 |
|
|
360 |
(context.getState()).Exit(context); |
|
361 |
context.clearState(); |
|
362 |
try |
|
363 |
{ |
|
364 |
ctxt.setQuestion(PluginServices.getText(this,"insert_move_first_point")); |
|
365 |
ctxt.setDescription(new String[]{"cancel"}); |
|
366 |
ctxt.addPoint(pointX, pointY, event); |
|
367 |
} |
|
368 |
finally |
|
369 |
{ |
|
370 |
context.setState(Stretch.MoveFirstPoint); |
|
371 |
(context.getState()).Entry(context); |
|
372 |
} |
|
373 |
return; |
|
374 |
} |
|
375 |
|
|
376 |
//------------------------------------------------------- |
|
377 |
// Member data. |
|
378 |
// |
|
379 |
} |
|
380 |
|
|
381 |
private static final class Stretch_MoveFirstPoint |
|
382 |
extends Stretch_Default |
|
383 |
{ |
|
384 |
//------------------------------------------------------- |
|
385 |
// Member methods. |
|
386 |
// |
|
387 |
|
|
388 |
private Stretch_MoveFirstPoint(String name, int id) |
|
389 |
{ |
|
390 |
super (name, id); |
|
391 |
} |
|
392 |
|
|
393 |
protected void addPoint(StretchCADToolContext context, double pointX, double pointY, InputEvent event) |
|
394 |
{ |
|
395 |
StretchCADTool ctxt = context.getOwner(); |
|
396 |
|
|
397 |
|
|
398 |
(context.getState()).Exit(context); |
|
399 |
context.clearState(); |
|
400 |
try |
|
401 |
{ |
|
402 |
ctxt.setQuestion(PluginServices.getText(this,"insert_move_last_point")); |
|
403 |
ctxt.setDescription(new String[]{"cancel"}); |
|
404 |
ctxt.addPoint(pointX, pointY, event); |
|
405 |
} |
|
406 |
finally |
|
407 |
{ |
|
408 |
context.setState(Stretch.MoveLastPoint); |
|
409 |
(context.getState()).Entry(context); |
|
410 |
} |
|
411 |
return; |
|
412 |
} |
|
413 |
|
|
414 |
//------------------------------------------------------- |
|
415 |
// Member data. |
|
416 |
// |
|
417 |
} |
|
418 |
|
|
419 |
private static final class Stretch_MoveLastPoint |
|
420 |
extends Stretch_Default |
|
421 |
{ |
|
422 |
//------------------------------------------------------- |
|
423 |
// Member methods. |
|
424 |
// |
|
425 |
|
|
426 |
private Stretch_MoveLastPoint(String name, int id) |
|
427 |
{ |
|
428 |
super (name, id); |
|
429 |
} |
|
430 |
|
|
431 |
protected void addPoint(StretchCADToolContext context, double pointX, double pointY, InputEvent event) |
|
432 |
{ |
|
433 |
StretchCADTool ctxt = context.getOwner(); |
|
434 |
|
|
435 |
|
|
436 |
(context.getState()).Exit(context); |
|
437 |
context.clearState(); |
|
438 |
try |
|
439 |
{ |
|
440 |
ctxt.setQuestion(PluginServices.getText(this,"insert_selection_point")); |
|
441 |
ctxt.setDescription(new String[]{"cancel"}); |
|
442 |
ctxt.addPoint(pointX, pointY, event); |
|
443 |
ctxt.end(); |
|
444 |
} |
|
445 |
finally |
|
446 |
{ |
|
447 |
context.setState(Stretch.SelFirstPoint); |
|
448 |
(context.getState()).Entry(context); |
|
449 |
} |
|
450 |
return; |
|
451 |
} |
|
452 |
|
|
453 |
//------------------------------------------------------- |
|
454 |
// Member data. |
|
455 |
// |
|
456 |
} |
|
457 |
|
|
458 |
//----------------------------------------------------------- |
|
459 |
// Member data. |
|
460 |
// |
|
461 |
} |
|
462 |
} |
|
0 | 463 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/StretchCADTool.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.cit.gvsig.gui.cad.tools; |
|
42 |
|
|
43 |
import java.awt.Graphics; |
|
44 |
import java.awt.Graphics2D; |
|
45 |
import java.awt.event.InputEvent; |
|
46 |
import java.awt.geom.Point2D; |
|
47 |
import java.awt.geom.Rectangle2D; |
|
48 |
import java.io.IOException; |
|
49 |
import java.util.ArrayList; |
|
50 |
|
|
51 |
import com.iver.andami.PluginServices; |
|
52 |
import com.iver.cit.gvsig.CADExtension; |
|
53 |
import com.iver.cit.gvsig.fmap.core.DefaultFeature; |
|
54 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
55 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
56 |
import com.iver.cit.gvsig.fmap.core.Handler; |
|
57 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
58 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
59 |
import com.iver.cit.gvsig.fmap.core.v02.FGraphicUtilities; |
|
60 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
61 |
import com.iver.cit.gvsig.fmap.edition.DefaultRowEdited; |
|
62 |
import com.iver.cit.gvsig.fmap.edition.EditionEvent; |
|
63 |
import com.iver.cit.gvsig.fmap.edition.IRowEdited; |
|
64 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
|
65 |
import com.iver.cit.gvsig.gui.cad.DefaultCADTool; |
|
66 |
import com.iver.cit.gvsig.gui.cad.exception.CommandException; |
|
67 |
import com.iver.cit.gvsig.gui.cad.tools.smc.StretchCADToolContext; |
|
68 |
import com.iver.cit.gvsig.gui.cad.tools.smc.StretchCADToolContext.StretchCADToolState; |
|
69 |
import com.iver.cit.gvsig.layers.VectorialLayerEdited; |
|
70 |
|
|
71 |
|
|
72 |
/** |
|
73 |
* Herramienta para estirar los handlers que seleccionemos previamente. |
|
74 |
* |
|
75 |
* @author Vicente Caballero Navarro |
|
76 |
*/ |
|
77 |
public class StretchCADTool extends DefaultCADTool { |
|
78 |
private StretchCADToolContext _fsm; |
|
79 |
private Point2D selfirstPoint; |
|
80 |
private Point2D sellastPoint; |
|
81 |
private Point2D movefirstPoint; |
|
82 |
private Point2D movelastPoint; |
|
83 |
private Rectangle2D rect = null; |
|
84 |
|
|
85 |
/** |
|
86 |
* Crea un nuevo PolylineCADTool. |
|
87 |
*/ |
|
88 |
public StretchCADTool() { |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* M?todo de incio, para poner el c?digo de todo lo que se requiera de una |
|
93 |
* carga previa a la utilizaci?n de la herramienta. |
|
94 |
*/ |
|
95 |
public void init() { |
|
96 |
_fsm = new StretchCADToolContext(this); |
|
97 |
} |
|
98 |
|
|
99 |
/* (non-Javadoc) |
|
100 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double, double) |
|
101 |
*/ |
|
102 |
public void transition(double x, double y, InputEvent event) { |
|
103 |
_fsm.addPoint(x, y, event); |
|
104 |
} |
|
105 |
|
|
106 |
/* (non-Javadoc) |
|
107 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double) |
|
108 |
*/ |
|
109 |
public void transition(double d) { |
|
110 |
_fsm.addValue(d); |
|
111 |
} |
|
112 |
|
|
113 |
/* (non-Javadoc) |
|
114 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, java.lang.String) |
|
115 |
*/ |
|
116 |
public void transition(String s) throws CommandException { |
|
117 |
if (!super.changeCommand(s)){ |
|
118 |
_fsm.addOption(s); |
|
119 |
} |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* DOCUMENT ME! |
|
124 |
*/ |
|
125 |
public void selection() { |
|
126 |
ArrayList rowSelected=getSelectedRows(); |
|
127 |
if (rowSelected.size() == 0 && !CADExtension.getCADTool().getClass().getName().equals("com.iver.cit.gvsig.gui.cad.tools.SelectionCADTool")) { |
|
128 |
CADExtension.setCADTool("_selection",false); |
|
129 |
((SelectionCADTool) CADExtension.getCADTool()).setNextTool( |
|
130 |
"_stretch"); |
|
131 |
} |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* Equivale al transition del prototipo pero sin pasarle como par?metro el |
|
136 |
* editableFeatureSource que ya estar? creado. |
|
137 |
* |
|
138 |
* @param x par?metro x del punto que se pase en esta transici?n. |
|
139 |
* @param y par?metro y del punto que se pase en esta transici?n. |
|
140 |
*/ |
|
141 |
public void addPoint(double x, double y,InputEvent event) { |
|
142 |
StretchCADToolState actualState = (StretchCADToolState) _fsm.getPreviousState(); |
|
143 |
String status = actualState.getName(); |
|
144 |
|
|
145 |
if (status.equals("Stretch.SelFirstPoint")) { |
|
146 |
selfirstPoint = new Point2D.Double(x, y); |
|
147 |
} else if (status.equals("Stretch.SelLastPoint")) { |
|
148 |
sellastPoint = new Point2D.Double(x,y); |
|
149 |
|
|
150 |
double x1; |
|
151 |
double y1; |
|
152 |
double w1; |
|
153 |
double h1; |
|
154 |
|
|
155 |
if (selfirstPoint.getX() < sellastPoint.getX()) { |
|
156 |
x1 = selfirstPoint.getX(); |
|
157 |
w1 = sellastPoint.getX() - selfirstPoint.getX(); |
|
158 |
} else { |
|
159 |
x1 = sellastPoint.getX(); |
|
160 |
w1 = selfirstPoint.getX() - sellastPoint.getX(); |
|
161 |
} |
|
162 |
|
|
163 |
if (selfirstPoint.getY() < sellastPoint.getY()) { |
|
164 |
y1 = selfirstPoint.getY(); |
|
165 |
h1 = sellastPoint.getY() - selfirstPoint.getY(); |
|
166 |
} else { |
|
167 |
y1 = sellastPoint.getY(); |
|
168 |
h1 = selfirstPoint.getY() - sellastPoint.getY(); |
|
169 |
} |
|
170 |
|
|
171 |
rect = new Rectangle2D.Double(x1, y1, w1, h1); |
|
172 |
} else if (status.equals("Stretch.MoveFirstPoint")) { |
|
173 |
movefirstPoint = new Point2D.Double(x, y); |
|
174 |
} else if (status.equals("Stretch.MoveLastPoint")) { |
|
175 |
VectorialLayerEdited vle=getVLE(); |
|
176 |
VectorialEditableAdapter vea=vle.getVEA(); |
|
177 |
vea.startComplexRow(); |
|
178 |
ArrayList selectedRow=getSelectedRows(); |
|
179 |
ArrayList selectedRowAux=new ArrayList(); |
|
180 |
PluginServices.getMDIManager().setWaitCursor(); |
|
181 |
movelastPoint = new Point2D.Double(x, y); |
|
182 |
|
|
183 |
Handler[] handlers = null; |
|
184 |
|
|
185 |
//for (int i = selectedGeometries.nextSetBit(0); i >= 0; |
|
186 |
// i = selectedGeometries.nextSetBit(i + 1)) { |
|
187 |
try { |
|
188 |
for (int i =0;i<selectedRow.size(); i++) { |
|
189 |
IRowEdited edRow = (IRowEdited) selectedRow.get(i); |
|
190 |
DefaultFeature fea = (DefaultFeature) edRow.getLinkedRow().cloneRow(); |
|
191 |
IGeometry geometry = null; |
|
192 |
geometry = fea.getGeometry(); |
|
193 |
|
|
194 |
handlers = geometry.getHandlers(IGeometry.STRETCHINGHANDLER); |
|
195 |
|
|
196 |
for (int j = 0; j < handlers.length; j++) { |
|
197 |
if (rect.contains(handlers[j].getPoint())) { |
|
198 |
handlers[j].move(movelastPoint.getX() - |
|
199 |
movefirstPoint.getX(), |
|
200 |
movelastPoint.getY() - movefirstPoint.getY()); |
|
201 |
} |
|
202 |
} |
|
203 |
vea.modifyRow(edRow.getIndex(),fea,getName(),EditionEvent.GRAPHIC); |
|
204 |
selectedRowAux.add(new DefaultRowEdited(fea,IRowEdited.STATUS_MODIFIED,edRow.getIndex())); |
|
205 |
} |
|
206 |
vea.endComplexRow(); |
|
207 |
vle.setSelectionCache(selectedRowAux); |
|
208 |
|
|
209 |
PluginServices.getMDIManager().restoreCursor(); |
|
210 |
} catch (IOException e) { |
|
211 |
// TODO Auto-generated catch block |
|
212 |
e.printStackTrace(); |
|
213 |
} catch (DriverIOException e) { |
|
214 |
// TODO Auto-generated catch block |
|
215 |
e.printStackTrace(); |
|
216 |
} |
|
217 |
} |
|
218 |
} |
|
219 |
|
|
220 |
/** |
|
221 |
* M?todo para dibujar la lo necesario para el estado en el que nos |
|
222 |
* encontremos. |
|
223 |
* |
|
224 |
* @param g Graphics sobre el que dibujar. |
|
225 |
* @param x par?metro x del punto que se pase para dibujar. |
|
226 |
* @param y par?metro x del punto que se pase para dibujar. |
|
227 |
*/ |
|
228 |
public void drawOperation(Graphics g, double x, double y) { |
|
229 |
StretchCADToolState actualState = ((StretchCADToolContext) _fsm).getState(); |
|
230 |
String status = actualState.getName(); |
|
231 |
ArrayList selectedRow = getSelectedRows(); |
|
232 |
|
|
233 |
if (status.equals("Stretch.SelLastPoint")) { |
|
234 |
GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, |
|
235 |
4); |
|
236 |
elShape.moveTo(selfirstPoint.getX(), selfirstPoint.getY()); |
|
237 |
elShape.lineTo(x, selfirstPoint.getY()); |
|
238 |
elShape.lineTo(x, y); |
|
239 |
elShape.lineTo(selfirstPoint.getX(), y); |
|
240 |
elShape.lineTo(selfirstPoint.getX(), selfirstPoint.getY()); |
|
241 |
ShapeFactory.createPolyline2D(elShape).draw((Graphics2D) g, |
|
242 |
getCadToolAdapter().getMapControl().getViewPort(), |
|
243 |
modifySymbol); |
|
244 |
} else if (status.equals("Stretch.MoveFirstPoint")) { |
|
245 |
Handler[] handlers = null; |
|
246 |
for (int i = 0;i<selectedRow.size();i++) { |
|
247 |
IRowEdited edRow = (IRowEdited) selectedRow.get(i); |
|
248 |
DefaultFeature fea = (DefaultFeature) edRow.getLinkedRow().cloneRow(); |
|
249 |
IGeometry geometry = null; |
|
250 |
geometry = fea.getGeometry(); |
|
251 |
|
|
252 |
handlers = geometry.getHandlers(IGeometry.STRETCHINGHANDLER); |
|
253 |
|
|
254 |
for (int j = 0; j < handlers.length; j++) { |
|
255 |
if (rect.contains(handlers[j].getPoint())) { |
|
256 |
FGraphicUtilities.DrawHandlers((Graphics2D) g,getCadToolAdapter().getMapControl().getViewPort().getAffineTransform(),new Handler[] {handlers[j]}); |
|
257 |
} |
|
258 |
} |
|
259 |
} |
|
260 |
} else if (status.equals("Stretch.MoveLastPoint")) { |
|
261 |
Handler[] handlers = null; |
|
262 |
|
|
263 |
for (int i = 0;i<selectedRow.size();i++) { |
|
264 |
IRowEdited edRow = (IRowEdited) selectedRow.get(i); |
|
265 |
DefaultFeature fea = (DefaultFeature) edRow.getLinkedRow().cloneRow(); |
|
266 |
IGeometry geometry = null; |
|
267 |
geometry = fea.getGeometry(); |
|
268 |
|
|
269 |
handlers = geometry.getHandlers(IGeometry.STRETCHINGHANDLER); |
|
270 |
|
|
271 |
for (int j = 0; j < handlers.length; j++) { |
|
272 |
if (rect.contains(handlers[j].getPoint())) { |
|
273 |
handlers[j].move(x - movefirstPoint.getX(), |
|
274 |
y - movefirstPoint.getY()); |
|
275 |
} |
|
276 |
} |
|
277 |
geometry.draw((Graphics2D) g, |
|
278 |
getCadToolAdapter().getMapControl().getViewPort(), |
|
279 |
modifySymbol); |
|
280 |
} |
|
281 |
} |
|
282 |
} |
|
283 |
|
|
284 |
/** |
|
285 |
* Add a diferent option. |
|
286 |
* |
|
287 |
* @param s |
|
288 |
* Diferent option. |
|
289 |
*/ |
|
290 |
public void addOption(String s) { |
|
291 |
} |
|
292 |
|
|
293 |
/* (non-Javadoc) |
|
294 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double) |
|
295 |
*/ |
|
296 |
public void addValue(double d) { |
|
297 |
} |
|
298 |
|
|
299 |
|
|
300 |
public String getName() { |
|
301 |
return PluginServices.getText(this,"stretch_"); |
|
302 |
} |
|
303 |
|
|
304 |
public String toString() { |
|
305 |
return "_stretch"; |
|
306 |
} |
|
307 |
public boolean isApplicable(int shapeType) { |
|
308 |
switch (shapeType) { |
|
309 |
case FShape.POINT: |
|
310 |
case FShape.MULTIPOINT: |
|
311 |
return false; |
|
312 |
} |
|
313 |
return true; |
|
314 |
} |
|
315 |
} |
|
0 | 316 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/StretchExtension.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.cit.gvsig; |
|
42 |
|
|
43 |
import java.util.ArrayList; |
|
44 |
|
|
45 |
import com.iver.andami.PluginServices; |
|
46 |
import com.iver.andami.plugins.Extension; |
|
47 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
48 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
49 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
|
50 |
import com.iver.cit.gvsig.gui.View; |
|
51 |
import com.iver.cit.gvsig.gui.cad.tools.StretchCADTool; |
|
52 |
import com.iver.cit.gvsig.layers.VectorialLayerEdited; |
|
53 |
|
|
54 |
/** |
|
55 |
* Extensi?n que gestiona la simplificaci?n de una geometr?a compuesta en otras m?s sencillas. |
|
56 |
* |
|
57 |
* @author Vicente Caballero Navarro |
|
58 |
*/ |
|
59 |
public class StretchExtension extends Extension { |
|
60 |
private View view; |
|
61 |
|
|
62 |
private MapControl mapControl; |
|
63 |
private StretchCADTool stretch; |
|
64 |
|
|
65 |
/** |
|
66 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
67 |
*/ |
|
68 |
public void initialize() { |
|
69 |
stretch=new StretchCADTool(); |
|
70 |
CADExtension.addCADTool("_stretch",stretch); |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
75 |
*/ |
|
76 |
public void execute(String s) { |
|
77 |
CADExtension.initFocus(); |
|
78 |
if (s.equals("_stretch")) { |
|
79 |
CADExtension.setCADTool(s,true); |
|
80 |
} |
|
81 |
CADExtension.getEditionManager().setMapControl(mapControl); |
|
82 |
CADExtension.getCADToolAdapter().configureMenu(); |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
87 |
*/ |
|
88 |
public boolean isEnabled() { |
|
89 |
|
|
90 |
try { |
|
91 |
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) { |
|
92 |
view = (View) PluginServices.getMDIManager().getActiveView(); |
|
93 |
mapControl = (MapControl) view.getMapControl(); |
|
94 |
EditionManager em=CADExtension.getEditionManager(); |
|
95 |
if (em.getActiveLayerEdited()==null) |
|
96 |
return false; |
|
97 |
VectorialLayerEdited vle=(VectorialLayerEdited)em.getActiveLayerEdited(); |
|
98 |
FLyrVect lv=(FLyrVect)vle.getLayer(); |
|
99 |
ArrayList selectedRows=vle.getSelectedRow(); |
|
100 |
if (selectedRows.size()<1) { |
|
101 |
return false; |
|
102 |
} |
|
103 |
if (stretch.isApplicable(lv.getShapeType())){ |
|
104 |
return true; |
|
105 |
} |
|
106 |
} |
|
107 |
} catch (DriverException e) { |
|
108 |
e.printStackTrace(); |
|
109 |
} |
|
110 |
return false; |
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
114 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
115 |
*/ |
|
116 |
public boolean isVisible() { |
|
117 |
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) |
|
118 |
{ |
|
119 |
return true; |
|
120 |
} |
|
121 |
else |
|
122 |
return false; |
|
123 |
} |
|
124 |
} |
|
0 | 125 |
Also available in: Unified diff