Package icyllis.arc3d.core
Class RectanglePacker
java.lang.Object
icyllis.arc3d.core.RectanglePacker
- Direct Known Subclasses:
RectanglePacker.BinaryTree
,RectanglePacker.Horizon
,RectanglePacker.HorizonOld
,RectanglePacker.Power2Line
,RectanglePacker.Skyline
Packs rectangles into a larger rectangle.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
static final class
static final class
static final class
static final class
Tracks the current silhouette, optimized. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
Available rectangle packing algorithms, skyline is always recommended.static final int
protected int
protected final int
protected final int
-
Constructor Summary
ModifierConstructorDescriptionprotected
RectanglePacker
(int width, int height) Constructor assumes both width and height are in the range 1..32768. -
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
Decides upon an (x, y) position for the given rectangle (leaving its width and height unchanged).abstract void
clear()
Clears all the tracked data.void
free()
For native rectangle packer, this must be called to free its native resources.final double
Returns the ratio of the used area to the maximum area, higher is better.final int
final int
getWidth()
static RectanglePacker
make
(int width, int height) Creates a rectangle packer using the best algorithm.static RectanglePacker
make
(int width, int height, int algorithm)
-
Field Details
-
ALGORITHM_SKYLINE
public static final int ALGORITHM_SKYLINEAvailable rectangle packing algorithms, skyline is always recommended.- See Also:
-
ALGORITHM_HORIZON
public static final int ALGORITHM_HORIZON- See Also:
-
ALGORITHM_HORIZON_OLD
public static final int ALGORITHM_HORIZON_OLD- See Also:
-
ALGORITHM_BINARY_TREE
public static final int ALGORITHM_BINARY_TREE- See Also:
-
ALGORITHM_POWER2_LINE
public static final int ALGORITHM_POWER2_LINE- See Also:
-
ALGORITHM_SKYLINE_NEW
public static final int ALGORITHM_SKYLINE_NEW- See Also:
-
mWidth
protected final int mWidth -
mHeight
protected final int mHeight -
mArea
protected int mArea
-
-
Constructor Details
-
RectanglePacker
protected RectanglePacker(int width, int height) Constructor assumes both width and height are in the range 1..32768.- Parameters:
width
- the max widthheight
- the max height
-
-
Method Details
-
make
Creates a rectangle packer using the best algorithm.- Parameters:
width
- the max width, typical value is 256, 512 or 1024height
- the max height, typical value is 256, 512 or 1024
-
make
-
getWidth
public final int getWidth() -
getHeight
public final int getHeight() -
clear
public abstract void clear()Clears all the tracked data. -
addRect
Decides upon an (x, y) position for the given rectangle (leaving its width and height unchanged).- Returns:
- true on success; false on failure
-
getCoverage
public final double getCoverage()Returns the ratio of the used area to the maximum area, higher is better.- Returns:
- the ratio of coverage, 0..1
-
free
public void free()For native rectangle packer, this must be called to free its native resources.
-