Class TextAreaCreationTool
- java.lang.Object
-
- org.jhotdraw.beans.AbstractBean
-
- org.jhotdraw.draw.tool.AbstractTool
-
- org.jhotdraw.draw.tool.CreationTool
-
- org.jhotdraw.draw.tool.TextAreaCreationTool
-
- 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 TextAreaCreationTool extends CreationTool implements java.awt.event.ActionListener
A tool to create new or edit existing figures that implement the TextHolderFigure interface, such as TextAreaFigure. The figure to be created is specified by a prototype.To create a figure using the TextAreaCreationTool, the user does the following mouse gestures on a DrawingView:
- Press the mouse button over the DrawingView. This defines the start point of the Figure bounds.
- Drag the mouse while keeping the mouse button pressed, and then release the mouse button. This defines the end point of the Figure bounds.
To edit an existing text figure using the TextAreaCreationTool, the user does the following mouse gesture on a DrawingView:
- Press the mouse button over a Figure on the DrawingView.
The TextAreaCreationTool 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.
XXX - Maybe this class should be split up into a CreateTextAreaTool and a EditTextAreaTool.
Design PatternsFramework
The text creation and editing tools and theTextHolderFigureinterface 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.Prototype
The text creation tools create new figures by cloning a prototypeTextHolderFigureobject.
Prototype:TextHolderFigure; Client:TextCreationTool,TextAreaCreationTool.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description TextAreaCreationTool(TextHolderFigure prototype)Creates a new instance.TextAreaCreationTool(TextHolderFigure prototype, java.util.Map<AttributeKey,java.lang.Object> attributes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidactionPerformed(java.awt.event.ActionEvent event)voiddeactivate(DrawingEditor editor)Deactivates the tool.voiddraw(java.awt.Graphics2D g)Draws the tool.voidmousePressed(java.awt.event.MouseEvent e)Creates a new figure at the mouse location.voidsetRubberbandColor(java.awt.Color c)Sets the rubberband color for the tool.-
Methods inherited from class org.jhotdraw.draw.tool.CreationTool
activate, getPrototype, isToolDoneAfterCreation, mouseDragged, mouseReleased, setToolDoneAfterCreation, updateCursor
-
Methods inherited from class org.jhotdraw.draw.tool.AbstractTool
addToolListener, addUndoableEditListener, editCopy, editCut, editDelete, editDuplicate, editPaste, getActionMap, getInputMap, getToolTipText, isActive, keyPressed, keyReleased, keyTyped, mouseClicked, mouseEntered, mouseExited, mouseMoved, removeToolListener, removeUndoableEditListener, setActionMap, setInputMap, supportsHandleInteraction
-
Methods inherited from class org.jhotdraw.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, clone, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Constructor Detail
-
TextAreaCreationTool
public TextAreaCreationTool(TextHolderFigure prototype)
Creates a new instance.
-
TextAreaCreationTool
public TextAreaCreationTool(TextHolderFigure prototype, java.util.Map<AttributeKey,java.lang.Object> attributes)
-
-
Method Detail
-
setRubberbandColor
public void setRubberbandColor(java.awt.Color c)
Sets the rubberband color for the tool. Setting this to null, disables the rubberband.- Parameters:
c- Rubberband color or null.
-
deactivate
public void deactivate(DrawingEditor editor)
Description copied from interface:ToolDeactivates the tool. This method is called whenever the user switches to another tool.- Specified by:
deactivatein interfaceTool- Overrides:
deactivatein classCreationTool
-
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:
mousePressedin interfacejava.awt.event.MouseListener- Overrides:
mousePressedin classCreationTool
-
draw
public void draw(java.awt.Graphics2D g)
Description copied from interface:ToolDraws the tool.- Specified by:
drawin interfaceTool- Overrides:
drawin classAbstractTool
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent event)
- Specified by:
actionPerformedin interfacejava.awt.event.ActionListener
-
-
DataMelt 3.0 © DataMelt by jWork.ORG