Package microsim.statistics
Class TimeSeries
- java.lang.Object
-
- microsim.statistics.TimeSeries
-
- All Implemented Interfaces:
EventListener
,IUpdatableSource
public class TimeSeries extends java.lang.Object implements EventListener, IUpdatableSource
It is a collection of series (data panel). It contains more series synching their time.Title: JAS
Description: Java Agent-based Simulation library
Copyright (C) 2002 Michele Sonnessa
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple 8Place, Suite 330, Boston, MA 02111-1307, USA.- Author:
- Michele Sonnessa
-
-
Field Summary
Fields Modifier and Type Field Description static char
DEFAULT_SEPARATOR
The character used to separate data in the output file.static int
EVENT_SAVE
A custom event identifier for perfomAction method.
-
Constructor Summary
Constructors Constructor Description TimeSeries()
Create a new time series container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSeries(java.lang.Object target, java.lang.String variableName, boolean getFromMethod)
Add a new series.void
addSeries(java.lang.String name, IDoubleSource source, java.lang.Enum<?> valueID)
Add a new series.void
addSeries(java.lang.String name, IFloatSource source, java.lang.Enum<?> valueID)
Add a new series.void
addSeries(java.lang.String name, IIntSource source, java.lang.Enum<?> valueID)
Add a new series.void
addSeries(java.lang.String name, ILongSource source, java.lang.Enum<?> valueID)
Add a new series.void
addSeries(Series aSeries)
Add a new series.java.lang.String
getFileName()
Return the current output file name.Series
getSeries(int seriesIndex)
Return a series at the given index.int
getSeriesCount()
Return the number of series.java.util.ArrayList<Series>
getSeriesList()
Return the list of contained time series.void
onEvent(java.lang.Enum<?> type)
Perform one of the defined actions.void
saveToFile()
Store the entire data content on the output file.void
saveToFile(java.lang.String path, java.lang.String fileName)
Store the entire data content on the given output file.void
saveToFile(java.lang.String path, java.lang.String fileName, boolean withTimes)
Store the entire data content on the given output file.void
saveToFile(java.lang.String path, java.lang.String fileName, boolean withTimes, char separator)
Store the entire data content on the given output file.void
setFileName(java.lang.String fileName)
Set the output file name.void
updateSource()
Update all the contained time series and the current time.
-
-
-
Field Detail
-
EVENT_SAVE
public static final int EVENT_SAVE
A custom event identifier for perfomAction method. Save to disk.- See Also:
- Constant Field Values
-
DEFAULT_SEPARATOR
public static final char DEFAULT_SEPARATOR
The character used to separate data in the output file.- See Also:
- Constant Field Values
-
-
Method Detail
-
setFileName
public void setFileName(java.lang.String fileName)
Set the output file name.- Parameters:
fileName
- A valid path for the output file name.
-
getFileName
public java.lang.String getFileName()
Return the current output file name.- Returns:
- The output file name.
-
addSeries
public void addSeries(Series aSeries)
Add a new series.- Parameters:
aSeries
- An instance of the SeriesStats class.- Throws:
java.lang.IllegalArgumentException
- If the series name already exists.
-
addSeries
public void addSeries(java.lang.String name, IDoubleSource source, java.lang.Enum<?> valueID)
Add a new series.- Parameters:
name
- Name of the statistic object.source
- The IDoubleSource object.valueID
- The value identifier defined by source object.
-
addSeries
public void addSeries(java.lang.String name, IFloatSource source, java.lang.Enum<?> valueID)
Add a new series.- Parameters:
name
- Name of the statistic object.source
- The IFloatSource object.valueID
- The value identifier defined by source object.
-
addSeries
public void addSeries(java.lang.String name, IIntSource source, java.lang.Enum<?> valueID)
Add a new series.- Parameters:
name
- Name of the statistic object.source
- The IIntSource object.valueID
- The value identifier defined by source object.
-
addSeries
public void addSeries(java.lang.String name, ILongSource source, java.lang.Enum<?> valueID)
Add a new series.- Parameters:
name
- Name of the statistic object.source
- The ILongSource object.valueID
- The value identifier defined by source object.
-
addSeries
public void addSeries(java.lang.Object target, java.lang.String variableName, boolean getFromMethod)
Add a new series.- Parameters:
target
- A generic source object.variableName
- The name of the field or the method returning the variable to be probed.getFromMethod
- Specifies if valueName is a method or a property value.
-
updateSource
public void updateSource()
Update all the contained time series and the current time.- Specified by:
updateSource
in interfaceIUpdatableSource
-
getSeriesList
public java.util.ArrayList<Series> getSeriesList()
Return the list of contained time series.- Returns:
- An array list containing SeriesStats objects.
-
getSeries
public Series getSeries(int seriesIndex)
Return a series at the given index.- Parameters:
seriesIndex
- The name of the series.- Returns:
- The asked series. Null if series does not exists.
- Throws:
java.lang.IndexOutOfBoundsException
- If seriesIndex is out of bounds.
-
getSeriesCount
public int getSeriesCount()
Return the number of series.- Returns:
- The number of series.
-
saveToFile
public void saveToFile()
Store the entire data content on the output file. It is used the default separator and the time description is stored with the absolute one.
-
saveToFile
public void saveToFile(java.lang.String path, java.lang.String fileName)
Store the entire data content on the given output file. It is used the default separator and the time description is stored with the absolute one.- Parameters:
path
- The optional path string. Passing an empty string it is ignored.fileName
- The name of the output file.
-
saveToFile
public void saveToFile(java.lang.String path, java.lang.String fileName, boolean withTimes)
Store the entire data content on the given output file. It is used the default separator.- Parameters:
path
- The optional path string. Passing an empty string it is ignored.fileName
- The name of the output file.withTimes
- If true time description is saved. Only absolute time is saved if false.
-
saveToFile
public void saveToFile(java.lang.String path, java.lang.String fileName, boolean withTimes, char separator)
Store the entire data content on the given output file.- Parameters:
path
- The optional path string. Passing an empty string it is ignored.fileName
- The name of the output file.withTimes
- If true time description is saved. Only absolute time is saved if false.separator
- The character used to separate data.- Throws:
java.io.IOException
- In case of IO error.
-
onEvent
public void onEvent(java.lang.Enum<?> type)
Perform one of the defined actions.- Specified by:
onEvent
in interfaceEventListener
- Parameters:
actionType
- One of the following actions:
Sim.EVENT_UPDATE calls the update() method.
TimeSeries.EVENT_SAVE calls the saveToFile() method.
-
-