Class AutonomousSite

  • All Implemented Interfaces:
    Site

    public class AutonomousSite
    extends AbstractSite
    A site that is not attached to a figure. Autonomous sites are useful in building editors in which connectors can be reshaped or reconnected, as the connector can be attached to an autonomous site and then the autonomous site moved. Because sites must be located in a transform context, the constructor of autonomous sites requires that a transform context be supplied. For convenience, there are other constructors that accept a figures or pane, and use the transform context of that object.
    Version:
    $Id$
    Author:
    John Reekie
    • Constructor Summary

      Constructors 
      Constructor Description
      AutonomousSite​(CanvasLayer l, double x, double y)
      Create a new autonomous site in the transform context of the given pane and at the given location within that layer.
      AutonomousSite​(CanvasPane p, double x, double y)
      Create a new autonomous site in the transform context of the given pane and at the given location within that pane.
      AutonomousSite​(Figure f, double x, double y)
      Create a new autonomous site in the transform context of the given figure and at the given location within that figure.
      AutonomousSite​(TransformContext c, double x, double y)
      Create a new autonomous site in the given transform context and at the given location within that context.
    • Constructor Detail

      • AutonomousSite

        public AutonomousSite​(TransformContext c,
                              double x,
                              double y)
        Create a new autonomous site in the given transform context and at the given location within that context.
      • AutonomousSite

        public AutonomousSite​(CanvasPane p,
                              double x,
                              double y)
        Create a new autonomous site in the transform context of the given pane and at the given location within that pane.
      • AutonomousSite

        public AutonomousSite​(CanvasLayer l,
                              double x,
                              double y)
        Create a new autonomous site in the transform context of the given pane and at the given location within that layer.
      • AutonomousSite

        public AutonomousSite​(Figure f,
                              double x,
                              double y)
        Create a new autonomous site in the transform context of the given figure and at the given location within that figure.
    • Method Detail

      • getFigure

        public Figure getFigure()
        Return null. Autonomous sites are not attached to a figure.
        Specified by:
        getFigure in interface Site
        Specified by:
        getFigure in class AbstractSite
        Returns:
        The figure.
      • getID

        public int getID()
        Return zero. Autonomous sites don't have a meaningful ID.
        Specified by:
        getID in interface Site
        Specified by:
        getID in class AbstractSite
        Returns:
        The unique identifier.
      • getX

        public double getX()
        Get the x-coordinate of the site, in the enclosing transform context.
        Specified by:
        getX in interface Site
        Specified by:
        getX in class AbstractSite
        Returns:
        The x-coordinate of the site.
      • getY

        public double getY()
        Get the y-coordinate of the site, in the enclosing transform context.
        Specified by:
        getY in interface Site
        Specified by:
        getY in class AbstractSite
        Returns:
        The y-coordinate of the site.
      • setLocation

        public void setLocation​(TransformContext c,
                                double x,
                                double y)
        Set the transform context and the location within the new transform context. This is typically used when dragging an autonomous site across context boundaries.
      • translate

        public void translate​(double x,
                              double y)
        Translate the site by the indicated distance.
        Specified by:
        translate in interface Site
        Overrides:
        translate in class AbstractSite
        Parameters:
        x - The x distance to be translated.
        y - The y distance to be translated.