scale.common
Class DisplayGraph

java.lang.Object
  extended by scale.common.DisplayGraph
Direct Known Subclasses:
DaVinci, SGD, Vcg

public abstract class DisplayGraph
extends java.lang.Object

All tools used to display Scale graphs must extend this class.

$Id: DisplayGraph.java,v 1.31 2007-08-27 18:26:25 burrill Exp $

Copyright 2008 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.

The class instances that are displayed must adhere to the DisplayNode interface.

The sequence to using a display graph is

  1. Create a DisplayGraph instance
  2. Start a new graph display using newGraph()
  3. Add the nodes and edges using addEdge() and addNode().
  4. Disply the graphical window using openWindow()
  5. Repeat steps 2 through 4 as needed.
  6. Before terminating the process call interact()

Both graph files and GUI instantiations may be generated by classes derived from this base class.

Graphical Displays

It is important that every program, that creates a DisplayGraph instance, call the interact() method and use System.exit() to terminate. The graphical display class may create additional threads which may not terminate when all of the windows are closed. Thus a simple return from the main() method will not necessarily terminate the process. The interact() method should be programmed to return only when all the windows are closed. Then, the sequence

    display.interact();
    System.exit(0);
 
will guarantee proper termination of the complete process.

Graph Files

When the derived class generates a file instead of a display, it must still implement the same methods. However, the interact and closeWindow methods do not need to do anything other than just return. The file containing the graphing commands should be created and closed by the openWindow method.

See Also:
DisplayNode

Field Summary
static int DISPLAY_EDGE_LABELS
          Grap attribute: display edge labels.
protected static java.lang.String outputPath
           
static int SHOW_ANNO
          Display annotations.
static int SHOW_CDG
          Display control dependence.
static int SHOW_CLEF
          Display Clef types & declarations.
static int SHOW_DD
          Display data dependence relations.
static int SHOW_DEFUSE
          Display def-use links.
static int SHOW_DOM
          Display dominance relations.
static int SHOW_EXPR
          Display expressions - both high & low.
static int SHOW_EXPR_MASK
          Mask for SHOW_EXPR, SHOW_LOW_EXPR, SHOW_HIGH_EXPR.
static int SHOW_HIGH_EXPR
          Display high expressions only.
static int SHOW_LOW_EXPR
          Display low expressions only.
static int SHOW_MAYUSE
          Display may-use, may-def links.
static int SHOW_PDOM
          Display post dominance relations.
static int SHOW_TYPE
          Display Clef types & declarations.
 
Constructor Summary
DisplayGraph()
           
 
Method Summary
protected  void addDisplayString(java.lang.String v, java.lang.StringBuffer buf)
          Convert a string to a form suitable for display and append it to the StringBuffer.
abstract  void addEdge(DisplayNode n1, DisplayNode n2, DColor color, DEdge edgeAttributes, java.lang.Object edgeInfo)
          Add an edge to the graph from node n1 to node n2.
abstract  void addNode(DisplayNode n)
          Add a node to the graph.
abstract  void closeWindow(java.lang.String context)
          This closes an existing visualization window.
static DisplayGraph getVisualizer()
          Return the current visualizer or null if none.
static void initColors()
          Generate the java.awt.Color values for the colors array.
abstract  void interact()
          Respond to interative events with this display.
abstract  void newGraph(java.lang.String context, boolean top)
          Initialize for a new graph.
abstract  void openWindow(java.lang.String context, java.lang.String title, int graphAttributes)
          This opens a new visualization window.
static void setOutputPath(java.lang.String path)
          Specify the path to use when creating graphic display files.
static void setVisualizer(DisplayGraph v)
          Make the specified DisplayGraph available to all parts of the process.
abstract  void terminate()
          Terminates the visualizer process.
abstract  boolean visited(DisplayNode n)
          Return true if the node has been processed.
abstract  boolean windowExists(java.lang.String context)
          Return true if the window for the given context still exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISPLAY_EDGE_LABELS

public static final int DISPLAY_EDGE_LABELS
Grap attribute: display edge labels.

See Also:
Constant Field Values

SHOW_DEFUSE

public static final int SHOW_DEFUSE
Display def-use links.

See Also:
Constant Field Values

SHOW_MAYUSE

public static final int SHOW_MAYUSE
Display may-use, may-def links.

See Also:
Constant Field Values

SHOW_CLEF

public static final int SHOW_CLEF
Display Clef types & declarations.

See Also:
Constant Field Values

SHOW_TYPE

public static final int SHOW_TYPE
Display Clef types & declarations.

See Also:
Constant Field Values

SHOW_ANNO

public static final int SHOW_ANNO
Display annotations.

See Also:
Constant Field Values

SHOW_EXPR

public static final int SHOW_EXPR
Display expressions - both high & low.

See Also:
Constant Field Values

SHOW_LOW_EXPR

public static final int SHOW_LOW_EXPR
Display low expressions only.

See Also:
Constant Field Values

SHOW_HIGH_EXPR

public static final int SHOW_HIGH_EXPR
Display high expressions only.

See Also:
Constant Field Values

SHOW_DD

public static final int SHOW_DD
Display data dependence relations.

See Also:
Constant Field Values

SHOW_DOM

public static final int SHOW_DOM
Display dominance relations.

See Also:
Constant Field Values

SHOW_PDOM

public static final int SHOW_PDOM
Display post dominance relations.

See Also:
Constant Field Values

SHOW_CDG

public static final int SHOW_CDG
Display control dependence.

See Also:
Constant Field Values

SHOW_EXPR_MASK

public static final int SHOW_EXPR_MASK
Mask for SHOW_EXPR, SHOW_LOW_EXPR, SHOW_HIGH_EXPR.

See Also:
Constant Field Values

outputPath

protected static java.lang.String outputPath
Constructor Detail

DisplayGraph

public DisplayGraph()
Method Detail

setVisualizer

public static void setVisualizer(DisplayGraph v)
Make the specified DisplayGraph available to all parts of the process. If a visualizer was already set, terminate it.


getVisualizer

public static DisplayGraph getVisualizer()
Return the current visualizer or null if none.


setOutputPath

public static void setOutputPath(java.lang.String path)
Specify the path to use when creating graphic display files.


initColors

public static void initColors()
Generate the java.awt.Color values for the colors array.


newGraph

public abstract void newGraph(java.lang.String context,
                              boolean top)
Initialize for a new graph. Only one graph can be created at a time but multiple graphs can be displayed using just one DisplayGraph instance.

Parameters:
context - is the name associated with the graph
top - if true places the root node at the top of the display

addEdge

public abstract void addEdge(DisplayNode n1,
                             DisplayNode n2,
                             DColor color,
                             DEdge edgeAttributes,
                             java.lang.Object edgeInfo)
Add an edge to the graph from node n1 to node n2. Attributes of the edge are specified by an integer that contains three fields. pattern: solid, dashed, dotted
bitsuse
5-0color
6type: normal, backedge
8-7

Parameters:
n1 - is the first node
n2 - is the second node
edgeAttributes - specifies the color, type, and form of the edge
edgeInfo - is additional information about the edge

addNode

public abstract void addNode(DisplayNode n)
Add a node to the graph. This method should be used only for nodes that are not connected with an edge.

Parameters:
n - is the node

visited

public abstract boolean visited(DisplayNode n)
Return true if the node has been processed.

Parameters:
n - the node to check

terminate

public abstract void terminate()
Terminates the visualizer process.


openWindow

public abstract void openWindow(java.lang.String context,
                                java.lang.String title,
                                int graphAttributes)
This opens a new visualization window. The context string should be unique from that used for any other window. It should be the same string used when calling newGraph().
bitsuse
0display graph edge labels

Parameters:
context - is the user defined string to distinguish between different windows
title - is title for the window
graphAttributes - species attributes for the graph
See Also:
newGraph(java.lang.String, boolean)

closeWindow

public abstract void closeWindow(java.lang.String context)
This closes an existing visualization window. The context string should be unique from that used for any other window. It should be the same string used when calling newGraph().

Parameters:
context - is the user defined string to distinguish between different windows
See Also:
newGraph(java.lang.String, boolean)

windowExists

public abstract boolean windowExists(java.lang.String context)
Return true if the window for the given context still exists.


interact

public abstract void interact()
Respond to interative events with this display. The method terminates when the display is terminated.


addDisplayString

protected void addDisplayString(java.lang.String v,
                                java.lang.StringBuffer buf)
Convert a string to a form suitable for display and append it to the StringBuffer. For example, a double quote (") is converted to "\"" and "\0" is converted to "\\0".

Parameters:
v - the original string