Class 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 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
      • 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:
        setup in class DragInteractor
        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:
        translate in class DragInteractor
        Parameters:
        e - The event
        dx - The change in x
        dy - 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.).