|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.table.AbstractTableModel org.opensourcephysics.display.Dataset
public class Dataset
Dataset stores and plots (x,y) points. Dataset is Drawable and can be rendered on a DrawingPanel. Dataset extends AbstractTableModel and can be rendered in a JTable.
Nested Class Summary | |
---|---|
protected static class |
Dataset.Loader
A class to save and load Dataset data in an XMLControl. |
Field Summary | |
---|---|
static int |
AREA
Field AREA |
static int |
BAR
Field BAR |
static int |
CIRCLE
Field CIRCLE |
protected int |
columnID
Field columnID: an integer used by DataTool |
static int |
CUSTOM
Field POST |
protected java.awt.Shape |
customMarker
|
protected int |
datasetID
Field datasetID: an integer ID that identifies this object |
protected java.util.ArrayList<org.opensourcephysics.display.Dataset.ErrorBar> |
errorBars
|
protected java.awt.geom.GeneralPath |
generalPath
|
protected int |
index
|
protected int |
maxPoints
|
static int |
NO_MARKER
Field NO_MARKER |
static int |
PIXEL
Field PIXEL |
static int |
POST
Field POST |
protected boolean |
sorted
|
static int |
SQUARE
Field SQUARE |
protected boolean |
visible
|
protected double |
xmax
|
protected double |
xmaxLogscale
|
protected double |
xmin
|
protected double |
xminLogscale
|
protected double[] |
xpoints
|
protected double |
ymax
|
protected double |
ymaxLogscale
|
protected double |
ymin
|
protected double |
yminLogscale
|
protected double[] |
ypoints
|
Fields inherited from class javax.swing.table.AbstractTableModel |
---|
listenerList |
Constructor Summary | |
---|---|
Dataset()
Dataset constructor. |
|
Dataset(java.awt.Color _markerColor)
Dataset constructor specifying the marker color. |
|
Dataset(java.awt.Color markerColor,
java.awt.Color _lineColor,
boolean _connected)
Dataset constructor specifying the marker color, line color, and whether points are connected. |
Method Summary | |
---|---|
void |
append(double[] _xpoints,
double[] _ypoints)
Appends (x,y) arrays to the Dataset. |
void |
append(double[] xpoints,
double[] ypoints,
double[] delx,
double[] dely)
Appends arrays of data points and uncertainties to the Dataset. |
void |
append(double x,
double y)
Appends an (x,y) datum to the Dataset. |
void |
append(double x,
double y,
double delx,
double dely)
Appends a data point and its uncertainty to the Dataset. |
void |
clear()
Clear all data from this Dataset. |
static int |
convertTableColumnIndex(boolean[] visible,
int columnIndex)
Converts a table column in a table model to the appropriate table column. |
static int |
countColumnsVisible(boolean[] visible)
Counts the number of columns visible |
void |
draw(DrawingPanel drawingPanel,
java.awt.Graphics g)
Draw this Dataset in the drawing panel. |
protected void |
drawFilledPlot(DrawingPanel drawingPanel,
java.awt.Graphics2D g2)
Fills the line connecting the data points. |
protected void |
drawLinePlot(DrawingPanel drawingPanel,
java.awt.Graphics2D g2)
Draw the lines connecting the data points. |
protected void |
drawScatterPlot(DrawingPanel drawingPanel,
java.awt.Graphics2D g2)
Draw the markers at the data points. |
java.lang.Class<?> |
getColumnClass(int columnIndex)
Gets the type of object for JTable entry. |
int |
getColumnCount()
Gets the number of columns for rendering in a JTable. |
int |
getColumnID()
Returns the column ID. |
java.lang.String |
getColumnName(int columnIndex)
Gets the name of the colummn for rendering in a JTable |
java.lang.String[] |
getColumnNames()
The column names to be used in the data tool |
double[][] |
getData2D()
Gets a data array containing both x and y values. |
double[][][] |
getData3D()
Returns a null 3D array of data. |
java.util.List<Data> |
getDataList()
Some Data objects (e.g., a Group) do not contain data, but a list of Data objects which do. |
java.util.ArrayList<Dataset> |
getDatasets()
Returns a list containing this Dataset. |
java.awt.Color |
getEdgeColor()
Gets the data point edge color. |
java.awt.Color |
getFillColor()
Gets the data point fill color. |
java.awt.Color[] |
getFillColors()
Fill colors for Data interface. |
int |
getID()
Returns a unique identifier for this Data. |
int |
getIndex()
Gets the current index of the array. |
java.awt.Color |
getLineColor()
Gets the line color. |
java.awt.Color[] |
getLineColors()
Line colors for Data interface. |
static XML.ObjectLoader |
getLoader()
Returns the XML.ObjectLoader for this class. |
int |
getMarkerShape()
Gets the data point marker shape. |
int |
getMarkerSize()
Gets the half-width of the data point marker. |
java.lang.String |
getName()
Gets the dataset name. |
double[][] |
getPoints()
Gets a data array containing both x and y values. |
int |
getRowCount()
Gets the number of rows for rendering in a JTable. |
double[] |
getValidXPoints()
Gets an array of valid xpoints. |
double[] |
getValidYPoints()
Gets an array of valid ypoints. |
java.lang.Object |
getValueAt(int rowIndex,
int columnIndex)
Gets an x or y value for rendering in a JTable. |
boolean |
getVisible()
Gets the visibiliyt of htis dataset in a DrawingPanel. |
java.lang.String |
getXColumnName()
Gets the x column name. |
double |
getXMax()
Gets the x world coordinate for the right hand side of the panel. |
double |
getXMaxLogscale()
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 |
getXMinLogscale()
Gets the minimum x needed to draw this object on a log scale. |
double[] |
getXPoints()
Gets a copy of the xpoints array. |
java.lang.String |
getYColumnName()
Gets the y column name. |
double |
getYMax()
Gets y world coordinate for the top of the panel. |
double |
getYMaxLogscale()
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 |
getYMinLogscale()
Gets the minimum y needed to draw this object on a log scale. |
double[] |
getYPoints()
Gets a copy of the ypoints array. |
protected void |
insertionSort()
Perform an insertion sort of the data set. |
boolean |
isConnected()
Gets the data connected flag. |
boolean |
isMeasured()
Gets the valid measure flag. |
boolean |
isSorted()
Gets the sorted flag. |
boolean |
isXColumnVisible()
Gets the visibility of the x column of this Dataset in a table view. |
boolean |
isYColumnVisible()
Gets the visibility of the y column of this Dataset in a table view. |
protected void |
moveDatum(int loc)
Move an out-of-place datum into its correct position. |
void |
read(java.lang.String inputFile)
Reads a file and appends the data contained in the file to this Dataset. |
protected void |
recalculatePath()
Recalculate the general path. |
void |
setColumnID(int id)
Sets the column ID. |
void |
setConnected(boolean _connected)
Sets the data connected flag. |
void |
setCustomMarker(java.awt.Shape marker)
Sets a custom marker shape. |
void |
setID(int id)
Sets the ID number of this Data. |
void |
setLineColor(java.awt.Color _lineColor)
Sets the color of the lines connecting data points. |
void |
setMarkerColor(java.awt.Color markerColor)
Sets the data point fill, edge, and error bar colors to the same color. |
void |
setMarkerColor(java.awt.Color _fillColor,
java.awt.Color _edgeColor)
Sets the data point marker colors. |
void |
setMarkerColor(java.awt.Color _fillColor,
java.awt.Color _edgeColor,
java.awt.Color _errorBarColor)
Sets the data point marker colors. |
void |
setMarkerShape(int _markerShape)
Sets the data point marker shape. |
void |
setMarkerSize(int _markerSize)
Sets the half-width of the data point marker. |
void |
setMaximumPoints(int maxPoints)
Sets the maximum number of allowed datapoints. |
void |
setName(java.lang.String name)
Sets a name that can be used to identify the dataset. |
void |
setSorted(boolean _sorted)
Sets the sorted flag. |
void |
setStride(int _stride)
Sets the stride of this Dataset in a table view. |
void |
setVisible(boolean b)
Sets the visibility of this Dataset in a DrawingPanel. |
void |
setXColumnVisible(boolean b)
Sets the visibility of the x column of this Dataset in a table view. |
void |
setXYColumnNames(java.lang.String _xColumnName,
java.lang.String _yColumnName)
Sets the column names when rendering this dataset in a JTable. |
void |
setXYColumnNames(java.lang.String xColumnName,
java.lang.String yColumnName,
java.lang.String name)
Sets the column names and the dataset name. |
void |
setYColumnVisible(boolean b)
Sets the visibility of the y column of this Dataset in a table view. |
java.lang.String |
toString()
Creates a string representation of the data. |
void |
write(java.lang.String outputFile)
Writes data from this Dataset to a file. |
Methods inherited from class javax.swing.table.AbstractTableModel |
---|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int datasetID
protected int columnID
public static final int NO_MARKER
public static final int CIRCLE
public static final int SQUARE
public static final int AREA
public static final int PIXEL
public static final int BAR
public static final int POST
public static final int CUSTOM
protected double[] xpoints
protected double[] ypoints
protected java.awt.geom.GeneralPath generalPath
protected double xmax
protected double ymax
protected double xmin
protected double ymin
protected double xmaxLogscale
protected double ymaxLogscale
protected double xminLogscale
protected double yminLogscale
protected int index
protected boolean sorted
protected boolean visible
protected int maxPoints
protected java.util.ArrayList<org.opensourcephysics.display.Dataset.ErrorBar> errorBars
protected java.awt.Shape customMarker
Constructor Detail |
---|
public Dataset()
public Dataset(java.awt.Color _markerColor)
_markerColor
- public Dataset(java.awt.Color markerColor, java.awt.Color _lineColor, boolean _connected)
markerColor
- _lineColor
- _connected
- Method Detail |
---|
public void setID(int id)
setID
in interface Data
id
- the ID numberpublic int getID()
getID
in interface Data
public void setColumnID(int id)
id
- the column IDpublic int getColumnID()
public void setSorted(boolean _sorted)
_sorted
- true<\code> to sort
public void setConnected(boolean _connected)
_connected
- true<\code> if points are connected
public void setMarkerColor(java.awt.Color markerColor)
markerColor
- public void setMarkerColor(java.awt.Color _fillColor, java.awt.Color _edgeColor)
_fillColor
- _edgeColor
- public void setMarkerColor(java.awt.Color _fillColor, java.awt.Color _edgeColor, java.awt.Color _errorBarColor)
_fillColor
- _edgeColor
- _errorBarColor
- public java.awt.Color getFillColor()
public java.awt.Color[] getFillColors()
getFillColors
in interface Data
public java.awt.Color getEdgeColor()
public java.awt.Color getLineColor()
public java.awt.Color[] getLineColors()
getLineColors
in interface Data
public void setCustomMarker(java.awt.Shape marker)
marker
- Shapepublic void setMarkerShape(int _markerShape)
_markerShape
- public int getMarkerShape()
public void setMarkerSize(int _markerSize)
_markerSize
- in pixelspublic void setMaximumPoints(int maxPoints)
maxPoints
- intpublic int getMarkerSize()
public void setLineColor(java.awt.Color _lineColor)
_lineColor
- public void setXYColumnNames(java.lang.String _xColumnName, java.lang.String _yColumnName)
_xColumnName
- _yColumnName
- public void setXYColumnNames(java.lang.String xColumnName, java.lang.String yColumnName, java.lang.String name)
xColumnName
- yColumnName
- name
- public java.lang.String getXColumnName()
public java.lang.String getYColumnName()
public void setName(java.lang.String name)
name
- Stringpublic java.lang.String getName()
getName
in interface Data
public java.util.List<Data> getDataList()
getDataList
in interface Data
public java.lang.String[] getColumnNames()
getColumnNames
in interface Data
public boolean isMeasured()
isMeasured
in interface Measurable
true<\code> if measure is valid
public double getXMin()
getXMin
in interface Measurable
public double getXMax()
getXMax
in interface Measurable
public double getYMin()
getYMin
in interface Measurable
public double getYMax()
getYMax
in interface Measurable
public double getXMinLogscale()
getXMinLogscale
in interface LogMeasurable
public double getXMaxLogscale()
getXMaxLogscale
in interface LogMeasurable
public double getYMinLogscale()
getYMinLogscale
in interface LogMeasurable
public double getYMaxLogscale()
getYMaxLogscale
in interface LogMeasurable
public double[][] getPoints()
public double[][] getData2D()
getData2D
in interface Data
public double[][][] getData3D()
getData3D
in interface Data
public java.util.ArrayList<Dataset> getDatasets()
getDatasets
in interface Data
public double[] getXPoints()
public double[] getYPoints()
public double[] getValidXPoints()
public double[] getValidYPoints()
public boolean isSorted()
true<\code> if the data is sorted
public boolean isConnected()
true<\code> if points are connected
public int getColumnCount()
getColumnCount
in interface javax.swing.table.TableModel
public int getIndex()
public int getRowCount()
getRowCount
in interface javax.swing.table.TableModel
public java.lang.String getColumnName(int columnIndex)
getColumnName
in interface javax.swing.table.TableModel
getColumnName
in class javax.swing.table.AbstractTableModel
columnIndex
-
public java.lang.Object getValueAt(int rowIndex, int columnIndex)
getValueAt
in interface javax.swing.table.TableModel
rowIndex
- columnIndex
-
public java.lang.Class<?> getColumnClass(int columnIndex)
getColumnClass
in interface javax.swing.table.TableModel
getColumnClass
in class javax.swing.table.AbstractTableModel
columnIndex
-
public void append(double x, double y, double delx, double dely)
x
- y
- delx
- dely
- public void append(double x, double y)
x
- y
- public void append(double[] xpoints, double[] ypoints, double[] delx, double[] dely)
xpoints
- ypoints
- delx
- dely
- public void append(double[] _xpoints, double[] _ypoints)
_xpoints
- _ypoints
- public void read(java.lang.String inputFile)
inputFile
- public void write(java.lang.String outputFile)
outputFile
- public void draw(DrawingPanel drawingPanel, java.awt.Graphics g)
draw
in interface Drawable
drawingPanel
- g
- public void clear()
public java.lang.String toString()
toString
in class java.lang.Object
public static int countColumnsVisible(boolean[] visible)
visible
- array of column visibilities
public static int convertTableColumnIndex(boolean[] visible, int columnIndex)
visible
- array of column visibilitiescolumnIndex
- table column index to convert
public void setXColumnVisible(boolean b)
b
- new visibilitypublic void setYColumnVisible(boolean b)
b
- new visibilitypublic void setVisible(boolean b)
b
- new visibilitypublic boolean getVisible()
public void setStride(int _stride)
_stride
- the stridepublic boolean isXColumnVisible()
public boolean isYColumnVisible()
protected void insertionSort()
protected void recalculatePath()
protected void moveDatum(int loc)
loc
- the datumprotected void drawLinePlot(DrawingPanel drawingPanel, java.awt.Graphics2D g2)
drawingPanel
- g2
- protected void drawFilledPlot(DrawingPanel drawingPanel, java.awt.Graphics2D g2)
drawingPanel
- g2
- protected void drawScatterPlot(DrawingPanel drawingPanel, java.awt.Graphics2D g2)
drawingPanel
- g2
- public static XML.ObjectLoader getLoader()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |