Class ReportWriter
- All Implemented Interfaces:
EditableTableModel
,Comparator<Report>
,EventListener
,TreeModelListener
,TableModel
- Direct Known Subclasses:
ComparisonWriter
addReport
method.
Some reports include java applets to display histogram data.
In previous version of the report writer these applets would be
included by default. Applet support requires Java, and this can
sometimes be a problem for some viewers. In order to prevent
viewing problems Java applet support is now disabled by default.
To reenable applets within reports include the following code in the
Patchworks_Init section of the PIN file:
reportWriter.addDefaultParam("chart.applet", "true");
- Author:
- Tom Moore
- See Also:
Report
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionReportWriter(String label, PatchServer server)
Create an empty ReportWriter -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
void
Add the local HTTP server to the internal liststatic void
addCurrent(Vector<LabeledObject> list)
Add the local HTTP server to the specified liststatic void
addDefaultParam(String key, Object value)
Add a parameter pair to the default listvoid
Add a report definition that will not be exposed to the ReportWriter catalog.void
addKnownReport(String name, ReportConfigurator rc)
void
Add a scenario folder to the list of comparison folders.void
Add a scneario folder to the internal list of comparison folders.static void
addPath(Vector<LabeledObject> fileList, String name, File path)
Add a scenario folder to the specified list of comparison folders.static void
addPath(Vector<LabeledObject> list, String name, String pathname)
Add a scenario folder to the specified list of comparison folders.Add a report definition to the ReportWriter catalog.void
Add a row to the table using default values.void
Add a row to the table.void
addSupportFile(String filename, boolean autoload)
Add a support file to the ReportWriter.void
void
adjustList(Window parent)
static Vector<LabeledObject>
Build a list of directories to search.void
Clear all paths from the list of comparison folders.void
clearPaths(Vector fileList)
Clear all paths from the specified list.int
Comparator interface to sort dhandler names in order of decreasing length of name.boolean
containsReport(Report r)
Test if this reportWriter container contains the report object.void
doAllReports(Frame owner, String directory, String stage)
Output all known reports into the specified directoryInvoke a report and sent the output to the open stream.void
Generate a report and sent the output to the named file.Generate a report and sent the output to the named file.getColumnClass(int columnIndex)
int
getColumnName(int columnIndex)
static Object
getDefaultParam(String key)
Get the document base for this report writerGet the list of comparison folders.Get the default handlersGet a map of all of the known report templates in this ReportWriter.long
Retrieve a hashmap listing all documents visible to this report writer.Get the reports hashtableGet the reports hashtableint
Get the http server objectgetValueAt(int rowIndex, int columnIndex)
boolean
isCellEditable(int rowIndex, int columnIndex)
knownReport(String reportName)
Test if a document is known by the reportWriter.void
moveRow(int from, int to)
Move the specified row to a new locationstatic String
Pad a string with blank characters.void
removeReport(String filename)
Remove a report from the ReportWriter.void
removeRow(int row)
Remove the row specified by the row number.void
void
saveFolder(String folder, String scenarioFolder)
Save out the contents of a folder, plus the index files that point to it.void
saveReport(String report, String scenarioFolder)
Explicitly save out a report Call this for name of the report that you want to save.void
Save all reports to a named directory.void
Save all reports to a named directory.void
Save all reports to a named directory.void
Save all reports to a named directory.void
static void
setDefaultParams(String[][] param)
Set a list of parameters that will be used as a default on all reports.void
setValueAt(Object aValue, int rowIndex, int columnIndex)
void
void
void
void
void
updateNode(Report r)
void
updateReports(String scenario, String regex)
This method will update just the reports whose filenames are matched by the regular expression.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
ReportWriter
Create an empty ReportWriter- Parameters:
label
- the name of this report containerserver
- the server that this ReportWriter will be embedded in to
-
-
Method Details
-
getServer
Get the http server object -
getDocBase
Get the document base for this report writer -
addKnownReport
-
addBasicKnownReports
public void addBasicKnownReports() -
addAnalysisKnownReports
public void addAnalysisKnownReports() -
getKnownReports
Get a map of all of the known report templates in this ReportWriter. The templates can be used to instantiate new reports. -
addSupportFile
Add a support file to the ReportWriter. This file will be automatically copied in to the 'html' scenario folder and can be used in any of the reports. For example, a logo image can be added to the 'html' folder and then refered to by the reports.If you add css or js files then the report writer can add the required links so that file will be loaded with the reports after the base css and js files have been loaded. Specify the autoload parameter to be true for this feature. The autoload parameter will be ignored if the file is not a css or js file.
The support files will be referenced from their original locations when you are viewing reports from within Patchworks. If you make a change to the file the change will show up the next time you view the report.
When you save a scenario the custom files will be copied in to the scenario folder, and will no longer reference the original files. Even if the original file is deleted, the copy in the html folder will still remain.
- Parameters:
filename
- the name of the file to useautoload
- for css and js files, indicate if links should be generated in the report header to automatically load the file. If set to false then the files will be copied to the html folder but they will not be automatically referenced from the reports.
-
getSupportFiles
-
pad
Pad a string with blank characters. The extra spacing may be added to the right or left end of the string.- Parameters:
st
- The input stringsize
- The requested width of the output stringrightJustify
- A flag to indicate how the input string should be justified within the output. If true then right justify.
-
getLength
-
setDefaultParams
Set a list of parameters that will be used as a default on all reports. These defaults will be over ridden by defaults that are specfied on individual reports.The parameters influence the display of the report or of the chart. The default parameters are merged with parameters that are provided on the query string with the report URL. The parameters on the URL will over ride the default parameters.
Very few reports support parameters, but this mechanism will be used in future to support some form of report customization. See the
Report
class description for documenation of commonly used parameters. See the Parameter notes in the class description of each individual report for report-specific parameters.- Parameters:
param
- The list of name/value pairs of default parameters.
-
addDefaultParam
Add a parameter pair to the default list -
getDefaultParam
-
doReport
Generate a report and sent the output to the named file.- Parameters:
reportName
- The file name of the report (including the extension).filename
- The name of the file to store the report in
-
doReport
public Object doReport(String reportName, String filename, Map<String,Object> param, Object cache)Generate a report and sent the output to the named file.- Parameters:
reportName
- The file name of the report (including the extension).filename
- The name of the file to store the report inparam
- A hashmap containing report parameterscache
- An object holding cached repor results. In most cases this should be a null value.
-
doReport
public Object doReport(String reportName, PrintStream out, Map<String,Object> param, Object cache)Invoke a report and sent the output to the open stream.- Parameters:
reportName
- The name of the report (including the extension).out
- A stream to contain the outputparam
- A hashmap containing report parameters.cache
- An object holding cached report results. In most cases this should be a null value.
-
doAllReports
Output all known reports into the specified directory- Parameters:
directory
- A directory to contain the reportsstage
- A scenario name used to label the report
-
updateReports
This method will update just the reports whose filenames are matched by the regular expression. None of the other files will be altered. The checksum file will not be updated, so the updated reports will show as being modified.- Parameters:
scenario
- The name of the scenario folderregex
- A regular expression that identifies the files to be saved.
-
saveStage
Save all reports to a named directory. The stage name label on the reports will be taken from the final component of the directory path.- Parameters:
directory
- The name of the directory to contain the reports
-
saveStage
-
saveStage
Save all reports to a named directory. The stage name label on the reports will be taken from the final component of the directory path.- Parameters:
directory
- A File pointing to the directory to contain the reports
-
saveStage
Save all reports to a named directory.- Parameters:
directory
- A File pointing to the directory to contain the reportsstage
- A scenario name used to label the report
-
saveStage
Save all reports to a named directory. A FileChooser will be used to obtain a directory path. The stage name label on the reports will be taken from the final component of the directory path. -
saveReport
Explicitly save out a report Call this for name of the report that you want to save. All parts of the report will be saved automatically (e.g. PNG, CSV, HTML). E.g. saveReport("landscape/index.html", "scenarios/GCF_landscapeGuide_5"); -
saveFolder
Save out the contents of a folder, plus the index files that point to it.reportWriter.saveFolder("indicators/mapReports", "Scenario_6");
- Parameters:
folder
- The folder that the reports are stored in within the report writer.scenarioFolder
- The name of the top-level folder on disk to save the reports into.
-
getReportList
Retrieve a hashmap listing all documents visible to this report writer. -
knownReport
Test if a document is known by the reportWriter.- Parameters:
reportName
- The name of the report in question.
-
containsReport
Test if this reportWriter container contains the report object. -
addReport
Add a report definition to the ReportWriter catalog.- Parameters:
r
- The report to be added
-
addHiddenReport
Add a report definition that will not be exposed to the ReportWriter catalog.- Parameters:
r
- The report to be added
-
removeReport
Remove a report from the ReportWriter. If the report is an IndexReport then all reports in that folder will also be removed.- Parameters:
filename
- The filename of the report to remove. This should be the same name as was used to add the report.
-
getReports
Get the reports hashtable -
getHiddenReports
-
getHandlers
Get the default handlers -
getReportTree
Get the reports hashtable -
compare
Comparator interface to sort dhandler names in order of decreasing length of name.- Specified by:
compare
in interfaceComparator<Report>
-
treeNodesChanged
- Specified by:
treeNodesChanged
in interfaceTreeModelListener
-
treeNodesInserted
- Specified by:
treeNodesInserted
in interfaceTreeModelListener
-
treeNodesRemoved
- Specified by:
treeNodesRemoved
in interfaceTreeModelListener
-
treeStructureChanged
- Specified by:
treeStructureChanged
in interfaceTreeModelListener
-
updateNode
-
buildList
Build a list of directories to search. The list will include all sub-folders of the current analysis folder that contain the specified file, plus the current scenario.- Parameters:
file
- The name of a file that must be contained in the sub-folders in order for them to be included in the comparison list.parent
- A reference to the parent window component. This value may be null, in which case the search starts in the current analysis folder. If the value is non-null, the method will display a file chooser to locate another directory to be used to start the search.- Returns:
- A list of folders that meet the criteria. Note that a new list object is created each time this method is invoked.
-
addComparisonKnownReports
-
adjustList
-
addCurrent
public void addCurrent()Add the local HTTP server to the internal list -
addCurrent
Add the local HTTP server to the specified list -
addPath
Add a scneario folder to the internal list of comparison folders.- Parameters:
name
- The label name for this scenario.pathname
- The path to the scenario folder.
-
addPath
Add a scenario folder to the specified list of comparison folders.- Parameters:
list
- The list to change.name
- The label name for this scenario.pathname
- The path to the scenario folder.
-
addPath
Add a scenario folder to the list of comparison folders.- Parameters:
name
- The label name for this scenario.path
- A file object representing the scenario folder.
-
addPath
Add a scenario folder to the specified list of comparison folders.- Parameters:
fileList
- The list to change.name
- The label name for this scenario.path
- The path to the scenario folder.
-
clearPaths
public void clearPaths()Clear all paths from the list of comparison folders. -
clearPaths
Clear all paths from the specified list. -
getFileList
Get the list of comparison folders. -
addTableModelListener
- Specified by:
addTableModelListener
in interfaceTableModel
-
getColumnClass
- Specified by:
getColumnClass
in interfaceTableModel
-
getColumnCount
public int getColumnCount()- Specified by:
getColumnCount
in interfaceTableModel
-
getColumnName
- Specified by:
getColumnName
in interfaceTableModel
-
getRowCount
public int getRowCount()- Specified by:
getRowCount
in interfaceTableModel
-
getValueAt
- Specified by:
getValueAt
in interfaceTableModel
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex)- Specified by:
isCellEditable
in interfaceTableModel
-
removeTableModelListener
- Specified by:
removeTableModelListener
in interfaceTableModel
-
setValueAt
- Specified by:
setValueAt
in interfaceTableModel
-
addRow
Description copied from interface:EditableTableModel
Add a row to the table using default values. Optionally provide a reference to the parent window in case a dialog needs to be shown.- Specified by:
addRow
in interfaceEditableTableModel
-
addRow
Description copied from interface:EditableTableModel
Add a row to the table. The number of items in the rowData array must match the number of columns in the table.- Specified by:
addRow
in interfaceEditableTableModel
-
removeRow
public void removeRow(int row)Description copied from interface:EditableTableModel
Remove the row specified by the row number.- Specified by:
removeRow
in interfaceEditableTableModel
-
moveRow
public void moveRow(int from, int to)Description copied from interface:EditableTableModel
Move the specified row to a new location- Specified by:
moveRow
in interfaceEditableTableModel
-