Package org.jfree.data.xy
Class XYSeries
java.lang.Object
org.jfree.data.general.Series
org.jfree.data.xy.XYSeries
- All Implemented Interfaces:
Serializable,Cloneable
Represents a sequence of zero or more data items in the form (x, y). By
default, 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:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionXYSeries(Comparable key) Creates a new empty series.XYSeries(Comparable key, boolean autoSort) Constructs a new empty series, with the auto-sort flag set as requested, and duplicate values allowed.XYSeries(Comparable key, boolean autoSort, boolean allowDuplicateXValues) Constructs a new xy-series that contains no data. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(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.voidAdds a data item to the series and sends aSeriesChangeEventto all registered listeners.voidAdds a data item to the series and, if requested, sends aSeriesChangeEventto all registered listeners.voidAdds a new data item to the series (in the correct position if theautoSortflag is set for the series) and sends aSeriesChangeEventto all registered listeners.voidAdds 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.addOrUpdate(double x, double y) Adds or updates an item in the series and sends aSeriesChangeEventto all registered listeners.addOrUpdate(Number x, Number y) Adds or updates an item in the series and sends aSeriesChangeEventto all registered listeners.addOrUpdate(XYDataItem item) Adds or updates an item in the series and sends aSeriesChangeEventto all registered listeners.voidclear()Removes all data items from the series and sends aSeriesChangeEventto all registered listeners.clone()Returns a clone of the series.createCopy(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.booleanTests this series for equality with an arbitrary object.booleanReturns a flag that controls whether duplicate x-values are allowed.booleanReturns the flag that controls whether the items in the series are automatically sorted.getDataItem(int index) Return the data item with the specified index.intReturns the number of items in the series.getItems()Returns the list of data items for the series (the list containsXYDataItemobjects and is unmodifiable).intReturns the maximum number of items that will be retained in the series.doublegetMaxX()Returns the largest x-value in the series, ignoring any Double.NaN values.doublegetMaxY()Returns the largest y-value in the series, ignoring any Double.NaN values.doublegetMinX()Returns the smallest x-value in the series, ignoring any Double.NaN values.doublegetMinY()Returns the smallest y-value in the series, ignoring any null and Double.NaN values.getX(int index) Returns the x-value at the specified index.getY(int index) Returns the y-value at the specified index.inthashCode()Returns a hash code.intReturns 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.remove(int index) Removes the item at the specified index and sends aSeriesChangeEventto all registered listeners.Removes an item with the specified x-value and sends aSeriesChangeEventto all registered listeners.voidsetMaximumItemCount(int maximum) Sets the maximum number of items that will be retained in the series.double[][]toArray()Returns a new array containing the x and y values from this series.voidUpdates an item in the series.voidupdateByIndex(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.general.Series
addChangeListener, addPropertyChangeListener, addVetoableChangeListener, canEqual, firePropertyChange, fireSeriesChanged, fireVetoableChange, getDescription, getKey, getNotify, isEmpty, notifyListeners, removeChangeListener, removePropertyChangeListener, removeVetoableChangeListener, setDescription, setKey, setNotify
-
Field Details
-
data
Storage for the data items in the series.
-
-
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:
key- the series key (nullnot permitted).
-
XYSeries
Constructs a new empty series, with the auto-sort flag set as requested, and duplicate values allowed.- Parameters:
key- the series key (nullnot permitted).autoSort- a flag that controls whether or not the items in the series are sorted.
-
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:
key- the series key (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.
-
-
Method Details
-
getMinX
Returns the smallest x-value in the series, ignoring any Double.NaN values. This method returns Double.NaN if there is no smallest x-value (for example, when the series is empty).- Returns:
- The smallest x-value.
- See Also:
-
getMaxX
Returns the largest x-value in the series, ignoring any Double.NaN values. This method returns Double.NaN if there is no largest x-value (for example, when the series is empty).- Returns:
- The largest x-value.
- See Also:
-
getMinY
Returns the smallest y-value in the series, ignoring any null and Double.NaN values. This method returns Double.NaN if there is no smallest y-value (for example, when the series is empty).- Returns:
- The smallest y-value.
- See Also:
-
getMaxY
Returns the largest y-value in the series, ignoring any Double.NaN values. This method returns Double.NaN if there is no largest y-value (for example, when the series is empty).- Returns:
- The largest y-value.
- See Also:
-
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
Returns a flag that controls whether duplicate x-values are allowed. This flag can only be set in the constructor.- Returns:
- A boolean.
-
getItemCount
Returns the number of items in the series.- Specified by:
getItemCountin classSeries- Returns:
- The item count.
- See Also:
-
getItems
Returns the list of data items for the series (the list containsXYDataItemobjects and is unmodifiable).- Returns:
- The list of data items.
-
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
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
SeriesChangeEventwill be sent to all registered listeners).- Parameters:
maximum- the maximum number of items for the series.
-
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 sends aSeriesChangeEventto all registered listeners.- Parameters:
x- the x value.y- the y value.
-
add
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 addnully-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 a new data item to the series (in the correct position if theautoSortflag is set for 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).- Throws:
SeriesException- if the x-value is a duplicate and theallowDuplicateXValuesflag is not set for this series.
-
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.
-
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.
-
delete
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 and sends aSeriesChangeEventto all registered listeners.- Parameters:
index- the index.- Returns:
- The item removed.
-
remove
Removes an item with the specified x-value and sends aSeriesChangeEventto all registered listeners. Note that when a series permits multiple items with the same x-value, this method could remove any one of the items with that x-value.- Parameters:
x- the x-value.- Returns:
- The item removed.
-
clear
Removes all data items from the series and sends aSeriesChangeEventto all registered listeners. -
getDataItem
Return the data item with the specified index.- Parameters:
index- the index.- Returns:
- The data item with the specified index.
-
getX
Returns the x-value at the specified index.- Parameters:
index- the index (zero-based).- Returns:
- The x-value (never
null).
-
getY
Returns the y-value at the specified index.- Parameters:
index- the index (zero-based).- Returns:
- The y-value (possibly
null).
-
updateByIndex
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).
-
update
Updates an item in the series.- Parameters:
x- the x-value (nullnot permitted).y- the y-value (nullpermitted).- Throws:
SeriesException- if there is no existing item with the specified x-value.
-
addOrUpdate
Adds or updates an item in the series and sends aSeriesChangeEventto all registered listeners.- Parameters:
x- the x-value.y- the y-value.- Returns:
- The item that was overwritten, if any.
-
addOrUpdate
Adds or updates an item in the series and sends aSeriesChangeEventto all registered listeners.- Parameters:
x- the x-value (nullnot permitted).y- the y-value (nullpermitted).- Returns:
- A copy of the overwritten data item, or
nullif no item was overwritten.
-
addOrUpdate
Adds or updates an item in the series and sends aSeriesChangeEventto all registered listeners.- Parameters:
item- the data item (nullnot permitted).- Returns:
- A copy of the overwritten data item, or
nullif no item was overwritten.
-
indexOf
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 (nullnot permitted).- Returns:
- The index.
-
toArray
Returns a new array containing the x and y values from this series.- Returns:
- A new array containing the x and y values from this series.
-
clone
Returns a clone of the series.- Overrides:
clonein classSeries- Returns:
- A clone of the 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
Returns a hash code.
-