Class CategoryReport
- All Implemented Interfaces:
Selectable<Report>
,Comparable<Report>
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 determined by searching the
sourceDataTable
for column names that match the
columnPrefix
. All matching
values are used as column headings.
Row labels are specified in the categories
array. There will be one row in the table for each String
in the categories
array.
Records from the sourceDataTable
are classified by
the categoryColumn
to determine which row the record
values should be summed into. Values for each database
variable starting with columnPrefix
are summed into
the approprite column and row.
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 category. The first column in the table contains the period number, with a column heading of '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,1 - 20,21 - 40,41 - 60,61 - 80,81 - 100,101 - 120,121 - 140,140+,TOTAL 0,11291,10678,1357,20235,37621,15600,14596,15108,126486 1,9869,9648,4371,20235,37239,14930,12971,12472,121734 2,12123,10120,6816,11816,25072,29557,12579,13778,121861 3,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 range label 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
(additionalHTML
), 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.
- See Also:
ReportWriter
,RangeLabel
-
Field Summary
FieldsFields inherited from class ca.spatial.reportwriter.Report
AREA, LINE, PIE, SIDE_BY_SIDE_BARS, STACKED_BARS
-
Constructor Summary
ConstructorsConstructorDescriptionCategoryReport(String filename, String title, String units, AttributeStore sourceDataTable, String columnPattern, String categoryColumn, Comparable[] categories, int[] periods, String additionalHTML, boolean computePercent)
The CategoryReport constructor -
Method Summary
Modifier and TypeMethodDescriptionca.spatial.reportwriter.Report.DataCache
doReport(String filename, PrintStream out, Map<String,Object> param, ca.spatial.reportwriter.Report.DataCache cache)
The method used by the report writer to format the requested report.getAs()
Get the As value.Get the Categories value.Get the CategoryColumn value.Get the Link value.Get the column pattern value.int[]
Get the Periods value.String[]
getTypes()
An accessor function to retrieve the list of report types supported by this report.getUnits()
Get the Units value.boolean
Get the Percent value.void
setAs(AttributeStore newAs)
Set the As value.void
setCategories(Comparable[] newCategories)
Set the Categories value.void
setCategoryColumn(String newCategoryColumn)
Set the CategoryColumn value.void
setHTMLText(String newLink)
Set the Link value.void
setPattern(String newPattern)
Set the column pattern value.void
setPercent(boolean newPercent)
Set the Percent value.void
setPeriods(int[] newPeriods)
Set the Periods value.void
Set the Units value.Methods inherited from class ca.spatial.reportwriter.Report
addDefaultParam, chartImg, compareTo, csvLink, doesAnyTypes, doesCSV, doesGIF, doesHTML, doesPNG, doesType, encodeFileURL, encodeURL, endMainContent, escapeRegexChars, footer, formatColumnHeadings, formatColumnHeadings, getAdditionalFiles, getAttributeStore, getBasepart, getBasepart, getDefaultFilename, getDisplayFormat, getExtension, getExtension, getFilename, getFolderpart, getFolderpart, getLength, getNamepart, getNamepart, getPathToRoot, getReportFor, getTitle, header, htmlText, indexLink, interpolateParams, isDhandler, isIndexed, isSelected, parentIndex, patternToRegex, setAttributeStore, setDefaultParams, setDisplayFormat, setIndexed, setSelected, setTitle, toString, uniqueLabels
-
Field Details
-
TYPES
-
-
Constructor Details
-
CategoryReport
public CategoryReport(String filename, String title, String units, AttributeStore sourceDataTable, String columnPattern, String categoryColumn, Comparable[] categories, int[] periods, String additionalHTML, boolean computePercent)The CategoryReport 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.columnPattern
- The pattern used to find database columns that will compose the columns of the report. All matching columns will be used.categoryColumn
- The database column containing values to be summed into the rows of the table.categories
- An array of String labels providing the row names to be used for this table.periods
- An array of period numbers that will be used in composing the report. Only values from the specified periods will be used.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
-
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. -
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. -
getUnits
Get the Units value.- Returns:
- the Units value.
-
setUnits
Set the Units value.- Parameters:
newUnits
- The new Units value.
-
getAs
Get the As value.- Returns:
- the As value.
-
setAs
Set the As value.- Parameters:
newAs
- The new As value.
-
getPattern
Get the column pattern value. -
setPattern
Set the column pattern value.- Parameters:
newPattern
- The new column prefix value.
-
getCategoryColumn
Get the CategoryColumn value.- Returns:
- the CategoryColumn value.
-
setCategoryColumn
Set the CategoryColumn value.- Parameters:
newCategoryColumn
- The new CategoryColumn value.
-
getCategories
Get the Categories value.- Returns:
- the Categories value.
-
setCategories
Set the Categories value.- Parameters:
newCategories
- The new Categories value.
-
getPeriods
public int[] getPeriods()Get the Periods value.- Returns:
- the Periods value.
-
setPeriods
public void setPeriods(int[] newPeriods)Set the Periods value.- Parameters:
newPeriods
- The new Periods value.
-
getHTMLText
Get the Link value.- Returns:
- the Link value.
-
setHTMLText
Set the Link value.- Parameters:
newLink
- The new Link value.
-
isPercent
public boolean isPercent()Get the Percent value.- Returns:
- the Percent value.
-
setPercent
public void setPercent(boolean newPercent)Set the Percent value.- Parameters:
newPercent
- The new Percent value.
-