Package org.openstreetmap.josm.gui
Class MapMover
- java.lang.Object
-
- java.awt.event.MouseAdapter
-
- org.openstreetmap.josm.gui.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classMapMover.JMapViewerUpdaterprivate classMapMover.ZoomerAction
-
Field Summary
Fields Modifier and Type Field Description private MapViewState.MapViewPointmousePosMoveStartThe point in the map that was the under the mouse point when moving around started.private NavigatableComponentncThe map to move around.static BooleanPropertyPROP_ZOOM_REVERSE_WHEELZoom wheel is reversed.private java.util.ArrayList<Pair<MapMover.ZoomerAction,Shortcut>>registeredShortcuts
-
Constructor Summary
Constructors Constructor Description MapMover(NavigatableComponent navComp)Constructs a newMapMover.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()Called when the object has been destroyed.private voiddoMoveForDrag(java.awt.event.MouseEvent e)private voidendMovement()End the movement.voidmouseDragged(java.awt.event.MouseEvent e)If the right (and only the right) mouse button is pressed, move the map.voidmouseMoved(java.awt.event.MouseEvent e)Emulates dragging on Mac OSX.voidmousePressed(java.awt.event.MouseEvent e)Start the movement, if it was the 3rd button (right button).voidmouseReleased(java.awt.event.MouseEvent e)Change the cursor back to it's pre-move cursor.voidmouseWheelMoved(java.awt.event.MouseWheelEvent e)Zoom the map by 1/5th of current zoom per wheel-delta.booleanmovementInProgress()Determines if a map move is in progress.private voidregisterActionShortcut(MapMover.ZoomerAction action, Shortcut shortcut)private voidstartMovement(java.awt.event.MouseEvent e)Start movement by setting a new cursor and remember the current mouse position.
-
-
-
Field Detail
-
PROP_ZOOM_REVERSE_WHEEL
public static final BooleanProperty PROP_ZOOM_REVERSE_WHEEL
Zoom wheel is reversed.
-
mousePosMoveStart
private MapViewState.MapViewPoint mousePosMoveStart
The point in the map that was the under the mouse point when moving around started. This isnullif movement is not active
-
nc
private final NavigatableComponent nc
The map to move around.
-
registeredShortcuts
private final java.util.ArrayList<Pair<MapMover.ZoomerAction,Shortcut>> registeredShortcuts
-
-
Constructor Detail
-
MapMover
public MapMover(NavigatableComponent navComp)
Constructs a newMapMover.- Parameters:
navComp- the navigable component- Since:
- 11713
-
-
Method Detail
-
registerActionShortcut
private void registerActionShortcut(MapMover.ZoomerAction action, Shortcut shortcut)
-
movementInProgress
public boolean movementInProgress()
Determines if a map move is in progress.- Returns:
trueif 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:
mouseDraggedin interfacejava.awt.event.MouseMotionListener- Overrides:
mouseDraggedin classjava.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:
mousePressedin interfacejava.awt.event.MouseListener- Overrides:
mousePressedin classjava.awt.event.MouseAdapter
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
Change the cursor back to it's pre-move cursor.- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener- Overrides:
mouseReleasedin classjava.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:
mouseWheelMovedin interfacejava.awt.event.MouseWheelListener- Overrides:
mouseWheelMovedin classjava.awt.event.MouseAdapter- Parameters:
e- The wheel event.
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
Emulates dragging on Mac OSX.- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener- Overrides:
mouseMovedin classjava.awt.event.MouseAdapter
-
destroy
public void destroy()
Description copied from interface:DestroyableCalled when the object has been destroyed.- Specified by:
destroyin interfaceDestroyable
-
-