List of usage examples for com.lowagie.text Paragraph setAlignment
public void setAlignment(String alignment)
From source file:net.bull.javamelody.internal.web.pdf.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 ww . jav a 2s . c o m return; } if (collector.isStorageUsedByMultipleInstances()) { final String message = getString("storage_used_by_multiple_instances") + "\n\n"; final Paragraph jrobinParagraph = new Paragraph(message, PdfFonts.BOLD.getFont()); jrobinParagraph.setAlignment(Element.ALIGN_CENTER); addToDocument(jrobinParagraph); } 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")); final Collection<byte[]> graphs; if (mySmallGraphs != null) { // si les graphiques ont t prinitialiss (en Swing) alors on les utilise graphs = mySmallGraphs.values(); } else { if (jrobins.isEmpty()) { return; } graphs = new ArrayList<byte[]>(jrobins.size()); for (final JRobin jrobin : jrobins) { graphs.add(jrobin.graph(range, SMALL_GRAPH_WIDTH, SMALL_GRAPH_HEIGHT)); } } int i = 0; for (final byte[] graph : graphs) { 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(graph); 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.internal.web.pdf.PdfCounterReport.java
License:Apache License
private void writeFooter() throws DocumentException { final List<CounterRequest> requests = counterRequestAggregation.getRequests(); final CounterRequest globalRequest = counterRequestAggregation.getGlobalRequest(); // delta ni ngatif ni 0 final long deltaMillis = Math.max(System.currentTimeMillis() - counter.getStartDate().getTime(), 1); final long hitsParMinute = 60 * 1000 * globalRequest.getHits() / deltaMillis; final String key; if (isJobCounter()) { key = "nb_jobs"; } else if (isErrorCounter()) { key = "nb_erreurs"; } else {/*from ww w. j ava 2s.com*/ key = "nb_requetes"; } final Paragraph footer = new Paragraph( getFormattedString(key, integerFormat.format(hitsParMinute), integerFormat.format(requests.size())), normalFont); footer.setAlignment(Element.ALIGN_RIGHT); addToDocument(footer); }
From source file:net.bull.javamelody.internal.web.pdf.PdfCounterRequestContextReport.java
License:Apache License
private void writeFooter() throws DocumentException { final Paragraph footer = new Paragraph( getFormattedString("nb_requete_en_cours", integerFormat.format(rootCurrentContexts.size())), normalFont);//w w w. j a va 2 s .c o m footer.setAlignment(Element.ALIGN_RIGHT); addToDocument(footer); }
From source file:net.bull.javamelody.internal.web.pdf.PdfJobInformationsReport.java
License:Apache License
private void addConfigurationReference() throws DocumentException { final Anchor quartzAnchor = new Anchor("Configuration reference", PdfFonts.BLUE.getFont()); quartzAnchor.setName("Quartz configuration reference"); quartzAnchor.setReference("http://www.quartz-scheduler.org/docs/index.html"); quartzAnchor.setFont(PdfFonts.BLUE.getFont()); final Paragraph quartzParagraph = new Paragraph(); quartzParagraph.add(quartzAnchor);//from w w w .j a va2 s .c o m quartzParagraph.setAlignment(Element.ALIGN_RIGHT); addToDocument(quartzParagraph); }
From source file:net.bull.javamelody.internal.web.pdf.PdfProcessInformationsReport.java
License:Apache License
private void addPsCommandReference() throws DocumentException { final Anchor psAnchor = new Anchor("ps command reference", PdfFonts.BLUE.getFont()); psAnchor.setName("ps command reference"); psAnchor.setReference("http://en.wikipedia.org/wiki/Ps_(Unix)"); psAnchor.setFont(PdfFonts.BLUE.getFont()); final Paragraph psParagraph = new Paragraph(); psParagraph.add(psAnchor);/* www . j a v a 2 s . co m*/ psParagraph.setAlignment(Element.ALIGN_RIGHT); addToDocument(psParagraph); }
From source file:net.bull.javamelody.internal.web.pdf.PdfSessionInformationsReport.java
License:Apache License
@Override void toPdf() throws IOException, DocumentException { if (sessionsInformations.isEmpty()) { addToDocument(new Phrase(getString("Aucune_session"), cellFont)); return;//from ww w . ja v a2 s . co m } writeHeader(); writeSessions(); long totalSerializedSize = 0; int nbSerializableSessions = 0; for (final SessionInformations sessionInformations : sessionsInformations) { final int size = sessionInformations.getSerializedSize(); if (size >= 0) { totalSerializedSize += size; nbSerializableSessions++; } } final long meanSerializedSize; if (nbSerializableSessions > 0) { meanSerializedSize = totalSerializedSize / nbSerializableSessions; } else { meanSerializedSize = -1; } final Paragraph paragraph = new Paragraph("", cellFont); paragraph.add(getFormattedString("nb_sessions", sessionsInformations.size()) + "\n\n" + getFormattedString("taille_moyenne_sessions", meanSerializedSize)); paragraph.setAlignment(Element.ALIGN_RIGHT); addToDocument(paragraph); }
From source file:net.bull.javamelody.internal.web.pdf.PdfThreadInformationsReport.java
License:Apache License
@Override void toPdf() throws DocumentException, IOException { writeHeader();//from w w w . j a v a 2s .com for (final ThreadInformations threadInformations : threadInformationsList) { nextRow(); writeThreadInformations(threadInformations); } addTableToDocument(); final Paragraph tempsThreads = new Paragraph(getString("Temps_threads") + '\n', cellFont); tempsThreads.setAlignment(Element.ALIGN_RIGHT); addToDocument(tempsThreads); // rq stack-trace: on n'inclue pas dans le pdf les stack-traces des threads // car c'est trs verbeux et cela remplirait des pages pour pas grand chose // d'autant que si le pdf est gnr de nuit pour tre envoy par mail // alors ces stack-traces n'ont pas beaucoup d'intrt // if (stackTrace != null && !stackTrace.isEmpty()) { // // mme si stackTraceEnabled, ce thread n'a pas forcment de stack-trace // writeln(threadInformations.getName()); // for (final StackTraceElement stackTraceElement : stackTrace) { // writeln(stackTraceElement.toString()); // } // } }
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 ww w. j a v a2 s. co 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.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// w ww . j a va2s . c om * 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 createHeaderAndFooter(Document doc) { Paragraph p = new Paragraph("Checkstyle statistics", pageHeaderAndFooterFont); p.setAlignment(Element.ALIGN_CENTER); HeaderFooter header = new RtfHeaderFooter(p); doc.setHeader(header);/*from w w w. jav a 2 s . c o 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); }