protected BufferedImage resetDrawingBuffer(BufferedImage currentImageBuffer,Projection proj){
  try {
    int w=proj.getWidth();
    int h=proj.getHeight();
    if (currentImageBuffer != null) {
      int cibWidth=currentImageBuffer.getWidth();
      int cibHeight=currentImageBuffer.getHeight();
      if (cibWidth == w && cibHeight == h) {
        Graphics2D graphics=(Graphics2D)currentImageBuffer.getGraphics();
        graphics.setComposite(AlphaComposite.Clear);
        graphics.fillRect(0,0,w,h);
        graphics.setComposite(AlphaComposite.SrcOver);
        return currentImageBuffer;
      }
 else {
        currentImageBuffer.flush();
      }
    }
    return new BufferedImage(w,h,BufferedImage.TYPE_INT_ARGB);
  }
 catch (  java.lang.NegativeArraySizeException nae) {
  }
catch (  java.lang.IllegalArgumentException iae) {
  }
  return new BufferedImage(1,1,BufferedImage.TYPE_INT_ARGB);
}

protected BufferedImage resetDrawingBuffer ( BufferedImage currentImageBuffer , Projection proj ) { try { int w = proj . getWidth ( ) ; int h = proj . getHeight ( ) ; if ( currentImageBuffer != null ) { int cibWidth = currentImageBuffer . getWidth ( ) ; int cibHeight = currentImageBuffer . getHeight ( ) ; if ( cibWidth == w && cibHeight == h ) { Graphics2D graphics = ( Graphics2D ) currentImageBuffer . getGraphics ( ) ; graphics . setComposite ( AlphaComposite . Clear ) ; graphics . fillRect ( 0 , 0 , w , h ) ; graphics . setComposite ( AlphaComposite . SrcOver ) ; return currentImageBuffer ; } else { currentImageBuffer . flush ( ) ; } } return new BufferedImage ( w , h , BufferedImage . TYPE_INT_ARGB ) ; } catch ( java . lang . NegativeArraySizeException nae ) { } catch ( java . lang . IllegalArgumentException iae ) { } return new BufferedImage ( 1 , 1 , BufferedImage . TYPE_INT_ARGB ) ; }
provide a drawing buffer for the layers based on the projection parameters . if the currentimagebuffer is the right size , the pixels will be cleared .
