org.jhotdraw.draw.tool
Class AbstractTool
- java.lang.Object
-
- org.jhotdraw.beans.AbstractBean
-
- org.jhotdraw.draw.tool.AbstractTool
-
- All Implemented Interfaces:
- java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, Tool
- Direct Known Subclasses:
- BezierTool, ConnectionTool, CreationTool, DefaultDragTracker, DefaultHandleTracker, DefaultSelectAreaTracker, DnDTracker, SelectionTool, TextAreaEditingTool, TextEditingTool
public abstract class AbstractTool extends AbstractBean implements Tool
This abstract class can be extended to implement aTool.
Design PatternsProxy
To remove the need for null-handling,AbstractToolmakes use of a proxy forDrawingEditor. Subject:DrawingEditor; Proxy:DrawingEditorProxy; Client:AbstractTool.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description AbstractTool()Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidactivate(DrawingEditor editor)Activates the tool for the given editor.voidaddToolListener(ToolListener l)Adds a listener for this tool.voidaddUndoableEditListener(javax.swing.event.UndoableEditListener l)voiddeactivate(DrawingEditor editor)Deactivates the tool.voiddraw(java.awt.Graphics2D g)Draws the tool.voideditCopy()Copies the selection into the clipboard.voideditCut()Cuts the selection into the clipboard.voideditDelete()Deletes the selection.voideditDuplicate()Duplicates the selection.voideditPaste()Pastes the contents of the clipboard.javax.swing.ActionMapgetActionMap()Gets the action map of the Tooljavax.swing.InputMapgetInputMap()Gets the input map of the Tooljava.lang.StringgetToolTipText(DrawingView view, java.awt.event.MouseEvent evt)Returns the tooltip text for a mouse event on a drawing view.booleanisActive()voidkeyPressed(java.awt.event.KeyEvent evt)The Tool uses the InputMap to determine what to do, when a key is pressed.voidkeyReleased(java.awt.event.KeyEvent evt)voidkeyTyped(java.awt.event.KeyEvent evt)voidmouseClicked(java.awt.event.MouseEvent evt)voidmouseEntered(java.awt.event.MouseEvent evt)voidmouseExited(java.awt.event.MouseEvent evt)voidmouseMoved(java.awt.event.MouseEvent evt)voidmousePressed(java.awt.event.MouseEvent evt)voidmouseReleased(java.awt.event.MouseEvent evt)voidremoveToolListener(ToolListener l)Removes a listener for this tool.voidremoveUndoableEditListener(javax.swing.event.UndoableEditListener l)voidsetActionMap(javax.swing.ActionMap newValue)Sets the ActionMap for the Tool.voidsetInputMap(javax.swing.InputMap newValue)Sets the InputMap for the Tool.booleansupportsHandleInteraction()Returns true, if this tool lets the user interact with handles.voidupdateCursor(DrawingView view, java.awt.Point p)-
Methods inherited from class org.jhotdraw.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, clone, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Method Detail
-
addUndoableEditListener
public void addUndoableEditListener(javax.swing.event.UndoableEditListener l)
-
removeUndoableEditListener
public void removeUndoableEditListener(javax.swing.event.UndoableEditListener l)
-
activate
public void activate(DrawingEditor editor)
Description copied from interface:ToolActivates the tool for the given editor. This method is called whenever the user switches to this tool.
-
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
-
isActive
public boolean isActive()
-
setInputMap
public void setInputMap(javax.swing.InputMap newValue)
Sets the InputMap for the Tool.
-
getInputMap
public javax.swing.InputMap getInputMap()
Gets the input map of the Tool
-
setActionMap
public void setActionMap(javax.swing.ActionMap newValue)
Sets the ActionMap for the Tool.- See Also:
keyPressed(java.awt.event.KeyEvent)
-
getActionMap
public javax.swing.ActionMap getActionMap()
Gets the action map of the Tool
-
editDelete
public void editDelete()
Deletes the selection. Depending on the tool, this could be selected figures, selected points or selected text.- Specified by:
editDeletein interfaceTool
-
editCut
public void editCut()
Cuts the selection into the clipboard. Depending on the tool, this could be selected figures, selected points or selected text.
-
editCopy
public void editCopy()
Copies the selection into the clipboard. Depending on the tool, this could be selected figures, selected points or selected text.
-
editDuplicate
public void editDuplicate()
Duplicates the selection. Depending on the tool, this could be selected figures, selected points or selected text.- Specified by:
editDuplicatein interfaceTool
-
editPaste
public void editPaste()
Pastes the contents of the clipboard. Depending on the tool, this could be selected figures, selected points or selected text.
-
keyReleased
public void keyReleased(java.awt.event.KeyEvent evt)
- Specified by:
keyReleasedin interfacejava.awt.event.KeyListener
-
keyTyped
public void keyTyped(java.awt.event.KeyEvent evt)
- Specified by:
keyTypedin interfacejava.awt.event.KeyListener
-
keyPressed
public void keyPressed(java.awt.event.KeyEvent evt)
The Tool uses the InputMap to determine what to do, when a key is pressed. If the corresponding value of the InputMap is a String, the ActionMap of the tool is used, to find the action to be performed. If the corresponding value of the InputMap is a ActionListener, the actionPerformed method of the ActionListener is performed.- Specified by:
keyPressedin interfacejava.awt.event.KeyListener
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent evt)
- Specified by:
mouseClickedin interfacejava.awt.event.MouseListener
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent evt)
- Specified by:
mouseEnteredin interfacejava.awt.event.MouseListener
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent evt)
- Specified by:
mouseExitedin interfacejava.awt.event.MouseListener
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent evt)
- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent evt)
- Specified by:
mousePressedin interfacejava.awt.event.MouseListener
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent evt)
- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener
-
addToolListener
public void addToolListener(ToolListener l)
Description copied from interface:ToolAdds a listener for this tool.- Specified by:
addToolListenerin interfaceTool
-
removeToolListener
public void removeToolListener(ToolListener l)
Description copied from interface:ToolRemoves a listener for this tool.- Specified by:
removeToolListenerin interfaceTool
-
draw
public void draw(java.awt.Graphics2D g)
Description copied from interface:ToolDraws the tool.
-
updateCursor
public void updateCursor(DrawingView view, java.awt.Point p)
-
getToolTipText
public java.lang.String getToolTipText(DrawingView view, java.awt.event.MouseEvent evt)
Description copied from interface:ToolReturns the tooltip text for a mouse event on a drawing view.- Specified by:
getToolTipTextin interfaceTool- Parameters:
view- A drawing view.evt- A mouse event.- Returns:
- A tooltip text or null.
-
supportsHandleInteraction
public boolean supportsHandleInteraction()
Returns true, if this tool lets the user interact with handles.Handles may draw differently, if interaction is not possible.
- Specified by:
supportsHandleInteractionin interfaceTool- Returns:
- True, if this tool supports interaction with the handles.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG