Ignore:
Timestamp:
2011-01-23T13:17:10+01:00 (13 years ago)
Author:
bastiK
Message:

some renaming (to make future commits easier to read)

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  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.mappaint;
     2package org.openstreetmap.josm.gui.mappaint.xml;
    33
    44import org.openstreetmap.josm.data.osm.OsmUtils;
    55
    6 public class Rule
     6public class XmlCondition
    77{
    8     String key;
    9     String value;
    10     String boolValue;
     8    public String key;
     9    public String value;
     10    public String boolValue;
    1111
    12     public Rule()
     12    public XmlCondition()
    1313    {
    1414      init();
    1515    }
    16     public Rule(Rule r)
     16    public XmlCondition(XmlCondition c)
    1717    {
    18       key = r.key;
    19       value = r.value;
    20       boolValue = r.boolValue;
     18      key = c.key;
     19      value = c.value;
     20      boolValue = c.boolValue;
    2121    }
    2222    public String getKey()
  • trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSourceHandler.java

    r3803 r3805  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.mappaint;
     2package org.openstreetmap.josm.gui.mappaint.xml;
    33
    44import java.awt.Color;
     
    99
    1010import org.openstreetmap.josm.Main;
     11import org.openstreetmap.josm.gui.mappaint.AreaElemStyle;
     12import org.openstreetmap.josm.gui.mappaint.IconElemStyle;
     13import org.openstreetmap.josm.gui.mappaint.LineElemStyle;
     14import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
     15import org.openstreetmap.josm.gui.mappaint.StyleSource;
    1116import org.openstreetmap.josm.tools.ColorHelper;
    1217import org.xml.sax.Attributes;
    1318import org.xml.sax.helpers.DefaultHandler;
    1419
    15 public class ElemStyleHandler extends DefaultHandler
     20public class XmlStyleSourceHandler extends DefaultHandler
    1621{
    1722    private boolean inDoc, inRule, inCondition, inLine, inLineMod, inIcon, inArea, inScaleMax, inScaleMin;
     
    2227
    2328    static class RuleElem {
    24         Rule rule = new Rule();
    25         Collection<Rule> rules;
     29        XmlCondition cond = new XmlCondition();
     30        Collection<XmlCondition> conditions;
    2631        long scaleMax;
    2732        long scaleMin;
     
    3237        public void init()
    3338        {
    34             rules = null;
     39            conditions = null;
    3540            scaleMax = 1000000000;
    3641            scaleMin = 0;
    3742            line.init();
    38             rule.init();
     43            cond.init();
    3944            linemod.init();
    4045            area.init();
     
    4348    }
    4449
    45     public ElemStyleHandler(StyleSource style) {
     50    public XmlStyleSourceHandler(StyleSource style) {
    4651        this.style = style;
    4752        inDoc=inRule=inCondition=inLine=inIcon=inArea=false;
     
    7378
    7479    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);
    7681    }
    7782
     
    154159            {
    155160                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);
    165170                }
    166171                for (int count=0; count<atts.getLength(); count++)
    167172                {
    168173                    if(atts.getQName(count).equals("k")) {
    169                         r.key = atts.getValue(count);
     174                        c.key = atts.getValue(count);
    170175                    } else if(atts.getQName(count).equals("v")) {
    171                         r.value = atts.getValue(count);
     176                        c.value = atts.getValue(count);
    172177                    } else if(atts.getQName(count).equals("b")) {
    173                         r.boolValue = atts.getValue(count);
     178                        c.boolValue = atts.getValue(count);
    174179                    } else {
    175180                        error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!");
    176181                    }
    177182                }
    178                 if(r.key == null) {
     183                if(c.key == null) {
    179184                    error("The condition has no key!");
    180185                }
     
    239244            if(hadLine)
    240245            {
    241                 style.add(rule.rule, rule.rules,
     246                style.add(rule.cond, rule.conditions,
    242247                        new LineElemStyle(rule.line, rule.scaleMax, rule.scaleMin));
    243248            }
    244249            if(hadLineMod)
    245250            {
    246                 style.addModifier(rule.rule, rule.rules,
     251                style.addModifier(rule.cond, rule.conditions,
    247252                        new LineElemStyle(rule.linemod, rule.scaleMax, rule.scaleMin));
    248253            }
    249254            if(hadIcon)
    250255            {
    251                 style.add(rule.rule, rule.rules,
     256                style.add(rule.cond, rule.conditions,
    252257                        new IconElemStyle(rule.icon, rule.scaleMax, rule.scaleMin));
    253258            }
    254259            if(hadArea)
    255260            {
    256                 style.add(rule.rule, rule.rules,
     261                style.add(rule.cond, rule.conditions,
    257262                        new AreaElemStyle(rule.area, rule.scaleMax, rule.scaleMin));
    258263            }
Note: See TracChangeset for help on using the changeset viewer.