JHotDraw 7.0.6

org.jhotdraw.draw
Class TextTool

java.lang.Object
  extended by org.jhotdraw.draw.AbstractTool
      extended by org.jhotdraw.draw.CreationTool
          extended by org.jhotdraw.draw.TextTool
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, Tool

public class TextTool
extends CreationTool
implements java.awt.event.ActionListener

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

Field Summary
 
Fields inherited from class org.jhotdraw.draw.CreationTool
createdFigure, creationEdit
 
Fields inherited from class org.jhotdraw.draw.AbstractTool
anchor, editor, isWorking, listenerList
 
Constructor Summary
TextTool(Figure prototype, java.util.Map attributes)
          Creates a new instance.
TextTool(TextHolder prototype)
          Creates a new instance.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
           
protected  void beginEdit(TextHolder textHolder)
           
 void deactivate(DrawingEditor editor)
          Deactivates the tool.
protected  void endEdit()
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
          If the pressed figure is a TextHolder it can be edited otherwise a new text figure is created.
 void mouseReleased(java.awt.event.MouseEvent evt)
           
 
Methods inherited from class org.jhotdraw.draw.CreationTool
activate, createFigure, getAddedFigure, getCreatedFigure, getPrototype
 
Methods inherited from class org.jhotdraw.draw.AbstractTool
addToolListener, addUndoableEditListener, constrainPoint, constrainPoint, draw, editCopy, editCut, editDelete, editDuplicate, editPaste, fireAreaInvalidated, fireAreaInvalidated, fireToolDone, fireToolStarted, getDrawing, getEditor, getView, isActive, keyPressed, keyReleased, keyTyped, mouseClicked, mouseEntered, mouseExited, mouseMoved, removeToolListener, removeUndoableEditListener, updateCursor, viewToDrawing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextTool

public TextTool(TextHolder prototype)
Creates a new instance.


TextTool

public TextTool(Figure prototype,
                java.util.Map attributes)
Creates a new instance.

Method Detail

deactivate

public void deactivate(DrawingEditor editor)
Description copied from interface: Tool
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
Overrides:
deactivate in class CreationTool

mousePressed

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

Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class CreationTool

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Overrides:
mouseDragged in class CreationTool

beginEdit

protected void beginEdit(TextHolder textHolder)

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent evt)
Specified by:
mouseReleased in interface java.awt.event.MouseListener
Overrides:
mouseReleased in class CreationTool

endEdit

protected void endEdit()

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

Copyright 1996-2006 © JHotDraw.org