private Image calculateImage(){
  Thread me=Thread.currentThread();
  int width=canvas.getSize().width;
  int height=canvas.getSize().height;
  int xvals[]=new int[2];
  int yvals[]=new int[2];
  int xmethod=XControls.getParams(xvals);
  int ymethod=YControls.getParams(yvals);
  int pixels[]=new int[width * height];
  int c[]=new int[4];
  int index=0;
  for (int j=0; j < height; j++) {
    for (int i=0; i < width; i++) {
      c[0]=c[1]=c[2]=0;
      c[3]=255;
      if (xmethod < ymethod) {
        applyMethod(c,xmethod,i,width,xvals);
        applyMethod(c,ymethod,j,height,yvals);
      }
 else {
        applyMethod(c,ymethod,j,height,yvals);
        applyMethod(c,xmethod,i,width,xvals);
      }
      pixels[index++]=((c[3] << 24) | (c[0] << 16) | (c[1] << 8)| c[2]);
    }
    if (runner != me) {
      return null;
    }
  }
  return createImage(new MemoryImageSource(width,height,ColorModel.getRGBdefault(),pixels,0,width));
}

private Image calculateImage ( ) { Thread me = Thread . currentThread ( ) ; int width = canvas . getSize ( ) . width ; int height = canvas . getSize ( ) . height ; int xvals [ ] = new int [ 2 ] ; int yvals [ ] = new int [ 2 ] ; int xmethod = XControls . getParams ( xvals ) ; int ymethod = YControls . getParams ( yvals ) ; int pixels [ ] = new int [ width * height ] ; int c [ ] = new int [ 4 ] ; int index = 0 ; for ( int j = 0 ; j < height ; j ++ ) { for ( int i = 0 ; i < width ; i ++ ) { c [ 0 ] = c [ 1 ] = c [ 2 ] = 0 ; c [ 3 ] = 255 ; if ( xmethod < ymethod ) { applyMethod ( c , xmethod , i , width , xvals ) ; applyMethod ( c , ymethod , j , height , yvals ) ; } else { applyMethod ( c , ymethod , j , height , yvals ) ; applyMethod ( c , xmethod , i , width , xvals ) ; } pixels [ index ++ ] = ( ( c [ 3 ] << 24 ) | ( c [ 0 ] << 16 ) | ( c [ 1 ] << 8 ) | c [ 2 ] ) ; } if ( runner != me ) { return null ; } } return createImage ( new MemoryImageSource ( width , height , ColorModel . getRGBdefault ( ) , pixels , 0 , width ) ) ; }
calculates and returns the image . halts the calculation and returns null if the applet is stopped during the calculation .
