Class TimeSeries

java.lang.Object
microsim.statistics.TimeSeries
All Implemented Interfaces:
EventListener, IUpdatableSource

public class TimeSeries extends 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 Details

    • EVENT_SAVE

      public static final int EVENT_SAVE
      A custom event identifier for perfomAction method. Save to disk.
      See Also:
    • DEFAULT_SEPARATOR

      public static final char DEFAULT_SEPARATOR
      The character used to separate data in the output file.
      See Also:
    • series

      protected ArrayList<Series> series
    • absTimes

      protected cern.colt.list.DoubleArrayList absTimes
    • descTimes

      protected ArrayList<String> descTimes
  • Constructor Details

    • TimeSeries

      public TimeSeries()
      Create a new time series container.
  • Method Details

    • setFileName

      public void setFileName(String fileName)
      Set the output file name.
      Parameters:
      fileName - A valid path for the output file name.
    • getFileName

      public 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:
      IllegalArgumentException - If the series name already exists.
    • addSeries

      public void addSeries(String name, IDoubleSource source, 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(String name, IFloatSource source, 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(String name, IIntSource source, 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(String name, ILongSource source, 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(Object target, 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 interface IUpdatableSource
    • getSeriesList

      public 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:
      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(String path, 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(String path, 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(String path, 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.
    • onEvent

      public void onEvent(Enum<?> type)
      Perform one of the defined actions.
      Specified by:
      onEvent in interface EventListener
      Parameters:
      type - One of the following actions:
      Sim.EVENT_UPDATE calls the update() method.
      TimeSeries.EVENT_SAVE calls the saveToFile() method.