Package net.imglib2.loops
Class LoopUtils
- java.lang.Object
-
- net.imglib2.loops.LoopUtils
-
public final class LoopUtils extends java.lang.ObjectLoopUtilscontains methods to simplify writing a loop over an image line or image interval.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLoopUtils.LineProcessor
-
Field Summary
Fields Modifier and Type Field Description private static ClassCopyProvider<java.lang.Runnable>factory
-
Constructor Summary
Constructors Modifier Constructor Description privateLoopUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.RunnablecreateIntervalLoop(Positionable positionable, Dimensions dimensions, java.lang.Runnable action)Returns aRunnablecontaining a loop.static java.lang.RunnablecreateLineLoop(Positionable positionable, long length, int dimension, java.lang.Runnable action)Returns a loop, that moves the given positonable along a line, and executes the given operation for each pixel of the line.
-
-
-
Field Detail
-
factory
private static ClassCopyProvider<java.lang.Runnable> factory
-
-
Method Detail
-
createLineLoop
public static java.lang.Runnable createLineLoop(Positionable positionable, long length, int dimension, java.lang.Runnable action)
Returns a loop, that moves the given positonable along a line, and executes the given operation for each pixel of the line. The method uses
ClassCopyProvider, such that the returned loop can be optimised gracefully by the java just-in-time compiler. Aside from that, the result is functionally equivalent to:Runnable result = () -> { for (long i = 0; i < length; i++) { operation.run(); positionable.fwd(dimension); } positionable.move(- length, dimension); }- Parameters:
positionable- Positionable that is moved (along a line). Defines the starting point of the line. After the loops execution the positionable is moved back to the starting point.length- Length of the line.dimension- Direction of the line.action- Operation that is executed for each pixel along the line.- Returns:
- A
Runnablethat is functionally equivalent to:
-
createIntervalLoop
public static java.lang.Runnable createIntervalLoop(Positionable positionable, Dimensions dimensions, java.lang.Runnable action)
Returns aRunnablecontaining a loop. The loop moves the given positionable over all the pixels of an interval. For each pixel of the interval the given operation is executed.- Parameters:
positionable- Positionable that is moved. Defines the minimum point of the interval. After the loops execution the positionable is moved back to the starting point.dimensions- Dimensions of the interval.action- Operation that is executed for each pixel of the interval.
-
-