|
Algorithm Development Kit 1.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectalgs.model.kdtree.TwoDNode
public abstract class TwoDNode
Represents the base class of a node in the TwoD tree.
This class is intended as a simpler, optimized implementation of DimensionalNode
for two dimensional KD trees.
| Field Summary | |
|---|---|
double |
coord
Coordinate. |
IPoint |
point
Store the point. |
| Constructor Summary | |
|---|---|
TwoDNode(double coord,
IPoint point)
Stores the coordinate value to be used for dividing the plane either vertically or horizontally |
|
| Method Summary | |
|---|---|
abstract TwoDNode |
construct(IPoint value)
This method constructs the node of the appropriate class based upon the vertical property of this node. |
TwoDNode |
getAbove()
Return node "Above" this one. |
TwoDNode |
getBelow()
Return node "Below" this one. |
IRectangle |
getRegion()
Return region associated with this node. |
protected abstract boolean |
inAboveRange(IRectangle r)
Helper method for search algorithm, implemented in the Horizontal and Vertical subclasses. |
protected abstract boolean |
inBelowRange(IRectangle r)
Helper method for search algorithm, implemented in the Horizontal and Vertical subclasses. |
abstract boolean |
isBelow(IPoint point)
Returns whether the point is below the line represented by this node. |
abstract boolean |
isVertical()
Determines whether node splits plane vertically |
void |
search(IRectangle space,
java.util.ArrayList<IPoint> results)
Locate all points within the TwoDTree that fall within the given rectangle. |
void |
search(IRectangle space,
IVisitTwoDNode visitor)
Locate all points within the TwoDTree that fall within the given rectangle and use given visitor as the computation to perform on that node. |
void |
setAbove(TwoDNode node)
Set node "Above" this one. |
void |
setBelow(TwoDNode node)
Set the node "Below" this one. |
protected void |
specialUpdateRectangle()
Called once the node has its region properly set, and it must propagate to children (if they exist) in below and above. |
protected abstract void |
split(TwoDNode child,
boolean above)
Manipulates child node's region accordingly, based on our own. |
java.lang.String |
toString()
Reasonable toString method. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final double coord
public final IPoint point
| Constructor Detail |
|---|
public TwoDNode(double coord,
IPoint point)
Note the initial region associated with this TwoDNode object is unbounded
and will only be set properly when it is added into the tree.
coord - coordinate value to be used for dividing planepoint - the IPoint object from which coordinate is derived.| Method Detail |
|---|
public TwoDNode getBelow()
public TwoDNode getAbove()
public IRectangle getRegion()
public void setBelow(TwoDNode node)
Let subclass deal with updating region.
node - new node to be properly set.public void setAbove(TwoDNode node)
Let subclass deal with updating region.
node - new node to be properly set.public abstract boolean isVertical()
public abstract boolean isBelow(IPoint point)
For vertical nodes, below is clear. For horizontal nodes, a true value for below is interpreted as being left.
point -
protected abstract void split(TwoDNode child,
boolean above)
For VerticalNode, below is clear. For HorizontalNode, a true value
for below is interpreted as being left.
child - child node to be affected by splitabove - Determines whether to return left- or bottom- sidepublic abstract TwoDNode construct(IPoint value)
In short, this acts as a factory for the nodes in the next level of the tree.
value - point to be inserted.
TwoDNode subclass (either VerticalNode or
HorizontalNode)
public void search(IRectangle space,
java.util.ArrayList<IPoint> results)
space - non-null region within which search occurs.results - non-null ArrayListjava.lang.NullPointerException - if space is null or results is null
public void search(IRectangle space,
IVisitTwoDNode visitor)
space - non-null space within which search is to be conducted.visitor - visitor to perform computation on the node
NullPointer - if value is null or visitor is null.protected abstract boolean inBelowRange(IRectangle r)
r - query rectangleprotected abstract boolean inAboveRange(IRectangle r)
r - query rectangleprotected void specialUpdateRectangle()
public java.lang.String toString()
toString in class java.lang.Object
|
Algorithm Development Kit 1.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||