att.grappa
Class GrappaStyle

java.lang.Object
  extended by att.grappa.GrappaStyle
All Implemented Interfaces:
GrappaConstants, java.lang.Cloneable

public class GrappaStyle
extends java.lang.Object
implements GrappaConstants, java.lang.Cloneable

This class translates and encapsulates information provided by the style attribute.

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

Field Summary
(package private)  int cap
           
(package private)  float[] dash
           
(package private)  float dash_phase
           
static java.lang.String DEFAULT_SET_STRING
          A style attribute with this string value gets set to the default style for the associated element type.
(package private) static java.awt.BasicStroke defaultStroke
           
(package private) static java.lang.String defaultStrokeString
           
(package private)  boolean diagonals
           
private  int elementType
           
(package private)  boolean filled
           
(package private)  boolean fixed_size
           
(package private)  java.lang.Integer font_style
           
(package private)  boolean invis
           
(package private)  int join
           
(package private)  java.awt.Color line_color
           
(package private)  int line_style
           
(package private)  float line_width
           
(package private)  float miter_limit
           
(package private)  boolean rounded
           
(package private)  java.awt.BasicStroke stroke
           
private static java.util.Hashtable strokeCache
           
static int STYLE_CAP_BUTT
          Integer value for indicating butt cap info.
static int STYLE_CAP_DEFAULT
          Line cap default.
static int STYLE_CAP_ROUND
          Integer value for indicating round cap info.
static int STYLE_CAP_SQUARE
          Integer value for indicating square cap info.
static int STYLE_DASH
          Integer value for indicating specific dashed line info.
static float[] STYLE_DASH_DEFAULT
          Line dash default.
static int STYLE_DASH_PHASE
          Integer value for indicating dash phase info for a dashed line.
static float STYLE_DASH_PHASE_DEFAULT
          Line dash phase default.
static int STYLE_DASHED
          Integer value for indicating dashed line info.
static int STYLE_DIAGONALS
          Integer value for indicating diagonal corner info.
static boolean STYLE_DIAGONALS_DEFAULT
          Diagonal corner default.
static int STYLE_DOTTED
          Integer value for indicating dotted line info.
static int STYLE_FILLED
          Integer value for indicating fill info.
static boolean STYLE_FILLED_DEFAULT
          Fill default.
static int STYLE_FIXED_SIZE
          Integer value for indicating fixed size info.
static boolean STYLE_FIXED_SIZE_DEFAULT
          Fixed size default.
static int STYLE_INVIS
          Integer value for indicating fill info.
static boolean STYLE_INVIS_DEFAULT
          Invisibility default.
static int STYLE_JOIN_BEVEL
          Integer value for indicating bevel join info.
static int STYLE_JOIN_DEFAULT
          Line join default.
static int STYLE_JOIN_MITER
          Integer value for indicating miter join info.
static int STYLE_JOIN_ROUND
          Integer value for indicating round miter info.
static int STYLE_LINE_COLOR
          Integer value for indicating line color info.
static java.awt.Color STYLE_LINE_COLOR_DEFAULT
          Line color default.
static int STYLE_LINE_STYLE_DEFAULT
          Line style default.
static int STYLE_LINE_WIDTH
          Integer value for indicating line width info.
static float STYLE_LINE_WIDTH_DEFAULT
          Line width default.
static int STYLE_MITER_LIMIT
          Integer value for indicating miter limit info.
static float STYLE_MITER_LIMIT_DEFAULT
          Line miter default.
static int STYLE_OLD_BOLD
          Integer value for indicating bold font info (should use fontstyle)
static int STYLE_OLD_ITALIC
          Integer value for indicating italic font info (should use fontstyle)
static int STYLE_OLD_PLAIN
          Integer value for indicating plain font info (should use fontstyle)
static int STYLE_ROUNDED
          Integer value for indicating rounded corner info.
static boolean STYLE_ROUNDED_DEFAULT
          Rounded corner default.
static int STYLE_SOLID
          Integer value for indicating solid line info.
private static java.util.Hashtable styleTypes
           
 
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
GrappaStyle(int type, java.lang.String style)
          Constructs a new GrappaStyle object from a style description string.
 
Method Summary
 java.lang.Object clone()
          Creates a new object of the same class as this object.
private static java.lang.String generateStrokeString(float lineWidth, int capType, int joinType, float miterLimit, float[] dashSpec, float dashPhase)
           
private static java.lang.String generateStyleString(java.awt.Color color, int lineStyle, float lineWidth, int capType, int joinType, float miterLimit, float[] dashSpec, float dashPhase, boolean roundedFlag, boolean diagonalsFlag, boolean filledFlag, boolean invisFlag, boolean fixedSizeFlag, java.lang.Integer fontStyle, boolean showAll, int type)
           
 int getCapStyle()
          Get the cap style.
 float[] getDash()
          Get the dash specification.
 float getDashPhase()
          Get the dash phase.
 boolean getDiagonals()
          Get the diagonal corner specification.
 boolean getFilled()
          Get the fill specification.
 boolean getFixedSize()
          Get the fixed size specification.
 int getFontStyle()
          Get the font style.
 boolean getInvis()
          Get the invisibility specification.
 int getJoinStyle()
          Get the join style.
 java.awt.Color getLineColor()
          Get the line color.
 int getLineStyle()
          Get the line style.
 float getLineWidth()
          Get the line width.
 float getMiterLimit()
          Get the miter limit.
 boolean getRounded()
          Get the rounded corner specification.
 java.lang.String toAttributeString()
          Provides a string representation of this object consistent with Grappa attributes.
 java.lang.String toString()
          Provides a generic string representation of this object.
 void updateStyle(java.lang.String style)
          Update this GrappaStyle based on the supplied style string.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

elementType

private int elementType

DEFAULT_SET_STRING

public static final java.lang.String DEFAULT_SET_STRING
A style attribute with this string value gets set to the default style for the associated element type.

See Also:
Constant Field Values

STYLE_SOLID

public static final int STYLE_SOLID
Integer value for indicating solid line info.

See Also:
Constant Field Values

STYLE_DASHED

public static final int STYLE_DASHED
Integer value for indicating dashed line info.

See Also:
Constant Field Values

STYLE_DOTTED

public static final int STYLE_DOTTED
Integer value for indicating dotted line info.

See Also:
Constant Field Values

STYLE_DASH

public static final int STYLE_DASH
Integer value for indicating specific dashed line info.

See Also:
Constant Field Values

STYLE_DASH_PHASE

public static final int STYLE_DASH_PHASE
Integer value for indicating dash phase info for a dashed line.

See Also:
Constant Field Values

STYLE_LINE_WIDTH

public static final int STYLE_LINE_WIDTH
Integer value for indicating line width info.

See Also:
Constant Field Values

STYLE_LINE_COLOR

public static final int STYLE_LINE_COLOR
Integer value for indicating line color info.

See Also:
Constant Field Values

STYLE_FILLED

public static final int STYLE_FILLED
Integer value for indicating fill info.

See Also:
Constant Field Values

STYLE_DIAGONALS

public static final int STYLE_DIAGONALS
Integer value for indicating diagonal corner info.

See Also:
Constant Field Values

STYLE_ROUNDED

public static final int STYLE_ROUNDED
Integer value for indicating rounded corner info.

See Also:
Constant Field Values

STYLE_CAP_BUTT

public static final int STYLE_CAP_BUTT
Integer value for indicating butt cap info.

See Also:
Constant Field Values

STYLE_CAP_ROUND

public static final int STYLE_CAP_ROUND
Integer value for indicating round cap info.

See Also:
Constant Field Values

STYLE_CAP_SQUARE

public static final int STYLE_CAP_SQUARE
Integer value for indicating square cap info.

See Also:
Constant Field Values

STYLE_JOIN_BEVEL

public static final int STYLE_JOIN_BEVEL
Integer value for indicating bevel join info.

See Also:
Constant Field Values

STYLE_JOIN_MITER

public static final int STYLE_JOIN_MITER
Integer value for indicating miter join info.

See Also:
Constant Field Values

STYLE_JOIN_ROUND

public static final int STYLE_JOIN_ROUND
Integer value for indicating round miter info.

See Also:
Constant Field Values

STYLE_MITER_LIMIT

public static final int STYLE_MITER_LIMIT
Integer value for indicating miter limit info.

See Also:
Constant Field Values

STYLE_FIXED_SIZE

public static final int STYLE_FIXED_SIZE
Integer value for indicating fixed size info.

See Also:
Constant Field Values

STYLE_INVIS

public static final int STYLE_INVIS
Integer value for indicating fill info.

See Also:
Constant Field Values

STYLE_OLD_BOLD

public static final int STYLE_OLD_BOLD
Integer value for indicating bold font info (should use fontstyle)

See Also:
Constant Field Values

STYLE_OLD_ITALIC

public static final int STYLE_OLD_ITALIC
Integer value for indicating italic font info (should use fontstyle)

See Also:
Constant Field Values

STYLE_OLD_PLAIN

public static final int STYLE_OLD_PLAIN
Integer value for indicating plain font info (should use fontstyle)

See Also:
Constant Field Values

STYLE_LINE_COLOR_DEFAULT

public static final java.awt.Color STYLE_LINE_COLOR_DEFAULT
Line color default.


STYLE_LINE_STYLE_DEFAULT

public static final int STYLE_LINE_STYLE_DEFAULT
Line style default.

See Also:
Constant Field Values

STYLE_LINE_WIDTH_DEFAULT

public static final float STYLE_LINE_WIDTH_DEFAULT
Line width default.

See Also:
Constant Field Values

STYLE_CAP_DEFAULT

public static final int STYLE_CAP_DEFAULT
Line cap default.

See Also:
Constant Field Values

STYLE_JOIN_DEFAULT

public static final int STYLE_JOIN_DEFAULT
Line join default.

See Also:
Constant Field Values

STYLE_MITER_LIMIT_DEFAULT

public static final float STYLE_MITER_LIMIT_DEFAULT
Line miter default.

See Also:
Constant Field Values

STYLE_DASH_DEFAULT

public static final float[] STYLE_DASH_DEFAULT
Line dash default.


STYLE_DASH_PHASE_DEFAULT

public static final float STYLE_DASH_PHASE_DEFAULT
Line dash phase default.

See Also:
Constant Field Values

STYLE_ROUNDED_DEFAULT

public static final boolean STYLE_ROUNDED_DEFAULT
Rounded corner default.

See Also:
Constant Field Values

STYLE_DIAGONALS_DEFAULT

public static final boolean STYLE_DIAGONALS_DEFAULT
Diagonal corner default.

See Also:
Constant Field Values

STYLE_FILLED_DEFAULT

public static final boolean STYLE_FILLED_DEFAULT
Fill default.

See Also:
Constant Field Values

STYLE_INVIS_DEFAULT

public static final boolean STYLE_INVIS_DEFAULT
Invisibility default.

See Also:
Constant Field Values

STYLE_FIXED_SIZE_DEFAULT

public static final boolean STYLE_FIXED_SIZE_DEFAULT
Fixed size default.

See Also:
Constant Field Values

defaultStroke

static java.awt.BasicStroke defaultStroke

defaultStrokeString

static java.lang.String defaultStrokeString

styleTypes

private static java.util.Hashtable styleTypes

strokeCache

private static java.util.Hashtable strokeCache

line_color

java.awt.Color line_color

line_style

int line_style

line_width

float line_width

cap

int cap

join

int join

miter_limit

float miter_limit

dash

float[] dash

dash_phase

float dash_phase

rounded

boolean rounded

diagonals

boolean diagonals

filled

boolean filled

invis

boolean invis

fixed_size

boolean fixed_size

font_style

java.lang.Integer font_style

stroke

java.awt.BasicStroke stroke
Constructor Detail

GrappaStyle

public GrappaStyle(int type,
                   java.lang.String style)
Constructs a new GrappaStyle object from a style description string.

Parameters:
type - element type to associate with this style.
style - the String that specifies the style info. format is: style1,style2(extra2),...,styleN.
Method Detail

updateStyle

public void updateStyle(java.lang.String style)
Update this GrappaStyle based on the supplied style string.

Parameters:
style - a style specification

generateStrokeString

private static java.lang.String generateStrokeString(float lineWidth,
                                                     int capType,
                                                     int joinType,
                                                     float miterLimit,
                                                     float[] dashSpec,
                                                     float dashPhase)

toAttributeString

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

Returns:
attribute-suitable string representation of this GrappaStyle.

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 GrappaStyle.

generateStyleString

private static java.lang.String generateStyleString(java.awt.Color color,
                                                    int lineStyle,
                                                    float lineWidth,
                                                    int capType,
                                                    int joinType,
                                                    float miterLimit,
                                                    float[] dashSpec,
                                                    float dashPhase,
                                                    boolean roundedFlag,
                                                    boolean diagonalsFlag,
                                                    boolean filledFlag,
                                                    boolean invisFlag,
                                                    boolean fixedSizeFlag,
                                                    java.lang.Integer fontStyle,
                                                    boolean showAll,
                                                    int type)

getLineColor

public java.awt.Color getLineColor()
Get the line color.

Returns:
the line color.

getLineStyle

public int getLineStyle()
Get the line style.

Returns:
the line style.

getLineWidth

public float getLineWidth()
Get the line width.

Returns:
the line width.

getCapStyle

public int getCapStyle()
Get the cap style.

Returns:
the cap style.

getJoinStyle

public int getJoinStyle()
Get the join style.

Returns:
the join style.

getMiterLimit

public float getMiterLimit()
Get the miter limit.

Returns:
the miter limit.

getDash

public float[] getDash()
Get the dash specification.

Returns:
the dash specification.

getDashPhase

public float getDashPhase()
Get the dash phase.

Returns:
the dash phase.

getRounded

public boolean getRounded()
Get the rounded corner specification.

Returns:
the rounded corner specification color (true indicates rounded corners).

getDiagonals

public boolean getDiagonals()
Get the diagonal corner specification.

Returns:
the diagonal corner specification color (true indicates diagonal corners).

getFilled

public boolean getFilled()
Get the fill specification.

Returns:
the fill specification (true indicates filling should occur).

getInvis

public boolean getInvis()
Get the invisibility specification.

Returns:
the invisibility specification (true indicates element is invisible).

getFixedSize

public boolean getFixedSize()
Get the fixed size specification.

Returns:
the fixed size specification (true indicates that fixed size drawing is requested).

getFontStyle

public int getFontStyle()
Get the font style. Actually, the fontstyle attribute should be used for font style dealings rather than the style attribute, but the latter is permitted for backward compatibility with dot.

Returns:
the font style.

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