Package diva.canvas.connector
Class AutonomousSite
- java.lang.Object
-
- diva.canvas.AbstractSite
-
- 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$
- Author:
- John Reekie
-
-
Field Summary
-
Fields inherited from class diva.canvas.AbstractSite
_hasNormal, _normal
-
-
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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
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 interfaceSite
- Specified by:
getFigure
in classAbstractSite
- Returns:
- The figure.
-
getID
public int getID()
Return zero. Autonomous sites don't have a meaningful ID.- Specified by:
getID
in interfaceSite
- Specified by:
getID
in classAbstractSite
- Returns:
- The unique identifier.
-
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 interfaceSite
- Overrides:
getTransformContext
in classAbstractSite
- Returns:
- The transform context
-
getX
public double getX()
Get the x-coordinate of the site, in the enclosing transform context.- Specified by:
getX
in interfaceSite
- Specified by:
getX
in classAbstractSite
- 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 interfaceSite
- Specified by:
getY
in classAbstractSite
- 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 interfaceSite
- Overrides:
translate
in classAbstractSite
- Parameters:
x
- The x distance to be translated.y
- The y distance to be translated.
-
-