att.grappa
Class Subgraph

java.lang.Object
  extended by att.grappa.Element
      extended by att.grappa.Subgraph
All Implemented Interfaces:
GrappaConstants, java.util.Comparator
Direct Known Subclasses:
Graph

public class Subgraph
extends Element
implements java.util.Comparator

This class describes a subgraph, which can consist of nodes, edges and other subgraphs. Note: The topmost or root subgraph is the entire graph (the Graph object), which is an extension of this class.

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

Nested Class Summary
(package private)  class Subgraph.Enumerator
           
 
Field Summary
private  boolean cluster
           
 java.lang.Object currentSelection
          Reference to the current selection (or vector of selections).
static java.lang.String defaultNamePrefix
          Default graph name prefix used by setName().
private  java.util.Hashtable edgeAttributes
           
private  java.util.Hashtable edgedict
           
private  boolean edgeLabels
           
private  Element[] elPatches
           
private  java.util.Hashtable graphdict
           
private  java.util.Hashtable nodeAttributes
           
private  java.util.Hashtable nodedict
           
private  boolean nodeLabels
           
private  GrappaBox patch
           
private  double PATCHEDGE
           
private  double PATCHEDGE2
           
private  Element[] sgPatches
           
private  boolean subgLabels
           
 
Fields inherited from class att.grappa.Element
attributes, attrsOfInterest, canonName, counter, grappaNexus, highlight, linewidth, name, object, printAllAttributes, printDefaultAttributes, selectable, usePrintList, visastamp, visible
 
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
Subgraph()
          This constructor is needed by the Graph constructor
Subgraph(Subgraph subg)
          Use this constructor when creating a subgraph within a subgraph with an automatically generated name.
Subgraph(Subgraph subg, java.lang.String name)
          Use this constructor when creating a subgraph within a subgraph.
 
Method Summary
 void addEdge(Edge newEdge)
          Adds the specified edge to the subgraph's Edge dictionary.
 void addNode(Node newNode)
          Adds the specified node to the subgraph's Node dictionary.
 void addSubgraph(Subgraph newGraph)
          Adds the specified subgraph to the subgraph's graph dictionary.
 void addTypeTag(int type, java.lang.String tag)
          Adds a default tag for the specified element type within this subgraph.
(package private)  double aspect(java.awt.geom.Rectangle2D.Double r)
           
static int attributeType(java.lang.String attrname)
          Returns the attribute conversion type for the supplied attribute name.
 void clearPatchWork()
           
private  void combPatchWork()
           
 int compare(java.lang.Object o1, java.lang.Object o2)
           
private  void compSqPatchWork(java.awt.geom.Rectangle2D.Double r, boolean top)
           
private  void compStdPatchWork(java.awt.geom.Rectangle2D.Double r, boolean top)
           
 void computePatchWork(java.awt.geom.Rectangle2D.Double r, boolean square)
           
 int countOfElements(int types)
          Get a count of elements in this subgraph and, by recursion, descendant subgraphs.
 int countOfLocalElements(int types)
          Get a count of elements in this subgraph.
 Element createElement(int type, java.lang.Object[] info, Attribute[] attrs)
          Creates a new element and adds it to the subgraph's element dictionary.
 java.util.Enumeration edgeElements()
          Get an enumeration of the edge elements in this subgraph.
 GraphEnumeration elements()
          Get an enumeration of all elements in this subgraph and any subgraphs under this one.
 GraphEnumeration elements(int types)
          Get an enumeration of elements in this subgraph and any subgraphs under this one.
 boolean equals(java.lang.Object obj)
           
 Edge findEdgeByName(java.lang.String edgeName)
          Searches current subgraph and, by recursion, descendent subgraphs for the edge matching the supplied name.
private  Element findElementByName(int type, java.lang.String name)
           
private  Element findElementInSubgraphByName(int type, java.lang.String name)
           
 Node findNodeByName(java.lang.String nodeName)
          Searches current subgraph and, by recursion, descendent subgraphs for the node matching the supplied name.
 Subgraph findSubgraphByName(java.lang.String graphName)
          Searches current subgraph and, by recursion, descendent subgraphs for the subgraph matching the supplied name.
 java.awt.geom.Rectangle2D getBoundingBox()
          Get the bounding box of the subgraph.
 Attribute getEdgeAttribute(java.lang.String key)
          Gets the subgraph-specific default attribute for the named edge attribute.
 java.util.Enumeration getEdgeAttributeKeys()
          Gets an enumeration of the subgraph-specific edge attribute keys
 java.util.Enumeration getEdgeAttributePairs()
          Gets an enumeration of the subgraph-specific edge attributes
 java.lang.Object getEdgeAttributeValue(java.lang.String key)
          Gets the subgraph-specific default value for the named edge attribute.
 Attribute getNodeAttribute(java.lang.String key)
          Gets the subgraph-specific default attribute for the named node attribute.
 java.util.Enumeration getNodeAttributeKeys()
          Gets an enumeration of the subgraph-specific node attribute keys
 java.util.Enumeration getNodeAttributePairs()
          Gets an enumeration of the subgraph-specific node attributes
 java.lang.Object getNodeAttributeValue(java.lang.String key)
          Gets the subgraph-specific default value for the named node attribute.
private  Attribute getParentDefault(int type, java.lang.String key)
           
(package private)  Element[] getPatches()
           
 boolean getShowEdgeLabels()
          Get flag that indicates if edge labels should be rendered
 boolean getShowNodeLabels()
          Get flag that indicates if node labels should be rendered
 boolean getShowSubgraphLabels()
          Get flag that indicates if subgraph labels should be rendered
 int getType()
          Get the type of this element.
 boolean hasEmptySubgraphs()
           
 boolean hasTypeTag(int type, java.lang.String tag)
          Check if the specified element type has the supplied default tag within this subgraph.
 boolean hasTypeTags(int type)
          Check if this element type has any default tags at all.
 boolean isCluster()
          Check if the subgraph is a cluster subgraph.
 boolean isLR()
          Check if the orientation of this subgraph is LR (left-to-right) as opposed to TB (top-to-bottom).
 boolean isRoot()
          Check if the subgraph is the root of the graph.
 boolean isSubgraph()
          Check if this element is a subgraph.
 java.util.Enumeration nodeElements()
          Get an enumeration of the node elements in this subgraph.
 void patchWork(java.awt.geom.Rectangle2D.Double r, boolean square, int mode)
           
 double preparePatchWork(int mode)
           
private  double prepPatchWork(java.lang.String attrname, int mode)
           
private  void printDflt(java.io.PrintWriter out, int type)
           
private  void printDfltAttr(java.io.PrintWriter out, java.util.Hashtable dfltAttr, int type, java.lang.String prefix, java.lang.String suffix)
           
 void printSubgraph(java.io.PrintWriter out)
          Prints an ascii description of each graph element to the supplied stream.
(package private)  void recurseVectorOfElements(int types, java.util.Vector retVec, int count)
           
 Edge removeEdge(java.lang.String edgeName)
          Removes the edge matching the specified name from the subgraph's Edge dictionary.
private  void removeEdgeAttribute(java.lang.String name)
           
 void removeEmptySubgraphs()
          Delete this subgraph or any contained subgraph, at any depth, if the subgraph contains no elements.
 Node removeNode(java.lang.String nodeName)
          Removes the node matching the specified name from the subgraph's Node dictionary.
private  void removeNodeAttribute(java.lang.String name)
           
 Subgraph removeSubgraph(java.lang.String graphName)
          Removes the subgraph matching the specified name from the subgraph's graph dictionary.
 void removeTypeTag(int type, java.lang.String tag)
          Removes the specified tag from this element.
 void removeTypeTags(int type)
          Removes any and all default tags associated with this element type.
 java.awt.geom.Rectangle2D resetBoundingBox()
          Removes bounding box information from this subgraph and any contained subgraphs including the BBOX_ATTR value and then recomputes the bounding boxes.
(package private)  double score(double wd, double ht)
           
 java.lang.Object setAttribute(Attribute attr)
          Sets the subgraph-specific default for the specified graph attribute.
 java.lang.Object setAttribute(java.lang.String name, java.lang.Object value)
          Sets the subgraph-specific default using the specified name/value pair.
 java.lang.Object setEdgeAttribute(Attribute attr)
          Sets the subgraph-specific default for the specified edge attribute.
 java.lang.Object setEdgeAttribute(java.lang.String name, java.lang.Object value)
          Sets the subgraph-specific default using the specified name/value pair.
(package private)  void setName()
          Generates and sets the name for this subgraph.
 void setName(java.lang.String newName)
          Sets the subgraph name to a copy of the supplied argument.
 java.lang.Object setNodeAttribute(Attribute attr)
          Sets the subgraph-specific default for the specified node attribute.
 java.lang.Object setNodeAttribute(java.lang.String name, java.lang.Object value)
          Sets the subgraph-specific default using the specified name/value pair.
 boolean setShowEdgeLabels(boolean value)
          Set flag to indicate if edge labels should be rendered
 boolean setShowNodeLabels(boolean value)
          Set flag to indicate if node labels should be rendered
 boolean setShowSubgraphLabels(boolean value)
          Set flag to indicate if subgraph labels should be rendered
private  void subgraphAttrsOfInterest()
           
 java.util.Enumeration subgraphElements()
          Get an enumeration of the subgraph elements in this subgraph.
 java.util.Vector vectorOfElements(int types)
          Get a vector of elements in this subgraph and, by recursion, descendant subgraphs.
 
Methods inherited from class att.grappa.Element
addTag, attrNotOfInterest, attrOfInterest, bdfs, buildShape, canonString, canonValue, clearBBox, delete, deleteCalled, getAttribute, getAttributePairs, getAttributeValue, getDefaultAttribute, getDefaultAttribute, getGraph, getGrappaNexus, getId, getIdKey, getLocalAttribute, getLocalAttributeKeys, getLocalAttributePairs, getName, getPatch, getPatchSize, getSubgraph, getThisAttribute, getThisAttributeValue, hasAttributeForKey, hasDefaultTag, hasDefaultTags, hasLocalTag, hasLocalTags, hasTag, hasTags, isEdge, isNode, isOfInterest, listAttrsOfInterest, printElement, release, removeTag, removeTags, reserve, setDefaultAttribute, setDefaultAttribute, setDefaultAttribute, setDefaultAttribute, setDelete, setGraph, setIdKey, setPatch, setPatch, setPatchSize, setSubgraph, setUserAttributeType, toString, typeString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultNamePrefix

public static final java.lang.String defaultNamePrefix
Default graph name prefix used by setName().

See Also:
setName(), Constant Field Values

nodedict

private java.util.Hashtable nodedict

edgedict

private java.util.Hashtable edgedict

graphdict

private java.util.Hashtable graphdict

nodeLabels

private boolean nodeLabels

edgeLabels

private boolean edgeLabels

subgLabels

private boolean subgLabels

nodeAttributes

private java.util.Hashtable nodeAttributes

edgeAttributes

private java.util.Hashtable edgeAttributes

cluster

private boolean cluster

currentSelection

public java.lang.Object currentSelection
Reference to the current selection (or vector of selections). Normally set and used by a GrappaAdapter.


PATCHEDGE

private double PATCHEDGE

PATCHEDGE2

private double PATCHEDGE2

sgPatches

private Element[] sgPatches

elPatches

private Element[] elPatches

patch

private GrappaBox patch
Constructor Detail

Subgraph

Subgraph()
This constructor is needed by the Graph constructor


Subgraph

public Subgraph(Subgraph subg,
                java.lang.String name)
Use this constructor when creating a subgraph within a subgraph.

Parameters:
subg - the parent subgraph.
name - the name of this subgraph.

Subgraph

public Subgraph(Subgraph subg)
Use this constructor when creating a subgraph within a subgraph with an automatically generated name.

Parameters:
subg - the parent subgraph.
See Also:
setName()
Method Detail

subgraphAttrsOfInterest

private void subgraphAttrsOfInterest()

isSubgraph

public boolean isSubgraph()
Check if this element is a subgraph. Useful for testing the subclass type of a Element object.

Overrides:
isSubgraph in class Element
Returns:
true if this object is a Subgraph.
See Also:
isSubgraph()

getType

public int getType()
Get the type of this element. Useful for distinguishing Element objects.

Specified by:
getType in class Element
Returns:
the class variable constant SUBGRAPH.
See Also:
GrappaConstants.SUBGRAPH

setName

void setName()
Generates and sets the name for this subgraph. The generated name is the concatenation of the Subgraph.defaultNamePrefix with the numeric id of this subgraph Instance. Implements the abstract Element method.

Specified by:
setName in class Element
See Also:
Element.getId()

setName

public void setName(java.lang.String newName)
             throws java.lang.IllegalArgumentException
Sets the subgraph name to a copy of the supplied argument. When the argument is null, setName() is called. When the name is not unique or when the name has the same format as that generated by setName(), a IllegalArgumentException is thrown.

Parameters:
newName - the new name for the subgraph.
Throws:
java.lang.IllegalArgumentException
See Also:
setName()

isCluster

public boolean isCluster()
Check if the subgraph is a cluster subgraph.

Returns:
true, if the graph is a cluster subgraph.

isRoot

public boolean isRoot()
Check if the subgraph is the root of the graph.

Returns:
true, if the graph is the root of the graph.

getNodeAttribute

public Attribute getNodeAttribute(java.lang.String key)
Gets the subgraph-specific default attribute for the named node attribute.

Parameters:
key - the name of the node attribute pair to be retrieved.
Returns:
the requested attribute pair or null if not found.

getNodeAttributeValue

public java.lang.Object getNodeAttributeValue(java.lang.String key)
Gets the subgraph-specific default value for the named node attribute.

Parameters:
key - the name of the node attribute pair to be retrieved.
Returns:
the requested attribute value or null if not found.

getNodeAttributeKeys

public java.util.Enumeration getNodeAttributeKeys()
Gets an enumeration of the subgraph-specific node attribute keys

Returns:
an enumeration of String objects.

getNodeAttributePairs

public java.util.Enumeration getNodeAttributePairs()
Gets an enumeration of the subgraph-specific node attributes

Returns:
an enumeration of Attribute objects.

setNodeAttribute

public java.lang.Object setNodeAttribute(Attribute attr)
Sets the subgraph-specific default for the specified node attribute. If the attribute is not from the parent subgraph, then setNodeAttribute(attr.getName(), attr.getValue()) is called.

Parameters:
attr - the node Attribute object to set as a default.
Returns:
the Attribute object previously stored for this attribute, if any.
See Also:
Subgraph#setNodeAttribute(java.lang.String, java.lang.String)

setNodeAttribute

public java.lang.Object setNodeAttribute(java.lang.String name,
                                         java.lang.Object value)
Sets the subgraph-specific default using the specified name/value pair. A new attribute will be created if needed.

Parameters:
name - the node attribute name
value - the node attribute value
Returns:
the Attribute object previously stored for this attribute, if any.

removeNodeAttribute

private void removeNodeAttribute(java.lang.String name)

setEdgeAttribute

public java.lang.Object setEdgeAttribute(Attribute attr)
Sets the subgraph-specific default for the specified edge attribute. If the attribute is not from the parent subgraph, then setEdgeAttribute(attr.getName(), attr.getValue()) is called.

Parameters:
attr - the edge attribute pair to set.
Returns:
the attribute pair previously stored for this attribute.
See Also:
Subgraph#setEdgeAttribute(java.lang.String, java.lang.String)

setEdgeAttribute

public java.lang.Object setEdgeAttribute(java.lang.String name,
                                         java.lang.Object value)
Sets the subgraph-specific default using the specified name/value pair. A new attribute will be created if needed.

Parameters:
name - the edge attribute name
value - the edge attribute value
Returns:
the attribute pair previously stored for this attribute.

removeEdgeAttribute

private void removeEdgeAttribute(java.lang.String name)

setAttribute

public java.lang.Object setAttribute(Attribute attr)
Sets the subgraph-specific default for the specified graph attribute. If the attribute is not from the parent subgraph, then setAttribute(attr.getName(), attr.getValue()) is called. Overrides Element method.

Overrides:
setAttribute in class Element
Parameters:
attr - the graph attribute pair to set.
Returns:
the attribute pair previously stored for this attribute.
See Also:
Subgraph#setAttribute(java.lang.String, java.lang.String)

setAttribute

public java.lang.Object setAttribute(java.lang.String name,
                                     java.lang.Object value)
Sets the subgraph-specific default using the specified name/value pair. A new attribute will be created if needed. Overrides Element method.

Overrides:
setAttribute in class Element
Parameters:
name - the graph attribute name
value - the graph attribute value
Returns:
the attribute pair previously stored for this attribute.

getEdgeAttribute

public Attribute getEdgeAttribute(java.lang.String key)
Gets the subgraph-specific default attribute for the named edge attribute.

Parameters:
key - the name of the edge attribute pair to be retrieved.
Returns:
the requested attribute pair or null if not found.

getEdgeAttributeValue

public java.lang.Object getEdgeAttributeValue(java.lang.String key)
Gets the subgraph-specific default value for the named edge attribute.

Parameters:
key - the name of the edge attribute pair to be retrieved.
Returns:
the requested attribute value or null if not found.

getEdgeAttributeKeys

public java.util.Enumeration getEdgeAttributeKeys()
Gets an enumeration of the subgraph-specific edge attribute keys

Returns:
an enumeration of String objects.

getEdgeAttributePairs

public java.util.Enumeration getEdgeAttributePairs()
Gets an enumeration of the subgraph-specific edge attributes

Returns:
an enumeration of Attribute objects.

getBoundingBox

public java.awt.geom.Rectangle2D getBoundingBox()
Get the bounding box of the subgraph.

Returns:
the bounding box of the subgraph.

resetBoundingBox

public java.awt.geom.Rectangle2D resetBoundingBox()
Removes bounding box information from this subgraph and any contained subgraphs including the BBOX_ATTR value and then recomputes the bounding boxes.

Returns:
the new bounding box of the subgraph.

printSubgraph

public void printSubgraph(java.io.PrintWriter out)
Prints an ascii description of each graph element to the supplied stream.

Parameters:
output - the OutputStream for writing the graph description.

printDflt

private void printDflt(java.io.PrintWriter out,
                       int type)

printDfltAttr

private void printDfltAttr(java.io.PrintWriter out,
                           java.util.Hashtable dfltAttr,
                           int type,
                           java.lang.String prefix,
                           java.lang.String suffix)

attributeType

public static int attributeType(java.lang.String attrname)
Returns the attribute conversion type for the supplied attribute name. After subgraph specific attribute name/type mappings are checked, mappings at the element level are checked.

Parameters:
attrname - the attribute name
Returns:
the currently associated attribute type

getParentDefault

private Attribute getParentDefault(int type,
                                   java.lang.String key)

findElementByName

private Element findElementByName(int type,
                                  java.lang.String name)

findElementInSubgraphByName

private Element findElementInSubgraphByName(int type,
                                            java.lang.String name)

findNodeByName

public Node findNodeByName(java.lang.String nodeName)
Searches current subgraph and, by recursion, descendent subgraphs for the node matching the supplied name.

Parameters:
nodeName - the name of the node to be found.
Returns:
the Node matching the name or null, if there is no match.

findEdgeByName

public Edge findEdgeByName(java.lang.String edgeName)
Searches current subgraph and, by recursion, descendent subgraphs for the edge matching the supplied name.

Parameters:
edgeName - the name of the edge to be found.
Returns:
the Edge matching the name or null, if there is no match.

findSubgraphByName

public Subgraph findSubgraphByName(java.lang.String graphName)
Searches current subgraph and, by recursion, descendent subgraphs for the subgraph matching the supplied name.

Parameters:
graphName - the name of the subgraph to be found.
Returns:
the Subgraph matching the name or null, if there is no match.

createElement

public Element createElement(int type,
                             java.lang.Object[] info,
                             Attribute[] attrs)
Creates a new element and adds it to the subgraph's element dictionary. For nodes, the info vector can be null or contains: For edges, the info vector must contain (in this order) at least: Optionally, the info vector can also contain at its end (in this order): For subgraphs, the info vector can be null or contains:

Parameters:
type - type of the element to be added
info - a vector specifics for the particular type of element being created
attrs - attributes describing the element to be created
Throws:
java.lang.InstantiationException - whenever element cannot be created

addNode

public void addNode(Node newNode)
Adds the specified node to the subgraph's Node dictionary.

Parameters:
newNode - the node to be added to the dictionary.

removeNode

public Node removeNode(java.lang.String nodeName)
Removes the node matching the specified name from the subgraph's Node dictionary.

Parameters:
nodeName - the name of the node to be removed from the dictionary.
Returns:
the node that was removed.

addEdge

public void addEdge(Edge newEdge)
Adds the specified edge to the subgraph's Edge dictionary.

Parameters:
newEdge - the edge to be added to the dictionary.

removeEdge

public Edge removeEdge(java.lang.String edgeName)
Removes the edge matching the specified name from the subgraph's Edge dictionary.

Parameters:
edgeName - the name of the edge to be removed from the dictionary.
Returns:
the edge that was removed.

addSubgraph

public void addSubgraph(Subgraph newGraph)
Adds the specified subgraph to the subgraph's graph dictionary.

Parameters:
newGraph - the subgraph to be added to the dictionary.

removeSubgraph

public Subgraph removeSubgraph(java.lang.String graphName)
Removes the subgraph matching the specified name from the subgraph's graph dictionary.

Parameters:
graphName - the name of the subgraph to be removed from the dictionary.
Returns:
the subgraph that was removed.

setShowSubgraphLabels

public boolean setShowSubgraphLabels(boolean value)
Set flag to indicate if subgraph labels should be rendered

Returns:
the previous value

setShowNodeLabels

public boolean setShowNodeLabels(boolean value)
Set flag to indicate if node labels should be rendered

Returns:
the previous value

setShowEdgeLabels

public boolean setShowEdgeLabels(boolean value)
Set flag to indicate if edge labels should be rendered

Returns:
the previous value

getShowSubgraphLabels

public boolean getShowSubgraphLabels()
Get flag that indicates if subgraph labels should be rendered

Returns:
the flag value

getShowNodeLabels

public boolean getShowNodeLabels()
Get flag that indicates if node labels should be rendered

Returns:
the flag value

getShowEdgeLabels

public boolean getShowEdgeLabels()
Get flag that indicates if edge labels should be rendered

Returns:
the flag value

isLR

public boolean isLR()
Check if the orientation of this subgraph is LR (left-to-right) as opposed to TB (top-to-bottom).

Returns:
true if the orientation is left-to-right.

addTypeTag

public void addTypeTag(int type,
                       java.lang.String tag)
Adds a default tag for the specified element type within this subgraph.

Parameters:
type - the element type for this tag operation
tag - the tag to associate with this element type.

hasTypeTag

public boolean hasTypeTag(int type,
                          java.lang.String tag)
Check if the specified element type has the supplied default tag within this subgraph.

Parameters:
type - the element type for this tag operation
tag - tag value to be searched for
Returns:
true, if this subgraph contains the supplied tag as a default for the given type

hasTypeTags

public boolean hasTypeTags(int type)
Check if this element type has any default tags at all.

Parameters:
type - the element type for this tag operation
Returns:
true, if this Element has any tags

removeTypeTags

public void removeTypeTags(int type)
Removes any and all default tags associated with this element type.

Parameters:
type - the element type for this tag operation

removeTypeTag

public void removeTypeTag(int type,
                          java.lang.String tag)
Removes the specified tag from this element.

Parameters:
type - the element type for this tag operation
tag - the tag value to remove

countOfLocalElements

public int countOfLocalElements(int types)
Get a count of elements in this subgraph. No recursion to descendants is done.

Parameters:
types - a bitwise-oring of NODE, EDGE, SUBGRAPH to determine which element types should be in the count
Returns:
a count of the specified elements in this subgraph.
See Also:
GrappaConstants.NODE, GrappaConstants.EDGE, GrappaConstants.SUBGRAPH

countOfElements

public int countOfElements(int types)
Get a count of elements in this subgraph and, by recursion, descendant subgraphs. The subgraph itself is not counted.

Parameters:
types - a bitwise-oring of NODE, EDGE, SUBGRAPH to determine which element types should be in the count
Returns:
a count of the specified elements in this subgraph and its descendants.
See Also:
GrappaConstants.NODE, GrappaConstants.EDGE, GrappaConstants.SUBGRAPH

removeEmptySubgraphs

public void removeEmptySubgraphs()
Delete this subgraph or any contained subgraph, at any depth, if the subgraph contains no elements.


hasEmptySubgraphs

public boolean hasEmptySubgraphs()
Returns:
true if this subgraph or any subgraph contained within this subgraph, at any depth, is empty.

clearPatchWork

public void clearPatchWork()

patchWork

public void patchWork(java.awt.geom.Rectangle2D.Double r,
                      boolean square,
                      int mode)

preparePatchWork

public double preparePatchWork(int mode)

getPatches

Element[] getPatches()

combPatchWork

private void combPatchWork()

prepPatchWork

private double prepPatchWork(java.lang.String attrname,
                             int mode)

aspect

double aspect(java.awt.geom.Rectangle2D.Double r)

score

double score(double wd,
             double ht)

computePatchWork

public void computePatchWork(java.awt.geom.Rectangle2D.Double r,
                             boolean square)

compSqPatchWork

private void compSqPatchWork(java.awt.geom.Rectangle2D.Double r,
                             boolean top)

compStdPatchWork

private void compStdPatchWork(java.awt.geom.Rectangle2D.Double r,
                              boolean top)

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Specified by:
compare in interface java.util.Comparator

equals

public boolean equals(java.lang.Object obj)
Specified by:
equals in interface java.util.Comparator
Overrides:
equals in class java.lang.Object

nodeElements

public java.util.Enumeration nodeElements()
Get an enumeration of the node elements in this subgraph.

Returns:
an Enumeration of Node objects

edgeElements

public java.util.Enumeration edgeElements()
Get an enumeration of the edge elements in this subgraph.

Returns:
an Enumeration of Edge objects

subgraphElements

public java.util.Enumeration subgraphElements()
Get an enumeration of the subgraph elements in this subgraph.

Returns:
an Enumeration of Subgraph objects

elements

public GraphEnumeration elements(int types)
Get an enumeration of elements in this subgraph and any subgraphs under this one.

Parameters:
types - a bitwise-oring of NODE, EDGE, SUBGRAPH to determine which element types should be in the enumeration
Returns:
a GraphEnumeration containing Element objects.
See Also:
GrappaConstants.NODE, GrappaConstants.EDGE, GrappaConstants.SUBGRAPH

elements

public GraphEnumeration elements()
Get an enumeration of all elements in this subgraph and any subgraphs under this one. A convenience method equivalent to: elements(NODE|EDGE|SUBGRAPH)

Returns:
a GraphEnumeration containing Element objects.
See Also:
elements(int)

vectorOfElements

public java.util.Vector vectorOfElements(int types)
Get a vector of elements in this subgraph and, by recursion, descendant subgraphs.

Parameters:
types - a bitwise-oring of NODE, EDGE, SUBGRAPH to determine which element types should be in the count
Returns:
a vector of the specified elements in this subgraph and its descendants (excluding the current subgraph itself).
See Also:
GrappaConstants.NODE, GrappaConstants.EDGE, GrappaConstants.SUBGRAPH

recurseVectorOfElements

void recurseVectorOfElements(int types,
                             java.util.Vector retVec,
                             int count)