JHotDraw 6.0b1

org.jhotdraw.figures
Class TextTool

java.lang.Object
  extended by org.jhotdraw.standard.AbstractTool
      extended by org.jhotdraw.standard.CreationTool
          extended by org.jhotdraw.figures.TextTool
All Implemented Interfaces:
Tool
Direct Known Subclasses:
ConnectedTextTool

public class TextTool
extends CreationTool

Tool to create new or edit existing text figures. The editing behavior is implemented by overlaying the Figure providing the text with a FloatingTextField.

A tool interaction is done once a Figure that is not a TextHolder is clicked.

See Also:
TextHolder, FloatingTextField

Nested Class Summary
static class TextTool.UndoActivity
           
 
Nested classes/interfaces inherited from class org.jhotdraw.standard.AbstractTool
AbstractTool.EventDispatcher
 
Constructor Summary
TextTool(DrawingEditor newDrawingEditor, Figure prototype)
           
 
Method Summary
 void activate()
          Sets the text cursor.
protected  void beginEdit(TextHolder figure)
           
protected  Undoable createDeleteUndoActivity()
           
protected  Undoable createPasteUndoActivity()
           
protected  Undoable createUndoActivity()
          Factory method for undo activity
 void deactivate()
          Terminates the editing of a text figure.
protected  void endEdit()
           
protected  FloatingTextField getFloatingTextField()
           
protected  Figure getSelectedFigure()
           
protected  TextHolder getTypingTarget()
           
 boolean isActive()
          Test whether the text tool is currently activated and is displaying a overlay TextFigure for accepting input.
protected  boolean isDeleteTextFigure()
           
 void mouseDown(java.awt.event.MouseEvent e, int x, int y)
          If the pressed figure is a TextHolder it can be edited otherwise a new text figure is created.
 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.
protected  void setTypingTarget(TextHolder newTypingTarget)
           
 
Methods inherited from class org.jhotdraw.standard.CreationTool
createFigure, getAddedFigure, getAddedFigures, getCreatedFigure, getPrototypeFigure, setAddedFigure, setAddedFigures, setCreatedFigure, setPrototypeFigure
 
Methods inherited from class org.jhotdraw.standard.AbstractTool
addToolListener, checkUsable, createEventDispatcher, createViewChangeListener, drawing, editor, getActiveDrawing, getActiveView, getAnchorX, getAnchorY, getEventDispatcher, getUndoActivity, isEnabled, isUsable, keyDown, mouseMove, removeToolListener, setAnchorX, setAnchorY, setEditor, setEnabled, setUndoActivity, setUsable, setView, view, viewCreated, viewDestroying, viewSelectionChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextTool

public TextTool(DrawingEditor newDrawingEditor,
                Figure prototype)
Method Detail

mouseDown

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

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

mouseDrag

public void mouseDrag(java.awt.event.MouseEvent e,
                      int x,
                      int y)
Description copied from class: CreationTool
Adjusts the extent of the created figure

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

mouseUp

public void mouseUp(java.awt.event.MouseEvent e,
                    int x,
                    int y)
Description copied from class: CreationTool
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 CreationTool
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()
Sets the text cursor.

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

isActive

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

Specified by:
isActive in interface Tool
Overrides:
isActive in class AbstractTool
Returns:
true, if the text tool has a accepting target TextFigure for its input, false otherwise
See Also:
Tool.isEnabled(), Tool.isUsable()

beginEdit

protected void beginEdit(TextHolder figure)

endEdit

protected void endEdit()

isDeleteTextFigure

protected boolean isDeleteTextFigure()

setTypingTarget

protected void setTypingTarget(TextHolder newTypingTarget)

getTypingTarget

protected TextHolder getTypingTarget()

getSelectedFigure

protected Figure getSelectedFigure()

getFloatingTextField

protected FloatingTextField getFloatingTextField()

createDeleteUndoActivity

protected Undoable createDeleteUndoActivity()

createPasteUndoActivity

protected Undoable createPasteUndoActivity()

createUndoActivity

protected Undoable createUndoActivity()
Factory method for undo activity

Overrides:
createUndoActivity in class CreationTool

JHotDraw 6.0b1