Class PixelIterator

java.lang.Object
org.apache.sis.image.PixelIterator
Direct Known Subclasses:
WritablePixelIterator

public class PixelIterator extends Object
An iterator over sample values in a raster or an image. This iterator makes easier to read and write efficiently pixel or sample values. The iterator acquires tiles and releases them automatically. Unless otherwise specified, iterators are free to use an iteration order that minimize the "acquire / release tile" operations (in other words, iterations are not necessarily from left to right). Iteration can be performed on a complete image or only a sub-region of it. Some optimized iterator implementations exist for a few commonly used sample models.
Example:

Default implementation

This base class uses the Raster API for traversing the pixels in each tile. Calls to next() move the current position by increasing the following values, in order:
  1. Column index in a single tile (from left to right)
  2. Row index in a single tile (from top to bottom).
  3. Then, tileX index from left to right.
  4. Then, tileY index from top to bottom.
Since:
1.0
Version:
1.2
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Builds pixel iterators for specified region of interest, window size or iteration order.
    private final class 
    PixelIterator.Window implementation backed by an array of double[].
    private final class 
    PixelIterator.Window implementation backed by an array of float[].
    private final class 
    PixelIterator.Window implementation backed by an array of int[].
    static class 
    Contains the sample values in a moving window over the image.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
    Bounds of the region traversed by the iterator in current raster.
    private Raster
    The current raster in which iteration is occurring.
    private int
    Bounds of the region traversed by the iterator in current raster.
    private int
    Bounds of the region traversed by the iterator in current raster.
    (package private) final RenderedImage
    The image in which iteration is occurring, or null if none.
    private final boolean
    true for default iteration order, or false for SequenceType.LINEAR.
    (package private) final int
    The domain, in pixel coordinates, of the region traversed by this pixel iterator.
    (package private) final int
    The domain, in pixel coordinates, of the region traversed by this pixel iterator.
    (package private) final int
    Number of bands in all tiles in the image.
    private final int
    The X and Y coordinate of the upper-left pixel of tile (0,0).
    private final int
    The X and Y coordinate of the upper-left pixel of tile (0,0).
    private final int
    Size of all tiles in the image.
    private final int
    The domain, in tile coordinates, of the region traversed by this pixel iterator.
    private final int
    The domain, in tile coordinates, of the region traversed by this pixel iterator.
    private final int
    The domain, in tile coordinates, of the region traversed by this pixel iterator.
    private final int
    The domain, in tile coordinates, of the region traversed by this pixel iterator.
    private final int
    Size of all tiles in the image.
    (package private) int
    Tile coordinate of currentRaster.
    (package private) int
    Tile coordinate of currentRaster.
    (package private) final int
    The domain, in pixel coordinates, of the region traversed by this pixel iterator.
    (package private) final int
    The domain, in pixel coordinates, of the region traversed by this pixel iterator.
    private final int
    Size of the window to use in createWindow(TransferType) method, or 0 if none.
    private int
    Maximal x and y coordinates (exclusive) that PixelIterator.Window can use for fetching values in current tile.
    private int
    Maximal x and y coordinates (exclusive) that PixelIterator.Window can use for fetching values in current tile.
    private final int
    Size of the window to use in createWindow(TransferType) method, or 0 if none.
    (package private) int
    Current (column, row) index in current raster.
    (package private) int
    Current (column, row) index in current raster.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PixelIterator(Raster data, Rectangle subArea, Dimension window, SequenceType order)
    Creates an iterator for the given region in the given raster.
    PixelIterator(RenderedImage data, Rectangle subArea, Dimension window, SequenceType order)
    Creates an iterator for the given region in the given image.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    Invoked when the iterator fetched a new tile.
    (package private) void
    Invoked by the default next() implementation when the iterator moved to a new row or a new tile.
    Creates an iterator for all pixels in the given image.
    createWindow(double[] data, double[] transfer)
     
    createWindow(float[] data, float[] transfer)
    Creates a window for floating point values using the given arrays.
    Returns a moving window over the sample values in a rectangular region starting at iterator position.
    private void
    Invoked when a call to next() moved to the end of iteration.
    private int
    Fetches from the image a tile for the current tileX and tileY coordinates.
    (package private) final void
    Updates the content of given window with the sample values in the region starting at current iterator position.
    (package private) Raster
    Fetches from the writable image a tile for the current tileX and tileY coordinates.
    Returns the data elements (not necessarily band values) of current pixel.
    Returns the type used for storing data in the raster buffer.
    Returns the pixel coordinates of the region where this iterator is doing the iteration.
    Returns the order in which pixels are traversed.
    int
    Returns the number of bands (samples per pixel) in the image or raster.
    double[]
    getPixel(double[] dest)
    Returns the sample values of current pixel for all bands.
    float[]
    getPixel(float[] dest)
    Returns the sample values of current pixel for all bands.
    int[]
    getPixel(int[] dest)
    Returns the sample values of current pixel for all bands.
    Returns the column (x) and row (y) indices of the current pixel.
    int
    getSample(int band)
    Returns the sample value in the specified band of current pixel, rounded toward zero.
    double
    getSampleDouble(int band)
    Returns the sample value in the specified band of current pixel, without precision lost.
    float
    getSampleFloat(int band)
    Returns the sample value in the specified band of current pixel as a single-precision floating point number.
    private SampleModel
    Returns the sample model of the image or raster.
    Returns the range of sample values that can be stored in each band of the rendered image or raster.
    Returns the most efficient type (int, float or double) for transferring data between the underlying rasters and this iterator.
    Returns the exception to throw when the tile at index (tileX, tileY) uses an incompatible sample model.
    private static Rectangle
    intersection(int x, int y, int width, int height, Rectangle subArea, Dimension window)
    Computes the intersection between the given bounds and subArea if subArea is non-null.
    (package private) final boolean
    isSameRowAndTile(int px, int py)
    Returns whether given position is on the same row and same tile than current (x,y) position.
    private static boolean
    isValidTileSize(int actual, int expected, boolean isLast)
    Verifies if the width or height of a tile fetched by fetchTile() is valid.
    boolean
    Returns true if this iterator can write pixel values (after cast to WritablePixelIterator).
    void
    moveTo(int px, int py)
    Moves the pixel iterator to the given column (x) and row (y) indices.
    boolean
    Moves the iterator to the next pixel.
    (package private) void
    Releases the tiles acquired by this iterator, if any.
    void
    Restores the iterator to the start position.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • image

      final RenderedImage image
      The image in which iteration is occurring, or null if none. If null, then currentRaster must be non-null.
    • currentRaster

      private Raster currentRaster
      The current raster in which iteration is occurring. This may change when the iterator reaches a new image tile. May be null if not yet determined.
      See Also:
    • numBands

      final int numBands
      Number of bands in all tiles in the image. The currentRaster shall always have this number of bands.
    • lowerX

      final int lowerX
      The domain, in pixel coordinates, of the region traversed by this pixel iterator. This may be smaller than the image or raster bounds, but not greater. The lower values are inclusive and the upper values are exclusive.
      See Also:
    • lowerY

      final int lowerY
      The domain, in pixel coordinates, of the region traversed by this pixel iterator. This may be smaller than the image or raster bounds, but not greater. The lower values are inclusive and the upper values are exclusive.
      See Also:
    • upperX

      final int upperX
      The domain, in pixel coordinates, of the region traversed by this pixel iterator. This may be smaller than the image or raster bounds, but not greater. The lower values are inclusive and the upper values are exclusive.
      See Also:
    • upperY

      final int upperY
      The domain, in pixel coordinates, of the region traversed by this pixel iterator. This may be smaller than the image or raster bounds, but not greater. The lower values are inclusive and the upper values are exclusive.
      See Also:
    • tileWidth

      private final int tileWidth
      Size of all tiles in the image.
    • tileHeight

      private final int tileHeight
      Size of all tiles in the image.
    • tileGridXOffset

      private final int tileGridXOffset
      The X and Y coordinate of the upper-left pixel of tile (0,0). Note that tile (0,0) may not actually exist.
    • tileGridYOffset

      private final int tileGridYOffset
      The X and Y coordinate of the upper-left pixel of tile (0,0). Note that tile (0,0) may not actually exist.
    • tileLowerX

      private final int tileLowerX
      The domain, in tile coordinates, of the region traversed by this pixel iterator. The tile index ranges may be smaller than the ranges of valid indices in image, but not greater. The lower values are inclusive and the upper values exclusive.
    • tileLowerY

      private final int tileLowerY
      The domain, in tile coordinates, of the region traversed by this pixel iterator. The tile index ranges may be smaller than the ranges of valid indices in image, but not greater. The lower values are inclusive and the upper values exclusive.
    • tileUpperX

      private final int tileUpperX
      The domain, in tile coordinates, of the region traversed by this pixel iterator. The tile index ranges may be smaller than the ranges of valid indices in image, but not greater. The lower values are inclusive and the upper values exclusive.
    • tileUpperY

      private final int tileUpperY
      The domain, in tile coordinates, of the region traversed by this pixel iterator. The tile index ranges may be smaller than the ranges of valid indices in image, but not greater. The lower values are inclusive and the upper values exclusive.
    • windowWidth

      private final int windowWidth
      Size of the window to use in createWindow(TransferType) method, or 0 if none.
    • windowHeight

      private final int windowHeight
      Size of the window to use in createWindow(TransferType) method, or 0 if none.
    • tileX

      int tileX
      Tile coordinate of currentRaster. The tileY >= tileUpperY condition is used for detecting when we reached iteration end.
    • tileY

      int tileY
      Tile coordinate of currentRaster. The tileY >= tileUpperY condition is used for detecting when we reached iteration end.
    • x

      int x
      Current (column, row) index in current raster. The x >= lowerX condition is used for detecting if iteration started.
    • y

      int y
      Current (column, row) index in current raster. The x >= lowerX condition is used for detecting if iteration started.
    • currentLowerX

      private int currentLowerX
      Bounds of the region traversed by the iterator in current raster. When iteration reaches the upper coordinates, the iterator needs to move to next tile. This is the raster bounds clipped to the area of interest.
    • currentUpperX

      private int currentUpperX
      Bounds of the region traversed by the iterator in current raster. When iteration reaches the upper coordinates, the iterator needs to move to next tile. This is the raster bounds clipped to the area of interest.
    • currentUpperY

      private int currentUpperY
      Bounds of the region traversed by the iterator in current raster. When iteration reaches the upper coordinates, the iterator needs to move to next tile. This is the raster bounds clipped to the area of interest.
    • windowLimitX

      private int windowLimitX
      Maximal x and y coordinates (exclusive) that PixelIterator.Window can use for fetching values in current tile. If some (x,y) coordinates inside the window are equal or greater, then the window will need to fetch some values on neighbor tiles (i.e. the window is overlapping two or more tiles).

      This is initialized by fetchTile() to the same values than currentUpperX and currentUpperY but without clipping to the area of interest. We want to keep the flexibility to overwrite with other coordinate system in future versions, if useful for PixelIterator.Window performance. Consequently, those values should not be used in other context than fetchValues(Window, Object).

    • windowLimitY

      private int windowLimitY
      Maximal x and y coordinates (exclusive) that PixelIterator.Window can use for fetching values in current tile. If some (x,y) coordinates inside the window are equal or greater, then the window will need to fetch some values on neighbor tiles (i.e. the window is overlapping two or more tiles).

      This is initialized by fetchTile() to the same values than currentUpperX and currentUpperY but without clipping to the area of interest. We want to keep the flexibility to overwrite with other coordinate system in future versions, if useful for PixelIterator.Window performance. Consequently, those values should not be used in other context than fetchValues(Window, Object).

    • isDefaultOrder

      private final boolean isDefaultOrder
      true for default iteration order, or false for SequenceType.LINEAR. Note that the order is equivalent to linear order when there is only one tile.
  • Constructor Details

    • PixelIterator

      PixelIterator(Raster data, Rectangle subArea, Dimension window, SequenceType order)
      Creates an iterator for the given region in the given raster.
      Parameters:
      data - the raster which contains the sample values on which to iterate.
      subArea - the raster region where to perform the iteration, or null for iterating over all the raster domain.
      window - size of the window to use in createWindow(TransferType) method, or null if none.
      order - null or SequenceType.LINEAR. Other values may be added in future versions.
    • PixelIterator

      PixelIterator(RenderedImage data, Rectangle subArea, Dimension window, SequenceType order)
      Creates an iterator for the given region in the given image.
      Parameters:
      data - the image which contains the sample values on which to iterate.
      subArea - the image region where to perform the iteration, or null for iterating over all the image domain.
      window - size of the window to use in createWindow(TransferType) method, or null if none.
      order - null or SequenceType.LINEAR. Other values may be added in future versions.
  • Method Details

    • intersection

      private static Rectangle intersection(int x, int y, int width, int height, Rectangle subArea, Dimension window)
      Computes the intersection between the given bounds and subArea if subArea is non-null. If the result is empty, then the width and/or height are set to zero (not negative).
    • create

      public static PixelIterator create(RenderedImage data)
      Creates an iterator for all pixels in the given image. This is a convenience method for new Builder().create(data).
      Parameters:
      data - the image which contains the sample values on which to iterate.
      Returns:
      a new iterator traversing all pixels in the given image, in arbitrary order.
    • isWritable

      public boolean isWritable()
      Returns true if this iterator can write pixel values (after cast to WritablePixelIterator). This method should be used instead of instanceof check because, for some implementations, being an instance of WritablePixelIterator is not a sufficient condition.
      Returns:
      true if this iterator can safely be casted to WritablePixelIterator and used for writing pixel values.
    • getDataType

      public DataType getDataType()
      Returns the type used for storing data in the raster buffer. The data type identifies the DataBuffer subclass used for storage.
      Returns:
      the type used for storing data in the raster buffer.
      Since:
      1.2
      See Also:
    • getTransferType

      public TransferType<?> getTransferType()
      Returns the most efficient type (int, float or double) for transferring data between the underlying rasters and this iterator. The transfer type is not necessarily the storage type used by the rasters. For example, int values will be used for transferring data even if the underlying rasters store all sample values as bytes.

      The transfer type is only a hint since all iterator methods work for any type (conversions are applied as needed). However if this method returns TransferType.INT, then getSample(int) and getPixel(int[]) will be slightly more efficient than equivalent methods for other types. Conversely if this method returns TransferType.DOUBLE, then getSampleDouble(int) will be both more efficient and avoid accuracy lost.

      Returns:
      the most efficient data type for transferring data.
      See Also:
    • getSampleModel

      private SampleModel getSampleModel()
      Returns the sample model of the image or raster.
    • getSampleRanges

      public NumberRange<?>[] getSampleRanges()
      Returns the range of sample values that can be stored in each band of the rendered image or raster. The ranges depend on the data type (byte, integer, etc.) and the number of bits per sample. If the samples are stored as floating point values, then the ranges are infinite (unbounded).

      Usually, the range is the same for all bands. A situation where the ranges may differ is when an image uses SinglePixelPackedSampleModel, in which case the number of bits per pixel may vary for different bands.

      Returns:
      the ranges of valid sample values for each band. Ranges may be unbounded.
    • getIterationOrder

      public Optional<SequenceType> getIterationOrder()
      Returns the order in which pixels are traversed. SequenceType.LINEAR means that pixels on the first row are traversed from left to right, then pixels on the second row from left to right, etc. An empty value means that the iteration order is unspecified.
      Returns:
      order in which pixels are traversed.
    • getNumBands

      public int getNumBands()
      Returns the number of bands (samples per pixel) in the image or raster.
      Returns:
      number of bands.
    • getDomain

      public Rectangle getDomain()
      Returns the pixel coordinates of the region where this iterator is doing the iteration. If no region was specified at construction time, then this method returns the image or raster bounds.
      Returns:
      pixel coordinates of the iteration region.
    • getPosition

      public Point getPosition()
      Returns the column (x) and row (y) indices of the current pixel. The next() or moveTo(int,int) method must have been invoked before this method. Indices of the first pixel are not necessarily zero; they can even be negative.
      Returns:
      column and row indices of current iterator position.
      Throws:
      IllegalStateException - if this method is invoked before the first call to next() or moveTo(int,int), or after next() returned false.
    • moveTo

      public void moveTo(int px, int py)
      Moves the pixel iterator to the given column (x) and row (y) indices. After this method invocation, the iterator state is as if the next() method has been invoked just before to reach the specified position.
      Usage example:
      Parameters:
      px - the column index of the pixel to make current.
      py - the row index of the pixel to make current.
      Throws:
      IndexOutOfBoundsException - if the given indices are outside the iteration domain.
    • next

      public boolean next()
      Moves the iterator to the next pixel. A pixel iterator is initially positioned before the first pixel. The first call to next() makes the first pixel the current one; the second call makes the second pixel the current one, etc. The second pixel is not necessarily on the same row than the first one; iteration order is implementation dependent.

      When a call to next() returns false, the iterator is positioned after the last pixel. Any invocation of a getSample(int) method will result in a NoSuchElementException to be thrown.

      Returns:
      true if the current pixel is valid, or false if there are no more pixels.
      Throws:
      IllegalStateException - if this iterator already reached end of iteration in a previous call to next(), and rewind() or moveTo(int,int) have not been invoked.
    • changedRowOrTile

      void changedRowOrTile()
      Invoked by the default next() implementation when the iterator moved to a new row or a new tile. Subclasses can override for updating some y-dependent cached values.

      Note that this method is not invoked by moveTo(int, int) for performance reason. Subclasses can get equivalent functionality by overriding moveTo(…) and checking isSameRowAndTile(px, py).

    • isSameRowAndTile

      final boolean isSameRowAndTile(int px, int py)
      Returns whether given position is on the same row and same tile than current (x,y) position. This method is provided as a complement to changedRowOrTile().
    • incompatibleTile

      private RasterFormatException incompatibleTile()
      Returns the exception to throw when the tile at index (tileX, tileY) uses an incompatible sample model.
    • isValidTileSize

      private static boolean isValidTileSize(int actual, int expected, boolean isLast)
      Verifies if the width or height of a tile fetched by fetchTile() is valid. The tile size must be strictly equal to the expected size, except if the tile is the last one in a row or column in which case the tile is allowed to be smaller.
      Parameters:
      actual - the width or height of fetched tile.
      expected - the expected tile size, either tileWidth or tileHeight.
      isLast - whether the tile is in the last column (if checking width) or last row.
      Returns:
      whether the tile has a valid width or height.
    • fetchTile

      private int fetchTile()
      Fetches from the image a tile for the current tileX and tileY coordinates. All fields prefixed by current are updated by this method. The caller is responsible for updating the x and y fields.

      Note 1: releaseTile() is always invoked before this method. Consequently, currentRaster is already null.

      Note 2: there is no currentLowerY field in this PixelIterator class. Instead, that value is returned by this method.

      Returns:
      the y value of the first row of new tile.
    • fetchWritableTile

      Raster fetchWritableTile()
      Fetches from the writable image a tile for the current tileX and tileY coordinates. If the writable tile is the same tile than the one used for read operation, then that tile should be returned. This method is for fetchTile() internal usage only and should be implemented by WritablePixelIterator only.
      Returns:
      a tile that can be used for read operation, or null if none. This value shall be non-null only if the tile to write is the same than the tile to read.
    • acquiredTile

      void acquiredTile(Raster tile)
      Invoked when the iterator fetched a new tile. This is a hook for subclasses. The default implementation does nothing. This is overridden when a subclass needs to store additional raster properties, for example its buffer for more direct access to sample values.
      Parameters:
      tile - the new tile from which to read sample values.
    • releaseTile

      void releaseTile()
      Releases the tiles acquired by this iterator, if any.
    • endOfIteration

      private void endOfIteration()
      Invoked when a call to next() moved to the end of iteration. This method sets fields to values that will allow moveTo(int,int) and next() to detect that we already finished iteration.

      Note: releaseTile() is always invoked before this method. Consequently, currentRaster is already null.

    • getSample

      public int getSample(int band)
      Returns the sample value in the specified band of current pixel, rounded toward zero. The next() method must have returned true, or the moveTo(int,int) method must have been invoked successfully, before this getSample(int) method is invoked. If above condition is not met, then this method behavior is undefined: it may throw any runtime exception or return a meaningless value (there is no explicit bounds check for performance reasons).
      Parameters:
      band - the band for which to get the sample value.
      Returns:
      sample value in specified band of current pixel.
      See Also:
    • getSampleFloat

      public float getSampleFloat(int band)
      Returns the sample value in the specified band of current pixel as a single-precision floating point number. The next() method must have returned true, or the moveTo(int,int) method must have been invoked successfully, before this getSampleFloat(int) method is invoked. If above condition is not met, then this method behavior is undefined: it may throw any runtime exception or return a meaningless value (there is no explicit bounds check for performance reasons).
      Parameters:
      band - the band for which to get the sample value.
      Returns:
      sample value in specified band of current pixel.
      See Also:
    • getSampleDouble

      public double getSampleDouble(int band)
      Returns the sample value in the specified band of current pixel, without precision lost. The next() method must have returned true, or the moveTo(int,int) method must have been invoked successfully, before this getSampleDouble(int) method is invoked. If above condition is not met, then this method behavior is undefined: it may throw any runtime exception or return a meaningless value (there is no explicit bounds check for performance reasons).
      Parameters:
      band - the band for which to get the sample value.
      Returns:
      sample value in specified band of current pixel.
      See Also:
    • getPixel

      public int[] getPixel(int[] dest)
      Returns the sample values of current pixel for all bands. The next() method must have returned true, or the moveTo(int,int) method must have been invoked successfully, before this getPixel(…) method is invoked. If above condition is not met, then this method behavior is undefined: it may throw any runtime exception or return a meaningless value (there is no explicit bounds check for performance reasons).
      Parameters:
      dest - a pre-allocated array where to store the sample values, or null if none.
      Returns:
      the sample values for current pixel.
      See Also:
    • getPixel

      public float[] getPixel(float[] dest)
      Returns the sample values of current pixel for all bands. The next() method must have returned true, or the moveTo(int,int) method must have been invoked successfully, before this getPixel(…) method is invoked. If above condition is not met, then this method behavior is undefined: it may throw any runtime exception or return a meaningless value (there is no explicit bounds check for performance reasons).
      Parameters:
      dest - a pre-allocated array where to store the sample values, or null if none.
      Returns:
      the sample values for current pixel.
      See Also:
    • getPixel

      public double[] getPixel(double[] dest)
      Returns the sample values of current pixel for all bands. The next() method must have returned true, or the moveTo(int,int) method must have been invoked successfully, before this getPixel(…) method is invoked. If above condition is not met, then this method behavior is undefined: it may throw any runtime exception or return a meaningless value (there is no explicit bounds check for performance reasons).
      Parameters:
      dest - a pre-allocated array where to store the sample values, or null if none.
      Returns:
      the sample values for current pixel.
      See Also:
    • getDataElements

      public Object getDataElements(Object dest)
      Returns the data elements (not necessarily band values) of current pixel. The Object argument and return value is a relatively opaque format (it may be int[], byte[], etc.): it is used for transferring values in a packed format between compatible Java2D sample or color models. That Object should generally not be used directly by the caller.
      Example: if an image has Red, Green, Blue and Alpha bands, then the getPixel(int[]) methods will return arrays of length 4 containing the individual values for each band, no matter how those bands are stored in the image. By contrast this getDataElements​(…) method may return an array of length 1 with all sample values packed as a single ARGB value.
      Data elements are useful for copying values in another image using the same sample model, or for getting colors with a call to ColorModel.getRGB(Object).
      Parameters:
      dest - a pre-allocated array where to store the data elements, or null if none.
      Returns:
      the data elements for current pixel.
      Since:
      1.1
      See Also:
    • createWindow

      public <T extends Buffer> PixelIterator.Window<T> createWindow(TransferType<T> type)
      Returns a moving window over the sample values in a rectangular region starting at iterator position. The window size must have been specified at PixelIterator construction time. The current iterator position is the window corner having the smallest x and y coordinates. This is typically, but not necessarily (depending on axis orientations) the window upper-left corner. Sample values are stored in a sequence of length (number of bands) × (window width) × (window height). Values are always stored with band index varying fastest, then column index, then row index. Columns are traversed from left to right and rows are traversed from top to bottom (linear iteration order). That order is the same regardless the iteration order of this iterator.
      Example: for an RGB image, the 3 first values are the red, green and blue components of the pixel at current iterator position. The 3 next values are the red, green and blue components of the pixel at the right of current iterator position (not necessarily the position where a call to next() would have go), etc.
      Calls to next() or moveTo(int,int) followed by PixelIterator.Window.update() replaces the window content with values starting at the new iterator position. Before the first PixelIterator.Window.update() invocation, the window is filled with zero values.

      If this iterator is used for writing pixel values at current position, those write operations may change the content of windows at next positions unless the iteration order of this iterator is SequenceType.LINEAR.

      Usage example: following code creates an iterator over the full area of given image, then a window of 5×5 pixels. The window is moved over all the image area in iteration order. Inside the window, data are copied in linear order regardless the iteration order.
      Type Parameters:
      T - the type of the data buffer to use for transferring data.
      Parameters:
      type - the desired type of values (int, float or double). Use getTransferType() if the most efficient type is desired.
      Returns:
      a window over the sample values in the underlying image or raster.
      See Also:
    • createWindow

      PixelIterator.Window<FloatBuffer> createWindow(float[] data, float[] transfer)
      Creates a window for floating point values using the given arrays. This is a hook for allowing subclasses to specify alternative implementations. We provide hooks only for floating point types, not for integers, because the int type is already optimized by Java2D with specialized Raster.getPixels(…) method implementations. By contrast the float and double types in Java2D use generic and slower code paths.
    • createWindow

      PixelIterator.Window<DoubleBuffer> createWindow(double[] data, double[] transfer)
    • fetchValues

      final void fetchValues(PixelIterator.Window<?> window, Object data)
      Updates the content of given window with the sample values in the region starting at current iterator position.
      Performance note we could store the position of last update in the Window object and invoke getPixels(…) only for window area that changed. Sample values that are still inside the window could be moved with System.arraycopy(…). We tried that approach, but performance at least on small windows was worst than current naive implementation.
      Parameters:
      window - the window to update.
      data - the array of primitive type where sample values are stored.
    • rewind

      public void rewind()
      Restores the iterator to the start position. After this method has been invoked, the iterator is in the same state than after construction.