Class LayoutInfo
java.lang.Object
javafx.scene.text.LayoutInfo
Holds a snapshot of the text layout geometry in a
Text
or a TextFlow
node,
such as break up of the text into lines, as well as other shapes derived from the layout
(selection, underline, etc.).
The information in this object is valid until the next layout cycle.
- Since:
- 25
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract CaretInfo
caretInfoAt
(int charIndex, boolean leading) Returns the information related to the caret at the specified character index and the character bias.abstract Rectangle2D
getLogicalBounds
(boolean includeLineSpacing) Returns the logical bounds of the layout.abstract List
<Rectangle2D> getSelectionGeometry
(int start, int end, boolean includeLineSpacing) Returns the geometry of the text selection, as an immutable list ofRectangle2D
objects, for the given start and end offsets.abstract List
<Rectangle2D> getStrikeThroughGeometry
(int start, int end) Returns the geometry of the strike-through shape, as an immutable list ofRectangle2D
objects, for the given start and end offsets.abstract TextLineInfo
getTextLine
(int index, boolean includeLineSpacing) Returns theTextLineInfo
object which contains information about the text line at indexindex
.abstract int
Returns the number of text lines in the layout.abstract List
<TextLineInfo> getTextLines
(boolean includeLineSpacing) Returns the immutable list of text lines in the layout.abstract List
<Rectangle2D> getUnderlineGeometry
(int start, int end) Returns the geometry of the underline shape, as an immutable list ofRectangle2D
objects, for the given start and end offsets.
-
Constructor Details
-
LayoutInfo
protected LayoutInfo()Constructor for subclasses to call.
-
-
Method Details
-
getLogicalBounds
Returns the logical bounds of the layout. Depending onincludeLineSpacing
, the return value may include the line spacing after the last line of text.- Parameters:
includeLineSpacing
- determines whether the line spacing after last text line should be included- Returns:
- the layout bounds
-
getTextLineCount
public abstract int getTextLineCount()Returns the number of text lines in the layout.- Returns:
- the number of text lines
-
getTextLines
Returns the immutable list of text lines in the layout.- Parameters:
includeLineSpacing
- determines whether the result includes the line spacing- Returns:
- the immutable list of
TextLineInfo
objects
-
getTextLine
Returns theTextLineInfo
object which contains information about the text line at indexindex
.- Parameters:
index
- the line indexincludeLineSpacing
- determines whether the result includes the line spacing- Returns:
- the
TextLineInfo
object - Throws:
IndexOutOfBoundsException
- if the index is out of range(index < 0 || index >= getTextLineCount())
-
getSelectionGeometry
public abstract List<Rectangle2D> getSelectionGeometry(int start, int end, boolean includeLineSpacing) Returns the geometry of the text selection, as an immutable list ofRectangle2D
objects, for the given start and end offsets.- Parameters:
start
- the start offsetend
- the end offsetincludeLineSpacing
- determines whether the result includes the line spacing- Returns:
- the immutable list of
Rectangle2D
objects
-
getStrikeThroughGeometry
Returns the geometry of the strike-through shape, as an immutable list ofRectangle2D
objects, for the given start and end offsets.- Parameters:
start
- the start offsetend
- the end offset- Returns:
- the immutable list of
Rectangle2D
objects
-
getUnderlineGeometry
Returns the geometry of the underline shape, as an immutable list ofRectangle2D
objects, for the given start and end offsets.- Parameters:
start
- the start offsetend
- the end offset- Returns:
- the immutable list of
Rectangle2D
objects
-
caretInfoAt
Returns the information related to the caret at the specified character index and the character bias.- Parameters:
charIndex
- the character indexleading
- whether the caret is biased on the leading edge of the character- Returns:
- the
CaretInfo
object
-