Ticket #22695: text-rotation.1.patch

File text-rotation.1.patch, 1.5 KB (added by marcello@…, 3 years ago)

Rotate text around node

  • src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    diff --git a/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java b/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
    index b27acb4bc..bb7256f4a 100644
    a b public class StyledMapRenderer extends AbstractMapRenderer {  
    620620        FontRenderContext frc = g.getFontRenderContext();
    621621        Rectangle2D bounds = text.font.getStringBounds(s, frc);
    622622
    623         double x = p.getInViewX() + bs.xOffset;
    624         double y = p.getInViewY() + bs.yOffset;
     623        double x = bs.xOffset;
     624        double y = bs.yOffset;
    625625        /**
    626626         *
    627627         *       left-above __center-above___ right-above
    public class StyledMapRenderer extends AbstractMapRenderer {  
    660660            } else throw new AssertionError();
    661661        }
    662662
    663         final MapViewPoint viewPoint = mapState.getForView(x, y);
     663        final MapViewPoint viewPoint = mapState.getForView(p.getInViewX(), p.getInViewY());
    664664        final AffineTransform at = new AffineTransform();
    665665        at.setToTranslation(
    666666                Math.round(viewPoint.getInViewX()),
    public class StyledMapRenderer extends AbstractMapRenderer {  
    668668        if (!RotationAngle.NO_ROTATION.equals(text.rotationAngle)) {
    669669            at.rotate(text.rotationAngle.getRotationAngle(n));
    670670        }
     671        at.translate(x, y);
    671672        displayText(n, text, s, at);
    672673        g.setFont(defaultFont);
    673674    }