weka.gui.treevisualizer
Class Node

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

public class Node
extends java.lang.Object

This class records all the data about a particular node for displaying.

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

Field Summary
private  int m_backstyle
          The fill mode for the node (not in use).
private  double m_center
          The center of the node (between 0 and 1).
private  java.util.Vector m_children
          An array containing references to all the child edges.
private  java.awt.Color m_color
          The color of the node.
private  boolean m_cVisible
          true if this nodes descendants are visible (not in use currently).
private  java.lang.String m_data
          A String containing extra information about the node.
private  java.lang.String m_label
          the text for the node.
private  java.util.Vector m_lines
          the text broken up into lines
private  java.util.Vector m_parent
          An array containing references to all the parent edges (only 1 currently).
private  java.lang.String m_refer
          The ID string for this node (used for construction purposes)
private  boolean m_root
          true if this is the top of the tree. ie has no parent
private  int m_shape
          The shape of the node.
private  Instances m_theData
          An Instances variable generated from the data.
private  double m_top
          The top of the node (between 0 and 1).
private  boolean m_visible
          true if this node is visible (not currently in use).
 
Constructor Summary
Node(java.lang.String label, java.lang.String refer, int backstyle, int shape, java.awt.Color color, java.lang.String d)
          This will setup all the values of the node except for its top and center.
 
Method Summary
 void addChild(Edge v)
          Set the value of children.
 void adjustCenter(double v)
          Will increase or decrease the postion of center.
private  void breakupLabel()
          This Will break the node's text up into lines.
private  void childInv(Node r)
          Recursively goes through the tree and sets all the children to invisible, Not the parent though.
private  void childVis(Node r)
          Recursively goes through the tree and sets all the children and the parent to visible.
 double getCenter()
          Get the value of center.
 Edge getChild(int i)
          Get the Edge for the child number 'i'.
 java.awt.Color getColor()
          Get the value of color.
static int getCount(Node r, int n)
          Recursively finds the number of visible nodes there are (this may accidentally count some of the invis nodes).
 boolean getCVisible()
          Get If this node's childs are visible.
static int getGCount(Node r, int n)
          Recursively finds the number of visible groups of siblings there are.
static int getHeight(Node r, int l)
          Recursively finds the number of visible levels there are.
 Instances getInstances()
          This will return the Instances object related to this node.
 java.lang.String getLabel()
          Get the value of label.
 java.lang.String getLine(int n)
          Returns the text String for the specfied line.
 Edge getParent(int i)
          Get the parent edge.
 java.lang.String getRefer()
          Get the value of refer.
 boolean getRoot()
          Get the value of root.
 int getShape()
          Get the value of shape.
 double getTop()
          Get the value of top.
static int getTotalCount(Node r, int n)
          Recursively finds the total number of nodes there are.
static int getTotalGCount(Node r, int n)
          Recursively finds the total number of groups of siblings there are.
static int getTotalHeight(Node r, int l)
          Recursively finds the total number of levels there are.
 boolean getVisible()
          Get the value of visible.
 void setCenter(double v)
          Set the value of center.
 void setColor(java.awt.Color v)
          Set the value of color.
 void setCVisible(boolean v)
          Sets all the children of this node either to visible or invisible
 void setParent(Edge v)
          Set the value of parent.
 void setRefer(java.lang.String v)
          Set the value of refer.
 void setRoot(boolean v)
          Set the value of root.
 void setShape(int v)
          Set the value of shape.
 void setTop(double v)
          Set the value of top.
private  void setVisible(boolean v)
          Set the value of visible.
 java.awt.Dimension stringSize(java.awt.FontMetrics f)
          This will return the width and height of the rectangle that the text will fit into.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_backstyle

private int m_backstyle
The fill mode for the node (not in use).


m_shape

private int m_shape
The shape of the node.


m_color

private java.awt.Color m_color
The color of the node.


m_label

private java.lang.String m_label
the text for the node.


m_lines

private java.util.Vector m_lines
the text broken up into lines


m_center

private double m_center
The center of the node (between 0 and 1).


m_top

private double m_top
The top of the node (between 0 and 1).


m_cVisible

private boolean m_cVisible
true if this nodes descendants are visible (not in use currently).


m_visible

private boolean m_visible
true if this node is visible (not currently in use).


m_root

private boolean m_root
true if this is the top of the tree. ie has no parent


m_parent

private java.util.Vector m_parent
An array containing references to all the parent edges (only 1 currently).


m_children

private java.util.Vector m_children
An array containing references to all the child edges.


m_refer

private java.lang.String m_refer
The ID string for this node (used for construction purposes)


m_data

private java.lang.String m_data
A String containing extra information about the node.


m_theData

private Instances m_theData
An Instances variable generated from the data. Note that if this exists then the string shall be NULL to save space.

Constructor Detail

Node

public Node(java.lang.String label,
            java.lang.String refer,
            int backstyle,
            int shape,
            java.awt.Color color,
            java.lang.String d)
This will setup all the values of the node except for its top and center.

Parameters:
label - The text for the node.
refer - The ID string for this node.
backstyle - The backstyle of this node.
shape - The shape of this node.
color - The color of this node.
Method Detail

getInstances

public Instances getInstances()
This will return the Instances object related to this node. If it has not been allocated then that will be done also.

Returns:
The Instances object.

getCVisible

public boolean getCVisible()
Get If this node's childs are visible.

Returns:
True if the childs are visible.

childVis

private void childVis(Node r)
Recursively goes through the tree and sets all the children and the parent to visible.

Parameters:
r - The current node to set visible.

setCVisible

public void setCVisible(boolean v)
Sets all the children of this node either to visible or invisible

Parameters:
v - True if the children are to be visible

childInv

private void childInv(Node r)
Recursively goes through the tree and sets all the children to invisible, Not the parent though.

Parameters:
r - The current node from whom the children are gonna be set invisible.

getRefer

public java.lang.String getRefer()
Get the value of refer.

Returns:
Value of refer.

setRefer

public void setRefer(java.lang.String v)
Set the value of refer.

Parameters:
v - Value to assign to refer.

getShape

public int getShape()
Get the value of shape.

Returns:
Value of shape.

setShape

public void setShape(int v)
Set the value of shape.

Parameters:
v - Value to assign to shape.

getColor

public java.awt.Color getColor()
Get the value of color.

Returns:
Value of color.

setColor

public void setColor(java.awt.Color v)
Set the value of color.

Parameters:
v - Value to assign to color.

getLabel

public java.lang.String getLabel()
Get the value of label.

Returns:
Value of label.

breakupLabel

private void breakupLabel()
This Will break the node's text up into lines.


stringSize

public java.awt.Dimension stringSize(java.awt.FontMetrics f)
This will return the width and height of the rectangle that the text will fit into.

Parameters:
f - The size info for the Font.
Returns:
A Dimension containing the size of the text.

getLine

public java.lang.String getLine(int n)
Returns the text String for the specfied line.

Parameters:
n - The line wanted.
Returns:
The String corresponding to that line.

getCenter

public double getCenter()
Get the value of center.

Returns:
Value of center.

setCenter

public void setCenter(double v)
Set the value of center.

Parameters:
v - Value to assign to center.

adjustCenter

public void adjustCenter(double v)
Will increase or decrease the postion of center.

Parameters:
v - The amount to increase or decrease center by.

getTop

public double getTop()
Get the value of top.

Returns:
Value of top.

setTop

public void setTop(double v)
Set the value of top.

Parameters:
v - Value to assign to top.

getVisible

public boolean getVisible()
Get the value of visible.

Returns:
Value of visible.

setVisible

private void setVisible(boolean v)
Set the value of visible.

Parameters:
v - Value to assign to visible.

getRoot

public boolean getRoot()
Get the value of root.

Returns:
True if has no parents.

setRoot

public void setRoot(boolean v)
Set the value of root.

Parameters:
v - Value to assign to root.

getParent

public Edge getParent(int i)
Get the parent edge.

Parameters:
i - The parent number to get.
Returns:
The parent edge or NULL if it doesn't exist.

setParent

public void setParent(Edge v)
Set the value of parent.

Parameters:
v - Value to assign to parent.

getChild

public Edge getChild(int i)
Get the Edge for the child number 'i'.

Parameters:
i - The child number to get.
Returns:
The child Edge or NULL if it doesn't exist.

addChild

public void addChild(Edge v)
Set the value of children.

Parameters:
v - Value to assign to children.

getGCount

public static int getGCount(Node r,
                            int n)
Recursively finds the number of visible groups of siblings there are.

Parameters:
r - The current Node upto.
n - The current number of groups there are.
Returns:
The number of groups found so far.

getTotalGCount

public static int getTotalGCount(Node r,
                                 int n)
Recursively finds the total number of groups of siblings there are.

Parameters:
r - The current Node upto.
n - The current number of groups there are.
Returns:
The number of groups found so far.

getCount

public static int getCount(Node r,
                           int n)
Recursively finds the number of visible nodes there are (this may accidentally count some of the invis nodes).

Parameters:
r - The current Node upto.
n - The current number nodes there are.
Returns:
The number of nodes found so far.

getTotalCount

public static int getTotalCount(Node r,
                                int n)
Recursively finds the total number of nodes there are.

Parameters:
r - The current Node upto.
n - The current number nodes there are.
Returns:
The number of nodes found so far.

getHeight

public static int getHeight(Node r,
                            int l)
Recursively finds the number of visible levels there are.

Parameters:
r - The current Node upto.
l - The curent level.
Returns:
The max number of levels found so far.

getTotalHeight

public static int getTotalHeight(Node r,
                                 int l)
Recursively finds the total number of levels there are.

Parameters:
r - The current Node upto.
l - The curent level.
Returns:
The max number of levels found so far.