weka.gui.treevisualizer
Class PlaceNode2

java.lang.Object
  extended byweka.gui.treevisualizer.PlaceNode2
All Implemented Interfaces:
NodePlace

public class PlaceNode2
extends java.lang.Object
implements NodePlace

This class will place the Nodes of a tree.

It will place these nodes so that they fall at evenly below their parent. It will then go through and look for places where nodes fall on the wrong side of other nodes when it finds one it will trace back up the tree to find the first common sibling group these two nodes have And it will adjust the spacing between these two siblings so that the two nodes no longer overlap. This is nasty to calculate with , and takes a while with the current algorithm I am using to do this.

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

Nested Class Summary
private  class PlaceNode2.Ease
          An inner class used to report information about any tangles found.
private  class PlaceNode2.Group
          Inner class for containing the grouping data.
private  class PlaceNode2.Level
          Inner class for containing the level data.
 
Field Summary
private  int m_groupNum
          The Number of groups the tree has
private  PlaceNode2.Group[] m_groups
          An array that lists the groups and information about them.
private  int m_levelNum
          The number of levels the group tree has
private  PlaceNode2.Level[] m_levels
          An array that lists the levels and information about them.
private  double m_yRatio
          The space each row will take up.
 
Constructor Summary
PlaceNode2()
           
 
Method Summary
private  void groupBuild(Node r)
          This starts to create the information about the sibling groups.
private  void groupFind(Node r, int pg)
          This is called to build the rest of the grouping information.
private  void moveSubtree(int n, double o)
          This will recursively shift a sub there to be centered about a particular value.
private  void nodeY(Node r)
          This will set all of the children node of a particular node to their height.
private  PlaceNode2.Ease overlap(int l)
          This will find an overlap and then return information about that overlap
 void place(Node r)
          The Funtion to call to have the nodes arranged.
private  void scaleByInd()
          This scales the x values to between 0 and 1 for each individual line rather than doing them all at once.
private  void scaleByMax()
          This scales all the x values to be between 0 and 1.
private  void untangle()
          This will untangle the nodes in the tree so that they fall on the correct side of each other.
private  void untangle2()
          This untangles the nodes so that they will will fall on the correct side of the other nodes along their row.
private  void xPlacer(int start)
          This will set initial places for the x coord of the nodes.
private  void xShift(int n)
          This will shift a group of nodes to be aligned under their parent.
private  void yPlacer()
          This function sets up the height of each node, and also fills the levels array with information about what the start and end groups on that level are.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_yRatio

private double m_yRatio
The space each row will take up.


m_groups

private PlaceNode2.Group[] m_groups
An array that lists the groups and information about them.


m_levels

private PlaceNode2.Level[] m_levels
An array that lists the levels and information about them.


m_groupNum

private int m_groupNum
The Number of groups the tree has


m_levelNum

private int m_levelNum
The number of levels the group tree has

Constructor Detail

PlaceNode2

public PlaceNode2()
Method Detail

place

public void place(Node r)
The Funtion to call to have the nodes arranged.

Specified by:
place in interface NodePlace
Parameters:
r - The top node of the tree to arrange.

xPlacer

private void xPlacer(int start)
This will set initial places for the x coord of the nodes.

Parameters:
start - The `number for the first group to start on (I think).

xShift

private void xShift(int n)
This will shift a group of nodes to be aligned under their parent.

Parameters:
n - The group number to shift

scaleByMax

private void scaleByMax()
This scales all the x values to be between 0 and 1.


scaleByInd

private void scaleByInd()
This scales the x values to between 0 and 1 for each individual line rather than doing them all at once.


untangle2

private void untangle2()
This untangles the nodes so that they will will fall on the correct side of the other nodes along their row.


moveSubtree

private void moveSubtree(int n,
                         double o)
This will recursively shift a sub there to be centered about a particular value.

Parameters:
n - The first group in the sub tree.
o - The point to start shifting the subtree.

untangle

private void untangle()
This will untangle the nodes in the tree so that they fall on the correct side of each other.


overlap

private PlaceNode2.Ease overlap(int l)
This will find an overlap and then return information about that overlap

Parameters:
l - The level to start on.
Returns:
null if there was no overlap , otherwise an object containing the group number that overlaps (only need one) how much they overlap by, and the level they overlap on.

yPlacer

private void yPlacer()
This function sets up the height of each node, and also fills the levels array with information about what the start and end groups on that level are.


nodeY

private void nodeY(Node r)
This will set all of the children node of a particular node to their height.

Parameters:
r - The parent node of the children to set their height.

groupBuild

private void groupBuild(Node r)
This starts to create the information about the sibling groups. As more groups are created the for loop in this will check those groups for lower groups.

Parameters:
r - The top node.

groupFind

private void groupFind(Node r,
                       int pg)
This is called to build the rest of the grouping information.

Parameters:
r - The parent of the group.
pg - The number for the parents group.