Revision 30335 branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/gui/cad/tools/PolylineCADTool.java
PolylineCADTool.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
package org.gvsig.editing.gui.cad.tools; |
42 | 42 |
|
43 |
import java.awt.Graphics; |
|
44 |
import java.awt.Graphics2D; |
|
45 | 43 |
import java.awt.Image; |
46 | 44 |
import java.awt.event.InputEvent; |
47 | 45 |
import java.awt.event.MouseEvent; |
... | ... | |
60 | 58 |
import org.gvsig.fmap.geom.aggregate.MultiPrimitive; |
61 | 59 |
import org.gvsig.fmap.geom.handler.Handler; |
62 | 60 |
import org.gvsig.fmap.geom.operation.Draw; |
63 |
import org.gvsig.fmap.geom.operation.DrawOperationContext; |
|
64 | 61 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
65 | 62 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
63 |
import org.gvsig.fmap.geom.primitive.Curve; |
|
66 | 64 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
67 | 65 |
import org.gvsig.fmap.geom.util.Converter; |
68 | 66 |
import org.gvsig.fmap.geom.util.UtilFunctions; |
69 | 67 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
68 |
import org.gvsig.fmap.mapcontrol.MapControlDrawer; |
|
70 | 69 |
|
71 | 70 |
|
72 | 71 |
|
... | ... | |
105 | 104 |
MultiPrimitive fgc = createMultiPrimitive(geoms); |
106 | 105 |
// No queremos guardar FGeometryCollections: |
107 | 106 |
GeneralPathX gp = new GeneralPathX(); |
108 |
gp.append(fgc.getPathIterator(null, Converter.FLATNESS), true);
|
|
107 |
gp.append(fgc.getPathIterator(null, geomManager.getFlatness()), true);
|
|
109 | 108 |
Geometry newGeom = createCurve(gp); |
110 | 109 |
return newGeom; |
111 | 110 |
} |
... | ... | |
125 | 124 |
Geometry[] geoms = (Geometry[]) list.toArray(new Geometry[0]); |
126 | 125 |
MultiPrimitive fgc = createMultiPrimitive(geoms); |
127 | 126 |
// No queremos guardar FGeometryCollections: |
128 |
gpx.append(fgc.getPathIterator(null,Converter.FLATNESS), true);
|
|
127 |
gpx.append(fgc.getPathIterator(null, geomManager.getFlatness()), true);
|
|
129 | 128 |
} |
130 | 129 |
try { |
131 | 130 |
if (((FLyrVect)getVLE().getLayer()).getShapeType()==Geometry.TYPES.SURFACE && !close){ |
... | ... | |
156 | 155 |
Geometry[] geoms = (Geometry[]) list.toArray(new Geometry[0]); |
157 | 156 |
MultiPrimitive fgc = createMultiPrimitive(geoms); |
158 | 157 |
// No queremos guardar FGeometryCollections: |
159 |
gpx.append(fgc.getPathIterator(null,Converter.FLATNESS), true);
|
|
158 |
gpx.append(fgc.getPathIterator(null, geomManager.getFlatness()), true);
|
|
160 | 159 |
} |
161 | 160 |
close=true; |
162 | 161 |
gpx.closePath(); |
... | ... | |
338 | 337 |
* @param x par?metro x del punto que se pase para dibujar. |
339 | 338 |
* @param y par?metro x del punto que se pase para dibujar. |
340 | 339 |
*/ |
341 |
public void drawOperation(Graphics g, double x,
|
|
340 |
public void drawOperation(MapControlDrawer renderer, double x,
|
|
342 | 341 |
double y) { |
343 | 342 |
PolylineCADToolState actualState = _fsm.getState(); |
344 | 343 |
String status = actualState.getName(); |
345 | 344 |
|
346 | 345 |
if (status.equals("Polyline.NextPointOrArcOrClose") || status.equals("Polyline.FirstPoint")) { |
347 | 346 |
for (int i = 0; i < list.size(); i++) { |
348 |
DrawOperationContext doc=new DrawOperationContext(); |
|
349 |
doc.setGraphics((Graphics2D)g); |
|
350 |
doc.setViewPort(getCadToolAdapter().getMapControl().getViewPort()); |
|
351 |
doc.setSymbol(DefaultCADTool.geometrySelectSymbol); |
|
352 |
try { |
|
353 |
((Geometry) list.get(i)).cloneGeometry().invokeOperation(Draw.CODE,doc); |
|
354 |
} catch (GeometryOperationNotSupportedException e) { |
|
355 |
e.printStackTrace(); |
|
356 |
} catch (GeometryOperationException e) { |
|
357 |
e.printStackTrace(); |
|
358 |
} |
|
359 |
// ((Geometry) list.get(i)).cloneGeometry().draw((Graphics2D) g, |
|
360 |
// getCadToolAdapter().getMapControl().getViewPort(), |
|
361 |
// DefaultCADTool.geometrySelectSymbol); |
|
347 |
renderer.draw((Geometry) list.get(i), mapControlManager.getGeometrySelectionSymbol()); |
|
362 | 348 |
} |
363 | 349 |
if (antPoint!=null) |
364 |
drawLine((Graphics2D) g, antPoint, new Point2D.Double(x, y),DefaultCADTool.geometrySelectSymbol);
|
|
350 |
renderer.drawLine(antPoint, new Point2D.Double(x, y), mapControlManager.getGeometrySelectionSymbol());
|
|
365 | 351 |
|
366 | 352 |
} else if ((status.equals("Polyline.NextPointOrLineOrClose"))) { |
367 | 353 |
for (int i = 0; i < list.size(); i++) { |
368 |
DrawOperationContext doc=new DrawOperationContext(); |
|
369 |
doc.setGraphics((Graphics2D)g); |
|
370 |
doc.setViewPort(getCadToolAdapter().getMapControl().getViewPort()); |
|
371 |
doc.setSymbol(DefaultCADTool.geometrySelectSymbol); |
|
372 |
try { |
|
373 |
((Geometry) list.get(i)).cloneGeometry().invokeOperation(Draw.CODE,doc); |
|
374 |
} catch (GeometryOperationNotSupportedException e) { |
|
375 |
e.printStackTrace(); |
|
376 |
} catch (GeometryOperationException e) { |
|
377 |
e.printStackTrace(); |
|
378 |
} |
|
379 |
// ((Geometry) list.get(i)).cloneGeometry().draw((Graphics2D) g, |
|
380 |
// getCadToolAdapter().getMapControl().getViewPort(), |
|
381 |
// DefaultCADTool.geometrySelectSymbol); |
|
354 |
renderer.draw((Geometry) list.get(i), mapControlManager.getGeometrySelectionSymbol()); |
|
382 | 355 |
} |
383 | 356 |
|
384 | 357 |
Point2D point = new Point2D.Double(x, y); |
... | ... | |
389 | 362 |
if (antantPoint == null) { |
390 | 363 |
drawArc(point, lastp, |
391 | 364 |
new Point2D.Double(lastp.getX() + (point.getX() / 2), |
392 |
lastp.getY() + (point.getY() / 2)), g);
|
|
365 |
lastp.getY() + (point.getY() / 2)), renderer);
|
|
393 | 366 |
} else { |
394 |
drawArc(point, lastp, antantPoint, g);
|
|
367 |
drawArc(point, lastp, antantPoint, renderer);
|
|
395 | 368 |
} |
396 | 369 |
} else { |
397 | 370 |
if (antInter != null) { |
... | ... | |
415 | 388 |
Point2D unit = UtilFunctions.getUnitVector(ini1, ini2); |
416 | 389 |
Point2D correct = new Point2D.Double(lastp.getX() + |
417 | 390 |
unit.getX(), lastp.getY() + unit.getY()); |
418 |
drawArc(point, lastp, correct, g);
|
|
391 |
drawArc(point, lastp, correct, renderer);
|
|
419 | 392 |
} |
420 | 393 |
} |
421 | 394 |
} |
... | ... | |
426 | 399 |
gpx.moveTo(x,y); |
427 | 400 |
Point2D p1=handler1.getPoint(); |
428 | 401 |
gpx.lineTo(p1.getX(),p1.getY()); |
429 |
DrawOperationContext doc=new DrawOperationContext(); |
|
430 |
doc.setGraphics((Graphics2D)g); |
|
431 |
doc.setViewPort(getCadToolAdapter().getMapControl().getViewPort()); |
|
432 |
doc.setSymbol(DefaultCADTool.geometrySelectSymbol); |
|
433 |
try { |
|
434 |
createCurve(gpx).invokeOperation(Draw.CODE,doc); |
|
435 |
} catch (GeometryOperationNotSupportedException e) { |
|
436 |
e.printStackTrace(); |
|
437 |
} catch (GeometryOperationException e) { |
|
438 |
e.printStackTrace(); |
|
439 |
} |
|
440 |
// geomFactory.createPolyline2D(gpx).draw((Graphics2D) g, |
|
441 |
// getCadToolAdapter().getMapControl().getViewPort(), |
|
442 |
// DefaultCADTool.geometrySelectSymbol); |
|
402 |
Curve curve = createCurve(gpx); |
|
403 |
renderer.draw(curve, mapControlManager.getGeometrySelectionSymbol()); |
|
443 | 404 |
} |
444 | 405 |
VectorialLayerEdited vle=getVLE(); |
445 | 406 |
if (!vle.getLayer().isVisible()) |
446 | 407 |
return; |
447 | 408 |
try{ |
448 | 409 |
Image imgSel = vle.getSelectionImage(); |
449 |
if (imgSel!=null)
|
|
450 |
g.drawImage(imgSel, 0, 0, null); |
|
410 |
renderer.drawImage(imgSel, 0, 0);
|
|
411 |
|
|
451 | 412 |
Image imgHand = vle.getHandlersImage(); |
452 |
if (imgHand!=null) |
|
453 |
g.drawImage(imgHand, 0, 0, null); |
|
413 |
renderer.drawImage(imgHand, 0, 0); |
|
454 | 414 |
}catch (Exception e) { |
455 | 415 |
} |
456 | 416 |
} catch (ReadException e) { |
... | ... | |
466 | 426 |
* @param antp Punto antepenultimo. |
467 | 427 |
* @param g Graphics sobre el que se dibuja. |
468 | 428 |
*/ |
469 |
private void drawArc(Point2D point, Point2D lastp, Point2D antp, Graphics g) {
|
|
429 |
private void drawArc(Point2D point, Point2D lastp, Point2D antp, MapControlDrawer renderer) {
|
|
470 | 430 |
if (((point.getY() == lastp.getY()) && (point.getX() < lastp.getX())) || |
471 | 431 |
((point.getX() == lastp.getX()) && |
472 | 432 |
(point.getY() < lastp.getY()))) { |
... | ... | |
501 | 461 |
} |
502 | 462 |
|
503 | 463 |
Point2D centerp = UtilFunctions.getPoint(interp, mediop, radio); |
464 |
renderer.drawLine(lastp, point, mapControlManager.getGeometrySelectionSymbol()); |
|
504 | 465 |
|
505 |
drawLine((Graphics2D) g, lastp, point,DefaultCADTool.geometrySelectSymbol); |
|
506 |
|
|
507 | 466 |
Geometry ig = createArc(lastp, centerp, point); |
508 | 467 |
|
509 | 468 |
if (ig != null) { |
510 |
DrawOperationContext doc=new DrawOperationContext(); |
|
511 |
doc.setGraphics((Graphics2D)g); |
|
512 |
doc.setViewPort(getCadToolAdapter().getMapControl().getViewPort()); |
|
513 |
doc.setSymbol(DefaultCADTool.geometrySelectSymbol); |
|
514 |
try { |
|
515 |
ig.invokeOperation(Draw.CODE,doc); |
|
516 |
} catch (GeometryOperationNotSupportedException e) { |
|
517 |
e.printStackTrace(); |
|
518 |
} catch (GeometryOperationException e) { |
|
519 |
e.printStackTrace(); |
|
520 |
} |
|
521 |
// ig.draw((Graphics2D) g, |
|
522 |
// getCadToolAdapter().getMapControl().getViewPort(), |
|
523 |
// DefaultCADTool.axisReferencesSymbol); |
|
469 |
renderer.draw(ig, mapControlManager.getGeometrySelectionSymbol()); |
|
524 | 470 |
} |
525 | 471 |
} |
526 | 472 |
} |
Also available in: Unified diff