org.openstreetmap.josm.gui
Class MapMover

java.lang.Object
  extended by java.awt.event.MouseAdapter
      extended by 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 java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, 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
private  class MapMover.ZoomerAction
           
 
Field Summary
private  javax.swing.JPanel contentPane
           
private  EastNorth mousePosMove
          The point in the map that was the under the mouse point when moving around started.
private  boolean movementInPlace
           
private  NavigatableComponent nc
          The map to move around.
 
Constructor Summary
MapMover(NavigatableComponent navComp, javax.swing.JPanel contentPane)
          Create a new MapMover
 
Method Summary
 void destroy()
          Called when the object has been destroyed.
private  void endMovement()
          End the movement.
static boolean isPlatformOsx()
          Replies true if we are currently running on OSX
 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.
private  void startMovement(java.awt.event.MouseEvent e)
          Start movement by setting a new cursor and remember the current mouse position.
 
Methods inherited from class java.awt.event.MouseAdapter
mouseClicked, mouseEntered, mouseExited
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mousePosMove

private EastNorth mousePosMove
The point in the map that was the under the mouse point when moving around started.


nc

private final NavigatableComponent nc
The map to move around.


contentPane

private final javax.swing.JPanel contentPane

movementInPlace

private boolean movementInPlace
Constructor Detail

MapMover

public MapMover(NavigatableComponent navComp,
                javax.swing.JPanel contentPane)
Create a new MapMover

Method Detail

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

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

isPlatformOsx

public static boolean isPlatformOsx()
Replies true if we are currently running on OSX

Returns:
true if we are currently running on OSX

destroy

public void destroy()
Description copied from interface: Destroyable
Called when the object has been destroyed.

Specified by:
destroy in interface Destroyable


JOSM