Ignore:
Timestamp:
2014-11-01T23:00:42+01:00 (11 years ago)
Author:
stoecker
Message:

see #10684, see #10688 fix icon scaling a bit

File:
1 edited

Legend:

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

    r7595 r7687  
    109109
    110110    /**
     111     * Supported image sizes
     112     * @since 7687
     113     */
     114    public static enum ImageSizes {
     115        /* SMALL_ICON value of on Action */
     116        SMALLICON,
     117        /* LARGE_ICON_KEY value of on Action */
     118        LARGEICON,
     119        /* MAP icon */
     120        MAP,
     121        /* MAP icon maximum size*/
     122        MAPMAX,
     123    }
     124
     125    /**
    111126     * Property set on {@code BufferedImage} returned by {@link #makeImageTransparent}.
    112127     * @since 7132
     
    218233
    219234    /**
     235     * Convert enumarated size values to real numbers
     236     * @return dimension of imagei
     237     * @since 7687
     238     */
     239    public Dimension getImageSizes(ImageSizes size) {
     240        int sizeval;
     241        switch(size) {
     242        case MAPMAX: sizeval = Main.pref.getInteger("iconsize.mapmax", 48); break;
     243        case MAP: sizeval = Main.pref.getInteger("iconsize.mapmax", 16); break;
     244        case LARGEICON: sizeval = Main.pref.getInteger("iconsize.largeicon", 24); break;
     245        case SMALLICON: sizeval = Main.pref.getInteger("iconsize.smallicon", 16); break;
     246        default: sizeval = Main.pref.getInteger("iconsize.default", 24); break;
     247        }
     248        return new Dimension(sizeval, sizeval);
     249    }
     250   
     251    /**
    220252     * Set the dimensions of the image.
    221253     *
     
    232264
    233265    /**
     266     * Set the dimensions of the image.
     267     *
     268     * If not specified, the original size of the image is used.
     269     * @return the current object, for convenience
     270     * @since 7687
     271     */
     272    public ImageProvider setSize(ImageSizes size) {
     273        return setSize(getImageSizes(size));
     274    }
     275
     276    /**
    234277     * @see #setSize
    235278     * @return the current object, for convenience
     
    262305        this.maxHeight = maxSize.height;
    263306        return this;
     307    }
     308
     309    /**
     310     * Limit the maximum size of the image.
     311     *
     312     * It will shrink the image if necessary, but keep the aspect ratio.
     313     * The given width or height can be -1 which means this direction is not bounded.
     314     *
     315     * 'size' and 'maxSize' are not compatible, you should set only one of them.
     316     * @return the current object, for convenience
     317     * @since 7687
     318     */
     319    public ImageProvider setMaxSize(ImageSizes size) {
     320        return setMaxSize(getImageSizes(size));
    264321    }
    265322
Note: See TracChangeset for help on using the changeset viewer.