public class RegionalQuadTree<T extends Parallelogram> extends Object implements QuadTree<T>, Quad<T>
QuadTree which contains regions. Each region can contain
a maximum number of elements before it is subdivided into four regions.| Constructor and Description |
|---|
RegionalQuadTree(float width,
float height)
Default constructor
|
RegionalQuadTree(int elementLimitPerRegion,
float width,
float height)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(T object)
Adds an element to this
Quad |
int |
getElementLimit()
Returns the maximum number of elements per
Quad |
float |
getHeight() |
List<T> |
getIntersectionsFor(LineSegment line)
Returns all elements which intersect a
LineSegment |
int |
getNumberOfElements()
Returns the number of elements within this
Quad |
Quad<T> |
getParent()
|
List<Quad<T>> |
getQuadsFor(LineSegment line)
Returns all
Quads which intersect a LineSegment |
List<Quad<T>> |
getQuadsFor(T object)
Returns all
Quads containing an object |
List<T> |
getValues()
|
float |
getWidth() |
void |
positionChanged(T moved) |
void |
remove(T object)
Removes an element from this
Quad |
public RegionalQuadTree(float width,
float height)
width - The width of the tree in pixelsheight - The height of the tree in pixelspublic RegionalQuadTree(int elementLimitPerRegion,
float width,
float height)
elementLimitPerRegion - The maximum number of elements per region before subdivisionwidth - The width of the tree in pixelsheight - The height of the tree in pixelspublic List<Quad<T>> getQuadsFor(T object)
Quads containing an objectobject - The object to search forList if the object does not exist within this treepublic List<Quad<T>> getQuadsFor(LineSegment line)
Quads which intersect a LineSegmentline - The LineSegmentList if the LineSegment does not intersect this treepublic List<T> getIntersectionsFor(LineSegment line)
LineSegmentline - The LineSegmentList if the LineSegment does not intersect any elementspublic void add(T object)
QuadQuadadd in interface Quad<T extends Parallelogram>object - The element to be addedpublic void remove(T object)
QuadQuadremove in interface Quad<T extends Parallelogram>object - The element to be removedpublic Quad<T> getParent()
QuadgetParent in interface Quad<T extends Parallelogram>Quadpublic int getNumberOfElements()
QuadQuadgetNumberOfElements in interface Quad<T extends Parallelogram>Quadpublic int getElementLimit()
QuadQuadgetElementLimit in interface Quad<T extends Parallelogram>public float getWidth()
public float getHeight()
public void positionChanged(T moved)
positionChanged in interface PositionChangeListener<T extends Parallelogram>Copyright © 2014. All rights reserved.