Package diva.graph.toolbox
Class StateBubble
- java.lang.Object
-
- diva.canvas.AbstractFigure
-
- diva.graph.toolbox.StateBubble
-
- All Implemented Interfaces:
CanvasComponent
,Figure
,VisibleComponent
,UserObjectContainer
public class StateBubble extends AbstractFigure
A Figure that is customized for representing state bubbles.- Version:
- $Id$
- Author:
- John Reekie, Xiaojun Liu
-
-
Field Summary
Fields Modifier and Type Field Description static int
FINAL_STATE
The style of a finalstatestatic int
INITIAL_STATE
The style of an initial statestatic int
NORMAL_STATE
The style of a regular state
-
Constructor Summary
Constructors Constructor Description StateBubble(double x, double y, double width, double height)
Create a new figure at the given coordinates.StateBubble(double x, double y, double width, double height, java.awt.Paint fill)
Create a new figure at the given coordinates and with the given fill.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.geom.Rectangle2D
getBounds()
Get the bounding box of this figure.java.awt.Shape
getShape()
Get the shape of this figure.int
getStateType()
Get the state type.java.awt.Stroke
getStroke()
Get the stroke of this figure.java.awt.Paint
getStrokePaint()
Get the stroke paint pattern of this figure.boolean
hit(java.awt.geom.Rectangle2D r)
Test if this figure intersects the given rectangle.void
paint(java.awt.Graphics2D g)
Paint the figure.void
setFillPaint(java.awt.Paint p)
Set the fill paint pattern of this figure.void
setStateType(int type)
Set the type of the statevoid
setStroke(java.awt.BasicStroke s)
Set the stroke of this figure.void
setStrokePaint(java.awt.Paint p)
Set the stroke paint pattern of this figure.void
transform(java.awt.geom.AffineTransform at)
Transform the figure with the supplied transform.void
translate(double x, double y)
Translate the figure with by the given distance.-
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
-
-
-
-
Field Detail
-
NORMAL_STATE
public static final int NORMAL_STATE
The style of a regular state- See Also:
- Constant Field Values
-
INITIAL_STATE
public static final int INITIAL_STATE
The style of an initial state- See Also:
- Constant Field Values
-
FINAL_STATE
public static final int FINAL_STATE
The style of a finalstate- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StateBubble
public StateBubble(double x, double y, double width, double height)
Create a new figure at the given coordinates. The figure, by default, has a unit-width continuous black outline and no fill.
-
StateBubble
public StateBubble(double x, double y, double width, double height, java.awt.Paint fill)
Create a new figure at the given coordinates and with the given fill.
-
-
Method Detail
-
getBounds
public java.awt.geom.Rectangle2D getBounds()
Get the bounding box of this figure. This method overrides the inherited method to take account of the thickness of the stroke, if there is one.- Specified by:
getBounds
in interfaceFigure
- Overrides:
getBounds
in classAbstractFigure
- Returns:
- the bounding box of this figure.
-
getShape
public java.awt.Shape getShape()
Get the shape of this figure.- Specified by:
getShape
in interfaceFigure
- Specified by:
getShape
in classAbstractFigure
- Returns:
- the outline shape of this figure
-
getStateType
public int getStateType()
Get the state type. This will be one of NORMAL_STATE, INITIAL_STATE, or FINAL_STATE.
-
getStroke
public java.awt.Stroke getStroke()
Get the stroke of this figure.
-
getStrokePaint
public java.awt.Paint getStrokePaint()
Get the stroke paint pattern of this figure.
-
hit
public boolean hit(java.awt.geom.Rectangle2D r)
Test if this figure intersects the given rectangle. If there is a fill but no outline, then there is a hit if the shape is intersected. If there is an outline but no fill, then the area covered by the outline stroke is tested. If there is both a fill and a stroke, the region bounded by the outside edge of the stroke is tested. If there is neither a fill nor a stroke, then return false. If the figure is not visible, always return false.- 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 figure. The figure is redrawn with the current shape, fill, and outline.- Specified by:
paint
in interfaceVisibleComponent
- Specified by:
paint
in classAbstractFigure
- Parameters:
g
- The 2D graphics object that this object it to be painted upon.
-
setFillPaint
public void setFillPaint(java.awt.Paint p)
Set the fill paint pattern of this figure. The figure will be filled with this paint pattern. If no pattern is given, do not fill it.
-
setStroke
public void setStroke(java.awt.BasicStroke s)
Set the stroke of this figure.
-
setStateType
public void setStateType(int type)
Set the type of the state
-
setStrokePaint
public void setStrokePaint(java.awt.Paint p)
Set the stroke paint pattern of this figure.
-
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. As much as possible, this method attempts to preserve the type of the shape: if the shape of this figure is an of RectangularShape or Polyline, then the shape may be modified directly. Otherwise, a general transformation is used that loses the type of the shape, converting it into a GeneralPath.- 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 figure with by the given distance. As much as possible, this method attempts to preserve the type of the shape: if the shape of this figure is an of RectangularShape or Polyline, then the shape may be modified directly. Otherwise, a general transformation is used that loses the type of the shape, converting it into a GeneralPath.- Specified by:
translate
in interfaceFigure
- Overrides:
translate
in classAbstractFigure
- Parameters:
x
- The x value to be moved.y
- The y value to be moved.
-
-