Changeset 8097 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2015-02-22T14:19:20+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ImageOverlay.java
r8095 r8097 81 81 ImageIcon overlay; 82 82 if(width != -1 || height != -1) { 83 /* Don't modify ImageProvider, but apply maximum size, probably cloning the ImageProvider 84 would be a better approach. */ 85 overlay = image.getResource().getImageIconBounded(new Dimension(width, height)); 86 } else { 87 overlay = image.get(); 83 image = new ImageProvider(image).resetMaxSize(new Dimension(width, height)); 88 84 } 85 overlay = image.get(); 89 86 int x, y; 90 87 if (width == -1 && offsetLeft < 0) { -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r8096 r8097 240 240 241 241 /** 242 * Constructs a new {@code ImageProvider} from an existing one. 243 * @param image the existing image provider to be copied 244 * @since 8095 245 */ 246 public ImageProvider(ImageProvider image) { 247 this.dirs = image.dirs; 248 this.id = image.id; 249 this.subdir = image.subdir; 250 this.name = image.name; 251 this.archive = image.archive; 252 this.inArchiveDir = image.inArchiveDir; 253 this.width = image.width; 254 this.height = image.height; 255 this.maxWidth = image.maxWidth; 256 this.maxHeight = image.maxHeight; 257 this.optional = image.optional; 258 this.suppressWarnings = image.suppressWarnings; 259 this.additionalClassLoaders = image.additionalClassLoaders; 260 this.overlayInfo = image.overlayInfo; 261 } 262 263 /** 242 264 * Directories to look for the image. 243 265 * @param dirs The directories to look for. … … 384 406 this.maxWidth = maxSize.width; 385 407 this.maxHeight = maxSize.height; 408 return this; 409 } 410 411 /** 412 * Limit the maximum size of the image. 413 * 414 * It will shrink the image if necessary, but keep the aspect ratio. 415 * The given width or height can be -1 which means this direction is not bounded. 416 * 417 * This function sets value using the most restrictive of the new or existing set of 418 * values. 419 * 420 * @param maxSize maximum image size 421 * @return the current object, for convenience 422 * @see #setMaxSize(Dimension) 423 */ 424 public ImageProvider resetMaxSize(Dimension maxSize) { 425 if (this.maxWidth == -1 || maxSize.width < this.maxWidth) { 426 this.maxWidth = maxSize.width; 427 } 428 if (this.maxHeight == -1 || maxSize.height < this.maxHeight) { 429 this.maxHeight = maxSize.height; 430 } 386 431 return this; 387 432 }
Note:
See TracChangeset
for help on using the changeset viewer.