Package org.geotools.swing.event
Class MapMouseEvent
- Object
-
- EventObject
-
- AWTEvent
-
- ComponentEvent
-
- InputEvent
-
- MouseEvent
-
- MapMouseEvent
-
- All Implemented Interfaces:
Serializable
public final class MapMouseEvent extends MouseEvent
AMouseEvent
with methods to retrieve position in world coordinates.- Since:
- 2.6
- Author:
- Michael Bedward (adapted from code by Cameron Shorter)
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class MouseEvent
BUTTON1, BUTTON2, BUTTON3, MOUSE_CLICKED, MOUSE_DRAGGED, MOUSE_ENTERED, MOUSE_EXITED, MOUSE_FIRST, MOUSE_LAST, MOUSE_MOVED, MOUSE_PRESSED, MOUSE_RELEASED, MOUSE_WHEEL, NOBUTTON
-
Fields inherited from class InputEvent
ALT_DOWN_MASK, ALT_GRAPH_DOWN_MASK, ALT_GRAPH_MASK, ALT_MASK, BUTTON1_DOWN_MASK, BUTTON1_MASK, BUTTON2_DOWN_MASK, BUTTON2_MASK, BUTTON3_DOWN_MASK, BUTTON3_MASK, CTRL_DOWN_MASK, CTRL_MASK, META_DOWN_MASK, META_MASK, SHIFT_DOWN_MASK, SHIFT_MASK
-
Fields inherited from class ComponentEvent
COMPONENT_FIRST, COMPONENT_HIDDEN, COMPONENT_LAST, COMPONENT_MOVED, COMPONENT_RESIZED, COMPONENT_SHOWN
-
Fields inherited from class AWTEvent
ACTION_EVENT_MASK, ADJUSTMENT_EVENT_MASK, COMPONENT_EVENT_MASK, consumed, CONTAINER_EVENT_MASK, FOCUS_EVENT_MASK, HIERARCHY_BOUNDS_EVENT_MASK, HIERARCHY_EVENT_MASK, id, INPUT_METHOD_EVENT_MASK, INVOCATION_EVENT_MASK, ITEM_EVENT_MASK, KEY_EVENT_MASK, MOUSE_EVENT_MASK, MOUSE_MOTION_EVENT_MASK, MOUSE_WHEEL_EVENT_MASK, PAINT_EVENT_MASK, RESERVED_ID_MAX, TEXT_EVENT_MASK, WINDOW_EVENT_MASK, WINDOW_FOCUS_EVENT_MASK, WINDOW_STATE_EVENT_MASK
-
Fields inherited from class EventObject
source
-
-
Constructor Summary
Constructors Constructor Description MapMouseEvent(MapPane pane, MouseEvent event)
Creates a new event instance.MapMouseEvent(MapPane pane, MouseWheelEvent event)
Creates a new event instance for a mouse wheel event.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ReferencedEnvelope
getEnvelopeByPixels(double widthPixels)
Gets an envelope of specified width (in pixels) which is centred on the mouse position.ReferencedEnvelope
getEnvelopeByWorld(double widthWorld)
Gets an envelope of specified width (in world distance units) which is centred on the mouse position.MapPane
getSource()
Gets the source map pane for this event.int
getWheelAmount()
Gets the wheel travel amount for a mouse wheel event.Position2D
getWorldPos()
Gets the mouse position in world coordinates.boolean
isWheelEvent()
Queries whether this event was generated by a mouse wheel action.-
Methods inherited from class MouseEvent
getButton, getClickCount, getLocationOnScreen, getModifiersEx, getMouseModifiersText, getPoint, getX, getXOnScreen, getY, getYOnScreen, isPopupTrigger, paramString, translatePoint
-
Methods inherited from class InputEvent
consume, getMaskForButton, getModifiers, getModifiersExText, getWhen, isAltDown, isAltGraphDown, isConsumed, isControlDown, isMetaDown, isShiftDown
-
Methods inherited from class ComponentEvent
getComponent
-
-
-
-
Constructor Detail
-
MapMouseEvent
public MapMouseEvent(MapPane pane, MouseEvent event)
Creates a new event instance.- Parameters:
pane
- the source map paneevent
- the source mouse event
-
MapMouseEvent
public MapMouseEvent(MapPane pane, MouseWheelEvent event)
Creates a new event instance for a mouse wheel event.- Parameters:
pane
- the source map paneevent
- the source mouse wheel event
-
-
Method Detail
-
getSource
public MapPane getSource()
Gets the source map pane for this event.- Overrides:
getSource
in classEventObject
-
isWheelEvent
public boolean isWheelEvent()
Queries whether this event was generated by a mouse wheel action.- Returns:
- if a mouse event
-
getWheelAmount
public int getWheelAmount()
Gets the wheel travel amount for a mouse wheel event.- Returns:
- wheel travel, or 0 if this is not a mouse wheel event
-
getWorldPos
public Position2D getWorldPos()
Gets the mouse position in world coordinates.- Returns:
- world position
-
getEnvelopeByWorld
public ReferencedEnvelope getEnvelopeByWorld(double widthWorld)
Gets an envelope of specified width (in world distance units) which is centred on the mouse position.- Parameters:
widthWorld
- envelope width in world units- Returns:
- the envelope
- Throws:
IllegalArgumentException
- ifwidthWorld
is less than zero
-
getEnvelopeByPixels
public ReferencedEnvelope getEnvelopeByPixels(double widthPixels)
Gets an envelope of specified width (in pixels) which is centred on the mouse position.- Parameters:
widthPixels
- envelope width in pixels- Returns:
- the envelope
- Throws:
IllegalArgumentException
- ifwidthPixels
is less than zero
-
-