/**
   * Packs the given nuts (which embed images) in the smallest area.
   *
   * @param nuts the images to pack
   * @return a map which associates each packed image to its allocated region
   * @throws WuicException if one image could not be read
   */
  public Map<Region, Nut> pack(final List<Nut> nuts) throws WuicException {

    // Clear previous work
    dimensionPacker.clearElements();

    // Load each image, read its dimension and add it to the packer with the ile as data
    for (final Nut nut : nuts) {
      InputStream is = null;

      try {
        is = nut.openStream();
        final BufferedImage buff = ImageIO.read(is);

        dimensionPacker.addElement(new Dimension(buff.getWidth(), buff.getHeight()), nut);
      } catch (IOException ioe) {
        throw new StreamException(ioe);
      } finally {
        IOUtils.close(is);
      }
    }

    // Get the regions calculated by the packer !
    return dimensionPacker.getRegions();
  }
 /**
  * Gets the dimension computed by the packer when defining a position for elements.
  *
  * @return the packed dimension
  */
 public Dimension getDimensionPack() {
   return dimensionPacker.getFilledArea();
 }