Example usage for com.lowagie.text Element ALIGN_CENTER

List of usage examples for com.lowagie.text Element ALIGN_CENTER

Introduction

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

Prototype

int ALIGN_CENTER

To view the source code for com.lowagie.text Element ALIGN_CENTER.

Click Source Link

Document

A possible value for paragraph alignment.

Usage

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

License:Open Source License

private void setRankingTable(Document document, DataCollectionInformation dcInfo) throws Exception {
    SampleRankingVO rankingVO = dcInfo.getSampleRankingVO();
    if (rankingVO == null) {
        return;/*from  w  w w .j a  v  a  2 s  .  c o  m*/
    }
    DecimalFormat decimalFormat1 = (DecimalFormat) NumberFormat.getInstance(Locale.US);
    decimalFormat1.applyPattern("0");
    DecimalFormat decimalFormat2 = (DecimalFormat) NumberFormat.getInstance(Locale.US);
    decimalFormat2.applyPattern("0.00");
    Table aTable = new Table(6);
    // aTable.setWidth(100); // percentage
    aTable.setPadding(3);
    aTable.setCellsFitPage(true);
    aTable.getDefaultCell().setBorderWidth(1);
    aTable.setBorderWidth(1);
    aTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    // header
    aTable.getDefaultCell().setGrayFill(GREY_FILL_HEADER);
    aTable.addCell(new Paragraph("Ranking Resolution\n(" + Constants.ANGSTROM + ")", FONT_DOC_BOLD));
    aTable.addCell(new Paragraph("Exposure Time\n(s)", FONT_DOC_BOLD));
    aTable.addCell(new Paragraph("Mosaicity\n(" + Constants.DEGREE + ")", FONT_DOC_BOLD));
    aTable.addCell(new Paragraph("Number of spots", FONT_DOC_BOLD));
    aTable.addCell(new Paragraph("Number of images", FONT_DOC_BOLD));
    aTable.addCell(new Paragraph("Total", FONT_DOC_BOLD));
    aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    // row
    String rankRes = "#" + decimalFormat1.format(rankingVO.getTheoreticalResolutionRank());
    if (rankingVO.getTheoreticalResolutionValue() != null
            && !Double.isNaN(rankingVO.getTheoreticalResolutionValue())) {
        rankRes += "   " + decimalFormat2.format(rankingVO.getTheoreticalResolutionValue());
    }
    String rankExp = "#" + decimalFormat1.format(rankingVO.getTotalExposureTimeRank());
    if (rankingVO.getTotalExposureTimeValue() != null && !Double.isNaN(rankingVO.getTotalExposureTimeValue())) {
        rankExp += "   " + decimalFormat2.format(rankingVO.getTotalExposureTimeValue());
    }
    String rankMos = "#" + decimalFormat1.format(rankingVO.getMosaicityRank());
    if (rankingVO.getMosaicityValue() != null && !Double.isNaN(rankingVO.getMosaicityValue())) {
        rankMos += "   " + decimalFormat2.format(rankingVO.getMosaicityValue());
    }
    String rankSpot = "#" + decimalFormat1.format(rankingVO.getNumberOfSpotsIndexedRank());
    if (rankingVO.getNumberOfSpotsIndexedValue() != null
            && !Double.isNaN(rankingVO.getNumberOfSpotsIndexedValue())) {
        rankSpot += "   " + decimalFormat1.format(rankingVO.getNumberOfSpotsIndexedValue());
    }
    String rankImages = "#" + decimalFormat1.format(rankingVO.getNumberOfImagesRank());
    if (rankingVO.getNumberOfImagesValue() != null && !Double.isNaN(rankingVO.getNumberOfImagesValue())) {
        rankImages += "   " + decimalFormat1.format(rankingVO.getNumberOfImagesValue());
    }
    String rankTotal = "#" + decimalFormat1.format(rankingVO.getTotalRank());
    if (rankingVO.getTotalScore() != null && !Double.isNaN(rankingVO.getTotalScore())) {
        rankTotal += "   " + decimalFormat1.format(rankingVO.getTotalScore()) + " %";
    }
    // ... rank res
    if (rankingVO.getTheoreticalResolutionRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getTheoreticalResolutionValue() == null
            || Double.isNaN(rankingVO.getTheoreticalResolutionValue())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankRes, FONT_DOC));
    // ... exp. time
    if (rankingVO.getTotalExposureTimeRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getTotalExposureTimeValue() == null
            || Double.isNaN(rankingVO.getTotalExposureTimeValue())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankExp, FONT_DOC));
    // ... mosaicity
    if (rankingVO.getMosaicityRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getMosaicityValue() == null || Double.isNaN(rankingVO.getMosaicityValue())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankMos, FONT_DOC));
    // ... number of spots
    if (rankingVO.getNumberOfSpotsIndexedRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getNumberOfSpotsIndexedValue() == null
            || Double.isNaN(rankingVO.getNumberOfSpotsIndexedValue())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankSpot, FONT_DOC));
    // ... number of images
    if (rankingVO.getNumberOfImagesRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getNumberOfImagesValue() == null || Double.isNaN(rankingVO.getNumberOfImagesValue())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankImages, FONT_DOC));
    // ... total
    if (rankingVO.getTotalRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getTotalScore() == null || Double.isNaN(rankingVO.getTotalScore())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankTotal, FONT_DOC));
    //
    document.add(aTable);
    document.add(new Paragraph(" ", VERY_SMALL_FONT));
}

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

License:Open Source License

private void setAutoProcRankingTable(Document document, DataCollectionInformation dcInfo) throws Exception {
    AutoProcRankingVO rankingVO = dcInfo.getAutoProcRankingVO();
    if (rankingVO == null) {
        return;// w w w .  ja  va2s.co  m
    }
    DecimalFormat decimalFormat1 = (DecimalFormat) NumberFormat.getInstance(Locale.US);
    decimalFormat1.applyPattern("0");
    DecimalFormat decimalFormat2 = (DecimalFormat) NumberFormat.getInstance(Locale.US);
    decimalFormat2.applyPattern("0.00");
    Table aTable = new Table(4);
    // aTable.setWidth(100); // percentage
    aTable.setPadding(3);
    aTable.setCellsFitPage(true);
    aTable.getDefaultCell().setBorderWidth(1);
    aTable.setBorderWidth(1);
    aTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    // header
    aTable.getDefaultCell().setGrayFill(GREY_FILL_HEADER);
    aTable.addCell(new Paragraph("R-factor\n(" + Constants.ANGSTROM + ")", FONT_DOC_BOLD));
    aTable.addCell(new Paragraph("Highest resolution\n(" + Constants.ANGSTROM + ")", FONT_DOC_BOLD));
    aTable.addCell(new Paragraph("Completeness\n(%)", FONT_DOC_BOLD));
    aTable.addCell(new Paragraph("Total", FONT_DOC_BOLD));
    aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    // row
    String rankRfactor = "#" + decimalFormat1.format(rankingVO.getOverallRFactorRank());
    if (rankingVO.getOverallRFactorValue() != null && !Double.isNaN(rankingVO.getOverallRFactorValue())) {
        rankRfactor += "   " + decimalFormat2.format(rankingVO.getOverallRFactorValue());
    }
    String rankHighestRes = "#" + decimalFormat1.format(rankingVO.getHighestResolutionRank());
    if (rankingVO.getHighestResolutionValue() != null && !Double.isNaN(rankingVO.getHighestResolutionValue())) {
        rankHighestRes += "   " + decimalFormat2.format(rankingVO.getHighestResolutionValue());
    }
    String rankCom = "#" + decimalFormat1.format(rankingVO.getCompletenessRank());
    if (rankingVO.getCompletenessValue() != null && !Double.isNaN(rankingVO.getCompletenessValue())) {
        rankCom += "   " + decimalFormat2.format(rankingVO.getCompletenessValue());
    }
    String rankTotal = "#" + decimalFormat1.format(rankingVO.getTotalRank());
    if (rankingVO.getTotalScore() != null && !Double.isNaN(rankingVO.getTotalScore())) {
        rankTotal += "   " + decimalFormat1.format(rankingVO.getTotalScore()) + " %";
    }
    // ... R-factor
    if (rankingVO.getOverallRFactorRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getOverallRFactorValue() == null || Double.isNaN(rankingVO.getOverallRFactorValue())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankRfactor, FONT_DOC));
    // ... highest resolution
    if (rankingVO.getHighestResolutionRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getHighestResolutionValue() == null
            || Double.isNaN(rankingVO.getHighestResolutionValue())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankHighestRes, FONT_DOC));
    // ... completeness
    if (rankingVO.getCompletenessRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getCompletenessValue() == null || Double.isNaN(rankingVO.getCompletenessValue())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankCom, FONT_DOC));
    // ... total
    if (rankingVO.getTotalRank() == 1) {
        aTable.getDefaultCell().setBackgroundColor(GREEN_COLOR_RANK);
    } else if (rankingVO.getTotalScore() == null || Double.isNaN(rankingVO.getTotalScore())) {
        aTable.getDefaultCell().setBackgroundColor(NULL_COLOR_RANK);
    } else {
        aTable.getDefaultCell().setBackgroundColor(WHITE_COLOR);
    }
    aTable.addCell(new Paragraph(rankTotal, FONT_DOC));
    //
    document.add(aTable);
    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/*www .  ja v  a 2s. c  o m*/
 * 
 * @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 the cell for the mesh map//from  w w w.  ja  va 2s  . co  m
 * 
 * @param wfMesh
 * @return
 */
private Cell getMeshMapCell(WorkflowMesh3VO wfMesh) {
    String imgMap = null;
    String cartographyPath = wfMesh.getCartographyPath();
    if (cartographyPath != null) {
        imgMap = PathUtils.FitPathToOS(cartographyPath);
    }
    try {
        if (imgMap != null) {
            Image jpgMap = Image.getInstance(imgMap);
            // System.out.println(jpgMap.getWidth()+" * "+jpgMap.getHeight());
            jpgMap.scaleAbsolute(jpgMap.getWidth() * IMAGE_HEIGHT / jpgMap.getHeight(), IMAGE_HEIGHT);
            Cell cellImage = new Cell(jpgMap);
            cellImage.setLeading(0);
            cellImage.setBorderWidth(0);
            cellImage.setHorizontalAlignment(Element.ALIGN_CENTER);
            return cellImage;
        } else {
            return new Cell(new Paragraph("no map found", FONT_DOC));
        }
    } catch (IOException e) {
        try {
            return new Cell(new Paragraph(imgMap + " not found", FONT_DOC));
        } catch (BadElementException e1) {
            e1.printStackTrace();
            return null;
        }
    } catch (Exception e) {
        try {
            return new Cell(new Paragraph(imgMap + " not found", FONT_DOC));
        } catch (BadElementException e1) {
            e1.printStackTrace();
            return null;
        }
    }

}

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

License:Open Source License

/**
 * returns a cell with a given image inside
 * //from w  w w . j av a2s.c o  m
 * @param image
 * @return
 * @throws Exception
 */
private Cell getCellImage(String image) throws Exception {
    if (image != null && !image.equals("")) {
        try {
            Image jpg1 = Image.getInstance(image);
            jpg1.scaleAbsolute(jpg1.getWidth() * IMAGE_HEIGHT / jpg1.getHeight(), IMAGE_HEIGHT);
            Cell cell = new Cell(jpg1);
            cell.setLeading(0);
            cell.setBorderWidth(0);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_CENTER);
            return cell;
        } catch (IOException e) {
            return new Cell(new Paragraph(image + " not found", FONT_DOC));
        }
    }
    return new Cell(new Paragraph("", FONT_DOC));
}

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//w  ww.  j ava  2  s.co 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:ispyb.client.mx.collection.PdfRtfExporter.java

License:Open Source License

/**
 * set a line for a specified dataCollection in the dataCollection table
 * /*from   ww  w  .ja va2 s .c om*/
 * @param document
 * @param table
 * @param col
 * @param session
 * @param df2
 * @param df3
 * @throws Exception
 */
private void setDataCollectionData2(Document document, Table table, DataCollection3VO col,
        Session3Service sessionService, AutoProc3VO autoProcValue, AutoProcScalingStatistics3VO autoProcOverall,
        AutoProcScalingStatistics3VO autoProcInner, AutoProcScalingStatistics3VO autoProcOuter,
        boolean withAutoProcessing, boolean setEDNAInfo, ScreeningOutput3VO screeningOutput,
        ScreeningOutputLattice3VO screeningOutputLattice, String nbImage) throws Exception {
    // Session3VO slv = sessionService.findByPk(col.getSessionId(), false,
    // false, false);
    DataCollectionGroup3VO dcGroup = col.getDataCollectionGroupVO();
    Session3VO slv = dcGroup.getSessionVO();
    // here slv is not null
    if (col.getNumberOfImages() != null) {
        if (!DataCollectionExporter.isDataCollectionScreening(col)) {
            table.getDefaultCell().setGrayFill(GREY_FILL_DATA_COLLECT);
        } else
            table.getDefaultCell().setGrayFill(GREY_FILL_DATA);
    }
    if (col.getImagePrefix() != null)
        table.addCell(new Paragraph(col.getImagePrefix(), FONT_DOC));
    else
        table.addCell("");
    // The beamline name is only displayed for select by protein or by
    // sample name
    if (name != null) {
        if (slv.getBeamlineName() != null)
            table.addCell(new Paragraph(slv.getBeamlineName(), FONT_DOC));
        else
            table.addCell("");
    }

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

    if (nbImage != null)
        table.addCell(new Paragraph(nbImage, FONT_DOC));
    else
        table.addCell("");

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

        // unit cell
        if (autoProcValue != null && autoProcValue.getSpaceGroup() != null)
            table.addCell(new Paragraph(autoProcValue.getRefinedCellA() + " ("
                    + autoProcValue.getRefinedCellAlpha() + ")\n" + autoProcValue.getRefinedCellB() + " ("
                    + autoProcValue.getRefinedCellBeta() + ")\n" + autoProcValue.getRefinedCellC() + " ("
                    + autoProcValue.getRefinedCellGamma() + ")", FONT_DOC));
        else if (setEDNAInfo && screeningOutputLattice != null && screeningOutputLattice.getUnitCell_a() != null
                && screeningOutputLattice.getUnitCell_b() != null
                && screeningOutputLattice.getUnitCell_c() != null
                && screeningOutputLattice.getUnitCell_alpha() != null
                && screeningOutputLattice.getUnitCell_beta() != null
                && screeningOutputLattice.getUnitCell_gamma() != null) {
            Paragraph p = new Paragraph(df3.format(screeningOutputLattice.getUnitCell_a()) + " ("
                    + df3.format(screeningOutputLattice.getUnitCell_alpha()) + ")\n"
                    + df3.format(screeningOutputLattice.getUnitCell_b()) + " ("
                    + df3.format(screeningOutputLattice.getUnitCell_beta()) + ")\n"
                    + df3.format(screeningOutputLattice.getUnitCell_c()) + " ("
                    + df3.format(screeningOutputLattice.getUnitCell_gamma()) + ")", FONT_DOC);
            table.addCell(p);
        } else
            table.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();
        } else if (setEDNAInfo && screeningOutput != null && screeningOutput.getRankingResolution() != null) {
            resolutionString = df2.format(screeningOutput.getRankingResolution());
        }
        table.addCell(new Paragraph(completenessString, FONT_DOC));
        table.addCell(new Paragraph(rSymmString, FONT_DOC));
        table.addCell(new Paragraph(resolutionString, FONT_DOC));
    }

    // detector resolution
    if (col.getResolution() != null)
        table.addCell(new Paragraph(df2.format(col.getResolution()), FONT_DOC));
    else
        table.addCell("");

    // wavelength
    if (col.getWavelength() != null)
        table.addCell(new Paragraph(df3.format(col.getWavelength()), FONT_DOC));
    else
        table.addCell("");

    // phi range
    if (col.getAxisRange() != null)
        table.addCell(new Paragraph(df2.format(col.getAxisRange()), FONT_DOC));
    else
        table.addCell("");

    // Column crystalClass only for IFX proposal in case of MXPress
    // experiment
    if (proposalCode.toLowerCase().equals(Constants.PROPOSAL_CODE_FX)) {
        // if (col.getCrystalClass() != null && col.getCrystalClass() != "")
        // table.addCell(new
        // Paragraph(col.getCrystalClass(), new Font(Font.HELVETICA, 8)));
        // else table.addCell("");
        DataCollectionGroup3Service dataCollectionGroupService = (DataCollectionGroup3Service) ejb3ServiceLocator
                .getLocalService(DataCollectionGroup3Service.class);
        DataCollectionGroup3VO group = dataCollectionGroupService.findByPk(col.getDataCollectionGroupVOId(),
                true, true);
        boolean firstCollect = group.isFirstCollect(col);
        if (dcGroup.getCrystalClass() != null) {
            int idCC = getCrystalClassIndex(listOfCrystalClass, dcGroup.getCrystalClass().trim().toUpperCase());
            String crystalS = "";
            if (idCC == -1) {
                crystalS = dcGroup.getCrystalClass().toString();
            } else {
                crystalS = listOfCrystalClass.get(idCC).getCrystalClassName();
            }
            String crystalCell = crystalS;
            if (!firstCollect && crystalS != null && !crystalS.equals("")) {
                crystalCell = "(" + crystalS + ")";
            }
            table.addCell(new Paragraph(crystalCell, FONT_DOC));
        } else
            table.addCell("");

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

From source file:ispyb.client.mx.results.ExportAutoProcAction.java

License:Open Source License

/**
 * sets the header in the specified document
 * //from   w w  w .java2s .co m
 * @param document
 * @throws Exception
 */
private void setHeader(Document document) throws Exception {
    HeaderFooter header;
    String h = "Auto Processing for Proposal: " + proposalCode + proposalNumber;
    if (slv != null) {
        h += " on Beamline: " + (slv.getBeamlineName() == null ? "" : slv.getBeamlineName())
                + "  ---  Session start date: "
                + (slv.getStartDate() == null ? "" : Formatter.formatDate(slv.getStartDate()));
    }
    header = new HeaderFooter(new Phrase(h, PdfRtfExporter.FONT_HELVETICA_10), false);
    header.setAlignment(Element.ALIGN_CENTER);
    header.setBorderWidth(1);
    header.getBefore().getFont().setSize(PdfRtfExporter.SIZE_FONT);
    document.setHeader(header);
}

From source file:ispyb.common.util.export.ExiPdfRtfExporter.java

License:Open Source License

/**
 * sets the header in the specified document
 * /*from  w w  w  .  j av  a 2s  .  co m*/
 * @param document
 * @throws Exception
 */
private void setHeader(Document document) throws Exception {
    HeaderFooter header;
    String h = "Data Collections for Proposal: " + proposalDesc;
    if (slv != null) {
        h += " on Beamline: " + (slv.getBeamlineName() == null ? "" : slv.getBeamlineName())
                + "  ---  Session start date: "
                + (slv.getStartDate() == null ? "" : Formatter.formatDate(slv.getStartDate()));
    }
    header = new HeaderFooter(new Phrase(h, FONT_HELVETICA_10), false);
    header.setAlignment(Element.ALIGN_CENTER);
    header.setBorderWidth(1);
    header.getBefore().getFont().setSize(SIZE_FONT);
    document.setHeader(header);
}

From source file:ispyb.common.util.export.ExiPdfRtfExporter.java

License:Open Source License

/**
 * returns a cell with a given image inside
 * // ww  w.ja  va2s  .c  o  m
 * @param image
 * @return
 * @throws Exception
 */
private Cell getCellImage(Map<String, Object> dataCollectionMapItem, String imageParam) throws Exception {

    if (dataCollectionMapItem.get(imageParam) != null
            && !(dataCollectionMapItem.get(imageParam).toString()).equals("")) {
        String image = dataCollectionMapItem.get(imageParam).toString();
        image = PathUtils.getPath(image);
        try {
            Image jpg1 = Image.getInstance(image);
            jpg1.scaleAbsolute(jpg1.getWidth() * IMAGE_HEIGHT / jpg1.getHeight(), IMAGE_HEIGHT);
            Cell cell = new Cell(jpg1);
            cell.setLeading(0);
            cell.setBorderWidth(0);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_CENTER);
            return cell;
        } catch (IOException e) {
            return new Cell(new Paragraph(image + " not found", FONT_DOC));
        }
    }
    return new Cell(new Paragraph("", FONT_DOC));
}