Package diva.canvas
Class AbstractSite
- java.lang.Object
-
- diva.canvas.AbstractSite
-
- All Implemented Interfaces:
Site
- Direct Known Subclasses:
ArcMidpointSite
,AutonomousSite
,BoundsGeometry.BoundsSite
,BoundsSite
,CenterSite
,CircleGeometry.CircleSite
,NullSite
,ParametricSite
,PathGeometry.Vertex
,PerimeterSite
,PortConnectSite
,PortSite
public abstract class AbstractSite extends java.lang.Object implements Site
An abstract implementation of Site. This class provides default implementations of several methods in the Site interface, to make it easier to implement site classes.- Version:
- $Id$
- Author:
- John Reekie
- Pt.AcceptedRating:
- Red
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
_hasNormal
True if the site has had its normal set by setNormal.protected double
_normal
The normal of the site.
-
Constructor Summary
Constructors Constructor Description AbstractSite()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Figure
getFigure()
Get the figure to which this site is attached.abstract int
getID()
Get the ID of this site.double
getNormal()
Get the angle of the normal to this site, in radians between zero and 2pi.java.awt.geom.Point2D
getPoint()
Get the point location of the site, in the enclosing transform context with the default normal.java.awt.geom.Point2D
getPoint(double normal)
Get the point location of the site, in the enclosing transform context with the given normal.java.awt.geom.Point2D
getPoint(TransformContext tc)
Get the point location of the site, in the given transform context with the default normal.java.awt.geom.Point2D
getPoint(TransformContext tc, double normal)
Get the point location of the site, in the given transform context with the given normal.TransformContext
getTransformContext()
Get the enclosing transform context of this site.abstract double
getX()
Get the x-coordinate of the site, in the enclosing transform context.abstract double
getY()
Get the y-coordinate of the site, in the enclosing transform context.boolean
hasNormal()
Test if this site has a "normal" to it.boolean
isNormal(int direction)
Test if this site has a normal in the given direction.void
setNormal(double normal)
Set the normal "out" of the site.void
translate(double x, double y)
Translate the site by the indicated distance.
-
-
-
Method Detail
-
getFigure
public abstract Figure getFigure()
Get the figure to which this site is attached.
-
getID
public abstract int getID()
Get the ID of this site.
-
getNormal
public double getNormal()
Get the angle of the normal to this site, in radians between zero and 2pi. This default method returns 0.0.
-
getPoint
public java.awt.geom.Point2D getPoint()
Get the point location of the site, in the enclosing transform context with the default normal. This method uses the getPoint(double) method, so subclasses only have to override that method.
-
getPoint
public java.awt.geom.Point2D getPoint(TransformContext tc)
Get the point location of the site, in the given transform context with the default normal. The given context must be an enclosing context of the site. This method uses the getPoint(double) method, so subclasses only have to override that method.
-
getPoint
public java.awt.geom.Point2D getPoint(double normal)
Get the point location of the site, in the enclosing transform context with the given normal.
-
getPoint
public java.awt.geom.Point2D getPoint(TransformContext tc, double normal)
Get the point location of the site, in the given transform context with the given normal. The given context must be an enclosing context of the site. This method uses the getPoint(double) method, so subclasses only have to override that method.
-
getTransformContext
public TransformContext getTransformContext()
Get the enclosing transform context of this site. As a default behavior, return the transform context of the associated figure.- Specified by:
getTransformContext
in interfaceSite
- Returns:
- The transform context
-
getX
public abstract double getX()
Get the x-coordinate of the site, in the enclosing transform context.
-
getY
public abstract double getY()
Get the y-coordinate of the site, in the enclosing transform context.
-
hasNormal
public boolean hasNormal()
Test if this site has a "normal" to it. Return true if setNormal has been called and false otherwise.
-
isNormal
public boolean isNormal(int direction)
Test if this site has a normal in the given direction. This default implementation returns false.
-
setNormal
public void setNormal(double normal)
Set the normal "out" of the site. The site effectively moves so that it passes through the center of the given figure. The normal is limited to be between -pi and pi. A normal of zero points to the east, and a normal of pi/2 points to the south. This "upside down" coordinate system is consistent with the upside down coordinate system of the canvas, which has the origin in the upper left.
-
-