ciips.animation.tree
Class BasicNode

java.lang.Object
  |
  +--ciips.animation.tree.BasicNode
Direct Known Subclasses:
MultiNode

public class BasicNode
extends java.lang.Object


Field Summary
protected  int depth
           
protected  int diff_x
           
protected  int diff_y
           
 boolean highlight
           
protected  boolean highlightNode
           
protected  java.lang.String label
           
protected  java.awt.Color labelColor
           
 java.awt.Dimension node_dim
           
protected  java.awt.Color nodeColor
           
protected  java.lang.Object weight
           
protected  int x
           
protected  int y
           
 
Constructor Summary
BasicNode()
          Create a new leaf node with label and weight as specified in the parameters with multiple children.
BasicNode(java.lang.String label, java.lang.Object weight)
           
 
Method Summary
 void displace(int dx, int dy)
          Move the tree starting with node dx pixels to the right and dy pixels down.
 void draw(java.awt.Graphics g)
          This method draws the node on the corresponding graphical context normally passed in from the drawing panel.
 java.lang.Object getData()
          Get the weight of this node.
 int getDepth()
          Get the depth of his node.
 boolean getHighlight()
           
 java.lang.String getLabel()
          Get the label of this node.
 int getX()
          Get the left most position of the node.
 int getY()
          Get the top most position of the node.
 void initColors(java.awt.Color nodeColor)
          Set the color of the node.
 void initFonts(java.awt.Font hugeFont, java.awt.Font bigFont)
          Assign some font instances to reduce initialization over during redraw.
 boolean isLeaf()
          Check if this node is a leaf node.
 void move(int x, int y)
          Move the node and all its branches based on the parameters.
 void setColour(java.awt.Color x)
           
 void setDepth(int depth)
          Sets the depth of this node corresponding to the root node of the tree.
 void setHighlight()
          Set the highlight condition of a node
 void setLabel(java.lang.String label)
          Set the label of this node.
 void setLabelColour(java.awt.Color x)
           
 void setPosition(int x, int y, int dx, int dy)
          Start at a node and set the positions for the sub-tree elements dx is the distance between the first and the last child nodes in x direction dy is the distance between the parent and the child node in y direction
 void setWeight(java.lang.Object weight)
          Set the weight of this node.
 void setX(int x)
          Sets the x coordinate of the top-left corner of the node
 void setXY(int x, int y)
           
 void setY(int y)
          Sets the y coordinate of the top-left corner of the node
 void unHighlight()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

label

protected java.lang.String label

weight

protected java.lang.Object weight

x

protected int x

y

protected int y

depth

protected int depth

highlightNode

protected boolean highlightNode

nodeColor

protected java.awt.Color nodeColor

labelColor

protected java.awt.Color labelColor

highlight

public boolean highlight

node_dim

public java.awt.Dimension node_dim

diff_y

protected int diff_y

diff_x

protected int diff_x
Constructor Detail

BasicNode

public BasicNode()
Create a new leaf node with label and weight as specified in the parameters with multiple children.
Parameters:
label - The label of the new node.
weight - The weight of the new node.

BasicNode

public BasicNode(java.lang.String label,
                 java.lang.Object weight)
Method Detail

setWeight

public void setWeight(java.lang.Object weight)
Set the weight of this node.
Parameters:
weight - The weight to be assigned to this node.

setLabel

public void setLabel(java.lang.String label)
Set the label of this node.
Parameters:
label - The label to be assigned to this node.

getData

public java.lang.Object getData()
Get the weight of this node.
Returns:
Weight of this node.

getLabel

public java.lang.String getLabel()
Get the label of this node.
Returns:
Label of this node.

isLeaf

public boolean isLeaf()
Check if this node is a leaf node.
Returns:
true if the node is a leaf node; false otherwise.

setX

public void setX(int x)
Sets the x coordinate of the top-left corner of the node

setY

public void setY(int y)
Sets the y coordinate of the top-left corner of the node

getX

public int getX()
Get the left most position of the node.
Returns:
The x coordinates of the top-left corner of the node

getY

public int getY()
Get the top most position of the node.
Returns:
The y coordinates of the top-left corner of the node

getDepth

public int getDepth()
Get the depth of his node.
Returns:
The depth of this node in a tree.

setPosition

public void setPosition(int x,
                        int y,
                        int dx,
                        int dy)
Start at a node and set the positions for the sub-tree elements dx is the distance between the first and the last child nodes in x direction dy is the distance between the parent and the child node in y direction

setDepth

public void setDepth(int depth)
Sets the depth of this node corresponding to the root node of the tree.
Parameters:
depth - Depth of the node.

move

public void move(int x,
                 int y)
Move the node and all its branches based on the parameters.
Parameters:
x - The horizontal destination position of this node.
y - The vertical destination position of this node.

setXY

public void setXY(int x,
                  int y)

displace

public void displace(int dx,
                     int dy)
Move the tree starting with node dx pixels to the right and dy pixels down.
Parameters:
node - The root node of the tree to be moved.
dx - The change in x direction.
dy - The change in y direction.

initFonts

public void initFonts(java.awt.Font hugeFont,
                      java.awt.Font bigFont)
Assign some font instances to reduce initialization over during redraw.

initColors

public void initColors(java.awt.Color nodeColor)
Set the color of the node.
Parameters:
nodeColor - new color of the node.

setColour

public void setColour(java.awt.Color x)

setLabelColour

public void setLabelColour(java.awt.Color x)

setHighlight

public void setHighlight()
Set the highlight condition of a node

unHighlight

public void unHighlight()

getHighlight

public boolean getHighlight()

draw

public void draw(java.awt.Graphics g)
This method draws the node on the corresponding graphical context normally passed in from the drawing panel.