Class SimpleViewOnlyStyledModel
- 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 -
Method Summary
Modifier and TypeMethodDescriptionaddImage
(InputStream in) Adds a paragraph containing an image.addNodeSegment
(Supplier<Node> generator) Adds an inline Node to the last paragraph.addParagraph
(Supplier<Region> generator) Adds a paragraph containing aRegion
.addSegment
(String text) Appends a text segment to the last paragraph.addSegment
(String text, StyleAttributeMap a) Appends a text segment styled with the specified style attributes.addWavyUnderline
(int start, int length, Color c) Adds a wavy underline (typically used as a spell checker indicator) to the specified range within the last paragraph.addWithInlineAndStyleNames
(String text, String style, String... css) Appends a text segment styled with both the inline style and the stylesheet style names.addWithInlineStyle
(String text, String style) Appends a text segment styled with the inline style.addWithStyleNames
(String text, String... css) Appends a text segment styled with the stylesheet style names.getParagraph
(int index) Returns aRichParagraph
at the given model index.getPlainText
(int index) Returns the plain text string for the specified paragraph.getStyleAttributeMap
(StyleResolver r, TextPos pos) Returns theStyleAttributeMap
of the character at the specified position'scharIndex
.Adds a highlight of the given color to the specified range within the last paragraph.nl()
Adds a new paragraph (as if inserting a newline symbol into the text).nl
(int count) Addsn
new paragraphs (as if inserting a newline symbol into the textn
times).static SimpleViewOnlyStyledModel
Creates the model from the supplied text string by breaking it down into individual text segments, by splitting on newline characters.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()The constructor.
-
-
Method Details
-
of
Creates the model from the supplied text string by breaking it down into individual text segments, by splitting on newline characters.- Parameters:
text
- the input multi-line text- Returns:
- the new instance
- Throws:
IOException
- if an I/O error occurs
-
size
public int size()Description copied from class:StyledTextModel
Returns the number of paragraphs in the model.- Specified by:
size
in classStyledTextModel
- Returns:
- number of paragraphs
-
getPlainText
Description copied from class:StyledTextModel
Returns 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 ofindex
is within the valid document range, since doing otherwise might result in an exception or undetermined behavior.- Specified by:
getPlainText
in classStyledTextModel
- Parameters:
index
- the paragraph index in the range (0...StyledTextModel.size()
)- Returns:
- the non-null paragraph text string
-
getParagraph
Description copied from class:StyledTextModel
Returns aRichParagraph
at the given model index. The callers must ensure that the value ofindex
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:
getParagraph
in classStyledTextModel
- Parameters:
index
- the paragraph index in the range (0...StyledTextModel.size()
)- Returns:
- the instance of
RichParagraph
-
addSegment
Appends a text segment to the last paragraph. The caller must ensure that thetext
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) Appends a text segment styled with both the inline style and the stylesheet style names. Thetext
cannot contain newline (\n
) symbols.- Parameters:
text
- the text to append, must not contain\n
, cannot be nullstyle
- the inline style (example"-fx-fill:red;"
)css
- the stylesheet style names- Returns:
- this model instance
-
addWithStyleNames
Appends a text segment styled with the stylesheet style names. Thetext
cannot contain newline (\n
) symbols.- Parameters:
text
- the text to append, must not contain\n
, cannot be nullcss
- the stylesheet style names- Returns:
- this model instance
-
addWithInlineStyle
Appends a text segment styled with the inline style. Thetext
cannot contain newline (\n
) symbols.- Parameters:
text
- the text to append, must not contain\n
, cannot be nullstyle
- the inline style (example"-fx-fill:red;"
), or null- Returns:
- this model instance
-
addSegment
Appends a text segment styled with the specified style attributes.- Parameters:
text
- the text to append, must not contain control symbols other than TAB.a
- the style attributes- Returns:
- this model instance
-
highlight
Adds a highlight of the given color to the specified range within the last paragraph.- Parameters:
start
- the start offsetlength
- the length of the highlightc
- the highlight color- Returns:
- this model instance
-
addWavyUnderline
Adds a wavy underline (typically used as a spell checker indicator) to the specified range within the last paragraph.- Parameters:
start
- the start offsetlength
- the length of the highlightc
- the highlight color- Returns:
- this model instance
-
addImage
Adds a paragraph containing an image. The image will be reduced in size as necessary to fit into the available area ifwrapText
property is set. This method does not close the input stream.- Parameters:
in
- the input stream providing the image.- Returns:
- this model instance
-
addParagraph
Adds a paragraph containing aRegion
.The supplied generator must not cache or keep reference to the created
Region
, but the createdRegion
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
Adds an inline Node to the last paragraph.The supplied generator must not cache or keep reference to the created
Node
, but the createdNode
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
Adds a new paragraph (as if inserting a newline symbol into the text). This convenience method invokesnl(int)
with a value of 1.- Returns:
- this model instance
-
nl
Addsn
new paragraphs (as if inserting a newline symbol into the textn
times).- Parameters:
count
- the number of paragraphs to append- Returns:
- this model instance
-
getStyleAttributeMap
Description copied from class:StyledTextModel
Returns theStyleAttributeMap
of the character at the specified position'scharIndex
. When at the end of the document, returns the attributes of the last character.- Specified by:
getStyleAttributeMap
in classStyledTextModel
- Parameters:
r
- the style resolverpos
- the text position- Returns:
- the style attributes, non-null
-
setParagraphAttributes
Sets the last paragraph's attributes.- Parameters:
a
- the paragraph attributes- Returns:
- this model instance
-