Changeset 9705 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2016-02-01T16:41:36+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r9691 r9705 12 12 import java.awt.Image; 13 13 import java.awt.Point; 14 import java.awt.Rectangle;15 14 import java.awt.RenderingHints; 16 15 import java.awt.Toolkit; … … 134 133 public enum ImageSizes { 135 134 /** SMALL_ICON value of on Action */ 136 SMALLICON ,135 SMALLICON(Main.pref.getInteger("iconsize.smallicon", 16)), 137 136 /** LARGE_ICON_KEY value of on Action */ 138 LARGEICON ,137 LARGEICON(Main.pref.getInteger("iconsize.largeicon", 24)), 139 138 /** map icon */ 140 MAP ,139 MAP(Main.pref.getInteger("iconsize.map", 16)), 141 140 /** map icon maximum size */ 142 MAPMAX ,141 MAPMAX(Main.pref.getInteger("iconsize.mapmax", 48)), 143 142 /** cursor icon size */ 144 CURSOR ,143 CURSOR(Main.pref.getInteger("iconsize.cursor", 32)), 145 144 /** cursor overlay icon size */ 146 CURSOROVERLAY ,145 CURSOROVERLAY(CURSOR.imageSize), 147 146 /** menu icon size */ 148 MENU ,147 MENU(SMALLICON.imageSize), 149 148 /** menu icon size in popup menus 150 149 * @since 8323 151 150 */ 152 POPUPMENU ,151 POPUPMENU(LARGEICON.imageSize), 153 152 /** Layer list icon size 154 153 * @since 8323 155 154 */ 156 LAYER ,155 LAYER(Main.pref.getInteger("iconsize.layer", 16)), 157 156 /** Toolbar button icon size 158 157 * @since 9253 159 158 */ 160 TOOLBAR ,159 TOOLBAR(LARGEICON.imageSize), 161 160 /** Side button maximum height 162 161 * @since 9253 163 162 */ 164 SIDEBUTTON 163 SIDEBUTTON(Main.pref.getInteger("iconsize.sidebutton", 20)), 164 /** 165 * The default image size 166 * @since 9705 167 */ 168 DEFAULT(Main.pref.getInteger("iconsize.default", 24)); 169 170 private final int imageSize; 171 172 ImageSizes(int imageSize) { 173 this.imageSize = imageSize; 174 } 175 176 /** 177 * Returns the image size in pixels 178 * @return the image size in pixels 179 */ 180 public int getImageSize() { 181 return imageSize; 182 } 183 184 /** 185 * Returns the image size as dimension 186 * @return the image size as dimension 187 */ 188 public Dimension getImageDimension() { 189 return new Dimension(imageSize, imageSize); 190 } 165 191 } 166 192 … … 354 380 * @return dimension of image in pixels 355 381 * @since 7687 356 */ 382 * @deprecated Use {@link ImageSizes#getImageDimension()} instead 383 */ 384 @Deprecated 357 385 public static Dimension getImageSizes(ImageSizes size) { 358 int sizeval; 359 switch(size) { 360 case MAPMAX: sizeval = Main.pref.getInteger("iconsize.mapmax", 48); break; 361 case MAP: sizeval = Main.pref.getInteger("iconsize.mapmax", 16); break; 362 case SIDEBUTTON: sizeval = Main.pref.getInteger("iconsize.sidebutton", 20); break; 363 case TOOLBAR: /* TOOLBAR is LARGELICON - only provided in case of future changes */ 364 case POPUPMENU: /* POPUPMENU is LARGELICON - only provided in case of future changes */ 365 case LARGEICON: sizeval = Main.pref.getInteger("iconsize.largeicon", 24); break; 366 case MENU: /* MENU is SMALLICON - only provided in case of future changes */ 367 case SMALLICON: sizeval = Main.pref.getInteger("iconsize.smallicon", 16); break; 368 case CURSOROVERLAY: /* same as cursor - only provided in case of future changes */ 369 case CURSOR: sizeval = Main.pref.getInteger("iconsize.cursor", 32); break; 370 case LAYER: sizeval = Main.pref.getInteger("iconsize.layer", 16); break; 371 default: sizeval = Main.pref.getInteger("iconsize.default", 24); break; 372 } 373 return new Dimension(sizeval, sizeval); 386 return (size == null ? ImageSizes.DEFAULT : size).getImageDimension(); 374 387 } 375 388 … … 398 411 */ 399 412 public ImageProvider setSize(ImageSizes size) { 400 return setSize( getImageSizes(size));413 return setSize(size.getImageDimension()); 401 414 } 402 415 … … 474 487 */ 475 488 public ImageProvider setMaxSize(ImageSizes size) { 476 return setMaxSize( getImageSizes(size));489 return setMaxSize(size.getImageDimension()); 477 490 } 478 491 … … 1305 1318 * @since 8903 1306 1319 */ 1307 public static ImageIcon getPadded(OsmPrimitive primitive, RectangleiconSize) {1320 public static ImageIcon getPadded(OsmPrimitive primitive, Dimension iconSize) { 1308 1321 // Check if the current styles have special icon for tagged nodes. 1309 1322 if (primitive instanceof org.openstreetmap.josm.data.osm.Node) { … … 1314 1327 MapImage icon = nodeStyle.mapImage; 1315 1328 if (icon != null) { 1316 int backgroundWidth = iconSize. height;1329 int backgroundWidth = iconSize.width; 1317 1330 int backgroundHeight = iconSize.height; 1318 1331 int iconWidth = icon.getWidth(); … … 1769 1782 1770 1783 /** 1771 * Determines if the given {@code BufferedImage} has a transparent color determi end by a previous call to {@link #read}.1784 * Determines if the given {@code BufferedImage} has a transparent color determined by a previous call to {@link #read}. 1772 1785 * @param bi The {@code BufferedImage} to test 1773 1786 * @return {@code true} if {@code bi} has a transparent color determined by a previous call to {@code read}. -
trunk/src/org/openstreetmap/josm/tools/ImageResource.java
r9282 r9705 88 88 */ 89 89 public void getImageIcon(AbstractAction a) { 90 ImageIcon icon = getImageIconBounded(ImageProvider. getImageSizes(ImageProvider.ImageSizes.SMALLICON));90 ImageIcon icon = getImageIconBounded(ImageProvider.ImageSizes.SMALLICON.getImageDimension()); 91 91 a.putValue(Action.SMALL_ICON, icon); 92 icon = getImageIconBounded(ImageProvider. getImageSizes(ImageProvider.ImageSizes.LARGEICON));92 icon = getImageIconBounded(ImageProvider.ImageSizes.LARGEICON.getImageDimension()); 93 93 a.putValue(Action.LARGE_ICON_KEY, icon); 94 94 }
Note:
See TracChangeset
for help on using the changeset viewer.