APIdia Launch Partner
Top Inners Fields Methods
com.sun.javafx.scene.text

public Interface TextLayout

Known Direct Implementers
com.sun.javafx.text.PrismTextLayout
Imports
java.util.Objects, com.sun.javafx.geom.BaseBounds, .Shape

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
TextLayout.CaretGeometry

Encodes the caret geometry, which can be either a single vertical line, or two vertical lines (a "split" caret), represented by Single and Split classes respectively.

public static interface
TextLayout.GeometryCallback

Callback to be called for each rectangular shape

public static class

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int

Method Summary

Modifier and TypeMethod and Description
public BaseBounds

Returns:

the layout bounds
getBounds
()

Returns the (logical) bounds of the layout minX is always zero minY is the ascent of the first line (negative) width the width of the widest line height the sum of all lines height Note that this width is different the wrapping width!

public BaseBounds
getBounds(TextSpan filter, BaseBounds bounds)

public TextLayout.CaretGeometry

Returns:

the caret geometry
getCaretGeometry
(int
the character offset
offset
,
boolean
whether the caret is biased on the leading edge of the character
leading
)

Queries the caret geometry and associated information at the specified text position.

public TextLayout.Hit

Returns:

returns a Hit object containing character index, insertion index and position of cursor on the character.
getHitInfo
(float
x coordinate value.
x
,
float
y coordinate value.
y
)

Calculates character index and insertion index for the given coordinates and maps to Hit class.

public TextLine[]

Returns:

the text lines
getLines
()

Returns the lines of text layout.

public void
getRange(int
the start offset
start
,
int
the end offset
end
,
int
the type of the geometry
type
,
TextLayout.GeometryCallback
the callback to invoke for each rectangular shape
client
)

Queries the range geometry of the range of text within the text layout for one of the three possible types:

public GlyphList[]

Returns:

the runs
getRuns
()

Returns the GlyphList of text layout.

public Shape

Returns:

the shape
getShape
(int
the type of the shapes to include
type
,
TextSpan filter)

Returns the shape of the entire text layout relative to the baseline of the first line.

public BaseBounds

Returns:

the visual bounds
getVisualBounds
(int type)

Returns the visual bounds of the layout using glyph bounding box

public boolean

Returns:

returns true is the call modifies the layout internal state.
setAlignment
(int alignment)

Sets the alignment for the TextLayout.

public boolean

Returns:

returns true is the call modifies the layout internal state.
setBoundsType
(int type)

Sets the bounds type for the TextLayout.

public boolean

Returns:

returns true is the call modifies the layout internal state.
setContent
(TextSpan[] spans)

Sets the content for the TextLayout.

public boolean

Returns:

returns true is the call modifies the layout internal state.
setContent
(String string, Object font)

Sets the content for the TextLayout.

public boolean

Returns:

returns true is the call modifies the layout internal state.
setDirection
(int direction)

Sets the direction (bidi algorithm's) for the TextLayout.

public boolean

Returns:

returns true is the call modifies the layout internal state.
setLineSpacing
(float spacing)

Sets the line spacing for the TextLayout.

public boolean

Returns:

returns true if the call modifies the layout internal state
setTabAdvancePolicy
(int
the tab size
tabSize
,
TabAdvancePolicy
the tab advance policy, or null
policy
)

Sets the tab size and the tab advance policy for the TextLayout.

public boolean

Returns:

returns true is the call modifies the layout internal state.
setWrapWidth
(float wrapWidth)

Sets the wrap width for the TextLayout.

Field Detail

ALIGN_CENTERback to summary
public static final int ALIGN_CENTER
ALIGN_JUSTIFYback to summary
public static final int ALIGN_JUSTIFY
ALIGN_LEFTback to summary
public static final int ALIGN_LEFT
ALIGN_MASKback to summary
public static final int ALIGN_MASK
ALIGN_RIGHTback to summary
public static final int ALIGN_RIGHT
ANALYSIS_MASKback to summary
public static final int ANALYSIS_MASK
BOUNDS_CENTERback to summary
public static final int BOUNDS_CENTER
BOUNDS_MASKback to summary
public static final int BOUNDS_MASK
DEFAULT_TAB_SIZEback to summary
public static final int DEFAULT_TAB_SIZE
DIRECTION_DEFAULT_LTRback to summary
public static final int DIRECTION_DEFAULT_LTR
DIRECTION_DEFAULT_RTLback to summary
public static final int DIRECTION_DEFAULT_RTL
DIRECTION_LTRback to summary
public static final int DIRECTION_LTR
DIRECTION_MASKback to summary
public static final int DIRECTION_MASK
DIRECTION_RTLback to summary
public static final int DIRECTION_RTL
FLAGS_ANALYSIS_VALIDback to summary
public static final int FLAGS_ANALYSIS_VALID
FLAGS_CACHED_STRIKETHROUGHback to summary
public static final int FLAGS_CACHED_STRIKETHROUGH
FLAGS_CACHED_UNDERLINEback to summary
public static final int FLAGS_CACHED_UNDERLINE
FLAGS_HAS_BIDIback to summary
public static final int FLAGS_HAS_BIDI
FLAGS_HAS_CJKback to summary
public static final int FLAGS_HAS_CJK
FLAGS_HAS_COMPLEXback to summary
public static final int FLAGS_HAS_COMPLEX
FLAGS_HAS_EMBEDDEDback to summary
public static final int FLAGS_HAS_EMBEDDED
FLAGS_HAS_TABSback to summary
public static final int FLAGS_HAS_TABS
FLAGS_LASTback to summary
public static final int FLAGS_LAST
FLAGS_LINES_VALIDback to summary
public static final int FLAGS_LINES_VALID
FLAGS_RTL_BASEback to summary
public static final int FLAGS_RTL_BASE
FLAGS_WRAPPEDback to summary
public static final int FLAGS_WRAPPED
TYPE_BASELINEback to summary
public static final int TYPE_BASELINE
TYPE_BEARINGSback to summary
public static final int TYPE_BEARINGS
TYPE_STRIKETHROUGHback to summary
public static final int TYPE_STRIKETHROUGH
TYPE_TEXTback to summary
public static final int TYPE_TEXT
TYPE_TOPback to summary
public static final int TYPE_TOP
TYPE_UNDERLINEback to summary
public static final int TYPE_UNDERLINE

Method Detail

getBoundsback to summary
public BaseBounds getBounds()

Returns the (logical) bounds of the layout minX is always zero minY is the ascent of the first line (negative) width the width of the widest line height the sum of all lines height Note that this width is different the wrapping width!

Returns:BaseBounds

the layout bounds

getBoundsback to summary
public BaseBounds getBounds(TextSpan filter, BaseBounds bounds)
getCaretGeometryback to summary
public TextLayout.CaretGeometry getCaretGeometry(int offset, boolean leading)

Queries the caret geometry and associated information at the specified text position.

Parameters
offset:int

the character offset

leading:boolean

whether the caret is biased on the leading edge of the character

Returns:TextLayout.CaretGeometry

the caret geometry

getHitInfoback to summary
public TextLayout.Hit getHitInfo(float x, float y)

Calculates character index and insertion index for the given coordinates and maps to Hit class.

Parameters
x:float

x coordinate value.

y:float

y coordinate value.

Returns:TextLayout.Hit

returns a Hit object containing character index, insertion index and position of cursor on the character.

getLinesback to summary
public TextLine[] getLines()

Returns the lines of text layout.

Returns:TextLine[]

the text lines

getRangeback to summary
public void getRange(int start, int end, int type, TextLayout.GeometryCallback client)

Queries the range geometry of the range of text within the text layout for one of the three possible types:

Parameters
start:int

the start offset

end:int

the end offset

type:int

the type of the geometry

client:TextLayout.GeometryCallback

the callback to invoke for each rectangular shape

getRunsback to summary
public GlyphList[] getRuns()

Returns the GlyphList of text layout. The runs are returned order visually (rendering order), starting from the first line.

Returns:GlyphList[]

the runs

getShapeback to summary
public Shape getShape(int type, TextSpan filter)

Returns the shape of the entire text layout relative to the baseline of the first line.

Parameters
type:int

the type of the shapes to include

Returns:Shape

the shape

getVisualBoundsback to summary
public BaseBounds getVisualBounds(int type)

Returns the visual bounds of the layout using glyph bounding box

Returns:BaseBounds

the visual bounds

setAlignmentback to summary
public boolean setAlignment(int alignment)

Sets the alignment for the TextLayout.

Returns:boolean

returns true is the call modifies the layout internal state.

setBoundsTypeback to summary
public boolean setBoundsType(int type)

Sets the bounds type for the TextLayout.

Returns:boolean

returns true is the call modifies the layout internal state.

setContentback to summary
public boolean setContent(TextSpan[] spans)

Sets the content for the TextLayout. Supports multiple spans (rich text).

Returns:boolean

returns true is the call modifies the layout internal state.

setContentback to summary
public boolean setContent(String string, Object font)

Sets the content for the TextLayout. Shorthand for single span text (no rich text).

Returns:boolean

returns true is the call modifies the layout internal state.

setDirectionback to summary
public boolean setDirection(int direction)

Sets the direction (bidi algorithm's) for the TextLayout.

Returns:boolean

returns true is the call modifies the layout internal state.

setLineSpacingback to summary
public boolean setLineSpacing(float spacing)

Sets the line spacing for the TextLayout.

Returns:boolean

returns true is the call modifies the layout internal state.

setTabAdvancePolicyback to summary
public boolean setTabAdvancePolicy(int tabSize, TabAdvancePolicy policy)

Sets the tab size and the tab advance policy for the TextLayout. A non-null policy will override the fixed tab size.

Parameters
tabSize:int

the tab size

policy:TabAdvancePolicy

the tab advance policy, or null

Returns:boolean

returns true if the call modifies the layout internal state

setWrapWidthback to summary
public boolean setWrapWidth(float wrapWidth)

Sets the wrap width for the TextLayout.

Returns:boolean

returns true is the call modifies the layout internal state.

com.sun.javafx.scene.text back to summary

public sealed Interface TextLayout.CaretGeometry

permits Single, Split
Known Direct Implementers
com.sun.javafx.scene.text.TextLayout.CaretGeometry.Single, com.sun.javafx.scene.text.TextLayout.CaretGeometry.Split

Encodes the caret geometry, which can be either a single vertical line, or two vertical lines (a "split" caret), represented by Single and Split classes respectively.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static record
TextLayout.CaretGeometry.Single

Represents a single line from (x, y) to (x, y + height)

public static record
TextLayout.CaretGeometry.Split

Represents a split caret drawn as two lines, the first line from (x1, y) to (x1, y + height/2), the second line from (x2, y + height/2) to (x2, y + height).

com.sun.javafx.scene.text back to summary

public final Record TextLayout.CaretGeometry.Single

extends Record
implements CaretGeometry
Class Inheritance
All Implemented Interfaces
com.sun.javafx.scene.text.TextLayout.CaretGeometry
Record Components
x:float 
y:float 
height:float 

Represents a single line from (x, y) to (x, y + height)

Field Summary

Modifier and TypeField and Description
private final float
height

Record Component accessed by height().

private final float
x

Record Component accessed by x().

private final float
y

Record Component accessed by y().

Constructor Summary

AccessConstructor and Description
public
Single(float x, float y, float height)

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public float
height()

Record Component getter of height.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

public float
x()

Record Component getter of x.

public float
y()

Record Component getter of y.

Field Detail

heightback to summary
private final float height

Record Component accessed by height().

xback to summary
private final float x

Record Component accessed by x().

yback to summary
private final float y

Record Component accessed by y().

Constructor Detail

Singleback to summary
public Single(float x, float y, float height)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

heightback to summary
public float height()

Record Component getter of height.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

xback to summary
public float x()

Record Component getter of x.

yback to summary
public float y()

Record Component getter of y.

com.sun.javafx.scene.text back to summary

public final Record TextLayout.CaretGeometry.Split

extends Record
implements CaretGeometry
Class Inheritance
All Implemented Interfaces
com.sun.javafx.scene.text.TextLayout.CaretGeometry
Record Components
x1:float 
x2:float 
y:float 
height:float 

Represents a split caret drawn as two lines, the first line from (x1, y) to (x1, y + height/2), the second line from (x2, y + height/2) to (x2, y + height).

Field Summary

Modifier and TypeField and Description
private final float
height

Record Component accessed by height().

private final float
x1

Record Component accessed by x1().

private final float
x2

Record Component accessed by x2().

private final float
y

Record Component accessed by y().

Constructor Summary

AccessConstructor and Description
public
Split(float x1, float x2, float y, float height)

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public float
height()

Record Component getter of height.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

public float
x1()

Record Component getter of x1.

public float
x2()

Record Component getter of x2.

public float
y()

Record Component getter of y.

Field Detail

heightback to summary
private final float height

Record Component accessed by height().

x1back to summary
private final float x1

Record Component accessed by x1().

x2back to summary
private final float x2

Record Component accessed by x2().

yback to summary
private final float y

Record Component accessed by y().

Constructor Detail

Splitback to summary
public Split(float x1, float x2, float y, float height)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

heightback to summary
public float height()

Record Component getter of height.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

x1back to summary
public float x1()

Record Component getter of x1.

x2back to summary
public float x2()

Record Component getter of x2.

yback to summary
public float y()

Record Component getter of y.

com.sun.javafx.scene.text back to summary

public Interface TextLayout.GeometryCallback

Annotations
@FunctionalInterface

Callback to be called for each rectangular shape

Method Summary

Modifier and TypeMethod and Description
public void
addRectangle(float left, float top, float right, float bottom)

Method Detail

addRectangleback to summary
public void addRectangle(float left, float top, float right, float bottom)
com.sun.javafx.scene.text back to summary

public Class TextLayout.Hit

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv int
pack-priv boolean

Constructor Summary

AccessConstructor and Description
public
Hit(int charIndex, int insertionIndex, boolean leading)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int
public int
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

charIndexback to summary
pack-priv int charIndex
insertionIndexback to summary
pack-priv int insertionIndex
leadingback to summary
pack-priv boolean leading

Constructor Detail

Hitback to summary
public Hit(int charIndex, int insertionIndex, boolean leading)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
getCharIndexback to summary
public int getCharIndex()
getInsertionIndexback to summary
public int getInsertionIndex()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
isLeadingback to summary
public boolean isLeading()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override