org.geotools.gui.tools
Class AbstractTool

java.lang.Object
  extended byorg.geotools.gui.tools.AbstractTool
All Implemented Interfaces:
java.util.EventListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, Tool
Direct Known Subclasses:
ClickZoomToolImpl, PanToolImpl

public abstract class AbstractTool
extends java.lang.Object
implements Tool, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

Base class for all the geotools Tools, like PanTool, ZoomTool, etc. Tools process mouse events on behalf of widgets like MapPane and change data in the Context (like the AreaOfInterest).

Version:
$Id: AbstractTool.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Cameron Shorter

Field Summary
protected  MapContext context
          A tool is associated with only one context.
 
Constructor Summary
AbstractTool()
           
 
Method Summary
protected  void addMouseListener(java.awt.Component component, MapContext context, java.awt.event.MouseListener listener)
          Register this tool to receive MouseEvents from component.
protected  void addMouseMotionListener(java.awt.Component component, MapContext context, java.awt.event.MouseMotionListener listener)
          Register this tool to receive MouseMotionEvents from component.
 void destroy()
          Clean up this class.
 MapContext getContext()
          Get the context.
 java.awt.Cursor getCursor()
          Return the prefered cursor for this tool.
 java.lang.String getName()
          Get the name of the tool.
 void mouseClicked(java.awt.event.MouseEvent e)
          Invoked when the mouse button has been clicked (pressed and released) on a component.
 void mouseDragged(java.awt.event.MouseEvent e)
          Invoked when a mouse button is pressed on a component and then dragged.
 void mouseEntered(java.awt.event.MouseEvent e)
          Invoked when the mouse enters a component.
 void mouseExited(java.awt.event.MouseEvent e)
          Invoked when the mouse exits a component.
 void mouseMoved(java.awt.event.MouseEvent e)
          Invoked when the mouse button has been moved on a component (with no buttons down).
 void mousePressed(java.awt.event.MouseEvent e)
          Invoked when a mouse button has been pressed on a component.
 void mouseReleased(java.awt.event.MouseEvent e)
          Invoked when a mouse button has been released on a component.
 void paint(java.awt.Graphics g)
           
 void removeMouseListeners()
          Remove all Mouse Listeners from this tool.
 void setCursor(java.awt.Cursor cursor)
          Set the cursor for this Tool.
 void setName(java.lang.String name)
          Set the name for the tool, eg "Zoom In", "Zoom Out", "Pan".
 java.lang.String toString()
          Return the name of the tool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.geotools.gui.tools.Tool
addMouseListener, addMouseMotionListener
 

Field Detail

context

protected MapContext context
A tool is associated with only one context. The context stores all data about a mapping model. This tool will change data in context classes.

Constructor Detail

AbstractTool

public AbstractTool()
Method Detail

addMouseListener

protected void addMouseListener(java.awt.Component component,
                                MapContext context,
                                java.awt.event.MouseListener listener)
Register this tool to receive MouseEvents from component.

Parameters:
component - The tool will process mouseEvents from this component.
context - The Context that will be changed by this Tool.
listener - The tool to send mouseEvents to, usually the child of this class.
Throws:
java.lang.IllegalArgumentException - if an argument is null or the tool is being assigned a different context to before.

addMouseMotionListener

protected void addMouseMotionListener(java.awt.Component component,
                                      MapContext context,
                                      java.awt.event.MouseMotionListener listener)
                               throws java.lang.IllegalArgumentException
Register this tool to receive MouseMotionEvents from component.

Parameters:
component - The tool will process mouseMotionEvents from this component.
listener - The tool to send mouseMotionEvents to, usually the child of his class.
Throws:
java.lang.IllegalArgumentException - if an argument is null or the tool is being assigned a different context to before.

removeMouseListeners

public void removeMouseListeners()
Remove all Mouse Listeners from this tool. This method should be called when this tool is deselected from a MapPane.

Specified by:
removeMouseListeners in interface Tool

getContext

public MapContext getContext()
Get the context. If context has not been set yet, then null is returned.

Specified by:
getContext in interface Tool
Returns:
The context of this tool.

getCursor

public java.awt.Cursor getCursor()
Return the prefered cursor for this tool.

Specified by:
getCursor in interface Tool
Returns:
cursor The prefered cursor for this tool.

setCursor

public void setCursor(java.awt.Cursor cursor)
Set the cursor for this Tool.

Specified by:
setCursor in interface Tool
Parameters:
cursor - The cursor to associate with this tool.

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Invoked when the mouse button has been clicked (pressed and released) on a component.

Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Invoked when the mouse enters a component.

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Invoked when the mouse exits a component.

Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Invoked when a mouse button has been pressed on a component.

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Invoked when a mouse button has been released on a component.

Specified by:
mouseReleased in interface java.awt.event.MouseListener

destroy

public void destroy()
Clean up this class.

Specified by:
destroy in interface Tool

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Invoked when a mouse button is pressed on a component and then dragged. MOUSE_DRAGGED events will continue to be delivered to the component where the drag originated until the mouse button is released (regardless of whether the mouse position is within the bounds of the component).

Due to platform-dependent Drag&Drop implementations, MOUSE_DRAGGED events may not be delivered during a native Drag&Drop operation.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Invoked when the mouse button has been moved on a component (with no buttons down).

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

paint

public void paint(java.awt.Graphics g)
Specified by:
paint in interface Tool

setName

public void setName(java.lang.String name)
Set the name for the tool, eg "Zoom In", "Zoom Out", "Pan".

Specified by:
setName in interface Tool
Parameters:
name - what to call this tool.

getName

public java.lang.String getName()
Get the name of the tool.

Specified by:
getName in interface Tool
Returns:
The name of this tool.

toString

public java.lang.String toString()
Return the name of the tool.



Copyright © GeoTools. All Rights Reserved.