Changeset 597 in josm


Ignore:
Timestamp:
2008-04-07T22:04:53+02:00 (17 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
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java

    r582 r597  
    241241                                wayToAdd.keys = new HashMap<String, String>(selectedWay.keys);
    242242                                wayToAdd.checkTagged();
     243                                wayToAdd.checkDirectionTagged();
    243244                        }
    244245                        wayToAdd.nodes.addAll(chunkIt.next());
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java

    r582 r597  
    264264                                wnew2.keys = new HashMap<String, String>(wnew.keys);
    265265                                wnew2.checkTagged();
     266                                wnew2.checkDirectionTagged();
    266267                        }
    267268                        wnew2.nodes.addAll(n2);
  • 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);
  • trunk/src/org/openstreetmap/josm/gui/preferences/DrawingPreference.java

    r298 r597  
    1818        private JCheckBox largeGpsPoints = new JCheckBox(tr("Draw large GPS points."));
    1919        private JCheckBox directionHint = new JCheckBox(tr("Draw Direction Arrows"));
     20        private JCheckBox interestingDirections = new JCheckBox(tr("Only interesting direction hints (e.g. with oneway tag)."));
    2021        private JCheckBox segmentOrderNumber = new JCheckBox(tr("Draw segment order numbers"));
    2122        private JCheckBox sourceBounds = new JCheckBox(tr("Draw boundaries of downloaded data"));
     
    4748               
    4849                // directionHint
    49                 directionHint.setToolTipText(tr("Draw direction hints for all segments."));
     50                directionHint.addActionListener(new ActionListener(){
     51                        public void actionPerformed(ActionEvent e) {
     52                            if (directionHint.isSelected()){
     53                                interestingDirections.setSelected(Main.pref.getBoolean("draw.segment.relevant_directions_only"));
     54                            }else{
     55                                interestingDirections.setSelected(false);
     56                            }
     57                            interestingDirections.setEnabled(directionHint.isSelected());
     58                        }
     59                });
     60                directionHint.setToolTipText(tr("Draw direction hints for segments."));
    5061                directionHint.setSelected(Main.pref.getBoolean("draw.segment.direction"));
    5162                gui.display.add(directionHint, GBC.eop().insets(20,0,0,0));
     63
     64                // only interesting directions
     65                interestingDirections.setToolTipText(tr("Only interesting direction hints (e.g. with oneway tag)."));
     66                interestingDirections.setSelected(Main.pref.getBoolean("draw.segment.relevant_directions_only"));
     67                interestingDirections.setEnabled(directionHint.isSelected());
     68                gui.display.add(interestingDirections, GBC.eop().insets(40,0,0,0));
    5269               
    5370                // segment order number
     
    7289                Main.pref.put("draw.rawgps.large", largeGpsPoints.isSelected());
    7390                Main.pref.put("draw.segment.direction", directionHint.isSelected());
     91                Main.pref.put("draw.segment.relevant_directions_only", interestingDirections.isSelected());
    7492                Main.pref.put("draw.segment.order_number", segmentOrderNumber.isSelected());
    7593                Main.pref.put("draw.data.downloaded_area", sourceBounds.isSelected());
  • trunk/src/org/openstreetmap/josm/io/OsmReader.java

    r582 r597  
    8686                        osm.visible = visible;
    8787                        osm.checkTagged();
     88                        osm.checkDirectionTagged();
    8889                }
    8990        }
Note: See TracChangeset for help on using the changeset viewer.