Top Description Inners Fields Constructors Methods
jfx.incubator.scene.control.richtext.model

public abstract Class StyledSegment

extends Object
Class Inheritance
Imports
java.util.function.Supplier, javafx.scene.Node, javafx.scene.layout.Region, jfx.incubator.scene.control.richtext.StyleResolver

Data structure used to modify the styled text model.

Each instance represents:

  1. a single text segment with direct style and/or style names
  2. a line break
  3. an inline Node
  4. a paragraph containing a single Region
  5. paragraph attributes
Since
24

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
StyledSegment.Type

StyledSegment type

Field Summary

Modifier and TypeField and Description
public static final StyledSegment
LINE_BREAK

A styled segment that represents a line break

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Supplier<Node>

Returns:

code that creates a Node instance, or null
getInlineNodeGenerator
()

This method must return a non-null value for a segment of INLINE_NODE type, or null in any other case.

public Supplier<Region>

Returns:

code that creates a Region instance, or null
getParagraphNodeGenerator
()

This method must return a non-null value for a segment of REGION type, or null in any other case.

public StyleAttributeMap

Returns:

style attributes
getStyleAttributeMap
(StyleResolver
the style resolver to use
resolver
)

This method returns StyleAttributeMap (or null) for this segment.

public String

Returns:

the segment plain text
getText
()

Returns the text associated with this segment.

public int

Returns:

the length in characters
getTextLength
()

Returns the length of text in the segment, or 0 for segments that contain no text or where getText() returns null.

public abstract StyledSegment.Type

Returns:

the type
getType
()

Returns the type of this StyledSegment.

public static StyledSegment

Returns:

the StyledSegment instance
of
(String
the segment text
text
)

Creates a StyleSegment from a non-null plain text.

public static StyledSegment

Returns:

the StyledSegment instance
of
(String
the segment text
text
,
StyleAttributeMap
the segment style attributes
attrs
)

Creates a StyleSegment from a non-null plain text and style attributes.

public static StyledSegment

Returns:

the StyledSegment instance
ofInlineNode
(Supplier<Node>
the code to create a Node instance
generator
)

Creates a StyledSegment which consists of a single inline Node.

public static StyledSegment

Returns:

the StyledSegment instance
ofParagraphAttributes
(StyleAttributeMap
the paragraph attributes
attrs
)

Creates a StyledSegment which contains paragraph attributes only.

public static StyledSegment

Returns:

the StyledSegment instance
ofRegion
(Supplier<Region>
the code to create a Region instance
generator
)

Creates a StyledSegment for a paragraph that contains a single Region.

public abstract StyledSegment

Returns:

the StyledSegment
subSegment
(int
the start offset
start
,
int
the end offset
end
)

Creates a sub-segment of this segment.

private static String
substring(String text, int start, int end)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LINE_BREAKback to summary
public static final StyledSegment LINE_BREAK

A styled segment that represents a line break

Constructor Detail

StyledSegmentback to summary
private StyledSegment()

Method Detail

getInlineNodeGeneratorback to summary
public Supplier<Node> getInlineNodeGenerator()

This method must return a non-null value for a segment of INLINE_NODE type, or null in any other case.

Returns:Supplier<Node>

code that creates a Node instance, or null

getParagraphNodeGeneratorback to summary
public Supplier<Region> getParagraphNodeGenerator()

This method must return a non-null value for a segment of REGION type, or null in any other case.

Returns:Supplier<Region>

code that creates a Region instance, or null

getStyleAttributeMapback to summary
public StyleAttributeMap getStyleAttributeMap(StyleResolver resolver)

This method returns StyleAttributeMap (or null) for this segment. When the model manages style names (instead of actual attributes), an instance of StyleResolver 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:StyleResolver

the style resolver to use

Returns:StyleAttributeMap

style attributes

getTextback to summary
public String 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:String

the segment plain text

getTextLengthback to summary
public int getTextLength()

Returns the length of text in the segment, or 0 for segments that contain no text or where getText() returns null.

Returns:int

the length in characters

getTypeback to summary
public abstract StyledSegment.Type getType()

Returns the type of this StyledSegment.

Returns:StyledSegment.Type

the type

ofback to summary
public static StyledSegment of(String text)

Creates a StyleSegment from a non-null plain text.

Important Note

text must not contain any characters < 0x20, except for TAB.

Parameters
text:String

the segment text

Returns:StyledSegment

the StyledSegment instance

ofback to summary
public static StyledSegment of(String text, StyleAttributeMap attrs)

Creates a StyleSegment from a non-null plain text and style attributes.

Important Note

text must not contain any characters < 0x20, except for TAB.

Parameters
text:String

the segment text

attrs:StyleAttributeMap

the segment style attributes

Returns:StyledSegment

the StyledSegment instance

ofInlineNodeback to summary
public static StyledSegment ofInlineNode(Supplier<Node> generator)

Creates a StyledSegment which consists of a single inline Node.

Parameters
generator:Supplier<Node>

the code to create a Node instance

Returns:StyledSegment

the StyledSegment instance

ofParagraphAttributesback to summary
public static StyledSegment ofParagraphAttributes(StyleAttributeMap attrs)

Creates a StyledSegment which contains paragraph attributes only.

Parameters
attrs:StyleAttributeMap

the paragraph attributes

Returns:StyledSegment

the StyledSegment instance

ofRegionback to summary
public static StyledSegment ofRegion(Supplier<Region> generator)

Creates a StyledSegment for a paragraph that contains a single Region.

Parameters
generator:Supplier<Region>

the code to create a Region instance

Returns:StyledSegment

the StyledSegment instance

subSegmentback to summary
public abstract StyledSegment subSegment(int start, int end)

Creates a sub-segment of this segment.

Parameters
start:int

the start offset

end:int

the end offset

Returns:StyledSegment

the StyledSegment

substringback to summary
private static String substring(String text, int start, int end)
jfx.incubator.scene.control.richtext.model back to summary

public final Enum StyledSegment.Type

extends Enum<StyledSegment.Type>
Class Inheritance

StyledSegment type

Field Summary

Modifier and TypeField and Description
public static final StyledSegment.Type
INLINE_NODE

Identifies a segment which contains an inline node.

public static final StyledSegment.Type
LINE_BREAK

Identifies a line break segment.

public static final StyledSegment.Type
PARAGRAPH_ATTRIBUTES

Identifies a segment which contains the paragraph attributes.

public static final StyledSegment.Type
REGION

Identifies a segment which contains a single paragraph containing a Region.

public static final StyledSegment.Type
TEXT

Identifies a text segment

Constructor Summary

AccessConstructor and Description
private
Type()

Method Summary

Modifier and TypeMethod and Description
public static StyledSegment.Type
public static StyledSegment.Type[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INLINE_NODEback to summary
public static final StyledSegment.Type INLINE_NODE

Identifies a segment which contains an inline node.

LINE_BREAKback to summary
public static final StyledSegment.Type LINE_BREAK

Identifies a line break segment.

PARAGRAPH_ATTRIBUTESback to summary
public static final StyledSegment.Type PARAGRAPH_ATTRIBUTES

Identifies a segment which contains the paragraph attributes.

REGIONback to summary
public static final StyledSegment.Type REGION

Identifies a segment which contains a single paragraph containing a Region.

TEXTback to summary
public static final StyledSegment.Type TEXT

Identifies a text segment

Constructor Detail

Typeback to summary
private Type()

Method Detail

valueOfback to summary
public static StyledSegment.Type valueOf(String name)
valuesback to summary
public static StyledSegment.Type[] values()