Class MapMover

  • All Implemented Interfaces:
    java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.util.EventListener, Destroyable

    public class MapMover
    extends java.awt.event.MouseAdapter
    implements Destroyable
    Enables moving of the map by holding down the right mouse button and drag the mouse. Also, enables zooming by the mouse wheel.
    • Constructor Detail

      • MapMover

        public MapMover​(NavigatableComponent navComp)
        Constructs a new MapMover.
        Parameters:
        navComp - the navigable component
        Since:
        11713
    • Method Detail

      • movementInProgress

        public boolean movementInProgress()
        Determines if a map move is in progress.
        Returns:
        true if a map move is in progress
        Since:
        13987
      • mouseDragged

        public void mouseDragged​(java.awt.event.MouseEvent e)
        If the right (and only the right) mouse button is pressed, move the map.
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
        Overrides:
        mouseDragged in class java.awt.event.MouseAdapter
      • doMoveForDrag

        private void doMoveForDrag​(java.awt.event.MouseEvent e)
      • mousePressed

        public void mousePressed​(java.awt.event.MouseEvent e)
        Start the movement, if it was the 3rd button (right button).
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
        Overrides:
        mousePressed in class java.awt.event.MouseAdapter
      • mouseReleased

        public void mouseReleased​(java.awt.event.MouseEvent e)
        Change the cursor back to it's pre-move cursor.
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
        Overrides:
        mouseReleased in class java.awt.event.MouseAdapter
      • startMovement

        private void startMovement​(java.awt.event.MouseEvent e)
        Start movement by setting a new cursor and remember the current mouse position.
        Parameters:
        e - The mouse event that leat to the movement from.
      • endMovement

        private void endMovement()
        End the movement. Setting back the cursor and clear the movement variables
      • mouseWheelMoved

        public void mouseWheelMoved​(java.awt.event.MouseWheelEvent e)
        Zoom the map by 1/5th of current zoom per wheel-delta.
        Specified by:
        mouseWheelMoved in interface java.awt.event.MouseWheelListener
        Overrides:
        mouseWheelMoved in class java.awt.event.MouseAdapter
        Parameters:
        e - The wheel event.
      • mouseMoved

        public void mouseMoved​(java.awt.event.MouseEvent e)
        Emulates dragging on Mac OSX.
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
        Overrides:
        mouseMoved in class java.awt.event.MouseAdapter