com.babaroga.test.packing
Class BoundsGenerator

java.lang.Object
  extended by com.babaroga.test.packing.BoundsGenerator
Direct Known Subclasses:
ConstantBoundsGenerator, MinimumBoundsGenerator, SquareBoundsGenerator

public abstract class BoundsGenerator
extends java.lang.Object

A BoundsGenerator generates potential bounding rectangles.


Constructor Summary
BoundsGenerator()
           
 
Method Summary
 java.awt.Dimension getBounds()
          Returns the packed bounding rectangle.
 int getNumBoundsTested()
          Returns the number of bounding rectangles that the RectanglePacker attempted to pack whether or not the packing was successful.
 java.util.Collection<java.awt.Rectangle> getPackedRectangles()
          Returns the rectangles that were packed.
 java.util.Collection<java.awt.Rectangle> pack(java.util.Collection<java.awt.Rectangle> rectangles, RectanglePacker packer)
          Packs the supplied rectangles using a bounds generator.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoundsGenerator

public BoundsGenerator()
Method Detail

pack

public java.util.Collection<java.awt.Rectangle> pack(java.util.Collection<java.awt.Rectangle> rectangles,
                                                     RectanglePacker packer)
                                              throws java.lang.IllegalArgumentException
Packs the supplied rectangles using a bounds generator.

Parameters:
rectangles - The rectangles that should be packed.
packer - The packer to pack the generated bounds with.
Returns:
The rectangles that were packed or an empty collection if unable to pack all rectangles.
Throws:
java.lang.IllegalArgumentException - If any rectangles are empty (zero length dimensions).
java.lang.IllegalArgumentException - If any bounds generated by generator have width or height <= 0.

getBounds

public java.awt.Dimension getBounds()
Returns the packed bounding rectangle.

Returns:
The bounding rectangle.

getNumBoundsTested

public int getNumBoundsTested()
Returns the number of bounding rectangles that the RectanglePacker attempted to pack whether or not the packing was successful.

Returns:
the number of bounding rectangles tested.

getPackedRectangles

public java.util.Collection<java.awt.Rectangle> getPackedRectangles()
Returns the rectangles that were packed.

Returns:
the packed rectangles.