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
|
boolean |
markIfClear(java.awt.geom.Rectangle2D rect,
java.lang.Object o)
Check if the given rect intersects an already drawn one.
|
void |
print()
print the grid
|
void |
setGrid(java.awt.geom.Rectangle2D bbox,
java.awt.geom.Rectangle2D cellSize)
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 columnsny - maximum number of grid rowspublic void setGrid(java.awt.geom.Rectangle2D bbox,
java.awt.geom.Rectangle2D cellSize)
bbox - bounding box we are only interested in points inside of thiscellSize - divide the bounding box into cells of this size.
maximum number of grid cells is nx x nypublic void setOverlap(int overlap)
overlap - percent overlappublic void print()
public 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 findClosest(java.awt.geom.Point2D pt)
pt - find the closest marked cell to this point