Package org.fxmisc.richtext.model
Class ReadOnlyStyledDocumentBuilder<PS,SEG,S>
- java.lang.Object
-
- org.fxmisc.richtext.model.ReadOnlyStyledDocumentBuilder<PS,SEG,S>
-
- Type Parameters:
PS- the paragraph style typeSEG- the segment typeS- the segment style type
public final class ReadOnlyStyledDocumentBuilder<PS,SEG,S> extends Object
Helper class viaconstructDocument(SegmentOps, Object, Consumer)or one of its constructors andbuild()for easily creating aReadOnlyStyledDocumentfrom a list ofParagraphs that is constructed via "addParagraph(s)" methods.
-
-
Constructor Summary
Constructors Constructor Description ReadOnlyStyledDocumentBuilder(SegmentOps<SEG,S> segmentOps, PS defaultParagraphStyle)Creates a builderReadOnlyStyledDocumentBuilder(SegmentOps<SEG,S> segmentOps, PS defaultParagraphStyle, int initialCapacity)Creates a builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ReadOnlyStyledDocumentBuilder<PS,SEG,S>addParagraph(List<StyledSegment<SEG,S>> styledSegments)Adds to the list a paragraph that is constructed using the list ofStyledSegments.ReadOnlyStyledDocumentBuilder<PS,SEG,S>addParagraph(List<StyledSegment<SEG,S>> styledSegments, PS paragraphStyle)Adds to the list a paragraph that is constructed using the list ofStyledSegments.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 segmentsReadOnlyStyledDocumentBuilder<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 segmentsReadOnlyStyledDocumentBuilder<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 segmentReadOnlyStyledDocumentBuilder<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 segmentReadOnlyStyledDocumentBuilder<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.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.ReadOnlyStyledDocumentBuilder<PS,SEG,S>addParagraphs(List<List<SEG>> listOfSegLists, StyleSpans<S> entireDocumentStyleSpans)Adds multiple paragraphs to the list, using thedefaultParagraphStylefor each paragraph.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.ReadOnlyStyledDocument<PS,SEG,S>build()Returns an unmodifiable list of the constructedParagraphs and ensures this builder cannot be used again.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 paragraphsstatic <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
-
-
-
Constructor Detail
-
ReadOnlyStyledDocumentBuilder
public ReadOnlyStyledDocumentBuilder(SegmentOps<SEG,S> segmentOps, PS defaultParagraphStyle)
Creates a builder- Parameters:
segmentOps- theSegmentOpsto use for each call to one of theParagraph's constructors.defaultParagraphStyle- the default paragraph style to use when one is not specified in the "addParagraph"-prefixed methods
-
ReadOnlyStyledDocumentBuilder
public ReadOnlyStyledDocumentBuilder(SegmentOps<SEG,S> segmentOps, PS defaultParagraphStyle, int initialCapacity)
Creates a builder- Parameters:
segmentOps- theSegmentOpsto use for each call to one of theParagraph's constructors.defaultParagraphStyle- the default paragraph style to use when one is not specified in the "addParagraph"-prefixed methodsinitialCapacity- the initial capacity of the underlyingArrayList.
-
-
Method Detail
-
constructDocument
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- theSegmentOpsobject to use for one of theParagraph's constructorsdefaultParagraphStyle- the paragraph style object to use when it is not specified in the "addParagraph" methodsconfiguration- call the builder'saddParagraph(Object, Object)methods here
-
constructDocument
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- theSegmentOpsobject to use for one of theParagraph's constructorsdefaultParagraphStyle- the paragraph style object to use when it is not specified in the "addParagraph" methodsinitialCapacity- the initial capaicty for the underlyingArrayListconfiguration- call the builder'saddParagraph(Object, Object)methods here
-
addParagraph
public ReadOnlyStyledDocumentBuilder<PS,SEG,S> addParagraph(List<StyledSegment<SEG,S>> styledSegments)
Adds to the list a paragraph that is constructed using the list ofStyledSegments.
-
addParagraph
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 ofStyledSegments.
-
addParagraph
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.
-
addParagraph
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.
-
addParagraph
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
-
addParagraph
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
-
addParagraph
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
-
addParagraph
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
-
addParagraphs
public ReadOnlyStyledDocumentBuilder<PS,SEG,S> addParagraphs(List<List<SEG>> listOfSegLists, StyleSpans<S> entireDocumentStyleSpans)
Adds multiple paragraphs to the list, using thedefaultParagraphStylefor each paragraph. For more configuration on each paragraph's paragraph style, useaddParagraphs0(List, StyleSpans)- Parameters:
listOfSegLists- each item is the list of segments for a single paragraphentireDocumentStyleSpans- style spans for the entire document. It's length should be equal to the length of all the segments' length combined
-
addParagraphs0
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- each item is a Tuple2 that represents the paragraph style and segment list for a single paragraph. If the paragraph style isnull, thedefaultParagraphStylewill be used instead.entireDocumentStyleSpans- style spans for the entire document. It's length should be equal to the length of all the segments' length combined
-
build
public ReadOnlyStyledDocument<PS,SEG,S> build()
Returns an unmodifiable list of the constructedParagraphs and ensures this builder cannot be used again.
-
-