Package diva.canvas.connector
Class ConnectorInteractor
- java.lang.Object
-
- diva.canvas.interactor.AbstractInteractor
-
- diva.canvas.interactor.DragInteractor
-
- diva.canvas.connector.ConnectorInteractor
-
- All Implemented Interfaces:
LayerListener,LayerMotionListener,Interactor,java.util.EventListener
- Direct Known Subclasses:
ArcInteractor
public class ConnectorInteractor extends DragInteractor
An interactor for dragging one end of a connector. This is a utility class designed for use in conjunction with ConnectorManipulator.- Version:
- $Id$
- Author:
- John Reekie, Steve Neuendorffer
-
-
Constructor Summary
Constructors Constructor Description ConnectorInteractor(ConnectorManipulator m)Create a new interactor to be used with the given manipulator
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void_notifyConnectorListeners(ConnectorEvent event, int id)Notify registered connector listeners of the specified event.voidaddConnectorListener(ConnectorListener l)Add a connector listener.protected voidfireConnectorEvent(int id)Fire a connector event to all connector listeners.ConnectorgetConnector()Get the current connector.GrabHandlegetHandle()Get the current grab handle.FiguregetTarget()Get the current target figure.voidmouseReleased(LayerEvent event)Handle a mouse-released event.voidremoveConnectorListener(ConnectorListener l)Remove a connector listener.voidsetup(LayerEvent e)Initialize the interactor when a grab-handle is grabbed.voidsnapToSite(FigureContainer container, java.awt.geom.Rectangle2D hitRect)Pick a site using the connector target and then snap to it.voidtranslate(LayerEvent e, double dx, double dy)Respond to translation of the grab-handle.-
Methods inherited from class diva.canvas.interactor.DragInteractor
addLayerListener, appendConstraint, constrainPoint, fireLayerEvent, getSelectiveEnabled, getTargetArray, getX, getY, mouseDragged, mousePressed, prependConstraint, removeLayerListener, setSelectiveEnabled, setTargetArray, targets
-
Methods inherited from class diva.canvas.interactor.AbstractInteractor
accept, getMouseFilter, isConsuming, isEnabled, isMotionEnabled, mouseClicked, mouseEntered, mouseExited, mouseMoved, setConsuming, setEnabled, setMotionEnabled, setMouseFilter
-
-
-
-
Constructor Detail
-
ConnectorInteractor
public ConnectorInteractor(ConnectorManipulator m)
Create a new interactor to be used with the given manipulator
-
-
Method Detail
-
addConnectorListener
public void addConnectorListener(ConnectorListener l)
Add a connector listener. The listener will be notified on all significant events.- Parameters:
l- The connector listener
-
fireConnectorEvent
protected void fireConnectorEvent(int id)
Fire a connector event to all connector listeners.- Parameters:
id- The id
-
getConnector
public Connector getConnector()
Get the current connector. If there isn't one, return null.- Returns:
- The connector
-
getHandle
public GrabHandle getHandle()
Get the current grab handle.- Returns:
- The grab handle
-
getTarget
public Figure getTarget()
Get the current target figure. If there isn't one, return null.- Returns:
- The target
-
mouseReleased
public void mouseReleased(LayerEvent event)
Handle a mouse-released event. This overrides the inherited method to generate a connector-dropped event.- Specified by:
mouseReleasedin interfaceLayerListener- Overrides:
mouseReleasedin classDragInteractor- Parameters:
event- The event
-
removeConnectorListener
public void removeConnectorListener(ConnectorListener l)
Remove a connector listener.- Parameters:
l- The listener to be removed
-
setup
public void setup(LayerEvent e)
Initialize the interactor when a grab-handle is grabbed.- Overrides:
setupin classDragInteractor- Parameters:
e- The event
-
snapToSite
public void snapToSite(FigureContainer container, java.awt.geom.Rectangle2D hitRect)
Pick a site using the connector target and then snap to it.- Parameters:
container- The container to pick in.hitRect- the coordinates of the drag point in the transform context of that container.
-
translate
public void translate(LayerEvent e, double dx, double dy)
Respond to translation of the grab-handle. Move the grab-handle, and adjust the connector accordingly, snapping it to a suitable target if possible.- Overrides:
translatein classDragInteractor- Parameters:
e- The eventdx- The change in xdy- The change in y
-
_notifyConnectorListeners
protected void _notifyConnectorListeners(ConnectorEvent event, int id)
Notify registered connector listeners of the specified event.- Parameters:
event- The event.id- The id of the event (dragged, dropped, etc.).
-
-