Revision 24363 branches/v2_0_0_prep/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/ComplexSelectionCADTool.java
ComplexSelectionCADTool.java | ||
---|---|---|
87 | 87 |
*/ |
88 | 88 |
public class ComplexSelectionCADTool extends SelectionCADTool { |
89 | 89 |
private ComplexSelectionCADToolContext _fsm; |
90 |
private List pointsPolygon=new ArrayList();
|
|
90 |
private List pointsPolygon = new ArrayList();
|
|
91 | 91 |
|
92 | 92 |
/** |
93 | 93 |
* Crea un nuevo ComplexSelectionCADTool. |
94 | 94 |
*/ |
95 | 95 |
public ComplexSelectionCADTool() { |
96 |
type=PluginServices.getText(this,"inside_circle");
|
|
96 |
type = PluginServices.getText(this, "inside_circle");
|
|
97 | 97 |
} |
98 | 98 |
|
99 | 99 |
/** |
... | ... | |
104 | 104 |
_fsm = new ComplexSelectionCADToolContext(this); |
105 | 105 |
setNextTool("complex_selection"); |
106 | 106 |
|
107 |
setType(PluginServices.getText(this,"inside_circle")); |
|
107 |
setType(PluginServices.getText(this, "inside_circle"));
|
|
108 | 108 |
} |
109 | 109 |
|
110 | 110 |
/** |
... | ... | |
119 | 119 |
* par?metro y del punto que se pase en esta transici?n. |
120 | 120 |
*/ |
121 | 121 |
public void addPoint(double x, double y, InputEvent event) { |
122 |
if (event!=null && ((MouseEvent)event).getClickCount()==2){
|
|
122 |
if (event != null && ((MouseEvent) event).getClickCount() == 2) {
|
|
123 | 123 |
try { |
124 |
pointDoubleClick(((MapControl)event.getComponent()).getMapContext()); |
|
124 |
pointDoubleClick(((MapControl) event.getComponent()) |
|
125 |
.getMapContext()); |
|
125 | 126 |
} catch (ReadException e) { |
126 |
NotificationManager.addError(e.getMessage(),e); |
|
127 |
NotificationManager.addError(e.getMessage(), e);
|
|
127 | 128 |
} |
128 | 129 |
return; |
129 | 130 |
} |
... | ... | |
131 | 132 |
.getPreviousState(); |
132 | 133 |
String status = actualState.getName(); |
133 | 134 |
System.out.println("PREVIOUSSTATE =" + status); // + "ESTADO ACTUAL: " + |
134 |
// _fsm.getState());
|
|
135 |
// _fsm.getState()); |
|
135 | 136 |
VectorialLayerEdited vle = getVLE(); |
136 |
FeatureStore featureStore=null;
|
|
137 |
FeatureStore featureStore = null;
|
|
137 | 138 |
try { |
138 | 139 |
featureStore = vle.getFeatureStore(); |
139 | 140 |
} catch (ReadException e) { |
... | ... | |
143 | 144 |
ArrayList selectedHandler = vle.getSelectedHandler(); |
144 | 145 |
System.out.println("STATUS ACTUAL = " + _fsm.getTransition()); |
145 | 146 |
if (status.equals("Selection.FirstPoint")) { |
146 |
firstPoint=new Point2D.Double(x,y);
|
|
147 |
firstPoint = new Point2D.Double(x, y);
|
|
147 | 148 |
pointsPolygon.add(firstPoint); |
148 | 149 |
} else if (status.equals("Selection.SecondPoint")) { |
149 | 150 |
} else if (status.equals("Selection.WithFeatures")) { |
150 | 151 |
} else if (status.equals("Selection.WithHandlers")) { |
151 |
String description=PluginServices.getText(this,"move_handlers"); |
|
152 |
featureStore.beginEditingGroup(description); |
|
153 |
ArrayList selectedRowsAux=new ArrayList(); |
|
154 |
Iterator iterator; |
|
152 |
String description = PluginServices.getText(this, "move_handlers"); |
|
155 | 153 |
try { |
156 |
iterator = ((FeatureSelection)featureStore.getSelection()).iterator(); |
|
154 |
featureStore.beginEditingGroup(description); |
|
155 |
ArrayList selectedRowsAux = new ArrayList(); |
|
156 |
Iterator iterator; |
|
157 |
iterator = ((FeatureSelection) featureStore.getSelection()) |
|
158 |
.iterator(); |
|
157 | 159 |
|
158 | 160 |
while (iterator.hasNext()) { |
159 | 161 |
Feature feature = (Feature) iterator.next(); |
160 | 162 |
|
161 |
// } |
|
162 |
Geometry ig = ((Geometry)feature.getDefaultGeometry()).cloneGeometry(); |
|
163 |
// } |
|
164 |
Geometry ig = ((Geometry) feature.getDefaultGeometry()) |
|
165 |
.cloneGeometry(); |
|
163 | 166 |
// Movemos los handlers que hemos seleccionado |
164 | 167 |
// previamente dentro del m?todo select() |
165 |
Handler[] handlers=ig.getHandlers(Geometry.SELECTHANDLER);
|
|
168 |
Handler[] handlers = ig.getHandlers(Geometry.SELECTHANDLER);
|
|
166 | 169 |
for (int k = 0; k < selectedHandler.size(); k++) { |
167 |
Handler h = (Handler)selectedHandler.get(k); |
|
168 |
for (int j=0;j<handlers.length;j++) {
|
|
170 |
Handler h = (Handler) selectedHandler.get(k);
|
|
171 |
for (int j = 0; j < handlers.length; j++) {
|
|
169 | 172 |
if (h.getPoint().equals(handlers[j].getPoint())) |
170 |
handlers[j].set(x,y); |
|
173 |
handlers[j].set(x, y);
|
|
171 | 174 |
} |
172 | 175 |
} |
173 |
EditableFeature eFeature=feature.getEditable(); |
|
174 |
eFeature.setGeometry(featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName(), ig); |
|
176 |
EditableFeature eFeature = feature.getEditable(); |
|
177 |
eFeature.setGeometry(featureStore.getDefaultFeatureType() |
|
178 |
.getDefaultGeometryAttributeName(), ig); |
|
175 | 179 |
featureStore.update(eFeature); |
176 | 180 |
selectedRowsAux.add(eFeature); |
177 | 181 |
} |
182 |
|
|
183 |
firstPoint = new Point2D.Double(x, y); |
|
184 |
// vle.setSelectionCache(VectorialLayerEdited.SAVEPREVIOUS, |
|
185 |
// selectedRowsAux); |
|
186 |
|
|
187 |
featureStore.endEditingGroup(); |
|
178 | 188 |
} catch (DataException e1) { |
179 | 189 |
// TODO Auto-generated catch block |
180 | 190 |
e1.printStackTrace(); |
181 | 191 |
} |
182 |
firstPoint=new Point2D.Double(x,y); |
|
183 |
// vle.setSelectionCache(VectorialLayerEdited.SAVEPREVIOUS, selectedRowsAux); |
|
184 |
|
|
185 |
featureStore.endEditingGroup(); |
|
186 |
}else if (status.equals("Selection.NextPointPolygon")) { |
|
187 |
pointsPolygon.add(new Point2D.Double(x,y)); |
|
192 |
} else if (status.equals("Selection.NextPointPolygon")) { |
|
193 |
pointsPolygon.add(new Point2D.Double(x, y)); |
|
188 | 194 |
} |
189 | 195 |
} |
190 | 196 |
|
191 | 197 |
/** |
192 | 198 |
* Receives second point |
199 |
* |
|
193 | 200 |
* @param x |
194 | 201 |
* @param y |
195 | 202 |
* @return numFeatures selected |
196 | 203 |
*/ |
197 |
public long selectWithSecondPointOutRectangle(double x, double y, InputEvent event) { |
|
198 |
Point2D lastPoint=new Point2D.Double(x,y); |
|
199 |
GeneralPathX gpx=new GeneralPathX(); |
|
200 |
gpx.moveTo(firstPoint.getX(),firstPoint.getY()); |
|
201 |
gpx.lineTo(lastPoint.getX(),firstPoint.getY()); |
|
202 |
gpx.lineTo(lastPoint.getX(),lastPoint.getY()); |
|
203 |
gpx.lineTo(firstPoint.getX(),lastPoint.getY()); |
|
204 |
public long selectWithSecondPointOutRectangle(double x, double y, |
|
205 |
InputEvent event) { |
|
206 |
Point2D lastPoint = new Point2D.Double(x, y); |
|
207 |
GeneralPathX gpx = new GeneralPathX(); |
|
208 |
gpx.moveTo(firstPoint.getX(), firstPoint.getY()); |
|
209 |
gpx.lineTo(lastPoint.getX(), firstPoint.getY()); |
|
210 |
gpx.lineTo(lastPoint.getX(), lastPoint.getY()); |
|
211 |
gpx.lineTo(firstPoint.getX(), lastPoint.getY()); |
|
204 | 212 |
gpx.closePath(); |
205 |
Geometry rectangle=geomFactory.createPolygon2D(gpx);
|
|
213 |
Geometry rectangle = geomFactory.createPolygon2D(gpx);
|
|
206 | 214 |
return selectWithPolygon(rectangle); |
207 | 215 |
} |
216 |
|
|
208 | 217 |
/** |
209 | 218 |
* Receives second point |
219 |
* |
|
210 | 220 |
* @param x |
211 | 221 |
* @param y |
212 | 222 |
* @return numFeatures selected |
213 | 223 |
*/ |
214 | 224 |
public long selectWithCircle(double x, double y, InputEvent event) { |
215 |
Geometry circle=geomFactory.createCircle(firstPoint,new Point2D.Double(x,y)); |
|
225 |
Geometry circle = geomFactory.createCircle(firstPoint, |
|
226 |
new Point2D.Double(x, y)); |
|
216 | 227 |
return selectWithPolygon(circle); |
217 | 228 |
} |
229 |
|
|
218 | 230 |
public long selectWithPolygon(Geometry polygon) { |
219 | 231 |
VectorialLayerEdited vle = getVLE(); |
220 | 232 |
PluginServices.getMDIManager().setWaitCursor(); |
221 | 233 |
|
222 |
if (getType().equals(PluginServices.getText(this,"inside_circle")) || getType().equals(PluginServices.getText(this,"inside_polygon"))) { |
|
234 |
if (getType().equals(PluginServices.getText(this, "inside_circle")) |
|
235 |
|| getType().equals( |
|
236 |
PluginServices.getText(this, "inside_polygon"))) { |
|
223 | 237 |
vle.selectInsidePolygon(polygon); |
224 |
} else if (getType().equals(PluginServices.getText(this,"cross_circle")) || getType().equals(PluginServices.getText(this,"cross_polygon"))) { |
|
238 |
} else if (getType().equals( |
|
239 |
PluginServices.getText(this, "cross_circle")) |
|
240 |
|| getType().equals( |
|
241 |
PluginServices.getText(this, "cross_polygon"))) { |
|
225 | 242 |
vle.selectCrossPolygon(polygon); |
226 |
} else if (getType().equals(PluginServices.getText(this,"out_circle")) || getType().equals(PluginServices.getText(this,"out_polygon")) || getType().equals(PluginServices.getText(this,"out_rectangle"))) { |
|
243 |
} else if (getType().equals(PluginServices.getText(this, "out_circle")) |
|
244 |
|| getType() |
|
245 |
.equals(PluginServices.getText(this, "out_polygon")) |
|
246 |
|| getType().equals( |
|
247 |
PluginServices.getText(this, "out_rectangle"))) { |
|
227 | 248 |
vle.selectOutPolygon(polygon); |
228 | 249 |
} |
229 |
long countSelection=0;
|
|
250 |
long countSelection = 0;
|
|
230 | 251 |
try { |
231 |
countSelection = ((FeatureSelection)vle.getFeatureStore().getSelection()).getSize(); |
|
252 |
countSelection = ((FeatureSelection) vle.getFeatureStore() |
|
253 |
.getSelection()).getSize(); |
|
232 | 254 |
} catch (ReadException e) { |
233 | 255 |
// TODO Auto-generated catch block |
234 | 256 |
e.printStackTrace(); |
... | ... | |
237 | 259 |
e.printStackTrace(); |
238 | 260 |
} |
239 | 261 |
PluginServices.getMDIManager().restoreCursor(); |
240 |
if (countSelection>0){
|
|
262 |
if (countSelection > 0) {
|
|
241 | 263 |
nextState = "Selection.WithSelectedFeatures"; |
242 | 264 |
end(); |
243 | 265 |
} else |
... | ... | |
263 | 285 |
String status = actualState.getName(); |
264 | 286 |
VectorialLayerEdited vle = getVLE(); |
265 | 287 |
ArrayList selectedHandler = vle.getSelectedHandler(); |
266 |
ViewPort vp=vle.getLayer().getMapContext().getViewPort(); |
|
267 |
if (status.equals("Selection.SecondPoint") || status.equals("Selection.SecondPointOutRectangle")) { |
|
288 |
ViewPort vp = vle.getLayer().getMapContext().getViewPort(); |
|
289 |
if (status.equals("Selection.SecondPoint") |
|
290 |
|| status.equals("Selection.SecondPointOutRectangle")) { |
|
268 | 291 |
// Dibuja el rect?ngulo de selecci?n |
269 | 292 |
GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, |
270 | 293 |
4); |
... | ... | |
274 | 297 |
elShape.lineTo(firstPoint.getX(), y); |
275 | 298 |
elShape.lineTo(firstPoint.getX(), firstPoint.getY()); |
276 | 299 |
|
277 |
DrawOperationContext doc=new DrawOperationContext();
|
|
278 |
doc.setGraphics((Graphics2D)g); |
|
300 |
DrawOperationContext doc = new DrawOperationContext();
|
|
301 |
doc.setGraphics((Graphics2D) g);
|
|
279 | 302 |
doc.setViewPort(vp); |
280 | 303 |
doc.setSymbol(DefaultCADTool.geometrySelectSymbol); |
281 |
try { |
|
282 |
geomFactory.createPolyline2D(elShape).invokeOperation(Draw.CODE,doc); |
|
304 |
try { |
|
305 |
geomFactory.createPolyline2D(elShape).invokeOperation( |
|
306 |
Draw.CODE, doc); |
|
283 | 307 |
} catch (GeometryOperationNotSupportedException e) { |
284 | 308 |
e.printStackTrace(); |
285 | 309 |
} catch (GeometryOperationException e) { |
286 | 310 |
e.printStackTrace(); |
287 | 311 |
} |
288 | 312 |
Image img = vle.getSelectionImage(); |
289 |
g.drawImage(img, 0, 0, null); |
|
290 |
return; |
|
291 |
}if (status.equals("Selection.SecondPointCircle")) { |
|
292 |
Geometry circle=geomFactory.createCircle(firstPoint,new Point2D.Double(x,y)); |
|
293 |
GeneralPathX gpx=new GeneralPathX(); |
|
294 |
gpx.append(circle.getInternalShape(),true); |
|
295 |
Geometry circleSel=geomFactory.createPolyline2D(gpx); |
|
313 |
g.drawImage(img, 0, 0, null); |
|
314 |
return; |
|
315 |
} |
|
316 |
if (status.equals("Selection.SecondPointCircle")) { |
|
317 |
Geometry circle = geomFactory.createCircle(firstPoint, |
|
318 |
new Point2D.Double(x, y)); |
|
319 |
GeneralPathX gpx = new GeneralPathX(); |
|
320 |
gpx.append(circle.getInternalShape(), true); |
|
321 |
Geometry circleSel = geomFactory.createPolyline2D(gpx); |
|
296 | 322 |
// Dibuja el c?rculo de selecci?n |
297 |
DrawOperationContext doc=new DrawOperationContext();
|
|
298 |
doc.setGraphics((Graphics2D)g); |
|
323 |
DrawOperationContext doc = new DrawOperationContext();
|
|
324 |
doc.setGraphics((Graphics2D) g);
|
|
299 | 325 |
doc.setViewPort(vp); |
300 | 326 |
doc.setSymbol(DefaultCADTool.geometrySelectSymbol); |
301 |
try {
|
|
302 |
circleSel.invokeOperation(Draw.CODE,doc);
|
|
327 |
try {
|
|
328 |
circleSel.invokeOperation(Draw.CODE, doc);
|
|
303 | 329 |
} catch (GeometryOperationNotSupportedException e) { |
304 | 330 |
e.printStackTrace(); |
305 | 331 |
} catch (GeometryOperationException e) { |
306 | 332 |
e.printStackTrace(); |
307 | 333 |
} |
308 | 334 |
Image img = vle.getSelectionImage(); |
309 |
g.drawImage(img, 0, 0, null);
|
|
310 |
return;
|
|
311 |
}else if (status.equals("Selection.NextPointPolygon")) { |
|
335 |
g.drawImage(img, 0, 0, null);
|
|
336 |
return;
|
|
337 |
} else if (status.equals("Selection.NextPointPolygon")) {
|
|
312 | 338 |
// Dibuja el pol?gono de selecci?n |
313 |
Geometry polygon=getGeometryPolygon(new Point2D.Double(x,y));
|
|
314 |
DrawOperationContext doc=new DrawOperationContext();
|
|
315 |
doc.setGraphics((Graphics2D)g); |
|
339 |
Geometry polygon = getGeometryPolygon(new Point2D.Double(x, y));
|
|
340 |
DrawOperationContext doc = new DrawOperationContext();
|
|
341 |
doc.setGraphics((Graphics2D) g);
|
|
316 | 342 |
doc.setViewPort(vp); |
317 | 343 |
doc.setSymbol(DefaultCADTool.geometrySelectSymbol); |
318 |
try {
|
|
319 |
polygon.invokeOperation(Draw.CODE,doc);
|
|
344 |
try {
|
|
345 |
polygon.invokeOperation(Draw.CODE, doc);
|
|
320 | 346 |
} catch (GeometryOperationNotSupportedException e) { |
321 | 347 |
e.printStackTrace(); |
322 | 348 |
} catch (GeometryOperationException e) { |
323 | 349 |
e.printStackTrace(); |
324 | 350 |
} |
325 | 351 |
Image img = vle.getSelectionImage(); |
326 |
g.drawImage(img, 0, 0, null);
|
|
327 |
return;
|
|
328 |
}else if (status.equals("Selection.WithHandlers")) { |
|
352 |
g.drawImage(img, 0, 0, null);
|
|
353 |
return;
|
|
354 |
} else if (status.equals("Selection.WithHandlers")) {
|
|
329 | 355 |
// Movemos los handlers que hemos seleccionado |
330 | 356 |
// previamente dentro del m?todo select() |
331 |
double xPrev=0;
|
|
332 |
double yPrev=0;
|
|
357 |
double xPrev = 0;
|
|
358 |
double yPrev = 0;
|
|
333 | 359 |
for (int k = 0; k < selectedHandler.size(); k++) { |
334 |
Handler h = (Handler)selectedHandler.get(k); |
|
335 |
xPrev=h.getPoint().getX();
|
|
336 |
yPrev=h.getPoint().getY();
|
|
360 |
Handler h = (Handler) selectedHandler.get(k);
|
|
361 |
xPrev = h.getPoint().getX();
|
|
362 |
yPrev = h.getPoint().getY();
|
|
337 | 363 |
h.set(x, y); |
338 | 364 |
} |
339 | 365 |
// Y una vez movidos los v?rtices (handles) |
340 | 366 |
// redibujamos la nueva geometr?a. |
341 | 367 |
for (int i = 0; i < rowselectedHandlers.size(); i++) { |
342 | 368 |
Feature rowEd = (Feature) rowselectedHandlers.get(i); |
343 |
Geometry geom = ((Geometry)rowEd.getDefaultGeometry()).cloneGeometry(); |
|
369 |
Geometry geom = ((Geometry) rowEd.getDefaultGeometry()) |
|
370 |
.cloneGeometry(); |
|
344 | 371 |
g.setColor(Color.gray); |
345 |
DrawOperationContext doc=new DrawOperationContext();
|
|
346 |
doc.setGraphics((Graphics2D)g); |
|
372 |
DrawOperationContext doc = new DrawOperationContext();
|
|
373 |
doc.setGraphics((Graphics2D) g);
|
|
347 | 374 |
doc.setViewPort(vp); |
348 | 375 |
doc.setSymbol(DefaultCADTool.axisReferencesSymbol); |
349 |
try {
|
|
350 |
geom.invokeOperation(Draw.CODE,doc);
|
|
376 |
try {
|
|
377 |
geom.invokeOperation(Draw.CODE, doc);
|
|
351 | 378 |
} catch (GeometryOperationNotSupportedException e) { |
352 | 379 |
e.printStackTrace(); |
353 | 380 |
} catch (GeometryOperationException e) { |
... | ... | |
355 | 382 |
} |
356 | 383 |
} |
357 | 384 |
for (int k = 0; k < selectedHandler.size(); k++) { |
358 |
Handler h = (Handler)selectedHandler.get(k); |
|
385 |
Handler h = (Handler) selectedHandler.get(k);
|
|
359 | 386 |
h.set(xPrev, yPrev); |
360 | 387 |
} |
361 | 388 |
return; |
362 |
}else{
|
|
389 |
} else {
|
|
363 | 390 |
if (!vle.getLayer().isVisible()) |
364 | 391 |
return; |
365 |
try{ |
|
366 |
Image imgSel = vle.getSelectionImage(); |
|
367 |
if (imgSel!=null)
|
|
368 |
g.drawImage(imgSel, 0, 0, null); |
|
369 |
Image imgHand = vle.getHandlersImage();
|
|
370 |
if (imgHand!=null)
|
|
371 |
g.drawImage(imgHand, 0, 0, null); |
|
372 |
}catch (Exception e) { |
|
392 |
try {
|
|
393 |
Image imgSel = vle.getSelectionImage();
|
|
394 |
if (imgSel != null)
|
|
395 |
g.drawImage(imgSel, 0, 0, null);
|
|
396 |
Image imgHand = vle.getHandlersImage();
|
|
397 |
if (imgHand != null)
|
|
398 |
g.drawImage(imgHand, 0, 0, null);
|
|
399 |
} catch (Exception e) {
|
|
373 | 400 |
} |
374 | 401 |
} |
375 | 402 |
} |
... | ... | |
389 | 416 |
System.out.println("PREVIOUSSTATE =" + status); // + "ESTADO ACTUAL: " + |
390 | 417 |
// _fsm.getState()); |
391 | 418 |
System.out.println("STATUS ACTUAL = " + _fsm.getTransition()); |
392 |
if (s.equals(PluginServices.getText(this,"cancel"))){
|
|
419 |
if (s.equals(PluginServices.getText(this, "cancel"))) {
|
|
393 | 420 |
init(); |
394 | 421 |
return; |
395 |
}else if (s.equals(PluginServices.getText(this,"select_all"))){
|
|
422 |
} else if (s.equals(PluginServices.getText(this, "select_all"))) {
|
|
396 | 423 |
selectAll(); |
397 | 424 |
init(); |
398 | 425 |
return; |
... | ... | |
400 | 427 |
if (status.equals("Selection.FirstPoint")) { |
401 | 428 |
setType(s); |
402 | 429 |
return; |
403 |
}else if (status.equals("Selection.NextPointPolygon")){ |
|
404 |
if (s.equals(PluginServices.getText(this,"end_polygon")) || s.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.end"))) { |
|
405 |
Geometry polygon=getGeometryPolygon(null); |
|
406 |
GeneralPathX gpx=new GeneralPathX(); |
|
407 |
gpx.append(polygon,true); |
|
408 |
if (gpx.isCCW()) { |
|
409 |
gpx.flip(); |
|
410 |
polygon=geomFactory.createPolygon2D(gpx); |
|
430 |
} else if (status.equals("Selection.NextPointPolygon")) { |
|
431 |
if (s.equals(PluginServices.getText(this, "end_polygon")) |
|
432 |
|| s.equalsIgnoreCase(PluginServices.getText(this, |
|
433 |
"ComplexSelectionCADTool.end"))) { |
|
434 |
Geometry polygon = getGeometryPolygon(null); |
|
435 |
GeneralPathX gpx = new GeneralPathX(); |
|
436 |
gpx.append(polygon, true); |
|
437 |
if (gpx.isCCW()) { |
|
438 |
gpx.flip(); |
|
439 |
polygon = geomFactory.createPolygon2D(gpx); |
|
440 |
} |
|
441 |
selectWithPolygon(polygon); |
|
442 |
pointsPolygon.clear(); |
|
443 |
setType(PluginServices.getText(this, "inside_circle")); |
|
444 |
return; |
|
411 | 445 |
} |
412 |
selectWithPolygon(polygon); |
|
413 |
pointsPolygon.clear(); |
|
414 |
setType(PluginServices.getText(this,"inside_circle")); |
|
415 |
return; |
|
416 |
} |
|
417 | 446 |
} |
418 | 447 |
init(); |
419 | 448 |
} |
449 |
|
|
420 | 450 |
private long selectAll() { |
421 | 451 |
VectorialLayerEdited vle = getVLE(); |
422 | 452 |
PluginServices.getMDIManager().setWaitCursor(); |
423 | 453 |
vle.selectAll(); |
424 |
long countSelection=0;
|
|
454 |
long countSelection = 0;
|
|
425 | 455 |
try { |
426 |
countSelection = ((FeatureSelection)vle.getFeatureStore().getSelection()).getSize(); |
|
456 |
countSelection = ((FeatureSelection) vle.getFeatureStore() |
|
457 |
.getSelection()).getSize(); |
|
427 | 458 |
} catch (ReadException e) { |
428 | 459 |
// TODO Auto-generated catch block |
429 | 460 |
e.printStackTrace(); |
... | ... | |
450 | 481 |
gpx.lineTo(points[i].getX(), points[i].getY()); |
451 | 482 |
} |
452 | 483 |
} |
453 |
if (p!=null){
|
|
454 |
gpx.lineTo(p.getX(),p.getY()); |
|
484 |
if (p != null) {
|
|
485 |
gpx.lineTo(p.getX(), p.getY());
|
|
455 | 486 |
gpx.closePath(); |
456 | 487 |
Geometry polyline = geomFactory.createPolyline2D(gpx); |
457 | 488 |
return polyline; |
... | ... | |
471 | 502 |
|
472 | 503 |
public void end() { |
473 | 504 |
if (!getNextTool().equals("complex_selection")) |
474 |
CADExtension.setCADTool(getNextTool(),false); |
|
505 |
CADExtension.setCADTool(getNextTool(), false);
|
|
475 | 506 |
} |
476 | 507 |
|
477 | 508 |
public String getName() { |
478 |
return PluginServices.getText(this,"complex_selection_"); |
|
509 |
return PluginServices.getText(this, "complex_selection_");
|
|
479 | 510 |
} |
480 | 511 |
|
481 | 512 |
public boolean selectFeatures(double x, double y, InputEvent event) { |
482 |
ComplexSelectionCADToolState actualState =_fsm |
|
483 |
.getState(); |
|
513 |
ComplexSelectionCADToolState actualState = _fsm.getState(); |
|
484 | 514 |
|
485 | 515 |
String status = actualState.getName(); |
486 | 516 |
VectorialLayerEdited vle = getVLE(); |
487 | 517 |
|
488 |
|
|
489 | 518 |
if ((status.equals("Selection.FirstPoint")) |
490 | 519 |
|| (status.equals("Selection.WithSelectedFeatures"))) { |
491 | 520 |
PluginServices.getMDIManager().setWaitCursor(); |
492 | 521 |
firstPoint = new Point2D.Double(x, y); |
493 |
vle.selectWithPoint(x,y,multipleSelection);
|
|
522 |
vle.selectWithPoint(x, y, multipleSelection);
|
|
494 | 523 |
PluginServices.getMDIManager().restoreCursor(); |
495 | 524 |
} |
496 |
long countSelection=0;
|
|
525 |
long countSelection = 0;
|
|
497 | 526 |
try { |
498 |
countSelection = ((FeatureSelection)vle.getFeatureStore().getSelection()).getSize(); |
|
527 |
countSelection = ((FeatureSelection) vle.getFeatureStore() |
|
528 |
.getSelection()).getSize(); |
|
499 | 529 |
} catch (ReadException e) { |
500 | 530 |
// TODO Auto-generated catch block |
501 | 531 |
e.printStackTrace(); |
... | ... | |
529 | 559 |
|
530 | 560 |
Handler[] handlers = null; |
531 | 561 |
rowselectedHandlers.clear(); |
532 |
FeatureStore featureStore=null;
|
|
562 |
FeatureStore featureStore = null;
|
|
533 | 563 |
try { |
534 | 564 |
featureStore = vle.getFeatureStore(); |
535 | 565 |
} catch (ReadException e) { |
536 | 566 |
// TODO Auto-generated catch block |
537 | 567 |
e.printStackTrace(); |
538 | 568 |
} |
539 |
Iterator iterator=null;
|
|
569 |
Iterator iterator = null;
|
|
540 | 570 |
try { |
541 |
iterator = ((FeatureSelection)featureStore.getSelection()).iterator(); |
|
571 |
iterator = ((FeatureSelection) featureStore.getSelection()) |
|
572 |
.iterator(); |
|
542 | 573 |
} catch (DataException e1) { |
543 | 574 |
// TODO Auto-generated catch block |
544 | 575 |
e1.printStackTrace(); |
... | ... | |
546 | 577 |
while (iterator.hasNext()) { |
547 | 578 |
Feature feature = (Feature) iterator.next(); |
548 | 579 |
|
549 |
Geometry geom=((Geometry)feature.getDefaultGeometry()).cloneGeometry(); |
|
580 |
Geometry geom = ((Geometry) feature.getDefaultGeometry()) |
|
581 |
.cloneGeometry(); |
|
550 | 582 |
handlers = geom.getHandlers(Geometry.SELECTHANDLER); |
551 | 583 |
// y miramos los handlers de cada entidad seleccionada |
552 | 584 |
double min = tam; |
... | ... | |
560 | 592 |
EditableFeature eFeature; |
561 | 593 |
try { |
562 | 594 |
eFeature = featureStore.createNewFeature(false); |
563 |
FeatureType featureType=featureStore.getDefaultFeatureType(); |
|
595 |
FeatureType featureType = featureStore |
|
596 |
.getDefaultFeatureType(); |
|
564 | 597 |
for (int i = 0; i < featureType.size(); i++) { |
565 |
eFeature.set(i,feature.get(i)); |
|
598 |
eFeature.set(i, feature.get(i));
|
|
566 | 599 |
} |
567 |
eFeature.setGeometry(featureType.getDefaultGeometryAttributeName(), geom); |
|
600 |
eFeature.setGeometry(featureType |
|
601 |
.getDefaultGeometryAttributeName(), geom); |
|
568 | 602 |
} catch (InitializeException e) { |
569 | 603 |
// TODO Auto-generated catch block |
570 | 604 |
e.printStackTrace(); |
... | ... | |
592 | 626 |
} |
593 | 627 |
|
594 | 628 |
public void setType(String type) { |
595 |
if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.outrectangle"))){ |
|
596 |
this.type=PluginServices.getText(this,"out_rectangle"); |
|
597 |
}else if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.intropolygon"))){ |
|
598 |
this.type=PluginServices.getText(this,"inside_polygon"); |
|
599 |
}else if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.crosspolygon"))){ |
|
600 |
this.type=PluginServices.getText(this,"cross_polygon"); |
|
601 |
}else if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.outpolygon"))){ |
|
602 |
this.type=PluginServices.getText(this,"out_polygon"); |
|
603 |
}else if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.introcircle"))){ |
|
604 |
this.type=PluginServices.getText(this,"inside_circle"); |
|
605 |
}else if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.crosscircle"))){ |
|
606 |
this.type=PluginServices.getText(this,"cross_circle"); |
|
607 |
}else if (type.equalsIgnoreCase(PluginServices.getText(this,"ComplexSelectionCADTool.outcircle"))){ |
|
608 |
this.type=PluginServices.getText(this,"out_circle"); |
|
609 |
}else if (type.equals(PluginServices.getText(this,"select_all"))){ |
|
629 |
if (type.equalsIgnoreCase(PluginServices.getText(this, |
|
630 |
"ComplexSelectionCADTool.outrectangle"))) { |
|
631 |
this.type = PluginServices.getText(this, "out_rectangle"); |
|
632 |
} else if (type.equalsIgnoreCase(PluginServices.getText(this, |
|
633 |
"ComplexSelectionCADTool.intropolygon"))) { |
|
634 |
this.type = PluginServices.getText(this, "inside_polygon"); |
|
635 |
} else if (type.equalsIgnoreCase(PluginServices.getText(this, |
|
636 |
"ComplexSelectionCADTool.crosspolygon"))) { |
|
637 |
this.type = PluginServices.getText(this, "cross_polygon"); |
|
638 |
} else if (type.equalsIgnoreCase(PluginServices.getText(this, |
|
639 |
"ComplexSelectionCADTool.outpolygon"))) { |
|
640 |
this.type = PluginServices.getText(this, "out_polygon"); |
|
641 |
} else if (type.equalsIgnoreCase(PluginServices.getText(this, |
|
642 |
"ComplexSelectionCADTool.introcircle"))) { |
|
643 |
this.type = PluginServices.getText(this, "inside_circle"); |
|
644 |
} else if (type.equalsIgnoreCase(PluginServices.getText(this, |
|
645 |
"ComplexSelectionCADTool.crosscircle"))) { |
|
646 |
this.type = PluginServices.getText(this, "cross_circle"); |
|
647 |
} else if (type.equalsIgnoreCase(PluginServices.getText(this, |
|
648 |
"ComplexSelectionCADTool.outcircle"))) { |
|
649 |
this.type = PluginServices.getText(this, "out_circle"); |
|
650 |
} else if (type.equals(PluginServices.getText(this, "select_all"))) { |
|
610 | 651 |
selectAll(); |
611 | 652 |
init(); |
612 |
}else{
|
|
653 |
} else {
|
|
613 | 654 |
this.type = type; |
614 | 655 |
} |
615 | 656 |
pointsPolygon.clear(); |
616 | 657 |
} |
658 |
|
|
617 | 659 |
/* |
618 | 660 |
* (non-Javadoc) |
619 | 661 |
* |
... | ... | |
623 | 665 |
public void transition(double x, double y, InputEvent event) { |
624 | 666 |
System.out.println("TRANSICION DESDE ESTADO " + _fsm.getState() |
625 | 667 |
+ " x= " + x + " y=" + y); |
626 |
try{ |
|
627 |
_fsm.addPoint(x, y, event); |
|
628 |
}catch (Exception e) { |
|
668 |
try {
|
|
669 |
_fsm.addPoint(x, y, event);
|
|
670 |
} catch (Exception e) {
|
|
629 | 671 |
init(); |
630 | 672 |
} |
631 | 673 |
System.out.println("ESTADO ACTUAL: " + getStatus()); |
632 | 674 |
|
633 |
FLyrVect lv=(FLyrVect)((VectorialLayerEdited)CADExtension.getEditionManager().getActiveLayerEdited()).getLayer(); |
|
634 |
com.iver.andami.ui.mdiManager.IWindow[] views = PluginServices.getMDIManager().getAllWindows(); |
|
675 |
FLyrVect lv = (FLyrVect) ((VectorialLayerEdited) CADExtension |
|
676 |
.getEditionManager().getActiveLayerEdited()).getLayer(); |
|
677 |
com.iver.andami.ui.mdiManager.IWindow[] views = PluginServices |
|
678 |
.getMDIManager().getAllWindows(); |
|
635 | 679 |
|
636 |
for (int i=0 ; i<views.length ; i++){ |
|
637 |
if (views[i] instanceof Table){ |
|
638 |
Table table=(Table)views[i]; |
|
639 |
if (table.getModel().getAssociatedTable()!=null && table.getModel().getAssociatedTable().equals(lv)) |
|
680 |
for (int i = 0; i < views.length; i++) { |
|
681 |
if (views[i] instanceof Table) { |
|
682 |
Table table = (Table) views[i]; |
|
683 |
if (table.getModel().getAssociatedTable() != null |
|
684 |
&& table.getModel().getAssociatedTable().equals(lv)) |
|
640 | 685 |
table.updateSelection(); |
641 | 686 |
} |
642 | 687 |
} |
643 | 688 |
} |
689 |
|
|
644 | 690 |
public String getStatus() { |
645 | 691 |
try { |
646 | 692 |
ComplexSelectionCADToolState actualState = (ComplexSelectionCADToolState) _fsm |
... | ... | |
652 | 698 |
return "Selection.FirstPoint"; |
653 | 699 |
} |
654 | 700 |
} |
701 |
|
|
655 | 702 |
/* |
656 | 703 |
* (non-Javadoc) |
657 | 704 |
* |
... | ... | |
659 | 706 |
* java.lang.String) |
660 | 707 |
*/ |
661 | 708 |
public void transition(String s) throws CommandException { |
662 |
if (!super.changeCommand(s)){ |
|
709 |
if (!super.changeCommand(s)) {
|
|
663 | 710 |
|
664 | 711 |
_fsm.addOption(s); |
665 | 712 |
|
666 |
}
|
|
713 |
}
|
|
667 | 714 |
} |
715 |
|
|
668 | 716 |
/* |
669 | 717 |
* (non-Javadoc) |
670 | 718 |
* |
... | ... | |
678 | 726 |
public String toString() { |
679 | 727 |
return "_complex_selection"; |
680 | 728 |
} |
729 |
|
|
681 | 730 |
public String getNextState() { |
682 | 731 |
return nextState; |
683 | 732 |
} |
Also available in: Unified diff