sk.upjs.fontmapper
Class BinaryPacker

java.lang.Object
  extended by sk.upjs.fontmapper.BinaryPacker
All Implemented Interfaces:
TexturePacker

 class BinaryPacker
extends java.lang.Object
implements TexturePacker

Binary tree based texture packer. Subdivides 2D space to a binary tree of rectangles.


Nested Class Summary
private  class BinaryPacker.Node
          Node of the binary tree that can specify space taken by a texture or contain more nodes.
 
Field Summary
private  BinaryPacker.Node root_
          Root node of the binary tree.
private  int spacing_
          Spacing between textures in pixels.
 
Constructor Summary
BinaryPacker(java.awt.Dimension size, int spacing)
          Construct a BinaryPacker managing texture space with given size.
 
Method Summary
 java.awt.Rectangle allocateSpace(java.awt.Dimension size)
          Attempts to allocate space of specified size on the texture.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

root_

private BinaryPacker.Node root_
Root node of the binary tree.


spacing_

private int spacing_
Spacing between textures in pixels.

Constructor Detail

BinaryPacker

public BinaryPacker(java.awt.Dimension size,
                    int spacing)
Construct a BinaryPacker managing texture space with given size.

Parameters:
size - Size of texture space to manage.
spacing - Spacing between textures in pixels.
Method Detail

allocateSpace

public java.awt.Rectangle allocateSpace(java.awt.Dimension size)
                                 throws TextureAllocationException
Description copied from interface: TexturePacker
Attempts to allocate space of specified size on the texture.

Specified by:
allocateSpace in interface TexturePacker
Parameters:
size - Size of the space to allocate.
Throws:
TextureAllocationException - if space could not be allocated.