Ticket #9995: multi-resolution-images.patch
File multi-resolution-images.patch, 2.4 KB (added by , 7 years ago) |
---|
-
src/org/openstreetmap/josm/tools/ImageResource.java
18 18 import org.openstreetmap.josm.gui.util.GuiSizesHelper; 19 19 20 20 import com.kitfox.svg.SVGDiagram; 21 import java.util.Arrays; 21 22 22 23 /** 23 24 * Holds data for one particular image. … … 121 122 * @since 10369 122 123 */ 123 124 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 } 127 128 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 } 131 139 } 132 140 133 141 /** -
src/org/openstreetmap/josm/tools/MRImage.java
1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.tools; 3 4 import java.awt.Image; 5 import java.util.List; 6 7 public class MRImage { 8 public static Image getMulti(List<Image> imgs) { 9 return new java.awt.image.BaseMultiResolutionImage(imgs.toArray(new Image[0])); 10 } 11 }