All Downloads are FREE. Search and download functionalities are using the official Maven repository.

inspired.pdf.unbox.elements.FixedColumnsTable Maven / Gradle / Ivy

There is a newer version: 0.9.3
Show newest version
package inspired.pdf.unbox.elements;

import inspired.pdf.unbox.Bounds;
import inspired.pdf.unbox.Document;
import inspired.pdf.unbox.base.ColumnModel;
import inspired.pdf.unbox.base.TableModel;
import inspired.pdf.unbox.elements.internal.AbstractTable;

/**
 * Table with flexible rows and columns.
 */
public class FixedColumnsTable extends AbstractTable {

    private final TableModel model;

    public FixedColumnsTable(TableModel model) {
        this.model = model;
    }

    public TableRow addRow() {
        return addRow(new TableRow(model));
    }

    @Override
    protected float renderRow(Document document, TableRow row) {
        float rowHeight = super.renderRow(document, row);
        ColumnModel columns = model.scaleToSize(document.getViewPort().width());
        drawColumnLines(document, columns, rowHeight);
        return rowHeight;
    }

    private void drawColumnLines(Document document, ColumnModel columns, float height) {
        Bounds viewPort = document.getViewPort();
        Bounds bounds = new Bounds(viewPort.left(), document.getPosition(), viewPort.width(), height);
        drawColumnLines(document, columns, bounds);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy