com.lowagie.text.rtf.style

Class RtfParagraphStyle

public class RtfParagraphStyle extends RtfFont

The RtfParagraphStyle stores all style/formatting attributes of a RtfParagraph. Additionally it also supports the style name system available in RTF. The RtfParagraphStyle is a Font and can thus be used as such. To use the stylesheet functionality it needs to be set as the font of a Paragraph. Otherwise it will work like a RtfFont. It also supports inheritance of styles.

Version: $Id: RtfParagraphStyle.java 3580 2008-08-06 15:52:00Z howard_s $

Author: Mark Hall (Mark.Hall@mail.room3b.eu) Thomas Bickel (tmb99@inode.at)

Field Summary
static byte[]ALIGN_CENTER
Constant for center alignment
static byte[]ALIGN_JUSTIFY
Constant for justified alignment
static byte[]ALIGN_LEFT
Constant for left alignment
static byte[]ALIGN_RIGHT
Constant for right alignment
intalignment
The alignment of the paragraph.
StringbasedOnName
The name of the RtfParagraphStyle this RtfParagraphStyle is based on.
RtfParagraphStylebaseStyle
The RtfParagraphStyle this RtfParagraphStyle is based on.
intfirstLineIndent
The indentation for the first line
static byte[]FIRST_LINE_INDENT
Constant for the first line indentation
intindentLeft
The left indentation of the paragraph.
intindentRight
The right indentation of the paragraph.
static byte[]INDENT_LEFT
Constant for left indentation
static byte[]INDENT_RIGHT
Constant for right indentation
booleankeepTogether
Whether this RtfParagraph must stay on one page.
booleankeepTogetherWithNext
Whether this RtfParagraph must stay on the same page as the next paragraph.
static byte[]KEEP_TOGETHER
Constant for keeping the paragraph together on one page
static byte[]KEEP_TOGETHER_WITH_NEXT
Constant for keeping the paragraph together with the next one on one page
intlineLeading
The line leading of the paragraph.
intmodified
Which properties have been modified when compared to the base style.
static intMODIFIED_ALIGNMENT
The alignment has been modified.
static intMODIFIED_FONT_COLOR
The font color has been modified.
static intMODIFIED_FONT_NAME
The font name has been modified.
static intMODIFIED_FONT_SIZE
The font style has been modified.
static intMODIFIED_FONT_STYLE
The font size has been modified.
static intMODIFIED_INDENT_LEFT
The left indentation has been modified.
static intMODIFIED_INDENT_RIGHT
The right indentation has been modified.
static intMODIFIED_KEEP_TOGETHER
The paragraph keep together setting has been modified.
static intMODIFIED_KEEP_TOGETHER_WITH_NEXT
The paragraph keep together with next setting has been modified.
static intMODIFIED_LINE_LEADING
The line leading has been modified.
static intMODIFIED_NONE
No modification has taken place when compared to the RtfParagraphStyle this RtfParagraphStyle is based on.
static intMODIFIED_SPACING_AFTER
The spacing after a paragraph has been modified.
static intMODIFIED_SPACING_BEFORE
The spacing before a paragraph has been modified.
intspacingAfter
The spacing after a paragraph.
intspacingBefore
The spacing before a paragraph.
StringstyleName
The name of this RtfParagraphStyle.
intstyleNumber
The number of this RtfParagraphStyle in the stylesheet list.
static byte[]SPACING_AFTER
Constant for the space after the paragraph.
static byte[]SPACING_BEFORE
Constant for the space before the paragraph.
static RtfParagraphStyleSTYLE_HEADING_1
The style for level 1 headings.
static RtfParagraphStyleSTYLE_HEADING_2
The style for level 2 headings.
static RtfParagraphStyleSTYLE_HEADING_3
The style for level 3 headings.
static RtfParagraphStyleSTYLE_NORMAL
The NORMAL/STANDARD style.
Constructor Summary
RtfParagraphStyle(String styleName, String fontName, int fontSize, int fontStyle, Color fontColor)
Constructs a new RtfParagraphStyle with the given attributes.
RtfParagraphStyle(String styleName, String basedOnName)
Constructs a new RtfParagraphStyle that is based on an existing RtfParagraphStyle.
RtfParagraphStyle(RtfDocument doc, RtfParagraphStyle style)
Constructs a RtfParagraphStyle from another RtfParagraphStyle.
Method Summary
booleanequals(Object o)
Tests whether two RtfParagraphStyles are equal.
intgetAlignment()
Gets the alignment of this RtfParagraphStyle.
StringgetBasedOnName()
Gets the name of the RtfParagraphStyle this RtfParagraphStyle is based on.
intgetFirstLineIndent()
Gets the first line indentation of this RtfParagraphStyle.
intgetIndentLeft()
Gets the left indentation of this RtfParagraphStyle.
intgetIndentRight()
Gets the right indentation of this RtfParagraphStyle.
booleangetKeepTogether()
Gets whether the lines in the paragraph should be kept together in this RtfParagraphStyle.
booleangetKeepTogetherWithNext()
Gets whether the paragraph should be kept together with the next in this RtfParagraphStyle.
intgetLineLeading()
Gets the line leading of this RtfParagraphStyle.
intgetSpacingAfter()
Gets the space after the paragraph of this RtfParagraphStyle.
intgetSpacingBefore()
Gets the space before the paragraph of this RtfParagraphStyle..
StringgetStyleName()
Gets the name of this RtfParagraphStyle.
intgetStyleNumber()
Gets the number of this RtfParagraphStyle in the stylesheet list.
voidhandleInheritance()
Handles the inheritance of paragraph style settings.
inthashCode()
Gets the hash code of this RtfParagraphStyle.
voidsetAlignment(int alignment)
Sets the alignment of this RtfParagraphStyle.
voidsetColor(Color color)
Sets the color of this RtfParagraphStyle.
voidsetFirstLineIndent(int firstLineIndent)
Sets the first line indentation of this RtfParagraphStyle.
voidsetFontName(String fontName)
Sets the font name of this RtfParagraphStyle.
voidsetIndentLeft(int indentLeft)
Sets the left indentation of this RtfParagraphStyle.
voidsetIndentRight(int indentRight)
Sets the right indentation of this RtfParagraphStyle.
voidsetKeepTogether(boolean keepTogether)
Sets whether the lines in the paragraph should be kept together in this RtfParagraphStyle.
voidsetKeepTogetherWithNext(boolean keepTogetherWithNext)
Sets whether the paragraph should be kept together with the next in this RtfParagraphStyle.
voidsetLineLeading(int lineLeading)
Sets the line leading of this RtfParagraphStyle.
voidsetSize(float fontSize)
Sets the font size of this RtfParagraphStyle.
voidsetSpacingAfter(int spacingAfter)
Sets the space after the paragraph of this RtfParagraphStyle.
voidsetSpacingBefore(int spacingBefore)
Sets the space before the paragraph of this RtfParagraphStyle.
voidsetStyle(int fontStyle)
Sets the font style of this RtfParagraphStyle.
protected voidsetStyleNumber(int styleNumber)
Sets the number of this RtfParagraphStyle in the stylesheet list.
voidwriteBegin(OutputStream result)
Writes the start information of this RtfParagraphStyle.
voidwriteContent(OutputStream out)
unused
voidwriteDefinition(OutputStream result)
Writes the definition of this RtfParagraphStyle for the stylesheet list.
voidwriteEnd(OutputStream result)
Unused
voidwriteParagraphSettings(OutputStream result)
Writes the settings of this RtfParagraphStyle.

Field Detail

ALIGN_CENTER

public static final byte[] ALIGN_CENTER
Constant for center alignment

ALIGN_JUSTIFY

public static final byte[] ALIGN_JUSTIFY
Constant for justified alignment

ALIGN_LEFT

public static final byte[] ALIGN_LEFT
Constant for left alignment

ALIGN_RIGHT

public static final byte[] ALIGN_RIGHT
Constant for right alignment

alignment

private int alignment
The alignment of the paragraph.

basedOnName

private String basedOnName
The name of the RtfParagraphStyle this RtfParagraphStyle is based on.

baseStyle

private RtfParagraphStyle baseStyle
The RtfParagraphStyle this RtfParagraphStyle is based on.

firstLineIndent

private int firstLineIndent
The indentation for the first line

FIRST_LINE_INDENT

public static final byte[] FIRST_LINE_INDENT
Constant for the first line indentation

indentLeft

private int indentLeft
The left indentation of the paragraph.

indentRight

private int indentRight
The right indentation of the paragraph.

INDENT_LEFT

public static final byte[] INDENT_LEFT
Constant for left indentation

INDENT_RIGHT

public static final byte[] INDENT_RIGHT
Constant for right indentation

keepTogether

private boolean keepTogether
Whether this RtfParagraph must stay on one page.

keepTogetherWithNext

private boolean keepTogetherWithNext
Whether this RtfParagraph must stay on the same page as the next paragraph.

KEEP_TOGETHER

public static final byte[] KEEP_TOGETHER
Constant for keeping the paragraph together on one page

KEEP_TOGETHER_WITH_NEXT

public static final byte[] KEEP_TOGETHER_WITH_NEXT
Constant for keeping the paragraph together with the next one on one page

lineLeading

private int lineLeading
The line leading of the paragraph.

modified

private int modified
Which properties have been modified when compared to the base style.

MODIFIED_ALIGNMENT

private static final int MODIFIED_ALIGNMENT
The alignment has been modified.

MODIFIED_FONT_COLOR

private static final int MODIFIED_FONT_COLOR
The font color has been modified.

MODIFIED_FONT_NAME

private static final int MODIFIED_FONT_NAME
The font name has been modified.

MODIFIED_FONT_SIZE

private static final int MODIFIED_FONT_SIZE
The font style has been modified.

MODIFIED_FONT_STYLE

private static final int MODIFIED_FONT_STYLE
The font size has been modified.

MODIFIED_INDENT_LEFT

private static final int MODIFIED_INDENT_LEFT
The left indentation has been modified.

MODIFIED_INDENT_RIGHT

private static final int MODIFIED_INDENT_RIGHT
The right indentation has been modified.

MODIFIED_KEEP_TOGETHER

private static final int MODIFIED_KEEP_TOGETHER
The paragraph keep together setting has been modified.

MODIFIED_KEEP_TOGETHER_WITH_NEXT

private static final int MODIFIED_KEEP_TOGETHER_WITH_NEXT
The paragraph keep together with next setting has been modified.

MODIFIED_LINE_LEADING

private static final int MODIFIED_LINE_LEADING
The line leading has been modified.

MODIFIED_NONE

private static final int MODIFIED_NONE
No modification has taken place when compared to the RtfParagraphStyle this RtfParagraphStyle is based on. These modification markers are used to determine what needs to be inherited and what not from the parent RtfParagraphStyle.

MODIFIED_SPACING_AFTER

private static final int MODIFIED_SPACING_AFTER
The spacing after a paragraph has been modified.

MODIFIED_SPACING_BEFORE

private static final int MODIFIED_SPACING_BEFORE
The spacing before a paragraph has been modified.

spacingAfter

private int spacingAfter
The spacing after a paragraph.

spacingBefore

private int spacingBefore
The spacing before a paragraph.

styleName

private String styleName
The name of this RtfParagraphStyle.

styleNumber

private int styleNumber
The number of this RtfParagraphStyle in the stylesheet list.

SPACING_AFTER

public static final byte[] SPACING_AFTER
Constant for the space after the paragraph.

SPACING_BEFORE

public static final byte[] SPACING_BEFORE
Constant for the space before the paragraph.

STYLE_HEADING_1

public static final RtfParagraphStyle STYLE_HEADING_1
The style for level 1 headings.

STYLE_HEADING_2

public static final RtfParagraphStyle STYLE_HEADING_2
The style for level 2 headings.

STYLE_HEADING_3

public static final RtfParagraphStyle STYLE_HEADING_3
The style for level 3 headings.

STYLE_NORMAL

public static final RtfParagraphStyle STYLE_NORMAL
The NORMAL/STANDARD style.

Constructor Detail

RtfParagraphStyle

public RtfParagraphStyle(String styleName, String fontName, int fontSize, int fontStyle, Color fontColor)
Constructs a new RtfParagraphStyle with the given attributes.

Parameters: styleName The name of this RtfParagraphStyle. fontName The name of the font to use for this RtfParagraphStyle. fontSize The size of the font to use for this RtfParagraphStyle. fontStyle The style of the font to use for this RtfParagraphStyle. fontColor The color of the font to use for this RtfParagraphStyle.

RtfParagraphStyle

public RtfParagraphStyle(String styleName, String basedOnName)
Constructs a new RtfParagraphStyle that is based on an existing RtfParagraphStyle.

Parameters: styleName The name of this RtfParagraphStyle. basedOnName The name of the RtfParagraphStyle this RtfParagraphStyle is based on.

RtfParagraphStyle

public RtfParagraphStyle(RtfDocument doc, RtfParagraphStyle style)
Constructs a RtfParagraphStyle from another RtfParagraphStyle. INTERNAL USE ONLY

Parameters: doc The RtfDocument this RtfParagraphStyle belongs to. style The RtfParagraphStyle to copy settings from.

Method Detail

equals

public boolean equals(Object o)
Tests whether two RtfParagraphStyles are equal. Equality is determined via the name.

getAlignment

public int getAlignment()
Gets the alignment of this RtfParagraphStyle.

Returns: The alignment of this RtfParagraphStyle.

getBasedOnName

public String getBasedOnName()
Gets the name of the RtfParagraphStyle this RtfParagraphStyle is based on.

Returns: The name of the base RtfParagraphStyle.

getFirstLineIndent

public int getFirstLineIndent()
Gets the first line indentation of this RtfParagraphStyle.

Returns: The first line indentation of this RtfParagraphStyle.

getIndentLeft

public int getIndentLeft()
Gets the left indentation of this RtfParagraphStyle.

Returns: The left indentation of this RtfParagraphStyle.

getIndentRight

public int getIndentRight()
Gets the right indentation of this RtfParagraphStyle.

Returns: The right indentation of this RtfParagraphStyle.

getKeepTogether

public boolean getKeepTogether()
Gets whether the lines in the paragraph should be kept together in this RtfParagraphStyle.

Returns: Whether the lines in the paragraph should be kept together.

getKeepTogetherWithNext

public boolean getKeepTogetherWithNext()
Gets whether the paragraph should be kept together with the next in this RtfParagraphStyle.

Returns: Whether the paragraph should be kept together with the next.

getLineLeading

public int getLineLeading()
Gets the line leading of this RtfParagraphStyle.

Returns: The line leading of this RtfParagraphStyle.

getSpacingAfter

public int getSpacingAfter()
Gets the space after the paragraph of this RtfParagraphStyle.

Returns: The space after the paragraph.

getSpacingBefore

public int getSpacingBefore()
Gets the space before the paragraph of this RtfParagraphStyle..

Returns: The space before the paragraph.

getStyleName

public String getStyleName()
Gets the name of this RtfParagraphStyle.

Returns: The name of this RtfParagraphStyle.

getStyleNumber

private int getStyleNumber()
Gets the number of this RtfParagraphStyle in the stylesheet list.

Returns: The number of this RtfParagraphStyle in the stylesheet list.

handleInheritance

public void handleInheritance()
Handles the inheritance of paragraph style settings. All settings that have not been modified will be inherited from the base RtfParagraphStyle. If this RtfParagraphStyle is not based on another one, then nothing happens.

hashCode

public int hashCode()
Gets the hash code of this RtfParagraphStyle.

setAlignment

public void setAlignment(int alignment)
Sets the alignment of this RtfParagraphStyle.

Parameters: alignment The alignment to use.

setColor

public void setColor(Color color)
Sets the color of this RtfParagraphStyle.

Parameters: color The Color to use.

setFirstLineIndent

public void setFirstLineIndent(int firstLineIndent)
Sets the first line indentation of this RtfParagraphStyle. It is relative to the left indentation.

Parameters: firstLineIndent The first line indentation to use.

setFontName

public void setFontName(String fontName)
Sets the font name of this RtfParagraphStyle.

Parameters: fontName The font name to use

setIndentLeft

public void setIndentLeft(int indentLeft)
Sets the left indentation of this RtfParagraphStyle.

Parameters: indentLeft The left indentation to use.

setIndentRight

public void setIndentRight(int indentRight)
Sets the right indentation of this RtfParagraphStyle.

Parameters: indentRight The right indentation to use.

setKeepTogether

public void setKeepTogether(boolean keepTogether)
Sets whether the lines in the paragraph should be kept together in this RtfParagraphStyle.

Parameters: keepTogether Whether the lines in the paragraph should be kept together.

setKeepTogetherWithNext

public void setKeepTogetherWithNext(boolean keepTogetherWithNext)
Sets whether the paragraph should be kept together with the next in this RtfParagraphStyle.

Parameters: keepTogetherWithNext Whether the paragraph should be kept together with the next.

setLineLeading

public void setLineLeading(int lineLeading)
Sets the line leading of this RtfParagraphStyle.

Parameters: lineLeading The line leading to use.

setSize

public void setSize(float fontSize)
Sets the font size of this RtfParagraphStyle.

Parameters: fontSize The font size to use.

setSpacingAfter

public void setSpacingAfter(int spacingAfter)
Sets the space after the paragraph of this RtfParagraphStyle.

Parameters: spacingAfter The space after to use.

setSpacingBefore

public void setSpacingBefore(int spacingBefore)
Sets the space before the paragraph of this RtfParagraphStyle.

Parameters: spacingBefore The space before to use.

setStyle

public void setStyle(int fontStyle)
Sets the font style of this RtfParagraphStyle.

Parameters: fontStyle The font style to use.

setStyleNumber

protected void setStyleNumber(int styleNumber)
Sets the number of this RtfParagraphStyle in the stylesheet list.

Parameters: styleNumber The number to use.

writeBegin

public void writeBegin(OutputStream result)
Writes the start information of this RtfParagraphStyle.

Parameters: result The OutputStream to write to.

Throws: IOException On i/o errors.

writeContent

public void writeContent(OutputStream out)
unused

writeDefinition

public void writeDefinition(OutputStream result)
Writes the definition of this RtfParagraphStyle for the stylesheet list.

writeEnd

public void writeEnd(OutputStream result)
Unused

Parameters: result The OutputStream that nothing is written to

Throws: IOException On i/o errors.

writeParagraphSettings

private void writeParagraphSettings(OutputStream result)
Writes the settings of this RtfParagraphStyle.

Parameters: result The OutputStream to write to.

Throws: IOException On i/o errors.