org.esa.beam.framework.gpf.internal
Class TileImpl

java.lang.Object
  extended by org.esa.beam.framework.gpf.internal.TileImpl
All Implemented Interfaces:
Iterable<Tile.Pos>, Tile

public class TileImpl
extends Object
implements Tile

A Tile implementation backed by a Raster.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.esa.beam.framework.gpf.Tile
Tile.Pos
 
Constructor Summary
TileImpl(RasterDataNode rasterDataNode, Raster raster)
           
TileImpl(RasterDataNode rasterDataNode, Raster raster, Rectangle rectangle, boolean target)
           
TileImpl(RasterDataNode rasterDataNode, WritableRaster raster, Rectangle rectangle)
           
 
Method Summary
 ProductData getDataBuffer()
          Obtains access to the underlying raw sample buffer.
 byte[] getDataBufferByte()
          Gets the underlying raw sample array of type byte (signed or unsigned).
 double[] getDataBufferDouble()
          Gets the underlying raw sample array of type double.
 float[] getDataBufferFloat()
          Gets the underlying raw sample array of type float.
 int getDataBufferIndex(int x, int y)
          Gets the index into the underlying raw sample buffer for the given pixel coordinates.
 int[] getDataBufferInt()
          Gets the underlying raw sample array of type int.
 short[] getDataBufferShort()
          Gets the underlying raw sample array of type short (signed or unsigned).
 int getHeight()
          Gets the height in pixels within the scene covered by the tile's RasterDataNode.
 int getMaxX()
          Gets the maximum pixel x-coordinate within the scene covered by the tile's RasterDataNode.
 int getMaxY()
          Gets the maximum pixel y-coordinate within the scene covered by the tile's RasterDataNode.
 int getMinX()
          Gets the minimum pixel x-coordinate within the scene covered by the tile's RasterDataNode.
 int getMinY()
          Gets the minimum pixel y-coordinate within the scene covered by the tile's RasterDataNode.
 RasterDataNode getRasterDataNode()
          Gets the RasterDataNode associated with this tile, e.g.
 ProductData getRawSamples()
          Gets the raw (unscaled, uncalibrated) samples, e.g.
 Rectangle getRectangle()
          Gets the tile rectangle in pixel coordinates within the scene covered by the tile's RasterDataNode.
 boolean getSampleBit(int x, int y, int bitIndex)
          Gets the bit-coded sample value for the given pixel coordinate and the specified bit index as a boolean.
 boolean getSampleBoolean(int x, int y)
          Gets the (geo-)physically scaled sample at the given pixel coordinate as boolean value.
 double getSampleDouble(int x, int y)
          Gets the (geo-)physically scaled sample value for the given pixel coordinate as double.
 float getSampleFloat(int x, int y)
          Gets the (geo-)physically scaled sample at the given pixel coordinate as float value.
 int getSampleInt(int x, int y)
          Gets the (geo-)physically scaled sample at the given pixel coordinate as int value.
 double[] getSamplesDouble()
          Gets the scaled, (geo-)physical array of double samples, copied from or directly returning the underlying data buffer.
 float[] getSamplesFloat()
          Gets the scaled, (geo-)physical array of double samples, copied from or directly returning the underlying data buffer.
 int[] getSamplesInt()
          Gets the scaled, (geo-)physical array of int samples, copied from or directly returning the underlying data buffer.
 int getScanlineOffset()
          Gets the scanline offset.
 int getScanlineStride()
          Gets the raster scanline stride for addressing the internal data buffer.
 int getWidth()
          Gets the width in pixels within the scene covered by the tile's RasterDataNode.
 boolean isSampleValid(int x, int y)
          Checks whether or not the sample value exists and is valid at a given image pixel position.
 boolean isTarget()
          Checks if this is a target tile.
 Iterator<Tile.Pos> iterator()
          Gets an iterator which can be used to visit all pixels in the tile.
 void setRawSamples(ProductData rawSamples)
          Sets this tile's raw (unscaled, uncalibrated) samples.
 void setSample(int x, int y, boolean sample)
          Sets the (geo-)physically scaled sample at the given pixel coordinate from a boolean value.
 void setSample(int x, int y, double sample)
          Sets the (geo-)physically scaled sample at the given pixel coordinate from a double value.
 void setSample(int x, int y, float sample)
          Sets the (geo-)physically scaled sample at the given pixel coordinate from a float value.
 void setSample(int x, int y, int sample)
          Sets the (geo-)physically scaled sample at the given pixel coordinate from a int value.
 void setSample(int x, int y, int bitIndex, boolean sample)
          Sets the bit-coded sample at the given pixel coordinate and the specified bit index from a boolean value.
 void setSamples(double[] samples)
          Sets this tile's scaled, (geo-)physical samples as array of doubles.
 void setSamples(float[] samples)
          Sets this tile's scaled, (geo-)physical samples as array of floatss.
 void setSamples(int[] samples)
          Sets this tile's scaled, (geo-)physical samples as array of floatss.
 double toGeoPhysical(double sample)
          Converts a raw sample value (e.g.
 float toGeoPhysical(float sample)
          Converts a raw sample value (e.g.
 double toRaw(double sample)
          Converts a (geo-)physically scaled sample value of type double to a its corresponding raw sample value (e.g.
 float toRaw(float sample)
          Converts a (geo-)physically scaled sample value of type float to a its corresponding raw sample value (e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TileImpl

public TileImpl(RasterDataNode rasterDataNode,
                Raster raster)

TileImpl

public TileImpl(RasterDataNode rasterDataNode,
                WritableRaster raster,
                Rectangle rectangle)

TileImpl

public TileImpl(RasterDataNode rasterDataNode,
                Raster raster,
                Rectangle rectangle,
                boolean target)
Method Detail

toGeoPhysical

public float toGeoPhysical(float sample)
Description copied from interface: Tile
Converts a raw sample value (e.g. digital counts) to a (geo-)physically scaled sample value of type float.

Specified by:
toGeoPhysical in interface Tile
Parameters:
sample - The raw sample value.
Returns:
The calibrated sample value.

toGeoPhysical

public double toGeoPhysical(double sample)
Description copied from interface: Tile
Converts a raw sample value (e.g. digital counts) to a (geo-)physically scaled sample value of type double.

Specified by:
toGeoPhysical in interface Tile
Parameters:
sample - The raw sample value.
Returns:
The calibrated sample value.

toRaw

public float toRaw(float sample)
Description copied from interface: Tile
Converts a (geo-)physically scaled sample value of type float to a its corresponding raw sample value (e.g. digital counts).

Specified by:
toRaw in interface Tile
Parameters:
sample - The calibrated sample value.
Returns:
The raw sample value.

toRaw

public double toRaw(double sample)
Description copied from interface: Tile
Converts a (geo-)physically scaled sample value of type double to a its corresponding raw sample value (e.g. digital counts).

Specified by:
toRaw in interface Tile
Parameters:
sample - The calibrated sample value.
Returns:
The raw sample value.

isTarget

public final boolean isTarget()
Description copied from interface: Tile
Checks if this is a target tile. Non-target tiles are read only.

Specified by:
isTarget in interface Tile
Returns:
true if this is a target tile.

isSampleValid

public boolean isSampleValid(int x,
                             int y)
Description copied from interface: Tile
Checks whether or not the sample value exists and is valid at a given image pixel position.

Specified by:
isSampleValid in interface Tile
Parameters:
x - the image pixel x-coordinate
y - the image pixel y-coordinate
Returns:
true, if the sample exists and is valid

getRectangle

public final Rectangle getRectangle()
Description copied from interface: Tile
Gets the tile rectangle in pixel coordinates within the scene covered by the tile's RasterDataNode. Simply returns new Rectangle( minX, minY, width, height).

Specified by:
getRectangle in interface Tile
Returns:
The tile rectangle in pixel coordinates.

getMinX

public final int getMinX()
Description copied from interface: Tile
Gets the minimum pixel x-coordinate within the scene covered by the tile's RasterDataNode.

Specified by:
getMinX in interface Tile
Returns:
The minimum pixel x-coordinate.

getMaxX

public final int getMaxX()
Description copied from interface: Tile
Gets the maximum pixel x-coordinate within the scene covered by the tile's RasterDataNode.

Specified by:
getMaxX in interface Tile
Returns:
The maximum pixel x-coordinate.

getMinY

public final int getMinY()
Description copied from interface: Tile
Gets the minimum pixel y-coordinate within the scene covered by the tile's RasterDataNode.

Specified by:
getMinY in interface Tile
Returns:
The minimum pixel y-coordinate.

getMaxY

public final int getMaxY()
Description copied from interface: Tile
Gets the maximum pixel y-coordinate within the scene covered by the tile's RasterDataNode.

Specified by:
getMaxY in interface Tile
Returns:
The maximum pixel y-coordinate.

getWidth

public final int getWidth()
Description copied from interface: Tile
Gets the width in pixels within the scene covered by the tile's RasterDataNode.

Specified by:
getWidth in interface Tile
Returns:
The width in pixels.

getHeight

public final int getHeight()
Description copied from interface: Tile
Gets the height in pixels within the scene covered by the tile's RasterDataNode.

Specified by:
getHeight in interface Tile
Returns:
The height in pixels.

getRasterDataNode

public final RasterDataNode getRasterDataNode()
Description copied from interface: Tile
Gets the RasterDataNode associated with this tile, e.g. a Band for source and target tiles or TiePointGrid for a source tile.

Specified by:
getRasterDataNode in interface Tile
Returns:
The RasterDataNode associated with this tile.

getDataBufferIndex

public int getDataBufferIndex(int x,
                              int y)
Description copied from interface: Tile
Gets the index into the underlying raw sample buffer for the given pixel coordinates.

The pixel coordinates are absolute; meaning they are defined in the scene raster coordinate system of this tile's RasterDataNode.

The returned index is computed as follows:

   int dx = x - Tile.getMinX();
   int dy = y - Tile.getMinY();
   int index = Tile.getScanlineOffset() + dy * Tile.getScanlineStride() + dx;
 

Specified by:
getDataBufferIndex in interface Tile
Parameters:
x - The absolute pixel x-coordinate, must be greater or equal Tile.getMinX() and less or equal Tile.getMaxX().
y - The absolute pixel y-coordinate, must be greater or equal Tile.getMinY() and less or equal Tile.getMaxY().
Returns:
an index into the underlying data buffer

getDataBuffer

public ProductData getDataBuffer()
Description copied from interface: Tile

Obtains access to the underlying raw sample buffer. The data buffer holds the raw (unscaled, uncalibrated) sample data (e.g. detector counts).

Elements in this array must be addressed by an index computed via the scanlineStride and scanlineOffset properties. The index can also be directly computed using the Tile.getDataBufferIndex(int, int) method.

The most efficient way to access and/or modify the samples in the raw data buffer is using the following nested loops:

   int lineStride = tile.Tile.getScanlineStride();
   int lineOffset = tile.Tile.getScanlineOffset();
   for (int y = tile.Tile.getMinY(); y <= tile.Tile.getMaxY(); y++) {
      int index = lineOffset;
      for (int x = tile.Tile.getMinX(); x <= tile.Tile.getMaxX(); x++) {
           // use index here to access raw data buffer...
           index++;
       }
       lineOffset += lineStride;
   }
 

If the absolute x,y pixel coordinates are not required, the following construct maybe more readable:

   int lineStride = tile.Tile.getScanlineStride();
   int lineOffset = tile.Tile.getScanlineOffset();
   for (int y = 0; y < tile.Tile.getHeight(); y++) {
      int index = lineOffset;
      for (int x = 0; x < tile.Tile.getWidth(); x++) {
           // use index here to access raw data buffer...
           index++;
       }
       lineOffset += lineStride;
   }
 

Specified by:
getDataBuffer in interface Tile
Returns:
the sample data

getDataBufferByte

public final byte[] getDataBufferByte()
Description copied from interface: Tile
Gets the underlying raw sample array of type byte (signed or unsigned). If the underlying data buffer is not of type byte, null is returned.

Refer to Tile.getDataBuffer() for using the primitive array.

Specified by:
getDataBufferByte in interface Tile
Returns:
The underlying data buffer's primitive array, or null (see above).
See Also:
Tile.getDataBufferIndex(int, int), Tile.getDataBuffer()

getDataBufferShort

public final short[] getDataBufferShort()
Description copied from interface: Tile
Gets the underlying raw sample array of type short (signed or unsigned). If the underlying data buffer is not of type short, null is returned.

Refer to Tile.getDataBuffer() for using the primitive array.

Specified by:
getDataBufferShort in interface Tile
Returns:
The underlying data buffer's primitive array, or null (see above).
See Also:
Tile.getDataBufferIndex(int, int), Tile.getDataBuffer()

getDataBufferInt

public final int[] getDataBufferInt()
Description copied from interface: Tile
Gets the underlying raw sample array of type int. If the underlying data buffer is not of type int, null is returned.

Refer to Tile.getDataBuffer() for using the primitive array.

Specified by:
getDataBufferInt in interface Tile
Returns:
The underlying data buffer's primitive array, or null (see above).
See Also:
Tile.getDataBufferIndex(int, int), Tile.getDataBuffer()

getDataBufferFloat

public final float[] getDataBufferFloat()
Description copied from interface: Tile
Gets the underlying raw sample array of type float. If the underlying data buffer is not of type float, null is returned.

Refer to Tile.getDataBuffer() for using the primitive array.

Specified by:
getDataBufferFloat in interface Tile
Returns:
The underlying data buffer's primitive array, or null (see above).
See Also:
Tile.getDataBufferIndex(int, int), Tile.getDataBuffer()

getDataBufferDouble

public final double[] getDataBufferDouble()
Description copied from interface: Tile
Gets the underlying raw sample array of type double. If the underlying data buffer is not of type double, null is returned.

Refer to Tile.getDataBuffer() for using the primitive array.

Specified by:
getDataBufferDouble in interface Tile
Returns:
The underlying data buffer's primitive array, or null (see above).
See Also:
Tile.getDataBufferIndex(int, int), Tile.getDataBuffer()

getScanlineOffset

public final int getScanlineOffset()
Description copied from interface: Tile
Gets the scanline offset. The scanline offset is the index to the first valid sample element in the data buffer.

Specified by:
getScanlineOffset in interface Tile
Returns:
The raster scanline offset.
See Also:
Tile.getScanlineStride()

getScanlineStride

public final int getScanlineStride()
Description copied from interface: Tile
Gets the raster scanline stride for addressing the internal data buffer. The scanline stride is added to the scanline offset in order to compute offsets of subsequent scanlines.

Specified by:
getScanlineStride in interface Tile
Returns:
The raster scanline stride.
See Also:
Tile.getScanlineOffset()

getRawSamples

public ProductData getRawSamples()
Description copied from interface: Tile
Gets the raw (unscaled, uncalibrated) samples, e.g. detector counts, copied from or wrapping the underlying data buffer. In contradiction to the Tile.getDataBuffer() method, the returned samples will cover exactly the region Tile.getRectangle() rectangle} of this tile. Thus, the number of returned samples will always equal width * height.

In order to apply changes of the samples values to this tile, it is mandatory to call Tile.setRawSamples(org.esa.beam.framework.datamodel.ProductData) with the modified ProductData instance.

Specified by:
getRawSamples in interface Tile
Returns:
The raw samples copied from or wrapping the underlying data buffer.

setRawSamples

public void setRawSamples(ProductData rawSamples)
Description copied from interface: Tile
Sets this tile's raw (unscaled, uncalibrated) samples. The number of given samples must be equal width * height of this tile.

This method must be used in order to apply changes made to the samples returned by the Tile.getRawSamples() method.

Specified by:
setRawSamples in interface Tile
Parameters:
rawSamples - The raw samples to be set.

getSamplesInt

public int[] getSamplesInt()
Description copied from interface: Tile
Gets the scaled, (geo-)physical array of int samples, copied from or directly returning the underlying data buffer. In contradiction to the Tile.getDataBuffer() method, the returned samples will cover exactly the region Tile.getRectangle() rectangle} of this tile. Thus, the number of returned samples will always equal width * height.

Sample values that are masked out (see Tile.isSampleValid(int, int)) are returned as array elements having the value Float.NaN.

Specified by:
getSamplesInt in interface Tile
Returns:
The (geo-)physical samples computed from the underlying raw data buffer.
See Also:
Tile.setSamples(int[])

getSamplesFloat

public float[] getSamplesFloat()
Description copied from interface: Tile
Gets the scaled, (geo-)physical array of double samples, copied from or directly returning the underlying data buffer. In contradiction to the Tile.getDataBuffer() method, the returned samples will cover exactly the region Tile.getRectangle() rectangle} of this tile. Thus, the number of returned samples will always equal width * height.

Sample values that are masked out (see Tile.isSampleValid(int, int)) are returned as array elements having the value Float.NaN.

Specified by:
getSamplesFloat in interface Tile
Returns:
The (geo-)physical samples computed from the underlying raw data buffer.
See Also:
Tile.setSamples(float[])

getSamplesDouble

public double[] getSamplesDouble()
Description copied from interface: Tile
Gets the scaled, (geo-)physical array of double samples, copied from or directly returning the underlying data buffer. In contradiction to the Tile.getDataBuffer() method, the returned samples will cover exactly the region Tile.getRectangle() rectangle} of this tile. Thus, the number of returned samples will always equal width * height.

Sample values that are masked out (see Tile.isSampleValid(int, int)) are returned as array elements having the value Float.NaN.

Specified by:
getSamplesDouble in interface Tile
Returns:
The (geo-)physical samples computed from the underlying raw data buffer.
See Also:
Tile.setSamples(double[])

setSamples

public void setSamples(int[] samples)
Description copied from interface: Tile
Sets this tile's scaled, (geo-)physical samples as array of floatss. The number of given samples must be equal width * height of this tile.

Specified by:
setSamples in interface Tile
Parameters:
samples - The (geo-)physical samples to be set.
See Also:
Tile.getSamplesInt()

setSamples

public void setSamples(float[] samples)
Description copied from interface: Tile
Sets this tile's scaled, (geo-)physical samples as array of floatss. The number of given samples must be equal width * height of this tile.

Specified by:
setSamples in interface Tile
Parameters:
samples - The (geo-)physical samples to be set.
See Also:
Tile.getSamplesFloat()

setSamples

public void setSamples(double[] samples)
Description copied from interface: Tile
Sets this tile's scaled, (geo-)physical samples as array of doubles. The number of given samples must be equal width * height of this tile.

This method must be used in order to apply changes made to the samples returned by the Tile.getRawSamples() method.

Specified by:
setSamples in interface Tile
Parameters:
samples - The (geo-)physical samples to be set.
See Also:
Tile.getSamplesDouble()

getSampleBoolean

public boolean getSampleBoolean(int x,
                                int y)
Description copied from interface: Tile
Gets the (geo-)physically scaled sample at the given pixel coordinate as boolean value.

If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed.

Note that in most cases, accessing the tile's dataBuffer directly in conjunction with the scanlineOffset and scanlineStride properties gives a better performance.

Specified by:
getSampleBoolean in interface Tile
Parameters:
x - The absolute pixel x-coordinate, must be greater or equal Tile.getMinX() and less or equal Tile.getMaxX().
y - The absolute pixel y-coordinate, must be greater or equal Tile.getMinY() and less or equal Tile.getMaxY().
Returns:
The (geo-)physical sample as boolean value.

setSample

public void setSample(int x,
                      int y,
                      boolean sample)
Description copied from interface: Tile
Sets the (geo-)physically scaled sample at the given pixel coordinate from a boolean value.

If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed.

Note that in most cases, accessing the tile's dataBuffer directly in conjunction with the scanlineOffset and scanlineStride properties gives a better performance.

Specified by:
setSample in interface Tile
Parameters:
x - The absolute pixel x-coordinate, must be greater or equal Tile.getMinX() and less or equal Tile.getMaxX().
y - The absolute pixel y-coordinate, must be greater or equal Tile.getMinY() and less or equal Tile.getMaxY().
sample - The (geo-)physically scaled sample as boolean value.

getSampleInt

public int getSampleInt(int x,
                        int y)
Description copied from interface: Tile
Gets the (geo-)physically scaled sample at the given pixel coordinate as int value.

If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed.

Note that in most cases, accessing the tile's dataBuffer directly in conjunction with the scanlineOffset and scanlineStride properties gives a better performance.

Specified by:
getSampleInt in interface Tile
Parameters:
x - The absolute pixel x-coordinate, must be greater or equal Tile.getMinX() and less or equal Tile.getMaxX().
y - The absolute pixel y-coordinate, must be greater or equal Tile.getMinY() and less or equal Tile.getMaxY().
Returns:
The (geo-)physically scaled sample as int value.

setSample

public void setSample(int x,
                      int y,
                      int sample)
Description copied from interface: Tile
Sets the (geo-)physically scaled sample at the given pixel coordinate from a int value.

If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed. The conversion ensures that no overflow happens. If necessary the value is cropped to the value range.

Note that in most cases, accessing the tile's dataBuffer directly in conjunction with the scanlineOffset and scanlineStride properties gives a better performance.

Specified by:
setSample in interface Tile
Parameters:
x - The absolute pixel x-coordinate, must be greater or equal Tile.getMinX() and less or equal Tile.getMaxX().
y - The absolute pixel y-coordinate, must be greater or equal Tile.getMinY() and less or equal Tile.getMaxY().
sample - The (geo-)physically scaled sample as int value.

getSampleFloat

public float getSampleFloat(int x,
                            int y)
Description copied from interface: Tile
Gets the (geo-)physically scaled sample at the given pixel coordinate as float value.

If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed.

Note that in most cases it is more performant to directly access the tile's dataBuffer in conjunction with the scanlineOffset and scanlineStride properties.

Specified by:
getSampleFloat in interface Tile
Parameters:
x - The absolute pixel x-coordinate, must be greater or equal Tile.getMinX() and less or equal Tile.getMaxX().
y - The absolute pixel y-coordinate, must be greater or equal Tile.getMinY() and less or equal Tile.getMaxY().
Returns:
The (geo-)physically scaled sample as float value.

setSample

public void setSample(int x,
                      int y,
                      float sample)
Description copied from interface: Tile
Sets the (geo-)physically scaled sample at the given pixel coordinate from a float value.

If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed. The conversion ensures that no overflow happens. If necessary the value is cropped to the value range.

Note that in most cases, accessing the tile's dataBuffer directly in conjunction with the scanlineOffset and scanlineStride properties gives a better performance.

Specified by:
setSample in interface Tile
Parameters:
x - The absolute pixel x-coordinate, must be greater or equal Tile.getMinX() and less or equal Tile.getMaxX().
y - The absolute pixel y-coordinate, must be greater or equal Tile.getMinY() and less or equal Tile.getMaxY().
sample - The (geo-)physically scaled sample as float value.

getSampleDouble

public double getSampleDouble(int x,
                              int y)
Description copied from interface: Tile
Gets the (geo-)physically scaled sample value for the given pixel coordinate as double.

If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed.

Note that in most cases, accessing the tile's dataBuffer directly in conjunction with the scanlineOffset and scanlineStride properties gives a better performance.

Specified by:
getSampleDouble in interface Tile
Parameters:
x - The absolute pixel x-coordinate, must be greater or equal Tile.getMinX() and less or equal Tile.getMaxX().
y - The absolute pixel y-coordinate, must be greater or equal Tile.getMinY() and less or equal Tile.getMaxY().
Returns:
The (geo-)physically scaled sample as double value.

setSample

public void setSample(int x,
                      int y,
                      double sample)
Description copied from interface: Tile
Sets the (geo-)physically scaled sample at the given pixel coordinate from a double value.

If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed. The conversion ensures that no overflow happens. If necessary the value is cropped to the value range.

Note that in most cases, accessing the tile's dataBuffer directly in conjunction with the scanlineOffset and scanlineStride properties gives a better performance.

Specified by:
setSample in interface Tile
Parameters:
x - The absolute pixel x-coordinate, must be greater or equal Tile.getMinX() and less or equal Tile.getMaxX().
y - The absolute pixel y-coordinate, must be greater or equal Tile.getMinY() and less or equal Tile.getMaxY().
sample - The (geo-)physically scaled sample as double value.

getSampleBit

public boolean getSampleBit(int x,
                            int y,
                            int bitIndex)
Description copied from interface: Tile
Gets the bit-coded sample value for the given pixel coordinate and the specified bit index as a boolean.

If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed.

Note that in most cases it is more performant to directly access the tile's dataBuffer in conjunction with the scanlineOffset and scanlineStride properties.

Specified by:
getSampleBit in interface Tile
Parameters:
x - The absolute pixel x-coordinate, must be greater or equal Tile.getMinX() and less or equal Tile.getMaxX().
y - The absolute pixel y-coordinate, must be greater or equal Tile.getMinY() and less or equal Tile.getMaxY().
bitIndex - The bit index.
Returns:
The sample as boolean value.

setSample

public void setSample(int x,
                      int y,
                      int bitIndex,
                      boolean sample)
Description copied from interface: Tile
Sets the bit-coded sample at the given pixel coordinate and the specified bit index from a boolean value.

If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed.

Note that in most cases it is more performant to directly access the tile's dataBuffer in conjunction with the scanlineOffset and scanlineStride properties.

Specified by:
setSample in interface Tile
Parameters:
x - The absolute pixel x-coordinate, must be greater or equal Tile.getMinX() and less or equal Tile.getMaxX().
y - The absolute pixel y-coordinate, must be greater or equal Tile.getMinY() and less or equal Tile.getMaxY().
bitIndex - The bit index.
sample - The sample as boolean value.

iterator

public Iterator<Tile.Pos> iterator()
Description copied from interface: Tile
Gets an iterator which can be used to visit all pixels in the tile. The method allows this tile to be the target of the Java "foreach" statement. Using the tile as an iterator in a single loop
 for (Tile.Pos pos: tile) {
    int x = pos.x;
    int y = pos.y;
    // ...
 }
 
is equivalent to iterating over all pixels using two nested loops
 for (int y = tile.getMinY(); y <= tile.getMaxY(); y++) {
     for (int x = tile.getMinX(); x <= tile.getMaxX(); x++) {
         // ...
     }
 }
 

Specified by:
iterator in interface Iterable<Tile.Pos>
Specified by:
iterator in interface Tile


Copyright © 2002-2012 Brockmann Consult GmbH. All Rights Reserved.