Changeset 3858 in josm for trunk/src/org
- Timestamp:
- 2011-02-05T18:28:47+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintSettings.java
r3691 r3858 108 108 } 109 109 110 public Color getSelectedColor(int alpha) { 111 return new Color(selectedColor.getRGB() & 0x00ffffff | (alpha << 24), true); 112 } 113 110 114 public Color getRelationSelectedColor() { 111 115 return relationSelectedColor; 112 116 } 113 117 118 public Color getRelationSelectedColor(int alpha) { 119 return new Color(relationSelectedColor.getRGB() & 0x00ffffff | (alpha << 24), true); 120 } 121 114 122 public Color getHighlightColor() { 115 123 return highlightColor; -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPainter.java
r3841 r3858 277 277 protected void drawArea(Polygon polygon, Color color, String name) { 278 278 279 /* set the opacity (alpha) level of the filled polygon */ 280 g.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), fillAlpha)); 279 g.setColor(color); 281 280 282 281 if (outlineOnly) { -
trunk/src/org/openstreetmap/josm/gui/mappaint/AreaElemStyle.java
r3856 r3858 4 4 import java.awt.Color; 5 5 6 import org.openstreetmap.josm.Main; 6 7 import org.openstreetmap.josm.data.osm.OsmPrimitive; 7 8 import org.openstreetmap.josm.data.osm.Relation; … … 24 25 if (color == null) 25 26 return null; 27 int alpha = Math.min(255, Math.max(0, Integer.valueOf(Main.pref.getInteger("mappaint.fillalpha", 50)))); 28 Integer pAlpha = color_float2int(c.get("fill-opacity", null, float.class)); 29 if (pAlpha != null) { 30 alpha = pAlpha; 31 } 32 color = new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha); 26 33 return new AreaElemStyle(c, color); 27 34 } 28 35 29 36 @Override 30 public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, MapPainter painter, boolean selected, boolean member) { 31 if (primitive instanceof Way) { 32 Way w = (Way) primitive; 33 String name = painter.isShowNames() ? painter.getAreaName(w) : null; 34 painter.drawArea(w, w.isSelected() ? paintSettings.getSelectedColor() : color, name); 35 } else if (primitive instanceof Relation) { 36 painter.drawArea((Relation) primitive, selected ? paintSettings.getRelationSelectedColor() : color, painter.getAreaName(primitive)); 37 public void paintPrimitive(OsmPrimitive osm, MapPaintSettings paintSettings, MapPainter painter, boolean selected, boolean member) { 38 if (osm instanceof Way) 39 { 40 painter.drawArea((Way) osm, 41 osm.isSelected() ? paintSettings.getSelectedColor(color.getAlpha()) : color, 42 painter.isShowNames() ? painter.getAreaName(osm) : null); 43 } else if (osm instanceof Relation) 44 { 45 painter.drawArea((Relation) osm, 46 selected ? paintSettings.getRelationSelectedColor(color.getAlpha()) : color, 47 painter.getAreaName(osm)); 37 48 } 38 49 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java
r3856 r3858 160 160 if (val instanceof float[]) { 161 161 res.append(Arrays.toString((float[]) val)); 162 } else if (val instanceof Color) { 163 res.append(String.format("#%x", ((Color) val).getRGB())); 162 164 } else { 163 165 res.append(val+""); -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyle.java
r3856 r3858 45 45 return ""; 46 46 } 47 48 public static Integer color_float2int(Float val) { 49 if (val == null || val < 0 || val > 1) 50 return null; 51 return (int) (255f * val + 0.5f); 52 } 53 54 public static Float color_int2float(Integer val) { 55 if (val == null || val < 0 || val > 255) 56 return null; 57 return ((float) val) / 255f; 58 } 47 59 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java
r3856 r3858 60 60 color = PaintColors.UNTAGGED.get(); 61 61 } 62 63 int alpha = 255; 64 Integer pAlpha = color_float2int(c.get("opacity", null, float.class)); 65 if (pAlpha != null) { 66 alpha = pAlpha; 67 } 68 color = new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha); 69 62 70 float[] dashes = c.get(prefix + "dashes", null, float[].class); 63 71 if (dashes != null) { … … 124 132 markColor = paintSettings.getHighlightColor(); 125 133 } else if (selected) { 126 markColor = paintSettings.getSelectedColor( );134 markColor = paintSettings.getSelectedColor(color.getAlpha()); 127 135 } else if (member) { 128 markColor = paintSettings.getRelationSelectedColor( );136 markColor = paintSettings.getRelationSelectedColor(color.getAlpha()); 129 137 } else if(w.isDisabled()) { 130 138 markColor = paintSettings.getInactiveColor(); -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r3855 r3858 47 47 48 48 public String iconName; 49 public XmlStyleSource source;50 51 public IconReference(String iconName, XmlStyleSource source) {49 public StyleSource source; 50 51 public IconReference(String iconName, StyleSource source) { 52 52 this.iconName = iconName; 53 53 this.source = source; 54 } 55 56 @Override 57 public String toString() { 58 return "IconReference{" + "iconName=" + iconName + " source=" + source.getDisplayString() + '}'; 54 59 } 55 60 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Environment.java
r3848 r3858 5 5 import org.openstreetmap.josm.gui.mappaint.Cascade; 6 6 import org.openstreetmap.josm.gui.mappaint.MultiCascade; 7 import org.openstreetmap.josm.gui.mappaint.StyleSource; 7 8 8 9 public class Environment { … … 11 12 MultiCascade mc; 12 13 String layer; 14 StyleSource source; 13 15 14 public Environment(OsmPrimitive osm, MultiCascade mc, String layer ) {16 public Environment(OsmPrimitive osm, MultiCascade mc, String layer, StyleSource source) { 15 17 this.osm = osm; 16 18 this.mc = mc; 17 19 this.layer = layer; 20 this.source = source; 18 21 } 19 22 -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Instruction.java
r3848 r3858 3 3 4 4 import java.util.Arrays; 5 6 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference; 5 7 6 8 abstract public class Instruction { … … 32 34 @Override 33 35 public void execute(Environment env) { 34 if (val instanceof Expression) { 35 env.getCascade().putOrClear(key, ((Expression) val).evaluate(env)); 36 } else { 37 env.getCascade().putOrClear(key, val); 36 Object value = (val instanceof Expression) ? ((Expression) val).evaluate(env) : val; 37 if (key.equals("icon-image")) { 38 if (value instanceof String) { 39 value = new IconReference((String) value, env.source); 40 } 38 41 } 42 env.getCascade().putOrClear(key, value); 39 43 } 40 44 -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java
r3856 r3858 80 80 n.put("lang", code); 81 81 // create a fake environment to read the meta data block 82 Environment env = new Environment(n, mc, "default" );82 Environment env = new Environment(n, mc, "default", this); 83 83 84 84 NEXT_RULE: … … 105 105 @Override 106 106 public void apply(MultiCascade mc, OsmPrimitive osm, double scale, OsmPrimitive multipolyOuterWay, boolean pretendWayIsClosed) { 107 Environment env = new Environment(osm, mc, null );107 Environment env = new Environment(osm, mc, null, this); 108 108 for (MapCSSRule r : rules) { 109 109 for (Selector s : r.selectors) { -
trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSource.java
r3856 r3858 20 20 import org.openstreetmap.josm.data.osm.Way; 21 21 import org.openstreetmap.josm.gui.mappaint.Cascade; 22 import org.openstreetmap.josm.gui.mappaint.ElemStyle; 22 23 import org.openstreetmap.josm.gui.mappaint.MultiCascade; 23 24 import org.openstreetmap.josm.gui.mappaint.Range; … … 300 301 def.putOrClear("real-width", p.line.realWidth != null ? new Float(p.line.realWidth) : null); 301 302 def.putOrClear("color", p.line.color); 303 if (p.line.color != null) { 304 int alpha = p.line.color.getAlpha(); 305 if (alpha != 255) { 306 def.put("opacity", ElemStyle.color_int2float(alpha)); 307 } 308 } 302 309 def.putOrClear("dashes", p.line.getDashed()); 303 310 def.putOrClear("dashes-background-color", p.line.dashedColor); … … 323 330 c.put("width", new Float(mod.getWidth(refWidth))); 324 331 c.putOrClear("color", mod.color); 332 if (mod.color != null) { 333 int alpha = mod.color.getAlpha(); 334 if (alpha != 255) { 335 c.put("opacity", ElemStyle.color_int2float(alpha)); 336 } 337 } 325 338 c.putOrClear("dashes", mod.getDashed()); 326 339 c.putOrClear("dashes-background-color", mod.dashedColor);
Note:
See TracChangeset
for help on using the changeset viewer.