Ignore:
Timestamp:
2007-10-12T01:28:49+02:00 (17 years ago)
Author:
framm
Message:
  • changed appearance of tagged nodes (now: dot with square around it) and untagged ways (now: have their own colour). FOr this I introduced a "tagged" flag that is only set when the primitive has "interesting" tags; currently, "created_by", "source", and "note" are deemed un-interesting.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r362 r367  
    55import java.text.SimpleDateFormat;
    66import java.util.ArrayList;
     7import java.util.Arrays;
    78import java.util.Collection;
    89import java.util.Collections;
    910import java.util.Date;
    1011import java.util.HashMap;
     12import java.util.HashSet;
    1113import java.util.Map;
    1214import java.util.Map.Entry;
     
    8183
    8284        /**
     85         * true if this object is considered "tagged". To be "tagged", an object
     86         * must have one or more "non-standard" tags. "created_by" and "source"
     87         * are typically considered "standard" tags and do not make an object
     88         * "tagged".
     89         */
     90        public boolean tagged = false;
     91       
     92        /**
    8393         * If set to true, this object is currently selected.
    8494         */
     
    104114        public boolean incomplete = false;
    105115
     116        /**
     117         * Contains a list of "uninteresting" keys that do not make an object
     118         * "tagged".
     119         */
     120        public static Collection<String> uninteresting =
     121                new HashSet<String>(Arrays.asList(new String[] {"source", "note", "created_by"}));
     122       
    106123        /**
    107124         * Implementation of the visitor scheme. Subclases have to call the correct
     
    176193                        keys.put(key, value);
    177194                }
     195                checkTagged();
    178196        }
    179197        /**
     
    186204                                keys = null;
    187205                }
     206                checkTagged();
    188207        }
    189208
     
    215234                selected = osm.selected;
    216235                timestamp = osm.timestamp;
     236                tagged = osm.tagged;
    217237        }
    218238
     
    237257        }
    238258       
     259        /**
     260         * Updates the "tagged" flag. "keys" property should probably be made private
     261         * to make sure this gets called when keys are set.
     262         */
     263        public void checkTagged() {
     264                tagged = false;
     265                if (keys != null) {
     266                        for (Entry<String,String> e : keys.entrySet()) {
     267                                if (!uninteresting.contains(e.getKey())) {
     268                                        tagged = true;
     269                                        break;
     270                                }
     271                        }
     272                }
     273        }
    239274       
    240275}
Note: See TracChangeset for help on using the changeset viewer.