public class RegionQuadTree<T extends CollisionShape> extends PointQuadTree<T>
bottomLeft, bottomRight, DEFAULT_MINIMUM_QUAD_SIZE, ELEMENT_COLOR, elementLimitPerQuad, elements, mergeWatermark, minimumQuadHeight, minimumQuadWidth, parent, QUAD_COLOR, topLeft, topRight, totalElementsCache
Constructor and Description |
---|
RegionQuadTree(float minimumQuadWidth,
float minimumQuadHeight,
int elementLimitPerQuad,
int mergeWatermark,
float x,
float y,
float width,
float height)
Constructs a
RegionQuadTree with a specified minimum quad size,
element limit and watermark |
RegionQuadTree(int elementLimit,
float x,
float y,
float width,
float height)
Constructs a
RegionQuadTree with a specified element limit and no
merging watermark. |
RegionQuadTree(int elementLimit,
int mergeWatermark,
float x,
float y,
float width,
float height)
Constructs a
RegionQuadTree with a specified element limit and
watermark |
RegionQuadTree(RegionQuadTree<T> parent,
float x,
float y,
float width,
float height)
Constructs a
RegionQuadTree as a child of another
RegionQuadTree |
Modifier and Type | Method and Description |
---|---|
boolean |
add(T element) |
void |
addAll(java.util.List<T> elementsToAdd) |
protected boolean |
addElementToChild(T element) |
void |
clear() |
void |
debugRender(Graphics g) |
java.util.List<T> |
getElements() |
void |
getElements(java.util.List<T> result) |
void |
getElementsContainingPoint(java.util.Collection<T> result,
Point point) |
java.util.List<T> |
getElementsContainingPoint(Point point) |
void |
getElementsIntersectingLineSegment(java.util.Collection<T> result,
LineSegment lineSegment) |
java.util.List<T> |
getElementsIntersectingLineSegment(LineSegment lineSegment) |
void |
getElementsWithinArea(java.util.Collection<T> result,
Shape area) |
java.util.List<T> |
getElementsWithinArea(Shape area) |
int |
getTotalElements() |
void |
positionChanged(T moved) |
boolean |
remove(T element) |
protected void |
subdivide() |
addElement, clearTotalElementsCache, getElementLimitPerQuad, getMergeWatermark, getMinimumQuadHeight, getMinimumQuadWidth, getParent, getTotalQuads, hasChildQuads, isMergable, merge, removeAll, removeElement, removeElementFromChild
contains, contains, contains, contains, contains, contains, copy, draw, edgeIterator, fill, getCenterX, getCenterY, getDistanceTo, getDistanceTo, getHeight, getMaxX, getMaxY, getMinX, getMinY, getNumberOfSides, getPolygon, getRotation, getVertices, getWidth, getX, getY, intersection, intersects, intersects, intersects, intersects, intersects, intersects, intersects, intersectsLineSegment, intersectsLineSegment, intersectsLineSegment, isCircle, lerp, rotate, rotateAround, scale, set, set, set, set, setHeight, setRadius, setRotation, setRotationAround, setRotationAround, setSize, setSize, setWidth, setX, setY, toString, translate
add, intersects, subtract
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
contains, contains, getHeight, getMaxX, getMaxY, getRotation, getWidth, getX, getY, intersects, intersects, intersectsLineSegment, rotate, rotateAround, setRotation, setRotationAround
public RegionQuadTree(int elementLimit, int mergeWatermark, float x, float y, float width, float height)
RegionQuadTree
with a specified element limit and
watermarkelementLimit
- The maximum number of elements in a RegionQuadTree
before it is split into 4 child quadsmergeWatermark
- When a parent RegionQuadTree
's total elements go lower
than this mark, the child RegionQuadTree
s will be
merged back togetherx
- The x coordinate of the RegionQuadTree
y
- The y coordiante of the RegionQuadTree
width
- The width of the RegionQuadTree
height
- The height of the RegionQuadTree
public RegionQuadTree(int elementLimit, float x, float y, float width, float height)
RegionQuadTree
with a specified element limit and no
merging watermark. As elements are removed, small sized child
RegionQuadTree
s will not be merged back together.elementLimit
- The maximum number of elements in a quad before it is split
into 4 child RegionQuadTree
sx
- The x coordinate of the RegionQuadTree
y
- The y coordiante of the RegionQuadTree
width
- The width of the RegionQuadTree
height
- The height of the RegionQuadTree
public RegionQuadTree(RegionQuadTree<T> parent, float x, float y, float width, float height)
RegionQuadTree
as a child of another
RegionQuadTree
parent
- The parent RegionQuadTree
x
- The x coordinate of the RegionQuadTree
y
- The y coordiante of the RegionQuadTree
width
- The width of the RegionQuadTree
height
- The height of the RegionQuadTree
public RegionQuadTree(float minimumQuadWidth, float minimumQuadHeight, int elementLimitPerQuad, int mergeWatermark, float x, float y, float width, float height)
RegionQuadTree
with a specified minimum quad size,
element limit and watermarkminimumQuadWidth
- The minimum width of quads. Quads will not subdivide smaller
than this width.minimumQuadHeight
- The minimum height of quads. Quads will not subdivide smaller
than this height.elementLimitPerQuad
- The maximum number of elements in a quad before it is split
into 4 child RegionQuadTree
smergeWatermark
- When a parent RegionQuadTree
's total elements go lower
than this mark, the child PointQuadTree
s will be
merged back togetherx
- The x coordinate of the RegionQuadTree
y
- The y coordiante of the RegionQuadTree
width
- The width of the RegionQuadTree
height
- The height of the RegionQuadTree
public void debugRender(Graphics g)
debugRender
in interface QuadTree<T extends CollisionShape>
debugRender
in class PointQuadTree<T extends CollisionShape>
public void addAll(java.util.List<T> elementsToAdd)
addAll
in interface QuadTree<T extends CollisionShape>
addAll
in class PointQuadTree<T extends CollisionShape>
public boolean add(T element)
add
in interface QuadTree<T extends CollisionShape>
add
in class PointQuadTree<T extends CollisionShape>
protected boolean addElementToChild(T element)
addElementToChild
in class PointQuadTree<T extends CollisionShape>
protected void subdivide()
subdivide
in class PointQuadTree<T extends CollisionShape>
public boolean remove(T element)
remove
in interface QuadTree<T extends CollisionShape>
remove
in class PointQuadTree<T extends CollisionShape>
public void clear()
clear
in class PointQuadTree<T extends CollisionShape>
public java.util.List<T> getElementsWithinArea(Shape area)
getElementsWithinArea
in interface QuadTree<T extends CollisionShape>
getElementsWithinArea
in class PointQuadTree<T extends CollisionShape>
public void getElementsWithinArea(java.util.Collection<T> result, Shape area)
getElementsWithinArea
in interface QuadTree<T extends CollisionShape>
getElementsWithinArea
in class PointQuadTree<T extends CollisionShape>
public java.util.List<T> getElementsContainingPoint(Point point)
getElementsContainingPoint
in interface QuadTree<T extends CollisionShape>
getElementsContainingPoint
in class PointQuadTree<T extends CollisionShape>
public void getElementsContainingPoint(java.util.Collection<T> result, Point point)
getElementsContainingPoint
in interface QuadTree<T extends CollisionShape>
getElementsContainingPoint
in class PointQuadTree<T extends CollisionShape>
public java.util.List<T> getElementsIntersectingLineSegment(LineSegment lineSegment)
getElementsIntersectingLineSegment
in interface QuadTree<T extends CollisionShape>
getElementsIntersectingLineSegment
in class PointQuadTree<T extends CollisionShape>
public void getElementsIntersectingLineSegment(java.util.Collection<T> result, LineSegment lineSegment)
getElementsIntersectingLineSegment
in interface QuadTree<T extends CollisionShape>
getElementsIntersectingLineSegment
in class PointQuadTree<T extends CollisionShape>
public java.util.List<T> getElements()
getElements
in interface QuadTree<T extends CollisionShape>
getElements
in class PointQuadTree<T extends CollisionShape>
public void getElements(java.util.List<T> result)
getElements
in interface QuadTree<T extends CollisionShape>
getElements
in class PointQuadTree<T extends CollisionShape>
public int getTotalElements()
getTotalElements
in interface QuadTree<T extends CollisionShape>
getTotalElements
in class PointQuadTree<T extends CollisionShape>
public void positionChanged(T moved)
positionChanged
in interface PositionChangeListener<T extends CollisionShape>
positionChanged
in class PointQuadTree<T extends CollisionShape>