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: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); }// www . jav a2s.co m 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.PdfRequestAndGraphDetailReport.java
License:Apache License
private void writeRequestValues(CounterRequest aRequest, boolean allChildHitsDisplayed) { final PdfPCell defaultCell = getDefaultCell(); defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); addCell(integerFormat.format(aRequest.getMean())); addCell(integerFormat.format(aRequest.getMaximum())); addCell(integerFormat.format(aRequest.getStandardDeviation())); if (aRequest.getCpuTimeMean() >= 0) { addCell(integerFormat.format(aRequest.getCpuTimeMean())); } else {// w w w .j av a 2s.c o m addCell(""); } if (isAllocatedKBytesDisplayed()) { if (aRequest.getAllocatedKBytesMean() >= 0) { addCell(integerFormat.format(aRequest.getAllocatedKBytesMean())); } else { addCell(""); } } addCell(systemErrorFormat.format(aRequest.getSystemErrorPercentage())); if (allChildHitsDisplayed) { final boolean childHitsDisplayed = aRequest.hasChildHits(); if (childHitsDisplayed) { addCell(integerFormat.format(aRequest.getChildHitsMean())); } else { addCell(""); } if (childHitsDisplayed) { addCell(integerFormat.format(aRequest.getChildDurationsMean())); } else { addCell(""); } } }
From source file:net.bull.javamelody.internal.web.pdf.PdfRequestAndGraphDetailReport.java
License:Apache License
private void writeGraph() throws IOException, DocumentException { final JRobin jrobin = collector.getJRobin(graphName); if (jrobin != null) { final byte[] img = jrobin.graph(range, 960, 400); final Image image = Image.getInstance(img); image.scalePercent(50);//from w w w. j a v a2 s . com final PdfPTable table = new PdfPTable(1); table.setHorizontalAlignment(Element.ALIGN_CENTER); table.setWidthPercentage(100); table.getDefaultCell().setBorder(0); table.addCell("\n"); table.addCell(image); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(new Phrase(getString("graph_units"), cellFont)); addToDocument(table); } else { // just in case request is null and collector.getJRobin(graphName) is null, we must write something in the document addToDocument(new Phrase("\n", cellFont)); } }
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 ww w. j a v a 2s. c o 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
@Override void toPdf() throws IOException, DocumentException { if (sessionsInformations.isEmpty()) { addToDocument(new Phrase(getString("Aucune_session"), cellFont)); return;//w w w .j a va 2s . c o 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.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 ww . jav a2s. 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
@Override void toPdf() throws DocumentException, IOException { writeHeader();/*from www .j ava2 s . c om*/ 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.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 ww w.j a v a 2 s . 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 w w . ja v a2 s . c om 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 .jav a 2 s . c o m if (isNumber(value)) { defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); } else { defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); } addCell(value); } } }