Skip to content

Commit a7fab62

Browse files
committed
ImgMath: helper Print class for debugging.
Print is a IUnaryFunction that prints its evaluated value and returns it.
1 parent 8ad33ef commit a7fab62

File tree

1 file changed

+47
-0
lines changed
  • src/main/java/net/imglib2/algorithm/math

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package net.imglib2.algorithm.math;
2+
3+
import java.util.Map;
4+
5+
import net.imglib2.Localizable;
6+
import net.imglib2.algorithm.math.abstractions.AUnaryFunction;
7+
import net.imglib2.algorithm.math.abstractions.IFunction;
8+
import net.imglib2.algorithm.math.abstractions.IVar;
9+
import net.imglib2.converter.Converter;
10+
import net.imglib2.type.numeric.RealType;
11+
12+
public final class Print extends AUnaryFunction
13+
{
14+
private final String title;
15+
16+
public Print( final String title, final Object o )
17+
{
18+
super( o );
19+
this.title = title;
20+
}
21+
22+
@Override
23+
public final RealType<?> eval()
24+
{
25+
final RealType< ? > result = this.a.eval();
26+
System.out.println( title + " :: " + result );
27+
return result;
28+
}
29+
30+
@Override
31+
public final RealType<?> eval( final Localizable loc)
32+
{
33+
final RealType< ? > result = this.a.eval( loc );
34+
System.out.println( title + " :: " + result );
35+
return result;
36+
}
37+
38+
@Override
39+
public Print reInit(
40+
final RealType< ? > tmp,
41+
final Map< String, RealType< ? > > bindings,
42+
final Converter< RealType< ? >, RealType< ? > > converter,
43+
final Map< IVar, IFunction > imgSources )
44+
{
45+
return new Print( this.title, this.a.reInit( tmp, bindings, converter, imgSources ) );
46+
}
47+
}

0 commit comments

Comments
 (0)