Package org.geotools.swing.tool
Class InfoTool
- Object
-
- MapMouseAdapter
-
- CursorTool
-
- InfoTool
-
- All Implemented Interfaces:
TextReporterListener,MapMouseListener
public class InfoTool extends CursorTool implements TextReporterListener
A cursor tool to retrieve information about features that the user clicks on with the mouse. It works with InfoToolHelper objects which do the work of querying feature data.Feature information is displayed on screen using a JTextReporter dialog. If you want to access the displayed text programmatically you can override the onReporterUpdated() method as shown here:
InfoTool tool = new InfoTool() { @Override public void onReporterUpdated() { String text = getTextReporterConnection().getText(); // do something with text } };- Since:
- 2.6
- Author:
- Michael Bedward
-
-
Field Summary
Fields Modifier and Type Field Description static PointCURSOR_HOTSPOTCursor hotspot coordinatesstatic StringCURSOR_IMAGECursorstatic StringICON_IMAGEIcon for the controlstatic StringTOOL_NAMEThe tool namestatic StringTOOL_TIPTool tip text
-
Constructor Summary
Constructors Constructor Description InfoTool()Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandrawDragBox()Query if the tool is one that draws a box on the map display when the mouse is being dragged (eg. to indicate a zoom area).CursorgetCursor()Get the cursor for this tool.JTextReporter.ConnectiongetTextReporterConnection()Gets the connection to the text reporter displayed by this tool.voidonMouseClicked(MapMouseEvent ev)Respond to a mouse click by querying each of theLayers.voidonReporterClosed()Called when aJTextReporterdialog used by this tool is closed.voidonReporterUpdated()Called when text is updated in a JTextReporter dialog being used by this tool.-
Methods inherited from class CursorTool
getMapPane, setMapPane
-
Methods inherited from class MapMouseAdapter
onMouseDragged, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onMouseWheelMoved
-
-
-
-
Field Detail
-
TOOL_NAME
public static final String TOOL_NAME
The tool name
-
TOOL_TIP
public static final String TOOL_TIP
Tool tip text
-
CURSOR_IMAGE
public static final String CURSOR_IMAGE
Cursor- See Also:
- Constant Field Values
-
CURSOR_HOTSPOT
public static final Point CURSOR_HOTSPOT
Cursor hotspot coordinates
-
ICON_IMAGE
public static final String ICON_IMAGE
Icon for the control- See Also:
- Constant Field Values
-
-
Method Detail
-
onMouseClicked
public void onMouseClicked(MapMouseEvent ev)
Respond to a mouse click by querying each of theLayers. The details of features lying within the threshold distance of the mouse position are reported on screen using aJTextReporterdialog.Implementation note: An instance of
InfoToolHelperis created and cached for each of theLayers. The helpers are created using reflection to avoid direct references to grid coverage classes here that would required JAI (Java Advanced Imaging) to be on the classpath even when only vector layers are being used.- Specified by:
onMouseClickedin interfaceMapMouseListener- Overrides:
onMouseClickedin classMapMouseAdapter- Parameters:
ev- mouse event- See Also:
JTextReporter,InfoToolHelper
-
getTextReporterConnection
public JTextReporter.Connection getTextReporterConnection()
Gets the connection to the text reporter displayed by this tool. Returnsnullif the reporter dialog is not currently displayed. The connection should not be stored because it will expire when the reporter dialog is closed.This method was added for unit test purposes but may be useful for applications wishing to access the feature data report text, e.g. by overriding onReporterUpdated().
- Returns:
- the text reporter connection or
nullif the reporter dialog is not currently displayed
-
getCursor
public Cursor getCursor()
Description copied from class:CursorToolGet the cursor for this tool. Sub-classes should override this method to provide a custom cursor.- Overrides:
getCursorin classCursorTool- Returns:
- the default cursor
-
drawDragBox
public boolean drawDragBox()
Query if the tool is one that draws a box on the map display when the mouse is being dragged (eg. to indicate a zoom area).- Overrides:
drawDragBoxin classCursorTool- Returns:
- Always returns false
-
onReporterClosed
public void onReporterClosed()
Called when aJTextReporterdialog used by this tool is closed.- Specified by:
onReporterClosedin interfaceTextReporterListener
-
onReporterUpdated
public void onReporterUpdated()
Called when text is updated in a JTextReporter dialog being used by this tool. This is an empty method but may be useful to override.- Specified by:
onReporterUpdatedin interfaceTextReporterListener
-
-