Package com.jogamp.opengl.util.packrect
Class LevelSet
java.lang.Object
com.jogamp.opengl.util.packrect.LevelSet
Manages a list of Levels; this is the core data structure
contained within the RectanglePacker and encompasses the storage
algorithm for the contained Rects.
-
Constructor Summary
ConstructorsConstructorDescriptionLevelSet
(int w, int h) A LevelSet manages all of the backing store for a region of a specified width and height. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true if the given rectangle was successfully added to the LevelSet given its current dimensions, false if not.boolean
Indicates whether it's legal to trivially increase the height of the given Level.void
clear()
Clears out all Levels stored in this LevelSet.boolean
compactAndAdd
(Rect rect, Object backingStore, BackingStoreManager manager) Allocates the given Rectangle, performing compaction of a Level if necessary.void
int
Gets the used height of the levels in this LevelSet.int
h()
iterator()
boolean
Removes the given Rect from this LevelSet.void
setHeight
(int height) Sets the height of this LevelSet.void
Updates the references to the Rect objects in this LevelSet with the "next locations" of those Rects.float
Returns the vertical fragmentation ratio of this LevelSet.void
visit
(RectVisitor visitor) Visits all Rects contained in this LevelSet.int
w()
-
Constructor Details
-
LevelSet
public LevelSet(int w, int h) A LevelSet manages all of the backing store for a region of a specified width and height.
-
-
Method Details
-
w
public int w() -
h
public int h() -
add
Returns true if the given rectangle was successfully added to the LevelSet given its current dimensions, false if not. Caller is responsible for performing compaction, expansion, etc. as a consequence. -
remove
Removes the given Rect from this LevelSet. -
compactAndAdd
Allocates the given Rectangle, performing compaction of a Level if necessary. This is the correct fallback path toadd(Rect)
above. Returns true if allocated successfully, false otherwise (indicating the need to expand the backing store). -
canExpand
Indicates whether it's legal to trivially increase the height of the given Level. This is only possible if it's the last Level added and there's enough room in the backing store. -
expand
-
getUsedHeight
public int getUsedHeight()Gets the used height of the levels in this LevelSet. -
setHeight
Sets the height of this LevelSet. It is only legal to reduce the height to greater than or equal to the currently used height.- Throws:
IllegalArgumentException
-
verticalFragmentationRatio
public float verticalFragmentationRatio()Returns the vertical fragmentation ratio of this LevelSet. This is defined as the ratio of the sum of the heights of all completely empty Levels divided by the overall used height of the LevelSet. A high vertical fragmentation ratio indicates that it may be profitable to perform a compaction. -
iterator
-
visit
Visits all Rects contained in this LevelSet. -
updateRectangleReferences
public void updateRectangleReferences()Updates the references to the Rect objects in this LevelSet with the "next locations" of those Rects. This is actually used to update the new Rects in a newly laid-out LevelSet with the original Rects. -
clear
public void clear()Clears out all Levels stored in this LevelSet.
-