Example usage for com.lowagie.text Table setWidths

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

Introduction

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

Prototype

public void setWidths(int[] widths) throws DocumentException 

Source Link

Document

Sets the widths of the different columns (percentages).

Usage

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

License:Open Source License

/**
 * set the XFR Spectra table/*from ww w.ja  v a 2s. c  o m*/
 * 
 * @param document
 * @throws Exception
 */
private void setXfrSpectraTable(Document document) throws Exception {
    if (slv == null) {// if session is null, no sense to display XFRSpectra
        return;
    }
    document.add(new Paragraph("XRF Spectra:", FONT_TITLE));
    document.add(new Paragraph(" "));
    if (xfeList == null || xfeList.isEmpty()) {
        document.add(new Paragraph("There is no XRF spectra in this report", FONT_DOC));
    } else {
        int NumColumnsXRF = 6;
        Table tableXRF = new Table(NumColumnsXRF);
        int headerwidthsSessionXRF[] = { 15, 15, 15, 15, 15, 25 }; // percentage
        int headerwidthsMXPressXRF[] = { 16, 16, 15, 15, 15, 8, 17 }; // percentage
        tableXRF.setWidths(headerwidthsSessionXRF);
        // Column crystalClass added only for IFX proposal in case of
        // MXPress experiment
        if (proposalCode.toLowerCase().equals(Constants.PROPOSAL_CODE_FX)) {
            tableXRF = new Table(NumColumnsXRF + 1);
            tableXRF.setWidths(headerwidthsMXPressXRF);
        }

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

        // XRF Spectra Header

        tableXRF.getDefaultCell().setGrayFill(GREY_FILL_HEADER);
        tableXRF.addCell(new Paragraph("Energy\n(keV)", FONT_DOC_BOLD));
        tableXRF.addCell(new Paragraph("Exposure Time\n(s)", FONT_DOC_BOLD));
        tableXRF.addCell(new Paragraph("Beam size Hor.\n(" + Constants.MICRO + "m)", FONT_DOC_BOLD));
        tableXRF.addCell(new Paragraph("Beam size Ver.\n(" + Constants.MICRO + "m)", FONT_DOC_BOLD));
        tableXRF.addCell(new Paragraph("Transm. Factor\n(%)", FONT_DOC_BOLD));
        // Column crystalClass only for IFX proposal in case of MXPress
        // experiment
        if (proposalCode.toLowerCase().equals(Constants.PROPOSAL_CODE_FX))
            tableXRF.addCell(new Paragraph("Crystal class", FONT_DOC_BOLD));
        tableXRF.addCell(new Paragraph("Comments", FONT_DOC_BOLD));
        tableXRF.getDefaultCell().setGrayFill(GREY_FILL_DATA);
        tableXRF.getDefaultCell().setBorderWidth(1);

        // XRF Spectra Rows
        Iterator<XFEFluorescenceSpectrum3VO> itES = xfeList.iterator();
        while (itES.hasNext()) {
            XFEFluorescenceSpectrum3VO col = itES.next();
            if (col.getEnergy() != null)
                tableXRF.addCell(new Paragraph(col.getEnergy().toString(), FONT_DOC));
            else
                tableXRF.addCell("");

            if (col.getExposureTime() != null)
                tableXRF.addCell(new Paragraph(col.getExposureTime().toString(), FONT_DOC));
            else
                tableXRF.addCell("");

            if (col.getBeamSizeHorizontal() != null)
                tableXRF.addCell(new Paragraph(col.getBeamSizeHorizontal().toString(), FONT_DOC));
            else
                tableXRF.addCell("");

            if (col.getBeamSizeVertical() != null)
                tableXRF.addCell(new Paragraph(col.getBeamSizeVertical().toString(), FONT_DOC));
            else
                tableXRF.addCell("");

            if (col.getBeamTransmission() != null)
                tableXRF.addCell(new Paragraph(col.getBeamTransmission().toString(), FONT_DOC));
            else
                tableXRF.addCell("");

            if (proposalCode.toLowerCase().equals(Constants.PROPOSAL_CODE_FX)) {
                // if (col.getCrystalClass()!= null) tableXRF.addCell(new
                // Paragraph(col.getCrystalClass().toString(), new
                // Font(Font.HELVETICA, 8)));
                // else tableXRF.addCell("");
                if (col.getCrystalClass() != null) {
                    int idCC = getCrystalClassIndex(listOfCrystalClass,
                            col.getCrystalClass().trim().toUpperCase());
                    if (idCC == -1) {
                        tableXRF.addCell(new Paragraph(col.getCrystalClass().toString(), FONT_DOC));
                    } else
                        tableXRF.addCell(
                                new Paragraph(listOfCrystalClass.get(idCC).getCrystalClassName(), FONT_DOC));
                } else
                    tableXRF.addCell("");
            }

            tableXRF.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
            if (col.getComments() != null)
                tableXRF.addCell(new Paragraph(col.getComments().toString(), FONT_DOC));
            else
                tableXRF.addCell("");
            tableXRF.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);

        }
        document.add(tableXRF);
    }
}

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

License:Open Source License

/**
 * set the summary - IFX proposal//from  www.jav  a 2  s .c  o m
 * 
 * @param document
 * @throws Exception
 */
private void setSummary(Document document) throws Exception {
    if (proposalCode.toLowerCase().equals(Constants.PROPOSAL_CODE_FX) && name == null) {
        document.add(new Paragraph(" "));
        document.add(new Paragraph("Summary:", FONT_TITLE));
        document.add(new Paragraph(" "));

        int NumColumnsCC = 2;
        Table tableCC = new Table(NumColumnsCC);
        int headerwidthsCC[] = { 30, 15 }; // percentage
        tableCC.setWidths(headerwidthsCC);

        tableCC.setWidth(50); // percentage
        tableCC.setPadding(3);
        tableCC.setCellsFitPage(true);
        tableCC.getDefaultCell().setBorderWidth(1);
        tableCC.getDefaultCell().setGrayFill(GREY_FILL_HEADER);
        tableCC.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
        tableCC.addCell(new Paragraph("Crystal class", FONT_DOC_BOLD));
        tableCC.addCell(new Paragraph("Number of crystals", FONT_DOC_BOLD));
        tableCC.getDefaultCell().setGrayFill(GREY_FILL_DATA);

        int nbCC = listOfCrystalClass.size();
        for (int cc = 0; cc < nbCC; cc++) {
            if (listOfNbCrystalPerClass.get(cc) > 0) {
                tableCC.addCell(new Paragraph(listOfCrystalClass.get(cc).getCrystalClassName() + " ("
                        + listOfCrystalClass.get(cc).getCrystalClassCode() + ")", FONT_DOC));
                tableCC.addCell(new Paragraph(listOfNbCrystalPerClass.get(cc).toString(), FONT_DOC));
            }
            LOG.debug("classe " + listOfCrystalClass.get(cc).getCrystalClassCode() + ": "
                    + listOfNbCrystalPerClass.get(cc).toString());
        }

        document.add(tableCC);

        // total
        // int nbPuckScreen = nbCrystal3;
        // int nbTotal = nbCrystal1 + nbCrystal2 + nbCrystalT;
        int nbPuckScreen = listOfNbCrystalPerClass.get(getCrystalClassIndex(listOfCrystalClass, "PS"));
        // nbTotal = C+CR+T+SC+SCR
        int nbTotal = listOfNbCrystalPerClass.get(getCrystalClassIndex(listOfCrystalClass, "C"))
                + listOfNbCrystalPerClass.get(getCrystalClassIndex(listOfCrystalClass, "SC"))
                + listOfNbCrystalPerClass.get(getCrystalClassIndex(listOfCrystalClass, "T"))
                + listOfNbCrystalPerClass.get(getCrystalClassIndex(listOfCrystalClass, "CR"))
                + listOfNbCrystalPerClass.get(getCrystalClassIndex(listOfCrystalClass, "SCR"));
        document.add(new Paragraph(" "));
        document.add(new Paragraph("Total number of tests: " + new String(new Integer(nbTotal).toString()),
                FONT_DOC));
        document.add(new Paragraph("Nb of puck screens: " + new String(new Integer(nbPuckScreen).toString()),
                FONT_DOC));
        document.add(new Paragraph(
                "Total number of samples: " + new String(new Integer(nbTotal + (nbPuckScreen * 10)).toString()),
                FONT_DOC));
    }
}

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

License:Open Source License

/**
 * set a table for a sessionDataObject//w  ww .j  a  v  a  2  s .c  om
 * 
 * @param document
 * @param sessionDataObject
 * @param mRequest
 */
private void setDetailSessionObjectTable(Document document, SessionDataObjectInformation sessionDataObject,
        HttpServletRequest mRequest) {
    try {
        int nbCol = 6;
        int nbRows = 5;
        List<Param> listParam = sessionDataObject.getListParameters();
        int idParam = 0;
        int nbParam = listParam.size();
        nbRows = Math.max(nbRows, nbParam);
        boolean secondGraph = sessionDataObject.getGraph2Path() != null
                && !sessionDataObject.getGraph2Path().isEmpty();
        if (secondGraph)
            nbCol += 1;

        Table table = new Table(nbCol);

        int l = 0;

        int[] headersWidth = new int[nbCol];

        headersWidth[l++] = 10; // def
        headersWidth[l++] = 6; // parameters title
        headersWidth[l++] = 6; // parameters value
        headersWidth[l++] = 12; // Thumbnail
        headersWidth[l++] = 12; // Snapshot
        headersWidth[l++] = 22; // Graph
        if (secondGraph)
            headersWidth[l++] = 22; // Graph2
        table.setWidths(headersWidth);

        table.setWidth(100); // percentage
        table.setPadding(1);
        table.setCellsFitPage(true);
        table.setTableFitsPage(true);
        table.setBorderWidth(1);
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
        // no header
        // first Row
        // firstCell: def : date
        SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
        String collectTime = formatter.format(sessionDataObject.getDataTime());
        Cell c = getCellValue(collectTime);
        c.setBorderWidthBottom(0);
        table.addCell(c);
        // second Cell param
        setCellParam(table, listParam, idParam++, 1);
        // third Cell : thumbnail
        Cell cellThumbnail = getCellImage(sessionDataObject.getImageThumbnailPath());
        cellThumbnail.setRowspan(nbRows);
        cellThumbnail.setBorderWidth(0);
        table.addCell(cellThumbnail);
        // 4 Cell : snapshot
        Cell cellSnapshot = getCellImage(sessionDataObject.getCrystalSnapshotPath());
        cellSnapshot.setRowspan(nbRows);
        cellSnapshot.setBorderWidth(0);
        table.addCell(cellSnapshot);
        // 5 Cell : graph
        Cell cellGraph = getCellGraph(sessionDataObject);
        cellGraph.setRowspan(nbRows);
        cellGraph.setBorderWidth(0);
        table.addCell(cellGraph);
        // 6 Cell : graph2
        if (secondGraph) {
            Cell cellGraph2 = getCellImage(sessionDataObject.getGraph2Path());
            cellGraph2.setRowspan(nbRows);
            cellGraph2.setBorderWidth(0);
            table.addCell(cellGraph2);
        }

        // second row
        Cell c2 = getCellValue(sessionDataObject.getImagePrefix() + " " + sessionDataObject.getRunNumber());
        c2.setBorderWidth(0);
        table.addCell(c2);
        // param2
        setCellParam(table, listParam, idParam++, 1);

        // third row
        Cell c3 = getCellValue(sessionDataObject.getExperimentType());
        c3.setBorderWidth(0);
        table.addCell(c3);
        // param3
        setCellParam(table, listParam, idParam++, 1);

        // 4 row
        Cell c4 = getCellValue(sessionDataObject.getSampleNameProtein());
        c4.setBorderWidth(0);
        table.addCell(c4);
        // param4
        setCellParam(table, listParam, idParam++, 1);

        // 5 row
        Cell c5 = new Cell();
        c5.setHorizontalAlignment(Element.ALIGN_LEFT);
        c5.add(new Paragraph(sessionDataObject.getComments(), FONT_DOC_ITALIC));
        c5.setBorderWidth(0);
        c5.setRowspan(nbRows - 4);
        table.addCell(c5);
        // param4
        setCellParam(table, listParam, idParam++, 1);

        for (int i = 5; i < nbRows; i++) {
            setCellParam(table, listParam, idParam++, 1);
        }

        // results
        // workflow result status
        if (sessionDataObject.isWorkflow()) {
            Cell resultCell = getWorkflowResult(sessionDataObject.getWorkflow(), mRequest);
            resultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
            resultCell.setColspan(nbCol);
            table.addCell(resultCell);
        }
        // collect OSC
        if ((sessionDataObject.isDataCollection()
                && !sessionDataObject.getDataCollection().getDataCollectionGroupVO().getExperimentType()
                        .equals(Constants.EXPERIMENT_TYPE_CHARACTERIZATION))) {
            DataCollectionExporter dcExporter = new DataCollectionExporter(df2, df3, proposalCode,
                    proposalNumber, mRequest);
            DataCollection3VO dataCollection = sessionDataObject.getDataCollection();
            DataCollectionInformation dcInfo = dcExporter.getDataCollectionInformation(dataCollection,
                    getSampleRankingVO(dataCollection.getDataCollectionId()),
                    getAutoProcRankingVO(dataCollection.getDataCollectionId()));
            Cell resultCell = getAutoProcResultStatus(dcInfo);
            resultCell.setColspan(nbCol);
            resultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(resultCell);
            document.add(table);
            document.add(new Paragraph(" ", VERY_SMALL_FONT));

            setAutoProcResultsTable(document, dcInfo);
        } else if (sessionDataObject.isWorkflow() && sessionDataObject.getWorkflow().isMXPressEOIA()) { // MXPRESS
            // wf
            DataCollectionExporter dcExporter = new DataCollectionExporter(df2, df3, proposalCode,
                    proposalNumber, mRequest);
            DataCollection3VO dataCollection = sessionDataObject.getListDataCollection().get(0);
            DataCollectionInformation dcInfo = dcExporter.getDataCollectionInformation(dataCollection,
                    getSampleRankingVO(dataCollection.getDataCollectionId()),
                    getAutoProcRankingVO(dataCollection.getDataCollectionId()));
            Cell resultCell = getAutoProcResultStatus(dcInfo);
            resultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
            resultCell.setColspan(nbCol);
            table.addCell(resultCell);

            document.add(table);
            document.add(new Paragraph(" ", VERY_SMALL_FONT));

            setAutoProcResultsTable(document, dcInfo);
        } else if ((sessionDataObject.isDataCollection()
                && sessionDataObject.getDataCollection().getDataCollectionGroupVO().getExperimentType()
                        .equals(Constants.EXPERIMENT_TYPE_CHARACTERIZATION))) { // Characterization
            DataCollectionExporter dcExporter = new DataCollectionExporter(df2, df3, proposalCode,
                    proposalNumber, mRequest);
            DataCollection3VO dataCollection = sessionDataObject.getDataCollection();
            DataCollectionInformation dcInfo = dcExporter.getDataCollectionInformation(dataCollection,
                    getSampleRankingVO(dataCollection.getDataCollectionId()),
                    getAutoProcRankingVO(dataCollection.getDataCollectionId()));
            Cell resultCell = getCharacterizationResultStatus(dcInfo, mRequest);
            resultCell.setColspan(nbCol);
            resultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(resultCell);
            document.add(table);
            document.add(new Paragraph(" ", VERY_SMALL_FONT));

            setStrategyTable2(document, dcInfo);
        } else {
            List<Param> listResults = sessionDataObject.getListResults();
            if (listResults != null) {
                int nbResults = listResults.size();
                for (int j = 0; j < nbResults; j++) {
                    setCellParam(table, listResults, j, 2);
                    Cell eCell = getEmptyCell(nbCol - 3);
                    eCell.setBorderWidth(0);
                    table.addCell(eCell);
                }
            }
            document.add(table);
            document.add(new Paragraph(" ", FONT_SPACE));
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

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

License:Open Source License

/**
 * set the EDNA Table/*from  w  w  w.j av a2s  .  com*/
 * 
 * @param document
 * @param dcInfo
 * @throws Exception
 */
private void setEDNATable(Document document, DataCollectionInformation dcInfo) throws Exception {
    if (dcInfo.getSpacegroup() != "") {
        int noCol = 4;
        Table tableEDNA = new Table(noCol);
        int headerEDNA[] = { 10, 10, 10, 10 }; // percentage
        tableEDNA.setWidths(headerEDNA);
        tableEDNA.setWidth(70); // percentage
        tableEDNA.setPadding(3);
        tableEDNA.setCellsFitPage(true);
        tableEDNA.setTableFitsPage(true);
        // tableEDNA.getDefaultCell().setBorderWidth(1);
        tableEDNA.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
        // EDNA Header
        tableEDNA.getDefaultCell().setBackgroundColor(BLUE_COLOR);
        tableEDNA.addCell(new Paragraph("Space Group", FONT_DOC_BOLD));
        tableEDNA.addCell(new Paragraph("Unit Cell", FONT_DOC_BOLD));
        tableEDNA.addCell(new Paragraph("Mosaicity\n(" + Constants.ANGSTROM + ")", FONT_DOC_BOLD));
        tableEDNA.addCell(new Paragraph("Ranking Resolution\n(" + Constants.ANGSTROM + ")", FONT_DOC_BOLD));
        tableEDNA.getDefaultCell().setBorderWidth(1);
        tableEDNA.getDefaultCell().setBackgroundColor(WHITE_COLOR);
        // EDNA data
        String unitCell = dcInfo.getCellA() + " (" + dcInfo.getCellAlpha() + ")\n" + dcInfo.getCellB() + " ("
                + dcInfo.getCellBeta() + ")\n" + dcInfo.getCellC() + " (" + dcInfo.getCellGamma() + ")";

        tableEDNA.addCell(new Paragraph(dcInfo.getSpacegroup(), FONT_DOC));
        tableEDNA.addCell(new Paragraph(unitCell, FONT_DOC));
        tableEDNA.addCell(new Paragraph(dcInfo.getMosaicity(), FONT_DOC));
        tableEDNA.addCell(new Paragraph(dcInfo.getResObserved(), FONT_DOC));
        //

        document.add(tableEDNA);
        document.add(new Paragraph(" ", VERY_SMALL_FONT));
    }
}

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

License:Open Source License

private void setEDNATable2(Document document, DataCollectionInformation dcInfo) throws Exception {
    if (dcInfo.getSpacegroup() != "") {
        int noCol = 4;
        Table tableEDNA = new Table(noCol);
        int headerEDNA[] = { 10, 10, 10, 10 }; // percentage
        tableEDNA.setWidths(headerEDNA);
        tableEDNA.setWidth(100); // percentage
        tableEDNA.setPadding(3);//from   w  w  w . j av  a 2 s.  co m
        tableEDNA.setCellsFitPage(true);
        tableEDNA.setTableFitsPage(true);
        // tableEDNA.getDefaultCell().setBorderWidth(1);
        tableEDNA.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
        // EDNA Header
        tableEDNA.getDefaultCell().setGrayFill(GREY_FILL_HEADER);
        tableEDNA.addCell(new Paragraph("Space Group", FONT_DOC_BOLD));
        tableEDNA.addCell(new Paragraph("Unit Cell (a, b, c, alpha, beta, gamma)", FONT_DOC_BOLD));
        tableEDNA.addCell(new Paragraph("Mosaicity (" + Constants.DEGREE + ")", FONT_DOC_BOLD));
        tableEDNA.addCell(new Paragraph("Ranking Resolution (" + Constants.ANGSTROM + ")", FONT_DOC_BOLD));
        tableEDNA.getDefaultCell().setBorderWidth(1);
        tableEDNA.getDefaultCell().setBackgroundColor(WHITE_COLOR);
        // EDNA data
        String unitCell = dcInfo.getCellA() + ", " + dcInfo.getCellB() + ", " + dcInfo.getCellC() + "\n"
                + dcInfo.getCellAlpha() + ", " + dcInfo.getCellBeta() + ", " + dcInfo.getCellGamma();
        tableEDNA.addCell(new Paragraph(dcInfo.getSpacegroup(), FONT_DOC));
        tableEDNA.addCell(new Paragraph(unitCell, FONT_DOC));
        tableEDNA.addCell(new Paragraph(dcInfo.getMosaicity(), FONT_DOC));
        tableEDNA.addCell(new Paragraph(dcInfo.getResObserved(), FONT_DOC));
        //

        document.add(tableEDNA);
        document.add(new Paragraph(" ", VERY_SMALL_FONT));
    }
}

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

License:Open Source License

/**
 * set the strategy table and wedge & subwedge strategy tables
 * /*  ww w .  j  a v  a2s  .c o  m*/
 * @param document
 * @param dcInfo
 * @throws Exception
 */
private void setStrategyTable(Document document, DataCollectionInformation dcInfo) throws Exception {
    // ------------------------------------------- Strategy Wedge
    // ------------------------------------------------
    List<StrategyWedgeInformation> strategyWedgeInformationList = dcInfo.getListStrategyWedgeInformation();
    for (Iterator<StrategyWedgeInformation> i = strategyWedgeInformationList.iterator(); i.hasNext();) {
        document.add(new Paragraph(" ", VERY_SMALL_FONT));
        StrategyWedgeInformation swi = i.next();
        Table strategyWedgeTable = new Table(10);
        int headerStrategyWedge[] = { 8, 10, 10, 10, 10, 10, 10, 10, 10, 20 }; // percentage
        strategyWedgeTable.setWidths(headerStrategyWedge);
        strategyWedgeTable.setWidth(100);
        strategyWedgeTable.setCellsFitPage(true);
        strategyWedgeTable.setTableFitsPage(true);
        strategyWedgeTable.setPadding(0);
        strategyWedgeTable.getDefaultCell().setBorderWidth(0);
        strategyWedgeTable.setBorderWidth(0);
        strategyWedgeTable.getDefaultCell().setBackgroundColor(WEDGE_COLOR);

        strategyWedgeTable.addCell(new Paragraph("Wedge number", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Resolution\n(" + Constants.ANGSTROM + ")", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Completeness", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Multiplicity", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Total dose", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Number of Images", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Phi\n(" + Constants.DEGREE + ")", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Kappa\n(" + Constants.DEGREE + ")", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Wavelength", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Comments", FONT_DOC_BOLD));

        strategyWedgeTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
        // rows
        strategyWedgeTable.addCell(new Paragraph(swi.getWedgeNumber(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getResolution(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getCompleteness(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getMultiplicity(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getDoseTotal(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getNumberOfImages(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getPhi(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getKappa(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getWavelength(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getComments(), FONT_DOC));

        document.add(strategyWedgeTable);

        // --- strategy sub wedge
        if (swi.getListStrategySubWedgeInformation().size() > 0) {
            document.add(new Paragraph(" ", VERY_SMALL_FONT));

            Table strategySubWedgeTable = new Table(12);
            int headerStrategySubWedge[] = { 8, 15, 10, 10, 10, 10, 10, 10, 10, 8, 8, 20 }; // percentage
            strategySubWedgeTable.setWidths(headerStrategySubWedge);
            strategySubWedgeTable.setWidth(80);
            strategySubWedgeTable.setCellsFitPage(true);
            strategySubWedgeTable.setTableFitsPage(true);
            strategySubWedgeTable.setPadding(0);
            strategySubWedgeTable.getDefaultCell().setBorderWidth(0);
            strategySubWedgeTable.setBorderWidth(0);
            strategySubWedgeTable.getDefaultCell().setBackgroundColor(SUBWEDGE_COLOR);

            strategySubWedgeTable.addCell(new Paragraph("Sub Wedge number", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Rotation axis", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Axis start", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Axis end", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Exposure time", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Transmission", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Oscillation Range", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Completeness", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Multiplicity", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Total dose", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Number of images", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Comments", FONT_DOC_BOLD));

            strategySubWedgeTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
            // rows
            for (Iterator<StrategySubWedgeInformation> s = swi.getListStrategySubWedgeInformation()
                    .iterator(); s.hasNext();) {
                StrategySubWedgeInformation sswi = s.next();
                strategySubWedgeTable.addCell(new Paragraph(sswi.getSubWedgeNumber(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getRotationAxis(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getAxisStart(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getAxisEnd(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getExposureTime(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getTransmission(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getOscillationRange(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getCompleteness(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getMultiplicity(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getDoseTotal(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getNumberOfImages(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getComments(), FONT_DOC));
            }
            document.add(strategySubWedgeTable);
        }
    }
    document.add(new Paragraph(" ", VERY_SMALL_FONT));
}

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

License:Open Source License

/**
 * set the strategy table and wedge & subwedge strategy tables copy from
 * setStrategyTable, waiting for feedback that we can remove the old reports
 * and the first method/* w w  w.  ja  v  a 2 s .c  om*/
 * 
 * @param document
 * @param dcInfo
 * @throws Exception
 */
private void setStrategyTable2(Document document, DataCollectionInformation dcInfo) throws Exception {
    // ------------------------------------------- Strategy Wedge
    // ------------------------------------------------
    List<StrategyWedgeInformation> strategyWedgeInformationList = dcInfo.getListStrategyWedgeInformation();
    for (Iterator<StrategyWedgeInformation> i = strategyWedgeInformationList.iterator(); i.hasNext();) {
        document.add(new Paragraph(" ", VERY_SMALL_FONT));
        StrategyWedgeInformation swi = i.next();
        Table strategyWedgeTable = new Table(10);
        int headerStrategyWedge[] = { 8, 10, 10, 10, 10, 10, 10, 10, 10, 20 }; // percentage
        strategyWedgeTable.setWidths(headerStrategyWedge);
        strategyWedgeTable.setWidth(100);
        strategyWedgeTable.setCellsFitPage(true);
        strategyWedgeTable.setTableFitsPage(true);
        strategyWedgeTable.setPadding(1);
        strategyWedgeTable.getDefaultCell().setBorderWidth(1);
        strategyWedgeTable.setBorderWidth(1);
        strategyWedgeTable.getDefaultCell().setBackgroundColor(LIGHT_GREY_COLOR);
        strategyWedgeTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);

        strategyWedgeTable.addCell(new Paragraph("Wedge number", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Resolution (" + Constants.ANGSTROM + ")", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Completeness", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Multiplicity", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Total dose", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Number of Images", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Phi (" + Constants.DEGREE + ")", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Kappa (" + Constants.DEGREE + ")", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Wavelength", FONT_DOC_BOLD));
        strategyWedgeTable.addCell(new Paragraph("Comments", FONT_DOC_BOLD));

        strategyWedgeTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
        // rows
        strategyWedgeTable.addCell(new Paragraph(swi.getWedgeNumber(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getResolution(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getCompleteness(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getMultiplicity(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getDoseTotal(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getNumberOfImages(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getPhi(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getKappa(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getWavelength(), FONT_DOC));
        strategyWedgeTable.addCell(new Paragraph(swi.getComments(), FONT_DOC));

        document.add(strategyWedgeTable);

        // --- strategy sub wedge
        if (swi.getListStrategySubWedgeInformation().size() > 0) {
            document.add(new Paragraph(" ", VERY_SMALL_FONT));

            Table strategySubWedgeTable = new Table(12);
            int headerStrategySubWedge[] = { 8, 15, 10, 10, 10, 10, 10, 10, 10, 8, 8, 20 }; // percentage
            strategySubWedgeTable.setWidths(headerStrategySubWedge);
            strategySubWedgeTable.setWidth(97);
            strategySubWedgeTable.setCellsFitPage(true);
            strategySubWedgeTable.setTableFitsPage(true);
            strategySubWedgeTable.setPadding(1);
            strategySubWedgeTable.getDefaultCell().setBorderWidth(1);
            strategySubWedgeTable.setBorderWidth(1);
            strategySubWedgeTable.getDefaultCell().setBackgroundColor(LIGHT_GREY_COLOR);
            strategySubWedgeTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);

            strategySubWedgeTable.addCell(new Paragraph("Sub Wedge number", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Rotation axis", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Axis start", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Axis end", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Exposure time", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Transmission", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Oscillation Range", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Completeness", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Multiplicity", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Total dose", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Number of images", FONT_DOC_BOLD));
            strategySubWedgeTable.addCell(new Paragraph("Comments", FONT_DOC_BOLD));

            strategySubWedgeTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
            // rows
            for (Iterator<StrategySubWedgeInformation> s = swi.getListStrategySubWedgeInformation()
                    .iterator(); s.hasNext();) {
                StrategySubWedgeInformation sswi = s.next();
                strategySubWedgeTable.addCell(new Paragraph(sswi.getSubWedgeNumber(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getRotationAxis(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getAxisStart(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getAxisEnd(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getExposureTime(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getTransmission(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getOscillationRange(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getCompleteness(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getMultiplicity(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getDoseTotal(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getNumberOfImages(), FONT_DOC));
                strategySubWedgeTable.addCell(new Paragraph(sswi.getComments(), FONT_DOC));
            }
            document.add(strategySubWedgeTable);
        }
    }
    document.add(new Paragraph(" ", VERY_SMALL_FONT));
}

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

License:Open Source License

/**
 * set the table for a given MXPressO/*from   w ww  . j a va2s .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

/**
 * set the autoproc results table, if no autoProc add a cell at the end of
 * topTable//from   w  w w  .j  a  v  a 2s .c  o m
 * 
 * @param document
 * @param topTable
 * @param collect
 * @throws Exception
 */
private void setAutoProcResultsTable(Document document, DataCollectionInformation collect) throws Exception {
    Integer idDc = -1;
    for (int k = 0; k < dataCollectionList.size(); k++) {
        DataCollection3VO dcVo = dataCollectionList.get(k);
        if (dcVo.getDataCollectionId().equals(collect.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.setHorizontalAlignment(Element.ALIGN_LEFT);
            // Table tableNR = new Table(1);
            // tableNR.setWidth(100); // percentage
            // tableNR.setPadding(3);
            // tableNR.setCellsFitPage(true);
            // tableNR.setTableFitsPage(true);
            // tableNR.getDefaultCell().setBorderWidth(1);
            // tableNR.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
            // tableNR.addCell(cNo);
            // document.add(tableNR);
        } 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(tableSPG);
        } // end autoProc null
    } // end idDc -1

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

From source file:jp.ac.utokyo.rcast.karkinos.graph.GetReadsStatsChart.java

License:Apache License

private static Object getSummaryTable(ReadsSummary readsSummary, String readsStat) {

    try {/*from www  .j  a v  a  2 s . c  o  m*/

        ReadsCounter normal = readsSummary.getNormalCounter();
        ReadsCounter tumor = readsSummary.getTumorCounter();

        Table table = new Table(3);
        int[] width = new int[] { 60, 20, 20 };
        table.setWidths(width);

        // row1
        table.addCell("reads stats/");
        table.addCell("normal");
        table.addCell("tumor");

        // // row
        if (readsStat != null) {

            String[] sa = readsStat.split(",");
            String normalfile = sa[0];
            Properties np = getProp(normalfile);
            String tumorfile = sa[1];
            Properties tp = getProp(tumorfile);
            // datamap.put("total", total);
            // datamap.put("passfilter", passfilter);
            // datamap.put("mapped", mapped);
            // datamap.put("nonduplicate", nonduplicate);
            // datamap.put("duplicate", duplicate);
            // //datamap.put("identityLow", identityLow);
            // datamap.put("unique", unique);
            // datamap.put("proper", proper);
            // datamap.put("properOrunique", properOrunique);
            // datamap.put("bincount", 1l);
            // datamap.put("afterrealgin", afterrealgin);
            // datamap.put("identityLow", identityLow);
            String[] keys = new String[] { "total", "passfilter", "mapped", "nonduplicate", "duplicate",
                    "unique", "proper", "properOrunique", "afterrealgin", "identityLow" };
            for (String key : keys) {
                if (np.containsKey(key)) {

                    // row2
                    String kyeDisp = key.replaceAll("Or", " or ");
                    table.addCell(kyeDisp + " tags");
                    table.addCell(format(np.getProperty(key)));
                    table.addCell(format(tp.getProperty(key)));

                    if (key.equals("duplicate")) {

                        try {
                            // row 13
                            table.addCell("duplicate (%)");
                            table.addCell(
                                    format(getParcent(np.getProperty(key), np.getProperty("nonduplicate")))
                                            + "%");
                            table.addCell(
                                    format(getParcent(tp.getProperty(key), tp.getProperty("nonduplicate")))
                                            + "%");
                        } catch (Exception ex) {
                        }
                    }
                }
            }

        }

        // row
        table.addCell("Total used tags");
        table.addCell(format(normal.getTotalmap()));
        table.addCell(format(tumor.getTotalmap()));

        // row4
        table.addCell("Target tags");
        table.addCell(format(normal.getTotalOnTarget()));
        table.addCell(format(tumor.getTotalOnTarget()));
        // row5
        table.addCell("Target unique tags");
        table.addCell(format(normal.getTotalUniqueOntarget()));
        table.addCell(format(tumor.getTotalUniqueOntarget()));

        if (readsSummary.isPairStats()) {

            // row6
            table.addCell("First reads");
            table.addCell(format(normal.getFirstReads()));
            table.addCell(format(tumor.getFirstReads()));
            // row7
            table.addCell("Second reads");
            table.addCell(format(normal.getSecondReads()));
            table.addCell(format(tumor.getSecondReads()));
            // row8
            table.addCell("Both mapped");
            table.addCell(format(normal.getBothmap()));
            table.addCell(format(tumor.getBothmap()));
            // row9
            table.addCell("Proper reads");
            table.addCell(format(normal.getPropermap()));
            table.addCell(format(tumor.getPropermap()));
            // row10
            table.addCell("mean library size");
            table.addCell(format(normal.getMeanInsertSize()));
            table.addCell(format(tumor.getMeanInsertSize()));

        }

        // // row11
        // row 12
        table.addCell("mean depth");
        table.addCell(format(readsSummary.getNormalDepth().getMeanDepth()));
        table.addCell(format(readsSummary.getTumorDepth().getMeanDepth()));

        table.addCell("total covered region");
        table.addCell(format(readsSummary.getNormalDepth().getTotal()));
        table.addCell(format(readsSummary.getTumorDepth().getTotal()));

        // row 13
        table.addCell("On target(%)");
        table.addCell(format(normal.onTargetParcent()) + "%");
        table.addCell(format(tumor.onTargetParcent()) + "%");

        table.addCell("more than X20(%)");
        table.addCell(format(getX20percent(readsSummary.getNormalDepth())) + "%");
        table.addCell(format(getX20percent(readsSummary.getTumorDepth())) + "%");

        table.addCell("mean depth CDS");
        table.addCell(format(readsSummary.getNormalDepth().getMeanCDSDepth()));
        table.addCell(format(readsSummary.getTumorDepth().getMeanCDSDepth()));

        table.addCell("more than X10(%) CDS");
        table.addCell(format(readsSummary.getNormalDepth().getOver10X()) + "%");
        table.addCell(format(readsSummary.getTumorDepth().getOver10X()) + "%");

        table.addCell("more than X20(%) CDS");
        table.addCell(format(readsSummary.getNormalDepth().getOver20X()) + "%");
        table.addCell(format(readsSummary.getTumorDepth().getOver20X()) + "%");

        return table;

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;

}