JHotDraw 6.0b1

org.jhotdraw.util
Class UndoableTool

java.lang.Object
  extended by org.jhotdraw.util.UndoableTool
All Implemented Interfaces:
Tool, ToolListener

public class UndoableTool
extends java.lang.Object
implements Tool, ToolListener


Constructor Summary
UndoableTool(Tool newWrappedTool)
           
 
Method Summary
 void activate()
          Activates the tool for the given view.
 void addToolListener(ToolListener newToolListener)
           
 AbstractTool.EventDispatcher createEventDispatcher()
           
 void deactivate()
          Deactivates the tool.
 DrawingEditor editor()
           
 DrawingView getActiveView()
           
protected  AbstractTool.EventDispatcher getEventDispatcher()
           
 Undoable getUndoActivity()
           
protected  Tool getWrappedTool()
           
 boolean isActive()
          An active tool is the currently selected tool in the DrawingView.
 boolean isEnabled()
          A tool must be enabled in order to use it and to activate/deactivate it.
 boolean isUsable()
          A usable tool is a enabled and either active or inactive.
 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.
 void removeToolListener(ToolListener oldToolListener)
           
 void setEnabled(boolean newIsEnabled)
           
 void setUndoActivity(Undoable newUndoableActivity)
           
 void setUsable(boolean newIsUsable)
           
protected  void setWrappedTool(Tool newWrappedTool)
           
 void toolActivated(java.util.EventObject toolEvent)
           
 void toolDeactivated(java.util.EventObject toolEvent)
           
 void toolDisabled(java.util.EventObject toolEvent)
           
 void toolEnabled(java.util.EventObject toolEvent)
           
 void toolUnusable(java.util.EventObject toolEvent)
           
 void toolUsable(java.util.EventObject toolEvent)
           
 DrawingView view()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UndoableTool

public UndoableTool(Tool newWrappedTool)
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. After the mouse button has been released, the associated tool activity can be undone if the associated tool supports the undo operation from the Undoable interface.

Specified by:
mouseUp in interface Tool
See Also:
Undoable

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

isUsable

public boolean isUsable()
Description copied from interface: Tool
A usable tool is a enabled and either active or inactive. Typically, the tool should be able to determine itself whether it is usable or not.

Specified by:
isUsable in interface Tool
See Also:
Tool.isEnabled(), Tool.isUsable()

isActive

public boolean isActive()
Description copied from interface: Tool
An active tool is the currently selected tool in the DrawingView. A tool can be activated/deactivated by calling the activate()/deactivate() method.

Specified by:
isActive in interface Tool
Returns:
true if the tool is the selected tool in the DrawingView, false otherwise
See Also:
Tool.isEnabled(), Tool.isUsable()

isEnabled

public boolean isEnabled()
Description copied from interface: Tool
A tool must be enabled in order to use it and to activate/deactivate it. Typically, the program enables or disables a tool.

Specified by:
isEnabled in interface Tool
See Also:
Tool.isUsable(), Tool.isActive()

setUsable

public void setUsable(boolean newIsUsable)
Specified by:
setUsable in interface Tool

setEnabled

public void setEnabled(boolean newIsEnabled)
Specified by:
setEnabled in interface Tool

setWrappedTool

protected void setWrappedTool(Tool newWrappedTool)

getWrappedTool

protected Tool getWrappedTool()

editor

public DrawingEditor editor()
Specified by:
editor in interface Tool

view

public DrawingView view()

getUndoActivity

public Undoable getUndoActivity()
Specified by:
getUndoActivity in interface Tool

setUndoActivity

public void setUndoActivity(Undoable newUndoableActivity)
Specified by:
setUndoActivity in interface Tool

toolUsable

public void toolUsable(java.util.EventObject toolEvent)
Specified by:
toolUsable in interface ToolListener

toolUnusable

public void toolUnusable(java.util.EventObject toolEvent)
Specified by:
toolUnusable in interface ToolListener

toolActivated

public void toolActivated(java.util.EventObject toolEvent)
Specified by:
toolActivated in interface ToolListener

toolDeactivated

public void toolDeactivated(java.util.EventObject toolEvent)
Specified by:
toolDeactivated in interface ToolListener

toolEnabled

public void toolEnabled(java.util.EventObject toolEvent)
Specified by:
toolEnabled in interface ToolListener

toolDisabled

public void toolDisabled(java.util.EventObject toolEvent)
Specified by:
toolDisabled in interface ToolListener

addToolListener

public void addToolListener(ToolListener newToolListener)
Specified by:
addToolListener in interface Tool

removeToolListener

public void removeToolListener(ToolListener oldToolListener)
Specified by:
removeToolListener in interface Tool

getEventDispatcher

protected AbstractTool.EventDispatcher getEventDispatcher()

createEventDispatcher

public AbstractTool.EventDispatcher createEventDispatcher()

getActiveView

public DrawingView getActiveView()

JHotDraw 6.0b1