Ignore:
Timestamp:
2008-04-07T22:04:53+02:00 (16 years ago)
Author:
ramack
Message:
  • implement ticket #671: add option to draw only interesting direction arrows, where interesting means: they way is tagged with a key oneway, incline, incline_steep or aerialway
Location:
trunk/src/org/openstreetmap/josm/data/osm
Files:
4 edited

Legend:

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

    r529 r597  
    8383       
    8484        /**
     85         * true if this object has direction dependant tags (e.g. oneway)
     86         */
     87        public boolean hasDirectionKeys = false;
     88       
     89        /**
    8590         * If set to true, this object is currently selected.
    8691         */
     
    112117        public static Collection<String> uninteresting =
    113118                new HashSet<String>(Arrays.asList(new String[] {"source", "note", "created_by"}));
     119       
     120        /**
     121         * Contains a list of direction-dependent keys that do not make an object
     122         * direction dependent.
     123         */
     124        public static Collection<String> directionKeys =
     125                new HashSet<String>(Arrays.asList(new String[] {"oneway", "incline", "incline_steep", "aerialway"}));
    114126       
    115127        /**
     
    186198                }
    187199                checkTagged();
     200                checkDirectionTagged();
    188201        }
    189202        /**
     
    197210                }
    198211                checkTagged();
     212                checkDirectionTagged();
    199213        }
    200214
     
    266280                }
    267281        }
     282    /**
     283     * Updates the "hasDirectionKeys" flag. "keys" property should probably be made private
     284     * to make sure this gets called when keys are set.
     285     */
     286    public void checkDirectionTagged() {
     287        hasDirectionKeys = false;
     288        if (keys != null) {
     289            for (Entry<String,String> e : keys.entrySet()) {
     290                if (directionKeys.contains(e.getKey())) {
     291                    hasDirectionKeys = true;
     292                    break;
     293                }
     294            }
     295        }
     296
     297    }
    268298       
    269299}
  • trunk/src/org/openstreetmap/josm/data/osm/Way.java

    r529 r597  
    5353         */
    5454        public Way(Way clone) {
    55                 cloneFrom(clone);
     55            cloneFrom(clone);           
    5656        }
    5757       
     
    7575                nodes.clear();
    7676                nodes.addAll(((Way)osm).nodes);
     77                checkDirectionTagged();
    7778        }
    7879
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java

    r596 r597  
    7575        protected Color backgroundColor;
    7676        protected boolean showDirectionArrow;
     77    protected boolean showRelevantDirectionsOnly;
    7778        protected boolean showOrderNumber;
    7879       
     
    136137        public void visit(Way w) {
    137138                double circum = Main.map.mapView.getScale()*100*Main.proj.scaleFactor()*40041455; // circumference of the earth in meter
    138                 boolean showDirection = showDirectionArrow && w.selected;
    139                 if (useRealWidth && showDirection) showDirection = false;
     139                // show direction arrows, if draw.segment.relevant_directions_only is not set, the way is tagged with a direction key
     140                // (even if the tag is negated as in oneway=false) or the way is selected
     141                boolean showDirection = (!useRealWidth)
     142                                        && (w.selected || (showDirectionArrow
     143                                                           && (!showRelevantDirectionsOnly || w.hasDirectionKeys)));
     144
    140145                Color colour = untaggedColor;
    141146                int width = 2;
    142147                int realWidth = 0; //the real width of the element in meters
    143148                boolean dashed = false;
    144                 boolean area=false;
     149                boolean area = false;
    145150                ElemStyle wayStyle = MapPaintStyles.getStyle(w);
    146151
     
    352357                textColor = getPreferencesColor ("text", Color.WHITE);
    353358                showDirectionArrow = Main.pref.getBoolean("draw.segment.direction");
     359                showRelevantDirectionsOnly = Main.pref.getBoolean("draw.segment.relevant_directions_only");
    354360                showOrderNumber = Main.pref.getBoolean("draw.segment.order_number");
    355361                useRealWidth = Main.pref.getBoolean("mappaint.useRealWidth",false);
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java

    r499 r597  
    5454        protected Color incompleteColor;
    5555        protected Color backgroundColor;
    56         protected boolean showDirectionArrow;
     56    protected boolean showDirectionArrow;
     57    protected boolean showRelevantDirectionsOnly;
    5758        protected boolean showOrderNumber;
    5859       
     
    7576                backgroundColor = getPreferencesColor("background", Color.BLACK);
    7677                showDirectionArrow = Main.pref.getBoolean("draw.segment.direction");
     78                showRelevantDirectionsOnly = Main.pref.getBoolean("draw.segment.relevant_directions_only");
    7779                showOrderNumber = Main.pref.getBoolean("draw.segment.order_number");
    7880               
     
    126128                if (w.incomplete) return;
    127129
     130                // show direction arrows, if draw.segment.relevant_directions_only is not set, the way is tagged with a direction key
     131                // (even if the tag is negated as in oneway=false) or the way is selected
     132
     133                boolean showThisDirectionArrow = w.selected
     134                                                 || (showDirectionArrow
     135                                                     && (!showRelevantDirectionsOnly || w.hasDirectionKeys));
    128136                Color wayColor;
    129137               
     
    141149                        for (int orderNumber = 1; it.hasNext(); orderNumber++) {
    142150                                Point p = nc.getPoint(it.next().eastNorth);
    143                                 drawSegment(lastP, p, w.selected && !inactive ? selectedColor : wayColor, showDirectionArrow || w.selected);
     151                                drawSegment(lastP, p, w.selected && !inactive ? selectedColor : wayColor, showThisDirectionArrow);
    144152                                if (showOrderNumber)
    145153                                        drawOrderNumber(lastP, p, orderNumber);
Note: See TracChangeset for help on using the changeset viewer.