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
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringA description of the series.private ComparableThe key for the series.private EventListenerListStorage for registered change listeners.private booleanA flag that controls whether changes are notified.private PropertyChangeSupportObject to support property change notification.private static final longFor serialization.private VetoableChangeSupportObject to support property change notification. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSeries(Comparable key) Creates a new series with the specified key.protectedSeries(Comparable key, String description) Creates a new series with the specified key and description. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChangeListener(SeriesChangeListener listener) Registers an object with this series, to receive notification whenever the series changes.voidAdds a property change listener to the series.voidAdds a vetoable property change listener to the series.booleanEnsures symmetry between super/subclass implementations of equals.clone()Returns a clone of the series.booleanTests the series for equality with another object.protected voidfirePropertyChange(String property, Object oldValue, Object newValue) Fires a property change event.voidGeneral method for signalling to registered listeners that the series has been changed.protected voidfireVetoableChange(String property, Object oldValue, Object newValue) Fires a vetoable property change event.Returns a description of the series.abstract intReturns the number of data items in the series.getKey()Returns the key for the series.booleanReturns 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(ObjectInputStream stream) Provides serialization support.voidremoveChangeListener(SeriesChangeListener listener) Deregisters an object, so that it not longer receives notification whenever the series changes.voidRemoves a property change listener from the series.voidRemoves a vetoable property change listener from the series.voidsetDescription(String description) Sets the description of the series and sends aPropertyChangeEventto all registered listeners.voidsetKey(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(ObjectOutputStream stream) Provides serialization support.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor serialization.- See Also:
-
key
The key for the series. -
description
A description of the series. -
listeners
Storage for registered change listeners. -
propertyChangeSupport
Object to support property change notification. -
vetoableChangeSupport
Object to support property change notification. -
notify
private boolean notifyA flag that controls whether changes are notified.
-
-
Constructor Details
-
Series
Creates a new series with the specified key.- Parameters:
key- the series key (nullnot permitted).
-
Series
Creates a new series with the specified key and description.- Parameters:
key- the series key (nullNOT permitted).description- the series description (nullpermitted).
-
-
Method Details
-
getKey
Returns the key for the series.- Returns:
- The series key (never
null). - See Also:
-
setKey
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:
-
getDescription
Returns a description of the series.- Returns:
- The series description (possibly
null). - See Also:
-
setDescription
Sets the description of the series and sends aPropertyChangeEventto all registered listeners.- Parameters:
description- the description (nullpermitted).- See Also:
-
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
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:
-
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
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:
clonein 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. -
canEqual
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. -
addChangeListener
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
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
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 PropertyVetoException Fires 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.
-
writeObject
Provides serialization support.- Parameters:
stream- the output stream (nullnot permitted).- Throws:
IOException- if there is an I/O error.
-
readObject
Provides serialization support.- Parameters:
stream- the input stream (nullnot permitted).- Throws:
IOException- if there is an I/O error.ClassNotFoundException- if there is a classpath problem.
-