Package microsim.statistics
Class TimeSeries
java.lang.Object
microsim.statistics.TimeSeries
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionprotected cern.colt.list.DoubleArrayListstatic final charThe character used to separate data in the output file.static final intA custom event identifier for perfomAction method. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a new series.voidaddSeries(String name, IDoubleSource source, Enum<?> valueID) Add a new series.voidaddSeries(String name, IFloatSource source, Enum<?> valueID) Add a new series.voidaddSeries(String name, IIntSource source, Enum<?> valueID) Add a new series.voidaddSeries(String name, ILongSource source, Enum<?> valueID) Add a new series.voidAdd a new series.Return the current output file name.getSeries(int seriesIndex) Return a series at the given index.intReturn the number of series.Return the list of contained time series.voidPerform one of the defined actions.voidStore the entire data content on the output file.voidsaveToFile(String path, String fileName) Store the entire data content on the given output file.voidsaveToFile(String path, String fileName, boolean withTimes) Store the entire data content on the given output file.voidsaveToFile(String path, String fileName, boolean withTimes, char separator) Store the entire data content on the given output file.voidsetFileName(String fileName) Set the output file name.voidUpdate all the contained time series and the current time.
-
Field Details
-
EVENT_SAVE
public static final int EVENT_SAVEA custom event identifier for perfomAction method. Save to disk.- See Also:
-
DEFAULT_SEPARATOR
public static final char DEFAULT_SEPARATORThe character used to separate data in the output file.- See Also:
-
series
-
absTimes
protected cern.colt.list.DoubleArrayList absTimes -
descTimes
-
-
Constructor Details
-
TimeSeries
public TimeSeries()Create a new time series container.
-
-
Method Details
-
setFileName
Set the output file name.- Parameters:
fileName- A valid path for the output file name.
-
getFileName
Return the current output file name.- Returns:
- The output file name.
-
addSeries
Add a new series.- Parameters:
aSeries- An instance of the SeriesStats class.- Throws:
IllegalArgumentException- If the series name already exists.
-
addSeries
Add a new series.- Parameters:
name- Name of the statistic object.source- The IDoubleSource object.valueID- The value identifier defined by source object.
-
addSeries
Add a new series.- Parameters:
name- Name of the statistic object.source- The IFloatSource object.valueID- The value identifier defined by source object.
-
addSeries
Add a new series.- Parameters:
name- Name of the statistic object.source- The IIntSource object.valueID- The value identifier defined by source object.
-
addSeries
Add a new series.- Parameters:
name- Name of the statistic object.source- The ILongSource object.valueID- The value identifier defined by source object.
-
addSeries
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:
updateSourcein interfaceIUpdatableSource
-
getSeriesList
Return the list of contained time series.- Returns:
- An array list containing SeriesStats objects.
-
getSeries
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:
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
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
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
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.
-
onEvent
Perform one of the defined actions.- Specified by:
onEventin interfaceEventListener- Parameters:
type- One of the following actions:
Sim.EVENT_UPDATE calls the update() method.
TimeSeries.EVENT_SAVE calls the saveToFile() method.
-