net.lenkaspace.creeper.report
Class CRTimeSeriesReport

java.lang.Object
  extended by net.lenkaspace.creeper.report.CRBaseReport
      extended by net.lenkaspace.creeper.report.CRTimeSeriesReport

public class CRTimeSeriesReport
extends CRBaseReport

Creates graphical time series reports, usually of a single run / trial. For better performance, maintain an instance that opens and closes with (updated) data rather than creating a new popup every time.

Version:
2.0
Author:
Lenka Pitonakova contact@lenkaspace.net

Nested Class Summary
static class CRTimeSeriesReport.FUNCTION
           
 
Constructor Summary
CRTimeSeriesReport(java.lang.String title_, java.lang.String[] variableNames_)
          Constructor
CRTimeSeriesReport(java.lang.String title_, java.lang.String[] variableNames_, java.awt.Dimension size_)
          Constructor
 
Method Summary
 void addValue(double value_)
          Register a new value for a 0th index of the overal value set
 void addValue(double value_, int variableIndex_)
          Register a new value for a specific index of the overal value set
 void addValue(double value_, java.lang.String variableName_)
          Register a new value for a specific variable name from the overal value set
 void addValueSet(double[] values_)
          Register new value set for the current time step.
 void createSelf(java.lang.String printToFileName_, boolean show_)
          Create a window of the report.
 void createSelfAsText(java.lang.String printToFileName_)
          Save a textual representation of data, where columns represent individual variables (tab-separated) and rows represent different time steps.
 boolean getShouldOutputVariableNames()
           
 double getVariableMean(int variableIndex_, org.jfree.data.Range timeRange_)
          Get mean of a data series identified by a variable index.
 double getVariableMean(java.lang.String variableName_, org.jfree.data.Range timeRange_)
          Get mean of a data series identified by a variable name
 void onRunStart(int runNumber_)
          Called by CRController each time a run starts.
 void onTrialEnd(int trialNumber_, int runNumber_)
          Save self to an image if allowed
 void onTrialStart(int trialNumber_, int runNumber_)
          Called by CRController each time a trial starts.
 void onUpdateLoopEnd(int timeCounter_, int timeUnit_)
          Called from CRController after onUpdateLoopEnd() of all world objects is called.
 void onUpdateLoopStart(int timeCounter_, int timeUnit_)
          Called from CRController before onUpdateLoopStart() of all world objects is called.
 void setColors(java.awt.Color[] colors_)
           
 void setIsScatterPlot(boolean value_)
           
 void setShapes(java.awt.Shape[] shapes_)
           
 void setShouldDisplayLegend(boolean value_)
           
 void setShouldOutputVariableNames(boolean value_)
          If set to true, variable names will be printed as the 1st row in the text ouput
 void setStrokes(java.awt.Stroke[] strokes_)
           
 void setXAxisTitle(java.lang.String value_)
           
 void setYAxisDisplayRange(org.jfree.data.Range range_)
           
 void setYAxisTitle(java.lang.String value_)
           
 
Methods inherited from class net.lenkaspace.creeper.report.CRBaseReport
display, getDisplaysWindow, getFileName, onRunEnd, onSimulationEnd, onSimulationStart, setController, setReportController
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CRTimeSeriesReport

public CRTimeSeriesReport(java.lang.String title_,
                          java.lang.String[] variableNames_)
Constructor

Parameters:
title_ - String title of the report
variableNames_ - String array of variable names to identify different time series lines

CRTimeSeriesReport

public CRTimeSeriesReport(java.lang.String title_,
                          java.lang.String[] variableNames_,
                          java.awt.Dimension size_)
Constructor

Parameters:
title_ - String title of the report
variableNames_ - String array of variable names to identify different time series lines
size_ - Dimension size of the report window
Method Detail

onRunStart

public void onRunStart(int runNumber_)
Called by CRController each time a run starts. Use this to reset self for a brand new simulation and call onNewTrial of children models.

Overrides:
onRunStart in class CRBaseReport
Parameters:
runNumber_ - int new run number

onTrialStart

public void onTrialStart(int trialNumber_,
                         int runNumber_)
Called by CRController each time a trial starts. Set all variables to 0 and create new data series.

Overrides:
onTrialStart in class CRBaseReport
Parameters:
trialNumber_ - int new trial number
runNumber_ - int current run number

onTrialEnd

public void onTrialEnd(int trialNumber_,
                       int runNumber_)
Save self to an image if allowed

Overrides:
onTrialEnd in class CRBaseReport
Parameters:
trialNumber_ - int ending trial number
runNumber_ - int current run number

onUpdateLoopStart

public void onUpdateLoopStart(int timeCounter_,
                              int timeUnit_)
Called from CRController before onUpdateLoopStart() of all world objects is called. Set the value for current time to 0

Overrides:
onUpdateLoopStart in class CRBaseReport
Parameters:
timeUnit_ - int current time unit
timeCounter_ - int current time counter, i.e. part of the timeUnit_

onUpdateLoopEnd

public void onUpdateLoopEnd(int timeCounter_,
                            int timeUnit_)
Called from CRController after onUpdateLoopEnd() of all world objects is called. Calculate average over the passed second

Overrides:
onUpdateLoopEnd in class CRBaseReport
Parameters:
timeUnit_ - int current time unit
timeCounter_ - int current time counter, i.e. part of the timeUnit_

addValueSet

public void addValueSet(double[] values_)
Register new value set for the current time step. The value set size should be the same as size of set names the report was initialised with.

Parameters:
values_ - double[] array of values

addValue

public void addValue(double value_,
                     java.lang.String variableName_)
Register a new value for a specific variable name from the overal value set

Parameters:
value_ - double new value
variableName_ - String variable name from the variable name set this object was initialised with

addValue

public void addValue(double value_)
Register a new value for a 0th index of the overal value set

Parameters:
value_ - double new value

addValue

public void addValue(double value_,
                     int variableIndex_)
Register a new value for a specific index of the overal value set

Parameters:
value_ - double new value
variableIndex_ - int 0 <= index < size of set names

createSelf

public void createSelf(java.lang.String printToFileName_,
                       boolean show_)
Create a window of the report. Optionally show it on screen as well

Overrides:
createSelf in class CRBaseReport
Parameters:
printToFileName_ - String file name to print report into, without extension
show_ - boolean if false, report is hidden immediately after printed

createSelfAsText

public void createSelfAsText(java.lang.String printToFileName_)
Save a textual representation of data, where columns represent individual variables (tab-separated) and rows represent different time steps.

Parameters:
printToFileName_ - String path + file name

getVariableMean

public double getVariableMean(java.lang.String variableName_,
                              org.jfree.data.Range timeRange_)
Get mean of a data series identified by a variable name

Parameters:
variableName_ - String variable name
timeRange_ - Range time range
Returns:
double variable mean

getVariableMean

public double getVariableMean(int variableIndex_,
                              org.jfree.data.Range timeRange_)
Get mean of a data series identified by a variable index.

Parameters:
variableIndex_ - int variable index
timeRange_ - Range time range
Returns:
double variable mean

setIsScatterPlot

public void setIsScatterPlot(boolean value_)

setColors

public void setColors(java.awt.Color[] colors_)

setShapes

public void setShapes(java.awt.Shape[] shapes_)

setStrokes

public void setStrokes(java.awt.Stroke[] strokes_)

setShouldDisplayLegend

public void setShouldDisplayLegend(boolean value_)

setYAxisTitle

public void setYAxisTitle(java.lang.String value_)

setXAxisTitle

public void setXAxisTitle(java.lang.String value_)

setYAxisDisplayRange

public void setYAxisDisplayRange(org.jfree.data.Range range_)

setShouldOutputVariableNames

public void setShouldOutputVariableNames(boolean value_)
If set to true, variable names will be printed as the 1st row in the text ouput

Parameters:
value_ - boolean

getShouldOutputVariableNames

public boolean getShouldOutputVariableNames()