public abstract class AbstractTool extends AbstractBean implements Tool
Tool
.
Proxy
To remove the need for null-handling, AbstractTool
makes use of
a proxy for DrawingEditor
.
Subject: DrawingEditor
; Proxy: DrawingEditorProxy
;
Client: AbstractTool
.
Modifier and Type | Field and Description |
---|---|
protected java.awt.Point |
anchor |
protected DrawingEditor |
editor |
protected boolean |
isWorking
This is set to true, while the tool is doing some work.
|
protected javax.swing.event.EventListenerList |
listenerList |
propertySupport
Constructor and Description |
---|
AbstractTool()
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
activate(DrawingEditor editor)
Activates the tool for the given editor.
|
void |
addToolListener(ToolListener l)
Adds a listener for this tool.
|
void |
addUndoableEditListener(javax.swing.event.UndoableEditListener l) |
protected java.awt.geom.Point2D.Double |
constrainPoint(java.awt.Point p) |
protected java.awt.geom.Point2D.Double |
constrainPoint(java.awt.geom.Point2D.Double p) |
protected javax.swing.ActionMap |
createActionMap()
Override this method to create a tool-specific action map, which
overrides the action map of the drawing edtior.
|
protected javax.swing.InputMap |
createInputMap()
Override this method to create a tool-specific input map, which
overrides the input map of the drawing edtior.
|
void |
deactivate(DrawingEditor editor)
Deactivates the tool.
|
void |
draw(java.awt.Graphics2D g)
Draws the tool.
|
void |
editCopy()
Copies the selection into the clipboard.
|
void |
editCut()
Cuts the selection into the clipboard.
|
void |
editDelete()
Deletes the selection.
|
void |
editDuplicate()
Duplicates the selection.
|
void |
editPaste()
Pastes the contents of the clipboard.
|
protected void |
fireAreaInvalidated(java.awt.Rectangle invalidatedArea)
Notify all listenerList that have registered interest for
notification on this event type.
|
protected void |
fireAreaInvalidated(java.awt.geom.Rectangle2D.Double r)
Notify all listenerList that have registered interest for
notification on this event type.
|
protected void |
fireBoundsInvalidated(java.awt.Rectangle invalidatedArea)
Notify all listenerList that have registered interest for
notification on this event type.
|
protected void |
fireToolDone()
Notify all listenerList that have registered interest for
notification on this event type.
|
protected void |
fireToolStarted(DrawingView view)
Notify all listenerList that have registered interest for
notification on this event type.
|
javax.swing.ActionMap |
getActionMap()
Gets the action map of the Tool
|
protected Drawing |
getDrawing() |
protected DrawingEditor |
getEditor() |
javax.swing.InputMap |
getInputMap()
Gets the input map of the Tool
|
java.lang.String |
getToolTipText(DrawingView view,
java.awt.event.MouseEvent evt)
Returns the tooltip text for a mouse event on a drawing view.
|
protected DrawingView |
getView() |
boolean |
isActive() |
void |
keyPressed(java.awt.event.KeyEvent evt)
The Tool uses the InputMap to determine what to do, when a key is pressed.
|
void |
keyReleased(java.awt.event.KeyEvent evt) |
void |
keyTyped(java.awt.event.KeyEvent evt) |
protected void |
maybeFireBoundsInvalidated(java.awt.Rectangle invalidatedArea)
Notify all listenerList that have registered interest for
notification on this event type.
|
void |
mouseClicked(java.awt.event.MouseEvent evt) |
void |
mouseEntered(java.awt.event.MouseEvent evt) |
void |
mouseExited(java.awt.event.MouseEvent evt) |
void |
mouseMoved(java.awt.event.MouseEvent evt) |
void |
mousePressed(java.awt.event.MouseEvent evt) |
void |
mouseReleased(java.awt.event.MouseEvent evt) |
void |
removeToolListener(ToolListener l)
Removes a listener for this tool.
|
void |
removeUndoableEditListener(javax.swing.event.UndoableEditListener l) |
void |
setActionMap(javax.swing.ActionMap newValue)
Sets the ActionMap for the Tool.
|
void |
setInputMap(javax.swing.InputMap newValue)
Sets the InputMap for the Tool.
|
boolean |
supportsHandleInteraction()
Returns true, if this tool lets the user interact with handles.
|
void |
updateCursor(DrawingView view,
java.awt.Point p) |
protected java.awt.geom.Point2D.Double |
viewToDrawing(java.awt.Point p) |
addPropertyChangeListener, addPropertyChangeListener, clone, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
protected boolean isWorking
protected DrawingEditor editor
protected java.awt.Point anchor
protected javax.swing.event.EventListenerList listenerList
public void addUndoableEditListener(javax.swing.event.UndoableEditListener l)
public void removeUndoableEditListener(javax.swing.event.UndoableEditListener l)
public void activate(DrawingEditor editor)
Tool
public void deactivate(DrawingEditor editor)
Tool
deactivate
in interface Tool
public boolean isActive()
protected DrawingView getView()
protected DrawingEditor getEditor()
protected Drawing getDrawing()
protected java.awt.geom.Point2D.Double viewToDrawing(java.awt.Point p)
protected java.awt.geom.Point2D.Double constrainPoint(java.awt.Point p)
protected java.awt.geom.Point2D.Double constrainPoint(java.awt.geom.Point2D.Double p)
public void setInputMap(javax.swing.InputMap newValue)
public javax.swing.InputMap getInputMap()
public void setActionMap(javax.swing.ActionMap newValue)
keyPressed(java.awt.event.KeyEvent)
public javax.swing.ActionMap getActionMap()
public void editDelete()
editDelete
in interface Tool
public void editCut()
public void editCopy()
public void editDuplicate()
editDuplicate
in interface Tool
public void editPaste()
public void keyReleased(java.awt.event.KeyEvent evt)
keyReleased
in interface java.awt.event.KeyListener
public void keyTyped(java.awt.event.KeyEvent evt)
keyTyped
in interface java.awt.event.KeyListener
public void keyPressed(java.awt.event.KeyEvent evt)
keyPressed
in interface java.awt.event.KeyListener
protected javax.swing.InputMap createInputMap()
The implementation of this class returns null.
protected javax.swing.ActionMap createActionMap()
The implementation of this class returns null.
public void mouseClicked(java.awt.event.MouseEvent evt)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent evt)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent evt)
mouseExited
in interface java.awt.event.MouseListener
public void mouseMoved(java.awt.event.MouseEvent evt)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mousePressed(java.awt.event.MouseEvent evt)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent evt)
mouseReleased
in interface java.awt.event.MouseListener
public void addToolListener(ToolListener l)
Tool
addToolListener
in interface Tool
public void removeToolListener(ToolListener l)
Tool
removeToolListener
in interface Tool
protected void fireToolStarted(DrawingView view)
protected void fireToolDone()
protected void fireAreaInvalidated(java.awt.geom.Rectangle2D.Double r)
protected void fireAreaInvalidated(java.awt.Rectangle invalidatedArea)
protected void maybeFireBoundsInvalidated(java.awt.Rectangle invalidatedArea)
protected void fireBoundsInvalidated(java.awt.Rectangle invalidatedArea)
public void draw(java.awt.Graphics2D g)
Tool
public void updateCursor(DrawingView view, java.awt.Point p)
public java.lang.String getToolTipText(DrawingView view, java.awt.event.MouseEvent evt)
Tool
getToolTipText
in interface Tool
view
- A drawing view.evt
- A mouse event.public boolean supportsHandleInteraction()
Handles may draw differently, if interaction is not possible.
supportsHandleInteraction
in interface Tool