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
Modifier and TypeMethodDescriptionvoidaddMapPaneListener(MapPaneListener listener) Adds a listener to receiveMapPaneEvents.voidaddMouseListener(MapMouseListener listener) Registers an object that wishes to receiveMapMouseEvents such as a JMapStatusBar.Gets the current cursor tool.Gets the current display area in world coordinates.Gets theMapConentinstance containing the layers being displayed by this map pane.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.Gets the screen to world coordinate transform.Gets the world to screen coordinate transform.voidmoveImage(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).voidremoveMapPaneListener(MapPaneListener listener) Removes the specified listener.voidremoveMouseListener(MapMouseListener listener) Removes the specified listener.voidreset()Reset the map area to include the full extent of all layers and redraw the displayvoidsetCursorTool(CursorTool tool) Sets the current cursor tool.voidsetDisplayArea(Bounds envelope) Sets the area to display in world units.voidsetMapContent(MapContent content) Sets theMapContentinstance containing the layers to display.voidsetMouseEventDispatcher(MapMouseEventDispatcher dispatcher) Replaces the current mouse event dispatcher.
-
Method Details
-
getMapContent
MapContent getMapContent()Gets theMapConentinstance containing the layers being displayed by this map pane.- Returns:
- the map content
-
setMapContent
Sets theMapContentinstance 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
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 emptyReferencedEnvelopeis returned.- Returns:
- the display area in world coordinates
-
setDisplayArea
Sets the area to display in world units.- Parameters:
envelope- the new display area- Throws:
IllegalArgumentException- ifenvelopeisnull
-
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
AffineTransformcan be used to determine the current drawing scale...double scale = mapPane.getWorldToScreenTransform().getScaleX();- Returns:
- the world to screen coordinate transform
-
addMapPaneListener
Adds a listener to receiveMapPaneEvents.- Parameters:
listener- the listener to add- Throws:
IllegalArgumentException- iflistenerisnull
-
removeMapPaneListener
Removes the specified listener.- Parameters:
listener- the listener to remove
-
addMouseListener
Registers an object that wishes to receiveMapMouseEvents such as a JMapStatusBar.- Parameters:
listener- the listener to add- Throws:
IllegalArgumentException- if listener is null- See Also:
-
removeMouseListener
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
Sets the current cursor tool.- Parameters:
tool- the tool; ornullfor 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.
-