Interface ContourPlot.ImgBase<P extends ContourPlot.PixelBase>
-
- Type Parameters:
P
- the pixel type of the image
- All Superinterfaces:
java.lang.Iterable<P>
- All Known Implementing Classes:
ContourPlot.Img
- Enclosing class:
- ContourPlot
public static interface ContourPlot.ImgBase<P extends ContourPlot.PixelBase> extends java.lang.Iterable<P>
Base interface for imagingkit's Img classes.This interface defines the most basic methods like getting the dimensions of an image and converting an image to
BufferedImage
.Appart from that it defines and implements all the
Iterable
functionality which is based onContourPlot.PixelBase
. The Iterable Functionality also comprisesSpliterator
s as well as theforEach(Consumer)
andstream()
functionality.The
Graphics2D
related functionality likecreateGraphics()
andpaint(Consumer)
is by default based ongetRemoteBufferedImage()
. If it is possible to create a remote BufferedImage from the implemented data structure, the method should be overridden to enable the mentioned funtionality.- Since:
- 2.0
- Author:
- hageldave
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.util.Spliterator<P>
colSpliterator()
Creates aSpliterator
that guarantees that each split will at least cover an entire column of the Img.ContourPlot.ImgBase<P>
copy()
Returns a deep copy of this image.default java.awt.Graphics2D
createGraphics()
Creates aGraphics2D
, which can be used to draw into this image.default <T> void
forEach(boolean parallel, int xStart, int yStart, int width, int height, ContourPlot.PixelManipulator<? super P,T> manipulator)
Applies the specified manipulator to every pixel in the specified area of this image.default void
forEach(boolean parallel, int xStart, int yStart, int width, int height, java.util.function.Consumer<? super P> action)
Applies the specified action to every pixel in the specified area of this image.default <T> void
forEach(boolean parallel, ContourPlot.PixelManipulator<? super P,T> manipulator)
Applies the specified manipulator to every pixel of this image.default void
forEach(boolean parallel, java.util.function.Consumer<? super P> action)
Performs the specified action on each of the pixels of this image.default <T> void
forEach(int xStart, int yStart, int width, int height, ContourPlot.PixelManipulator<? super P,T> manipulator)
Applies the specified manipulator to every pixel in the specified area of this image.default void
forEach(int xStart, int yStart, int width, int height, java.util.function.Consumer<? super P> action)
Applies the specified action to every pixel in the specified area of this image.default <T> void
forEach(ContourPlot.PixelConvertingSpliterator.PixelConverter<? super P,T> converter, boolean parallel, int xStart, int yStart, int width, int height, java.util.function.Consumer<? super T> action)
Applies the specified action to every pixel in the specified area of this image.default <T> void
forEach(ContourPlot.PixelConvertingSpliterator.PixelConverter<? super P,T> converter, boolean parallel, java.util.function.Consumer<? super T> action)
Applies the specified action to every pixel of this image.default <T> void
forEach(ContourPlot.PixelManipulator<? super P,T> manipulator)
Applies the specified manipulator to every pixel of this image.default void
forEach(java.util.function.Consumer<? super P> action)
Performs the specified action on each of the pixels of this image.default void
forEach_defaultimpl(java.util.function.Consumer<? super P> action)
Default implementation ofIterable.forEach(Consumer)
only for performance test purposes as it is slower than theforEach(Consumer)
implementation.default java.awt.Dimension
getDimension()
int
getHeight()
P
getPixel()
Creates a new pixel object (instance ofContourPlot.PixelBase
) for this Img with initial position (0,0) i.e. top left corner.P
getPixel(int x, int y)
Creates a new Pixel object for this Img at specified positiondefault java.awt.image.BufferedImage
getRemoteBufferedImage()
Creates aBufferedImage
that shares the data of this image.default int
getSpliteratorMinimumSplitSize()
Returns the minimum number of elements in a split of aSpliterator
of this Img.int
getWidth()
default java.util.Iterator<P>
iterator()
Returns an iterator over the pixels of this image.default java.util.Iterator<P>
iterator(int xStart, int yStart, int width, int height)
Returns anIterator
for the specified area of the image.default int
numValues()
default void
paint(java.util.function.Consumer<java.awt.Graphics2D> paintInstructions)
Uses the specified paintInstructions to draw into this image.default java.util.Spliterator<P>
rowSpliterator()
Creates aSpliterator
that guarantees that each split will at least cover an entire row of the Img.default java.util.Spliterator<P>
spliterator()
Returns aSpliterator
over the pixels of this image.default java.util.Spliterator<P>
spliterator(int xStart, int yStart, int width, int height)
Creates aSpliterator
over the pixels within the specified area.default java.util.stream.Stream<P>
stream()
Returns a sequentialStream
of pixels of this image.default java.util.stream.Stream<P>
stream(boolean parallel)
Returns aStream
of pixels of this image.default java.util.stream.Stream<P>
stream(boolean parallel, int xStart, int yStart, int width, int height)
Returns a PixelStream
for the specified area of this Img.
This Img'sspliterator(int,int,int,int)
is used to create the Stream.default java.util.stream.Stream<P>
stream(int xStart, int yStart, int width, int height)
Returns a PixelStream
for the specified area of this Img.
This Img'sspliterator(int,int,int,int)
is used to create the Stream.default <T> java.util.stream.Stream<T>
stream(ContourPlot.PixelConvertingSpliterator.PixelConverter<? super P,T> converter, boolean parallel)
Returns aStream
of the specifiedContourPlot.PixelConvertingSpliterator.PixelConverter
's element type over the pixels of this image.default <T> java.util.stream.Stream<T>
stream(ContourPlot.PixelConvertingSpliterator.PixelConverter<? super P,T> converter, boolean parallel, int xStart, int yStart, int width, int height)
Returns aStream
of the specifiedContourPlot.PixelConvertingSpliterator.PixelConverter
's element type over the pixels of this image within the specified area.static <Px extends ContourPlot.PixelBase>
java.util.stream.Stream<Px>stream(java.util.Spliterator<Px> spliterator, boolean parallel)
Returns aStream<Pixel>
for the specifiedSpliterator<Pixel>
.default boolean
supportsRemoteBufferedImage()
Returns true when this implementation ofContourPlot.ImgBase
supports thegetRemoteBufferedImage()
method.default java.awt.image.BufferedImage
toBufferedImage()
java.awt.image.BufferedImage
toBufferedImage(java.awt.image.BufferedImage bimg)
Copies this image's data to the specifiedBufferedImage
.
-
-
-
Method Detail
-
getDimension
default java.awt.Dimension getDimension()
- Returns:
- the dimension (width,height) of this image
- See Also:
getWidth()
,getHeight()
,numValues()
-
getWidth
int getWidth()
- Returns:
- the width of this image (number of pixels in horizontal direction)
- See Also:
getHeight()
,getDimension()
,numValues()
-
getHeight
int getHeight()
- Returns:
- the height of this image (number of pixels in vertical direction)
- See Also:
getWidth()
,getDimension()
,numValues()
-
numValues
default int numValues()
- Returns:
- the number of pixels of this image
- See Also:
getWidth()
,getHeight()
,getDimension()
-
getPixel
P getPixel()
Creates a new pixel object (instance ofContourPlot.PixelBase
) for this Img with initial position (0,0) i.e. top left corner.Tip:
Do not use this method repeatedly while iterating the image. UseContourPlot.PixelBase.setPosition(int, int)
instead to avoid excessive allocation of pixel objects.
You can also usefor(PixelBase px: img){...}
syntax or theforEach(Consumer)
method to iterate this image.- Returns:
- a pixel object for this image.
- See Also:
getPixel(int, int)
-
getPixel
P getPixel(int x, int y)
Creates a new Pixel object for this Img at specified position. (0,0) is the top left corner, (width-1,height-1) is the bottom right corner.Tip:
Do not use this method repeatedly while iterating the image. UseContourPlot.PixelBase.setPosition(int, int)
instead to avoid excessive allocation of pixel objects.
You can also usefor(PixelBase px: img){...}
syntax or theforEach(Consumer)
method to iterate this image.- Parameters:
x
- coordinatey
- coordinate- Returns:
- a Pixel object for this Img at {x,y}.
- See Also:
getPixel()
-
toBufferedImage
java.awt.image.BufferedImage toBufferedImage(java.awt.image.BufferedImage bimg)
Copies this image's data to the specifiedBufferedImage
. This method will preserve theRaster
of the specified BufferedImage and will only modify the contents of it.- Parameters:
bimg
- the BufferedImage- Returns:
- the specified BufferedImage
- Throws:
java.lang.IllegalArgumentException
- if the provided BufferedImage has a different dimension as this image.- See Also:
toBufferedImage()
,getRemoteBufferedImage()
-
toBufferedImage
default java.awt.image.BufferedImage toBufferedImage()
- Returns:
- a BufferedImage of type INT_ARGB with this Img's data copied to it.
- See Also:
toBufferedImage(BufferedImage)
,getRemoteBufferedImage()
-
getRemoteBufferedImage
default java.awt.image.BufferedImage getRemoteBufferedImage()
Creates aBufferedImage
that shares the data of this image. Changes in this image are reflected in the created BufferedImage and vice versa. TheColorModel
andRaster
of the resulting BufferedImage are implementation dependent.This operation may not be supported by an implementation of
ContourPlot.ImgBase
and will then throw anUnsupportedOperationException
. UsesupportsRemoteBufferedImage()
to check if this operation is supported.- Returns:
- BufferedImage sharing this Img's data.
- Throws:
java.lang.UnsupportedOperationException
- if this implementation ofContourPlot.ImgBase
does not support this method.- See Also:
supportsRemoteBufferedImage()
,toBufferedImage(BufferedImage)
,toBufferedImage()
-
supportsRemoteBufferedImage
default boolean supportsRemoteBufferedImage()
Returns true when this implementation ofContourPlot.ImgBase
supports thegetRemoteBufferedImage()
method. This by default also indicates the support for the following methods:- Returns:
- true when supported, false otherwise.
-
createGraphics
default java.awt.Graphics2D createGraphics()
Creates aGraphics2D
, which can be used to draw into this image.
This operation may not be supported by an implementation ofContourPlot.ImgBase
and will then throw anUnsupportedOperationException
. UsesupportsRemoteBufferedImage()
to check if this operation is supported.- Returns:
- Graphics2D object to draw into this image.
- Throws:
java.lang.UnsupportedOperationException
- if this implementation ofContourPlot.ImgBase
does not support this method.- See Also:
supportsRemoteBufferedImage()
,paint(Consumer)
-
paint
default void paint(java.util.function.Consumer<java.awt.Graphics2D> paintInstructions)
Uses the specified paintInstructions to draw into this image. This method will pass aGraphics2D
object of this image to the specifiedConsumer
. TheConsumer.accept(Object)
method can then draw into this image. When the accept method returns, the Graphics2D object is disposed.This operation may not be supported by an implementation of
ContourPlot.ImgBase
and will then throw anUnsupportedOperationException
. UsesupportsRemoteBufferedImage()
to check if this operation is supported.Example (using lambda expression for Consumers accept method):
Img img = new Img(100, 100); img.paint( g2d -> { g2d.drawLine(0, 0, 100, 100); } );
- Parameters:
paintInstructions
- to be executed on a Graphics2D object of this image of this Img.- Throws:
java.lang.UnsupportedOperationException
- if this implementation ofContourPlot.ImgBase
does not support this method.- Since:
- 1.3
- See Also:
createGraphics()
-
iterator
default java.util.Iterator<P> iterator()
Returns an iterator over the pixels of this image. The iterator will always return the same object on next() but with different index (thus referencing different values in the image).- Specified by:
iterator
in interfacejava.lang.Iterable<P extends ContourPlot.PixelBase>
- Returns:
- an iterator over the pixels of this image.
- See Also:
iterator(int, int, int, int)
,spliterator()
,spliterator(int, int, int, int)
-
getSpliteratorMinimumSplitSize
default int getSpliteratorMinimumSplitSize()
Returns the minimum number of elements in a split of aSpliterator
of this Img. Spliterators will only split if they contain more elements than specified by this value. Default is 1024.- Returns:
- minimum number of elements of a Spliterator to allow for splitting.
-
iterator
default java.util.Iterator<P> iterator(int xStart, int yStart, int width, int height)
Returns anIterator
for the specified area of the image. The Iterator will always return the same pixel object on next() but with different index (thus referencing different values in the image).- Parameters:
xStart
- left boundary of the area (inclusive)yStart
- upper boundary of the area (inclusive)width
- of the areaheight
- of the area- Returns:
- iterator for iterating over the pixels in the specified area.
- Throws:
java.lang.IllegalArgumentException
- if provided area is not within this image's bounds, or if the area is not positive (width or height ≤ 0).- See Also:
iterator()
,spliterator()
,spliterator(int, int, int, int)
-
spliterator
default java.util.Spliterator<P> spliterator()
Returns aSpliterator
over the pixels of this image. Within each split of the Spliterator a unique pixel object will be used on tryAdvance() but with changing index (thus referencing different values in the image).- Specified by:
spliterator
in interfacejava.lang.Iterable<P extends ContourPlot.PixelBase>
- Returns:
- a Spliterator over the pixels of this image
- See Also:
spliterator(int, int, int, int)
,rowSpliterator()
,colSpliterator()
,iterator()
,iterator(int, int, int, int)
-
rowSpliterator
default java.util.Spliterator<P> rowSpliterator()
Creates aSpliterator
that guarantees that each split will at least cover an entire row of the Img. It also guarantes that each row will be iterated starting at the least index of that row (e.g.starts at index 0 then continues with index 1, then 2, until the end of the row, then continuing with the next row). This Spliterator iterates in row-major order.- Returns:
- Spliterator that splits at beginning of rows.
- See Also:
colSpliterator()
,spliterator()
,stream(Spliterator, boolean)
,stream(PixelConverter, boolean)
-
colSpliterator
default java.util.Spliterator<P> colSpliterator()
Creates aSpliterator
that guarantees that each split will at least cover an entire column of the Img. It also guarantes that each column will be iterated starting at the least index of that column (e.g.starts at index 0 then continues with index 1, then 2, until the end of the column, then continuing with the next column). This Spliterator iterates in column-major order.- Returns:
- Spliterator that splits at beginning of columns.
- See Also:
rowSpliterator()
,spliterator()
,stream(Spliterator, boolean)
,stream(PixelConverter, boolean)
-
spliterator
default java.util.Spliterator<P> spliterator(int xStart, int yStart, int width, int height)
Creates aSpliterator
over the pixels within the specified area.- Parameters:
xStart
- left boundary of the area (inclusive)yStart
- upper boundary of the area (inclusive)width
- of the areaheight
- of the area- Returns:
- spliterator for the specified area.
- Throws:
java.lang.IllegalArgumentException
- if provided area is not within this image's bounds, or if the area is not positive (width or height ≤ 0).- See Also:
spliterator()
,colSpliterator()
,rowSpliterator()
,stream(Spliterator, boolean)
,stream(PixelConverter, boolean)
-
forEach_defaultimpl
default void forEach_defaultimpl(java.util.function.Consumer<? super P> action)
Default implementation ofIterable.forEach(Consumer)
only for performance test purposes as it is slower than theforEach(Consumer)
implementation.- Parameters:
action
- to be performed
-
forEach
default void forEach(java.util.function.Consumer<? super P> action)
Performs the specified action on each of the pixels of this image.- Specified by:
forEach
in interfacejava.lang.Iterable<P extends ContourPlot.PixelBase>
- Parameters:
action
- to be performed- Since:
- 1.0
- See Also:
forEach(PixelManipulator)
,forEach(boolean, Consumer)
,forEach(boolean, PixelManipulator)
,forEach(PixelConverter, boolean, Consumer)
,forEach(int, int, int, int, Consumer)
,forEach(int, int, int, int, PixelManipulator)
,forEach(boolean, int, int, int, int, Consumer)
,forEach(boolean, int, int, int, int, PixelManipulator)
,forEach(PixelConverter, boolean, int, int, int, int, Consumer)
,stream()
-
forEach
default void forEach(boolean parallel, java.util.function.Consumer<? super P> action)
Performs the specified action on each of the pixels of this image.- Parameters:
parallel
- whether to be performed in parallelaction
- to be performed- See Also:
forEach(Consumer)
,forEach(PixelManipulator)
,forEach(boolean, Consumer)
,forEach(boolean, PixelManipulator)
,forEach(PixelConverter, boolean, Consumer)
,forEach(int, int, int, int, Consumer)
,forEach(int, int, int, int, PixelManipulator)
,forEach(boolean, int, int, int, int, Consumer)
,forEach(boolean, int, int, int, int, PixelManipulator)
,forEach(PixelConverter, boolean, int, int, int, int, Consumer)
,stream()
-
forEach
default void forEach(int xStart, int yStart, int width, int height, java.util.function.Consumer<? super P> action)
Applies the specified action to every pixel in the specified area of this image.- Parameters:
xStart
- left boundary of the area (inclusive)yStart
- upper boundary of the area (inclusive)width
- of the areaheight
- of the areaaction
- to be performed on each pixel- Throws:
java.lang.IllegalArgumentException
- if provided area is not within this images's bounds.- See Also:
forEach(Consumer)
,forEach(PixelManipulator)
,forEach(boolean, Consumer)
,forEach(boolean, PixelManipulator)
,forEach(PixelConverter, boolean, Consumer)
,forEach(int, int, int, int, Consumer)
,forEach(int, int, int, int, PixelManipulator)
,forEach(boolean, int, int, int, int, Consumer)
,forEach(boolean, int, int, int, int, PixelManipulator)
,forEach(PixelConverter, boolean, int, int, int, int, Consumer)
,stream()
-
forEach
default void forEach(boolean parallel, int xStart, int yStart, int width, int height, java.util.function.Consumer<? super P> action)
Applies the specified action to every pixel in the specified area of this image.- Parameters:
parallel
- whether to be performed in parallelxStart
- left boundary of the area (inclusive)yStart
- upper boundary of the area (inclusive)width
- of the areaheight
- of the areaaction
- to be performed on each pixel- Throws:
java.lang.IllegalArgumentException
- if provided area is not within this images's bounds, or if the area is not positive (width or height ≤ 0).- See Also:
forEach(Consumer)
,forEach(PixelManipulator)
,forEach(boolean, Consumer)
,forEach(boolean, PixelManipulator)
,forEach(PixelConverter, boolean, Consumer)
,forEach(int, int, int, int, Consumer)
,forEach(int, int, int, int, PixelManipulator)
,forEach(boolean, int, int, int, int, Consumer)
,forEach(boolean, int, int, int, int, PixelManipulator)
,forEach(PixelConverter, boolean, int, int, int, int, Consumer)
,stream()
-
forEach
default <T> void forEach(ContourPlot.PixelConvertingSpliterator.PixelConverter<? super P,T> converter, boolean parallel, java.util.function.Consumer<? super T> action)
Applies the specified action to every pixel of this image. Prior to applying the action, each time the pixel is converted using the specified converter. The action is then performed on an instance of the element type of the converter (which is also the type accepted by the action). Finally the modified instance is then converted back to the pixel.- Type Parameters:
T
- converter's element type- Parameters:
converter
- that converts the pixel to the type accepted by the actionparallel
- whether to be performed in parallelaction
- to be performed on each pixel- See Also:
forEach(Consumer)
,forEach(PixelManipulator)
,forEach(boolean, Consumer)
,forEach(boolean, PixelManipulator)
,forEach(PixelConverter, boolean, Consumer)
,forEach(int, int, int, int, Consumer)
,forEach(int, int, int, int, PixelManipulator)
,forEach(boolean, int, int, int, int, Consumer)
,forEach(boolean, int, int, int, int, PixelManipulator)
,forEach(PixelConverter, boolean, int, int, int, int, Consumer)
,stream()
-
forEach
default <T> void forEach(ContourPlot.PixelConvertingSpliterator.PixelConverter<? super P,T> converter, boolean parallel, int xStart, int yStart, int width, int height, java.util.function.Consumer<? super T> action)
Applies the specified action to every pixel in the specified area of this image. Prior to applying the action, each time the pixel is converted using the specified converter. The action is then performed on an instance of the element type of the converter (which is also the type accepted by the action). Finally the modified instance is then converted back to the pixel.- Type Parameters:
T
- converter's element type- Parameters:
converter
- that converts the pixel to the type accepted by the actionparallel
- whether to be performed in parallelxStart
- left boundary of the area (inclusive)yStart
- upper boundary of the area (inclusive)width
- of the areaheight
- of the areaaction
- to be performed on each pixel- Throws:
java.lang.IllegalArgumentException
- if provided area is not within this images's bounds, or if the area is not positive (width or height ≤ 0).- See Also:
forEach(Consumer)
,forEach(PixelManipulator)
,forEach(boolean, Consumer)
,forEach(boolean, PixelManipulator)
,forEach(PixelConverter, boolean, Consumer)
,forEach(int, int, int, int, Consumer)
,forEach(int, int, int, int, PixelManipulator)
,forEach(boolean, int, int, int, int, Consumer)
,forEach(boolean, int, int, int, int, PixelManipulator)
,forEach(PixelConverter, boolean, int, int, int, int, Consumer)
,stream()
-
forEach
default <T> void forEach(ContourPlot.PixelManipulator<? super P,T> manipulator)
Applies the specified manipulator to every pixel of this image.- Type Parameters:
T
- manipulator's element type- Parameters:
manipulator
- that will be applied- See Also:
forEach(Consumer)
,forEach(PixelManipulator)
,forEach(boolean, Consumer)
,forEach(boolean, PixelManipulator)
,forEach(PixelConverter, boolean, Consumer)
,forEach(int, int, int, int, Consumer)
,forEach(int, int, int, int, PixelManipulator)
,forEach(boolean, int, int, int, int, Consumer)
,forEach(boolean, int, int, int, int, PixelManipulator)
,forEach(PixelConverter, boolean, int, int, int, int, Consumer)
,stream()
-
forEach
default <T> void forEach(boolean parallel, ContourPlot.PixelManipulator<? super P,T> manipulator)
Applies the specified manipulator to every pixel of this image.- Type Parameters:
T
- manipulator's element type- Parameters:
parallel
- whether to be performed in parallelmanipulator
- that will be applied- See Also:
forEach(Consumer)
,forEach(PixelManipulator)
,forEach(boolean, Consumer)
,forEach(boolean, PixelManipulator)
,forEach(PixelConverter, boolean, Consumer)
,forEach(int, int, int, int, Consumer)
,forEach(int, int, int, int, PixelManipulator)
,forEach(boolean, int, int, int, int, Consumer)
,forEach(boolean, int, int, int, int, PixelManipulator)
,forEach(PixelConverter, boolean, int, int, int, int, Consumer)
,stream()
-
forEach
default <T> void forEach(int xStart, int yStart, int width, int height, ContourPlot.PixelManipulator<? super P,T> manipulator)
Applies the specified manipulator to every pixel in the specified area of this image.- Type Parameters:
T
- manipulator's element type- Parameters:
xStart
- left boundary of the area (inclusive)yStart
- upper boundary of the area (inclusive)width
- of the areaheight
- of the areamanipulator
- that will be applied- Throws:
java.lang.IllegalArgumentException
- if provided area is not within this images's bounds.- See Also:
forEach(Consumer)
,forEach(PixelManipulator)
,forEach(boolean, Consumer)
,forEach(boolean, PixelManipulator)
,forEach(PixelConverter, boolean, Consumer)
,forEach(int, int, int, int, Consumer)
,forEach(int, int, int, int, PixelManipulator)
,forEach(boolean, int, int, int, int, Consumer)
,forEach(boolean, int, int, int, int, PixelManipulator)
,forEach(PixelConverter, boolean, int, int, int, int, Consumer)
,stream()
-
forEach
default <T> void forEach(boolean parallel, int xStart, int yStart, int width, int height, ContourPlot.PixelManipulator<? super P,T> manipulator)
Applies the specified manipulator to every pixel in the specified area of this image.- Type Parameters:
T
- manipulator's element type- Parameters:
parallel
- whether to be performed in parallelxStart
- left boundary of the area (inclusive)yStart
- upper boundary of the area (inclusive)width
- of the areaheight
- of the areamanipulator
- that will be applied- Throws:
java.lang.IllegalArgumentException
- if provided area is not within this images's bounds.- See Also:
forEach(Consumer)
,forEach(PixelManipulator)
,forEach(boolean, Consumer)
,forEach(boolean, PixelManipulator)
,forEach(PixelConverter, boolean, Consumer)
,forEach(int, int, int, int, Consumer)
,forEach(int, int, int, int, PixelManipulator)
,forEach(boolean, int, int, int, int, Consumer)
,forEach(boolean, int, int, int, int, PixelManipulator)
,forEach(PixelConverter, boolean, int, int, int, int, Consumer)
,stream()
-
stream
static <Px extends ContourPlot.PixelBase> java.util.stream.Stream<Px> stream(java.util.Spliterator<Px> spliterator, boolean parallel)
Returns aStream<Pixel>
for the specifiedSpliterator<Pixel>
. This is just a wrapper method arroundStreamSupport.stream(Spliterator, boolean)
mainly used as syntactic sugar for the use with the non default Spliterators (rowSpliterator()
andcolSpliterator()
. When the default spliterator of the Img is sufficient the non-staticstream()
can be used.For example (horizontal edge detection in parallel using forward difference):
Img myImg = ...; ImgBase.stream(myImg.rowSpliterator(), true).forEach( px -> { int next = px.getImg().getValue(px.getX()+1, px.getY(), Img.boundary_mode_repeat_edge); int forwardDiff = Math.abs( Pixel.getLuminance(next) - px.getLuminance() ); px.setRGB(forwardDiff, forwardDiff, forwardDiff); });
- Type Parameters:
Px
- pixel type of the stream- Parameters:
spliterator
- Spliterator of Img to be streamedparallel
- whether parallel or sequential stream is returned- Returns:
- a new sequential or parallel pixel stream.
- See Also:
stream()
-
stream
default java.util.stream.Stream<P> stream()
Returns a sequentialStream
of pixels of this image. This Img'sspliterator()
is used to create the Stream.The elements of this stream are not distinct!
This is due to aContourPlot.PixelBase
object being a pointer into the data of the image and not a pixel value itself. While streaming the index of the pixel object is changed for each actual pixel of the image.
Thus, a Set created by the expressionimg.stream().collect(Collectors.toSet())
will only contain a single element.- Returns:
- pixel Stream of this image.
- See Also:
stream()
,stream(boolean parallel)
,stream(int x, int y, int w, int h)
,stream(boolean parallel, int x, int y, int w, int h)
,stream(PixelConverter c, boolean parallel)
,stream(PixelConverter c, boolean parallel, int x, int y, int w, int h)
,stream(Spliterator spliterator, boolean parallel)
,forEach(Consumer action)
-
stream
default java.util.stream.Stream<P> stream(boolean parallel)
Returns aStream
of pixels of this image. Depending on the specified argument, the stream will be parallel or sequential. This Img'sspliterator()
is used to create the Stream.The elements of this stream are not distinct!
This is due to aContourPlot.PixelBase
object being a pointer into the data of the image and not a pixel value itself. While streaming the index of the pixel object is changed for each actual pixel of the image.
Thus, a Set created by the expressionimg.stream().collect(Collectors.toSet())
will only contain a single element.- Parameters:
parallel
- whether the stream is parallel (true) or sequential (false)- Returns:
- pixel Stream of this image.
- See Also:
stream()
,stream(boolean parallel)
,stream(int x, int y, int w, int h)
,stream(boolean parallel, int x, int y, int w, int h)
,stream(PixelConverter c, boolean parallel)
,stream(PixelConverter c, boolean parallel, int x, int y, int w, int h)
,stream(Spliterator spliterator, boolean parallel)
,forEach(Consumer action)
-
stream
default java.util.stream.Stream<P> stream(int xStart, int yStart, int width, int height)
Returns a PixelStream
for the specified area of this Img.
This Img'sspliterator(int,int,int,int)
is used to create the Stream.- Parameters:
xStart
- left boundary of the area (inclusive)yStart
- upper boundary of the area (inclusive)width
- of the areaheight
- of the area- Returns:
- Pixel Stream for specified area.
- Throws:
java.lang.IllegalArgumentException
- if provided area is not within this Img's bounds.- See Also:
stream()
,stream(boolean parallel)
,stream(int x, int y, int w, int h)
,stream(boolean parallel, int x, int y, int w, int h)
,stream(PixelConverter c, boolean parallel)
,stream(PixelConverter c, boolean parallel, int x, int y, int w, int h)
,stream(Spliterator spliterator, boolean parallel)
,forEach(Consumer action)
-
stream
default java.util.stream.Stream<P> stream(boolean parallel, int xStart, int yStart, int width, int height)
Returns a PixelStream
for the specified area of this Img.
This Img'sspliterator(int,int,int,int)
is used to create the Stream.- Parameters:
parallel
- whether the stream is parallel (true) or sequential (false)xStart
- left boundary of the area (inclusive)yStart
- upper boundary of the area (inclusive)width
- of the areaheight
- of the area- Returns:
- Pixel Stream for specified area.
- Throws:
java.lang.IllegalArgumentException
- if provided area is not within this image's bounds.- See Also:
stream()
,stream(boolean parallel)
,stream(int x, int y, int w, int h)
,stream(boolean parallel, int x, int y, int w, int h)
,stream(PixelConverter c, boolean parallel)
,stream(PixelConverter c, boolean parallel, int x, int y, int w, int h)
,stream(Spliterator spliterator, boolean parallel)
,forEach(Consumer action)
-
stream
default <T> java.util.stream.Stream<T> stream(ContourPlot.PixelConvertingSpliterator.PixelConverter<? super P,T> converter, boolean parallel)
Returns aStream
of the specifiedContourPlot.PixelConvertingSpliterator.PixelConverter
's element type over the pixels of this image. Each pixel will be converted to the element type before being processed, and the element will be back converted to the pixel after processing. The conversion and back conversion is handled by the specified converter.- Type Parameters:
T
- converter's element type- Parameters:
converter
- that determines the element type of the stream and handles conversion/back conversionparallel
- whether the stream is parallel (true) or sequential (false)- Returns:
- a Stream over the pixels of this image in the representation given by the specified converter.
- See Also:
stream()
,stream(boolean parallel)
,stream(int x, int y, int w, int h)
,stream(boolean parallel, int x, int y, int w, int h)
,stream(PixelConverter c, boolean parallel)
,stream(PixelConverter c, boolean parallel, int x, int y, int w, int h)
,stream(Spliterator spliterator, boolean parallel)
,forEach(boolean, PixelManipulator)
,forEach(PixelConverter, boolean, Consumer)
-
stream
default <T> java.util.stream.Stream<T> stream(ContourPlot.PixelConvertingSpliterator.PixelConverter<? super P,T> converter, boolean parallel, int xStart, int yStart, int width, int height)
Returns aStream
of the specifiedContourPlot.PixelConvertingSpliterator.PixelConverter
's element type over the pixels of this image within the specified area. Each pixel will be converted to the element type before being processed, and the element will be back converted to the pixel after processing. The conversion and back conversion is handled by the specified converter.- Type Parameters:
T
- converter's element type- Parameters:
converter
- that determines the element type of the stream and handles conversion/back conversionparallel
- whether the stream is parallel (true) or sequential (false)xStart
- left boundary of the area (inclusive)yStart
- upper boundary of the area (inclusive)width
- of the areaheight
- of the area- Returns:
- a Stream over the pixels in the specified area of this image in the representation given by the specified converter.
- Throws:
java.lang.IllegalArgumentException
- if provided area is not within this image's bounds.- See Also:
stream()
,stream(boolean parallel)
,stream(int x, int y, int w, int h)
,stream(boolean parallel, int x, int y, int w, int h)
,stream(PixelConverter c, boolean parallel)
,stream(PixelConverter c, boolean parallel, int x, int y, int w, int h)
,stream(Spliterator spliterator, boolean parallel)
,forEach(boolean parallel, int x, int y, int w, int h, PixelManipulator m)
,forEach(PixelConverter c, boolean parallel, int x, int y, int w, int h, Consumer action)
-
copy
ContourPlot.ImgBase<P> copy()
Returns a deep copy of this image. 'Deep' means that changes made to this image are NOT reflected in the copy.- Returns:
- a deep copy.
-
-