Example usage for com.lowagie.text Cell Cell

List of usage examples for com.lowagie.text Cell Cell

Introduction

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

Prototype

public Cell(Element element) throws BadElementException 

Source Link

Document

Constructs a Cell with a certain Element.

if the element is a ListItem, Row or Cell, an exception will be thrown.

Usage

From source file:org.displaytag.render.ItextTableWriter.java

License:Artistic License

/**
 * @see org.displaytag.render.TableWriterTemplate#writePostBodyFooter(org.displaytag.model.TableModel)
 * @throws DocumentException if an error occurs while writing post-body footer.
 *///ww  w. ja  v a 2  s  . com
protected void writePostBodyFooter(TableModel model) throws DocumentException {
    Chunk cellContent = new Chunk(model.getFooter(), this.getFooterFont());
    this.setFooterFontStyle(cellContent);
    Cell cell = new Cell(cellContent);
    cell.setLeading(8);
    cell.setBackgroundColor(this.getFooterBackgroundColor());
    cell.setHorizontalAlignment(this.getFooterHorizontalAlignment());
    cell.setColspan(model.getNumberOfColumns());
    table.addCell(cell);
}

From source file:org.displaytag.render.ItextTableWriter.java

License:Artistic License

/**
 * Returns a formatted cell for the given value.
 * @param value cell value//from  ww  w .j ava  2s.  com
 * @return Cell
 * @throws BadElementException if errors occurs while generating content.
 */
private Cell getCell(Object value) throws BadElementException {
    Cell cell = new Cell(new Chunk(StringUtils.trimToEmpty(ObjectUtils.toString(value)), this.defaultFont));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setLeading(8);
    return cell;
}

From source file:org.displaytag.render.ItextTableWriter.java

License:Artistic License

/**
 * Obtain a header cell./* w ww.j  av  a2  s.  com*/
 * @param value Cell content.
 * @return A header cell with the given content.
 * @throws BadElementException if errors occurs while generating content.
 */
private Cell getHeaderCell(String value) throws BadElementException {
    Chunk cellContent = new Chunk(value, this.getHeaderFont());
    setHeaderFontStyle(cellContent);
    Cell cell = new Cell(cellContent);
    cell.setLeading(8);
    cell.setHeader(true);
    cell.setHorizontalAlignment(this.getHeaderHorizontalAlignment());
    cell.setBackgroundColor(this.getHeaderBackgroundColor());
    return cell;
}

From source file:org.drools.verifier.doc.DroolsDocsComponentFactory.java

License:Apache License

private static Cell newHeaderCell(String text, Font font) throws BadElementException {
    Cell c = new Cell(new Phrase(text, font));
    c.setBackgroundColor(Color.decode("#CCCCFF"));
    c.setLeading(10);/*from w ww .jav a 2  s .c o  m*/
    c.setBorder(1);

    return c;
}

From source file:org.drools.verifier.doc.DroolsDocsComponentFactory.java

License:Apache License

private static Cell newCell(String text) throws BadElementException {
    Cell c = new Cell(new Phrase(text, BODY_TEXT));
    c.setLeading(10);/*from  www.j ava  2  s . c o  m*/
    c.setBorder(0);
    c.setBorderWidthBottom(1);

    return c;
}

From source file:org.eclipse.osee.ats.rest.internal.build.report.table.BuildTraceTable.java

License:Open Source License

public void initializeTraceReportTable(String program, String build) throws OseeCoreException {
    String header = String.format("%s: [%s - %s]", AtsElementData.BUILD_TRACE_REPORT, program, build);
    document = new Document();
    document.addTitle(header);//from   w  ww  .  j a  v  a 2s. c  o m
    HtmlWriter.getInstance(document, output);
    document.open();
    createTables();
    Cell headerCell = new RtfCell(header);
    headerCell.setColspan(1);
    headerCell.setHeader(true);
    headerCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    reportTable.addCell(headerCell);
    reportTable.endHeaders();
    reportTable.setTableFitsPage(true);

    Cell rpcrCell = new RtfCell(AtsElementData.RPCR);
    rpcrCell.setHeader(true);
    rpcrCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    traceReportTable.addCell(rpcrCell);

    Cell req = new Cell(AtsElementData.REQUIREMENT);
    req.setHeader(true);
    req.setHorizontalAlignment(Element.ALIGN_CENTER);
    nestedHeaderTable.addCell(req);
    Cell script = new Cell(AtsElementData.TEST_SCRIPT);
    script.setHeader(true);
    script.setHorizontalAlignment(Element.ALIGN_CENTER);
    nestedHeaderTable.addCell(script);

    traceReportTable.insertTable(nestedHeaderTable);
    sortedRpcr = new TreeSet<Pair<String, Table>>(PairCompare);

}

From source file:org.eclipse.osee.ats.rest.internal.build.report.table.UrlListTable.java

License:Open Source License

public void initializeTable(String title, String lastRun, String... headers) throws OseeCoreException {
    document = new Document();
    lastRunDate = lastRun;//  w w w  .j a v a2  s.com
    sortedList = new TreeSet<List<Anchor>>(new Comparator<List<Anchor>>() {

        @Override
        public int compare(List<Anchor> anchor1, List<Anchor> anchor2) {
            String name1 = anchor1.get(0).toString();
            String name2 = anchor2.get(0).toString();
            return name1.compareTo(name2);
        }
    });
    HtmlWriter.getInstance(document, output);
    document.addTitle(title);
    document.open();

    try {
        table = new Table(headers.length);
    } catch (BadElementException ex) {
        OseeExceptions.wrapAndThrow(ex);
    }

    for (String header : headers) {
        Cell headerCell = new Cell(header);
        headerCell.setHeader(true);
        headerCell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(headerCell);
    }
    table.setWidth(10f * headers.length);
    table.setAlignment(Element.ALIGN_BOTTOM);
}

From source file:org.egov.infra.web.displaytag.export.EGovPdfView.java

License:Open Source License

/**
 * Returns a formatted cell for the given value.
 * @param value cell value/*from  ww w  . j a v  a2  s. co m*/
 * @return Cell
 * @throws BadElementException errors while generating content
 */
private Cell getCell(String value) throws BadElementException {

    value = removeHtmlTagsAndSpaces(value);
    final Cell cell = new Cell(new Chunk(StringUtils.trimToEmpty(value), this.smallFont));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setLeading(8);
    return cell;
}

From source file:org.goobi.production.flow.helper.SearchResultHelper.java

License:Open Source License

public void getResultAsRtf(List<SearchColumn> columnList, String filter, String order,
        boolean showClosedProcesses, boolean showArchivedProjects, OutputStream out) {
    Document document = new Document();

    RtfWriter2.getInstance(document, out);

    @SuppressWarnings("rawtypes")
    List list = search(columnList, filter, order, showClosedProcesses, showArchivedProjects);

    document.open();/*from   ww w .j ava  2s  . com*/

    Table table = null;
    try {
        table = new Table(columnList.size());
    } catch (BadElementException e1) {
    }
    table.setBorderWidth(1);

    for (SearchColumn sc : columnList) {
        Cell cell = new Cell(Helper.getTranslation(sc.getValue()));
        cell.setHeader(true);
        table.addCell(cell);
    }
    table.endHeaders();

    for (Object obj : list) {
        Object[] objArr = (Object[]) obj;
        for (Object entry : objArr) {
            Cell cell = new Cell((String) entry);
            table.addCell(cell);
        }

    }
    try {
        document.add(table);
    } catch (DocumentException e) {
    }

    document.close();

    return;
}

From source file:org.inbio.modeling.core.manager.impl.ExportManagerImpl.java

License:Open Source License

private void addTableRow(Table t, String title, String value) throws BadElementException {

    // Fonts Definition
    Font boldFont = new Font(Font.TIMES_ROMAN, 12, Font.BOLD);
    Cell cell = new Cell(new Chunk(title, boldFont));
    cell.setHeader(true);//from  www .  j a  va2  s  . c o  m
    t.addCell(cell);
    t.addCell(value);
}