Changeset 16926 in josm


Ignore:
Timestamp:
2020-08-24T21:56:26+02:00 (4 years ago)
Author:
simon04
Message:

fix #19706 - Selection/Relation list: render primitive icons in HiDPI

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ImageResource.java

    r16486 r16926  
    297297     */
    298298    public ImageIcon getPaddedIcon(Dimension iconSize) {
     299        final ImageIcon imageIcon = getImageIcon(iconSize);
     300        if (imageIcon.getIconWidth() == iconSize.width && imageIcon.getIconHeight() == iconSize.height) {
     301            // fast path for square and svg icons
     302            return imageIcon;
     303        }
     304
    299305        final Dimension cacheKey = new Dimension(-iconSize.width, -iconSize.height); // use negative width/height for differentiation
    300306        BufferedImage image = imgCache.get(cacheKey);
  • trunk/test/unit/org/openstreetmap/josm/tools/OsmPrimitiveImageProviderTest.java

    r16838 r16926  
    1717import java.util.EnumSet;
    1818
     19import static org.junit.Assert.assertEquals;
    1920import static org.junit.Assert.assertNotNull;
    2021import static org.junit.Assert.assertNull;
     22
     23import javax.swing.ImageIcon;
    2124
    2225/**
     
    5861        assertNotNull(OsmPrimitiveImageProvider.getResource(OsmUtils.createPrimitive("way waterway=stream"), noDefault));
    5962        assertNotNull(OsmPrimitiveImageProvider.getResource(OsmUtils.createPrimitive("relation type=route route=railway"), noDefault));
     63        // a non-square svg icon
     64        final ImageIcon bankIcon = OsmPrimitiveImageProvider
     65                .getResource(OsmUtils.createPrimitive("node amenity=bank"), Options.DEFAULT)
     66                .getPaddedIcon(ImageProvider.ImageSizes.LARGEICON.getImageDimension());
     67        assertEquals(ImageProvider.ImageSizes.LARGEICON.getVirtualWidth(), bankIcon.getIconWidth());
     68        assertEquals(ImageProvider.ImageSizes.LARGEICON.getVirtualHeight(), bankIcon.getIconHeight());
    6069    }
    6170}
Note: See TracChangeset for help on using the changeset viewer.