Example usage for com.lowagie.text Paragraph add

List of usage examples for com.lowagie.text Paragraph add

Introduction

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

Prototype

public boolean add(Object o) 

Source Link

Document

Adds an Object to the Paragraph.

Usage

From source file:org.tellervo.desktop.print.ProSheet.java

License:Open Source License

/**
 * Get an iText Paragraph for the Title 
 * //from  w w  w  . ja va2s  .c  o  m
 * @return Paragraph
 */
private Paragraph getTitlePDF() {
    Paragraph p = new Paragraph();

    p.add(new Chunk(o.getLabCode() + " - " + o.getTitle() + "\n", titleFont));

    //p.add(new Chunk(i.getCode(), subTitleFont));

    return p;
}

From source file:org.tellervo.desktop.print.ProSheet.java

License:Open Source License

private Paragraph getObjectDescription() {

    Paragraph p = new Paragraph();
    p.setLeading(0, 1.2f);//w  w w  .  j av  a2s . com
    p.setAlignment(Element.ALIGN_JUSTIFIED);
    p.setSpacingAfter(10);
    p.setSpacingBefore(50);

    if (o.getDescription() != null) {
        p.add(new Chunk(o.getDescription(), bodyFont));
    } else {
        p.add(new Chunk("No description recorded", bodyFont));
    }

    return p;
}

From source file:org.tellervo.desktop.print.ProSheet.java

License:Open Source License

private Paragraph getObjectComments() {

    Paragraph p = new Paragraph();
    p.setLeading(0, 1.2f);//from ww w . ja va  2 s . co  m
    p.setAlignment(Element.ALIGN_JUSTIFIED);
    p.setSpacingAfter(10);

    if (o.getComments() != null) {
        p.add(new Chunk("Notes: ", commentFont));
        p.add(new Chunk(o.getComments(), commentFont));
    }

    return p;
}

From source file:org.tellervo.desktop.print.ReportBase.java

License:Open Source License

/**
 * Blank iText paragraph used for padding 
 * @return Paragraph//from w w  w  .ja  v a2 s.com
 */
protected Paragraph getParagraphSpace() {
    Paragraph p = new Paragraph();

    p.add(new Chunk(" "));
    return p;
}

From source file:org.tellervo.desktop.print.SeriesReport.java

License:Open Source License

private void generateSeriesReport(OutputStream output) {

    displayUnits = NormalTridasUnit/*ww  w .  j av  a  2  s .c  o m*/
            .valueOf(App.prefs.getPref(PrefKey.DISPLAY_UNITS, NormalTridasUnit.MICROMETRES.name().toString()));

    try {

        PdfWriter writer = PdfWriter.getInstance(document, output);
        document.setPageSize(PageSize.LETTER);
        document.open();
        cb = writer.getDirectContent();

        // Set basic metadata
        document.addAuthor("Peter Brewer");
        document.addSubject("Tellervo Series Report for " + s.getDisplayTitle());

        // Title Left      
        ColumnText ct = new ColumnText(cb);
        ct.setSimpleColumn(document.left(), document.top() - 163, 283, document.top(), 20, Element.ALIGN_LEFT);
        ct.addText(getTitlePDF());
        ct.go();

        // Barcode
        ColumnText ct2 = new ColumnText(cb);
        ct2.setSimpleColumn(370, document.top(15) - 100, document.right(0), document.top(0), 20,
                Element.ALIGN_RIGHT);
        ct2.addElement(getBarCode());
        ct2.go();

        // Timestamp
        ColumnText ct3 = new ColumnText(cb);
        ct3.setSimpleColumn(document.left(), document.top() - 223, 283, document.top() - 60, 20,
                Element.ALIGN_LEFT);
        ct3.setLeading(0, 1.2f);
        ct3.addText(getTimestampPDF());
        ct3.go();

        // Authorship
        ColumnText ct4 = new ColumnText(cb);
        ct4.setSimpleColumn(284, document.top() - 223, document.right(10), document.top() - 60, 20,
                Element.ALIGN_RIGHT);
        ct4.setLeading(0, 1.2f);
        ct4.addText(getAuthorshipPDF());
        ct4.go();

        // Pad text
        document.add(new Paragraph(" "));
        Paragraph p2 = new Paragraph();
        p2.setSpacingBefore(50);
        p2.setSpacingAfter(10);
        p2.add(new Chunk(" ", bodyFont));
        document.add(new Paragraph(p2));

        // Ring width table
        getRingWidthTable();
        document.add(getParagraphSpace());

        if (s.getSeries() instanceof TridasMeasurementSeries) {
            // MEASUREMENT SERIES

            //document.add(getRingRemarks());
            document.add(getWoodCompletenessPDF());
            document.add(getParagraphSpace());
            document.add(getSeriesComments());
            document.add(getParagraphSpace());
            document.add(getInterpretationPDF());
            document.add(getParagraphSpace());
            document.add(getElementAndSampleInfo());
        } else {
            // DERIVED SERIES
            getWJTable();
            document.add(getParagraphSpace());
            document.add(getSeriesComments());
            document.add(getParagraphSpace());
            //document.add(getRingRemarks());

        }

    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    }

    // Close the document
    document.close();
}

From source file:org.tellervo.desktop.print.SeriesReport.java

License:Open Source License

/**
 * Get an iText Paragraph for the Title 
 * /*from   www .  j  a  v a  2  s  .  c om*/
 * @return Paragraph
 */
private Paragraph getTitlePDF() {
    Paragraph p = new Paragraph();

    p.add(new Chunk(s.getDisplayTitle() + "\n", titleFont));

    // Add object name if this is a mSeries
    if (s.getSeries() instanceof TridasMeasurementSeries) {
        TridasObject tobj = s.getMeta(Metadata.OBJECT, TridasObject.class);

        p.add(new Chunk(tobj.getTitle(), subTitleFont));
    }
    return p;
}

From source file:org.tellervo.desktop.print.SeriesReport.java

License:Open Source License

/**
 * iText paragraph containing created and lastmodified timestamps
 * //  w  ww.  java 2 s  .c o  m
 * @return Paragraph
 */
private Paragraph getTimestampPDF() {
    // Set up calendar
    Date createdTimestamp = s.getSeries().getCreatedTimestamp().getValue().toGregorianCalendar().getTime();
    Date lastModifiedTimestamp = s.getSeries().getLastModifiedTimestamp().getValue().toGregorianCalendar()
            .getTime();
    DateFormat df1 = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT);

    Paragraph p = new Paragraph();

    p.add(new Chunk("Created: ", subSubSectionFont));
    p.add(new Chunk(df1.format(createdTimestamp), bodyFont));
    p.add(new Chunk("\nLast Modified: ", subSubSectionFont));
    p.add(new Chunk(df1.format(lastModifiedTimestamp), bodyFont));

    return p;

}

From source file:org.tellervo.desktop.print.SeriesReport.java

License:Open Source License

/**
 * iText Paragraph containing the various authorship fields
 * @return Paragraph/*from   ww w .  j  a  v  a 2  s  .c  o  m*/
 */
private Paragraph getAuthorshipPDF() {
    Paragraph p = new Paragraph();

    ITridasSeries sss = s.getSeries();
    TridasMeasurementSeries mseries = null;
    TridasDerivedSeries dseries = null;

    if (sss instanceof TridasMeasurementSeries) {
        mseries = (TridasMeasurementSeries) sss;
        if (mseries.getAnalyst() != null) {
            p.add(new Chunk("Measured by: ", subSubSectionFont));
            p.add(new Chunk(mseries.getAnalyst(), bodyFont));
        }

        if (mseries.getDendrochronologist() != null) {
            p.add(new Chunk("\nSupervised by: ", subSubSectionFont));
            p.add(new Chunk(mseries.getDendrochronologist(), bodyFont));
        }
    } else {
        dseries = (TridasDerivedSeries) sss;
        p.add(new Chunk("Created by: ", subSubSectionFont));
        p.add(new Chunk(dseries.getAuthor(), bodyFont));

    }

    return p;

}

From source file:org.tellervo.desktop.print.SeriesReport.java

License:Open Source License

private Paragraph getSeriesComments() {

    Paragraph p = new Paragraph();

    if (s.getSeries().getComments() != null) {

        p.setLeading(0, 1.2f);/*from   w  ww.  j a  va2s.  co m*/
        p.add(new Chunk("Comments: \n", subSubSectionFont));
        p.add(new Chunk(s.getSeries().getComments(), bodyFont));
        return p;
    } else {
        return p;
    }

}

From source file:org.tellervo.desktop.print.SeriesReport.java

License:Open Source License

private Paragraph getInterpretationPDF() {

    Paragraph p = new Paragraph();
    p.setLeading(0, 1.2f);//from  www.j av  a2  s  .co m
    Year firstyear = s.getSeries().getInterpretation().getFirstYear();
    Year pithYear = s.getSeries().getInterpretation().getPithYear();
    Year deathyear = s.getSeries().getInterpretation().getDeathYear();
    Boolean isRelativelyDated = false;
    p.add(new Chunk("Interpretation:", subSubSectionFont));

    String datingType = s.getSeries().getInterpretation().getDating().getType().toString();

    if (datingType == "RELATIVE")
        isRelativelyDated = true;

    if (firstyear != null) {
        p.add(new Chunk("\n- The first ring of this series begins in ", bodyFont));
        if (isRelativelyDated)
            p.add(new Chunk("relative year ", bodyFont));

        if (firstyear.getCertainty() != null) {
            p.add(new Chunk(firstyear.getCertainty().toString().toLowerCase() + " ", bodyFont));
        }
        p.add(new Chunk(firstyear.getValue().toString(), bodyFont));
        if (isRelativelyDated == false)
            p.add(new Chunk(firstyear.getSuffix().toString(), bodyFont));
        p.add(new Chunk(".\n", bodyFont));
    }

    if (pithYear != null && deathyear != null) {
        p.add(new Chunk("- The pith of this radius was laid down ", bodyFont));
        if (pithYear.getCertainty() != null) {
            p.add(certaintyToNaturalString(pithYear.getCertainty().toString()));
        }
        if (isRelativelyDated)
            p.add(new Chunk("relative year ", bodyFont));
        p.add(new Chunk(pithYear.getValue().toString(), bodyFont));
        if (isRelativelyDated == false)
            p.add(new Chunk(pithYear.getSuffix().toString(), bodyFont));
        p.add(new Chunk(" and died ", bodyFont));
        if (deathyear.getCertainty() != null) {
            p.add(certaintyToNaturalString(deathyear.getCertainty().toString()));
        }
        if (isRelativelyDated)
            p.add(new Chunk("relative year ", bodyFont));
        p.add(new Chunk(deathyear.getValue().toString(), bodyFont));
        if (isRelativelyDated == false)
            p.add(new Chunk(deathyear.getSuffix().toString(), bodyFont));
        p.add(new Chunk(".\n", bodyFont));

    }

    // Dated with...
    if (s.getSeries().getInterpretation().getDatingReference() != null) {
        p.add(new Chunk("\n- This series was dated using series: " + s.getSeries().getInterpretation()
                .getDatingReference().getLinkSeries().getIdentifier().getValue().toString(), bodyFont));
    }

    // Provence...
    if (s.getSeries().getInterpretation().getProvenance() != null) {
        p.add(new Chunk("\n- Provenance: " + s.getSeries().getInterpretation().getProvenance().toString(),
                bodyFont));
    }

    return p;
}