|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectWidget
Control
Scrollable
Composite
Canvas
SwtMapPane
public class SwtMapPane
A map display pane that works with a GTRenderer and MapContext to display features. It supports the use of tool classes to implement, for example, mouse-controlled zooming and panning.
Rendering is performed on a background thread and is managed by the RenderingExecutor class.
Adapted from original code by Ian Turton.
Field Summary | |
---|---|
static int |
DEFAULT_RESIZING_PAINT_DELAY
Default delay (milliseconds) before the map will be redrawn when resizing the pane. |
Fields inherited from class Control |
---|
handle |
Constructor Summary | |
---|---|
SwtMapPane(Composite parent,
int style)
Constructor - creates an instance of JMapPane with no map context or renderer initially |
|
SwtMapPane(Composite parent,
int style,
GTRenderer renderer,
MapContent content)
Constructor - creates an instance of JMapPane with the given renderer and map context. |
Method Summary | |
---|---|
void |
addMapPaneListener(MapPaneListener listener)
Register an object that wishes to receive MapPaneEvent s |
void |
addMouseListener(MapMouseListener listener)
Register an object that wishes to receive MapMouseEvent s
such as a org.geotools.swing.StatusBar |
RenderedImage |
getBaseImage()
Retrieve the map pane's current base image. |
Color |
getCursorToolColor()
Returns the colour which is used to draw the bounding box of the currently active cursor tool. |
int |
getCursorToolLineStyle()
Returns the line style of the bounding box of the currently active cursor tool. |
int |
getCursorToolLineWidth()
Returns the line width of the bounding box of the currently active cursor tool. |
ReferencedEnvelope |
getDisplayArea()
Return a (copy of) the currently displayed map area. |
MapContent |
getMapContent()
Get the map content associated with this map pane |
GTRenderer |
getRenderer()
Get the renderer being used by this map pane |
int |
getResizeDelay()
Get the length of the delay period between the pane being resized and the next repaint. |
AffineTransform |
getScreenToWorldTransform()
Get a (copy of) the screen to world coordinate transform being used by this map pane. |
Rectangle |
getVisibleRect()
|
AffineTransform |
getWorldToScreenTransform()
Get a (copy of) the world to screen coordinate transform being used by this map pane. |
void |
handleEvent(Event event)
|
boolean |
isAcceptingRepaints()
Query whether the map pane is currently accepting or ignoring repaint requests from other GUI components and the system. |
void |
layerAdded(MapLayerListEvent event)
Called when a new map layer has been added. |
void |
layerChanged(MapLayerListEvent event)
Called when a map layer has changed, e.g. features added to a displayed feature collection |
void |
layerMoved(MapLayerListEvent event)
Called when the bounds of a map layer have changed |
void |
layerPreDispose(MapLayerListEvent event)
Triggered when a layer is about to be disposed. |
void |
layerRemoved(MapLayerListEvent event)
Called when a map layer has been removed |
void |
mapBoundsChanged(MapBoundsEvent event)
Called by the map context when its bounds have changed. |
void |
moveImage(int dx,
int dy)
Move the image currently displayed by the map pane from its current origin (x,y) to (x+dx, y+dy). |
void |
onRenderingCancelled()
Called by the SwtMapPane.RenderingTask when rendering was cancelled. |
void |
onRenderingCompleted()
Called by the SwtMapPane.RenderingTask when rendering has been completed Publishes a MapPaneEvent of type MapPaneEvent.Type.RENDERING_STOPPED to listeners. |
void |
onRenderingFailed()
Called by the SwtMapPane.RenderingTask when rendering failed. |
void |
onRenderingRejected()
Called when a rendering request has been rejected. |
void |
removeMouseListener(MapMouseListener listener)
Unregister the MapMouseListener object. |
void |
reset()
Reset the map area to include the full extent of all layers and redraw the display |
void |
setBaseImageAlpha(int alpha)
Sets the transparency value for the base image (overlays not considered). |
void |
setCrs(CoordinateReferenceSystem crs)
|
void |
setCursorTool(CursorTool tool)
Set the current cursor tool |
void |
setCursorToolColor(Color color)
Sets the colour which is used to draw the bounding box of the currently active cursor tool. |
void |
setCursorToolLineStyle(int lineStyle)
Sets the line style of the bounding box of the currently active cursor tool. |
void |
setCursorToolLineWidth(int lineWidth)
Sets the line width of the bounding box of the currently active cursor tool. |
void |
setDisplayArea(Envelope envelope)
Sets the area to display by calling the MapContext#setAreaOfInterest method of this pane's map context. |
void |
setMapContent(MapContent content)
Set the map context for this map pane to display |
void |
setMapLayerTable(MapLayerComposite layerTable)
Register a MapLayerComposite object to be receive layer change events from this map pane and to control layer ordering, visibility and selection. |
void |
setOverlay(Image overlayImage,
ReferencedEnvelope overlayEnvelope,
boolean overlayDoXor,
boolean boundsChanged)
Define an image that has to be set as overlay. |
void |
setRenderer(GTRenderer renderer)
Set the renderer for this map pane. |
void |
setRepaint(boolean repaint)
Specify whether the map pane should defer its normal repainting behaviour. |
void |
setResizeDelay(int delay)
Set the length of the delay period between the pane being resized and the next repaint. |
Methods inherited from class Canvas |
---|
drawBackground, getCaret, getIME, scroll, setCaret, setFont, setIME |
Methods inherited from class Composite |
---|
changed, checkSubclass, computeSize, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList |
Methods inherited from class Scrollable |
---|
computeTrim, getClientArea, getHorizontalBar, getVerticalBar |
Methods inherited from class Control |
---|
addControlListener, addDragDetectListener, addFocusListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getRegion, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setRegion, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update |
Methods inherited from class Widget |
---|
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_RESIZING_PAINT_DELAY
Constructor Detail |
---|
public SwtMapPane(Composite parent, int style)
public SwtMapPane(Composite parent, int style, GTRenderer renderer, MapContent content)
renderer
- a renderer objectcontent
- an instance of MapContextMethod Detail |
---|
public void setCursorTool(CursorTool tool)
tool
- the tool to set; null means no active cursor toolpublic void addMouseListener(MapMouseListener listener)
MapMouseEvent
s
such as a org.geotools.swing.StatusBar
listener
- an object that implements MapMouseListener
IllegalArgumentException
- if listener is nullMapMouseListener
public void removeMouseListener(MapMouseListener listener)
MapMouseListener
object.
listener
- the listener to remove
IllegalArgumentException
- if listener is nullpublic void addMapPaneListener(MapPaneListener listener)
MapPaneEvent
s
listener
- an object that implements MapPaneListener
MapPaneListener
public void setMapLayerTable(MapLayerComposite layerTable)
layerTable
- an instance of MapLayerTable
IllegalArgumentException
- if layerTable is nullpublic GTRenderer getRenderer()
public void setRenderer(GTRenderer renderer)
renderer
- the renderer to usepublic MapContent getMapContent()
public void setMapContent(MapContent content)
content
- the map contextpublic ReferencedEnvelope getDisplayArea()
Note, this will not always be the same as the envelope returned by
MapContext.getAreaOfInterest()
. For example, when the
map is displayed at the full extent of all layers
MapContext.getAreaOfInterest()
will return the union of the
layer bounds while this method will return an evnelope that can
included extra space beyond the bounds of the layers.
ReferencedEnvelope
public void setCrs(CoordinateReferenceSystem crs)
public void setDisplayArea(Envelope envelope)
The map area that ends up being displayed will often be larger than the requested display area. For instance, if the square area is requested, but the map pane's screen area is a rectangle with width greater than height, then the displayed area will be centred on the requested square but include additional area on each side.
You can pass any GeoAPI Envelope implementation to this method such as ReferenedEnvelope or Envelope2D.
Note: This method does not check that the requested area overlaps the bounds of the current map layers.
envelope
- the bounds of the map to display
IllegalStateException
- if a map context is not setpublic void reset()
public void setRepaint(boolean repaint)
Typical use:
myMapPane.setRepaint(false);
// do various things that would cause time-consuming
// re-paints normally
myMapPane.setRepaint(true);
myMapPane.repaint();
repaint
- if true, paint requests will be handled normally;
if false, paint requests will be deferred.isAcceptingRepaints()
public boolean isAcceptingRepaints()
setRepaint(boolean)
public RenderedImage getBaseImage()
The map pane caches the most recent rendering of map layers as an image to avoid time-consuming rendering requests whenever possible. The base image will be re-drawn whenever there is a change to map layer data, style or visibility; and it will be replaced by a new image when the pane is resized.
This method returns a live reference to the current base image. Use with caution.
public int getResizeDelay()
The map pane imposes a delay between resize events and repainting to avoid flickering of the display during drag-resizing.
public void setResizeDelay(int delay)
The map pane imposes a delay between resize events and repainting to avoid flickering of the display during drag-resizing.
delay
- the delay in milliseconds; if <
0 the default delay
period will be setpublic AffineTransform getScreenToWorldTransform()
public AffineTransform getWorldToScreenTransform()
double scale = mapPane.getWorldToScreenTransform().getScaleX();
public void moveImage(int dx, int dy)
PanTool
.
dx
- the x offset in pixelsdy
- the y offset in pixels.public void onRenderingCompleted()
MapPaneEvent.Type.RENDERING_STOPPED
to listeners.
MapPaneListener#onRenderingStopped(org.geotools.swing.event.MapPaneEvent)
public void onRenderingCancelled()
MapPaneEvent.Type.RENDERING_STOPPED
to listeners.
MapPaneListener#onRenderingStopped(org.geotools.swing.event.MapPaneEvent)
public void onRenderingFailed()
MapPaneEvent.Type.RENDERING_STOPPED
to listeners.
MapPaneListener#onRenderingStopped(org.geotools.swing.event.MapPaneEvent)
public void onRenderingRejected()
public void layerAdded(MapLayerListEvent event)
layerAdded
in interface MapLayerListListener
event
- encapsulating the event informationpublic void layerRemoved(MapLayerListEvent event)
layerRemoved
in interface MapLayerListListener
event
- encapsulating the event informationpublic void layerChanged(MapLayerListEvent event)
layerChanged
in interface MapLayerListListener
event
- encapsulating the event informationpublic void layerMoved(MapLayerListEvent event)
layerMoved
in interface MapLayerListListener
event
- encapsulating the event informationpublic void mapBoundsChanged(MapBoundsEvent event)
mapBoundsChanged
in interface MapBoundsListener
event
- The change event.public Rectangle getVisibleRect()
public void setOverlay(Image overlayImage, ReferencedEnvelope overlayEnvelope, boolean overlayDoXor, boolean boundsChanged)
The image will be scaled to fit into the supplied envelope.
overlayImage
- the image to overlay.overlayEnvelope
- the envelope it has to cover.overlayDoXor
- flag for Xor mode.public void setBaseImageAlpha(int alpha)
alpha
- the transparency value (0 - 255).public void handleEvent(Event event)
handleEvent
in interface Listener
public void layerPreDispose(MapLayerListEvent event)
MapLayerListListener
layerPreDispose
in interface MapLayerListListener
event
- encapsulating the event informationpublic Color getCursorToolColor()
public void setCursorToolColor(Color color)
color
- the colour used for the tool's bounding boxpublic int getCursorToolLineWidth()
public void setCursorToolLineWidth(int lineWidth)
lineWidth
- line widthpublic int getCursorToolLineStyle()
public void setCursorToolLineStyle(int lineStyle)
lineStyle
- line styleSWT.LINE_SOLID
,
SWT.LINE_DASH
,
SWT.LINE_DOT
,
SWT.LINE_DASHDOT
,
SWT.LINE_DASHDOTDOT
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |