List of usage examples for com.lowagie.text Element ALIGN_CENTER
int ALIGN_CENTER
To view the source code for com.lowagie.text Element ALIGN_CENTER.
Click Source Link
From source file:net.bull.javamelody.internal.web.pdf.PdfThreadInformationsReport.java
License:Apache License
private void writeThreadInformations(ThreadInformations threadInformations) throws DocumentException, IOException { final PdfPCell defaultCell = getDefaultCell(); defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); addCell(threadInformations.getName()); defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER); if (threadInformations.isDaemon()) { addCell(getString("oui")); } else {/*from w w w .ja v a 2s . c o m*/ addCell(getString("non")); } defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); addCell(integerFormat.format(threadInformations.getPriority())); defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); final PdfPCell cell = new PdfPCell(); final Paragraph paragraph = new Paragraph(getDefaultCell().getLeading() + cellFont.getSize()); paragraph.add(new Chunk( getImage("bullets/" + HtmlThreadInformationsReport.getStateIcon(threadInformations)), 0, -1)); paragraph.add(new Phrase(String.valueOf(threadInformations.getState()), cellFont)); cell.addElement(paragraph); addCell(cell); if (stackTraceEnabled) { addCell(threadInformations.getExecutedMethod()); } if (cpuTimeEnabled) { defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); addCell(integerFormat.format(threadInformations.getCpuTimeMillis())); addCell(integerFormat.format(threadInformations.getUserTimeMillis())); } }
From source file:net.bull.javamelody.PdfCoreReport.java
License:Apache License
private void writeGraphs(Collection<JRobin> jrobins, Map<String, byte[]> mySmallGraphs) throws IOException, DocumentException { if (collector.isStopped()) { // pas de graphs, ils seraient en erreur sans timer // mais un message d'avertissement la place final String message = getString("collect_server_misusage"); final Paragraph jrobinParagraph = new Paragraph(message, PdfFonts.BOLD.getFont()); jrobinParagraph.setAlignment(Element.ALIGN_CENTER); addToDocument(jrobinParagraph);//from w w w .j a v a 2 s . c o m return; } final Paragraph jrobinParagraph = new Paragraph("", FontFactory.getFont(FontFactory.HELVETICA, 9f, Font.NORMAL)); jrobinParagraph.setAlignment(Element.ALIGN_CENTER); jrobinParagraph.add(new Phrase("\n\n\n\n")); int i = 0; if (mySmallGraphs != null) { // si les graphiques ont t prinitialiss (en Swing) alors on les utilise for (final byte[] imageData : mySmallGraphs.values()) { if (i % 3 == 0 && i != 0) { // un retour aprs httpSessions et avant activeThreads pour l'alignement jrobinParagraph.add(new Phrase("\n\n\n\n\n")); } final Image image = Image.getInstance(imageData); image.scalePercent(50); jrobinParagraph.add(new Phrase(new Chunk(image, 0, 0))); jrobinParagraph.add(new Phrase(" ")); i++; } } else { if (jrobins.isEmpty()) { return; } for (final JRobin jrobin : jrobins) { if (i % 3 == 0 && i != 0) { // un retour aprs httpSessions et avant activeThreads pour l'alignement jrobinParagraph.add(new Phrase("\n\n\n\n\n")); } final Image image = Image.getInstance(jrobin.graph(range, SMALL_GRAPH_WIDTH, SMALL_GRAPH_HEIGHT)); image.scalePercent(50); jrobinParagraph.add(new Phrase(new Chunk(image, 0, 0))); jrobinParagraph.add(new Phrase(" ")); i++; } } jrobinParagraph.add(new Phrase("\n")); addToDocument(jrobinParagraph); }
From source file:net.bull.javamelody.PdfSessionInformationsReport.java
License:Apache License
private void writeSession(SessionInformations session) throws IOException, BadElementException { final PdfPCell defaultCell = getDefaultCell(); defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); addCell(session.getId());// w w w . ja v a2 s.c om defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); addCell(durationFormat.format(session.getLastAccess())); addCell(durationFormat.format(session.getAge())); addCell(expiryFormat.format(session.getExpirationDate())); addCell(integerFormat.format(session.getAttributeCount())); defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER); if (session.isSerializable()) { addCell(getString("oui")); } else { final Phrase non = new Phrase(getString("non"), severeCellFont); addCell(non); } defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); addCell(integerFormat.format(session.getSerializedSize())); defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); final String remoteAddr = session.getRemoteAddr(); if (remoteAddr == null) { addCell(""); } else { addCell(remoteAddr); } defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER); writeCountry(session); if (displayUser) { defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); final String remoteUser = session.getRemoteUser(); if (remoteUser == null) { addCell(""); } else { addCell(remoteUser); } } }
From source file:net.bull.javamelody.swing.print.MPdfWriter.java
License:Apache License
/** * Effectue le rendu des headers./*from www . j a v a2 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.bull.javamelody.swing.print.MPdfWriter.java
License:Apache License
/** * Effectue le rendu de la liste./*www . j av a2 s .com*/ * * @param table * MBasicTable * @param datatable * Table * @throws BadElementException * e */ protected void renderList(final MBasicTable table, final Table datatable) throws BadElementException { final int columnCount = table.getColumnCount(); final int rowCount = table.getRowCount(); // data rows final Font font = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); datatable.getDefaultCell().setBorderWidth(1); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); // datatable.setDefaultCellGrayFill(0); Object value; String text; int horizontalAlignment; for (int k = 0; k < rowCount; k++) { for (int i = 0; i < columnCount; i++) { value = getValueAt(table, k, i); if (value instanceof Number || value instanceof Date) { horizontalAlignment = Element.ALIGN_RIGHT; } else if (value instanceof Boolean) { horizontalAlignment = Element.ALIGN_CENTER; } else { horizontalAlignment = Element.ALIGN_LEFT; } datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignment); text = getTextAt(table, k, i); datatable.addCell(new Phrase(8, text != null ? text : "", font)); } } }
From source file:net.bull.javamelody.swing.print.MRtfWriter.java
License:Apache License
/** * We create a writer that listens to the document and directs a RTF-stream to out * * @param table/*from w w w .j a v a2 s .c o m*/ * MBasicTable * @param document * Document * @param out * OutputStream * @return DocWriter */ @Override protected DocWriter createWriter(final MBasicTable table, final Document document, final OutputStream out) { final RtfWriter2 writer = RtfWriter2.getInstance(document, out); // title final String title = buildTitle(table); if (title != null) { final HeaderFooter header = new RtfHeaderFooter(new Paragraph(title)); header.setAlignment(Element.ALIGN_LEFT); header.setBorder(Rectangle.NO_BORDER); document.setHeader(header); document.addTitle(title); } // advanced page numbers : x/y final Paragraph footerParagraph = new Paragraph(); final Font font = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL); footerParagraph.add(new RtfPageNumber(font)); footerParagraph.add(new Phrase(" / ", font)); footerParagraph.add(new RtfTotalPageNumber(font)); footerParagraph.setAlignment(Element.ALIGN_CENTER); final HeaderFooter footer = new RtfHeaderFooter(footerParagraph); footer.setBorder(Rectangle.TOP); document.setFooter(footer); return writer; }
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 ww w .j a v a2 s. 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);//w ww. j a va 2 s .c om 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:net.sf.eclipsecs.ui.stats.export.internal.RTFStatsExporter.java
License:Open Source License
private void createHeaderAndFooter(Document doc) { Paragraph p = new Paragraph("Checkstyle statistics", pageHeaderAndFooterFont); p.setAlignment(Element.ALIGN_CENTER); HeaderFooter header = new RtfHeaderFooter(p); doc.setHeader(header);/* w w w. j a v a 2 s. co m*/ SimpleDateFormat simpleDateFormat = new SimpleDateFormat(); p = new Paragraph("Gnr le : " + simpleDateFormat.format(new Date()), pageHeaderAndFooterFont); p.setAlignment(Element.ALIGN_CENTER); RtfHeaderFooterGroup footer = new RtfHeaderFooterGroup(); footer.setHeaderFooter(new RtfHeaderFooter(p), com.lowagie.text.rtf.headerfooter.RtfHeaderFooter.DISPLAY_ALL_PAGES); doc.setFooter(footer); }
From source file:net.sf.jasperreports.engine.export.AbstractPdfTextRenderer.java
License:Open Source License
/** * /*w w w. j a v a2 s. c o m*/ */ public void initialize(JRPdfExporter pdfExporter, PdfContentByte pdfContentByte, JRPrintText text, int offsetX, int offsetY) { this.pdfExporter = pdfExporter; this.pdfContentByte = pdfContentByte; horizontalAlignment = Element.ALIGN_LEFT; leftOffsetFactor = 0f; rightOffsetFactor = 0f; //FIXMETAB 0.2f was a fair approximation switch (text.getHorizontalAlignmentValue()) { case JUSTIFIED: { horizontalAlignment = Element.ALIGN_JUSTIFIED_ALL; leftOffsetFactor = 0f; rightOffsetFactor = 0f; break; } case RIGHT: { if (text.getRunDirectionValue() == RunDirectionEnum.LTR) { horizontalAlignment = Element.ALIGN_RIGHT; } else { horizontalAlignment = Element.ALIGN_LEFT; } leftOffsetFactor = -0.2f; rightOffsetFactor = 0f; break; } case CENTER: { horizontalAlignment = Element.ALIGN_CENTER; leftOffsetFactor = -0.1f; rightOffsetFactor = 0.1f; break; } case LEFT: default: { if (text.getRunDirectionValue() == RunDirectionEnum.LTR) { horizontalAlignment = Element.ALIGN_LEFT; } else { horizontalAlignment = Element.ALIGN_RIGHT; } leftOffsetFactor = 0f; rightOffsetFactor = 0.2f; break; } } super.initialize(text, offsetX, offsetY); }