Class RichTextModel
StyledTextModel based on a collection of styled segments.
 This model is suitable for relatively small documents as it has neither disk storage backing nor storage of incremental changes.
- Since:
- 24
- 
Nested Class SummaryNested classes/interfaces declared in class jfx.incubator.scene.control.richtext.model.StyledTextModelStyledTextModel.Listener
- 
Property SummaryProperties declared in class jfx.incubator.scene.control.richtext.model.StyledTextModelredoable, undoable
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidapplyStyle(int index, int start, int end, StyleAttributeMap attrs, boolean merge) Applies style to the specified text range within a single paragraph.getParagraph(int index) Returns aRichParagraphat the given model index.getPlainText(int index) Returns the plain text string for the specified paragraph.getStyleAttributeMap(StyleResolver resolver, TextPos pos) Returns theStyleAttributeMapof the character at the specified position'scharIndex.protected voidinsertLineBreak(int index, int offset) Inserts a line break at the specified position.protected voidinsertParagraph(int index, Supplier<Region> generator) Inserts a paragraph that contains a singleRegion.protected intinsertTextSegment(int index, int offset, String text, StyleAttributeMap attrs) This method is called to insert a single styled text segment at the given position.final booleanIndicates whether the model supports content modifications made viaapplyStyle(),replace(),undo(),redo()methods.protected voidremoveRange(TextPos start, TextPos end) Removes the specified text range.protected voidsetParagraphStyle(int index, StyleAttributeMap attrs) Replaces the paragraph styles in the specified paragraph.intsize()Returns the number of paragraphs in the model.Methods declared in class jfx.incubator.scene.control.richtext.model.StyledTextModeladdListener, applyStyle, clamp, clearUndoRedo, export, exportParagraph, fireChangeEvent, fireStyleChangeEvent, getDataFormatHandler, getDocumentEnd, getEndOfParagraphTextPos, getMarker, getParagraphLength, getSupportedAttributes, getSupportedDataFormats, isRedoable, isUndoable, read, redo, redoableProperty, registerDataFormatHandler, removeDataFormatHandler, removeListener, replace, replace, undo, undoableProperty, write
- 
Constructor Details- 
RichTextModelpublic RichTextModel()Constructs the empty model.
 
- 
- 
Method Details- 
isWritablepublic final boolean isWritable()Description copied from class:StyledTextModelIndicates whether the model supports content modifications made viaapplyStyle(),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:
- isWritablein class- StyledTextModel
- Returns:
- true if the model supports content modifications
 
- 
sizepublic int size()Description copied from class:StyledTextModelReturns the number of paragraphs in the model.- Specified by:
- sizein class- StyledTextModel
- Returns:
- number of paragraphs
 
- 
getPlainTextDescription copied from class:StyledTextModelReturns the plain text string for the specified paragraph. The returned text string cannot be null and must not contain any control characters other than TAB. The callers must ensure that the value ofindexis within the valid document range, since doing otherwise might result in an exception or undetermined behavior.- Specified by:
- getPlainTextin class- StyledTextModel
- Parameters:
- index- the paragraph index in the range (0...- StyledTextModel.size())
- Returns:
- the non-null paragraph text string
 
- 
getParagraphDescription copied from class:StyledTextModelReturns aRichParagraphat the given model index. The callers must ensure that the value ofindexis within the valid document range, since doing otherwise might result in an exception or undetermined behavior.This method makes no guarantees that the same paragraph instance will be returned for the same model index. - Specified by:
- getParagraphin class- StyledTextModel
- Parameters:
- index- the paragraph index in the range (0...- StyledTextModel.size())
- Returns:
- the instance of RichParagraph
 
- 
insertTextSegmentDescription copied from class:StyledTextModelThis method is called to insert a single styled text segment at the given position.- Specified by:
- insertTextSegmentin 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
 
- 
insertLineBreakprotected void insertLineBreak(int index, int offset) Description copied from class:StyledTextModelInserts a line break at the specified position.- Specified by:
- insertLineBreakin class- StyledTextModel
- Parameters:
- index- the model index
- offset- the text offset
 
- 
removeRangeDescription copied from class:StyledTextModelRemoves the specified text range. This method gets called only if the model is editable. The caller guarantees thatstartprecedesend.- Specified by:
- removeRangein 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
 
- 
insertParagraphDescription copied from class:StyledTextModelInserts a paragraph that contains a singleRegion.The model should not cache or otherwise retain references to the created Regions, as they might be requested multiple times during the lifetime of the model, or by different views.This method allows for embedding Controls 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:
- insertParagraphin class- StyledTextModel
- Parameters:
- index- model index
- generator- code that will be used to create a Node instance
 
- 
setParagraphStyleDescription copied from class:StyledTextModelReplaces the paragraph styles in the specified paragraph.- Specified by:
- setParagraphStylein class- StyledTextModel
- Parameters:
- index- the paragraph index
- attrs- the paragraph attributes
 
- 
applyStyleDescription copied from class:StyledTextModelApplies style to the specified text range within a single paragraph. The new attributes override any existing attributes. Theendargument may exceed the paragraph length, in which case the outcome should be the same as supplying the paragraph length value.- Specified by:
- applyStylein class- StyledTextModel
- Parameters:
- index- the paragraph index
- start- the start offset
- end- the end offset
- attrs- the character attributes
- merge- determines whether to merge with or overwrite the existing attributes
 
- 
getStyleAttributeMapDescription copied from class:StyledTextModelReturns theStyleAttributeMapof the character at the specified position'scharIndex. When at the end of the document, returns the attributes of the last character.- Specified by:
- getStyleAttributeMapin class- StyledTextModel
- Parameters:
- resolver- the style resolver
- pos- the text position
- Returns:
- the style attributes, non-null
 
 
-