Changeset 4272 in josm for trunk/src/org
- Timestamp:
- 2011-07-27T23:50:06+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/AreaElemStyle.java
r4005 r4272 45 45 IconReference iconRef = c.get("fill-image", null, IconReference.class); 46 46 if (iconRef != null) { 47 ImageIcon icon = MapPaintStyles.getIcon(iconRef, false);47 ImageIcon icon = MapPaintStyles.getIcon(iconRef, -1, -1, false); 48 48 if (icon != null) { 49 49 if (!(icon.getImage() instanceof BufferedImage)) { 50 icon = MapPaintStyles.getIcon(iconRef, true);50 icon = MapPaintStyles.getIcon(iconRef, -1, -1, true); 51 51 } 52 52 if (!(icon.getImage() instanceof BufferedImage)) -
trunk/src/org/openstreetmap/josm/gui/mappaint/LinePatternElemStyle.java
r4006 r4272 28 28 if (iconRef == null) 29 29 return null; 30 ImageIcon icon = MapPaintStyles.getIcon(iconRef, false);30 ImageIcon icon = MapPaintStyles.getIcon(iconRef, -1, -1, false); 31 31 if (icon == null) 32 32 return null; -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r4172 r4272 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Dimension; 6 7 import java.io.IOException; 7 8 import java.io.InputStream; … … 63 64 } 64 65 66 /** 67 * IconReference is used to remember the associated style source for 68 * each icon URL. 69 * This is necessary because image URLs can be paths relative 70 * to the source file and we have cascading of properties from different 71 * source files. 72 */ 65 73 public static class IconReference { 66 74 … … 79 87 } 80 88 81 public static ImageIcon getIcon(IconReference ref, boolean sanitize) {82 String namespace = ref.source.getPrefName();83 ImageIcon i = ImageProvider.getIfAvailable(getIconSourceDirs(ref.source), "mappaint."+namespace, null, ref.iconName, ref.source.zipIcons, sanitize);89 public static ImageIcon getIcon(IconReference ref, int width, int height, boolean sanitize) { 90 final String namespace = ref.source.getPrefName(); 91 ImageIcon i = ImageProvider.getIfAvailable(getIconSourceDirs(ref.source), "mappaint."+namespace, null, ref.iconName, ref.source.zipIcons, width == -1 && height == -1 ? null : new Dimension(width, height), sanitize); 84 92 if(i == null) 85 93 { -
trunk/src/org/openstreetmap/josm/gui/mappaint/NodeElemStyle.java
r4191 r4272 6 6 import java.awt.BasicStroke; 7 7 import java.awt.Color; 8 import java.awt.Dimension; 8 9 import java.awt.Image; 9 10 import java.awt.Stroke; … … 221 222 return null; 222 223 223 ImageIcon icon = null; 224 int iconAlpha = 0; 225 226 icon = MapPaintStyles.getIcon(iconRef, false); 224 Float widthOnDefault = c_def.get("icon-width", null, Float.class); 225 if (widthOnDefault != null && widthOnDefault <= 0) { 226 widthOnDefault = null; 227 } 228 Float widthF = getWidth(c, "icon-width", widthOnDefault); 229 230 Float heightOnDefault = c_def.get("icon-height", null, Float.class); 231 if (heightOnDefault != null && heightOnDefault <= 0) { 232 heightOnDefault = null; 233 } 234 Float heightF = getWidth(c, "icon-height", heightOnDefault); 235 236 int width = widthF == null ? -1 : Math.round(widthF); 237 int height = heightF == null ? -1 : Math.round(heightF); 238 239 ImageIcon icon = MapPaintStyles.getIcon(iconRef, width, height, false); 227 240 if (icon == null) 228 241 return new Pair<ImageIcon, Integer>(MapPaintStyles.getNoIcon_Icon(iconRef.source, false), 255); 229 else { 230 Float sizeOnDefault = c_def.get("icon-size", null, Float.class); 231 if (sizeOnDefault != null && sizeOnDefault <= 0) { 232 sizeOnDefault = null; 233 } 234 Float sizeF = getWidth(c, "icon-size", sizeOnDefault); 235 236 if (sizeF != null) { 237 if (sizeF <= 0) 238 return null; 239 int size = Math.round(sizeF); 240 int width = icon.getIconWidth(); 241 int height = icon.getIconHeight(); 242 if (Math.max(width, height) != size) { 243 if (width >= height) { 244 width = size; 245 height = -1; 246 } else { 247 width = -1; 248 height = size; 249 } 250 icon.setImage(icon.getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH)); 251 } 252 } 253 iconAlpha = Math.min(255, Math.max(0, Integer.valueOf(Main.pref.getInteger("mappaint.icon-image-alpha", 255)))); 254 Integer pAlpha = Utils.color_float2int(c.get("icon-opacity", null, float.class)); 255 if (pAlpha != null) { 256 iconAlpha = pAlpha; 257 } 258 259 return new Pair<ImageIcon, Integer>(icon, iconAlpha); 260 } 242 int iconAlpha = Math.min(255, Math.max(0, Integer.valueOf(Main.pref.getInteger("mappaint.icon-image-alpha", 255)))); 243 Integer pAlpha = Utils.color_float2int(c.get("icon-opacity", null, float.class)); 244 if (pAlpha != null) { 245 iconAlpha = pAlpha; 246 } 247 248 return new Pair<ImageIcon, Integer>(icon, iconAlpha); 261 249 } 262 250 -
trunk/src/org/openstreetmap/josm/gui/mappaint/StyleSource.java
r3896 r4272 74 74 if (imageIcon == null) { 75 75 if (icon != null) { 76 imageIcon = MapPaintStyles.getIcon(new IconReference(icon, this), false);76 imageIcon = MapPaintStyles.getIcon(new IconReference(icon, this), -1, -1, false); 77 77 } 78 78 if (imageIcon == null) { -
trunk/src/org/openstreetmap/josm/tools/Pair.java
r3719 r4272 48 48 } 49 49 50 50 /* convenience constructor method */ 51 public static <U,V> Pair<U,V> create(U u, V v) { 52 return new Pair<U,V>(u,v); 53 } 51 54 } -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r4197 r4272 258 258 } 259 259 } 260 261 private final static double EPSILION = 1e-11; 262 263 public static boolean equalsEpsilon(double a, double b) { 264 return Math.abs(a - b) <= EPSILION; 265 } 260 266 }
Note:
See TracChangeset
for help on using the changeset viewer.