Package diva.canvas.connector
Class ConnectorManipulator
- java.lang.Object
-
- diva.canvas.AbstractFigure
-
- diva.canvas.AbstractFigureContainer
-
- diva.canvas.FigureDecorator
-
- diva.canvas.interactor.Manipulator
-
- diva.canvas.connector.ConnectorManipulator
-
- All Implemented Interfaces:
CanvasComponent
,Figure
,FigureContainer
,FigureSet
,VisibleComponent
,UserObjectContainer
- Direct Known Subclasses:
ArcManipulator
public class ConnectorManipulator extends Manipulator
A manipulator which attaches grab handles to the ends of a connector. The interactor given to the grab-handles determines the behaviour of the grab-handles.- Version:
- $Id$
- Author:
- John Reekie, Michael Shilman
-
-
Constructor Summary
Constructors Constructor Description ConnectorManipulator()
Construct a new manipulator that uses rectangular grab-handles.ConnectorManipulator(GrabHandleFactory f)
Construct a new manipulator using the given grab-handle factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_createGrabHandles(Connector connector)
Clear the current grab handles and create one for each of the head and tail sites.void
addConnectorListener(ConnectorListener l)
Add a connector listener to the interactor that is attached to grab-handles.void
addLayerMotionListener(LayerMotionListener l)
Add the given layer motion listener to this interactor.ConnectorTarget
getConnectorTarget()
Get the connector targetGrabHandle
getHeadHandle()
Get the head handledouble
getSnapHalo()
Get the snap halo.GrabHandle
getTailHandle()
Get the tail handleLayerMotionListener
getTargetHighlighter()
Get the listener that highlights target objects.FigureDecorator
newInstance(Figure f)
Create a new instance of this manipulator.void
refresh()
Refresh the geometry.void
removeConnectorListener(ConnectorListener l)
Remove a connector listener from the interactor that is attached to grab-handles.void
removeLayerMotionListener(LayerMotionListener l)
Remove the given layer motion listener from this interactor.void
setChild(Figure f)
Set the child figure.void
setConnectorTarget(ConnectorTarget t)
Set the connector target objectvoid
setSnapHalo(double halo)
Set the snap halo.void
setTargetHighlighter(LayerMotionListener l)
Set the listener that highlights target objects.void
setTargetProperty(java.lang.String key, java.lang.String value)
Set the drop target property and value.-
Methods inherited from class diva.canvas.interactor.Manipulator
addGrabHandle, clearGrabHandles, getBounds, getGrabHandleFactory, getHandleInteractor, isRepainting, paint, pick, relocateGrabHandles, removeGrabHandle, repaint, repaint, repaintAlready, setGrabHandleFactory, setHandleFilter, setHandleInteractor, setRepainting
-
Methods inherited from class diva.canvas.FigureDecorator
add, contains, figures, figuresFromBack, figuresFromFront, getChild, getContainer, getDecoratedFigure, getFigureCount, getShape, hit, remove, replaceChild, transform, translate
-
Methods inherited from class diva.canvas.AbstractFigureContainer
decorate, pick, undecorate
-
Methods inherited from class diva.canvas.AbstractFigure
contains, getInteractor, getLayer, getOrigin, getParent, getToolTipText, getTransformContext, getUserObject, intersects, isVisible, paint, setInteractor, setParent, setToolTipText, setUserObject, setVisible
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface diva.canvas.CanvasComponent
getTransformContext
-
Methods inherited from interface diva.canvas.VisibleComponent
isVisible, paint, setVisible
-
-
-
-
Constructor Detail
-
ConnectorManipulator
public ConnectorManipulator()
Construct a new manipulator that uses rectangular grab-handles.
-
ConnectorManipulator
public ConnectorManipulator(GrabHandleFactory f)
Construct a new manipulator using the given grab-handle factory.
-
-
Method Detail
-
addConnectorListener
public void addConnectorListener(ConnectorListener l)
Add a connector listener to the interactor that is attached to grab-handles.
-
addLayerMotionListener
public void addLayerMotionListener(LayerMotionListener l)
Add the given layer motion listener to this interactor. The listener will be invoked when the mouse moves into, around on, or out of a suitable target object.
-
getConnectorTarget
public ConnectorTarget getConnectorTarget()
Get the connector target
-
getHeadHandle
public GrabHandle getHeadHandle()
Get the head handle
-
getTailHandle
public GrabHandle getTailHandle()
Get the tail handle
-
getSnapHalo
public double getSnapHalo()
Get the snap halo.
-
getTargetHighlighter
public LayerMotionListener getTargetHighlighter()
Get the listener that highlights target objects.
-
newInstance
public FigureDecorator newInstance(Figure f)
Create a new instance of this manipulator. The new instance will have the same grab handle, and interactor for grab-handles, as this one.- Specified by:
newInstance
in classFigureDecorator
- Parameters:
f
- The figure- Returns:
- The new instance of the figure decorator.
-
removeConnectorListener
public void removeConnectorListener(ConnectorListener l)
Remove a connector listener from the interactor that is attached to grab-handles.
-
removeLayerMotionListener
public void removeLayerMotionListener(LayerMotionListener l)
Remove the given layer motion listener from this interactor.
-
refresh
public void refresh()
Refresh the geometry. Check that the sites that the handles are attached to are the same as the sites at the ends of the connector, and if not, fix them. This is needed because some clients might unnecessarily over-write the sites that a connector is already snapped to. If the grab-handles aren't re-attached accordingly, grabbing and moving them will cause unpredictable results.- Specified by:
refresh
in classManipulator
-
setChild
public void setChild(Figure f)
Set the child figure. If we have any grab-handles, lose them. Then create the grab-handles on the ends of the connector.- Overrides:
setChild
in classFigureDecorator
- Parameters:
f
- The child figure.
-
setConnectorTarget
public void setConnectorTarget(ConnectorTarget t)
Set the connector target object
-
setSnapHalo
public void setSnapHalo(double halo)
Set the snap halo. This is the distance from a target object that the connector will "snap" to it.
-
setTargetHighlighter
public void setTargetHighlighter(LayerMotionListener l)
Set the listener that highlights target objects.
-
setTargetProperty
public void setTargetProperty(java.lang.String key, java.lang.String value)
Set the drop target property and value. The interactor will make callbacks to the layer motion listeners while the mouse is over any figure which has an interactor with matching properties.
-
_createGrabHandles
protected void _createGrabHandles(Connector connector)
Clear the current grab handles and create one for each of the head and tail sites. Subclasses may override this to create additional grab handles.- Parameters:
connector
- The connector.
-
-