public class Quadtree.Node extends AbstractCloneableSerializable
| Modifier and Type | Field and Description |
|---|---|
protected java.awt.geom.Rectangle2D.Double |
bounds
The two-dimensional bounds for this node.
|
protected java.util.ArrayList<Quadtree.Node> |
children
The list of children for this node.
|
protected int |
depth
The depth of this node in the tree.
|
protected java.util.LinkedList<DataType> |
localItems
The local items stored at this node.
|
protected Quadtree.Node |
lowerLeft
The child for the lower-left quadrant of this node.
|
protected Quadtree.Node |
lowerRight
The child for the lower-right quadrant of this node.
|
protected Quadtree.Node |
parent
The parent of this node in the tree.
|
protected Quadtree.Node |
upperLeft
The child for the upper-left quadrant of this node.
|
protected Quadtree.Node |
upperRight
The child for the upper-right quadrant of this node.
|
| Constructor and Description |
|---|
Node(Quadtree.Node parent,
java.awt.geom.Rectangle2D.Double bounds)
Creates a new
Node with the given parent and region bounds. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
areLocalItemsSame()
Returns true if this is a leaf and all the local items are the same.
|
boolean |
boundsContain(double x,
double y)
Returns true if the given point is within the bounds of this node.
|
boolean |
boundsContain(java.awt.geom.Point2D point)
Returns true if the given point is within the bounds of this node.
|
boolean |
boundsContain(java.awt.geom.Rectangle2D rectangle)
Returns true if the given rectangle is completely within the bounds
of this node.
|
boolean |
boundsContain(Vector2 point)
Returns true if the given point is within the bounds of this node.
|
boolean |
boundsOverlap(java.awt.geom.Rectangle2D rectangle)
Returns true if the given rectangle intersects the bounds for this
node.
|
Quadtree.Node |
findChild(DataType item)
Finds the child corresponding to the given point.
|
Quadtree.Node |
findChild(double x,
double y)
Finds the child corresponding to the given point.
|
Quadtree.Node |
findChild(Vector2 point)
Finds the child corresponding to the given point.
|
void |
findItems(java.awt.geom.Rectangle2D rectangle,
java.util.LinkedList<DataType> result)
Finds all of the items that fall within the region defined by this
node (and its children) and adds it to the given list.
|
java.awt.geom.Rectangle2D.Double |
getBounds()
Gets the bounding box of the region represented by this node.
|
java.util.List<Quadtree.Node> |
getChildren()
Gets the children of this node.
|
int |
getDepth()
The depth in the tree that this node exists at.
|
java.util.Collection<DataType> |
getItems()
Gets the collection of items contained in this node and all subnodes.
|
int |
getLocalCount()
Gets the number of items that are locally contained at the node.
|
java.util.LinkedList<DataType> |
getLocalItems()
Gets the list of items stored locally at the node in the tree.
|
Quadtree.Node |
getLowerLeft()
Gets the child representing lower-left quadrant of the node, when
treating the 2D coordinate grid in a mathematical representation
(positive x values go left and positive y values go up).
|
Quadtree.Node |
getLowerRight()
Gets the child representing lower-right quadrant of the node, when
treating the 2D coordinate grid in a mathematical representation
(positive x values go left and positive y values go up).
|
Quadtree.Node |
getParent()
Gets the parent node of this node.
|
Quadtree.Node |
getUpperLeft()
Gets the child representing upper-left quadrant of the node, when
treating the 2D coordinate grid in a mathematical representation
(positive x values go left and positive y values go up).
|
Quadtree.Node |
getUpperRight()
Gets the child representing upper-right quadrant of the node, when
treating the 2D coordinate grid in a mathematical representation
(positive x values go left and positive y values go up).
|
boolean |
isEmpty()
Returns true if this is a leaf node and has no items in it.
|
boolean |
isInBounds(DataType item)
Returns true if the given point is within the bounds of this node.
|
boolean |
isLeaf()
Returns true if this node is a leaf node, which means it has no
children.
|
protected void |
setBounds(java.awt.geom.Rectangle2D.Double bounds)
Sets the bounding box of the region represented by this node.
|
protected void |
setChildren(java.util.ArrayList<Quadtree.Node> children)
Sets the list of child nodes of this node.
|
protected void |
setDepth(int depth)
Sets the depth in the tree of this node.
|
protected void |
setLocalItems(java.util.LinkedList<DataType> localItems)
Gets the list of items stored locally at the node in the tree.
|
protected void |
setLowerLeft(Quadtree.Node lowerLeft)
Sets the lower-left child.
|
protected void |
setLowerRight(Quadtree.Node lowerRight)
Sets the lower-right child.
|
protected void |
setParent(Quadtree.Node parent)
Sets the parent node of this node.
|
protected void |
setUpperLeft(Quadtree.Node upperLeft)
Sets the upper-left child.
|
protected void |
setUpperRight(Quadtree.Node upperRight)
Sets the upper-right child.
|
cloneprotected Quadtree.Node parent
protected java.awt.geom.Rectangle2D.Double bounds
protected int depth
protected java.util.LinkedList<DataType extends Vectorizable> localItems
protected Quadtree.Node lowerRight
protected Quadtree.Node lowerLeft
protected Quadtree.Node upperLeft
protected Quadtree.Node upperRight
protected java.util.ArrayList<Quadtree.Node> children
public Node(Quadtree.Node parent, java.awt.geom.Rectangle2D.Double bounds)
Node with the given parent and region bounds.parent - The parent node. Null for the root node.bounds - The bounding rectangle for the region the node represents.public boolean isInBounds(DataType item)
item - The point.public boolean boundsContain(Vector2 point)
point - The point.public boolean boundsContain(java.awt.geom.Point2D point)
point - The point.public boolean boundsContain(double x,
double y)
x - The x-coordinate of the point.y - The y-coordinate of the point.public boolean boundsContain(java.awt.geom.Rectangle2D rectangle)
rectangle - The rectangle to test.public boolean boundsOverlap(java.awt.geom.Rectangle2D rectangle)
rectangle - The rectangle to test.public Quadtree.Node findChild(DataType item)
item - The item to query.public Quadtree.Node findChild(Vector2 point)
point - The point to query.public Quadtree.Node findChild(double x, double y)
x - The x-coordinate to query.y - The y-coordinate to query.public void findItems(java.awt.geom.Rectangle2D rectangle,
java.util.LinkedList<DataType> result)
rectangle - The rectangle to search in.result - The result list to put the items in.public boolean areLocalItemsSame()
public java.util.Collection<DataType> getItems()
public java.util.List<Quadtree.Node> getChildren()
public boolean isEmpty()
public boolean isLeaf()
public int getLocalCount()
public int getDepth()
protected void setDepth(int depth)
depth - The new depth in the tree for the node.public Quadtree.Node getParent()
protected void setParent(Quadtree.Node parent)
parent - The parent node of this node.public java.awt.geom.Rectangle2D.Double getBounds()
protected void setBounds(java.awt.geom.Rectangle2D.Double bounds)
bounds - The bounding box of the region represented by this node.public java.util.LinkedList<DataType> getLocalItems()
protected void setLocalItems(java.util.LinkedList<DataType> localItems)
localItems - The local items stored at the node.public Quadtree.Node getLowerLeft()
protected void setLowerLeft(Quadtree.Node lowerLeft)
lowerLeft - The lower-left child.public Quadtree.Node getLowerRight()
protected void setLowerRight(Quadtree.Node lowerRight)
lowerRight - The lower-right child.public Quadtree.Node getUpperLeft()
protected void setUpperLeft(Quadtree.Node upperLeft)
upperLeft - The upper-left child.public Quadtree.Node getUpperRight()
protected void setUpperRight(Quadtree.Node upperRight)
upperRight - The upper-right child.protected void setChildren(java.util.ArrayList<Quadtree.Node> children)
children - The list of child nodes of this node.