Package org.jfree.data.general
Class Series
- java.lang.Object
-
- org.jfree.data.general.Series
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
- Direct Known Subclasses:
ComparableObjectSeries,MatrixSeries,TaskSeries,TimePeriodValues,TimeSeries,XYSeries
public abstract class Series extends java.lang.Object implements java.lang.Cloneable, java.io.SerializableBase 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
SeriesChangeListenerto receive notification of changes to the series data.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringdescriptionA description of the series.private java.lang.ComparablekeyThe key for the series.private javax.swing.event.EventListenerListlistenersStorage for registered change listeners.private booleannotifyA flag that controls whether changes are notified.private java.beans.PropertyChangeSupportpropertyChangeSupportObject to support property change notification.private static longserialVersionUIDFor serialization.private java.beans.VetoableChangeSupportvetoableChangeSupportObject to support property change notification.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddChangeListener(SeriesChangeListener listener)Registers an object with this series, to receive notification whenever the series changes.voidaddPropertyChangeListener(java.beans.PropertyChangeListener listener)Adds a property change listener to the series.voidaddVetoableChangeListener(java.beans.VetoableChangeListener listener)Adds a vetoable property change listener to the series.booleancanEqual(java.lang.Object other)Ensures symmetry between super/subclass implementations of equals.java.lang.Objectclone()Returns a clone of the series.booleanequals(java.lang.Object obj)Tests the series for equality with another object.protected voidfirePropertyChange(java.lang.String property, java.lang.Object oldValue, java.lang.Object newValue)Fires a property change event.voidfireSeriesChanged()General method for signalling to registered listeners that the series has been changed.protected voidfireVetoableChange(java.lang.String property, java.lang.Object oldValue, java.lang.Object newValue)Fires a vetoable property change event.java.lang.StringgetDescription()Returns a description of the series.abstract intgetItemCount()Returns the number of data items in the series.java.lang.ComparablegetKey()Returns the key for the series.booleangetNotify()Returns the flag that controls whether or not change events are sent to registered listeners.inthashCode()Returns a hash code.booleanisEmpty()Returnstrueif the series contains no data items, andfalseotherwise.protected voidnotifyListeners(SeriesChangeEvent event)Sends a change event to all registered listeners.private voidreadObject(java.io.ObjectInputStream stream)Provides serialization support.voidremoveChangeListener(SeriesChangeListener listener)Deregisters an object, so that it not longer receives notification whenever the series changes.voidremovePropertyChangeListener(java.beans.PropertyChangeListener listener)Removes a property change listener from the series.voidremoveVetoableChangeListener(java.beans.VetoableChangeListener listener)Removes a vetoable property change listener from the series.voidsetDescription(java.lang.String description)Sets the description of the series and sends aPropertyChangeEventto all registered listeners.voidsetKey(java.lang.Comparable key)Deprecated.In future releases the series key will be immutable.voidsetNotify(boolean notify)Sets the flag that controls whether or not change events are sent to registered listeners.private voidwriteObject(java.io.ObjectOutputStream stream)Provides serialization support.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
key
private java.lang.Comparable key
The key for the series.
-
description
private java.lang.String description
A description of the series.
-
listeners
private transient javax.swing.event.EventListenerList listeners
Storage for registered change listeners.
-
propertyChangeSupport
private transient java.beans.PropertyChangeSupport propertyChangeSupport
Object to support property change notification.
-
vetoableChangeSupport
private transient java.beans.VetoableChangeSupport vetoableChangeSupport
Object to support property change notification.
-
notify
private boolean notify
A flag that controls whether changes are notified.
-
-
Constructor Detail
-
Series
protected Series(java.lang.Comparable key)
Creates a new series with the specified key.- Parameters:
key- the series key (nullnot permitted).
-
Series
protected Series(java.lang.Comparable key, java.lang.String description)Creates a new series with the specified key and description.- Parameters:
key- the series key (nullNOT permitted).description- the series description (nullpermitted).
-
-
Method Detail
-
getKey
public java.lang.Comparable getKey()
Returns the key for the series.- Returns:
- The series key (never
null). - See Also:
setKey(Comparable)
-
setKey
@Deprecated public void setKey(java.lang.Comparable key)
Deprecated.In future releases the series key will be immutable.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. This implementation is not very robust when cloning or deserialising series collections, so you should not rely upon it for that purpose. In future releases, the series key will be made immutable.- Parameters:
key- the key (nullnot permitted).- See Also:
getKey()
-
getDescription
public java.lang.String getDescription()
Returns a description of the series.- Returns:
- The series description (possibly
null). - See Also:
setDescription(String)
-
setDescription
public void setDescription(java.lang.String description)
Sets the description of the series and sends aPropertyChangeEventto all registered listeners.- Parameters:
description- the description (nullpermitted).- See Also:
getDescription()
-
getNotify
public boolean getNotify()
Returns the flag that controls whether or not change events are sent to registered listeners.- Returns:
- A boolean.
- See Also:
setNotify(boolean)
-
setNotify
public void setNotify(boolean notify)
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
public boolean isEmpty()
Returnstrueif the series contains no data items, andfalseotherwise.- Returns:
- A boolean.
-
getItemCount
public abstract int getItemCount()
Returns the number of data items in the series.- Returns:
- The number of data items in the series.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionReturns 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:
clonein classjava.lang.Object- Returns:
- A clone of the series.
- Throws:
java.lang.CloneNotSupportedException- not thrown by this class, but subclasses may differ.
-
equals
public boolean equals(java.lang.Object obj)
Tests the series for equality with another object.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the object (nullpermitted).- Returns:
trueorfalse.
-
canEqual
public boolean canEqual(java.lang.Object other)
Ensures symmetry between super/subclass implementations of equals. For more detail, see http://jqno.nl/equalsverifier/manual/inheritance.- Parameters:
other- Object- Returns:
- true ONLY if the parameter is THIS class type
-
hashCode
public int hashCode()
Returns a hash code.- Overrides:
hashCodein classjava.lang.Object- Returns:
- A hash code.
-
addChangeListener
public void addChangeListener(SeriesChangeListener listener)
Registers an object with this series, to receive notification whenever the series changes.Objects being registered must implement the
SeriesChangeListenerinterface.- Parameters:
listener- the listener to register.
-
removeChangeListener
public void removeChangeListener(SeriesChangeListener listener)
Deregisters an object, so that it not longer receives notification whenever the series changes.- Parameters:
listener- the listener to deregister.
-
fireSeriesChanged
public void fireSeriesChanged()
General method for signalling to registered listeners that the series has been changed.
-
notifyListeners
protected void notifyListeners(SeriesChangeEvent event)
Sends a change event to all registered listeners.- Parameters:
event- contains information about the event that triggered the notification.
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a property change listener to the series.- Parameters:
listener- the listener.
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a property change listener from the series.- Parameters:
listener- the listener.
-
firePropertyChange
protected void firePropertyChange(java.lang.String property, java.lang.Object oldValue, java.lang.Object newValue)Fires a property change event.- Parameters:
property- the property key.oldValue- the old value.newValue- the new value.
-
addVetoableChangeListener
public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Adds a vetoable property change listener to the series.- Parameters:
listener- the listener.
-
removeVetoableChangeListener
public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Removes a vetoable property change listener from the series.- Parameters:
listener- the listener.
-
fireVetoableChange
protected void fireVetoableChange(java.lang.String property, java.lang.Object oldValue, java.lang.Object newValue) throws java.beans.PropertyVetoExceptionFires a vetoable property change event.- Parameters:
property- the property key.oldValue- the old value.newValue- the new value.- Throws:
java.beans.PropertyVetoException- if the change was vetoed.
-
writeObject
private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOExceptionProvides serialization support.- Parameters:
stream- the output stream (nullnot permitted).- 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.ClassNotFoundExceptionProvides serialization support.- Parameters:
stream- the input stream (nullnot permitted).- Throws:
java.io.IOException- if there is an I/O error.java.lang.ClassNotFoundException- if there is a classpath problem.
-
-