Changeset 5217 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2012-05-06T21:23:18+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r4327 r5217 28 28 /** 29 29 * <p>A map renderer which renders a map according to style rules in a set of style sheets.</p> 30 * 30 * 31 31 */ 32 32 public class StyledMapRenderer extends AbstractMapRenderer{ … … 39 39 private static int FLAG_NORMAL = 0; 40 40 private static int FLAG_DISABLED = 1; 41 private static int FLAG_ SELECTED = 2;42 private static int FLAG_ MEMBER_OF_SELECTED = 4;41 private static int FLAG_MEMBER_OF_SELECTED = 2; 42 private static int FLAG_SELECTED = 4; 43 43 44 44 private static class StyleRecord implements Comparable<StyleRecord> { … … 59 59 if ((this.flags & FLAG_DISABLED) == 0 && (other.flags & FLAG_DISABLED) != 0) 60 60 return 1; 61 float z_index1 = this.style.z_index; 62 if ((this.flags & FLAG_SELECTED) != 0) { 63 z_index1 += 700f; 64 } else if ((this.flags & FLAG_MEMBER_OF_SELECTED) != 0) { 65 z_index1 += 600f; 66 } 67 float z_index2 = other.style.z_index; 68 if ((other.flags & FLAG_SELECTED) != 0) { 69 z_index2 += 700f; 70 } else if ((other.flags & FLAG_MEMBER_OF_SELECTED) != 0) { 71 z_index2 += 600f; 72 } 73 74 int d1 = Float.compare(z_index1, z_index2); 75 if (d1 != 0) 76 return d1; 61 62 int d0 = Float.compare(this.style.major_z_index, other.style.major_z_index); 63 if (d0 != 0) 64 return d0; 65 66 // selected on top of member of selected on top of unselected 67 // FLAG_DISABLED bit is the same at this point 68 if (this.flags > other.flags) 69 return 1; 70 if (this.flags < other.flags) 71 return -1; 72 73 int dz = Float.compare(this.style.z_index, other.style.z_index); 74 if (dz != 0) 75 return dz; 77 76 78 77 // simple node on top of icons and shapes -
trunk/src/org/openstreetmap/josm/gui/mappaint/AreaElemStyle.java
r5054 r5217 28 28 29 29 protected AreaElemStyle(Cascade c, Color color, MapImage fillImage, TextElement text) { 30 super(c, -1000f);30 super(c, 1f); 31 31 CheckParameterUtil.ensureParameterNotNull(color); 32 32 this.color = color; -
trunk/src/org/openstreetmap/josm/gui/mappaint/BoxTextElemStyle.java
r5054 r5217 90 90 91 91 public BoxTextElemStyle(Cascade c, TextElement text, BoxProvider boxProvider, Rectangle box, HorizontalTextAlignment hAlign, VerticalTextAlignment vAlign) { 92 super(c, 2000f);92 super(c, 5f); 93 93 CheckParameterUtil.ensureParameterNotNull(text); 94 94 CheckParameterUtil.ensureParameterNotNull(hAlign); … … 197 197 if (boxProvider != null) { 198 198 if (!boxProvider.equals(other.boxProvider)) return false; 199 } else if (other.boxProvider != null) {199 } else if (other.boxProvider != null) 200 200 return false; 201 }else {201 else { 202 202 if (!box.equals(other.box)) return false; 203 203 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyle.java
r4040 r5217 16 16 abstract public class ElemStyle { 17 17 18 public float major_z_index; 18 19 public float z_index; 19 20 public float object_z_index; … … 21 22 // primitive; true, if it is a highlight or modifier 22 23 23 public ElemStyle(float z_index, float object_z_index, boolean isModifier) { 24 public ElemStyle(float major_z_index, float z_index, float object_z_index, boolean isModifier) { 25 this.major_z_index = major_z_index; 24 26 this.z_index = z_index; 25 27 this.object_z_index = object_z_index; … … 27 29 } 28 30 29 protected ElemStyle(Cascade c, float default_z_index) { 30 z_index = c.get("z-index", default_z_index, Float.class); 31 protected ElemStyle(Cascade c, float default_major_z_index) { 32 major_z_index = c.get("major-z-index", default_major_z_index, Float.class); 33 z_index = c.get("z-index", 0f, Float.class); 31 34 object_z_index = c.get("object-z-index", 0f, Float.class); 32 35 isModifier = c.get("modifier", false, Boolean.class); … … 81 84 * expensive lookups and to avoid too many font objects 82 85 * (in analogy to flyweight pattern). 83 * 86 * 84 87 * FIXME: cached preference values are not updated if the user changes them during 85 88 * a JOSM session. Should have a listener listening to preference changes. … … 170 173 return false; 171 174 ElemStyle s = (ElemStyle) o; 172 return z_index == s.z_index && object_z_index == s.object_z_index && isModifier == s.isModifier; 175 return major_z_index == s.major_z_index && 176 z_index == s.z_index && 177 object_z_index == s.object_z_index && 178 isModifier == s.isModifier; 173 179 } 174 180 … … 176 182 public int hashCode() { 177 183 int hash = 5; 184 hash = 41 * hash + Float.floatToIntBits(this.major_z_index); 178 185 hash = 41 * hash + Float.floatToIntBits(this.z_index); 179 186 hash = 41 * hash + Float.floatToIntBits(this.object_z_index); … … 184 191 @Override 185 192 public String toString() { 186 if (z_index != 0f || object_z_index != 0f) 187 return String.format("z_idx=%s/%s ", z_index, object_z_index) + (isModifier ? "modifier " : ""); 188 return ""; 193 return String.format("z_idx=[%s/%s/%s] ", major_z_index, z_index, object_z_index) + (isModifier ? "modifier " : ""); 189 194 } 190 195 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java
r5214 r5217 40 40 41 41 protected enum LineType { 42 NORMAL(""), 43 CASING("casing-"), 44 LEFT_CASING("left-casing-"), 45 RIGHT_CASING("right-casing-"); 46 47 public String prefix; 48 49 LineType(String prefix) { 42 NORMAL("", 3f), 43 CASING("casing-", 2f), 44 LEFT_CASING("left-casing-", 2.1f), 45 RIGHT_CASING("right-casing-", 2.1f); 46 47 public final String prefix; 48 public final float default_major_z_index; 49 50 LineType(String prefix, float default_major_z_index) { 50 51 this.prefix = prefix; 51 } 52 } 53 54 protected LineElemStyle(Cascade c, BasicStroke line, Color color, BasicStroke dashesLine, Color dashesBackground, float offset, float realWidth) { 55 super(c, 0f); 52 this.default_major_z_index = default_major_z_index; 53 } 54 } 55 56 protected LineElemStyle(Cascade c, float default_major_z_index, BasicStroke line, Color color, BasicStroke dashesLine, Color dashesBackground, float offset, float realWidth) { 57 super(c, default_major_z_index); 56 58 this.line = line; 57 59 this.color = color; … … 69 71 LineElemStyle leftCasing = createImpl(env, LineType.LEFT_CASING); 70 72 if (leftCasing != null) { 71 leftCasing.z_index += -90;72 73 leftCasing.isModifier = true; 73 74 } … … 78 79 LineElemStyle rightCasing = createImpl(env, LineType.RIGHT_CASING); 79 80 if (rightCasing != null) { 80 rightCasing.z_index += -90;81 81 rightCasing.isModifier = true; 82 82 } … … 87 87 LineElemStyle casing = createImpl(env, LineType.CASING); 88 88 if (casing != null) { 89 casing.z_index += -100;90 89 casing.isModifier = true; 91 90 } … … 263 262 } 264 263 265 return new LineElemStyle(c, line, color, dashesLine, dashesBackground, offset, realWidth);264 return new LineElemStyle(c, type.default_major_z_index, line, color, dashesLine, dashesBackground, offset, realWidth); 266 265 } 267 266 -
trunk/src/org/openstreetmap/josm/gui/mappaint/LinePatternElemStyle.java
r5054 r5217 16 16 17 17 public LinePatternElemStyle(Cascade c, MapImage pattern) { 18 super(c, -1f);18 super(c, 2.9f); 19 19 this.pattern = pattern; 20 20 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/LineTextElemStyle.java
r4281 r5217 10 10 11 11 public class LineTextElemStyle extends ElemStyle { 12 12 13 13 private TextElement text; 14 14 15 15 protected LineTextElemStyle(Cascade c, TextElement text) { 16 super(c, 2f);16 super(c, 4.9f); 17 17 this.text = text; 18 18 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/NodeElemStyle.java
r5054 r5217 15 15 import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings; 16 16 import org.openstreetmap.josm.data.osm.visitor.paint.MapPainter; 17 import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle.BoxProvider; 18 import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle.SimpleBoxProvider; 17 19 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference; 18 20 import org.openstreetmap.josm.gui.mappaint.StyleCache.StyleList; 19 import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle.BoxProvider;20 import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle.SimpleBoxProvider;21 import org.openstreetmap.josm.tools.Pair;22 21 import org.openstreetmap.josm.tools.Utils; 23 22 … … 85 84 MultiCascade mc = new MultiCascade(); 86 85 Cascade c = mc.getOrCreateCascade("default"); 87 SIMPLE_NODE_ELEMSTYLE = create(new Environment(null, mc, "default", null), true);86 SIMPLE_NODE_ELEMSTYLE = create(new Environment(null, mc, "default", null), 4.1f, true); 88 87 if (SIMPLE_NODE_ELEMSTYLE == null) throw new AssertionError(); 89 88 } … … 92 91 public static final StyleList DEFAULT_NODE_STYLELIST_TEXT = new StyleList(NodeElemStyle.SIMPLE_NODE_ELEMSTYLE, BoxTextElemStyle.SIMPLE_NODE_TEXT_ELEMSTYLE); 93 92 94 protected NodeElemStyle(Cascade c, MapImage mapImage, Symbol symbol ) {95 super(c, 1000f);93 protected NodeElemStyle(Cascade c, MapImage mapImage, Symbol symbol, float default_major_z_index) { 94 super(c, default_major_z_index); 96 95 this.mapImage = mapImage; 97 96 this.symbol = symbol; … … 99 98 100 99 public static NodeElemStyle create(Environment env) { 101 return create(env, false);102 } 103 104 private static NodeElemStyle create(Environment env, boolean allowDefault) {100 return create(env, 4f, false); 101 } 102 103 private static NodeElemStyle create(Environment env, float default_major_z_index, boolean allowDefault) { 105 104 Cascade c = env.mc.getCascade(env.layer); 106 105 … … 116 115 if (!allowDefault && symbol == null && mapImage == null) return null; 117 116 118 return new NodeElemStyle(c, mapImage, symbol );117 return new NodeElemStyle(c, mapImage, symbol, default_major_z_index); 119 118 } 120 119 … … 302 301 303 302 public BoxProvider getBoxProvider() { 304 if (mapImage != null) {303 if (mapImage != null) 305 304 return mapImage.getBoxProvider(); 306 } else if (symbol != null) {305 else if (symbol != null) 307 306 return new SimpleBoxProvider(new Rectangle(-symbol.size/2, -symbol.size/2, symbol.size, symbol.size)); 308 }else {307 else { 309 308 // This is only executed once, so no performance concerns. 310 309 // However, it would be better, if the settings could be changed at runtime.
Note:
See TracChangeset
for help on using the changeset viewer.