att.grappa
Class GrappaSupport

java.lang.Object
  extended by att.grappa.GrappaSupport
All Implemented Interfaces:
GrappaConstants

public abstract class GrappaSupport
extends java.lang.Object
implements GrappaConstants

A class providing some supports function for Grappa.

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

Field Summary
private static short ALNUM
           
private static short ALPHA
           
private static short CN
           
private static short[] ctype
           
private static short DG
           
private static short GRAPH
           
private static short HD
           
private static short LC
           
private static short LOWERTOUPPER
           
private static short OD
           
private static short ODIGIT
           
private static short PRINT
           
private static short PU
           
private static short SP
           
private static short UC
           
private static short UPPERTOLOWER
           
private static short WS
           
private static short XDIGIT
           
 
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
GrappaSupport()
           
 
Method Summary
(package private) static double[] arrayForTuple(java.lang.String tuple)
           
static GrappaBox boxFromCorners(double x1, double y1, double x2, double y2)
          Creates a GrappaBox from the coordinates of any two opposing corners.
static GrappaBox boxFromCorners(GrappaBox box, double x1, double y1, double x2, double y2)
          Creates a GrappaBox from the coordinates of any two opposing corners.
static java.lang.String canonize(java.lang.String input)
          Canonize string by converting to lower-case and removing all non-letter, non-digit characters.
static boolean centerPanel(java.awt.geom.Point2D cpt, GrappaPanel gpanel)
          Scroll to the viewport containing the specified GrappaPanel so that it is centered on the given point.
static boolean filterGraph(Graph graph, java.lang.Object connector)
          Filter the supplied graph using the given connector.
static boolean filterGraph(Graph graph, java.lang.Object connector, java.lang.String preamble)
          Filter the supplied graph using the given connector.
static java.util.Vector findContainedElements(Subgraph subg, GrappaBox box)
          Find the elements in the supplied subgraph that are contained in the given box.
static Element findContainingElement(Subgraph subg, java.awt.geom.Point2D pt)
          Find an element in the supplied subgraph that contains the given point.
(package private) static float[] floatArrayForTuple(java.lang.String tuple)
           
(package private) static boolean isalnum(int ch)
          for ASCII only
(package private) static boolean isalpha(int ch)
          for ASCII only
(package private) static boolean isascii(int ch)
          for ASCII only
(package private) static boolean iscntrl(int ch)
          for ASCII only
(package private) static boolean isdigit(int ch)
          for ASCII only
(package private) static boolean isgraph(int ch)
          for ASCII only
(package private) static boolean islower(int ch)
          for ASCII only
(package private) static boolean isoctal(int ch)
          for ASCII only
(package private) static boolean isprint(int ch)
          for ASCII only
(package private) static boolean ispunct(int ch)
          for ASCII only
(package private) static boolean isspace(int ch)
          for ASCII only
(package private) static boolean isupper(int ch)
          for ASCII only
(package private) static boolean isxdigit(int ch)
          for ASCII only
static void setHighlight(Element elem, int mode, int setting)
          Set the highlight on an element and, possibly, related elements.
(package private) static java.lang.String[] strsplit(java.lang.String tuple)
           
(package private) static int tolower(int ch)
          for ASCII only
(package private) static int toupper(int ch)
          for ASCII only
static java.lang.String xlateDir(int direction)
          Converts an integer edge direction value to a string representation.
static int xlateDirString(java.lang.String direction)
          Converts a string to an integer edge direction.
static java.lang.String xlateFontStyle(int fontstyle)
          Converts an integer font style value to a string representation.
static int xlateFontStyleString(java.lang.String fontstyle)
          Converts a string to an integer font style.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CN

private static final short CN
See Also:
Constant Field Values

WS

private static final short WS
See Also:
Constant Field Values

SP

private static final short SP
See Also:
Constant Field Values

PU

private static final short PU
See Also:
Constant Field Values

DG

private static final short DG
See Also:
Constant Field Values

OD

private static final short OD
See Also:
Constant Field Values

UC

private static final short UC
See Also:
Constant Field Values

HD

private static final short HD
See Also:
Constant Field Values

LC

private static final short LC
See Also:
Constant Field Values

ctype

private static final short[] ctype

ALPHA

private static final short ALPHA
See Also:
Constant Field Values

ALNUM

private static final short ALNUM
See Also:
Constant Field Values

GRAPH

private static final short GRAPH
See Also:
Constant Field Values

PRINT

private static final short PRINT
See Also:
Constant Field Values

ODIGIT

private static final short ODIGIT
See Also:
Constant Field Values

XDIGIT

private static final short XDIGIT
See Also:
Constant Field Values

LOWERTOUPPER

private static final short LOWERTOUPPER
See Also:
Constant Field Values

UPPERTOLOWER

private static final short UPPERTOLOWER
See Also:
Constant Field Values
Constructor Detail

GrappaSupport

public GrappaSupport()
Method Detail

isalnum

static boolean isalnum(int ch)
for ASCII only


isalpha

static boolean isalpha(int ch)
for ASCII only


isascii

static boolean isascii(int ch)
for ASCII only


iscntrl

static boolean iscntrl(int ch)
for ASCII only


isdigit

static boolean isdigit(int ch)
for ASCII only


isgraph

static boolean isgraph(int ch)
for ASCII only


islower

static boolean islower(int ch)
for ASCII only


isoctal

static boolean isoctal(int ch)
for ASCII only


isprint

static boolean isprint(int ch)
for ASCII only


ispunct

static boolean ispunct(int ch)
for ASCII only


isspace

static boolean isspace(int ch)
for ASCII only


isupper

static boolean isupper(int ch)
for ASCII only


isxdigit

static boolean isxdigit(int ch)
for ASCII only


tolower

static int tolower(int ch)
for ASCII only


toupper

static int toupper(int ch)
for ASCII only


strsplit

static java.lang.String[] strsplit(java.lang.String tuple)
                            throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

floatArrayForTuple

static float[] floatArrayForTuple(java.lang.String tuple)
                           throws java.lang.IllegalArgumentException,
                                  java.lang.NumberFormatException
Throws:
java.lang.IllegalArgumentException
java.lang.NumberFormatException

arrayForTuple

static double[] arrayForTuple(java.lang.String tuple)
                       throws java.lang.IllegalArgumentException,
                              java.lang.NumberFormatException
Throws:
java.lang.IllegalArgumentException
java.lang.NumberFormatException

xlateDirString

public static int xlateDirString(java.lang.String direction)
Converts a string to an integer edge direction. The string is first canonicalized (converted to lower case and non-alphanumerics are removed) then compared to none, back, forward or both. A match returns GrappaLine.NONE_ARROW_EDGE, GrappaLine.HEAD_ARROW_EDGE, GrappaLine.TAIL_ARROW_EDGE or GrappaLine.BOTH_ARROW_EDGE, respectively. When there is no match, GrappaLine.NONE_ARROW_EDGE is returned.

Parameters:
direction - a string representing an edge direction
Returns:
an integer representation of the supplied edge direction

xlateDir

public static java.lang.String xlateDir(int direction)
Converts an integer edge direction value to a string representation. Only GrappaLine.NONE_ARROW_EDGE, GrappaLine.HEAD_ARROW_EDGE, GrappaLine.TAIL_ARROW_EDGE and GrappaLine.BOTH_ARROW_EDGE are understood, all others are taken to mean GrappaLine.NONE_ARROW_EDGE.

Parameters:
direction - an integer representing an edge direction
Returns:
a string representation of the supplied edge direction

xlateFontStyleString

public static int xlateFontStyleString(java.lang.String fontstyle)
Converts a string to an integer font style. The string is first canonicalized (converted to lower case and non-alphanumerics are removed) then compared to italic, bold or bolditalic. A match returns Font.ITALIC, Font.BOLD, or a bitwise OR-ing of the two, respectively. When there is no match, Font.PLAIN is returned.

Parameters:
fontstyle - a string representing a font style
Returns:
an integer representation of the supplied font style string

xlateFontStyle

public static java.lang.String xlateFontStyle(int fontstyle)
Converts an integer font style value to a string representation. Only Font.ITALIC, Font.BOLD, and (Font.BOLD|Font.ITALIC) are understood, all others are taken to mean Font.PLAIN.

Parameters:
fontstyle - an integer representing a font style
Returns:
a string representation of the supplied font style value

canonize

public static java.lang.String canonize(java.lang.String input)
Canonize string by converting to lower-case and removing all non-letter, non-digit characters.

Parameters:
input - the string to be canonized
Returns:
the canonized string

boxFromCorners

public static GrappaBox boxFromCorners(double x1,
                                       double y1,
                                       double x2,
                                       double y2)
Creates a GrappaBox from the coordinates of any two opposing corners.

Parameters:
x1 - x-coordinate of corner number 1.
y1 - x-coordinate of corner number 1.
x2 - x-coordinate of corner number 2, which is opposite corner 1.
y2 - x-coordinate of corner number 2, which is opposite corner 1.
Returns:
a GrappaBox generated the possibly-reordered coordinates.

boxFromCorners

public static GrappaBox boxFromCorners(GrappaBox box,
                                       double x1,
                                       double y1,
                                       double x2,
                                       double y2)
Creates a GrappaBox from the coordinates of any two opposing corners.

Parameters:
box - if non-null, the coordinates of this box are changed and this box is returned, otherwise a new box is created.
x1 - x-coordinate of corner number 1.
y1 - x-coordinate of corner number 1.
x2 - x-coordinate of corner number 2, which is opposite corner 1.
y2 - x-coordinate of corner number 2, which is opposite corner 1.
Returns:
a GrappaBox generated the possibly-reordered coordinates.

findContainingElement

public static Element findContainingElement(Subgraph subg,
                                            java.awt.geom.Point2D pt)
Find an element in the supplied subgraph that contains the given point. The last element encoutered is returned from a search of first subgraphs, then edges, then nodes. The ordering within a set of elements (e.g., nodes) is indeterminate.

Parameters:
subg - the subgraph to be searched.
pt - the point of the search.
Returns:
an element containing the point, or null.

findContainedElements

public static java.util.Vector findContainedElements(Subgraph subg,
                                                     GrappaBox box)
Find the elements in the supplied subgraph that are contained in the given box.

Parameters:
subg - the subgraph to be searched.
pt - the container box.
Returns:
a vector whose components may be single elements or another vector of this same type with the property that all the elements in the vector (when eventually unravelled) are contained in the supplied box.

setHighlight

public static void setHighlight(Element elem,
                                int mode,
                                int setting)
Set the highlight on an element and, possibly, related elements. Since deletion can affect related elements (i.e., the edges connected to a node or the sub-elements of a subgraph), those elements are affected as well when highlighting.

Parameters:
elem - the element whose highlighting is to be adjusted.
mode - the highlight mode to apply or remove; a mode of zero indicates all highlighting is turned off regardless of the setting.
setting - one of HIGHLIGHT_ON, HIGHLIGHT_OFF or HIGHLIGHT_TOGGLE.

filterGraph

public static boolean filterGraph(Graph graph,
                                  java.lang.Object connector)
Filter the supplied graph using the given connector. The connector is either a java.lang.Process or a java.net.URLConnection. As such, it provides an output stream to which the graph can be written and an input stream from which the processed graph can be read back in (to replace the original graph). Such filtering is useful for processing the graph through a layout engine such as the dot program.

Unlike previous versions of Grappa, this version does not try to explicitly redraw the graph after filtering is completed.

Parameters:
graph - the graph to be processed and reset
connector - a Process or URLConnector that provides an input and output stream
Returns:
true if the filtering completed successfully, false otherwise.

filterGraph

public static boolean filterGraph(Graph graph,
                                  java.lang.Object connector,
                                  java.lang.String preamble)
Filter the supplied graph using the given connector. The connector is either a java.lang.Process or a java.net.URLConnection. As such, it provides an output stream to which the graph can be written and an input stream from which the processed graph can be read back in (to replace the original graph). Such filtering is useful for processing the graph through a layout engine such as the dot program. The existing graph is reset and its contents are replaced with the graph that is read in.

Unlike previous versions of Grappa, this version does not try to explicitly redraw the graph after filtering is completed.

Parameters:
graph - the graph to be processed and reset
connector - a Process or URLConnector that provides an input and output stream
preamble - if not null, a string sent to filter prior to graph
Returns:
true if the filtering completed successfully, false otherwise.

centerPanel

public static boolean centerPanel(java.awt.geom.Point2D cpt,
                                  GrappaPanel gpanel)
Scroll to the viewport containing the specified GrappaPanel so that it is centered on the given point. If the point is not contained in the subgraph being displayed in the GrappaPanel, no action is taken. If the getParent() method applied to the GrappaPanel argument does not return a JViewport, an error message is displayed.

Parameters:
cpt - the point to place at the center of the GrappaPanel viewport
gpanel - the GrappaPanel displaying the graph
Returns:
true for a valid request, false otherwise