Changeset 4006 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2011-03-26T19:34:21+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/mappaint
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyle.java
r4005 r4006 34 34 35 35 public abstract void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, MapPainter painter, boolean selected, boolean member); 36 37 public boolean isProperLineStyle() { 38 return false; 39 } 36 40 37 41 /** -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r3903 r4006 64 64 } 65 65 } else if (osm instanceof Way) { 66 boolean has NonModifierLine = false;66 boolean hasProperLineStyle = false; 67 67 for (ElemStyle s : p.a) { 68 if (s instanceof LineElemStyle && !s.isModifier) {69 has NonModifierLine = true;68 if (s.isProperLineStyle()) { 69 hasProperLineStyle = true; 70 70 break; 71 71 } 72 72 } 73 if (!has NonModifierLine) {73 if (!hasProperLineStyle) { 74 74 AreaElemStyle area = Utils.find(p.a, AreaElemStyle.class); 75 75 LineElemStyle line = (area == null ? LineElemStyle.UNTAGGED_WAY : LineElemStyle.createSimpleLineStyle(area.color)); … … 92 92 93 93 boolean isOuterWayOfSomeMP = false; 94 boolean hasIndependentLineElemStyle = false;95 94 Color wayColor = null; 96 95 … … 104 103 105 104 if (multipolygon.getOuterWays().contains(osm)) { 105 boolean hasIndependentLineStyle = false; 106 106 if (!isOuterWayOfSomeMP) { // do this only one time 107 107 List<ElemStyle> tmp = new ArrayList<ElemStyle>(p.a.size()); … … 111 111 } else { 112 112 tmp.add(s); 113 if (s.isProperLineStyle()) { 114 hasIndependentLineStyle = true; 115 } 113 116 } 114 117 } 115 118 p.a = new StyleList(tmp); 116 119 isOuterWayOfSomeMP = true; 117 hasIndependentLineElemStyle = Utils.exists(p.a, LineElemStyle.class); 118 } 119 120 if (!hasIndependentLineElemStyle) { 120 } 121 122 if (!hasIndependentLineStyle) { 121 123 Pair<StyleList, Range> mpElemStyles = getStyleCacheWithRange(r, scale, nc); 122 LineElemStyle mpLine = Utils.find(mpElemStyles.a, LineElemStyle.class); 124 ElemStyle mpLine = null; 125 for (ElemStyle s : mpElemStyles.a) { 126 if (s.isProperLineStyle()) { 127 mpLine = s; 128 break; 129 } 130 } 123 131 if (mpLine != null) { 124 125 126 132 p.a = new StyleList(p.a, mpLine); 133 p.b = Range.cut(p.b, mpElemStyles.b); 134 break; 127 135 } else if (wayColor == null) { 128 136 AreaElemStyle mpArea = Utils.find(mpElemStyles.a, AreaElemStyle.class); … … 136 144 } 137 145 if (isOuterWayOfSomeMP) { 138 if (!Utils.exists(p.a, LineElemStyle.class)) { 146 boolean hasLineStyle = false; 147 for (ElemStyle s : p.a) { 148 if (s.isProperLineStyle()) { 149 hasLineStyle = true; 150 break; 151 } 152 } 153 if (!hasLineStyle) { 139 154 p.a = new StyleList(p.a, LineElemStyle.createSimpleLineStyle(wayColor)); 140 155 } … … 155 170 boolean hasIndependentElemStyle = false; 156 171 for (ElemStyle s : p.a) { 157 if (s instanceof LineElemStyle|| s instanceof AreaElemStyle) {172 if (s.isProperLineStyle() || s instanceof AreaElemStyle) { 158 173 hasIndependentElemStyle = true; 159 174 } … … 226 241 if (osm instanceof Way) { 227 242 addIfNotNull(sl, AreaElemStyle.create(c)); 243 addIfNotNull(sl, LinePatternElemStyle.create(env)); 228 244 addIfNotNull(sl, LineElemStyle.createLine(env)); 229 245 addIfNotNull(sl, LineElemStyle.createCasing(env)); 246 addIfNotNull(sl, LineTextElemStyle.create(env)); 230 247 } else if (osm instanceof Node) { 231 248 addIfNotNull(sl, NodeElemStyle.create(env)); … … 233 250 if (((Relation)osm).isMultipolygon()) { 234 251 addIfNotNull(sl, AreaElemStyle.create(c)); 252 addIfNotNull(sl, LinePatternElemStyle.create(env)); 235 253 addIfNotNull(sl, LineElemStyle.createLine(env)); 236 254 addIfNotNull(sl, LineElemStyle.createCasing(env)); 255 addIfNotNull(sl, LineTextElemStyle.create(env)); 237 256 } else if ("restriction".equals(osm.get("type"))) { 238 257 addIfNotNull(sl, NodeElemStyle.create(env)); -
trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java
r4005 r4006 30 30 public Color color; 31 31 public Color dashesBackground; 32 public TextElement text;33 32 public float realWidth; // the real width of this line in meter 34 33 35 34 private BasicStroke dashesLine; 36 35 37 protected LineElemStyle(Cascade c, BasicStroke line, Color color, BasicStroke dashesLine, Color dashesBackground, TextElement text,float realWidth) {36 protected LineElemStyle(Cascade c, BasicStroke line, Color color, BasicStroke dashesLine, Color dashesBackground, float realWidth) { 38 37 super(c, 0f); 39 38 this.line = line; … … 41 40 this.dashesLine = dashesLine; 42 41 this.dashesBackground = dashesBackground; 43 this.text = text;44 42 this.realWidth = realWidth; 45 43 } … … 181 179 } 182 180 183 TextElement text = null; 184 if (!casing) { 185 Keyword textPos = c.get("text-position", null, Keyword.class); 186 if (textPos == null || equal(textPos.val, "line")) { 187 text = TextElement.create(c, PaintColors.TEXT.get(), false); 188 } 189 } 190 191 return new LineElemStyle(c, line, color, dashesLine, dashesBackground, text, realWidth); 181 return new LineElemStyle(c, line, color, dashesLine, dashesBackground, realWidth); 192 182 } 193 183 … … 235 225 } 236 226 237 painter.drawWay(w, myColor, myLine, myDashLine, myDashedColor, text,showOrientation,227 painter.drawWay(w, myColor, myLine, myDashLine, myDashedColor, showOrientation, 238 228 showOnlyHeadArrowOnly, showOneway, onewayReversed); 239 229 … … 252 242 253 243 @Override 244 public boolean isProperLineStyle() { 245 return !isModifier; 246 } 247 248 @Override 254 249 public boolean equals(Object obj) { 255 250 if (obj == null || getClass() != obj.getClass()) … … 259 254 final LineElemStyle other = (LineElemStyle) obj; 260 255 return equal(line, other.line) && 261 equal(color, other.color) && 262 equal(dashesLine, other.dashesLine) && 263 equal(dashesBackground, other.dashesBackground) && 264 equal(text, other.text) && 265 realWidth == other.realWidth; 256 equal(color, other.color) && 257 equal(dashesLine, other.dashesLine) && 258 equal(dashesBackground, other.dashesBackground) && 259 realWidth == other.realWidth; 266 260 } 267 261 … … 273 267 hash = 29 * hash + (dashesLine != null ? dashesLine.hashCode() : 0); 274 268 hash = 29 * hash + (dashesBackground != null ? dashesBackground.hashCode() : 0); 275 hash = 29 * hash + (text != null ? text.hashCode() : 0);276 269 hash = 29 * hash + Float.floatToIntBits(realWidth); 277 270 return hash; … … 281 274 public String toString() { 282 275 return "LineElemStyle{" + super.toString() + "width=" + line.getLineWidth() + 283 " realWidth=" + realWidth + " color=" + Utils.toString(color) +284 " dashed=" + Arrays.toString(line.getDashArray()) +285 (line.getDashPhase() == 0f ? "" : " dashesOffses=" + line.getDashPhase()) +286 " dashedColor=" + Utils.toString(dashesBackground) + '}';276 " realWidth=" + realWidth + " color=" + Utils.toString(color) + 277 " dashed=" + Arrays.toString(line.getDashArray()) + 278 (line.getDashPhase() == 0f ? "" : " dashesOffses=" + line.getDashPhase()) + 279 " dashedColor=" + Utils.toString(dashesBackground) + '}'; 287 280 } 288 281 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Instruction.java
r3893 r4006 40 40 public void execute(Environment env) { 41 41 Object value = (val instanceof Expression) ? ((Expression) val).evaluate(env) : val; 42 if (key.equals("icon-image") || key.equals("fill-image") ) {42 if (key.equals("icon-image") || key.equals("fill-image") || key.equals("pattern-image")) { 43 43 if (value instanceof String) { 44 44 value = new IconReference((String) value, env.source);
Note:
See TracChangeset
for help on using the changeset viewer.