TextState
Inheritance: java.lang.Object
public class TextState
Represents a text state of a text
Constructors
Constructor | Description |
---|---|
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
Field | Description |
---|---|
TabTag | You can place this tag in text to declare tabulation. |
TabstopDefaultValue | Default value of tabulation in widths of space character of default font. |
Methods
Method | Description |
---|---|
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:
Parameter | Type | Description |
---|---|---|
fontSize | double | Font size. |
TextState(Color foregroundColor)
public TextState(Color foregroundColor)
Creates text state object with foreground color specification.
Parameters:
Parameter | Type | Description |
---|---|---|
foregroundColor | java.awt.Color | Foreground color. |
TextState(Color foregroundColor, double fontSize)
public TextState(Color foregroundColor, double fontSize)
Creates text state object with foreground color and font size specification.
Parameters:
Parameter | Type | Description |
---|---|---|
foregroundColor | java.awt.Color | Foreground color. |
fontSize | double | Font size. |
TextState(String fontFamily)
public TextState(String fontFamily)
Creates text state object with font family specification.
Parameters:
Parameter | Type | Description |
---|---|---|
fontFamily | java.lang.String | Font 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:
Parameter | Type | Description |
---|---|---|
fontFamily | java.lang.String | Font family. |
bold | boolean | Bold font style. |
italic | boolean | Italic 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:
Parameter | Type | Description |
---|---|---|
fontFamily | java.lang.String | Font family. |
fontSize | double | Font 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:
Parameter | Type | Description |
---|---|---|
textState | TextState | Text 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:
Parameter | Type | Description |
---|---|---|
value | float | float 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:
Parameter | Type | Description |
---|---|---|
value | 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. |
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:
Parameter | Type | Description |
---|---|---|
value | float | float 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:
Parameter | Type | Description |
---|---|---|
value | boolean | boolean 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:
Parameter | Type | Description |
---|---|---|
value | boolean | boolean 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:
Parameter | Type | Description |
---|---|---|
value | float | float 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:
Parameter | Type | Description |
---|---|---|
value | boolean | boolean 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:
Parameter | Type | Description |
---|---|---|
value | int | TextRenderingMode 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:
Parameter | Type | Description |
---|---|---|
value | float | float value |
setFontSize(float value)
public void setFontSize(float value)
Sets font size of the text.
Parameters:
Parameter | Type | Description |
---|---|---|
value | float | float 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:
Parameter | Type | Description |
---|---|---|
value | Font | Font object |
setFont(Font value)
public void setFont(Font value)
Gets font of the text.
Parameters:
Parameter | Type | Description |
---|---|---|
value | Font | Font 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:
Parameter | Type | Description |
---|---|---|
value | Color | Color 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:
Parameter | Type | Description |
---|---|---|
value | Color | Color 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:
Parameter | Type | Description |
---|---|---|
value | boolean | boolean 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:
Parameter | Type | Description |
---|---|---|
value | boolean | boolean 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:
Parameter | Type | Description |
---|---|---|
value | Color | Color 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:
Parameter | Type | Description |
---|---|---|
value | int | FontStyles 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:
Parameter | Type | Description |
---|---|---|
value | HorizontalAlignment | HorizontalAlignment 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:
Parameter | Type | Description |
---|---|---|
value | int | CoordinateOrigin 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:
Parameter | Type | Description |
---|---|---|
str | java.lang.String | String value |
insideLine | boolean | boolean value |
Returns: double - double value
measureString(String str)
public double measureString(String str)
Measures the string.
Parameters:
Parameter | Type | Description |
---|---|---|
str | java.lang.String | The string. |
Returns: double - Width of the string represented with this text state.
measureHeight(char character)
public double measureHeight(char character)
Measures character height.
Parameters:
Parameter | Type | Description |
---|---|---|
character | char | Character 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:
Parameter | Type | Description |
---|---|---|
str | java.lang.String | String value |
rect | Rectangle | Rectangle object |
Returns: double - double value