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
-
defaultNamePrefix
- Default graph name prefix used by setName().
-
Subgraph(Subgraph)
- Use this constructor when creating a subgraph within a subgraph
with an automatically generated name.
-
Subgraph(Subgraph, String)
- Use this constructor when creating a subgraph within a subgraph.
-
addEdge(Edge)
- Adds the specified edge to the subgraph's Edge dictionary.
-
addNode(Node)
- Adds the specified node to the subgraph's Node dictionary.
-
addSubgraph(Subgraph)
- Adds the specified subgraph to the subgraph's graph dictionary.
-
addToBBox(Rectangle)
- Adds the given rectangle to graph bounding box.
-
buildAppObjects()
- Builds the application components associated with the graph elements
-
buildDrawObjects()
- Builds the drawing components associated with the graph elements; if
the application components have not been built yet, those are constructed
as well.
-
buildObjects()
- Instantiates both the application and drawing components of each of
the graph elements within the graph.
-
countOfElements(int)
- Get a count of elements in this subgraph and, by recursion, descendant
subgraphs.
-
countOfLocalElements(int)
- Get a count of elements in this subgraph.
-
createElement(int, Vector, Vector)
- Creates a new element and adds it to the subgraph's element dictionary.
-
drawGraph()
- Draws the graph onto the DrawPanes.
-
edgeElements()
- Get an enumeration of the edge elements in this subgraph.
-
elements()
- Get an enumeration of all elements in this subgraph and any subgraphs under this one.
-
elements(int)
- Get an enumeration of elements in this subgraph and any subgraphs under this one.
-
findEdgeByName(String)
- Searches current subgraph and, by recursion, descendent subgraphs
for the edge matching the supplied name.
-
findNodeByName(String)
- Searches current subgraph and, by recursion, descendent subgraphs
for the node matching the supplied name.
-
findSubgraphByName(String)
- Searches current subgraph and, by recursion, descendent subgraphs
for the subgraph matching the supplied name.
-
getBaseBBox()
- Get the minimal dimensions of the graph bounding box.
-
getBounds()
- Get the bounding box of the graph, possibly intersected with a
previously specified cropping box.
-
getBoundsFlag()
- Get the bounding box recomputation indicator.
-
getCropBBox()
- Get the cropping box.
-
getEdgeAttribute(String)
- Gets the subgraph-specific default for the requested edge attribute.
-
getEdgeAttributeKeys()
- Gets an enumeration of the subgraph-specific edge attribute keys
-
getEdgeAttributePairs()
- Gets an enumeration of the subgraph-specific edge attributes
-
getNodeAttribute(String)
- Gets the subgraph-specific default for the requested node attribute.
-
getNodeAttributeKeys()
- Gets an enumeration of the subgraph-specific node attribute keys
-
getNodeAttributePairs()
- Gets an enumeration of the subgraph-specific node attributes
-
getType()
- Get the type of this element.
-
hasAppObjects()
- Check if AppObjects have been instantiated.
-
hasDrawObjects()
- Check if DrawObjects have been instantiated.
-
isCluster()
- Check if the subgraph is a cluster subgraph.
-
isLR()
- Check if the orientation of this subgraph is LR (left-to-right) as opposed
to TB (top-to-bottom).
-
isRoot()
- Check if the subgraph is the root of the graph.
-
isSubgraph()
- Check if this element is a subgraph.
-
nodeElements()
-
/**
Get an enumeration of the node elements in this subgraph.
-
printSubgraph(PrintWriter)
- Prints an ascii description of each graph element to the supplied stream.
-
redrawGraph()
- Redraws the graph, as needed, onto the DrawPanes.
-
removeEdge(String)
- Removes the edge matching the specified name from the subgraph's Edge dictionary.
-
removeGraph(String)
- Removes the subgraph matching the specified name from the
subgraph's graph dictionary.
-
removeNode(String)
- Removes the node matching the specified name from the subgraph's Node dictionary.
-
setAttribute(Attribute)
- Sets the subgraph-specific default for the specified graph attribute.
-
setAttribute(String, String)
- Sets the subgraph-specific default using the specified name/value
pair.
-
setBaseBBox(Rectangle)
- Set the minimal dimensions of the graph bounding box.
-
setBoundsFlag(boolean)
- Set an indicator regarding the need to re-compute the graph
bounding box.
-
setCropBBox(Rectangle)
- Set the dimensions of the cropping box.
-
setEdgeAttribute(Attribute)
- Sets the subgraph-specific default for the specified edge attribute.
-
setEdgeAttribute(String, String)
- Sets the subgraph-specific default using the specified name/value
pair.
-
setName(String)
- Sets the subgraph name to a copy of the supplied argument.
-
setNodeAttribute(Attribute)
- Sets the subgraph-specific default for the specified node attribute.
-
setNodeAttribute(String, String)
- Sets the subgraph-specific default using the specified name/value
pair.
-
subgraphElements()
- Get an enumeration of the subgraph elements in this subgraph.
defaultNamePrefix
public static final String defaultNamePrefix
- Default graph name prefix used by setName().
- See Also:
- setName
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.
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
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
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
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
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(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.
getNodeAttributeKeys
public Enumeration getNodeAttributeKeys()
- Gets an enumeration of the subgraph-specific node attribute keys
- Returns:
- an enumeration of String objects.
getNodeAttributePairs
public Enumeration getNodeAttributePairs()
- Gets an enumeration of the subgraph-specific node attributes
- Returns:
- an enumeration of Attribute objects.
getEdgeAttributeKeys
public Enumeration getEdgeAttributeKeys()
- Gets an enumeration of the subgraph-specific edge attribute keys
- Returns:
- an enumeration of String objects.
getEdgeAttributePairs
public Enumeration getEdgeAttributePairs()
- Gets an enumeration of the subgraph-specific edge attributes
- Returns:
- an enumeration of Attribute objects.
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
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.
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
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.
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
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
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.
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.
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.
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.
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.
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:
- String - name of the node (optional, for automatic name generation)
For edges, the info vector must contain (in this order) at least:
- Node - head node,
- String - headport tag (or null),
- Node - tail node,
Optionally, the info vector can also contain at its end (in this order):
- String - tailport tag (or null),
- String - a key for distinguishing multiple edges between the same nodes (or null),
For subgraphs, the info vector can be null or contains:
- String - name of the subgraph (optional, for automatic name generation)
- 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
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(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(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.
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.
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.
hasAppObjects
public boolean hasAppObjects()
- Check if AppObjects have been instantiated.
- Returns:
- true once AppObjects have been instantiated
hasDrawObjects
public boolean hasDrawObjects()
- Check if DrawObjects have been instantiated.
- Returns:
- true once DrawObjects have been instantiated
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
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
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
drawGraph
public void drawGraph()
- Draws the graph onto the DrawPanes.
redrawGraph
public void redrawGraph()
- Redraws the graph, as needed, onto the DrawPanes.
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
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
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
getCropBBox
public Rectangle getCropBBox()
- Get the cropping box.
- Returns:
- the current value of the cropping box
- See Also:
- setCropBBox
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.
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
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
getBoundsFlag
public boolean getBoundsFlag()
- Get the bounding box recomputation indicator.
- Returns:
- true if the bounding box should be recomputed.
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
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
nodeElements
public Enumeration nodeElements()
- /**
Get an enumeration of the node elements in this subgraph.
- Returns:
- an Enumeration of Node objects
edgeElements
public Enumeration edgeElements()
- Get an enumeration of the edge elements in this subgraph.
- Returns:
- an Enumeration of Edge objects
subgraphElements
public 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 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
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