Package org.geotools.swing.tool
Class InfoToolHelper
Object
InfoToolHelper
- All Implemented Interfaces:
EventListener
,MapBoundsListener
- Direct Known Subclasses:
FeatureLayerHelper
,GridCoverageLayerHelper
,GridReaderLayerHelper
Abstract base class for helper classes used by InfoTool to query features in map layers.
- Since:
- 2.6
- Author:
- Michael Bedward
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected WeakReference<MapContent>
static final String
String key used for the position element in theMap
passed to getInfo(org.geotools.geometry.Position2D).protected WeakReference<Layer>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected MathTransform
Gets theMathTransform
used to convert coordinates from the projection being used by theMapContent
to that of theLayer
.abstract InfoToolResult
getInfo
(Position2D pos) Gets layer data at the specified position.getLayer()
Gets the map layer associated with this helper.Gets the map content associated with this helper.abstract boolean
isSupportedLayer
(Layer layer) Called by the helper lookup system when selecting a helper for a given layer.protected boolean
boolean
isValid()
Checks if this helper is holding a reference to aMapContent
and aLayer
.Helpers only hold aWeakReference
to both the map content and layer to avoid blocking garbage collection when layers are discarded.void
mapBoundsChanged
(MapBoundsEvent event) A method from theMapBoundsListener
interface used to listen for a change to the map content's coordinate reference system.void
Sets the map layer for this helper.void
setMapContent
(MapContent content) Sets the map content for this helper.
-
Field Details
-
KEY_POSITION
String key used for the position element in theMap
passed to getInfo(org.geotools.geometry.Position2D).- See Also:
-
contentRef
-
layerRef
-
-
Constructor Details
-
InfoToolHelper
public InfoToolHelper()
-
-
Method Details
-
isSupportedLayer
Called by the helper lookup system when selecting a helper for a given layer.- Parameters:
layer
- the layer- Returns:
true
is this helper can handle the layer- Throws:
IllegalArgumentException
- iflayer
isnull
-
getInfo
Gets layer data at the specified position. If there are no feature data at the position, an emptyInfoToolResult
object is returned.- Parameters:
pos
- query position- Returns:
- layer data
- Throws:
Exception
- on error querying the layer
-
isValid
public boolean isValid()Checks if this helper is holding a reference to aMapContent
and aLayer
.Helpers only hold aWeakReference
to both the map content and layer to avoid blocking garbage collection when layers are discarded.- Returns:
true
if both map content and layer references are valid
-
setMapContent
Sets the map content for this helper.- Parameters:
content
- the map content- Throws:
IllegalArgumentException
- ifcontent
isnull
-
getMapContent
Gets the map content associated with this helper.- Returns:
- the map content
-
setLayer
Sets the map layer for this helper.- Parameters:
layer
- the map layer- Throws:
IllegalArgumentException
- iflayer
isnull
-
getLayer
Gets the map layer associated with this helper. -
mapBoundsChanged
A method from theMapBoundsListener
interface used to listen for a change to the map content's coordinate reference system.- Specified by:
mapBoundsChanged
in interfaceMapBoundsListener
- Parameters:
event
- The change event.
-
getContentToLayerTransform
Gets theMathTransform
used to convert coordinates from the projection being used by theMapContent
to that of theLayer
.- Returns:
- the transform or
null
if the layer's CRS is the same as that of the map content, or if either has no CRS defined
-
isTransformRequired
protected boolean isTransformRequired() -
clearTransform
protected void clearTransform()
-