org.geotools.renderer.j2d
Class GeoMouseEvent
java.lang.Object
java.util.EventObject
java.awt.AWTEvent
java.awt.event.ComponentEvent
java.awt.event.InputEvent
java.awt.event.MouseEvent
org.geotools.renderer.j2d.GeoMouseEvent
- All Implemented Interfaces:
- java.io.Serializable
- public final class GeoMouseEvent
- extends java.awt.event.MouseEvent
An event which indicates that a mouse action occurred in a map component. This event can
convert mouse position to geographic coordinates. All MouseListener
s registered
in MapPane
will automatically receive events of this class.
Listeners implementations can implements their code as below:
public void mouseClicked(MouseEvent e) {
GeoMouseEvent event = (GeoMouseEvent) e;
// Process event here...
}
- Version:
- $Id: GeoMouseEvent.java 17934 2006-02-09 09:08:30Z desruisseaux $
- Author:
- Martin Desruisseaux
- See Also:
- Serialized Form
Fields inherited from class java.awt.event.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 java.awt.event.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 java.awt.event.ComponentEvent |
COMPONENT_FIRST, COMPONENT_HIDDEN, COMPONENT_LAST, COMPONENT_MOVED, COMPONENT_RESIZED, COMPONENT_SHOWN |
Fields inherited from class java.awt.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 java.util.EventObject |
source |
Constructor Summary |
GeoMouseEvent(java.awt.event.MouseEvent event,
Renderer renderer)
A mouseClick event which also contains methods to transform from
pixels to the Coordinate System of the Renderer. |
Methods inherited from class java.awt.event.MouseEvent |
getButton, getClickCount, getMouseModifiersText, getPoint, getX, getY, isPopupTrigger, paramString, translatePoint |
Methods inherited from class java.awt.event.InputEvent |
consume, getModifiers, getModifiersEx, getModifiersExText, getWhen, isAltDown, isAltGraphDown, isConsumed, isControlDown, isMetaDown, isShiftDown |
Methods inherited from class java.awt.event.ComponentEvent |
getComponent |
Methods inherited from class java.awt.AWTEvent |
getID, setSource, toString |
Methods inherited from class java.util.EventObject |
getSource |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
GeoMouseEvent
public GeoMouseEvent(java.awt.event.MouseEvent event,
Renderer renderer)
- A mouseClick event which also contains methods to transform from
pixels to the Coordinate System of the Renderer.
- Parameters:
event
- The original mouse event.renderer
- The renderer used by the viewer that emmited the
event
.
getPixelCoordinate
public java.awt.geom.Point2D getPixelCoordinate(java.awt.geom.Point2D dest)
- Returns the mouse's position in pixel units. This method is
similar to
MouseEvent.getPoint()
except that the mouse location
is corrected for deformations caused by some artifacts like the
magnifying glass.
- Parameters:
dest
- A pre-allocated point that stores the mouse's
location, or null
if none.
- Returns:
- The mouse's location in pixel coordinates.
getMapCoordinate
public java.awt.geom.Point2D getMapCoordinate(java.awt.geom.Point2D dest)
- Returns the "real world" mouse's position. The coordinates are expressed in
renderer's coordinate system (a.k.a.
mapCS
).
- Parameters:
dest
- A pre-allocated point that stores the mouse's
location, or null
if none.
- Returns:
- The mouse's location in map coordinates.
getCoordinate
public java.awt.geom.Point2D getCoordinate(CoordinateSystem cs,
java.awt.geom.Point2D dest)
throws org.opengis.referencing.operation.TransformException
- Returns the "real world" mouse's position in the specified coordinate system.
- Parameters:
cs
- The desired coordinate system.dest
- A pre-allocated point that stores the mouse's
location, or null
if none.
- Returns:
- The mouse's location in map coordinates.
- Throws:
org.opengis.referencing.operation.TransformException
- if the mouse's position can't
be expressed in the specified coordinate system.
getCoordinate
public CoordinatePoint getCoordinate(CoordinateSystem cs,
CoordinatePoint dest)
throws org.opengis.referencing.operation.TransformException
- Returns the "real world" mouse's position in the specified coordinate system.
The coordinate system may have an arbitrary number of dimensions (as long as
a transform exists from the two-dimensional renderer's coordinate system), but is usually two-dimensional.
- Parameters:
cs
- The desired coordinate system.dest
- A pre-allocated point that stores the mouse's
location, or null
if none.
- Returns:
- The mouse's location in map coordinates.
- Throws:
org.opengis.referencing.operation.TransformException
- if the mouse's position can't
be expressed in the specified coordinate system.
getTextToMap
public MathTransform2D getTextToMap()
- Returns the transform from the widget coordinate reference system to the
renderer's coordinate reference system.
More specifically, this is the transform from
textCS
to mapCS
. This transform is usually (but not always)
affine.
In order to get the transform from the renderer to the widget's CRS, use the following:
getTextToMap().inverse()
. However, this
transform may not be invertible. In general:
- A pixel in the widget can always be mapped to one and only one "real world"
coordinate. Consequently, the
textToMap
transform always exists.
- A "real world" coordinate may be mapped to more than one widget's pixel in some very
particular situations (e.g. a magnifier with a scale factor smaller than 1). In this
particular case, the
mapToText
transform may not exists and the above
call to inverse()
will fails.
IMPLEMENTATION NOTE: In current implementation, this transform do not
apply any correction for deformable viewer. For fetching
current mouse coordinate, it is better to invokes getMapCoordinate(java.awt.geom.Point2D)
. The later
corrects for deformable viewers. A future version may includes the correction in the
textToMap
math transform, in which case this transform may no longer be
affine.
- Returns:
- The transform from widget CRS to renderer CRS.
Copyright © GeoTools. All Rights Reserved.