Changeset 4712 in josm for trunk/src/org/openstreetmap/josm/tools/ImageRequest.java
- Timestamp:
- 2011-12-26T15:13:52+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ImageRequest.java
r4271 r4712 27 27 protected int width = -1; 28 28 protected int height = -1; 29 protected int maxWidth = -1; 30 protected int maxHeight = -1; 29 31 protected boolean sanitize; 30 32 protected boolean required = true; … … 65 67 } 66 68 69 public ImageRequest setMaxWidth(int maxWidth) { 70 this.maxWidth = maxWidth; 71 return this; 72 } 73 74 public ImageRequest setMaxHeight(int maxHeight) { 75 this.maxHeight = maxHeight; 76 return this; 77 } 78 67 79 public ImageRequest setSanitize(boolean sanitize) { 68 80 this.sanitize = sanitize; … … 76 88 77 89 public ImageIcon get() { 78 ImageIcon icon = ImageProvider.getIfAvailable(dirs, id, subdir, name, archive, new Dimension(width, height), sanitize); 79 if (required && icon == null) { 80 String ext = name.indexOf('.') != -1 ? "" : ".???"; 81 throw new NullPointerException(tr("Fatal: failed to locate image ''{0}''. This is a serious configuration problem. JOSM will stop working.", name + ext)); 90 ImageResource ir = ImageProvider.getIfAvailableImpl(dirs, id, subdir, name, archive); 91 if (ir == null) { 92 if (required) { 93 String ext = name.indexOf('.') != -1 ? "" : ".???"; 94 throw new RuntimeException(tr("Fatal: failed to locate image ''{0}''. This is a serious configuration problem. JOSM will stop working.", name + ext)); 95 } else 96 return null; 82 97 } 83 return icon; 98 if (maxWidth != -1 || maxHeight != -1) 99 return ir.getImageIconBounded(new Dimension(maxWidth, maxHeight), sanitize); 100 else 101 return ir.getImageIcon(new Dimension(width, height), sanitize); 84 102 } 85 103
Note:
See TracChangeset
for help on using the changeset viewer.
