All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class att.grappa.Graph

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

public class Graph
extends Subgraph
This class is the root of the overall graph and provides methods for working with the entire graph (for example. printing the graph). It is an extension of the Subgraph class.

Version:
1.1, 30 Sep 1999; Copyright 1996 - 1999 by AT&T Corp.
Author:
John Mocenigo, Research @ AT&T Labs

Variable Index

 o INDENT_STRING
The string used for indentation when printing out the graph.

Constructor Index

 o Graph(String)
Creates a directed graph that is not strict A convenience method equivalent to Graph(graphName,true,false).
 o Graph(String, boolean, boolean)
Creates a new, empty Graph object.

Method Index

 o addDrawPane(DrawPane)
Adds a DrawPane to the graph's list of DrawPanes if it is not already in the list.
 o addGroupingContext(GraphicContext)
Add a GraphicContext to the list of GraphicContexts used when indicating groupings of elements.
 o decrementIndent()
Decrease the indent string by removing one INDENT_STRING.
 o getCurrent()
Get the element marked as the current element.
 o getDeletionContext()
Get the GraphicContext to use when an element is to be deleted.
 o getErrorWriter()
Get the current PrintWriter used for error messages.
 o getGlobalAttribute(int, String)
Gets a graph default attribute.
 o getGlobalAttributeKeys(int)
Gets an enumeration of the specified graph default attribute keys
 o getGlobalAttributePairs(int)
Gets an enumeration of the specified graph default attributes
 o getGlobalAttributeSize(int)
Get a count of the graph default attributes of a particular type.
 o getGraphPanes()
Get an enumeration of the panes upon which given graph is displayed.
 o getGraphPropertiesCard()
Get the graph properties card.
 o getGrappaAttribute(String)
Gets Grappa default attribute.
 o getGrappaAttributeKeys()
Get an enumeration of the Grappa package attribute keys.
 o getGroupingContextAt(int)
Get a specific GraphicContext from the list of GraphicContexts used to indicate groupings of elements.
 o getGroupingContextsSize()
Get the size of the list of GraphicContexts used to indicate groupings of elements.
 o getId(int)
Get the next id number for the specified type, but do not increment the counter.
 o getIndent()
Get the current indent string.
 o getSelectionContext()
Get the GraphicContext to use when an element is selected.
 o hasAppObjectsSomewhere()
Indicates that there are AppObjects somewhere in the graph.
 o hasDrawObjectsSomewhere()
Indicates that there are DrawObjects somewhere in the graph.
 o incrementIndent()
Increase the indent string by appending INDENT_STRING.
 o instantiateGraph()
Instantiates both the application and drawing components of each of the graph elements within the graph. Deprecated.
 o isDirected()
Check if the graph is directed.
 o isEditable()
Check if this graph is interactively editable (i.e., through mouse events).
 o isMenuable()
Check if an element-specific menu is available interactively (i.e., through mouse events).
 o isSelectable()
Check if graph elements are interactively selectable (i.e., through mouse events).
 o isStrict()
Check if the graph is strict (i.e., no self-loops).
 o printError(String)
Print the supplied message to the error output.
 o printError(String, Exception)
Print the supplied message and exception information to the error output.
 o printGraph(OutputStream)
Output graph to specified OutputStream.
 o printGraph(Writer)
Output graph to specified Writer.
 o removeDrawPane(DrawPane)
Removes a DrawPane from the graph's list of DrawPanes.
 o replaceContents(Graph)
Replace all aspects of the current graph with the supplied graph.
 o reset()
Reset this graph by removing all its elements and re-initiailizing its internal variables.
 o reset(String, boolean, boolean)
Reset this graph by removing all its elements and re-initiailizing its internal variables and possibly changing its name, directedness and strictness.
 o setAsGraphPropertiesCard(PopUpCard)
Sets the value of the graph properties card.
 o setCurrent(Element)
Set the supplied element as the current element of the graph.
 o setDeletionContext(GraphicContext)
Set the GraphicContext to use when an element is to be deleted.
 o setEditable(boolean)
Set the editability of the graph.
 o setErrorWriter(PrintWriter)
Set the PrintWriter for error messages.
 o setGrappaAttribute(String, String)
Sets a Grappa package attribute.
 o setGroupingContexts(Vector)
Set the list of GraphicContexts to use when indicating groupings of elements.
 o setMenuable(boolean)
Set whether element-specific menus are to be available interactively.
 o setSelectable(boolean)
Set the selectability of the graph.
 o setSelectionContext(GraphicContext)
Set the GraphicContext to use when an element is selected.
 o validGrappaAttributeKey(String)
Check if the given key has a format consistent with Grappa package attribute keys.

Variables

 o INDENT_STRING
 public static final String INDENT_STRING
The string used for indentation when printing out the graph.

Constructors

 o Graph
 public Graph(String graphName,
              boolean directed,
              boolean strict)
Creates a new, empty Graph object.

Parameters:
graphName - the name of this graph.
directed - use true if graph is to be a directed graph
strict - use true if graph is a strict graph
 o Graph
 public Graph(String graphName)
Creates a directed graph that is not strict A convenience method equivalent to Graph(graphName,true,false).

Parameters:
graphName - the name of this graph.
See Also:
Graph

Methods

 o hasDrawObjectsSomewhere
 public boolean hasDrawObjectsSomewhere()
Indicates that there are DrawObjects somewhere in the graph.

Returns:
true, if there are DrawObjects in the graph.
 o hasAppObjectsSomewhere
 public boolean hasAppObjectsSomewhere()
Indicates that there are AppObjects somewhere in the graph.

Returns:
true, if there are AppObjects in the graph.
 o getGrappaAttribute
 public Attribute getGrappaAttribute(String key) throws IllegalArgumentException
Gets Grappa default attribute.

Parameters:
key - the search key for the corresponding attribute.
Returns:
the value of the matching Grappa default attribute or null.
Throws: IllegalArgumentException
whenever the key is null
 o setGrappaAttribute
 public String setGrappaAttribute(String key,
                                  String value) throws IllegalArgumentException
Sets a Grappa package attribute. A Grappa package attribute is one specific to Grappa (for example, a display color) rather than an attribute that relates to a graph.

Parameters:
key - the search key for the corresponding attribute.
Returns:
the previous value of the matching Grappa default attribute or null.
Throws: IllegalArgumentException
whenever the key is not prefixed by Grappa.PKG_LOWER
See Also:
PKG_LOWER
 o getGrappaAttributeKeys
 public Enumeration getGrappaAttributeKeys()
Get an enumeration of the Grappa package attribute keys.

Returns:
an Enumeration of Attribute objects
 o validGrappaAttributeKey
 public static boolean validGrappaAttributeKey(String key)
Check if the given key has a format consistent with Grappa package attribute keys. A Grappa package key starts with Grappa.PKG_LOWER.

Parameters:
key - the key to validate
Returns:
true if the supplied key could serve as a Grappa package attribute key.
See Also:
PKG_LOWER
 o getGlobalAttribute
 public Attribute getGlobalAttribute(int type,
                                     String key) throws IllegalArgumentException
Gets a graph default attribute. A graph default attribute determines basic graph characteristics initially (e.g., node shape).

Parameters:
type - indicates attribute type.
key - the search key for the corresponding attribute.
Returns:
the value of the matching graph default attribute or null.
Throws: IllegalArgumentException
whenever the specified type is not valid
See Also:
NODE, EDGE, SUBGRAPH
 o getGlobalAttributeKeys
 public Enumeration getGlobalAttributeKeys(int type) throws IllegalArgumentException
Gets an enumeration of the specified graph default attribute keys

Parameters:
type - indicates attribute type.
Returns:
an Enumeration of String objects
Throws: IllegalArgumentException
whenever the specified type is not valid
See Also:
NODE, EDGE, SUBGRAPH
 o getGlobalAttributePairs
 public Enumeration getGlobalAttributePairs(int type) throws IllegalArgumentException
Gets an enumeration of the specified graph default attributes

Parameters:
type - indicates attribute type.
Returns:
an Enumeration of Attribute objects
Throws: IllegalArgumentException
whenever the specified type is not valid
See Also:
NODE, EDGE, SUBGRAPH
 o getGlobalAttributeSize
 public int getGlobalAttributeSize(int type) throws IllegalArgumentException
Get a count of the graph default attributes of a particular type.

Parameters:
type - indicates attribute type.
Returns:
a count of the specified graph default attributes
Throws: IllegalArgumentException
whenever the specified type is not valid
See Also:
NODE, EDGE, SUBGRAPH
 o instantiateGraph
 public void instantiateGraph() throws InstantiationException
Note: instantiateGraph() is deprecated. Replaced by buildObjects().

Instantiates both the application and drawing components of each of the graph elements within the graph.

Throws: InstantiationException
occurs if there is a problem instantiating the AppObjects or DrawObjects for this graph.
See Also:
buildObjects
 o printGraph
 public void printGraph(Writer output)
Output graph to specified Writer.

Parameters:
output - the Writer for writing
 o printGraph
 public void printGraph(OutputStream output)
Output graph to specified OutputStream. A convenience method to accomodate the OuputStreams easily.

Parameters:
output - the OutputStream for writing
 o getId
 public int getId(int type) throws IllegalArgumentException
Get the next id number for the specified type, but do not increment the counter.

Parameters:
type - type of id number to return
Returns:
the next sequential id number (counter is not incremented).
Throws: IllegalArgumentException
whenever the specified type is not valid
See Also:
NODE, EDGE, SUBGRAPH
 o getIndent
 public String getIndent()
Get the current indent string.

Returns:
the current indent string.
 o incrementIndent
 public void incrementIndent()
Increase the indent string by appending INDENT_STRING.

See Also:
INDENT_STRING
 o decrementIndent
 public void decrementIndent()
Decrease the indent string by removing one INDENT_STRING.

See Also:
INDENT_STRING
 o isDirected
 public boolean isDirected()
Check if the graph is directed.

Returns:
true if graph is a directed graph
 o isStrict
 public boolean isStrict()
Check if the graph is strict (i.e., no self-loops).

Returns:
true if the graph is strict
 o reset
 public void reset()
Reset this graph by removing all its elements and re-initiailizing its internal variables.

 o reset
 public void reset(String graphName,
                   boolean directed,
                   boolean strict)
Reset this graph by removing all its elements and re-initiailizing its internal variables and possibly changing its name, directedness and strictness.

 o isEditable
 public boolean isEditable()
Check if this graph is interactively editable (i.e., through mouse events).

Returns:
true if the graph can be edited interactively.
 o setEditable
 public boolean setEditable(boolean mode)
Set the editability of the graph.

Parameters:
mode - true to turn on editability.
Returns:
previous value
See Also:
isEditable
 o isSelectable
 public boolean isSelectable()
Check if graph elements are interactively selectable (i.e., through mouse events).

Returns:
true if graph elements can be selected interactively.
 o setSelectable
 public boolean setSelectable(boolean mode)
Set the selectability of the graph.

Parameters:
mode - true to turn on selectability.
Returns:
previous value
See Also:
isSelectable
 o isMenuable
 public boolean isMenuable()
Check if an element-specific menu is available interactively (i.e., through mouse events).

Returns:
true if an element-specific menu is available
 o setMenuable
 public boolean setMenuable(boolean mode)
Set whether element-specific menus are to be available interactively.

Parameters:
mode - true to turn on element-specific-menus.
Returns:
previous value
See Also:
isMenuable
 o setErrorWriter
 public PrintWriter setErrorWriter(PrintWriter errWriter)
Set the PrintWriter for error messages.

Parameters:
errWriter - the PrintWriter to use for error messages.
Returns:
the previous PrintWriter used for error messages.
See Also:
PrintWriter
 o getErrorWriter
 public PrintWriter getErrorWriter()
Get the current PrintWriter used for error messages.

Returns:
the current PrintWriter used for error messages.
See Also:
PrintWriter
 o printError
 public void printError(String msg)
Print the supplied message to the error output. Nothing happens if the error output is set to null.

Parameters:
msg - the message to print on the error output.
See Also:
setErrorWriter
 o printError
 public void printError(String msg,
                        Exception ex)
Print the supplied message and exception information to the error output. Nothing happens if the error output is set to null.

Parameters:
msg - the message to print on the error output.
ex - if supplied, the stack trace associated with this exception is also printed.
See Also:
setErrorWriter
 o getGraphPanes
 public Enumeration getGraphPanes()
Get an enumeration of the panes upon which given graph is displayed.

Returns:
an Enumeration of DrawPane objects
 o addDrawPane
 public void addDrawPane(DrawPane pane)
Adds a DrawPane to the graph's list of DrawPanes if it is not already in the list.

Parameters:
pane - the DrawPane to be added
 o removeDrawPane
 public void removeDrawPane(DrawPane pane)
Removes a DrawPane from the graph's list of DrawPanes.

Parameters:
pane - the DrawPane to be removed
 o getGraphPropertiesCard
 public PopUpCard getGraphPropertiesCard()
Get the graph properties card. The graph properities card is used for displaying information such as local and default attribute values for a specific element. A single card is used (and re-used) for all elements in the graph. Naturally, the content displayed varies by element.

Returns:
the graph properties card for this graph
 o setAsGraphPropertiesCard
 public PopUpCard setAsGraphPropertiesCard(PopUpCard newCard)
Sets the value of the graph properties card.

Parameters:
newCard - the new card to use as the graph properties card
Returns:
the previous graph properties card
 o setSelectionContext
 public GraphicContext setSelectionContext(GraphicContext context)
Set the GraphicContext to use when an element is selected.

Parameters:
context - the GraphicContext to use for selection
Returns:
the previous GraphicContext used for selection
 o getSelectionContext
 public GraphicContext getSelectionContext()
Get the GraphicContext to use when an element is selected.

Returns:
the current GraphicContext used for selection
 o setDeletionContext
 public GraphicContext setDeletionContext(GraphicContext context)
Set the GraphicContext to use when an element is to be deleted.

Parameters:
context - the GraphicContext to use to indicate a pending deletion
Returns:
the previous GraphicContext used to indicate a pending deletion
 o getDeletionContext
 public GraphicContext getDeletionContext()
Get the GraphicContext to use when an element is to be deleted.

Returns:
the current GraphicContext used to indicate a pending deletion
 o setGroupingContexts
 public Vector setGroupingContexts(Vector contexts)
Set the list of GraphicContexts to use when indicating groupings of elements.

Parameters:
contexts - the Vector of GraphicContexts to use when indicating groupings of elements
Returns:
the previous Vector of GraphicContexts used when indicating groupings of elements
 o addGroupingContext
 public GraphicContext addGroupingContext(GraphicContext gc)
Add a GraphicContext to the list of GraphicContexts used when indicating groupings of elements.

Parameters:
gc - the GraphicContext to be added
Returns:
the GraphicContext that was added (which is a clone of the supplied context)
 o getGroupingContextsSize
 public int getGroupingContextsSize()
Get the size of the list of GraphicContexts used to indicate groupings of elements.

Returns:
the size of the grouping context list
 o getGroupingContextAt
 public GraphicContext getGroupingContextAt(int slot)
Get a specific GraphicContext from the list of GraphicContexts used to indicate groupings of elements.

Parameters:
slot - the slot number of the element in the list to return
Returns:
the requested GraphicContext or null if there is no such list element
 o setCurrent
 public Element setCurrent(Element newValue)
Set the supplied element as the current element of the graph. A call to AppObject.setCurrent(boolean) is triggered also.

Parameters:
newValue - the element to set as the current element
Returns:
the element that had been marked as the current element
See Also:
setCurrent
 o getCurrent
 public Element getCurrent()
Get the element marked as the current element.

Returns:
the graph element marked as the current element
 o replaceContents
 public void replaceContents(Graph demon)
Replace all aspects of the current graph with the supplied graph.

Parameters:
demon - the graph taking possession of this graph.

All Packages  Class Hierarchy  This Package  Previous  Next  Index