scale.visual
Class DaVinci

java.lang.Object
  extended by scale.common.DisplayGraph
      extended by scale.visual.DaVinci

public class DaVinci
extends DisplayGraph

This class implements methods to generate commands to display a graph using daVinci.

$Id: DaVinci.java,v 1.40 2007-10-04 19:58:40 burrill Exp $

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

This wrapper uses the daVinci program to provide an Xwindow display of a graph. This wrapper assumes a single tasking environment, but supports multiple graphs.

A user of this class will in general, have the following code:

  1. visualizer = new DaVinci();
  2. visualizer.newGraph(name, top);
  3. Called once per graph.

  4. create the graph using visualizer instance
  5. visualizer.openWindow(name, title);
The openWindow() method must be called before newGraph() is called again.


Field Summary
 
Fields inherited from class scale.common.DisplayGraph
DISPLAY_EDGE_LABELS, outputPath, SHOW_ANNO, SHOW_CDG, SHOW_CLEF, SHOW_DD, SHOW_DEFUSE, SHOW_DOM, SHOW_EXPR, SHOW_EXPR_MASK, SHOW_HIGH_EXPR, SHOW_LOW_EXPR, SHOW_MAYUSE, SHOW_PDOM, SHOW_TYPE
 
Constructor Summary
DaVinci()
           
 
Method Summary
 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.
 void addNode(DisplayNode n)
          Add a node to the graph.
protected  boolean checkOk()
          Checks input from visualizer to see if it has returned an "ok".
 void closeWindow(java.lang.String context)
          This closes an existing new visualization window.
 java.lang.String dashedEdgeAttr()
          Return attribute for dashed edges.
 java.lang.String dottedEdgeAttr()
          Retrn attribute for dotted edges.
protected  java.lang.String getContext()
          Reads line from input which is expected to be a context indicator and parses it to extract the context.
 java.lang.Object getLocation(java.lang.String context, java.lang.String key)
          Return the node or edge represented by the key in the specified graph.
 void interact()
          Respond to interative events with this display.
 void newGraph(java.lang.String context, boolean top)
          Initialize for a new graph.
 void openWindow(java.lang.String context, java.lang.String title, int graphAttributes)
          This opens a new visualization window.
protected  boolean processResponse(java.lang.String context)
          High level method which handles reading input until an acknowledgement is received from the expected window.
protected  void showMessage(java.lang.String context, java.lang.String message)
          Show a message in the window.
 void terminate()
          Terminates the visualizer process.
 boolean visited(DisplayNode n)
          Return true if the node has been processed.
 boolean windowExists(java.lang.String context)
          Return true if the window for the given context still exists.
 
Methods inherited from class scale.common.DisplayGraph
addDisplayString, getVisualizer, initColors, setOutputPath, setVisualizer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DaVinci

public DaVinci()
Method Detail

newGraph

public void newGraph(java.lang.String context,
                     boolean top)
Initialize for a new graph. Only one graph can be created at a time.

Specified by:
newGraph in class DisplayGraph
Parameters:
context - is the name associated with the graph
top - if true places the root node at the top of the display

dottedEdgeAttr

public java.lang.String dottedEdgeAttr()
Retrn attribute for dotted edges.


dashedEdgeAttr

public java.lang.String dashedEdgeAttr()
Return attribute for dashed edges.


visited

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

Specified by:
visited in class DisplayGraph
Parameters:
n - is the node to check

addNode

public 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.

Specified by:
addNode in class DisplayGraph
Parameters:
n - is the node

addEdge

public 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

Specified by:
addEdge in class DisplayGraph
Parameters:
n1 - is the first node
n2 - is the second node
color - specifies the edge color
edgeAttributes - specifies the type, and form of the edge
edgeInfo - is additional information about the edge

getLocation

public java.lang.Object getLocation(java.lang.String context,
                                    java.lang.String key)
Return the node or edge represented by the key in the specified graph.


terminate

public void terminate()
Terminates the visualizer process.

Specified by:
terminate in class DisplayGraph

openWindow

public 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.

Specified by:
openWindow in class DisplayGraph
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:
DisplayGraph.newGraph(java.lang.String, boolean)

closeWindow

public void closeWindow(java.lang.String context)
This closes an existing new visualization window. The context string should be unique from that used for any other window.

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

checkOk

protected boolean checkOk()
Checks input from visualizer to see if it has returned an "ok".

To avoid problems if user manually terminates the visualization tool, this method returns true if the input is null. Null input occurs when the pipe is broken.

Returns:
true if ok response

getContext

protected java.lang.String getContext()
Reads line from input which is expected to be a context indicator and parses it to extract the context.

Returns:
the context

processResponse

protected boolean processResponse(java.lang.String context)
High level method which handles reading input until an acknowledgement is received from the expected window.

This method currently doesn't handle errors well. It simply returns whether or not it encounters an error.

This method may have to be made public once we support mouse input.

Parameters:
context - indicates from which window input is expected
Returns:
true if the response was not recognized

showMessage

protected void showMessage(java.lang.String context,
                           java.lang.String message)
Show a message in the window.

Parameters:
context - indicates to which window the graph is to be drawn
message - is the message to display

windowExists

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

Specified by:
windowExists in class DisplayGraph

interact

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

Specified by:
interact in class DisplayGraph