Example usage for com.lowagie.text Cell setColspan

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

Introduction

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

Prototype

public void setColspan(int value) 

Source Link

Document

Sets the colspan.

Usage

From source file:ispyb.client.mx.collection.PdfRtfExporter.java

License:Open Source License

/**
 * set the table for a given MXPressO/*from w w w .  j a va2  s.  c om*/
 * 
 * @param document
 * @param dataCollectionGroupVO
 * @param mRequest
 * @param lastCollectOSC
 * @param nextToLastCollectChar
 * @throws Exception
 */
private void setMXPressOTable(Document document, DataCollectionGroup3VO dataCollectionGroupVO,
        HttpServletRequest mRequest, DataCollection3VO lastCollectOSC, DataCollection3VO nextToLastCollectChar)
        throws Exception {
    if (dataCollectionGroupVO != null) {

        DataCollectionExporter dcExporter = new DataCollectionExporter(df2, df3, proposalCode, proposalNumber,
                mRequest);
        if (lastCollectOSC != null) {

            DataCollectionInformation dcInfo = dcExporter.getDataCollectionInformation(lastCollectOSC,
                    getSampleRankingVO(lastCollectOSC.getDataCollectionId()),
                    getAutoProcRankingVO(lastCollectOSC.getDataCollectionId()));

            int noCol = 3;
            Table tableWF = new Table(noCol);
            int[] headersWidthWF = new int[noCol];
            int l = 0;

            headersWidthWF[l++] = 27; // snapshot
            headersWidthWF[l++] = 24; // map 1
            headersWidthWF[l++] = 51; // map2
            // tableWF.setWidths(headersWidthWF);

            tableWF.setWidth(100); // percentage
            tableWF.setPadding(1);
            tableWF.setCellsFitPage(true);
            tableWF.setTableFitsPage(true);
            tableWF.getDefaultCell().setBorderWidth(1);
            tableWF.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
            // first row: protein acronym and sample name (or image prefix)
            // and startTime
            String collectName = lastCollectOSC.getImagePrefix();
            if (dataCollectionGroupVO.getBlSampleVO() != null
                    && dataCollectionGroupVO.getBlSampleVO().getCrystalVO() != null) {
                collectName = dataCollectionGroupVO.getBlSampleVO().getCrystalVO().getProteinVO().getAcronym()
                        + "-" + dataCollectionGroupVO.getBlSampleVO().getName();
            }
            tableWF.addCell(new Paragraph(collectName, FONT_DOC));

            String collectTime = lastCollectOSC.getStartTime().toString();
            Cell c = new Cell(new Paragraph(collectTime, FONT_DOC));
            c.setColspan(2);
            tableWF.addCell(c);

            // second row: first snapshot + cartography graphes (2 mesh)
            // first snapshot
            String imgCrystal = dcInfo.getPathJpgCrystal3();
            Cell cellCrystalImage = getCellImage(imgCrystal);
            tableWF.addCell(cellCrystalImage);
            // workflowMesh cartography
            Workflow3VO mxExpressOWF = dataCollectionGroupVO.getWorkflowVO();
            List<WorkflowMesh3VO> listWFMesh = new ArrayList<WorkflowMesh3VO>();
            Ejb3ServiceLocator ejb3ServiceLocator = Ejb3ServiceLocator.getInstance();
            WorkflowMesh3Service workflowMeshService = (WorkflowMesh3Service) ejb3ServiceLocator
                    .getLocalService(WorkflowMesh3Service.class);
            listWFMesh = workflowMeshService.findByWorkflowId(mxExpressOWF.getWorkflowId());

            if (listWFMesh != null && listWFMesh.size() > 0) {
                Cell cellImg1 = getMeshMapCell(listWFMesh.get(0));
                if (cellImg1 == null) {
                    tableWF.addCell(new Paragraph("Image not found", FONT_DOC));
                } else {
                    tableWF.addCell(cellImg1);
                }
                if (listWFMesh.size() > 1) {
                    Cell cellImg2 = getMeshMapCell(listWFMesh.get(1));
                    if (cellImg2 == null) {
                        tableWF.addCell(new Paragraph("Image not found", FONT_DOC));
                    } else {
                        tableWF.addCell(cellImg2);
                    }
                } else
                    tableWF.addCell(new Paragraph("No Workflow found", FONT_DOC));
            } else {
                tableWF.addCell(new Paragraph("No Workflow found", FONT_DOC));
                tableWF.addCell(new Paragraph("No Workflow found", FONT_DOC));
            }

            //
            // third row:
            // autoprocessing results
            Cell resultCell = getAutoProcResultStatus(dcInfo);
            resultCell.setColspan(3);
            resultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
            tableWF.addCell(resultCell);

            Integer idDc = -1;
            for (int k = 0; k < dataCollectionList.size(); k++) {
                DataCollection3VO dcVo = dataCollectionList.get(k);
                if (dcVo.getDataCollectionId().equals(lastCollectOSC.getDataCollectionId())) {
                    idDc = k;
                    break;
                }
            }

            if (idDc != -1) {
                AutoProc3VO[] autoProcs = wrapper.getAutoProcs();
                AutoProcScalingStatistics3VO[] autoProcsOverall = wrapper.getScalingStatsOverall();
                AutoProcScalingStatistics3VO[] autoProcsInner = wrapper.getScalingStatsInner();
                AutoProcScalingStatistics3VO[] autoProcsOuter = wrapper.getScalingStatsOuter();

                AutoProc3VO autoProcValue = autoProcs[idDc];
                AutoProcScalingStatistics3VO autoProcOverall = autoProcsOverall[idDc];
                AutoProcScalingStatistics3VO autoProcInner = autoProcsInner[idDc];
                AutoProcScalingStatistics3VO autoProcOuter = autoProcsOuter[idDc];
                if (autoProcValue == null) {
                    Cell cNo = new Cell(new Paragraph("No autoprocessing results found", FONT_DOC));
                    cNo.setColspan(3);
                    cNo.setHorizontalAlignment(Element.ALIGN_LEFT);
                    tableWF.addCell(cNo);
                    document.add(tableWF);
                } else {
                    int noColSPG = 5;
                    Table tableSPG = new Table(noColSPG);
                    int[] headersWidth = new int[noColSPG];
                    int i = 0;

                    headersWidth[i++] = 7; // space group
                    headersWidth[i++] = 10; // completeness
                    headersWidth[i++] = 9; // resolution
                    headersWidth[i++] = 9; // rsymm
                    headersWidth[i++] = 12; // unit cell
                    tableSPG.setWidths(headersWidth);

                    tableSPG.setWidth(100); // percentage
                    tableSPG.setPadding(3);
                    tableSPG.setCellsFitPage(true);
                    tableSPG.setTableFitsPage(true);
                    tableSPG.getDefaultCell().setBorderWidth(1);
                    tableSPG.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);

                    tableSPG.getDefaultCell().setGrayFill(GREY_FILL_HEADER);
                    tableSPG.addCell(new Paragraph("Space Group", FONT_DOC_BOLD));
                    tableSPG.addCell(new Paragraph("Completeness (Inner, Outer, Overall)", FONT_DOC_BOLD));
                    tableSPG.addCell(new Paragraph("Resolution", FONT_DOC_BOLD));
                    tableSPG.addCell(new Paragraph("Rsymm (Inner, Outer, Overall)", FONT_DOC_BOLD));
                    tableSPG.addCell(new Paragraph("Unit Cell (a, b, c, alpha, beta, gamma)", FONT_DOC_BOLD));

                    tableSPG.getDefaultCell().setGrayFill(GREY_FILL_DATA);

                    // space group
                    if (autoProcValue != null && autoProcValue.getSpaceGroup() != null) {
                        Paragraph p = new Paragraph(autoProcValue.getSpaceGroup(), FONT_DOC);
                        tableSPG.addCell(p);
                    } else
                        tableSPG.addCell("");

                    // completeness, rsymm, processed resolution
                    String completenessString = new String();
                    String rSymmString = new String();
                    String resolutionString = new String();

                    if (autoProcOverall != null && autoProcInner != null && autoProcOuter != null) {
                        completenessString += df2.format(autoProcInner.getCompleteness()) + "\n"
                                + df2.format(autoProcOuter.getCompleteness()) + "\n"
                                + df2.format(autoProcOverall.getCompleteness());
                        rSymmString += (autoProcInner.getRmerge() == null ? ""
                                : df2.format(autoProcInner.getRmerge()))
                                + "\n"
                                + (autoProcOuter.getRmerge() == null ? ""
                                        : df2.format(autoProcOuter.getRmerge()))
                                + "\n" + (autoProcOverall.getRmerge() == null ? ""
                                        : df2.format(autoProcOverall.getRmerge()));
                        resolutionString += autoProcInner.getResolutionLimitLow() + " - "
                                + autoProcInner.getResolutionLimitHigh() + "\n"
                                + autoProcOuter.getResolutionLimitLow() + " - "
                                + autoProcOuter.getResolutionLimitHigh() + "\n"
                                + autoProcOverall.getResolutionLimitLow() + " - "
                                + autoProcOverall.getResolutionLimitHigh();
                    }
                    tableSPG.addCell(new Paragraph(completenessString, FONT_DOC));
                    tableSPG.addCell(new Paragraph(resolutionString, FONT_DOC));
                    tableSPG.addCell(new Paragraph(rSymmString, FONT_DOC));

                    // unit cell
                    if (autoProcValue != null && autoProcValue.getSpaceGroup() != null) {
                        tableSPG.addCell(new Paragraph("" + autoProcValue.getRefinedCellA() + ", "
                                + autoProcValue.getRefinedCellB() + ", " + autoProcValue.getRefinedCellC()
                                + "\n" + autoProcValue.getRefinedCellAlpha() + ", "
                                + autoProcValue.getRefinedCellBeta() + ", "
                                + autoProcValue.getRefinedCellGamma(), FONT_DOC));
                    } else {
                        tableSPG.addCell("");
                    }

                    document.add(tableWF);
                    document.add(new Paragraph("Best autoprocessing result", FONT_DOC));
                    document.add(tableSPG);
                } // end autoProc null
            } // end idDc -1

            //
            document.add(new Paragraph(" ", FONT_SPACE));

        } // end lastCollect null
        if (nextToLastCollectChar != null) {
            DataCollectionInformation dcInfo = dcExporter.getDataCollectionInformation(nextToLastCollectChar,
                    getSampleRankingVO(nextToLastCollectChar.getDataCollectionId()),
                    getAutoProcRankingVO(nextToLastCollectChar.getDataCollectionId()));

            if (dcInfo.getSpacegroup() != "") {
                document.add(new Paragraph("EDNA characterisation output and collect strategy", FONT_DOC));
            }
            setEDNATable2(document, dcInfo);
            setStrategyTable2(document, dcInfo);
        }
    } // end dataCollectionGroup null
}

From source file:ispyb.client.mx.collection.PdfRtfExporter.java

License:Open Source License

/**
 * returns a simple cell witha given value inside
 * /*  w  w w .  j  a  va  2  s .  com*/
 * @param value
 * @return
 */
private Cell getCellValue(String value) {
    Cell cell = new Cell();
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.add(new Paragraph(value, FONT_DOC_BOLD));
    cell.setColspan(1);
    return cell;
}

From source file:ispyb.client.mx.collection.PdfRtfExporter.java

License:Open Source License

private Cell getEmptyCell(int colspan) throws Exception {
    Cell emptyCell = new Cell(new Paragraph("", FONT_DOC));
    emptyCell.setColspan(colspan);
    return emptyCell;
}

From source file:org.activityinfo.server.report.renderer.itext.ItextMapRenderer.java

License:Open Source License

private void renderLegend(MapReportElement element, Document doc) throws DocumentException, IOException {

    Table table = new Table(2);
    table.setBorderWidth(1);// ww w  .j  a  v  a2s. c o  m
    table.setWidth(100f);
    table.setBorderColor(new Color(100, 100, 100));
    table.setPadding(5);
    table.setSpacing(0);
    table.setCellsFitPage(true);
    table.setTableFitsPage(true);
    table.setWidths(new int[] { 1, 3 });

    Cell cell = new Cell(I18N.CONSTANTS.legend());
    cell.setHeader(true);
    cell.setColspan(2);
    table.addCell(cell);
    table.endHeaders();

    for (MapLayerLegend legend : element.getContent().getLegends()) {

        Cell symbolCell = new Cell();
        symbolCell.setHorizontalAlignment(Element.ALIGN_CENTER);
        symbolCell.setVerticalAlignment(Element.ALIGN_MIDDLE);

        Image symbol = createLegendSymbol(legend, imageCreator);
        symbolCell.addElement(symbol);

        Cell descriptionCell = new Cell();
        addLegendDescription(element, legend.getDefinition(), descriptionCell);

        table.addCell(symbolCell);
        table.addCell(descriptionCell);
    }
    doc.add(table);
}

From source file:org.activityinfo.server.report.renderer.itext.ItextPivotTableRenderer.java

License:Open Source License

@Override
public void render(DocWriter writer, Document document, PivotTableReportElement element)
        throws DocumentException {

    document.add(ThemeHelper.elementTitle(element.getTitle()));
    ItextRendererHelper.addFilterDescription(document, element.getContent().getFilterDescriptions());
    ItextRendererHelper.addDateFilterDescription(document, element.getFilter().getDateRange());
    PivotTableData data = element.getContent().getData();

    if (data.isEmpty()) {
        document.add(new Paragraph("Aucune Donnes")); // TODO: i18n

    } else {/* ww  w. j  av a 2s . c  om*/
        int colDepth = data.getRootColumn().getDepth();
        List<PivotTableData.Axis> colLeaves = data.getRootColumn().getLeaves();
        int colBreadth = colLeaves.size();

        Table table = new Table(colBreadth + 1, 1);
        table.setUseVariableBorders(true);
        table.setWidth(100.0f);
        table.setWidths(calcColumnWidths(document, data, colLeaves));
        table.setBorderWidth(0);

        // first write the column headers

        for (int depth = 1; depth <= colDepth; ++depth) {

            if (depth == 1) {
                Cell cell = ThemeHelper.cornerCell();
                cell.setRowspan(colDepth);
                table.addCell(cell);
            }

            List<PivotTableData.Axis> columns = data.getRootColumn().getDescendantsAtDepth(depth);
            for (PivotTableData.Axis column : columns) {
                Cell cell = ThemeHelper.columnHeaderCell(column.getLabel(), column.isLeaf());
                cell.setColspan(Math.max(1, column.getLeaves().size()));
                table.addCell(cell);
            }

        }
        table.endHeaders();

        for (PivotTableData.Axis row : data.getRootRow().getChildren()) {
            writeRow(table, row, colLeaves, 0);
        }
        document.add(table);
    }
}

From source file:org.activityinfo.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);// w w w .j  a  v  a2 s.  c om
    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 (SiteDTO row : data.getRows()) {
        for (TableColumn column : colLeaves) {

            Object value = row.get(column.getSitePropertyName());

            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: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  2s.co  m
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.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 av a2 s  .  c  om*/
    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.framework.ui.skynet.util.TableWriterAdaptor.java

License:Open Source License

public void writeHeader(Table table, String[] headers) throws Exception {
    for (String header : headers) {
        Cell cell = new Cell();
        cell.setHeader(true);//from  w  ww .  jav a  2s. c  om
        cell.setColspan(1);
        cell.setBackgroundColor(WebColors.getRGBColor("#d9d9d9"));
        cell.setHorizontalAlignment(ElementTags.ALIGN_CENTER);

        Font font = FontFactory.getFont("Times New Roman", BaseFont.CP1252, BaseFont.EMBEDDED, 9, Font.BOLD,
                WebColors.getRGBColor("#000000"));
        Paragraph paragraph = new Paragraph(header, font);
        paragraph.setAlignment(ElementTags.ALIGN_CENTER);
        cell.add(paragraph);
        table.addCell(cell);
    }
}

From source file:org.eclipse.osee.framework.ui.skynet.util.TableWriterAdaptor.java

License:Open Source License

public void writeRow(Table table, String... cellData) {
    for (String cellText : cellData) {
        Cell cell = new Cell();
        cell.setHeader(false);//  w  ww.j a v a2  s . c  om
        cell.setColspan(1);
        Font font = FontFactory.getFont("Times New Roman", BaseFont.CP1252, BaseFont.EMBEDDED, 9, Font.NORMAL,
                WebColors.getRGBColor("#000000"));
        Paragraph paragraph = new Paragraph(cellText, font);
        cell.add(paragraph);
        table.addCell(cell);
    }
}