aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl/impl/packrect/LevelSet.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2007-01-13 22:21:13 +0000
committerKenneth Russel <[email protected]>2007-01-13 22:21:13 +0000
commit97910f24754333f5934dc7c5836d101d709550d0 (patch)
treed4cfb23c18f439ee16b9270cadde1b34a207ce8f /src/classes/com/sun/opengl/impl/packrect/LevelSet.java
parent446556d8e8bf1f7e5365bf46deb192e346aa5025 (diff)
Robustness improvements to TextRenderer and underlying RectanglePacker.
Added ability to specify a maximum size to which the RectanglePacker can expand. Added preExpand method to BackingStoreManager to support early eviction of unused entries instead of always expanding the backing store, and additionFailed method used when the backing store can not expand further. Added more robust free list coalescing to Level. Added support for shrinking of backing store and for eager compaction when there is a lot of vertical dead space. Added TextFlow demo which shows how to do dynamic layout of text and which acts as a stress test for the TextRenderer. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1083 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/opengl/impl/packrect/LevelSet.java')
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/packrect/LevelSet.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/classes/com/sun/opengl/impl/packrect/LevelSet.java b/src/classes/com/sun/opengl/impl/packrect/LevelSet.java
index 561a3fe14..97a1f2e74 100755
--- a/src/classes/com/sun/opengl/impl/packrect/LevelSet.java
+++ b/src/classes/com/sun/opengl/impl/packrect/LevelSet.java
@@ -149,6 +149,39 @@ public class LevelSet {
nextAddY += (newHeight - oldHeight);
}
+ /** Gets the used height of the levels in this LevelSet. */
+ public int getUsedHeight() {
+ return nextAddY;
+ }
+
+ /** Sets the height of this LevelSet. It is only legal to reduce the
+ height to greater than or equal to the currently used height. */
+ public void setHeight(int height) throws IllegalArgumentException {
+ if (height < getUsedHeight()) {
+ throw new IllegalArgumentException("May not reduce height below currently used height");
+ }
+ h = height;
+ }
+
+ /** 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. */
+ public float verticalFragmentationRatio() {
+ int freeHeight = 0;
+ int usedHeight = getUsedHeight();
+ if (usedHeight == 0)
+ return 0.0f;
+ for (Iterator iter = iterator(); iter.hasNext(); ) {
+ Level level = (Level) iter.next();
+ if (level.isEmpty()) {
+ freeHeight += level.h();
+ }
+ }
+ return (float) freeHeight / (float) usedHeight;
+ }
+
public Iterator iterator() {
return levels.iterator();
}
@@ -171,4 +204,10 @@ public class LevelSet {
level.updateRectangleReferences();
}
}
+
+ /** Clears out all Levels stored in this LevelSet. */
+ public void clear() {
+ levels.clear();
+ nextAddY = 0;
+ }
}