att.grappa
Class GrappaSupport
java.lang.Object
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, ; Copyright 1996 - 2010 by AT&T Corp.
- Author:
- John Mocenigo and Rich Drechsler, Research @ AT&T Labs
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, HASHMAP_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 |
Method Summary |
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.List |
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. |
static void |
setHighlight(Element elem,
int mode,
int setting)
Set the highlight on an element and, possibly, related elements. |
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 |
GrappaSupport
public GrappaSupport()
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.List 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 resetconnector
- 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 resetconnector
- a Process or URLConnector that provides an input and
output streampreamble
- 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 viewportgpanel
- the GrappaPanel displaying the graph
- Returns:
- true for a valid request, false otherwise
Grappa 1.2