Package org.opensourcephysics.display
Class DatasetManager
java.lang.Object
org.opensourcephysics.display.DataTable.DataModel
org.opensourcephysics.display.DatasetManager
- All Implemented Interfaces:
Data
,Drawable
,LogMeasurable
,Measurable
DatasetManager maintains a list of datasets. Datasets are added automatically
to this DatasetCollection by calling a method in this DatasetManager with a
dataset index greater than the maximum value for the dataset index that has
been used previously. For example the statements:
DatasetManager datasetManager = new DatasetManager();
datasetManager.append(0,3,4);
datasetManager.append(1,5,6);
appends the point (3,4) to the 0th
dataset (and creates this dataset automatically) and appends the point (5,6)
to the 1-st dataset (and also creates this dataset automatically).- Version:
- 1.1
- Author:
- Joshua Gould, Wolfgang Christian
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDatasetManager constructor.DatasetManager
(boolean linked) DatasetManager constructor.DatasetManager
(boolean _connected, boolean _sorted) DatasetManager constructor specifying whether points are connected and sorted.DatasetManager
(boolean _connected, boolean _sorted, boolean _linked, int _markerShape) DatasetManager constructor specifying whether points are connected, sorted, and the marker shape. -
Method Summary
Modifier and TypeMethodDescriptionint
addDataset
(Dataset dataset) Adds a dataset.void
append
(int datasetIndex, double[] xpoints, double[] ypoints) Appends (x,y) arrays to the Dataset.void
append
(int datasetIndex, double[] xpoints, double[] ypoints, double[] delx, double[] dely) Appends arrays of data points and uncertainties to the Dataset.void
append
(int datasetIndex, double x, double y) Appends an (x,y) datum to the Dataset with the given index.void
append
(int datasetIndex, double x, double y, double delx, double dely) Appends a data point and its uncertainty to the Dataset.protected void
checkDatasetIndex
(int datasetIndex) Ensures capacityvoid
clear()
Clears all data from all Datasets.void
clear
(int datasetIndex) Clears all data from Dataset with the given datasetIndex.void
clearConstant
(String name) Clears a constant.void
draw
(DrawingPanel drawingPanel, Graphics g) Draws this Dataset in the drawing panel.double
int
Gets the number of columns for rendering in a JTable.getColumnName
(int tableColumnIndex) Gets the name of the column for rendering in a JTableString[]
The column names to be used in the data display toolgetConstantDescription
(String name) Returns the description of a constant.getConstantExpression
(String name) Returns the expression of a constant.getConstantValue
(String name) Returns the value of a constant.double[][]
Gets a 2D array of data.double[][][]
Gets a 3D array of data.Some objects (eg, a Group) do not contain data, but a list of Data objects that do.getDataset
(int datasetIndex) Gets a dataset with the given index.int
getDatasetIndex
(String yColumnName) Returns the index of the first dataset with the specified y column name.Gets a shallow clone of the dataset list.Color[]
Fill colors for Data interface.int
getID()
Returns a unique identifier for this Data.Color[]
Line colors for Data interface.static XML.ObjectLoader
Returns the XML.ObjectLoader for this class.getName()
Gets the name of this data.int
Gets the number of rows for rendering in a JTable.getUniqueYColumnName
(Component c, Dataset d, String proposed) Returns a column name that is provided by the user and is unique to this tab, contains no spaces, and is not reserved by the OSP parser.double
getValueAt
(int row, int col) double
getXMax()
Gets the x world coordinate for the right hand side of the panel.double
Gets the maximum x needed to draw this object on a log scale.double
getXMin()
Gets the x world coordinate for the left hand side of the panel.double
Gets the minimum x needed to draw this object on a log scale.double[]
getXPoints
(int datasetIndex) Gets a copy of the xpoints array.double
getYMax()
Gets y world coordinate for the top of the panel.double
Gets the maximum y needed to draw this object on a log scale on a log scale.double
getYMin()
Gets y world coordinate for the bottom of the panel.double
Gets the minimum y needed to draw this object on a log scale.double[]
getYPoints
(int datasetIndex) Gets a copy of the ypoints array.boolean
isConnected
(int datasetIndex) Gets the data connected flag.boolean
isDuplicateName
(Dataset d, String name) Returns true if name is a duplicate of an existing dataset.boolean
Gets the valid measure flag.boolean
isSorted
(int datasetIndex) Gets the sorted flag.boolean
Gets the linked flag.removeDataset
(int index) Removes the dataset at the specified index.void
Removes all Datasets from the manager.void
setConnected
(boolean _connected) Sets the connected flag for all datasets.void
setConnected
(int datasetIndex, boolean _connected) Sets the data connected flag.void
setConstant
(String name, double val, String expression) Sets the value of a constant.void
setConstant
(String name, double val, String expression, String desc) Sets the value of a constant.void
setCustomMarker
(int datasetIndex, Shape marker) Sets a custom marker shape.void
setID
(int id) Sets the ID number of this Data.void
setLineColor
(int datasetIndex, Color _lineColor) Sets the color of the lines connecting data points.void
setMarkerColor
(int datasetIndex, Color _markerColor) Sets the data point marker color.void
setMarkerColor
(int datasetIndex, Color fillColor, Color edgeColor) Sets the data point marker's fill and edge color.void
setMarkerShape
(int datasetIndex, int _markerShape) Sets the data point marker shape.void
setMarkerSize
(int datasetIndex, int _markerSize) Sets the half-width of the data point marker.void
Sets the name of this data.void
setSorted
(boolean _sorted) Sets the sorted flag for all datasets.void
setSorted
(int datasetIndex, boolean _sorted) Sets the sorted flag.void
setStride
(int _stride) Sets the stride for all datasets.void
setStride
(int datasetIndex, int stride) Sets the stride for the given dataset.void
setXColumnVisible
(int datasetIndex, boolean visible) Sets the visibility of the x column in a table view.void
setXPointsLinked
(boolean _linked) Sets the linked flag.void
setXYColumnNames
(int datasetIndex, String xColumnName, String yColumnName) Sets the column names when rendering this dataset in a JTable.void
setXYColumnNames
(int datasetIndex, String xColumnName, String yColumnName, String datsetName) Sets the column names when rendering this dataset in a JTable.void
setXYColumnNames
(String _xColumnName, String _yColumnName) Sets the column names for all datasets when rendering this dataset in a JTable.void
setYColumnVisible
(int datasetIndex, boolean visible) Sets the visibility of the y column in a table view.toString()
Create a string representation of the data.uniquifyColumnName
(Dataset d, String name) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opensourcephysics.display.Drawable
isInteractive
-
Field Details
-
model
-
dsFound
-
-
Constructor Details
-
DatasetManager
public DatasetManager()DatasetManager constructor. -
DatasetManager
public DatasetManager(boolean linked) DatasetManager constructor.- Parameters:
linked
-
-
DatasetManager
public DatasetManager(boolean _connected, boolean _sorted) DatasetManager constructor specifying whether points are connected and sorted.- Parameters:
_connected
- Description of Parameter_sorted
- Description of Parameter
-
DatasetManager
public DatasetManager(boolean _connected, boolean _sorted, boolean _linked, int _markerShape) DatasetManager constructor specifying whether points are connected, sorted, and the marker shape.- Parameters:
_connected
- Description of Parameter_sorted
- Description of Parameter_linked
-_markerShape
- Description of Parameter
-
-
Method Details
-
setXPointsLinked
public void setXPointsLinked(boolean _linked) Sets the linked flag. X data for datasets > 0 will not be shown in a table view.- Parameters:
_linked
- The new value
-
isXPointsLinked
public boolean isXPointsLinked()Gets the linked flag.- Returns:
- true if linked
-
setSorted
public void setSorted(int datasetIndex, boolean _sorted) Sets the sorted flag. Data is sorted by increasing x.- Parameters:
datasetIndex
- The new sorted value_sorted
-true<\code> to sort
-
setSorted
public void setSorted(boolean _sorted) Sets the sorted flag for all datasets.- Parameters:
_sorted
-
-
setConnected
public void setConnected(int datasetIndex, boolean _connected) Sets the data connected flag. Points are connected by straight lines.- Parameters:
datasetIndex
- The new connected value_connected
-true<\code> if points are connected
-
setConnected
public void setConnected(boolean _connected) Sets the connected flag for all datasets.- Parameters:
_connected
- true if connected; false otherwise
-
setStride
public void setStride(int datasetIndex, int stride) Sets the stride for the given dataset.- Parameters:
datasetIndex
- The new markerColor valuestride
-
-
setStride
public void setStride(int _stride) Sets the stride for all datasets.- Parameters:
_stride
-
-
setMarkerColor
Sets the data point marker color.- Parameters:
datasetIndex
-_markerColor
-
-
setMarkerColor
Sets the data point marker's fill and edge color.- Parameters:
datasetIndex
-fillColor
-edgeColor
-
-
setMarkerShape
public void setMarkerShape(int datasetIndex, int _markerShape) Sets the data point marker shape. Shapes are: NO_MARKER, CIRCLE, SQUARE, AREA, PIXEL, BAR, POST- Parameters:
datasetIndex
-_markerShape
-
-
setCustomMarker
Sets a custom marker shape.- Parameters:
datasetIndex
- intmarker
- Shape
-
setXColumnVisible
public void setXColumnVisible(int datasetIndex, boolean visible) Sets the visibility of the x column in a table view.- Parameters:
datasetIndex
-visible
-
-
setYColumnVisible
public void setYColumnVisible(int datasetIndex, boolean visible) Sets the visibility of the y column in a table view.- Parameters:
datasetIndex
-visible
-
-
setMarkerSize
public void setMarkerSize(int datasetIndex, int _markerSize) Sets the half-width of the data point marker.- Parameters:
datasetIndex
-_markerSize
- in pixels
-
setLineColor
Sets the color of the lines connecting data points.- Parameters:
datasetIndex
-_lineColor
-
-
getLineColors
Line colors for Data interface.- Specified by:
getLineColors
in interfaceData
- Returns:
- color array
-
getFillColors
Fill colors for Data interface.- Specified by:
getFillColors
in interfaceData
- Returns:
- color array
-
setXYColumnNames
public void setXYColumnNames(int datasetIndex, String xColumnName, String yColumnName, String datsetName) Sets the column names when rendering this dataset in a JTable.- Parameters:
datasetIndex
-xColumnName
-yColumnName
-datsetName
-
-
setXYColumnNames
Sets the column names when rendering this dataset in a JTable.- Parameters:
datasetIndex
-xColumnName
-yColumnName
-
-
isMeasured
public boolean isMeasured()Gets the valid measure flag. The measure is valid if the min and max values have been set for at least one dataset.- Specified by:
isMeasured
in interfaceMeasurable
- Returns:
true<\code> if measure is valid
-
setID
public void setID(int id) Sets the ID number of this Data. -
getID
public int getID()Returns a unique identifier for this Data. -
getXMin
public double getXMin()Gets the x world coordinate for the left hand side of the panel.- Specified by:
getXMin
in interfaceMeasurable
- Returns:
- xmin
-
getXMinLogscale
public double getXMinLogscale()Description copied from interface:LogMeasurable
Gets the minimum x needed to draw this object on a log scale.- Specified by:
getXMinLogscale
in interfaceLogMeasurable
- Returns:
- minimum
-
getXMax
public double getXMax()Gets the x world coordinate for the right hand side of the panel.- Specified by:
getXMax
in interfaceMeasurable
- Returns:
- xmax
-
getXMaxLogscale
public double getXMaxLogscale()Description copied from interface:LogMeasurable
Gets the maximum x needed to draw this object on a log scale.- Specified by:
getXMaxLogscale
in interfaceLogMeasurable
- Returns:
- maximum
-
getYMin
public double getYMin()Gets y world coordinate for the bottom of the panel.- Specified by:
getYMin
in interfaceMeasurable
- Returns:
- ymin
-
getYMinLogscale
public double getYMinLogscale()Description copied from interface:LogMeasurable
Gets the minimum y needed to draw this object on a log scale.- Specified by:
getYMinLogscale
in interfaceLogMeasurable
- Returns:
- minimum
-
getYMax
public double getYMax()Gets y world coordinate for the top of the panel.- Specified by:
getYMax
in interfaceMeasurable
- Returns:
- ymax
-
getYMaxLogscale
public double getYMaxLogscale()Description copied from interface:LogMeasurable
Gets the maximum y needed to draw this object on a log scale on a log scale.- Specified by:
getYMaxLogscale
in interfaceLogMeasurable
- Returns:
- maximum
-
getXPoints
public double[] getXPoints(int datasetIndex) Gets a copy of the xpoints array.- Parameters:
datasetIndex
- Description of Parameter- Returns:
- xpoints[]
-
getYPoints
public double[] getYPoints(int datasetIndex) Gets a copy of the ypoints array.- Parameters:
datasetIndex
- Description of Parameter- Returns:
- ypoints[]
-
isSorted
public boolean isSorted(int datasetIndex) Gets the sorted flag.- Parameters:
datasetIndex
- Description of Parameter- Returns:
true<\code> if the data is sorted
-
isConnected
public boolean isConnected(int datasetIndex) Gets the data connected flag.- Parameters:
datasetIndex
- Description of Parameter- Returns:
true<\code> if points are connected
-
getColumnCount
public int getColumnCount()Gets the number of columns for rendering in a JTable.- Specified by:
getColumnCount
in classDataTable.DataModel
- Returns:
- the count
-
getRowCount
public int getRowCount()Gets the number of rows for rendering in a JTable.- Specified by:
getRowCount
in classDataTable.DataModel
- Returns:
- the count
-
getName
Gets the name of this data. -
setName
Sets the name of this data.- Parameters:
name
-
-
getColumnName
Gets the name of the column for rendering in a JTable- Specified by:
getColumnName
in classDataTable.DataModel
- Parameters:
tableColumnIndex
-- Returns:
- the name
-
getValueAt
public double getValueAt(int row, int col) - Specified by:
getValueAt
in classDataTable.DataModel
-
append
public void append(int datasetIndex, double x, double y) Appends an (x,y) datum to the Dataset with the given index.- Parameters:
x
-y
-datasetIndex
- Description of Parameter
-
append
public void append(int datasetIndex, double x, double y, double delx, double dely) Appends a data point and its uncertainty to the Dataset. (not used)- Parameters:
datasetIndex
-x
-y
-delx
-dely
-
-
append
public void append(int datasetIndex, double[] xpoints, double[] ypoints) Appends (x,y) arrays to the Dataset.- Parameters:
xpoints
-ypoints
-datasetIndex
- Description of Parameter
-
append
public void append(int datasetIndex, double[] xpoints, double[] ypoints, double[] delx, double[] dely) Appends arrays of data points and uncertainties to the Dataset.- Parameters:
datasetIndex
-xpoints
-ypoints
-delx
-dely
-
-
draw
Draws this Dataset in the drawing panel. -
clear
public void clear(int datasetIndex) Clears all data from Dataset with the given datasetIndex.- Parameters:
datasetIndex
- Description of Parameter
-
clear
public void clear()Clears all data from all Datasets. Dataset properties are preserved because only the data is cleared. -
removeDatasets
public void removeDatasets()Removes all Datasets from the manager. New datasets will be created with default properties as needed. -
getDataset
Gets a dataset with the given index.- Parameters:
datasetIndex
-- Returns:
- the index
-
getDatasets
Gets a shallow clone of the dataset list. Implements Data.- Specified by:
getDatasets
in interfaceData
- Returns:
- cloned list
-
getDatasetsRaw
-
getDataList
Some objects (eg, a Group) do not contain data, but a list of Data objects that do. This method is used by Data displaying tools to create as many pages as needed.- Specified by:
getDataList
in interfaceData
- Returns:
- a list of Data objects, or null if this object contains data
-
getColumnNames
The column names to be used in the data display tool- Specified by:
getColumnNames
in interfaceData
- Returns:
- string array
-
getData2D
public double[][] getData2D()Gets a 2D array of data. Implements Data. -
getData3D
public double[][][] getData3D()Gets a 3D array of data. Implements Data. -
addDataset
Adds a dataset. Method added by Doug Brown 2007-1-15.- Parameters:
dataset
- the Dataset to add- Returns:
- the index of the added dataset
-
removeDataset
Removes the dataset at the specified index. Method added by Doug Brown 1/15/2007.- Parameters:
index
- the index- Returns:
- the removed dataset, or null if none removed
-
getDatasetIndex
Returns the index of the first dataset with the specified y column name. Method added by Doug Brown 1/15/2007.- Parameters:
yColumnName
- the y column name- Returns:
- the index, or -1 if none found
-
getConstantNames
-
getConstantValue
Returns the value of a constant. Added by Doug Brown 3/24/2011.- Parameters:
name
- the name of the constant- Returns:
- Double value of the constant, or null if not defined
-
getConstantExpression
Returns the expression of a constant. Added by Doug Brown 3/24/2011.- Parameters:
name
- the name of the constant- Returns:
- the expression, or null if not defined
-
getConstantDescription
Returns the description of a constant. Added by Doug Brown 11/23/14.- Parameters:
name
- the name of the constant- Returns:
- the description, or null if not defined
-
setConstant
Sets the value of a constant. Added by Doug Brown 3/24/2011. modified 11/23/14.- Parameters:
name
- the name of the constantval
- the value of the constantexpression
- the expression that defines the value
-
setConstant
Sets the value of a constant. Added by Doug Brown 11/23/14.- Parameters:
name
- the name of the constantval
- the value of the constantexpression
- the expression that defines the valuedesc
- the description of the constant (may be null)
-
clearConstant
Clears a constant. Added by Doug Brown 3/24/2011, modified 11/23/14.- Parameters:
name
- the name of the constant
-
toString
Create a string representation of the data. -
setXYColumnNames
Sets the column names for all datasets when rendering this dataset in a JTable.- Parameters:
_xColumnName
-_yColumnName
-
-
checkDatasetIndex
protected void checkDatasetIndex(int datasetIndex) Ensures capacity- Parameters:
datasetIndex
-
-
getLoader
Returns the XML.ObjectLoader for this class.- Returns:
- the object loader
-
getFrameDataset
-
isDuplicateName
Returns true if name is a duplicate of an existing dataset.- Parameters:
d
- the datasetname
- the proposed name for the dataset- Returns:
- true if duplicate
-
getUniqueYColumnName
Returns a column name that is provided by the user and is unique to this tab, contains no spaces, and is not reserved by the OSP parser.- Parameters:
d
- the datasetproposed
- the proposed name to be offered to the user, or null- Returns:
- unique name
-
uniquifyColumnName
-
get
-