org.geotools.swt.tool
Class InfoTool

Object
  extended by MapMouseAdapter
      extended by CursorTool
          extended by InfoTool
All Implemented Interfaces:
MapMouseListener

public class InfoTool
extends CursorTool

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. The primary reason for this design is to shield this class from the grid coverage classes so that users who are working purely with vector data are not forced to have JAI in the classpath.

Since:
2.6
Author:
Michael Bedward
See Also:
InfoToolHelper

Field Summary
static double DEFAULT_DISTANCE_FRACTION
          Default distance fraction used with line and point features.
static String TOOL_NAME
          The tool name
static String TOOL_TIP
          Tool tip text
 
Fields inherited from class CursorTool
ANY_BUTTON
 
Constructor Summary
InfoTool()
          Constructs a new info tool which is triggered by any mouse button.
InfoTool(int triggerButtonMask)
          Constructs a new info tool.
 
Method Summary
 boolean canDraw()
          Checks if the tool can draw when dragging.
 boolean canMove()
          Checks if the tool can move the map when dragging.
 Cursor getCursor()
          Get the cursor for this tool.
 void onMouseClicked(MapMouseEvent ev)
          Respond to a mouse click by querying each of the MapLayers.
 
Methods inherited from class CursorTool
getMapPane, isDrawing, isTriggerMouseButton, setMapPane
 
Methods inherited from class MapMouseAdapter
onMouseDragged, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onMouseWheelMoved
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TOOL_NAME

public static final String TOOL_NAME
The tool name


TOOL_TIP

public static final String TOOL_TIP
Tool tip text


DEFAULT_DISTANCE_FRACTION

public static final double DEFAULT_DISTANCE_FRACTION
Default distance fraction used with line and point features. When the user clicks on the map, this tool searches for features within a rectangle of width w centred on the mouse location, where w is the average map side length multiplied by the value of this constant.

See Also:
Constant Field Values
Constructor Detail

InfoTool

public InfoTool(int triggerButtonMask)
Constructs a new info tool. To activate the tool only on certain mouse events provide a single mask, e.g. SWT.BUTTON1, or a combination of multiple SWT-masks.

Parameters:
triggerButtonMask - Mouse button which triggers the tool's activation or if the tool is to be triggered by any button

InfoTool

public InfoTool()
Constructs a new info tool which is triggered by any mouse button.

Method Detail

onMouseClicked

public void onMouseClicked(MapMouseEvent ev)
Respond to a mouse click by querying each of the MapLayers. 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 MapLayers. 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:
onMouseClicked in interface MapMouseListener
Overrides:
onMouseClicked in class MapMouseAdapter
Parameters:
ev - mouse event
See Also:
JTextReporter, InfoToolHelper

getCursor

public Cursor getCursor()
Description copied from class: CursorTool
Get the cursor for this tool. Sub-classes should override this method to provide a custom cursor.

Overrides:
getCursor in class CursorTool
Returns:
the default cursor

canDraw

public boolean canDraw()
Description copied from class: CursorTool
Checks if the tool can draw when dragging.

Specified by:
canDraw in class CursorTool
Returns:
true if the tool can draw.

canMove

public boolean canMove()
Description copied from class: CursorTool
Checks if the tool can move the map when dragging.

Specified by:
canMove in class CursorTool
Returns:
true if the tool can move the map while dragging.


Copyright © 1996-2014 Geotools. All Rights Reserved.