Skip to content

Commit 7ab7a41

Browse files
committed
Simplify
1 parent 7aa667a commit 7ab7a41

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

src/main/java/net/imglib2/img/display/imagej/ImageJFunctions.java

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
import net.imglib2.type.numeric.integer.UnsignedIntType;
5858
import net.imglib2.type.numeric.integer.UnsignedShortType;
5959
import net.imglib2.type.numeric.real.FloatType;
60-
import net.imglib2.util.Util;
60+
import net.imglib2.util.Cast;
6161

6262
import ij.ImagePlus;
6363
import ij.VirtualStack;
@@ -217,26 +217,20 @@ public static < T extends NumericType< T > > ImagePlus wrap( final RandomAccessi
217217
final ExecutorService service )
218218
{
219219
ImagePlus target;
220-
final T t = Util.getTypeFromInterval( img );
221-
222-
// NB: Casting madness thanks to a long standing javac bug;
223-
// see e.g. http://bugs.sun.com/view_bug.do?bug_id=6548436
224-
// TODO: remove casting madness as soon as the bug is fixed
225-
final Object oImg = img;
226-
if ( ARGBType.class.isInstance( t ) )
227-
target = wrapRGB( ( RandomAccessibleInterval< ARGBType > ) oImg, title, service );
228-
else if ( UnsignedByteType.class.isInstance( t ) )
229-
target = wrapUnsignedByte( ( RandomAccessibleInterval< RealType > ) oImg, title, service );
230-
else if ( BitType.class.isInstance( t ) )
231-
{
232-
target = wrapBit( ( RandomAccessibleInterval< RealType > ) oImg, title, service );
233-
}
234-
else if ( IntegerType.class.isInstance( t ) )
235-
target = wrapUnsignedShort( ( RandomAccessibleInterval< RealType > ) oImg, title, service );
236-
else if ( RealType.class.isInstance( t ) )
237-
target = wrapFloat( ( RandomAccessibleInterval< RealType > ) oImg, title, service );
238-
else if ( ComplexType.class.isInstance( t ) )
239-
target = wrapFloat( ( RandomAccessibleInterval< ComplexType > ) oImg, new ComplexPowerGLogFloatConverter(), title, service );
220+
final T t = img.getType();
221+
222+
if ( t instanceof ARGBType )
223+
target = wrapRGB( Cast.unchecked( img ), title, service );
224+
else if ( t instanceof UnsignedByteType )
225+
target = wrapUnsignedByte( Cast.unchecked( img ), title, service );
226+
else if ( t instanceof BitType )
227+
target = wrapBit( Cast.unchecked( img ), title, service );
228+
else if ( t instanceof IntegerType )
229+
target = wrapUnsignedShort( Cast.unchecked( img ), title, service );
230+
else if ( t instanceof RealType )
231+
target = wrapFloat( Cast.unchecked( img ), title, service );
232+
else if ( t instanceof ComplexType )
233+
target = wrapFloat( Cast.unchecked( img ), new ComplexPowerGLogFloatConverter(), title, service );
240234
else
241235
{
242236
System.out.println( "Do not know how to display Type " + t.getClass().getSimpleName() );

0 commit comments

Comments
 (0)