diva.canvas.connector
Class AutonomousSite

java.lang.Object
  extended by diva.canvas.AbstractSite
      extended by diva.canvas.connector.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: AutonomousSite.java 38798 2005-07-08 20:00:01Z cxh $
Author:
John Reekie

Field Summary
private  TransformContext _context
          The enclosing transform context
private  double _x
          The location of this site.
private  double _y
           
 
Fields inherited from class diva.canvas.AbstractSite
_hasNormal, _normal
 
Constructor Summary
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.
 
Method Summary
 Figure getFigure()
          Return null.
 int getID()
          Return zero.
 TransformContext getTransformContext()
          Get the enclosing transform context of this site.
 double getX()
          Get the x-coordinate of the site, in the enclosing transform context.
 double getY()
          Get the y-coordinate of the site, in the enclosing transform context.
 void setLocation(TransformContext c, double x, double y)
          Set the transform context and the location within the new transform context.
 void translate(double x, double y)
          Translate the site by the indicated distance.
 
Methods inherited from class diva.canvas.AbstractSite
getNormal, getPoint, getPoint, getPoint, getPoint, hasNormal, isNormal, setNormal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_context

private TransformContext _context
The enclosing transform context


_x

private double _x
The location of this site.


_y

private double _y
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

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

getTransformContext

public TransformContext getTransformContext()
Get the enclosing transform context of this site. This is the context given to the constructor or set in the setLocation() method.

Specified by:
getTransformContext in interface Site
Overrides:
getTransformContext in class AbstractSite

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

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

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