Revision 27525 branches/v2_0_0_prep/extensions/extEditing/src/com/iver/cit/gvsig/gui/cad/tools/StretchCADTool.java
StretchCADTool.java | ||
---|---|---|
46 | 46 |
import java.awt.event.InputEvent; |
47 | 47 |
import java.awt.geom.Point2D; |
48 | 48 |
import java.awt.geom.Rectangle2D; |
49 |
import java.util.Iterator; |
|
50 | 49 |
|
51 | 50 |
import org.gvsig.fmap.dal.exception.DataException; |
52 | 51 |
import org.gvsig.fmap.dal.exception.ReadException; |
52 |
import org.gvsig.fmap.dal.feature.DisposableIterator; |
|
53 | 53 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
54 | 54 |
import org.gvsig.fmap.dal.feature.Feature; |
55 | 55 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
... | ... | |
206 | 206 |
} else if (status.equals("Stretch.MoveLastPoint")) { |
207 | 207 |
VectorialLayerEdited vle = getVLE(); |
208 | 208 |
FeatureStore featureStore = null; |
209 |
DisposableIterator iterator = null; |
|
209 | 210 |
try { |
210 | 211 |
featureStore = vle.getFeatureStore(); |
211 | 212 |
|
... | ... | |
220 | 221 |
|
221 | 222 |
// for (int i = selectedGeometries.nextSetBit(0); i >= 0; |
222 | 223 |
// i = selectedGeometries.nextSetBit(i + 1)) { |
223 |
Iterator iterator = ((FeatureSelection) featureStore
|
|
224 |
iterator = ((FeatureSelection) featureStore |
|
224 | 225 |
.getSelection()).iterator(); |
225 | 226 |
while (iterator.hasNext()) { |
226 | 227 |
Feature feature = (Feature) iterator.next(); |
... | ... | |
231 | 232 |
// DefaultFeature fea = (DefaultFeature) |
232 | 233 |
// edRow.getLinkedRow().cloneRow(); |
233 | 234 |
Geometry geometry = null; |
234 |
geometry = ((Geometry) feature.getDefaultGeometry())
|
|
235 |
geometry = (feature.getDefaultGeometry()) |
|
235 | 236 |
.cloneGeometry(); |
236 | 237 |
|
237 | 238 |
handlers = geometry.getHandlers(Geometry.STRETCHINGHANDLER); |
... | ... | |
256 | 257 |
// selectedRowAux); |
257 | 258 |
|
258 | 259 |
// PluginServices.getMDIManager().restoreCursor(); |
259 |
} catch (ReadException e) { |
|
260 |
NotificationManager.addError(e.getMessage(), e); |
|
261 | 260 |
} catch (DataException e) { |
262 | 261 |
NotificationManager.addError(e.getMessage(), e); |
262 |
} finally { |
|
263 |
if (iterator != null) { |
|
264 |
iterator.dispose(); |
|
265 |
} |
|
263 | 266 |
} |
264 | 267 |
} |
265 | 268 |
} |
... | ... | |
276 | 279 |
* par?metro x del punto que se pase para dibujar. |
277 | 280 |
*/ |
278 | 281 |
public void drawOperation(Graphics g, double x, double y) { |
279 |
StretchCADToolState actualState = ((StretchCADToolContext) _fsm)
|
|
280 |
.getState();
|
|
282 |
StretchCADToolState actualState = (_fsm) |
|
283 |
.getState(); |
|
281 | 284 |
String status = actualState.getName(); |
282 | 285 |
|
283 | 286 |
// ArrayList selectedRow = getSelectedRows(); |
284 |
Iterator iterator = null; |
|
287 |
DisposableIterator iterator = null;
|
|
285 | 288 |
try { |
286 | 289 |
iterator = ((FeatureSelection) getVLE().getFeatureStore() |
287 | 290 |
.getSelection()).iterator(); |
288 |
} catch (ReadException e1) { |
|
289 |
// TODO Auto-generated catch block |
|
290 |
e1.printStackTrace(); |
|
291 |
} catch (DataException e) { |
|
292 |
// TODO Auto-generated catch block |
|
293 |
e.printStackTrace(); |
|
294 |
} |
|
295 |
if (status.equals("Stretch.SelLastPoint")) { |
|
296 |
GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, |
|
297 |
4); |
|
298 |
elShape.moveTo(selfirstPoint.getX(), selfirstPoint.getY()); |
|
299 |
elShape.lineTo(x, selfirstPoint.getY()); |
|
300 |
elShape.lineTo(x, y); |
|
301 |
elShape.lineTo(selfirstPoint.getX(), y); |
|
302 |
elShape.lineTo(selfirstPoint.getX(), selfirstPoint.getY()); |
|
291 |
if (status.equals("Stretch.SelLastPoint")) { |
|
292 |
GeneralPathX elShape = new GeneralPathX( |
|
293 |
GeneralPathX.WIND_EVEN_ODD, 4); |
|
294 |
elShape.moveTo(selfirstPoint.getX(), selfirstPoint.getY()); |
|
295 |
elShape.lineTo(x, selfirstPoint.getY()); |
|
296 |
elShape.lineTo(x, y); |
|
297 |
elShape.lineTo(selfirstPoint.getX(), y); |
|
298 |
elShape.lineTo(selfirstPoint.getX(), selfirstPoint.getY()); |
|
303 | 299 |
|
304 |
DrawOperationContext doc = new DrawOperationContext(); |
|
305 |
doc.setGraphics((Graphics2D) g); |
|
306 |
doc.setViewPort(getCadToolAdapter().getMapControl().getViewPort()); |
|
307 |
doc.setSymbol(DefaultCADTool.axisReferencesSymbol); |
|
308 |
try { |
|
309 |
createCurve(elShape).invokeOperation( |
|
310 |
Draw.CODE, doc); |
|
311 |
} catch (GeometryOperationNotSupportedException e) { |
|
312 |
e.printStackTrace(); |
|
313 |
} catch (GeometryOperationException e) { |
|
314 |
e.printStackTrace(); |
|
315 |
} |
|
316 |
// geomFactory.createPolyline2D(elShape).draw((Graphics2D) g, |
|
317 |
// getCadToolAdapter().getMapControl().getViewPort(), |
|
318 |
// DefaultCADTool.axisReferencesSymbol); |
|
319 |
} else if (status.equals("Stretch.MoveFirstPoint")) { |
|
320 |
|
|
321 |
Handler[] handlers = null; |
|
322 |
while (iterator.hasNext()) { |
|
323 |
Feature feature = (Feature) iterator.next(); |
|
324 |
|
|
325 |
// } |
|
326 |
// for (int i = 0;i<selectedRow.size();i++) { |
|
327 |
// IRowEdited edRow = (IRowEdited) selectedRow.get(i); |
|
328 |
// DefaultFeature fea = (DefaultFeature) |
|
329 |
// edRow.getLinkedRow().cloneRow(); |
|
330 |
Geometry geometry = null; |
|
331 |
geometry = ((Geometry) feature.getDefaultGeometry()) |
|
332 |
.cloneGeometry(); |
|
333 |
|
|
334 |
handlers = geometry.getHandlers(Geometry.STRETCHINGHANDLER); |
|
335 |
|
|
336 |
for (int j = 0; j < handlers.length; j++) { |
|
337 |
if (rect.contains(handlers[j].getPoint())) { |
|
338 |
FGraphicUtilities.DrawHandlers((Graphics2D) g, |
|
339 |
getCadToolAdapter().getMapControl() |
|
340 |
.getViewPort().getAffineTransform(), |
|
341 |
new Handler[] { handlers[j] }, |
|
342 |
DefaultCADTool.handlerSymbol); |
|
343 |
} |
|
344 |
} |
|
345 |
} |
|
346 |
} else if (status.equals("Stretch.MoveLastPoint")) { |
|
347 |
Handler[] handlers = null; |
|
348 |
while (iterator.hasNext()) { |
|
349 |
Feature feature = (Feature) iterator.next(); |
|
350 |
// for (int i = 0;i<selectedRow.size();i++) { |
|
351 |
// IRowEdited edRow = (IRowEdited) selectedRow.get(i); |
|
352 |
// DefaultFeature fea = (DefaultFeature) |
|
353 |
// edRow.getLinkedRow().cloneRow(); |
|
354 |
Geometry geometry = null; |
|
355 |
geometry = ((Geometry) feature.getDefaultGeometry()) |
|
356 |
.cloneGeometry(); |
|
357 |
|
|
358 |
handlers = geometry.getHandlers(Geometry.STRETCHINGHANDLER); |
|
359 |
|
|
360 |
for (int j = 0; j < handlers.length; j++) { |
|
361 |
if (rect.contains(handlers[j].getPoint())) { |
|
362 |
handlers[j].move(x - movefirstPoint.getX(), y |
|
363 |
- movefirstPoint.getY()); |
|
364 |
} |
|
365 |
} |
|
366 | 300 |
DrawOperationContext doc = new DrawOperationContext(); |
367 | 301 |
doc.setGraphics((Graphics2D) g); |
368 | 302 |
doc.setViewPort(getCadToolAdapter().getMapControl() |
369 | 303 |
.getViewPort()); |
370 | 304 |
doc.setSymbol(DefaultCADTool.axisReferencesSymbol); |
371 | 305 |
try { |
372 |
geometry.cloneGeometry().invokeOperation(Draw.CODE, doc);
|
|
306 |
createCurve(elShape).invokeOperation(Draw.CODE, doc);
|
|
373 | 307 |
} catch (GeometryOperationNotSupportedException e) { |
374 | 308 |
e.printStackTrace(); |
375 | 309 |
} catch (GeometryOperationException e) { |
376 | 310 |
e.printStackTrace(); |
377 | 311 |
} |
378 |
// geometry.draw((Graphics2D) g,
|
|
312 |
// geomFactory.createPolyline2D(elShape).draw((Graphics2D) g,
|
|
379 | 313 |
// getCadToolAdapter().getMapControl().getViewPort(), |
380 | 314 |
// DefaultCADTool.axisReferencesSymbol); |
315 |
} else if (status.equals("Stretch.MoveFirstPoint")) { |
|
316 |
|
|
317 |
Handler[] handlers = null; |
|
318 |
while (iterator.hasNext()) { |
|
319 |
Feature feature = (Feature) iterator.next(); |
|
320 |
|
|
321 |
// } |
|
322 |
// for (int i = 0;i<selectedRow.size();i++) { |
|
323 |
// IRowEdited edRow = (IRowEdited) selectedRow.get(i); |
|
324 |
// DefaultFeature fea = (DefaultFeature) |
|
325 |
// edRow.getLinkedRow().cloneRow(); |
|
326 |
Geometry geometry = null; |
|
327 |
geometry = (feature.getDefaultGeometry()).cloneGeometry(); |
|
328 |
|
|
329 |
handlers = geometry.getHandlers(Geometry.STRETCHINGHANDLER); |
|
330 |
|
|
331 |
for (int j = 0; j < handlers.length; j++) { |
|
332 |
if (rect.contains(handlers[j].getPoint())) { |
|
333 |
FGraphicUtilities |
|
334 |
.DrawHandlers((Graphics2D) g, |
|
335 |
getCadToolAdapter().getMapControl() |
|
336 |
.getViewPort() |
|
337 |
.getAffineTransform(), |
|
338 |
new Handler[] { handlers[j] }, |
|
339 |
DefaultCADTool.handlerSymbol); |
|
340 |
} |
|
341 |
} |
|
342 |
} |
|
343 |
} else if (status.equals("Stretch.MoveLastPoint")) { |
|
344 |
Handler[] handlers = null; |
|
345 |
while (iterator.hasNext()) { |
|
346 |
Feature feature = (Feature) iterator.next(); |
|
347 |
// for (int i = 0;i<selectedRow.size();i++) { |
|
348 |
// IRowEdited edRow = (IRowEdited) selectedRow.get(i); |
|
349 |
// DefaultFeature fea = (DefaultFeature) |
|
350 |
// edRow.getLinkedRow().cloneRow(); |
|
351 |
Geometry geometry = null; |
|
352 |
geometry = (feature.getDefaultGeometry()).cloneGeometry(); |
|
353 |
|
|
354 |
handlers = geometry.getHandlers(Geometry.STRETCHINGHANDLER); |
|
355 |
|
|
356 |
for (int j = 0; j < handlers.length; j++) { |
|
357 |
if (rect.contains(handlers[j].getPoint())) { |
|
358 |
handlers[j].move(x - movefirstPoint.getX(), y |
|
359 |
- movefirstPoint.getY()); |
|
360 |
} |
|
361 |
} |
|
362 |
DrawOperationContext doc = new DrawOperationContext(); |
|
363 |
doc.setGraphics((Graphics2D) g); |
|
364 |
doc.setViewPort(getCadToolAdapter().getMapControl() |
|
365 |
.getViewPort()); |
|
366 |
doc.setSymbol(DefaultCADTool.axisReferencesSymbol); |
|
367 |
try { |
|
368 |
geometry.cloneGeometry() |
|
369 |
.invokeOperation(Draw.CODE, doc); |
|
370 |
} catch (GeometryOperationNotSupportedException e) { |
|
371 |
e.printStackTrace(); |
|
372 |
} catch (GeometryOperationException e) { |
|
373 |
e.printStackTrace(); |
|
374 |
} |
|
375 |
// geometry.draw((Graphics2D) g, |
|
376 |
// getCadToolAdapter().getMapControl().getViewPort(), |
|
377 |
// DefaultCADTool.axisReferencesSymbol); |
|
378 |
} |
|
379 |
} else { |
|
380 |
VectorialLayerEdited vle = getVLE(); |
|
381 |
if (!vle.getLayer().isVisible()) { |
|
382 |
return; |
|
383 |
} |
|
384 |
try { |
|
385 |
Image imgSel = vle.getSelectionImage(); |
|
386 |
if (imgSel != null) { |
|
387 |
g.drawImage(imgSel, 0, 0, null); |
|
388 |
} |
|
389 |
Image imgHand = vle.getHandlersImage(); |
|
390 |
if (imgHand != null) { |
|
391 |
g.drawImage(imgHand, 0, 0, null); |
|
392 |
} |
|
393 |
} catch (Exception e) { |
|
394 |
} |
|
381 | 395 |
} |
382 |
}else{ |
|
383 |
VectorialLayerEdited vle=getVLE(); |
|
384 |
if (!vle.getLayer().isVisible()) |
|
385 |
return; |
|
386 |
try{ |
|
387 |
Image imgSel = vle.getSelectionImage(); |
|
388 |
if (imgSel!=null) |
|
389 |
g.drawImage(imgSel, 0, 0, null); |
|
390 |
Image imgHand = vle.getHandlersImage(); |
|
391 |
if (imgHand!=null) |
|
392 |
g.drawImage(imgHand, 0, 0, null); |
|
393 |
}catch (Exception e) { |
|
394 |
} |
|
395 |
} |
|
396 |
|
|
397 |
} catch (DataException e) { |
|
398 |
// TODO Auto-generated catch block |
|
399 |
e.printStackTrace(); |
|
400 |
} finally { |
|
401 |
if (iterator != null) { |
|
402 |
iterator.dispose(); |
|
403 |
} |
|
404 |
} |
|
405 |
|
|
396 | 406 |
} |
397 | 407 |
|
398 | 408 |
/** |
Also available in: Unified diff