# Class StyledTextModelViewOnlyBase

java.lang.Object
jfx.incubator.scene.control.richtext.model.StyledTextModel
jfx.incubator.scene.control.richtext.model.StyledTextModelViewOnlyBase

Direct Known Subclasses:
  `SimpleViewOnlyStyledModel`

public abstract class StyledTextModelViewOnlyBase extends StyledTextModel
The base class for view-only `StyledTextModel`s.

Models extending this class will not be user editable.

Since:
  24

- ## Nested Class Summary

  ### Nested classes/interfaces declared in class jfx.incubator.scene.control.richtext.model.StyledTextModel

  `StyledTextModel.Listener`

- ## Property Summary

  ### Properties declared in class jfx.incubator.scene.control.richtext.model.StyledTextModel

  `redoable, undoable`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StyledTextModelViewOnlyBase()`
  The constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected final void`
  `applyStyle(int ix, int start, int end, StyleAttributeMap a, boolean merge)`
  Applies style to the specified text range within a single paragraph.
  `protected void`
  `insertLineBreak(int index, int offset)`
  Inserts a line break at the specified position.
  `protected void`
  `insertParagraph(int index, Supplier<Region> generator)`
  Inserts a paragraph that contains a single `Region`.
  `protected int`
  `insertTextSegment(int index, int offset, String text, StyleAttributeMap attrs)`
  This method is called to insert a single styled text segment at the given position.
  `final boolean`
  `isWritable()`
  Indicates whether the model supports content modifications made via `applyStyle()`, `replace()`, `undo()`, `redo()` methods.
  `protected void`
  `removeRange(TextPos start, TextPos end)`
  Removes the specified text range.
  `protected final void`
  `setParagraphStyle(int ix, StyleAttributeMap a)`
  Replaces the paragraph styles in the specified paragraph.

  ### Methods declared in class jfx.incubator.scene.control.richtext.model.StyledTextModel

  `addListener, applyStyle, clamp, clearUndoRedo, export, exportParagraph, fireChangeEvent, fireStyleChangeEvent, getDataFormatHandler, getDocumentEnd, getEndOfParagraphTextPos, getMarker, getParagraph, getParagraphLength, getPlainText, getStyleAttributeMap, getSupportedAttributes, getSupportedDataFormats, isRedoable, isUndoable, read, redo, redoableProperty, registerDataFormatHandler, removeDataFormatHandler, removeListener, replace, replace, size, undo, undoableProperty, write`

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

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

- ## Constructor Details

  - ### StyledTextModelViewOnlyBase

    public StyledTextModelViewOnlyBase()
    The constructor.

- ## Method Details

  - ### isWritable

    public final boolean isWritable()
    Description copied from class: `StyledTextModel`
    Indicates whether the model supports content modifications made via `applyStyle()`, `replace()`, `undo()`, `redo()` methods.

    Note that even when this method returns `false`, the model itself may still update its content and fire the change events as a response, for example, to changes in its backing data storage.

    Specified by:
      `isWritable` in class `StyledTextModel`
    Returns:
      always returns `false`

  - ### removeRange

    protected void removeRange(TextPos start, TextPos end)
    Description copied from class: `StyledTextModel`
    Removes the specified text range. This method gets called only if the model is editable. The caller guarantees that `start` precedes `end`.
    Specified by:
      `removeRange` in class `StyledTextModel`
    Parameters:
      `start` - the start of the range to be removed
      `end` - the end of the range to be removed, expected to be greater than the start position

  - ### insertTextSegment

    protected int insertTextSegment(int index, int offset, String text, StyleAttributeMap attrs)
    Description copied from class: `StyledTextModel`
    This method is called to insert a single styled text segment at the given position.
    Specified by:
      `insertTextSegment` in class `StyledTextModel`
    Parameters:
      `index` - the paragraph index
      `offset` - the insertion offset within the paragraph
      `text` - the text to insert
      `attrs` - the style attributes
    Returns:
      the number of characters inserted

  - ### insertLineBreak

    protected void insertLineBreak(int index, int offset)
    Description copied from class: `StyledTextModel`
    Inserts a line break at the specified position.
    Specified by:
      `insertLineBreak` in class `StyledTextModel`
    Parameters:
      `index` - the model index
      `offset` - the text offset

  - ### insertParagraph

    protected void insertParagraph(int index, Supplier<Region> generator)
    Description copied from class: `StyledTextModel`
    Inserts a paragraph that contains a single `Region`.

    The model should not cache or otherwise retain references to the created `Region`s, as they might be requested multiple times during the lifetime of the model, or by different views.

    This method allows for embedding `Control`s that handle user input. In this case, the model should declare necessary properties and provide bidirectional bindings between the properties in the model and the corresponding properties in the control, as well as handle copy, paste, writing to and reading from I/O streams.

    Specified by:
      `insertParagraph` in class `StyledTextModel`
    Parameters:
      `index` - model index
      `generator` - code that will be used to create a Node instance

  - ### setParagraphStyle

    protected final void setParagraphStyle(int ix, StyleAttributeMap a)
    Description copied from class: `StyledTextModel`
    Replaces the paragraph styles in the specified paragraph.
    Specified by:
      `setParagraphStyle` in class `StyledTextModel`
    Parameters:
      `ix` - the paragraph index
      `a` - the paragraph attributes

  - ### applyStyle

    protected final void applyStyle(int ix, int start, int end, StyleAttributeMap a, boolean merge)
    Description copied from class: `StyledTextModel`
    Applies style to the specified text range within a single paragraph. The new attributes override any existing attributes. The `end` argument may exceed the paragraph length, in which case the outcome should be the same as supplying the paragraph length value.
    Specified by:
      `applyStyle` in class `StyledTextModel`
    Parameters:
      `ix` - the paragraph index
      `start` - the start offset
      `end` - the end offset
      `a` - the character attributes
      `merge` - determines whether to merge with or overwrite the existing attributes