List of usage examples for com.lowagie.text Element ALIGN_RIGHT
int ALIGN_RIGHT
To view the source code for com.lowagie.text Element ALIGN_RIGHT.
Click Source Link
From source file:gov.utah.dts.det.ccl.documents.reporting.reports.TopFindingsReport.java
@Override public void render(Map<String, Object> context, OutputStream outputStream, FileDescriptor fileDescriptor) throws TemplateException { List<Object[]> results = getResults(context); setFileName(context, fileDescriptor); Document document = new Document(PAGE_SIZE, 36, 36, 36, 36); try {//from ww w . j a v a 2 s. c om PdfWriter.getInstance(document, outputStream); document.open(); StringBuilder sb = new StringBuilder((String) context.get(LICENSE_TYPE_KEY)); sb.append(" Top Findings Report"); Paragraph heading = new Paragraph(sb.toString(), HEADING_FONT); heading.setAlignment(Element.ALIGN_CENTER); document.add(heading); Date startDate = (Date) context.get(DATE_RANGE_START_KEY); Date endDate = (Date) context.get(DATE_RANGE_END_KEY); ReportType reportType = ReportType.valueOf((String) context.get(REPORT_TYPE_KEY)); clearStringBuilder(sb); sb.append(DATE_FORMATTER.format(startDate)); sb.append(" - "); sb.append(DATE_FORMATTER.format(endDate)); Paragraph date = new Paragraph(sb.toString(), FONT); date.setAlignment(Element.ALIGN_RIGHT); document.add(date); PdfPTable table = new PdfPTable(2); table.setHeaderRows(1); table.setSpacingBefore(FONT_SIZE); table.setWidthPercentage(100f); table.setWidths(new float[] { 80f, 20f }); setDefaultCellAttributes(table.getDefaultCell()); table.addCell(getHeaderCell("Rule Number")); table.addCell(getHeaderCell(reportType.getLabel())); double total = 0; for (Iterator<Object[]> itr = results.iterator(); itr.hasNext();) { Object[] row = itr.next(); Paragraph p = new Paragraph(); p.add(new Paragraph((String) row[0], TABLE_HEADER_FONT)); p.add(new Paragraph((String) row[1], FONT)); table.addCell(p); double rowTotal = ((BigDecimal) row[2]).doubleValue(); total += rowTotal; if (reportType == ReportType.CMP_AMOUNT) { PdfPCell cell = getCurrencyCell(CURRENCY_FORMATTER.format(rowTotal)); table.addCell(cell); } else { table.addCell(getNumberCell(Integer.toString((int) rowTotal))); } } PdfPCell totCell = getHeaderCell("Total"); totCell.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(totCell); if (reportType == ReportType.CMP_AMOUNT) { PdfPCell cell = getHeaderCell(CURRENCY_FORMATTER.format(total)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell); } else { PdfPCell cell = getHeaderCell(Integer.toString((int) total)); table.addCell(cell); } document.add(table); } catch (DocumentException de) { throw new TemplateException(de); } document.close(); }
From source file:io.vertigo.dynamo.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
private void renderObject(final ExportSheet exportSheet, final Table datatable) throws BadElementException { final Font labelFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD); final Font valueFont = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); for (final ExportField exportColumn : exportSheet.getExportFields()) { datatable.getDefaultCell().setBorderWidth(2); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell(new Phrase(exportColumn.getLabel().getDisplay(), labelFont)); datatable.getDefaultCell().setBorderWidth(1); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); final DtField dtField = exportColumn.getDtField(); final Object value = dtField.getDataAccessor().getValue(exportSheet.getDtObject()); final int horizontalAlignement; if (value instanceof Number || value instanceof Date) { horizontalAlignement = Element.ALIGN_RIGHT; } else if (value instanceof Boolean) { horizontalAlignement = Element.ALIGN_CENTER; } else {//from www.j a v a2 s. c o m horizontalAlignement = Element.ALIGN_LEFT; } datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignement); String text = ExportUtil.getText(persistenceManager, referenceCache, denormCache, exportSheet.getDtObject(), exportColumn); if (text == null) { text = ""; } datatable.addCell(new Phrase(8, text, valueFont)); } }
From source file:io.vertigo.dynamo.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
/** * Effectue le rendu de la liste./*from www . j a va 2s.c o m*/ * * @param parameters Paramtres * @param datatable Table */ private void renderList(final ExportSheet parameters, final Table datatable) throws BadElementException { // data rows final Font font = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); final Font whiteFont = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); whiteFont.setColor(Color.WHITE); datatable.getDefaultCell().setBorderWidth(1); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); // datatable.getDefaultCell().setGrayFill(0); // Parcours des DTO de la DTC for (final DtObject dto : parameters.getDtList()) { for (final ExportField exportColumn : parameters.getExportFields()) { final DtField dtField = exportColumn.getDtField(); final Object value = dtField.getDataAccessor().getValue(dto); final int horizontalAlignement; if (value instanceof Number || value instanceof Date) { horizontalAlignement = Element.ALIGN_RIGHT; } else if (value instanceof Boolean) { horizontalAlignement = Element.ALIGN_CENTER; } else { horizontalAlignement = Element.ALIGN_LEFT; } datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignement); String text = ExportUtil.getText(persistenceManager, referenceCache, denormCache, dto, exportColumn); if (text == null) { text = ""; } datatable.addCell(new Phrase(8, text, font)); } } }
From source file:io.vertigo.quarto.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
private void renderObject(final ExportSheet exportSheet, final Table datatable) throws BadElementException { final Font labelFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD); final Font valueFont = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); for (final ExportField exportColumn : exportSheet.getExportFields()) { datatable.getDefaultCell().setBorderWidth(2); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell(new Phrase(exportColumn.getLabel().getDisplay(), labelFont)); datatable.getDefaultCell().setBorderWidth(1); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); final DtField dtField = exportColumn.getDtField(); final Object value = dtField.getDataAccessor().getValue(exportSheet.getDtObject()); final int horizontalAlignement; if (value instanceof Number || value instanceof LocalDate || value instanceof Instant) { horizontalAlignement = Element.ALIGN_RIGHT; } else if (value instanceof Boolean) { horizontalAlignement = Element.ALIGN_CENTER; } else {//ww w .j ava 2 s .com horizontalAlignement = Element.ALIGN_LEFT; } datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignement); String text = ExportUtil.getText(storeManager, referenceCache, denormCache, exportSheet.getDtObject(), exportColumn); if (text == null) { text = ""; } datatable.addCell(new Phrase(8, text, valueFont)); } }
From source file:io.vertigo.quarto.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
/** * Effectue le rendu de la liste.//from w w w.jav a 2s .c o m * * @param parameters Paramtres * @param datatable Table */ private void renderList(final ExportSheet parameters, final Table datatable) throws BadElementException { // data rows final Font font = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); final Font whiteFont = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); whiteFont.setColor(Color.WHITE); datatable.getDefaultCell().setBorderWidth(1); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); // Parcours des DTO de la DTC for (final DtObject dto : parameters.getDtList()) { for (final ExportField exportColumn : parameters.getExportFields()) { final DtField dtField = exportColumn.getDtField(); final Object value = dtField.getDataAccessor().getValue(dto); final int horizontalAlignement; if (value instanceof Number || value instanceof LocalDate || value instanceof Instant) { horizontalAlignement = Element.ALIGN_RIGHT; } else if (value instanceof Boolean) { horizontalAlignement = Element.ALIGN_CENTER; } else { horizontalAlignement = Element.ALIGN_LEFT; } datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignement); String text = ExportUtil.getText(storeManager, referenceCache, denormCache, dto, exportColumn); if (text == null) { text = ""; } datatable.addCell(new Phrase(8, text, font)); } } }
From source file:ispyb.client.biosaxs.pdf.DataAcquisitionPDFReport.java
License:Open Source License
private ByteArrayOutputStream exportAsPdf(Experiment3VO experiment, List<Buffer3VO> buffers, Proposal3VO proposal) throws Exception { Document document = new Document(PageSize.A4.rotate(), 10, 10, 20, 20); document.addTitle("exportSamplesView"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); HeaderFooter header = new HeaderFooter( new Phrase(proposal.getTitle() + " " + proposal.getCode() + proposal.getNumber()), false); header.setAlignment(Element.ALIGN_CENTER); header.getBefore().getFont().setSize(8); HeaderFooter footer = new HeaderFooter(new Phrase("Page n."), true); footer.setAlignment(Element.ALIGN_RIGHT); footer.setBorderWidth(1);/* w w w .j a va 2 s . co m*/ footer.getBefore().getFont().setSize(6); document.setHeader(header); document.setFooter(footer); document.open(); BaseFont bf = BaseFont.createFont(FONTS[0][0], FONTS[0][1], BaseFont.EMBEDDED); Font font = new Font(bf, 6); document.add(new Paragraph("Data Acquisition: " + experiment.getName(), font)); document.add(new Paragraph("Type: " + experiment.getType(), font)); document.add(new Paragraph("Date: " + experiment.getCreationDate(), font)); document.add(new Paragraph("Proposal: " + proposal.getCode() + proposal.getNumber(), font)); document.add(new Paragraph("Title: " + proposal.getTitle(), font)); document.add(new Paragraph(" ")); document.add(new Paragraph("Measurements", PdfRtfExporter.FONT_DOC_BOLD)); document.add(new Paragraph(" ")); document.add(this.getMeasurementTable(experiment, buffers)); document.newPage(); document.add(new Paragraph(" ")); document.add(new Paragraph("Analysis", PdfRtfExporter.FONT_DOC_BOLD)); document.add(new Paragraph(" ")); document.add(this.getAnalysis(experiment, buffers)); document.newPage(); document.add(this.getImageTable(experiment, buffers)); document.close(); return baos; }
From source file:ispyb.client.mx.collection.PdfRtfExporter.java
License:Open Source License
/** * set footer in the specified document//from w w w. ja v a 2 s .com * * @param document * @throws Exception */ private void setFooter(Document document) throws Exception { HeaderFooter footer = new HeaderFooter(new Phrase("Page n."), true); footer.setAlignment(Element.ALIGN_RIGHT); footer.setBorderWidth(1); footer.getBefore().getFont().setSize(SMALL_FONT); document.setFooter(footer); }
From source file:ispyb.client.mx.collection.PdfRtfExporter.java
License:Open Source License
/** * set a cell for a param or empty cell if no more param in the list * /* ww w . j a va2 s . co m*/ * @param table * @param listParam * @param id * @param colSpanTitle * @throws Exception */ private void setCellParam(Table table, List<Param> listParam, int id, int colSpanTitle) throws Exception { if (id < listParam.size()) { Param param = listParam.get(id); Cell cellTitle = new Cell(); cellTitle.setBorderWidth(0); cellTitle.setColspan(colSpanTitle); cellTitle.setHorizontalAlignment(Element.ALIGN_RIGHT); cellTitle.add(new Paragraph(param.getText(), FONT_DOC_PARAM_TITLE)); table.addCell(cellTitle); Cell cellValue = new Cell(); cellValue.setBorderWidth(0); cellValue.setHorizontalAlignment(Element.ALIGN_LEFT); cellValue.add(new Paragraph(param.getValue(), FONT_DOC)); table.addCell(cellValue); } else { Cell cellTitle = getEmptyCell(1); cellTitle.setBorderWidth(0); cellTitle.setColspan(colSpanTitle); table.addCell(cellTitle); Cell cellValue = getEmptyCell(1); cellValue.setBorderWidth(0); table.addCell(cellValue); } }
From source file:ispyb.client.mx.results.ExportAutoProcAction.java
License:Open Source License
/** * set footer in the specified document/* w ww .j a va 2s . co m*/ * * @param document * @throws Exception */ private void setFooter(Document document) throws Exception { HeaderFooter footer = new HeaderFooter(new Phrase("Page n."), true); footer.setAlignment(Element.ALIGN_RIGHT); footer.setBorderWidth(1); footer.getBefore().getFont().setSize(PdfRtfExporter.SMALL_FONT); document.setFooter(footer); }
From source file:ispyb.common.util.export.PdfExporterSample.java
License:Open Source License
/** * Exports the file for viewSample for shipment * //from w w w . j a v a2s. com * @return * @throws Exception */ public ByteArrayOutputStream exportAsPdf() throws Exception { // create simple doc and write to a ByteArrayOutputStream Document document = new Document(PageSize.A4.rotate(), 20, 20, 20, 20); document.addTitle("exportSamplesView"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); HeaderFooter header; // header + footer if (viewName != null) header = new HeaderFooter(new Phrase("Samples for Proposal: " + proposalDesc + " --- " + viewName), false); else header = new HeaderFooter(new Phrase("Samples for Proposal: " + proposalDesc), false); header.setAlignment(Element.ALIGN_CENTER); header.setBorderWidth(1); header.getBefore().getFont().setSize(8); HeaderFooter footer = new HeaderFooter(new Phrase("Page n."), true); footer.setAlignment(Element.ALIGN_RIGHT); footer.setBorderWidth(1); footer.getBefore().getFont().setSize(6); document.setHeader(header); document.setFooter(footer); document.open(); if (aList.isEmpty()) { document.add(new Paragraph("There is no samples in this report")); document.close(); return baos; } // Create first table for samples int NumColumns = 19; PdfPTable table = new PdfPTable(NumColumns); int headerwidths[] = { 6, 6, 6, 6, 6, 4, 6, 4, 4, 4, 4, 4, 4, 8, 5, 5, 5, 10, 6 }; // percentage table.setWidths(headerwidths); table.setWidthPercentage(100); // percentage table.getDefaultCell().setPadding(3); table.getDefaultCell().setBorderWidth(1); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); // header PdfPCell cell = new PdfPCell(); table.addCell(new Paragraph("Protein", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Sample name", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Smp code", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Dewar", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Container", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Loc. in cont.", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Space group", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Cell a", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Cell b", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Cell c", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Cell alpha", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Cell beta", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Cell gamma", new Font(Font.HELVETICA, 8))); cell = new PdfPCell(new Paragraph("Crystal comments", new Font(Font.HELVETICA, 8))); table.addCell(cell); table.addCell(new Paragraph("Already observed resol.", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Required resol.", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Min. resol.", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Sample comments", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Sample status", new Font(Font.HELVETICA, 8))); table.setHeaderRows(1); // this is the end of the table header table.getDefaultCell().setBorderWidth(1); DecimalFormat df1 = new DecimalFormat("#####0.0"); DecimalFormat df2 = new DecimalFormat("#####0.00"); Iterator it = aList.iterator(); int i = 1; String currentContainer = "next"; String nextContainer = "next"; while (it.hasNext()) { table.getDefaultCell().setGrayFill(0.99f); if (i % 2 == 1) { table.getDefaultCell().setGrayFill(0.9f); } BLSample3VO samplefv = (BLSample3VO) it.next(); LOG.debug("table of datacollections pdf " + samplefv.getBlSampleId()); if (samplefv.getContainerVO() != null && samplefv.getContainerVO().getCode() != null) nextContainer = samplefv.getContainerVO().getCode(); else nextContainer = "next"; // in the case of view sorted by dewar/container, we add a page break afetr each container if (sortView.equals("2") && !currentContainer.equals(nextContainer)) { document.add(table); table.deleteBodyRows(); document.newPage(); } if (samplefv.getCrystalVO().getProteinVO().getAcronym() != null) table.addCell(new Paragraph(samplefv.getCrystalVO().getProteinVO().getAcronym(), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getName() != null) table.addCell(new Paragraph(samplefv.getName(), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getCode() != null) table.addCell(new Paragraph(samplefv.getCode(), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getContainerVO() != null && samplefv.getContainerVO().getDewarVO() != null && samplefv.getContainerVO().getDewarVO().getCode() != null) table.addCell(new Paragraph(samplefv.getContainerVO().getDewarVO().getCode(), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getContainerVO() != null && samplefv.getContainerVO().getCode() != null) { currentContainer = samplefv.getContainerVO().getCode(); table.addCell(new Paragraph(currentContainer, new Font(Font.HELVETICA, 8))); } else { currentContainer = "current"; table.addCell(""); } if (samplefv.getLocation() != null) table.addCell(new Paragraph(samplefv.getLocation(), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getCrystalVO().getSpaceGroup() != null) table.addCell(new Paragraph(samplefv.getCrystalVO().getSpaceGroup(), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getCrystalVO().getCellA() != null) table.addCell( new Paragraph(df1.format(samplefv.getCrystalVO().getCellA()), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getCrystalVO().getCellB() != null) table.addCell( new Paragraph(df1.format(samplefv.getCrystalVO().getCellB()), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getCrystalVO().getCellC() != null) table.addCell( new Paragraph(df1.format(samplefv.getCrystalVO().getCellC()), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getCrystalVO().getCellAlpha() != null) table.addCell(new Paragraph(df1.format(samplefv.getCrystalVO().getCellAlpha()), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getCrystalVO().getCellBeta() != null) table.addCell(new Paragraph(df1.format(samplefv.getCrystalVO().getCellBeta()), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getCrystalVO().getCellGamma() != null) table.addCell(new Paragraph(df1.format(samplefv.getCrystalVO().getCellGamma()), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getCrystalVO().getComments() != null) table.addCell(new Paragraph(samplefv.getCrystalVO().getComments(), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getDiffractionPlanVO() != null && samplefv.getDiffractionPlanVO().getObservedResolution() != null) { table.addCell(new Paragraph(df2.format(samplefv.getDiffractionPlanVO().getObservedResolution()), new Font(Font.HELVETICA, 8))); } else if (samplefv.getCrystalVO().getDiffractionPlanVO() != null && samplefv.getCrystalVO().getDiffractionPlanVO().getObservedResolution() != null) table.addCell(new Paragraph( df2.format(samplefv.getCrystalVO().getDiffractionPlanVO().getObservedResolution()), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getDiffractionPlanVO() != null && samplefv.getDiffractionPlanVO().getRequiredResolution() != null) { table.addCell(new Paragraph(df2.format(samplefv.getDiffractionPlanVO().getRequiredResolution()), new Font(Font.HELVETICA, 8))); } else if (samplefv.getCrystalVO().getDiffractionPlanVO() != null && samplefv.getCrystalVO().getDiffractionPlanVO().getRequiredResolution() != null) table.addCell(new Paragraph( df2.format(samplefv.getCrystalVO().getDiffractionPlanVO().getRequiredResolution()), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getDiffractionPlanVO() != null && samplefv.getDiffractionPlanVO().getMinimalResolution() != null) { table.addCell(new Paragraph(df2.format(samplefv.getDiffractionPlanVO().getMinimalResolution()), new Font(Font.HELVETICA, 8))); } else if (samplefv.getCrystalVO().getDiffractionPlanVO() != null && samplefv.getCrystalVO().getDiffractionPlanVO().getMinimalResolution() != null) table.addCell(new Paragraph( df2.format(samplefv.getCrystalVO().getDiffractionPlanVO().getMinimalResolution()), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getComments() != null && samplefv.getComments() != "") table.addCell(new Paragraph(samplefv.getComments(), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getBlSampleStatus() != null) table.addCell(new Paragraph(samplefv.getBlSampleStatus(), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (i % 2 == 1) { table.getDefaultCell().setGrayFill(0.0f); } i++; } document.add(table); document.close(); return baos; }