SpatialGrid extends AbstractSpatial<N, N> implements Spatial<N>, TreeNode { public static <N> List<Shape> getGrid(List<Shape> list, SpatialGrid<N> grid) { list.addAll(grid.getGrid()); return list; } SpatialGrid(LayoutModel<N> layoutModel);  SpatialGrid(
      LayoutModel<N> layoutModel, Rectangle2D bounds, int horizontalCount, int verticalCount); void setBounds(Rectangle2D bounds); @Override Set<TreeNode> getContainingLeafs(Point2D p); @Override Set<TreeNode> getContainingLeafs(double x, double y); @Override TreeNode getContainingLeaf(Object element); static List<Shape> getGrid(List<Shape> list, SpatialGrid<N> grid); @Override List<Shape> getGrid(); Multimap<Integer, N> getMap(); @Override void recalculate(); @Override void clear(); void recalculate(Collection<N> nodes); @Override void update(N node, Point location); @Override N getClosestElement(Point2D p); @Override N getClosestElement(double x, double y); @Override Set<N> getVisibleElements(Shape visibleArea); @Override Rectangle2D getLayoutArea(); @Override Rectangle2D getBounds(); @Override Collection<? extends TreeNode> getChildren();  }
@Test public void testBoxLocations() { SpatialGrid spatial = new SpatialGrid(null, new Rectangle(0, 0, 100, 100), 4, 4); log.trace("grid is " + spatial.getGrid()); showBoxIndex(spatial, 10, 10); showBoxIndex(spatial, 49, 49); showBoxIndex(spatial, 50, 50); showBoxIndex(spatial, 99, 1); showBoxIndex(spatial, 70, 10); showVisibleTiles(spatial, new Rectangle(0, 0, 100, 100)); showVisibleTiles(spatial, new Rectangle(25, 25, 10, 10)); showVisibleTiles(spatial, new Rectangle(25, 25, 30, 30)); showVisibleTiles(spatial, new Rectangle(99, 99, 30, 30)); }