Top Description Inners Constructors Methods
jfx.incubator.scene.control.richtext.model

public abstract Class RichParagraph

extends Object
Class Inheritance
Imports
java.io.IOException, java.util.ArrayList, .List, .Objects, java.util.function.Consumer, .Supplier, javafx.scene.Node, javafx.scene.layout.Region, javafx.scene.paint.Color, com.sun.jfx.incubator.scene.control.richtext.RichParagraphHelper, .TextCell, jfx.incubator.scene.control.richtext.StyleResolver

Represents a single immutable paragraph within the StyledModel. A single paragraph may contain either:
Since
24

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
RichParagraph.Builder

Utility class for building immutable RichParagraphs.

Constructor Summary

AccessConstructor and Description
public
RichParagraph()

The constructor.

Method Summary

Modifier and TypeMethod and Description
public static RichParagraph.Builder

Returns:

the new Builder instance
builder
()

Creates an instance of the Builder class.

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

pack-priv List<Consumer<TextCell>>
public StyleAttributeMap

Returns:

the paragraph attributes, can be null
getParagraphAttributes
()

Returns the paragraph attributes.

public Supplier<Region>

Returns:

the generator, or null
getParagraphRegion
()

Returns the generator for this paragraph Region representation.

public abstract String

Returns:

the plain text
getPlainText
()

Returns the plain text of this paragraph, or null.

pack-priv abstract List<StyledSegment>
pack-priv StyleAttributeMap
getStyleAttributeMap(StyleResolver resolver, int offset)

private static void
public static RichParagraph

Returns:

the RichParagraph instance
of
(Supplier<Region>
the content generator
paragraphGenerator
)

Creates a paragraph consisting of a single Rectangle.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

RichParagraphback to summary
public RichParagraph()

The constructor.

Method Detail

builderback to summary
public static RichParagraph.Builder builder()

Creates an instance of the Builder class.

Returns:RichParagraph.Builder

the new Builder instance

exportback to summary
pack-priv void export(int start, int end, StyledOutput out) throws IOException
getHighlightsback to summary
pack-priv List<Consumer<TextCell>> getHighlights()
getParagraphAttributesback to summary
public StyleAttributeMap getParagraphAttributes()

Returns the paragraph attributes.

Returns:StyleAttributeMap

the paragraph attributes, can be null

getParagraphRegionback to summary
public Supplier<Region> getParagraphRegion()

Returns the generator for this paragraph Region representation. This method returns a non-null value when the paragraph is represented by a single Region.

Returns:Supplier<Region>

the generator, or null

getPlainTextback to summary
public abstract String getPlainText()

Returns the plain text of this paragraph, or null.

Returns:String

the plain text

getSegmentsback to summary
pack-priv abstract List<StyledSegment> getSegments()
getStyleAttributeMapback to summary
pack-priv StyleAttributeMap getStyleAttributeMap(StyleResolver resolver, int offset)
initAccessorback to summary
private static void initAccessor()
ofback to summary
public static RichParagraph of(Supplier<Region> paragraphGenerator)

Creates a paragraph consisting of a single Rectangle. The paragraph will typically assume its Rectangle preferred size, or, when the text wrap mode is on, might get resized to fit the available width.

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
paragraphGenerator:Supplier<Region>

the content generator

Returns:RichParagraph

the RichParagraph instance

jfx.incubator.scene.control.richtext.model back to summary

public Class RichParagraph.Builder

extends Object
Class Inheritance
  • java.lang.Object
  • jfx.incubator.scene.control.richtext.model.RichParagraph.Builder

Utility class for building immutable RichParagraphs.

Field Summary

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

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public RichParagraph.Builder

Returns:

this Builder instance
addHighlight
(int
the start offset
start
,
int
the end offset
length
,
Color
the background color
color
)

Adds a color background highlight.

public RichParagraph.Builder

Returns:

this Builder instance
addHighlight
(int
the start offset
start
,
int
the end offset
length
,
String...
the style name(s)
css
)

Adds a highlight with the specified style name(s).

public RichParagraph.Builder

Returns:

this Builder instance
addInlineNode
(Supplier<Node>
the generator that provides the actual Node
generator
)

Adds an inline node.

public RichParagraph.Builder

Returns:

this Builder instance
addSegment
(String
the text to append, must not contain \n, cannot be null
text
)

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

public RichParagraph.Builder

Returns:

this Builder instance
addSegment
(String
the text to append, must not contain \n, cannot be null
text
,
StyleAttributeMap
the styled attributes, cannot be null
attrs
)

Adds a styled text segment.

public RichParagraph.Builder

Returns:

this Builder instance
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.

public RichParagraph.Builder

Returns:

this Builder instance
addWavyUnderline
(int
the start offset
start
,
int
the end offset
length
,
Color
the background color
color
)

Adds a wavy underline (typically used as a spell checker indicator) with the given color.

public RichParagraph.Builder

Returns:

this Builder instance
addWavyUnderline
(int
the start offset
start
,
int
the end offset
length
,
String...
the style name(s)
css
)

Adds a wavy underline (typically used as a spell checker indicator) with the specified style name(s).

public RichParagraph.Builder

Returns:

this Builder instance
addWithInlineAndStyleNames
(String
non-null text string
text
,
String
direct style (such as -fx-fill:red;), or null
style
,
String...
array of style names
css
)

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

public RichParagraph.Builder

Returns:

this Builder instance
addWithInlineStyle
(String
non-null text string
text
,
String
the inline style (example "-fx-fill:red;"), or null
style
)

Appends a text segment styled with the stylesheet style names.

public RichParagraph.Builder

Returns:

this Builder instance
addWithStyleNames
(String
non-null text string
text
,
String...
array of style names, cannot be null
css
)

Appends a text segment styled with the stylesheet style names.

public RichParagraph

Returns:

the new paragraph instance
build
()

Creates an instance of immutable RichParagraph from information in this Builder.

private List<Consumer<TextCell>>
private List<StyledSegment>
public RichParagraph.Builder

Returns:

this Builder instance
setParagraphAttributes
(StyleAttributeMap
the paragraph attributes
a
)

Sets the paragraph attributes.

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

Builderback to summary
pack-priv Builder()

Method Detail

addHighlightback to summary
public RichParagraph.Builder 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

Returns:RichParagraph.Builder

this Builder instance

addHighlightback to summary
public RichParagraph.Builder addHighlight(int start, int length, String... css)

Adds a highlight with the specified style name(s). Use translucent colors to enable multiple highlights in the same region of text.

The corresponding styles should define CSS properties applicable to javafx.scene.shape.Path.

Parameters
start:int

the start offset

length:int

the end offset

css:String[]

the style name(s)

Returns:RichParagraph.Builder

this Builder instance

Since
25
addInlineNodeback to summary
public RichParagraph.Builder 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

Returns:RichParagraph.Builder

this Builder instance

addSegmentback to summary
public RichParagraph.Builder addSegment(String text)

Adds a text segment with no styling (i.e. using default style). This convenience method is equivalent to calling addSegment(text, StyleAttributeMap.EMPTY);

Parameters
text:String

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

Returns:RichParagraph.Builder

this Builder instance

addSegmentback to summary
public RichParagraph.Builder addSegment(String text, StyleAttributeMap attrs)

Adds a styled text segment.

Parameters
text:String

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

attrs:StyleAttributeMap

the styled attributes, cannot be null

Returns:RichParagraph.Builder

this Builder instance

addSegmentback to summary
public RichParagraph.Builder 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

Returns:RichParagraph.Builder

this Builder instance

addWavyUnderlineback to summary
public RichParagraph.Builder addWavyUnderline(int start, int length, Color color)

Adds a wavy underline (typically used as a spell checker indicator) with the given color.

Parameters
start:int

the start offset

length:int

the end offset

color:Color

the background color

Returns:RichParagraph.Builder

this Builder instance

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

Adds a wavy underline (typically used as a spell checker indicator) with the specified style name(s).

The corresponding styles should define CSS properties applicable to javafx.scene.shape.Path.

Parameters
start:int

the start offset

length:int

the end offset

css:String[]

the style name(s)

Returns:RichParagraph.Builder

this Builder instance

Since
25
addWithInlineAndStyleNamesback to summary
public RichParagraph.Builder addWithInlineAndStyleNames(String text, String style, String... css)

Appends a text segment styled with both the inline style and the stylesheet style names. The corresponding styles should define CSS properties applicable to javafx.scene.text.Text.

Parameters
text:String

non-null text string

style:String

direct style (such as -fx-fill:red;), or null

css:String[]

array of style names

Returns:RichParagraph.Builder

this Builder instance

addWithInlineStyleback to summary
public RichParagraph.Builder addWithInlineStyle(String text, String style)

Appends a text segment styled with the stylesheet style names. The corresponding styles should define CSS properties applicable to javafx.scene.text.Text.

Parameters
text:String

non-null text string

style:String

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

Returns:RichParagraph.Builder

this Builder instance

addWithStyleNamesback to summary
public RichParagraph.Builder addWithStyleNames(String text, String... css)

Appends a text segment styled with the stylesheet style names. The corresponding styles should define CSS properties applicable to javafx.scene.text.Text.

Parameters
text:String

non-null text string

css:String[]

array of style names, cannot be null

Returns:RichParagraph.Builder

this Builder instance

buildback to summary
public RichParagraph build()

Creates an instance of immutable RichParagraph from information in this Builder.

Returns:RichParagraph

the new paragraph instance

highlightsback to summary
private List<Consumer<TextCell>> highlights()
segmentsback to summary
private List<StyledSegment> segments()
setParagraphAttributesback to summary
public RichParagraph.Builder setParagraphAttributes(StyleAttributeMap a)

Sets the paragraph attributes.

Parameters
a:StyleAttributeMap

the paragraph attributes

Returns:RichParagraph.Builder

this Builder instance