com.lowagie.text

Class Paragraph

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:

Example:
 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

Field Summary
protected intalignment
The alignment of the text.
floatextraParagraphSpace
Holds value of property extraParagraphSpace.
floatfirstLineIndent
Holds value of property firstLineIndent.
protected floatindentationLeft
The indentation of this paragraph on the left side.
protected floatindentationRight
The indentation of this paragraph on the right side.
protected booleankeeptogether
Does the paragraph has to be kept together on 1 page.
protected floatmultipliedLeading
The text leading that is multiplied by the biggest font size in the line.
static longserialVersionUID
protected floatspacingAfter
The spacing after the paragraph.
protected floatspacingBefore
The spacing before the paragraph.
Constructor Summary
Paragraph()
Constructs a Paragraph.
Paragraph(float leading)
Constructs a Paragraph with a certain leading.
Paragraph(Chunk chunk)
Constructs a Paragraph with a certain Chunk.
Paragraph(float leading, Chunk chunk)
Constructs a Paragraph with a certain Chunk and a certain leading.
Paragraph(String string)
Constructs a Paragraph with a certain String.
Paragraph(String string, Font font)
Constructs a Paragraph with a certain String and a certain Font.
Paragraph(float leading, String string)
Constructs a Paragraph with a certain String and a certain leading.
Paragraph(float leading, String string, Font font)
Constructs a Paragraph with a certain leading, String and Font.
Paragraph(Phrase phrase)
Constructs a Paragraph with a certain Phrase.
Paragraph(Properties attributes)
Returns a Paragraph that has been constructed taking in account the value of some attributes.
Method Summary
booleanadd(Object o)
Adds an Object to the Paragraph.
intalignment()
Gets the alignment of this paragraph.
floatgetExtraParagraphSpace()
Getter for property extraParagraphSpace.
floatgetFirstLineIndent()
Getter for property firstLineIndent.
booleangetKeepTogether()
Checks if this paragraph has to be kept together on one page.
floatgetMultipliedLeading()
Gets the variable leading
floatgetTotalLeading()
Gets the total leading.
floatindentationLeft()
Gets the indentation of this paragraph on the left side.
floatindentationRight()
Gets the indentation of this paragraph on the right side.
static booleanisTag(String tag)
Checks if a given tag corresponds with this object.
voidsetAlignment(int alignment)
Sets the alignment of this paragraph.
voidsetAlignment(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, float multipliedLeading)
Sets the leading fixed and variable.
voidsetLeading(float fixedLeading)
voidsetSpacingAfter(float spacing)
Sets the spacing after this paragraph.
voidsetSpacingBefore(float spacing)
Sets the spacing before this paragraph.
floatspacingAfter()
Gets the spacing after this paragraph.
floatspacingBefore()
Gets the spacing before this paragraph.
inttype()
Gets the type of the text element.

Field Detail

alignment

protected int alignment
The alignment of the text.

extraParagraphSpace

private float extraParagraphSpace
Holds value of property extraParagraphSpace.

firstLineIndent

private float firstLineIndent
Holds value of property firstLineIndent.

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.

keeptogether

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

multipliedLeading

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

serialVersionUID

private static final long serialVersionUID

spacingAfter

protected float spacingAfter
The spacing after the paragraph.

spacingBefore

protected float spacingBefore
The spacing before the paragraph.

Constructor Detail

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

Paragraph

public Paragraph(Properties attributes)
Returns a Paragraph that has been constructed taking in account the value of some attributes.

Parameters: attributes Some attributes

Method Detail

add

public boolean add(Object o)
Adds an Object to the Paragraph.

Parameters: o object the object to add.

Returns: true is adding the object succeeded

alignment

public int alignment()
Gets the alignment of this paragraph.

Returns: alignment

getExtraParagraphSpace

public float getExtraParagraphSpace()
Getter for property extraParagraphSpace.

Returns: Value of property extraParagraphSpace.

getFirstLineIndent

public float getFirstLineIndent()
Getter for property firstLineIndent.

Returns: Value of property firstLineIndent.

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.

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)

indentationLeft

public float indentationLeft()
Gets the indentation of this paragraph on the left side.

Returns: the indentation

indentationRight

public float indentationRight()
Gets the indentation of this paragraph on the right side.

Returns: the indentation

isTag

public static boolean isTag(String tag)
Checks if a given tag corresponds with this object.

Parameters: tag the given tag

Returns: true if the tag corresponds

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

setExtraParagraphSpace

public void setExtraParagraphSpace(float extraParagraphSpace)
Setter for property extraParagraphSpace.

Parameters: extraParagraphSpace New value of property extraParagraphSpace.

setFirstLineIndent

public void setFirstLineIndent(float firstLineIndent)
Setter for property firstLineIndent.

Parameters: firstLineIndent New value of property firstLineIndent.

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

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

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 bigest font in the line.

Parameters: fixedLeading the fixed leading multipliedLeading the variable leading

setLeading

public void setLeading(float fixedLeading)

See Also: Phrase

setSpacingAfter

public void setSpacingAfter(float spacing)
Sets the spacing after this paragraph.

Parameters: spacing the new spacing

setSpacingBefore

public void setSpacingBefore(float spacing)
Sets the spacing before this paragraph.

Parameters: spacing the new spacing

spacingAfter

public float spacingAfter()
Gets the spacing after this paragraph.

Returns: the spacing

spacingBefore

public float spacingBefore()
Gets the spacing before this paragraph.

Returns: the spacing

type

public int type()
Gets the type of the text element.

Returns: a type