org.jhotdraw.draw
Class TextAreaEditingTool

java.lang.Object
  extended by org.jhotdraw.beans.AbstractBean
      extended by org.jhotdraw.draw.AbstractTool
          extended by org.jhotdraw.draw.TextAreaEditingTool
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, Tool

public class TextAreaEditingTool
extends AbstractTool
implements java.awt.event.ActionListener

A tool to edit existing figures that implement the TextHolderFigure interface, such as TextAreaFigure.

To edit an existing text figure using the TextAreaEditingTool, the user does the following mouse gesture on a DrawingView:

  1. Press the mouse button over a Figure on the DrawingView.

The TextAreaEditingTool then uses Figure.findFigureInside to find a Figure that implements the TextHolderFigure interface and that is editable. Then it overlays a text area over the drawing where the user can enter the text for the Figure.


Design Patterns

Framework
The text creation and editing tools and the TextHolderFigure interface define together the contracts of a smaller framework inside of the JHotDraw framework for structured drawing editors.
Contract: TextHolderFigure, TextCreationTool, TextAreaCreationTool, TextEditingTool, TextAreaEditingTool, FloatingTextField, FloatingTextArea.


Version:
$Id: TextAreaEditingTool.java 542 2009-07-06 05:57:55Z rawcoder $
Author:
Werner Randelshofer
See Also:
TextHolderFigure, FloatingTextArea, Serialized Form

Field Summary
private  FloatingTextArea textArea
           
private  TextHolderFigure typingTarget
           
 
Fields inherited from class org.jhotdraw.draw.AbstractTool
anchor, editor, isWorking, listenerList
 
Fields inherited from class org.jhotdraw.beans.AbstractBean
propertySupport
 
Constructor Summary
TextAreaEditingTool(TextHolderFigure typingTarget)
          Creates a new instance.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
           
protected  void beginEdit(TextHolderFigure textHolder)
           
 void deactivate(DrawingEditor editor)
          Deactivates the tool.
 void draw(java.awt.Graphics2D g)
          Draws the tool.
protected  void endEdit()
           
private  java.awt.geom.Rectangle2D.Double getFieldBounds(TextHolderFigure figure)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
          Creates a new figure at the mouse location.
 
Methods inherited from class org.jhotdraw.draw.AbstractTool
activate, addToolListener, addUndoableEditListener, constrainPoint, constrainPoint, createActionMap, createInputMap, editCopy, editCut, editDelete, editDuplicate, editPaste, fireAreaInvalidated, fireAreaInvalidated, fireToolDone, fireToolStarted, getActionMap, getDrawing, getEditor, getInputMap, getToolTipText, getView, isActive, keyPressed, keyReleased, keyTyped, mouseClicked, mouseEntered, mouseExited, mouseMoved, mouseReleased, removeToolListener, removeUndoableEditListener, setActionMap, setInputMap, supportsHandleInteraction, updateCursor, viewToDrawing
 
Methods inherited from class org.jhotdraw.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, clone, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

textArea

private FloatingTextArea textArea

typingTarget

private TextHolderFigure typingTarget
Constructor Detail

TextAreaEditingTool

public TextAreaEditingTool(TextHolderFigure typingTarget)
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.

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

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Creates a new figure at the mouse location. If editing is in progress, this finishes editing.

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

draw

public void draw(java.awt.Graphics2D g)
Description copied from interface: Tool
Draws the tool.

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

beginEdit

protected void beginEdit(TextHolderFigure textHolder)

getFieldBounds

private java.awt.geom.Rectangle2D.Double getFieldBounds(TextHolderFigure figure)

endEdit

protected void endEdit()

actionPerformed

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

mouseDragged

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