Class SelectAction

    • Constructor Detail

      • SelectAction

        public SelectAction​(MapFrame mapFrame)
        Create a new SelectAction
        Parameters:
        mapFrame - The MapFrame this action belongs to.
    • Method Detail

      • giveUserFeedback

        private boolean giveUserFeedback​(MouseEvent e)
        handles adding highlights and updating the cursor for the given mouse event. Please note that the highlighting for merging while moving is handled via mouseDragged.
        Parameters:
        e - MouseEvent which should be used as base for the feedback
        Returns:
        true if repaint is required
      • giveUserFeedback

        private boolean giveUserFeedback​(MouseEvent e,
                                         int modifiers)
        handles adding highlights and updating the cursor for the given mouse event. Please note that the highlighting for merging while moving is handled via mouseDragged.
        Parameters:
        e - MouseEvent which should be used as base for the feedback
        modifiers - define custom keyboard extended modifiers if the ones from MouseEvent are outdated or similar
        Returns:
        true if repaint is required
      • getCursor

        private Cursor getCursor​(OsmPrimitive nearbyStuff)
        works out which cursor should be displayed for most of SelectAction's features. The only exception is the "move" cursor when actually dragging primitives.
        Parameters:
        nearbyStuff - primitives near the cursor
        Returns:
        the cursor that should be displayed
      • removeHighlighting

        private boolean removeHighlighting()
        Removes all existing highlights.
        Returns:
        true if a repaint is required
      • mousePressed

        public void mousePressed​(MouseEvent e)
        Look, whether any object is selected. If not, select the nearest node. If there are no nodes in the dataset, do nothing. If the user did not press the left mouse button, do nothing. Also remember the starting position of the movement and change the mouse cursor to movement.
        Specified by:
        mousePressed in interface MouseListener
        Overrides:
        mousePressed in class MapMode
      • determineMapMode

        private void determineMapMode​(boolean hasSelectionNearby)
        sets the mapmode according to key modifiers and if there are any selectables nearby. Everything has to be pre-determined for this function; its main purpose is to centralize what the modifiers do.
        Parameters:
        hasSelectionNearby - true if some primitves are selectable nearby
      • dragInProgress

        private boolean dragInProgress()
        Determines whenever elements have been grabbed and moved (i.e. the initial thresholds have been exceeded) and is still in progress (i.e. mouse button still pressed)
        Returns:
        true if a drag is in progress
      • updateCommandWhileDragging

        private boolean updateCommandWhileDragging​(EastNorth currentEN)
        Create or update data modification command while dragging mouse - implementation of continuous moving, scaling and rotation
        Parameters:
        currentEN - - mouse position
        Returns:
        status of action (true when action was performed)
      • useLastMoveCommandIfPossible

        private void useLastMoveCommandIfPossible()
        Adapt last move command (if it is suitable) to work with next drag, started at point startEN
      • getLastCommandInDataset

        private static Command getLastCommandInDataset​(DataSet ds)
        Obtain command in undoRedo stack to "continue" when dragging
        Parameters:
        ds - The data set the command needs to be in.
        Returns:
        last command
      • confirmOrUndoMovement

        private void confirmOrUndoMovement​(MouseEvent e)
        Present warning in the following cases and undo unwanted movements:
        • large and possibly unwanted movements
        • movement of node with attached ways that are hidden by filters
        Parameters:
        e - the mouse event causing the action (mouse released)
      • mergePrims

        private void mergePrims​(Point p)
        Merges the selected nodes to the one closest to the given mouse position if the control key is pressed. If there is no such node, no action will be done and no error will be reported. If there is, it will execute the merge and add it to the undo buffer.
        Parameters:
        p - mouse position
      • mergeNodes

        public void mergeNodes​(OsmDataLayer layer,
                               Collection<Node> nodes,
                               Node targetLocationNode)
        Merge nodes using MergeNodesAction. Can be overridden for testing purpose.
        Parameters:
        layer - layer the reference data layer. Must not be null
        nodes - the collection of nodes. Ignored if null
        targetLocationNode - this node's location will be used for the target node
      • findNodeToMergeTo

        private Node findNodeToMergeTo​(Point p)
        Tries to find a node to merge to when in move-merge mode for the current mouse position. Either returns the node or null, if no suitable one is nearby.
        Parameters:
        p - mouse position
        Returns:
        node to merge to, or null
      • getMode

        public final SelectAction.Mode getMode()
        Returns the current select mode.
        Returns:
        the select mode
        Since:
        7543
      • getModeHelpText

        public String getModeHelpText()
        Description copied from class: MapMode
        Returns a short translated help message describing how this map mode can be used, to be displayed in status line.
        Overrides:
        getModeHelpText in class MapMode
        Returns:
        a short translated help message describing how this map mode can be used
      • layerIsSupported

        public boolean layerIsSupported​(Layer l)
        Description copied from class: MapMode
        Determines if layer l is supported by this map mode. By default, all tools will work with all layers. Can be overwritten to require a special type of layer
        Overrides:
        layerIsSupported in class MapMode
        Parameters:
        l - layer
        Returns:
        true if the layer is supported by this map mode
      • setLassoMode

        public void setLassoMode​(boolean lassoMode)
        Enable or diable the lasso mode
        Parameters:
        lassoMode - true to enable the lasso mode, false otherwise
      • asColl

        protected static <T> Collection<T> asColl​(T o)
        Returns o as collection of o's type.
        Type Parameters:
        T - object type
        Parameters:
        o - any object
        Returns:
        o as collection of o's type.