Class 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.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
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String description
      A description of the series.
      private java.lang.Comparable key
      The key for the series.
      private javax.swing.event.EventListenerList listeners
      Storage for registered change listeners.
      private boolean notify
      A flag that controls whether changes are notified.
      private java.beans.PropertyChangeSupport propertyChangeSupport
      Object to support property change notification.
      private static long serialVersionUID
      For serialization.
      private java.beans.VetoableChangeSupport vetoableChangeSupport
      Object to support property change notification.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Series​(java.lang.Comparable key)
      Creates a new series with the specified key.
      protected Series​(java.lang.Comparable key, java.lang.String description)
      Creates a new series with the specified key and description.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void addChangeListener​(SeriesChangeListener listener)
      Registers an object with this series, to receive notification whenever the series changes.
      void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)
      Adds a property change listener to the series.
      void addVetoableChangeListener​(java.beans.VetoableChangeListener listener)
      Adds a vetoable property change listener to the series.
      boolean canEqual​(java.lang.Object other)
      Ensures symmetry between super/subclass implementations of equals.
      java.lang.Object clone()
      Returns a clone of the series.
      boolean equals​(java.lang.Object obj)
      Tests the series for equality with another object.
      protected void firePropertyChange​(java.lang.String property, java.lang.Object oldValue, java.lang.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​(java.lang.String property, java.lang.Object oldValue, java.lang.Object newValue)
      Fires a vetoable property change event.
      java.lang.String getDescription()
      Returns a description of the series.
      abstract int getItemCount()
      Returns the number of data items in the series.
      java.lang.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()
      Returns true if the series contains no data items, and false otherwise.
      protected void notifyListeners​(SeriesChangeEvent event)
      Sends a change event to all registered listeners.
      private void readObject​(java.io.ObjectInputStream stream)
      Provides serialization support.
      void removeChangeListener​(SeriesChangeListener listener)
      Deregisters an object, so that it not longer receives notification whenever the series changes.
      void removePropertyChangeListener​(java.beans.PropertyChangeListener listener)
      Removes a property change listener from the series.
      void removeVetoableChangeListener​(java.beans.VetoableChangeListener listener)
      Removes a vetoable property change listener from the series.
      void setDescription​(java.lang.String description)
      Sets the description of the series and sends a PropertyChangeEvent to all registered listeners.
      void setKey​(java.lang.Comparable key)
      Deprecated.
      In future releases the series key will be immutable.
      void setNotify​(boolean notify)
      Sets the flag that controls whether or not change events are sent to registered listeners.
      private void writeObject​(java.io.ObjectOutputStream stream)
      Provides serialization support.
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • 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 (null not 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 (null NOT permitted).
        description - the series description (null permitted).
    • 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 a VetoableChangeEvent (with the property name "Key") to all registered listeners. For backwards compatibility, this method also fires a regular PropertyChangeEvent. 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 (null not 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 a PropertyChangeEvent to all registered listeners.
        Parameters:
        description - the description (null permitted).
        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()
        Returns true if the series contains no data items, and false otherwise.
        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.CloneNotSupportedException
        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 class java.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:
        equals in class java.lang.Object
        Parameters:
        obj - the object (null permitted).
        Returns:
        true or false.
      • 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:
        hashCode in class java.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 SeriesChangeListener interface.

        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.PropertyVetoException
        Fires 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.IOException
        Provides serialization support.
        Parameters:
        stream - the output stream (null not 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.ClassNotFoundException
        Provides serialization support.
        Parameters:
        stream - the input stream (null not permitted).
        Throws:
        java.io.IOException - if there is an I/O error.
        java.lang.ClassNotFoundException - if there is a classpath problem.