Package org.apache.sis.image
Class PixelIterator.Builder
java.lang.Object
org.apache.sis.image.PixelIterator.Builder
- Enclosing class:
PixelIterator
Builds pixel iterators for specified region of interest, window size or iteration order.
By default, the builder creates iterators for all pixels in the given raster or image,
with unspecified iteration order. Users can invoke setter methods for specifying
desired behavior for the iterators to create.
Example:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate SequenceType
The desired iteration order, ornull
for a default order.private Rectangle
The region where to perform the iteration, ornull
for iterating over all the domain.private Dimension
Size of the window to use inPixelIterator.createWindow(TransferType)
method, ornull
if none. -
Constructor Summary
ConstructorsConstructorDescriptionBuilder()
Creates a new iterator builder with no region of interest, no window size and default iterator order. -
Method Summary
Modifier and TypeMethodDescriptionCreates a read-only iterator for the given raster.create
(RenderedImage data) Creates a read-only iterator for the given image.createWritable
(Raster input, WritableRaster output) Creates an iterator which will read and write in two different rasters.createWritable
(RenderedImage input, WritableRenderedImage output) Creates an iterator which will read and write in two different images.createWritable
(WritableRaster data) Creates a read/write iterator for the given raster.Creates a read/write iterator for the given image.(package private) static int
If the given sample model is compatible withBandedIterator
, returns the model scanline stride.setIteratorOrder
(SequenceType order) Sets the desired iteration order.setRegionOfInterest
(Rectangle subArea) Sets the region (in pixel coordinates) where to perform the iteration.setWindowSize
(Dimension window) Sets the size of the window to use inPixelIterator.createWindow(TransferType)
method.private static RenderedImage
unwrap
(RenderedImage image) If the given image is a wrapper doing nothing else than computing a property value, unwraps it since the iterators are not interested in properties.
-
Field Details
-
subArea
The region where to perform the iteration, ornull
for iterating over all the domain. -
window
Size of the window to use inPixelIterator.createWindow(TransferType)
method, ornull
if none. -
order
The desired iteration order, ornull
for a default order.
-
-
Constructor Details
-
Builder
public Builder()Creates a new iterator builder with no region of interest, no window size and default iterator order.
-
-
Method Details
-
setRegionOfInterest
Sets the region (in pixel coordinates) where to perform the iteration. If this method is not invoked, then by default iterators will traverse all pixels in the image or raster. If a sub-area is specified, then the traversed area is the intersection ofsubArea
with the image or raster bounds.- Parameters:
subArea
- region to intersect, ornull
for iterating over all image domain.- Returns:
this
for method call chaining.- Throws:
IllegalArgumentException
- if the given rectangle is empty.
-
setWindowSize
Sets the size of the window to use inPixelIterator.createWindow(TransferType)
method. By default, iterators do not create windows.- Parameters:
window
- the window size, ornull
if no window will be created.- Returns:
this
for method call chaining.
-
setIteratorOrder
Sets the desired iteration order. Theorder
argument can have the following values:Supported iteration order Value Iteration order null
Most efficient iteration order. SequenceType.LINEAR
From left to right, then from top to bottom. order
value will cause anIllegalArgumentException
to be thrown. More iteration orders may be supported in future Apache SIS versions.- Parameters:
order
- the desired iteration order, ornull
for a default order.- Returns:
this
for method call chaining.
-
unwrap
If the given image is a wrapper doing nothing else than computing a property value, unwraps it since the iterators are not interested in properties. This unwrapping is also necessary for allowing the builder to recognize theBufferedImage
case. -
getScanlineStride
If the given sample model is compatible withBandedIterator
, returns the model scanline stride. Otherwise returns 0. ABandedIterator
can be used only if the returned value is greater than 0. -
create
Creates a read-only iterator for the given raster.- Parameters:
data
- the raster which contains the sample values on which to iterate.- Returns:
- a new iterator traversing pixels in the given raster.
-
create
Creates a read-only iterator for the given image.- Parameters:
data
- the image which contains the sample values on which to iterate.- Returns:
- a new iterator traversing pixels in the given image.
-
createWritable
Creates a read/write iterator for the given raster.- Parameters:
data
- the raster which contains the sample values on which to iterate.- Returns:
- a new iterator traversing pixels in the given raster.
-
createWritable
Creates a read/write iterator for the given image.- Parameters:
data
- the image which contains the sample values on which to iterate.- Returns:
- a new iterator traversing pixels in the given image.
-
createWritable
Creates an iterator which will read and write in two different rasters. The two rasters must use the same sample model and have the same bounds.- Parameters:
input
- the raster which contains the sample values to read.output
- the raster where to write the sample values. Can be the same thaninput
.- Returns:
- a new writable iterator.
-
createWritable
Creates an iterator which will read and write in two different images. The two images must use the same sample model and have the same bounds.- Parameters:
input
- the image which contains the sample values to read.output
- the image where to write the sample values. Can be the same thaninput
.- Returns:
- a new writable iterator.
-