org.jfree.data
Class XYSeries

java.lang.Object
  extended byorg.jfree.data.Series
      extended byorg.jfree.data.XYSeries
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class XYSeries
extends Series
implements java.lang.Cloneable, java.io.Serializable

Represents a sequence of zero or more data items in the form (x, y).

Author:
David Gilbert
See Also:
Serialized Form

Field Summary
protected  java.util.List data
          Storage for the data items in the series.
 
Constructor Summary
XYSeries(java.lang.String name)
          Constructs a new xy-series that contains no data.
XYSeries(java.lang.String name, boolean allowDuplicateXValues)
          Constructs a new xy-series that contains no data.
 
Method Summary
 void add(double x, double y)
          Adds a data item to the series.
 void add(double x, double y, boolean notify)
          Adds a data item to the series.
 void add(double x, java.lang.Number y)
          Adds a data item to the series.
 void add(double x, java.lang.Number y, boolean notify)
          Adds a data item to the series.
 void add(java.lang.Number x, java.lang.Number y)
          Adds new data to the series.
 void add(java.lang.Number x, java.lang.Number y, boolean notify)
          Adds new data to the series.
 void add(XYDataItem item)
          Adds a data item to the series.
 void add(XYDataItem item, boolean notify)
          Adds a data item to the series.
 void clear()
          Removes all data items from the series.
 java.lang.Object clone()
          Returns a clone of the series.
 XYSeries createCopy(int start, int end)
          Creates a new series by copying a subset of the data in this time series.
 void delete(int start, int end)
          Deletes a range of items from the series.
 boolean equals(java.lang.Object object)
          Tests this series for equality with an arbitrary object.
 boolean getAllowDuplicateXValues()
          Returns whether duplicate X-Values are allowed.
 XYDataItem getDataItem(int index)
          Return the data item with the specified index.
 XYDataPair getDataPair(int index)
          Deprecated. Use getDataItem(index).
 int getItemCount()
          Returns the number of items in the series.
 java.util.List getItems()
          Returns the list of data items for the series (the list contains XYDataItem objects and is unmodifiable).
 int getMaximumItemCount()
          Returns the maximum number of items that will be retained in the series.
 java.lang.Number getXValue(int index)
          Returns the x-value at the specified index.
 java.lang.Number getYValue(int index)
          Returns the y-value at the specified index.
 void setMaximumItemCount(int maximum)
          Sets the maximum number of items that will be retained in the series.
 void update(int index, java.lang.Number y)
          Updates the value of an item in the series.
 
Methods inherited from class org.jfree.data.Series
addChangeListener, addPropertyChangeListener, firePropertyChange, fireSeriesChanged, getDescription, getName, getNotify, notifyListeners, removeChangeListener, removePropertyChangeListener, setDescription, setName, setNotify
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

protected java.util.List data
Storage for the data items in the series.

Constructor Detail

XYSeries

public XYSeries(java.lang.String name)
Constructs a new xy-series that contains no data.

By default, duplicate x-values will be allowed for the series.

Parameters:
name - the series name.

XYSeries

public XYSeries(java.lang.String name,
                boolean allowDuplicateXValues)
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 Detail

getAllowDuplicateXValues

public boolean getAllowDuplicateXValues()
Returns whether duplicate X-Values are allowed.

Returns:
a boolean.

getItemCount

public int getItemCount()
Returns the number of items in the series.

Returns:
the item count.

getItems

public java.util.List getItems()
Returns the list of data items for the series (the list contains XYDataItem objects 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

public void add(XYDataItem item)
         throws SeriesException
Adds a data item to the series. A SeriesChangeEvent is sent to all registered listeners.

Parameters:
item - the (x, y) item.
Throws:
SeriesException - if there is a problem adding the data.

add

public void add(XYDataItem item,
                boolean notify)
         throws SeriesException
Adds a data item to the series. If requested (via notify), a SeriesChangeEvent is sent to all registered listeners.

Parameters:
item - the (x, y) item.
notify - a flag that controls whether or not a SeriesChangeEvent is sent to all registered listeners.
Throws:
SeriesException - if there is a problem adding the data.

add

public void add(double x,
                double y)
         throws SeriesException
Adds a data item to the series.

Parameters:
x - the x value.
y - the y value.
Throws:
SeriesException - if there is a problem adding the data.

add

public void add(double x,
                double y,
                boolean notify)
         throws SeriesException
Adds a data item to the series.

Parameters:
x - the x value.
y - the y value.
notify - a flag that controls whether or not a SeriesChangeEvent is sent to all registered listeners.
Throws:
SeriesException - if there is a problem adding the data.

add

public void add(double x,
                java.lang.Number y)
         throws SeriesException
Adds a data item to the series.

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.
Throws:
SeriesException - if there is a problem adding the data.

add

public void add(double x,
                java.lang.Number y,
                boolean notify)
         throws SeriesException
Adds a data item to the series.

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.
notify - a flag that controls whether or not a SeriesChangeEvent is sent to all registered listeners.
Throws:
SeriesException - if there is a problem adding the data.

add

public void add(java.lang.Number x,
                java.lang.Number y)
         throws SeriesException
Adds new data to the series.

Throws an exception if the x-value is a duplicate AND the allowDuplicateXValues flag is false.

Parameters:
x - the x-value.
y - the y-value.
Throws:
SeriesException - if there is a problem adding the data.

add

public void add(java.lang.Number x,
                java.lang.Number y,
                boolean notify)
         throws SeriesException
Adds new data to the series.

Throws an exception if the x-value is a duplicate AND the allowDuplicateXValues flag is false.

Parameters:
x - the x-value.
y - the y-value.
notify - a flag the controls whether or not a SeriesChangeEvent is sent to all registered listeners.
Throws:
SeriesException - if there is a problem adding the data.

delete

public void delete(int start,
                   int end)
Deletes a range of items from the series.

Parameters:
start - the start index (zero-based).
end - the end index (zero-based).

clear

public void clear()
Removes all data items from the series.


getDataPair

public XYDataPair getDataPair(int index)
Deprecated. Use getDataItem(index).

Return the data pair with the specified index.

Parameters:
index - The index.
Returns:
The data pair with the specified index.

getDataItem

public XYDataItem getDataItem(int index)
Return the data item with the specified index.

Parameters:
index - the index.
Returns:
the data item with the specified index.

getXValue

public java.lang.Number getXValue(int index)
Returns the x-value at the specified index.

Parameters:
index - The index.
Returns:
The x-value.

getYValue

public java.lang.Number getYValue(int index)
Returns the y-value at the specified index.

Parameters:
index - The index.
Returns:
The y-value.

update

public void update(int index,
                   java.lang.Number y)
Updates the value of an item in the series.

Parameters:
index - The item (zero based index).
y - The new value.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Returns a clone of the series.

Overrides:
clone in class Series
Returns:
a clone of the time series.
Throws:
java.lang.CloneNotSupportedException - if there is a cloning problem.

createCopy

public XYSeries createCopy(int start,
                           int end)
                    throws java.lang.CloneNotSupportedException
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:
java.lang.CloneNotSupportedException - if there is a cloning problem.

equals

public boolean equals(java.lang.Object object)
Tests this series for equality with an arbitrary object.

Overrides:
equals in class Series
Parameters:
object - the object to test against for equality (null permitted).
Returns:
A boolean.