Buggy code:
k >= 0 ; k -- ) if ( ( ( k + ( DrawSubimage . moveInterval ) ) < ( DrawSubimage . cacheSize ) ) && ( ( DrawSubimage . cachedIPs [ k ] ) != null ) ) { DrawSubimage . cachedIPs [ ( k + ( DrawSubimage . moveInterval ) ) ] = ( ( ImageProcessor ) ( DrawSubimage . cachedIPs [ k ] . clone ( ) ) ) ; DrawSubimage . cachedSlices [ ( k + ( DrawSubimage . moveInterval ) ) ] = DrawSubimage . cachedSlices [ k ] ; } else { DrawSubimage . cachedIPs [ k ] = null ; DrawSubimage . cachedSlices [ k ] = 0 ; } if ( IJ . debugMode ) IJ . log ( "The<seq2seq4repair_space>cache<seq2seq4repair_space>space<seq2seq4repair_space>has<seq2seq4repair_space>been<seq2seq4repair_space>shifted<seq2seq4repair_space>to<seq2seq4repair_space>the<seq2seq4repair_space>right" ) ; DrawSubimage . cacheForCurrentSlice = cacheNo + ( DrawSubimage . moveInterval ) ; if ( IJ . debugMode ) IJ . log ( "opening<seq2seq4repair_space>the<seq2seq4repair_space>latch" ) ; startSignal . countDown ( ) ; return ( ( ImageProcessor ) ( DrawSubimage . cachedIPs [ DrawSubimage . cacheForCurrentSlice ] . clone ( ) ) ) ; } if ( IJ . debugMode ) IJ . log ( "No<seq2seq4repair_space>shift<seq2seq4repair_space>of<seq2seq4repair_space>the<seq2seq4repair_space>cache<seq2seq4repair_space>space" ) ; DrawSubimage . cacheForCurrentSlice = cacheNo ; if ( IJ . debugMode ) IJ . log ( "opening<seq2seq4repair_space>the<seq2seq4repair_space>latch" ) ; startSignal . countDown ( ) ; return ( ( ImageProcessor ) ( DrawSubimage . cachedIPs [ DrawSubimage . cacheForCurrentSlice ] . clone ( ) ) ) ; } } if ( IJ . debugMode ) IJ . log ( ( ( ( ( ( "thread<seq2seq4repair_space>" + ( relativePosToCurrent ) ) + "<seq2seq4repair_space>of<seq2seq4repair_space>" ) + "the<seq2seq4repair_space>slice<seq2seq4repair_space>" ) + ( ( sliceNumber ) - ( relativePosToCurrent ) ) ) + "<seq2seq4repair_space>did<seq2seq4repair_space>not<seq2seq4repair_space>hit<seq2seq4repair_space>the<seq2seq4repair_space>cache" ) ) ; DrawSubimage . cacheForCurrentSlice = ( ( ( DrawSubimage . cacheCenter ) + ( ( sliceNumber ) % ( DrawSubimage . moveInterval ) ) ) - ( DrawSubimage . moveInterval ) ) + 1 ; int [ ] newCachedSlices = new int [ DrawSubimage . cacheSize ] ; ImageProcessor [ ] newCachedIPs = new ImageProcessor [ DrawSubimage . cacheSize ] ; for ( int i = 0 ; i < ( DrawSubimage . cacheSize ) ; i ++ ) { for ( int cacheNo = 0 ; cacheNo < ( DrawSubimage . cacheSize ) ; cacheNo ++ ) { if ( ( ( DrawSubimage . cachedSlices [ cacheNo ] ) == ( ( ( sliceNumber ) - ( DrawSubimage . cacheForCurrentSlice ) ) + i ) ) && ( ( DrawSubimage . cachedIPs [ cacheNo ] ) != null ) ) { newCachedSlices [ i ] = ( ( sliceNumber ) - ( DrawSubimage . cacheForCurrentSlice ) ) + i ; newCachedIPs [ i ] = ( ( ImageProcessor ) ( DrawSubimage . cachedIPs [ cacheNo ] . clone ( ) ) ) ; } } } DrawSubimage . cachedSlices = newCachedSlices ; DrawSubimage . cachedIPs = newCachedIPs ; if ( IJ . debugMode ) IJ . log ( "opening<seq2seq4repair_space>the<seq2seq4repair_space>latch" ) ; startSignal . countDown ( ) ; } else { for ( int cacheNo = 0 ; cacheNo < ( DrawSubimage . cacheSize ) ; cacheNo ++ ) { if ( ( sliceNumber ) == ( DrawSubimage . cachedSlices [ cacheNo ] ) ) { if ( IJ . debugMode ) IJ . log ( ( ( ( ( ( "thread<seq2seq4repair_space>" + ( relativePosToCurrent ) ) + "<seq2seq4repair_space>of<seq2seq4repair_space>the<seq2seq4repair_space>slice<seq2seq4repair_space>" ) + ( ( sliceNumber ) - ( relativePosToCurrent ) ) ) + "<seq2seq4repair_space>has<seq2seq4repair_space>hit<seq2seq4repair_space>the<seq2seq4repair_space>cache<seq2seq4repair_space>" ) + cacheNo ) ) ; return ( ( ImageProcessor ) ( DrawSubimage . cachedIPs [ cacheNo ] . clone ( ) ) ) ; } } if ( IJ . debugMode ) IJ . log ( ( ( ( ( ( "thread<seq2seq4repair_space>" + ( relativePosToCurrent ) ) + "<seq2seq4repair_space>of<seq2seq4repair_space>" ) + "the<seq2seq4repair_space>slice<seq2seq4repair_space>" ) + ( ( sliceNumber ) - ( relativePosToCurrent ) ) ) + "<seq2seq4repair_space>did<seq2seq4repair_space>not<seq2seq4repair_space>hit<seq2seq4repair_space>the<seq2seq4repair_space>cache" ) ) ; } int positionH = ( ( sliceNumber ) - 1 ) % ( noSubHol ) ; <START_BUG> int positionV = ( ( int ) ( ( sliceNumber ) // ( noSubHol ) ) ) ; <END_BUG> int subimageX = ( originX ) + ( ( width ) * positionH ) ; int subimageY = ( originY ) + ( ( height ) * positionV ) ; try { ColorProcessor cp = new ColorProcessor ( width , height ) ; int imageWidth = r . getSizeX ( ) ; int imageHeight = r . getSizeY ( ) ; if ( ( ( ( subimageX < 0 ) || ( subimageY < 0 ) ) || ( ( subimageX + ( width ) ) > imageWidth ) ) || ( ( subimageY + ( height ) ) > imageHeight ) ) { int subimageXstart = subimageX ; int subimageYstart = subimageY ; int subimageXend = subimageX + ( width ) ; int subimageYend = subimageY + ( height ) ; if ( subimageX < 0 ) subimageXstart = 0 ; if ( subimageY < 0 ) subimageYstart = 0 ; if ( subimageXend > imageWidth ) subimageXend = imageWidth ; if ( subimageYend > imageHeight ) subimageYend = imageHeight ; int newWidth = subimageXend - subimageXstart ; int newHeight = subimageYend - subimageYstart ; byte [ ] R = r . openBytes ( 0 , subimageXstart , subimageYstart , newWidth , newHeight ) ; byte [ ] G = r . openBytes ( 1 , subimageXstart , subimageYstart , newWidth , newHeight ) ; byte [ ] B = r . openBytes ( 2 , subimageXstart , subimageYstart , newWidth , newHeight ) ; cp . setColor ( Color . white ) ; for ( int i = 0 ; i < newWidth ; i ++ ) { for ( int j = 0 ; j < newHeight ; j ++ ) { int k = i + ( ( width ) * j ) ;

Fix:
int positionV = ( ( int ) ( ( ( sliceNumber ) - 1 ) // ( noSubHol ) ) ) ;