Changeset 6246 in josm for trunk/src/org/openstreetmap/josm/gui/mappaint
- Timestamp:
- 2013-09-22T18:36:07+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSourceHandler.java
r6085 r6246 31 31 AreaPrototype area = new AreaPrototype(); 32 32 IconPrototype icon = new IconPrototype(); 33 public void init() 34 { 33 public void init() { 35 34 conditions = null; 36 35 scaleMax = Double.POSITIVE_INFINITY; … … 50 49 } 51 50 52 Color convertColor(String colString) 53 { 51 Color convertColor(String colString) { 54 52 int i = colString.indexOf('#'); 55 53 Color ret; … … 80 78 81 79 private void startElementLine(String qName, Attributes atts, LinePrototype line) { 82 for (int count=0; count<atts.getLength(); count++) 83 { 84 if(atts.getQName(count).equals("width")) 85 { 80 for (int count=0; count<atts.getLength(); count++) { 81 if(atts.getQName(count).equals("width")) { 86 82 String val = atts.getValue(count); 87 83 if (! (val.startsWith("+") || val.startsWith("-") || val.endsWith("%"))) { 88 84 line.setWidth(Integer.parseInt(val)); 89 85 } 90 } 91 else if (atts.getQName(count).equals("colour")) { 86 } else if (atts.getQName(count).equals("colour")) { 92 87 line.color=convertColor(atts.getValue(count)); 93 88 } else if (atts.getQName(count).equals("realwidth")) { … … 122 117 private void startElementLinemod(String qName, Attributes atts, LinemodPrototype line) { 123 118 startElementLine(qName, atts, line); 124 for (int count=0; count<atts.getLength(); count++) 125 { 126 if(atts.getQName(count).equals("width")) 127 { 119 for (int count=0; count<atts.getLength(); count++) { 120 if (atts.getQName(count).equals("width")) { 128 121 String val = atts.getValue(count); 129 if(val.startsWith("+")) 130 { 122 if (val.startsWith("+")) { 131 123 line.setWidth(Integer.parseInt(val.substring(1))); 132 124 line.widthMode = LinemodPrototype.WidthMode.OFFSET; 133 } 134 else if(val.startsWith("-")) 135 { 125 } else if(val.startsWith("-")) { 136 126 line.setWidth(Integer.parseInt(val)); 137 127 line.widthMode = LinemodPrototype.WidthMode.OFFSET; 138 } 139 else if(val.endsWith("%")) 140 { 128 } else if(val.endsWith("%")) { 141 129 line.setWidth(Integer.parseInt(val.substring(0, val.length()-1))); 142 130 line.widthMode = LinemodPrototype.WidthMode.PERCENT; … … 151 139 152 140 @Override public void startElement(String uri,String name, String qName, Attributes atts) { 153 if (inDoc==true) 154 { 141 if (inDoc) { 155 142 if (qName.equals("rule")) { 156 143 inRule=true; 157 } else if (qName.equals("rules")) 158 { 144 } else if (qName.equals("rules")) { 159 145 if (style.name == null) { 160 146 style.name = atts.getValue("name"); … … 166 152 style.icon = atts.getValue("icon"); 167 153 } 168 } 169 else if (qName.equals("scale_max")) { 154 } else if (qName.equals("scale_max")) { 170 155 inScaleMax = true; 171 156 } else if (qName.equals("scale_min")) { 172 157 inScaleMin = true; 173 } else if (qName.equals("condition") && inRule) 174 { 158 } else if (qName.equals("condition") && inRule) { 175 159 inCondition=true; 176 160 XmlCondition c = rule.cond; 177 if(c.key != null) 178 { 161 if (c.key != null) { 179 162 if(rule.conditions == null) { 180 163 rule.conditions = new LinkedList<XmlCondition>(); … … 184 167 rule.conditions.add(c); 185 168 } 186 for (int count=0; count<atts.getLength(); count++) 187 { 188 if(atts.getQName(count).equals("k")) { 169 for (int count=0; count<atts.getLength(); count++) { 170 if (atts.getQName(count).equals("k")) { 189 171 c.key = atts.getValue(count); 190 } else if (atts.getQName(count).equals("v")) {172 } else if (atts.getQName(count).equals("v")) { 191 173 c.value = atts.getValue(count); 192 174 } else if(atts.getQName(count).equals("b")) { … … 199 181 error("The condition has no key!"); 200 182 } 201 } 202 else if (qName.equals("line")) 203 { 183 } else if (qName.equals("line")) { 204 184 hadLine = inLine = true; 205 185 startElementLine(qName, atts, rule.line); 206 } 207 else if (qName.equals("linemod")) 208 { 186 } else if (qName.equals("linemod")) { 209 187 hadLineMod = inLineMod = true; 210 188 startElementLinemod(qName, atts, rule.linemod); 211 } 212 else if (qName.equals("icon")) 213 { 189 } else if (qName.equals("icon")) { 214 190 inIcon = true; 215 for (int count=0; count<atts.getLength(); count++) 216 { 191 for (int count=0; count<atts.getLength(); count++) { 217 192 if (atts.getQName(count).equals("src")) { 218 193 IconReference icon = new IconReference(atts.getValue(count), style); … … 227 202 } 228 203 } 229 } 230 else if (qName.equals("area")) 231 { 204 } else if (qName.equals("area")) { 232 205 hadArea = inArea = true; 233 206 for (int count=0; count<atts.getLength(); count++) … … 251 224 @Override public void endElement(String uri,String name, String qName) 252 225 { 253 if (inRule && qName.equals("rule")) 254 { 255 if(hadLine) 226 if (inRule && qName.equals("rule")) { 227 if (hadLine) { 228 style.add(rule.cond, rule.conditions, 229 new LinePrototype(rule.line, new Range(rule.scaleMin, rule.scaleMax))); 230 } 231 if (hadLineMod) 256 232 { 257 233 style.add(rule.cond, rule.conditions, 258 new Line Prototype(rule.line, new Range(rule.scaleMin, rule.scaleMax)));259 } 260 if (hadLineMod)234 new LinemodPrototype(rule.linemod, new Range(rule.scaleMin, rule.scaleMax))); 235 } 236 if (hadIcon) 261 237 { 262 238 style.add(rule.cond, rule.conditions, 263 new LinemodPrototype(rule.linemod, new Range(rule.scaleMin, rule.scaleMax)));264 }265 if(hadIcon)266 {267 style.add(rule.cond, rule.conditions,268 239 new IconPrototype(rule.icon, new Range(rule.scaleMin, rule.scaleMax))); 269 240 } 270 if (hadArea)241 if (hadArea) 271 242 { 272 243 style.add(rule.cond, rule.conditions, … … 276 247 hadLine = hadLineMod = hadIcon = hadArea = false; 277 248 rule.init(); 278 } 279 else if (inCondition && qName.equals("condition")) { 249 } else if (inCondition && qName.equals("condition")) { 280 250 inCondition = false; 281 251 } else if (inLine && qName.equals("line")) { … … 294 264 } 295 265 296 @Override public void characters(char[] ch, int start, int length) 297 { 298 if (inScaleMax == true) { 266 @Override public void characters(char[] ch, int start, int length) { 267 if (inScaleMax) { 299 268 rule.scaleMax = Long.parseLong(new String(ch, start, length)); 300 } else if (inScaleMin == true) {269 } else if (inScaleMin) { 301 270 rule.scaleMin = Long.parseLong(new String(ch, start, length)); 302 271 }
Note:
See TracChangeset
for help on using the changeset viewer.