Changeset 6374 in josm


Ignore:
Timestamp:
2013-11-07T17:03:07+01:00 (11 years ago)
Author:
Don-vip
Message:

fix #9286 - fix rendering of names for rescaled SVG icons

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapImage.java

    r6291 r6374  
    1919
    2020public class MapImage {
     21   
     22    private static final int MAX_SIZE = 48;
     23   
    2124    /**
    2225     * ImageIcon can change while the image is loading.
     
    117120        private Rectangle box() {
    118121            int w = getWidth(), h = getHeight();
     122            if (mustRescale(getImage())) {
     123                w = h = 16;
     124            }
    119125            return new Rectangle(-w/2, -h/2, w, h);
    120126        }
     
    158164     */
    159165    public Image getDisplayedNodeIcon(boolean disabled) {
    160         final int maxSize = 48;
    161166        final Image image = disabled ? getDisabled() : getImage();
    162167        // Scale down large (.svg) images to 16x16 pixels if no size is explicitely specified
    163         if ((width  == -1 && image.getWidth(null) > maxSize)
    164          && (height == -1 && image.getHeight(null) > maxSize)) {
     168        if (mustRescale(image)) {
    165169            return ImageProvider.createBoundedImage(image, 16);
    166170        } else {
    167171            return image;
    168172        }
     173    }
     174   
     175    private boolean mustRescale(Image image) {
     176        return ((width  == -1 && image.getWidth(null) > MAX_SIZE)
     177             && (height == -1 && image.getHeight(null) > MAX_SIZE));
    169178    }
    170179
Note: See TracChangeset for help on using the changeset viewer.