public class ConnectionTool extends AbstractTool
ConnectionFigure
to be created is specified by a prototype.
The location of the start and end points are controlled by Connector
s.
To create a connection using the ConnectionTool, the user does the following mouse gestures on a DrawingView:
Modifier and Type | Field and Description |
---|---|
protected java.util.Collection<Connector> |
connectors |
protected ConnectionFigure |
createdFigure
The created figure.
|
protected Connector |
endConnector
The Connector at the end point of the connection.
|
protected ConnectionFigure |
prototype
the prototypical figure that is used to create new
connections.
|
protected Connector |
startConnector
The Connector at the start point of the connection.
|
protected Figure |
targetFigure
The figure for which we enabled drawing of connectors.
|
anchor, editor, isWorking, listenerList
propertySupport
Constructor and Description |
---|
ConnectionTool(ConnectionFigure prototype)
Creates a new instance.
|
ConnectionTool(ConnectionFigure prototype,
java.util.Map<AttributeKey,java.lang.Object> attributes) |
ConnectionTool(ConnectionFigure prototype,
java.util.Map<AttributeKey,java.lang.Object> attributes,
java.lang.String presentationName) |
ConnectionTool(java.lang.String prototypeClassName) |
ConnectionTool(java.lang.String prototypeClassName,
java.util.Map<AttributeKey,java.lang.Object> attributes,
java.lang.String presentationName) |
Modifier and Type | Method and Description |
---|---|
void |
activate(DrawingEditor editor)
Activates the tool for the given editor.
|
protected boolean |
canConnect(ConnectionFigure f,
Connector startConnector)
This method is called on the Figure, onto which the user wants
to start a new connection.
|
protected boolean |
canConnect(ConnectionFigure f,
Connector startConnector,
Connector endConnector)
This method is called on the Figure, onto which the user wants
to end a new connection.
|
protected ConnectionFigure |
createFigure()
Creates the ConnectionFigure.
|
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.
|
void |
draw(java.awt.Graphics2D g)
Draws the tool.
|
protected int |
getAnchorWidth() |
ConnectionFigure |
getPrototype() |
boolean |
isToolDoneAfterCreation()
Returns true, if this tool fires toolDone immediately after a new
figure has been created.
|
void |
mouseDragged(java.awt.event.MouseEvent e)
Adjust the created connection.
|
void |
mouseMoved(java.awt.event.MouseEvent evt) |
void |
mousePressed(java.awt.event.MouseEvent evt)
Manipulates connections in a context dependent way.
|
void |
mouseReleased(java.awt.event.MouseEvent e)
Connects the figures if the mouse is released over another
figure.
|
void |
repaintConnectors(java.awt.event.MouseEvent evt)
Updates the list of connectors that we draw when the user
moves or drags the mouse over a figure to which can connect.
|
void |
setToolDoneAfterCreation(boolean newValue)
If this is set to false, the CreationTool does not fire toolDone
after a new Figure has been created.
|
addToolListener, addUndoableEditListener, constrainPoint, constrainPoint, createActionMap, createInputMap, editCopy, editCut, editDelete, editDuplicate, editPaste, fireAreaInvalidated, fireAreaInvalidated, fireBoundsInvalidated, fireToolDone, fireToolStarted, getActionMap, getDrawing, getEditor, getInputMap, getToolTipText, getView, isActive, keyPressed, keyReleased, keyTyped, maybeFireBoundsInvalidated, mouseClicked, mouseEntered, mouseExited, removeToolListener, removeUndoableEditListener, setActionMap, setInputMap, supportsHandleInteraction, updateCursor, viewToDrawing
addPropertyChangeListener, addPropertyChangeListener, clone, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
protected Connector startConnector
protected Connector endConnector
protected ConnectionFigure createdFigure
protected ConnectionFigure prototype
protected Figure targetFigure
protected java.util.Collection<Connector> connectors
public ConnectionTool(ConnectionFigure prototype)
public ConnectionTool(ConnectionFigure prototype, java.util.Map<AttributeKey,java.lang.Object> attributes)
public ConnectionTool(ConnectionFigure prototype, java.util.Map<AttributeKey,java.lang.Object> attributes, java.lang.String presentationName)
public ConnectionTool(java.lang.String prototypeClassName)
public ConnectionTool(java.lang.String prototypeClassName, java.util.Map<AttributeKey,java.lang.Object> attributes, java.lang.String presentationName)
public ConnectionFigure getPrototype()
protected int getAnchorWidth()
protected boolean canConnect(ConnectionFigure f, Connector startConnector)
f
- The ConnectionFigure.startConnector
- The Connector of the start Figure.protected boolean canConnect(ConnectionFigure f, Connector startConnector, Connector endConnector)
f
- The ConnectionFigure.startConnector
- The Connector of the start Figure.endConnector
- The Connector of the end Figure.public void mouseMoved(java.awt.event.MouseEvent evt)
mouseMoved
in interface java.awt.event.MouseMotionListener
mouseMoved
in class AbstractTool
public void repaintConnectors(java.awt.event.MouseEvent evt)
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 e)
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
mouseReleased
in class AbstractTool
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
protected ConnectionFigure createFigure()
public void draw(java.awt.Graphics2D g)
Tool
draw
in interface Tool
draw
in class AbstractTool
protected void creationFinished(Figure createdFigure)
public void setToolDoneAfterCreation(boolean newValue)
public boolean isToolDoneAfterCreation()