public class TimeSeries extends Series implements Cloneable, Serializable
RegularTimePeriod
.
The time series will ensure that (a) all data items have the same type of
period (for example, Day
) and (b) that each period appears at
most one time in the series.Constructor and Description |
---|
TimeSeries(Comparable name)
Creates a new (empty) time series.
|
TimeSeries(Comparable name,
Class timePeriodClass)
Deprecated.
As of 1.0.13, it is not necessary to specify the
timePeriodClass as this will be inferred when the
first data item is added to the dataset. |
TimeSeries(Comparable name,
String domain,
String range)
Creates a new time series that contains no data.
|
TimeSeries(Comparable name,
String domain,
String range,
Class timePeriodClass)
Deprecated.
As of 1.0.13, it is not necessary to specify the
timePeriodClass as this will be inferred when the
first data item is added to the dataset. |
Modifier and Type | Method and Description |
---|---|
void |
add(RegularTimePeriod period,
double value)
Adds a new data item to the series and sends a
SeriesChangeEvent
to all registered listeners. |
void |
add(RegularTimePeriod period,
double value,
boolean notify)
Adds a new data item to the series and sends a
SeriesChangeEvent
to all registered listeners. |
void |
add(RegularTimePeriod period,
Number value)
Adds a new data item to the series and sends
a
SeriesChangeEvent to all registered
listeners. |
void |
add(RegularTimePeriod period,
Number value,
boolean notify)
Adds a new data item to the series and sends a
SeriesChangeEvent
to all registered listeners. |
void |
add(TimeSeriesDataItem item)
Adds a data item to the series and sends a
SeriesChangeEvent to
all registered listeners. |
void |
add(TimeSeriesDataItem item,
boolean notify)
Adds a data item to the series and sends a
SeriesChangeEvent to
all registered listeners. |
TimeSeries |
addAndOrUpdate(TimeSeries series)
Adds or updates data from one series to another.
|
TimeSeriesDataItem |
addOrUpdate(RegularTimePeriod period,
double value)
Adds or updates an item in the times series and sends a
SeriesChangeEvent to all registered listeners. |
TimeSeriesDataItem |
addOrUpdate(RegularTimePeriod period,
Number value)
Adds or updates an item in the times series and sends a
SeriesChangeEvent to all registered listeners. |
TimeSeriesDataItem |
addOrUpdate(TimeSeriesDataItem item)
Adds or updates an item in the times series and sends a
SeriesChangeEvent to all registered listeners. |
void |
clear()
Removes all data items from the series and sends a
SeriesChangeEvent to all registered listeners. |
Object |
clone()
Returns a clone of the time series.
|
TimeSeries |
createCopy(int start,
int end)
Creates a new timeseries by copying a subset of the data in this time
series.
|
TimeSeries |
createCopy(RegularTimePeriod start,
RegularTimePeriod end)
Creates a new timeseries by copying a subset of the data in this time
series.
|
void |
delete(int start,
int end)
Deletes data from start until end index (end inclusive).
|
void |
delete(int start,
int end,
boolean notify)
Deletes data from start until end index (end inclusive).
|
void |
delete(RegularTimePeriod period)
Deletes the data item for the given time period and sends a
SeriesChangeEvent to all registered listeners. |
boolean |
equals(Object obj)
Tests the series for equality with an arbitrary object.
|
Range |
findValueRange()
Returns the range of y-values in the time series.
|
Range |
findValueRange(Range xRange,
TimePeriodAnchor xAnchor,
TimeZone zone)
Finds the range of y-values that fall within the specified range of
x-values (where the x-values are interpreted as milliseconds since the
epoch and converted to time periods using the specified timezone).
|
Range |
findValueRange(Range xRange,
TimeZone timeZone)
Returns the range of y-values in the time series that fall within
the specified range of x-values.
|
TimeSeriesDataItem |
getDataItem(int index)
Returns a data item from the dataset.
|
TimeSeriesDataItem |
getDataItem(RegularTimePeriod period)
Returns the data item for a specific period.
|
String |
getDomainDescription()
Returns the domain description.
|
int |
getIndex(RegularTimePeriod period)
Returns the index for the item (if any) that corresponds to a time
period.
|
int |
getItemCount()
Returns the number of items in the series.
|
List |
getItems()
Returns the list of data items for the series (the list contains
TimeSeriesDataItem objects and is unmodifiable). |
long |
getMaximumItemAge()
Returns the maximum item age (in time periods) for the series.
|
int |
getMaximumItemCount()
Returns the maximum number of items that will be retained in the series.
|
double |
getMaxY()
Returns the largest y-value in the series, ignoring any
null and Double.NaN values. |
double |
getMinY()
Returns the smallest y-value in the series, ignoring any
null and Double.NaN values. |
RegularTimePeriod |
getNextTimePeriod()
Returns a time period that would be the next in sequence on the end of
the time series.
|
String |
getRangeDescription()
Returns the range description.
|
RegularTimePeriod |
getTimePeriod(int index)
Returns the time period at the specified index.
|
Class |
getTimePeriodClass()
Returns the time period class for this series.
|
Collection |
getTimePeriods()
Returns a collection of all the time periods in the time series.
|
Collection |
getTimePeriodsUniqueToOtherSeries(TimeSeries series)
Returns a collection of time periods in the specified series, but not in
this series, and therefore unique to the specified series.
|
Number |
getValue(int index)
Returns the value at the specified index.
|
Number |
getValue(RegularTimePeriod period)
Returns the value for a time period.
|
int |
hashCode()
Returns a hash code value for the object.
|
void |
removeAgedItems(boolean notify)
Age items in the series.
|
void |
removeAgedItems(long latest,
boolean notify)
Age items in the series.
|
void |
setDomainDescription(String description)
Sets the domain description and sends a
PropertyChangeEvent
(with the property name Domain ) to all registered
property change listeners. |
void |
setMaximumItemAge(long periods)
Sets the number of time units in the 'history' for the series.
|
void |
setMaximumItemCount(int maximum)
Sets the maximum number of items that will be retained in the series.
|
void |
setRangeDescription(String description)
Sets the range description and sends a
PropertyChangeEvent
(with the property name Range ) to all registered listeners. |
void |
update(int index,
Number value)
Updates (changes) the value of a data item.
|
void |
update(RegularTimePeriod period,
double value)
Updates (changes) the value for a time period.
|
void |
update(RegularTimePeriod period,
Number value)
Updates (changes) the value for a time period.
|
addChangeListener, addPropertyChangeListener, addVetoableChangeListener, fireSeriesChanged, getDescription, getKey, getNotify, isEmpty, removeChangeListener, removePropertyChangeListener, removeVetoableChangeListener, setDescription, setKey, setNotify
public TimeSeries(Comparable name)
name
- the series name (null
not permitted).public TimeSeries(Comparable name, String domain, String range)
Descriptions can be specified for the domain and range. One situation where this is helpful is when generating a chart for the time series - axis labels can be taken from the domain and range description.
name
- the name of the series (null
not permitted).domain
- the domain description (null
permitted).range
- the range description (null
permitted).public TimeSeries(Comparable name, Class timePeriodClass)
timePeriodClass
as this will be inferred when the
first data item is added to the dataset.RegularTimePeriod
.name
- the series name (null
not permitted).timePeriodClass
- the type of time period (null
not
permitted).public TimeSeries(Comparable name, String domain, String range, Class timePeriodClass)
timePeriodClass
as this will be inferred when the
first data item is added to the dataset.Descriptions can be specified for the domain and range. One situation where this is helpful is when generating a chart for the time series - axis labels can be taken from the domain and range description.
name
- the name of the series (null
not permitted).domain
- the domain description (null
permitted).range
- the range description (null
permitted).timePeriodClass
- the type of time period (null
not
permitted).public String getDomainDescription()
null
).setDomainDescription(String)
public void setDomainDescription(String description)
PropertyChangeEvent
(with the property name Domain
) to all registered
property change listeners.description
- the description (null
permitted).getDomainDescription()
public String getRangeDescription()
null
).setRangeDescription(String)
public void setRangeDescription(String description)
PropertyChangeEvent
(with the property name Range
) to all registered listeners.description
- the description (null
permitted).getRangeDescription()
public int getItemCount()
getItemCount
in class Series
public List getItems()
TimeSeriesDataItem
objects and is unmodifiable).public int getMaximumItemCount()
Integer.MAX_VALUE
.setMaximumItemCount(int)
public void setMaximumItemCount(int maximum)
maximum
- the maximum (requires >= 0).getMaximumItemCount()
public long getMaximumItemAge()
setMaximumItemAge(long)
public void setMaximumItemAge(long periods)
periods
- the number of time periods.getMaximumItemAge()
public Range findValueRange()
null
data values in the series will be ignored (except for the special case
where all data values are null
, in which case the return
value is Range(Double.NaN, Double.NaN)
). If the time
series contains no items, this method will return null
.null
).public Range findValueRange(Range xRange, TimeZone timeZone)
findValueRange(xRange, TimePeriodAnchor.MIDDLE, timeZone)
.xRange
- the subrange of x-values (null
not
permitted).timeZone
- the time zone used to convert x-values to time periods
(null
not permitted).public Range findValueRange(Range xRange, TimePeriodAnchor xAnchor, TimeZone zone)
xRange
- the subset of x-values to use (null
not
permitted).xAnchor
- the anchor point for the x-values (null
not permitted).zone
- the time zone (null
not permitted).public double getMinY()
null
and Double.NaN
values. This method
returns Double.NaN
if there is no smallest y-value (for
example, when the series is empty).getMaxY()
public double getMaxY()
null
and Double.NaN
values. This method
returns Double.NaN
if there is no largest y-value
(for example, when the series is empty).getMinY()
public Class getTimePeriodClass()
Only one time period class can be used within a single series (enforced).
If you add a data item with a Year
for the time period, then all
subsequent data items must also have a Year
for the time period.
null
but only for
an empty series).public TimeSeriesDataItem getDataItem(int index)
index
- the item index.public TimeSeriesDataItem getDataItem(RegularTimePeriod period)
period
- the period of interest (null
not allowed).null
if there is no match).getDataItem(int)
public RegularTimePeriod getTimePeriod(int index)
index
- the index of the data item.public RegularTimePeriod getNextTimePeriod()
public Collection getTimePeriods()
public Collection getTimePeriodsUniqueToOtherSeries(TimeSeries series)
series
- the series to check against this one.public int getIndex(RegularTimePeriod period)
period
- the time period (null
not permitted).public Number getValue(int index)
index
- index of a value.null
).public Number getValue(RegularTimePeriod period)
null
.period
- time period (null
not permitted).null
).public void add(TimeSeriesDataItem item)
SeriesChangeEvent
to
all registered listeners.item
- the (timeperiod, value) pair (null
not
permitted).public void add(TimeSeriesDataItem item, boolean notify)
SeriesChangeEvent
to
all registered listeners.item
- the (timeperiod, value) pair (null
not
permitted).notify
- notify listeners?public void add(RegularTimePeriod period, double value)
SeriesChangeEvent
to all registered listeners.period
- the time period (null
not permitted).value
- the value.public void add(RegularTimePeriod period, double value, boolean notify)
SeriesChangeEvent
to all registered listeners.period
- the time period (null
not permitted).value
- the value.notify
- notify listeners?public void add(RegularTimePeriod period, Number value)
SeriesChangeEvent
to all registered
listeners.period
- the time period (null
not permitted).value
- the value (null
permitted).public void add(RegularTimePeriod period, Number value, boolean notify)
SeriesChangeEvent
to all registered listeners.period
- the time period (null
not permitted).value
- the value (null
permitted).notify
- notify listeners?public void update(RegularTimePeriod period, double value)
SeriesException
if the period does not exist.period
- the period (null
not permitted).value
- the value.public void update(RegularTimePeriod period, Number value)
SeriesException
if the period does not exist.period
- the period (null
not permitted).value
- the value (null
permitted).public void update(int index, Number value)
index
- the index of the data item.value
- the new value (null
permitted).public TimeSeries addAndOrUpdate(TimeSeries series)
series
- the series to merge with this.public TimeSeriesDataItem addOrUpdate(RegularTimePeriod period, double value)
SeriesChangeEvent
to all registered listeners.period
- the time period to add/update (null
not
permitted).value
- the new value.null
if no
item was overwritten.public TimeSeriesDataItem addOrUpdate(RegularTimePeriod period, Number value)
SeriesChangeEvent
to all registered listeners.period
- the time period to add/update (null
not
permitted).value
- the new value (null
permitted).null
if no
item was overwritten.public TimeSeriesDataItem addOrUpdate(TimeSeriesDataItem item)
SeriesChangeEvent
to all registered listeners.item
- the data item (null
not permitted).null
if no
item was overwritten.public void removeAgedItems(boolean notify)
notify
- controls whether or not a SeriesChangeEvent
is
sent to registered listeners IF any items are removed.public void removeAgedItems(long latest, boolean notify)
latest
- the time to be compared against when aging data
(specified in milliseconds).notify
- controls whether or not a SeriesChangeEvent
is
sent to registered listeners IF any items are removed.public void clear()
SeriesChangeEvent
to all registered listeners.public void delete(RegularTimePeriod period)
SeriesChangeEvent
to all registered listeners. If there is no
item with the specified time period, this method does nothing.period
- the period of the item to delete (null
not
permitted).public void delete(int start, int end)
start
- the index of the first period to delete.end
- the index of the last period to delete.public void delete(int start, int end, boolean notify)
start
- the index of the first period to delete.end
- the index of the last period to delete.notify
- notify listeners?public Object clone() throws CloneNotSupportedException
Notes:
clone
in class Series
CloneNotSupportedException
- not thrown by this class, but
subclasses may differ.public TimeSeries createCopy(int start, int end) throws CloneNotSupportedException
start
- the index of the first time period to copy.end
- the index of the last time period to copy.CloneNotSupportedException
- if there is a cloning problem.public TimeSeries createCopy(RegularTimePeriod start, RegularTimePeriod end) throws CloneNotSupportedException
start
- the first time period to copy (null
not
permitted).end
- the last time period to copy (null
not
permitted).CloneNotSupportedException
- if there is a cloning problem.public boolean equals(Object obj)
Jas4pp 1.5 © Java Analysis Studio for Particle Physics