Changeset 5811 in josm
- Timestamp:
- 2013-03-29T12:21:07+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/mappaint
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/NodeElemStyle.java
r5571 r5811 24 24 * applies for Nodes and turn restriction relations 25 25 */ 26 public class NodeElemStyle extends ElemStyle {26 public class NodeElemStyle extends ElemStyle implements StyleKeys { 27 27 public MapImage mapImage; 28 28 public Symbol symbol; … … 104 104 Cascade c = env.mc.getCascade(env.layer); 105 105 106 MapImage mapImage = createIcon(env );106 MapImage mapImage = createIcon(env, ICON_KEYS); 107 107 Symbol symbol = null; 108 108 if (mapImage == null) { … … 118 118 } 119 119 120 p rivate static MapImage createIcon(Environment env) {120 public static MapImage createIcon(Environment env, String[] keys) { 121 121 Cascade c = env.mc.getCascade(env.layer); 122 Cascade c_def = env.mc.getCascade("default"); 123 124 final IconReference iconRef = c.get(ICON_IMAGE, null, IconReference.class); 122 123 final IconReference iconRef = c.get(keys[ICON_IMAGE_IDX], null, IconReference.class); 125 124 if (iconRef == null) 126 125 return null; 127 126 128 Float widthOnDefault = c_def.get("icon-width", null, Float.class); 127 Cascade c_def = env.mc.getCascade("default"); 128 129 Float widthOnDefault = c_def.get(keys[ICON_WIDTH_IDX], null, Float.class); 129 130 if (widthOnDefault != null && widthOnDefault <= 0) { 130 131 widthOnDefault = null; 131 132 } 132 Float widthF = getWidth(c, "icon-width", widthOnDefault);133 134 Float heightOnDefault = c_def.get( "icon-height", null, Float.class);133 Float widthF = getWidth(c, keys[ICON_WIDTH_IDX], widthOnDefault); 134 135 Float heightOnDefault = c_def.get(keys[ICON_HEIGHT_IDX], null, Float.class); 135 136 if (heightOnDefault != null && heightOnDefault <= 0) { 136 137 heightOnDefault = null; 137 138 } 138 Float heightF = getWidth(c, "icon-height", heightOnDefault);139 Float heightF = getWidth(c, keys[ICON_HEIGHT_IDX], heightOnDefault); 139 140 140 141 int width = widthF == null ? -1 : Math.round(widthF); … … 147 148 148 149 mapImage.alpha = Math.min(255, Math.max(0, Integer.valueOf(Main.pref.getInteger("mappaint.icon-image-alpha", 255)))); 149 Integer pAlpha = Utils.color_float2int(c.get( "icon-opacity", null, float.class));150 Integer pAlpha = Utils.color_float2int(c.get(keys[ICON_OPACITY_IDX], null, float.class)); 150 151 if (pAlpha != null) { 151 152 mapImage.alpha = pAlpha; -
trunk/src/org/openstreetmap/josm/gui/mappaint/RepeatImageElemStyle.java
r5801 r5811 8 8 import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings; 9 9 import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer; 10 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference;11 10 import org.openstreetmap.josm.tools.CheckParameterUtil; 12 11 … … 31 30 32 31 public static RepeatImageElemStyle create(Environment env) { 33 // FIXME: make use of NodeElemStyle.createIcon, in order to have 34 // -width, -height and -opacity properties. 32 MapImage pattern = NodeElemStyle.createIcon(env, REPEAT_IMAGE_KEYS); 33 if (pattern == null) 34 return null; 35 35 Cascade c = env.mc.getCascade(env.layer); 36 37 IconReference iconRef = c.get(REPEAT_IMAGE, null, IconReference.class);38 if (iconRef == null)39 return null;40 MapImage pattern = new MapImage(iconRef.iconName, iconRef.source);41 36 Float offset = c.get(REPEAT_IMAGE_OFFSET, 0f, Float.class); 42 37 Float spacing = c.get(REPEAT_IMAGE_SPACING, 0f, Float.class); -
trunk/src/org/openstreetmap/josm/gui/mappaint/StyleKeys.java
r5801 r5811 26 26 String REPEAT_IMAGE_SPACING = "repeat-image-spacing"; 27 27 String REPEAT_IMAGE_ALIGN = "repeat-image-align"; 28 29 int ICON_IMAGE_IDX = 0; 30 int ICON_WIDTH_IDX = 1; 31 int ICON_HEIGHT_IDX = 2; 32 int ICON_OPACITY_IDX = 3; 33 String[] ICON_KEYS = {"icon-image", "icon-width", "icon-height", "icon-opacity"}; 34 String[] REPEAT_IMAGE_KEYS = {"repeat-image", "repeat-image-width", "repeat-image-height", "repeat-image-opacity"}; 28 35 }
Note:
See TracChangeset
for help on using the changeset viewer.