Class VirtualBand

  • All Implemented Interfaces:
    Extensible, Scaling, SceneTransformProvider

    public class VirtualBand
    extends Band
    A band contains the data for geophysical parameter in remote sensing data products. Bands are two-dimensional images which hold their pixel values (samples) in a buffer of the type ProductData. The band class is just a container for attached metadata of the band, currently:
    • the flag coding FlagCoding
    • the band index at which position the band is stored in the associated product
    • the center wavelength of the band
    • the bandwidth of the band
    • the solar spectral flux of the band
    • the width and height of the band
    The band can contain a buffer to the real data, but this buffer must be read explicitely, to keep the memory fingerprint small, the data is not read automatically.

    The several getPixel and readPixel methods of this class do not necessarily return the values contained in the data buffer of type ProductData. If the scalingFactor, scalingOffset or log10Scaled are set a conversion of the form scalingFactor * rawSample + scalingOffset is applied to the raw samples before the getPixel and readPixel methods return the actual pixel values. If the log10Scaled property is true then the conversion is pow(10, scalingFactor * rawSample + scalingOffset). The several setPixel and writePixel perform the inverse operations in this case.

    Version:
    $Revision$ $Date$
    See Also:
    ProductData
    • Constructor Detail

      • VirtualBand

        public VirtualBand​(String name,
                           int dataType,
                           int width,
                           int height,
                           String expression)
        Constructs a new Band.
        Parameters:
        name - the name of the new object
        dataType - the raster data type, must be one of the multiple ProductData.TYPE_X constants, with the exception of ProductData.TYPE_UINT32
        width - the width of the raster in pixels
        height - the height of the raster in pixels
        expression - the expression code
    • Method Detail

      • getExpression

        public String getExpression()
      • setExpression

        public void setExpression​(String expression)
      • updateExpression

        public void updateExpression​(String oldExternalName,
                                     String newExternalName)
        Asks a product node to replace all occurences of and references to the node name given by oldExternalName with oldExternalName. Such references most often occur in band arithmetic expressions.
        Overrides:
        updateExpression in class RasterDataNode
        Parameters:
        oldExternalName - The old node name.
        newExternalName - The new node name.
      • setPixelInt

        public void setPixelInt​(int x,
                                int y,
                                int pixelValue)
        Description copied from class: AbstractBand
        Sets the pixel at the given pixel co-ordinate to the given pixel value.
        Overrides:
        setPixelInt in class AbstractBand
        Parameters:
        x - The X co-ordinate of the pixel location
        y - The Y co-ordinate of the pixel location
        pixelValue - the new pixel value
      • setPixelFloat

        public void setPixelFloat​(int x,
                                  int y,
                                  float pixelValue)
        Description copied from class: AbstractBand
        Sets the pixel at the given pixel coordinate to the given pixel value.
        Overrides:
        setPixelFloat in class AbstractBand
        Parameters:
        x - The X co-ordinate of the pixel location
        y - The Y co-ordinate of the pixel location
        pixelValue - the new pixel value
      • setPixelDouble

        public void setPixelDouble​(int x,
                                   int y,
                                   double pixelValue)
        Description copied from class: AbstractBand
        Sets the pixel value at the given pixel coordinate to the given pixel value.
        Overrides:
        setPixelDouble in class AbstractBand
        Parameters:
        x - The X co-ordinate of the pixel location
        y - The Y co-ordinate of the pixel location
        pixelValue - the new pixel value
      • writePixels

        public void writePixels​(int x,
                                int y,
                                int w,
                                int h,
                                int[] pixels,
                                ProgressMonitor pm)
                         throws IOException
        Retrieves the range of pixels specified by the coordinates as integer array. Reads the data from disk if ot is not in memory yet. If the data is loaded, just copies the data..
        Overrides:
        writePixels in class AbstractBand
        Parameters:
        x - x offset into the band
        y - y offset into the band
        w - width of the pixel array to be read
        h - height of the pixel array to be read.
        pixels - integer array to be filled with data
        pm - a monitor to inform the user about progress
        Throws:
        IOException - if an I/O error occurs
      • writePixels

        public void writePixels​(int x,
                                int y,
                                int w,
                                int h,
                                float[] pixels,
                                ProgressMonitor pm)
                         throws IOException
        Retrieves the range of pixels specified by the coordinates as float array. Reads the data from disk if ot is not in memory yet. If the data is loaded, just copies the data..
        Overrides:
        writePixels in class AbstractBand
        Parameters:
        x - x offset into the band
        y - y offset into the band
        w - width of the pixel array to be read
        h - height of the pixel array to be read.
        pixels - float array to be filled with data
        pm - a monitor to inform the user about progress
        Throws:
        IOException - if an I/O error occurs
      • writePixels

        public void writePixels​(int x,
                                int y,
                                int w,
                                int h,
                                double[] pixels,
                                ProgressMonitor pm)
                         throws IOException
        Retrieves the range of pixels specified by the coordinates as double array. Reads the data from disk if ot is not in memory yet. If the data is loaded, just copies the data..
        Overrides:
        writePixels in class AbstractBand
        Parameters:
        x - x offset into the band
        y - y offset into the band
        w - width of the pixel array to be read
        h - height of the pixel array to be read.
        pixels - double array to be filled with data
        pm - a monitor to inform the user about progress
        Throws:
        IOException - if an I/O error occurs
      • acceptVisitor

        public void acceptVisitor​(ProductVisitor visitor)
        Accepts the given visitor. This method implements the well known 'Visitor' design pattern of the gang-of-four. The visitor pattern allows to define new operations on the product data model without the need to add more code to it. The new operation is implemented by the visitor.

        The method simply calls visitor.visit(this).

        Overrides:
        acceptVisitor in class Band
        Parameters:
        visitor - the visitor, must not be null
      • getRawStorageSize

        public long getRawStorageSize​(ProductSubsetDef subsetDef)
        Gets an estimated raw storage size in bytes of this product node.
        Overrides:
        getRawStorageSize in class Band
        Parameters:
        subsetDef - if not null the subset may limit the size returned
        Returns:
        the size in bytes.
      • toString

        public String toString()
        Creates a string defining this band object.
        Overrides:
        toString in class Band
      • dispose

        public void dispose()
        Releases all of the resources used by this object instance and all of its owned children. Its primary use is to allow the garbage collector to perform a vanilla job.

        This method should be called only if it is for sure that this object instance will never be used again. The results of referencing an instance of this class after a call to dispose() are undefined.

        Overrides of this method should always call super.dispose(); after disposing this instance.

        Overrides:
        dispose in class Band
      • createSourceImage

        protected RenderedImage createSourceImage()
        Description copied from class: RasterDataNode
        Creates the source image associated with this RasterDataNode. This shall preferably be a MultiLevelImage instance which recognises this raster data node's {@link ##getImageToModelTransform() imageToModelTransform} property, if set.
        Overrides:
        createSourceImage in class Band
        Returns:
        A new source image instance.
      • createSourceImage

        public static MultiLevelImage createSourceImage​(RasterDataNode raster,
                                                        String expression)
        Create a MultiLevelImage that computes its pixel values from the given band math expression. The returned image is intended to be used as source image for the given target raster.

        Non-API.

        Parameters:
        raster - The raster data node.
        expression - The band-arithmetic expression.
        Returns:
        A multi-level image.