Package diva.canvas.connector
Class TerminalFigure
- java.lang.Object
- 
- diva.canvas.AbstractFigure
- 
- diva.canvas.connector.TerminalFigure
 
 
- 
- All Implemented Interfaces:
- CanvasComponent,- Terminal,- Figure,- VisibleComponent,- UserObjectContainer
 - Direct Known Subclasses:
- PortTerminal
 
 public class TerminalFigure extends AbstractFigure implements Terminal A TerminalFigure decorates a figure to be a terminal as well. Using this class, any Figure can be made a terminal. As per the decorator pattern, the Figure should be not be accessed externally to this class.- Version:
- $Id$
- Author:
- Steve Neuendorffer
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected Site_connectSite
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedTerminalFigure(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 SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(java.awt.geom.Point2D p)Test whether this figure contains the point given.SitegetAttachSite()Get the site that the terminal is attached to.java.awt.geom.Rectangle2DgetBounds()Get the bounding box of this figure.SitegetConnectSite()Get the site that a connector can connect to.FiguregetFigure()Get the figure that this terminal figure is wrapping.InteractorgetInteractor()Return the interactor of this figure.CanvasLayergetLayer()Get the most immediate layer containing this figure.java.awt.geom.Point2DgetOrigin()Return the origin of the wrapped figure in the enclosing transform context.CanvasComponentgetParent()Return the parent of this component.java.awt.ShapegetShape()Get the outline shape of this figure.java.lang.StringgetToolTipText()Return the tooltip for this figure.TransformContextgetTransformContext()Return the transform context of the component.java.lang.ObjectgetUserObject()Return the user object.booleanhit(java.awt.geom.Rectangle2D r)Test if this figure is "hit" by the given rectangle.booleanintersects(java.awt.geom.Rectangle2D r)Test if this figure intersects the given rectangle.booleanisVisible()Test the visibility flag of this object.voidpaint(java.awt.Graphics2D g)Paint the figure.voidpaint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D region)Paint this object onto a 2D graphics object, within the given region.voidrelocate()Tell the terminal to relocate itself because the attachment site (or the figure that owns it) has moved.voidrepaint()Schedule a repaint of the component.voidrepaint(DamageRegion d)Accept notification that a repaint has occurred somewhere in the tree below this component.voidsetAttachSite(Site s)Set the site that the terminal is attached to.voidsetInteractor(Interactor interactor)Set the interactor of this figure.voidsetParent(CanvasComponent fc)Set the parent of this figure.voidsetToolTipText(java.lang.String tip)Set the tool tip for this figure.voidsetUserObject(java.lang.Object o)Set the user object.voidsetVisible(boolean flag)Set the visibility flag of this object.voidtransform(java.awt.geom.AffineTransform at)Transform the figure with the supplied transform.voidtranslate(double x, double y)Move the figure the indicated distance.
 
- 
- 
- 
Field Detail- 
_connectSiteprotected Site _connectSite 
 
- 
 - 
Constructor Detail- 
TerminalFigurepublic TerminalFigure(Figure figure, Site connectSite) Create a new TerminalFigure for the given figure, with the given site for connections.
 - 
TerminalFigureprotected 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- 
containspublic 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:
- containsin interface- Figure
- Overrides:
- containsin class- AbstractFigure
- Parameters:
- p- The given point
- Returns:
- true if the point is contained by this figure.
 
 - 
getBoundspublic java.awt.geom.Rectangle2D getBounds() Get the bounding box of this figure. The result rectangle is given in the enclosing transform context.- Specified by:
- getBoundsin interface- Figure
- Overrides:
- getBoundsin class- AbstractFigure
- Returns:
- the bounding box of this figure.
 
 - 
getAttachSitepublic Site getAttachSite() Get the site that the terminal is attached to.- Specified by:
- getAttachSitein interface- Terminal
 
 - 
getConnectSitepublic Site getConnectSite() Get the site that a connector can connect to.- Specified by:
- getConnectSitein interface- Terminal
 
 - 
getFigurepublic 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.
 - 
getInteractorpublic Interactor getInteractor() Return the interactor of this figure. Return null if there isn't one.- Specified by:
- getInteractorin interface- Figure
- Overrides:
- getInteractorin class- AbstractFigure
- Returns:
- the interactor of this figure or null.
- See Also:
- Figure.setInteractor(Interactor)
 
 - 
getLayerpublic CanvasLayer getLayer() Get the most immediate layer containing this figure.- Specified by:
- getLayerin interface- Figure
- Overrides:
- getLayerin class- AbstractFigure
- Returns:
- the most immediate layer containing this figure.
 
 - 
getOriginpublic java.awt.geom.Point2D getOrigin() Return the origin of the wrapped figure in the enclosing transform context.- Specified by:
- getOriginin interface- Figure
- Overrides:
- getOriginin class- AbstractFigure
- Returns:
- The origin of the background figure.
- See Also:
- AbstractFigure.getBounds()
 
 - 
getParentpublic CanvasComponent getParent() Return the parent of this component. Return null if the component does not have a parent.- Specified by:
- getParentin interface- CanvasComponent
- Specified by:
- getParentin interface- Figure
- Overrides:
- getParentin class- AbstractFigure
- Returns:
- the parent of this figure.
- See Also:
- Figure.setParent(CanvasComponent)
 
 - 
getTransformContextpublic 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:
- getTransformContextin interface- CanvasComponent
- Overrides:
- getTransformContextin class- AbstractFigure
- Returns:
- The transform context of this component.
 
 - 
getShapepublic 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:
- getShapein interface- Figure
- Specified by:
- getShapein class- AbstractFigure
- Returns:
- the outline shape of this figure
 
 - 
getToolTipTextpublic java.lang.String getToolTipText() Return the tooltip for this figure.- Specified by:
- getToolTipTextin interface- Figure
- Overrides:
- getToolTipTextin class- AbstractFigure
- Returns:
- the tooltip string for this figure.
- See Also:
- Figure.setToolTipText(String)
 
 - 
getUserObjectpublic java.lang.Object getUserObject() Return the user object.- Specified by:
- getUserObjectin interface- UserObjectContainer
- Overrides:
- getUserObjectin class- AbstractFigure
- Returns:
- The user object.
- See Also:
- UserObjectContainer.setUserObject(Object)
 
 - 
hitpublic 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:
- hitin interface- Figure
- Overrides:
- hitin class- AbstractFigure
- Parameters:
- r- The rectangle to be checked.
- Returns:
- true if the figure is hit by the given rectangle.
 
 - 
intersectspublic 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:
- intersectsin interface- Figure
- Overrides:
- intersectsin class- AbstractFigure
- Parameters:
- r- The rectangle to be checked.
- Returns:
- truen if the figure intersects the given rectangle.
 
 - 
isVisiblepublic 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:
- isVisiblein interface- VisibleComponent
- Overrides:
- isVisiblein class- AbstractFigure
- Returns:
- true if the object is visible.
 
 - 
paintpublic void paint(java.awt.Graphics2D g) Paint the figure.- Specified by:
- paintin interface- VisibleComponent
- Specified by:
- paintin class- AbstractFigure
- Parameters:
- g- The 2D graphics object that this object it to be painted upon.
 
 - 
paintpublic 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:
- paintin interface- VisibleComponent
- Overrides:
- paintin class- AbstractFigure
- Parameters:
- g- The 2D graphics object that this object it to be painted upon.
- region- The region.
 
 - 
relocatepublic void relocate() Tell the terminal to relocate itself because the attachment site (or the figure that owns it) has moved.
 - 
repaintpublic void repaint() Schedule a repaint of the component. This should be called after performing modifications on the component.- Specified by:
- repaintin interface- CanvasComponent
- Overrides:
- repaintin class- AbstractFigure
 
 - 
repaintpublic 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:
- repaintin interface- CanvasComponent
- Overrides:
- repaintin class- AbstractFigure
- Parameters:
- d- The region where a repaint has occurred.
 
 - 
setAttachSitepublic void setAttachSite(Site s) Set the site that the terminal is attached to.- Specified by:
- setAttachSitein interface- Terminal
 
 - 
setInteractorpublic 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:
- setInteractorin interface- Figure
- Overrides:
- setInteractorin class- AbstractFigure
- Parameters:
- interactor- The interactor.
- See Also:
- Figure.getInteractor()
 
 - 
setParentpublic 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:
- setParentin interface- Figure
- Overrides:
- setParentin class- AbstractFigure
- Parameters:
- fc- The parent of the figure.
- See Also:
- Figure.getParent()
 
 - 
setToolTipTextpublic void setToolTipText(java.lang.String tip) Set the tool tip for this figure.- Specified by:
- setToolTipTextin interface- Figure
- Overrides:
- setToolTipTextin class- AbstractFigure
- Parameters:
- tip- The tool tip text.
- See Also:
- Figure.getToolTipText()
 
 - 
transformpublic 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:
- transformin interface- Figure
- Specified by:
- transformin class- AbstractFigure
- Parameters:
- at- The transform to be used.
 
 - 
translatepublic void translate(double x, double y)Move the figure the indicated distance.- Specified by:
- translatein interface- Figure
- Overrides:
- translatein class- AbstractFigure
- Parameters:
- x- The x value to be moved.
- y- The y value to be moved.
 
 - 
setUserObjectpublic void setUserObject(java.lang.Object o) Set the user object.- Specified by:
- setUserObjectin interface- UserObjectContainer
- Overrides:
- setUserObjectin class- AbstractFigure
- Parameters:
- o- The user object.
- See Also:
- UserObjectContainer.getUserObject()
 
 - 
setVisiblepublic 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:
- setVisiblein interface- VisibleComponent
- Overrides:
- setVisiblein class- AbstractFigure
- Parameters:
- flag- True if this object is to be visible.
 
 
- 
 
-