Example usage for com.lowagie.text Table setBorderWidth

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

Introduction

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

Prototype

public void setBorderWidth(float borderWidth) 

Source Link

Document

Sets the borderwidth of the table.

Usage

From source file:org.sigmah.server.report.renderer.itext.ItextTableRenderer.java

License:Open Source License

private void renderTable(Document document, TableData data) throws DocumentException {
    int colDepth = data.getRootColumn().getDepth();
    List<TableColumn> colLeaves = data.getRootColumn().getLeaves();
    int colBreadth = colLeaves.size();

    Table table = new Table(colBreadth, 1);
    table.setUseVariableBorders(true);/*from   w w w  . j  a  va 2 s  . c  o  m*/
    table.setWidth(100.0f);
    table.setBorderWidth(0);

    // first write the column headers

    for (int depth = 1; depth <= colDepth; ++depth) {
        List<TableColumn> columns = data.getRootColumn().getDescendantsAtDepth(depth);
        for (TableColumn column : columns) {
            Cell cell = ThemeHelper.columnHeaderCell(column.getLabel(), column.isLeaf(), computeHAlign(column));
            cell.setColspan(Math.max(1, column.getChildren().size()));
            cell.setRowspan(colDepth - depth - column.getDepth() + 1);
            table.addCell(cell);
        }
    }
    table.endHeaders();

    DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
    NumberFormat numberFormat = NumberFormat.getIntegerInstance();
    numberFormat.setGroupingUsed(true);

    for (TableData.Row row : data.getRows()) {
        for (TableColumn column : colLeaves) {

            Object value = row.values[data.getColumnIndex(column)];

            String label = "";
            if (value instanceof Date) {
                label = dateFormat.format(value);
            } else if (value instanceof Number) {
                label = numberFormat.format(value);
            } else if (value != null) {
                label = value.toString();
            }

            table.addCell(ThemeHelper.bodyCell(label, false, 0, true, computeHAlign(column)));
        }
    }
    document.add(table);
}

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);
    table.setPadding(1);/*w  ww  .j  a  va2  s .c o  m*/
    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;
}

From source file:sg.edu.nus.util.ReportWriter.java

private static void createTable(Section subCatPart) throws BadElementException {
    Table t = new Table(3, 2);

    t.setBorderColor(Color.GRAY);
    t.setPadding(4);//from  www.  ja va 2 s .c  o m
    t.setSpacing(4);
    t.setBorderWidth(1);

    Cell c1 = new Cell("Table Header 1");
    c1.setHeader(true);
    t.addCell(c1);
    c1 = new Cell("Table Header 2");
    t.addCell(c1);
    c1 = new Cell("Table Header 3");
    t.addCell(c1);
    t.endHeaders();

    t.addCell("1.0");
    t.addCell("1.1");
    t.addCell("1.2");
    t.addCell("2.1");
    t.addCell("2.2");
    t.addCell("2.3");

    subCatPart.add(t);

}