net.sourceforge.openforecast.input
Class TimeSeriesBuilder

java.lang.Object
  extended by net.sourceforge.openforecast.input.AbstractBuilder
      extended by net.sourceforge.openforecast.input.TimeSeriesBuilder
All Implemented Interfaces:
Builder

public class TimeSeriesBuilder
extends AbstractBuilder

Defines a Builder that can be used to construct a DataSet from a TimeSeries object as used/defined by JFreeChart. This class makes for a quick and easy "import" of data from a JFreeChart TimeSeries. Note that since a TimeSeries does not give a name to the independent, time variable, this builder defaults the name to be the class name of the RegularTimePeriod used in the TimeSeries. For example, if a series of org.jfree.data.time.Day objects are used, then the name of the independent variable will default to "Day" (without the quotes).

Since:
0.4
Author:
Steven R. Gould

Constructor Summary
TimeSeriesBuilder(org.jfree.data.time.TimeSeries timeSeries)
          Constructs a new TimeSeriesBuilder that reads its input from the given TimeSeries object.
TimeSeriesBuilder(org.jfree.data.time.TimeSeries timeSeries, String timeVariableName)
          Constructs a new TimeSeriesBuilder that reads its input from the given TimeSeries object.
 
Method Summary
 DataSet build()
          Retrieves a DataSet - a collection of DataPoints - from the current (JFreeChart) TimeSeries.
 String getTimeVariable()
          Returns the name of the currently defined time variable.
 void setTimeVariable(String name)
          Used to change the time variable name.
 
Methods inherited from class net.sourceforge.openforecast.input.AbstractBuilder
addVariable, getNumberOfVariables, getVariableName, setNumberOfVariables, setVariableName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeSeriesBuilder

public TimeSeriesBuilder(org.jfree.data.time.TimeSeries timeSeries)
Constructs a new TimeSeriesBuilder that reads its input from the given TimeSeries object. This builder defaults the of the independent, time variable to be the class name of the RegularTimePeriod used in the TimeSeries. For example, if a series of org.jfree.data.time.Day objects are used, then the name of the independent variable will default to "Day" (without the quotes). See the class description for more information.

Parameters:
timeSeries - the TimeSeries object containing data to be used to build the DataSet.
Throws:
IllegalArgumentException - if the TimeSeries is empty.

TimeSeriesBuilder

public TimeSeriesBuilder(org.jfree.data.time.TimeSeries timeSeries,
                         String timeVariableName)
Constructs a new TimeSeriesBuilder that reads its input from the given TimeSeries object. This builder uses the given name for the independent, time variable in the DataPoints that are created.

Parameters:
timeSeries - the TimeSeries object containing data to be used to build the DataSet.
timeVariableName - the name to use for the time variable.
Throws:
IllegalArgumentException - if the TimeSeries is empty.
Method Detail

getTimeVariable

public String getTimeVariable()
Returns the name of the currently defined time variable.

Returns:
the name currently defined for the time variable.

setTimeVariable

public void setTimeVariable(String name)
Used to change the time variable name.

Parameters:
name - the new name for the time variable.

build

public DataSet build()
Retrieves a DataSet - a collection of DataPoints - from the current (JFreeChart) TimeSeries. The DataSet should contain all DataPoints defined by the TimeSeries.

In general, build will attempt to convert all values in the TimeSeries to data points.

Returns:
a DataSet built from the current TimeSeries.


OpenForecast, Copyright (c) Steven Gould, 2002-2011