Example usage for com.lowagie.text Paragraph setLeading

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

Introduction

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

Prototype

public void setLeading(float fixedLeading, float multipliedLeading) 

Source Link

Document

Sets the leading fixed and variable.

Usage

From source file:com.jd.survey.web.pdf.SurveyPdf.java

License:Open Source License

private void writeAnswer(Document document, String questionText, String answerValue) throws Exception {
    Paragraph questionParagraph = new Paragraph();
    questionParagraph.setLeading(14, 0);
    questionParagraph.add(new Chunk(questionText.trim() + ": ", boldedFont));
    questionParagraph.add(new Chunk(answerValue == null ? "" : answerValue.trim(), normalFont));
    document.add(questionParagraph);/*from   w w w .j a v  a2 s . c  o m*/
}

From source file:com.jd.survey.web.pdf.SurveyPdf.java

License:Open Source License

private void writeAnswersMatrix(Document document, Question question, Boolean[][] answerValuesMatrix,
        String falseMessage, String trueMessage) throws Exception {
    Table matrixTable;/*from   w  ww.  j  a va  2s. c  om*/
    Cell cell;

    Paragraph questionParagraph = new Paragraph();
    questionParagraph.add(new Chunk(question.getQuestionText().trim() + ": ", boldedFont));
    document.add(questionParagraph);

    matrixTable = new Table(question.getColumnLabels().size() + 1);
    matrixTable.setPadding(2);
    matrixTable.setWidth(100);
    matrixTable.setDefaultCellBorder(0);
    matrixTable.setBorder(0);

    matrixTable.setOffset(4);

    matrixTable.setAutoFillEmptyCells(true);
    matrixTable.setCellsFitPage(true);

    matrixTable.setTableFitsPage(true);
    cell = new Cell("");
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    matrixTable.addCell(cell);

    for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) {
        cell = new Cell(new Paragraph(questionColumnLabel.getLabel(), boldedFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        matrixTable.addCell(cell);
    }
    int rowIndex = 0;
    for (QuestionRowLabel questionRowLabel : question.getRowLabels()) {
        int columnIndex = 0;
        questionParagraph = new Paragraph(questionRowLabel.getLabel(), boldedFont);
        questionParagraph.setLeading(12, 0);
        cell = new Cell(questionParagraph);
        if ((rowIndex % 2) == 1) {
            cell.setBackgroundColor(new Color(231, 238, 244));
        }
        matrixTable.addCell(cell);
        for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) {
            questionParagraph = new Paragraph(
                    answerValuesMatrix[rowIndex][columnIndex] ? trueMessage : falseMessage, normalFont);
            questionParagraph.setLeading(12, 0);
            cell = new Cell(questionParagraph);
            if ((rowIndex % 2) == 1) {
                cell.setBackgroundColor(new Color(231, 238, 244));
            }
            matrixTable.addCell(cell);
            columnIndex++;
        }
        rowIndex++;
    }
    document.add(matrixTable);
}

From source file:com.jd.survey.web.pdf.SurveyPdf.java

License:Open Source License

private void writeAnswersMatrix(Document document, Question question, String[][] answerValuesMatrix)
        throws Exception {
    Table matrixTable;/* w  w w.ja  v  a  2 s  .c  o m*/
    Cell cell;

    Paragraph questionParagraph = new Paragraph();
    questionParagraph.add(new Chunk(question.getQuestionText().trim() + ": ", boldedFont));
    document.add(questionParagraph);

    matrixTable = new Table(question.getColumnLabels().size() + 1);
    matrixTable.setPadding(2);
    matrixTable.setWidth(100);
    matrixTable.setDefaultCellBorder(0);
    matrixTable.setBorder(0);
    matrixTable.setOffset(4);
    matrixTable.setAutoFillEmptyCells(true);
    matrixTable.setCellsFitPage(true);

    matrixTable.setTableFitsPage(true);
    cell = new Cell("");
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    matrixTable.addCell(cell);

    for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) {
        cell = new Cell(new Paragraph(questionColumnLabel.getLabel(), boldedFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        matrixTable.addCell(cell);
    }
    int rowIndex = 0;
    for (QuestionRowLabel questionRowLabel : question.getRowLabels()) {
        int columnIndex = 0;
        questionParagraph = new Paragraph(questionRowLabel.getLabel(), boldedFont);
        questionParagraph.setLeading(12, 0);
        cell = new Cell(questionParagraph);
        if ((rowIndex % 2) == 1) {
            cell.setBackgroundColor(new Color(231, 238, 244));
        }
        matrixTable.addCell(cell);
        for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) {
            questionParagraph = new Paragraph(answerValuesMatrix[rowIndex][columnIndex] == null ? ""
                    : answerValuesMatrix[rowIndex][columnIndex], normalFont);
            questionParagraph.setLeading(12, 0);
            cell = new Cell(questionParagraph);
            if ((rowIndex % 2) == 1) {
                cell.setBackgroundColor(new Color(231, 238, 244));
            }
            matrixTable.addCell(cell);
            columnIndex++;
        }
        rowIndex++;
    }
    document.add(matrixTable);
}

From source file:com.songbook.pc.exporter.PdfExporter.java

License:Open Source License

private Paragraph buildLine(LineNode lineNode) {
    Paragraph paragraph = new Paragraph();
    for (Node node : lineNode.getContentList()) {
        if (node instanceof TextNode) {
            TextNode textNode = (TextNode) node;
            paragraph.add(new Chunk(textNode.getText(), textFont));
        } else if (node instanceof ChordNode) {
            ChordNode chordNode = (ChordNode) node;
            Chunk chunk = new Chunk(" " + chordNode.getText() + " ", chordFont);
            chunk.setTextRise(4f);/*from  www.  j a v  a2 s .c o  m*/
            paragraph.add(chunk);
            paragraph.setLeading(4f, 1.2f);
        }
    }
    return paragraph;
}

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

License:Open Source License

private Paragraph getComments(WSIBox b) throws DocumentException {

    Paragraph p = new Paragraph();
    p.setLeading(0, 1.2f);

    p.add(new Chunk("Comments: \n", subSubSectionFont));
    if (b.getComments() != null) {
        p.add(new Chunk(b.getComments(), bodyFont));
    } else {//www. j  a v a2  s  .c om
        p.add(new Chunk("No comments recorded", bodyFont));
    }

    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);
    p.setAlignment(Element.ALIGN_JUSTIFIED);
    p.setSpacingAfter(10);/*w  w w .j  a va 2 s  . co  m*/
    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);
    p.setAlignment(Element.ALIGN_JUSTIFIED);
    p.setSpacingAfter(10);//www . j a  va 2s .com

    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.SeriesReport.java

License:Open Source License

private Paragraph getSeriesComments() {

    Paragraph p = new Paragraph();

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

        p.setLeading(0, 1.2f);
        p.add(new Chunk("Comments: \n", subSubSectionFont));
        p.add(new Chunk(s.getSeries().getComments(), bodyFont));
        return p;
    } else {/*  w  w  w .  j ava2  s  . co m*/
        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);
    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;/*from  w w w  .  ja v a  2 s.c o m*/

    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;
}

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

License:Open Source License

/**
 * iText paragraph for the TRiDaS wood completeness fields
 * //from   w  w w .j av a  2 s  .  c om
 * @return Paragraph
 */
private Paragraph getWoodCompletenessPDF() {
    Paragraph p = new Paragraph();
    p.setLeading(0, 1.2f);
    TridasRadius trad = s.getMeta(Metadata.RADIUS, TridasRadius.class);
    TridasWoodCompleteness woodCompleteness = trad.getWoodCompleteness();

    String pithPresence = null;
    String barkPresence = null;

    p.add(new Chunk("Wood Completeness:\n", subSubSectionFont));

    // Extract pith info
    if (woodCompleteness.getPith() != null) {

        if (woodCompleteness.getPith().getPresence() != null) {
            pithPresence = woodCompleteness.getPith().getPresence().value();
        } else {
            pithPresence = "not specified";
        }

        p.add(new Chunk("- Pith is " + pithPresence + ".\n", bodyFont));
    } else {
        p.add(new Chunk("- No pith details were recorded.\n", bodyFont));
    }

    // Ring count 
    p.add(new Chunk("- A total of " + String.valueOf(s.countRings()) + " rings were measured.", bodyFont));

    // Unmeasured rings
    if (woodCompleteness.isSetNrOfUnmeasuredInnerRings() || woodCompleteness.isSetNrOfUnmeasuredOuterRings()) {
        String txt = " Additional rings were observed but not measured (";
        if (woodCompleteness.isSetNrOfUnmeasuredInnerRings()) {
            txt += String.valueOf(woodCompleteness.getNrOfUnmeasuredInnerRings()) + " towards the pith";
            if (woodCompleteness.isSetNrOfUnmeasuredOuterRings()) {
                txt += " and ";
            }
        }
        if (woodCompleteness.isSetNrOfUnmeasuredOuterRings()) {
            txt += String.valueOf(woodCompleteness.getNrOfUnmeasuredOuterRings()) + " towards the bark";
        }

        txt += ").";

        p.add(new Chunk(txt, bodyFont));
        p.add(new Chunk("\n"));
    } else {
        p.add(new Chunk("\n"));
    }

    // Extract Heartwood and sapwood info
    p.add(getHeartSapwoodDetails(woodCompleteness, WoodType.HEARTWOOD));
    p.add(getHeartSapwoodDetails(woodCompleteness, WoodType.SAPWOOD));

    // Extract last ring under bark info
    if (woodCompleteness.getSapwood().getLastRingUnderBark() != null) {
        TridasLastRingUnderBark lastRing = woodCompleteness.getSapwood().getLastRingUnderBark();
        if (lastRing.getPresence() != null) {
            if (lastRing.getPresence().equals(PresenceAbsence.PRESENT)) {
                p.add(new Chunk("- Last ring under bark is present", bodyFont));

                if (lastRing.getContent() != null) {
                    p.add(new Chunk(
                            " and the user has noted that it is: " + lastRing.getContent().toString() + ".\n",
                            bodyFont));
                } else {
                    p.add(new Chunk(".\n", bodyFont));
                }

            } else if (lastRing.getPresence().equals(PresenceAbsence.ABSENT)) {
                p.add(new Chunk("- Last ring under bark is absent.\n", bodyFont));
            }
        }

    }

    // Extract bark info
    if (woodCompleteness.getBark() != null) {
        if (woodCompleteness.getBark().getPresence().toString().toLowerCase() != null) {
            if (woodCompleteness.getBark().getPresence().value() == "present") {
                p.add(new Chunk("- Bark is present ", bodyFont));
                // Last ring info
                if (woodCompleteness.getSapwood().getLastRingUnderBark() != null) {
                    p.add(new Chunk("and the last ring before the bark is noted as: \""
                            + woodCompleteness.getSapwood().getLastRingUnderBark().getContent().toString()
                            + "\"", bodyFont));
                } else {
                    p.add(new Chunk("but no details about the last ring under the bark were recorded.\n",
                            bodyFont));
                }
            } else if (woodCompleteness.getBark().getPresence().value() == "absent") {

                // Calculate if we have waney edge
                if (woodCompleteness.getSapwood().getPresence().equals(ComplexPresenceAbsence.COMPLETE)) {
                    p.add(new Chunk("- Waney edge present\n", bodyFont));
                } else {
                    p.add(new Chunk("- Bark is absent.\n", bodyFont));
                }
            } else {
                barkPresence = woodCompleteness.getBark().getPresence().value();
                p.add(new Chunk("- Bark is " + barkPresence + "\n", bodyFont));
            }
        } else {
            p.add(new Chunk("- Bark information was not recorded.\n", bodyFont));
        }
    }

    return p;
}