Class Scalar2DFrame

All Implemented Interfaces:
ClipboardOwner, ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants, AppFrame, Hidable

public class Scalar2DFrame extends DrawingFrame
A DrawingFrame that displays 2D plots of scalar fields.
Version:
1.0
Author:
W. Christian
See Also:
  • Constructor Details

    • Scalar2DFrame

      public Scalar2DFrame(String xlabel, String ylabel, String frameTitle)
      Constructs a Scalar2DFrame with the given axes labels and frame title.
      Parameters:
      xlabel - String
      ylabel - String
      frameTitle - String
    • Scalar2DFrame

      public Scalar2DFrame(String frameTitle)
      Constructs a Scalar2DFrame with the given frame title but without axes.
      Parameters:
      frameTitle - String
  • Method Details

    • indexToX

      public double indexToX(int i)
      Gets the x coordinate for the given index.
      Parameters:
      i - int
      Returns:
      double the x coordiante
    • xToIndex

      public int xToIndex(double x)
      Gets the index that is closest to the given x value
      Returns:
      double the x coordiante
    • yToIndex

      public int yToIndex(double y)
      Gets the index that is closest to the given y value
      Returns:
      double the y coordiante
    • indexToY

      public double indexToY(int i)
      Gets the y coordinate for the given index.
      Parameters:
      i - int
      Returns:
      double the y coordiante
    • getNx

      public int getNx()
      Gets the number of x entries.
      Returns:
      nx
    • getNy

      public int getNy()
      Gets the number of y entries.
      Returns:
      nx
    • setZRange

      public void setZRange(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 are 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.
      Parameters:
      isAutoscale -
      floor -
      ceil -
    • getCeiling

      public double getCeiling()
      Gets the maximum z value of the plot.
      Returns:
      zmax
    • getFloor

      public double getFloor()
      Gets the minimum z value of the plot.
      Returns:
      zmin
    • isAutoscaleZ

      public boolean isAutoscaleZ()
      Gets the autoscale flag for z.
      Returns:
      boolean
    • setExpandedZ

      public void setExpandedZ(boolean expanded, double expansionFactor)
      Expands the z scale so as to enhance values close to zero.
      Parameters:
      expanded - boolean
      expansionFactor - double
    • setPaletteType

      public void setPaletteType(int type)
      Sets the color palette that will be used to color the scalar field. Palette types are defined in ColorMapper.
      Parameters:
      type -
    • setBuffered

      public void setBuffered(boolean b)
      Sets the buffered image option. Buffered panels copy the offscreen image into the panel during a repaint unless the image has been invalidated. Use the render() method to draw the image immediately.
      Parameters:
      b -
    • setShowGrid

      public void setShowGrid(boolean show)
      Outlines the data grid's boundaries.
      Parameters:
      showGrid -
    • isShowGrid

      public boolean isShowGrid()
      True if the data grid's boundaries are shown.
      Returns:
      showGrid
    • addMenuItems

      protected void addMenuItems()
      Adds Views menu items on the menu bar.
      Overrides:
      addMenuItems in class DrawingFrame
    • clearDrawables

      public void clearDrawables()
      Clears drawable objects added by the user from this frame.
      Overrides:
      clearDrawables in class DrawingFrame
    • getDrawables

      public ArrayList<Drawable> getDrawables()
      Gets Drawable objects added by the user to this frame.
      Overrides:
      getDrawables in class DrawingFrame
      Returns:
      the list
    • getDrawables

      public <T extends Drawable> ArrayList<T> getDrawables(Class<T> c)
      Gets Drawable objects added by the user of an assignable type. The list contains objects that are assignable from the class or interface.
      Overrides:
      getDrawables in class DrawingFrame
      Parameters:
      c - the type of Drawable object
      Returns:
      the cloned list
      See Also:
    • clearData

      public void clearData()
      Sets the scalar field to zero.
      Overrides:
      clearData in class OSPFrame
    • setPlotType

      public void setPlotType(String type)
      Sets the type of plot type so that it cannot be changed from the menu.
      Parameters:
      type - String
    • convertToContourPlot

      public void convertToContourPlot()
      Converts to a contour plot.
    • convertToInterpolatedPlot

      public void convertToInterpolatedPlot()
    • convertToGridPlot

      public void convertToGridPlot()
    • convertToGrayscalePlot

      public void convertToGrayscalePlot()
    • convertToSurfacePlot

      public void convertToSurfacePlot()
      Converts to a SurfacePlot plot.
    • resizeGrid

      public void resizeGrid(int nx, int ny)
      Resizes the number of columns and rows.
      Parameters:
      nx - int
      ny - int
    • setRow

      public void setRow(int row, double[] vals) throws IllegalArgumentException
      Sets the data in the given row to new values.
      Parameters:
      row - int
      vals - double[] new values
      Throws:
      IllegalArgumentException - if array length does not match grid size.
    • setAll

      public void setAll(double[][] vals, double xmin, double xmax, double ymin, double ymax)
      Sets the scalar field's values and scale..
      Parameters:
      vals - int[][] the new values
      xmin - double
      xmax - double
      ymin - double
      ymax - double
    • setAll

      public void setAll(double[][] vals)
      Sets the scalar field's values.
      Parameters:
      vals - double[][] new values
    • setAll

      public void setAll(double[] vals)
      Sets all the scalar field values using the given array. The array is assumed to contain numbers in row-major format.
      Parameters:
      vals - double[] field values
    • showDataTable

      public void showDataTable(boolean show)
      Shows or hides the data table.
      Parameters:
      show - boolean