diva.canvas.connector
Class Blob

java.lang.Object
  extended by diva.canvas.connector.Blob
All Implemented Interfaces:
ConnectorEnd

public class Blob
extends 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:
$Revision: 1.8 $
Author:
John Reekie (johnr@eecs.berkeley.edu)

Field Summary
static int BLOB_CIRCLE
          Specify a circle style
static int BLOB_DIAMOND
          Specify a diamond style
 Stroke stroke
          The stroke.
 
Constructor Summary
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(int style)
          Create a new blob at (0,0) in the given style.
 
Method Summary
 Rectangle2D getBounds()
          Get the bounding box of the shape used to draw this connector end.
 void getConnection(Point2D p)
          Get the connection point into the given point
 void getOrigin(Point2D p)
          Get the origin into the given point.
 double getSizeUnit()
          Get the size unit.
 int getStyle()
          Get the style.
 boolean isFilled()
          Test if the blob is filled or not.
 void paint(Graphics2D g)
          Paint the blob.
 void reshape()
          Recalculate the shape of the blob.
 void setFilled(boolean flag)
          Test the flag that sets whether to fill the blob.
 void setNormal(double angle)
          Set the normal of the blob.
 void setOrigin(double x, double y)
          Set the end-point of the blob.
 void setSizeUnit(double s)
          Set the size unit.
 void setStyle(int s)
          Set the style.
 void translate(double x, double y)
          Translate the origin by the given amount.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

stroke

public Stroke stroke
The stroke. This is needed to get the bounding box. As the default, we use a stroke width of 1.5 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.

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.

Method Detail

getBounds

public Rectangle2D getBounds()
Get the bounding box of the shape used to draw this connector end.

Specified by:
getBounds in interface ConnectorEnd

getConnection

public void getConnection(Point2D p)
Get the connection point into the given point

Specified by:
getConnection in interface ConnectorEnd

getOrigin

public void getOrigin(Point2D p)
Get the origin into the given point.

Specified by:
getOrigin in interface ConnectorEnd

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(Graphics2D g)
Paint the blob. This method assumes that the graphics context is already set up with the correct paint and stroke.

Specified by:
paint in interface ConnectorEnd

reshape

public void reshape()
Recalculate the shape of the blob.


setFilled

public void setFilled(boolean flag)
Test the flag that sets 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:
setNormal in interface ConnectorEnd

setOrigin

public void setOrigin(double x,
                      double y)
Set the end-point of the blob.

Specified by:
setOrigin in interface ConnectorEnd

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:
translate in interface ConnectorEnd


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.