Changeset 735 in josm for trunk/src


Ignore:
Timestamp:
2008-07-24T12:06:08+02:00 (16 years ago)
Author:
stoecker
Message:

added boolean checks to mappaint element styles

Location:
trunk/src/org/openstreetmap/josm/gui/mappaint
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyleHandler.java

    r627 r735  
    1717        String curKey = null;
    1818        String curValue = null;
     19        String curBoolean = null;
    1920        int curLineWidth = -1;
    2021        int curLineRealWidth = 0;
     
    5657                                for (int count=0; count<atts.getLength(); count++) {
    5758                                        if(atts.getQName(count).equals("k"))
    58                                                 curKey = atts.getValue(count);       
     59                                        {
     60                                                curKey = atts.getValue(count);
     61                                                curBoolean = null;
     62                                                curValue = null;
     63                                        }
    5964                                        else if(atts.getQName(count).equals("v"))
    60                                                 curValue = atts.getValue(count);       
     65                                                curValue = atts.getValue(count);
     66                                        else if(atts.getQName(count).equals("b"))
     67                                                curBoolean = atts.getValue(count);
    6168                                }
    6269                        } else if (qName.equals("line")) {
     
    127134                                newStyle = new LineElemStyle(curLineWidth, curLineRealWidth, curLineColour,
    128135                                                curLineDashed, curScaleMax, curScaleMin);
    129                                 MapPaintStyles.add(curKey, curValue, newStyle);
     136                                MapPaintStyles.add(curKey, curValue, curBoolean, newStyle);
    130137                                curLineWidth    = -1;
    131138                                curLineRealWidth= 0;
     
    136143                        if (curIcon != null) {
    137144                                newStyle = new IconElemStyle(curIcon, curIconAnnotate, curScaleMax, curScaleMin);
    138                                 MapPaintStyles.add(curKey, curValue, newStyle);
     145                                MapPaintStyles.add(curKey, curValue, curBoolean, newStyle);
    139146                                curIcon                 = null;
    140147                                curIconAnnotate = true;
     
    142149                        if (curAreaColour != null) {
    143150                                newStyle = new AreaElemStyle (curAreaColour, curScaleMax, curScaleMin);
    144                                 MapPaintStyles.add(curKey, curValue, newStyle);
     151                                MapPaintStyles.add(curKey, curValue, curBoolean, newStyle);
    145152                                curAreaColour   = null;
    146153                        }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r627 r735  
    99import org.openstreetmap.josm.Main;
    1010import org.openstreetmap.josm.data.osm.OsmPrimitive;
     11import org.openstreetmap.josm.data.osm.OsmUtils;
    1112import org.xml.sax.InputSource;
    1213import org.xml.sax.XMLReader;
     
    7576        }
    7677
    77         static int nr = 0;
     78//      static int nr = 0;
    7879
    79         public static void add (String k, String v, ElemStyle style) {
     80        public static void add (String k, String v, String b, ElemStyle style) {
    8081                ElemStyle  old_style;
    81                 String key = k + "=" + v;
     82                String key;
    8283
    8384                /* unfortunately, there don't seem to be an efficient way to */
    8485                /* find out, if a given OsmPrimitive is an area or not, */
    8586                /* so distinguish only between way and node here - for now */
    86                 if (style instanceof AreaElemStyle) {
    87                         key = key + "way";
    88                 } else if (style instanceof LineElemStyle) {
    89                         key = key + "way";
    90                 } else if (style instanceof IconElemStyle) {
    91                         key = key + "node";
    92                 }
     87                if (style instanceof AreaElemStyle)
     88                        key = "way";
     89                else if (style instanceof LineElemStyle)
     90                        key = "way";
     91                else if (style instanceof IconElemStyle)
     92                        key = "node";
     93                else
     94                        key = "";
     95
     96                if(v != null)
     97                        key += "n" + k + "=" + v;
     98                else if(b != null)
     99                        key += "b" + k  + "=" + OsmUtils.getNamedOsmBoolean(b);
     100                else
     101                        key += "x" + k;
     102
    93103                /* avoid duplicates - for now */
    94104                old_style = styles.get(key);
     
    120130                        {
    121131                                String key = iterator.next();
    122                                 kv = key + "=" + p.keys.get(key) + classname;
    123                                 if (styles.containsKey(kv))     {
     132                                kv = classname + "n" + key + "=" + p.keys.get(key);
     133                                if (styles.containsKey(kv))
    124134                                        return styles.get(kv);
    125                                 }
     135                                kv = classname + "b" + key + "=" + OsmUtils.getNamedOsmBoolean(p.keys.get(key));
     136                                if (styles.containsKey(kv))
     137                                        return styles.get(kv);
     138                                kv = classname + "x" + key;
     139                                if (styles.containsKey(kv))
     140                                        return styles.get(kv);
    126141                        }
    127142
    128143                        // not a known key/value combination
    129                         boolean first_line = true;
     144//                      boolean first_line = true;
    130145
    131146                        // filter out trivial tags and show the rest
    132                         iterator = p.keys.keySet().iterator();
    133                         while (iterator.hasNext()) {
    134                                 String key = iterator.next();
    135                                 kv = key + "=" + p.keys.get(key);
    136                                 if (!kv.startsWith("created_by=") &&
    137                                                 !kv.startsWith("converted_by=") &&
    138                                                 !kv.startsWith("source=") &&
    139                                                 !kv.startsWith("note=") &&
    140                                                 !kv.startsWith("layer=") &&
    141                                                 !kv.startsWith("bridge=") &&
    142                                                 !kv.startsWith("tunnel=") &&
    143                                                 !kv.startsWith("oneway=") &&
    144                                                 !kv.startsWith("speedlimit=") &&
    145                                                 !kv.startsWith("motorcar=") &&
    146                                                 !kv.startsWith("horse=") &&
    147                                                 !kv.startsWith("bicycle=") &&
    148                                                 !kv.startsWith("foot=")
    149                                 ) {
     147//                      iterator = p.keys.keySet().iterator();
     148//                      while (iterator.hasNext()) {
     149//                              String key = iterator.next();
     150//                              kv = key + "=" + p.keys.get(key);
     151//                              if (!kv.startsWith("created_by=") &&
     152//                                              !kv.startsWith("converted_by=") &&
     153//                                              !kv.startsWith("source=") &&
     154//                                              !kv.startsWith("note=") &&
     155//                                              !kv.startsWith("layer=") &&
     156//                                              !kv.startsWith("bridge=") &&
     157//                                              !kv.startsWith("tunnel=") &&
     158//                                              !kv.startsWith("oneway=") &&
     159//                                              !kv.startsWith("speedlimit=") &&
     160//                                              !kv.startsWith("motorcar=") &&
     161//                                              !kv.startsWith("horse=") &&
     162//                                              !kv.startsWith("bicycle=") &&
     163//                                              !kv.startsWith("foot=")
     164//                              ) {
    150165
    151                                         if (first_line) {
    152                                                 nr++;
    153                                                 //System.out.println("mappaint - rule not found[" + nr + "]: " + kv + " id:" + p.id);
    154                                         } else {
    155                                                 //System.out.println("mappaint - rule not found[" + nr + "]: " + kv);
    156                                         }
    157                                         first_line=false;
    158                                 }
    159                         }
     166//                                      if (first_line) {
     167//                                              nr++;
     168//                                              System.out.println("mappaint - rule not found[" + nr + "]: " + kv + " id:" + p.id);
     169//                                      } else {
     170//                                              System.out.println("mappaint - rule not found[" + nr + "]: " + kv);
     171//                                      }
     172//                                      first_line=false;
     173//                              }
     174//                      }
    160175                }
    161176
Note: See TracChangeset for help on using the changeset viewer.