Changeset 3805 in josm for trunk/src/org/openstreetmap/josm/gui/mappaint/xml
- Timestamp:
- 2011-01-23T13:17:10+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/mappaint/xml
- Files:
-
- 1 added
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlCondition.java
r3803 r3805 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.mappaint ;2 package org.openstreetmap.josm.gui.mappaint.xml; 3 3 4 4 import org.openstreetmap.josm.data.osm.OsmUtils; 5 5 6 public class Rule6 public class XmlCondition 7 7 { 8 String key;9 String value;10 String boolValue;8 public String key; 9 public String value; 10 public String boolValue; 11 11 12 public Rule()12 public XmlCondition() 13 13 { 14 14 init(); 15 15 } 16 public Rule(Rule r)16 public XmlCondition(XmlCondition c) 17 17 { 18 key = r.key;19 value = r.value;20 boolValue = r.boolValue;18 key = c.key; 19 value = c.value; 20 boolValue = c.boolValue; 21 21 } 22 22 public String getKey() -
trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSourceHandler.java
r3803 r3805 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.mappaint ;2 package org.openstreetmap.josm.gui.mappaint.xml; 3 3 4 4 import java.awt.Color; … … 9 9 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.gui.mappaint.AreaElemStyle; 12 import org.openstreetmap.josm.gui.mappaint.IconElemStyle; 13 import org.openstreetmap.josm.gui.mappaint.LineElemStyle; 14 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 15 import org.openstreetmap.josm.gui.mappaint.StyleSource; 11 16 import org.openstreetmap.josm.tools.ColorHelper; 12 17 import org.xml.sax.Attributes; 13 18 import org.xml.sax.helpers.DefaultHandler; 14 19 15 public class ElemStyleHandler extends DefaultHandler20 public class XmlStyleSourceHandler extends DefaultHandler 16 21 { 17 22 private boolean inDoc, inRule, inCondition, inLine, inLineMod, inIcon, inArea, inScaleMax, inScaleMin; … … 22 27 23 28 static class RuleElem { 24 Rule rule = new Rule();25 Collection< Rule> rules;29 XmlCondition cond = new XmlCondition(); 30 Collection<XmlCondition> conditions; 26 31 long scaleMax; 27 32 long scaleMin; … … 32 37 public void init() 33 38 { 34 rules = null;39 conditions = null; 35 40 scaleMax = 1000000000; 36 41 scaleMin = 0; 37 42 line.init(); 38 rule.init();43 cond.init(); 39 44 linemod.init(); 40 45 area.init(); … … 43 48 } 44 49 45 public ElemStyleHandler(StyleSource style) {50 public XmlStyleSourceHandler(StyleSource style) { 46 51 this.style = style; 47 52 inDoc=inRule=inCondition=inLine=inIcon=inArea=false; … … 73 78 74 79 private void error(String message) { 75 System.out.println(style.getDisplayString() + " (" + rule. rule.key + "=" + rule.rule.value + "): " + message);80 System.out.println(style.getDisplayString() + " (" + rule.cond.key + "=" + rule.cond.value + "): " + message); 76 81 } 77 82 … … 154 159 { 155 160 inCondition=true; 156 Rule r = rule.rule;157 if( r.key != null)158 { 159 if(rule. rules == null) {160 rule. rules = new LinkedList<Rule>();161 } 162 rule. rules.add(new Rule(rule.rule));163 r = new Rule();164 rule. rules.add(r);161 XmlCondition c = rule.cond; 162 if(c.key != null) 163 { 164 if(rule.conditions == null) { 165 rule.conditions = new LinkedList<XmlCondition>(); 166 } 167 rule.conditions.add(new XmlCondition(rule.cond)); 168 c = new XmlCondition(); 169 rule.conditions.add(c); 165 170 } 166 171 for (int count=0; count<atts.getLength(); count++) 167 172 { 168 173 if(atts.getQName(count).equals("k")) { 169 r.key = atts.getValue(count);174 c.key = atts.getValue(count); 170 175 } else if(atts.getQName(count).equals("v")) { 171 r.value = atts.getValue(count);176 c.value = atts.getValue(count); 172 177 } else if(atts.getQName(count).equals("b")) { 173 r.boolValue = atts.getValue(count);178 c.boolValue = atts.getValue(count); 174 179 } else { 175 180 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 176 181 } 177 182 } 178 if( r.key == null) {183 if(c.key == null) { 179 184 error("The condition has no key!"); 180 185 } … … 239 244 if(hadLine) 240 245 { 241 style.add(rule. rule, rule.rules,246 style.add(rule.cond, rule.conditions, 242 247 new LineElemStyle(rule.line, rule.scaleMax, rule.scaleMin)); 243 248 } 244 249 if(hadLineMod) 245 250 { 246 style.addModifier(rule. rule, rule.rules,251 style.addModifier(rule.cond, rule.conditions, 247 252 new LineElemStyle(rule.linemod, rule.scaleMax, rule.scaleMin)); 248 253 } 249 254 if(hadIcon) 250 255 { 251 style.add(rule. rule, rule.rules,256 style.add(rule.cond, rule.conditions, 252 257 new IconElemStyle(rule.icon, rule.scaleMax, rule.scaleMin)); 253 258 } 254 259 if(hadArea) 255 260 { 256 style.add(rule. rule, rule.rules,261 style.add(rule.cond, rule.conditions, 257 262 new AreaElemStyle(rule.area, rule.scaleMax, rule.scaleMin)); 258 263 }
Note:
See TracChangeset
for help on using the changeset viewer.