Top Description Fields Constructors Methods
com.jogamp.opengl.util.packrect

public Class LevelSet

extends Object
Class Inheritance
Imports
java.util.*

Manages a list of Levels; this is the core data structure contained within the RectanglePacker and encompasses the storage algorithm for the contained Rects.

Field Summary

Modifier and TypeField and Description
private int
h

private final List<Level>
private int
private final int
w

Constructor Summary

AccessConstructor and Description
public
LevelSet(final int w, final int h)

A LevelSet manages all of the backing store for a region of a specified width and height.

Method Summary

Modifier and TypeMethod and Description
public boolean
add(final Rect rect)

Returns true if the given rectangle was successfully added to the LevelSet given its current dimensions, false if not.

public boolean
canExpand(final Level level, final int height)

Indicates whether it's legal to trivially increase the height of the given Level.

public void
clear()

Clears out all Levels stored in this LevelSet.

public boolean
compactAndAdd(final Rect rect, final Object backingStore, final BackingStoreManager manager)

Allocates the given Rectangle, performing compaction of a Level if necessary.

public void
expand(final Level level, final int oldHeight, final int newHeight)

public int
getUsedHeight()

Gets the used height of the levels in this LevelSet.

public int
h()

public Iterator<Level>
public boolean
remove(final Rect rect)

Removes the given Rect from this LevelSet.

public void
setHeight(final int height)

Sets the height of this LevelSet.

public void
updateRectangleReferences()

Updates the references to the Rect objects in this LevelSet with the "next locations" of those Rects.

public float
verticalFragmentationRatio()

Returns the vertical fragmentation ratio of this LevelSet.

public void
visit(final RectVisitor visitor)

Visits all Rects contained in this LevelSet.

public int
w()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hback to summary
private int h
levelsback to summary
private final List<Level> levels
nextAddYback to summary
private int nextAddY
wback to summary
private final int w

Constructor Detail

LevelSetback to summary
public LevelSet(final int w, final int h)

A LevelSet manages all of the backing store for a region of a specified width and height.

Method Detail

addback to summary
public boolean add(final Rect rect)

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.

canExpandback to summary
public boolean canExpand(final Level level, final int height)

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.

clearback to summary
public void clear()

Clears out all Levels stored in this LevelSet.

compactAndAddback to summary
public boolean compactAndAdd(final Rect rect, final Object backingStore, final BackingStoreManager manager)

Allocates the given Rectangle, performing compaction of a Level if necessary. This is the correct fallback path to add(Rect) above. Returns true if allocated successfully, false otherwise (indicating the need to expand the backing store).

expandback to summary
public void expand(final Level level, final int oldHeight, final int newHeight)
getUsedHeightback to summary
public int getUsedHeight()

Gets the used height of the levels in this LevelSet.

hback to summary
public int h()
iteratorback to summary
public Iterator<Level> iterator()
removeback to summary
public boolean remove(final Rect rect)

Removes the given Rect from this LevelSet.

setHeightback to summary
public void setHeight(final int height) throws IllegalArgumentException

Sets the height of this LevelSet. It is only legal to reduce the height to greater than or equal to the currently used height.

updateRectangleReferencesback to summary
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.

verticalFragmentationRatioback to summary
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.

visitback to summary
public void visit(final RectVisitor visitor)

Visits all Rects contained in this LevelSet.

wback to summary
public int w()