Class ByteImage

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

public class ByteImage extends Object implements Measurable
A ByteImage contains an array of bytes 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
    ByteImage(byte[][] data)
    Constructs ByteImage with the given data.
    ByteImage(ColorModel colorModel, byte[][] data)
    Constructs IntegerImage with the given ColorModel and data.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Draws the image.
    static ByteImage
    getBinaryImage(byte[][] data)
    Gets a two-color ByteImage with 0 -> red and 1 -> blue.
    static ByteImage
    getColorImage(Color[] colors, byte[][] data)
     
    boolean
     
    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, byte[][] val)
    Sets an offset block to new values.
    void
    setCell(int row, int col, byte val)
    Sets a cell to a new value.
    void
    setCol(int col, byte[] val)
    Sets a column to new values.
    void
    setMinMax(double _xmin, double _xmax, double _ymin, double _ymax)
     
    void
    setRow(int row, byte[] val)
    Sets array elements in a row to new values.
    void
    setVisible(boolean b)
     
    void
    setXMax(double _xmax)
     
    void
    setXMin(double _xmin)
     
    void
    setYMax(double _ymax)
     
    void
    setYMin(double _ymin)
     
    void
    updateImage(byte[][] 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

    • ByteImage

      public ByteImage(byte[][] data)
      Constructs ByteImage with the given data.
      Parameters:
      data -
    • ByteImage

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

    • setVisible

      public void setVisible(boolean b)
    • getVisible

      public boolean getVisible()
    • getBinaryImage

      public static ByteImage getBinaryImage(byte[][] data)
      Gets a two-color ByteImage with 0 -> red and 1 -> blue.
    • getColorImage

      public static ByteImage getColorImage(Color[] colors, byte[][] data)
    • updateImage

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

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

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

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

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

      public void draw(DrawingPanel panel, Graphics g)
      Draws the image.
      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)