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
Quad s which intersect a LineSegment |
List<Quad<T>> |
getQuadsFor(T object)
Returns all
Quad s 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)
Quad
s containing an objectobject
- The object to search forList
if the object does not exist within this treepublic List<Quad<T>> getQuadsFor(LineSegment line)
Quad
s which intersect a LineSegment
line
- The LineSegment
List
if the LineSegment
does not intersect this treepublic List<T> getIntersectionsFor(LineSegment line)
LineSegment
line
- The LineSegment
List
if the LineSegment
does not intersect any elementspublic void add(T object)
Quad
Quad
add
in interface Quad<T extends Parallelogram>
object
- The element to be addedpublic void remove(T object)
Quad
Quad
remove
in interface Quad<T extends Parallelogram>
object
- The element to be removedpublic Quad<T> getParent()
Quad
getParent
in interface Quad<T extends Parallelogram>
Quad
public int getNumberOfElements()
Quad
Quad
getNumberOfElements
in interface Quad<T extends Parallelogram>
Quad
public int getElementLimit()
Quad
Quad
getElementLimit
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.