APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jfx.incubator.scene.control.richtext.model

public Class SimpleViewOnlyStyledModel

extends StyledTextModelViewOnlyBase
Class Inheritance
Imports
java.io.BufferedReader, .IOException, .InputStream, .StringReader, java.util.ArrayList, .List, .Objects, java.util.function.Consumer, .Supplier, javafx.scene.Node, javafx.scene.image.Image, javafx.scene.layout.Region, javafx.scene.paint.Color, com.sun.jfx.incubator.scene.control.richtext.ImageCellPane, .TextCell, jfx.incubator.scene.control.richtext.StyleResolver, .TextPos

A simple, view-only, in-memory, styled text model.
Since
24

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
SimpleViewOnlyStyledModel.Paragraph

Encapsulates a paragraph

Field Summary

Modifier and TypeField and Description
private final ArrayList<SimpleViewOnlyStyledModel.Paragraph>

Constructor Summary

AccessConstructor and Description
public
SimpleViewOnlyStyledModel()

The constructor.

Method Summary

Modifier and TypeMethod and Description
public SimpleViewOnlyStyledModel

Returns:

this model instance
addImage
(InputStream
the input stream providing the image.
in
)

Adds a paragraph containing an image.

public SimpleViewOnlyStyledModel

Returns:

this model instance
addNodeSegment
(Supplier<Node>
the supplier of the embedded Node
generator
)

Adds an inline Node to the last paragraph.

public SimpleViewOnlyStyledModel

Returns:

this model instance
addParagraph
(Supplier<Region>
the supplier of the paragraph content
generator
)

Adds a paragraph containing a Region.

public SimpleViewOnlyStyledModel

Returns:

this model instance
addSegment
(String
the text to append, must not contain newline symbols, cannot be null
text
)

Appends a text segment to the last paragraph.

public SimpleViewOnlyStyledModel

Returns:

this model instance
addSegment
(String
the text to append, must not contain control symbols other than TAB.
text
,
StyleAttributeMap
the style attributes
a
)

Appends a text segment styled with the specified style attributes.

public SimpleViewOnlyStyledModel

Returns:

this model instance
addWavyUnderline
(int
the start offset
start
,
int
the length of the highlight
length
,
Color
the highlight color
c
)

Adds a wavy underline (typically used as a spell checker indicator) to the specified range within the last paragraph.

public SimpleViewOnlyStyledModel

Returns:

this model instance
addWavyUnderline
(int
the start offset
start
,
int
the length of the highlight
length
,
String...
the highlight style name(s)
css
)

Adds a wavy underline (typically used as a spell checker indicator) to the specified range within the last paragraph, with the specified style name(s).

public SimpleViewOnlyStyledModel

Returns:

this model instance
addWithInlineAndStyleNames
(String
the text to append, must not contain \n, cannot be null
text
,
String
the inline style (example "-fx-fill:red;")
style
,
String...
the stylesheet style names
css
)

Appends a text segment styled with both the inline style and the stylesheet style names.

public SimpleViewOnlyStyledModel

Returns:

this model instance
addWithInlineStyle
(String
the text to append, must not contain \n, cannot be null
text
,
String
the inline style (example "-fx-fill:red;"), or null
style
)

Appends a text segment styled with the inline style.

public SimpleViewOnlyStyledModel

Returns:

this model instance
addWithStyleNames
(String
the text to append, must not contain \n, cannot be null
text
,
String...
the stylesheet style names
css
)

Appends a text segment styled with the stylesheet style names.

public RichParagraph
getParagraph(int index)

Implements abstract jfx.incubator.scene.control.richtext.model.StyledTextModel.getParagraph.

Returns a RichParagraph at the given model index.

public String
getPlainText(int index)

Implements abstract jfx.incubator.scene.control.richtext.model.StyledTextModel.getPlainText.

Returns the plain text string for the specified paragraph.

public StyleAttributeMap
getStyleAttributeMap(StyleResolver r, TextPos pos, boolean forInsert)

Implements abstract jfx.incubator.scene.control.richtext.model.StyledTextModel.getStyleAttributeMap.

Returns the StyleAttributeMap of the character at the specified position's charIndex.

public SimpleViewOnlyStyledModel

Returns:

this model instance
highlight
(int
the start offset
start
,
int
the length of the highlight
length
,
Color
the highlight color
c
)

Adds a highlight of the given color to the specified range within the last paragraph.

public SimpleViewOnlyStyledModel

Returns:

this model instance
highlight
(int
the start offset
start
,
int
the length of the highlight
length
,
String...
the highlight style name(s)
css
)

Adds a highlight of the given color to the specified range within the last paragraph, with the specified style name(s).

public SimpleViewOnlyStyledModel

Returns:

this model instance
nl
()

Adds a new paragraph (as if inserting a newline symbol into the text).

public SimpleViewOnlyStyledModel

Returns:

this model instance
nl
(int
the number of paragraphs to append
count
)

Adds n new paragraphs (as if inserting a newline symbol into the text n times).

public static SimpleViewOnlyStyledModel

Returns:

the new instance
of
(String
the input multi-line text
text
)

Creates the model from the supplied text string by breaking it down into individual text segments, by splitting on newline characters.

public SimpleViewOnlyStyledModel

Returns:

this model instance
setParagraphAttributes
(StyleAttributeMap
the paragraph attributes
a
)

Sets the last paragraph's attributes.

public int
size()

Implements abstract jfx.incubator.scene.control.richtext.model.StyledTextModel.size.

Returns the number of paragraphs in the model.

private SimpleViewOnlyStyledModel.Paragraph
Inherited from jfx.incubator.scene.control.richtext.model.StyledTextModelViewOnlyBase:
applyParagraphStyleapplyStyleinsertLineBreakinsertParagraphinsertTextSegmentisWritableremoveRangesetParagraphStyle

Field Detail

paragraphsback to summary
private final ArrayList<SimpleViewOnlyStyledModel.Paragraph> paragraphs

Constructor Detail

SimpleViewOnlyStyledModelback to summary
public SimpleViewOnlyStyledModel()

The constructor.

Method Detail

addImageback to summary
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:InputStream

the input stream providing the image.

Returns:SimpleViewOnlyStyledModel

this model instance

addNodeSegmentback to summary
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:Supplier<Node>

the supplier of the embedded Node

Returns:SimpleViewOnlyStyledModel

this model instance

addParagraphback to summary
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:Supplier<Region>

the supplier of the paragraph content

Returns:SimpleViewOnlyStyledModel

this model instance

addSegmentback to summary
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:String

the text to append, must not contain newline symbols, cannot be null

Returns:SimpleViewOnlyStyledModel

this model instance

addSegmentback to summary
public SimpleViewOnlyStyledModel addSegment(String text, StyleAttributeMap a)

Appends a text segment styled with the specified style attributes.

Parameters
text:String

the text to append, must not contain control symbols other than TAB.

a:StyleAttributeMap

the style attributes

Returns:SimpleViewOnlyStyledModel

this model instance

addWavyUnderlineback to summary
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:int

the start offset

length:int

the length of the highlight

c:Color

the highlight color

Returns:SimpleViewOnlyStyledModel

this model instance

addWavyUnderlineback to summary
public SimpleViewOnlyStyledModel addWavyUnderline(int start, int length, String... css)

Adds a wavy underline (typically used as a spell checker indicator) to the specified range within the last paragraph, with the specified style name(s).

Parameters
start:int

the start offset

length:int

the length of the highlight

css:String[]

the highlight style name(s)

Returns:SimpleViewOnlyStyledModel

this model instance

Since
25
addWithInlineAndStyleNamesback to summary
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:String

the text to append, must not contain \n, cannot be null

style:String

the inline style (example "-fx-fill:red;")

css:String[]

the stylesheet style names

Returns:SimpleViewOnlyStyledModel

this model instance

addWithInlineStyleback to summary
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:String

the text to append, must not contain \n, cannot be null

style:String

the inline style (example "-fx-fill:red;"), or null

Returns:SimpleViewOnlyStyledModel

this model instance

addWithStyleNamesback to summary
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:String

the text to append, must not contain \n, cannot be null

css:String[]

the stylesheet style names

Returns:SimpleViewOnlyStyledModel

this model instance

getParagraphback to summary
public RichParagraph getParagraph(int index)

Implements abstract jfx.incubator.scene.control.richtext.model.StyledTextModel.getParagraph.

Doc from jfx.incubator.scene.control.richtext.model.StyledTextModel.getParagraph.

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.

Annotations
@Override
getPlainTextback to summary
public String getPlainText(int index)

Implements abstract jfx.incubator.scene.control.richtext.model.StyledTextModel.getPlainText.

Doc from jfx.incubator.scene.control.richtext.model.StyledTextModel.getPlainText.

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.

Annotations
@Override
getStyleAttributeMapback to summary
public StyleAttributeMap getStyleAttributeMap(StyleResolver r, TextPos pos, boolean forInsert)

Implements abstract jfx.incubator.scene.control.richtext.model.StyledTextModel.getStyleAttributeMap.

Doc from jfx.incubator.scene.control.richtext.model.StyledTextModel.getStyleAttributeMap.

Returns the StyleAttributeMap of the character at the specified position's charIndex.

When the position points to the boundary between two text segments with different attributes, the value of forInsert determines which segment will be used: when true, the preceding segment's attributes will be returned so inserted/typed text has the same style as the preceding text. When forInsert is false, the returned attributes correspond exactly to the symbol indicated by the specified position.

Annotations
@Override
highlightback to summary
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:int

the start offset

length:int

the length of the highlight

c:Color

the highlight color

Returns:SimpleViewOnlyStyledModel

this model instance

highlightback to summary
public SimpleViewOnlyStyledModel highlight(int start, int length, String... css)

Adds a highlight of the given color to the specified range within the last paragraph, with the specified style name(s).

Parameters
start:int

the start offset

length:int

the length of the highlight

css:String[]

the highlight style name(s)

Returns:SimpleViewOnlyStyledModel

this model instance

Since
25
nlback to summary
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:SimpleViewOnlyStyledModel

this model instance

nlback to summary
public SimpleViewOnlyStyledModel nl(int count)

Adds n new paragraphs (as if inserting a newline symbol into the text n times).

Parameters
count:int

the number of paragraphs to append

Returns:SimpleViewOnlyStyledModel

this model instance

ofback to summary
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:String

the input multi-line text

Returns:SimpleViewOnlyStyledModel

the new instance

Exceptions
IOException:
if an I/O error occurs
setParagraphAttributesback to summary
public SimpleViewOnlyStyledModel setParagraphAttributes(StyleAttributeMap a)

Sets the last paragraph's attributes.

Parameters
a:StyleAttributeMap

the paragraph attributes

Returns:SimpleViewOnlyStyledModel

this model instance

sizeback to summary
public int size()

Implements abstract jfx.incubator.scene.control.richtext.model.StyledTextModel.size.

Doc from jfx.incubator.scene.control.richtext.model.StyledTextModel.size.

Returns the number of paragraphs in the model.

Annotations
@Override
textParagraphback to summary
private SimpleViewOnlyStyledModel.Paragraph textParagraph()
jfx.incubator.scene.control.richtext.model back to summary

private Class SimpleViewOnlyStyledModel.Paragraph

extends Object
Class Inheritance
  • java.lang.Object
  • jfx.incubator.scene.control.richtext.model.SimpleViewOnlyStyledModel.Paragraph

Encapsulates a paragraph

Field Summary

Modifier and TypeField and Description
private ArrayList<Consumer<TextCell>>
private StyleAttributeMap
private ArrayList<StyledSegment>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv void
addHighlight(int
the start offset
start
,
int
the end offset
length
,
Color
the background color
color
)

Adds a color background highlight.

pack-priv void
addHighlight(int start, int length, String[] css)

pack-priv void
addInlineNode(Supplier<Node>
the generator that provides the actual Node
generator
)

Adds an inline node.

pack-priv void
addSegment(String
segment text
text
)

Adds a text segment with no styling (i.e. using default style).

pack-priv void
addSegment(String
the non-null text string
text
,
StyleAttributeMap
the styled attributes
attrs
)

Adds a styled text segment.

pack-priv void
addSegment(String
the source non-null string
text
,
int
the start offset of the input string
start
,
int
the end offset of the input string
end
,
StyleAttributeMap
the styled attributes
attrs
)

Adds a styled text segment.

pack-priv void
addWavyUnderline(int
the start offset
start
,
int
the end offset
length
,
Color
the background color
color
)

Adds a wavy underline (as seen in a spell checker) with the given color.

pack-priv void
addWavyUnderline(int start, int length, String[] css)

pack-priv void
export(int start, int end, StyledOutput out)

public Supplier<Region>
pack-priv String
private List<StyledSegment>
pack-priv StyleAttributeMap
getStyleAttrs(StyleResolver r, int charIndex, boolean leading, boolean forInsert)

private List<Consumer<TextCell>>
public boolean
public static SimpleViewOnlyStyledModel.Paragraph
of(Supplier<Region> paragraphGenerator)

private List<StyledSegment>
pack-priv void
setParagraphAttributes(StyleAttributeMap
the paragraph attributes
a
)

Sets the paragraph attributes.

private int
size()

public RichParagraph
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

highlightsback to summary
private ArrayList<Consumer<TextCell>> highlights
paragraphAttributesback to summary
private StyleAttributeMap paragraphAttributes
segmentsback to summary
private ArrayList<StyledSegment> segments

Constructor Detail

Paragraphback to summary
public Paragraph()

Method Detail

addHighlightback to summary
pack-priv void addHighlight(int start, int length, Color color)

Adds a color background highlight. Use translucent colors to enable multiple highlights in the same region of text.

Parameters
start:int

the start offset

length:int

the end offset

color:Color

the background color

addHighlightback to summary
pack-priv void addHighlight(int start, int length, String[] css)
addInlineNodeback to summary
pack-priv void addInlineNode(Supplier<Node> generator)

Adds an inline node.

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 some 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:Supplier<Node>

the generator that provides the actual Node

addSegmentback to summary
pack-priv void addSegment(String text)

Adds a text segment with no styling (i.e. using default style).

Parameters
text:String

segment text

addSegmentback to summary
pack-priv void addSegment(String text, StyleAttributeMap attrs)

Adds a styled text segment.

Parameters
text:String

the non-null text string

attrs:StyleAttributeMap

the styled attributes

addSegmentback to summary
pack-priv void addSegment(String text, int start, int end, StyleAttributeMap attrs)

Adds a styled text segment.

Parameters
text:String

the source non-null string

start:int

the start offset of the input string

end:int

the end offset of the input string

attrs:StyleAttributeMap

the styled attributes

addWavyUnderlineback to summary
pack-priv void addWavyUnderline(int start, int length, Color color)

Adds a wavy underline (as seen in a spell checker) with the given color.

Parameters
start:int

the start offset

length:int

the end offset

color:Color

the background color

addWavyUnderlineback to summary
pack-priv void addWavyUnderline(int start, int length, String[] css)
exportback to summary
pack-priv void export(int start, int end, StyledOutput out) throws IOException
getParagraphRegionback to summary
public Supplier<Region> getParagraphRegion()
getPlainTextback to summary
pack-priv String getPlainText()
getSegmentsback to summary
private List<StyledSegment> getSegments()
getStyleAttrsback to summary
pack-priv StyleAttributeMap getStyleAttrs(StyleResolver r, int charIndex, boolean leading, boolean forInsert)
highlightsback to summary
private List<Consumer<TextCell>> highlights()
isTextParagraphback to summary
public boolean isTextParagraph()
ofback to summary
public static SimpleViewOnlyStyledModel.Paragraph of(Supplier<Region> paragraphGenerator)
segmentsback to summary
private List<StyledSegment> segments()
setParagraphAttributesback to summary
pack-priv void setParagraphAttributes(StyleAttributeMap a)

Sets the paragraph attributes.

Parameters
a:StyleAttributeMap

the paragraph attributes

sizeback to summary
private int size()
toRichParagraphback to summary
public RichParagraph toRichParagraph()