Package org.geotools.swing
Interface MapPane
-
- All Known Implementing Classes:
AbstractMapPane
,JLayeredMapPane
,JMapPane
public interface MapPane
Defines the core map pane methods.- Since:
- 8.0
- Author:
- Michael Bedward
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addMapPaneListener(MapPaneListener listener)
Adds a listener to receiveMapPaneEvent
s.void
addMouseListener(MapMouseListener listener)
Registers an object that wishes to receiveMapMouseEvent
s such as a JMapStatusBar.CursorTool
getCursorTool()
Gets the current cursor tool.ReferencedEnvelope
getDisplayArea()
Gets the current display area in world coordinates.MapContent
getMapContent()
Gets theMapConent
instance containing the layers being displayed by this map pane.MapMouseEventDispatcher
getMouseEventDispatcher()
Gets the current mouse event dispatcher which is responsible for converting each input Java AWT mouse event into a MapMouseEvent and forwarding it to each MapMouseListener.AffineTransform
getScreenToWorldTransform()
Gets the screen to world coordinate transform.AffineTransform
getWorldToScreenTransform()
Gets the world to screen coordinate transform.void
moveImage(int dx, int dy)
Moves the image(s) displayed by the map pane from the current origin (x,y) (device pixels) to (x+dx, y+dy).void
removeMapPaneListener(MapPaneListener listener)
Removes the specified listener.void
removeMouseListener(MapMouseListener listener)
Removes the specified listener.void
reset()
Reset the map area to include the full extent of all layers and redraw the displayvoid
setCursorTool(CursorTool tool)
Sets the current cursor tool.void
setDisplayArea(Bounds envelope)
Sets the area to display in world units.void
setMapContent(MapContent content)
Sets theMapContent
instance containing the layers to display.void
setMouseEventDispatcher(MapMouseEventDispatcher dispatcher)
Replaces the current mouse event dispatcher.
-
-
-
Method Detail
-
getMapContent
MapContent getMapContent()
Gets theMapConent
instance containing the layers being displayed by this map pane.- Returns:
- the map content
-
setMapContent
void setMapContent(MapContent content)
Sets theMapContent
instance containing the layers to display.- Parameters:
content
- the map content
-
getMouseEventDispatcher
MapMouseEventDispatcher getMouseEventDispatcher()
Gets the current mouse event dispatcher which is responsible for converting each input Java AWT mouse event into a MapMouseEvent and forwarding it to each MapMouseListener.- Returns:
- the current mouse event dispatcher (may be
null
)
-
setMouseEventDispatcher
void setMouseEventDispatcher(MapMouseEventDispatcher dispatcher)
Replaces the current mouse event dispatcher. All current listeners will be removed. It is the responsibility of the client to add them to the new dispatcher if this is desired.- Parameters:
dispatcher
- the new dispatcher (may benull
)
-
getDisplayArea
ReferencedEnvelope getDisplayArea()
Gets the current display area in world coordinates. This is a short-cut formapPane.getMapContent().getViewport().getBounds()
. If a MapContent object has not yet been associated with the map pane, an emptyReferencedEnvelope
is returned.- Returns:
- the display area in world coordinates
-
setDisplayArea
void setDisplayArea(Bounds envelope)
Sets the area to display in world units.- Parameters:
envelope
- the new display area- Throws:
IllegalArgumentException
- ifenvelope
isnull
-
reset
void reset()
Reset the map area to include the full extent of all layers and redraw the display
-
getScreenToWorldTransform
AffineTransform getScreenToWorldTransform()
Gets the screen to world coordinate transform. This is a short-cut formapPane.getMapContent().getViewport().getScreenToWorld()
.- Returns:
- the screen to world coordinate transform
-
getWorldToScreenTransform
AffineTransform getWorldToScreenTransform()
Gets the world to screen coordinate transform. This is a short-cut formapPane.getMapContent().getViewport().getWorldToScreen()
.The returned
AffineTransform
can be used to determine the current drawing scale...double scale = mapPane.getWorldToScreenTransform().getScaleX();
- Returns:
- the world to screen coordinate transform
-
addMapPaneListener
void addMapPaneListener(MapPaneListener listener)
Adds a listener to receiveMapPaneEvent
s.- Parameters:
listener
- the listener to add- Throws:
IllegalArgumentException
- iflistener
isnull
-
removeMapPaneListener
void removeMapPaneListener(MapPaneListener listener)
Removes the specified listener.- Parameters:
listener
- the listener to remove
-
addMouseListener
void addMouseListener(MapMouseListener listener)
Registers an object that wishes to receiveMapMouseEvent
s such as a JMapStatusBar.- Parameters:
listener
- the listener to add- Throws:
IllegalArgumentException
- if listener is null- See Also:
MapMouseListener
-
removeMouseListener
void removeMouseListener(MapMouseListener listener)
Removes the specified listener.- Parameters:
listener
- the listener to remove
-
getCursorTool
CursorTool getCursorTool()
Gets the current cursor tool.- Returns:
- the current cursor tool (may be
null
)
-
setCursorTool
void setCursorTool(CursorTool tool)
Sets the current cursor tool.- Parameters:
tool
- the tool; ornull
for no cursor tool
-
moveImage
void moveImage(int dx, int dy)
Moves the image(s) displayed by the map pane from the current origin (x,y) (device pixels) to (x+dx, y+dy). If this method is called when the map pane is not visible, or when the pane's visible rectangle is empty, it is ignored.- Parameters:
dx
- the x offset in pixelsdy
- the y offset in pixels.
-
-