CH.ifa.draw.standard
Class AbstractTool

java.lang.Object
  extended by CH.ifa.draw.standard.AbstractTool
All Implemented Interfaces:
Tool
Direct Known Subclasses:
ActionTool, ConnectionTool, CreationTool, DragTracker, HandleTracker, PolygonTool, ScribbleTool, SelectAreaTracker, SelectionTool, URLTool

public class AbstractTool
extends java.lang.Object
implements Tool

Default implementation support for Tools.

See Also:
DrawingView, Tool

Field Summary
protected  int fAnchorX
          The position of the initial mouse down.
protected  int fAnchorY
          The position of the initial mouse down.
protected  DrawingView fView
           
 
Constructor Summary
AbstractTool(DrawingView itsView)
          Constructs a tool for the given view.
 
Method Summary
 void activate()
          Activates the tool for the given view.
 void deactivate()
          Deactivates the tool.
 Drawing drawing()
          Gets the tool's drawing.
 DrawingEditor editor()
          Gets the tool's editor.
 void keyDown(java.awt.event.KeyEvent evt, int key)
          Handles key down events in the drawing view.
 void mouseDown(java.awt.event.MouseEvent e, int x, int y)
          Handles mouse down events in the drawing view.
 void mouseDrag(java.awt.event.MouseEvent e, int x, int y)
          Handles mouse drag events in the drawing view.
 void mouseMove(java.awt.event.MouseEvent evt, int x, int y)
          Handles mouse moves (if the mouse button is up).
 void mouseUp(java.awt.event.MouseEvent e, int x, int y)
          Handles mouse up in the drawing view.
 DrawingView view()
          Gets the tool's view.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fView

protected DrawingView fView

fAnchorX

protected int fAnchorX
The position of the initial mouse down.


fAnchorY

protected int fAnchorY
The position of the initial mouse down.

Constructor Detail

AbstractTool

public AbstractTool(DrawingView itsView)
Constructs a tool for the given view.

Method Detail

activate

public void activate()
Activates the tool for the given view. This method is called whenever the user switches to this tool. Use this method to reinitialize a tool.

Specified by:
activate in interface Tool

deactivate

public void deactivate()
Deactivates the tool. This method is called whenever the user switches to another tool. Use this method to do some clean-up when the tool is switched. Subclassers should always call super.deactivate.

Specified by:
deactivate in interface Tool

mouseDown

public void mouseDown(java.awt.event.MouseEvent e,
                      int x,
                      int y)
Handles mouse down events in the drawing view.

Specified by:
mouseDown in interface Tool

mouseDrag

public void mouseDrag(java.awt.event.MouseEvent e,
                      int x,
                      int y)
Handles mouse drag events in the drawing view.

Specified by:
mouseDrag in interface Tool

mouseUp

public void mouseUp(java.awt.event.MouseEvent e,
                    int x,
                    int y)
Handles mouse up in the drawing view.

Specified by:
mouseUp in interface Tool

mouseMove

public void mouseMove(java.awt.event.MouseEvent evt,
                      int x,
                      int y)
Handles mouse moves (if the mouse button is up).

Specified by:
mouseMove in interface Tool

keyDown

public void keyDown(java.awt.event.KeyEvent evt,
                    int key)
Handles key down events in the drawing view.

Specified by:
keyDown in interface Tool

drawing

public Drawing drawing()
Gets the tool's drawing.


editor

public DrawingEditor editor()
Gets the tool's editor.


view

public DrawingView view()
Gets the tool's view.