예제 #1
0
  /**
   * Sets the bottom of the Rectangle and determines the proper {link #verticalOffset} to
   * appropriately align the contents vertically.
   *
   * @param value
   */
  public void setBottom(float value) {
    super.setBottom(value);
    float firstLineRealHeight = firstLineRealHeight();

    float totalHeight = ury - value; // can't use top (already compensates for cellspacing)
    float nonContentHeight = (cellpadding() * 2f) + (cellspacing() * 2f);
    nonContentHeight += getBorderWidthInside(TOP) + getBorderWidthInside(BOTTOM);

    float interiorHeight = totalHeight - nonContentHeight;
    float extraHeight = 0.0f;

    switch (verticalAlignment) {
      case Element.ALIGN_BOTTOM:
        extraHeight = interiorHeight - contentHeight;
        break;
      case Element.ALIGN_MIDDLE:
        extraHeight = (interiorHeight - contentHeight) / 2.0f;
        break;
      default: // ALIGN_TOP
        extraHeight = 0f;
    }

    extraHeight += cellpadding() + cellspacing();
    extraHeight += getBorderWidthInside(TOP);
    if (firstLine != null) {
      firstLine.height = firstLineRealHeight + extraHeight;
    }
  }
예제 #2
0
 /**
  * Gets a Rectangle that is altered to fit on the page.
  *
  * @param top the top position
  * @param bottom the bottom position
  * @return a <CODE>Rectangle</CODE>
  */
 public Rectangle rectangle(float top, float bottom) {
   Rectangle tmp = new Rectangle(left(), bottom(), right(), top());
   tmp.cloneNonPositionParameters(this);
   if (top() > top) {
     tmp.setTop(top);
     tmp.setBorder(border - (border & TOP));
   }
   if (bottom() < bottom) {
     tmp.setBottom(bottom);
     tmp.setBorder(border - (border & BOTTOM));
   }
   return tmp;
 }