Example usage for com.lowagie.text Table addCell

List of usage examples for com.lowagie.text Table addCell

Introduction

In this page you can find the example usage for com.lowagie.text Table addCell.

Prototype

public void addCell(Cell aCell, int row, int column) throws BadElementException 

Source Link

Document

Adds a Cell to the Table at a certain row and column.

Usage

From source file:pl.exsio.ca.app.report.terraincard.view.TerrainCardsView.java

License:Open Source License

private Element buildTable(TerrainCardPage page) throws Exception {
    Table table = new Table(this.viewModel.getTableColumnsNo() * 2);
    table.setBorderWidth(1);/*from ww  w  . j  av a2s . c o m*/
    table.setPadding(1);
    table.setSpacing(1);
    table.setWidth(100);
    int currentCol = START_COL;
    int currentRow = START_ROW;
    for (int i = 0; i < page.getColumns().size(); i++) {
        TerrainCardColumn column = page.getColumns().get(i);
        table.addCell(this.getColumnTitleCell(column.getTerrainName()), 0, currentCol);
        table.addCell(this.getColumnDescCell("from"), 1, currentCol);
        table.addCell(this.getColumnDescCell("to"), 1, currentCol + 1);
        for (int j = 0; j < column.getCells().size(); j++) {
            TerrainCardCell cell = column.getCells().get(j);
            boolean odd = j % 2 != 0;
            table.addCell(this.getNotificationCell(cell.getGroup(), odd, 2), currentRow, currentCol);
            table.addCell(this.getNotificationCell(cell.getFrom(), odd, 1), currentRow + 1, currentCol);
            table.addCell(this.getNotificationCell(cell.getTo(), odd, 1), currentRow + 1, currentCol + 1);
            currentRow += 2;
        }
        currentCol += 2;
        currentRow = START_ROW;
    }

    return table;
}