# Class StyledSegment

java.lang.Object
jfx.incubator.scene.control.richtext.model.StyledSegment

public abstract class StyledSegment extends Object
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 Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `StyledSegment.Type`
  StyledSegment type

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final StyledSegment`
  `LINE_BREAK`
  A styled segment that represents a line break

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Supplier<Node>`
  `getInlineNodeGenerator()`
  This method must return a non-null value for a segment of `INLINE_NODE` type, or null in any other case.
  `Supplier<Region>`
  `getParagraphNodeGenerator()`
  This method must return a non-null value for a segment of `REGION` type, or null in any other case.
  `StyleAttributeMap`
  `getStyleAttributeMap(StyleResolver resolver)`
  This method returns StyleAttributeMap (or null) for this segment.
  `String`
  `getText()`
  Returns the text associated with this segment.
  `int`
  `getTextLength()`
  Returns the length of text in the segment, or 0 for segments that contain no text or where `getText()` returns null.
  `abstract StyledSegment.Type`
  `getType()`
  Returns the type of this StyledSegment.
  `static StyledSegment`
  `of(String text)`
  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`
  `ofParagraphAttributes(StyleAttributeMap attrs)`
  Creates a StyledSegment which contains paragraph attributes only.
  `static StyledSegment`
  `ofRegion(Supplier<Region> generator)`
  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.

  ### Methods declared in class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### LINE_BREAK

    public static final StyledSegment LINE_BREAK
    A styled segment that represents a line break

- ## Method Details

  - ### getType

    public abstract StyledSegment.Type getType()
    Returns the type of this StyledSegment.
    Returns:
      the type

  - ### getText

    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:
      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 where `getText()` returns null.
    Returns:
      the length in characters

  - ### getInlineNodeGenerator

    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:
      code that creates a Node instance, or null

  - ### getParagraphNodeGenerator

    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:
      code that creates a Region instance, or null

  - ### getStyleAttributeMap

    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` - the style resolver to use
    Returns:
      style attributes

  - ### subSegment

    public abstract StyledSegment subSegment(int start, int end)
    Creates a sub-segment of this segment.
    Parameters:
      `start` - the start offset
      `end` - the end offset
    Returns:
      the StyledSegment

  - ### of

    public static StyledSegment of(String text)
    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

    public static StyledSegment of(String text, StyleAttributeMap attrs)
    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 text
      `attrs` - the segment style attributes
    Returns:
      the StyledSegment instance

  - ### ofInlineNode

    public static StyledSegment ofInlineNode(Supplier<Node> generator)
    Creates a StyledSegment which consists of a single inline Node.
    Parameters:
      `generator` - the code to create a Node instance
    Returns:
      the StyledSegment instance

  - ### ofRegion

    public static StyledSegment ofRegion(Supplier<Region> generator)
    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

    public static StyledSegment ofParagraphAttributes(StyleAttributeMap attrs)
    Creates a StyledSegment which contains paragraph attributes only.
    Parameters:
      `attrs` - the paragraph attributes
    Returns:
      the StyledSegment instance