Changeset 367 in josm


Ignore:
Timestamp:
Oct 12, 2007 1:28:49 AM (6 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.
Location:
trunk/src/org/openstreetmap/josm
Files:
3 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} 
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java

    r357 r367  
    77import java.awt.Point; 
    88import java.awt.Rectangle; 
     9import java.awt.Stroke; 
    910import java.awt.geom.GeneralPath; 
    1011import java.awt.geom.Line2D; 
     
    5152        protected Color nodeColor; 
    5253        protected Color dfltWayColor; 
     54        protected Color untaggedWayColor; 
    5355        protected Color incompleteColor; 
    5456        protected Color backgroundColor; 
     
    6870                nodeColor = getPreferencesColor("node", Color.RED); 
    6971                dfltWayColor = getPreferencesColor("way", darkblue); 
     72                untaggedWayColor = getPreferencesColor("untagged way", darkgreen); 
    7073                incompleteColor = getPreferencesColor("incomplete way", darkerblue); 
    7174                backgroundColor = getPreferencesColor("background", Color.BLACK); 
     
    7376                showOrderNumber = Main.pref.getBoolean("draw.segment.order_number"); 
    7477                 
     78                // draw tagged ways first, then untagged ways. takes 
     79                // time to iterate through list twice, OTOH does not 
     80                // require changing the colour while painting... 
    7581                for (final OsmPrimitive osm : data.ways) 
    76                         if (!osm.deleted && !osm.selected) 
     82                        if (!osm.deleted && !osm.selected && osm.tagged) 
    7783                                osm.visit(this); 
    7884                displaySegments(null); 
     85 
     86            for (final OsmPrimitive osm : data.ways) 
     87                        if (!osm.deleted && !osm.selected && !osm.tagged) 
     88                                osm.visit(this); 
     89                displaySegments(null); 
     90             
    7991                for (final OsmPrimitive osm : data.nodes) 
    8092                        if (!osm.deleted && !osm.selected) 
    8193                                osm.visit(this); 
     94         
    8295                for (final OsmPrimitive osm : data.getSelected()) 
    8396                        if (!osm.deleted) 
     
    113126 
    114127                Color wayColor; 
    115                 if (inactive) 
     128                 
     129                if (inactive) { 
    116130                        wayColor = inactiveColor; 
    117                 else { 
     131                } else if (!w.tagged) { 
     132                        wayColor = untaggedWayColor; 
     133                } else { 
    118134                        wayColor = dfltWayColor; 
    119135                } 
     
    171187 
    172188                if (screen.contains(p.x, p.y)) 
    173                         g.drawRect(p.x-1, p.y-1, 2, 2); 
     189                        if (n.tagged) { 
     190                                g.drawRect(p.x, p.y, 0, 0); 
     191                                g.drawRect(p.x-2, p.y-2, 4, 4); 
     192                        } else { 
     193                                g.drawRect(p.x-1, p.y-1, 2, 2); 
     194                        } 
    174195        } 
    175196 
     
    179200        protected void drawSegment(Node n1, Node n2, Color col, boolean showDirection) { 
    180201 
    181                 if (col != currentColor) { 
    182                         displaySegments(col); 
    183                 } 
     202                if (col != currentColor) displaySegments(col); 
    184203                 
    185204                Point p1 = nc.getPoint(n1.eastNorth); 
  • trunk/src/org/openstreetmap/josm/io/OsmReader.java

    r362 r367  
    8888                        osm.user = user; 
    8989                        osm.visible = visible; 
     90                        osm.checkTagged(); 
    9091                } 
    9192        } 
Note: See TracChangeset for help on using the changeset viewer.