RichParagraph (JavaFX 27)
Description: declaration: module: jfx.incubator.richtext, package: jfx.incubator.scene.control.richtext.model, class: RichParagraph

# Class RichParagraph

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

public abstract class RichParagraph extends Object
Represents a single immutable paragraph within the `StyledModel`. A single paragraph may contain either:

- A number of `StyledSegments` such as styled text or `Supplier`s of embedded `Node`s
- A supplier of a single `Region` which fills the entire paragraph

Since:
  24

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `RichParagraph.Builder`
  Utility class for building immutable `RichParagraph`s.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RichParagraph()`
  The constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static RichParagraph.Builder`
  `builder()`
  Creates an instance of the `Builder` class.
  `StyleAttributeMap`
  `getParagraphAttributes()`
  Returns the paragraph attributes.
  `Supplier<Region>`
  `getParagraphRegion()`
  Returns the generator for this paragraph `Region` representation.
  `abstract String`
  `getPlainText()`
  Returns the plain text of this paragraph, or null.
  `abstract StyledSegment`
  `getSegment(int index)`
  Returns the segment at the specified index.
  `abstract int`
  `getSegmentCount()`
  Returns the number of segments in the paragraph.
  `static RichParagraph`
  `of(Supplier<Region> paragraphGenerator)`
  Creates a paragraph consisting of a single Rectangle.

  ### Methods declared in class Object

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

- ## Constructor Details

  - ### RichParagraph

    public RichParagraph()
    The constructor.

- ## Method Details

  - ### of

    public static RichParagraph of(Supplier<Region> paragraphGenerator)
    Creates a paragraph consisting of a single Rectangle. The paragraph will typically assume its Rectangle preferred size, or, when the text wrap mode is on, might get resized to fit the available width.

    The supplied generator must not cache or keep reference to the created Node, but the created Node can keep a reference to the model or a property therein.

    For example, a bidirectional binding between an inline control and some property in the model would synchronize the model with all the views that use it.

    Parameters:
      `paragraphGenerator` - the content generator
    Returns:
      the RichParagraph instance

  - ### getParagraphRegion

    public Supplier<Region> getParagraphRegion()
    Returns the generator for this paragraph `Region` representation. This method returns a non-null value when the paragraph is represented by a single `Region`.
    Returns:
      the generator, or null

  - ### getPlainText

    public abstract String getPlainText()
    Returns the plain text of this paragraph, or null.
    Returns:
      the plain text

  - ### getSegmentCount

    public abstract int getSegmentCount()
    Returns the number of segments in the paragraph.
    Returns:
      the number of segments
    Since:
      26

  - ### getSegment

    public abstract StyledSegment getSegment(int index)
    Returns the segment at the specified index.
    Parameters:
      `index` - the segment index
    Returns:
      the segment
    Throws:
      `IndexOutOfBoundsException` - if the index is outside of the range `0 ... getSegmentCount()-1` (inclusive)
    Since:
      26

  - ### getParagraphAttributes

    public StyleAttributeMap getParagraphAttributes()
    Returns the paragraph attributes.
    Returns:
      the paragraph attributes, can be null

  - ### builder

    public static RichParagraph.Builder builder()
    Creates an instance of the `Builder` class.
    Returns:
      the new Builder instance