Class StandardReport

All Implemented Interfaces:
Selectable<Report>, Comparable<Report>

public class StandardReport extends GeneralReport
The StandardReport class creates reports that summarize groups of records found in the specified sourceDataTable. Each row in the report represents data summarized from a single planning period. All planning periods are reported.

Column values are determined by searching the 'TARGET' column of the sourceDataTable for values that start with the value of the targetPattern parameter. All matching values are used as column headings.

Cell values are computed according to the expression parameter. The report will sum the value of the expression for each row, for each period, and for each uniquely matched target name.

This class generates reports in three formats: HTML, PNG, and CSV. Each sub-report contains the same data, formatted appropriately for the output style. When specifying the filename parameter do not supply a filename extension. This report will automatically create the corresponding ".html", ".png", and ".csv" files. The default report provided by the ReportWriter is the HTML format report, which also provides links to the other two formats.

The CSV sub-report has the simplest formatting. The file contains comma separated text values, and can be read in a text editor or loaded into a spreadsheet. The first row contains the column headings. Subsequent rows contain values for each period. The first column in the table contains the period number, with a column heading of 'PERIOD'. Subsequent columns contain the unique target names sorted in alphabetical order, and the final column contains row totals with a column heading of 'TOTAL'. The following shows a sample of a CSV format file:

PERIOD,product.Area.managed.DF,product.Area.managed.LA,product.Area.managed.PL,product.Area.managed.SEFA,product.Area.managed.SW,product.Area.managed.SWWet,TOTAL
0,0,0,0,0,0,0,0
1,123,0,342,69,116,3,653
2,91,0,335,70,113,1,611
3,75,0,391,132,91,2,690
4,75,0,391,100,83,1,651
5,43,0,363,66,71,0,543
...
 

The HTML sub-report contains a table holding similar information to the CSV report. Column headings are based on the unique values found within the 'TARGET' column, and are displayed in a nested format according to the following recipe:

  • Column names are sorted in alphabetical order.
  • The targetPattern is trimmed off of each column name.
  • The remainder of the column name is split into words at "." characters.
  • Columns headings are displayed in multiple rows, one row for each split of the target name. Column headings are merged together where adjacent cells have the same word.

Besides the table, the HTML report also contains a title, the name of the scenario, an embedding of a PNG version of the report, optional supplementary HTML data (additionalHTML), a link to the CSV sub-report, and a link to an index report.

The following figure shows an example of the table portion of the HTML report. The colour-coded areas shows columns common to all Standard reports (blue), target column headings (green), and cell values (tan).
Standard report table

The PNG sub-report shows a stacked-bar chart with one bar for each period, and one stack for each unique target. The Y-axis is automatically scaled to fit the data, and labeled with the units parameter. The X-axis displays period numbers.
Standard report chart

See Also:
ReportWriter
  • Field Details

    • TYPES

      public static final String[] TYPES
      This field describes the multiple renderings that are supported by the report. In this case the report supports html, csv, and png.
  • Constructor Details

    • StandardReport

      public StandardReport(String filename, String title, String units, AttributeStore sourceDataTable, String targetPattern, String expression, String additionalHTML, boolean computePercent)
      The StandardReport constructor.
      Parameters:
      filename - The basename to be used for output from this report. This name must be unique with respect to other reports added to the report writer. The name should not contain a filename extension. The report will add ".html", ".png", or ".csv" as appropriate.
      title - The title to be displayed in the HTML and PNG sub-reports. The report writer will automatically append the Scenario Name to the to the report title.
      units - The units of measure to be displayed on the Y-axis of the PNG sub-report.
      sourceDataTable - The table containing the data to be summarized.
      targetPattern - A string containing the pattern of the targets of interest. The string can contain '*' and '?' wild card characters.
      expression - An expression describing the data value to be displayed in the cells of the table. The expression can refer to any column in the sourceDataTable.
      additionalHTML - Artibrary HTML format text that can be added in to the HTML sub-report. This text can contain explanatory text, display a coporate logo, or provide a hyper-link to a related table.
      computePercent - A boolean value that indicates if the cell data should be converted to percent of the row total. Percent format data can assist in showing changed in relative composition over time.
  • Method Details

    • getPattern

      public String getPattern()
    • setPeriods

      public StandardReport setPeriods(int[] periodList)
      Description copied from class: GeneralReport
      Set the list of periods that will be summarized in this report.
      Overrides:
      setPeriods in class GeneralReport
    • setPattern

      public void setPattern(String pattern)
    • setExpression

      public void setExpression(String expression)
    • getExpression

      public String getExpression()
    • doReport

      public ca.spatial.reportwriter.Report.DataCache doReport(String filename, PrintStream out, Map<String,​Object> param, ca.spatial.reportwriter.Report.DataCache cache)
      Description copied from class: Report
      The method used by the report writer to format the requested report. This method is implemented in every custom report. Application programs generally do not need to call this method, but instead use the report writer methods to obtain reports.
      Specified by:
      doReport in class Report
      Parameters:
      filename - The full name of the report to be printed, including the extension of the sub-report (if any).
      out - The output stream to print output on to.
      param - A HashMap containing parameters that modify the report (for example the scenario name).
    • getTypes

      public String[] getTypes()
      Description copied from class: Report
      An accessor function to retrieve the list of report types supported by this report. See the documentation for the TYPES variable for the list of sub-types.
      Overrides:
      getTypes in class GeneralReport