Package com.aowagie.text
Class Paragraph
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList
-
- com.aowagie.text.Phrase
-
- com.aowagie.text.Paragraph
-
- All Implemented Interfaces:
Element,TextElementArray,java.io.Serializable,java.lang.Cloneable,java.lang.Iterable,java.util.Collection,java.util.List,java.util.RandomAccess
- Direct Known Subclasses:
ListItem
public class Paragraph extends Phrase
AParagraphis a series ofChunks and/orPhrases.A
Paragraphhas the same qualities of aPhrase, but also some additional layout-parameters:- the indentation
- the alignment of the text
Paragraph p = new Paragraph("This is a paragraph", FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC, new Color(0, 0, 255)));- See Also:
Element,Phrase,ListItem, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private intalignmentThe alignment of the text.private floatextraParagraphSpaceHolds value of property extraParagraphSpace.private floatfirstLineIndentHolds value of property firstLineIndent.private floatindentationLeftThe indentation of this paragraph on the left side.private floatindentationRightThe indentation of this paragraph on the right side.private booleankeeptogetherDoes the paragraph has to be kept together on 1 page.private floatmultipliedLeadingThe text leading that is multiplied by the biggest font size in the line.private static longserialVersionUIDprivate floatspacingAfterThe spacing after the paragraph.private floatspacingBeforeThe spacing before the paragraph.-
Fields inherited from interface com.aowagie.text.Element
ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_JUSTIFIED, ALIGN_JUSTIFIED_ALL, ALIGN_LEFT, ALIGN_MIDDLE, ALIGN_RIGHT, ALIGN_TOP, ALIGN_UNDEFINED, ANCHOR, ANNOTATION, AUTHOR, CCITT_BLACKIS1, CCITT_ENCODEDBYTEALIGN, CCITT_ENDOFBLOCK, CCITT_ENDOFLINE, CCITTG3_1D, CCITTG3_2D, CCITTG4, CELL, CHAPTER, CHUNK, CREATIONDATE, CREATOR, HEADER, IMGRAW, IMGTEMPLATE, JBIG2, JPEG, JPEG2000, KEYWORDS, LIST, LISTITEM, MARKED, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, ROW, SECTION, SUBJECT, TABLE, TITLE, YMARK
-
-
Constructor Summary
Constructors Constructor Description Paragraph()Constructs aParagraph.Paragraph(float leading)Constructs aParagraphwith a certain leading.Paragraph(Chunk chunk)Constructs aParagraphwith a certainChunk.Paragraph(Phrase phrase)Constructs aParagraphwith a certainPhrase.Paragraph(java.lang.String string)Constructs aParagraphwith a certainString.Paragraph(java.lang.String string, Font font)Constructs aParagraphwith a certainStringand a certainFont.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanadd(java.lang.Object o)Adds anObjectto theParagraph.intgetAlignment()Gets the alignment of this paragraph.floatgetExtraParagraphSpace()Getter for property extraParagraphSpace.floatgetFirstLineIndent()Getter for property firstLineIndent.floatgetIndentationLeft()Gets the indentation of this paragraph on the left side.floatgetIndentationRight()Gets the indentation of this paragraph on the right side.booleangetKeepTogether()Checks if this paragraph has to be kept together on one page.floatgetMultipliedLeading()Gets the variable leadingfloatgetSpacingAfter()Gets the spacing after this paragraph.floatgetSpacingBefore()Gets the spacing before this paragraph.floatgetTotalLeading()Gets the total leading.voidsetAlignment(int alignment)Sets the alignment of this paragraph.voidsetAlignment(java.lang.String alignment)Sets the alignment of this paragraph.voidsetExtraParagraphSpace(float extraParagraphSpace)Setter for property extraParagraphSpace.voidsetFirstLineIndent(float firstLineIndent)Setter for property firstLineIndent.voidsetIndentationLeft(float indentation)Sets the indentation of this paragraph on the left side.voidsetIndentationRight(float indentation)Sets the indentation of this paragraph on the right side.voidsetKeepTogether(boolean keeptogether)Indicates that the paragraph has to be kept together on one page.voidsetLeading(float fixedLeading)Sets the leading of this phrase.private voidsetLeading(float fixedLeading, float multipliedLeading)Sets the leading fixed and variable.voidsetMultipliedLeading(float multipliedLeading)Sets the variable leading.voidsetSpacingAfter(float spacing)Sets the spacing after this paragraph.voidsetSpacingBefore(float spacing)Sets the spacing before this paragraph.private floatspacingAfter()Deprecated.As of iText 2.1.5, replaced bygetSpacingAfter(), scheduled for removal at 2.3.0private floatspacingBefore()Deprecated.As of iText 2.1.5, replaced bygetSpacingBefore(), scheduled for removal at 2.3.0inttype()Gets the type of the text element.-
Methods inherited from class com.aowagie.text.Phrase
add, addAll, addSpecial, getChunks, getContent, getFont, getHyphenation, getLeading, hasLeading, isContent, isEmpty, isNestable, process, setFont, setHyphenation
-
Methods inherited from class java.util.ArrayList
addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
alignment
private int alignment
The alignment of the text.
-
multipliedLeading
private float multipliedLeading
The text leading that is multiplied by the biggest font size in the line.
-
indentationLeft
private float indentationLeft
The indentation of this paragraph on the left side.
-
indentationRight
private float indentationRight
The indentation of this paragraph on the right side.
-
firstLineIndent
private float firstLineIndent
Holds value of property firstLineIndent.
-
spacingBefore
private float spacingBefore
The spacing before the paragraph.
-
spacingAfter
private float spacingAfter
The spacing after the paragraph.
-
extraParagraphSpace
private float extraParagraphSpace
Holds value of property extraParagraphSpace.
-
keeptogether
private boolean keeptogether
Does the paragraph has to be kept together on 1 page.
-
-
Constructor Detail
-
Paragraph
public Paragraph()
Constructs aParagraph.
-
Paragraph
Paragraph(float leading)
Constructs aParagraphwith a certain leading.- Parameters:
leading- the leading
-
Paragraph
public Paragraph(Chunk chunk)
Constructs aParagraphwith a certainChunk.- Parameters:
chunk- aChunk
-
Paragraph
public Paragraph(java.lang.String string)
Constructs aParagraphwith a certainString.- Parameters:
string- aString
-
Paragraph
public Paragraph(java.lang.String string, Font font)Constructs aParagraphwith a certainStringand a certainFont.- Parameters:
string- aStringfont- aFont
-
Paragraph
public Paragraph(Phrase phrase)
Constructs aParagraphwith a certainPhrase.- Parameters:
phrase- aPhrase
-
-
Method Detail
-
type
public int type()
Gets the type of the text element.
-
add
public boolean add(java.lang.Object o)
Adds anObjectto theParagraph.- Specified by:
addin interfacejava.util.Collection- Specified by:
addin interfacejava.util.List- Specified by:
addin interfaceTextElementArray- Overrides:
addin classPhrase- Parameters:
o- object the object to add.- Returns:
- true is adding the object succeeded
-
setAlignment
public void setAlignment(int alignment)
Sets the alignment of this paragraph.- Parameters:
alignment- the new alignment
-
setAlignment
public void setAlignment(java.lang.String alignment)
Sets the alignment of this paragraph.- Parameters:
alignment- the new alignment as aString
-
setLeading
public void setLeading(float fixedLeading)
Description copied from class:PhraseSets the leading of this phrase.- Overrides:
setLeadingin classPhrase- Parameters:
fixedLeading- the new leading- See Also:
Phrase.setLeading(float)
-
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
-
setLeading
private 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 leadingmultipliedLeading- the variable leading
-
setIndentationLeft
public void setIndentationLeft(float indentation)
Sets the indentation of this paragraph on the left side.- Parameters:
indentation- the new indentation
-
setIndentationRight
public void setIndentationRight(float indentation)
Sets the indentation of this paragraph on the right side.- Parameters:
indentation- the new indentation
-
setFirstLineIndent
public void setFirstLineIndent(float firstLineIndent)
Setter for property firstLineIndent.- Parameters:
firstLineIndent- New value of property firstLineIndent.
-
setSpacingBefore
public void setSpacingBefore(float spacing)
Sets the spacing before this paragraph.- Parameters:
spacing- the new spacing
-
setSpacingAfter
public void setSpacingAfter(float spacing)
Sets the spacing after this paragraph.- Parameters:
spacing- the new spacing
-
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
-
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.
-
getAlignment
public int getAlignment()
Gets the alignment of this paragraph.- Returns:
- alignment
-
getMultipliedLeading
public float getMultipliedLeading()
Gets the variable leading- Returns:
- the 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
-
getIndentationRight
public float getIndentationRight()
Gets the indentation of this paragraph on the right side.- Returns:
- the indentation
-
getFirstLineIndent
public float getFirstLineIndent()
Getter for property firstLineIndent.- Returns:
- Value of property firstLineIndent.
-
getSpacingBefore
public float getSpacingBefore()
Gets the spacing before this paragraph.- Returns:
- the spacing
- Since:
- 2.1.5
-
getSpacingAfter
public float getSpacingAfter()
Gets the spacing after this paragraph.- Returns:
- the spacing
- Since:
- 2.1.5
-
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.
-
spacingBefore
@Deprecated private float spacingBefore()
Deprecated.As of iText 2.1.5, replaced bygetSpacingBefore(), scheduled for removal at 2.3.0Gets the spacing before this paragraph.- Returns:
- the spacing
-
spacingAfter
@Deprecated private float spacingAfter()
Deprecated.As of iText 2.1.5, replaced bygetSpacingAfter(), scheduled for removal at 2.3.0Gets the spacing after this paragraph.- Returns:
- the spacing
-
-