Spec-Zone.ru › OpenJavaFX 24

Class SimpleViewOnlyStyledModel

java.lang.Object
jfx.incubator.scene.control.richtext.model.StyledTextModel
jfx.incubator.scene.control.richtext.model.StyledTextModelViewOnlyBase
jfx.incubator.scene.control.richtext.model.SimpleViewOnlyStyledModel
public class SimpleViewOnlyStyledModel extends StyledTextModelViewOnlyBase
A simple, view-only, in-memory, styled text model.
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(InputStream in)
Adds a paragraph containing an image.
SimpleViewOnlyStyledModel addNodeSegment(Supplier<Node> generator)
Adds an inline Node to the last paragraph.
SimpleViewOnlyStyledModel addParagraph(Supplier<Region> generator)
Adds a paragraph containing a Region.
SimpleViewOnlyStyledModel addSegment(String text)
Appends a text segment to the last paragraph.
SimpleViewOnlyStyledModel addSegment(String text, StyleAttributeMap a)
Appends a text segment styled with the specified style attributes.
SimpleViewOnlyStyledModel 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.
SimpleViewOnlyStyledModel addWithInlineAndStyleNames(String text, String style, String... css)
Appends a text segment styled with both the inline style and the stylesheet style names.
SimpleViewOnlyStyledModel addWithInlineStyle(String text, String style)
Appends a text segment styled with the inline style.
SimpleViewOnlyStyledModel addWithStyleNames(String text, String... css)
Appends a text segment styled with the stylesheet style names.
RichParagraph getParagraph(int index)
Returns a RichParagraph at the given model index.
String getPlainText(int index)
Returns the plain text string for the specified paragraph.
StyleAttributeMap getStyleAttributeMap(StyleResolver r, TextPos pos)
Returns the StyleAttributeMap of the character at the specified position's charIndex.
SimpleViewOnlyStyledModel highlight(int start, int length, Color c)
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(int count)
Adds n new paragraphs (as if inserting a newline symbol into the text n times).
static SimpleViewOnlyStyledModel of(String text)
Creates the model from the supplied text string by breaking it down into individual text segments, by splitting on newline characters.
SimpleViewOnlyStyledModel setParagraphAttributes(StyleAttributeMap a)
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

Methods declared in class java.lang.Object

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

Constructor Details

SimpleViewOnlyStyledModel

public SimpleViewOnlyStyledModel()
The constructor.

Method Details

of

public static SimpleViewOnlyStyledModel of(String text) throws IOException
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 class StyledTextModel
Returns:
number of paragraphs

getPlainText

public String getPlainText(int index)
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 of index is within the valid document range, since doing otherwise might result in an exception or undetermined behavior.
Specified by:
getPlainText in class StyledTextModel
Parameters:
index - the paragraph index in the range (0...StyledTextModel.size())
Returns:
the non-null paragraph text string

getParagraph

public RichParagraph getParagraph(int index)
Description copied from class: StyledTextModel
Returns a RichParagraph 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:
getParagraph in class StyledTextModel
Parameters:
index - the paragraph index in the range (0...StyledTextModel.size())
Returns:
the instance of RichParagraph

addSegment

public SimpleViewOnlyStyledModel addSegment(String text)
Appends a text segment to the last paragraph. The caller must ensure that the 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)
Appends a text segment styled with both the inline style and the stylesheet style names. The 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)
Appends a text segment styled with the stylesheet style names. The 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)
Appends a text segment styled with the inline style. The 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)
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

public SimpleViewOnlyStyledModel highlight(int start, int length, Color c)
Adds a highlight of the given color to the specified range within the last paragraph.
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)
Adds a wavy underline (typically used as a spell checker indicator) to the specified range within the last paragraph.
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)
Adds a paragraph containing an image. The image will be reduced in size as necessary to fit into the available area if 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)
Adds a paragraph containing a 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)
Adds an inline Node to the last paragraph.

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()
Adds a new paragraph (as if inserting a newline symbol into the text). This convenience method invokes nl(int) with a value of 1.
Returns:
this model instance

nl

public SimpleViewOnlyStyledModel nl(int count)
Adds 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)
Description copied from class: StyledTextModel
Returns the StyleAttributeMap 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:
getStyleAttributeMap in class StyledTextModel
Parameters:
r - the style resolver
pos - the text position
Returns:
the style attributes, non-null

setParagraphAttributes

public SimpleViewOnlyStyledModel setParagraphAttributes(StyleAttributeMap a)
Sets the last paragraph's attributes.
Parameters:
a - the paragraph attributes
Returns:
this model instance

Report a bug or suggest an enhancement
Copyright © 2008, 2025, Oracle and/or its affiliates. All rights reserved.

© 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.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API