public class SpatialGrid extends Object
| Constructor and Description |
|---|
SpatialGrid(int nx,
int ny)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
clear all the grid cells
|
Object |
findClosest(Point2D pt)
Find the closest marked cell to the given point
|
Object |
findIntersection(Point2D p)
Check if the given point is contained in already drawn object
|
Object |
findIntersection(Rectangle2D rect)
Check if the given rect intersects an already drawn object
|
boolean |
markIfClear(Rectangle2D rect,
Object o)
Check if the given rect intersects an already drawn one.
|
void |
setGrid(Rectangle2D bbox,
double width,
double height)
Set the grid scale.
|
void |
setOverlap(int overlap)
Set how much the data may overlap.
|
public SpatialGrid(int nx,
int ny)
nx - maximum number of grid cells in xny - : maximum number of grid cells in ypublic void setGrid(Rectangle2D bbox, double width, double height)
bbox - bounding box: we are only interested in points inside of thiswidth - : divide the bounding box into cells of this width.height - : divide the bounding box into cells of this height.
maximum number of grid cells is nx x nypublic void setOverlap(int overlap)
overlap - : percent overlappublic void clear()
public boolean markIfClear(Rectangle2D rect, Object o)
rect - the bounding box of the thing we want to drawo - store this objectpublic Object findIntersection(Rectangle2D rect)
rect - the bounding box of the thing we want to drawpublic Object findIntersection(Point2D p)
p - the point to check