source: josm/trunk/src/org/openstreetmap/josm/data/osm/WaySegment.java @ 5241

Revision 4327, 1.2 KB checked in by xeen, 9 months ago (diff)

updates visual appearance of highlights and adds them to select and delete action

in more detail:

  • add target highlighting to select action
  • add target cursor to select action
  • add target highlighting to delete action
  • unify ctrl/alt/shift modifier detection in MapMode actions
  • highlights are now a halo around the way/node instead of a color change
  • default highlight color is now the same as the select color (red)
  • ability to highlight WaySegments and VirtualNodes
  • various style/whitespace nits
  • fixes #2411

This patch touches a lot of areas, so please report any regressions in the map mode
tools. Also please add a comment to #2411 if you find to highlighting in select
mode distracting, so it can be fine tuned (or turned off by default).

  • Property svn:eol-style set to native
Line 
1// License: GPL. Copyright 2007 by Gabriel Ebner
2package org.openstreetmap.josm.data.osm;
3
4/**
5 * A segment consisting of 2 consecutive nodes out of a way.
6 */
7public final class WaySegment {
8    /**
9     * The way.
10     */
11    public Way way;
12
13    /**
14     * The index of one of the 2 nodes in the way.  The other node has the
15     * index <code>lowerIndex + 1</code>.
16     */
17    public int lowerIndex;
18
19    public WaySegment(Way w, int i) {
20        way = w;
21        lowerIndex = i;
22    }
23
24    public Node getFirstNode(){
25        return way.getNode(lowerIndex);
26    }
27
28    public Node getSecondNode(){
29        return way.getNode(lowerIndex + 1);
30    }
31
32    /**
33     * returns this way segment as complete way.
34     * @return
35     */
36    public Way toWay() {
37        Way w = new Way();
38        w.addNode(getFirstNode());
39        w.addNode(getSecondNode());
40        return w;
41    }
42
43    @Override public boolean equals(Object o) {
44        return o != null && o instanceof WaySegment
45            && ((WaySegment) o).way == way
46            && ((WaySegment) o).lowerIndex == lowerIndex;
47    }
48
49    @Override public int hashCode() {
50        return way.hashCode() ^ lowerIndex;
51    }
52}
Note: See TracBrowser for help on using the repository browser.