Package reportWriter

Class ReportSection

java.lang.Object
reportWriter.ReportSection

public class ReportSection extends Object
A section in the report. This is the object that contains all of the information that will eventually go into the docx document. Each section can have any of the following:
  • A title
  • Any amount of text
  • A table (PamTable class)
  • A figure (BufferedImage class)
A Report is made up of multiple sections, each one after the other. See the ReportWriterTest class for an example of how to create a Report with multiple sections.
Author:
mo55
  • Constructor Details

    • ReportSection

      public ReportSection()
      Constructor with no section title
    • ReportSection

      public ReportSection(String sectionTitle)
      Constructor with section title at heading level 1
      Parameters:
      sectionTitle -
    • ReportSection

      public ReportSection(String sectionTitle, int headingLevel)
      Constructor with section title
      Parameters:
      sectionTitle -
      heading - level, e.g. 1, 2, 3 etc.
  • Method Details

    • getSectionTitle

      public String getSectionTitle()
      Returns:
      the section title
    • getHeadingLevel

      public int getHeadingLevel()
      Returns:
      The heading level (1, 2, 3, etc.)
    • setSectionTitle

      public void setSectionTitle(String sectionTitle)
      Parameters:
      sectionTitle - Section title to set
    • getSectionText

      public ArrayList<String> getSectionText()
      Returns:
      The section text
    • addSectionText

      public void addSectionText(String newText)
      Add text to the section. This will appear in the same paragraph.
      Parameters:
      newText - Text to add
    • clearSectionText

      public void clearSectionText()
      Clear all text in the sectin
    • getTable

      public PamTable getTable()
      Get a table from the section. This will appear AFTER any section text.
      Returns:
      A table of data (can be null)
    • setTable

      public void setTable(PamTable table)
      Set a table with no caption
      Parameters:
      table - table
    • setTable

      public void setTable(PamTable table, String tableCaption)
      Set a table with a caption. The caption will display above the table
      Parameters:
      table - Table
      tableCaption - Caption. Table numbers will be added automatically.
    • getImage

      public BufferedImage getImage()
      Get an image to add to the document. This will appear after any section text
      Returns:
      an image
    • getImageCaption

      public String getImageCaption()
      Get a caption for the image. This will appear below the image and automatically be numbered Figure 1, Figure 2, etc.
      Returns:
      an image
    • setImage

      public void setImage(BufferedImage image)
      Set an image with no caption
      Parameters:
      image -
    • setImage

      public void setImage(BufferedImage image, String imageCaption)
      Set an image with text for the caption.
      Parameters:
      image -
      imageCaption -
    • setImage

      public void setImage(BufferedImage image, String imageCaption, boolean trimWhiteSpace)
      Set an image with text for the caption.
      Parameters:
      image -
      imageCaption -
    • getImageWidth

      public long getImageWidth()

      Get the width of the image. If the value is 0, the image will automatically be scaled to fit the width of the page.

      The units are twips (twentieth of a point). For reference, half the width of an A4 page (210mm/2 = 105mm) is 5953 twips. Half the width of a 'letter' size page (8.5"/2 = 4.25") is 6120 twips.

      Returns:
      the width of the image in twips
    • setImageWidth

      public void setImageWidth(long imageWidth)

      Set the width of the image. If the value is 0, the image will automatically be scaled to fit the width of the page.

      The units are twips (twentieth of a point). For reference, half the width of an A4 page (210mm/2 = 105mm) is 5953 twips. Half the width of a 'letter' size page (8.5"/2 = 4.25") is 6120 twips.

    • hashCode

      public int hashCode()
      Override the hashCode method to look at the sectionTitle String
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Override the equals method to look at the sectionTitle String
      Overrides:
      equals in class Object
    • getTableCaption

      public String getTableCaption()
      Returns:
      the tableCaption
    • setTableCaption

      public void setTableCaption(String tableCaption)
      Parameters:
      tableCaption - the tableCaption to set