Changeset 3803 in josm for trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyleHandler.java
- Timestamp:
- 2011-01-22T19:27:33+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyleHandler.java
r3719 r3803 15 15 public class ElemStyleHandler extends DefaultHandler 16 16 { 17 boolean inDoc, inRule, inCondition, inLine, inLineMod, inIcon, inArea, inScaleMax, inScaleMin;18 boolean hadLine, hadLineMod, hadIcon, hadArea;19 ElemStyles styles;20 String styleName; 21 RuleElem rule = new RuleElem();17 private boolean inDoc, inRule, inCondition, inLine, inLineMod, inIcon, inArea, inScaleMax, inScaleMin; 18 private boolean hadLine, hadLineMod, hadIcon, hadArea; 19 private RuleElem rule = new RuleElem(); 20 21 StyleSource style; 22 22 23 23 static class RuleElem { … … 43 43 } 44 44 45 public ElemStyleHandler(St ring name) {46 styleName = name;45 public ElemStyleHandler(StyleSource style) { 46 this.style = style; 47 47 inDoc=inRule=inCondition=inLine=inIcon=inArea=false; 48 48 rule.init(); 49 styles = MapPaintStyles.getStyles();50 49 } 51 50 … … 54 53 int i = colString.indexOf("#"); 55 54 Color ret; 56 if (i < 0) {57 ret = Main.pref.getColor("mappaint."+style Name+"."+colString, Color.red);55 if (i < 0) { 56 ret = Main.pref.getColor("mappaint."+style.getPrefName()+"."+colString, Color.red); 58 57 } else if(i == 0) { 59 58 ret = ColorHelper.html2color(colString); 60 59 } else { 61 ret = Main.pref.getColor("mappaint."+style Name+"."+colString.substring(0,i),60 ret = Main.pref.getColor("mappaint."+style.getPrefName()+"."+colString.substring(0,i), 62 61 ColorHelper.html2color(colString.substring(i))); 63 62 } … … 74 73 75 74 private void error(String message) { 76 System.out.println(style Name+ " (" + rule.rule.key + "=" + rule.rule.value + "): " + message);75 System.out.println(style.getDisplayString() + " (" + rule.rule.key + "=" + rule.rule.value + "): " + message); 77 76 } 78 77 … … 141 140 } else if (qName.equals("rules")) 142 141 { 143 if(styleName == null) 144 { 145 String n = atts.getValue("name"); 146 if(n == null) { 147 n = "standard"; 148 } 149 styleName = n; 142 if (style.name == null) { 143 style.name = atts.getValue("name"); 144 } 145 if (style.shortdescription == null) { 146 style.shortdescription = atts.getValue("shortdescription"); 150 147 } 151 148 } … … 203 200 { 204 201 if (atts.getQName(count).equals("src")) { 205 ImageIcon icon = MapPaintStyles.getIcon(atts.getValue(count), style Name);202 ImageIcon icon = MapPaintStyles.getIcon(atts.getValue(count), style.getPrefName()); 206 203 hadIcon = (icon != null); 207 204 rule.icon.icon = icon; … … 242 239 if(hadLine) 243 240 { 244 style s.add(styleName,rule.rule, rule.rules,241 style.add(rule.rule, rule.rules, 245 242 new LineElemStyle(rule.line, rule.scaleMax, rule.scaleMin)); 246 243 } 247 244 if(hadLineMod) 248 245 { 249 style s.addModifier(styleName,rule.rule, rule.rules,246 style.addModifier(rule.rule, rule.rules, 250 247 new LineElemStyle(rule.linemod, rule.scaleMax, rule.scaleMin)); 251 248 } 252 249 if(hadIcon) 253 250 { 254 style s.add(styleName,rule.rule, rule.rules,251 style.add(rule.rule, rule.rules, 255 252 new IconElemStyle(rule.icon, rule.scaleMax, rule.scaleMin)); 256 253 } 257 254 if(hadArea) 258 255 { 259 style s.add(styleName,rule.rule, rule.rules,256 style.add(rule.rule, rule.rules, 260 257 new AreaElemStyle(rule.area, rule.scaleMax, rule.scaleMin)); 261 258 }
Note:
See TracChangeset
for help on using the changeset viewer.