示例#1
0
  /**
   * Gets the lines of a cell that can be drawn between certain limits.
   *
   * <p>Remark: all the lines that can be drawn are removed from the object!
   *
   * @param top the top of the part of the table that can be drawn
   * @param bottom the bottom of the part of the table that can be drawn
   * @return an <CODE>ArrayList</CODE> of <CODE>PdfLine</CODE>s
   */
  public ArrayList getLines(float top, float bottom) {
    float lineHeight;
    float currentPosition = Math.min(top(), top);
    setTop(currentPosition + cellspacing);
    ArrayList result = new ArrayList();

    // if the bottom of the page is higher than the top of the cell: do nothing
    if (top() < bottom) {
      return result;
    }

    // we loop over the lines
    int size = lines.size();
    boolean aboveBottom = true;
    for (int i = 0; i < size && aboveBottom; i++) {
      line = (PdfLine) lines.get(i);
      lineHeight = line.height();
      currentPosition -= lineHeight;
      // if the currentPosition is higher than the bottom, we add the line to the result
      if (currentPosition > (bottom + cellpadding + getBorderWidthInside(BOTTOM))) {
        result.add(line);
      } else {
        aboveBottom = false;
      }
    }
    // if the bottom of the cell is higher than the bottom of the page, the cell is written, so we
    // can remove all lines
    float difference = 0f;
    if (!header) {
      if (aboveBottom) {
        lines = new ArrayList();
        contentHeight = 0f;
      } else {
        size = result.size();
        for (int i = 0; i < size; i++) {
          line = removeLine(0);
          difference += line.height();
        }
      }
    }
    if (difference > 0) {
      Image image;
      for (Iterator i = images.iterator(); i.hasNext(); ) {
        image = (Image) i.next();
        image.setAbsolutePosition(image.absoluteX(), image.absoluteY() - difference - leading);
      }
    }
    return result;
  }
示例#2
0
  /**
   * Gets the images of a cell that can be drawn between certain limits.
   *
   * <p>Remark: all the lines that can be drawn are removed from the object!
   *
   * @param top the top of the part of the table that can be drawn
   * @param bottom the bottom of the part of the table that can be drawn
   * @return an <CODE>ArrayList</CODE> of <CODE>Image</CODE>s
   */
  public ArrayList getImages(float top, float bottom) {

    // if the bottom of the page is higher than the top of the cell: do nothing
    if (top() < bottom) {
      return new ArrayList();
    }
    top = Math.min(top(), top);
    // initialisations
    Image image;
    float height;
    ArrayList result = new ArrayList();
    // we loop over the images
    for (Iterator i = images.iterator(); i.hasNext() && !header; ) {
      image = (Image) i.next();
      height = image.absoluteY();
      // if the currentPosition is higher than the bottom, we add the line to the result
      if (top - height > (bottom + cellpadding)) {
        image.setAbsolutePosition(image.absoluteX(), top - height);
        result.add(image);
        i.remove();
      }
    }
    return result;
  }