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 FiguregetFigure()Return null.intgetID()Return zero.TransformContextgetTransformContext()Get the enclosing transform context of this site.doublegetX()Get the x-coordinate of the site, in the enclosing transform context.doublegetY()Get the y-coordinate of the site, in the enclosing transform context.voidsetLocation(TransformContext c, double x, double y)Set the transform context and the location within the new transform context.voidtranslate(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:
getFigurein interfaceSite- Specified by:
getFigurein classAbstractSite- Returns:
- The figure.
-
getID
public int getID()
Return zero. Autonomous sites don't have a meaningful ID.- Specified by:
getIDin interfaceSite- Specified by:
getIDin 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:
getTransformContextin interfaceSite- Overrides:
getTransformContextin classAbstractSite- Returns:
- The transform context
-
getX
public double getX()
Get the x-coordinate of the site, in the enclosing transform context.- Specified by:
getXin interfaceSite- Specified by:
getXin 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:
getYin interfaceSite- Specified by:
getYin 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:
translatein interfaceSite- Overrides:
translatein classAbstractSite- Parameters:
x- The x distance to be translated.y- The y distance to be translated.
-
-