public class GridRectanglePacker extends java.lang.Object implements RectanglePacker
| Constructor and Description |
|---|
GridRectanglePacker(int width,
int height,
int gridWidth,
int gridHeight) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears all rectangles, to start over
|
boolean |
fits(int w,
int h)
Checks whether a rectangle with given size will
fit in the pack.
|
int |
getGridHeight()
Height of a grid space
|
int |
getGridWidth()
Width of a grid space
|
int |
getHeight()
Height of bounding box
|
int |
getWidth()
Width of bounding box
|
int |
numRemaining()
Number of remaining empty grid spaces
|
Rectangle |
pack(int w,
int h)
Packs a rectangle with given dimensions, returning
the destination rectangle.
|
public GridRectanglePacker(int width,
int height,
int gridWidth,
int gridHeight)
public int getGridWidth()
public int getGridHeight()
public int getWidth()
getWidth in interface RectanglePackerpublic int getHeight()
getHeight in interface RectanglePackerpublic boolean fits(int w,
int h)
RectanglePackerRectanglePacker.pack(int, int) is
an O(1) operation.fits in interface RectanglePackerw - widthh - heightpublic int numRemaining()
public Rectangle pack(int w, int h)
RectanglePackerpack in interface RectanglePackerw - widthh - heightpublic void clear()
RectanglePackerclear in interface RectanglePacker