Class RichParagraph.Builder
java.lang.Object
jfx.incubator.scene.control.richtext.model.RichParagraph.Builder
- Enclosing class:
RichParagraph
Utility class for building immutable
RichParagraphs.- Since:
- 24
-
Method Summary
Modifier and TypeMethodDescriptionaddHighlight(int start, int length, String... css) Adds a highlight with the specified style name(s).addHighlight(int start, int length, Color color) Adds a color background highlight.addInlineNode(Supplier<Node> generator) Adds an inline node.addSegment(String text) Adds a text segment with no styling (i.e.addSegment(String text, int start, int end, StyleAttributeMap attrs) Adds a styled text segment.addSegment(String text, StyleAttributeMap attrs) Adds a styled text segment.addWavyUnderline(int start, int length, String... css) Adds a wavy underline (typically used as a spell checker indicator) with the specified style name(s).addWavyUnderline(int start, int length, Color color) Adds a wavy underline (typically used as a spell checker indicator) with the given color.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 stylesheet style names.addWithStyleNames(String text, String... css) Appends a text segment styled with the stylesheet style names.build()Creates an instance of immutableRichParagraphfrom information in thisBuilder.getSegment(int index) Returns the segment at the specified index.intReturns the number of segments currently added to the builder.Sets the paragraph attributes.
-
Method Details
-
addWavyUnderline
Adds a wavy underline (typically used as a spell checker indicator) with the given color.- Parameters:
start- the start offsetlength- the end offsetcolor- the background color- Returns:
- this
Builderinstance
-
addWavyUnderline
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
Path.- Parameters:
start- the start offsetlength- the end offsetcss- the style name(s)- Returns:
- this
Builderinstance - Since:
- 25
-
addSegment
Adds a text segment with no styling (i.e. using default style). This convenience method is equivalent to callingaddSegment(text, StyleAttributeMap.EMPTY);- Parameters:
text- the text to append, must not contain\n, cannot be null- Returns:
- this
Builderinstance
-
addWithStyleNames
Appends a text segment styled with the stylesheet style names. The corresponding styles should define CSS properties applicable toText.- Parameters:
text- non-null text stringcss- array of style names, cannot be null- Returns:
- this
Builderinstance
-
addWithInlineAndStyleNames
Appends a text segment styled with both the inline style and the stylesheet style names. The corresponding styles should define CSS properties applicable toText.- Parameters:
text- non-null text stringstyle- direct style (such as-fx-fill:red;), or nullcss- array of style names- Returns:
- this
Builderinstance
-
addWithInlineStyle
Appends a text segment styled with the stylesheet style names. The corresponding styles should define CSS properties applicable toText.- Parameters:
text- non-null text stringstyle- the inline style (example"-fx-fill:red;"), or null- Returns:
- this
Builderinstance
-
addSegment
Adds a styled text segment.- Parameters:
text- the text to append, must not contain\n, cannot be nullattrs- the styled attributes, cannot be null- Returns:
- this
Builderinstance
-
addSegment
Adds a styled text segment.- Parameters:
text- the source non-null stringstart- the start offset of the input stringend- the end offset of the input stringattrs- the styled attributes- Returns:
- this
Builderinstance
-
addHighlight
Adds a color background highlight. Use translucent colors to enable multiple highlights in the same region of text.- Parameters:
start- the start offsetlength- the end offsetcolor- the background color- Returns:
- this
Builderinstance
-
addHighlight
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
Path.- Parameters:
start- the start offsetlength- the end offsetcss- the style name(s)- Returns:
- this
Builderinstance - Since:
- 25
-
addInlineNode
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- the generator that provides the actualNode- Returns:
- this
Builderinstance
-
setParagraphAttributes
Sets the paragraph attributes.- Parameters:
a- the paragraph attributes- Returns:
- this
Builderinstance
-
getSegmentCount
public int getSegmentCount()Returns the number of segments currently added to the builder.- Returns:
- the number of segments
- Since:
- 26
-
getSegment
Returns the segment at the specified index.- Parameters:
index- the segment index- Returns:
- the segment
- Throws:
IndexOutOfBoundsException- if the index is outside of the range0 ... getSegmentCount()-1(inclusive)- Since:
- 26
-
build
Creates an instance of immutableRichParagraphfrom information in thisBuilder.- Returns:
- the new paragraph instance
-