Class ComplexGridPlot

java.lang.Object
org.opensourcephysics.display.MeasuredImage
org.opensourcephysics.display2d.ComplexGridPlot
All Implemented Interfaces:
Drawable, Measurable, Plot2D

public class ComplexGridPlot extends MeasuredImage implements Plot2D
ComplexGridPlot plots a complex scalar field by coloring pixels a buffered image. The buffered image is scaled before it is copied to a drawing panel.
Version:
1.0
Author:
Wolfgang Christian
  • Constructor Details

    • ComplexGridPlot

      public ComplexGridPlot()
      Constructs the ComplexGridPlot without data.
    • ComplexGridPlot

      public ComplexGridPlot(GridData _griddata)
      Constructs the ComplexGridPlot using the given 2d datset.
      Parameters:
      _griddata -
  • Method Details

    • getGridData

      public GridData getGridData()
      Gets the GridData object.
      Specified by:
      getGridData in interface Plot2D
      Returns:
      GridData
    • xToIndex

      public int xToIndex(double x)
      Gets closest index from the given x world coordinate.
      Specified by:
      xToIndex in interface Plot2D
      Parameters:
      x - double the coordinate
      Returns:
      int the index
    • yToIndex

      public int yToIndex(double y)
      Gets closest index from the given y world coordinate.
      Specified by:
      yToIndex in interface Plot2D
      Parameters:
      y - double the coordinate
      Returns:
      int the index
    • indexToX

      public double indexToX(int i)
      Gets the x coordinate for the given index.
      Specified by:
      indexToX in interface Plot2D
      Parameters:
      i - int
      Returns:
      double the x coordinate
    • indexToY

      public double indexToY(int i)
      Gets the y coordinate for the given index.
      Specified by:
      indexToY in interface Plot2D
      Parameters:
      i - int
      Returns:
      double the y coordinate
    • setAll

      public void setAll(Object obj)
      Sets the data to new values. The grid is resized to fit the new data if needed.
      Specified by:
      setAll in interface Plot2D
      Parameters:
      obj -
    • setAll

      public void setAll(Object obj, double xmin, double xmax, double ymin, double ymax)
      Sets the values and the scale. The grid is resized to fit the new data if needed.
      Specified by:
      setAll in interface Plot2D
      Parameters:
      obj - array of new values
      xmin - double
      xmax - double
      ymin - double
      ymax - double
    • setGridData

      public void setGridData(GridData _griddata)
      Description copied from interface: Plot2D
      Sets the data storage to the given value.
      Specified by:
      setGridData in interface Plot2D
    • showLegend

      public JFrame showLegend()
      Shows a legend of phase angle and color.
      Specified by:
      showLegend in interface Plot2D
    • setAutoscaleZ

      public void setAutoscaleZ(boolean isAutoscale, double floor, double ceil)
      Sets the autoscale flag and the floor and ceiling values for the colors. If autoscaling is true, then the min and max values of z will span the colors. If autoscaling is false, then floor and ceiling values limit the colors. Values below min map to the first color; values above max map to the last color.
      Specified by:
      setAutoscaleZ in interface Plot2D
      Parameters:
      isAutoscale -
      floor - not supported
      ceil - ceiling value
    • setSymmetricZ

      public void setSymmetricZ(boolean symmetric)
      Forces the z-scale to be symmetric about zero. Not applicable in complex map because amplitude is always positive
      Specified by:
      setSymmetricZ in interface Plot2D
      Parameters:
      symmetric -
    • isSymmetricZ

      public boolean isSymmetricZ()
      Gets the symmetric z flag.
      Specified by:
      isSymmetricZ in interface Plot2D
    • isAutoscaleZ

      public boolean isAutoscaleZ()
      Gets the autoscale flag for z.
      Specified by:
      isAutoscaleZ in interface Plot2D
      Returns:
      boolean
    • getFloor

      public double getFloor()
      Gets the floor for scaling the z data.
      Specified by:
      getFloor in interface Plot2D
      Returns:
      double
    • getCeiling

      public double getCeiling()
      Gets the ceiling for scaling the z data.
      Specified by:
      getCeiling in interface Plot2D
      Returns:
      double
    • setFloorCeilColor

      public void setFloorCeilColor(Color floorColor, Color ceilColor)
      Sets the floor and ceiling colors.
      Specified by:
      setFloorCeilColor in interface Plot2D
      Parameters:
      floorColor - not supported
      ceilColor - ceiling color
    • setShowGridLines

      public void setShowGridLines(boolean showGrid)
      Shows the grid lines if set to true.
      Specified by:
      setShowGridLines in interface Plot2D
      Parameters:
      showGrid -
    • update

      public void update()
      Updates in response to changes in the data.
      Specified by:
      update in interface Plot2D
    • setExpandedZ

      public void setExpandedZ(boolean expanded, double expansionFactor)
      Expands the magnitude scale so as to enhance values close to zero.
      Specified by:
      setExpandedZ in interface Plot2D
      Parameters:
      expanded - boolean
      expansionFactor - double
    • recolorImage

      protected void recolorImage()
      Recolors the image pixels using the data array.
    • draw

      public void draw(DrawingPanel panel, Graphics g)
      Draws the image and the grid.
      Specified by:
      draw in interface Drawable
      Overrides:
      draw in class MeasuredImage
      Parameters:
      panel -
      g -
    • setColorPalette

      public void setColorPalette(Color[] colors)
      Setting the color palette is not supported. The complex palette always maps phase to color.
      Specified by:
      setColorPalette in interface Plot2D
      Parameters:
      colors -
    • setPaletteType

      public void setPaletteType(int type)
      Setting the palette is not supported. The complex palette always maps phase to color.
      Specified by:
      setPaletteType in interface Plot2D
      Parameters:
      type -
    • setGridLineColor

      public void setGridLineColor(Color c)
      Description copied from interface: Plot2D
      Sets the color for grid line boundaries
      Specified by:
      setGridLineColor in interface Plot2D
    • setIndexes

      public void setIndexes(int[] indexes)
      Description copied from interface: Plot2D
      Sets the indexes for the data components that will be plotted. Indexes determine the postion of the amplitude, phase, x-component, and y-component data in the data array. The amplitude index is usually the first index.
      Specified by:
      setIndexes in interface Plot2D
      Parameters:
      indexes - the sample-component indexes
    • getLoader

      public static XML.ObjectLoader getLoader()
      Gets an XML.ObjectLoader to save and load data for this program.
      Returns:
      the object loader