Class RasterFrame

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

public class RasterFrame extends DrawingFrame
A DrawingFrame that displays data using a ByteRaster.
Version:
1.0
Author:
W. Christian
See Also:
  • Field Details

  • Constructor Details

    • RasterFrame

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

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

    • addMenuItems

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

      public void setBWPalette()
      Sets black and white palette.
    • setColorPalette

      public void setColorPalette()
    • showLegend

      public void showLegend()
    • setColorPalette

      public void setColorPalette(Color[] colors)
      Sets the color palette.
      Parameters:
      colors -
    • 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()
      Clears the lattice data by setting all values to zero.
      Overrides:
      clearData in class OSPFrame
    • randomize

      public void randomize()
      Randomizes the lattice values.
    • setIndexedColor

      public void setIndexedColor(int index, Color color)
      Sets the color for a single index.
      Parameters:
      index -
      color -
    • setAll

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

      public void setAll(byte[][] val)
      Sets the raster's values using byte values.
      Parameters:
      val -
    • setAll

      public void setAll(int[][] val)
      Sets the raster's values using integer values.
      Parameters:
      val -
    • setAll

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

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

      public void setAll(int[] v)
      Sets an array v of int values into the raster, starting at (x=0,y=0). Values are in row-major format such that the index corresponds to iy*ny+ix.
      Parameters:
      v -
    • setAtIndex

      public void setAtIndex(int i, int v)
      Sets the ith indexed pixel to value v Values are in row-major format such that the index corresponds to iy*ny+ix.
      Parameters:
      i -
      v -
    • setValue

      public void setValue(int ix, int iy, int v)
      Sets the (ix,iy) cell or the site of the raster to store value v
      Parameters:
      ix -
      iy -
      v -
    • getAtIndex

      public int getAtIndex(int i)
      Gets the ith indexed pixel of the raster Values are in row-major format such that the index corresponds to iy*ny+ix.
      Parameters:
      i -
      Returns:
      value indexed by i
    • get

      public int get(int ix, int iy)
      Gets the (x,y) pixel of the raster
      Parameters:
      ix -
      iy -
      Returns:
      value at (ix,iy)
    • getAll

      public int[] getAll()
      Gets the entire raster contents in an int array Values are in row-major format such that the index corresponds to iy*ny+ix.
      Returns:
      array containing entire lattice contents
    • setToggleOnClick

      public void setToggleOnClick(boolean enable, int v1, int v2)
      Sets an action to toggle the grid betweem the given values when the mouse is pressed.
      Parameters:
      enable - boolean
      v1 - int
      v2 - int
    • 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
    • indexFromPoint

      public int indexFromPoint(double x, double y)
      Determines the lattice index (row-major order) from given x and y world coordinates
      Parameters:
      x -
      y -
      Returns:
      index