public class InfoTool extends CursorTool implements TextReporterListener
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
}
};
| Modifier and Type | Field and Description |
|---|---|
static Point |
CURSOR_HOTSPOT
Cursor hotspot coordinates
|
static String |
CURSOR_IMAGE
Cursor
|
static String |
ICON_IMAGE
Icon for the control
|
static String |
TOOL_NAME
The tool name
|
static String |
TOOL_TIP
Tool tip text
|
| Constructor and Description |
|---|
InfoTool()
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
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).
|
Cursor |
getCursor()
Get the cursor for this tool.
|
JTextReporter.Connection |
getTextReporterConnection()
Gets the connection to the text reporter displayed by this tool.
|
void |
onMouseClicked(MapMouseEvent ev)
Respond to a mouse click by querying each of the
Layers. |
void |
onReporterClosed()
Called when a
JTextReporter dialog used by this tool is closed. |
void |
onReporterUpdated()
Called when text is updated in a JTextReporter dialog being used by this tool.
|
getMapPane, setMapPaneonMouseDragged, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onMouseWheelMovedpublic static final String TOOL_NAME
public static final String TOOL_TIP
public static final String CURSOR_IMAGE
public static final Point CURSOR_HOTSPOT
public static final String ICON_IMAGE
public void onMouseClicked(MapMouseEvent ev)
Layers. The details of features
lying within the threshold distance of the mouse position are reported on screen using a
JTextReporter dialog.
Implementation note: An instance of InfoToolHelper is created and cached
for each of the Layers. 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.
onMouseClicked in interface MapMouseListeneronMouseClicked in class MapMouseAdapterev - mouse eventJTextReporter,
InfoToolHelperpublic JTextReporter.Connection getTextReporterConnection()
null if 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().
null if the reporter dialog is not currently
displayedpublic Cursor getCursor()
CursorToolgetCursor in class CursorToolpublic boolean drawDragBox()
drawDragBox in class CursorToolpublic void onReporterClosed()
JTextReporter dialog used by this tool is closed.onReporterClosed in interface TextReporterListenerpublic void onReporterUpdated()
onReporterUpdated in interface TextReporterListenerCopyright © 1996–2019 Geotools. All rights reserved.