TextState

Inheritance: java.lang.Object

public class TextState

Represents a text state of a text

Constructors

ConstructorDescription
TextState()Creates text state object.
TextState(double fontSize)Creates text state object with font size specification.
TextState(Color foregroundColor)Creates text state object with foreground color specification.
TextState(Color foregroundColor, double fontSize)Creates text state object with foreground color and font size specification.
TextState(String fontFamily)Creates text state object with font family specification.
TextState(String fontFamily, boolean bold, boolean italic)Creates text state object with font family and font style specification.
TextState(String fontFamily, double fontSize)Creates text state object with font family and font size specification.

Fields

FieldDescription
TabTagYou can place this tag in text to declare tabulation.
TabstopDefaultValueDefault value of tabulation in widths of space character of default font.

Methods

MethodDescription
applyChangesFrom(TextState textState)Applies settings from another textState
getCharacterSpacing()Gets character spacing of the text.
setCharacterSpacing(float value)Sets character spacing of the text.
getLineSpacing()Gets line spacing of the text.
setLineSpacing(float value)Sets line spacing of the text.
getHorizontalScaling()Gets horizontal scaling of the text.
setHorizontalScaling(float value)Sets horizontal scaling of the text.
isSubscript()Gets or sets subscript of the text.
setSubscript(boolean value)Gets or sets subscript of the text.
isSuperscript()Gets superscript of the text.
setSuperscript(boolean value)Sets superscript of the text.
getWordSpacing()Gets word spacing of the text.
setWordSpacing(float value)Sets word spacing of the text.
isInvisible()Gets the invisibility of text.
setInvisible(boolean value)Sets the invisibility of text.
getRenderingMode()Gets or sets rendering mode of text.
setRenderingMode(int value)Gets or sets rendering mode of text.
getFontSize()Gets font size of the text.
setFontSizeSuppressedUpdate(float value)Sets font size of the text wish suppressed update.
setFontSize(float value)Sets font size of the text.
getTextHeight()Gets text height.
getFont()Gets font of the text.
setFontSuppressedUpdate(Font value)Gets font of the text wish suppressed update.
setFont(Font value)Gets font of the text.
getForegroundColor()Gets foreground color of the text.
setForegroundColor(Color value)Sets foreground color of the text.
getStrokingColor()Gets or sets foreground color of the text.
setStrokingColor(Color value)Gets or sets foreground color of the text.
isUnderline()Gets underline for the text, represented by the TextFragment object
setUnderline(boolean value)Sets underline for the text, represented by the TextFragment object
getStrikeOut()Gets strikeout for the text, represented by the TextFragment object
setStrikeOut(boolean value)Sets strikeout for the text, represented by the TextFragment object
getBackgroundColor()Gets background color of the text.
setBackgroundColor(Color value)Sets background color of the text.
getFontStyle()Sets font style of the text.
setFontStyle(int value)Sets font style of the text.
getHorizontalAlignment()Gets horizontal alignment for the text.
setHorizontalAlignment(HorizontalAlignment value)Sets horizontal alignment for the text.
getCoordinateOrigin()Gets or sets text CoordinateOrigin.
setCoordinateOrigin(int value)Gets or sets text CoordinateOrigin.
measureString(String str, boolean insideLine)Measures the string.
measureString(String str)Measures the string.
measureHeight(char character)Measures character height.
calculateFontSize(String str, Rectangle rect)Calculates the font size for the rectangle.

TextState()

public TextState()

Creates text state object.

TextState(double fontSize)

public TextState(double fontSize)

Creates text state object with font size specification.

Parameters:

ParameterTypeDescription
fontSizedoubleFont size.

TextState(Color foregroundColor)

public TextState(Color foregroundColor)

Creates text state object with foreground color specification.

Parameters:

ParameterTypeDescription
foregroundColorjava.awt.ColorForeground color.

TextState(Color foregroundColor, double fontSize)

public TextState(Color foregroundColor, double fontSize)

Creates text state object with foreground color and font size specification.

Parameters:

ParameterTypeDescription
foregroundColorjava.awt.ColorForeground color.
fontSizedoubleFont size.

TextState(String fontFamily)

public TextState(String fontFamily)

Creates text state object with font family specification.

Parameters:

ParameterTypeDescription
fontFamilyjava.lang.StringFont family.

TextState(String fontFamily, boolean bold, boolean italic)

public TextState(String fontFamily, boolean bold, boolean italic)

Creates text state object with font family and font style specification.

Parameters:

ParameterTypeDescription
fontFamilyjava.lang.StringFont family.
boldbooleanBold font style.
italicbooleanItalic font style.

TextState(String fontFamily, double fontSize)

public TextState(String fontFamily, double fontSize)

Creates text state object with font family and font size specification.

Parameters:

ParameterTypeDescription
fontFamilyjava.lang.StringFont family.
fontSizedoubleFont size.

TabTag

public static final String TabTag

You can place this tag in text to declare tabulation.


It has effect only in couple with TabStops .

TabstopDefaultValue

public final float TabstopDefaultValue

Default value of tabulation in widths of space character of default font.

applyChangesFrom(TextState textState)

public void applyChangesFrom(TextState textState)

Applies settings from another textState


Only those properties will be copied that were changed explicitly.

Parameters:

ParameterTypeDescription
textStateTextStateText state object.

getCharacterSpacing()

public float getCharacterSpacing()

Gets character spacing of the text.

Returns: float - float value

setCharacterSpacing(float value)

public void setCharacterSpacing(float value)

Sets character spacing of the text.

Parameters:

ParameterTypeDescription
valuefloatfloat value

getLineSpacing()

public float getLineSpacing()

Gets line spacing of the text.

Returns: float - float value


Note that the value is not preserved as a text characteristic within the document. The LineSpacing property getter works for an object in case it was explicitly set previously with LineSpacing setter for those object. The property is used by runtime in context of current generation/modification process.

setLineSpacing(float value)

public void setLineSpacing(float value)

Sets line spacing of the text.

Parameters:

ParameterTypeDescription
valuefloatfloat value

Note that the value is not preserved as a text characteristic within the document. The LineSpacing property getter works for an object in case it was explicitly set previously with LineSpacing setter for those object. The property is used by runtime in context of current generation/modification process. |

getHorizontalScaling()

public float getHorizontalScaling()

Gets horizontal scaling of the text.

Returns: float - float value

setHorizontalScaling(float value)

public void setHorizontalScaling(float value)

Sets horizontal scaling of the text.

Parameters:

ParameterTypeDescription
valuefloatfloat value

isSubscript()

public boolean isSubscript()

Gets or sets subscript of the text.

Returns: boolean - boolean value

setSubscript(boolean value)

public void setSubscript(boolean value)

Gets or sets subscript of the text.

Parameters:

ParameterTypeDescription
valuebooleanboolean value

isSuperscript()

public boolean isSuperscript()

Gets superscript of the text.

Returns: boolean - boolean value

setSuperscript(boolean value)

public void setSuperscript(boolean value)

Sets superscript of the text.

Parameters:

ParameterTypeDescription
valuebooleanboolean value

getWordSpacing()

public float getWordSpacing()

Gets word spacing of the text.

Returns: float - float value

setWordSpacing(float value)

public void setWordSpacing(float value)

Sets word spacing of the text.

Parameters:

ParameterTypeDescription
valuefloatfloat value

isInvisible()

public boolean isInvisible()

Gets the invisibility of text. This basically reflects the RenderingMode (#getRenderingMode#getRenderingMode/#setRenderingMode(int)#setRenderingMode(int)) state, except for some special cases (like clipping).

Returns: boolean - boolean value

setInvisible(boolean value)

public void setInvisible(boolean value)

Sets the invisibility of text. This basically reflects the RenderingMode (#getRenderingMode#getRenderingMode/#setRenderingMode(int)#setRenderingMode(int)) state, except for some special cases (like clipping).

Parameters:

ParameterTypeDescription
valuebooleanboolean value

getRenderingMode()

public int getRenderingMode()

Gets or sets rendering mode of text.

Returns: int - TextRenderingMode element

setRenderingMode(int value)

public void setRenderingMode(int value)

Gets or sets rendering mode of text.

Parameters:

ParameterTypeDescription
valueintTextRenderingMode element

getFontSize()

public float getFontSize()

Gets font size of the text.

Returns: float - float value

setFontSizeSuppressedUpdate(float value)

public void setFontSizeSuppressedUpdate(float value)

Sets font size of the text wish suppressed update.

Parameters:

ParameterTypeDescription
valuefloatfloat value

setFontSize(float value)

public void setFontSize(float value)

Sets font size of the text.

Parameters:

ParameterTypeDescription
valuefloatfloat value

getTextHeight()

public float getTextHeight()

Gets text height.

Returns: float - float value

getFont()

public Font getFont()

Gets font of the text.

Returns: Font - Font object

setFontSuppressedUpdate(Font value)

public void setFontSuppressedUpdate(Font value)

Gets font of the text wish suppressed update.

Parameters:

ParameterTypeDescription
valueFontFont object

setFont(Font value)

public void setFont(Font value)

Gets font of the text.

Parameters:

ParameterTypeDescription
valueFontFont object

getForegroundColor()

public Color getForegroundColor()

Gets foreground color of the text.

Returns: Color - Color value

setForegroundColor(Color value)

public void setForegroundColor(Color value)

Sets foreground color of the text.

Parameters:

ParameterTypeDescription
valueColorColor value

getStrokingColor()

public Color getStrokingColor()

Gets or sets foreground color of the text.

Returns: Color - Color instance

setStrokingColor(Color value)

public void setStrokingColor(Color value)

Gets or sets foreground color of the text.

Parameters:

ParameterTypeDescription
valueColorColor instance

isUnderline()

public boolean isUnderline()

Gets underline for the text, represented by the TextFragment object

Returns: boolean - boolean value

setUnderline(boolean value)

public void setUnderline(boolean value)

Sets underline for the text, represented by the TextFragment object

Parameters:

ParameterTypeDescription
valuebooleanboolean value

getStrikeOut()

public boolean getStrikeOut()

Gets strikeout for the text, represented by the TextFragment object

Returns: boolean - boolean value

setStrikeOut(boolean value)

public void setStrikeOut(boolean value)

Sets strikeout for the text, represented by the TextFragment object

Parameters:

ParameterTypeDescription
valuebooleanboolean value

getBackgroundColor()

public Color getBackgroundColor()

Gets background color of the text.


Note that the value is not preserved as a text characteristic within the document. The BackgroundColor property getter works for an object in case it was explicitly set previously with BackgroundColor setter for those object. The property is used by runtime in context of current generation/modification process.

Returns: Color - Color value

setBackgroundColor(Color value)

public void setBackgroundColor(Color value)

Sets background color of the text.


Note that the value is not preserved as a text characteristic within the document. The BackgroundColor property getter works for an object in case it was explicitly set previously with BackgroundColor setter for those object. The property is used by runtime in context of current generation/modification process.

Parameters:

ParameterTypeDescription
valueColorColor value

getFontStyle()

public int getFontStyle()

Sets font style of the text.

Returns: int - FontStyles element

setFontStyle(int value)

public void setFontStyle(int value)

Sets font style of the text.

Parameters:

ParameterTypeDescription
valueintFontStyles value

getHorizontalAlignment()

public HorizontalAlignment getHorizontalAlignment()

Gets horizontal alignment for the text.


HorizontalAlignment.None is equal to HorizontalAlignment.Left. Note that TextState.HorizontalAlignment property works in new document generation scenarios only.

Returns: HorizontalAlignment - HorizontalAlignment value

setHorizontalAlignment(HorizontalAlignment value)

public void setHorizontalAlignment(HorizontalAlignment value)

Sets horizontal alignment for the text.


HorizontalAlignment.None is equal to HorizontalAlignment.Left. Note that TextState.HorizontalAlignment property works in new document generation scenarios only.

Parameters:

ParameterTypeDescription
valueHorizontalAlignmentHorizontalAlignment value

getCoordinateOrigin()

public int getCoordinateOrigin()

Gets or sets text CoordinateOrigin. If CoordinateOrigin is Descender, the text Y coordinate corresponds to the font’s lowest point. If CoordinateOrigin is BaseLine, the text Y coordinate corresponds to the font’s baseline. The default value is Descender. If the font’s Descent value is too big, text can be rendered higher than other fonts. In this case, CoordinateOrigin BaseLine can be selected for better text rendering.

Returns: int - CoordinateOrigin element

setCoordinateOrigin(int value)

public void setCoordinateOrigin(int value)

Gets or sets text CoordinateOrigin. If CoordinateOrigin is Descender, the text Y coordinate corresponds to the font’s lowest point. If CoordinateOrigin is BaseLine, the text Y coordinate corresponds to the font’s baseline. The default value is Descender. If the font’s Descent value is too big, text can be rendered higher than other fonts. In this case, CoordinateOrigin BaseLine can be selected for better text rendering.

Parameters:

ParameterTypeDescription
valueintCoordinateOrigin element

measureString(String str, boolean insideLine)

public double measureString(String str, boolean insideLine)

Measures the string.


insideLine indicate that the string is not ending. in case part of the whole string is measured - the insideLine should be true. in case the whole string is measured the insideLine should be false. in other words: in case insideLine = true only character widths are taken into account. no additional transformations are taken into account in case insideLine = false end of the string is handled properly - italic transformation is taken into account.

Parameters:

ParameterTypeDescription
strjava.lang.StringString value
insideLinebooleanboolean value

Returns: double - double value

measureString(String str)

public double measureString(String str)

Measures the string.

Parameters:

ParameterTypeDescription
strjava.lang.StringThe string.

Returns: double - Width of the string represented with this text state.

measureHeight(char character)

public double measureHeight(char character)

Measures character height.

Parameters:

ParameterTypeDescription
charactercharCharacter to measure.

Returns: double - Height of the character if we could get it from font; otherwise 0.

calculateFontSize(String str, Rectangle rect)

public double calculateFontSize(String str, Rectangle rect)

Calculates the font size for the rectangle.

Parameters:

ParameterTypeDescription
strjava.lang.StringString value
rectRectangleRectangle object

Returns: double - double value