weka.gui.treevisualizer
Class TreeBuild

java.lang.Object
  extended byweka.gui.treevisualizer.TreeBuild

public class TreeBuild
extends java.lang.Object

This class will parse a dotty file and construct a tree structure from it with Edge's and Node's

Version:
$Revision: 1.3 $
Author:
Malcolm Ware (mfw4@cs.waikato.ac.nz)

Nested Class Summary
private  class TreeBuild.InfoObject
          This is an internal class used to keep track of the info for the objects before they are actually created.
 
Field Summary
private  java.util.Vector m_aEdges
          An array with all the edges initially constructed into it.
private  java.util.Vector m_aNodes
          An array with all the nodes initially constructed into it.
private  java.util.Hashtable m_colorTable
          A table containing all the colors.
private  boolean m_digraph
          true if it is a digraph.
private  java.util.Vector m_edges
          An arry containing a structure that describes the edge without actually creating it.
private  TreeBuild.InfoObject m_edObj
          An object setup to take edge data.
private  java.lang.String m_graphName
          The name of the tree, Not in use.
private  TreeBuild.InfoObject m_grObj
          An object setup to take graph data.
private  java.util.Vector m_nodes
          An array containing a structure that describes the node without actually creating it.
private  TreeBuild.InfoObject m_noObj
          An object setup to take node data.
private  java.io.StreamTokenizer m_st
          The stream to parse.
 
Constructor Summary
TreeBuild()
          Upon construction this will only setup the color table for quick reference of a color.
 
Method Summary
private  void alterSyntax()
          This is the alternative syntax for the tokenizer.
private  void attrList(TreeBuild.InfoObject a)
          This will parse all the items in the attrib list for an object.
private  void attrStmt()
          This will deal specifically with a new object such as graph , node , edge.
 Node create(java.io.Reader t)
          This will build A node structure from the dotty format passed.
private  void edgeStmt(java.lang.String i)
          This will get the target of the edge.
private  Node generateStructures()
          This will go through all the found Nodes and Edges build instances of these and link them together.
private  java.lang.Integer getShape(java.lang.String sh)
          This will convert the shape string to an int representing that shape.
private  java.lang.Integer getStyle(java.lang.String sty)
          Converts the string representing the fill style int oa number representing it.
private  void graph()
          Parses the top of the dotty stream that has the graph information.
private  void nextToken(java.lang.String r)
          This will parse the next token out of the stream and check for certain conditions.
private  void nodeId(java.lang.String s, int t)
          Generates a new InfoObject with the specified name and either does further processing if applicable Otherwise it is an edge and will deal with that.
private  void setSyntax()
          This will setup the syntax for the tokenizer so that it parses the string properly.
private  void stmtList()
          This is one of the states, this one is where new items can be defined or the structure can end.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_graphName

private java.lang.String m_graphName
The name of the tree, Not in use.


m_aNodes

private java.util.Vector m_aNodes
An array with all the nodes initially constructed into it.


m_aEdges

private java.util.Vector m_aEdges
An array with all the edges initially constructed into it.


m_nodes

private java.util.Vector m_nodes
An array containing a structure that describes the node without actually creating it.


m_edges

private java.util.Vector m_edges
An arry containing a structure that describes the edge without actually creating it.


m_grObj

private TreeBuild.InfoObject m_grObj
An object setup to take graph data.


m_noObj

private TreeBuild.InfoObject m_noObj
An object setup to take node data.


m_edObj

private TreeBuild.InfoObject m_edObj
An object setup to take edge data.


m_digraph

private boolean m_digraph
true if it is a digraph. (note that this can't build digraphs).


m_st

private java.io.StreamTokenizer m_st
The stream to parse.


m_colorTable

private java.util.Hashtable m_colorTable
A table containing all the colors.

Constructor Detail

TreeBuild

public TreeBuild()
Upon construction this will only setup the color table for quick reference of a color.

Method Detail

create

public Node create(java.io.Reader t)
This will build A node structure from the dotty format passed. Don't send a dotty format with multiple parents per node, and ensure that there is 1 and only 1 node with no parent.

Parameters:
t - The reader with the dotty string to be read.
Returns:
The top node of the tree structure (the last node with no parent).

generateStructures

private Node generateStructures()
This will go through all the found Nodes and Edges build instances of these and link them together.

Returns:
The node with no parent (the top of the tree).

getShape

private java.lang.Integer getShape(java.lang.String sh)
This will convert the shape string to an int representing that shape.

Parameters:
sh - The name of the shape.
Returns:
An Integer representing the shape.

getStyle

private java.lang.Integer getStyle(java.lang.String sty)
Converts the string representing the fill style int oa number representing it.

Parameters:
sty - The name of the style.
Returns:
An Integer representing the shape.

setSyntax

private void setSyntax()
This will setup the syntax for the tokenizer so that it parses the string properly.


alterSyntax

private void alterSyntax()
This is the alternative syntax for the tokenizer.


nextToken

private void nextToken(java.lang.String r)
This will parse the next token out of the stream and check for certain conditions.

Parameters:
r - The error string to print out if something goes wrong.

graph

private void graph()
Parses the top of the dotty stream that has the graph information.


stmtList

private void stmtList()
This is one of the states, this one is where new items can be defined or the structure can end.


attrStmt

private void attrStmt()
This will deal specifically with a new object such as graph , node , edge.


nodeId

private void nodeId(java.lang.String s,
                    int t)
Generates a new InfoObject with the specified name and either does further processing if applicable Otherwise it is an edge and will deal with that.

Parameters:
s - The ID string.
t - Not sure!.

edgeStmt

private void edgeStmt(java.lang.String i)
This will get the target of the edge.

Parameters:
i - The source of the edge.

attrList

private void attrList(TreeBuild.InfoObject a)
This will parse all the items in the attrib list for an object.

Parameters:
a - The object that the attribs apply to.