Revision 30335 branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/gui/cad/tools/ComplexSelectionCADTool.java
ComplexSelectionCADTool.java | ||
---|---|---|
41 | 41 |
package org.gvsig.editing.gui.cad.tools; |
42 | 42 |
|
43 | 43 |
import java.awt.Color; |
44 |
import java.awt.Graphics; |
|
45 | 44 |
import java.awt.Graphics2D; |
46 | 45 |
import java.awt.Image; |
47 | 46 |
import java.awt.event.InputEvent; |
... | ... | |
74 | 73 |
import org.gvsig.fmap.geom.operation.DrawOperationContext; |
75 | 74 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
76 | 75 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
76 |
import org.gvsig.fmap.geom.primitive.Curve; |
|
77 | 77 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
78 | 78 |
import org.gvsig.fmap.mapcontext.ViewPort; |
79 | 79 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
80 | 80 |
import org.gvsig.fmap.mapcontrol.MapControl; |
81 |
import org.gvsig.fmap.mapcontrol.MapControlDrawer; |
|
81 | 82 |
|
82 | 83 |
|
83 | 84 |
/** |
... | ... | |
288 | 289 |
* @param y |
289 | 290 |
* par?metro x del punto que se pase para dibujar. |
290 | 291 |
*/ |
291 |
public void drawOperation(Graphics g, double x, double y) {
|
|
292 |
public void drawOperation(MapControlDrawer renderer, double x, double y) {
|
|
292 | 293 |
ComplexSelectionCADToolState actualState = _fsm.getState(); |
293 | 294 |
String status = actualState.getName(); |
294 | 295 |
VectorialLayerEdited vle = getVLE(); |
... | ... | |
304 | 305 |
elShape.lineTo(x, y); |
305 | 306 |
elShape.lineTo(firstPoint.getX(), y); |
306 | 307 |
elShape.lineTo(firstPoint.getX(), firstPoint.getY()); |
307 |
|
|
308 |
DrawOperationContext doc = new DrawOperationContext(); |
|
309 |
doc.setGraphics((Graphics2D) g); |
|
310 |
doc.setViewPort(vp); |
|
311 |
doc.setSymbol(DefaultCADTool.geometrySelectSymbol); |
|
312 |
try { |
|
313 |
createCurve(elShape).invokeOperation( |
|
314 |
Draw.CODE, doc); |
|
315 |
} catch (GeometryOperationNotSupportedException e) { |
|
316 |
e.printStackTrace(); |
|
317 |
} catch (GeometryOperationException e) { |
|
318 |
e.printStackTrace(); |
|
319 |
} |
|
308 |
|
|
309 |
renderer.draw(createCurve(elShape), mapControlManager.getGeometrySelectionSymbol()); |
|
310 |
|
|
320 | 311 |
Image img = vle.getSelectionImage(); |
321 |
g.drawImage(img, 0, 0, null);
|
|
312 |
renderer.drawImage(img, 0, 0);
|
|
322 | 313 |
return; |
323 | 314 |
} |
324 | 315 |
if (status.equals("Selection.SecondPointCircle")) { |
... | ... | |
328 | 319 |
gpx.append(circle.getInternalShape().getPathIterator(null), true); |
329 | 320 |
Geometry circleSel = createCurve(gpx); |
330 | 321 |
// Dibuja el c?rculo de selecci?n |
331 |
DrawOperationContext doc = new DrawOperationContext(); |
|
332 |
doc.setGraphics((Graphics2D) g); |
|
333 |
doc.setViewPort(vp); |
|
334 |
doc.setSymbol(DefaultCADTool.geometrySelectSymbol); |
|
335 |
try { |
|
336 |
circleSel.invokeOperation(Draw.CODE, doc); |
|
337 |
} catch (GeometryOperationNotSupportedException e) { |
|
338 |
e.printStackTrace(); |
|
339 |
} catch (GeometryOperationException e) { |
|
340 |
e.printStackTrace(); |
|
341 |
} |
|
322 |
renderer.draw(circleSel, mapControlManager.getGeometrySelectionSymbol()); |
|
323 |
|
|
342 | 324 |
Image img = vle.getSelectionImage(); |
343 |
g.drawImage(img, 0, 0, null);
|
|
325 |
renderer.drawImage(img, 0, 0);
|
|
344 | 326 |
return; |
345 | 327 |
} else if (status.equals("Selection.NextPointPolygon")) { |
346 | 328 |
// Dibuja el pol?gono de selecci?n |
347 | 329 |
Geometry polygon = getGeometryPolygon(new Point2D.Double(x, y)); |
348 |
DrawOperationContext doc = new DrawOperationContext(); |
|
349 |
doc.setGraphics((Graphics2D) g); |
|
350 |
doc.setViewPort(vp); |
|
351 |
doc.setSymbol(DefaultCADTool.geometrySelectSymbol); |
|
352 |
try { |
|
353 |
polygon.invokeOperation(Draw.CODE, doc); |
|
354 |
} catch (GeometryOperationNotSupportedException e) { |
|
355 |
e.printStackTrace(); |
|
356 |
} catch (GeometryOperationException e) { |
|
357 |
e.printStackTrace(); |
|
358 |
} |
|
330 |
renderer.draw(polygon, mapControlManager.getGeometrySelectionSymbol()); |
|
331 |
|
|
359 | 332 |
Image img = vle.getSelectionImage(); |
360 |
g.drawImage(img, 0, 0, null);
|
|
333 |
renderer.drawImage(img, 0, 0);
|
|
361 | 334 |
return; |
362 | 335 |
} else if (status.equals("Selection.WithHandlers")) { |
363 | 336 |
// Movemos los handlers que hemos seleccionado |
... | ... | |
376 | 349 |
Feature rowEd = (Feature) rowselectedHandlers.get(i); |
377 | 350 |
Geometry geom = (rowEd.getDefaultGeometry()) |
378 | 351 |
.cloneGeometry(); |
379 |
g.setColor(Color.gray); |
|
380 |
DrawOperationContext doc = new DrawOperationContext(); |
|
381 |
doc.setGraphics((Graphics2D) g); |
|
382 |
doc.setViewPort(vp); |
|
383 |
doc.setSymbol(DefaultCADTool.axisReferencesSymbol); |
|
384 |
try { |
|
385 |
geom.invokeOperation(Draw.CODE, doc); |
|
386 |
} catch (GeometryOperationNotSupportedException e) { |
|
387 |
e.printStackTrace(); |
|
388 |
} catch (GeometryOperationException e) { |
|
389 |
e.printStackTrace(); |
|
390 |
} |
|
352 |
renderer.setColor(Color.gray); |
|
353 |
renderer.draw(geom, mapControlManager.getAxisReferenceSymbol()); |
|
391 | 354 |
} |
392 | 355 |
for (int k = 0; k < selectedHandler.size(); k++) { |
393 | 356 |
Handler h = (Handler) selectedHandler.get(k); |
... | ... | |
400 | 363 |
} |
401 | 364 |
try { |
402 | 365 |
Image imgSel = vle.getSelectionImage(); |
403 |
if (imgSel != null) { |
|
404 |
g.drawImage(imgSel, 0, 0, null); |
|
405 |
} |
|
366 |
renderer.drawImage(imgSel, 0, 0); |
|
367 |
|
|
406 | 368 |
Image imgHand = vle.getHandlersImage(); |
407 |
if (imgHand != null) { |
|
408 |
g.drawImage(imgHand, 0, 0, null); |
|
409 |
} |
|
369 |
renderer.drawImage(imgHand, 0, 0); |
|
410 | 370 |
} catch (Exception e) { |
411 | 371 |
} |
412 | 372 |
} |
... | ... | |
568 | 528 |
PluginServices.getMDIManager().setWaitCursor(); |
569 | 529 |
|
570 | 530 |
double tam = getCadToolAdapter().getMapControl().getViewPort() |
571 |
.toMapDistance(MapControl.tolerance);
|
|
531 |
.toMapDistance(mapControlManager.getTolerance());
|
|
572 | 532 |
|
573 | 533 |
Handler[] handlers = null; |
574 | 534 |
rowselectedHandlers.clear(); |
Also available in: Unified diff