net.sourceforge.olduvai.accordiondrawer
Class SplitLine

java.lang.Object
  extended by net.sourceforge.olduvai.accordiondrawer.SplitLine
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
StaticSplitLine

public class SplitLine
extends java.lang.Object
implements java.lang.Comparable

An instance of a SplitLine. Note that the comparator uses the absoluteValue of this object. This code also implements the TreeSet lookup hack, which allows for the retrieving of an object in the TreeSet using the 'contains' method call on the tree. Note that this hack is not thread safe. This class must be kept lightweight with respect to state, as there may be many of them in some applications.


Field Summary
protected  double absoluteValue
          Absolute value, between 0 and 1, between SplitAxis.minStuckLine and SplitAxis.maxStuckLine.
protected  boolean color
          State for red-black tree.
protected  int computedFrame
          Current frame for rendering, monotonically increasing, for determining validity of absoluteValue (caching).
 java.lang.Object cullingObject
          An object to assist with aggregation when multiple splitcells are hidden under a single pixel.
static boolean getSplitLine
          Global static variable for retrieving a split line from the split axis.
private  boolean isFakeLine
          State for fake lines or real lines.
private  SplitLine leftChild
          Left child of this split line, null if the child is null (possible leaf is right is also null).
private  SplitLine opBound
          Off-parent bound of this split line, null if this is the root.
private  SplitLine parent
          Parent of this split line, null if this is the root.
protected  double relativeValue
          Relative value, between 0 and 1, between opBound and parent, the bounds for this split line.
private  SplitLine rightChild
          Right child of this split line, null if the child is null (possible leaf is left is also null).
 java.lang.Object rowObject
          An object that stores a 'row' of data.
static SplitLine splitLineFound
          Global static variable for storing a found split line from the split axis.
protected  int subTreeSize
          How many nodes are below me, including me (1 for leaves).
 
Constructor Summary
SplitLine()
          Default split line constructor.
SplitLine(double value, SplitLine parent, SplitLine opAncestor, boolean isVirtual)
          Make a new splitline with given key, value, and parent, and with null child links, and BLACK color.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares absolute values of two SplitLines.
 boolean equals(java.lang.Object o)
          Note: natural ordering is NOT consistent with equals.
 double getCachedValue()
          Returns the cached value of the line without checking if it is up to date.
 java.lang.Object getCullingObject()
          Accessor for cullingObject.
 SplitLine getLeftChild()
          Accessor for left child.
 SplitLine getOpBound()
          Accessor for opBound.
static SplitLine getOverlapSplitCell(java.util.TreeSet searchTree, SplitLine input)
          Returns a SplitLine whose absoluteValue is either equal to the input SplitLine's absoluteValue, or is the closest SplitLine less than the input SplitLine's absoluteValue.
 SplitLine getParent()
          Accessor for parent object.
 SplitLine getRightChild()
          Accessor for right child.
 java.lang.Object getRowObject()
          Accessor for rowObject.
 int getSubTreeSize()
          Accessor for subTreeSize.
 double getValue(SplitAxis axis, int frameNum)
          Returns the absolute value of this splitLine.
 boolean isLeftChild()
          Test function for internal nodes, true if this line is a left child of its immediate parent.
 boolean isRoot()
          Root test.
 void setCullingObject(java.lang.Object cullingObject)
          Modifier for cullingObject.
 void setLeftChild(SplitLine s)
          Modifier for left child.
 void setOpBound(SplitLine opBound)
          Modifier for opBound.
 void setParent(SplitLine s)
          Modifier for parent object.
 void setRightChild(SplitLine s)
          Modifier for right child.
 void setRowObject(java.lang.Object rowObject)
          Modifier for rowObject.
 void setSubTreeSize(int subTreeSize)
          Modifier for subTreeSize.
 java.lang.String toLongString()
          Recursive descent print: For printing the split axis tree under this node (recursive).
 java.lang.String toString()
          String representation of this split line.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

isFakeLine

private boolean isFakeLine
State for fake lines or real lines. Fake lines are not in the treeset, but are added as needed during partitioning.


getSplitLine

public static boolean getSplitLine
Global static variable for retrieving a split line from the split axis. See compareTo(Object), which does not have a return value, but sets a value for splitLineFound if this is true.


splitLineFound

public static SplitLine splitLineFound
Global static variable for storing a found split line from the split axis. See compareTo(Object), which does not have a return value, but sets this if getSplitLine is true.


leftChild

private SplitLine leftChild
Left child of this split line, null if the child is null (possible leaf is right is also null).


rightChild

private SplitLine rightChild
Right child of this split line, null if the child is null (possible leaf is left is also null).


parent

private SplitLine parent
Parent of this split line, null if this is the root. Set to some real splitline for virtual split lines, null for stuck lines.


opBound

private SplitLine opBound
Off-parent bound of this split line, null if this is the root. Set to some real splitline for virtual split lines, null for stuck lines. An example off parent is the first left parent of a node that is the right child of it's direct parent. This, with the parent split line, bounds the movement of this split line in world space, and are used to compute absoluteValue with the hierarchy of relativeValue


color

protected boolean color
State for red-black tree. Either SplitAxis.BLACK or SplitAxis.RED.


relativeValue

protected double relativeValue
Relative value, between 0 and 1, between opBound and parent, the bounds for this split line.


absoluteValue

protected double absoluteValue
Absolute value, between 0 and 1, between SplitAxis.minStuckLine and SplitAxis.maxStuckLine.


computedFrame

protected int computedFrame
Current frame for rendering, monotonically increasing, for determining validity of absoluteValue (caching).


subTreeSize

protected int subTreeSize
How many nodes are below me, including me (1 for leaves).


cullingObject

public java.lang.Object cullingObject
An object to assist with aggregation when multiple splitcells are hidden under a single pixel. Stores CellGeom or other application-specific objects.


rowObject

public java.lang.Object rowObject
An object that stores a 'row' of data. LRAC-specific purpose. TODO: identify this purpose, the type of object stored here.

Constructor Detail

SplitLine

public SplitLine()
Default split line constructor. Use all default (impossible in some cases) values for state. No parameter constructor initializes absolute value to the (invalid) value of -1.0 which should be fixed on the next compute place this frame. Use the SplitAxis.putAt() method to add this to the tree, at which point the parent and opParent values are set by the SplitAxis class.


SplitLine

public SplitLine(double value,
                 SplitLine parent,
                 SplitLine opAncestor,
                 boolean isVirtual)
Make a new splitline with given key, value, and parent, and with null child links, and BLACK color. This is used to create "dummy" split lines. A new SplitLine object. Generally the absoluteValue set here is meaningless since the first time SplitAxis.computePlaceThisFrame is run it will get changed anyway. The relativeValue is set based on SplitAxis.defaultSplitValue which would typically be .5 if the red-black tree is perfectly balanced.

Parameters:
isVirtual - true for virtual split lines, created for rendering but not added to the split axis hierarchy.
value - initial absoluteValue value for this split line. Will be used to place and determine relative value.
parent - parent split line
opAncestor - opposite split line, opBound
Method Detail

getParent

public SplitLine getParent()
Accessor for parent object.

Returns:
Split line that is the parent.

setParent

public void setParent(SplitLine s)
Modifier for parent object. For dynamic split lines.

Parameters:
s - new parent for this line.

getLeftChild

public SplitLine getLeftChild()
Accessor for left child.

Returns:
Split line that is the leftChild.

setLeftChild

public void setLeftChild(SplitLine s)
Modifier for left child.

Parameters:
s - New leftChild for this line.

getRightChild

public SplitLine getRightChild()
Accessor for right child.

Returns:
Split line that is the rightChild.

setRightChild

public void setRightChild(SplitLine s)
Modifier for right child.

Parameters:
s - New rightChild for this line.

getValue

public double getValue(SplitAxis axis,
                       int frameNum)
Returns the absolute value of this splitLine. Computes the place of the line for the current frame.

Parameters:
axis - the axis to use for computing the value for this line.
frameNum - the frame number to check if computing the position is required (or if cache is safe)
Returns:
the absolute location of this split line on screen (used for drawing)

getCachedValue

public double getCachedValue()
Returns the cached value of the line without checking if it is up to date. getValue(SplitAxis, int) is much safer if the real position of the line is required.

Returns:
The value of absoluteValue.

equals

public boolean equals(java.lang.Object o)
Note: natural ordering is NOT consistent with equals. Natural ordering uses absoluteValue, equals uses splitCount (metricName).

Overrides:
equals in class java.lang.Object
Parameters:
o - Second object to test for equality.
Returns:
True if the object and this split line have identical cached absolute positions.

toString

public java.lang.String toString()
String representation of this split line.

Overrides:
toString in class java.lang.Object
Returns:
debugging string used to identify the split line.

toLongString

public java.lang.String toLongString()
Recursive descent print: For printing the split axis tree under this node (recursive). Very inefficient and time consuming for large trees. Danger: used by SplitAxis.print(String) on the root node.

Returns:
recursive concatenation of axis tree below this node

compareTo

public int compareTo(java.lang.Object o)
Compares absolute values of two SplitLines. NOTE: this comparison is really only valid AFTER you have called 'computeplacethisframe'!! Note, if 'getSplitLine' static boolean is set to true it will set the splitLineFound static pointer either to the exact match or the nearest match less than the absoluteValue of the object passed in.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - Second split line to test position.
Returns:
-1 for this lesser than o, +1 for greater than, 0 for equality.

getOverlapSplitCell

public static SplitLine getOverlapSplitCell(java.util.TreeSet searchTree,
                                            SplitLine input)
Returns a SplitLine whose absoluteValue is either equal to the input SplitLine's absoluteValue, or is the closest SplitLine less than the input SplitLine's absoluteValue. NOTE: if you return a value smaller than the first line in the partition, this function will RETURN the first line in the partition, not the minStuckLine as you might expect.

Parameters:
searchTree - Tree of split lines to test, usually a partitioned set of split lines (set covers whole space between SplitAxis.minStuckLine and SplitAxis.maxStuckLine.
input - Split line to locate within searchTree (should bounded by exactly one split line in the tree)
Returns:
The split line in searchTree that contains the given split line.

getSubTreeSize

public int getSubTreeSize()
Accessor for subTreeSize.

Returns:
Returns the subTreeSize.

setSubTreeSize

public void setSubTreeSize(int subTreeSize)
Modifier for subTreeSize.

Parameters:
subTreeSize - The subTreeSize to set.

getCullingObject

public java.lang.Object getCullingObject()
Accessor for cullingObject. Should be cast later for application-specific use.

Returns:
Returns the cullingObject.

setCullingObject

public void setCullingObject(java.lang.Object cullingObject)
Modifier for cullingObject. Generic object, application-specific use for culling.

Parameters:
cullingObject - The cullingObject to set.

getRowObject

public java.lang.Object getRowObject()
Accessor for rowObject.

Returns:
Returns the rowObject.

setRowObject

public void setRowObject(java.lang.Object rowObject)
Modifier for rowObject.

Parameters:
rowObject - The rowObject to set.

isLeftChild

public boolean isLeftChild()
Test function for internal nodes, true if this line is a left child of its immediate parent.

Returns:
True if this split line is to the left of its parent. Already known that this is not the root.

getOpBound

public SplitLine getOpBound()
Accessor for opBound.

Returns:
Returns the opBound.

setOpBound

public void setOpBound(SplitLine opBound)
Modifier for opBound.

Parameters:
opBound - The opBound to set.

isRoot

public boolean isRoot()
Root test.

Returns:
True if this is the root node, which means the parent of this node is unset.