Label is displayed below the template (i.e. similar to dragging a token) + *
Label is displayed near the dragged terminus * * @param g where to draw. * @param startVertex the starting point. @@ -1112,10 +1111,9 @@ private void paintTemplateMovementLabel( if (moveDistance != 0) { Rectangle bounds = at.getBounds(zone); - int x = (int) (bounds.getMinX() + bounds.getMaxX()) / 2; - int y = (int) (bounds.getMaxY()); - ScreenPoint centerText = renderer.getViewModel().getZoneScale().toScreenSpace(x, y); - + ScreenPoint centerText = + renderer.getViewModel().getZoneScale().toScreenSpace(endVertex.x, endVertex.y); + centerText.translate(CURSOR_WIDTH, CURSOR_WIDTH); ToolHelper.drawMeasurement(g, moveDistance, (int) centerText.x, (int) centerText.y); } } @@ -1176,19 +1174,23 @@ private void paintTemplateMovementLine( } /** - * Paint the radius value in feet. To be displayed above the template vertex (i.e. same as when - * drawing a template) + * Paint the template radius value label. + * + *
Label is displayed to the right of the template.
*
* @param g where to paint.
* @param zp where on the map to paint the radius label.
*/
private void paintTemplateRadiusLabel(Graphics2D g, ZonePoint zp, AbstractTemplate at) {
if (at.getRadius() > 0) {
- ScreenPoint centerText = renderer.getViewModel().getZoneScale().toScreenSpace(zp.x, zp.y);
- centerText.translate(CURSOR_WIDTH, -CURSOR_WIDTH);
+ Zone zone = getZone();
+ Rectangle bounds = at.getBounds(zone);
+ int x = (int) bounds.getMaxX();
+ int y = (int) (bounds.getMinY() + bounds.getMaxY()) / 2;
+ ScreenPoint centerText = renderer.getViewModel().getZoneScale().toScreenSpace(x, y);
ToolHelper.drawMeasurement(
g, at.getRadius() * getZone().getUnitsPerCell(), (int) centerText.x, (int) centerText.y);
- } // endif
+ }
}
/**
@@ -1359,14 +1361,55 @@ private void updateDraggedDrawnElements(MouseEvent e, ShapeDrawable sd) {
dragPointOffset.y = dragWorkingZonePoint.y - dragPointOffset.y;
}
- if (sd.getShape() instanceof RectangularShape rs) {
+ Shape s = sd.getShape();
+ if (s instanceof RectangularShape rs) {
rs.setFrame(
- rs.getBounds().x - dragPointOffset.x,
- rs.getBounds().y - dragPointOffset.y,
+ rs.getX() - dragPointOffset.x,
+ rs.getY() - dragPointOffset.y,
rs.getWidth(),
rs.getHeight());
- } else if (sd.getShape() instanceof Polygon p) {
+ } else if (s instanceof Polygon p) {
p.translate(-dragPointOffset.x, -dragPointOffset.y);
+ } else if (s instanceof Area a) {
+ AffineTransform tx =
+ AffineTransform.getTranslateInstance(-dragPointOffset.x, -dragPointOffset.y);
+ a.transform(tx);
+ } else if (s instanceof Path2D p2d) {
+ AffineTransform tx =
+ AffineTransform.getTranslateInstance(-dragPointOffset.x, -dragPointOffset.y);
+ p2d.transform(tx);
+ } else if (s instanceof Line2D line) {
+ line.setLine(
+ line.getX1() - dragPointOffset.x,
+ line.getY1() - dragPointOffset.y,
+ line.getX2() - dragPointOffset.x,
+ line.getY2() - dragPointOffset.y);
+ } else if (s instanceof QuadCurve2D quad) {
+ quad.setCurve(
+ quad.getX1() - dragPointOffset.x,
+ quad.getY1() - dragPointOffset.y,
+ quad.getCtrlX() - dragPointOffset.x,
+ quad.getCtrlY() - dragPointOffset.y,
+ quad.getX2() - dragPointOffset.x,
+ quad.getY2() - dragPointOffset.y);
+ } else if (s instanceof CubicCurve2D cubic) {
+ cubic.setCurve(
+ cubic.getX1() - dragPointOffset.x,
+ cubic.getY1() - dragPointOffset.y,
+ cubic.getCtrlX1() - dragPointOffset.x,
+ cubic.getCtrlY1() - dragPointOffset.y,
+ cubic.getCtrlX2() - dragPointOffset.x,
+ cubic.getCtrlY2() - dragPointOffset.y,
+ cubic.getX2() - dragPointOffset.x,
+ cubic.getY2() - dragPointOffset.y);
+ } else {
+ // log that we cannot drag certain types of shape that are being dragged
+ log.warn(
+ I18N.getText(
+ "tool.drawingpointer.draggingUnsupportedShapeType",
+ s.getClass().getSimpleName(),
+ sd.getId(),
+ sd.getName()));
}
}
diff --git a/src/main/java/net/rptools/maptool/model/drawing/LineSegment.java b/src/main/java/net/rptools/maptool/model/drawing/LineSegment.java
index 18e615e63d..77092cca40 100644
--- a/src/main/java/net/rptools/maptool/model/drawing/LineSegment.java
+++ b/src/main/java/net/rptools/maptool/model/drawing/LineSegment.java
@@ -41,7 +41,6 @@ public class LineSegment extends AbstractDrawing {
private final List