org.jhotdraw.standard
Class CreationTool

java.lang.Object
  extended by org.jhotdraw.standard.AbstractTool
      extended by org.jhotdraw.standard.CreationTool
All Implemented Interfaces:
Tool
Direct Known Subclasses:
CompositeFigureCreationTool, NestedCreationTool, TextAreaTool, TextTool

public class CreationTool
extends AbstractTool

A tool to create new figures. The figure to be created is specified by a prototype.


Design Patterns

 o Prototype
CreationTool creates new figures by cloning a prototype.


Version:
<$CURRENT_VERSION$>
See Also:
Figure, Object.clone()

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jhotdraw.standard.AbstractTool
AbstractTool.EventDispatcher
 
Constructor Summary
CreationTool(DrawingEditor newDrawingEditor, Figure prototype)
          Initializes a CreationTool with the given prototype.
 
Method Summary
 void activate()
          Sets the cross hair cursor.
 void deactivate()
          Deactivates the tool.
 void mouseDown(java.awt.event.MouseEvent e, int x, int y)
          Creates a new figure by cloning the prototype.
 void mouseDrag(java.awt.event.MouseEvent e, int x, int y)
          Adjusts the extent of the created figure
 void mouseUp(java.awt.event.MouseEvent e, int x, int y)
          Checks if the created figure is empty.
 
Methods inherited from class org.jhotdraw.standard.AbstractTool
addToolListener, drawing, editor, getActiveDrawing, getActiveView, getUndoActivity, isActive, isEnabled, isUsable, keyDown, mouseMove, removeToolListener, setEnabled, setUndoActivity, setUsable, view
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CreationTool

public CreationTool(DrawingEditor newDrawingEditor,
                    Figure prototype)
Initializes a CreationTool with the given prototype.

Method Detail

activate

public void activate()
Sets the cross hair cursor.

Specified by:
activate in interface Tool
Overrides:
activate in class AbstractTool

deactivate

public void deactivate()
Description copied from class: AbstractTool
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. An inactive tool should never be deactivated

Specified by:
deactivate in interface Tool
Overrides:
deactivate in class AbstractTool
See Also:
Tool.deactivate()

mouseDown

public void mouseDown(java.awt.event.MouseEvent e,
                      int x,
                      int y)
Creates a new figure by cloning the prototype.

Specified by:
mouseDown in interface Tool
Overrides:
mouseDown in class AbstractTool

mouseDrag

public void mouseDrag(java.awt.event.MouseEvent e,
                      int x,
                      int y)
Adjusts the extent of the created figure

Specified by:
mouseDrag in interface Tool
Overrides:
mouseDrag in class AbstractTool

mouseUp

public void mouseUp(java.awt.event.MouseEvent e,
                    int x,
                    int y)
Checks if the created figure is empty. If it is, the figure is removed from the drawing.

Specified by:
mouseUp in interface Tool
Overrides:
mouseUp in class AbstractTool
See Also:
Figure.isEmpty()