Class DataSet

All Implemented Interfaces:
Serializable, TableModel

public class DataSet extends DefaultTableModel
This is essentially a table of not necessarily equal length columns.
Author:
heddle
See Also:
  • Constructor Details

    • DataSet

      public DataSet(Histo2DData h2d) throws DataSetException
      This constructor is for a 2D histogram
      Parameters:
      h2d -
      Throws:
      DataSetException
    • DataSet

      public DataSet(HistoData... histos) throws DataSetException
      This constructor is used for 1D histograms
      Parameters:
      histos - an array of histo data objects
      Throws:
      DataSetException
    • DataSet

      public DataSet(StripData stripData, String... colNames)
      Create a dataset for a simple strip chart
      Parameters:
      stripData - the StripData data object
      colNames - should be just two of them
    • DataSet

      public DataSet(DataSetType type, String... colNames) throws DataSetException
      Create a dataset of a specific type
      Parameters:
      type - the dataset type
      colNames - the column names. There should be one name for every expected column based on the type.
      Throws:
      DataSetException - When the number of columns is inconsistent with the type
  • Method Details

    • size

      public long size()
      Get the number of data points in the first column of a plot.
      Returns:
      the number of data points
    • addCurve

      public DataColumn addCurve(String xname, String yname)
      Add a curve to an existing data set. For now limited to type XYXY only.
      Parameters:
      xname - the name for the new xdata (ignored for some types)
      yname - the name for the new y data
    • addToCurve

      public void addToCurve(int curveIndex, double... vals) throws DataSetException
      Add data to a specific curve. For now limited to type XYXY only.
      Throws:
      DataSetException
    • hasXErrors

      public boolean hasXErrors()
      Check to see if this data set has x errors
      Returns:
      true if this set has x errors
    • is1DHistoSet

      public boolean is1DHistoSet()
      Check to see if this data set is for 1D Histograms
      Returns:
      true if this is for 1D histograms
    • is2DHistoSet

      public boolean is2DHistoSet()
      Check to see if this data set is for 2D Histograms
      Returns:
      true if this is for 2D histograms
    • setAllFitsDirty

      public void setAllFitsDirty()
      Set all fits to dirty.
    • getCurve

      public DataColumn getCurve(int index)
      Get a curve from an index. E.g., f the index is 0 it will return the 1st Y column. Y Columns are also known as "curves".
      Parameters:
      index - the index
      Returns:
      the corresponding curve
    • getXColumn

      public DataColumn getXColumn(int index)
      Get a x column from an index. E.g., f the index is 0 it will return the 1st X column.
      Parameters:
      index - the index
      Returns:
      the corresponding X column
    • getCurveStyle

      public IStyled getCurveStyle(int index)
      Get the style for the curve at the given index.
      Parameters:
      index - the curve index.
      Returns:
      the style
    • standardDev

      public static double standardDev(double[] x)
      Compute the "standard" standard deviation (divide variance by N) using an accurate one-pass method.
      Parameters:
      x - the data
      Returns:
      the standard deviation
    • getType

      public DataSetType getType()
      Get the DataSet type
      Returns:
      the data set type
    • getColumnMin

      public double getColumnMin(int index)
      Get the minimum value of a column
      Parameters:
      index - the index of the column
      Returns:
      the minimum value of the x data
    • getColumnMax

      public double getColumnMax(int index)
      Get the maximum value of a column
      Parameters:
      index - the index of the column
      Returns:
      the maximum value of the x data
    • getAllVisibleCurves

      public Collection<DataColumn> getAllVisibleCurves()
      Get a collection of all the curves that are set visible.
      Returns:
      a collection of all the curves that are set visible.
    • getAllCurves

      public Collection<DataColumn> getAllCurves()
      Get all curves, visible or not
      Returns:
      a collection of all the curves, visible or not
    • getCurveCount

      public int getCurveCount()
      Get a count of all the curves
      Returns:
      a count of all the curves
    • dataAdded

      public boolean dataAdded()
      Has any data been added
      Returns:
      true<.code> if any data has been added.
    • getAllColumnsByType

      public Collection<DataColumn> getAllColumnsByType(DataColumnType type)
      Get all the columns of a given type. For example, all the Y columns
      Parameters:
      type - the type to match
      Returns:
      all the matching columns
    • getAllHistos

      public Vector<HistoData> getAllHistos()
      Get all the histo data
      Returns:
      a collection of the histo data
    • getXmin

      public double getXmin()
      Convenience method to get the minimum value of the x data
      Returns:
      the minimum value of the x data
    • getXmax

      public double getXmax()
      Convenience method to get the maximum value of the x data
      Returns:
      the minimum value of the x data
    • getYmin

      public double getYmin()
      Convenience function to get the minimum value of the y data. If there is more than one y column, it returns the overall minimum.
      Returns:
      the minimum value of the y data
    • getYmax

      public double getYmax()
      Convenience function to get the maximum value of the y data. If there is more than one y column, it returns the overall maximum.
      Returns:
      the maximum value of the y data
    • getDataMin

      public double getDataMin(DataColumnType type)
      Get the overall min for all columns of the given type
      Parameters:
      type - the type to match
      Returns:
      the overall min for the given type
    • getDataMax

      public double getDataMax(DataColumnType type)
      Get the overall max for all columns of the given type
      Parameters:
      type - the type to match
      Returns:
      the overall max for the given type
    • getMinimalArray

      public double[] getMinimalArray(int index)
      Get the minimal array of a column. The minimal array is a copy from the underlying GrowableArray that is the same size as the amount of real data.
      Parameters:
      index - the column index
      Returns:
      the minimal array
    • getSize

      public int getSize()
      Get the size of the real data, This is the same as the row count.
      Returns:
      the data count
    • getFit

      public Fit getFit(int index)
      Get the fit for a given column
      Parameters:
      index - the column index
      Returns:
      the fit for the column
    • add

      public void add(double... vals) throws DataSetException
      Add data values. This is the only entry point.
      Parameters:
      vals - a variable number of entries for the columns
      Throws:
      DataSetException
    • add

      public void add(int column, double val) throws DataSetException
      Add data value to a specific column.
      Parameters:
      column - the column
      val - the value
      Throws:
      DataSetException
    • clear

      public void clear()
      Clear all the data.
    • notifyListeners

      public void notifyListeners()
    • addDataChangeListener

      public void addDataChangeListener(DataChangeListener DataChangeListener)
      Add a data change listener
      Parameters:
      DataChangeListener - the listener to add
    • removeDataChangeListener

      public void removeDataChangeListener(DataChangeListener DataChangeListener)
      Remove a DataChangeListener.
      Parameters:
      DataChangeListener - the DataChangeListener to remove.
    • getColumnStyle

      public Styled getColumnStyle(int index)
      Get the style for a column
      Parameters:
      index - the column index
      Returns:
      the style for this dataset
    • getColumns

      public Collection<DataColumn> getColumns()
      Get all the data columns
      Returns:
      all the data columns
    • getColumn

      public DataColumn getColumn(int index)
      Get the column at a specific index
      Parameters:
      index - the column index
      Returns:
      the column at a specific index
    • getRowCount

      public int getRowCount()
      Specified by:
      getRowCount in interface TableModel
      Overrides:
      getRowCount in class DefaultTableModel
    • getColumnCount

      public int getColumnCount()
      Specified by:
      getColumnCount in interface TableModel
      Overrides:
      getColumnCount in class DefaultTableModel
    • getColumnClass

      public Class<?> getColumnClass(int columnIndex)
      Specified by:
      getColumnClass in interface TableModel
      Overrides:
      getColumnClass in class AbstractTableModel
    • isCellEditable

      public boolean isCellEditable(int rowIndex, int columnIndex)
      Specified by:
      isCellEditable in interface TableModel
      Overrides:
      isCellEditable in class DefaultTableModel
    • getValueAt

      public Object getValueAt(int rowIndex, int columnIndex)
      Specified by:
      getValueAt in interface TableModel
      Overrides:
      getValueAt in class DefaultTableModel
    • setValueAt

      public void setValueAt(Object aValue, int rowIndex, int columnIndex)
      Specified by:
      setValueAt in interface TableModel
      Overrides:
      setValueAt in class DefaultTableModel