Top Description Fields Constructors Methods
com.sun.prism.impl.packrect

public Class RectanglePacker

extends Object
Class Inheritance
Imports
com.sun.javafx.geom.Rectangle, com.sun.prism.Texture, java.util.ArrayList, .List

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.

Field Summary

Modifier and TypeField and Description
private Texture
backingStore

A reference to the backing store that was created (lazily) by the backing store manager.

private int
private List<Level>
levels

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

private static final int
private int
private static final int
private int
private int
private boolean
private int
x

private int
y

Constructor Summary

AccessConstructor and Description
public
RectanglePacker(Texture backingStore, int x, int y, int width, int height, boolean vertical)

public
RectanglePacker(Texture
The backing store texture, must not be null
backingStore
,
int
The width of the backing store, must be > 0 (typically > 512)
width
,
int
The height of the backing store, must be > 0 (typically > 512)
height
)

Creates a new RectanglePacker.

Method Summary

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

Decides upon an (x, y) position for the given rectangle (leaving its width and height unchanged) and places it on the backing store.

private static int
binarySearch(List<Level> levels, int k)

Using binary search to find the last index of best fit level for k, where k is a rounded-up value.

public void
clear()

Clears all Rectangles contained in this RectanglePacker.

public void
dispose()

Disposes the backing store allocated by the BackingStoreManager.

public final Texture

Returns:

A reference to the backing store.
getBackingStore
()

Gets a reference to the backing store, creating it lazily if necessary.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

backingStoreback to summary
private Texture backingStore

A reference to the backing store that was created (lazily) by the backing store manager.

lengthback to summary
private int length
levelsback to summary
private List<Level> levels

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

MIN_SIZEback to summary
private static final int MIN_SIZE
recentUsedLevelIndexback to summary
private int recentUsedLevelIndex
ROUND_UPback to summary
private static final int ROUND_UP
sizeback to summary
private int size
sizeOffsetback to summary
private int sizeOffset
verticalback to summary
private boolean vertical
xback to summary
private int x
yback to summary
private int y

Constructor Detail

RectanglePackerback to summary
public RectanglePacker(Texture backingStore, int x, int y, int width, int height, boolean vertical)
RectanglePackerback to summary
public RectanglePacker(Texture backingStore, int width, int height)

Creates a new RectanglePacker. You must specify the texture used as the backing store, and the width and height of the space within which rectangles are to be packed.

Parameters
backingStore:Texture

The backing store texture, must not be null

width:int

The width of the backing store, must be > 0 (typically > 512)

height:int

The height of the backing store, must be > 0 (typically > 512)

Method Detail

addback to summary
public final boolean add(Rectangle rect)

Decides upon an (x, y) position for the given rectangle (leaving its width and height unchanged) and places it on the backing store.

binarySearchback to summary
private static int binarySearch(List<Level> levels, int k)

Using binary search to find the last index of best fit level for k, where k is a rounded-up value.

clearback to summary
public void clear()

Clears all Rectangles contained in this RectanglePacker.

disposeback to summary
public void dispose()

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

getBackingStoreback to summary
public final Texture getBackingStore()

Gets a reference to the backing store, creating it lazily if necessary.

Returns:Texture

A reference to the backing store.