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 class
MapMover.JMapViewerUpdater
private class
MapMover.ZoomerAction
-
Field Summary
Fields Modifier and Type Field Description private MapViewState.MapViewPoint
mousePosMoveStart
The point in the map that was the under the mouse point when moving around started.private NavigatableComponent
nc
The map to move around.static BooleanProperty
PROP_ZOOM_REVERSE_WHEEL
Zoom 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 void
destroy()
Called when the object has been destroyed.private void
doMoveForDrag(java.awt.event.MouseEvent e)
private void
endMovement()
End the movement.void
mouseDragged(java.awt.event.MouseEvent e)
If the right (and only the right) mouse button is pressed, move the map.void
mouseMoved(java.awt.event.MouseEvent e)
Emulates dragging on Mac OSX.void
mousePressed(java.awt.event.MouseEvent e)
Start the movement, if it was the 3rd button (right button).void
mouseReleased(java.awt.event.MouseEvent e)
Change the cursor back to it's pre-move cursor.void
mouseWheelMoved(java.awt.event.MouseWheelEvent e)
Zoom the map by 1/5th of current zoom per wheel-delta.boolean
movementInProgress()
Determines if a map move is in progress.private void
registerActionShortcut(MapMover.ZoomerAction action, Shortcut shortcut)
private void
startMovement(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 isnull
if 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:
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 interfacejava.awt.event.MouseMotionListener
- Overrides:
mouseDragged
in 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:
mousePressed
in interfacejava.awt.event.MouseListener
- Overrides:
mousePressed
in 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:
mouseReleased
in interfacejava.awt.event.MouseListener
- Overrides:
mouseReleased
in 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:
mouseWheelMoved
in interfacejava.awt.event.MouseWheelListener
- Overrides:
mouseWheelMoved
in 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:
mouseMoved
in interfacejava.awt.event.MouseMotionListener
- Overrides:
mouseMoved
in classjava.awt.event.MouseAdapter
-
destroy
public void destroy()
Description copied from interface:Destroyable
Called when the object has been destroyed.- Specified by:
destroy
in interfaceDestroyable
-
-