Ticket #9995: multi-resolution-images.patch

File multi-resolution-images.patch, 2.4 KB (added by bastiK, 2 months ago)
  • src/org/openstreetmap/josm/tools/ImageResource.java

     
    1818import org.openstreetmap.josm.gui.util.GuiSizesHelper;
    1919
    2020import com.kitfox.svg.SVGDiagram;
     21import java.util.Arrays;
    2122
    2223/**
    2324 * Holds data for one particular image.
     
    121122     * @since 10369
    122123     */
    123124    public void attachImageIcon(AbstractAction a) {
    124         Dimension iconDimension = ImageProvider.ImageSizes.SMALLICON.getImageDimension();
    125         ImageIcon icon = getImageIconBounded(iconDimension);
    126         a.putValue(Action.SMALL_ICON, icon);
     125        a.putValue(Action.SMALL_ICON, multiResImage(ImageProvider.ImageSizes.SMALLICON.getImageDimension()));
     126        a.putValue(Action.LARGE_ICON_KEY, multiResImage(ImageProvider.ImageSizes.LARGEICON.getImageDimension()));
     127    }
    127128
    128         iconDimension = ImageProvider.ImageSizes.LARGEICON.getImageDimension();
    129         icon = getImageIconBounded(iconDimension);
    130         a.putValue(Action.LARGE_ICON_KEY, icon);
     129    private ImageIcon multiResImage(Dimension dim) {
     130        ImageIcon icon = getImageIconBounded(dim);
     131        ImageIcon icon2 = getImageIconBounded(new Dimension(2 * dim.width, 2 * dim.height));
     132        List<Image> images = Arrays.asList(icon.getImage(), icon2.getImage());
     133        try {
     134            Image img = MRImage.getMulti(images);
     135            return new ImageIcon(img);
     136        } catch (NoClassDefFoundError e) {
     137            return icon;
     138        }
    131139    }
    132140
    133141    /**
  • src/org/openstreetmap/josm/tools/MRImage.java

     
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.tools;
     3
     4import java.awt.Image;
     5import java.util.List;
     6
     7public class MRImage {
     8    public static Image getMulti(List<Image> imgs) {
     9        return new java.awt.image.BaseMultiResolutionImage(imgs.toArray(new Image[0]));
     10    }
     11}