y.view
Class Arrow

java.lang.Object
  extended by y.view.Arrow

public final class Arrow
extends Object

Defines a class for arrows, which are usually seen at the end of edges. There are several arrow types predefined.

It is also possible to create custom arrows which then can be used system-wide like predefined arrows. For this to work one has to register a new arrow via addCustomArrow(String name, Shape shape, Color fillColor). The given shape defines the shape of the arrow. The arrow head should be at shape coordinate (0,0) and the tail somewhere on (x,0), where x < 0. the arrow can now be retrieved via getCustomArrow(String name).

 

Field Summary
static byte CUSTOM_TYPE
          Arrow type constant that describes a custom arrow type.
static Arrow DELTA
          A unicolored arrow that has the shape of a triangle.
static byte DELTA_TYPE
          Arrow type constant that describes arrow DELTA.
static Arrow DIAMOND
          A unicolored arrow that has the shape of a diamond.
static byte DIAMOND_TYPE
          Arrow type constant that describes arrow DIAMOND.
static Arrow NONE
          An arrow that does not have a graphical representation.
static byte NONE_TYPE
          Arrow type constant that describes arrow NONE.
static Arrow SHORT
          An arrow that is short and broad.
static byte SHORT_TYPE
          Arrow type constant that describes arrow SHORT
static Arrow STANDARD
          A unicolored arrow that has the shape of a triangle with impressed bottom side.
static byte STANDARD_TYPE
          Arrow type constant that describes arrow STANDARD.
static Arrow WHITE_DELTA
          An arrow that has the shape of a triangle.
static byte WHITE_DELTA_TYPE
          Arrow type constant that describes arrow WHITE_DELTA.
static Arrow WHITE_DIAMOND
          An arrow that has the shape of a diamond.
static byte WHITE_DIAMOND_TYPE
          Arrow type constant that describes arrow WHITE_DIAMOND.
 
Method Summary
static Arrow addCustomArrow(String name, Arrow existingArrow, double clipLength)
          Creates, registers and returns a custom arrow that is created using a given arrow but the drawing of the arrow is offset from the corresponding end of the path using the given offset.
static Arrow addCustomArrow(String name, Drawable drawable)
          Adds a new custom arrow with the given name to the set of available custom arrows.
static Arrow addCustomArrow(String name, Drawable drawable, double arrowLength, double clipLength)
          Adds a new custom arrow with the given name to the set of available custom arrows.
static Arrow addCustomArrow(String name, Shape shape, Color fillColor)
          Adds a new custom arrow with the given name to the set of available custom arrows.
static Arrow addCustomArrow(String name, Shape shape, Color fillColor, Stroke lineStroke, Color lineColor)
          Adds a new custom arrow with the given name to the set of available custom arrows.
static Arrow addCustomArrow(String name, Shape shape, Color fillColor, Stroke lineStroke, Color lineColor, double arrowLength, double clipLength)
          Adds a new custom arrow with the given name to the set of available custom arrows.
static Vector availableArrows()
          Returns a vector of all available arrows, i.e. all built in types and all added custom types.
static Arrow getArrow(byte type)
          Returns the arrow described by the given arrow type specifier.
 double getArrowLength()
          Returns the "length" of this arrow.
 double getClipLength()
          Returns the length of the clip that should be applied to the edge's path before attaching the arrow.
static Arrow getCustomArrow(String name)
          Returns the custom arrow that was added under the given name.
 String getCustomName()
          If this arrow is a custom arrow it's custom name will be returned.
static double getDefaultClipLength()
          Returns the statically shared clipLength of all default arrows.
 Shape getShape()
          Returns the shape of this arrow.
 byte getType()
          Returns the type of this arrow.
 void paint(Graphics2D gfx, AffineTransform t)
          Paints an affine transform of this arrow.
 void paint(Graphics2D g, double x, double y, double dx, double dy)
          Paints the arrow at a specific position in a specific direction.
static void setDefaultClipLength(double defaultClipLength)
          Sets the statically shared clipLength for all default arrows.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE

public static final Arrow NONE
An arrow that does not have a graphical representation. To be used when no arrow should be displayed.


STANDARD

public static final Arrow STANDARD
A unicolored arrow that has the shape of a triangle with impressed bottom side.


DELTA

public static final Arrow DELTA
A unicolored arrow that has the shape of a triangle.


WHITE_DELTA

public static final Arrow WHITE_DELTA
An arrow that has the shape of a triangle. Its fill color is always white.


DIAMOND

public static final Arrow DIAMOND
A unicolored arrow that has the shape of a diamond.


SHORT

public static final Arrow SHORT
An arrow that is short and broad.


WHITE_DIAMOND

public static final Arrow WHITE_DIAMOND
An arrow that has the shape of a diamond. Its fill color is white.


CUSTOM_TYPE

public static final byte CUSTOM_TYPE
Arrow type constant that describes a custom arrow type.

See Also:
Constant Field Values

NONE_TYPE

public static final byte NONE_TYPE
Arrow type constant that describes arrow NONE.

See Also:
Constant Field Values

STANDARD_TYPE

public static final byte STANDARD_TYPE
Arrow type constant that describes arrow STANDARD.

See Also:
Constant Field Values

DELTA_TYPE

public static final byte DELTA_TYPE
Arrow type constant that describes arrow DELTA.

See Also:
Constant Field Values

WHITE_DELTA_TYPE

public static final byte WHITE_DELTA_TYPE
Arrow type constant that describes arrow WHITE_DELTA.

See Also:
Constant Field Values

DIAMOND_TYPE

public static final byte DIAMOND_TYPE
Arrow type constant that describes arrow DIAMOND.

See Also:
Constant Field Values

WHITE_DIAMOND_TYPE

public static final byte WHITE_DIAMOND_TYPE
Arrow type constant that describes arrow WHITE_DIAMOND.

See Also:
Constant Field Values

SHORT_TYPE

public static final byte SHORT_TYPE
Arrow type constant that describes arrow SHORT

See Also:
Constant Field Values
Method Detail

getDefaultClipLength

public static double getDefaultClipLength()
Returns the statically shared clipLength of all default arrows. The default is 0.0d.

Returns:
the length of the clip

setDefaultClipLength

public static void setDefaultClipLength(double defaultClipLength)
Sets the statically shared clipLength for all default arrows. The default is 0.0d.

Parameters:
defaultClipLength - the length of the clip

addCustomArrow

public static Arrow addCustomArrow(String name,
                                   Shape shape,
                                   Color fillColor)
Adds a new custom arrow with the given name to the set of available custom arrows. The arrow will receive the given shape and fillColor.

The arrow head should be at shape coordinate (0,0) and the tail somewhere on (x,0), where x < 0.

Returns:
The added arrow.

addCustomArrow

public static Arrow addCustomArrow(String name,
                                   Arrow existingArrow,
                                   double clipLength)
Creates, registers and returns a custom arrow that is created using a given arrow but the drawing of the arrow is offset from the corresponding end of the path using the given offset.

Parameters:
name - The name to identify the arrow.
existingArrow - the existing arrow to wrap
clipLength - the clipping length
Returns:
an Arrow instance

addCustomArrow

public static Arrow addCustomArrow(String name,
                                   Shape shape,
                                   Color fillColor,
                                   Stroke lineStroke,
                                   Color lineColor)
Adds a new custom arrow with the given name to the set of available custom arrows. The arrow will receive the given shape, fillColor, lineStroke and lineColor.

The arrow head should be at shape coordinate (0,0) and the tail somewhere on (x,0), where x < 0.

Returns:
The added arrow.

addCustomArrow

public static Arrow addCustomArrow(String name,
                                   Shape shape,
                                   Color fillColor,
                                   Stroke lineStroke,
                                   Color lineColor,
                                   double arrowLength,
                                   double clipLength)
Adds a new custom arrow with the given name to the set of available custom arrows. The arrow will receive the given shape, fillColor, lineStroke, lineColor, arrowLenght, and clipLength.

The arrow head should be at shape coordinate (0,0) and the tail somewhere on (x,0), where x < 0.

Returns:
The added arrow.

addCustomArrow

public static Arrow addCustomArrow(String name,
                                   Drawable drawable)
Adds a new custom arrow with the given name to the set of available custom arrows. The arrow will be renderered by the given Drawable implementation.

When drawing the arrow the head of the arrow shape should be rendered at coordinate (0,0) and the tail somewhere on (x,0), where x < 0.

Returns:
The added arrow.

addCustomArrow

public static Arrow addCustomArrow(String name,
                                   Drawable drawable,
                                   double arrowLength,
                                   double clipLength)
Adds a new custom arrow with the given name to the set of available custom arrows. The arrow will be renderered by the given Drawable implementation.

When drawing the arrow the head of the arrow shape should be rendered at coordinate (0,0) and the tail somewhere on (x,0), where x < 0.

Returns:
The added arrow.

getCustomArrow

public static Arrow getCustomArrow(String name)
Returns the custom arrow that was added under the given name.


availableArrows

public static Vector availableArrows()
Returns a vector of all available arrows, i.e. all built in types and all added custom types.


getArrow

public static Arrow getArrow(byte type)
Returns the arrow described by the given arrow type specifier.

Parameters:
type - one of NONE_TYPE, STANDARD_TYPE, DELTA_TYPE, WHITE_DELTA_TYPE, DIAMOND_TYPE, WHITE_DIAMOND_TYPE.

getType

public byte getType()
Returns the type of this arrow.


getCustomName

public String getCustomName()
If this arrow is a custom arrow it's custom name will be returned. Otherwise null will be returned.


getShape

public Shape getShape()
Returns the shape of this arrow.


paint

public void paint(Graphics2D g,
                  double x,
                  double y,
                  double dx,
                  double dy)
Paints the arrow at a specific position in a specific direction.


paint

public void paint(Graphics2D gfx,
                  AffineTransform t)
Paints an affine transform of this arrow.

Parameters:
t - The affine trasform being applied to the arrow before painting.

getArrowLength

public double getArrowLength()
Returns the "length" of this arrow. This value will be used, e.g. during the calculation of the path of an EdgeRealizer to clip the ends of the path by the given value, so that the drawing of the path does not corrupt the drawing of the Arrow.

Returns:
the length of the piece of the path that should be clipped to get a better drawing.

getClipLength

public double getClipLength()
Returns the length of the clip that should be applied to the edge's path before attaching the arrow. The default is 0.0d

Returns:
the length of the path that should be clipped before the arrow is painted

© Copyright 2000-2008,
yWorks GmbH.
All rights reserved.