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 RectanglePacker

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

    public class RectanglePacker

extends Object

Packs rectangles supplied by the user (typically representing image regions) into a larger backing store rectangle (typically representing a large texture). Supports automatic compaction of the space on the backing store, and automatic expansion of the backing store, when necessary.

Constructor Summary
`RectanglePacker(BackingStoreManager manager, int initialWidth, int initialHeight)`

Method Summary
`void` | `add(Rect rect)` Decides upon an (x, y) position for the given rectangle (leaving its width and height unchanged) and places it on the backing store.
`void` | `clear()` Clears all Rects contained in this RectanglePacker.
`void` | `compact()` Forces a compaction cycle, which typically results in allocating a new backing store and copying all entries to it.
`void` | `dispose()` Disposes the backing store allocated by the BackingStoreManager.
`Object` | `getBackingStore()`
`void` | `remove(Rect rect)` Removes the given rectangle from this RectanglePacker.
`void` | `setMaxSize(int maxWidth, int maxHeight)` Sets up a maximum width and height for the backing store.
`float` | `verticalFragmentationRatio()` Returns the vertical fragmentation ratio of this RectanglePacker.
`void` | `visit(RectVisitor visitor)` Visits all Rects contained in this RectanglePacker.

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

Constructor Detail

### RectanglePacker

    public RectanglePacker(BackingStoreManager manager,
                           int initialWidth,
                           int initialHeight)

Method Detail

### getBackingStore

    public Object getBackingStore()

### setMaxSize

    public void setMaxSize(int maxWidth,
                           int maxHeight)

  Sets up a maximum width and height for the backing store. These are optional and if not specified the backing store will grow as necessary. Setting up a maximum width and height introduces the possibility that additions will fail; these are handled with the BackingStoreManager's allocationFailed notification.

### add

    public void add(Rect rect)
             throws RuntimeException

  Decides upon an (x, y) position for the given rectangle (leaving its width and height unchanged) and places it on the backing store. May provoke re-layout of other Rects already added. If the BackingStoreManager does not support compaction, and `BackingStoreManager.preExpand` does not clear enough space for the incoming rectangle, then this method will throw a RuntimeException.

  Throws:
    `RuntimeException`

### remove

    public void remove(Rect rect)

  Removes the given rectangle from this RectanglePacker.

### visit

    public void visit(RectVisitor visitor)

  Visits all Rects contained in this RectanglePacker.

### verticalFragmentationRatio

    public float verticalFragmentationRatio()

  Returns the vertical fragmentation ratio of this RectanglePacker. 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.

### compact

    public void compact()

  Forces a compaction cycle, which typically results in allocating a new backing store and copying all entries to it.

### clear

    public void clear()

  Clears all Rects contained in this RectanglePacker.

### dispose

    public void dispose()

  Disposes the backing store allocated by the BackingStoreManager. This RectanglePacker may no longer be used after calling this method.

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.