Class Paragraph

All Implemented Interfaces:
Element, TextElementArray, Serializable, Cloneable, Iterable<Element>, Collection<Element>, List<Element>, RandomAccess, SequencedCollection<Element>
Direct Known Subclasses:
ListItem

public class Paragraph extends Phrase
A Paragraph is a series of Chunks and/or Phrases.

A Paragraph has the same qualities of a Phrase, but also some additional layout-parameters:

  • the indentation
  • the alignment of the text

Example:

 Paragraph p = new Paragraph("This is a paragraph",
 FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC, new Color(0, 0, 255)));
 
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • alignment

      protected int alignment
      The alignment of the text.
    • runDirection

      protected int runDirection
      The base run direction of paragraph
    • multipliedLeading

      protected float multipliedLeading
      The text leading that is multiplied by the biggest font size in the line.
    • indentationLeft

      protected float indentationLeft
      The indentation of this paragraph on the left side.
    • indentationRight

      protected float indentationRight
      The indentation of this paragraph on the right side.
    • spacingBefore

      protected float spacingBefore
      The spacing before the paragraph.
    • spacingAfter

      protected float spacingAfter
      The spacing after the paragraph.
    • keeptogether

      protected boolean keeptogether
      Does the paragraph has to be kept together on 1 page.
    • firstLineIndent

      private float firstLineIndent
      Holds value of property firstLineIndent.
    • extraParagraphSpace

      private float extraParagraphSpace
      Holds value of property extraParagraphSpace.
  • Constructor Details

    • Paragraph

      public Paragraph()
      Constructs a Paragraph.
    • Paragraph

      public Paragraph(float leading)
      Constructs a Paragraph with a certain leading.
      Parameters:
      leading - the leading
    • Paragraph

      public Paragraph(Chunk chunk)
      Constructs a Paragraph with a certain Chunk.
      Parameters:
      chunk - a Chunk
    • Paragraph

      public Paragraph(float leading, Chunk chunk)
      Constructs a Paragraph with a certain Chunk and a certain leading.
      Parameters:
      leading - the leading
      chunk - a Chunk
    • Paragraph

      public Paragraph(String string)
      Constructs a Paragraph with a certain String.
      Parameters:
      string - a String
    • Paragraph

      public Paragraph(String string, Font font)
      Constructs a Paragraph with a certain String and a certain Font.
      Parameters:
      string - a String
      font - a Font
    • Paragraph

      public Paragraph(float leading, String string)
      Constructs a Paragraph with a certain String and a certain leading.
      Parameters:
      leading - the leading
      string - a String
    • Paragraph

      public Paragraph(float leading, String string, Font font)
      Constructs a Paragraph with a certain leading, String and Font.
      Parameters:
      leading - the leading
      string - a String
      font - a Font
    • Paragraph

      public Paragraph(Phrase phrase)
      Constructs a Paragraph with a certain Phrase.
      Parameters:
      phrase - a Phrase
  • Method Details

    • type

      public int type()
      Gets the type of the text element.
      Specified by:
      type in interface Element
      Overrides:
      type in class Phrase
      Returns:
      a type
    • add

      public boolean add(Element o)
      Adds an Object to the Paragraph.
      Specified by:
      add in interface Collection<Element>
      Specified by:
      add in interface List<Element>
      Specified by:
      add in interface TextElementArray
      Overrides:
      add in class Phrase
      Parameters:
      o - object the object to add.
      Returns:
      true is adding the object succeeded
    • setLeading

      public void setLeading(float fixedLeading)
      Description copied from class: Phrase
      Sets the leading of this phrase.
      Overrides:
      setLeading in class Phrase
      Parameters:
      fixedLeading - the new leading
      See Also:
    • setLeading

      public void setLeading(float fixedLeading, float multipliedLeading)
      Sets the leading fixed and variable. The resultant leading will be fixedLeading+multipliedLeading*maxFontSize where maxFontSize is the size of the biggest font in the line.
      Parameters:
      fixedLeading - the fixed leading
      multipliedLeading - the variable leading
    • getKeepTogether

      public boolean getKeepTogether()
      Checks if this paragraph has to be kept together on one page.
      Returns:
      true if the paragraph may not be split over 2 pages.
    • setKeepTogether

      public void setKeepTogether(boolean keeptogether)
      Indicates that the paragraph has to be kept together on one page.
      Parameters:
      keeptogether - true of the paragraph may not be split over 2 pages
    • getAlignment

      public int getAlignment()
      Gets the alignment of this paragraph.
      Returns:
      alignment
    • setAlignment

      public void setAlignment(int alignment)
      Sets the alignment of this paragraph.
      Parameters:
      alignment - the new alignment
    • setAlignment

      public void setAlignment(String alignment)
      Sets the alignment of this paragraph.
      Parameters:
      alignment - the new alignment as a String
    • getMultipliedLeading

      public float getMultipliedLeading()
      Gets the variable leading
      Returns:
      the leading
    • setMultipliedLeading

      public void setMultipliedLeading(float multipliedLeading)
      Sets the variable leading. The resultant leading will be multipliedLeading*maxFontSize where maxFontSize is the size of the biggest font in the line.
      Parameters:
      multipliedLeading - the variable leading
    • getTotalLeading

      public float getTotalLeading()
      Gets the total leading. This method is based on the assumption that the font of the Paragraph is the font of all the elements that make part of the paragraph. This isn't necessarily true.
      Returns:
      the total leading (fixed and multiplied)
    • getIndentationLeft

      public float getIndentationLeft()
      Gets the indentation of this paragraph on the left side.
      Returns:
      the indentation
    • setIndentationLeft

      public void setIndentationLeft(float indentation)
      Sets the indentation of this paragraph on the left side.
      Parameters:
      indentation - the new indentation
    • getIndentationRight

      public float getIndentationRight()
      Gets the indentation of this paragraph on the right side.
      Returns:
      the indentation
    • setIndentationRight

      public void setIndentationRight(float indentation)
      Sets the indentation of this paragraph on the right side.
      Parameters:
      indentation - the new indentation
    • getFirstLineIndent

      public float getFirstLineIndent()
      Getter for property firstLineIndent.
      Returns:
      Value of property firstLineIndent.
    • setFirstLineIndent

      public void setFirstLineIndent(float firstLineIndent)
      Setter for property firstLineIndent.
      Parameters:
      firstLineIndent - New value of property firstLineIndent.
    • getSpacingBefore

      public float getSpacingBefore()
      Gets the spacing before this paragraph.
      Returns:
      the spacing
      Since:
      2.1.5
    • setSpacingBefore

      public void setSpacingBefore(float spacing)
      Sets the spacing before this paragraph.
      Parameters:
      spacing - the new spacing
    • getSpacingAfter

      public float getSpacingAfter()
      Gets the spacing after this paragraph.
      Returns:
      the spacing
      Since:
      2.1.5
    • setSpacingAfter

      public void setSpacingAfter(float spacing)
      Sets the spacing after this paragraph.
      Parameters:
      spacing - the new spacing
    • getExtraParagraphSpace

      public float getExtraParagraphSpace()
      Getter for property extraParagraphSpace.
      Returns:
      Value of property extraParagraphSpace.
    • setExtraParagraphSpace

      public void setExtraParagraphSpace(float extraParagraphSpace)
      Setter for property extraParagraphSpace.
      Parameters:
      extraParagraphSpace - New value of property extraParagraphSpace.
    • getRunDirection

      public int getRunDirection()
    • setRunDirection

      public void setRunDirection(int runDirection)