Package org.jfree.data
Class ComparableObjectSeries
- java.lang.Object
-
- org.jfree.data.general.Series
-
- org.jfree.data.ComparableObjectSeries
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
- Direct Known Subclasses:
OHLCSeries
,VectorSeries
,XIntervalSeries
,XYIntervalSeries
,YIntervalSeries
public class ComparableObjectSeries extends Series implements java.lang.Cloneable, java.io.Serializable
A (possibly ordered) list of (Comparable, Object) data items.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
allowDuplicateXValues
A flag that controls whether or not duplicate x-values are allowed.private boolean
autoSort
A flag that controls whether the items are automatically sorted.protected java.util.List
data
Storage for the data items in the series.private int
maximumItemCount
The maximum number of items for the series.
-
Constructor Summary
Constructors Constructor Description ComparableObjectSeries(java.lang.Comparable key)
Creates a new empty series.ComparableObjectSeries(java.lang.Comparable key, boolean autoSort, boolean allowDuplicateXValues)
Constructs a new series that contains no data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
add(java.lang.Comparable x, java.lang.Object y)
Adds new data to the series and sends aSeriesChangeEvent
to all registered listeners.protected void
add(java.lang.Comparable x, java.lang.Object y, boolean notify)
Adds new data to the series and, if requested, sends aSeriesChangeEvent
to all registered listeners.protected void
add(ComparableObjectItem item, boolean notify)
Adds a data item to the series and, if requested, sends aSeriesChangeEvent
to all registered listeners.void
clear()
Removes all data items from the series and, unless the series is already empty, sends aSeriesChangeEvent
to all registered listeners.java.lang.Object
clone()
Returns a clone of the series.protected void
delete(int start, int end)
Deletes a range of items from the series and sends aSeriesChangeEvent
to all registered listeners.boolean
equals(java.lang.Object obj)
Tests this series for equality with an arbitrary object.boolean
getAllowDuplicateXValues()
Returns a flag that controls whether duplicate x-values are allowed.boolean
getAutoSort()
Returns the flag that controls whether the items in the series are automatically sorted.protected ComparableObjectItem
getDataItem(int index)
Return the data item with the specified index.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.int
hashCode()
Returns a hash code.int
indexOf(java.lang.Comparable x)
Returns the index of the item with the specified x-value, or a negative index if the series does not contain an item with that x-value.protected ComparableObjectItem
remove(int index)
Removes the item at the specified index and sends aSeriesChangeEvent
to all registered listeners.ComparableObjectItem
remove(java.lang.Comparable x)
Removes the item with the specified x-value and sends aSeriesChangeEvent
to all registered listeners.void
setMaximumItemCount(int maximum)
Sets the maximum number of items that will be retained in the series.protected void
update(java.lang.Comparable x, java.lang.Object y)
Updates an item in the series.protected void
updateByIndex(int index, java.lang.Object y)
Updates the value of an item in the series and sends aSeriesChangeEvent
to all registered listeners.-
Methods inherited from class org.jfree.data.general.Series
addChangeListener, addPropertyChangeListener, addVetoableChangeListener, canEqual, firePropertyChange, fireSeriesChanged, fireVetoableChange, getDescription, getKey, getNotify, isEmpty, notifyListeners, removeChangeListener, removePropertyChangeListener, removeVetoableChangeListener, setDescription, setKey, setNotify
-
-
-
-
Field Detail
-
data
protected java.util.List data
Storage for the data items in the series.
-
maximumItemCount
private int maximumItemCount
The maximum number of items for the series.
-
autoSort
private boolean autoSort
A flag that controls whether the items are automatically sorted.
-
allowDuplicateXValues
private boolean allowDuplicateXValues
A flag that controls whether or not duplicate x-values are allowed.
-
-
Constructor Detail
-
ComparableObjectSeries
public ComparableObjectSeries(java.lang.Comparable key)
Creates a new empty series. By default, items added to the series will be sorted into ascending order by x-value, and duplicate x-values will be allowed (these defaults can be modified with another constructor.- Parameters:
key
- the series key (null
not permitted).
-
ComparableObjectSeries
public ComparableObjectSeries(java.lang.Comparable key, boolean autoSort, boolean allowDuplicateXValues)
Constructs a new series that contains no data. You can specify whether or not duplicate x-values are allowed for the series.- Parameters:
key
- the series key (null
not permitted).autoSort
- a flag that controls whether or not the items in the series are sorted.allowDuplicateXValues
- a flag that controls whether duplicate x-values are allowed.
-
-
Method Detail
-
getAutoSort
public boolean getAutoSort()
Returns the flag that controls whether the items in the series are automatically sorted. There is no setter for this flag, it must be defined in the series constructor.- Returns:
- A boolean.
-
getAllowDuplicateXValues
public boolean getAllowDuplicateXValues()
Returns a flag that controls whether duplicate x-values are allowed. This flag can only be set in the constructor.- Returns:
- A boolean.
-
getItemCount
public int getItemCount()
Returns the number of items in the series.- Specified by:
getItemCount
in classSeries
- Returns:
- The item count.
-
getMaximumItemCount
public int getMaximumItemCount()
Returns the maximum number of items that will be retained in the series. The default value isInteger.MAX_VALUE
.- Returns:
- The maximum item count.
- See Also:
setMaximumItemCount(int)
-
setMaximumItemCount
public void setMaximumItemCount(int maximum)
Sets the maximum number of items that will be retained in the series. 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.Typically this value is set before the series is populated with data, but if it is applied later, it may cause some items to be removed from the series (in which case a
SeriesChangeEvent
will be sent to all registered listeners.- Parameters:
maximum
- the maximum number of items for the series.
-
add
protected void add(java.lang.Comparable x, java.lang.Object y)
Adds new data to the series and sends aSeriesChangeEvent
to all registered listeners.Throws an exception if the x-value is a duplicate AND the allowDuplicateXValues flag is false.
- Parameters:
x
- the x-value (null
not permitted).y
- the y-value (null
permitted).
-
add
protected void add(java.lang.Comparable x, java.lang.Object y, boolean notify)
Adds new data to the series and, if requested, sends aSeriesChangeEvent
to all registered listeners.Throws an exception if the x-value is a duplicate AND the allowDuplicateXValues flag is false.
- Parameters:
x
- the x-value (null
not permitted).y
- the y-value (null
permitted).notify
- a flag the controls whether or not aSeriesChangeEvent
is sent to all registered listeners.
-
add
protected void add(ComparableObjectItem item, boolean notify)
Adds a data item to the series and, if requested, sends aSeriesChangeEvent
to all registered listeners.- Parameters:
item
- the (x, y) item (null
not permitted).notify
- a flag that controls whether or not aSeriesChangeEvent
is sent to all registered listeners.
-
indexOf
public int indexOf(java.lang.Comparable x)
Returns the index of the item with the specified x-value, or a negative index if the series does not contain an item with that x-value. Be aware that for an unsorted series, the index is found by iterating through all items in the series.- Parameters:
x
- the x-value (null
not permitted).- Returns:
- The index.
-
update
protected void update(java.lang.Comparable x, java.lang.Object y)
Updates an item in the series.- Parameters:
x
- the x-value (null
not permitted).y
- the y-value (null
permitted).- Throws:
SeriesException
- if there is no existing item with the specified x-value.
-
updateByIndex
protected void updateByIndex(int index, java.lang.Object y)
Updates the value of an item in the series and sends aSeriesChangeEvent
to all registered listeners.- Parameters:
index
- the item (zero based index).y
- the new value (null
permitted).
-
getDataItem
protected ComparableObjectItem getDataItem(int index)
Return the data item with the specified index.- Parameters:
index
- the index.- Returns:
- The data item with the specified index.
-
delete
protected void delete(int start, int end)
Deletes a range of items from the series and sends aSeriesChangeEvent
to all registered listeners.- Parameters:
start
- the start index (zero-based).end
- the end index (zero-based).
-
clear
public void clear()
Removes all data items from the series and, unless the series is already empty, sends aSeriesChangeEvent
to all registered listeners.
-
remove
protected ComparableObjectItem remove(int index)
Removes the item at the specified index and sends aSeriesChangeEvent
to all registered listeners.- Parameters:
index
- the index.- Returns:
- The item removed.
-
remove
public ComparableObjectItem remove(java.lang.Comparable x)
Removes the item with the specified x-value and sends aSeriesChangeEvent
to all registered listeners.- Parameters:
x
- the x-value.- Returns:
- The item removed.
-
equals
public boolean equals(java.lang.Object obj)
Tests this series for equality with an arbitrary object.
-
hashCode
public int hashCode()
Returns a hash code.
-
-