/**
  * Arranges the blocks without any constraints. This puts all blocks into a single row.
  *
  * @param container the container.
  * @param g2 the graphics device.
  * @return The size after the arrangement.
  */
 protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) {
   List blocks = container.getBlocks();
   Block b = (Block) blocks.get(0);
   Size2D s = b.arrange(g2, RectangleConstraint.NONE);
   b.setBounds(new Rectangle2D.Double(0.0, 0.0, s.width, s.height));
   return new Size2D(s.width, s.height);
 }
 /**
  * Arranges the blocks without any constraints. This puts all blocks into a single row.
  *
  * @param container the container.
  * @param g2 the graphics device.
  * @return The size after the arrangement.
  */
 protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) {
   double x = 0.0;
   double width = 0.0;
   double maxHeight = 0.0;
   List blocks = container.getBlocks();
   int blockCount = blocks.size();
   if (blockCount > 0) {
     Size2D[] sizes = new Size2D[blocks.size()];
     for (int i = 0; i < blocks.size(); i++) {
       Block block = (Block) blocks.get(i);
       sizes[i] = block.arrange(g2, RectangleConstraint.NONE);
       width = width + sizes[i].getWidth();
       maxHeight = Math.max(sizes[i].height, maxHeight);
       block.setBounds(new Rectangle2D.Double(x, 0.0, sizes[i].width, sizes[i].height));
       x = x + sizes[i].width + this.horizontalGap;
     }
     if (blockCount > 1) {
       width = width + this.horizontalGap * (blockCount - 1);
     }
     if (this.verticalAlignment != VerticalAlignment.TOP) {
       for (int i = 0; i < blocks.size(); i++) {
         // Block b = (Block) blocks.get(i);
         if (this.verticalAlignment == VerticalAlignment.CENTER) {
           // TODO: shift block down by half
         } else if (this.verticalAlignment == VerticalAlignment.BOTTOM) {
           // TODO: shift block down to bottom
         }
       }
     }
   }
   return new Size2D(width, maxHeight);
 }
  /**
   * Arranges the blocks in the container with a fixed width and no height constraint.
   *
   * @param container the container.
   * @param g2 the graphics device.
   * @param constraint the constraint.
   * @return The size.
   */
  protected Size2D arrangeFN(
      BlockContainer container, Graphics2D g2, RectangleConstraint constraint) {

    List blocks = container.getBlocks();
    Block b = (Block) blocks.get(0);
    Size2D s = b.arrange(g2, RectangleConstraint.NONE);
    double width = constraint.getWidth();
    Rectangle2D bounds = new Rectangle2D.Double((width - s.width) / 2.0, 0.0, s.width, s.height);
    b.setBounds(bounds);
    return new Size2D((width - s.width) / 2.0, s.height);
  }
  /**
   * Arranges the blocks in the container with a fixed width and no height constraint.
   *
   * @param container the container.
   * @param constraint the constraint.
   * @param g2 the graphics device.
   * @return The size.
   */
  protected Size2D arrangeFN(
      BlockContainer container, Graphics2D g2, RectangleConstraint constraint) {

    List blocks = container.getBlocks();
    double width = constraint.getWidth();

    double x = 0.0;
    double y = 0.0;
    double maxHeight = 0.0;
    List itemsInRow = new ArrayList();
    for (int i = 0; i < blocks.size(); i++) {
      Block block = (Block) blocks.get(i);
      Size2D size = block.arrange(g2, RectangleConstraint.NONE);
      if (x + size.width <= width) {
        itemsInRow.add(block);
        block.setBounds(new Rectangle2D.Double(x, y, size.width, size.height));
        x = x + size.width + this.horizontalGap;
        maxHeight = Math.max(maxHeight, size.height);
      } else {
        if (itemsInRow.isEmpty()) {
          // place in this row (truncated) anyway
          block.setBounds(
              new Rectangle2D.Double(x, y, Math.min(size.width, width - x), size.height));
          x = 0.0;
          y = y + size.height + this.verticalGap;
        } else {
          // start new row
          itemsInRow.clear();
          x = 0.0;
          y = y + maxHeight + this.verticalGap;
          maxHeight = size.height;
          block.setBounds(new Rectangle2D.Double(x, y, Math.min(size.width, width), size.height));
          x = size.width + this.horizontalGap;
          itemsInRow.add(block);
        }
      }
    }
    return new Size2D(constraint.getWidth(), y + maxHeight);
  }