Class TerminalFigure

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Site _connectSite  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected TerminalFigure​(Figure figure)
      Create a new TerminalFigure for the given figure.
        TerminalFigure​(Figure figure, Site connectSite)
      Create a new TerminalFigure for the given figure, with the given site for connections.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contains​(java.awt.geom.Point2D p)
      Test whether this figure contains the point given.
      Site getAttachSite()
      Get the site that the terminal is attached to.
      java.awt.geom.Rectangle2D getBounds()
      Get the bounding box of this figure.
      Site getConnectSite()
      Get the site that a connector can connect to.
      Figure getFigure()
      Get the figure that this terminal figure is wrapping.
      Interactor getInteractor()
      Return the interactor of this figure.
      CanvasLayer getLayer()
      Get the most immediate layer containing this figure.
      java.awt.geom.Point2D getOrigin()
      Return the origin of the wrapped figure in the enclosing transform context.
      CanvasComponent getParent()
      Return the parent of this component.
      java.awt.Shape getShape()
      Get the outline shape of this figure.
      java.lang.String getToolTipText()
      Return the tooltip for this figure.
      TransformContext getTransformContext()
      Return the transform context of the component.
      java.lang.Object getUserObject()
      Return the user object.
      boolean hit​(java.awt.geom.Rectangle2D r)
      Test if this figure is "hit" by the given rectangle.
      boolean intersects​(java.awt.geom.Rectangle2D r)
      Test if this figure intersects the given rectangle.
      boolean isVisible()
      Test the visibility flag of this object.
      void paint​(java.awt.Graphics2D g)
      Paint the figure.
      void paint​(java.awt.Graphics2D g, java.awt.geom.Rectangle2D region)
      Paint this object onto a 2D graphics object, within the given region.
      void relocate()
      Tell the terminal to relocate itself because the attachment site (or the figure that owns it) has moved.
      void repaint()
      Schedule a repaint of the component.
      void repaint​(DamageRegion d)
      Accept notification that a repaint has occurred somewhere in the tree below this component.
      void setAttachSite​(Site s)
      Set the site that the terminal is attached to.
      void setInteractor​(Interactor interactor)
      Set the interactor of this figure.
      void setParent​(CanvasComponent fc)
      Set the parent of this figure.
      void setToolTipText​(java.lang.String tip)
      Set the tool tip for this figure.
      void setUserObject​(java.lang.Object o)
      Set the user object.
      void setVisible​(boolean flag)
      Set the visibility flag of this object.
      void transform​(java.awt.geom.AffineTransform at)
      Transform the figure with the supplied transform.
      void translate​(double x, double y)
      Move the figure the indicated distance.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • _connectSite

        protected Site _connectSite
    • Constructor Detail

      • TerminalFigure

        public TerminalFigure​(Figure figure,
                              Site connectSite)
        Create a new TerminalFigure for the given figure, with the given site for connections.
      • TerminalFigure

        protected TerminalFigure​(Figure figure)
        Create a new TerminalFigure for the given figure. This is intended for use by derived classes that will provide their own connect site or sites.
    • Method Detail

      • contains

        public boolean contains​(java.awt.geom.Point2D p)
        Test whether this figure contains the point given. The point given is in the enclosing transform context.
        Specified by:
        contains in interface Figure
        Overrides:
        contains in class AbstractFigure
        Parameters:
        p - The given point
        Returns:
        true if the point is contained by this figure.
      • getBounds

        public java.awt.geom.Rectangle2D getBounds()
        Get the bounding box of this figure. The result rectangle is given in the enclosing transform context.
        Specified by:
        getBounds in interface Figure
        Overrides:
        getBounds in class AbstractFigure
        Returns:
        the bounding box of this figure.
      • getAttachSite

        public Site getAttachSite()
        Get the site that the terminal is attached to.
        Specified by:
        getAttachSite in interface Terminal
      • getConnectSite

        public Site getConnectSite()
        Get the site that a connector can connect to.
        Specified by:
        getConnectSite in interface Terminal
      • getFigure

        public Figure getFigure()
        Get the figure that this terminal figure is wrapping. Note usage of this figure must be considered extremely carefully to avoid breaking the decorator pattern.
      • getLayer

        public CanvasLayer getLayer()
        Get the most immediate layer containing this figure.
        Specified by:
        getLayer in interface Figure
        Overrides:
        getLayer in class AbstractFigure
        Returns:
        the most immediate layer containing this figure.
      • getTransformContext

        public TransformContext getTransformContext()
        Return the transform context of the component. If the component has its own transform context, this method should return it, otherwise it should return the transform context of its parent.
        Specified by:
        getTransformContext in interface CanvasComponent
        Overrides:
        getTransformContext in class AbstractFigure
        Returns:
        The transform context of this component.
      • getShape

        public java.awt.Shape getShape()
        Get the outline shape of this figure. The outline shape is used for things like highlighting. The result shape is given in the enclosing transform context.
        Specified by:
        getShape in interface Figure
        Specified by:
        getShape in class AbstractFigure
        Returns:
        the outline shape of this figure
      • hit

        public boolean hit​(java.awt.geom.Rectangle2D r)
        Test if this figure is "hit" by the given rectangle. This is the same as intersects if the interior of the figure is not transparent. The rectangle is given in the enclosing transform context. If the figure is not visible, it must return false. The default implementation is the same as intersects if the figure is visible.

        (This method would be better named hits, but the name hit is consistent with java.awt.Graphics2D.)

        Specified by:
        hit in interface Figure
        Overrides:
        hit in class AbstractFigure
        Parameters:
        r - The rectangle to be checked.
        Returns:
        true if the figure is hit by the given rectangle.
      • intersects

        public boolean intersects​(java.awt.geom.Rectangle2D r)
        Test if this figure intersects the given rectangle. The rectangle is given in the enclosing transform context.
        Specified by:
        intersects in interface Figure
        Overrides:
        intersects in class AbstractFigure
        Parameters:
        r - The rectangle to be checked.
        Returns:
        truen if the figure intersects the given rectangle.
      • isVisible

        public boolean isVisible()
        Test the visibility flag of this object. Note that this flag does not indicate whether the object is actually visible on the screen, as one of its ancestors may not be visible.
        Specified by:
        isVisible in interface VisibleComponent
        Overrides:
        isVisible in class AbstractFigure
        Returns:
        true if the object is visible.
      • paint

        public void paint​(java.awt.Graphics2D g)
        Paint the figure.
        Specified by:
        paint in interface VisibleComponent
        Specified by:
        paint in class AbstractFigure
        Parameters:
        g - The 2D graphics object that this object it to be painted upon.
      • paint

        public void paint​(java.awt.Graphics2D g,
                          java.awt.geom.Rectangle2D region)
        Paint this object onto a 2D graphics object, within the given region. Implementors should first test if the visibility flag is set, and paint the object if it is. The provided region can be used to optimize the paint, but implementors can assume that the clip region is correctly set beforehand.
        Specified by:
        paint in interface VisibleComponent
        Overrides:
        paint in class AbstractFigure
        Parameters:
        g - The 2D graphics object that this object it to be painted upon.
        region - The region.
      • relocate

        public void relocate()
        Tell the terminal to relocate itself because the attachment site (or the figure that owns it) has moved.
        Specified by:
        relocate in interface Terminal
      • repaint

        public void repaint()
        Schedule a repaint of the component. This should be called after performing modifications on the component.
        Specified by:
        repaint in interface CanvasComponent
        Overrides:
        repaint in class AbstractFigure
      • repaint

        public void repaint​(DamageRegion d)
        Accept notification that a repaint has occurred somewhere in the tree below this component. The component must clear any cached data that depends on its children and forward the notification upwards.
        Specified by:
        repaint in interface CanvasComponent
        Overrides:
        repaint in class AbstractFigure
        Parameters:
        d - The region where a repaint has occurred.
      • setAttachSite

        public void setAttachSite​(Site s)
        Set the site that the terminal is attached to.
        Specified by:
        setAttachSite in interface Terminal
      • setInteractor

        public void setInteractor​(Interactor interactor)
        Set the interactor of this figure. Once a figure has an interactor given to it, it will respond to events on the canvas, in the ways determined by the interactor.
        Specified by:
        setInteractor in interface Figure
        Overrides:
        setInteractor in class AbstractFigure
        Parameters:
        interactor - The interactor.
        See Also:
        Figure.getInteractor()
      • setParent

        public void setParent​(CanvasComponent fc)
        Set the parent of this figure. A null argument means that the figure is being removed from its parent. No checks are performed to see if the figure already has a parent -- it is the responsibility of the caller to do this. This method is not intended for public use, and should never be called by client code.
        Specified by:
        setParent in interface Figure
        Overrides:
        setParent in class AbstractFigure
        Parameters:
        fc - The parent of the figure.
        See Also:
        Figure.getParent()
      • transform

        public void transform​(java.awt.geom.AffineTransform at)
        Transform the figure with the supplied transform. This can be used to perform arbitrary translation, scaling, shearing, and rotation operations.
        Specified by:
        transform in interface Figure
        Specified by:
        transform in class AbstractFigure
        Parameters:
        at - The transform to be used.
      • translate

        public void translate​(double x,
                              double y)
        Move the figure the indicated distance.
        Specified by:
        translate in interface Figure
        Overrides:
        translate in class AbstractFigure
        Parameters:
        x - The x value to be moved.
        y - The y value to be moved.
      • setVisible

        public void setVisible​(boolean flag)
        Set the visibility flag of this object. If the flag is false, then the object will not be painted on the screen.
        Specified by:
        setVisible in interface VisibleComponent
        Overrides:
        setVisible in class AbstractFigure
        Parameters:
        flag - True if this object is to be visible.