- Timestamp:
- 2008-08-26T23:58:16+02:00 (16 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r863 r874 114 114 115 115 Color colour = untaggedColor; 116 Color areacolour = untaggedColor; 116 117 int width = defaultSegmentWidth; 117 118 int realWidth = 0; //the real width of the element in meters … … 126 127 if(wayStyle!=null) 127 128 { 129 LineElemStyle l = null; 128 130 if(wayStyle instanceof LineElemStyle) 129 131 { 130 colour = ((LineElemStyle)wayStyle).colour; 131 width = ((LineElemStyle)wayStyle).width; 132 realWidth = ((LineElemStyle)wayStyle).realWidth; 133 dashed = ((LineElemStyle)wayStyle).dashed; 132 l = (LineElemStyle)wayStyle; 134 133 } 135 134 else if (wayStyle instanceof AreaElemStyle) 136 135 { 137 colour = ((AreaElemStyle)wayStyle).getColour(); 136 areacolour = ((AreaElemStyle)wayStyle).colour; 137 l = ((AreaElemStyle)wayStyle).line; 138 138 area = true; 139 139 } 140 if(l != null) 141 { 142 colour = l.colour; 143 width = l.width; 144 realWidth = l.realWidth; 145 dashed = l.dashed; 146 } 140 147 } 141 148 142 149 if (area && fillAreas) 143 drawWayAsArea(w, colour); 150 drawWayAsArea(w, areacolour); 144 151 int orderNumber = 0; 145 152 … … 152 159 orderNumber++; 153 160 154 if (!area && realWidth > 0 && useRealWidth && !showDirection) { 161 if (realWidth > 0 && useRealWidth && !showDirection) 162 { 155 163 int tmpWidth = (int) (100 / (float) (circum / realWidth)); 156 164 if (tmpWidth > width) width = tmpWidth; -
trunk/src/org/openstreetmap/josm/gui/mappaint/AreaElemStyle.java
r627 r874 4 4 public class AreaElemStyle extends ElemStyle 5 5 { 6 Color colour; 6 public Color colour; 7 public LineElemStyle line = null; 7 8 8 9 public AreaElemStyle (Color colour, long maxScale, long minScale) { … … 12 13 } 13 14 14 public Color getColour() { 15 return colour; 15 public AreaElemStyle(AreaElemStyle a, LineElemStyle l) 16 { 17 this.colour = a.colour; 18 this.maxScale = a.maxScale; 19 this.minScale = a.minScale; 20 this.line = l; 16 21 } 17 22 -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyleHandler.java
r801 r874 145 145 curLineDashed, curScaleMax, curScaleMin); 146 146 MapPaintStyles.add(curKey, curValue, curBoolean, newStyle); 147 curLineWidth 147 curLineWidth = -1; 148 148 curLineRealWidth= 0; 149 curLineDashed 150 curLineColour 149 curLineDashed = false; 150 curLineColour = null; 151 151 } 152 152 … … 154 154 newStyle = new IconElemStyle(curIcon, curIconAnnotate, curScaleMax, curScaleMin); 155 155 MapPaintStyles.add(curKey, curValue, curBoolean, newStyle); 156 curIcon 156 curIcon = null; 157 157 curIconAnnotate = true; 158 158 } … … 160 160 newStyle = new AreaElemStyle (curAreaColour, curScaleMax, curScaleMin); 161 161 MapPaintStyles.add(curKey, curValue, curBoolean, newStyle); 162 curAreaColour 162 curAreaColour = null; 163 163 } 164 164 curScaleMax = 1000000000; -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r791 r874 5 5 6 6 import org.openstreetmap.josm.data.osm.OsmPrimitive; 7 import org.openstreetmap.josm.data.osm.OsmUtils; 8 7 9 public class ElemStyles 8 10 { 9 HashMap<String, ElemStyle> styles; 10 // static int nr = 0; 11 11 private HashMap<String, ElemStyle> styles; 12 12 13 13 public ElemStyles() … … 16 16 } 17 17 18 public void add 18 public void add(String k, String v, String b, ElemStyle style) 19 19 { 20 20 ElemStyle old_style; 21 String key = k + "=" + v;22 21 String key; 22 23 23 /* unfortunately, there don't seem to be an efficient way to */ 24 24 /* find out, if a given OsmPrimitive is an area or not, */ 25 25 /* so distinguish only between way and node here - for now */ 26 if(style instanceof AreaElemStyle) { 27 key = key + "way"; 28 } 29 else if(style instanceof LineElemStyle) { 30 key = key + "way"; 31 } 32 else if(style instanceof IconElemStyle) { 33 key = key + "node"; 34 } 26 if (style instanceof AreaElemStyle) 27 key = "w"; 28 else if (style instanceof LineElemStyle) 29 key = "w"; 30 else if (style instanceof IconElemStyle) 31 key = "n"; 32 else 33 key = ""; 34 35 if(v != null) 36 key += "n" + k + "=" + v; 37 else if(b != null) 38 key += "b" + k + "=" + OsmUtils.getNamedOsmBoolean(b); 39 else 40 key += "x" + k; 41 35 42 /* avoid duplicates - for now */ 36 43 old_style = styles.get(key); 37 if(old_style == null) { 44 if (old_style == null) { 38 45 /* new key/value, insert */ 39 46 styles.put(key, style); 40 47 } else { 41 if(style.getMaxScale() < old_style.getMaxScale()) { 48 if (style.getMaxScale() < old_style.getMaxScale()) { 42 49 /* existing larger scale key/value, replace */ 43 50 styles.remove(old_style); … … 47 54 } 48 55 49 public ElemStyle get Style(OsmPrimitive p)56 public ElemStyle get(OsmPrimitive p, Boolean area) 50 57 { 51 if(p.keys!=null) 52 { 58 if (p.keys!=null) { 53 59 String classname; 54 60 String kv = null; 55 56 if(p instanceof org.openstreetmap.josm.data.osm.Node) { 57 classname = "node"; 61 62 if (p instanceof org.openstreetmap.josm.data.osm.Node) { 63 if(area) 64 return null; 65 classname = "n"; 58 66 } else { 59 classname = "w ay";67 classname = "w"; 60 68 } 61 69 Iterator<String> iterator = p.keys.keySet().iterator(); 62 while(iterator.hasNext()) 70 while (iterator.hasNext()) 63 71 { 64 72 String key = iterator.next(); 65 kv = key + "=" + p.keys.get(key) + classname; 66 if(styles.containsKey(kv)) 73 ElemStyle style = null; 74 kv = classname + "n" + key + "=" + p.keys.get(key); 75 if (styles.containsKey(kv)) 67 76 { 68 return styles.get(kv); 77 style = styles.get(kv); 78 if(area == style instanceof AreaElemStyle) 79 return style; 80 } 81 kv = classname + "b" + key + "=" + OsmUtils.getNamedOsmBoolean(p.keys.get(key)); 82 if (styles.containsKey(kv)) 83 { 84 style = styles.get(kv); 85 if(area == style instanceof AreaElemStyle) 86 return style; 87 } 88 kv = classname + "x" + key; 89 if (styles.containsKey(kv)) 90 { 91 style = styles.get(kv); 92 if(area == style instanceof AreaElemStyle) 93 return style; 69 94 } 70 95 } 71 /** 72 // not a known key/value combination 73 boolean first_line = true; 96 } 74 97 75 // filter out trivial tags and show the rest76 iterator = p.keys.keySet().iterator();77 while(iterator.hasNext())78 {79 String key = iterator.next();80 kv = key + "=" + p.keys.get(key);81 if( !kv.startsWith("created_by=") &&82 !kv.startsWith("converted_by=") &&83 !kv.startsWith("source=") &&84 !kv.startsWith("note=") &&85 !kv.startsWith("layer=") &&86 !kv.startsWith("bridge=") &&87 !kv.startsWith("tunnel=") &&88 !kv.startsWith("oneway=") &&89 !kv.startsWith("speedlimit=") &&90 !kv.startsWith("motorcar=") &&91 !kv.startsWith("horse=") &&92 !kv.startsWith("bicycle=") &&93 !kv.startsWith("foot=")94 ) {95 96 if (first_line) {97 nr++;98 //System.out.println("mappaint - rule not found[" + nr + "]: " + kv + " id:" + p.id);99 } else {100 //System.out.println("mappaint - rule not found[" + nr + "]: " + kv);101 }102 first_line=false;103 }104 }105 */106 }107 98 return null; 108 99 } … … 110 101 public boolean isArea(OsmPrimitive p) 111 102 { 112 return get Style(p) instanceof AreaElemStyle;103 return get(p, true) instanceof AreaElemStyle; 113 104 } 114 105 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r851 r874 9 9 import org.openstreetmap.josm.Main; 10 10 import org.openstreetmap.josm.data.osm.OsmPrimitive; 11 import org.openstreetmap.josm. data.osm.OsmUtils;11 import org.openstreetmap.josm.gui.mappaint.ElemStyles; 12 12 import org.xml.sax.InputSource; 13 13 import org.xml.sax.XMLReader; … … 20 20 private static String internalImageDir; 21 21 private static Boolean isInternal = false; 22 private static HashMap<String,ElemStyle>styles = newHashMap<String,ElemStyle>();22 private static ElemStyles styles = new ElemStyles(); 23 23 24 24 public static String getStyleDir(){ … … 33 33 public static Boolean isInternal(){ 34 34 return isInternal; 35 } 36 public static void add(String k, String v, String b, ElemStyle style) 37 { 38 styles.add(k, v, b, style); 39 } 40 public static ElemStyle getStyle(OsmPrimitive osm) 41 { 42 ElemStyle s = styles.get(osm, true); 43 if(s != null) 44 { 45 ElemStyle l = styles.get(osm, false); 46 if(l != null && l instanceof LineElemStyle) 47 { 48 s = new AreaElemStyle((AreaElemStyle)s, (LineElemStyle)l); 49 } 50 } 51 else 52 s = styles.get(osm, false); 53 return s; 54 } 55 public static boolean isArea(OsmPrimitive osm) 56 { 57 return styles.isArea(osm); 35 58 } 36 59 … … 93 116 } 94 117 95 // static int nr = 0;96 97 public static void add (String k, String v, String b, ElemStyle style) {98 ElemStyle old_style;99 String key;100 101 /* unfortunately, there don't seem to be an efficient way to */102 /* find out, if a given OsmPrimitive is an area or not, */103 /* so distinguish only between way and node here - for now */104 if (style instanceof AreaElemStyle)105 key = "way";106 else if (style instanceof LineElemStyle)107 key = "way";108 else if (style instanceof IconElemStyle)109 key = "node";110 else111 key = "";112 113 if(v != null)114 key += "n" + k + "=" + v;115 else if(b != null)116 key += "b" + k + "=" + OsmUtils.getNamedOsmBoolean(b);117 else118 key += "x" + k;119 120 /* avoid duplicates - for now */121 old_style = styles.get(key);122 if (old_style == null) {123 /* new key/value, insert */124 styles.put(key, style);125 } else {126 if (style.getMaxScale() < old_style.getMaxScale()) {127 /* existing larger scale key/value, replace */128 styles.remove(old_style);129 styles.put(key, style);130 }131 }132 }133 134 public static ElemStyle getStyle (OsmPrimitive p)135 {136 if (p.keys!=null) {137 String classname;138 String kv = null;139 140 if (p instanceof org.openstreetmap.josm.data.osm.Node) {141 classname = "node";142 } else {143 classname = "way";144 }145 Iterator<String> iterator = p.keys.keySet().iterator();146 while (iterator.hasNext())147 {148 String key = iterator.next();149 kv = classname + "n" + key + "=" + p.keys.get(key);150 if (styles.containsKey(kv))151 return styles.get(kv);152 kv = classname + "b" + key + "=" + OsmUtils.getNamedOsmBoolean(p.keys.get(key));153 if (styles.containsKey(kv))154 return styles.get(kv);155 kv = classname + "x" + key;156 if (styles.containsKey(kv))157 return styles.get(kv);158 }159 160 // not a known key/value combination161 // boolean first_line = true;162 163 // filter out trivial tags and show the rest164 // iterator = p.keys.keySet().iterator();165 // while (iterator.hasNext()) {166 // String key = iterator.next();167 // kv = key + "=" + p.keys.get(key);168 // if (!kv.startsWith("created_by=") &&169 // !kv.startsWith("converted_by=") &&170 // !kv.startsWith("source=") &&171 // !kv.startsWith("note=") &&172 // !kv.startsWith("layer=") &&173 // !kv.startsWith("bridge=") &&174 // !kv.startsWith("tunnel=") &&175 // !kv.startsWith("oneway=") &&176 // !kv.startsWith("speedlimit=") &&177 // !kv.startsWith("motorcar=") &&178 // !kv.startsWith("horse=") &&179 // !kv.startsWith("bicycle=") &&180 // !kv.startsWith("foot=")181 // ) {182 183 // if (first_line) {184 // nr++;185 // System.out.println("mappaint - rule not found[" + nr + "]: " + kv + " id:" + p.id);186 // } else {187 // System.out.println("mappaint - rule not found[" + nr + "]: " + kv);188 // }189 // first_line=false;190 // }191 // }192 }193 194 return null;195 }196 197 public static boolean isArea(OsmPrimitive p)198 {199 return getStyle(p) instanceof AreaElemStyle;200 }201 118 } -
trunk/styles/standard/elemstyles.xml
r852 r874 595 595 <rule> 596 596 <condition k="junction" v="roundabout"/> 597 <!-- this overwrites the "underlying" highway tag, so comment it out until we have a better way to display this --> 598 <!--area width="1" colour="roundabout#eeeeee" /--> 597 <area width="1" colour="roundabout#eeeeee"/> 599 598 <!-- tagging a node makes no real sense, a roundabout should be tagged with several nodes, or a highway=mini_roundabout should probably be used --> 600 599 <icon annotate="true" src="misc/deprecated.png"/>
Note:
See TracChangeset
for help on using the changeset viewer.