Package com.lowagie.text.rtf.style
Class RtfParagraphStyle
- java.lang.Object
-
- com.lowagie.text.Font
-
- com.lowagie.text.rtf.style.RtfFont
-
- com.lowagie.text.rtf.style.RtfParagraphStyle
-
- All Implemented Interfaces:
RtfBasicElement,RtfExtendedElement,com.lowagie.text.RtfElementInterface,java.lang.Comparable
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
Fields Modifier and Type Field Description static byte[]ALIGN_CENTERConstant for center alignmentstatic byte[]ALIGN_JUSTIFYConstant for justified alignmentstatic byte[]ALIGN_LEFTConstant for left alignmentstatic byte[]ALIGN_RIGHTConstant for right alignmentstatic byte[]FIRST_LINE_INDENTConstant for the first line indentationstatic byte[]INDENT_LEFTConstant for left indentationstatic byte[]INDENT_RIGHTConstant for right indentationstatic byte[]KEEP_TOGETHERConstant for keeping the paragraph together on one pagestatic byte[]KEEP_TOGETHER_WITH_NEXTConstant for keeping the paragraph together with the next one on one pagestatic byte[]SPACING_AFTERConstant for the space after the paragraph.static byte[]SPACING_BEFOREConstant for the space before the paragraph.static RtfParagraphStyleSTYLE_HEADING_1The style for level 1 headings.static RtfParagraphStyleSTYLE_HEADING_2The style for level 2 headings.static RtfParagraphStyleSTYLE_HEADING_3The style for level 3 headings.static RtfParagraphStyleSTYLE_NORMALThe NORMAL/STANDARD style.-
Fields inherited from class com.lowagie.text.rtf.style.RtfFont
DEFAULT_FONT, document, FONT_SIZE, STYLE_BOLD, STYLE_DOUBLE_STRIKETHROUGH, STYLE_EMBOSSED, STYLE_ENGRAVED, STYLE_HIDDEN, STYLE_ITALIC, STYLE_NONE, STYLE_OUTLINE, STYLE_SHADOW, STYLE_STRIKETHROUGH, STYLE_UNDERLINE
-
Fields inherited from class com.lowagie.text.Font
BOLD, BOLDITALIC, COURIER, DEFAULTSIZE, HELVETICA, ITALIC, NORMAL, STRIKETHRU, SYMBOL, TIMES_ROMAN, UNDEFINED, UNDERLINE, ZAPFDINGBATS
-
Fields inherited from interface com.lowagie.text.rtf.RtfBasicElement
CLOSE_GROUP, COMMA_DELIMITER, DELIMITER, OPEN_GROUP, TWIPS_FACTOR
-
-
Constructor Summary
Constructors Constructor Description RtfParagraphStyle(RtfDocument doc, RtfParagraphStyle style)Constructs a RtfParagraphStyle from another RtfParagraphStyle.RtfParagraphStyle(java.lang.String styleName, java.lang.String basedOnName)Constructs a new RtfParagraphStyle that is based on an existing RtfParagraphStyle.RtfParagraphStyle(java.lang.String styleName, java.lang.String fontName, int fontSize, int fontStyle, java.awt.Color fontColor)Constructs a new RtfParagraphStyle with the given attributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)Tests whether two RtfParagraphStyles are equal.intgetAlignment()Gets the alignment of this RtfParagraphStyle.java.lang.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..java.lang.StringgetStyleName()Gets the name of this RtfParagraphStyle.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(java.awt.Color color)Sets the color of this RtfParagraphStyle.voidsetFirstLineIndent(int firstLineIndent)Sets the first line indentation of this RtfParagraphStyle.voidsetFontName(java.lang.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(java.io.OutputStream result)Writes the start information of this RtfParagraphStyle.voidwriteContent(java.io.OutputStream out)unusedvoidwriteDefinition(java.io.OutputStream result)Writes the definition of this RtfParagraphStyle for the stylesheet list.voidwriteEnd(java.io.OutputStream result)Unused-
Methods inherited from class com.lowagie.text.rtf.style.RtfFont
compareTo, difference, getCharset, getFamilyname, getFontName, getFontNumber, getFontSize, getFontStyle, intToByteArray, isStandardFont, setCharset, setColor, setFamily, setInHeader, setInTable, setRtfDocument, setStyle
-
Methods inherited from class com.lowagie.text.Font
getBaseFont, getBaseFontStyle, getCalculatedBaseFont, getCalculatedLeading, getCalculatedSize, getCalculatedStyle, getColor, getCombinedStyle, getFamily, getFamilyIndex, getFontStyleFromName, getSize, getStyle, getStyleValue, isBold, isItalic, isStrikethru, isUnderlined
-
-
-
-
Field Detail
-
ALIGN_LEFT
public static final byte[] ALIGN_LEFT
Constant for left alignment
-
ALIGN_RIGHT
public static final byte[] ALIGN_RIGHT
Constant for right alignment
-
ALIGN_CENTER
public static final byte[] ALIGN_CENTER
Constant for center alignment
-
ALIGN_JUSTIFY
public static final byte[] ALIGN_JUSTIFY
Constant for justified alignment
-
FIRST_LINE_INDENT
public static final byte[] FIRST_LINE_INDENT
Constant for the first line indentation
-
INDENT_LEFT
public static final byte[] INDENT_LEFT
Constant for left indentation
-
INDENT_RIGHT
public static final byte[] INDENT_RIGHT
Constant for right indentation
-
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
-
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_NORMAL
public static final RtfParagraphStyle STYLE_NORMAL
The NORMAL/STANDARD style.
-
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.
-
-
Constructor Detail
-
RtfParagraphStyle
public RtfParagraphStyle(java.lang.String styleName, java.lang.String fontName, int fontSize, int fontStyle, java.awt.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(java.lang.String styleName, java.lang.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
-
getStyleName
public java.lang.String getStyleName()
Gets the name of this RtfParagraphStyle.- Returns:
- The name of this RtfParagraphStyle.
-
getBasedOnName
public java.lang.String getBasedOnName()
Gets the name of the RtfParagraphStyle this RtfParagraphStyle is based on.- Returns:
- The name of the base RtfParagraphStyle.
-
getAlignment
public int getAlignment()
Gets the alignment of this RtfParagraphStyle.- Returns:
- The alignment of this RtfParagraphStyle.
-
setAlignment
public void setAlignment(int alignment)
Sets the alignment of this RtfParagraphStyle.- Parameters:
alignment- The alignment to use.
-
getFirstLineIndent
public int getFirstLineIndent()
Gets the first line indentation of this RtfParagraphStyle.- Returns:
- The first line indentation of this RtfParagraphStyle.
-
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.
-
getIndentLeft
public int getIndentLeft()
Gets the left indentation of this RtfParagraphStyle.- Returns:
- The left indentation of this RtfParagraphStyle.
-
setIndentLeft
public void setIndentLeft(int indentLeft)
Sets the left indentation of this RtfParagraphStyle.- Parameters:
indentLeft- The left indentation to use.
-
getIndentRight
public int getIndentRight()
Gets the right indentation of this RtfParagraphStyle.- Returns:
- The right indentation of this RtfParagraphStyle.
-
setIndentRight
public void setIndentRight(int indentRight)
Sets the right indentation of this RtfParagraphStyle.- Parameters:
indentRight- The right indentation to use.
-
getSpacingBefore
public int getSpacingBefore()
Gets the space before the paragraph of this RtfParagraphStyle..- Returns:
- The space before the paragraph.
-
setSpacingBefore
public void setSpacingBefore(int spacingBefore)
Sets the space before the paragraph of this RtfParagraphStyle.- Parameters:
spacingBefore- The space before to use.
-
getSpacingAfter
public int getSpacingAfter()
Gets the space after the paragraph of this RtfParagraphStyle.- Returns:
- The space after the paragraph.
-
setSpacingAfter
public void setSpacingAfter(int spacingAfter)
Sets the space after the paragraph of this RtfParagraphStyle.- Parameters:
spacingAfter- The space after to use.
-
setFontName
public void setFontName(java.lang.String fontName)
Sets the font name of this RtfParagraphStyle.- Overrides:
setFontNamein classRtfFont- Parameters:
fontName- The font name to use
-
setSize
public void setSize(float fontSize)
Sets the font size of this RtfParagraphStyle.
-
setStyle
public void setStyle(int fontStyle)
Sets the font style of this RtfParagraphStyle.
-
setColor
public void setColor(java.awt.Color color)
Sets the color of this RtfParagraphStyle.
-
getLineLeading
public int getLineLeading()
Gets the line leading of this RtfParagraphStyle.- Returns:
- The line leading of this RtfParagraphStyle.
-
setLineLeading
public void setLineLeading(int lineLeading)
Sets the line leading of this RtfParagraphStyle.- Parameters:
lineLeading- The line leading to use.
-
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.
-
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.
-
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.
-
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.
-
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.
-
writeDefinition
public void writeDefinition(java.io.OutputStream result) throws java.io.IOExceptionWrites the definition of this RtfParagraphStyle for the stylesheet list.- Specified by:
writeDefinitionin interfaceRtfExtendedElement- Overrides:
writeDefinitionin classRtfFont- Parameters:
result- TheOutputStreamto write the element definition to- Throws:
java.io.IOException
-
writeBegin
public void writeBegin(java.io.OutputStream result) throws java.io.IOExceptionWrites the start information of this RtfParagraphStyle.- Overrides:
writeBeginin classRtfFont- Parameters:
result- TheOutputStreamto write to.- Throws:
java.io.IOException- On i/o errors.
-
writeEnd
public void writeEnd(java.io.OutputStream result) throws java.io.IOExceptionUnused
-
writeContent
public void writeContent(java.io.OutputStream out) throws java.io.IOExceptionunused- Specified by:
writeContentin interfaceRtfBasicElement- Overrides:
writeContentin classRtfFont- Parameters:
out- TheOutputStreamto write the content to- Throws:
java.io.IOException
-
equals
public boolean equals(java.lang.Object o)
Tests whether two RtfParagraphStyles are equal. Equality is determined via the name.
-
hashCode
public int hashCode()
Gets the hash code of this RtfParagraphStyle.
-
setStyleNumber
protected void setStyleNumber(int styleNumber)
Sets the number of this RtfParagraphStyle in the stylesheet list.- Parameters:
styleNumber- The number to use.
-
-