Top Description Fields Constructors Methods
org.fxmisc.richtext.model

public final Class ReadOnlyStyledDocumentBuilder<PS, SEG, S>

extends Object
Class Inheritance
Type Parameters
<PS>
the paragraph style type
<SEG>
the segment type
<S>
the segment style type
Imports
org.reactfx.util.Tuple2, java.util.ArrayList, .List, java.util.function.Consumer, .Function

Helper class via constructDocument(SegmentOps, Object, Consumer) or one of its constructors and build() for easily creating a ReadOnlyStyledDocument from a list of Paragraphs that is constructed via "addParagraph(s)" methods.

Field Summary

Modifier and TypeField and Description
private boolean
private final PS
private final List<Paragraph<PS, SEG, S>>
private final SegmentOps<SEG, S>

Constructor Summary

AccessConstructor and Description
public
ReadOnlyStyledDocumentBuilder(SegmentOps<SEG, S>
the SegmentOps to use for each call to one of the Paragraph's constructors.
segmentOps
,
PS
the default paragraph style to use when one is not specified in the "addParagraph"-prefixed methods
defaultParagraphStyle
)

Creates a builder

public
ReadOnlyStyledDocumentBuilder(SegmentOps<SEG, S>
the SegmentOps to use for each call to one of the Paragraph's constructors.
segmentOps
,
PS
the default paragraph style to use when one is not specified in the "addParagraph"-prefixed methods
defaultParagraphStyle
,
int
the initial capacity of the underlying ArrayList.
initialCapacity
)

Creates a builder

private
ReadOnlyStyledDocumentBuilder(SegmentOps<SEG, S> segmentOps, PS defaultParagraphStyle, List<Paragraph<PS, SEG, S>> list)

Method Summary

Modifier and TypeMethod and Description
private ReadOnlyStyledDocumentBuilder<PS, SEG, S>
addPar(Paragraph<PS, SEG, S> paragraph)

public ReadOnlyStyledDocumentBuilder<PS, SEG, S>
addParagraph(List<StyledSegment<SEG, S>> styledSegments)

Adds to the list a paragraph that is constructed using the list of StyledSegments.

public ReadOnlyStyledDocumentBuilder<PS, SEG, S>
addParagraph(List<StyledSegment<SEG, S>> styledSegments, PS paragraphStyle)

Adds to the list a paragraph that is constructed using the list of StyledSegments.

public ReadOnlyStyledDocumentBuilder<PS, SEG, S>
addParagraph(SEG segment, S style)

Adds to the list a paragraph that has only one segment that has the same given style throughout.

public ReadOnlyStyledDocumentBuilder<PS, SEG, S>
addParagraph(SEG segment, S style, PS paragraphStyle)

Adds to the list a paragraph that has only one segment that has the same given style throughout.

public ReadOnlyStyledDocumentBuilder<PS, SEG, S>
addParagraph(SEG segment, StyleSpans<S> styles)

Adds to the list a paragraph that has only one segment but a number of different styles throughout that segment

public ReadOnlyStyledDocumentBuilder<PS, SEG, S>
addParagraph(SEG segment, StyleSpans<S> styles, PS paragraphStyle)

Adds to the list a paragraph that has only one segment but a number of different styles throughout that segment

public ReadOnlyStyledDocumentBuilder<PS, SEG, S>
addParagraph(List<SEG> segments, StyleSpans<S> styles)

Adds to the list a paragraph that has multiple segments with multiple styles throughout those segments

public ReadOnlyStyledDocumentBuilder<PS, SEG, S>
addParagraph(List<SEG> segments, StyleSpans<S> styles, PS paragraphStyle)

Adds to the list a paragraph that has multiple segments with multiple styles throughout those segments

private <T> ReadOnlyStyledDocumentBuilder<PS, SEG, S>
addParagraphList(List<T> paragraphContentList, StyleSpans<S> spansThroughoutDocument, Function<T, PS> getStyle, Function<T, List<SEG>> getSegList)

public ReadOnlyStyledDocumentBuilder<PS, SEG, S>
addParagraphs(List<List<SEG>>
each item is the list of segments for a single paragraph
listOfSegLists
,
StyleSpans<S>
style spans for the entire document. It's length should be equal to the length of all the segments' length combined
entireDocumentStyleSpans
)

Adds multiple paragraphs to the list, using the defaultParagraphStyle for each paragraph.

public ReadOnlyStyledDocumentBuilder<PS, SEG, S>
addParagraphs0(List<Tuple2<PS, List<SEG>>>
each item is a Tuple2 that represents the paragraph style and segment list for a single paragraph. If the paragraph style is null, the defaultParagraphStyle will be used instead.
paragraphArgList
,
StyleSpans<S>
style spans for the entire document. It's length should be equal to the length of all the segments' length combined
entireDocumentStyleSpans
)

Adds multiple paragraphs to the list, allowing one to specify each paragraph's paragraph style.

private PS
argumentOrDefault(PS paragraphStyle)

Returns the argument if it is not null; otherwise, returns defaultParagraphStyle

public ReadOnlyStyledDocument<PS, SEG, S>
build()

Returns an unmodifiable list of the constructed Paragraphs and ensures this builder cannot be used again.

public static <PS, SEG, S> ReadOnlyStyledDocument<PS, SEG, S>
constructDocument(SegmentOps<SEG, S>
the SegmentOps object to use for one of the Paragraph's constructors
segmentOps
,
PS
the paragraph style object to use when it is not specified in the "addParagraph" methods
defaultParagraphStyle
,
Consumer<ReadOnlyStyledDocumentBuilder<PS, SEG, S>>
call the builder's addParagraph(Object, Object) methods here
configuration
)

Constructs a list of paragraphs

public static <PS, SEG, S> ReadOnlyStyledDocument<PS, SEG, S>
constructDocument(SegmentOps<SEG, S>
the SegmentOps object to use for one of the Paragraph's constructors
segmentOps
,
PS
the paragraph style object to use when it is not specified in the "addParagraph" methods
defaultParagraphStyle
,
int
the initial capaicty for the underlying ArrayList
initialCapacity
,
Consumer<ReadOnlyStyledDocumentBuilder<PS, SEG, S>>
call the builder's addParagraph(Object, Object) methods here
configuration
)

Constructs a list of paragraphs

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

alreadyCreatedback to summary
private boolean alreadyCreated
defaultParagraphStyleback to summary
private final PS defaultParagraphStyle
paragraphListback to summary
private final List<Paragraph<PS, SEG, S>> paragraphList
segmentOpsback to summary
private final SegmentOps<SEG, S> segmentOps

Constructor Detail

ReadOnlyStyledDocumentBuilderback to summary
public ReadOnlyStyledDocumentBuilder(SegmentOps<SEG, S> segmentOps, PS defaultParagraphStyle)

Creates a builder

Parameters
segmentOps:SegmentOps<SEG, S>

the SegmentOps to use for each call to one of the Paragraph's constructors.

defaultParagraphStyle:PS

the default paragraph style to use when one is not specified in the "addParagraph"-prefixed methods

ReadOnlyStyledDocumentBuilderback to summary
public ReadOnlyStyledDocumentBuilder(SegmentOps<SEG, S> segmentOps, PS defaultParagraphStyle, int initialCapacity)

Creates a builder

Parameters
segmentOps:SegmentOps<SEG, S>

the SegmentOps to use for each call to one of the Paragraph's constructors.

defaultParagraphStyle:PS

the default paragraph style to use when one is not specified in the "addParagraph"-prefixed methods

initialCapacity:int

the initial capacity of the underlying ArrayList.

ReadOnlyStyledDocumentBuilderback to summary
private ReadOnlyStyledDocumentBuilder(SegmentOps<SEG, S> segmentOps, PS defaultParagraphStyle, List<Paragraph<PS, SEG, S>> list)

Method Detail

addParback to summary
private ReadOnlyStyledDocumentBuilder<PS, SEG, S> addPar(Paragraph<PS, SEG, S> paragraph)
addParagraphback to summary
public ReadOnlyStyledDocumentBuilder<PS, SEG, S> addParagraph(List<StyledSegment<SEG, S>> styledSegments)

Adds to the list a paragraph that is constructed using the list of StyledSegments.

addParagraphback to summary
public ReadOnlyStyledDocumentBuilder<PS, SEG, S> addParagraph(List<StyledSegment<SEG, S>> styledSegments, PS paragraphStyle)

Adds to the list a paragraph that is constructed using the list of StyledSegments.

addParagraphback to summary
public ReadOnlyStyledDocumentBuilder<PS, SEG, S> addParagraph(SEG segment, S style)

Adds to the list a paragraph that has only one segment that has the same given style throughout.

addParagraphback to summary
public ReadOnlyStyledDocumentBuilder<PS, SEG, S> addParagraph(SEG segment, S style, PS paragraphStyle)

Adds to the list a paragraph that has only one segment that has the same given style throughout.

addParagraphback to summary
public ReadOnlyStyledDocumentBuilder<PS, SEG, S> addParagraph(SEG segment, StyleSpans<S> styles)

Adds to the list a paragraph that has only one segment but a number of different styles throughout that segment

addParagraphback to summary
public ReadOnlyStyledDocumentBuilder<PS, SEG, S> addParagraph(SEG segment, StyleSpans<S> styles, PS paragraphStyle)

Adds to the list a paragraph that has only one segment but a number of different styles throughout that segment

addParagraphback to summary
public ReadOnlyStyledDocumentBuilder<PS, SEG, S> addParagraph(List<SEG> segments, StyleSpans<S> styles)

Adds to the list a paragraph that has multiple segments with multiple styles throughout those segments

addParagraphback to summary
public ReadOnlyStyledDocumentBuilder<PS, SEG, S> addParagraph(List<SEG> segments, StyleSpans<S> styles, PS paragraphStyle)

Adds to the list a paragraph that has multiple segments with multiple styles throughout those segments

addParagraphListback to summary
private <T> ReadOnlyStyledDocumentBuilder<PS, SEG, S> addParagraphList(List<T> paragraphContentList, StyleSpans<S> spansThroughoutDocument, Function<T, PS> getStyle, Function<T, List<SEG>> getSegList)
addParagraphsback to summary
public ReadOnlyStyledDocumentBuilder<PS, SEG, S> addParagraphs(List<List<SEG>> listOfSegLists, StyleSpans<S> entireDocumentStyleSpans)

Adds multiple paragraphs to the list, using the defaultParagraphStyle for each paragraph. For more configuration on each paragraph's paragraph style, use addParagraphs0(List, StyleSpans)

Parameters
listOfSegLists:List<List<SEG>>

each item is the list of segments for a single paragraph

entireDocumentStyleSpans:StyleSpans<S>

style spans for the entire document. It's length should be equal to the length of all the segments' length combined

addParagraphs0back to summary
public ReadOnlyStyledDocumentBuilder<PS, SEG, S> addParagraphs0(List<Tuple2<PS, List<SEG>>> paragraphArgList, StyleSpans<S> entireDocumentStyleSpans)

Adds multiple paragraphs to the list, allowing one to specify each paragraph's paragraph style.

Parameters
paragraphArgList:List<Tuple2<PS, List<SEG>>>

each item is a Tuple2 that represents the paragraph style and segment list for a single paragraph. If the paragraph style is null, the defaultParagraphStyle will be used instead.

entireDocumentStyleSpans:StyleSpans<S>

style spans for the entire document. It's length should be equal to the length of all the segments' length combined

argumentOrDefaultback to summary
private PS argumentOrDefault(PS paragraphStyle)

Returns the argument if it is not null; otherwise, returns defaultParagraphStyle

buildback to summary
public ReadOnlyStyledDocument<PS, SEG, S> build()

Returns an unmodifiable list of the constructed Paragraphs and ensures this builder cannot be used again.

constructDocumentback to summary
public static <PS, SEG, S> ReadOnlyStyledDocument<PS, SEG, S> constructDocument(SegmentOps<SEG, S> segmentOps, PS defaultParagraphStyle, Consumer<ReadOnlyStyledDocumentBuilder<PS, SEG, S>> configuration)

Constructs a list of paragraphs

Parameters
segmentOps:SegmentOps<SEG, S>

the SegmentOps object to use for one of the Paragraph's constructors

defaultParagraphStyle:PS

the paragraph style object to use when it is not specified in the "addParagraph" methods

configuration:Consumer<ReadOnlyStyledDocumentBuilder<PS, SEG, S>>

call the builder's addParagraph(Object, Object) methods here

constructDocumentback to summary
public static <PS, SEG, S> ReadOnlyStyledDocument<PS, SEG, S> constructDocument(SegmentOps<SEG, S> segmentOps, PS defaultParagraphStyle, int initialCapacity, Consumer<ReadOnlyStyledDocumentBuilder<PS, SEG, S>> configuration)

Constructs a list of paragraphs

Parameters
segmentOps:SegmentOps<SEG, S>

the SegmentOps object to use for one of the Paragraph's constructors

defaultParagraphStyle:PS

the paragraph style object to use when it is not specified in the "addParagraph" methods

initialCapacity:int

the initial capaicty for the underlying ArrayList

configuration:Consumer<ReadOnlyStyledDocumentBuilder<PS, SEG, S>>

call the builder's addParagraph(Object, Object) methods here

ensureNotYetCreatedback to summary
private void ensureNotYetCreated()