Example usage for com.lowagie.text.pdf PdfPRow setWidths

List of usage examples for com.lowagie.text.pdf PdfPRow setWidths

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfPRow setWidths.

Prototype

public boolean setWidths(float widths[]) 

Source Link

Document

Sets the widths of the columns in the row.

Usage

From source file:fr.opensagres.xdocreport.itext.extension.ExtendedPdfPTable.java

License:Open Source License

/**
 * Gets the height of a particular row./* www  .ja  va2 s  . c  om*/
 *
 * @param idx the row index (starts at 0)
 * @param firsttime is this the first time the row heigh is calculated?
 * @return the height of a particular row
 * @since 3.0.0
 */
public float getRowHeight(int idx, boolean firsttime) {
    if (totalWidth <= 0 || idx < 0 || idx >= rows.size())
        return 0;
    PdfPRow row = (PdfPRow) rows.get(idx);
    if (row == null)
        return 0;
    if (firsttime)
        row.setWidths(absoluteWidths);
    float height = row.getMaxHeights();
    PdfPCell cell;
    PdfPRow tmprow;
    for (int i = 0; i < relativeWidths.length; i++) {
        if (!rowSpanAbove(idx, i))
            continue;
        int rs = 1;
        while (rowSpanAbove(idx - rs, i)) {
            rs++;
        }
        tmprow = (PdfPRow) rows.get(idx - rs);
        cell = tmprow.getCells()[i];
        float tmp = 0;
        // AZERR patch : sometimes cell is null????
        // LP : cell may be null if colspan/rowspan occurs
        // create a dummy cell to avoid NullPointerException
        if (cell == null) {
            cell = new PdfPCell();
            tmprow.getCells()[i] = cell;
        }
        if (cell.getRowspan() == rs + 1) {
            tmp = cell.getMaxHeight();
            while (rs > 0) {
                tmp -= getRowHeight(idx - rs);
                rs--;
            }
        }
        if (tmp > height)
            height = tmp;
    }
    row.setMaxHeights(height);
    return height;
}