Class BNode

java.lang.Object
  extended byciips.animation.Drawable
      extended byciips.animation.tree.TreeNode
          extended byBNode
All Implemented Interfaces:
ciips.animation.DrawingObj

public class BNode
extends ciips.animation.tree.TreeNode


Field Summary
protected  java.awt.Font bigFont
           
protected  BNode[] child
          subtree array
protected  int height
          height of node
protected  java.awt.Color highlightColor
           
protected  java.awt.Font hugeFont
           
protected  int[] key
          key array
protected  java.awt.Color labelColor
           
protected  int max_children
          maximum number of children
protected  int max_key
          maximum number of key
protected  java.awt.Color nodeColor
           
protected static Nodespace nodespace
           
 
Fields inherited from class ciips.animation.tree.TreeNode
DEF_TREENODE_COL, depth, highlightLeft, highlightRight, last_dx, last_dy, left, right, weight
 
Fields inherited from class ciips.animation.Drawable
colour, DEFAULT_START, grey, highlight, label, x, y
 
Constructor Summary
BNode(int max_key)
          Create a new leaf node with multiple weight and children.
BNode(int weight, int max_key)
          Create a new node with multiple weight and children with weight to insert
 
Method Summary
 void appendKey(int newkey)
          Adds a new key in appropriate position
 void deleteKey(int index)
          Delete specific key(at index) return current key count
 void draw(java.awt.Graphics g)
          This method draws the node on the corresponding graphical context normally passed in from the drawing panel.
 void drawEdge(java.awt.Graphics g, BNode child)
           
 void expandSize(float factor)
          Adjust the node size by a factor
 int findChildPosition(int specifickey)
          find child position which has spechfic key
 int findKey(int specifickey)
          Find specific key in this Node Return founded position(index) return -1, if didn't find
 java.lang.String getAllKeyString()
          return all key as string
 BNode getChild(int index)
          return child at index
 int getChildCount()
          return actual child number
 java.awt.Color getColour()
           
 java.awt.Dimension getEdgeXY(BNode child)
           
 int getFilledkeywidth()
          return actual node size which was filled by inserted key
 java.awt.Dimension getHeadXY()
           
 int getHeight()
          return height in the tree
 int getKey(int index)
          return key at index
 int getKeyCount()
          return actual key number
 java.lang.String getLabel()
           
 int getMaxKey()
          Get Maximum key in this Node
 java.awt.Dimension getNodesize()
          return maximum node size
 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.
 void insertKey(int specifickey, BNode left, BNode right)
          insert specifickey and set two children on the left of weight and right of weight.
 boolean isLeaf()
          return true if it is leaf
 boolean isSentinel(int index)
          return true if child is null at index
 void move(int x, int y)
          Move the node and all its branches based on the parameters.
 void moveTreeNode(int dx, int dy)
          Move the tree starting with node dx pixels to the right and dy pixels down.
 void setChild(BNode newnode)
          Adds a new node
 void setChild(int index, BNode newnode)
          Adds a new node at index
 void setColour(java.awt.Color x)
           
 void setHighlight(java.awt.Graphics g)
           
 void setKey(int index, int newkey)
          Adds a new key at index
 void setKeyCount(int key_cnt)
          set actual key number
 void setLabel(java.lang.String label)
           
 void setLabelColour(java.awt.Color x)
           
 void setNodespace(Nodespace nodespace)
           
 void setPosition(int x, int y, int dx, int dy)
          Start at a node and set the positions for the sub-tree elements
 void setPosition(int x, int y, int dx, int dy, int height)
          Start at a node and set the positions for the sub-tree elements
 java.lang.String toString()
          return all key and height as string
 void Unhighlight_Node()
           
 
Methods inherited from class ciips.animation.tree.TreeNode
getDepth, getLeft, getLeftTreeNode, getNodeSize, getRight, getRightTreeNode, getWeight, setDepth, setLeft, setLeftTreeNode, setRight, setRightTreeNode, setWeight
 
Methods inherited from class ciips.animation.Drawable
getCurrentColour, getX, getY, setGrey, setHighlight, setText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

key

protected int[] key
key array


child

protected BNode[] child
subtree array


max_children

protected int max_children
maximum number of children


max_key

protected int max_key
maximum number of key


height

protected int height
height of node


nodespace

protected static Nodespace nodespace

nodeColor

protected java.awt.Color nodeColor

labelColor

protected java.awt.Color labelColor

highlightColor

protected java.awt.Color highlightColor

hugeFont

protected java.awt.Font hugeFont

bigFont

protected java.awt.Font bigFont
Constructor Detail

BNode

public BNode(int max_key)
Create a new leaf node with multiple weight and children.


BNode

public BNode(int weight,
             int max_key)
Create a new node with multiple weight and children with weight to insert

Method Detail

insertKey

public void insertKey(int specifickey,
                      BNode left,
                      BNode right)
insert specifickey and set two children on the left of weight and right of weight.


setKey

public void setKey(int index,
                   int newkey)
Adds a new key at index


appendKey

public void appendKey(int newkey)
Adds a new key in appropriate position


setNodespace

public void setNodespace(Nodespace nodespace)

setChild

public void setChild(BNode newnode)
Adds a new node


setChild

public void setChild(int index,
                     BNode newnode)
Adds a new node at index


getLabel

public java.lang.String getLabel()

getMaxKey

public int getMaxKey()
Get Maximum key in this Node


findKey

public int findKey(int specifickey)
Find specific key in this Node Return founded position(index) return -1, if didn't find


findChildPosition

public int findChildPosition(int specifickey)
find child position which has spechfic key


deleteKey

public void deleteKey(int index)
Delete specific key(at index) return current key count


getChildCount

public int getChildCount()
return actual child number


getChild

public BNode getChild(int index)
return child at index


getKeyCount

public int getKeyCount()
return actual key number


setKeyCount

public void setKeyCount(int key_cnt)
set actual key number


isLeaf

public boolean isLeaf()
return true if it is leaf


isSentinel

public boolean isSentinel(int index)
return true if child is null at index


getNodesize

public java.awt.Dimension getNodesize()
return maximum node size


getFilledkeywidth

public int getFilledkeywidth()
return actual node size which was filled by inserted key


getHeight

public int getHeight()
return height in the tree


getAllKeyString

public java.lang.String getAllKeyString()
return all key as string


toString

public java.lang.String toString()
return all key and height as string


getKey

public int getKey(int index)
return key at index


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


setPosition

public void setPosition(int x,
                        int y,
                        int dx,
                        int dy,
                        int height)
Start at a node and set the positions for the sub-tree elements


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.

moveTreeNode

public void moveTreeNode(int dx,
                         int dy)
Move the tree starting with node dx pixels to the right and dy pixels down.

Parameters:
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.

setLabel

public void setLabel(java.lang.String label)

setColour

public void setColour(java.awt.Color x)

getColour

public java.awt.Color getColour()

setLabelColour

public void setLabelColour(java.awt.Color x)

setHighlight

public void setHighlight(java.awt.Graphics g)

Unhighlight_Node

public void Unhighlight_Node()

expandSize

public void expandSize(float factor)
Adjust the node size by a factor

Parameters:
factor - - expansion factor: factor > 1.0 => expansion, factor < 1.0 => shrinkage

drawEdge

public void drawEdge(java.awt.Graphics g,
                     BNode child)

getHeadXY

public java.awt.Dimension getHeadXY()

getEdgeXY

public java.awt.Dimension getEdgeXY(BNode child)

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.