List of usage examples for com.lowagie.text Table addCell
public void addCell(String content) throws BadElementException
Cell
to the Table
. 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 ww. j a v a2 s . c om } 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 ww . j a v a 2s .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(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//from w ww . j ava 2 s.co 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
/** * 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:ispyb.client.mx.collection.PdfRtfExporter.java
License:Open Source License
/** * set a line for a specified dataCollection in the dataCollection table * //from w w w .ja va 2s .co m * @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
private void setAutoProcInfo(Document document) throws Exception { // header/* w w w . ja v a 2s. c o m*/ Table headerTable = new Table(1); headerTable.getDefaultCell().setBorderWidth(0); headerTable.setBorderWidth(0); headerTable.setCellsFitPage(true); headerTable.setAlignment(Element.ALIGN_LEFT); headerTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); headerTable.getDefaultCell().setBackgroundColor(PdfRtfExporter.LIGHT_YELLOW_COLOR); headerTable.getDefaultCell().setLeading(3); headerTable.setWidth(100); // percentage headerTable .addCell(new Paragraph("Crystal data and data-collection statistics", PdfRtfExporter.FONT_DOC_11)); headerTable.addCell(new Paragraph("Values in parentheses are for the highest resolution shell.", PdfRtfExporter.FONT_DOC_11)); document.add(headerTable); document.add(new Paragraph(" ", PdfRtfExporter.VERY_SMALL_FONT)); // auto proc table Table autoProcTable = new Table(2); autoProcTable.getDefaultCell().setBorderWidth(0); autoProcTable.setBorderWidth(0); autoProcTable.setCellsFitPage(true); autoProcTable.setAlignment(Element.ALIGN_LEFT); autoProcTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); // autoProcTable.getDefaultCell().setLeading(3); autoProcTable.setPadding(2); autoProcTable.setWidth(100); // percentage // data String spaceGroup = autoProc == null ? "" : autoProc.getSpaceGroup(); String unitCell_a = autoProc == null ? "" : autoProc.getRefinedCellA().toString(); String unitCell_b = autoProc == null ? "" : autoProc.getRefinedCellB().toString(); String unitCell_c = autoProc == null ? "" : autoProc.getRefinedCellC().toString(); String unitCell_alpha = autoProc == null ? "" : autoProc.getRefinedCellAlpha().toString(); String unitCell_beta = autoProc == null ? "" : autoProc.getRefinedCellBeta().toString(); String unitCell_gamma = autoProc == null ? "" : autoProc.getRefinedCellGamma().toString(); String resolutionRange = ""; String nTotalObservations = ""; String nTotalUniqueReflections = ""; String completeness = ""; String multiplicity = ""; String isigma = ""; String rmerge = ""; if (autoProcStatisticsOverall != null) { resolutionRange = autoProcStatisticsOverall.getResolutionLimitLow() + " - " + autoProcStatisticsOverall.getResolutionLimitHigh(); nTotalObservations = "" + autoProcStatisticsOverall.getnTotalObservations(); nTotalUniqueReflections = "" + (autoProcStatisticsOverall.getnTotalUniqueObservations() == null ? "" : autoProcStatisticsOverall.getnTotalUniqueObservations()); completeness = "" + autoProcStatisticsOverall.getCompleteness(); multiplicity = "" + autoProcStatisticsOverall.getMultiplicity(); isigma = "" + autoProcStatisticsOverall.getMeanIoverSigI(); rmerge = "" + (autoProcStatisticsOverall.getRmerge() == null ? "" : autoProcStatisticsOverall.getRmerge()); } if (autoProcStatisticsOuter != null) { resolutionRange += " (" + autoProcStatisticsOuter.getResolutionLimitLow() + " - " + autoProcStatisticsOuter.getResolutionLimitHigh() + ")"; nTotalObservations += " (" + autoProcStatisticsOuter.getnTotalObservations() + ")"; nTotalUniqueReflections += autoProcStatisticsOuter.getnTotalUniqueObservations() == null ? "" : (" (" + autoProcStatisticsOuter.getnTotalUniqueObservations() + ")"); completeness += " (" + autoProcStatisticsOuter.getCompleteness() + ")"; multiplicity += " (" + autoProcStatisticsOuter.getMultiplicity() + ")"; isigma += " (" + autoProcStatisticsOuter.getMeanIoverSigI() + ")"; rmerge += " (" + (autoProcStatisticsOuter.getRmerge() == null ? "" : autoProcStatisticsOuter.getRmerge()) + ")"; } // space group autoProcTable.addCell(new Paragraph("Space Group", PdfRtfExporter.FONT_DOC_11)); autoProcTable.addCell(new Paragraph(spaceGroup, PdfRtfExporter.FONT_DOC_11)); // unit cell parameters autoProcTable.addCell( new Paragraph("Unit-cell parameters (" + Constants.ANGSTROM + ")", PdfRtfExporter.FONT_DOC_11)); autoProcTable.addCell(new Paragraph("", PdfRtfExporter.FONT_DOC_11)); Paragraph pa = new Paragraph("\t a", PdfRtfExporter.FONT_DOC_11); pa.setAlignment(Element.ALIGN_JUSTIFIED); pa.setIndentationLeft(PdfRtfExporter.INDENTATION_LEFT); autoProcTable.addCell(pa); autoProcTable.addCell(new Paragraph(unitCell_a, PdfRtfExporter.FONT_DOC_11)); Paragraph pb = new Paragraph("\t b", PdfRtfExporter.FONT_DOC_11); pb.setAlignment(Element.ALIGN_JUSTIFIED); pb.setIndentationLeft(PdfRtfExporter.INDENTATION_LEFT); autoProcTable.addCell(pb); autoProcTable.addCell(new Paragraph(unitCell_b, PdfRtfExporter.FONT_DOC_11)); Paragraph pc = new Paragraph("\t c", PdfRtfExporter.FONT_DOC_11); pc.setAlignment(Element.ALIGN_JUSTIFIED); pc.setIndentationLeft(PdfRtfExporter.INDENTATION_LEFT); autoProcTable.addCell(pc); autoProcTable.addCell(new Paragraph(unitCell_c, PdfRtfExporter.FONT_DOC_11)); // Issue 1733: cell angles info added Paragraph palpha = new Paragraph("\t alpha", PdfRtfExporter.FONT_DOC_11); palpha.setAlignment(Element.ALIGN_JUSTIFIED); palpha.setIndentationLeft(PdfRtfExporter.INDENTATION_LEFT); autoProcTable.addCell(palpha); autoProcTable.addCell(new Paragraph(unitCell_alpha, PdfRtfExporter.FONT_DOC_11)); Paragraph pbeta = new Paragraph("\t beta", PdfRtfExporter.FONT_DOC_11); pbeta.setAlignment(Element.ALIGN_JUSTIFIED); pbeta.setIndentationLeft(PdfRtfExporter.INDENTATION_LEFT); autoProcTable.addCell(pbeta); autoProcTable.addCell(new Paragraph(unitCell_beta, PdfRtfExporter.FONT_DOC_11)); Paragraph pgamma = new Paragraph("\t gamma", PdfRtfExporter.FONT_DOC_11); pgamma.setAlignment(Element.ALIGN_JUSTIFIED); pgamma.setIndentationLeft(PdfRtfExporter.INDENTATION_LEFT); autoProcTable.addCell(pgamma); autoProcTable.addCell(new Paragraph(unitCell_gamma, PdfRtfExporter.FONT_DOC_11)); // resolution range autoProcTable.addCell( new Paragraph("Resolution range (" + Constants.ANGSTROM + ")", PdfRtfExporter.FONT_DOC_11)); autoProcTable.addCell(new Paragraph(resolutionRange, PdfRtfExporter.FONT_DOC_11)); // Observed reflections autoProcTable.addCell(new Paragraph("Observed reflections", PdfRtfExporter.FONT_DOC_11)); autoProcTable.addCell(new Paragraph(nTotalObservations, PdfRtfExporter.FONT_DOC_11)); // No. of unique reflections autoProcTable.addCell(new Paragraph("No. of unique reflections", PdfRtfExporter.FONT_DOC_11)); autoProcTable.addCell(new Paragraph(nTotalUniqueReflections, PdfRtfExporter.FONT_DOC_11)); // Completeness autoProcTable.addCell(new Paragraph("Completeness (%)", PdfRtfExporter.FONT_DOC_11)); autoProcTable.addCell(new Paragraph(completeness, PdfRtfExporter.FONT_DOC_11)); // multiplicity autoProcTable.addCell(new Paragraph("Multiplicity", PdfRtfExporter.FONT_DOC_11)); autoProcTable.addCell(new Paragraph(multiplicity, PdfRtfExporter.FONT_DOC_11)); new Phrase(); // I/(I) Phrase p = Phrase.getInstance("<I/" + (char) 963 + "(I)>"); p.setFont(PdfRtfExporter.FONT_DOC_11); autoProcTable.addCell(p); autoProcTable.addCell(new Paragraph(isigma, PdfRtfExporter.FONT_DOC_11)); // Rmerge Chunk c1 = new Chunk("R", PdfRtfExporter.FONT_DOC_11); Chunk c2 = new Chunk("merge", PdfRtfExporter.FONT_DOC_EXPONENT); c2.setTextRise(PdfRtfExporter.TEXT_RISE_SUB); Chunk c3 = new Chunk("(%)", PdfRtfExporter.FONT_DOC_11); Chunk c4 = new Chunk("#", PdfRtfExporter.FONT_DOC_EXPONENT_BLUE); c4.setTextRise(PdfRtfExporter.TEXT_RISE_EXP); Paragraph rMergeParagraph = new Paragraph(); rMergeParagraph.add(c1); rMergeParagraph.add(c2); rMergeParagraph.add(c3); rMergeParagraph.add(c4); autoProcTable.addCell(rMergeParagraph); autoProcTable.addCell(new Paragraph(rmerge, PdfRtfExporter.FONT_DOC_11)); document.add(autoProcTable); document.add(new Paragraph(" ", PdfRtfExporter.FONT_DOC_11)); // nota bene info Paragraph nbParagraph = new Paragraph(); nbParagraph.add(c4); nbParagraph.add(c1); nbParagraph.add(c2); Chunk cesp = new Chunk(" ", PdfRtfExporter.FONT_DOC_11); Chunk c5 = new Chunk(" = ", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c5); Phrase pSigma = Phrase.getInstance("" + (char) 931); pSigma.setFont(PdfRtfExporter.FONT_DOC_11); nbParagraph.add(pSigma); Chunk chkl = new Chunk("hkl", PdfRtfExporter.FONT_DOC_EXPONENT); chkl.setTextRise(PdfRtfExporter.TEXT_RISE_SUB); nbParagraph.add(chkl); nbParagraph.add(cesp); nbParagraph.add(pSigma); Chunk ci = new Chunk("i", PdfRtfExporter.FONT_DOC_EXPONENT); ci.setTextRise(PdfRtfExporter.TEXT_RISE_SUB); nbParagraph.add(ci); Chunk c8 = new Chunk(" |I", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c8); nbParagraph.add(ci); Chunk c9 = new Chunk("(hkl) - (I(hkl))| / ", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c9); nbParagraph.add(pSigma); nbParagraph.add(chkl); nbParagraph.add(cesp); nbParagraph.add(pSigma); nbParagraph.add(ci); nbParagraph.add(cesp); Chunk c10 = new Chunk("I", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c10); nbParagraph.add(ci); Chunk c11 = new Chunk("(hkl), where ", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c11); Chunk c12 = new Chunk("I", PdfRtfExporter.FONT_DOC_11_ITALIC); nbParagraph.add(c12); Chunk cii = new Chunk("i", PdfRtfExporter.FONT_DOC_EXPONENT_ITALIC); cii.setTextRise(PdfRtfExporter.TEXT_RISE_SUB); nbParagraph.add(cii); Chunk c13 = new Chunk("(hkl)", PdfRtfExporter.FONT_DOC_11_ITALIC); nbParagraph.add(c13); Chunk c14 = new Chunk(" is the ", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c14); Chunk c15 = new Chunk("i", PdfRtfExporter.FONT_DOC_11_ITALIC); nbParagraph.add(c15); Chunk c16 = new Chunk("th observation of reflection ", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c16); Chunk chklI = new Chunk("hkl", PdfRtfExporter.FONT_DOC_11_ITALIC); nbParagraph.add(chklI); Chunk c17 = new Chunk(" and ", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c17); Chunk c18 = new Chunk("<I(hkl)> ", PdfRtfExporter.FONT_DOC_11_ITALIC); nbParagraph.add(c18); Chunk c19 = new Chunk(" is the weighted average intensity for all observations of reflection ", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c19); nbParagraph.add(chklI); Chunk c20 = new Chunk(".", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c20); document.add(nbParagraph); document.add(new Paragraph(" ", PdfRtfExporter.FONT_DOC_11)); }
From source file:ispyb.common.util.export.ExiPdfRtfExporter.java
License:Open Source License
/*** * sets the sessions informations in the pdf document for fx or ix accounts * (Issue 1049)//ww w.j a va 2 s .c o m * * @param document * @throws Exception */ private void setSessionTable(Document document) throws Exception { String proposalCode = proposalDesc.substring(0, 2); if (slv != null && (proposalCode.toLowerCase().equals(Constants.PROPOSAL_CODE_FX) || proposalCode.equals(Constants.PROPOSAL_CODE_IX))) { if (proposalCode.toLowerCase().equals(Constants.PROPOSAL_CODE_FX)) { // session // title // only // for // FX // accounts document.add(new Paragraph("Session title:", FONT_TITLE)); document.add(new Paragraph(slv.getSessionTitle(), FONT_DOC)); } Table sessionTable = new Table(2); // sessionTable.setWidth(50); // percentage sessionTable.setPadding(3); sessionTable.setCellsFitPage(true); sessionTable.getDefaultCell().setBorderWidth(0); sessionTable.setBorder(0); sessionTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); boolean hasData = false; // print only if the value > 0 if (proposalCode.toLowerCase().equals(Constants.PROPOSAL_CODE_FX)) { // structure // determinations // only // for // FX // accounts if (slv.getStructureDeterminations() != null && !slv.getStructureDeterminations().isNaN() && slv.getStructureDeterminations() != 0) { hasData = true; sessionTable.addCell(new Paragraph("Structure determinations", FONT_DOC_BOLD)); sessionTable.addCell(new Paragraph("" + slv.getStructureDeterminations(), FONT_DOC)); } } if (slv.getDewarTransport() != null && !slv.getDewarTransport().isNaN() && slv.getDewarTransport() != 0) { hasData = true; sessionTable.addCell(new Paragraph("Dewar transport", FONT_DOC_BOLD)); sessionTable.addCell(new Paragraph("" + slv.getDewarTransport(), FONT_DOC)); } if (slv.getDatabackupFrance() != null && !slv.getDatabackupFrance().isNaN() && slv.getDatabackupFrance() != 0) { hasData = true; sessionTable.addCell(new Paragraph("Data backup & Express delivery France", FONT_DOC_BOLD)); sessionTable.addCell(new Paragraph("" + slv.getDatabackupFrance(), FONT_DOC)); } if (slv.getDatabackupEurope() != null && !slv.getDatabackupEurope().isNaN() && slv.getDatabackupEurope() != 0) { hasData = true; sessionTable.addCell(new Paragraph("Data backup & Express delivery Europe", FONT_DOC_BOLD)); sessionTable.addCell(new Paragraph("" + slv.getDatabackupEurope(), FONT_DOC)); } if (hasData) { document.add(sessionTable); } } }
From source file:ispyb.common.util.export.ExiPdfRtfExporter.java
License:Open Source License
/** * set a line for a specified dataCollection in the dataCollection table * //from w w w .j av a 2 s . com * @param document * @param table * @param col * @param session * @param df2 * @param df3 * @throws Exception */ private void setDataCollectionMapData(Document document, Map<String, Object> dataCollectionMapItem) throws Exception { // 1st row String parag = getCellParam(dataCollectionMapItem, "DataCollectionGroup_experimentType") + " " + getCellParam(dataCollectionMapItem, "DataCollection_startTime"); Paragraph p = new Paragraph(parag, FONT_DOC_BLUE); document.add(p); //row2 parag = getCellParam(dataCollectionMapItem, "DataCollection_imageDirectory"); document.add(new Paragraph(parag, FONT_DOC_ITALIC)); //row3 Table table = new Table(NB_COL_DATACOLLECTION); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.getDefaultCell().setBorderWidth(0); // 1st Cell parag = "Workflow: \n" + "Protein: \n" + "Sample: \n" + "Prefix: \n" + "Run #: \n" + "Images: \n" + "Transmission: \n"; LOG.info("parag=" + parag); p = new Paragraph(parag, FONT_DOC); table.addCell(p); // Cell2 parag = getCellParam(dataCollectionMapItem, "Workflow_workflowType") + "\n" + getCellParam(dataCollectionMapItem, "Protein_acronym") + "\n" + getCellParam(dataCollectionMapItem, "BLSample_name") + "\n" + getCellParam(dataCollectionMapItem, "DataCollection_imagePrefix") + "\n" + getCellParam(dataCollectionMapItem, "DataCollection_dataCollectionNumber") + "\n" + getCellParam(dataCollectionMapItem, "Protein_acronym") + "\n" + getCellParam(dataCollectionMapItem, "DataCollection_transmission") + "\n"; LOG.info("parag=" + parag); p = new Paragraph(parag, FONT_DOC_BOLD); table.addCell(p); // 3 Cell parag = "Resolution (corner): \n" + "Wavelength: \n" + "Omega range: \n" + "Omega start: \n" + "Exposure time: \n" + "Flux start: \n" + "Flux end: \n"; table.addCell(new Paragraph(parag, FONT_DOC)); // Cell 4 parag = getCellParam(dataCollectionMapItem, "DataCollection_resolutionAtCorner") + "\n" + getCellParam(dataCollectionMapItem, "DataCollection_wavelength") + "\n" + getCellParam(dataCollectionMapItem, "DataCollection_axisRange") + "\n" + getCellParam(dataCollectionMapItem, "DataCollection_omegaStart") + "\n" + getCellParam(dataCollectionMapItem, "exposureTime") + "\n" + getCellParam(dataCollectionMapItem, "DataCollection_flux") + "\n" + getCellParam(dataCollectionMapItem, "DataCollection_flux_end") + "\n"; table.addCell(new Paragraph(parag, FONT_DOC_BOLD)); // 5 Cell add cell containing autoproc results table.addCell(" "); // 6 Cell : thumbnail if (!getCellParam(dataCollectionMapItem, "lastImageId").isEmpty()) { String thumbnailPath = (imageService .findByPk(new Integer(getCellParam(dataCollectionMapItem, "lastImageId")))) .getJpegThumbnailFileFullPath(); Cell cellThumbnail = getCellImage(thumbnailPath); cellThumbnail.setBorderWidth(0); table.addCell(cellThumbnail); } else { table.addCell(" "); } //cellThumbnail.setRowspan(nbRows); // 7 Cell : snapshot Cell cellSnapshot = getCellImage(dataCollectionMapItem, "DataCollection_xtalSnapshotFullPath1"); //cellSnapshot.setRowspan(nbRows); cellSnapshot.setBorderWidth(0); table.addCell(cellSnapshot); // 8 Cell : graph or other plot if (!getCellParam(dataCollectionMapItem, "DataCollection_dataCollectionId").isEmpty()) { String plotPath = (dcService.findByPk( new Integer(getCellParam(dataCollectionMapItem, "DataCollection_dataCollectionId")), false, false)).getImageQualityIndicatorsPlotPath(); Cell cellGraph = getCellImage(plotPath); cellGraph.setBorderWidth(0); table.addCell(cellGraph); } else { table.addCell(" "); } document.add(table); // row3 if (dataCollectionMapItem.get("DataCollection_comments") != null && dataCollectionMapItem.get("DataCollection_comments") != "") document.add(new Paragraph(dataCollectionMapItem.get("DataCollection_comments").toString(), FONT_DOC)); else document.add(new Paragraph(" ")); return; }
From source file:it.eng.spagobi.engines.exporters.ChartExporter.java
License:Mozilla Public License
public File getChartPDF(String uuid, boolean multichart, String orientation) throws Exception { logger.debug("IN"); File tmpFile;// ww w . j av a 2 s . c o m try { tmpFile = null; String dir = System.getProperty("java.io.tmpdir"); String path = (new StringBuilder(String.valueOf(dir))).append("/").append(uuid).append(".png") .toString(); File dirF = new File(dir); tmpFile = File.createTempFile("tempPDFExport", ".pdf", dirF); Document pdfDocument = new Document(); PdfWriter docWriter = PdfWriter.getInstance(pdfDocument, new FileOutputStream(tmpFile)); //pdfDocument.open(); if (multichart) { pdfDocument.open(); List images = new ArrayList(); for (int i = 0; i < MAX_NUM_IMG; i++) { String imgName = (new StringBuilder(String.valueOf(path.substring(0, path.indexOf(".png"))))) .append(i).append(".png").toString(); Image png = Image.getInstance(imgName); if (png == null) { break; } images.add(png); } Table table = new Table(images.size()); for (int i = 0; i < images.size(); i++) { Image png = (Image) images.get(i); if (HORIZONTAL_ORIENTATION.equalsIgnoreCase(orientation)) { Cell pngCell = new Cell(png); pngCell.setBorder(0); table.setBorder(0); table.addCell(pngCell); } else { png.setAlignment(5); pdfDocument.add(png); } } pdfDocument.add(table); } else { Image jpg = Image.getInstance(path); float height = jpg.getHeight(); float width = jpg.getWidth(); // if in need to change layout if (width > MAX_WIDTH || height > MAX_HEIGHT) { changeLayout(pdfDocument, jpg, width, height); } pdfDocument.open(); pdfDocument.add(jpg); } pdfDocument.close(); docWriter.close(); logger.debug("OUT"); return tmpFile; } catch (Throwable e) { logger.error("An exception has occured", e); throw new Exception(e); } finally { //tmpFile.delete(); } }
From source file:jmemorize.core.io.PdfRtfBuilder.java
License:Open Source License
/** * Adds given card to document//from w w w . j a v a2s. c o m * * @param doc document to add to * @param card given card */ private static void writeCard(Document doc, Card card) throws DocumentException { Table table = new Table(2); table.setPadding(3f); table.setBorderWidth(1.0f); table.setTableFitsPage(true); table.complete(); Phrase front = new Phrase(card.getFrontSide().getText().getUnformatted(), frontFont); table.addCell(front); Phrase back = new Phrase(card.getBackSide().getText().getUnformatted(), backFont); table.addCell(back); doc.add(table); }