public class CreationTool extends AbstractTool
Tool
to create a new figure by drawing its bounds.
The figure to be created is specified by a prototype.
To create a figure using the CreationTool
, the user does the
following mouse gestures on a DrawingView:
Alltough the mouse gestures might be fitting for the creation of a connection, the CreationTool is not suited for the creation of a ConnectionFigure. Use the ConnectionTool for this type of figures instead.
Prototype
The creation tool creates new figures by cloning a prototype figure object.
That's the reason why Figure
extends the Cloneable
interface.
Prototype: Figure
; Client: CreationTool
.
Modifier and Type | Field and Description |
---|---|
protected Figure |
createdFigure
The created figure.
|
protected java.awt.Dimension |
minimalSize
We set the figure to this minimal size, if it is smaller than the
minimal size treshold.
|
protected java.awt.Dimension |
minimalSizeTreshold
Treshold for which we create a larger shape of a minimal size.
|
protected java.lang.String |
presentationName
A localized name for this tool.
|
protected Figure |
prototype
The prototype for new figures.
|
protected java.util.Map<AttributeKey,java.lang.Object> |
prototypeAttributes
Attributes to be applied to the created ConnectionFigure.
|
anchor, editor, isWorking, listenerList
propertySupport
Constructor and Description |
---|
CreationTool(Figure prototype)
Creates a new instance with the specified prototype but without an
attribute set.
|
CreationTool(Figure prototype,
java.util.Map<AttributeKey,java.lang.Object> attributes)
Creates a new instance with the specified prototype but without an
attribute set.
|
CreationTool(Figure prototype,
java.util.Map<AttributeKey,java.lang.Object> attributes,
java.lang.String name)
Deprecated.
This constructor might go away, because the name parameter
is not used.
|
CreationTool(java.lang.String prototypeClassName)
Creates a new instance.
|
CreationTool(java.lang.String prototypeClassName,
java.util.Map<AttributeKey,java.lang.Object> attributes) |
CreationTool(java.lang.String prototypeClassName,
java.util.Map<AttributeKey,java.lang.Object> attributes,
java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
void |
activate(DrawingEditor editor)
Activates the tool for the given editor.
|
protected Figure |
createFigure() |
protected void |
creationFinished(Figure createdFigure)
This method allows subclasses to do perform additonal user interactions
after the new figure has been created.
|
void |
deactivate(DrawingEditor editor)
Deactivates the tool.
|
protected Figure |
getAddedFigure() |
protected Figure |
getCreatedFigure() |
Figure |
getPrototype() |
boolean |
isToolDoneAfterCreation()
Returns true, if this tool fires toolDone immediately after a new
figure has been created.
|
void |
mouseDragged(java.awt.event.MouseEvent evt) |
void |
mousePressed(java.awt.event.MouseEvent evt) |
void |
mouseReleased(java.awt.event.MouseEvent evt) |
void |
setToolDoneAfterCreation(boolean newValue)
If this is set to false, the CreationTool does not fire toolDone
after a new Figure has been created.
|
void |
updateCursor(DrawingView view,
java.awt.Point p) |
addToolListener, addUndoableEditListener, constrainPoint, constrainPoint, createActionMap, createInputMap, draw, editCopy, editCut, editDelete, editDuplicate, editPaste, fireAreaInvalidated, fireAreaInvalidated, fireBoundsInvalidated, fireToolDone, fireToolStarted, getActionMap, getDrawing, getEditor, getInputMap, getToolTipText, getView, isActive, keyPressed, keyReleased, keyTyped, maybeFireBoundsInvalidated, mouseClicked, mouseEntered, mouseExited, mouseMoved, removeToolListener, removeUndoableEditListener, setActionMap, setInputMap, supportsHandleInteraction, viewToDrawing
addPropertyChangeListener, addPropertyChangeListener, clone, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
protected java.util.Map<AttributeKey,java.lang.Object> prototypeAttributes
protected java.lang.String presentationName
protected java.awt.Dimension minimalSizeTreshold
protected java.awt.Dimension minimalSize
protected Figure prototype
protected Figure createdFigure
public CreationTool(java.lang.String prototypeClassName)
public CreationTool(java.lang.String prototypeClassName, java.util.Map<AttributeKey,java.lang.Object> attributes)
public CreationTool(java.lang.String prototypeClassName, java.util.Map<AttributeKey,java.lang.Object> attributes, java.lang.String name)
public CreationTool(Figure prototype)
prototype
- The prototype used to create a new Figure.public CreationTool(Figure prototype, java.util.Map<AttributeKey,java.lang.Object> attributes)
prototype
- The prototype used to create a new Figure.attributes
- The CreationTool applies these attributes to the
prototype after having applied the default attributes from the DrawingEditor.public CreationTool(Figure prototype, java.util.Map<AttributeKey,java.lang.Object> attributes, java.lang.String name)
prototype
- The prototype used to create a new Figure.attributes
- The CreationTool applies these attributes to the
prototype after having applied the default attributes from the DrawingEditor.name
- The name parameter is currently not used.public Figure getPrototype()
public void activate(DrawingEditor editor)
Tool
activate
in interface Tool
activate
in class AbstractTool
public void deactivate(DrawingEditor editor)
Tool
deactivate
in interface Tool
deactivate
in class AbstractTool
public void mousePressed(java.awt.event.MouseEvent evt)
mousePressed
in interface java.awt.event.MouseListener
mousePressed
in class AbstractTool
public void mouseDragged(java.awt.event.MouseEvent evt)
public void mouseReleased(java.awt.event.MouseEvent evt)
mouseReleased
in interface java.awt.event.MouseListener
mouseReleased
in class AbstractTool
protected Figure createFigure()
protected Figure getCreatedFigure()
protected Figure getAddedFigure()
protected void creationFinished(Figure createdFigure)
public void setToolDoneAfterCreation(boolean newValue)
public boolean isToolDoneAfterCreation()
public void updateCursor(DrawingView view, java.awt.Point p)
updateCursor
in class AbstractTool