Class Paragraph

  • All Implemented Interfaces:
    ContentLogger, Serializable

    public class Paragraph
    extends Sequence

    This content is rendered as a paragraph. A subsequent content will begin after a line break and (depending on the renderer) after some vertical distance. A ParagraphContent serves as a container for several InlineContents or NewlineContents.

    Usage example:

            Sequence sq= new Sequence();
      Paragraph para= new Paragraph(Inline.format(includeSpec, 
                 "Expected return value from '%s': %f. Observed: %f.", avgMethodName, expected, observed)));
      para.formatInlineItem(includeSpec, FontWeightAndStyle.smaller(), " Here comes some debug information ...");
      sq.addItem(para);
    
    See Also:
    Serialized Form
    • Constructor Detail

      • Paragraph

        public Paragraph()
        Create an empty paragraph.
      • Paragraph

        public Paragraph​(IncludeSpec includeSpec,
                         String firstInlineData)
        Create a paragraph with a first inline content with normal font style.
        Parameters:
        includeSpec - the include spec of the first inline content
        firstInlineData - the text of the first inline content
      • Paragraph

        public Paragraph​(IncludeSpec includeSpec,
                         String firstInlineData,
                         FontWeightAndStyle fwas)
        Create a paragraph with a first inline content with given font style.
        Parameters:
        includeSpec - the include Spec of the first inline content
        firstInlineData - the text of the first inline content
        fwas - the font of the first inline content
      • Paragraph

        public Paragraph​(Inline firstInline)
        Create a paragraph with a first inline content.
        Parameters:
        firstInline - the first inline content
    • Method Detail

      • addItem

        public void addItem​(Content content)
        Adds an inline content or a line break to the paragraph. If the item is globally excluded (see AbstractSequenceContent#excludeGlobally(Content), then the item is not added and ignored.
        Specified by:
        addItem in interface ContentLogger
        Overrides:
        addItem in class Sequence
        Parameters:
        content - content to be added. This must be an instance of Inline or Newline. Otherwise an exception is thrown.
        Throws:
        IllegalArgumentException - if the parameter is not an instance of Inline or Newline
      • newLine

        public void newLine​(IncludeSpec includeSpec)
        Add a line break.
        Parameters:
        includeSpec - the include spec for the line break
      • toString

        public String toString​(String prefix)
        Description copied from class: Content
        This method is for debugging purposes.
        Overrides:
        toString in class Content
        Parameters:
        prefix - If the output has multiple lines, prefix specifies the indentation of the subsequent lines.
        Returns:
        a string representation of the content and it's internal structure.
        See Also:
        Content.toString(java.lang.String)
      • renderHtmlImpl

        public void renderHtmlImpl​(StringBuilder sb,
                                   IncludeInfo includeInfo,
                                   RenderContext ctx,
                                   boolean useJavascript)
        Description copied from class: Sequence
        appends all comments in the sequence one after the other without any visual marks between the individual items.
        Overrides:
        renderHtmlImpl in class Sequence
        Parameters:
        sb - HTML code result
        includeInfo - controls, which content to be rendered.
        ctx - render context
        useJavascript - if true, the generated HTML code will contain Javascript
        See Also:
        Content#renderHtmlImpl(StringBuilder, IncludeInfo, RenderContext)