Package diva.canvas.connector
Class Blob
- java.lang.Object
-
- diva.canvas.connector.Blob
-
- All Implemented Interfaces:
ConnectorEnd
public class Blob extends java.lang.Object implements ConnectorEnd
An object that draws a blob of some kind on the end of a connector. The blob can be one of several styles, such as circle or diamond, and can either be draw filled or not. This is a low-level utility class, not a self-contained Figure.- Version:
- $Id$
- Author:
- John Reekie
-
-
Field Summary
Fields Modifier and Type Field Description static intARROW_CIRCLE_HArrow, circle, H style.static intBLOB_CIRCLESpecify a circle stylestatic intBLOB_CIRCLE_DIAMONDSpecify a circle and a diamond stylestatic intBLOB_DIAMONDSpecify a diamond stylestatic intERRORError style.java.awt.StrokenarrowStrokeA narrow stroke.static intSTARSpecify a star stylejava.awt.StrokestrokeThe stroke.static intTRIANGLETriangle style.
-
Constructor Summary
Constructors Constructor Description Blob()Create a new circle blob at (0,0).Blob(double x, double y, double normal, int style)Create a new blob at the given coordinates and in the given style.Blob(double x, double y, double normal, int style, double size, java.awt.Paint fillColor)Create a new blob at the given coordinates and in the given style.Blob(int style)Create a new blob at (0,0) in the given style.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.geom.Rectangle2DgetBounds()Get the bounding box of the shape used to draw this connector end.voidgetConnection(java.awt.geom.Point2D p)Get the connection point into the given pointvoidgetOrigin(java.awt.geom.Point2D p)Get the origin into the given point.doublegetSizeUnit()Get the size unit.intgetStyle()Get the style.booleanisFilled()Test if the blob is filled or not.voidpaint(java.awt.Graphics2D g)Paint the blob.voidreshape()Recalculate the shape of the blob.voidsetFilled(boolean flag)Set the flag that determines whether to fill the blob.voidsetNormal(double angle)Set the normal of the blob.voidsetOrigin(double x, double y)Set the end-point of the blob.voidsetSizeUnit(double s)Set the size unit.voidsetStyle(int s)Set the style.voidtranslate(double x, double y)Translate the origin by the given amount.
-
-
-
Field Detail
-
BLOB_CIRCLE
public static final int BLOB_CIRCLE
Specify a circle style- See Also:
- Constant Field Values
-
BLOB_DIAMOND
public static final int BLOB_DIAMOND
Specify a diamond style- See Also:
- Constant Field Values
-
BLOB_CIRCLE_DIAMOND
public static final int BLOB_CIRCLE_DIAMOND
Specify a circle and a diamond style- See Also:
- Constant Field Values
-
STAR
public static final int STAR
Specify a star style- See Also:
- Constant Field Values
-
ARROW_CIRCLE_H
public static final int ARROW_CIRCLE_H
Arrow, circle, H style.- See Also:
- Constant Field Values
-
TRIANGLE
public static final int TRIANGLE
Triangle style.- See Also:
- Constant Field Values
-
ERROR
public static final int ERROR
Error style.- See Also:
- Constant Field Values
-
stroke
public java.awt.Stroke stroke
The stroke. This is needed to get the bounding box. As the default, we use a stroke width of 3.0 pixels, in order that redraw is clean even in the presence of anti-aliasing. Connectors that have non-unit stroke widths should set this variable to a stroke with appropriate width.
-
narrowStroke
public java.awt.Stroke narrowStroke
A narrow stroke.
-
-
Constructor Detail
-
Blob
public Blob()
Create a new circle blob at (0,0).
-
Blob
public Blob(int style)
Create a new blob at (0,0) in the given style.
-
Blob
public Blob(double x, double y, double normal, int style)Create a new blob at the given coordinates and in the given style.
-
Blob
public Blob(double x, double y, double normal, int style, double size, java.awt.Paint fillColor)Create a new blob at the given coordinates and in the given style.
-
-
Method Detail
-
getBounds
public java.awt.geom.Rectangle2D getBounds()
Get the bounding box of the shape used to draw this connector end.- Specified by:
getBoundsin interfaceConnectorEnd
-
getConnection
public void getConnection(java.awt.geom.Point2D p)
Get the connection point into the given point- Specified by:
getConnectionin interfaceConnectorEnd
-
getOrigin
public void getOrigin(java.awt.geom.Point2D p)
Get the origin into the given point.- Specified by:
getOriginin interfaceConnectorEnd
-
getSizeUnit
public double getSizeUnit()
Get the size unit.
-
getStyle
public int getStyle()
Get the style.
-
isFilled
public boolean isFilled()
Test if the blob is filled or not.
-
paint
public void paint(java.awt.Graphics2D g)
Paint the blob. This method assumes that the graphics context is already set up with the correct paint and stroke.- Specified by:
paintin interfaceConnectorEnd
-
reshape
public void reshape()
Recalculate the shape of the blob.
-
setFilled
public void setFilled(boolean flag)
Set the flag that determines whether to fill the blob.
-
setNormal
public void setNormal(double angle)
Set the normal of the blob. The argument is the angle in radians away from the origin.- Specified by:
setNormalin interfaceConnectorEnd
-
setOrigin
public void setOrigin(double x, double y)Set the end-point of the blob.- Specified by:
setOriginin interfaceConnectorEnd
-
setSizeUnit
public void setSizeUnit(double s)
Set the size unit. This unit is used differently depending on the style, but is generally half the width of the blob.
-
setStyle
public void setStyle(int s)
Set the style.
-
translate
public void translate(double x, double y)Translate the origin by the given amount.- Specified by:
translatein interfaceConnectorEnd
-
-