Class VassalMapQuadTree
java.lang.Object
VASSAL.tools.qtree.QuadTree
VASSAL.build.module.index.VassalMapQuadTree
- All Implemented Interfaces:
Cloneable
A Quadtree index of pieces on the playable area of the Map.
Each node of the Quadtree holds an Arraylist of the Game Pieces at that Map location
Pieces that do not reside on the actual map (i.e. in the edge buffer, or off map) will not be
indexed and NOT be found by a Ranged GKC
-
Constructor Summary
ConstructorsConstructorDescriptionVassalMapQuadTree(VassalMapQuadTree qtree, int x1, int y1, int x2, int y2) Create a new Quadtree with larger bounds from an existing QuadtreeVassalMapQuadTree(Map map) Create a QuadTree to cover the entire map -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a piece to the Qtree, or change it's locationReturn the bounds of the current QuadtreegetPiecesInRange(Point pos, int range) Return a list of all pieces within range of a given Point NOTE: This is just a pre-selection, we are seacrchign a box, not a circle so extra pieces will be returned that are not in range.voidRemove a piece from the Qtree and the cross-referenceMethods inherited from class QuadTree
clear, clone, contains, find, get, getCount, getKeys, getRootNode, getValues, isEmpty, navigate, remove, searchIntersect, searchWithin, set, setRootNode, traverseModifier and TypeMethodDescriptionvoidclear()Removes all items from the tree.clone()Clones the quad-tree and returns the new instance.booleancontains(double x, double y) Returns true if the point at (x, y) exists in the tree.Finds a leaf node with the same (x, y) coordinates as the target point, or null if no point exists.Gets the value of the point at (x, y) or null if the point is empty.intgetCount()QPoint[]getKeys()Returns an array containing the coordinates of each point stored in the tree.Returns a reference to the tree's root node.Returns a list containing all values stored within the tree.booleanisEmpty()voidremove(double x, double y) Removes a point from (x, y) if it exists.QPoint[]searchIntersect(double xmin, double ymin, double xmax, double ymax) QPoint[]searchWithin(double xmin, double ymin, double xmax, double ymax) voidSets the value of an (x, y) point within the quad-tree.voidsetRootNode(QNode root) voidTraverses the tree depth-first, with quadrants being traversed in clockwise order (NE, SE, SW, NW).
-
Constructor Details
-
VassalMapQuadTree
-
VassalMapQuadTree
Create a new Quadtree with larger bounds from an existing Quadtree- Parameters:
qtree- Existing Quadtreex1- New left marginy1- New top marginx2- New right marginy2- New bottom margin
-
-
Method Details
-
getBounds
-
addOrUpdatePiece
Add a piece to the Qtree, or change it's location- Parameters:
p- Piece to add/move
-
removePiece
Remove a piece from the Qtree and the cross-reference- Parameters:
p- Piece to remove
-
getPiecesInRange
Return a list of all pieces within range of a given Point NOTE: This is just a pre-selection, we are seacrchign a box, not a circle so extra pieces will be returned that are not in range. This will be handled at the level above which will post-process our selection.- Parameters:
pos- Positionrange- range in pixels to search- Returns:
- List of pieces
-