Package diva.canvas.connector
Class StraightTerminal
- java.lang.Object
-
- diva.canvas.AbstractFigure
-
- diva.canvas.connector.StraightTerminal
-
- All Implemented Interfaces:
CanvasComponent
,Terminal
,Figure
,VisibleComponent
,UserObjectContainer
public class StraightTerminal extends AbstractFigure implements Terminal
A terminal that consists of a straight line plus an additional decoration at the connection end of the terminal.- Version:
- $Id$
- Author:
- John Reekie
-
-
Constructor Summary
Constructors Constructor Description StraightTerminal()
Create a new terminal which is not attached to anything.StraightTerminal(Site attachSite)
Create a new terminal attached to the given site.StraightTerminal(Site attachSite, java.awt.Stroke stroke, java.awt.Paint paint)
Create a new terminal attached to the given site, with the given stroke and paint.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Site
getAttachSite()
Get the site to which the terminal is attachedjava.awt.geom.Rectangle2D
getBounds()
Get the bounding box of this terminal.Site
getConnectSite()
Get the site to which a connector can attachConnectorEnd
getEnd()
Get the object drawn at the end of the terminal, if there is one.java.awt.Paint
getPaint()
Get the paint of this terminal.java.awt.Shape
getShape()
Get the outline shape of this terminal.java.awt.Stroke
getStroke()
Get the stroke of this terminal.boolean
hit(java.awt.geom.Rectangle2D r)
Test if this terminal is hit by the given rectangle.void
paint(java.awt.Graphics2D g)
Paint the terminal.void
relocate()
Tell the terminal to reposition itself over the attachment site.void
setAttachSite(Site s)
Set the site to which the terminal is attached.void
setEnd(ConnectorEnd e)
Set the object drawn at the end of the terminal.void
setPaint(java.awt.Paint p)
Set the stroke paint pattern of this terminal.void
setStroke(java.awt.Stroke s)
Set the stroke of this terminal.void
transform(java.awt.geom.AffineTransform at)
Transform the terminal.void
translate(double x, double y)
Translate the terminal.-
Methods inherited from class diva.canvas.AbstractFigure
contains, getInteractor, getLayer, getOrigin, getParent, getToolTipText, getTransformContext, getUserObject, intersects, isVisible, paint, repaint, repaint, setInteractor, setParent, setToolTipText, setUserObject, setVisible
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface diva.canvas.CanvasComponent
getTransformContext, repaint, repaint
-
Methods inherited from interface diva.canvas.Figure
contains, getInteractor, getLayer, getOrigin, getParent, getToolTipText, intersects, setInteractor, setParent, setToolTipText
-
Methods inherited from interface diva.util.UserObjectContainer
getUserObject, setUserObject
-
Methods inherited from interface diva.canvas.VisibleComponent
isVisible, paint, setVisible
-
-
-
-
Constructor Detail
-
StraightTerminal
public StraightTerminal()
Create a new terminal which is not attached to anything. The terminal should not be displayed until after setAttachSite() is called.
-
StraightTerminal
public StraightTerminal(Site attachSite)
Create a new terminal attached to the given site.
-
StraightTerminal
public StraightTerminal(Site attachSite, java.awt.Stroke stroke, java.awt.Paint paint)
Create a new terminal attached to the given site, with the given stroke and paint. If the attach site is not yet available, pass a NullSite.
-
-
Method Detail
-
getAttachSite
public Site getAttachSite()
Get the site to which the terminal is attached- Specified by:
getAttachSite
in interfaceTerminal
-
getBounds
public java.awt.geom.Rectangle2D getBounds()
Get the bounding box of this terminal.- Specified by:
getBounds
in interfaceFigure
- Overrides:
getBounds
in classAbstractFigure
- Returns:
- the bounding box of this figure.
-
getConnectSite
public Site getConnectSite()
Get the site to which a connector can attach- Specified by:
getConnectSite
in interfaceTerminal
-
getEnd
public ConnectorEnd getEnd()
Get the object drawn at the end of the terminal, if there is one.
-
getPaint
public java.awt.Paint getPaint()
Get the paint of this terminal.
-
getShape
public java.awt.Shape getShape()
Get the outline shape of this terminal.- Specified by:
getShape
in interfaceFigure
- Specified by:
getShape
in classAbstractFigure
- Returns:
- the outline shape of this figure
-
getStroke
public java.awt.Stroke getStroke()
Get the stroke of this terminal.
-
hit
public boolean hit(java.awt.geom.Rectangle2D r)
Test if this terminal is hit by the given rectangle.- Specified by:
hit
in interfaceFigure
- Overrides:
hit
in classAbstractFigure
- Parameters:
r
- The rectangle to be checked.- Returns:
- true if the figure is hit by the given rectangle.
-
paint
public void paint(java.awt.Graphics2D g)
Paint the terminal.- Specified by:
paint
in interfaceVisibleComponent
- Specified by:
paint
in classAbstractFigure
- Parameters:
g
- The 2D graphics object that this object it to be painted upon.
-
relocate
public void relocate()
Tell the terminal to reposition itself over the attachment site.
-
setAttachSite
public void setAttachSite(Site s)
Set the site to which the terminal is attached.- Specified by:
setAttachSite
in interfaceTerminal
-
setEnd
public void setEnd(ConnectorEnd e)
Set the object drawn at the end of the terminal.
-
setStroke
public void setStroke(java.awt.Stroke s)
Set the stroke of this terminal. Currently, this call has no effect on the terminal end shape, if it has one.
-
setPaint
public void setPaint(java.awt.Paint p)
Set the stroke paint pattern of this terminal. Currently, this call has no effect on the terminal end shape, if it has one.
-
transform
public void transform(java.awt.geom.AffineTransform at)
Transform the terminal. This is ignored, since the location and orientation of a terminal is determined solely by its attachment site and other parameters.- Specified by:
transform
in interfaceFigure
- Specified by:
transform
in classAbstractFigure
- Parameters:
at
- The transform to be used.
-
translate
public void translate(double x, double y)
Translate the terminal. This is implemented since it is the most efficient way for figures that contain terminals to translate themselves. However, this method does not call repaint(), on the assumption that the parent figure will do so anyway.- Specified by:
translate
in interfaceFigure
- Overrides:
translate
in classAbstractFigure
- Parameters:
x
- The x value to be moved.y
- The y value to be moved.
-
-