Class CategoryCategoryReport

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

public class CategoryCategoryReport extends GeneralReport
The CategoryCategoryReport class creates reports that summarize groups of records found in the specified sourceDataTable. Each row in the report represents data summarized from a range of planning periods. Not all planning periods need be reported.

Column values are specified by the array of column 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 columnCategoryExpression calculation.

Row values are also specified by the array of row categories that are passed in to the constructor. There will be one row per category. Records will be classified into rows based on the contents of the rowCategoryExpression 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:

Category,1 - 20,21 - 40,41 - 60,61 - 80,81 - 100,101 - 120,121 - 140,140+,TOTAL
A,11291,10678,1357,20235,37621,15600,14596,15108,126486
B,9869,9648,4371,20235,37239,14930,12971,12472,121734
C,12123,10120,6816,11816,25072,29557,12579,13778,121861
D,13763,12034,8338,7630,29035,29193,11039,10091,121123
...
 

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 column category, and one stack for each column. The Y-axis is automatically scaled to fit the data, and labeled with the units parameter. The X-axis row categories.

See Also:
GeneralReport
  • Constructor Details

    • CategoryCategoryReport

      public CategoryCategoryReport(String filename, String title, String units, AttributeStore sourceDataTable, String reselectExpression, int[] periods, boolean annualize, String htmlText, boolean percent, String valueExpression, String rowCategoryExpression, Comparable[] rowCategories, String columnCategoryExpression, Comparable[] columnCategories)
      The CategoryCategoryReport 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.
      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.
      rowCategoryExpression - A database expression that evaluates to the values to be used to classify the record into a table row.
      rowCategories - An array of objects providing the classification scheme and row labels to be used for this table. One row will be created for each member of the array. These objects are typically Strings or RangeLabels.
      columnCategoryExpression - A database expression that evaluates to the values to be used to classify the record into a table column.
      columnCategories - 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.
  • Method Details

    • getValueExpression

      public String getValueExpression()
    • setValueExpression

      public void setValueExpression(String exp)
    • getRowCategoryExpression

      public String getRowCategoryExpression()
    • setRowCategoryExpression

      public void setRowCategoryExpression(String exp)
    • getRowCategories

      public Comparable[] getRowCategories()
    • setRowCategories

      public void setRowCategories(Comparable[] cats)
    • getColumnCategoryExpression

      public String getColumnCategoryExpression()
    • setColumnCategoryExpression

      public void setColumnCategoryExpression(String exp)
    • getColumnCategories

      public Comparable[] getColumnCategories()
    • setColumnCategories

      public void setColumnCategories(Comparable[] cats)
    • setCategoryLabel

      public void setCategoryLabel(String label)
    • getCategoryLabel

      public String getCategoryLabel()
    • 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).