Skip to content

Allow easier construction of a ReadOnlyStyledDocument with content #646

@JordanMartinez

Description

@JordanMartinez

In tandem with #644, we should be able to easily construct a list of Paragraphs that can be passed into a ROSD. Something like...

ParagraphListBuilder<PS, SEG, S> builder = new ParagraphListBuilder<>(segmentOps, defaultParagraphStyle);
List<Paragraph<PS, SEG, S> list = builder
   // each add paragraph method is a wrapper around the `Paragraph` constructor
   // but ignores the segmentOps part since this should be the same object 
   // for the entire StyledDocument
   .addParagraph(SEG seg, S style)
   // to avoid passing in a paragraph style each time, we can ignore it
   // and use the default paragraph style
   .addParagraph(List<SEG> segs, StyleSpans<S> spans)
   // in cases where it's desired, it can still be added
   .addParagraph(overridingParagraphStyle, List<StyledSegmetn<SEG, S>> list)

   // when finished, we can create it
   // only one builder can be used per list
   .build();

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions