code: public static <PS, SEG, S> ReadOnlyStyledDocument<PS, SEG, S> from(StyledDocument<PS, SEG, S> doc) {
          if(doc instanceof ReadOnlyStyledDocument) {
              return (ReadOnlyStyledDocument<PS, SEG, S>) doc;
          } else {
              return new ReadOnlyStyledDocument<>(doc.getParagraphs());
          }
      }
docs: Creates a {@link ReadOnlyStyledDocument} from the given {@link StyledDocument}.
  
  @param <PS> The type of the paragraph style.
  @param <SEG> The type of the segments in the paragraph (e.g. {@link String}).
  @param <S> The type of the style of individual segments.