List of usage examples for com.lowagie.text Element ALIGN_LEFT
int ALIGN_LEFT
To view the source code for com.lowagie.text Element ALIGN_LEFT.
Click Source Link
From source file:net.bull.javamelody.internal.web.pdf.PdfProcessInformationsReport.java
License:Apache License
private void writeProcessInformations(ProcessInformations processInformations) { final PdfPCell defaultCell = getDefaultCell(); defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); addCell(processInformations.getUser()); defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); addCell(integerFormat.format(processInformations.getPid())); if (!windows) { addCell(percentFormat.format(processInformations.getCpuPercentage())); addCell(percentFormat.format(processInformations.getMemPercentage())); }/*from ww w . jav a2 s .co m*/ addCell(integerFormat.format(processInformations.getVsz())); if (!windows) { addCell(integerFormat.format(processInformations.getRss())); defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); addCell(processInformations.getTty()); addCell(processInformations.getStat()); defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); addCell(processInformations.getStart()); } addCell(processInformations.getCpuTime()); defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); addCell(processInformations.getCommand()); }
From source file:net.bull.javamelody.internal.web.pdf.PdfRequestAndGraphDetailReport.java
License:Apache License
private void writeRequestRumData() throws DocumentException { final CounterRequestRumData rumData = request.getRumData(); final DecimalFormat percentFormat = I18N.createPercentFormat(); final int networkTimeMean = rumData.getNetworkTimeMean(); final int serverMean = request.getMean(); final int domProcessingMean = rumData.getDomProcessingMean(); final int pageRenderingMean = rumData.getPageRenderingMean(); final int totalTime = networkTimeMean + serverMean + domProcessingMean + pageRenderingMean; final double networkPercent = 100d * networkTimeMean / totalTime; final double serverPercent = 100d * serverMean / totalTime; final double domProcessingPercent = 100d * domProcessingMean / totalTime; final double pageRenderingPercent = 100d * pageRenderingMean / totalTime; final PdfPTable table = new PdfPTable(2); table.setHorizontalAlignment(Element.ALIGN_LEFT); table.setWidthPercentage(25);/* w ww .j a va 2 s .c o m*/ table.getDefaultCell().setBorderWidth(0); table.addCell(new Phrase(I18N.getString("Network"), cellFont)); table.addCell(new Phrase( integerFormat.format(networkTimeMean) + " ms (" + percentFormat.format(networkPercent) + "%)", cellFont)); table.addCell(new Phrase(I18N.getString("Server"), cellFont)); table.addCell(new Phrase( integerFormat.format(serverMean) + " ms (" + percentFormat.format(serverPercent) + "%)", cellFont)); table.addCell(new Phrase(I18N.getString("DOM_processing"), cellFont)); table.addCell(new Phrase(integerFormat.format(domProcessingMean) + " ms (" + percentFormat.format(domProcessingPercent) + "%)", cellFont)); table.addCell(new Phrase(I18N.getString("Page_rendering"), cellFont)); table.addCell(new Phrase(integerFormat.format(pageRenderingMean) + " ms (" + percentFormat.format(pageRenderingPercent) + "%)", cellFont)); addToDocument(table); addToDocument(new Phrase("\n", cellFont)); }
From source file:net.bull.javamelody.internal.web.pdf.PdfRequestAndGraphDetailReport.java
License:Apache License
private void writeRequest(CounterRequest childRequest, float executionsByRequest, boolean allChildHitsDisplayed) throws IOException, DocumentException { final PdfPCell defaultCell = getDefaultCell(); defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); final Paragraph paragraph = new Paragraph(defaultCell.getLeading() + cellFont.getSize()); if (executionsByRequest != -1) { paragraph.setIndentationLeft(5); }/*from w ww . j a va2 s .com*/ final Counter parentCounter = getCounterByRequestId(childRequest); if (parentCounter != null && parentCounter.getIconName() != null) { paragraph.add(new Chunk(getSmallImage(parentCounter.getIconName()), 0, -1)); } paragraph.add(new Phrase(childRequest.getName(), cellFont)); final PdfPCell requestCell = new PdfPCell(); requestCell.addElement(paragraph); requestCell.setGrayFill(defaultCell.getGrayFill()); requestCell.setPaddingTop(defaultCell.getPaddingTop()); addCell(requestCell); defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); if (executionsByRequest != -1) { addCell(nbExecutionsFormat.format(executionsByRequest)); } else { addCell(""); } writeRequestValues(childRequest, allChildHitsDisplayed); }
From source file:net.bull.javamelody.internal.web.pdf.PdfRuntimeDependenciesReport.java
License:Apache License
private void writeBeanDependencies(String callerBean, Map<String, Integer> beanDependencies) { getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); addCell(callerBean, cellFont);/*from w w w . jav a 2 s. co m*/ getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); for (final String calledBean : calledBeans) { final Integer dependency = beanDependencies.get(calledBean); if (dependency == null) { addCell("", cellFont); } else { final String s = dependency.toString(); if (dependency > standardDeviation * 2) { addCell(s, severeCellFont); } else if (dependency > standardDeviation) { addCell(s, warningCellFont); } else { addCell(s, cellFont); } } } }
From source file:net.bull.javamelody.internal.web.pdf.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());/*from w w w. j a v a 2 s . c o m*/ 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); writeBrowserAndOs(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.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. j a v a 2s . com*/ 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.PdfCounterReport.java
License:Apache License
private void writeRequest(CounterRequest request) throws BadElementException, IOException { getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); final String name = request.getName(); if (name.length() > 1000) { // si la requte fait plus de 1000 caractres, on la coupe pour y voir quelque chose addCell(name.substring(0, 1000) + "..."); } else {//from w ww . j a va 2 s . c o m addCell(name); } if (includeGraph) { writeRequestGraph(request); } getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); final CounterRequest globalRequest = counterRequestAggregation.getGlobalRequest(); if (counterRequestAggregation.isTimesDisplayed()) { addPercentageCell(request.getDurationsSum(), globalRequest.getDurationsSum()); addCell(integerFormat.format(request.getHits())); final int mean = request.getMean(); addCell(new Phrase(integerFormat.format(mean), getSlaFont(mean))); addCell(integerFormat.format(request.getMaximum())); addCell(integerFormat.format(request.getStandardDeviation())); } else { addCell(integerFormat.format(request.getHits())); } if (counterRequestAggregation.isCpuTimesDisplayed()) { addPercentageCell(request.getCpuTimeSum(), globalRequest.getCpuTimeSum()); final int cpuTimeMean = request.getCpuTimeMean(); addCell(new Phrase(integerFormat.format(cpuTimeMean), getSlaFont(cpuTimeMean))); } if (!isErrorAndNotJobCounter()) { addCell(systemErrorFormat.format(request.getSystemErrorPercentage())); } if (counterRequestAggregation.isResponseSizeDisplayed()) { addCell(integerFormat.format(request.getResponseSizeMean() / 1024)); } if (counterRequestAggregation.isChildHitsDisplayed()) { addCell(integerFormat.format(request.getChildHitsMean())); addCell(integerFormat.format(request.getChildDurationsMean())); } }
From source file:net.bull.javamelody.PdfDatabaseInformationsReport.java
License:Apache License
private void writeRow(String[] row) { final PdfPCell defaultCell = getDefaultCell(); defaultCell.setVerticalAlignment(Element.ALIGN_TOP); for (final String value : row) { if (value == null || value.length() == 0) { addCell(""); } else {/*from w ww .j a v a 2 s . c om*/ if (isNumber(value)) { defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); } else { defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); } addCell(value); } } }
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());//from www . ja va2 s . co m 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
/** * We create a writer that listens to the document and directs a PDF-stream to out * * @param table/*from ww w . j a va2 s . co m*/ * MBasicTable * @param document * Document * @param out * OutputStream * @return DocWriter * @throws DocumentException * e */ protected DocWriter createWriter(final MBasicTable table, final Document document, final OutputStream out) throws DocumentException { final PdfWriter writer = PdfWriter.getInstance(document, out); // writer.setViewerPreferences(PdfWriter.PageLayoutTwoColumnLeft); // title if (table.getName() != null) { final HeaderFooter header = new HeaderFooter(new Phrase(table.getName()), false); header.setAlignment(Element.ALIGN_LEFT); header.setBorder(Rectangle.NO_BORDER); document.setHeader(header); document.addTitle(table.getName()); } // simple page numbers : x // HeaderFooter footer = new HeaderFooter(new Phrase(), true); // footer.setAlignment(Element.ALIGN_RIGHT); // footer.setBorder(Rectangle.TOP); // document.setFooter(footer); // add the event handler for advanced page numbers : x/y writer.setPageEvent(new AdvancedPageNumberEvents()); return writer; }