Changeset 16922 in josm for trunk


Ignore:
Timestamp:
2020-08-23T23:43:20+02:00 (4 years ago)
Author:
simon04
Message:

fix #19705 - StyledMapRenderer: render turn restrictions in HiDPI

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r16913 r16922  
    77import java.awt.Component;
    88import java.awt.Composite;
    9 import java.awt.Dimension;
    109import java.awt.Font;
    1110import java.awt.FontMetrics;
     
    8685import org.openstreetmap.josm.tools.Geometry.AreaAndPerimeter;
    8786import org.openstreetmap.josm.tools.HiDPISupport;
    88 import org.openstreetmap.josm.tools.ImageProvider;
    8987import org.openstreetmap.josm.tools.JosmRuntimeException;
    9088import org.openstreetmap.josm.tools.Logging;
     
    797795        }
    798796
    799         drawIcon(p, img, disabled, selected, member, theta, (g, r) -> {
     797        drawIcon(p.getInViewX(), p.getInViewY(), img, disabled, selected, member, theta, (g, r) -> {
    800798            Color color = getSelectionHintColor(disabled, selected);
    801799            g.setColor(color);
     
    825823            }
    826824            MapViewPoint p = placement.getPoint();
    827             drawIcon(p, img, disabled, selected, member, theta + placement.getRotation(), (g, r) -> {
     825            drawIcon(p.getInViewX(), p.getInViewY(), img, disabled, selected, member, theta + placement.getRotation(), (g, r) -> {
    828826                if (useStrokes) {
    829827                    g.setStroke(new BasicStroke(2));
     
    838836    }
    839837
    840     private void drawIcon(MapViewPoint p, MapImage img, boolean disabled, boolean selected, boolean member, double theta,
     838    private void drawIcon(final double x, final double y, MapImage img, boolean disabled, boolean selected, boolean member, double theta,
    841839            BiConsumer<Graphics2D, Rectangle2D> selectionDrawer) {
    842840        float alpha = img.getAlphaFloat();
     
    847845        }
    848846
    849         double x = Math.round(p.getInViewX());
    850         double y = Math.round(p.getInViewY());
    851         temporaryGraphics.translate(x, y);
     847        temporaryGraphics.translate(Math.round(x), Math.round(y));
    852848        temporaryGraphics.rotate(theta);
    853849        int drawX = -img.getWidth() / 2 + img.offsetX;
     
    955951            g.fill(new RoundRectangle2D.Double(p.getX()-r, p.getY()-r, s, s, r, r));
    956952            s -= step;
    957         }
    958     }
    959 
    960     /**
    961      * Draws a restriction.
    962      * @param img symbol image
    963      * @param pVia "via" node
    964      * @param vx X offset
    965      * @param vy Y offset
    966      * @param angle the rotated angle, in degree, clockwise
    967      * @param selected if true, draws a selection rectangle
    968      * @since 13676
    969      */
    970     public void drawRestriction(Image img, Point pVia, double vx, double vy, double angle, boolean selected) {
    971         // rotate image with direction last node in from to, and scale down image to 16*16 pixels
    972         Image smallImg = ImageProvider.createRotatedImage(img, angle, new Dimension(16, 16));
    973         int w = smallImg.getWidth(null), h = smallImg.getHeight(null);
    974         g.drawImage(smallImg, (int) (pVia.x+vx)-w/2, (int) (pVia.y+vy)-h/2, nc);
    975 
    976         if (selected) {
    977             g.setColor(isInactiveMode ? inactiveColor : relationSelectedColor);
    978             g.drawRect((int) (pVia.x+vx)-w/2-2, (int) (pVia.y+vy)-h/2-2, w+4, h+4);
    979953        }
    980954    }
     
    11501124        }
    11511125
    1152         drawRestriction(icon.getImage(disabled),
    1153                 pVia, vx+vx2, vy+vy2, iconAngle, r.isSelected());
     1126        drawIcon(
     1127                pVia.x + vx + vx2,
     1128                pVia.y + vy + vy2,
     1129                icon, disabled, false, false, Math.toRadians(iconAngle), (graphics2D, rectangle2D) -> {
     1130                });
    11541131    }
    11551132
Note: See TracChangeset for help on using the changeset viewer.