Package org.jfree.data.general
Class Series
java.lang.Object
org.jfree.data.general.Series
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
ComparableObjectSeries
,MatrixSeries
,TaskSeries
,TimePeriodValues
,TimeSeries
,XYSeries
public abstract class Series extends Object implements Cloneable, Serializable
Base class representing a data series. Subclasses are left to implement the
actual data structures.
The series has two properties ("Key" and "Description") for which you can
register a PropertyChangeListener
.
You can also register a SeriesChangeListener
to receive notification
of changes to the series data.
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Modifier Constructor Description protected
Series(Comparable key)
Creates a new series with the specified key.protected
Series(Comparable key, String description)
Creates a new series with the specified key and description. -
Method Summary
Modifier and Type Method Description void
addChangeListener(SeriesChangeListener listener)
Registers an object with this series, to receive notification whenever the series changes.void
addPropertyChangeListener(PropertyChangeListener listener)
Adds a property change listener to the series.void
addVetoableChangeListener(VetoableChangeListener listener)
Adds a vetoable property change listener to the series.Object
clone()
Returns a clone of the series.boolean
equals(Object obj)
Tests the series for equality with another object.protected void
firePropertyChange(String property, Object oldValue, Object newValue)
Fires a property change event.void
fireSeriesChanged()
General method for signalling to registered listeners that the series has been changed.protected void
fireVetoableChange(String property, Object oldValue, Object newValue)
Fires a vetoable property change event.String
getDescription()
Returns a description of the series.abstract int
getItemCount()
Returns the number of data items in the series.Comparable
getKey()
Returns the key for the series.boolean
getNotify()
Returns the flag that controls whether or not change events are sent to registered listeners.int
hashCode()
Returns a hash code.boolean
isEmpty()
Returnstrue
if the series contains no data items, andfalse
otherwise.protected void
notifyListeners(SeriesChangeEvent event)
Sends a change event to all registered listeners.void
removeChangeListener(SeriesChangeListener listener)
Deregisters an object, so that it not longer receives notification whenever the series changes.void
removePropertyChangeListener(PropertyChangeListener listener)
Removes a property change listener from the series.void
removeVetoableChangeListener(VetoableChangeListener listener)
Removes a vetoable property change listener from the series.void
setDescription(String description)
Sets the description of the series and sends aPropertyChangeEvent
to all registered listeners.void
setKey(Comparable key)
Sets the key for the series and sends aVetoableChangeEvent
(with the property name "Key") to all registered listeners.void
setNotify(boolean notify)
Sets the flag that controls whether or not change events are sent to registered listeners.
-
Constructor Details
-
Series
Creates a new series with the specified key.- Parameters:
key
- the series key (null
not permitted).
-
Series
Creates a new series with the specified key and description.- Parameters:
key
- the series key (null
NOT permitted).description
- the series description (null
permitted).
-
-
Method Details
-
getKey
Returns the key for the series.- Returns:
- The series key (never
null
). - See Also:
setKey(Comparable)
-
setKey
Sets the key for the series and sends aVetoableChangeEvent
(with the property name "Key") to all registered listeners. For backwards compatibility, this method also fires a regularPropertyChangeEvent
. If the key change is vetoed this method will throw an IllegalArgumentException.- Parameters:
key
- the key (null
not permitted).- See Also:
getKey()
-
getDescription
Returns a description of the series.- Returns:
- The series description (possibly
null
). - See Also:
setDescription(String)
-
setDescription
Sets the description of the series and sends aPropertyChangeEvent
to all registered listeners.- Parameters:
description
- the description (null
permitted).- See Also:
getDescription()
-
getNotify
Returns the flag that controls whether or not change events are sent to registered listeners.- Returns:
- A boolean.
- See Also:
setNotify(boolean)
-
setNotify
Sets the flag that controls whether or not change events are sent to registered listeners.- Parameters:
notify
- the new value of the flag.- See Also:
getNotify()
-
isEmpty
Returnstrue
if the series contains no data items, andfalse
otherwise.- Returns:
- A boolean.
-
getItemCount
Returns the number of data items in the series.- Returns:
- The number of data items in the series.
-
clone
Returns a clone of the series.Notes:
- No need to clone the name or description, since String object is immutable.
- We set the listener list to empty, since the listeners did not register with the clone.
- Same applies to the PropertyChangeSupport instance.
- Overrides:
clone
in classObject
- Returns:
- A clone of the series.
- Throws:
CloneNotSupportedException
- not thrown by this class, but subclasses may differ.
-
equals
Tests the series for equality with another object. -
hashCode
Returns a hash code. -
addChangeListener
Registers an object with this series, to receive notification whenever the series changes.Objects being registered must implement the
SeriesChangeListener
interface.- Parameters:
listener
- the listener to register.
-
removeChangeListener
Deregisters an object, so that it not longer receives notification whenever the series changes.- Parameters:
listener
- the listener to deregister.
-
fireSeriesChanged
General method for signalling to registered listeners that the series has been changed. -
notifyListeners
Sends a change event to all registered listeners.- Parameters:
event
- contains information about the event that triggered the notification.
-
addPropertyChangeListener
Adds a property change listener to the series.- Parameters:
listener
- the listener.
-
removePropertyChangeListener
Removes a property change listener from the series.- Parameters:
listener
- the listener.
-
firePropertyChange
Fires a property change event.- Parameters:
property
- the property key.oldValue
- the old value.newValue
- the new value.
-
addVetoableChangeListener
Adds a vetoable property change listener to the series.- Parameters:
listener
- the listener.
-
removeVetoableChangeListener
Removes a vetoable property change listener from the series.- Parameters:
listener
- the listener.
-
fireVetoableChange
protected void fireVetoableChange(String property, Object oldValue, Object newValue) throws PropertyVetoExceptionFires a vetoable property change event.- Parameters:
property
- the property key.oldValue
- the old value.newValue
- the new value.- Throws:
PropertyVetoException
- if the change was vetoed.
-