y.view
Class Arrow

java.lang.Object
  |
  +--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 Arrow.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 Arrow.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 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 Arrow.DIAMOND.
static Arrow NONE
          An arrow that does not have a graphical representation.
static byte NONE_TYPE
          Arrow type constant that describes arrow Arrow.NONE.
static Arrow SHORT
          An arrow that is short and broad.
static byte SHORT_TYPE
          Arrow type constant that describes arrow 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 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 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 Arrow.WHITE_DIAMOND.
 
Method Summary
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 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.
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.
 Shape getShape()
          Returns the shape of this arrow.
 byte getType()
          Returns the type of this arrow.
 void paint(Graphics2D g, 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE

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


STANDARD

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


DELTA

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


WHITE_DELTA

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


DIAMOND

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


SHORT

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


WHITE_DIAMOND

public static 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 Arrow.NONE.

See Also:
Constant Field Values

STANDARD_TYPE

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

See Also:
Constant Field Values

DELTA_TYPE

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

See Also:
Constant Field Values

WHITE_DELTA_TYPE

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

See Also:
Constant Field Values

DIAMOND_TYPE

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

See Also:
Constant Field Values

WHITE_DIAMOND_TYPE

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

See Also:
Constant Field Values

SHORT_TYPE

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

See Also:
Constant Field Values
Method Detail

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.

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 Arrow.NONE_TYPE, Arrow.STANDARD_TYPE, Arrow.DELTA_TYPE, Arrow.WHITE_DELTA_TYPE, Arrow.DIAMOND_TYPE, Arrow.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 g,
                  AffineTransform t)
Paints an affine transform of this arrow.

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

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

2003