Class ArcConnector

  • All Implemented Interfaces:
    CanvasComponent, Connector, Figure, VisibleComponent, UserObjectContainer
    Direct Known Subclasses:
    KielerLayoutArcConnector

    public class ArcConnector
    extends AbstractConnector
    A Connector that draws itself in an arc. The connector draws itself approximately through the center of the figures that own the sites to which it is connected. The curvature of the arc can be specified in one of two ways, depending on which variable of the arc's shape remain constant as the distance between the two figures at the ends of the arc is varied:
    1. Constant incident angle: The angle at which the arc connects to the figure remains constant. This is the default behaviour, and the default angle is 45 degrees.
    2. Constant displacement at the maximum arc point, from the straight line drawn between the two end points of the connector. The default displacement is 20 (not for any good reason, but is has to be something...).

    Currently, only the first is supported.

    The connector uses an instance of PaintedPath to draw itself, so see that class for a more detailed description of the paint- and stroke-related methods.

    Version:
    $Id$
    Author:
    Edward Lee, John Reekie
    Pt.AcceptedRating:
    Red
    • Field Detail

      • _CLOSE_THRESHOLD

        protected static final double _CLOSE_THRESHOLD
        The threshold for when a source and a destination of an arc are considered close to one another. This determines how self-loops get drawn.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ArcConnector

        public ArcConnector​(Site tail,
                            Site head)
        Create a new arc connector between the given sites. The connector is drawn with a width of one and in black, and at the default incident angle of 45 degrees (PI/4 radians).
        Parameters:
        tail - The tail
        head - The head
    • Method Detail

      • getAngle

        public double getAngle()
        Get the angle at which the arc leaves the tail figure.
        Returns:
        the angle
        See Also:
        setAngle(double)
      • getGamma

        public double getGamma()
        Get the angle that determines the orientation of a self-loop. This method should be used when saving an arc to an external representation, if the arc is a self-loop.
        Returns:
        the gamma
        See Also:
        setGamma(double)
      • getArcMidpoint

        public java.awt.geom.Point2D getArcMidpoint()
        Return the midpoint of the arc.
        Returns:
        The midpoint of the arc.
      • getMidpointSite

        public Site getMidpointSite()
        Get the site that marks the midpoint of the connector.
        Returns:
        A site representing the midpoint of the arc.
      • getSelfLoop

        public boolean getSelfLoop()
        Get the flag saying whether this arc is to be drawn as a self-loop.
        Returns:
        True if this arc is to be drawn as a self-loop.
        See Also:
        setSelfLoop(boolean)
      • repositionLabel

        public void repositionLabel()
        Tell the connector to reposition its label if it has one. The label is currently only positioned at the center of the arc.
        Specified by:
        repositionLabel in class AbstractConnector
      • route

        public void route()
        Tell the connector to route itself between the current positions of the head and tail sites.
        Specified by:
        route in interface Connector
        Specified by:
        route in class AbstractConnector
      • setAngle

        public void setAngle​(double angle)
        Set the angle at which the arc leaves the tail figure, in radians. Because of the sign of the geometry, an arc with positive angle and with an arrowhead on its head will appear to be drawn counter-clockwise, and an arc with a negative angle will appear to be drawn clockwise. As a general rule, angles should be somewhat less than PI/2, and PI/4 a good general maximum figure. If the angle is outside the range -PI to PI, then it is corrected to lie within that range.
        Parameters:
        angle - The angle
        See Also:
        getAngle()
      • setGamma

        public void setGamma​(double gamma)
        Set the angle that determines the orientation of a self-loop. This value is roughly equal to the angle of the tangent to the loop at it's mid-point. This method is only intended for use when creating self-loop arcs from a saved representation.
        Parameters:
        gamma - The gamma
        See Also:
        getGamma()
      • setSelfLoop

        public void setSelfLoop​(boolean selfloop)
        Set the flag that says that this arc is drawn as a "self-loop." Apart from changing (slightly) the way the arc geometry is determined, this method resets some internal variables so that the arc doesn't get into a "funny state" when switching between self-loops and non-self-loops. Not, however, that this method should only be called when the arc changes, otherwise manipulation won't work properly. Use getSelfLoop() to test the current state of this flag.
        Parameters:
        selfloop - true if this is a self-loop.
        See Also:
        getSelfLoop()
      • translate

        public void translate​(double x,
                              double y)
        Translate the connector. This method is implemented, since controllers may wish to translate connectors when the sites at both ends are moved the same distance.
        Specified by:
        translate in interface Figure
        Specified by:
        translate in class AbstractConnector
        Parameters:
        x - The x value to be moved.
        y - The y value to be moved.
      • translateMidpoint

        public void translateMidpoint​(double dx,
                                      double dy)
        Translate the midpoint of the arc. This method is not exact, but attempts to alter the shape of the arc so that the midpoint moves by something close to the given amount.
        Parameters:
        dx - The x value to transform
        dy - The y value to transform