List of usage examples for com.lowagie.text Table setWidth
public void setWidth(float width)
From source file:ispyb.client.mx.collection.PdfRtfExporter.java
License:Open Source License
/** * set the table for a given MXPressO/*w w w .ja v a2 s . c om*/ * * @param document * @param dataCollectionGroupVO * @param mRequest * @param lastCollectOSC * @param nextToLastCollectChar * @throws Exception */ private void setMXPressOTable(Document document, DataCollectionGroup3VO dataCollectionGroupVO, HttpServletRequest mRequest, DataCollection3VO lastCollectOSC, DataCollection3VO nextToLastCollectChar) throws Exception { if (dataCollectionGroupVO != null) { DataCollectionExporter dcExporter = new DataCollectionExporter(df2, df3, proposalCode, proposalNumber, mRequest); if (lastCollectOSC != null) { DataCollectionInformation dcInfo = dcExporter.getDataCollectionInformation(lastCollectOSC, getSampleRankingVO(lastCollectOSC.getDataCollectionId()), getAutoProcRankingVO(lastCollectOSC.getDataCollectionId())); int noCol = 3; Table tableWF = new Table(noCol); int[] headersWidthWF = new int[noCol]; int l = 0; headersWidthWF[l++] = 27; // snapshot headersWidthWF[l++] = 24; // map 1 headersWidthWF[l++] = 51; // map2 // tableWF.setWidths(headersWidthWF); tableWF.setWidth(100); // percentage tableWF.setPadding(1); tableWF.setCellsFitPage(true); tableWF.setTableFitsPage(true); tableWF.getDefaultCell().setBorderWidth(1); tableWF.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); // first row: protein acronym and sample name (or image prefix) // and startTime String collectName = lastCollectOSC.getImagePrefix(); if (dataCollectionGroupVO.getBlSampleVO() != null && dataCollectionGroupVO.getBlSampleVO().getCrystalVO() != null) { collectName = dataCollectionGroupVO.getBlSampleVO().getCrystalVO().getProteinVO().getAcronym() + "-" + dataCollectionGroupVO.getBlSampleVO().getName(); } tableWF.addCell(new Paragraph(collectName, FONT_DOC)); String collectTime = lastCollectOSC.getStartTime().toString(); Cell c = new Cell(new Paragraph(collectTime, FONT_DOC)); c.setColspan(2); tableWF.addCell(c); // second row: first snapshot + cartography graphes (2 mesh) // first snapshot String imgCrystal = dcInfo.getPathJpgCrystal3(); Cell cellCrystalImage = getCellImage(imgCrystal); tableWF.addCell(cellCrystalImage); // workflowMesh cartography Workflow3VO mxExpressOWF = dataCollectionGroupVO.getWorkflowVO(); List<WorkflowMesh3VO> listWFMesh = new ArrayList<WorkflowMesh3VO>(); Ejb3ServiceLocator ejb3ServiceLocator = Ejb3ServiceLocator.getInstance(); WorkflowMesh3Service workflowMeshService = (WorkflowMesh3Service) ejb3ServiceLocator .getLocalService(WorkflowMesh3Service.class); listWFMesh = workflowMeshService.findByWorkflowId(mxExpressOWF.getWorkflowId()); if (listWFMesh != null && listWFMesh.size() > 0) { Cell cellImg1 = getMeshMapCell(listWFMesh.get(0)); if (cellImg1 == null) { tableWF.addCell(new Paragraph("Image not found", FONT_DOC)); } else { tableWF.addCell(cellImg1); } if (listWFMesh.size() > 1) { Cell cellImg2 = getMeshMapCell(listWFMesh.get(1)); if (cellImg2 == null) { tableWF.addCell(new Paragraph("Image not found", FONT_DOC)); } else { tableWF.addCell(cellImg2); } } else tableWF.addCell(new Paragraph("No Workflow found", FONT_DOC)); } else { tableWF.addCell(new Paragraph("No Workflow found", FONT_DOC)); tableWF.addCell(new Paragraph("No Workflow found", FONT_DOC)); } // // third row: // autoprocessing results Cell resultCell = getAutoProcResultStatus(dcInfo); resultCell.setColspan(3); resultCell.setHorizontalAlignment(Element.ALIGN_LEFT); tableWF.addCell(resultCell); Integer idDc = -1; for (int k = 0; k < dataCollectionList.size(); k++) { DataCollection3VO dcVo = dataCollectionList.get(k); if (dcVo.getDataCollectionId().equals(lastCollectOSC.getDataCollectionId())) { idDc = k; break; } } if (idDc != -1) { AutoProc3VO[] autoProcs = wrapper.getAutoProcs(); AutoProcScalingStatistics3VO[] autoProcsOverall = wrapper.getScalingStatsOverall(); AutoProcScalingStatistics3VO[] autoProcsInner = wrapper.getScalingStatsInner(); AutoProcScalingStatistics3VO[] autoProcsOuter = wrapper.getScalingStatsOuter(); AutoProc3VO autoProcValue = autoProcs[idDc]; AutoProcScalingStatistics3VO autoProcOverall = autoProcsOverall[idDc]; AutoProcScalingStatistics3VO autoProcInner = autoProcsInner[idDc]; AutoProcScalingStatistics3VO autoProcOuter = autoProcsOuter[idDc]; if (autoProcValue == null) { Cell cNo = new Cell(new Paragraph("No autoprocessing results found", FONT_DOC)); cNo.setColspan(3); cNo.setHorizontalAlignment(Element.ALIGN_LEFT); tableWF.addCell(cNo); document.add(tableWF); } else { int noColSPG = 5; Table tableSPG = new Table(noColSPG); int[] headersWidth = new int[noColSPG]; int i = 0; headersWidth[i++] = 7; // space group headersWidth[i++] = 10; // completeness headersWidth[i++] = 9; // resolution headersWidth[i++] = 9; // rsymm headersWidth[i++] = 12; // unit cell tableSPG.setWidths(headersWidth); tableSPG.setWidth(100); // percentage tableSPG.setPadding(3); tableSPG.setCellsFitPage(true); tableSPG.setTableFitsPage(true); tableSPG.getDefaultCell().setBorderWidth(1); tableSPG.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); tableSPG.getDefaultCell().setGrayFill(GREY_FILL_HEADER); tableSPG.addCell(new Paragraph("Space Group", FONT_DOC_BOLD)); tableSPG.addCell(new Paragraph("Completeness (Inner, Outer, Overall)", FONT_DOC_BOLD)); tableSPG.addCell(new Paragraph("Resolution", FONT_DOC_BOLD)); tableSPG.addCell(new Paragraph("Rsymm (Inner, Outer, Overall)", FONT_DOC_BOLD)); tableSPG.addCell(new Paragraph("Unit Cell (a, b, c, alpha, beta, gamma)", FONT_DOC_BOLD)); tableSPG.getDefaultCell().setGrayFill(GREY_FILL_DATA); // space group if (autoProcValue != null && autoProcValue.getSpaceGroup() != null) { Paragraph p = new Paragraph(autoProcValue.getSpaceGroup(), FONT_DOC); tableSPG.addCell(p); } else tableSPG.addCell(""); // completeness, rsymm, processed resolution String completenessString = new String(); String rSymmString = new String(); String resolutionString = new String(); if (autoProcOverall != null && autoProcInner != null && autoProcOuter != null) { completenessString += df2.format(autoProcInner.getCompleteness()) + "\n" + df2.format(autoProcOuter.getCompleteness()) + "\n" + df2.format(autoProcOverall.getCompleteness()); rSymmString += (autoProcInner.getRmerge() == null ? "" : df2.format(autoProcInner.getRmerge())) + "\n" + (autoProcOuter.getRmerge() == null ? "" : df2.format(autoProcOuter.getRmerge())) + "\n" + (autoProcOverall.getRmerge() == null ? "" : df2.format(autoProcOverall.getRmerge())); resolutionString += autoProcInner.getResolutionLimitLow() + " - " + autoProcInner.getResolutionLimitHigh() + "\n" + autoProcOuter.getResolutionLimitLow() + " - " + autoProcOuter.getResolutionLimitHigh() + "\n" + autoProcOverall.getResolutionLimitLow() + " - " + autoProcOverall.getResolutionLimitHigh(); } tableSPG.addCell(new Paragraph(completenessString, FONT_DOC)); tableSPG.addCell(new Paragraph(resolutionString, FONT_DOC)); tableSPG.addCell(new Paragraph(rSymmString, FONT_DOC)); // unit cell if (autoProcValue != null && autoProcValue.getSpaceGroup() != null) { tableSPG.addCell(new Paragraph("" + autoProcValue.getRefinedCellA() + ", " + autoProcValue.getRefinedCellB() + ", " + autoProcValue.getRefinedCellC() + "\n" + autoProcValue.getRefinedCellAlpha() + ", " + autoProcValue.getRefinedCellBeta() + ", " + autoProcValue.getRefinedCellGamma(), FONT_DOC)); } else { tableSPG.addCell(""); } document.add(tableWF); document.add(new Paragraph("Best autoprocessing result", FONT_DOC)); document.add(tableSPG); } // end autoProc null } // end idDc -1 // document.add(new Paragraph(" ", FONT_SPACE)); } // end lastCollect null if (nextToLastCollectChar != null) { DataCollectionInformation dcInfo = dcExporter.getDataCollectionInformation(nextToLastCollectChar, getSampleRankingVO(nextToLastCollectChar.getDataCollectionId()), getAutoProcRankingVO(nextToLastCollectChar.getDataCollectionId())); if (dcInfo.getSpacegroup() != "") { document.add(new Paragraph("EDNA characterisation output and collect strategy", FONT_DOC)); } setEDNATable2(document, dcInfo); setStrategyTable2(document, dcInfo); } } // end dataCollectionGroup null }
From source file:ispyb.client.mx.collection.PdfRtfExporter.java
License:Open Source License
/** * set the autoproc results table, if no autoProc add a cell at the end of * topTable// w w w . jav 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.results.ExportAutoProcAction.java
License:Open Source License
private void setAutoProcInfo(Document document) throws Exception { // header/*from ww w.j a v a 2 s .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:net.bull.javamelody.swing.print.MPdfWriter.java
License:Apache License
/** * Effectue le rendu des headers./*from www .ja v a 2 s . c om*/ * * @param table * MBasicTable * @param datatable * Table * @throws BadElementException * e */ protected void renderHeaders(final MBasicTable table, final Table datatable) throws BadElementException { final int columnCount = table.getColumnCount(); final TableColumnModel columnModel = table.getColumnModel(); // size of columns float totalWidth = 0; for (int i = 0; i < columnCount; i++) { totalWidth += columnModel.getColumn(i).getWidth(); } final float[] headerwidths = new float[columnCount]; for (int i = 0; i < columnCount; i++) { headerwidths[i] = 100f * columnModel.getColumn(i).getWidth() / totalWidth; } datatable.setWidths(headerwidths); datatable.setWidth(100f); // table header final com.lowagie.text.Font font = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD); datatable.getDefaultCell().setBorderWidth(2); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); // datatable.setDefaultCellGrayFill(0.75f); String text; Object value; for (int i = 0; i < columnCount; i++) { value = columnModel.getColumn(i).getHeaderValue(); text = value != null ? value.toString() : ""; datatable.addCell(new Phrase(text, font)); } // end of the table header datatable.endHeaders(); }
From source file:net.sf.eclipsecs.ui.stats.export.internal.RTFStatsExporter.java
License:Open Source License
private void createDetailSection(List details, Document doc) throws CoreException, DocumentException { Table table = new Table(4); table.setSpaceInsideCell(10);//from w ww . j a v a 2s . c o m table.setAlignment(Element.ALIGN_LEFT); table.setWidth(100); table.setWidths(new float[] { 30, 30, 10, 30 }); Cell resourceHeader = new Cell(new Chunk(Messages.MarkerStatsView_fileColumn, tableHeaderAndFooterFont)); resourceHeader.setHorizontalAlignment(Element.ALIGN_CENTER); resourceHeader.setHeader(true); table.addCell(resourceHeader); Cell folderHeader = new Cell(new Chunk(Messages.MarkerStatsView_folderColumn, tableHeaderAndFooterFont)); folderHeader.setHorizontalAlignment(Element.ALIGN_CENTER); folderHeader.setHeader(true); table.addCell(folderHeader); Cell lineHeader = new Cell(new Chunk(Messages.MarkerStatsView_lineColumn, tableHeaderAndFooterFont)); lineHeader.setHorizontalAlignment(Element.ALIGN_CENTER); lineHeader.setHeader(true); table.addCell(lineHeader); Cell messageHeader = new Cell(new Chunk(Messages.MarkerStatsView_messageColumn, tableHeaderAndFooterFont)); messageHeader.setHorizontalAlignment(Element.ALIGN_CENTER); messageHeader.setHeader(true); table.addCell(messageHeader); Cell resourceCell; Cell fileCell; Cell lineCell; Cell messageCell; for (Iterator iter = details.iterator(); iter.hasNext();) { IMarker marker = (IMarker) iter.next(); resourceCell = new Cell(new Chunk(marker.getResource().getName(), mainFont)); table.addCell(resourceCell); fileCell = new Cell(new Chunk(marker.getResource().getParent().getFullPath().toString(), mainFont)); table.addCell(fileCell); lineCell = new Cell(new Chunk(marker.getAttribute(IMarker.LINE_NUMBER).toString(), mainFont)); lineCell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(lineCell); messageCell = new Cell(new Chunk(marker.getAttribute(IMarker.MESSAGE).toString(), mainFont)); table.addCell(messageCell); } doc.add(table); }
From source file:net.sf.eclipsecs.ui.stats.export.internal.RTFStatsExporter.java
License:Open Source License
private void createSummaryTable(Stats stats, Document doc) throws DocumentException { Table table = new Table(2); table.setSpaceInsideCell(10);/*from w ww . j a va 2 s .c o m*/ table.setAlignment(Element.ALIGN_LEFT); table.setWidth(100); table.setWidths(new float[] { 80, 20 }); Cell typeHeader = new Cell(new Chunk(Messages.MarkerStatsView_kindOfErrorColumn, tableHeaderAndFooterFont)); typeHeader.setHorizontalAlignment(Element.ALIGN_CENTER); typeHeader.setHeader(true); table.addCell(typeHeader); Cell countHeader = new Cell( new Chunk(Messages.MarkerStatsView_numberOfErrorsColumn, tableHeaderAndFooterFont)); countHeader.setHorizontalAlignment(Element.ALIGN_CENTER); countHeader.setHeader(true); table.addCell(countHeader); ArrayList markerStatsSortedList = new ArrayList(stats.getMarkerStats()); Collections.sort(markerStatsSortedList, new Comparator() { public int compare(Object arg0, Object arg1) { MarkerStat markerStat0 = (MarkerStat) arg0; MarkerStat markerStat1 = (MarkerStat) arg1; return markerStat1.getCount() - markerStat0.getCount(); } }); Cell typeCell; Cell countCell; for (Iterator iter = markerStatsSortedList.iterator(); iter.hasNext();) { MarkerStat markerStat = (MarkerStat) iter.next(); typeCell = new Cell(new Chunk(markerStat.getIdentifiant(), mainFont)); table.addCell(typeCell); countCell = new Cell(new Chunk(markerStat.getCount() + "", mainFont)); countCell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(countCell); } doc.add(table); }
From source file:open.dolphin.client.AuditController.java
License:Open Source License
private void makePDF() { //- ?// w w w. j a v a2 s . c o m Document doc = new Document(PageSize.A4, 20.0F, 20.0F, 40.0F, 40.0F); try { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); String fileName = "_" + sdf.format(new java.util.Date()) + ".pdf"; //()?? FileOutputStream fos = new FileOutputStream(outputDir.getText() + fileName); PdfWriter pdfwriter = PdfWriter.getInstance(doc, fos); Font font_header = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 15.0F, 1); Font font_g11 = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 11.0F); Font font_g10 = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 10.0F); //- ? Font font_m8 = new Font(BaseFont.createFont("HeiseiMin-W3", "UniJIS-UCS2-HW-H", false), 8.0F); Font font_underline_11 = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 11.0F, 4); Font font_red_11 = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 11.0F); font_red_11.setColor(new Color(255, 0, 0)); Font font_empty = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 9.0F); font_empty.setColor(new Color(255, 255, 255)); Paragraph para_NF = new Paragraph(5, "\r\n", new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 13, Font.NORMAL)); para_NF.setAlignment(Element.ALIGN_CENTER); // ?? String author = Project.getProjectStub().getUserModel().getCommonName(); doc.addAuthor(author); doc.addSubject(""); HeaderFooter header = new HeaderFooter(new Phrase("", font_header), false); header.setAlignment(1); doc.setHeader(header); HeaderFooter footer = new HeaderFooter(new Phrase("--"), new Phrase("--")); footer.setAlignment(1); footer.setBorder(0); doc.setFooter(footer); doc.open(); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy''MM''dd'' HH''mm''"); String today = sdf1.format(new java.util.Date()); Paragraph para_0 = new Paragraph("?" + today, font_g11); para_0.setAlignment(2); doc.add(para_0); Paragraph para_1 = new Paragraph("?" + author, font_g11); para_1.setAlignment(2); doc.add(para_1); doc.add(new Paragraph("")); // doc.add(para_NF); doc.add(para_NF); for (int cnt = 0; cnt < outputList.size(); cnt++) { InnerBean bean = outputList.get(cnt); Person person = bean.getPerson(); Paragraph para_2 = new Paragraph("ID" + person.idProperty().get(), font_underline_11); para_2.setAlignment(0); doc.add(para_2); Paragraph para_3 = new Paragraph("???" + person.nameProperty().get(), font_underline_11); para_3.setAlignment(0); doc.add(para_3); Paragraph para_4 = new Paragraph("" + person.nameKanaProperty().get(), font_underline_11); para_4.setAlignment(0); doc.add(para_4); Paragraph para_5 = new Paragraph("" + person.sexProperty().get(), font_underline_11); para_5.setAlignment(0); doc.add(para_5); Paragraph para_6 = new Paragraph("" + person.birthdayProperty().get(), font_underline_11); para_6.setAlignment(0); doc.add(para_6); Table karteHistoryTable = new Table(5); karteHistoryTable.setWidth(100.0F); int[] uriage_table_width = { 25, 20, 30, 20, 25 }; karteHistoryTable.setWidths(uriage_table_width); //karteHistoryTable.setDefaultHorizontalAlignment(1); //karteHistoryTable.setDefaultVerticalAlignment(5); karteHistoryTable.setPadding(3.0F); karteHistoryTable.setSpacing(0.0F); karteHistoryTable.setBorderColor(new Color(0, 0, 0)); Cell cell_01 = new Cell(new Phrase("?", font_g10)); cell_01.setGrayFill(0.8F); cell_01.setHorizontalAlignment(Element.ALIGN_CENTER); Cell cell_11 = new Cell(new Phrase("?", font_g10)); cell_11.setGrayFill(0.8F); cell_11.setHorizontalAlignment(Element.ALIGN_CENTER); Cell cell_21 = new Cell(new Phrase("", font_g10)); cell_21.setGrayFill(0.8F); cell_21.setHorizontalAlignment(Element.ALIGN_CENTER); Cell cell_31 = new Cell(new Phrase("", font_g10)); cell_31.setGrayFill(0.8F); cell_31.setHorizontalAlignment(Element.ALIGN_CENTER); Cell cell_41 = new Cell(new Phrase("", font_g10)); cell_41.setGrayFill(0.8F); cell_41.setHorizontalAlignment(Element.ALIGN_CENTER); karteHistoryTable.addCell(cell_01); karteHistoryTable.addCell(cell_11); karteHistoryTable.addCell(cell_21); karteHistoryTable.addCell(cell_31); karteHistoryTable.addCell(cell_41); List<KarteBean> list = bean.getResult(); KarteBean karteInfo = list.get(0); List<DocInfoModel> docInfoList = karteInfo.getDocInfoList(); //- ??? int stepCount = 22; int tempCount = 0; int pageCount = 0; String firstKarteMaker = null; String karteMakeDate = null; if (docInfoList != null) { for (int i = 0; i < docInfoList.size(); ++i) { DocInfoModel docInfo = docInfoList.get(i); Cell cell = new Cell(new Phrase(docInfo.getFirstConfirmDateTime(), font_m8)); if (karteMakeDate == null || !karteMakeDate.equals(docInfo.getFirstConfirmDateTime())) { karteMakeDate = docInfo.getFirstConfirmDateTime(); firstKarteMaker = docInfo.getPurpose(); } cell.setHorizontalAlignment(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); karteHistoryTable.addCell(cell); cell = new Cell(new Phrase(firstKarteMaker, font_m8)); cell.setHorizontalAlignment(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); karteHistoryTable.addCell(cell); //- String addTitle = docInfo.getTitle(); addTitle = addTitle.replace("\r\n", ""); addTitle = addTitle.replace("\n", ""); cell = new Cell(new Phrase(addTitle, font_m8)); cell.setHorizontalAlignment(0); karteHistoryTable.addCell(cell); cell = new Cell(new Phrase(docInfo.getPurpose(), font_m8)); cell.setHorizontalAlignment(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); karteHistoryTable.addCell(cell); cell = new Cell(new Phrase(docInfo.getConfirmDateTime(), font_m8)); cell.setHorizontalAlignment(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); karteHistoryTable.addCell(cell); if (stepCount == tempCount) { if (pageCount == 0) { stepCount += 5; pageCount++; } tempCount = 0; doc.add(karteHistoryTable); doc.newPage(); karteHistoryTable.deleteAllRows(); karteHistoryTable.addCell(cell_01); karteHistoryTable.addCell(cell_11); karteHistoryTable.addCell(cell_21); karteHistoryTable.addCell(cell_31); karteHistoryTable.addCell(cell_41); } else { tempCount++; } } // Cell Empty_Cell = new Cell(new Phrase("empty", font_empty)); // for (int i = docInfoList.size(); i < docInfoList.size() + 4; ++i) { // for (int j = 0; j < 4; ++j) { // karteHistoryTable.addCell(Empty_Cell); // } // } // // Cell cell_goukei = new Cell(new Phrase("?", font_g10)); // cell_goukei.setGrayFill(0.8F); // cell_goukei.setColspan(3); // karteHistoryTable.addCell(cell_goukei); // Cell cell_sum = new Cell(new Phrase("136,900", font_m10)); // cell_sum.setHorizontalAlignment(2); // karteHistoryTable.addCell(cell_sum); doc.add(karteHistoryTable); doc.newPage(); } else { // doc.add(para_NF); Paragraph noData = new Paragraph("??", font_m8); noData.setAlignment(0); doc.add(noData); doc.newPage(); } } } catch (DocumentException | IOException e) { Logger.getLogger(AuditController.class.getName()).log(Level.SEVERE, null, e); } finally { doc.close(); } }
From source file:opisiame.controller.gestion_resultat.Choix_exportController.java
@FXML public void pdf_export() { File pdf_file = choix_chemin_enregistrement("PDF files (*.pdf)", "*.pdf"); if (onglet_actif.equals("questions")) { if (pdf_file != null) { Document document = new Document(PageSize.A4); try { PdfWriter.getInstance(document, new FileOutputStream(pdf_file)); document.open();//from w w w. j a v a2 s . co m document.add(new Paragraph("Rsultat Quiz")); Table tableau = new Table(6, reponse_questions.size()); tableau.setAutoFillEmptyCells(true); tableau.setPadding(2); Cell cell = new Cell("Question"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Pourcentage reponse A"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Pourcentage reponse B"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Pourcentage reponse C"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Pourcentage reponse D"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Pourcentage bonne rponse"); cell.setHeader(true); tableau.addCell(cell); tableau.endHeaders(); tableau.setWidth(100); fill_data_pdf(tableau); document.add(tableau); } catch (DocumentException | IOException de) { de.printStackTrace(); } document.close(); } } else if (onglet_actif.equals("eleves")) { if (pdf_file != null) { Document document = new Document(PageSize.A4); try { PdfWriter.getInstance(document, new FileOutputStream(pdf_file)); document.open(); document.add(new Paragraph("Rsultats des tudiants")); Table tableau = new Table(5, resultats_eleves.size()); tableau.setAutoFillEmptyCells(true); tableau.setPadding(2); Cell cell = new Cell("Nom"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Prnom"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("N tudiant"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Note"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Pourcentage"); cell.setHeader(true); tableau.addCell(cell); tableau.endHeaders(); tableau.setWidth(100); fill_data_pdf(tableau); document.add(tableau); } catch (DocumentException | IOException de) { de.printStackTrace(); } document.close(); } } else if (onglet_actif.equals("eleves_pas_num")) { if (pdf_file != null) { Document document = new Document(PageSize.A4); try { PdfWriter.getInstance(document, new FileOutputStream(pdf_file)); document.open(); document.add(new Paragraph("Rsultats des tudiants")); Table tableau = new Table(4, resultats_eleves.size()); tableau.setAutoFillEmptyCells(true); tableau.setPadding(2); Cell cell = new Cell("Nom"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Prnom"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Note"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Pourcentage"); cell.setHeader(true); tableau.addCell(cell); tableau.endHeaders(); tableau.setWidth(100); fill_data_pdf(tableau); document.add(tableau); } catch (DocumentException | IOException de) { de.printStackTrace(); } document.close(); } } close_window(); }
From source file:org.activityinfo.server.report.renderer.itext.ItextMapRenderer.java
License:Open Source License
private void renderLegend(MapReportElement element, Document doc) throws DocumentException, IOException { Table table = new Table(2); table.setBorderWidth(1);/*w w w . ja v a 2 s . c om*/ table.setWidth(100f); table.setBorderColor(new Color(100, 100, 100)); table.setPadding(5); table.setSpacing(0); table.setCellsFitPage(true); table.setTableFitsPage(true); table.setWidths(new int[] { 1, 3 }); Cell cell = new Cell(I18N.CONSTANTS.legend()); cell.setHeader(true); cell.setColspan(2); table.addCell(cell); table.endHeaders(); for (MapLayerLegend legend : element.getContent().getLegends()) { Cell symbolCell = new Cell(); symbolCell.setHorizontalAlignment(Element.ALIGN_CENTER); symbolCell.setVerticalAlignment(Element.ALIGN_MIDDLE); Image symbol = createLegendSymbol(legend, imageCreator); symbolCell.addElement(symbol); Cell descriptionCell = new Cell(); addLegendDescription(element, legend.getDefinition(), descriptionCell); table.addCell(symbolCell); table.addCell(descriptionCell); } doc.add(table); }
From source file:org.activityinfo.server.report.renderer.itext.ItextPivotTableRenderer.java
License:Open Source License
@Override public void render(DocWriter writer, Document document, PivotTableReportElement element) throws DocumentException { document.add(ThemeHelper.elementTitle(element.getTitle())); ItextRendererHelper.addFilterDescription(document, element.getContent().getFilterDescriptions()); ItextRendererHelper.addDateFilterDescription(document, element.getFilter().getDateRange()); PivotTableData data = element.getContent().getData(); if (data.isEmpty()) { document.add(new Paragraph("Aucune Donnes")); // TODO: i18n } else {/*from ww w . j a v a 2 s. c om*/ int colDepth = data.getRootColumn().getDepth(); List<PivotTableData.Axis> colLeaves = data.getRootColumn().getLeaves(); int colBreadth = colLeaves.size(); Table table = new Table(colBreadth + 1, 1); table.setUseVariableBorders(true); table.setWidth(100.0f); table.setWidths(calcColumnWidths(document, data, colLeaves)); table.setBorderWidth(0); // first write the column headers for (int depth = 1; depth <= colDepth; ++depth) { if (depth == 1) { Cell cell = ThemeHelper.cornerCell(); cell.setRowspan(colDepth); table.addCell(cell); } List<PivotTableData.Axis> columns = data.getRootColumn().getDescendantsAtDepth(depth); for (PivotTableData.Axis column : columns) { Cell cell = ThemeHelper.columnHeaderCell(column.getLabel(), column.isLeaf()); cell.setColspan(Math.max(1, column.getLeaves().size())); table.addCell(cell); } } table.endHeaders(); for (PivotTableData.Axis row : data.getRootRow().getChildren()) { writeRow(table, row, colLeaves, 0); } document.add(table); } }