Package diva.canvas

Class AbstractSite

    • 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.
      • 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
        Returns:
        The figure.
      • getID

        public abstract int getID()
        Get the ID of this site.
        Specified by:
        getID in interface Site
        Returns:
        The unique identifier.
      • 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
        Returns:
        The normal.
      • 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
        Returns:
        The point.
      • 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
        Parameters:
        tc - The transformation context.
        Returns:
        The point.
      • 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
        Parameters:
        normal - The normal
        Returns:
        The point.
      • 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
        Parameters:
        tc - The Transform context
        normal - The normal
        Returns:
        The point.
      • 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
        Returns:
        The transform context
      • getX

        public abstract double getX()
        Get the x-coordinate of the site, in the enclosing transform context.
        Specified by:
        getX in interface Site
        Returns:
        The x-coordinate of the site.
      • getY

        public abstract double getY()
        Get the y-coordinate of the site, in the enclosing transform context.
        Specified by:
        getY in interface Site
        Returns:
        The y-coordinate of the 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
        Returns:
        true if the site has a normal.
      • 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
        Parameters:
        direction - The direction
        Returns:
        true if the site is normal in the given direction.
      • 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
        Parameters:
        normal - The normal.
      • 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
        Parameters:
        x - The x distance to be translated.
        y - The y distance to be translated.