org.jhotdraw.contrib
Class TextAreaTool

java.lang.Object
  extended by org.jhotdraw.standard.AbstractTool
      extended by org.jhotdraw.standard.CreationTool
          extended by org.jhotdraw.contrib.TextAreaTool
All Implemented Interfaces:
Tool
Direct Known Subclasses:
HTMLTextAreaTool

public class TextAreaTool
extends CreationTool

A TextAreaTool creates TextAreaFigures.
To create a new text area, the user drags a rectangle on the drawing on a free spot.
When releasing the mouse the tool calls the area's editor to enter the text.
If the tool is clicked on an existing area the tool simply calls the area's editor.
When creating a new area, if the user leaves the text empty, the newly created area figure is discarded.

Version:
1.0
Author:
Eduardo Francos - InContext

Nested Class Summary
static class TextAreaTool.UndoActivity
          Handles undo/redo for text areas
 
Nested classes/interfaces inherited from class org.jhotdraw.standard.AbstractTool
AbstractTool.EventDispatcher
 
Constructor Summary
TextAreaTool(DrawingEditor newDrawingEditor, Figure prototype)
          Constructor for the TextAreaTool object
 
Method Summary
 void activate()
          Activates the figure's editor
 void deactivate()
          Terminates the editing of a text figure.
 boolean isActivated()
          Test whether the text tool is currently activated and is displaying a overlay TextFigure for accepting input.
 void mouseDown(java.awt.event.MouseEvent e, int x, int y)
          If the pressed figure is a TextHolder and it accepts editing it can be edited.
 void mouseDrag(java.awt.event.MouseEvent e, int x, int y)
          Drags to set the initial text area display box
 void mouseUp(java.awt.event.MouseEvent e, int x, int y)
          If creating a figure it ends the creation process and calls the editor
 
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

TextAreaTool

public TextAreaTool(DrawingEditor newDrawingEditor,
                    Figure prototype)
Constructor for the TextAreaTool object

Parameters:
newDrawingEditor - the managing drawing editor
prototype - the prototype for the figure
Method Detail

mouseDown

public void mouseDown(java.awt.event.MouseEvent e,
                      int x,
                      int y)
If the pressed figure is a TextHolder and it accepts editing it can be edited.
If there is no pressed figure a new text figure is created.

Specified by:
mouseDown in interface Tool
Overrides:
mouseDown in class CreationTool
Parameters:
e - Description of the Parameter
x - Description of the Parameter
y - Description of the Parameter

mouseDrag

public void mouseDrag(java.awt.event.MouseEvent e,
                      int x,
                      int y)
Drags to set the initial text area display box

Specified by:
mouseDrag in interface Tool
Overrides:
mouseDrag in class CreationTool
Parameters:
e - Description of the Parameter
x - Description of the Parameter
y - Description of the Parameter

mouseUp

public void mouseUp(java.awt.event.MouseEvent e,
                    int x,
                    int y)
If creating a figure it ends the creation process and calls the editor

Specified by:
mouseUp in interface Tool
Overrides:
mouseUp in class CreationTool
Parameters:
e - Description of the Parameter
x - Description of the Parameter
y - Description of the Parameter
See Also:
Figure.isEmpty()

deactivate

public void deactivate()
Terminates the editing of a text figure.

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

activate

public void activate()
Activates the figure's editor

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

isActivated

public boolean isActivated()
Test whether the text tool is currently activated and is displaying a overlay TextFigure for accepting input.

Returns:
true, if the text tool has a accepting target TextFigure for its input, false otherwise