Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow easier construction of a ReadOnlyStyledDocument with content #646

Closed
JordanMartinez opened this issue Nov 17, 2017 · 1 comment
Closed

Comments

@JordanMartinez
Copy link
Contributor

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();
@JordanMartinez
Copy link
Contributor Author

On second though, it would be better if the paragraph list builder itself just created a ReadOnlyStyledDocument, since that's how it will be used anyways. I don't think there would be any value in creating such a list if it wasn't used for that end. Even if one did, one could use the built ROSD's getParagraphs() to accomplish the same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant