Changeset 16926 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ImageResource.java
r16486 r16926 297 297 */ 298 298 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 299 305 final Dimension cacheKey = new Dimension(-iconSize.width, -iconSize.height); // use negative width/height for differentiation 300 306 BufferedImage image = imgCache.get(cacheKey); -
trunk/test/unit/org/openstreetmap/josm/tools/OsmPrimitiveImageProviderTest.java
r16838 r16926 17 17 import java.util.EnumSet; 18 18 19 import static org.junit.Assert.assertEquals; 19 20 import static org.junit.Assert.assertNotNull; 20 21 import static org.junit.Assert.assertNull; 22 23 import javax.swing.ImageIcon; 21 24 22 25 /** … … 58 61 assertNotNull(OsmPrimitiveImageProvider.getResource(OsmUtils.createPrimitive("way waterway=stream"), noDefault)); 59 62 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()); 60 69 } 61 70 }
Note:
See TracChangeset
for help on using the changeset viewer.