|
57 | 57 | import net.imglib2.type.numeric.integer.UnsignedIntType;
|
58 | 58 | import net.imglib2.type.numeric.integer.UnsignedShortType;
|
59 | 59 | import net.imglib2.type.numeric.real.FloatType;
|
60 |
| -import net.imglib2.util.Util; |
| 60 | +import net.imglib2.util.Cast; |
61 | 61 |
|
62 | 62 | import ij.ImagePlus;
|
63 | 63 | import ij.VirtualStack;
|
@@ -217,26 +217,20 @@ public static < T extends NumericType< T > > ImagePlus wrap( final RandomAccessi
|
217 | 217 | final ExecutorService service )
|
218 | 218 | {
|
219 | 219 | 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 ); |
240 | 234 | else
|
241 | 235 | {
|
242 | 236 | System.out.println( "Do not know how to display Type " + t.getClass().getSimpleName() );
|
|
0 commit comments