Class SingleBandedSampleModel

java.lang.Object
java.awt.image.SampleModel
java.awt.image.ComponentSampleModel
javax.media.jai.ComponentSampleModelJAI
org.esa.snap.core.util.jai.SingleBandedSampleModel

public class SingleBandedSampleModel extends javax.media.jai.ComponentSampleModelJAI
This class represents image data which is composed of a single band so that (a pixel comprises a single sample and occupies one data element of the DataBuffer). It subclasses ComponentSampleModelJAI but provides a more efficent implementation for accessing pixel interleaved image data than is provided by ComponentSampleModelJAI. This class stores sample data in a single bank of the DataBuffer. Accessor methods are provided so that image data can be manipulated directly. This class supports TYPE_BYTE, TYPE_USHORT, TYPE_SHORT, TYPE_INT, TYPE_FLOAT and TYPE_DOUBLE datatypes.
  • Constructor Details

    • SingleBandedSampleModel

      public SingleBandedSampleModel(int dataType, int w, int h)
      Constructs a SingleBandSampleModel with the specified parameters. The number of bands will be given by the length of the bandOffsets array.
      Parameters:
      dataType - The data type for storing samples.
      w - The width (in pixels) of the region of image data described.
      h - The height (in pixels) of the region of image data described.
      Throws:
      IllegalArgumentException - if w or h is not greater than 0 or if dataType is not one of the supported data types
  • Method Details

    • createCompatibleSampleModel

      public SampleModel createCompatibleSampleModel(int w, int h)
      Creates a new SingleBandSampleModel with the specified width and height. The new SingleBandSampleModel will have the same storage data type as this SingleBandSampleModel.
      Overrides:
      createCompatibleSampleModel in class javax.media.jai.ComponentSampleModelJAI
      Parameters:
      w - the width of the resulting SampleModel
      h - the height of the resulting SampleModel
      Returns:
      a new SampleModel with the specified width and height.
      Throws:
      IllegalArgumentException - if w or h is not greater than 0
    • createSubsetSampleModel

      public SampleModel createSubsetSampleModel(int[] bands)
      Overrides:
      createSubsetSampleModel in class javax.media.jai.ComponentSampleModelJAI
      Parameters:
      bands - Ignored.
      Returns:
      a new org.esa.snap.jai.SingleBandSampleModel.
    • getOffset

      public final int getOffset(int x, int y)
      Overrides:
      getOffset in class ComponentSampleModel
    • getOffset

      public final int getOffset(int x, int y, int b)
      Overrides:
      getOffset in class ComponentSampleModel
    • getDataElements

      public Object getDataElements(int x, int y, int w, int h, Object obj, DataBuffer data)
      Overrides:
      getDataElements in class javax.media.jai.ComponentSampleModelJAI
    • setDataElements

      public void setDataElements(int x, int y, int w, int h, Object obj, DataBuffer data)
      Overrides:
      setDataElements in class javax.media.jai.ComponentSampleModelJAI
    • getPixels

      public int[] getPixels(int x, int y, int w, int h, int[] array, DataBuffer data)
      Overrides:
      getPixels in class ComponentSampleModel
    • getPixels

      public float[] getPixels(int x, int y, int w, int h, float[] array, DataBuffer data)
      Overrides:
      getPixels in class SampleModel
    • getPixels

      public double[] getPixels(int x, int y, int w, int h, double[] array, DataBuffer data)
      Overrides:
      getPixels in class javax.media.jai.ComponentSampleModelJAI
    • setPixels

      public void setPixels(int x, int y, int w, int h, int[] array, DataBuffer data)
      Overrides:
      setPixels in class ComponentSampleModel
    • setPixels

      public void setPixels(int x, int y, int w, int h, float[] array, DataBuffer data)
      Overrides:
      setPixels in class SampleModel
    • setPixels

      public void setPixels(int x, int y, int w, int h, double[] array, DataBuffer data)
      Overrides:
      setPixels in class SampleModel
    • getPixel

      public int[] getPixel(int x, int y, int[] array, DataBuffer data)
      Overrides:
      getPixel in class ComponentSampleModel
    • getPixel

      public float[] getPixel(int x, int y, float[] array, DataBuffer data)
      Overrides:
      getPixel in class SampleModel
    • getPixel

      public double[] getPixel(int x, int y, double[] array, DataBuffer data)
      Overrides:
      getPixel in class SampleModel
    • setPixel

      public void setPixel(int x, int y, int[] array, DataBuffer data)
      Overrides:
      setPixel in class ComponentSampleModel
    • setPixel

      public void setPixel(int x, int y, float[] array, DataBuffer data)
      Overrides:
      setPixel in class SampleModel
    • setPixel

      public void setPixel(int x, int y, double[] array, DataBuffer data)
      Overrides:
      setPixel in class SampleModel
    • getSamples

      public int[] getSamples(int x, int y, int w, int h, int b, int[] array, DataBuffer data)
      Overrides:
      getSamples in class ComponentSampleModel
    • getSamples

      public float[] getSamples(int x, int y, int w, int h, int b, float[] array, DataBuffer data)
      Overrides:
      getSamples in class SampleModel
    • getSamples

      public double[] getSamples(int x, int y, int w, int h, int b, double[] array, DataBuffer data)
      Overrides:
      getSamples in class SampleModel
    • setSamples

      public void setSamples(int x, int y, int w, int h, int b, int[] array, DataBuffer data)
      Overrides:
      setSamples in class ComponentSampleModel
    • setSamples

      public void setSamples(int x, int y, int w, int h, int b, float[] array, DataBuffer data)
      Overrides:
      setSamples in class SampleModel
    • setSamples

      public void setSamples(int x, int y, int w, int h, int b, double[] array, DataBuffer data)
      Overrides:
      setSamples in class SampleModel
    • getSample

      public int getSample(int x, int y, int b, DataBuffer data)
      Overrides:
      getSample in class ComponentSampleModel
    • getSampleFloat

      public float getSampleFloat(int x, int y, int b, DataBuffer data)
      Overrides:
      getSampleFloat in class javax.media.jai.ComponentSampleModelJAI
    • getSampleDouble

      public double getSampleDouble(int x, int y, int b, DataBuffer data)
      Overrides:
      getSampleDouble in class javax.media.jai.ComponentSampleModelJAI
    • setSample

      public void setSample(int x, int y, int b, int s, DataBuffer data)
      Overrides:
      setSample in class ComponentSampleModel
    • setSample

      public void setSample(int x, int y, int b, float s, DataBuffer data)
      Overrides:
      setSample in class javax.media.jai.ComponentSampleModelJAI
    • setSample

      public void setSample(int x, int y, int b, double s, DataBuffer data)
      Overrides:
      setSample in class javax.media.jai.ComponentSampleModelJAI