// This class define the tree node. public class Node { public final static int Black = 0; // constants used to define the public final static int Red = 1; // node color public final static int Left_son = 2; // constants used to identify public final static int Right_son = 3;// the node parent and sons. public final static int Parent = 4; public final static int Bold = 5; // constants used to define public final static int Reg = 6; // the node presentation. private int color; private int key; private Node L,R,P; // L-left son,R-right son,P-parent private int bold; private int LocX; // location of the node on the display private int LocY; // they could change exch time the tree redraw. // constructor create a new node the default color is red // the default appearance (bold) is regular. // initialize the key field. public Node(int k) { color = Red; key = k; L = null; R = null; P = null; bold = Reg; } // constructor for constructing a tree null object, is color // is black. public Node() { color = Black; key = -1; L = null; R = null; P = null; } // This method set the node key. public void setKey(int k) { key = k; } // This method return the node key. public int getKey() { return (key); } // This method set the node color. public void setColor(int c) { if (c == Black) color = Black; else if (c == Red) color = Red; } // This method return the node color. public int getColor() { return (color); } // This method set the node parent or childs acording to the who // parameter. public void setNode(int who,Node n) { switch (who) { case Left_son: L = n; break; case Right_son: R = n; break; case Parent: P = n; break; } } // This method return the node parent or childs acording to the who // parameter. public Node getNode(int who) { switch (who) { case Left_son: return (L); case Right_son: return (R); case Parent: return (P); } return (null); } // This method set the appearance of the node acording to the b // parameter. public void setBold(int b) { switch (b) { case Bold: bold = Bold; break; case Reg: bold = Reg; break; } } // This method return true if the node appearance is Bold. public boolean isBold() { if (bold == Bold) return (true); return (false); } // This method return the current X location of the node on the // display. public int getLocX() { return LocX; } // This method return the current Y location of the node on the // display public int getLocY() { return LocY; } // This method setthe X location of the node on the display. public void setLocX(int x) { LocX = x; } // This method setthe Y location of the node on the display. public void setLocY(int y) { LocY = y; } }