Package org.jfree.data
Class XYSeries
java.lang.Object
org.jfree.data.Series
org.jfree.data.XYSeries
- All Implemented Interfaces:
Serializable,Cloneable
public class XYSeries extends Series implements Cloneable, Serializable
Represents a sequence of zero or more data items in the form (x, y). Items in
the series will be sorted into ascending order by X-value, and duplicate
X-values are permitted. Both the sorting and duplicate defaults can be
changed in the constructor. Y-values can be
null to represent
missing values.- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description XYSeries(String name)Creates a new empty series.XYSeries(String name, boolean allowDuplicateXValues)Deprecated.Use a XYSeries(String, boolean, boolean) instead.XYSeries(String name, boolean autoSort, boolean allowDuplicateXValues)Constructs a new xy-series that contains no data. -
Method Summary
Modifier and Type Method Description voidadd(double x, double y)Adds a data item to the series and sends aSeriesChangeEventto all registered listeners.voidadd(double x, double y, boolean notify)Adds a data item to the series and, if requested, sends aSeriesChangeEventto all registered listeners.voidadd(double x, Number y)Adds a data item to the series and sends aSeriesChangeEventto all registered listeners.voidadd(double x, Number y, boolean notify)Adds a data item to the series and, if requested, sends aSeriesChangeEventto all registered listeners.voidadd(Number x, Number y)Adds new data to the series and sends aSeriesChangeEventto all registered listeners.voidadd(Number x, Number y, boolean notify)Adds new data to the series and, if requested, sends aSeriesChangeEventto all registered listeners.voidadd(XYDataItem item)Adds a data item to the series and sends aSeriesChangeEventto all registered listeners.voidadd(XYDataItem item, boolean notify)Adds a data item to the series and, if requested, sends aSeriesChangeEventto all registered listeners.voidclear()Removes all data items from the series.Objectclone()Returns a clone of the series.XYSeriescreateCopy(int start, int end)Creates a new series by copying a subset of the data in this time series.voiddelete(int start, int end)Deletes a range of items from the series and sends aSeriesChangeEventto all registered listeners.booleanequals(Object object)Tests this series for equality with an arbitrary object.booleangetAllowDuplicateXValues()Returns a flag that controls whether duplicate x-values are allowed.booleangetAutoSort()Returns the flag that controls whether the items in the series are automatically sorted.XYDataItemgetDataItem(int index)Return the data item with the specified index.XYDataPairgetDataPair(int index)Deprecated.Use getDataItem(index).intgetItemCount()Returns the number of items in the series.ListgetItems()Returns the list of data items for the series (the list containsXYDataItemobjects and is unmodifiable).intgetMaximumItemCount()Returns the maximum number of items that will be retained in the series.NumbergetXValue(int index)Returns the x-value at the specified index.NumbergetYValue(int index)Returns the y-value at the specified index.inthashCode()Returns a hash code.intindexOf(Number x)Returns the index of the item with the specified x-value.XYDataItemremove(int index)Removes the item at the specified index.XYDataItemremove(Number x)Removes the item(s) with the specified x-value.voidsetMaximumItemCount(int maximum)Sets the maximum number of items that will be retained in the series.voidupdate(int index, Number y)Updates the value of an item in the series and sends aSeriesChangeEventto all registered listeners.Methods inherited from class org.jfree.data.Series
addChangeListener, addPropertyChangeListener, fireSeriesChanged, getDescription, getName, getNotify, removeChangeListener, removePropertyChangeListener, setDescription, setName, setNotify
-
Constructor Details
-
XYSeries
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:
name- the series name (nullnot permitted).
-
XYSeries
Constructs a new xy-series that contains no data. You can specify whether or not duplicate x-values are allowed for the series.- Parameters:
name- the series name (nullnot 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.
-
XYSeries
Deprecated.Use a XYSeries(String, boolean, boolean) instead.Constructs a new xy-series that contains no data. You can specify whether or not duplicate x-values are allowed for the series.- Parameters:
name- the series name.allowDuplicateXValues- a flag that controls whether duplicate x-values are allowed.
-
-
Method Details
-
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.- Returns:
- the item count.
-
getItems
Returns the list of data items for the series (the list containsXYDataItemobjects and is unmodifiable).- Returns:
- the list of data items.
-
getMaximumItemCount
public int getMaximumItemCount()Returns the maximum number of items that will be retained in the series.The default value is
Integer.MAX_VALUE).- Returns:
- the maximum item count.
-
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.
- Parameters:
maximum- the maximum.
-
add
Adds a data item to the series and sends aSeriesChangeEventto all registered listeners.- Parameters:
item- the (x, y) item (nullnot permitted).
-
add
Adds a data item to the series and, if requested, sends aSeriesChangeEventto all registered listeners.- Parameters:
item- the (x, y) item (nullnot permitted).notify- a flag that controls whether or not aSeriesChangeEventis sent to all registered listeners.
-
add
public void add(double x, double y)Adds a data item to the series and sends aSeriesChangeEventto all registered listeners.- Parameters:
x- the x value.y- the y value.
-
add
public void add(double x, double y, boolean notify)Adds a data item to the series and, if requested, sends aSeriesChangeEventto all registered listeners.- Parameters:
x- the x value.y- the y value.notify- a flag that controls whether or not aSeriesChangeEventis sent to all registered listeners.
-
add
Adds a data item to the series and sends aSeriesChangeEventto all registered listeners.The unusual pairing of parameter types is to make it easier to add
nully-values.- Parameters:
x- the x value.y- the y value (nullpermitted).
-
add
Adds a data item to the series and, if requested, sends aSeriesChangeEventto all registered listeners.The unusual pairing of parameter types is to make it easier to add null y-values.
- Parameters:
x- the x value.y- the y value (nullpermitted).notify- a flag that controls whether or not aSeriesChangeEventis sent to all registered listeners.
-
add
Adds new data to the series and sends aSeriesChangeEventto all registered listeners.Throws an exception if the x-value is a duplicate AND the allowDuplicateXValues flag is false.
- Parameters:
x- the x-value (nullnot permitted).y- the y-value (nullpermitted).
-
add
Adds new data to the series and, if requested, sends aSeriesChangeEventto all registered listeners.Throws an exception if the x-value is a duplicate AND the allowDuplicateXValues flag is false.
- Parameters:
x- the x-value (nullnot permitted).y- the y-value (nullpermitted).notify- a flag the controls whether or not aSeriesChangeEventis sent to all registered listeners.
-
delete
public void delete(int start, int end)Deletes a range of items from the series and sends aSeriesChangeEventto all registered listeners.- Parameters:
start- the start index (zero-based).end- the end index (zero-based).
-
remove
Removes the item at the specified index.- Parameters:
index- the index.- Returns:
- the item removed.
-
remove
Removes the item(s) with the specified x-value.- Parameters:
x- the x-value.- Returns:
- the item removed.
-
clear
public void clear()Removes all data items from the series. -
getDataItem
Return the data item with the specified index.- Parameters:
index- the index.- Returns:
- the data item with the specified index.
-
getXValue
Returns the x-value at the specified index.- Parameters:
index- the index (zero-based).- Returns:
- the x-value (never
null).
-
getYValue
Returns the y-value at the specified index.- Parameters:
index- the index (zero-based).- Returns:
- the y-value (possibly
null).
-
update
Updates the value of an item in the series and sends aSeriesChangeEventto all registered listeners.- Parameters:
index- the item (zero based index).y- the new value (nullpermitted).
-
indexOf
Returns the index of the item with the specified x-value. Note: if the series is not sorted in order of ascending x-values, the result is undefined.- Parameters:
x- the x-value (nullnot permitted).- Returns:
- the index.
-
clone
Returns a clone of the series.- Overrides:
clonein classSeries- Returns:
- a clone of the time series.
- Throws:
CloneNotSupportedException- if there is a cloning problem.
-
createCopy
Creates a new series by copying a subset of the data in this time series.- Parameters:
start- the index of the first item to copy.end- the index of the last item to copy.- Returns:
- a series containing a copy of this series from start until end.
- Throws:
CloneNotSupportedException- if there is a cloning problem.
-
equals
Tests this series for equality with an arbitrary object. -
hashCode
public int hashCode()Returns a hash code. -
getDataPair
Deprecated.Use getDataItem(index).Return the data pair with the specified index.- Parameters:
index- the index.- Returns:
- the data pair with the specified index.
-