All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class att.grappa.Subgraph

java.lang.Object
   |
   +----att.grappa.Element
           |
           +----att.grappa.Subgraph

public class Subgraph
extends Element
implements Shape
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.1, 30 Sep 1999; Copyright 1996 - 1999 by AT&T Corp.
Author:
John Mocenigo, Research @ AT&T Labs
See Also:
Graph

Variable Index

 o defaultNamePrefix
Default graph name prefix used by setName().

Constructor Index

 o Subgraph(Subgraph)
Use this constructor when creating a subgraph within a subgraph with an automatically generated name.
 o Subgraph(Subgraph, String)
Use this constructor when creating a subgraph within a subgraph.

Method Index

 o addEdge(Edge)
Adds the specified edge to the subgraph's Edge dictionary.
 o addNode(Node)
Adds the specified node to the subgraph's Node dictionary.
 o addSubgraph(Subgraph)
Adds the specified subgraph to the subgraph's graph dictionary.
 o addToBBox(Rectangle)
Adds the given rectangle to graph bounding box.
 o buildAppObjects()
Builds the application components associated with the graph elements
 o buildDrawObjects()
Builds the drawing components associated with the graph elements; if the application components have not been built yet, those are constructed as well.
 o buildObjects()
Instantiates both the application and drawing components of each of the graph elements within the graph.
 o countOfElements(int)
Get a count of elements in this subgraph and, by recursion, descendant subgraphs.
 o countOfLocalElements(int)
Get a count of elements in this subgraph.
 o createElement(int, Vector, Vector)
Creates a new element and adds it to the subgraph's element dictionary.
 o drawGraph()
Draws the graph onto the DrawPanes.
 o edgeElements()
Get an enumeration of the edge elements in this subgraph.
 o elements()
Get an enumeration of all elements in this subgraph and any subgraphs under this one.
 o elements(int)
Get an enumeration of elements in this subgraph and any subgraphs under this one.
 o findEdgeByName(String)
Searches current subgraph and, by recursion, descendent subgraphs for the edge matching the supplied name.
 o findNodeByName(String)
Searches current subgraph and, by recursion, descendent subgraphs for the node matching the supplied name.
 o findSubgraphByName(String)
Searches current subgraph and, by recursion, descendent subgraphs for the subgraph matching the supplied name.
 o getBaseBBox()
Get the minimal dimensions of the graph bounding box.
 o getBounds()
Get the bounding box of the graph, possibly intersected with a previously specified cropping box.
 o getBoundsFlag()
Get the bounding box recomputation indicator.
 o getCropBBox()
Get the cropping box.
 o getEdgeAttribute(String)
Gets the subgraph-specific default for the requested edge attribute.
 o getEdgeAttributeKeys()
Gets an enumeration of the subgraph-specific edge attribute keys
 o getEdgeAttributePairs()
Gets an enumeration of the subgraph-specific edge attributes
 o getNodeAttribute(String)
Gets the subgraph-specific default for the requested node attribute.
 o getNodeAttributeKeys()
Gets an enumeration of the subgraph-specific node attribute keys
 o getNodeAttributePairs()
Gets an enumeration of the subgraph-specific node attributes
 o getType()
Get the type of this element.
 o hasAppObjects()
Check if AppObjects have been instantiated.
 o hasDrawObjects()
Check if DrawObjects have been instantiated.
 o isCluster()
Check if the subgraph is a cluster subgraph.
 o isLR()
Check if the orientation of this subgraph is LR (left-to-right) as opposed to TB (top-to-bottom).
 o isRoot()
Check if the subgraph is the root of the graph.
 o isSubgraph()
Check if this element is a subgraph.
 o nodeElements()
/** Get an enumeration of the node elements in this subgraph.
 o printSubgraph(PrintWriter)
Prints an ascii description of each graph element to the supplied stream.
 o redrawGraph()
Redraws the graph, as needed, onto the DrawPanes.
 o removeEdge(String)
Removes the edge matching the specified name from the subgraph's Edge dictionary.
 o removeGraph(String)
Removes the subgraph matching the specified name from the subgraph's graph dictionary.
 o removeNode(String)
Removes the node matching the specified name from the subgraph's Node dictionary.
 o setAttribute(Attribute)
Sets the subgraph-specific default for the specified graph attribute.
 o setAttribute(String, String)
Sets the subgraph-specific default using the specified name/value pair.
 o setBaseBBox(Rectangle)
Set the minimal dimensions of the graph bounding box.
 o setBoundsFlag(boolean)
Set an indicator regarding the need to re-compute the graph bounding box.
 o setCropBBox(Rectangle)
Set the dimensions of the cropping box.
 o setEdgeAttribute(Attribute)
Sets the subgraph-specific default for the specified edge attribute.
 o setEdgeAttribute(String, String)
Sets the subgraph-specific default using the specified name/value pair.
 o setName(String)
Sets the subgraph name to a copy of the supplied argument.
 o setNodeAttribute(Attribute)
Sets the subgraph-specific default for the specified node attribute.
 o setNodeAttribute(String, String)
Sets the subgraph-specific default using the specified name/value pair.
 o subgraphElements()
Get an enumeration of the subgraph elements in this subgraph.

Variables

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

See Also:
setName

Constructors

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

Parameters:
subg - the parent subgraph.
name - the name of this subgraph.
 o 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

Methods

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

Returns:
true if this object is a Subgraph.
Overrides:
isSubgraph in class Element
 o getType
 public int getType()
Get the type of this element. Useful for distinguishing Element objects.

Returns:
the class variable constant Grappa.SUBGRAPH.
Overrides:
getType in class Element
See Also:
Grappa
 o setName
 public void setName(String newName) throws 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.
See Also:
setName
 o isCluster
 public boolean isCluster()
Check if the subgraph is a cluster subgraph.

Returns:
true, if the graph is a cluster subgraph.
 o 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.
 o getNodeAttribute
 public Attribute getNodeAttribute(String key)
Gets the subgraph-specific default for the requested node attribute.

Parameters:
key - the name of the node attribute pair to be retrieved.
Returns:
the requested Attribute object or null if not found.
 o getNodeAttributeKeys
 public Enumeration getNodeAttributeKeys()
Gets an enumeration of the subgraph-specific node attribute keys

Returns:
an enumeration of String objects.
 o getNodeAttributePairs
 public Enumeration getNodeAttributePairs()
Gets an enumeration of the subgraph-specific node attributes

Returns:
an enumeration of Attribute objects.
 o getEdgeAttributeKeys
 public Enumeration getEdgeAttributeKeys()
Gets an enumeration of the subgraph-specific edge attribute keys

Returns:
an enumeration of String objects.
 o getEdgeAttributePairs
 public Enumeration getEdgeAttributePairs()
Gets an enumeration of the subgraph-specific edge attributes

Returns:
an enumeration of Attribute objects.
 o setNodeAttribute
 public String 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:
setNodeAttribute
 o setNodeAttribute
 public String setNodeAttribute(String name,
                                String 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.
 o setEdgeAttribute
 public String 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:
setEdgeAttribute
 o setEdgeAttribute
 public String setEdgeAttribute(String name,
                                String 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.
 o setAttribute
 public String 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.

Parameters:
attr - the graph attribute pair to set.
Returns:
the attribute pair previously stored for this attribute.
Overrides:
setAttribute in class Element
See Also:
setAttribute
 o setAttribute
 public String setAttribute(String name,
                            String value)
Sets the subgraph-specific default using the specified name/value pair. A new attribute will be created if needed. Overrides Element setAttribute(String,String).

Parameters:
name - the graph attribute name
value - the graph attribute value
Returns:
the attribute pair previously stored for this attribute.
Overrides:
setAttribute in class Element
 o getEdgeAttribute
 public Attribute getEdgeAttribute(String key)
Gets the subgraph-specific default for the requested edge attribute.

Parameters:
key - the name of the edge attribute pair to be retrieved.
Returns:
the requested attribute pair or null if not found.
 o printSubgraph
 public void printSubgraph(PrintWriter out)
Prints an ascii description of each graph element to the supplied stream.

Parameters:
output - the OutputStream for writing the graph description.
 o findNodeByName
 public Node findNodeByName(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.
 o findEdgeByName
 public Edge findEdgeByName(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.
 o findSubgraphByName
 public Subgraph findSubgraphByName(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.
 o createElement
 public Element createElement(int type,
                              Vector info,
                              Vector attrs) throws InstantiationException
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: InstantiationException
whenever element cannot be created
 o 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.
 o removeNode
 public Node removeNode(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.
 o 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.
 o removeEdge
 public Edge removeEdge(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.
 o 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.
 o removeGraph
 public Subgraph removeGraph(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.
 o 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.
 o hasAppObjects
 public boolean hasAppObjects()
Check if AppObjects have been instantiated.

Returns:
true once AppObjects have been instantiated
 o hasDrawObjects
 public boolean hasDrawObjects()
Check if DrawObjects have been instantiated.

Returns:
true once DrawObjects have been instantiated
 o buildAppObjects
 public void buildAppObjects() throws InstantiationException
Builds the application components associated with the graph elements

Throws: InstantiationException
occurs if there is a problem instantiating the AppObjects for this graph
 o buildDrawObjects
 public void buildDrawObjects() throws InstantiationException
Builds the drawing components associated with the graph elements; if the application components have not been built yet, those are constructed as well.

Throws: InstantiationException
occurs if there is a problem instantiating the DrawObjects or AppObjects for this graph
 o buildObjects
 public void buildObjects() throws InstantiationException
Instantiates both the application and drawing components of each of the graph elements within the graph. Equivalent to buildDrawObjects().

Throws: InstantiationException
occurs if there is a problem instantiating the DrawObjects or AppObjects for this graph
See Also:
buildDrawObjects
 o drawGraph
 public void drawGraph()
Draws the graph onto the DrawPanes.

 o redrawGraph
 public void redrawGraph()
Redraws the graph, as needed, onto the DrawPanes.

 o setBaseBBox
 public Rectangle setBaseBBox(Rectangle box)
Set the minimal dimensions of the graph bounding box.

Parameters:
box - the Rectangle to use as the minimal bounding box dimensions.
Returns:
the previous value of the minimal bounding box
See Also:
getBounds
 o getBaseBBox
 public Rectangle getBaseBBox()
Get the minimal dimensions of the graph bounding box.

Returns:
the current value of the minimal bounding box
See Also:
setBaseBBox
 o setCropBBox
 public Rectangle setCropBBox(Rectangle box)
Set the dimensions of the cropping box. The cropping box is intersected with the graph bounding box whenever the bounding box is requested. In this way, zooming is easily accomplished.

Parameters:
box - the Rectangle to use as the cropping box.
Returns:
the previous value of the cropping box
See Also:
getBounds
 o getCropBBox
 public Rectangle getCropBBox()
Get the cropping box.

Returns:
the current value of the cropping box
See Also:
setCropBBox
 o addToBBox
 public Rectangle addToBBox(Rectangle bbox)
Adds the given rectangle to graph bounding box. A null argument just returns the current BBox.

Parameters:
bbox - bounding box to be added to graph bounding box.
Returns:
the augmented graph bounding box.
 o getBounds
 public Rectangle getBounds()
Get the bounding box of the graph, possibly intersected with a previously specified cropping box.

Returns:
the graph bounding box, possibly intersected with a non-null cropping box
See Also:
setCropBBox
 o setBoundsFlag
 public void setBoundsFlag(boolean mode)
Set an indicator regarding the need to re-compute the graph bounding box.

Parameters:
mode - use true to indicate that recomputation is needed
 o getBoundsFlag
 public boolean getBoundsFlag()
Get the bounding box recomputation indicator.

Returns:
true if the bounding box should be recomputed.
 o 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 Grappa.NODE, Grappa.EDGE, Grappa.SUBGRAPH to determine which element types should be in the count
Returns:
a count of the specified elements in this subgraph.
See Also:
NODE, EDGE, SUBGRAPH
 o countOfElements
 public int countOfElements(int types)
Get a count of elements in this subgraph and, by recursion, descendant subgraphs.

Parameters:
types - a bitwise-oring of Grappa.NODE, Grappa.EDGE, Grappa.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:
NODE, EDGE, SUBGRAPH
 o nodeElements
 public Enumeration nodeElements()
/** Get an enumeration of the node elements in this subgraph.

Returns:
an Enumeration of Node objects
 o edgeElements
 public Enumeration edgeElements()
Get an enumeration of the edge elements in this subgraph.

Returns:
an Enumeration of Edge objects
 o subgraphElements
 public Enumeration subgraphElements()
Get an enumeration of the subgraph elements in this subgraph.

Returns:
an Enumeration of Subgraph objects
 o 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 Grappa.NODE, Grappa.EDGE, Grappa.SUBGRAPH to determine which element types should be in the enumeration
Returns:
a GraphEnumeration containing Element objects.
See Also:
NODE, EDGE, SUBGRAPH
 o 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(Grappa.NODE|Grappa.EDGE|Grappa.SUBGRAPH)

Returns:
a GraphEnumeration containing Element objects.
See Also:
elements

All Packages  Class Hierarchy  This Package  Previous  Next  Index