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 RectanglePacker
public int getHeight()
getHeight
in interface RectanglePacker
public boolean fits(int w, int h)
RectanglePacker
RectanglePacker.pack(int, int)
is
an O(1) operation.fits
in interface RectanglePacker
w
- widthh
- heightpublic int numRemaining()
public Rectangle pack(int w, int h)
RectanglePacker
pack
in interface RectanglePacker
w
- widthh
- heightpublic void clear()
RectanglePacker
clear
in interface RectanglePacker