Changeset 5206 in josm for trunk/src/org
- Timestamp:
- 2012-04-29T22:23:26+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPainter.java
r5054 r5206 127 127 * @param onewayReversed for oneway=-1 and similar 128 128 */ 129 public void drawWay(Way way, Color color, BasicStroke line, BasicStroke dashes, Color dashedColor, int offset,129 public void drawWay(Way way, Color color, BasicStroke line, BasicStroke dashes, Color dashedColor, float offset, 130 130 boolean showOrientation, boolean showHeadArrowOnly, 131 131 boolean showOneway, boolean onewayReversed) { … … 259 259 260 260 private List<Node> nodes; 261 private int offset;261 private float offset; 262 262 private int idx; 263 263 … … 269 269 private int x_prev0, y_prev0; 270 270 271 public OffsetIterator(List<Node> nodes, int offset) {271 public OffsetIterator(List<Node> nodes, float offset) { 272 272 this.nodes = nodes; 273 273 this.offset = offset; … … 282 282 @Override 283 283 public Point next() { 284 if ( offset == 0) return nc.getPoint(nodes.get(idx++));284 if (Math.abs(offset) < 0.1f) return nc.getPoint(nodes.get(idx++)); 285 285 286 286 Point current = nc.getPoint(nodes.get(idx)); … … 861 861 if ((pb.width >= nb.getWidth() && pb.height >= nb.getHeight()) && // quick check 862 862 area.contains(centeredNBounds) // slow but nice 863 863 ) { 864 864 g.setColor(text.color); 865 865 Font defaultFont = g.getFont(); -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r5054 r5206 311 311 addIfNotNull(sl, LinePatternElemStyle.create(env)); 312 312 addIfNotNull(sl, LineElemStyle.createLine(env)); 313 addIfNotNull(sl, LineElemStyle.createLeftCasing(env)); 314 addIfNotNull(sl, LineElemStyle.createRightCasing(env)); 313 315 addIfNotNull(sl, LineElemStyle.createCasing(env)); 314 316 addIfNotNull(sl, LineTextElemStyle.create(env)); … … 347 349 */ 348 350 private boolean isDefaultNodes() { 349 if (defaultNodesIdx == cacheIdx) {351 if (defaultNodesIdx == cacheIdx) 350 352 return defaultNodes; 351 }352 353 defaultNodes = fromCanvas("default-points", true, Boolean.class); 353 354 defaultNodesIdx = cacheIdx; … … 359 360 */ 360 361 private boolean isDefaultLines() { 361 if (defaultLinesIdx == cacheIdx) {362 if (defaultLinesIdx == cacheIdx) 362 363 return defaultLines; 363 }364 364 defaultLines = fromCanvas("default-lines", true, Boolean.class); 365 365 defaultLinesIdx = cacheIdx; … … 420 420 */ 421 421 public static AreaElemStyle getAreaElemStyle(OsmPrimitive p, boolean pretendWayIsClosed) { 422 if (MapPaintStyles.getStyles() == null) {422 if (MapPaintStyles.getStyles() == null) 423 423 return null; 424 }425 424 for (ElemStyle s : MapPaintStyles.getStyles().generateStyles(p, 1.0, null, pretendWayIsClosed).a) { 426 if (s instanceof AreaElemStyle) {425 if (s instanceof AreaElemStyle) 427 426 return (AreaElemStyle) s; 428 }429 427 } 430 428 return null; -
trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java
r4871 r5206 33 33 public Color color; 34 34 public Color dashesBackground; 35 public int offset;35 public float offset; 36 36 public float realWidth; // the real width of this line in meter 37 37 38 38 private BasicStroke dashesLine; 39 39 40 protected LineElemStyle(Cascade c, BasicStroke line, Color color, BasicStroke dashesLine, Color dashesBackground, int offset, float realWidth) {40 protected LineElemStyle(Cascade c, BasicStroke line, Color color, BasicStroke dashesLine, Color dashesBackground, float offset, float realWidth) { 41 41 super(c, 0f); 42 42 this.line = line; … … 49 49 50 50 public static LineElemStyle createLine(Environment env) { 51 return createImpl(env, false); 51 return createImpl(env, ""); 52 } 53 54 public static LineElemStyle createLeftCasing(Environment env) { 55 LineElemStyle leftCasing = createImpl(env, "left-casing-"); 56 if (leftCasing != null) { 57 leftCasing.z_index += -90; 58 leftCasing.isModifier = true; 59 } 60 return leftCasing; 61 } 62 63 public static LineElemStyle createRightCasing(Environment env) { 64 LineElemStyle rightCasing = createImpl(env, "right-casing-"); 65 if (rightCasing != null) { 66 rightCasing.z_index += -90; 67 rightCasing.isModifier = true; 68 } 69 return rightCasing; 52 70 } 53 71 54 72 public static LineElemStyle createCasing(Environment env) { 55 LineElemStyle casing = createImpl(env, true);73 LineElemStyle casing = createImpl(env, "casing-"); 56 74 if (casing != null) { 57 75 casing.z_index += -100; … … 61 79 } 62 80 63 private static LineElemStyle createImpl(Environment env, boolean casing) {81 private static LineElemStyle createImpl(Environment env, String prefix) { 64 82 Cascade c = env.mc.getCascade(env.layer); 65 83 Cascade c_def = env.mc.getCascade("default"); 66 84 67 String prefix = casing ? "casing-" : ""; 68 69 Float width; 70 if (casing) { 71 Float widthOnDefault = getWidth(c_def, "width", null); 72 Float widthLine = getWidth(c, "width", widthOnDefault); 73 width = getWidth(c, "casing-width", widthLine); 74 } else { 75 Float widthOnDefault = getWidth(c_def, "width", null); 76 width = getWidth(c, "width", widthOnDefault); 77 } 78 85 Float widthOnDefault = getWidth(c_def, "width", null); 86 Float width = getWidth(c, "width", widthOnDefault); 87 if (!prefix.isEmpty()) { 88 width = getWidth(c, prefix + "width", width); 89 } 79 90 if (width == null) 80 91 return null; … … 97 108 } 98 109 110 Float offsetOnDefault = getWidth(c_def, "offset", null); 111 Float offset = getWidth(c, "offset", offsetOnDefault); 112 if (offset == null) { 113 offset = 0f; 114 } 115 if (!prefix.isEmpty()) { 116 Float base_width = getWidth(c, "width", widthOnDefault); 117 Float base_offset = offset; 118 if (base_width == null || base_width < 2f) { 119 base_width = 2f; 120 } 121 /* pre-calculate an offset */ 122 if (prefix.startsWith("left") || prefix.startsWith("right")) { 123 offset = base_width/2 + width/2; 124 } else { 125 offset = 0f; 126 } 127 /* overwrites (e.g. "4") or adjusts (e.g. "+4") a prefixed -offset */ 128 if (getWidth(c, prefix + "offset", offset) != null) { 129 offset = getWidth(c, prefix + "offset", offset); 130 } 131 /* flip sign for the right-casing-offset */ 132 if (prefix.startsWith("right")) { 133 offset *= -1f; 134 } 135 /* use base_offset as the reference center */ 136 offset += base_offset; 137 } 138 99 139 Color color = c.get(prefix + "color", null, Color.class); 100 if ( !casing&& color == null) {140 if (prefix.isEmpty() && color == null) { 101 141 color = c.get("fill-color", null, Color.class); 102 142 } … … 177 217 BasicStroke dashesLine = null; 178 218 179 float offset = c.get("offset", 0f, Float.class);180 181 219 if (dashes != null && dashesBackground != null) { 182 220 float[] dashes2 = new float[dashes.length]; … … 186 224 } 187 225 188 return new LineElemStyle(c, line, color, dashesLine, dashesBackground, (int)offset, realWidth);226 return new LineElemStyle(c, line, color, dashesLine, dashesBackground, offset, realWidth); 189 227 } 190 228 … … 273 311 hash = 29 * hash + (dashesLine != null ? dashesLine.hashCode() : 0); 274 312 hash = 29 * hash + (dashesBackground != null ? dashesBackground.hashCode() : 0); 275 hash = 29 * hash + offset;313 hash = 29 * hash + Float.floatToIntBits(offset); 276 314 hash = 29 * hash + Float.floatToIntBits(realWidth); 277 315 return hash; -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Expression.java
r4401 r5206 20 20 import org.openstreetmap.josm.gui.mappaint.Environment; 21 21 import org.openstreetmap.josm.tools.CheckParameterUtil; 22 import org.openstreetmap.josm.tools.ColorHelper; 22 23 import org.openstreetmap.josm.tools.Utils; 23 24 … … 114 115 } 115 116 return c; 117 } 118 119 public Color html2color(String html) { 120 return ColorHelper.html2color(html); 121 } 122 123 public String color2html(Color c) { 124 return ColorHelper.color2html(c); 116 125 } 117 126
Note:
See TracChangeset
for help on using the changeset viewer.