jdraw.framework
Interface DrawTool


public interface DrawTool

A tool defines a mode of the drawing view, intendid to be set over a tool bar. An example of a tool is the construction of new figures. Whenever a new tool is activated or deactivated, the corresponding methods are called. This can be used to e.g. adjust the mouse cursor depending on the current tool.

All input events targeted to the drawing view are forwarded to its current tool.

See Also:
Figure

Method Summary
 void activate()
          Activates the tool for the given view.
 void deactivate()
          Deactivates the tool.
 void mouseDown(int x, int y, java.awt.event.MouseEvent e)
          Handles mouse down events in the drawing view.
 void mouseDrag(int x, int y, java.awt.event.MouseEvent e)
          Handles mouse drag events in the drawing view.
 void mouseUp(int x, int y, java.awt.event.MouseEvent e)
          Handles mouse up in the drawing 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.


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.


mouseDown

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

Parameters:
x - x coordinate of mouse position
y - y coordinate of mouse position
e - mouse event, contains state of modifiers

mouseDrag

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

Parameters:
x - x coordinate of mouse position
y - y coordinate of mouse position
e - mouse event, contains state of modifiers

mouseUp

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

Parameters:
x - x coordinate of mouse position
y - y coordinate of mouse position
e - mouse event, contains state of modifiers