Contents
Class StyledSegment
java.lang.Object
jfx.incubator.scene.control.richtext.model.StyledSegment
Data structure used to modify the styled text model.
Each instance represents:
- a single text segment with direct style and/or style names
- a line break
- an inline Node
- a paragraph containing a single Region
- paragraph attributes
- Since:
- 24
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StyledSegment
A styled segment that represents a line break -
Method Summary
Modifier and TypeMethodDescriptionThis method must return a non-null value for a segment ofINLINE_NODE
type, or null in any other case.This method must return a non-null value for a segment ofREGION
type, or null in any other case.getStyleAttributeMap
(StyleResolver resolver) This method returns StyleAttributeMap (or null) for this segment.getText()
Returns the text associated with this segment.int
Returns the length of text in the segment, or 0 for segments that contain no text or wheregetText()
returns null.abstract StyledSegment.Type
getType()
Returns the type of this StyledSegment.static StyledSegment
Creates a StyleSegment from a non-null plain text.static StyledSegment
of
(String text, StyleAttributeMap attrs) Creates a StyleSegment from a non-null plain text and style attributes.static StyledSegment
ofInlineNode
(Supplier<Node> generator) Creates a StyledSegment which consists of a single inline Node.static StyledSegment
Creates a StyledSegment which contains paragraph attributes only.static StyledSegment
Creates a StyledSegment for a paragraph that contains a single Region.abstract StyledSegment
subSegment
(int start, int end) Creates a sub-segment of this segment.
-
Field Details
-
Method Details
-
getType
Returns the type of this StyledSegment.- Returns:
- the type
-
getText
Returns the text associated with this segment. Must be one character for inline nodes, must be null for node paragraphs or line breaks.- Returns:
- the segment plain text
-
getTextLength
public int getTextLength()Returns the length of text in the segment, or 0 for segments that contain no text or wheregetText()
returns null.- Returns:
- the length in characters
-
getInlineNodeGenerator
-
getParagraphNodeGenerator
-
getStyleAttributeMap
This method returns StyleAttributeMap (or null) for this segment. When the model manages style names (instead of actual attributes), an instance ofStyleResolver
may be used to convert the style names to individual attributes. Keep in mind that different views might have different stylesheet applied and resulting in a different set of attributes.- Parameters:
resolver
- the style resolver to use- Returns:
- style attributes
-
subSegment
Creates a sub-segment of this segment.- Parameters:
start
- the start offsetend
- the end offset- Returns:
- the StyledSegment
-
of
Creates a StyleSegment from a non-null plain text. Important: text must not contain any characters < 0x20, except for TAB.- Parameters:
text
- the segment text- Returns:
- the StyledSegment instance
-
of
Creates a StyleSegment from a non-null plain text and style attributes. Important: text must not contain any characters < 0x20, except for TAB.- Parameters:
text
- the segment textattrs
- the segment style attributes- Returns:
- the StyledSegment instance
-
ofInlineNode
Creates a StyledSegment which consists of a single inline Node.- Parameters:
generator
- the code to create a Node instance- Returns:
- the StyledSegment instance
-
ofRegion
Creates a StyledSegment for a paragraph that contains a single Region.- Parameters:
generator
- the code to create a Region instance- Returns:
- the StyledSegment instance
-
ofParagraphAttributes
Creates a StyledSegment which contains paragraph attributes only.- Parameters:
attrs
- the paragraph attributes- Returns:
- the StyledSegment instance
-