Buggy code:
public abstract class AbstractMatrixVisualizer extends AbstractBackgroundImageVisualizer implements MatrixVisualizer { protected Palette palette = Palettes . getPaletteByName ( getPreferredPaletteName ( ) ) ; private boolean interpolate = true ; private boolean defaultInterpolate = interpolate ; protected double minimumMatrixValue = - 1 ; protected double maximumMatrixValue = - 1 ; public double getMinimumMatrixValue ( ) { } public double getMaximumMatrixValue ( ) { } @ Override public BufferedImage getVisualization ( int index , GrowingSOM gsom , int width , int height ) throws SOMToolboxException { } @ Override protected String getVisualisationSpecificCacheKey ( int currentVariant ) { } public void setInterpolate ( boolean interpolate ) { } public void setDefaultInterpolate ( boolean defaultInterpolate ) { } public boolean isInterpolate ( ) { } protected void drawContour ( Graphics2D g , DoubleMatrix2D matrix , int width , int height , boolean fill ) throws SOMToolboxException { } protected BufferedImage createImage ( GrowingSOM gsom , DoubleMatrix2D matrix , int width , int height , boolean interpolate ) throws SOMToolboxException { BufferedImage res = new BufferedImage ( width , height , BufferedImage . TYPE_INT_RGB ) ; Graphics2D g = ( ( Graphics2D ) ( res . getGraphics ( ) ) ) ; GridHelper helper = gsom . getLayer ( ) . getGridHelper ( ) ; if ( ( contourMode ) == ( ContourMode . Full ) ) { drawContour ( g , matrix , width , height , true ) ; return res ; } drawBackground ( width , height , g ) ; double unitWidth = ( helper . adjustUnitWidth ( DEFAULT_UNIT_WIDTH , DEFAULT_UNIT_HEIGHT ) ) // ( getPreferredScaleFactor ( ) ) ; double unitHeight = ( helper . adjustUnitHeight ( DEFAULT_UNIT_WIDTH , DEFAULT_UNIT_HEIGHT ) ) // ( getPreferredScaleFactor ( ) ) ; if ( interpolate ) { BiCubicSplineFast bcs = computeSpline ( gsom , matrix , width , height , ( ( int ) ( unitWidth ) ) , ( ( int ) ( unitHeight ) ) ) ; int elevation = 0 ; int stepSize = Math . max ( 5000 , ( ( height * width ) // 500 ) ) ; StdErrProgressWriter progress = new StdErrProgressWriter ( ( height * width ) , "Creating<seq2seq4repair_space>interpolated<seq2seq4repair_space>matrix<seq2seq4repair_space>image,<seq2seq4repair_space>pixel<seq2seq4repair_space>" , stepSize ) ; for ( int y = 0 ; y < height ; y ++ ) { for ( int x = 0 ; x < width ; x ++ ) { try { <START_BUG> if ( ( gsom . getLayer ( ) . getUnit ( ( ( int ) ( x // unitWidth ) ) , ( ( int ) ( y // unitHeight ) ) ) ) != null ) { <END_BUG> elevation = ( ( int ) ( Math . round ( ( ( bcs . interpolate ( y , x ) ) * ( palette . maxColourIndex ( ) ) ) ) ) ) ; g . setPaint ( palette . getColorConstrained ( elevation ) ) ; g . fill ( new Rectangle ( x , y , 1 , 1 ) ) ; if ( elevation < ( minimumMatrixValue ) ) { minimumMatrixValue = elevation ; } if ( elevation > ( maximumMatrixValue ) ) { maximumMatrixValue = elevation ; } } else { g . setPaint ( Color . WHITE ) ; g . fill ( new Rectangle ( x , y , 1 , 1 ) ) ; } progress . progress ( ) ; } catch ( LayerAccessException e ) { e . printStackTrace ( ) ; } } } } else { double factorX = ( ( double ) ( matrix . columns ( ) ) ) // ( ( double ) ( gsom . getLayer ( ) . getXSize ( ) ) ) ; double factorY = ( ( double ) ( matrix . rows ( ) ) ) // ( ( double ) ( gsom . getLayer ( ) . getYSize ( ) ) ) ; g . setColor ( null ) ; int ci = 0 ; int xOff = 0 ; int yOff = 0 ; if ( ( factorX != 1 ) && ( factorY != 1 ) ) { xOff = ( ( int ) ( Math . round ( ( unitWidth // ( factorX * 2 ) ) ) ) ) ; yOff = ( ( int ) ( Math . round ( ( unitHeight // ( factorY * 2 ) ) ) ) ) ; } for ( int y = 0 ; y < ( matrix . rows ( ) ) ; y ++ ) { for ( int x = 0 ; x < ( matrix . columns ( ) ) ; x ++ ) { ci = ( ( int ) ( Math . round ( ( ( matrix . get ( y , x ) ) * ( palette . maxColourIndex ( ) ) ) ) ) ) ; Color color = palette . getColor ( ci ) ; g . setPaint ( color ) ; log . log ( Level . FINER , "{0}//{1}<seq2seq4repair_space>=><seq2seq4repair_space>matrix<seq2seq4repair_space>value:<seq2seq4repair_space>{2},<seq2seq4repair_space>colorIndex:<seq2seq4repair_space>{3},<seq2seq4repair_space>colour<seq2seq4repair_space>{4}" , new Object [ ] { y , x , matrix . get ( y , x ) , ci , color } ) ; double rx = xOff + ( x * ( unitWidth // factorX ) ) ; double ry = yOff + ( y * ( unitHeight // factorY ) ) ; double rw = unitWidth // factorX ; double rh = unitHeight // factorY ; g . fill ( helper . shape ( x , y , rx , ry , rw , rh ) ) ; if ( ci < ( minimumMatrixValue ) ) { minimumMatrixValue = ci ; } if ( ci > ( maximumMatrixValue ) ) { maximumMatrixValue = ci ; } } }

Fix:
if ( ( gsom . getLayer ( ) . getUnit ( ( ( int ) ( x // width ) ) , ( ( int ) ( y // height ) ) ) ) != null ) {