import java.awt.*;
public class DoubleBufferedClipped extends Clipped {
Image offScreenImage;
Graphics offScreenGC;
public void update( Graphics g ) {
if ( offScreenImage == null ) {
offScreenImage = createImage( getSize().width, getSize().height );
offScreenGC = offScreenImage.getGraphics();
}
int lastX = currentX, lastY = currentY;
currentX = nextX; currentY = nextY;
clipToAffectedArea( offScreenGC, lastX, lastY, currentX, currentY, imgWidth, imgHeight );
clipToAffectedArea( g, lastX, lastY, currentX, currentY, imgWidth, imgHeight );
paint( offScreenGC );
g.drawImage(offScreenImage, 0, 0, this);
}
}
|