Class ComplexDataset

java.lang.Object
org.opensourcephysics.display.DataTable.DataModel
org.opensourcephysics.display.ComplexDataset
All Implemented Interfaces:
Data, Drawable, Measurable

public class ComplexDataset extends DataTable.DataModel implements Drawable, Measurable, Data
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
  • Field Details

    • model

      public final ComplexDataset.Model model
    • AMP_CURVE

      public static final int AMP_CURVE
      AMP height equal to |z|..
      See Also:
    • RE_IM_CURVE

      public static final int RE_IM_CURVE
      RE_IM real and imaginary curves.
      See Also:
    • PHASE_CURVE

      public static final int PHASE_CURVE
      PHASE_CURVE the phase is shown as color.
      See Also:
    • PHASE_BAR

      public static final int PHASE_BAR
      PHASE_BAR the phase is shown as the bar's color
      See Also:
    • PHASE_POST

      public static final int PHASE_POST
      Field POST
      See Also:
    • visible

      protected boolean visible
      visible in drawing panel
    • measurable

      protected boolean measurable
      affect 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

      public JFrame 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 interface Measurable
      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 interface Measurable
      Returns:
      xmin
    • getXMax

      public double getXMax()
      Gets the x world coordinate for the right hand side of the panel.
      Specified by:
      getXMax in interface Measurable
      Returns:
      xmax
    • getYMin

      public double getYMin()
      Gets y world coordinate for the bottom of the panel.
      Specified by:
      getYMin in interface Measurable
      Returns:
      ymin
    • getYMax

      public double getYMax()
      Gets y world coordinate for the top of the panel.
      Specified by:
      getYMax in interface Measurable
      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

      public void setLineColor(Color _lineColor)
      Sets the color of the lines connecting data points.
      Parameters:
      _lineColor -
    • setLineColor

      public void setLineColor(Color reColor, Color imColor)
      Sets the color of the lines connecting data points.
      Parameters:
      reColor - the real component color
      imColor - the imaginary component color
    • getLineColors

      public Color[] getLineColors()
      Line colors for Data interface.
      Specified by:
      getLineColors in interface Data
      Returns:
    • getLineColor

      public Color getLineColor()
      Gets the line color.
      Returns:
      the line color
    • getFillColors

      public Color[] getFillColors()
      Fill colors to Data interface.
      Specified by:
      getFillColors in interface Data
      Returns:
    • getFillColor

      public Color getFillColor()
      Fill color to use for this data
      Returns:
    • setXYColumnNames

      public void setXYColumnNames(String _xColumnName, String _reColumnName, String _imColumnName)
      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 - String
      datasetName - String
    • append

      public void append(double x, double re, double im)
      Appends (x, re, im) datum to the Dataset.
      Parameters:
      x - double
      re - double
      im - 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.
      Specified by:
      setID in interface Data
      Parameters:
      id - the ID number
    • getID

      public int getID()
      Returns a unique identifier for this Data.
      Specified by:
      getID in interface Data
      Returns:
      the ID number
    • draw

      public void draw(DrawingPanel drawingPanel, Graphics g)
      Draw this Dataset in the drawing panel.
      Specified by:
      draw in interface Drawable
      Parameters:
      drawingPanel -
      g -
    • clear

      public void clear()
      Clear all data from this Dataset.
    • toString

      public String toString()
      Create a string representation of the data.
      Overrides:
      toString in class Object
      Returns:
      the data
    • getColumnCount

      public int getColumnCount()
      Gets the number of columns for rendering in a JTable.
      Specified by:
      getColumnCount in class DataTable.DataModel
      Returns:
      the count
    • getRowCount

      public int getRowCount()
      Gets the number of rows for rendering in a JTable.
      Specified by:
      getRowCount in class DataTable.DataModel
      Returns:
      the count
    • getColumnName

      public String getColumnName(int columnIndex)
      Gets the name of the colummn for rendering in a JTable
      Specified by:
      getColumnName in class DataTable.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 class DataTable.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

      protected void drawLinePlot(DrawingPanel drawingPanel, Graphics2D g2)
      Draw the lines connecting the data points.
      Parameters:
      drawingPanel -
      g2 -
    • drawReImPlot

      protected void drawReImPlot(DrawingPanel drawingPanel, Graphics2D g2)
      Draw the lines connecting the data points.
      Parameters:
      drawingPanel -
      g2 -
    • drawPhaseCurve

      protected void drawPhaseCurve(DrawingPanel drawingPanel, Graphics2D g2)
      Draw the phase as color.
      Parameters:
      drawingPanel -
      g2 -
    • drawPhaseBars

      protected void drawPhaseBars(DrawingPanel drawingPanel, Graphics2D g2)
      Draw the phase as a colored bar.
      Parameters:
      drawingPanel -
      g2 -
    • drawPhasePosts

      protected void drawPhasePosts(DrawingPanel drawingPanel, Graphics2D g2)
      Draw the phase as a colored post.
      Parameters:
      drawingPanel -
      g2 -
    • getLoader

      public static XML.ObjectLoader getLoader()
      Returns the XML.ObjectLoader for this class.
      Returns:
      the object loader
    • setName

      public void setName(String name)
      Sets a name that can be used to identify the dataset.
      Parameters:
      name - String
    • getName

      public String getName()
      Gets the name.
      Specified by:
      getName in interface Data
      Returns:
      String
    • getColumnNames

      public String[] getColumnNames()
      The column names to be used in the data display tool
      Specified by:
      getColumnNames in interface Data
      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.
      Specified by:
      getData2D in interface Data
      Returns:
      double[][]
    • 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.
      Specified by:
      getData3D in interface Data
      Returns:
      double[][][]
    • getDatasets

      public ArrayList<Dataset> 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 interface Data
      Returns:
      list of Datasets
    • getDataList

      public List<Data> 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 interface Data
      Returns:
      A list of DataInformation elements, null if the element itself is a DataInformation