Ignore:
Timestamp:
2011-08-21T13:12:53+02:00 (15 years ago)
Author:
xeen
Message:

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).

File:
1 edited

Legend:

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

    r4310 r4327  
    115115    private CopyOnWriteArrayList<DataSetListener> listeners = new CopyOnWriteArrayList<DataSetListener>();
    116116
     117    // provide means to highlight map elements that are not osm primitives
     118    private Collection<WaySegment> highlightedVirtualNodes = new LinkedList<WaySegment>();
     119    private Collection<WaySegment> highlightedWaySegments = new LinkedList<WaySegment>();
     120
    117121    // Number of open calls to beginUpdate
    118122    private int updateCount;
     
    431435
    432436    /**
     437     * returns an unmodifiable collection of *WaySegments* whose virtual
     438     * nodes should be highlighted. WaySegments are used to avoid having
     439     * to create a VirtualNode class that wouldn't have much purpose otherwise.
     440     *
     441     * @return unmodifiable collection of WaySegments
     442     */
     443    public Collection<WaySegment> getHighlightedVirtualNodes() {
     444        return Collections.unmodifiableCollection(highlightedVirtualNodes);
     445    }
     446
     447    /**
     448     * returns an unmodifiable collection of WaySegments that should be
     449     * highlighted.
     450     *
     451     * @return unmodifiable collection of WaySegments
     452     */
     453    public Collection<WaySegment> getHighlightedWaySegments() {
     454        return Collections.unmodifiableCollection(highlightedWaySegments);
     455    }
     456
     457    /**
    433458     * Replies an unmodifiable collection of primitives currently selected
    434459     * in this dataset. May be empty, but not null.
     
    505530        selectionSnapshot = null;
    506531        return true;
     532    }
     533
     534    /**
     535     * set what virtual nodes should be highlighted. Requires a Collection of
     536     * *WaySegments* to avoid a VirtualNode class that wouldn't have much use
     537     * otherwise.
     538     * @param Collection of waySegments
     539     */
     540    public void setHighlightedVirtualNodes(Collection<WaySegment> waySegments) {
     541        if(highlightedVirtualNodes.isEmpty() && waySegments.isEmpty())
     542            return;
     543
     544        highlightedVirtualNodes = waySegments;
     545        // can't use fireHighlightingChanged because it requires an OsmPrimitive
     546        highlightUpdateCount++;
     547    }
     548
     549    /**
     550     * set what virtual ways should be highlighted.
     551     * @param Collection of waySegments
     552     */
     553    public void setHighlightedWaySegments(Collection<WaySegment> waySegments) {
     554        if(highlightedWaySegments.isEmpty() && waySegments.isEmpty())
     555            return;
     556
     557        highlightedWaySegments = waySegments;
     558        // can't use fireHighlightingChanged because it requires an OsmPrimitive
     559        highlightUpdateCount++;
    507560    }
    508561
     
    590643        }
    591644        return changed;
     645    }
     646
     647    /**
     648     * clear all highlights of virtual nodes
     649     */
     650    public void clearHighlightedVirtualNodes() {
     651        setHighlightedVirtualNodes(new ArrayList<WaySegment>());
     652    }
     653
     654    /**
     655     * clear all highlights of way segments
     656     */
     657    public void clearHighlightedWaySegments() {
     658        setHighlightedWaySegments(new ArrayList<WaySegment>());
    592659    }
    593660
Note: See TracChangeset for help on using the changeset viewer.