com.babaroga.test.packing
Class RectanglePacker

java.lang.Object
  extended by com.babaroga.test.packing.RectanglePacker
Direct Known Subclasses:
BspPacker, SimplePacker

public abstract class RectanglePacker
extends java.lang.Object

Abstract base class for all rectangle packers. Rectangle packers should return the collection of packed rectangles in the same order that they were supplied.


Constructor Summary
RectanglePacker()
           
 
Method Summary
abstract  java.util.Collection<java.awt.Rectangle> pack(int width, int height, java.util.Collection<java.awt.Rectangle> rectangles)
          Packs the supplied rectangles into the specified bounds.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RectanglePacker

public RectanglePacker()
Method Detail

pack

public abstract java.util.Collection<java.awt.Rectangle> pack(int width,
                                                              int height,
                                                              java.util.Collection<java.awt.Rectangle> rectangles)
                                                       throws java.lang.IllegalArgumentException
Packs the supplied rectangles into the specified bounds.

Parameters:
width - The width of the bounding rectangle.
height - The height of the bounding rectangle.
rectangles - The rectangles to be packed.
Returns:
the packed rectangles. This collection may not return all the rectangles that were specified to be packed.
Throws:
java.lang.IllegalArgumentException - If any rectangles are empty (zero length dimensions).
java.lang.IllegalArgumentException - If width or height are <= 0.