Package org.opensourcephysics.display
Class ComplexDataset
java.lang.Object
org.opensourcephysics.display.DataTable.DataModel
org.opensourcephysics.display.ComplexDataset
- All Implemented Interfaces:
Data
,Drawable
,Measurable
ComplexDataset stores and plots a complex dataset (x,z) where the dependent
variable has real and imaginary parts, z=(real, imaginary).
In Re_Im mode, both the real and imaginary parts are shown as separate
curves. In Phase mode, the vertical coordinate represents magnitude and color
represents phase. ComplexDataset is Drawable and can be rendered on a
DrawingPanel. ComplexDataset extends AbstractTableModel and can be rendered
in a JTable.
- Version:
- 1.0
- Author:
- Wolfgang Christian
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
AMP height equal to |z|..protected double[]
protected double[]
protected int
protected boolean
affect autoscaled drawing panelsfinal ComplexDataset.Model
static final int
PHASE_BAR the phase is shown as the bar's colorstatic final int
PHASE_CURVE the phase is shown as color.static final int
Field POSTstatic final int
RE_IM real and imaginary curves.protected double[]
protected boolean
visible in drawing panelprotected double[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
append
(double[] _xpoints, double[] _zpoints) Appends x and z data to the Dataset.void
append
(double[] _xpoints, double[] _repoints, double[] _impoints) Appends x, real, and imaginary arrays to the Dataset.void
append
(double x, double re, double im) Appends (x, re, im) datum to the Dataset.void
clear()
Clear all data from this Dataset.void
draw
(DrawingPanel drawingPanel, Graphics g) Draw this Dataset in the drawing panel.protected void
drawLinePlot
(DrawingPanel drawingPanel, Graphics2D g2) Draw the lines connecting the data points.protected void
drawPhaseBars
(DrawingPanel drawingPanel, Graphics2D g2) Draw the phase as a colored bar.protected void
drawPhaseCurve
(DrawingPanel drawingPanel, Graphics2D g2) Draw the phase as color.protected void
drawPhasePosts
(DrawingPanel drawingPanel, Graphics2D g2) Draw the phase as a colored post.protected void
drawReImPlot
(DrawingPanel drawingPanel, Graphics2D g2) Draw the lines connecting the data points.int
Gets the number of columns for rendering in a JTable.getColumnName
(int columnIndex) Gets the name of the colummn for rendering in a JTableString[]
The column names to be used in the data display tooldouble[][]
Gets a 2D array of data.double[][][]
Gets a 3D array of data.Some elements (a Group, for instance) do not contain data, but a list of subelements which do.Gets a list of OSP Datasets.Fill color to use for this dataColor[]
Fill colors to Data interface.int
getID()
Returns a unique identifier for this Data.double[]
Gets a copy of the imaginary points array.Gets the line color.Color[]
Line colors for Data interface.static XML.ObjectLoader
Returns the XML.ObjectLoader for this class.int
Gets the marker shape.int
Gets the marker size.boolean
Gets the measurable property.getName()
Gets the name.double[][]
Gets a data array containing both x and y values.double[]
Gets a copy of the real points array.int
Gets the number of rows for rendering in a JTable.double
getValueAt
(int rowIndex, int columnIndex) Gets an x or y value for rendering in a JTable.boolean
Gets the visibility of this dataset in the DrawingPanel.double
getXMax()
Gets the x world coordinate for the right hand side of the panel.double
getXMin()
Gets the x world coordinate for the left hand side of the panel.double[]
Gets a copy of the xpoints array.double
getYMax()
Gets y world coordinate for the top of the panel.double
getYMin()
Gets y world coordinate for the bottom of the panel.double[]
Gets a copy of the ypoints array.protected void
Perform an insertion sort of the data set.boolean
Gets the data connected flag.boolean
Gets the valid measure flag.boolean
isSorted()
Gets the sorted flag.protected void
moveDatum
(int loc) Move an out-of-place datum into its correct position.protected void
Recalcualte the general path.void
setCentered
(boolean _centered) Sets the centered flag.void
setConnected
(boolean _connected) Sets the data connected flag.void
setID
(int id) Sets the ID number of this Data.void
setLineColor
(Color _lineColor) Sets the color of the lines connecting data points.void
setLineColor
(Color reColor, Color imColor) Sets the color of the lines connecting data points.void
setMarkerShape
(int _markerShape) Sets the data point marker.void
setMarkerSize
(int size) Sets the marker size.void
setMeasurable
(boolean b) Sets the measurable property.void
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 data stride for table view.void
setVisible
(boolean b) Sets the visibility of this Dataset in a DrawingPanel.void
setXYColumnNames
(String _xColumnName, String _reColumnName, String _imColumnName) Sets the column names when rendering this dataset in a JTable.void
setXYColumnNames
(String _xColumnName, String _reColumnName, String _imColumnName, String datasetName) Sets the column names when rendering this dataset in a JTable.Shows the phase legend.toString()
Create a string representation of the data.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
-
AMP_CURVE
public static final int AMP_CURVEAMP height equal to |z|..- See Also:
-
RE_IM_CURVE
public static final int RE_IM_CURVERE_IM real and imaginary curves.- See Also:
-
PHASE_CURVE
public static final int PHASE_CURVEPHASE_CURVE the phase is shown as color.- See Also:
-
PHASE_BAR
public static final int PHASE_BARPHASE_BAR the phase is shown as the bar's color- See Also:
-
PHASE_POST
public static final int PHASE_POSTField POST- See Also:
-
visible
protected boolean visiblevisible in drawing panel -
measurable
protected boolean measurableaffect autoscaled drawing panels -
xpoints
protected double[] xpoints -
re_points
protected double[] re_points -
im_points
protected double[] im_points -
amp_points
protected double[] amp_points -
index
protected int index
-
-
Constructor Details
-
ComplexDataset
public ComplexDataset()Dataset constructor.
-
-
Method Details
-
showLegend
Shows the phase legend. -
isMeasured
public boolean isMeasured()Gets the valid measure flag. The measure is valid if the min and max values have been set.- Specified by:
isMeasured
in interfaceMeasurable
- Returns:
true<\code> if measure is valid
-
getXMin
public double getXMin()Gets the x world coordinate for the left hand side of the panel.- Specified by:
getXMin
in interfaceMeasurable
- Returns:
- xmin
-
getXMax
public double getXMax()Gets the x world coordinate for the right hand side of the panel.- Specified by:
getXMax
in interfaceMeasurable
- Returns:
- xmax
-
getYMin
public double getYMin()Gets y world coordinate for the bottom of the panel.- Specified by:
getYMin
in interfaceMeasurable
- Returns:
- ymin
-
getYMax
public double getYMax()Gets y world coordinate for the top of the panel.- Specified by:
getYMax
in interfaceMeasurable
- Returns:
- ymax
-
getXPoints
public double[] getXPoints()Gets a copy of the xpoints array.- Returns:
- xpoints[]
-
getRePoints
public double[] getRePoints()Gets a copy of the real points array.- Returns:
- repoints[]
-
getImPoints
public double[] getImPoints()Gets a copy of the imaginary points array.- Returns:
- impoints[]
-
getYPoints
public double[] getYPoints()Gets a copy of the ypoints array.- Returns:
- ypoints[]
-
getPoints
public double[][] getPoints()Gets a data array containing both x and y values.- Returns:
- a double[index][2] array of data
-
setMarkerShape
public void setMarkerShape(int _markerShape) Sets the data point marker. Shapes are: AMP_CURVE RE_IM_CURVE PHASE_CURVE PHASE_BAR PHASE_POST- Parameters:
_markerShape
-
-
getMarkerShape
public int getMarkerShape()Gets the marker shape.- Returns:
- int
-
getMarkerSize
public int getMarkerSize()Gets the marker size.- Returns:
- int
-
setMarkerSize
public void setMarkerSize(int size) Sets the marker size.- Parameters:
size
- int
-
setSorted
public void setSorted(boolean _sorted) Sets the sorted flag. Data is sorted by increasing x.- Parameters:
_sorted
-true<\code> to sort
-
setStride
public void setStride(int _stride) Sets the data stride for table view. A stride of i will show every i-th point.- Parameters:
_stride
-
-
isSorted
public boolean isSorted()Gets the sorted flag.- Returns:
true<\code> if the data is sorted
-
setVisible
public void setVisible(boolean b) Sets the visibility of this Dataset in a DrawingPanel.- Parameters:
b
-true<\code> if dataset is visible
-
getVisible
public boolean getVisible()Gets the visibility of this dataset in the DrawingPanel.- Returns:
- boolean
-
setMeasurable
public void setMeasurable(boolean b) Sets the measurable property. Measurable objects affect panel autoscaling.- Parameters:
b
-true<\code> if points are connected
-
getMeasurable
public boolean getMeasurable()Gets the measurable property.- Returns:
- boolean
-
setConnected
public void setConnected(boolean _connected) Sets the data connected flag. Points are connected by straight lines.- Parameters:
_connected
-true<\code> if points are connected
-
setCentered
public void setCentered(boolean _centered) Sets the centered flag. Centered complex numbers are shown extending above and below the y axis.- Parameters:
_centered
-true<\code> if data is centered
-
isConnected
public boolean isConnected()Gets the data connected flag.- Returns:
true<\code> if points are connected
-
setLineColor
Sets the color of the lines connecting data points.- Parameters:
_lineColor
-
-
setLineColor
Sets the color of the lines connecting data points.- Parameters:
reColor
- the real component colorimColor
- the imaginary component color
-
getLineColors
Line colors for Data interface.- Specified by:
getLineColors
in interfaceData
- Returns:
-
getLineColor
Gets the line color.- Returns:
- the line color
-
getFillColors
Fill colors to Data interface.- Specified by:
getFillColors
in interfaceData
- Returns:
-
getFillColor
Fill color to use for this data- Returns:
-
setXYColumnNames
Sets the column names when rendering this dataset in a JTable.- Parameters:
_xColumnName
- String_reColumnName
- String_imColumnName
- String
-
setXYColumnNames
public void setXYColumnNames(String _xColumnName, String _reColumnName, String _imColumnName, String datasetName) Sets the column names when rendering this dataset in a JTable.- Parameters:
_xColumnName
- String_reColumnName
- String_imColumnName
- StringdatasetName
- String
-
append
public void append(double x, double re, double im) Appends (x, re, im) datum to the Dataset.- Parameters:
x
- doublere
- doubleim
- double
-
append
public void append(double[] _xpoints, double[] _repoints, double[] _impoints) Appends x, real, and imaginary arrays to the Dataset.- Parameters:
_xpoints
-_repoints
-_impoints
-
-
append
public void append(double[] _xpoints, double[] _zpoints) Appends x and z data to the Dataset. Z array has length twice that of x array.Re(z) = z[2*i] Im(z) = z[2*i + 1]
- Parameters:
_xpoints
-_zpoints
-
-
setID
public void setID(int id) Sets the ID number of this Data. -
getID
public int getID()Returns a unique identifier for this Data. -
draw
Draw this Dataset in the drawing panel. -
clear
public void clear()Clear all data from this Dataset. -
toString
Create a string representation of the data. -
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
-
getColumnName
Gets the name of the colummn for rendering in a JTable- Specified by:
getColumnName
in classDataTable.DataModel
- Parameters:
columnIndex
-- Returns:
- the name
-
getValueAt
public double getValueAt(int rowIndex, int columnIndex) Gets an x or y value for rendering in a JTable.- Specified by:
getValueAt
in classDataTable.DataModel
- Parameters:
rowIndex
-columnIndex
-- Returns:
- the datum
-
insertionSort
protected void insertionSort()Perform an insertion sort of the data set. Since data will be partially sorted this should be fast. Added by W. Christian. -
recalculatePath
protected void recalculatePath()Recalcualte the general path. -
moveDatum
protected void moveDatum(int loc) Move an out-of-place datum into its correct position.- Parameters:
loc
- the datum
-
drawLinePlot
Draw the lines connecting the data points.- Parameters:
drawingPanel
-g2
-
-
drawReImPlot
Draw the lines connecting the data points.- Parameters:
drawingPanel
-g2
-
-
drawPhaseCurve
Draw the phase as color.- Parameters:
drawingPanel
-g2
-
-
drawPhaseBars
Draw the phase as a colored bar.- Parameters:
drawingPanel
-g2
-
-
drawPhasePosts
Draw the phase as a colored post.- Parameters:
drawingPanel
-g2
-
-
getLoader
Returns the XML.ObjectLoader for this class.- Returns:
- the object loader
-
setName
Sets a name that can be used to identify the dataset.- Parameters:
name
- String
-
getName
Gets the name. -
getColumnNames
The column names to be used in the data display tool- Specified by:
getColumnNames
in interfaceData
- Returns:
-
getData2D
public double[][] getData2D()Description copied from interface:Data
Gets a 2D array of data. The first column, double[0][] often contains x-values; Remaining columns often contain y values. May return null if data not yet generated or object does not support 2D data. -
getData3D
public double[][][] getData3D()Description copied from interface:Data
Gets a 3D array of data. May return null if data not yet generated or object does not support 3D data. -
getDatasets
Description copied from interface:Data
Gets a list of OSP Datasets. May return null if data not yet generated or object does not support Datasets.- Specified by:
getDatasets
in interfaceData
- Returns:
- list of Datasets
-
getDataList
Some elements (a Group, for instance) do not contain data, but a list of subelements which 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 DataInformation elements, null if the element itself is a DataInformation
-