Changeset 5214 in josm
- Timestamp:
- 2012-05-06T12:44:35+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java
r5213 r5214 14 14 import org.openstreetmap.josm.data.osm.visitor.paint.MapPainter; 15 15 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors; 16 import org.openstreetmap.josm.gui.mappaint.mapcss.Instruction.RelativeFloat; 16 17 import org.openstreetmap.josm.tools.Utils; 17 18 … … 95 96 Cascade c = env.mc.getCascade(env.layer); 96 97 Cascade c_def = env.mc.getCascade("default"); 97 Float widthOnDefault = getWidth(c_def, "width", null); 98 Float width = getWidth(c, "width", widthOnDefault); 99 if (type != LineType.NORMAL) { 100 width = getWidth(c, type.prefix + "width", width); 98 Float width; 99 switch (type) { 100 case NORMAL: 101 { 102 Float widthOnDefault = getWidth(c_def, "width", null); 103 width = getWidth(c, "width", widthOnDefault); 104 break; 105 } 106 case CASING: 107 { 108 Float casingWidth = c.get(type.prefix + "width", null, Float.class, true); 109 if (casingWidth == null) { 110 RelativeFloat rel_casingWidth = c.get(type.prefix + "width", null, RelativeFloat.class, true); 111 if (rel_casingWidth != null) { 112 casingWidth = rel_casingWidth.val / 2; 113 } 114 } 115 if (casingWidth == null) 116 return null; 117 Float widthOnDefault = getWidth(c_def, "width", null); 118 width = getWidth(c, "width", widthOnDefault); 119 if (width == null) { 120 width = 0f; 121 } 122 width += 2 * casingWidth; 123 break; 124 } 125 case LEFT_CASING: 126 case RIGHT_CASING: 127 width = getWidth(c, type.prefix + "width", null); 128 break; 129 default: 130 throw new AssertionError(); 101 131 } 102 132 if (width == null) … … 120 150 } 121 151 122 Float offsetOnDefault = getWidth(c_def, "offset", null); 123 Float offset = getWidth(c, "offset", offsetOnDefault); 124 if (offset == null) { 125 offset = 0f; 126 } 127 if (type != LineType.NORMAL) { 128 /* pre-calculate an offset */ 129 Float base_offset = offset; 130 if (type == LineType.LEFT_CASING || type == LineType.RIGHT_CASING) { 131 Float base_width = getWidth(c, "width", widthOnDefault); 132 if (base_width == null || base_width < 2f) { 133 base_width = 2f; 134 } 135 offset = base_width/2 + width/2; 136 } else { 137 offset = 0f; 138 } 139 /* overwrites (e.g. "4") or adjusts (e.g. "+4") a prefixed -offset */ 140 if (getWidth(c, type.prefix + "offset", offset) != null) { 141 offset = getWidth(c, type.prefix + "offset", offset); 142 } 143 /* flip sign for the right-casing-offset */ 144 if (type == LineType.RIGHT_CASING) { 145 offset *= -1f; 146 } 147 /* use base_offset as the reference center */ 148 offset += base_offset; 152 Float offset = c.get("offset", 0f, Float.class); 153 switch (type) { 154 case NORMAL: 155 break; 156 case CASING: 157 offset += c.get(type.prefix + "offset", 0f, Float.class); 158 break; 159 case LEFT_CASING: 160 case RIGHT_CASING: 161 { 162 Float baseWidthOnDefault = getWidth(c_def, "width", null); 163 Float baseWidth = getWidth(c, "width", baseWidthOnDefault); 164 if (baseWidth == null || baseWidth < 2f) { 165 baseWidth = 2f; 166 } 167 float casingOffset = c.get(type.prefix + "offset", 0f, Float.class); 168 casingOffset += baseWidth / 2 + width / 2; 169 /* flip sign for the right-casing-offset */ 170 if (type == LineType.RIGHT_CASING) { 171 casingOffset *= -1f; 172 } 173 offset += casingOffset; 174 break; 175 } 149 176 } 150 177
Note:
See TracChangeset
for help on using the changeset viewer.