Changeset 1924 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2009-08-07T23:22:31+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/mappaint
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyle.java
r1747 r1924 2 2 3 3 import java.util.Collection; 4 import java.util.Map;5 4 6 5 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 31 30 return code; 32 31 } 33 public boolean check( Map<String, String> keys)32 public boolean check(OsmPrimitive primitive) 34 33 { 35 34 if(rules == null) … … 37 36 for(Rule r : rules) 38 37 { 39 String k = keys.get(r.key);38 String k = primitive.get(r.key); 40 39 String bv = OsmUtils.getNamedOsmBoolean(r.boolValue); 41 40 if(k == null || (r.value != null && !k.equals(r.value)) -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r1843 r1924 7 7 import java.util.LinkedList; 8 8 import java.util.List; 9 import java.util.Map ;9 import java.util.Map.Entry; 10 10 11 11 import org.openstreetmap.josm.Main; … … 37 37 areasList = new LinkedList<AreaElemStyle>(); 38 38 } 39 private IconElemStyle getNode( Map<String, String> keys)39 private IconElemStyle getNode(OsmPrimitive primitive) 40 40 { 41 41 IconElemStyle ret = null; 42 Iterator<String> iterator = keys.keySet().iterator(); 43 while(iterator.hasNext()) 44 { 45 String key = iterator.next(); 46 String val = keys.get(key); 42 for (Entry<String, String> entry:primitive.entrySet()) { 43 String key = entry.getKey(); 44 String val = entry.getValue(); 47 45 IconElemStyle style; 48 46 if((style = icons.get("n" + key + "=" + val)) != null) … … 64 62 for(IconElemStyle s : iconsList) 65 63 { 66 if((ret == null || s.priority > ret.priority) && s.check( keys))64 if((ret == null || s.priority > ret.priority) && s.check(primitive)) 67 65 ret = s; 68 66 } 69 67 return ret; 70 68 } 71 private ElemStyle get( Map<String, String> keys, boolean noclosed)69 private ElemStyle get(OsmPrimitive primitive, boolean noclosed) 72 70 { 73 71 AreaElemStyle retArea = null; … … 75 73 String linestring = null; 76 74 HashMap<String, LineElemStyle> over = new HashMap<String, LineElemStyle>(); 77 Iterator<String> iterator = keys.keySet().iterator(); 78 while(iterator.hasNext()) 79 { 80 String key = iterator.next(); 81 String val = keys.get(key); 75 for (Entry<String, String> entry:primitive.entrySet()) { 76 String key = entry.getKey(); 77 String val = entry.getValue(); 82 78 AreaElemStyle styleArea; 83 79 LineElemStyle styleLine; … … 125 121 { 126 122 if((retArea == null || s.priority > retArea.priority) 127 && (!noclosed || !s.closed) && s.check( keys))123 && (!noclosed || !s.closed) && s.check(primitive)) 128 124 retArea = s; 129 125 } … … 131 127 { 132 128 if((retLine == null || s.priority > retLine.priority) 133 && s.check( keys))129 && s.check(primitive)) 134 130 retLine = s; 135 131 } 136 132 for(LineElemStyle s : modifiersList) 137 133 { 138 if(s.check( keys))134 if(s.check(primitive)) 139 135 over.put(s.getCode(), s); 140 136 } … … 158 154 public ElemStyle get(OsmPrimitive osm) 159 155 { 160 return ( osm.keys == null) ? null :161 ((osm instanceof Node) ? getNode(osm .keys) : get(osm.keys,156 return (!osm.hasKeys()) ? null : 157 ((osm instanceof Node) ? getNode(osm) : get(osm, 162 158 osm instanceof Way && !((Way)osm).isClosed())); 163 159 } … … 165 161 public ElemStyle getArea(Way osm) 166 162 { 167 if(osm. keys != null)163 if(osm.hasKeys()) 168 164 { 169 165 /* force area mode also for unclosed ways */ 170 ElemStyle style = get(osm .keys, false);166 ElemStyle style = get(osm, false); 171 167 if(style != null && style instanceof AreaElemStyle) 172 168 return style; … … 177 173 public IconElemStyle getIcon(OsmPrimitive osm) 178 174 { 179 return (osm.keys == null) ? null : getNode(osm.keys);175 return osm.hasKeys() ? getNode(osm): null; 180 176 } 181 177 182 178 public boolean isArea(OsmPrimitive o) 183 179 { 184 if(o. keys != null&& !(o instanceof Node))180 if(o.hasKeys() && !(o instanceof Node)) 185 181 { 186 182 boolean noclosed = o instanceof Way && !((Way)o).isClosed(); … … 200 196 for(AreaElemStyle s : areasList) 201 197 { 202 if(!(s.closed && noclosed) && s.check(o .keys))198 if(!(s.closed && noclosed) && s.check(o)) 203 199 return true; 204 200 }
Note:
See TracChangeset
for help on using the changeset viewer.