Changeset 7687 in josm
- Timestamp:
- 2014-11-01T23:00:42+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r7668 r7687 124 124 125 125 public Icon getDisplayIcon() { 126 return ico != null ? ico : (Icon) action.getValue(Action.SMALL_ICON); 126 if(ico != null) 127 return ico; 128 Object o = action.getValue(Action.LARGE_ICON_KEY); 129 if(o == null) 130 o = action.getValue(Action.SMALL_ICON); 131 return (Icon) o; 127 132 } 128 133 -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r7616 r7687 11 11 import java.awt.Insets; 12 12 import java.awt.event.ActionEvent; 13 import java.io.File; 13 14 import java.util.ArrayList; 14 15 import java.util.Collection; … … 143 144 * Called from the XML parser to set the icon. 144 145 * This task is performed in the background in order to speedup startup. 145 *146 * FIXME for Java 1.6 - use 24x24 icons for LARGE_ICON_KEY (button bar)147 * and the 16x16 icons for SMALL_ICON.148 146 */ 149 147 public void setIcon(final String iconName) { 148 File arch = TaggingPresetReader.getZipIcons(); 149 final Collection<String> s = Main.pref.getCollection("taggingpreset.icon.sources", null); 150 150 ImageProvider imgProv = new ImageProvider(iconName); 151 final Collection<String> s = Main.pref.getCollection("taggingpreset.icon.sources", null);152 151 imgProv.setDirs(s); 153 152 imgProv.setId("presets"); 154 imgProv.setArchive( TaggingPresetReader.getZipIcons());153 imgProv.setArchive(arch); 155 154 imgProv.setOptional(true); 156 imgProv.set MaxWidth(16).setMaxHeight(16);155 imgProv.setSize(ImageProvider.ImageSizes.SMALLICON); 157 156 imgProv.getInBackground(new ImageProvider.ImageCallback() { 158 157 @Override … … 167 166 } else { 168 167 Main.warn("Could not get presets icon " + iconName); 168 } 169 } 170 }); 171 imgProv = new ImageProvider(iconName); 172 imgProv.setDirs(s); 173 imgProv.setId("presets"); 174 imgProv.setArchive(arch); 175 imgProv.setOptional(true); 176 imgProv.setSize(ImageProvider.ImageSizes.LARGEICON); 177 imgProv.getInBackground(new ImageProvider.ImageCallback() { 178 @Override 179 public void finished(final ImageIcon result) { 180 if (result != null) { 181 GuiHelper.runInEDT(new Runnable() { 182 @Override 183 public void run() { 184 putValue(Action.LARGE_ICON_KEY, result); 185 } 186 }); 169 187 } 170 188 } -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r7595 r7687 109 109 110 110 /** 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 /** 111 126 * Property set on {@code BufferedImage} returned by {@link #makeImageTransparent}. 112 127 * @since 7132 … … 218 233 219 234 /** 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 /** 220 252 * Set the dimensions of the image. 221 253 * … … 232 264 233 265 /** 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 /** 234 277 * @see #setSize 235 278 * @return the current object, for convenience … … 262 305 this.maxHeight = maxSize.height; 263 306 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)); 264 321 } 265 322
Note:
See TracChangeset
for help on using the changeset viewer.