Package cnuphys.splot.pdata
Class DataSet
java.lang.Object
javax.swing.table.AbstractTableModel
javax.swing.table.DefaultTableModel
cnuphys.splot.pdata.DataSet
- All Implemented Interfaces:
Serializable
,TableModel
This is essentially a table of not necessarily equal length columns.
- Author:
- heddle
- See Also:
-
Field Summary
Fields inherited from class javax.swing.table.DefaultTableModel
columnIdentifiers, dataVector
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
Constructor Summary
ConstructorsConstructorDescriptionDataSet
(DataSetType type, String... colNames) Create a dataset of a specific typeDataSet
(Histo2DData h2d) This constructor is for a 2D histogramThis constructor is used for 1D histogramsCreate a dataset for a simple strip chart -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(double... vals) Add data values.void
add
(int column, double val) Add data value to a specific column.Add a curve to an existing data set.void
addDataChangeListener
(DataChangeListener DataChangeListener) Add a data change listenervoid
addToCurve
(int curveIndex, double... vals) Add data to a specific curve.void
clear()
Clear all the data.boolean
Has any data been addedGet all the columns of a given type.Get all curves, visible or notGet all the histo dataGet a collection of all the curves that are set visible.getColumn
(int index) Get the column at a specific indexClass<?>
getColumnClass
(int columnIndex) int
double
getColumnMax
(int index) Get the maximum value of a columndouble
getColumnMin
(int index) Get the minimum value of a columnGet all the data columnsgetColumnStyle
(int index) Get the style for a columngetCurve
(int index) Get a curve from an index.int
Get a count of all the curvesgetCurveStyle
(int index) Get the style for the curve at the given index.double
getDataMax
(DataColumnType type) Get the overall max for all columns of the given typedouble
getDataMin
(DataColumnType type) Get the overall min for all columns of the given typegetFit
(int index) Get the fit for a given columndouble[]
getMinimalArray
(int index) Get the minimal array of a column.int
int
getSize()
Get the size of the real data, This is the same as the row count.getType()
Get the DataSet typegetValueAt
(int rowIndex, int columnIndex) getXColumn
(int index) Get a x column from an index.double
getXmax()
Convenience method to get the maximum value of the x datadouble
getXmin()
Convenience method to get the minimum value of the x datadouble
getYmax()
Convenience function to get the maximum value of the y data.double
getYmin()
Convenience function to get the minimum value of the y data.boolean
Check to see if this data set has x errorsboolean
Check to see if this data set is for 1D Histogramsboolean
Check to see if this data set is for 2D Histogramsboolean
isCellEditable
(int rowIndex, int columnIndex) void
void
removeDataChangeListener
(DataChangeListener DataChangeListener) Remove a DataChangeListener.void
Set all fits to dirty.void
setValueAt
(Object aValue, int rowIndex, int columnIndex) long
size()
Get the number of data points in the first column of a plot.static double
standardDev
(double[] x) Compute the "standard" standard deviation (divide variance by N) using an accurate one-pass method.Methods inherited from class javax.swing.table.DefaultTableModel
addColumn, addColumn, addColumn, addRow, addRow, convertToVector, convertToVector, getColumnName, getDataVector, insertRow, insertRow, moveRow, newDataAvailable, newRowsAdded, removeRow, rowsRemoved, setColumnCount, setColumnIdentifiers, setColumnIdentifiers, setDataVector, setDataVector, setNumRows, setRowCount
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
-
Constructor Details
-
DataSet
This constructor is for a 2D histogram- Parameters:
h2d
-- Throws:
DataSetException
-
DataSet
This constructor is used for 1D histograms- Parameters:
histos
- an array of histo data objects- Throws:
DataSetException
-
DataSet
Create a dataset for a simple strip chart- Parameters:
stripData
- the StripData data objectcolNames
- should be just two of them
-
DataSet
Create a dataset of a specific type- Parameters:
type
- the dataset typecolNames
- 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
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
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
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
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
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
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
Get a collection of all the curves that are set visible.- Returns:
- a collection of all the curves that are set visible.
-
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
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
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
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
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
Get the fit for a given column- Parameters:
index
- the column index- Returns:
- the fit for the column
-
add
Add data values. This is the only entry point.- Parameters:
vals
- a variable number of entries for the columns- Throws:
DataSetException
-
add
Add data value to a specific column.- Parameters:
column
- the columnval
- the value- Throws:
DataSetException
-
clear
public void clear()Clear all the data. -
notifyListeners
public void notifyListeners() -
addDataChangeListener
Add a data change listener- Parameters:
DataChangeListener
- the listener to add
-
removeDataChangeListener
Remove a DataChangeListener.- Parameters:
DataChangeListener
- the DataChangeListener to remove.
-
getColumnStyle
Get the style for a column- Parameters:
index
- the column index- Returns:
- the style for this dataset
-
getColumns
Get all the data columns- Returns:
- all the data columns
-
getColumn
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 interfaceTableModel
- Overrides:
getRowCount
in classDefaultTableModel
-
getColumnCount
public int getColumnCount()- Specified by:
getColumnCount
in interfaceTableModel
- Overrides:
getColumnCount
in classDefaultTableModel
-
getColumnClass
- Specified by:
getColumnClass
in interfaceTableModel
- Overrides:
getColumnClass
in classAbstractTableModel
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex) - Specified by:
isCellEditable
in interfaceTableModel
- Overrides:
isCellEditable
in classDefaultTableModel
-
getValueAt
- Specified by:
getValueAt
in interfaceTableModel
- Overrides:
getValueAt
in classDefaultTableModel
-
setValueAt
- Specified by:
setValueAt
in interfaceTableModel
- Overrides:
setValueAt
in classDefaultTableModel
-