Package org.jfree.data.xy
Class XYSeriesCollection
- java.lang.Object
-
- org.jfree.data.general.AbstractDataset
-
- org.jfree.data.general.AbstractSeriesDataset
-
- org.jfree.data.xy.AbstractXYDataset
-
- org.jfree.data.xy.AbstractIntervalXYDataset
-
- org.jfree.data.xy.XYSeriesCollection
-
- All Implemented Interfaces:
java.beans.VetoableChangeListener
,java.io.ObjectInputValidation
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,PublicCloneable
,DomainInfo
,Dataset
,SeriesChangeListener
,SeriesDataset
,RangeInfo
,IntervalXYDataset
,XYDataset
public class XYSeriesCollection extends AbstractIntervalXYDataset implements IntervalXYDataset, DomainInfo, RangeInfo, java.beans.VetoableChangeListener, PublicCloneable, java.io.Serializable
Represents a collection ofXYSeries
objects that can be used as a dataset.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List
data
The series that are included in the collection.private IntervalXYDelegate
intervalDelegate
The interval delegate (used to calculate the start and end x-values).private static long
serialVersionUID
For serialization.
-
Constructor Summary
Constructors Constructor Description XYSeriesCollection()
Constructs an empty dataset.XYSeriesCollection(XYSeries series)
Constructs a dataset and populates it with a single series.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSeries(XYSeries series)
Adds a series to the collection and sends aDatasetChangeEvent
to all registered listeners.java.lang.Object
clone()
Returns a clone of this instance.boolean
equals(java.lang.Object obj)
Tests this collection for equality with an arbitrary object.Range
getDomainBounds(boolean includeInterval)
Returns the range of the values in this dataset's domain.double
getDomainLowerBound(boolean includeInterval)
Returns the minimum x-value in the dataset.DomainOrder
getDomainOrder()
Returns the order of the domain (X) values, if this is known.double
getDomainUpperBound(boolean includeInterval)
Returns the maximum x-value in the dataset.java.lang.Number
getEndX(int series, int item)
Returns the ending X value for the specified series and item.java.lang.Number
getEndY(int series, int item)
Returns the ending Y value for the specified series and item.double
getIntervalPositionFactor()
Returns the interval position factor.double
getIntervalWidth()
Returns the interval width.int
getItemCount(int series)
Returns the number of items in the specified series.Range
getRangeBounds(boolean includeInterval)
Returns the range of the values in this dataset's range.double
getRangeLowerBound(boolean includeInterval)
Returns the minimum y-value in the dataset.double
getRangeUpperBound(boolean includeInterval)
Returns the maximum y-value in the dataset.java.util.List
getSeries()
Returns a list of all the series in the collection.XYSeries
getSeries(int series)
Returns a series from the collection.XYSeries
getSeries(java.lang.Comparable key)
Returns a series from the collection.int
getSeriesCount()
Returns the number of series in the collection.int
getSeriesIndex(java.lang.Comparable key)
Returns the index of the series with the specified key, or -1 if no series has that key.java.lang.Comparable
getSeriesKey(int series)
Returns the key for a series.java.lang.Number
getStartX(int series, int item)
Returns the starting X value for the specified series and item.java.lang.Number
getStartY(int series, int item)
Returns the starting Y value for the specified series and item.java.lang.Number
getX(int series, int item)
Returns the x-value for the specified series and item.java.lang.Number
getY(int series, int index)
Returns the y-value for the specified series and item.int
hashCode()
Returns a hash code.int
indexOf(XYSeries series)
Returns the index of the specified series, or -1 if that series is not present in the dataset.boolean
isAutoWidth()
Returns whether the interval width is automatically calculated or not.private void
readObject(java.io.ObjectInputStream stream)
Provides serialization support.void
removeAllSeries()
Removes all the series from the collection and sends aDatasetChangeEvent
to all registered listeners.void
removeSeries(int series)
Removes a series from the collection and sends aDatasetChangeEvent
to all registered listeners.void
removeSeries(XYSeries series)
Removes a series from the collection and sends aDatasetChangeEvent
to all registered listeners.void
setAutoWidth(boolean b)
Sets the flag that indicates whether the interval width is automatically calculated or not.void
setIntervalPositionFactor(double factor)
Sets the interval position factor.void
setIntervalWidth(double width)
Sets the interval width and sends aDatasetChangeEvent
to all registered listeners.void
vetoableChange(java.beans.PropertyChangeEvent e)
Receives notification that the key for one of the series in the collection has changed, and vetos it if the key is already present in the collection.private void
writeObject(java.io.ObjectOutputStream stream)
Provides serialization support.-
Methods inherited from class org.jfree.data.xy.AbstractIntervalXYDataset
getEndXValue, getEndYValue, getStartXValue, getStartYValue
-
Methods inherited from class org.jfree.data.xy.AbstractXYDataset
getXValue, getYValue
-
Methods inherited from class org.jfree.data.general.AbstractSeriesDataset
indexOf, seriesChanged
-
Methods inherited from class org.jfree.data.general.AbstractDataset
addChangeListener, canEqual, fireDatasetChanged, getGroup, getNotify, hasListener, notifyListeners, removeChangeListener, setGroup, setNotify, validateObject
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jfree.data.general.Dataset
addChangeListener, getGroup, removeChangeListener, setGroup
-
Methods inherited from interface org.jfree.data.xy.IntervalXYDataset
getEndXValue, getEndYValue, getStartXValue, getStartYValue
-
Methods inherited from interface org.jfree.data.general.SeriesDataset
indexOf
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
data
private java.util.List data
The series that are included in the collection.
-
intervalDelegate
private IntervalXYDelegate intervalDelegate
The interval delegate (used to calculate the start and end x-values).
-
-
Constructor Detail
-
XYSeriesCollection
public XYSeriesCollection()
Constructs an empty dataset.
-
XYSeriesCollection
public XYSeriesCollection(XYSeries series)
Constructs a dataset and populates it with a single series.- Parameters:
series
- the series (null
ignored).
-
-
Method Detail
-
getDomainOrder
public DomainOrder getDomainOrder()
Returns the order of the domain (X) values, if this is known.- Specified by:
getDomainOrder
in interfaceXYDataset
- Overrides:
getDomainOrder
in classAbstractXYDataset
- Returns:
- The domain order.
-
addSeries
public void addSeries(XYSeries series)
Adds a series to the collection and sends aDatasetChangeEvent
to all registered listeners.- Parameters:
series
- the series (null
not permitted).- Throws:
java.lang.IllegalArgumentException
- if the key for the series is null or not unique within the dataset.
-
removeSeries
public void removeSeries(int series)
Removes a series from the collection and sends aDatasetChangeEvent
to all registered listeners.- Parameters:
series
- the series index (zero-based).
-
removeSeries
public void removeSeries(XYSeries series)
Removes a series from the collection and sends aDatasetChangeEvent
to all registered listeners.- Parameters:
series
- the series (null
not permitted).
-
removeAllSeries
public void removeAllSeries()
Removes all the series from the collection and sends aDatasetChangeEvent
to all registered listeners.
-
getSeriesCount
public int getSeriesCount()
Returns the number of series in the collection.- Specified by:
getSeriesCount
in interfaceSeriesDataset
- Specified by:
getSeriesCount
in classAbstractSeriesDataset
- Returns:
- The series count.
-
getSeries
public java.util.List getSeries()
Returns a list of all the series in the collection.- Returns:
- The list (which is unmodifiable).
-
indexOf
public int indexOf(XYSeries series)
Returns the index of the specified series, or -1 if that series is not present in the dataset.- Parameters:
series
- the series (null
not permitted).- Returns:
- The series index.
-
getSeries
public XYSeries getSeries(int series)
Returns a series from the collection.- Parameters:
series
- the series index (zero-based).- Returns:
- The series.
- Throws:
java.lang.IllegalArgumentException
- ifseries
is not in the range0
togetSeriesCount() - 1
.
-
getSeries
public XYSeries getSeries(java.lang.Comparable key)
Returns a series from the collection.- Parameters:
key
- the key (null
not permitted).- Returns:
- The series with the specified key.
- Throws:
UnknownKeyException
- ifkey
is not found in the collection.
-
getSeriesKey
public java.lang.Comparable getSeriesKey(int series)
Returns the key for a series.- Specified by:
getSeriesKey
in interfaceSeriesDataset
- Specified by:
getSeriesKey
in classAbstractSeriesDataset
- Parameters:
series
- the series index (in the range0
togetSeriesCount() - 1
).- Returns:
- The key for a series.
- Throws:
java.lang.IllegalArgumentException
- ifseries
is not in the specified range.
-
getSeriesIndex
public int getSeriesIndex(java.lang.Comparable key)
Returns the index of the series with the specified key, or -1 if no series has that key.- Parameters:
key
- the key (null
not permitted).- Returns:
- The index.
-
getItemCount
public int getItemCount(int series)
Returns the number of items in the specified series.- Specified by:
getItemCount
in interfaceXYDataset
- Parameters:
series
- the series (zero-based index).- Returns:
- The item count.
- Throws:
java.lang.IllegalArgumentException
- ifseries
is not in the range0
togetSeriesCount() - 1
.
-
getX
public java.lang.Number getX(int series, int item)
Returns the x-value for the specified series and item.
-
getStartX
public java.lang.Number getStartX(int series, int item)
Returns the starting X value for the specified series and item.- Specified by:
getStartX
in interfaceIntervalXYDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The starting X value.
-
getEndX
public java.lang.Number getEndX(int series, int item)
Returns the ending X value for the specified series and item.- Specified by:
getEndX
in interfaceIntervalXYDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The ending X value.
-
getY
public java.lang.Number getY(int series, int index)
Returns the y-value for the specified series and item.
-
getStartY
public java.lang.Number getStartY(int series, int item)
Returns the starting Y value for the specified series and item.- Specified by:
getStartY
in interfaceIntervalXYDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The starting Y value.
-
getEndY
public java.lang.Number getEndY(int series, int item)
Returns the ending Y value for the specified series and item.- Specified by:
getEndY
in interfaceIntervalXYDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The ending Y value.
-
equals
public boolean equals(java.lang.Object obj)
Tests this collection for equality with an arbitrary object.- Overrides:
equals
in classAbstractDataset
- Parameters:
obj
- the object (null
permitted).- Returns:
- A boolean.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns a clone of this instance.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classAbstractDataset
- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException
- if there is a problem.
-
hashCode
public int hashCode()
Returns a hash code.- Overrides:
hashCode
in classAbstractDataset
- Returns:
- A hash code.
-
getDomainLowerBound
public double getDomainLowerBound(boolean includeInterval)
Returns the minimum x-value in the dataset.- Specified by:
getDomainLowerBound
in interfaceDomainInfo
- Parameters:
includeInterval
- a flag that determines whether the x-interval is taken into account.- Returns:
- The minimum value.
-
getDomainUpperBound
public double getDomainUpperBound(boolean includeInterval)
Returns the maximum x-value in the dataset.- Specified by:
getDomainUpperBound
in interfaceDomainInfo
- Parameters:
includeInterval
- a flag that determines whether the x-interval is taken into account.- Returns:
- The maximum value.
-
getDomainBounds
public Range getDomainBounds(boolean includeInterval)
Returns the range of the values in this dataset's domain.- Specified by:
getDomainBounds
in interfaceDomainInfo
- Parameters:
includeInterval
- a flag that determines whether the x-interval is taken into account.- Returns:
- The range (or
null
if the dataset contains no values).
-
getIntervalWidth
public double getIntervalWidth()
Returns the interval width. This is used to calculate the start and end x-values, if/when the dataset is used as anIntervalXYDataset
.- Returns:
- The interval width.
-
setIntervalWidth
public void setIntervalWidth(double width)
Sets the interval width and sends aDatasetChangeEvent
to all registered listeners.- Parameters:
width
- the width (negative values not permitted).
-
getIntervalPositionFactor
public double getIntervalPositionFactor()
Returns the interval position factor.- Returns:
- The interval position factor.
-
setIntervalPositionFactor
public void setIntervalPositionFactor(double factor)
Sets the interval position factor. This controls where the x-value is in relation to the interval surrounding the x-value (0.0 means the x-value will be positioned at the start, 0.5 in the middle, and 1.0 at the end).- Parameters:
factor
- the factor.
-
isAutoWidth
public boolean isAutoWidth()
Returns whether the interval width is automatically calculated or not.- Returns:
- Whether the width is automatically calculated or not.
-
setAutoWidth
public void setAutoWidth(boolean b)
Sets the flag that indicates whether the interval width is automatically calculated or not.- Parameters:
b
- a boolean.
-
getRangeBounds
public Range getRangeBounds(boolean includeInterval)
Returns the range of the values in this dataset's range.- Specified by:
getRangeBounds
in interfaceRangeInfo
- Parameters:
includeInterval
- ignored.- Returns:
- The range (or
null
if the dataset contains no values).
-
getRangeLowerBound
public double getRangeLowerBound(boolean includeInterval)
Returns the minimum y-value in the dataset.- Specified by:
getRangeLowerBound
in interfaceRangeInfo
- Parameters:
includeInterval
- a flag that determines whether the y-interval is taken into account.- Returns:
- The minimum value.
-
getRangeUpperBound
public double getRangeUpperBound(boolean includeInterval)
Returns the maximum y-value in the dataset.- Specified by:
getRangeUpperBound
in interfaceRangeInfo
- Parameters:
includeInterval
- a flag that determines whether the y-interval is taken into account.- Returns:
- The maximum value.
-
vetoableChange
public void vetoableChange(java.beans.PropertyChangeEvent e) throws java.beans.PropertyVetoException
Receives notification that the key for one of the series in the collection has changed, and vetos it if the key is already present in the collection.- Specified by:
vetoableChange
in interfacejava.beans.VetoableChangeListener
- Parameters:
e
- the event.- Throws:
java.beans.PropertyVetoException
- if the series name is already present in the collection.
-
writeObject
private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOException
Provides serialization support.- Parameters:
stream
- the output stream.- Throws:
java.io.IOException
- if there is an I/O error.
-
readObject
private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
Provides serialization support.- Parameters:
stream
- the input stream.- Throws:
java.io.IOException
- if there is an I/O error.java.lang.ClassNotFoundException
- if there is a classpath problem.
-
-