Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.opengl.util.packrect
Class LevelSet

    java.lang.Object
      com.sun.opengl.util.packrect.LevelSet

    public class LevelSet

extends Object

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
`LevelSet(int w, int h)` A LevelSet manages all of the backing store for a region of a specified width and height.

Method Summary
`boolean` | `add(Rect rect)` Returns true if the given rectangle was successfully added to the LevelSet given its current dimensions, false if not.
`boolean` | `canExpand(Level level, int height)` 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` | `expand(Level level, int oldHeight, int newHeight)`
`int` | `getUsedHeight()` Gets the used height of the levels in this LevelSet.
`int` | `h()`
`Iterator` | `iterator()`
`boolean` | `remove(Rect rect)` Removes the given Rect from this LevelSet.
`void` | `setHeight(int height)` Sets the height of this LevelSet.
`void` | `updateRectangleReferences()` Updates the references to the Rect objects in this LevelSet with the "next locations" of those Rects.
`float` | `verticalFragmentationRatio()` Returns the vertical fragmentation ratio of this LevelSet.
`void` | `visit(RectVisitor visitor)` Visits all Rects contained in this LevelSet.
`int` | `w()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### 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 Detail

### w

    public int w()

### h

    public int h()

### add

    public boolean add(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.

### remove

    public boolean remove(Rect rect)

  Removes the given Rect from this LevelSet.

### compactAndAdd

    public boolean compactAndAdd(Rect rect,
                                 Object backingStore,
                                 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).

### canExpand

    public boolean canExpand(Level level,
                             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.

### expand

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

### getUsedHeight

    public int getUsedHeight()

  Gets the used height of the levels in this LevelSet.

### setHeight

    public void setHeight(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.

  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

    public Iterator iterator()

### visit

    public void visit(RectVisitor visitor)

  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.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.