Example usage for com.lowagie.text.pdf PdfPCell setHorizontalAlignment

List of usage examples for com.lowagie.text.pdf PdfPCell setHorizontalAlignment

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfPCell setHorizontalAlignment.

Prototype

public void setHorizontalAlignment(int horizontalAlignment) 

Source Link

Document

Sets the horizontal alignment for the cell.

Usage

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 {//w w  w .  jav  a2 s . com
            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.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.  j  a  va2 s. 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.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);/*from  w  w  w. j  av  a 2 s  .c  o m*/
        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());/*from  w w  w  .  j  a  v  a 2  s  . c o  m*/
    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"));
    }
}

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  w ww .ja v a  2 s  .  c  o  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 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  w w .  jav  a  2 s.c  o  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 {/*from  w w  w.j  a  va  2  s  .  co 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.PdfRuntimeDependenciesReport.java

License:Apache License

private void writeHeader() throws DocumentException {
    final List<String> headers = new ArrayList<String>();
    headers.add("Beans");
    headers.addAll(calledBeans);/* ww w . j a v a2s .  c o m*/
    final int[] relativeWidths = new int[headers.size()];
    Arrays.fill(relativeWidths, 0, headers.size(), 1);
    relativeWidths[0] = 4;

    final PdfPTable table = new PdfPTable(headers.size());
    table.setWidthPercentage(100);
    table.setWidths(relativeWidths);
    table.setHeaderRows(1);
    final PdfPCell defaultCell = table.getDefaultCell();
    defaultCell.setGrayFill(0.9f);
    defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    defaultCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    defaultCell.setPaddingLeft(0);
    defaultCell.setPaddingRight(0);
    for (final String header : headers) {
        table.addCell(new Phrase(header, boldCellFont));
        // pas la premire entte de colonne
        defaultCell.setRotation(90);
    }
    defaultCell.setRotation(0);
    defaultCell.setPaddingLeft(2);
    defaultCell.setPaddingRight(2);
    currentTable = table;
}

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 ww.j a va 2s.  com*/
    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);
        }
    }
}