|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.jrefinery.data.Series | +--com.jrefinery.data.BasicTimeSeries
Represents a sequence of zero or more data pairs in the form (period, value).
Field Summary | |
protected static java.lang.String |
DEFAULT_DOMAIN_DESCRIPTION
Default value for the domain description. |
protected static java.lang.String |
DEFAULT_RANGE_DESCRIPTION
Default value for the range description. |
Constructor Summary | |
BasicTimeSeries(java.lang.String name)
Creates a new (empty) time series. |
|
BasicTimeSeries(java.lang.String name,
java.lang.Class timePeriodClass)
Creates a new (empty) time series. |
|
BasicTimeSeries(java.lang.String name,
java.lang.String domain,
java.lang.String range,
java.lang.Class timePeriodClass)
Creates a new time series that contains no data. |
Method Summary | |
void |
add(TimePeriod period,
double value)
Adds a new data item to the series. |
void |
add(TimePeriod period,
java.lang.Number value)
Adds a new data item to the series. |
void |
add(TimeSeriesDataPair pair)
Adds a data item to the series. |
BasicTimeSeries |
addAndOrUpdate(BasicTimeSeries series)
Adds or updates data from one series to another. |
TimeSeriesDataPair |
addOrUpdate(TimePeriod period,
java.lang.Number value)
Adds or updates the times series. |
java.lang.Object |
clone()
Returns a clone of the time series. |
BasicTimeSeries |
createCopy(int start,
int end)
Creates a new timeseries by copying a subset of the data in this time series. |
BasicTimeSeries |
createCopy(TimePeriod start,
TimePeriod 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(TimePeriod period)
Deletes data for the given time period. |
TimeSeriesDataPair |
getDataPair(int index)
Returns one data pair for the series. |
TimeSeriesDataPair |
getDataPair(TimePeriod period)
Returns the data pair for a specific period. |
java.lang.String |
getDomainDescription()
Returns the domain description. |
int |
getHistoryCount()
Returns the history count for the series. |
int |
getIndex(TimePeriod period)
Returns the index of the specified time period. |
int |
getItemCount()
Returns the number of items in the series. |
int |
getMaximumItemCount()
Returns the maximum number of items that will be retained in the series. |
TimePeriod |
getNextTimePeriod()
Returns a time period that would be the next in sequence on the end of the time series. |
java.lang.String |
getRangeDescription()
Returns the range description. |
TimePeriod |
getTimePeriod(int index)
Returns the time period at the specified index. |
java.lang.Class |
getTimePeriodClass()
Returns the time period class for this series. |
java.util.Collection |
getTimePeriods()
Returns a collection of all the time periods in the time series. |
java.util.Collection |
getTimePeriodsUniqueToOtherSeries(BasicTimeSeries series)
Returns a collection of time periods in the specified series, but not in this series, and therefore unique to the specified series. |
java.lang.Number |
getValue(int index)
Returns the value at the specified index. |
java.lang.Number |
getValue(TimePeriod period)
Returns the value for a time period. |
void |
setDomainDescription(java.lang.String description)
Sets the domain description. |
void |
setHistoryCount(int 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(java.lang.String description)
Sets the range description. |
void |
update(int index,
java.lang.Number value)
Updates (changes) the value of a data pair. |
void |
update(TimePeriod period,
java.lang.Number value)
Updates (changes) the value for a time period. |
Methods inherited from class com.jrefinery.data.Series |
addChangeListener, addPropertyChangeListener, firePropertyChange, fireSeriesChanged, getDescription, getName, notifyListeners, removeChangeListener, removePropertyChangeListener, setDescription, setName |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final java.lang.String DEFAULT_DOMAIN_DESCRIPTION
protected static final java.lang.String DEFAULT_RANGE_DESCRIPTION
Constructor Detail |
public BasicTimeSeries(java.lang.String name)
By default, a daily time series is created. Use one of the other constructors if you require a different time period.
name
- the name of the series.public BasicTimeSeries(java.lang.String name, java.lang.Class timePeriodClass)
name
- the series name.timePeriodClass
- the type of time period.public BasicTimeSeries(java.lang.String name, java.lang.String domain, java.lang.String range, java.lang.Class timePeriodClass)
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.domain
- the domain description.range
- the range description.timePeriodClass
- the type of time period.Method Detail |
public java.lang.String getDomainDescription()
public void setDomainDescription(java.lang.String description)
A property change event is fired, and an undoable edit is posted.
description
- the new description.public java.lang.String getRangeDescription()
public void setRangeDescription(java.lang.String description)
Registered listeners are notified of the change.
description
- the new description.public int getItemCount()
public int getMaximumItemCount()
The default value is Integer.MAX_VALUE
).
public void setMaximumItemCount(int maximum)
If you add a new item to the series such that the number of items will exceed the maximum item count, then the FIRST element in the series is automatically removed, ensuring that the maximum item count is not exceeded.
maximum
- the maximum.public int getHistoryCount()
public void setHistoryCount(int periods)
This provides one mechanism for automatically dropping old data from the time series. For example, if a series contains daily data, you might set the history count to 30. Then, when you add a new data item, all data items more than 30 days older than the latest value are automatically dropped from the series.
periods
- the number of time periods.public java.lang.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.
public TimeSeriesDataPair getDataPair(int index)
index
- the index within the series (zero-based).public TimeSeriesDataPair getDataPair(TimePeriod period)
period
- the period of interest.public TimePeriod getTimePeriod(int index)
index
- the index of the data pair.public TimePeriod getNextTimePeriod()
public java.util.Collection getTimePeriods()
public java.util.Collection getTimePeriodsUniqueToOtherSeries(BasicTimeSeries series)
series
- the series to check against this one.public int getIndex(TimePeriod period)
period
- time period to lookup.public java.lang.Number getValue(int index)
index
- index of a value.public java.lang.Number getValue(TimePeriod period)
period
- time period to lookup.null
if the time period is not in the series.public void add(TimeSeriesDataPair pair) throws SeriesException
pair
- the (timeperiod, value) pair.SeriesException
- if there is a problem adding the data.public void add(TimePeriod period, double value) throws SeriesException
period
- the time period.value
- the value.SeriesException
- if there is a problem adding the data.public void add(TimePeriod period, java.lang.Number value) throws SeriesException
period
- the time period.value
- the value.SeriesException
- if there is a problem adding the data.public void update(TimePeriod period, java.lang.Number value) throws SeriesException
period
- the period to update.value
- the new value.SeriesException
- if there is a problem adding the data.public void update(int index, java.lang.Number value)
index
- the index of the data pair to update.value
- the new value.public BasicTimeSeries addAndOrUpdate(BasicTimeSeries series)
series
- the series to merge with this.public TimeSeriesDataPair addOrUpdate(TimePeriod period, java.lang.Number value)
period
- the time period to add/update.value
- the new value.public void delete(TimePeriod period)
period
- period to delete.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 java.lang.Object clone()
Notes:
clone
in class Series
public BasicTimeSeries createCopy(int start, int end)
start
- the index of the first time period to copy.end
- the index of the last time period to copy.public BasicTimeSeries createCopy(TimePeriod start, TimePeriod end)
start
- the first time period to copy.end
- the last time period to copy.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |