Package org.geotools.swing.tool
Class InfoToolHelper
- Object
- 
- InfoToolHelper
 
- 
- All Implemented Interfaces:
- EventListener,- MapBoundsListener
 - Direct Known Subclasses:
- FeatureLayerHelper,- GridCoverageLayerHelper,- GridReaderLayerHelper
 
 public abstract class InfoToolHelper extends Object implements MapBoundsListener Abstract base class for helper classes used by InfoTool to query features in map layers.- Since:
- 2.6
- Author:
- Michael Bedward
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected WeakReference<MapContent>contentRefstatic StringKEY_POSITIONString key used for the position element in theMappassed to getInfo(org.geotools.geometry.Position2D).protected WeakReference<Layer>layerRef
 - 
Constructor SummaryConstructors Constructor Description InfoToolHelper()
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidclearTransform()protected MathTransformgetContentToLayerTransform()Gets theMathTransformused to convert coordinates from the projection being used by theMapContentto that of theLayer.abstract InfoToolResultgetInfo(Position2D pos)Gets layer data at the specified position.LayergetLayer()Gets the map layer associated with this helper.MapContentgetMapContent()Gets the map content associated with this helper.abstract booleanisSupportedLayer(Layer layer)Called by the helper lookup system when selecting a helper for a given layer.protected booleanisTransformRequired()booleanisValid()Checks if this helper is holding a reference to aMapContentand aLayer.Helpers only hold aWeakReferenceto both the map content and layer to avoid blocking garbage collection when layers are discarded.voidmapBoundsChanged(MapBoundsEvent event)A method from theMapBoundsListenerinterface used to listen for a change to the map content's coordinate reference system.voidsetLayer(Layer layer)Sets the map layer for this helper.voidsetMapContent(MapContent content)Sets the map content for this helper.
 
- 
- 
- 
Field Detail- 
KEY_POSITIONpublic static final String KEY_POSITION String key used for the position element in theMappassed to getInfo(org.geotools.geometry.Position2D).- See Also:
- Constant Field Values
 
 - 
contentRefprotected WeakReference<MapContent> contentRef 
 - 
layerRefprotected WeakReference<Layer> layerRef 
 
- 
 - 
Method Detail- 
isSupportedLayerpublic abstract boolean isSupportedLayer(Layer layer) Called by the helper lookup system when selecting a helper for a given layer.- Parameters:
- layer- the layer
- Returns:
- trueis this helper can handle the layer
- Throws:
- IllegalArgumentException- if- layeris- null
 
 - 
getInfopublic abstract InfoToolResult getInfo(Position2D pos) throws Exception Gets layer data at the specified position. If there are no feature data at the position, an emptyInfoToolResultobject is returned.- Parameters:
- pos- query position
- Returns:
- layer data
- Throws:
- Exception- on error querying the layer
 
 - 
isValidpublic boolean isValid() Checks if this helper is holding a reference to aMapContentand aLayer.Helpers only hold aWeakReferenceto both the map content and layer to avoid blocking garbage collection when layers are discarded.- Returns:
- trueif both map content and layer references are valid
 
 - 
setMapContentpublic void setMapContent(MapContent content) Sets the map content for this helper.- Parameters:
- content- the map content
- Throws:
- IllegalArgumentException- if- contentis- null
 
 - 
getMapContentpublic MapContent getMapContent() Gets the map content associated with this helper.- Returns:
- the map content
 
 - 
setLayerpublic void setLayer(Layer layer) Sets the map layer for this helper.- Parameters:
- layer- the map layer
- Throws:
- IllegalArgumentException- if- layeris- null
 
 - 
getLayerpublic Layer getLayer() Gets the map layer associated with this helper.
 - 
mapBoundsChangedpublic void mapBoundsChanged(MapBoundsEvent event) A method from theMapBoundsListenerinterface used to listen for a change to the map content's coordinate reference system.- Specified by:
- mapBoundsChangedin interface- MapBoundsListener
- Parameters:
- event- The change event.
 
 - 
getContentToLayerTransformprotected MathTransform getContentToLayerTransform() Gets theMathTransformused to convert coordinates from the projection being used by theMapContentto that of theLayer.- Returns:
- the transform or nullif the layer's CRS is the same as that of the map content, or if either has no CRS defined
 
 - 
isTransformRequiredprotected boolean isTransformRequired() 
 - 
clearTransformprotected void clearTransform() 
 
- 
 
-