public class SpatialGrid
extends java.lang.Object
Constructor and Description |
---|
SpatialGrid(int nx,
int ny)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
clear all the grid cells
|
java.lang.Object |
findClosest(java.awt.geom.Point2D pt)
Find the closest marked cell to the given point
|
java.lang.Object |
findIntersection(java.awt.geom.Point2D p)
Check if the given point is contained in already drawn object
|
java.lang.Object |
findIntersection(java.awt.geom.Rectangle2D rect)
Check if the given rect intersects an already drawn object
|
boolean |
markIfClear(java.awt.geom.Rectangle2D rect,
java.lang.Object o)
Check if the given rect intersects an already drawn one.
|
void |
setGrid(java.awt.geom.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(java.awt.geom.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(java.awt.geom.Rectangle2D rect, java.lang.Object o)
rect
- the bounding box of the thing we want to drawo
- store this objectpublic java.lang.Object findIntersection(java.awt.geom.Rectangle2D rect)
rect
- the bounding box of the thing we want to drawpublic java.lang.Object findIntersection(java.awt.geom.Point2D p)
p
- the point to checkpublic java.lang.Object findClosest(java.awt.geom.Point2D pt)
pt
- find the closest marked cell to this point