Class ObservationPlotModel

java.lang.Object
org.jfree.data.general.AbstractDataset
org.jfree.data.general.AbstractSeriesDataset
org.jfree.data.xy.AbstractXYDataset
org.jfree.data.xy.AbstractIntervalXYDataset
org.aavso.tools.vstar.ui.model.plot.ObservationPlotModel
All Implemented Interfaces:
ObjectInputValidation, Serializable, Cloneable, EventListener, ISeriesInfoProvider, org.jfree.data.general.Dataset, org.jfree.data.general.SeriesChangeListener, org.jfree.data.general.SeriesDataset, org.jfree.data.xy.IntervalXYDataset, org.jfree.data.xy.XYDataset
Direct Known Subclasses:
ObservationAndMeanPlotModel

public abstract class ObservationPlotModel extends org.jfree.data.xy.AbstractIntervalXYDataset implements ISeriesInfoProvider
This is the abstract base class for models that represent a series of valid variable star observations, e.g. for different bands (or from different sources). In practice, this class is only intended to be used as a the base class for ObservationAndMeanPlot. The two could be merged with the latter assuming the current class's name.
See Also:
  • Field Details

    • NO_SERIES

      protected static final int NO_SERIES
      See Also:
    • coordSrc

      protected ICoordSource coordSrc
      Coordinate and error source.
    • obComparator

      protected Comparator<ValidObservation> obComparator
      An observation comparator (e.g. to provide an ordering over time: JD or phase).
    • seriesNum

      protected int seriesNum
      A unique next series number for this model.
    • seriesNumToObSrcListMap

      protected Map<Integer,List<ValidObservation>> seriesNumToObSrcListMap
      A mapping from series number to a list of observations where each such list is a data series.
    • seriesNumToSrcTypeMap

      protected Map<Integer,SeriesType> seriesNumToSrcTypeMap
      A mapping from series number to source type.
    • srcTypeToSeriesNumMap

      protected Map<SeriesType,Integer> srcTypeToSeriesNumMap
      A mapping from source type to series number.
    • seriesVisibilityMap

      protected Map<SeriesType,Boolean> seriesVisibilityMap
      A mapping from series numbers to whether or not they visible.
    • atLeastOneVisualBandPresent

      protected boolean atLeastOneVisualBandPresent
      Is at least one visual band observation present?
    • seriesToBeJoinedVisually

      protected Set<Integer> seriesToBeJoinedVisually
      A collection of series to be joined visually.
    • discrepantListener

      protected Listener<DiscrepantObservationMessage> discrepantListener
      Discrepant observation listener.
    • excludedListener

      protected Listener<ExcludedObservationMessage> excludedListener
      Excluded observation listener.
    • lastSinglySelectedSeries

      protected SeriesType lastSinglySelectedSeries
      What was the most recently singly selected series (e.g. via a dialog).
    • modelSeriesNum

      protected int modelSeriesNum
    • modelFunctionSeriesNum

      protected int modelFunctionSeriesNum
    • residualsSeriesNum

      protected int residualsSeriesNum
    • filterSeriesNum

      protected int filterSeriesNum
  • Constructor Details

    • ObservationPlotModel

      protected ObservationPlotModel(Map<SeriesType,List<ValidObservation>> obsSourceListMap, ICoordSource coordSrc, Comparator<ValidObservation> obComparator, Map<SeriesType,Boolean> seriesVisibilityMap)
      Constructor (for phase plots). We add named observation source lists to unique series numbers, and if the visibility map is non-null, potentially change the set of visible series.
      Parameters:
      obsSourceListMap - A mapping from source series to lists of observation sources.
      coordSrc - A coordinate and error source.
      obComparator - A valid observation comparator (e.g. by JD or phase).
      seriesVisibilityMap - A mapping from series number to visibility status.
  • Method Details

    • addObservationSeries

      public int addObservationSeries(SeriesType type, List<ValidObservation> obs)
      Add an observation series.
      Parameters:
      type - The series type to be associated with the series.
      obs - A series (list) of observations, in particular, magnitude and Julian Day.
      Returns:
      The number of the series added.
    • addObservationToSeries

      public void addObservationToSeries(ValidObservation ob, SeriesType series)
      Add a single observation to a series list, creating the series first if necessary.
      Parameters:
      ob - A valid observation.
      series - A series.
    • addObservationsToSeries

      public void addObservationsToSeries(List<ValidObservation> obs, SeriesType series)
      Add a list of observations to a series list, creating the series first if necessary.
      Parameters:
      obs - The list of observations to be added.
      series - The series to which to add the list.
    • replaceObservationSeries

      public int replaceObservationSeries(SeriesType type, List<ValidObservation> obs)
      Replace an existing series
      Parameters:
      type - The series type to be associated with the series.
      obs - A series (list) of observations, in particular, magnitude and Julian Day.
      Returns:
      The number of the series replaced.
    • removeObservationFromSeries

      public boolean removeObservationFromSeries(ValidObservation ob, SeriesType series)
      Remove a single observation from a series list.
      Parameters:
      ob - A valid observation.
      series - A series.
      Returns:
      Whether or not the observation was removed.
    • removeObservationsFromSeries

      public boolean removeObservationsFromSeries(List<ValidObservation> obs, SeriesType series)
      Remove a single observation from a series list.
      Parameters:
      obs - The list of valid observations to be removed.
      series - The series from which the list is to be removed.
      Returns:
      Whether or not the observations were removed.
    • removeAllObservationFromSeries

      public boolean removeAllObservationFromSeries(SeriesType type)
      Remove all observations from the specified series, but not the series itself.
      Parameters:
      type - The series type.
      Returns:
      Whether or not the series observations were removed.
    • changeSeriesVisibility

      public boolean changeSeriesVisibility(int seriesNum, boolean visibility)
      Attempt to change the specified series' visibility.
      Parameters:
      seriesNum - The series number of interest.
      visibility - Whether this series should be visible.
      Returns:
      Whether or not the visibility of the object changed.
    • getVisibleSeries

      public Set<SeriesType> getVisibleSeries()
      Description copied from interface: ISeriesInfoProvider
      What is the current set of visible series?
      Specified by:
      getVisibleSeries in interface ISeriesInfoProvider
      Returns:
      The current set of visible series?
      See Also:
    • getSeriesCount

      public int getSeriesCount()
      Specified by:
      getSeriesCount in interface ISeriesInfoProvider
      Specified by:
      getSeriesCount in interface org.jfree.data.general.SeriesDataset
      Specified by:
      getSeriesCount in class org.jfree.data.general.AbstractSeriesDataset
      See Also:
    • getSeriesKey

      public Comparable getSeriesKey(int series)
      Specified by:
      getSeriesKey in interface org.jfree.data.general.SeriesDataset
      Specified by:
      getSeriesKey in class org.jfree.data.general.AbstractSeriesDataset
      See Also:
      • AbstractSeriesDataset.getSeriesKey(int)
    • getSeriesKeys

      public Set<SeriesType> getSeriesKeys()
      Description copied from interface: ISeriesInfoProvider
      Get a set of series keys.
      Specified by:
      getSeriesKeys in interface ISeriesInfoProvider
      Returns:
      The set of series keys.
      See Also:
    • seriesExists

      public boolean seriesExists(SeriesType type)
      Description copied from interface: ISeriesInfoProvider
      Does the specified series type exist, i.e. has it been added to the plot?
      Specified by:
      seriesExists in interface ISeriesInfoProvider
      Parameters:
      type - The series type in question.
      Returns:
      Whether the series has been added to the plot.
      See Also:
    • getObservations

      public List<ValidObservation> getObservations(SeriesType type)
      Description copied from interface: ISeriesInfoProvider
      Get the observations for the specified series.
      Specified by:
      getObservations in interface ISeriesInfoProvider
      Parameters:
      type - The series type for which observations are requested.
      Returns:
      The observation list for the specified series; may be null.
    • getItemCount

      public int getItemCount(int series)
      Specified by:
      getItemCount in interface org.jfree.data.xy.XYDataset
      Returns:
      The number of observations (items) in the requested series.
      See Also:
      • XYDataset.getItemCount(int)
    • getX

      public Number getX(int series, int item)
      Specified by:
      getX in interface org.jfree.data.xy.XYDataset
      See Also:
      • XYDataset.getX(int, int)
    • getY

      public Number getY(int series, int item)
      Specified by:
      getY in interface org.jfree.data.xy.XYDataset
      See Also:
      • XYDataset.getY(int, int)
    • getDomainOrder

      public org.jfree.data.DomainOrder getDomainOrder()
      Specified by:
      getDomainOrder in interface org.jfree.data.xy.XYDataset
      Overrides:
      getDomainOrder in class org.jfree.data.xy.AbstractXYDataset
      See Also:
      • AbstractXYDataset.getDomainOrder()
    • getSeriesWhoseElementsShouldBeJoinedVisually

      public Collection<Integer> getSeriesWhoseElementsShouldBeJoinedVisually()
      Which series' elements should be joined visually (e.g. with lines)?
      Returns:
      A collection of series numbers for series whose elements should be joined visually.
    • getStartX

      public Number getStartX(int series, int item)
      Specified by:
      getStartX in interface org.jfree.data.xy.IntervalXYDataset
    • getEndX

      public Number getEndX(int series, int item)
      Specified by:
      getEndX in interface org.jfree.data.xy.IntervalXYDataset
    • getStartY

      public Number getStartY(int series, int item)
      Specified by:
      getStartY in interface org.jfree.data.xy.IntervalXYDataset
    • getEndY

      public Number getEndY(int series, int item)
      Specified by:
      getEndY in interface org.jfree.data.xy.IntervalXYDataset
    • getNextSeriesNum

      protected int getNextSeriesNum()
    • getMagAsYCoord

      public double getMagAsYCoord(int series, int item)
      Return the magnitude as the Y coordinate.
      Parameters:
      series - The series number.
      item - The item number within the series.
      Returns:
      The magnitude value.
    • getMagError

      public double getMagError(int series, int item)
      Return the error associated with the magnitude. We skip the series and item legality check to improve performance on the assumption that this has been checked already when calling getMagAsYCoord(). So this is a precondition of calling the current function.
      Parameters:
      series - The series number.
      item - The item number within the series.
      Returns:
      The error value associated with the mean.
    • getValidObservation

      public ValidObservation getValidObservation(int series, int item)
      Given a series and item number, return the corresponding observation.
      Parameters:
      series - The series number.
      item - The item within the series.
      Returns:
      The valid observation.
      Throws:
      IllegalArgumentException - if series or item are out of range.
    • getSeriesNumToObSrcListMap

      public Map<Integer,List<ValidObservation>> getSeriesNumToObSrcListMap()
      Returns:
      the seriesNumToObSrcListMap
    • getSrcTypeToSeriesNumMap

      public Map<SeriesType,Integer> getSrcTypeToSeriesNumMap()
      Returns:
      the srcTypeToSeriesNumMap
    • getSeriesNumToSrcTypeMap

      public Map<Integer,SeriesType> getSeriesNumToSrcTypeMap()
      Returns:
      the seriesNumToSrcTypeMap
    • getSeriesVisibilityMap

      public Map<SeriesType,Boolean> getSeriesVisibilityMap()
      Returns:
      the seriesVisibilityMap
    • setLastSinglySelectedSeries

      public void setLastSinglySelectedSeries(SeriesType series)
      Parameters:
      lastSinglySelectedSeries - the lastSinglySelectedSeries to set
    • getLastSinglySelectedSeries

      public SeriesType getLastSinglySelectedSeries()
      Returns:
      the lastSinglySelectedSeries
    • isSeriesVisibleByDefault

      public boolean isSeriesVisibleByDefault(SeriesType series)
      Should the specified series be visible by default?
      Parameters:
      series - The series name.
      Returns:
      Whether or not the series should be visible by default.
    • createSeriesCreationListener

      protected Listener<SeriesCreationMessage> createSeriesCreationListener()
    • createModelSelectionListener

      protected abstract Listener<ModelSelectionMessage> createModelSelectionListener()
      Listen for a model series selection and add/remove its fit and residual observations from the relevant collections. We need to re-calculate the means series if any of the model observations' series type is the same as the mean source series type.
    • createFilteredObservationListener

      protected abstract Listener<FilteredObservationMessage> createFilteredObservationListener()
      Listen for a filtered observation and add/remove its observations from the relevant collections. We need to re-calculate the means series if any of the model observations' series type is the same as the mean source series type.