edu.princeton.cs.algs4.growingtree.framework
Class NodeProperties

java.lang.Object
  extended by edu.princeton.cs.algs4.growingtree.framework.NodeProperties
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
AVLNodeProperties, RankNodeProperties, RBNodeProperties

public class NodeProperties
extends java.lang.Object
implements java.lang.Cloneable

This class hold the local state for a node. It can be extended by client code to include more properties. It also provides callbacks to allow for limited control over the animation.

Author:
Josh Israel

Field Summary
static int NULL_HEIGHT
           
 
Constructor Summary
NodeProperties()
           
 
Method Summary
 java.lang.Object clone()
          Returns a copy of this NodeProperties object.
 boolean colorParentLink()
          Determines whether the node itself is colored or its parent link
 int getHeight()
           
 java.awt.Color getIntegerFieldColor()
           
 java.awt.Color getLeftLinkColor()
           
 java.lang.Integer getLLIntegerFieldValue()
           
 java.lang.Integer getLRIntegerFieldValue()
           
 java.awt.Color getNodeColor()
           
 java.awt.Color getRightLinkColor()
           
 int getSize()
           
 java.lang.Integer getULIntegerFieldValue()
           
 java.lang.Integer getURIntegerFieldValue()
           
 NodeProperties makeDefaultProperties()
          This functions as a factory for NodeProperty objects.
 void setHeight(int i)
          The height field of NodeProperties is maintained by the framework, so this should not be called by the client
 void setSize(int i)
          The size field of NodeProperties is maintained by the framework, so this should not be called by the client
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_HEIGHT

public static final int NULL_HEIGHT
See Also:
Constant Field Values
Constructor Detail

NodeProperties

public NodeProperties()
Method Detail

clone

public java.lang.Object clone()
Returns a copy of this NodeProperties object.

Overrides:
clone in class java.lang.Object
Returns:
an Object that is a copy of this NodeProperties object.

makeDefaultProperties

public NodeProperties makeDefaultProperties()
This functions as a factory for NodeProperty objects. It is called whenever a new node is created (for insertion into the tree). If extended, this MUST be overridden to return an instance of the subclass as a result of some of the quirks of Java generics.

Returns:
An instance of this class. Subclasses should return an instance of the subclass.

getHeight

public int getHeight()

setHeight

public void setHeight(int i)
The height field of NodeProperties is maintained by the framework, so this should not be called by the client

Parameters:
i - The new height of the tree

getSize

public int getSize()

setSize

public void setSize(int i)
The size field of NodeProperties is maintained by the framework, so this should not be called by the client

Parameters:
i - The new height of the tree

getNodeColor

public java.awt.Color getNodeColor()
Returns:
The color this node should be drawn. If colorParentLink returns true, then the parent link will be drawn this color and the node will be black.

colorParentLink

public boolean colorParentLink()
Determines whether the node itself is colored or its parent link

Returns:
True if getNodeColor should be used for the parent link

getLeftLinkColor

public java.awt.Color getLeftLinkColor()
Returns:
The color the left link should be drawn. Ignored if colorParentLink returns true.

getRightLinkColor

public java.awt.Color getRightLinkColor()
Returns:
The color the right link should be drawn. Ignored if colorParentLink returns true;

getULIntegerFieldValue

public java.lang.Integer getULIntegerFieldValue()
Returns:
The value the upper right integer field should contain, or null if nothing should be drawn. This is not to be confused with the actual key value of the node. It is to be used for values like height or rank.

getURIntegerFieldValue

public java.lang.Integer getURIntegerFieldValue()
Returns:
The value the upper right integer field should contain, or null if nothing should be drawn. This is not to be confused with the actual key value of the node. It is to be used for values like height or rank.

getLLIntegerFieldValue

public java.lang.Integer getLLIntegerFieldValue()
Returns:
The value the lower left integer field should contain, or null if nothing should be drawn. This is not to be confused with the actual key value of the node. It is to be used for values like height or rank.

getLRIntegerFieldValue

public java.lang.Integer getLRIntegerFieldValue()
Returns:
The value the lower right integer field should contain, or null if nothing should be drawn. This is not to be confused with the actual key value of the node. It is to be used for values like height or rank.

getIntegerFieldColor

public java.awt.Color getIntegerFieldColor()
Returns:
The color the integer field should be drawn;