Changeset 1814 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2009-07-19T19:04:49+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r1748 r1814 29 29 30 30 import org.openstreetmap.josm.Main; 31 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 31 32 import org.openstreetmap.josm.io.MirroredInputStream; 33 import static org.openstreetmap.josm.tools.I18n.tr; 32 34 33 35 /** … … 95 97 { 96 98 MirroredInputStream is = new MirroredInputStream(name, 97 new File(Main.pref.getPreferencesDir(), "images").toString());99 new File(Main.pref.getPreferencesDir(), "images").toString()); 98 100 if(is != null) 99 101 { 100 img = Toolkit.getDefaultToolkit().createImage(is.getFile().toURI().toURL());101 cache.put(name, img);102 img = Toolkit.getDefaultToolkit().createImage(is.getFile().toURI().toURL()); 103 cache.put(name, img); 102 104 } 103 105 } … … 107 109 return img == null ? null : new ImageIcon(img); 108 110 } 109 if (subdir == null) 111 if (subdir == null) { 110 112 subdir = ""; 111 else if (!subdir.equals(""))113 } else if (!subdir.equals("")) { 112 114 subdir += "/"; 115 } 113 116 String ext = name.indexOf('.') != -1 ? "" : ".png"; 114 117 String full_name = subdir+name+ext; 115 118 String cache_name = full_name; 116 119 /* cache separately */ 117 if(dirs != null && dirs.size() > 0) 120 if(dirs != null && dirs.size() > 0) { 118 121 cache_name = "id:"+id+":"+full_name; 122 } 119 123 120 124 Image img = cache.get(cache_name); … … 198 202 public static Cursor getCursor(String name, String overlay) { 199 203 ImageIcon img = get("cursor",name); 200 if (overlay != null) 204 if (overlay != null) { 201 205 img = overlay(img, "cursor/modifier/"+overlay, OverlayPosition.SOUTHEAST); 206 } 202 207 Cursor c = Toolkit.getDefaultToolkit().createCustomCursor(img.getImage(), 203 208 name.equals("crosshair") ? new Point(10,10) : new Point(3,2), "Cursor"); … … 251 256 } 252 257 253 /* from: http://www.jidesoft.com/blog/2008/02/29/rotate-an-icon-in-java/254 * License: "feel free to use"255 */256 final static double DEGREE_90 = 90.0 * Math.PI / 180.0;258 /* from: http://www.jidesoft.com/blog/2008/02/29/rotate-an-icon-in-java/ 259 * License: "feel free to use" 260 */ 261 final static double DEGREE_90 = 90.0 * Math.PI / 180.0; 257 262 258 263 /** … … 315 320 return new ImageIcon(image); 316 321 } 322 323 /** 324 * Replies the icon for an OSM primitive type 325 * @param type the type 326 * @return the icon 327 */ 328 public static ImageIcon get(OsmPrimitiveType type) throws IllegalArgumentException { 329 if (type == null) 330 throw new IllegalArgumentException(tr("parameter ''{0}'' must not be null", "type")); 331 return get("data",type.getAPIName()); 332 } 317 333 }
Note:
See TracChangeset
for help on using the changeset viewer.