Example usage for com.lowagie.text Element ALIGN_LEFT

List of usage examples for com.lowagie.text Element ALIGN_LEFT

Introduction

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

Prototype

int ALIGN_LEFT

To view the source code for com.lowagie.text Element ALIGN_LEFT.

Click Source Link

Document

A possible value for paragraph alignment.

Usage

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

License:Apache License

private void writeError(CounterError error, boolean displayUser, boolean displayHttpRequest) {
    getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
    addCell(dateTimeFormat.format(error.getDate()));
    getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    if (displayHttpRequest) {
        if (error.getHttpRequest() == null) {
            addCell("");
        } else {/*www  .jav  a  2s  .com*/
            addCell(error.getHttpRequest());
        }
    }
    if (displayUser) {
        if (error.getRemoteUser() == null) {
            addCell("");
        } else {
            addCell(error.getRemoteUser());
        }
    }
    addCell(error.getMessage());
}

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);/*from w  w  w .  j a v  a2 s . c om*/
    }
    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 writeContext(CounterRequestContext rootContext, boolean displayRemoteUser)
        throws DocumentException, IOException {
    getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    // attention, cela ne marcherait pas sur le serveur de collecte,  partir du seul threadId
    // s'il y a plusieurs instances en cluster
    final ThreadInformations threadInformations = threadInformationsByThreadId.get(rootContext.getThreadId());
    if (threadInformations == null) {
        addCell(""); // un dcalage n'a pas permis de rcuprer le thread de ce context
    } else {//w  ww  . j a v  a  2  s . c  o m
        addCell(threadInformations.getName());
    }
    if (displayRemoteUser) {
        if (rootContext.getRemoteUser() == null) {
            addCell("");
        } else {
            addCell(rootContext.getRemoteUser());
        }
    }

    final List<CounterRequestContext> contexts = new ArrayList<CounterRequestContext>();
    contexts.add(rootContext);
    contexts.addAll(rootContext.getChildContexts());
    writeRequests(contexts);
    writeDurations(contexts);

    final CounterRequestContextReportHelper counterRequestContextReportHelper = new CounterRequestContextReportHelper(
            contexts, childHitsDisplayed);
    for (final int[] requestValues : counterRequestContextReportHelper.getRequestValues()) {
        writeRequestValues(requestValues);
    }

    if (stackTraceEnabled) {
        getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
        if (threadInformations == null) {
            addCell(""); // un dcalage n'a pas permis de rcuprer le thread de ce context
        } else {
            addCell(threadInformations.getExecutedMethod());
        }
    }
}

From source file:net.bull.javamelody.internal.web.pdf.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.isEmpty()) {
            addCell("");
        } else {//from  w  ww .  jav a 2s  . c  o  m
            if (isNumber(value)) {
                defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            } else {
                defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
            }
            addCell(value);
        }
    }
}

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

License:Apache License

private void createWriter(Document document, String title) throws DocumentException, IOException {
    final PdfWriter writer = PdfWriter.getInstance(document, output);
    //writer.setViewerPreferences(PdfWriter.PageLayoutTwoColumnLeft);

    // title//from w w w.j  a  v  a  2s.  com
    final HeaderFooter header = new HeaderFooter(new Phrase(title), false);
    header.setAlignment(Element.ALIGN_LEFT);
    header.setBorder(Rectangle.NO_BORDER);
    document.setHeader(header);

    // 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 PdfAdvancedPageNumberEvents());
}

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

License:Apache License

private void writeClassInfoRow(ClassInfo classInfo, long totalInstances, long totalBytes,
        boolean sourceDisplayed) {
    final PdfPCell defaultCell = getDefaultCell();
    defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    addCell(classInfo.getName());//  w ww  .  java  2s.c o m
    defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    final long bytes = classInfo.getBytes();
    final long instancesCount = classInfo.getInstancesCount();
    addCell(integerFormat.format(bytes / 1024));
    addCell(integerFormat.format(bytes * 100 / totalBytes));
    addCell(integerFormat.format(instancesCount));
    addCell(integerFormat.format(instancesCount * 100 / totalInstances));
    defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    if (sourceDisplayed) {
        final String source = classInfo.getSource();
        if (source == null) {
            addCell("");
        } else {
            addCell(source);
        }
    }
}

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

License:Apache License

private void writeHotspot(SampledMethod hotspot) {
    final PdfPCell defaultCell = getDefaultCell();
    defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    addCell(hotspot.getClassName() + '.' + hotspot.getMethodName());
    defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    final double percent = 100d * hotspot.getCount() / totalCount;
    addCell(percentFormat.format(percent));
}

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

License:Apache License

private static PdfPTable createJavaInformationsTable() throws DocumentException {
    final PdfPTable table = new PdfPTable(2);
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.setWidthPercentage(100);/*from   w ww .  j  a  v a2 s. co  m*/
    table.setWidths(new int[] { 2, 8 });
    table.getDefaultCell().setBorder(0);
    return table;
}

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

License:Apache License

private void writeJndiBinding(JndiBinding jndiBinding) throws BadElementException, IOException {
    final PdfPCell defaultCell = getDefaultCell();
    defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    final String name = jndiBinding.getName();
    final String className = jndiBinding.getClassName();
    final String contextPath = jndiBinding.getContextPath();
    final String value = jndiBinding.getValue();
    if (contextPath != null) {
        final Image image = getFolderImage();
        final Phrase phrase = new Phrase("", cellFont);
        phrase.add(new Chunk(image, 0, 0));
        phrase.add(" ");
        phrase.add(name);// ww  w.  ja  va2s.  c  om
        addCell(phrase);
    } else {
        addCell(name);
    }
    addCell(className != null ? className : "");
    addCell(value != null ? value : "");
}

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

License:Apache License

private void writeJobInformations(JobInformations jobInformations) throws BadElementException, IOException {
    final PdfPCell defaultCell = getDefaultCell();
    defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    addCell(jobInformations.getGroup());
    addCell(jobInformations.getName());/*  w  w  w  .j  a  v  a 2  s  . c  om*/
    addCell(jobInformations.getJobClassName());
    defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    final CounterRequest counterRequest = getCounterRequest(jobInformations);
    // counterRequest ne peut pas tre null ici
    if (counterRequest.getMean() >= 0) {
        addCell(formatDuration(counterRequest.getMean()));
    } else {
        addCell("");
    }
    // rq: on n'affiche pas ici le nb d'excutions, le maximum, l'cart-type
    // ou le pourcentage d'erreurs, uniquement car cela ferait trop de colonnes dans la page
    writeJobTimes(jobInformations, counterRequest);
    defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    if (jobInformations.isPaused()) {
        addCell(getString("oui"));
    } else {
        addCell(getString("non"));
    }
}