Class PeriodCategoryReport

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

public class PeriodCategoryReport extends GeneralReport
The PeriodCategoryReport 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 specified by the array of categories that are passed in to the constructor. There will be one column per category. Records will be classified into columns based on the contents of the categoryExpression calculation.

Cell values are summed by the valueExpression database calculation.

A reselection expression can be used to limit the number of records that contribute to the table. The reselection expression must evaluate to a boolean (true or false) value.

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'. The second column contains the final YEAR of the period. Subsequent columns contain the range labels 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,YEAR,1 - 20,21 - 40,41 - 60,61 - 80,81 - 100,101 - 120,121 - 140,140+,TOTAL

The HTML sub-report contains a table holding similar information to the CSV report. Column headings are based on the category values.

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 (htmlText), a link to the CSV sub-report, and a link to an index report.

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

See Also:
ReportWriter, RangeLabel
  • Constructor Details

    • PeriodCategoryReport

      public PeriodCategoryReport(String filename, String title, String units, AttributeStore sourceDataTable, String reselectExpression, int[] periods, boolean annualize, String htmlText, boolean percent, String valueExpression, String categoryExpression, Comparable[] categories)
      The PeriodCategoryReport constructor.
      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.
      reselectExpression - An SQL-like expression that will limit the set of records to be used in constructing this table.
      periods - The number of periods in the report (including the initial time zero period).
      annualize - A flag to indicate if the values should be annualized. If true then values from period 0 (prior to the start of the simulation) are not shown. All other values are divided by the width of the period.
      htmlText - 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.
      percent - 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.
      valueExpression - A database expression that evaluates to the value to be summed into the cells of the table.
      categoryExpression - A database expression that evaluates to the values to be used to classify the record into a table column.
      categories - An array of objects providing the classification scheme and column names to be used for this table. One column will be created for each member of the array. These objects are typically Strings or RangeLabels. If this parameter is a null value then the report will automatically determine the categories to use when the report is produced, based on the data content.
  • Method Details

    • getValueExpression

      public String getValueExpression()
    • setValueExpression

      public void setValueExpression(String exp)
    • getCategoryExpression

      public String getCategoryExpression()
    • setCategoryExpression

      public void setCategoryExpression(String exp)
    • getCategories

      public Comparable[] getCategories()
    • setCategories

      public void setCategories(Comparable[] cats)
    • 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
      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).