Package reportWriter
Class ReportSection
java.lang.Object
reportWriter.ReportSection
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)
- Author:
- mo55
-
Constructor Summary
ConstructorDescriptionConstructor with no section titleReportSection
(String sectionTitle) Constructor with section title at heading level 1ReportSection
(String sectionTitle, int headingLevel) Constructor with section title -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSectionText
(String newText) Add text to the section.void
Clear all text in the sectinboolean
Override the equals method to look at the sectionTitle Stringint
getImage()
Get an image to add to the document.Get a caption for the image.long
Get the width of the image.getTable()
Get a table from the section.int
hashCode()
Override the hashCode method to look at the sectionTitle Stringvoid
setImage
(BufferedImage image) Set an image with no captionvoid
setImage
(BufferedImage image, String imageCaption) Set an image with text for the caption.void
setImage
(BufferedImage image, String imageCaption, boolean trimWhiteSpace) Set an image with text for the caption.void
setImageWidth
(long imageWidth) Set the width of the image.void
setSectionTitle
(String sectionTitle) void
Set a table with no captionvoid
Set a table with a caption.void
setTableCaption
(String tableCaption)
-
Constructor Details
-
ReportSection
public ReportSection()Constructor with no section title -
ReportSection
Constructor with section title at heading level 1- Parameters:
sectionTitle
-
-
ReportSection
Constructor with section title- Parameters:
sectionTitle
-heading
- level, e.g. 1, 2, 3 etc.
-
-
Method Details
-
getSectionTitle
- Returns:
- the section title
-
getHeadingLevel
public int getHeadingLevel()- Returns:
- The heading level (1, 2, 3, etc.)
-
setSectionTitle
- Parameters:
sectionTitle
- Section title to set
-
getSectionText
- Returns:
- The section text
-
addSectionText
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
Get a table from the section. This will appear AFTER any section text.- Returns:
- A table of data (can be null)
-
setTable
Set a table with no caption- Parameters:
table
- table
-
setTable
Set a table with a caption. The caption will display above the table- Parameters:
table
- TabletableCaption
- Caption. Table numbers will be added automatically.
-
getImage
Get an image to add to the document. This will appear after any section text- Returns:
- an image
-
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
Set an image with no caption- Parameters:
image
-
-
setImage
Set an image with text for the caption.- Parameters:
image
-imageCaption
-
-
setImage
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 -
equals
Override the equals method to look at the sectionTitle String -
getTableCaption
- Returns:
- the tableCaption
-
setTableCaption
- Parameters:
tableCaption
- the tableCaption to set
-