CH.ifa.draw.standard
Class CreationTool

java.lang.Object
  extended by CH.ifa.draw.standard.AbstractTool
      extended by CH.ifa.draw.standard.CreationTool
All Implemented Interfaces:
Tool
Direct Known Subclasses:
PertFigureCreationTool, 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.


See Also:
Figure, Object.clone()

Field Summary
 
Fields inherited from class CH.ifa.draw.standard.AbstractTool
fAnchorX, fAnchorY, fView
 
Constructor Summary
protected CreationTool(DrawingView view)
          Constructs a CreationTool without a prototype.
  CreationTool(DrawingView view, Figure prototype)
          Initializes a CreationTool with the given prototype.
 
Method Summary
 void activate()
          Sets the cross hair cursor.
protected  Figure createdFigure()
          Gets the currently created figure
protected  Figure createFigure()
          Creates a new figure by cloning the prototype.
 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 CH.ifa.draw.standard.AbstractTool
deactivate, drawing, editor, keyDown, mouseMove, view
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CreationTool

public CreationTool(DrawingView view,
                    Figure prototype)
Initializes a CreationTool with the given prototype.


CreationTool

protected CreationTool(DrawingView view)
Constructs a CreationTool without a prototype. This is for subclassers overriding createFigure.

Method Detail

activate

public void activate()
Sets the cross hair cursor.

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

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

createFigure

protected Figure createFigure()
Creates a new figure by cloning the prototype.


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()

createdFigure

protected Figure createdFigure()
Gets the currently created figure