Class IntegerImage

java.lang.Object
org.opensourcephysics.display.IntegerImage
All Implemented Interfaces:
Drawable, Measurable

public class IntegerImage extends Object implements Measurable
A IntegerImage contains an array of integers int[row][col] where each integer represents an image pixel. The row index determines the y-location of the pixel and the col index determines the x-location in the drawing panel.
Version:
1.0
Author:
Wolfgang Christian
  • Constructor Summary

    Constructors
    Constructor
    Description
    IntegerImage(int[][] data)
    Constructs IntegerImage with the given data.
    IntegerImage(ColorModel colorModel, int[][] data)
    Constructs IntegerImage with the given ColorModel and data.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Draws the image and the grid.
    get256ColorImage(int[][] data)
    Gets a 256 color IntegerImage with 0 -> blue, 128->green, and 255 -> red.
    getBinaryImage(int[][] data)
    Gets a two-color IntegerImage with 0 -> red and 1 -> blue.
    getColorImage(Color[] colors, int[][] data)
     
    getGrayscaleImage(int[][] data)
    Creates an IntegerImage with a gray-scale palette.
    double
    Gets the maximum x needed to draw this object.
    double
    Gets the minimum x needed to draw this object.
    double
    Gets the maximum y needed to draw this object.
    double
    Gets the minimum y needed to draw this object.
    boolean
    Determines if information is available to set min/max values.
    void
    setBlock(int row_offset, int col_offset, int[][] val)
    Sets an offset block to new values.
    void
    setCell(int row, int col, int val)
    Sets a cell to a new value.
    void
    setCol(int col, int[] val)
    Sets a column to new values.
    void
    setMinMax(double _xmin, double _xmax, double _ymin, double _ymax)
     
    void
    setRow(int row, int[] val)
    Sets array elements in a row to new values.
    void
    setXMax(double _xmax)
     
    void
    setXMin(double _xmin)
     
    void
    setYMax(double _ymax)
     
    void
    setYMin(double _ymin)
     
    void
    updateImage(int[][] val)
    Sets new values assuming that the integer array has not changed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.opensourcephysics.display.Drawable

    isInteractive
  • Constructor Details

    • IntegerImage

      public IntegerImage(int[][] data)
      Constructs IntegerImage with the given data.
      Parameters:
      data -
    • IntegerImage

      public IntegerImage(ColorModel colorModel, int[][] data)
      Constructs IntegerImage with the given ColorModel and data.
      Parameters:
      colorModel -
      data -
  • Method Details

    • getGrayscaleImage

      public static IntegerImage getGrayscaleImage(int[][] data)
      Creates an IntegerImage with a gray-scale palette.
      Parameters:
      data -
      Returns:
    • getBinaryImage

      public static IntegerImage getBinaryImage(int[][] data)
      Gets a two-color IntegerImage with 0 -> red and 1 -> blue.
    • get256ColorImage

      public static IntegerImage get256ColorImage(int[][] data)
      Gets a 256 color IntegerImage with 0 -> blue, 128->green, and 255 -> red.
    • getColorImage

      public static IntegerImage getColorImage(Color[] colors, int[][] data)
    • updateImage

      public void updateImage(int[][] val)
      Sets new values assuming that the integer array has not changed.
      Parameters:
      val -
    • setBlock

      public void setBlock(int row_offset, int col_offset, int[][] val)
      Sets an offset block to new values.
      Parameters:
      row_offset -
      col_offset -
      val -
    • setRow

      public void setRow(int row, int[] val)
      Sets array elements in a row to new values.
      Parameters:
      row -
      val -
    • setCol

      public void setCol(int col, int[] val)
      Sets a column to new values.
      Parameters:
      col -
      val -
    • setCell

      public void setCell(int row, int col, int val)
      Sets a cell to a new value.
    • draw

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

      public boolean isMeasured()
      Description copied from interface: Measurable
      Determines if information is available to set min/max values. Objects that store data should return false if data is null.
      Specified by:
      isMeasured in interface Measurable
      Returns:
      true if min/max values are valid
    • getXMin

      public double getXMin()
      Description copied from interface: Measurable
      Gets the minimum x needed to draw this object.
      Specified by:
      getXMin in interface Measurable
      Returns:
      minimum
    • getXMax

      public double getXMax()
      Description copied from interface: Measurable
      Gets the maximum x needed to draw this object.
      Specified by:
      getXMax in interface Measurable
      Returns:
      maximum
    • getYMin

      public double getYMin()
      Description copied from interface: Measurable
      Gets the minimum y needed to draw this object.
      Specified by:
      getYMin in interface Measurable
      Returns:
      minimum
    • getYMax

      public double getYMax()
      Description copied from interface: Measurable
      Gets the maximum y needed to draw this object.
      Specified by:
      getYMax in interface Measurable
      Returns:
      minimum
    • setXMin

      public void setXMin(double _xmin)
    • setXMax

      public void setXMax(double _xmax)
    • setYMin

      public void setYMin(double _ymin)
    • setYMax

      public void setYMax(double _ymax)
    • setMinMax

      public void setMinMax(double _xmin, double _xmax, double _ymin, double _ymax)