svn-gvsig-desktop / trunk / extensions / extCAD / src / com / iver / cit / gvsig / gui / cad / tools / ComplexSelectionCADTool.java @ 10626
History | View | Annotate | Download (18.6 KB)
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.Color; |
44 |
import java.awt.Graphics; |
45 |
import java.awt.Graphics2D; |
46 |
import java.awt.Image; |
47 |
import java.awt.event.InputEvent; |
48 |
import java.awt.event.MouseEvent; |
49 |
import java.awt.geom.Point2D; |
50 |
import java.util.ArrayList; |
51 |
|
52 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
53 |
import com.iver.andami.PluginServices; |
54 |
import com.iver.cit.gvsig.CADExtension; |
55 |
import com.iver.cit.gvsig.fmap.MapControl; |
56 |
import com.iver.cit.gvsig.fmap.ViewPort; |
57 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
58 |
import com.iver.cit.gvsig.fmap.core.Handler; |
59 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
60 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
61 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
62 |
import com.iver.cit.gvsig.fmap.edition.DefaultRowEdited; |
63 |
import com.iver.cit.gvsig.fmap.edition.IRowEdited; |
64 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
65 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
66 |
import com.iver.cit.gvsig.gui.cad.CADTool; |
67 |
import com.iver.cit.gvsig.gui.cad.exception.CommandException; |
68 |
import com.iver.cit.gvsig.gui.cad.tools.smc.ComplexSelectionCADToolContext; |
69 |
import com.iver.cit.gvsig.gui.cad.tools.smc.ComplexSelectionCADToolContext.ComplexSelectionCADToolState; |
70 |
import com.iver.cit.gvsig.layers.VectorialLayerEdited; |
71 |
import com.iver.cit.gvsig.project.documents.table.gui.Table; |
72 |
|
73 |
/**
|
74 |
* DOCUMENT ME!
|
75 |
*
|
76 |
* @author Vicente Caballero Navarro
|
77 |
*/
|
78 |
public class ComplexSelectionCADTool extends SelectionCADTool { |
79 |
//public final static int tolerance = 4;
|
80 |
|
81 |
private ComplexSelectionCADToolContext _fsm;
|
82 |
|
83 |
//private Point2D firstPoint;
|
84 |
|
85 |
//private Point2D lastPoint;
|
86 |
|
87 |
|
88 |
|
89 |
//private String nextState;
|
90 |
// Registros de los que se ha sleccionado alg?n handler.
|
91 |
//private ArrayList rowselectedHandlers=new ArrayList();
|
92 |
//private String type=PluginServices.getText(this,"inside_circle");
|
93 |
//private ArrayList pointsPolygon=new ArrayList();
|
94 |
/**
|
95 |
* Crea un nuevo ComplexSelectionCADTool.
|
96 |
*/
|
97 |
public ComplexSelectionCADTool() {
|
98 |
type=PluginServices.getText(this,"inside_circle"); |
99 |
} |
100 |
|
101 |
/**
|
102 |
* M?todo de incio, para poner el c?digo de todo lo que se requiera de una
|
103 |
* carga previa a la utilizaci?n de la herramienta.
|
104 |
*/
|
105 |
public void init() { |
106 |
_fsm = new ComplexSelectionCADToolContext(this); |
107 |
setNextTool("complex_selection");
|
108 |
|
109 |
setType(PluginServices.getText(this,"inside_circle")); |
110 |
} |
111 |
|
112 |
/**
|
113 |
* Equivale al transition del prototipo pero sin pasarle como par? metro el
|
114 |
* editableFeatureSource que ya estar? creado.
|
115 |
*
|
116 |
* @param selection
|
117 |
* Bitset con las geometr?as que est?n seleccionadas.
|
118 |
* @param x
|
119 |
* par?metro x del punto que se pase en esta transici?n.
|
120 |
* @param y
|
121 |
* par?metro y del punto que se pase en esta transici?n.
|
122 |
*/
|
123 |
public void addPoint(double x, double y, InputEvent event) { |
124 |
if (event!=null && ((MouseEvent)event).getClickCount()==2){ |
125 |
try {
|
126 |
pointDoubleClick((MapControl)event.getComponent()); |
127 |
} catch (ReadDriverException e) {
|
128 |
e.printStackTrace(); |
129 |
} |
130 |
return;
|
131 |
} |
132 |
ComplexSelectionCADToolState actualState = (ComplexSelectionCADToolState) _fsm |
133 |
.getPreviousState(); |
134 |
String status = actualState.getName();
|
135 |
System.out.println("PREVIOUSSTATE =" + status); // + "ESTADO ACTUAL: " + |
136 |
// _fsm.getState());
|
137 |
VectorialLayerEdited vle = getVLE(); |
138 |
VectorialEditableAdapter vea=vle.getVEA(); |
139 |
ArrayList selectedHandler = vle.getSelectedHandler();
|
140 |
ArrayList selectedRow = vle.getSelectedRow();
|
141 |
System.out.println("STATUS ACTUAL = " + _fsm.getTransition()); |
142 |
if (status.equals("Selection.FirstPoint")) { |
143 |
firstPoint=new Point2D.Double(x,y); |
144 |
pointsPolygon.add(firstPoint); |
145 |
} else if (status.equals("Selection.SecondPoint")) { |
146 |
} else if (status.equals("Selection.WithFeatures")) { |
147 |
} else if (status.equals("Selection.WithHandlers")) { |
148 |
vea.startComplexRow(); |
149 |
ArrayList selectedRowsAux=new ArrayList(); |
150 |
for (int i = 0; i < selectedRow.size(); i++) { |
151 |
IRowEdited row = (IRowEdited) selectedRow.get(i); |
152 |
IFeature feat = (IFeature) row.getLinkedRow().cloneRow(); |
153 |
// Movemos los handlers que hemos seleccionado
|
154 |
// previamente dentro del m?todo select()
|
155 |
for (int k = 0; k < selectedHandler.size(); k++) { |
156 |
Handler h = (Handler) selectedHandler.get(k); |
157 |
h.set(x, y); |
158 |
} |
159 |
|
160 |
modifyFeature(row.getIndex(), feat); |
161 |
selectedRowsAux.add(new DefaultRowEdited(feat,IRowEdited.STATUS_MODIFIED,row.getIndex()));
|
162 |
} |
163 |
firstPoint=new Point2D.Double(x,y); |
164 |
vle.setSelectionCache(VectorialLayerEdited.SAVEPREVIOUS, selectedRowsAux); |
165 |
String description=PluginServices.getText(this,"move_handlers"); |
166 |
vea.endComplexRow(description); |
167 |
}else if (status.equals("Selection.NextPointPolygon")) { |
168 |
pointsPolygon.add(new Point2D.Double(x,y)); |
169 |
} |
170 |
} |
171 |
|
172 |
/**
|
173 |
* Receives second point
|
174 |
* @param x
|
175 |
* @param y
|
176 |
* @return numFeatures selected
|
177 |
*/
|
178 |
public int selectWithSecondPointOutRectangle(double x, double y, InputEvent event) { |
179 |
Point2D lastPoint=new Point2D.Double(x,y); |
180 |
GeneralPathX gpx=new GeneralPathX();
|
181 |
gpx.moveTo(firstPoint.getX(),firstPoint.getY()); |
182 |
gpx.lineTo(lastPoint.getX(),firstPoint.getY()); |
183 |
gpx.lineTo(lastPoint.getX(),lastPoint.getY()); |
184 |
gpx.lineTo(firstPoint.getX(),lastPoint.getY()); |
185 |
gpx.closePath(); |
186 |
IGeometry rectangle=ShapeFactory.createPolygon2D(gpx); |
187 |
return selectWithPolygon(rectangle);
|
188 |
} |
189 |
/**
|
190 |
* Receives second point
|
191 |
* @param x
|
192 |
* @param y
|
193 |
* @return numFeatures selected
|
194 |
*/
|
195 |
public int selectWithCircle(double x, double y, InputEvent event) { |
196 |
IGeometry circle=ShapeFactory.createCircle(firstPoint,new Point2D.Double(x,y)); |
197 |
return selectWithPolygon(circle);
|
198 |
} |
199 |
public int selectWithPolygon(IGeometry polygon) { |
200 |
VectorialLayerEdited vle = getVLE(); |
201 |
PluginServices.getMDIManager().setWaitCursor(); |
202 |
|
203 |
if (getType().equals(PluginServices.getText(this,"inside_circle")) || getType().equals(PluginServices.getText(this,"inside_polygon"))) { |
204 |
vle.selectInsidePolygon(polygon); |
205 |
} else if (getType().equals(PluginServices.getText(this,"cross_circle")) || getType().equals(PluginServices.getText(this,"cross_polygon"))) { |
206 |
vle.selectCrossPolygon(polygon); |
207 |
} else if (getType().equals(PluginServices.getText(this,"out_circle")) || getType().equals(PluginServices.getText(this,"out_polygon")) || getType().equals(PluginServices.getText(this,"out_rectangle"))) { |
208 |
vle.selectOutPolygon(polygon); |
209 |
} |
210 |
ArrayList selectedRow = vle.getSelectedRow();
|
211 |
PluginServices.getMDIManager().restoreCursor(); |
212 |
if (selectedRow.size() > 0) { |
213 |
nextState = "Selection.WithSelectedFeatures";
|
214 |
end(); |
215 |
} else
|
216 |
nextState = "Selection.FirstPoint";
|
217 |
return selectedRow.size();
|
218 |
} |
219 |
|
220 |
/**
|
221 |
* M?todo para dibujar la lo necesario para el estado en el que nos
|
222 |
* encontremos.
|
223 |
*
|
224 |
* @param g
|
225 |
* Graphics sobre el que dibujar.
|
226 |
* @param selectedGeometries
|
227 |
* BitSet con las geometr?as seleccionadas.
|
228 |
* @param x
|
229 |
* par?metro x del punto que se pase para dibujar.
|
230 |
* @param y
|
231 |
* par?metro x del punto que se pase para dibujar.
|
232 |
*/
|
233 |
public void drawOperation(Graphics g, double x, double y) { |
234 |
ComplexSelectionCADToolState actualState = _fsm.getState(); |
235 |
String status = actualState.getName();
|
236 |
VectorialLayerEdited vle = getVLE(); |
237 |
ArrayList selectedHandler = vle.getSelectedHandler();
|
238 |
ViewPort vp=vle.getLayer().getMapContext().getViewPort(); |
239 |
if (status.equals("Selection.SecondPoint") || status.equals("Selection.SecondPointOutRectangle")) { |
240 |
// Dibuja el rect?ngulo de selecci?n
|
241 |
GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD,
|
242 |
4);
|
243 |
elShape.moveTo(firstPoint.getX(), firstPoint.getY()); |
244 |
elShape.lineTo(x, firstPoint.getY()); |
245 |
elShape.lineTo(x, y); |
246 |
elShape.lineTo(firstPoint.getX(), y); |
247 |
elShape.lineTo(firstPoint.getX(), firstPoint.getY()); |
248 |
ShapeFactory.createPolyline2D(elShape).draw((Graphics2D) g,
|
249 |
vp, |
250 |
CADTool.selectSymbol); |
251 |
Image img = vle.getSelectionImage();
|
252 |
g.drawImage(img, 0, 0, null); |
253 |
return;
|
254 |
}if (status.equals("Selection.SecondPointCircle")) { |
255 |
IGeometry circle=ShapeFactory.createCircle(firstPoint,new Point2D.Double(x,y)); |
256 |
GeneralPathX gpx=new GeneralPathX();
|
257 |
gpx.append(circle.getInternalShape(),true);
|
258 |
IGeometry circleSel=ShapeFactory.createPolyline2D(gpx); |
259 |
// Dibuja el c?rculo de selecci?n
|
260 |
circleSel.draw((Graphics2D) g,
|
261 |
vp, |
262 |
CADTool.selectSymbol); |
263 |
Image img = vle.getSelectionImage();
|
264 |
g.drawImage(img, 0, 0, null); |
265 |
return;
|
266 |
}else if (status.equals("Selection.NextPointPolygon")) { |
267 |
// Dibuja el pol?gono de selecci?n
|
268 |
IGeometry polygon=getGeometryPolygon(new Point2D.Double(x,y)); |
269 |
polygon.draw((Graphics2D) g,
|
270 |
vp, |
271 |
CADTool.selectSymbol); |
272 |
Image img = vle.getSelectionImage();
|
273 |
g.drawImage(img, 0, 0, null); |
274 |
return;
|
275 |
}else if (status.equals("Selection.WithHandlers")) { |
276 |
// Movemos los handlers que hemos seleccionado
|
277 |
// previamente dentro del m?todo select()
|
278 |
for (int k = 0; k < selectedHandler.size(); k++) { |
279 |
Handler h = (Handler) selectedHandler.get(k); |
280 |
h.set(x, y); |
281 |
} |
282 |
// Y una vez movidos los v?rtices (handles)
|
283 |
// redibujamos la nueva geometr?a.
|
284 |
for (int i = 0; i < rowselectedHandlers.size(); i++) { |
285 |
IRowEdited rowEd = (IRowEdited) rowselectedHandlers.get(i); |
286 |
IGeometry geom = ((IFeature) rowEd.getLinkedRow()) |
287 |
.getGeometry().cloneGeometry(); |
288 |
g.setColor(Color.gray);
|
289 |
geom.draw((Graphics2D) g, vp, CADTool.modifySymbol);
|
290 |
} |
291 |
return;
|
292 |
}else{
|
293 |
if (!vle.getLayer().isVisible())
|
294 |
return;
|
295 |
try{
|
296 |
Image imgSel = vle.getSelectionImage();
|
297 |
if (imgSel!=null) |
298 |
g.drawImage(imgSel, 0, 0, null); |
299 |
Image imgHand = vle.getHandlersImage();
|
300 |
if (imgHand!=null) |
301 |
g.drawImage(imgHand, 0, 0, null); |
302 |
}catch (Exception e) { |
303 |
} |
304 |
} |
305 |
} |
306 |
|
307 |
/**
|
308 |
* Add a diferent option.
|
309 |
*
|
310 |
* @param sel
|
311 |
* DOCUMENT ME!
|
312 |
* @param s
|
313 |
* Diferent option.
|
314 |
*/
|
315 |
public void addOption(String s) { |
316 |
ComplexSelectionCADToolState actualState = (ComplexSelectionCADToolState) _fsm |
317 |
.getPreviousState(); |
318 |
String status = actualState.getName();
|
319 |
System.out.println("PREVIOUSSTATE =" + status); // + "ESTADO ACTUAL: " + |
320 |
// _fsm.getState());
|
321 |
System.out.println("STATUS ACTUAL = " + _fsm.getTransition()); |
322 |
if (s.equals(PluginServices.getText(this,"cancel"))){ |
323 |
init(); |
324 |
return;
|
325 |
}else if (s.equals(PluginServices.getText(this,"select_all"))){ |
326 |
selectAll(); |
327 |
init(); |
328 |
return;
|
329 |
} |
330 |
if (status.equals("Selection.FirstPoint")) { |
331 |
setType(s); |
332 |
return;
|
333 |
}else if (status.equals("Selection.NextPointPolygon")){ |
334 |
if (s.equals(PluginServices.getText(this,"end_polygon")) || s.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.end"))) { |
335 |
IGeometry polygon=getGeometryPolygon(null);
|
336 |
GeneralPathX gpx=new GeneralPathX();
|
337 |
gpx.append(polygon,true);
|
338 |
if (gpx.isCCW()) {
|
339 |
gpx.flip(); |
340 |
polygon=ShapeFactory.createPolygon2D(gpx); |
341 |
} |
342 |
selectWithPolygon(polygon); |
343 |
pointsPolygon.clear(); |
344 |
setType(PluginServices.getText(this,"inside_circle")); |
345 |
return;
|
346 |
} |
347 |
} |
348 |
init(); |
349 |
} |
350 |
private int selectAll() { |
351 |
VectorialLayerEdited vle = getVLE(); |
352 |
PluginServices.getMDIManager().setWaitCursor(); |
353 |
vle.selectAll(); |
354 |
ArrayList selectedRow = vle.getSelectedRow();
|
355 |
PluginServices.getMDIManager().restoreCursor(); |
356 |
if (selectedRow.size() > 0) { |
357 |
nextState = "Selection.WithSelectedFeatures";
|
358 |
} else
|
359 |
nextState = "Selection.FirstPoint";
|
360 |
end(); |
361 |
return selectedRow.size();
|
362 |
} |
363 |
|
364 |
private IGeometry getGeometryPolygon(Point2D p) { |
365 |
Point2D[] points = (Point2D[]) pointsPolygon.toArray(new Point2D[0]); |
366 |
GeneralPathX gpx = new GeneralPathX();
|
367 |
for (int i = 0; i < points.length; i++) { |
368 |
if (i == 0) { |
369 |
gpx.moveTo(points[i].getX(), points[i].getY()); |
370 |
} else {
|
371 |
gpx.lineTo(points[i].getX(), points[i].getY()); |
372 |
} |
373 |
} |
374 |
if (p!=null){ |
375 |
gpx.lineTo(p.getX(),p.getY()); |
376 |
gpx.closePath(); |
377 |
IGeometry polyline = ShapeFactory.createPolyline2D(gpx); |
378 |
return polyline;
|
379 |
} |
380 |
gpx.closePath(); |
381 |
IGeometry polygon = ShapeFactory.createPolygon2D(gpx); |
382 |
return polygon;
|
383 |
} |
384 |
|
385 |
/*
|
386 |
* (non-Javadoc)
|
387 |
*
|
388 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double)
|
389 |
*/
|
390 |
public void addValue(double d) { |
391 |
} |
392 |
|
393 |
public void end() { |
394 |
if (!getNextTool().equals("complex_selection")) |
395 |
CADExtension.setCADTool(getNextTool(),false);
|
396 |
} |
397 |
|
398 |
public String getName() { |
399 |
return PluginServices.getText(this,"complex_selection_"); |
400 |
} |
401 |
|
402 |
public boolean selectFeatures(double x, double y, InputEvent event) { |
403 |
ComplexSelectionCADToolState actualState =_fsm |
404 |
.getState(); |
405 |
|
406 |
String status = actualState.getName();
|
407 |
VectorialLayerEdited vle = getVLE(); |
408 |
|
409 |
|
410 |
if ((status.equals("Selection.FirstPoint")) |
411 |
|| (status.equals("Selection.WithSelectedFeatures"))) {
|
412 |
PluginServices.getMDIManager().setWaitCursor(); |
413 |
firstPoint = new Point2D.Double(x, y); |
414 |
vle.selectWithPoint(x,y,multipleSelection); |
415 |
PluginServices.getMDIManager().restoreCursor(); |
416 |
} |
417 |
ArrayList selectedRow = vle.getSelectedRow();
|
418 |
if (selectedRow.size() > 0) { |
419 |
nextState = "Selection.WithSelectedFeatures";
|
420 |
return true; |
421 |
} else {
|
422 |
{ |
423 |
nextState = "Selection.SecondPoint";
|
424 |
return true; |
425 |
} |
426 |
} |
427 |
} |
428 |
|
429 |
public int selectHandlers(double x, double y, InputEvent event) { |
430 |
Point2D auxPoint = new Point2D.Double(x, y); |
431 |
|
432 |
VectorialLayerEdited vle = getVLE(); |
433 |
ArrayList selectedHandler = vle.getSelectedHandler();
|
434 |
ArrayList selectedRow = vle.getSelectedRow();
|
435 |
System.out.println("DENTRO DE selectHandlers. selectedRow.size= " |
436 |
+ selectedRow.size()); |
437 |
selectedHandler.clear(); |
438 |
|
439 |
// Se comprueba si se pincha en una gemometr?a
|
440 |
PluginServices.getMDIManager().setWaitCursor(); |
441 |
|
442 |
double tam = getCadToolAdapter().getMapControl().getViewPort()
|
443 |
.toMapDistance(tolerance); |
444 |
|
445 |
Handler[] handlers = null; |
446 |
rowselectedHandlers.clear(); |
447 |
for (int i = 0; i < selectedRow.size(); i++) { |
448 |
IRowEdited rowEd = (IRowEdited) selectedRow.get(i); |
449 |
|
450 |
IFeature fea = (IFeature) rowEd.getLinkedRow(); |
451 |
handlers = fea.getGeometry().getHandlers(IGeometry.SELECTHANDLER); |
452 |
// y miramos los handlers de cada entidad seleccionada
|
453 |
double min = tam;
|
454 |
// int hSel = -1;
|
455 |
|
456 |
for (int j = 0; j < handlers.length; j++) { |
457 |
Point2D handlerPoint = handlers[j].getPoint();
|
458 |
double distance = auxPoint.distance(handlerPoint);
|
459 |
if (distance <= min) {
|
460 |
min = distance; |
461 |
// hSel = j;
|
462 |
selectedHandler.add(handlers[j]); |
463 |
rowselectedHandlers.add(rowEd); |
464 |
} |
465 |
} |
466 |
} |
467 |
PluginServices.getMDIManager().restoreCursor(); |
468 |
|
469 |
int numHandlesSelected = selectedHandler.size();
|
470 |
|
471 |
/*
|
472 |
* if (numHandlesSelected == 0) selectFeatures(x,y);
|
473 |
*/
|
474 |
|
475 |
return numHandlesSelected;
|
476 |
} |
477 |
|
478 |
public String getType() { |
479 |
return type;
|
480 |
} |
481 |
|
482 |
public void setType(String type) { |
483 |
if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle"))){ |
484 |
this.type=PluginServices.getText(this,"out_rectangle"); |
485 |
}else if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon"))){ |
486 |
this.type=PluginServices.getText(this,"inside_polygon"); |
487 |
}else if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon"))){ |
488 |
this.type=PluginServices.getText(this,"cross_polygon"); |
489 |
}else if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon"))){ |
490 |
this.type=PluginServices.getText(this,"out_polygon"); |
491 |
}else if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.introcircle"))){ |
492 |
this.type=PluginServices.getText(this,"inside_circle"); |
493 |
}else if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle"))){ |
494 |
this.type=PluginServices.getText(this,"cross_circle"); |
495 |
}else if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.outcircle"))){ |
496 |
this.type=PluginServices.getText(this,"out_circle"); |
497 |
}else if (type.equals(PluginServices.getText(this,"select_all"))){ |
498 |
selectAll(); |
499 |
init(); |
500 |
}else{
|
501 |
this.type = type;
|
502 |
} |
503 |
pointsPolygon.clear(); |
504 |
} |
505 |
/*
|
506 |
* (non-Javadoc)
|
507 |
*
|
508 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet,
|
509 |
* double, double)
|
510 |
*/
|
511 |
public void transition(double x, double y, InputEvent event) { |
512 |
System.out.println("TRANSICION DESDE ESTADO " + _fsm.getState() |
513 |
+ " x= " + x + " y=" + y); |
514 |
try{
|
515 |
_fsm.addPoint(x, y, event); |
516 |
}catch (Exception e) { |
517 |
init(); |
518 |
} |
519 |
System.out.println("ESTADO ACTUAL: " + getStatus()); |
520 |
|
521 |
FLyrVect lv=(FLyrVect)((VectorialLayerEdited)CADExtension.getEditionManager().getActiveLayerEdited()).getLayer(); |
522 |
com.iver.andami.ui.mdiManager.IWindow[] views = PluginServices.getMDIManager().getAllWindows();
|
523 |
|
524 |
for (int i=0 ; i<views.length ; i++){ |
525 |
if (views[i] instanceof Table){ |
526 |
Table table=(Table)views[i]; |
527 |
if (table.getModel().getAssociatedTable()!=null && table.getModel().getAssociatedTable().equals(lv)) |
528 |
table.updateSelection(); |
529 |
} |
530 |
} |
531 |
} |
532 |
public String getStatus() { |
533 |
try {
|
534 |
ComplexSelectionCADToolState actualState = (ComplexSelectionCADToolState) _fsm |
535 |
.getPreviousState(); |
536 |
String status = actualState.getName();
|
537 |
|
538 |
return status;
|
539 |
} catch (NullPointerException e) { |
540 |
return "Selection.FirstPoint"; |
541 |
} |
542 |
} |
543 |
/*
|
544 |
* (non-Javadoc)
|
545 |
*
|
546 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet,
|
547 |
* java.lang.String)
|
548 |
*/
|
549 |
public void transition(String s) throws CommandException { |
550 |
if (!super.changeCommand(s)){ |
551 |
|
552 |
_fsm.addOption(s); |
553 |
|
554 |
} |
555 |
} |
556 |
/*
|
557 |
* (non-Javadoc)
|
558 |
*
|
559 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet,
|
560 |
* double)
|
561 |
*/
|
562 |
public void transition(double d) { |
563 |
_fsm.addValue(d); |
564 |
} |
565 |
|
566 |
public String toString() { |
567 |
return "_complex_selection"; |
568 |
} |
569 |
public String getNextState() { |
570 |
return nextState;
|
571 |
} |
572 |
|
573 |
} |