diva.canvas
Class AbstractSite

java.lang.Object
  extended by 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, StraightTerminal.ConnectSite

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: AbstractSite.java 39592 2005-10-24 19:09:12Z cxh $
Author:
John Reekie
Accepted Rating:
Red

Field Summary
protected  boolean _hasNormal
          True if the site has had its normal set by setNormal.
protected  double _normal
          The normal of the site.
 
Constructor Summary
AbstractSite()
           
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_normal

protected double _normal
The normal of the site. This is 0.0 by default.


_hasNormal

protected boolean _hasNormal
True if the site has had its normal set by setNormal. Default is false.

Constructor Detail

AbstractSite

public AbstractSite()
Method Detail

getFigure

public abstract Figure getFigure()
Get the figure to which this site is attached.

Specified by:
getFigure in interface Site

getID

public abstract int getID()
Get the ID of this site.

Specified by:
getID in interface 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.

Specified by:
getNormal in interface Site

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.

Specified by:
getPoint in interface Site

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.

Specified by:
getPoint in interface Site

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.

Specified by:
getPoint in interface Site

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.

Specified by:
getPoint in interface Site

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 interface Site

getX

public abstract double getX()
Get the x-coordinate of the site, in the enclosing transform context.

Specified by:
getX in interface Site

getY

public abstract double getY()
Get the y-coordinate of the site, in the enclosing transform context.

Specified by:
getY in interface Site

hasNormal

public boolean hasNormal()
Test if this site has a "normal" to it. Return true if setNormal has been called and false otherwise.

Specified by:
hasNormal in interface Site

isNormal

public boolean isNormal(int direction)
Test if this site has a normal in the given direction. This default implementation returns false.

Specified by:
isNormal in interface Site

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.

Specified by:
setNormal in interface Site

translate

public void translate(double x,
                      double y)
Translate the site by the indicated distance. This default implementation does nothing.

Specified by:
translate in interface Site