RichTextArea.
This class handles the following functionality with the intent to simplify custom models:
Markers
isWritable() returns true.
Three methods participate in modification of the content:
replace(StyleResolver, TextPos, TextPos, String, boolean),
replace(StyleResolver, TextPos, TextPos, StyledInput, boolean),
applyStyle(TextPos, TextPos, StyleAttributeMap, boolean).
These methods decompose the main modification into operations with individual paragraphs
and delegate these to subclasses.
At the end of this process, an event is sent to all the Listeners, followed by the
skin requesting the updated paragraphs when required.
RichParagraph.
There are two ways of adding styles to the model:
"-fx-font-size:200%;"), or
StyleAttributeMap, such as bold typeface, italic, and so on.
In this case, the resulting paragraph appearance is decoupled from the stylesheet and will look the same
regardless of the active stylesheet.
Nodes, since multiple skins might be attached to the same
model. When required, the model may contain properties which can be bound to the Nodes created in
getParagraph(int). It is the responsibility of the model to store and restore the values
of such properties.
| Modifier and Type | Class and Description |
|---|---|
| private static record | |
| private static record | StyledTextModel.
stores the handler and its priority |
| public static interface | StyledTextModel.
Receives information about modifications of the model. |
| Modifier and Type | Field and Description |
|---|---|
| private final HashMap | |
| private final UndoableChange | |
| private final CopyOnWriteArrayList | |
| private final Markers | |
| private final ReadOnlyBooleanWrapper | |
| private UndoableChange | |
| private final ReadOnlyBooleanWrapper |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | add(UndoableChange
the change ch, TextPos the caret position after the change end)Adds an |
| public final void | |
| protected abstract void | applyStyle(int
the paragraph index index, int the start offset start, int the end offset end, StyleAttributeMap the character attributes a, boolean determines whether to merge with or overwrite the existing attributes merge)Applies style to the specified text range within a single paragraph. |
| public final void | applyStyle(TextPos
the start of text range start, TextPos the end of text range end, StyleAttributeMap the style attributes to set attrs, boolean whether to merge or replace the attributes mergeAttributes)Applies the style attributes to the specified range in the document. |
| private void | |
| public final TextPos | |
| public final void | |
| private String | |
| public final void | export(TextPos
start of the range start, TextPos end of the range end, StyledOutput StyledOutput to receive the streamExports the stream of |
| protected final void | exportParagraph(int
the paragraph index in the model index, int the start offset start, int the end offset (may exceed the paragraph length) end, boolean determines whether to emit paragraph attributes withParAttrs, StyledOutput the target StyledOutput out)Exports part of the paragraph as a sequence of styled segments. |
| private StyleAttributeMap | Returns: the attributes that exclude unsupported onesthe input attributes attrs)Removes unsupported attributes per |
| public void | fireChangeEvent(TextPos
start of the affected range start, TextPos end of the affected range end, int number of characters added before any added paragraphs charsTop, int number of paragraphs inserted linesAdded, int number of characters added after any inserted paragraphs charsBottom)Fires a text modification event for the given range. |
| public void | fireStyleChangeEvent(TextPos
the start position start, TextPos the end position, must be greater than the start position end)Fires a style change event for the given range. |
| public final DataFormatHandler | Returns: DataFormatHandler or nulldata format format, boolean for export (true) or for input (false) forExport)Returns a |
| public final TextPos | Returns: the text positionReturns the text position corresponding to the end of the document. |
| public final TextPos | Returns: the text positionthe paragraph index index)Returns a TextPos corresponding to the end of paragraph at the given index. |
| public final Marker | |
| public abstract RichParagraph | Returns: the instance ofRichParagraphthe paragraph index in the range (0... index)size())Returns a |
| public int | Returns: the lengththe paragraph index index)Returns the length of text in a paragraph at the specified index. |
| public abstract String | Returns: the non-null paragraph text stringthe paragraph index in the range (0... index)size())Returns the plain text string for the specified paragraph. |
| public abstract StyleAttributeMap | Returns: the style attributes, non-nullthe style resolver resolver, TextPos the text position pos)Returns the |
| protected Set | Returns: the set of supported attributes, or null if the model requires no filteringReturns the set of attributes supported attributes. |
| public final List | Returns: the immutable list of supported formatsdetermines whether the operation is export (true) or import (false) forExport)Returns an immutable list of supported data formats for either export or import operations, in the order of priority - from high to low. |
| protected abstract void | insertLineBreak(int
the model index index, int the text offset offset)Inserts a line break at the specified position. |
| protected abstract void | insertParagraph(int
model index index, Supplier<Region> code that will be used to create a Node instance generator)Inserts a paragraph that contains a single |
| protected abstract int | Returns: the number of characters insertedthe paragraph index index, int the insertion offset within the paragraph offset, String the text to insert text, StyleAttributeMap the style attributes attrs)This method is called to insert a single styled text segment at the given position. |
| public final boolean | |
| public final boolean | |
| public abstract boolean | Returns: true if the model supports content modificationsIndicates whether the model supports content modifications made via
|
| public final void | read(StyleResolver
the style resolver r, DataFormat the data format f, InputStream the input stream input)Replaces the content of the model with the data read from the input stream,
using the specified |
| public final TextPos[] | Returns: the [start, end] text positions prior to the changethe StyleResolver to use resolver)Redoes the recent change, if possible, returning an array comprising [start, end] text positions prior to the change. |
| public final ReadOnlyBooleanProperty | Returns: the read-only propertyThe property describes if it's currently possible to redo the latest change of the content that was undone. |
| protected final void | registerDataFormatHandler(DataFormatHandler
data format handler h, boolean true if the handler supports export operations forExport, boolean true if the handler supports import operations forImport, int from 0 (lowest, usually plain text) to priority)Integer.MAX_VALUERegisters a format handler for export and/or import operations. |
| protected final void | removeDataFormatHandler(DataFormat
the data format f, boolean whether to remove the export handler forExport, boolean whether to remove the import handler forImport)Removes the data format handler registered previously with
|
| public final void | removeListener(StyledTextModel.
a non-null listener listenerRemoves a |
| protected abstract void | removeRange(TextPos
the start of the range to be removed start, TextPos the end of the range to be removed, expected to be greater than the start position end)Removes the specified text range. |
| public final TextPos | Returns: the text position at the end of the inserted text, or null if the model is read onlythe StyleResolver to use resolver, TextPos start text position start, TextPos end text position end, String text string to insert text, boolean when true, creates an undo-redo entry allowUndo)Replaces the given range with the provided plain text. |
| public final TextPos | Returns: the text position at the end of the inserted text, or null if the model is read onlythe StyleResolver to use, can be null resolver, TextPos the start text position start, TextPos the end text position end, StyledInput the input content stream input, boolean when true, creates an undo-redo entry allowUndo)Replaces the given range with the provided styled text input. |
| protected abstract void | setParagraphStyle(int
the paragraph index index, StyleAttributeMap the paragraph attributes paragraphAttrs)Replaces the paragraph styles in the specified paragraph. |
| private void | |
| private void | |
| public abstract int | |
| public final TextPos[] | Returns: the [start, end] text positions prior to the changethe StyleResolver to use resolver)Undoes the recent change, if possible, returning an array comprising [start, end] text positions prior to the change. |
| public final ReadOnlyBooleanProperty | Returns: the read-only propertyThe property describes if it's currently possible to undo the latest change of the content that was done. |
| private void | |
| public final void | write(StyleResolver
the style resolver r, DataFormat the data format f, OutputStream the output stream out)Writes the model content to the output stream using the specified |