org.primordion.xholon.io
Class ChartViewerGnuplot

java.lang.Object
  extended byorg.primordion.xholon.io.AbstractChartViewer
      extended byorg.primordion.xholon.io.ChartViewerGnuplot
All Implemented Interfaces:
IChartViewer

public class ChartViewerGnuplot
extends AbstractChartViewer
implements IChartViewer

Captures data, and creates a script to display the data in a gnuplot chart.

Data is captured by writing data points to a file at each time step. The file is in comma delimited .csv format, and can therefore be processed by various applications, including Microsoft Excel, and gnuplot. In addition to writing out the data, this class also produces a gnuplot script file that will generate a .png file from the data. You can download gnuplot free from www.gnuplot.info. On a Windows computer, if you double-click the .csv file, it will be directly loaded into Excel as a spreadsheet, from which you can easily generate a chart. Data and script files are written by default to the statistics directory.

Since:
0.3 (Created on April 24, 2006)
Author:
Ken Webb

Field Summary
 
Fields inherited from interface org.primordion.xholon.io.IChartViewer
WRITE_AS_DOUBLE, WRITE_AS_FLOAT, WRITE_AS_INT, WRITE_AS_LONG, WRITE_AS_NULL, WRITE_AS_SHORT, WRITE_TIME_IN_HEADING
 
Constructor Summary
ChartViewerGnuplot(IXholon chartRoot, int nameConcatLevels, java.lang.String pathName, java.lang.String typeOfData, int writeType)
          constructor
 
Method Summary
 void capture(double timeStep)
          Capture data at each timestep.
 void capture(int numTimeSeries, double xVal, double[] yVal)
          Capture specified data at each time interval.
 void chart()
          Produce a chart from the captured data.
 void chart(boolean showLegend)
          Produce a chart from the captured data.
 void createNotes()
          Create a notes file that can be used by a human to capture observations as the simulation is running.
 void createXySeries(int seriesCount, java.lang.String[] seriesName)
          Create one or more xy data series.
 void initialize(IXholon chartRoot, int nameConcatLevels)
          Initialize the chart viewer.
 void remove()
          Remove the chart from the screen.
 
Methods inherited from class org.primordion.xholon.io.AbstractChartViewer
setXRange, setYFormat, setYRange
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.primordion.xholon.io.IChartViewer
setXRange, setYFormat, setYRange
 

Constructor Detail

ChartViewerGnuplot

public ChartViewerGnuplot(IXholon chartRoot,
                          int nameConcatLevels,
                          java.lang.String pathName,
                          java.lang.String typeOfData,
                          int writeType)
constructor

Parameters:
chartRoot - XYChart node.
nameConcatLevels - Number of composite levels to concatenate in deriving series name.
pathName - Path in which data and plot files will be created.
typeOfData - The type of data will be included as part of the file name.
writeType -
Method Detail

initialize

public void initialize(IXholon chartRoot,
                       int nameConcatLevels)
Description copied from interface: IChartViewer
Initialize the chart viewer.

Specified by:
initialize in interface IChartViewer
Parameters:
chartRoot - XYChart node.
nameConcatLevels - Number of composite levels to concatenate in deriving series name.

createXySeries

public void createXySeries(int seriesCount,
                           java.lang.String[] seriesName)
Description copied from interface: IChartViewer
Create one or more xy data series.

Specified by:
createXySeries in interface IChartViewer
Parameters:
seriesCount - Number of xy series.
seriesName - Name of each xy series.

capture

public void capture(double timeStep)
Description copied from interface: IChartViewer
Capture data at each timestep.

Specified by:
capture in interface IChartViewer
Specified by:
capture in class AbstractChartViewer

capture

public void capture(int numTimeSeries,
                    double xVal,
                    double[] yVal)
Description copied from interface: IChartViewer
Capture specified data at each time interval.

Specified by:
capture in interface IChartViewer
Specified by:
capture in class AbstractChartViewer

chart

public void chart()
Description copied from interface: IChartViewer
Produce a chart from the captured data.

Specified by:
chart in interface IChartViewer
Specified by:
chart in class AbstractChartViewer

chart

public void chart(boolean showLegend)
Description copied from interface: IChartViewer
Produce a chart from the captured data.

Specified by:
chart in interface IChartViewer
Parameters:
showLegend - Whether or not to show the legend. The legend shows the name and color of all data series. If there are a lot of different series, then the legend can get too big.

createNotes

public void createNotes()
Create a notes file that can be used by a human to capture observations as the simulation is running. It may be inititilized with various parameters relevant to the application.


remove

public void remove()
Description copied from interface: IChartViewer
Remove the chart from the screen.

Specified by:
remove in interface IChartViewer
Specified by:
remove in class AbstractChartViewer