Package com.lowagie.text
Class Paragraph
- All Implemented Interfaces:
Element
,TextElementArray
,Serializable
,Cloneable
,Iterable<Element>
,Collection<Element>
,List<Element>
,RandomAccess
,SequencedCollection<Element>
- Direct Known Subclasses:
ListItem
A
Paragraph
is a series of Chunk
s 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 Summary
FieldsModifier and TypeFieldDescriptionprotected int
The alignment of the text.private float
Holds value of property extraParagraphSpace.private float
Holds value of property firstLineIndent.protected float
The indentation of this paragraph on the left side.protected float
The indentation of this paragraph on the right side.protected boolean
Does the paragraph has to be kept together on 1 page.protected float
The text leading that is multiplied by the biggest font size in the line.protected int
The base run direction of paragraphprivate static final long
protected float
The spacing after the paragraph.protected float
The spacing before the paragraph.Fields inherited from class com.lowagie.text.Phrase
font, hyphenation, leading
Fields inherited from class java.util.AbstractList
modCount
Fields inherited from interface com.lowagie.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, FOOTNOTE, HEADER, IMGRAW, IMGTEMPLATE, JBIG2, JPEG, JPEG2000, KEYWORDS, LIST, LISTITEM, MARKED, MODIFICATIONDATE, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, ROW, SECTION, SUBJECT, TABLE, TITLE, YMARK
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs aParagraph
.Paragraph
(float leading) Constructs aParagraph
with a certain leading.Constructs aParagraph
with a certainChunk
and a certain leading.Constructs aParagraph
with a certainString
and a certain leading.Constructs aParagraph
with a certain leading,String
andFont
.Constructs aParagraph
with a certainChunk
.Constructs aParagraph
with a certainPhrase
.Constructs aParagraph
with a certainString
.Constructs aParagraph
with a certainString
and a certainFont
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds anObject
to theParagraph
.int
Gets the alignment of this paragraph.float
Getter for property extraParagraphSpace.float
Getter for property firstLineIndent.float
Gets the indentation of this paragraph on the left side.float
Gets the indentation of this paragraph on the right side.boolean
Checks if this paragraph has to be kept together on one page.float
Gets the variable leadingint
float
Gets the spacing after this paragraph.float
Gets the spacing before this paragraph.float
Gets the total leading.void
setAlignment
(int alignment) Sets the alignment of this paragraph.void
setAlignment
(String alignment) Sets the alignment of this paragraph.void
setExtraParagraphSpace
(float extraParagraphSpace) Setter for property extraParagraphSpace.void
setFirstLineIndent
(float firstLineIndent) Setter for property firstLineIndent.void
setIndentationLeft
(float indentation) Sets the indentation of this paragraph on the left side.void
setIndentationRight
(float indentation) Sets the indentation of this paragraph on the right side.void
setKeepTogether
(boolean keeptogether) Indicates that the paragraph has to be kept together on one page.void
setLeading
(float fixedLeading) Sets the leading of this phrase.void
setLeading
(float fixedLeading, float multipliedLeading) Sets the leading fixed and variable.void
setMultipliedLeading
(float multipliedLeading) Sets the variable leading.void
setRunDirection
(int runDirection) void
setSpacingAfter
(float spacing) Sets the spacing after this paragraph.void
setSpacingBefore
(float spacing) Sets the spacing before this paragraph.int
type()
Gets the type of the text element.Methods inherited from class com.lowagie.text.Phrase
add, add, addAll, addChunk, addSpecial, getChunks, getContent, getFont, getHyphenation, getInstance, getInstance, getInstance, getLeading, hasLeading, isContent, isEmpty, isNestable, process, setFont, setHyphenation
Methods inherited from class java.util.ArrayList
addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
Methods inherited from class java.util.AbstractCollection
containsAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
Methods inherited from interface java.util.List
containsAll, reversed
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
alignment
protected int alignmentThe alignment of the text. -
runDirection
protected int runDirectionThe base run direction of paragraph -
multipliedLeading
protected float multipliedLeadingThe text leading that is multiplied by the biggest font size in the line. -
indentationLeft
protected float indentationLeftThe indentation of this paragraph on the left side. -
indentationRight
protected float indentationRightThe indentation of this paragraph on the right side. -
spacingBefore
protected float spacingBeforeThe spacing before the paragraph. -
spacingAfter
protected float spacingAfterThe spacing after the paragraph. -
keeptogether
protected boolean keeptogetherDoes the paragraph has to be kept together on 1 page. -
firstLineIndent
private float firstLineIndentHolds value of property firstLineIndent. -
extraParagraphSpace
private float extraParagraphSpaceHolds value of property extraParagraphSpace.
-
-
Constructor Details
-
Paragraph
public Paragraph()Constructs aParagraph
. -
Paragraph
public Paragraph(float leading) Constructs aParagraph
with a certain leading.- Parameters:
leading
- the leading
-
Paragraph
Constructs aParagraph
with a certainChunk
.- Parameters:
chunk
- aChunk
-
Paragraph
Constructs aParagraph
with a certainChunk
and a certain leading.- Parameters:
leading
- the leadingchunk
- aChunk
-
Paragraph
Constructs aParagraph
with a certainString
.- Parameters:
string
- aString
-
Paragraph
Constructs aParagraph
with a certainString
and a certainFont
.- Parameters:
string
- aString
font
- aFont
-
Paragraph
Constructs aParagraph
with a certainString
and a certain leading.- Parameters:
leading
- the leadingstring
- aString
-
Paragraph
Constructs aParagraph
with a certain leading,String
andFont
.- Parameters:
leading
- the leadingstring
- aString
font
- aFont
-
Paragraph
Constructs aParagraph
with a certainPhrase
.- Parameters:
phrase
- aPhrase
-
-
Method Details
-
type
public int type()Gets the type of the text element. -
add
Adds anObject
to theParagraph
.- Specified by:
add
in interfaceCollection<Element>
- Specified by:
add
in interfaceList<Element>
- Specified by:
add
in interfaceTextElementArray
- Overrides:
add
in classPhrase
- 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 classPhrase
- 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 leadingmultipliedLeading
- 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
Sets the alignment of this paragraph.- Parameters:
alignment
- the new alignment as aString
-
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)
-