Example usage for com.lowagie.text Phrase Phrase

List of usage examples for com.lowagie.text Phrase Phrase

Introduction

In this page you can find the example usage for com.lowagie.text Phrase Phrase.

Prototype

public Phrase(float leading, String string) 

Source Link

Document

Constructs a Phrase with a certain leading and a certain String.

Usage

From source file:net.bull.javamelody.internal.web.pdf.PdfCoreReport.java

License:Apache License

private void writeDurationAndOverhead() throws DocumentException {
    final long displayDuration = System.currentTimeMillis() - start;
    final String tmp = "\n\n" + getString("temps_derniere_collecte") + ": " + collector.getLastCollectDuration()
            + ' ' + getString("ms") + '\n' + getString("temps_affichage") + ": " + displayDuration + ' '
            + getString("ms") + '\n' + getString("Estimation_overhead_memoire") + ": < "
            + (collector.getEstimatedMemorySize() / 1024 / 1024 + 1) + ' ' + getString("Mo") + '\n'
            + getString("Usage_disque") + ": " + (collector.getDiskUsage() / 1024 / 1024 + 1) + ' '
            + getString("Mo");
    final String string;
    if (Parameters.JAVAMELODY_VERSION != null) {
        string = tmp + "\n\n" + "JavaMelody " + Parameters.JAVAMELODY_VERSION;
    } else {//w  ww.jav  a 2s .co m
        string = tmp;
    }
    addToDocument(new Phrase(string, cellFont));
}

From source file:net.bull.javamelody.internal.web.pdf.PdfCounterErrorReport.java

License:Apache License

@Override
void toPdf() throws DocumentException {
    final List<CounterError> errors = counter.getErrors();
    if (errors.isEmpty()) {
        addToDocument(new Phrase(getString("Aucune_erreur"), normalFont));
    } else {/*from w w w  .j a  v a 2 s. c om*/
        writeErrors(errors);
    }
}

From source file:net.bull.javamelody.internal.web.pdf.PdfCounterErrorReport.java

License:Apache License

private void writeErrors(List<CounterError> errors) throws DocumentException {
    assert errors != null;
    final boolean displayUser = HtmlCounterErrorReport.shouldDisplayUser(errors);
    final boolean displayHttpRequest = HtmlCounterErrorReport.shouldDisplayHttpRequest(errors);
    if (errors.size() >= Counter.MAX_ERRORS_COUNT) {
        addToDocument(//w  w w . j  a va 2s  .  co  m
                new Phrase(getFormattedString("Dernieres_erreurs_seulement", Counter.MAX_ERRORS_COUNT) + '\n',
                        severeFont));
    }
    writeHeader(displayUser, displayHttpRequest);

    for (final CounterError error : errors) {
        nextRow();
        writeError(error, displayUser, displayHttpRequest);
    }
    addTableToDocument();
}

From source file:net.bull.javamelody.internal.web.pdf.PdfCounterReport.java

License:Apache License

private void writeNoRequests() throws DocumentException {
    final String msg;
    if (isJobCounter()) {
        msg = "Aucun_job";
    } else if (isErrorCounter()) {
        msg = "Aucune_erreur";
    } else {/*from  w w w .  j a  v  a  2s .co  m*/
        msg = "Aucune_requete";
    }
    addToDocument(new Phrase(getString(msg), normalFont));
}

From source file:net.bull.javamelody.internal.web.pdf.PdfCounterReport.java

License:Apache License

private void writeRequest(CounterRequest request) throws BadElementException, IOException {
    getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    addCell(getShortRequestName(request));
    if (includeGraph) {
        writeRequestGraph(request);// www  .java 2 s . co  m
    }
    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 (counterRequestAggregation.isAllocatedKBytesDisplayed()) {
        final long allocatedKBytesMean = request.getAllocatedKBytesMean();
        addCell(integerFormat.format(allocatedKBytesMean));
    }
    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.internal.web.pdf.PdfCounterRequestContextReport.java

License:Apache License

private void writeDurations(List<CounterRequestContext> contexts) throws DocumentException, IOException {
    getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);

    final Paragraph paragraph = new Paragraph("", cellFont);
    boolean first = true;
    for (final CounterRequestContext context : contexts) {
        if (!first) {
            paragraph.add(new Chunk('\n', cellFont));
        }/* www . java2 s . c o m*/
        final int duration = context.getDuration(timeOfSnapshot);
        final Counter parentCounter = context.getParentCounter();
        final PdfCounterReport counterReport = counterReportsByCounterName.get(parentCounter.getName());
        if (parentCounter.getIconName() != null) {
            paragraph.add(new Chunk(getImage(parentCounter.getIconName()), 0, -1));
        }
        final Font slaFont;
        if (counterReport == null) {
            slaFont = infoCellFont;
        } else {
            slaFont = counterReport.getSlaFont(duration);
        }
        paragraph.add(new Phrase(integerFormat.format(duration), slaFont));
        first = false;
    }
    addCell(paragraph);
}

From source file:net.bull.javamelody.internal.web.pdf.PdfCounterRequestContextReport.java

License:Apache License

private void writeRequest(CounterRequestContext context, PdfPCell cell, int margin)
        throws DocumentException, IOException {
    final Paragraph paragraph = new Paragraph(getDefaultCell().getLeading() + cellFont.getSize());
    paragraph.setIndentationLeft(margin);
    if (context.getParentCounter().getIconName() != null) {
        paragraph.add(new Chunk(getImage(context.getParentCounter().getIconName()), 0, -1));
    }/*  w  w w  .ja  v a  2s.  co  m*/
    paragraph.add(new Phrase(context.getCompleteRequestName(), cellFont));
    cell.addElement(paragraph);
}

From source file:net.bull.javamelody.internal.web.pdf.PdfDocumentFactory.java

License:Apache License

Element createParagraphElement(String paragraphTitle, String iconName) throws DocumentException, IOException {
    final Paragraph paragraph = new Paragraph("", paragraphTitleFont);
    paragraph.setSpacingBefore(5);// w  ww. j  av  a 2  s.c o  m
    paragraph.setSpacingAfter(5);
    if (iconName != null) {
        paragraph.add(new Chunk(getParagraphImage(iconName), 0, -5));
    }
    final Phrase element = new Phrase(' ' + paragraphTitle, paragraphTitleFont);
    element.setLeading(12);
    paragraph.add(element);
    // chapter pour avoir la liste des signets
    final ChapterAutoNumber chapter = new ChapterAutoNumber(paragraph);
    // sans numro de chapitre
    chapter.setNumberDepth(0);
    chapter.setBookmarkOpen(false);
    chapter.setTriggerNewPage(false);
    return chapter;
}

From source file:net.bull.javamelody.internal.web.pdf.PdfHeapHistogramReport.java

License:Apache License

@Override
void toPdf() throws DocumentException {
    addToDocument(new Phrase(getString("Heap"), boldFont));
    final List<ClassInfo> heap = heapHistogram.getHeapHistogram();
    final long totalHeapInstances = heapHistogram.getTotalHeapInstances();
    final long totalHeapBytes = heapHistogram.getTotalHeapBytes();
    final String separator = ",   ";
    addToDocument(new Phrase("     " + getString("Classes") + ": " + integerFormat.format(heap.size())
            + separator + getString("Instances") + ": " + integerFormat.format(totalHeapInstances) + separator
            + getString("Kilo-Octets") + ": " + integerFormat.format(totalHeapBytes / 1024), cellFont));
    writeHeader(heapHistogram.isSourceDisplayed());
    writeClassInfo(heap, totalHeapInstances, totalHeapBytes, heapHistogram.isSourceDisplayed());
    final List<ClassInfo> permGen = heapHistogram.getPermGenHistogram();
    if (!permGen.isEmpty()) {
        // avec jrockit, permGen est vide
        addToDocument(new Phrase("\n\n" + getString("PermGen"), boldFont));
        final long totalPermGenInstances = heapHistogram.getTotalPermGenInstances();
        final long totalPermGenBytes = heapHistogram.getTotalPermGenBytes();
        addToDocument(new Phrase("     " + getString("Classes") + ": " + integerFormat.format(permGen.size())
                + separator + getString("Instances") + ": " + integerFormat.format(totalPermGenInstances)
                + separator + getString("Kilo-Octets") + ": " + integerFormat.format(totalPermGenBytes / 1024),
                cellFont));/*from   w w w  .  j a  v a 2 s .  c  om*/
        writeHeader(false);
        writeClassInfo(permGen, totalPermGenInstances, totalPermGenBytes, false);
    }
}

From source file:net.bull.javamelody.internal.web.pdf.PdfJavaInformationsReport.java

License:Apache License

private void writeSummary(JavaInformations javaInformations) throws BadElementException, IOException {
    addCell(getString("Host") + ':');
    currentTable.addCell(new Phrase(javaInformations.getHost(), boldCellFont));
    addCell(getString("memoire_utilisee") + ':');
    final MemoryInformations memoryInformations = javaInformations.getMemoryInformations();
    final long usedMemory = memoryInformations.getUsedMemory();
    final long maxMemory = memoryInformations.getMaxMemory();
    final Phrase memoryPhrase = new Phrase(
            integerFormat.format(usedMemory / 1024 / 1024) + ' ' + getString("Mo") + DIVIDE
                    + integerFormat.format(maxMemory / 1024 / 1024) + ' ' + getString("Mo") + BAR_SEPARATOR,
            cellFont);// w ww .  j  a v a2  s  .  c  o  m
    final Image memoryImage = Image
            .getInstance(Bar.toBarWithAlert(memoryInformations.getUsedMemoryPercentage()), null);
    memoryImage.scalePercent(50);
    memoryPhrase.add(new Chunk(memoryImage, 0, 0));
    currentTable.addCell(memoryPhrase);
    if (javaInformations.getSessionCount() >= 0) {
        addCell(getString("nb_sessions_http") + ':');
        addCell(integerFormat.format(javaInformations.getSessionCount()));
    }
    addCell(getString("nb_threads_actifs") + "\n(" + getString("Requetes_http_en_cours") + "):");
    addCell(integerFormat.format(javaInformations.getActiveThreadCount()));
    if (!noDatabase) {
        addCell(getString("nb_connexions_actives") + ':');
        addCell(integerFormat.format(javaInformations.getActiveConnectionCount()));
        addCell(getString("nb_connexions_utilisees") + "\n(" + getString("ouvertes") + "):");
        final int usedConnectionCount = javaInformations.getUsedConnectionCount();
        final int maxConnectionCount = javaInformations.getMaxConnectionCount();
        if (maxConnectionCount <= 0) {
            addCell(integerFormat.format(usedConnectionCount));
        } else {
            final Phrase usedConnectionCountPhrase = new Phrase(integerFormat.format(usedConnectionCount)
                    + DIVIDE + integerFormat.format(maxConnectionCount) + BAR_SEPARATOR, cellFont);
            final Image usedConnectionCountImage = Image
                    .getInstance(Bar.toBarWithAlert(javaInformations.getUsedConnectionPercentage()), null);
            usedConnectionCountImage.scalePercent(50);
            usedConnectionCountPhrase.add(new Chunk(usedConnectionCountImage, 0, 0));
            currentTable.addCell(usedConnectionCountPhrase);
        }
    }
    if (javaInformations.getSystemLoadAverage() >= 0) {
        addCell(getString("Charge_systeme") + ':');
        addCell(decimalFormat.format(javaInformations.getSystemLoadAverage()));
    }
    if (javaInformations.getSystemCpuLoad() >= 0) {
        addCell(getString("systemCpuLoad") + ':');
        final Phrase systemCpuLoadPhrase = new Phrase(
                decimalFormat.format(javaInformations.getSystemCpuLoad()) + BAR_SEPARATOR, cellFont);
        final Image systemCpuLoadImage = Image
                .getInstance(Bar.toBarWithAlert(javaInformations.getSystemCpuLoad()), null);
        systemCpuLoadImage.scalePercent(50);
        systemCpuLoadPhrase.add(new Chunk(systemCpuLoadImage, 0, 0));
        currentTable.addCell(systemCpuLoadPhrase);
    }
}