att.grappa
Class GrappaLine

java.lang.Object
  extended by att.grappa.GrappaLine
All Implemented Interfaces:
GrappaConstants, java.awt.Shape, java.lang.Cloneable

public class GrappaLine
extends java.lang.Object
implements GrappaConstants, java.lang.Cloneable, java.awt.Shape

This class provides line and bezier-curve support for Grappa.

Version:
1.2, 21 Aug 2005; Copyright 1996 - 2005 by AT&T Corp.
Author:
John Mocenigo, Research @ AT&T Labs

Field Summary
private  int arrow
           
static double arrowLength
          Arrow head length
static double arrowWidth
          Arrow head width
static int BOTH_ARROW_EDGE
          Bit flag to indicate that line has arrow heads at both ends.
private  GrappaPoint[] gpts
           
static int HEAD_ARROW_EDGE
          Bit flag to indicate that line has an arrow head at its head end.
static int NONE_ARROW_EDGE
          Bit flag to indicate that line has no arrow heads.
private  java.awt.geom.GeneralPath path
           
static int TAIL_ARROW_EDGE
          Bit flag to indicate that line has an arrow head at its tail end.
private  java.awt.geom.GeneralPath testpath
           
private  int windingRule
           
 
Fields inherited from interface att.grappa.GrappaConstants
_NO_TYPE, ANONYMOUS_PREFIX, BBOX_ATTR, BBOX_HASH, BOX_SHAPE, BOX_TYPE, CLUSTERRANK_ATTR, COLOR_ATTR, COLOR_HASH, COLOR_TYPE, CUSTOM_ATTR, CUSTOM_HASH, CUSTOM_SHAPE, DELETION_MASK, DIAMOND_SHAPE, DIR_ATTR, DIR_HASH, DIR_TYPE, DISTORTION_ATTR, DISTORTION_HASH, DOUBLE_TYPE, DOUBLECIRCLE_SHAPE, DOUBLEOCTAGON_SHAPE, EDGE, EGG_SHAPE, FILLCOLOR_ATTR, FILLCOLOR_HASH, FONTCOLOR_ATTR, FONTCOLOR_HASH, FONTNAME_ATTR, FONTNAME_HASH, FONTSIZE_ATTR, FONTSIZE_HASH, FONTSTYLE_ATTR, FONTSTYLE_HASH, FONTSTYLE_TYPE, GRAPPA_BACKGROUND_COLOR_ATTR, GRAPPA_BACKGROUND_COLOR_HASH, GRAPPA_DELETION_STYLE_ATTR, GRAPPA_DELETION_STYLE_HASH, GRAPPA_FONTSIZE_ADJUSTMENT_ATTR, GRAPPA_FONTSIZE_ADJUSTMENT_HASH, GRAPPA_SELECTION_STYLE_ATTR, GRAPPA_SELECTION_STYLE_HASH, GRAPPA_SHAPE, HASHLIST_TYPE, HEADLABEL_ATTR, HEADLABEL_HASH, HEADLP_ATTR, HEADLP_HASH, HEIGHT_ATTR, HEIGHT_HASH, HEXAGON_SHAPE, HIGHLIGHT_MASK, HIGHLIGHT_OFF, HIGHLIGHT_ON, HIGHLIGHT_TOGGLE, HOUSE_SHAPE, IDENTXFRM, IMAGE_ATTR, IMAGE_HASH, INTEGER_TYPE, INVERTEDHOUSE_SHAPE, INVERTEDTRAPEZIUM_SHAPE, INVERTEDTRIANGLE_SHAPE, LABEL_ATTR, LABEL_HASH, LINE_SHAPE, LINE_TYPE, LOG10, LP_ATTR, LP_HASH, MARGIN_ATTR, MARGIN_HASH, MCIRCLE_SHAPE, MCLIMIT_ATTR, MCLIMIT_HASH, MDIAMOND_SHAPE, MINBOX_ATTR, MINBOX_HASH, MINLEN_ATTR, MINLEN_HASH, MINSIZE_ATTR, MINSIZE_HASH, MRECORD_SHAPE, MSQUARE_SHAPE, NBSP, NEW_LINE, NO_SHAPE, NODE, NODESEP_ATTR, NODESEP_HASH, OCTAGON_SHAPE, ORIENTATION_ATTR, ORIENTATION_HASH, OVAL_SHAPE, PACKAGE_PREFIX, PARALLELOGRAM_SHAPE, PATCH_ATTR, PATCH_HASH, PENTAGON_SHAPE, PERIPHERIES_ATTR, PERIPHERIES_HASH, PERIPHERY_GAP, PKG_LOWER, PKG_UPLOW, PKG_UPPER, PLAINTEXT_SHAPE, POINT_SHAPE, POINT_TYPE, PointsPerInch, POLYGON_SHAPE, POS_ATTR, POS_HASH, PRINTLIST_ATTR, PRINTLIST_HASH, RANKDIR_ATTR, RANKDIR_HASH, RANKSEP_ATTR, RANKSEP_HASH, RECORD_SHAPE, RECTS_ATTR, RECTS_HASH, ROTATION_ATTR, ROTATION_HASH, ROUNDEDBOX_SHAPE, SELECTION_MASK, SHAPE_ATTR, SHAPE_HASH, SHAPE_MASK, SHAPE_TYPE, SIDES_ATTR, SIDES_HASH, SIZE_ATTR, SIZE_HASH, SIZE_TYPE, SKEW_ATTR, SKEW_HASH, STRING_TYPE, STYLE_ATTR, STYLE_HASH, STYLE_TYPE, SUBGRAPH, SYSTEM, TAG_ATTR, TAG_HASH, TAILLABEL_ATTR, TAILLABEL_HASH, TAILLP_ATTR, TAILLP_HASH, TIP_ATTR, TIP_HASH, TRAPEZIUM_SHAPE, TRIANGLE_SHAPE, TRIPLEOCTAGON_SHAPE, TYPES_SHIFT, WEIGHT_ATTR, WEIGHT_HASH, WIDTH_ATTR, WIDTH_HASH
 
Constructor Summary
GrappaLine(GrappaPoint[] pts, int type)
          Constructs a new GrappaLine object from an array of (cubic) curve points.
GrappaLine(java.lang.String curve)
          Constructs a new GrappaLine object from a string of (cubic) curve points as used by "dot".
 
Method Summary
private  void addArrow(java.awt.geom.GeneralPath path, java.awt.geom.GeneralPath testpath, GrappaPoint tip, GrappaPoint shaft, double length, double width)
           
 boolean changeArrowType(int new_type)
          Changes the arrow type for this line.
 java.lang.Object clone()
          Creates a new object of the same class as this object.
 boolean contains(double x, double y)
           
 boolean contains(double x, double y, double width, double height)
           
 boolean contains(java.awt.geom.Point2D p)
           
 boolean contains(java.awt.geom.Rectangle2D r)
           
 boolean equals(java.lang.Object obj)
          Check for equality of this object with the supplied object.
 int getArrowType()
          Return the arrow type for this line.
 java.awt.Rectangle getBounds()
           
 java.awt.geom.Rectangle2D getBounds2D()
           
 java.awt.geom.PathIterator getPathIterator()
          Equivalent to getPathIterator(null).
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
           
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at, double flatness)
           
 int getWindingRule()
          Return the winding rule for this line.
 boolean intersects(double x, double y, double width, double height)
           
 boolean intersects(java.awt.geom.Rectangle2D r)
           
 boolean startsNear(java.awt.geom.Point2D pt)
          Check is the line is oriented away from the given point.
 java.lang.String toAttributeString()
          Provides a string representation of this object consistent with Grappa attributes.
 java.lang.String toFormattedString(java.lang.String pointFormat)
          Provides a formatted string representation of this object.
 java.lang.String toString()
          Provides a generic string representation of this object.
private  void updateLine(GrappaPoint[] grpts, int type)
           
private  void updateLine(java.lang.String curve)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

arrowLength

public static final double arrowLength
Arrow head length

See Also:
Constant Field Values

arrowWidth

public static final double arrowWidth
Arrow head width

See Also:
Constant Field Values

NONE_ARROW_EDGE

public static final int NONE_ARROW_EDGE
Bit flag to indicate that line has no arrow heads.

See Also:
Constant Field Values

HEAD_ARROW_EDGE

public static final int HEAD_ARROW_EDGE
Bit flag to indicate that line has an arrow head at its head end.

See Also:
Constant Field Values

TAIL_ARROW_EDGE

public static final int TAIL_ARROW_EDGE
Bit flag to indicate that line has an arrow head at its tail end.

See Also:
Constant Field Values

BOTH_ARROW_EDGE

public static final int BOTH_ARROW_EDGE
Bit flag to indicate that line has arrow heads at both ends. Note that NONE_ARROW_EDGE + HEAD_ARROW_EDGE + TAIL_ARROW_EDGE = BOTH_ARROW_EDGE

See Also:
Constant Field Values

path

private java.awt.geom.GeneralPath path

testpath

private java.awt.geom.GeneralPath testpath

arrow

private int arrow

gpts

private GrappaPoint[] gpts

windingRule

private int windingRule
Constructor Detail

GrappaLine

public GrappaLine(GrappaPoint[] pts,
                  int type)
Constructs a new GrappaLine object from an array of (cubic) curve points. The winding rule for this path is defaulted (from Grappa.windingRule).

Parameters:
pts - the GrappaPoint array used to describe the curve
type - indicates arrow type (NONE_ARROW_EDGE,HEAD_ARROW_EDGE, TAIL_ARROW_EDGE,BOTH_ARROW_EDGE)

GrappaLine

public GrappaLine(java.lang.String curve)
Constructs a new GrappaLine object from a string of (cubic) curve points as used by "dot". All of the initial geometry and the winding rule for this path are defaulted.

Parameters:
curve - the String that specifies the point list; the format is: [s,x0,y0|e,xN,yN] [x1,y2] ... [xN-1,yN-1]
Method Detail

equals

public boolean equals(java.lang.Object obj)
Check for equality of this object with the supplied object.

Overrides:
equals in class java.lang.Object
Parameters:
the - object to be checked for equality
Returns:
true, when equal

getArrowType

public int getArrowType()
Return the arrow type for this line.

Returns:
one of NONE_ARROW_EDGE,HEAD_ARROW_EDGE, TAIL_ARROW_EDGE, or BOTH_ARROW_EDGE

getWindingRule

public int getWindingRule()
Return the winding rule for this line.

Returns:
one of WIND_NON_ZERO or WIND_EVEN_ODD

startsNear

public boolean startsNear(java.awt.geom.Point2D pt)
Check is the line is oriented away from the given point.

Returns:
true if the line is oriented so that its starting point is nearer to the supplied point than its ending point.

toAttributeString

public java.lang.String toAttributeString()
Provides a string representation of this object consistent with Grappa attributes.

Returns:
attribute-suitable string representation of this GrappaLine.

toFormattedString

public java.lang.String toFormattedString(java.lang.String pointFormat)
Provides a formatted string representation of this object.

Parameters:
pointFormat - the specific format directive to use for each point in the line (%p is the base directive).
Returns:
a string representation of this GrappaLine.

toString

public java.lang.String toString()
Provides a generic string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
a generic string representation of this GrappaLine.

changeArrowType

public boolean changeArrowType(int new_type)
Changes the arrow type for this line.

Parameters:
new_type - indicates arrow type (NONE_ARROW_EDGE,HEAD_ARROW_EDGE, TAIL_ARROW_EDGE,BOTH_ARROW_EDGE)
Returns:
true if the type changed, false otherwise.

addArrow

private void addArrow(java.awt.geom.GeneralPath path,
                      java.awt.geom.GeneralPath testpath,
                      GrappaPoint tip,
                      GrappaPoint shaft,
                      double length,
                      double width)

updateLine

private void updateLine(java.lang.String curve)

updateLine

private void updateLine(GrappaPoint[] grpts,
                        int type)

clone

public java.lang.Object clone()
Creates a new object of the same class as this object.

Overrides:
clone in class java.lang.Object
Returns:
a clone of this instance.
Throws:
java.lang.OutOfMemoryError - if there is not enough memory.
See Also:
Cloneable

contains

public final boolean contains(double x,
                              double y)
Specified by:
contains in interface java.awt.Shape

contains

public final boolean contains(double x,
                              double y,
                              double width,
                              double height)
Specified by:
contains in interface java.awt.Shape

contains

public final boolean contains(java.awt.geom.Point2D p)
Specified by:
contains in interface java.awt.Shape

contains

public final boolean contains(java.awt.geom.Rectangle2D r)
Specified by:
contains in interface java.awt.Shape

getBounds

public final java.awt.Rectangle getBounds()
Specified by:
getBounds in interface java.awt.Shape

getBounds2D

public final java.awt.geom.Rectangle2D getBounds2D()
Specified by:
getBounds2D in interface java.awt.Shape

getPathIterator

public final java.awt.geom.PathIterator getPathIterator()
Equivalent to getPathIterator(null).

See Also:
getPathIterator(AffineTransform)

getPathIterator

public final java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
Specified by:
getPathIterator in interface java.awt.Shape

getPathIterator

public final java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at,
                                                        double flatness)
Specified by:
getPathIterator in interface java.awt.Shape

intersects

public final boolean intersects(double x,
                                double y,
                                double width,
                                double height)
Specified by:
intersects in interface java.awt.Shape

intersects

public final boolean intersects(java.awt.geom.Rectangle2D r)
Specified by:
intersects in interface java.awt.Shape