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

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

Introduction

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

Prototype

public PdfPCell() 

Source Link

Document

Constructs an empty PdfPCell.

Usage

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

License:Apache License

private void writeRequests(List<CounterRequestContext> contexts) throws DocumentException, IOException {
    final PdfPCell defaultCell = getDefaultCell();
    final PdfPCell requestCell = new PdfPCell();
    final Paragraph phrase = new Paragraph("", cellFont);
    int margin = 0;
    for (final CounterRequestContext context : contexts) {
        writeRequest(context, requestCell, margin);
        margin += 5;/*from   ww w .j a  v  a2 s  . c  om*/
    }
    // on utilise ici PdfPCell et addElement pour que les proprits
    // leading et indentationLeft des paragraphes soient prises en compte
    requestCell.addElement(phrase);
    requestCell.setGrayFill(defaultCell.getGrayFill());
    requestCell.setPaddingTop(defaultCell.getPaddingTop());
    addCell(requestCell);
}

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 ww w .j ava2s  .  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.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.c  o  m
        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:nl.dykema.jxmlnote.report.pdf.PdfTable.java

License:Open Source License

public Table add(Cell cel) {
    if (cel instanceof PdfCell) {
        super.addCell((PdfCell) cel);
    } else {//from w ww.  j  av a 2 s . com
        PdfPCell c = new PdfPCell();
        c.addElement(new Paragraph(new Chunk("Cannot mix different implementations")));
        super.addCell(c);
    }
    return this;
}

From source file:optika.sql.java

public PdfPCell getCellWhite(String text, int alignment, int bottom) {
    PdfPCell cell = new PdfPCell();
    FontSelector selector = new FontSelector();
    com.lowagie.text.Font f1 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12);
    f1.setColor(Color.white);//from  www  .  j a v  a 2  s.c o  m
    selector.addFont(f1);
    cell.addElement(selector.process(text));
    cell.setPadding(0);
    cell.setHorizontalAlignment(alignment);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setPaddingBottom(bottom);
    return cell;
}

From source file:org.areasy.common.doclet.document.Inherited.java

License:Open Source License

/**
 * Prints inherited methods and fields from superclasses
 *
 * @param supercls  class source to get inherited fields and methods for.
 * @param show SHOW_METHODS or SHOW_FIELDS
 * @throws Exception/*from   w w  w.  j av a2  s . co m*/
 */
public static void print(ClassDoc supercls, int show) throws Exception {
    String type;

    FieldDoc[] fields = supercls.fields();

    Arrays.sort(fields);

    if (supercls.isInterface())
        type = "interface";
    else
        type = "class";

    // Create cell for additional spacing below
    PdfPCell spacingCell = new PdfPCell();
    spacingCell.addElement(new Chunk(" "));
    spacingCell.setFixedHeight((float) 4.0);
    spacingCell.setBorder(Rectangle.BOTTOM + Rectangle.LEFT + Rectangle.RIGHT);
    spacingCell.setBorderColor(Color.gray);

    if ((fields.length > 0) && (show == SHOW_FIELDS)) {
        Document.instance().add(new Paragraph((float) 6.0, " "));

        PdfPTable table = new PdfPTable(1);
        table.setWidthPercentage((float) 100);

        Paragraph newLine = new Paragraph();
        newLine.add(new Chunk("Fields inherited from " + type + " ", Fonts.getFont(TEXT_FONT, BOLD, 10)));
        newLine.add(new LinkPhrase(supercls.qualifiedTypeName(), null, 10, false));

        table.addCell(new CustomPdfPCell(newLine, COLOR_INHERITED_SUMMARY));

        Paragraph paraList = new Paragraph();

        for (int i = 0; i < fields.length; i++) {
            paraList.add(new LinkPhrase(fields[i].qualifiedName(), fields[i].name(), 10, false));

            if (i != (fields.length - 1))
                paraList.add(new Chunk(", ", Fonts.getFont(TEXT_FONT, BOLD, 12)));
        }

        PdfPCell contentCell = new CellBorderPadding(paraList);
        float leading = (float) contentCell.getLeading() + (float) 1.1;
        contentCell.setLeading(leading, leading);
        table.addCell(contentCell);
        table.addCell(spacingCell);

        Document.instance().add(table);
    }

    MethodDoc[] meth = supercls.methods();

    Arrays.sort(meth);

    if ((meth.length > 0) && (show == SHOW_METHODS)) {
        Document.instance().add(new Paragraph((float) 6.0, " "));

        PdfPTable table = new CustomPdfPTable();

        Paragraph newLine = new Paragraph();
        newLine.add(new Chunk("Methods inherited from " + type + " ", Fonts.getFont(TEXT_FONT, BOLD, 10)));
        newLine.add(new LinkPhrase(supercls.qualifiedTypeName(), null, 10, false));

        table.addCell(new CustomPdfPCell(newLine, COLOR_INHERITED_SUMMARY));
        Paragraph paraList = new Paragraph();

        for (int i = 0; i < meth.length; i++) {
            String methodLabel = meth[i].name();

            // Do not list static initializers like "<clinit>"
            if (!methodLabel.startsWith("<")) {
                paraList.add(new LinkPhrase(supercls.qualifiedTypeName() + "." + meth[i].name(), meth[i].name(),
                        10, false));

                if (i != (meth.length - 1))
                    paraList.add(new Chunk(", ", Fonts.getFont(CODE_FONT, 10)));
            }
        }

        PdfPCell contentCell = new CellBorderPadding(paraList);
        float leading = (float) contentCell.getLeading() + (float) 1.1;
        contentCell.setLeading(leading, leading);
        table.addCell(contentCell);
        table.addCell(spacingCell);

        Document.instance().add(table);
    }

    // Print inherited interfaces / class methods and fields recursively
    ClassDoc supersupercls = null;

    if (supercls.isClass())
        supersupercls = supercls.superclass();

    if (supersupercls != null) {
        String className = supersupercls.qualifiedName();
        if (ifClassMustBePrinted(className))
            Inherited.print(supersupercls, show);
    }

    ClassDoc[] interfaces = supercls.interfaces();
    for (int i = 0; i < interfaces.length; i++) {
        supersupercls = interfaces[i];
        String className = supersupercls.qualifiedName();
        if (ifClassMustBePrinted(className))
            Inherited.print(supersupercls, show);
    }
}

From source file:org.cocktail.superplan.server.gestionimpression.TabularEdtReport.java

License:CeCILL license

public NSData genererPdf(NSArray creneaux, NSTimestamp debutSemaine, String semaine, String libelleFormation)
        throws DocumentException {

    ByteArrayOutputStream os = new ByteArrayOutputStream();
    Document document = new Document();
    PdfWriter.getInstance(document, os);
    document.open();/* w ww . j  av a2  s  .c  o m*/
    document.setMargins(0, 0, 0, 0);

    Font font = new Font(Font.TIMES_ROMAN, 12, Font.BOLD, Color.DARK_GRAY);

    PdfPTable headerTable = new PdfPTable(1);

    PdfPCell cell = new PdfPCell();
    Phrase ph = new Phrase();
    ph.add(new Chunk(libelleFormation, font));
    cell.setPhrase(ph);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    headerTable.addCell(cell);

    font = new Font(Font.TIMES_ROMAN, 10, Font.NORMAL, Color.DARK_GRAY);
    cell = new PdfPCell();
    ph = new Phrase();
    ph.add(new Chunk(semaine, font));
    cell.setPhrase(ph);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    headerTable.addCell(cell);

    headerTable.setWidthPercentage(100);
    headerTable.setSpacingAfter(5.0f);

    document.add(headerTable);

    PdfPTable pdfTable = creerCreneauxTable(creneaux, debutSemaine);

    pdfTable.setWidthPercentage(100);

    document.add(pdfTable);
    document.close();
    return new NSData(os.toByteArray());
}

From source file:org.cocktail.superplan.server.gestionimpression.TabularEdtReport.java

License:CeCILL license

public void ecrireCreneauxJour(String nomJour, NSArray creneaux, NSTimestamp date, PdfPTable pdfTable) {

    PdfPCell cell = new PdfPCell();
    cell.setBackgroundColor(Color.YELLOW);
    Phrase ph = new Phrase();
    ph.add(new Chunk(nomJour, BOLD_ITALIC));
    cell.setPhrase(ph);//from  w w  w  .  jav a2  s .  com
    pdfTable.addCell(cell);

    cell = new PdfPCell();
    ph = new Phrase();
    ph.add(new Chunk(FormatHandler.dateToStr(date, FORMAT_DATE), BOLD_ITALIC));
    cell.setPhrase(ph);
    cell.setColspan(3);
    pdfTable.addCell(cell);

    Object obj;

    for (int i = 0; i < creneaux.count(); i++) {
        obj = creneaux.objectAtIndex(i);
        if (obj instanceof NSArray) {
            for (int j = 0; j < ((NSArray) obj).count(); j++) {
                ecrireCreneau((NSDictionary) ((NSArray) obj).objectAtIndex(j), pdfTable);
            }
        } else {
            ecrireCreneau((NSDictionary) obj, pdfTable);
        }
    }
}

From source file:org.jcryptool.visual.euclid.FileExporter.java

License:Open Source License

public void exportToPDF() {
    table = new PdfPTable(5);
    try {//from w  w w . j av  a2 s  . com
        PdfWriter.getInstance(document, new FileOutputStream(file));
        document.open();
        PdfPCell cell = new PdfPCell();
        cell.setColspan(5);
        float[] width = { 1.2f, 3f, 3f, 3f, 3f };
        table.setTotalWidth(width);
        table.addCell("Index");
        table.addCell("Quotient");
        table.addCell("Remainder");
        table.addCell("x");
        table.addCell("y");

        int size = euclid.length;
        String pValue = euclid[2];
        String qValue = euclid[7];
        String yValue = euclid[size - 7];
        String xValue = euclid[size - 6];
        String resultValue = euclid[size - 8];

        for (int i = 0; i < size; i++) {
            table.addCell(new Phrase(euclid[i]));
            System.out.println("3 " + i);
        }

        document.add(new Paragraph("Extended Euclidian"));
        document.add(new Paragraph("gcd(" + pValue + "," + qValue + ")"));
        document.add(new Paragraph("\n"));
        document.add(table);
        document.add(new Paragraph("\n"));

        if (xValue.charAt(0) == '-') {
            xValue = "( " + xValue + " )";
        }
        if (yValue.charAt(0) == '-') {
            yValue = "( " + yValue + " )";
        }
        String tmpValue = " = " + pValue + " * " + yValue + " + " + qValue + " * " + xValue;
        String resultValueString = tmpValue + " = " + resultValue;

        document.add(new Paragraph(
                "The Greatest Common Divisor of " + pValue + " and " + qValue + " is " + resultValue + "."));
        document.add(new Paragraph("gcd(p,q) = p * x + q * y", fontValuesItalic));
        document.add(new Paragraph("gcd(" + pValue + "," + qValue + ")" + resultValueString, fontValuesItalic));
        document.close();

    } catch (FileNotFoundException e) {
        LogUtil.logError(e);
    } catch (DocumentException e) {
        LogUtil.logError(e);
    }
}

From source file:org.jcryptool.visual.xeuclidean.export.FileExporter.java

License:Open Source License

public void exportToPDF() {
    table = new PdfPTable(5);
    try {/*from w ww. j  av a  2 s .c o m*/
        PdfWriter.getInstance(document, new FileOutputStream(file));
        document.open();
        PdfPCell cell = new PdfPCell();
        cell.setColspan(5);
        float[] width = { 1.2f, 3f, 3f, 3f, 3f };
        table.setTotalWidth(width);
        table.addCell("Index");
        table.addCell("Quotient");
        table.addCell("Remainder");
        table.addCell("X");
        table.addCell("Y");

        String pValue = rTmp.get(0).toString();
        String qValue = rTmp.get(1).toString();
        String yValue = yTmp.lastElement().toString();
        String xValue = xTmp.lastElement().toString();
        String resultValue = rTmp.get(qTmp.size() - 2).toString();
        String resultValueString;

        int size = qTmp.size();
        for (int index = 0; index < size; index++) {
            table.addCell(new Phrase(String.valueOf(index), fontValues));
            if (index == 0 || index == qTmp.size() - 1) {
                table.addCell(new Phrase("", fontValues));
            } else {
                table.addCell(new Phrase(qTmp.get(index).toString(), fontValues));
            }
            table.addCell(new Phrase(rTmp.get(index).toString(), fontValues));
            table.addCell(new Phrase(xTmp.get(index).toString(), fontValues));
            table.addCell(new Phrase(yTmp.get(index).toString(), fontValues));
        }

        document.add(new Paragraph("Extended Euclidian"));
        document.add(new Paragraph("gcd(" + pValue + "," + qValue + ")"));
        document.add(new Paragraph("\n"));
        document.add(table);
        document.add(new Paragraph("\n"));

        if (xTmp.lastElement().compareTo(BigInteger.ZERO) < 0) {
            xValue = "( " + xValue + " )";
        }
        if (yTmp.lastElement().compareTo(BigInteger.ZERO) < 0) {
            yValue = "( " + yValue + " )";
        }
        String tmpValue = " = " + pValue + " * " + yValue + " + " + qValue + " * " + xValue;
        resultValueString = tmpValue + " = " + resultValue;

        document.add(new Paragraph(
                "The Greates Common Divisor of " + pValue + " and " + qValue + " is " + resultValue + "."));
        document.add(new Paragraph("gcd(p,q) = p * x + q * y", fontValuesItalic));
        document.add(new Paragraph("gcd(" + rTmp.get(0) + "," + rTmp.get(1) + ")" + resultValueString,
                fontValuesItalic));
        document.close();

    } catch (FileNotFoundException e) {
        LogUtil.logError(e);
    } catch (DocumentException e) {
        LogUtil.logError(e);
    }
}