Class SimpleViewOnlyStyledModel
public class SimpleViewOnlyStyledModel extends StyledTextModelViewOnlyBase
- 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
| Constructor | Description |
|---|---|
SimpleViewOnlyStyledModel() |
The constructor. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
SimpleViewOnlyStyledModel |
addImage |
Adds a paragraph containing an image. |
SimpleViewOnlyStyledModel |
addNodeSegment |
Adds an inline Node to the last paragraph. |
SimpleViewOnlyStyledModel |
addParagraph |
Adds a paragraph containing a Region. |
SimpleViewOnlyStyledModel |
addSegment |
Appends a text segment to the last paragraph. |
SimpleViewOnlyStyledModel |
addSegment |
Appends a text segment styled with the specified style attributes. |
SimpleViewOnlyStyledModel |
addWavyUnderline |
Adds a wavy underline (typically used as a spell checker indicator) to the specified range within the last paragraph. |
SimpleViewOnlyStyledModel |
addWithInlineAndStyleNames |
Appends a text segment styled with both the inline style and the stylesheet style names. |
SimpleViewOnlyStyledModel |
addWithInlineStyle |
Appends a text segment styled with the inline style. |
SimpleViewOnlyStyledModel |
addWithStyleNames |
Appends a text segment styled with the stylesheet style names. |
RichParagraph |
getParagraph |
Returns a RichParagraph at the given model index. |
String |
getPlainText |
Returns the plain text string for the specified paragraph. |
StyleAttributeMap |
getStyleAttributeMap |
Returns the StyleAttributeMap of the character at the specified position's charIndex. |
SimpleViewOnlyStyledModel |
highlight |
Adds a highlight of the given color to the specified range within the last paragraph. |
SimpleViewOnlyStyledModel |
nl() |
Adds a new paragraph (as if inserting a newline symbol into the text). |
SimpleViewOnlyStyledModel |
nl |
Adds n new paragraphs (as if inserting a newline symbol into the text n times). |
static SimpleViewOnlyStyledModel |
of |
Creates the model from the supplied text string by breaking it down into individual text segments, by splitting on newline characters. |
SimpleViewOnlyStyledModel |
setParagraphAttributes |
Sets the last paragraph's attributes. |
int |
size() |
Returns the number of paragraphs in the model. |
Methods declared in class jfx.incubator.scene.control.richtext.model.StyledTextModelViewOnlyBase
applyStyle, insertLineBreak, insertParagraph, insertTextSegment, isWritable, removeRange, setParagraphStyle
Methods declared in class jfx.incubator.scene.control.richtext.model.StyledTextModel
addListener, 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
SimpleViewOnlyStyledModel
public SimpleViewOnlyStyledModel()
Method Details
of
public static SimpleViewOnlyStyledModel of(String text) throws IOException
- Parameters:
-
text- the input multi-line text - Returns:
- the new instance
- Throws:
-
IOException- if an I/O error occurs
size
public int size()
StyledTextModel- Specified by:
-
sizein classStyledTextModel - Returns:
- number of paragraphs
getPlainText
public String getPlainText(int index)
StyledTextModelindex is within the valid document range, since doing otherwise might result in an exception or undetermined behavior.- Specified by:
-
getPlainTextin classStyledTextModel - Parameters:
-
index- the paragraph index in the range (0...StyledTextModel.size()) - Returns:
- the non-null paragraph text string
getParagraph
public RichParagraph getParagraph(int index)
StyledTextModelRichParagraph at the given model index. The callers must ensure that the value of index is 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 classStyledTextModel - Parameters:
-
index- the paragraph index in the range (0...StyledTextModel.size()) - Returns:
- the instance of
RichParagraph
addSegment
public SimpleViewOnlyStyledModel addSegment(String text)
text does not contain newline symbols, as the behavior is undefined in this case. This convenience method is equivalent to calling addSegment(text, StyleAttributeMap.EMPTY);
- Parameters:
-
text- the text to append, must not contain newline symbols, cannot be null - Returns:
- this model instance
addWithInlineAndStyleNames
public SimpleViewOnlyStyledModel addWithInlineAndStyleNames(String text, String style, String... css)
text cannot contain newline (\n) symbols.- Parameters:
-
text- the text to append, must not contain\n, cannot be null -
style- the inline style (example"-fx-fill:red;") -
css- the stylesheet style names - Returns:
- this model instance
addWithStyleNames
public SimpleViewOnlyStyledModel addWithStyleNames(String text, String... css)
text cannot contain newline (\n) symbols.- Parameters:
-
text- the text to append, must not contain\n, cannot be null -
css- the stylesheet style names - Returns:
- this model instance
addWithInlineStyle
public SimpleViewOnlyStyledModel addWithInlineStyle(String text, String style)
text cannot contain newline (\n) symbols.- Parameters:
-
text- the text to append, must not contain\n, cannot be null -
style- the inline style (example"-fx-fill:red;"), or null - Returns:
- this model instance
addSegment
public SimpleViewOnlyStyledModel addSegment(String text, StyleAttributeMap a)
- Parameters:
-
text- the text to append, must not contain control symbols other than TAB. -
a- the style attributes - Returns:
- this model instance
highlight
public SimpleViewOnlyStyledModel highlight(int start, int length, Color c)
- Parameters:
-
start- the start offset -
length- the length of the highlight -
c- the highlight color - Returns:
- this model instance
addWavyUnderline
public SimpleViewOnlyStyledModel addWavyUnderline(int start, int length, Color c)
- Parameters:
-
start- the start offset -
length- the length of the highlight -
c- the highlight color - Returns:
- this model instance
addImage
public SimpleViewOnlyStyledModel addImage(InputStream in)
wrapText property is set. This method does not close the input stream.- Parameters:
-
in- the input stream providing the image. - Returns:
- this model instance
addParagraph
public SimpleViewOnlyStyledModel addParagraph(Supplier<Region> generator)
Region. The supplied generator must not cache or keep reference to the created Region, but the created Region 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:
-
generator- the supplier of the paragraph content - Returns:
- this model instance
addNodeSegment
public SimpleViewOnlyStyledModel addNodeSegment(Supplier<Node> generator)
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:
-
generator- the supplier of the embedded Node - Returns:
- this model instance
nl
public SimpleViewOnlyStyledModel nl()
nl(int) with a value of 1.- Returns:
- this model instance
nl
public SimpleViewOnlyStyledModel nl(int count)
n new paragraphs (as if inserting a newline symbol into the text n times).- Parameters:
-
count- the number of paragraphs to append - Returns:
- this model instance
getStyleAttributeMap
public StyleAttributeMap getStyleAttributeMap(StyleResolver r, TextPos pos)
StyledTextModelStyleAttributeMap of the character at the specified position's charIndex. When at the end of the document, returns the attributes of the last character.- Specified by:
-
getStyleAttributeMapin classStyledTextModel - Parameters:
-
r- the style resolver -
pos- the text position - Returns:
- the style attributes, non-null
setParagraphAttributes
public SimpleViewOnlyStyledModel setParagraphAttributes(StyleAttributeMap a)
- Parameters:
-
a- the paragraph attributes - Returns:
- this model instance
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.