}
@Override
public void run() {
if ( this.isDrawable() ) {
BufferStrategy bs;
Graphics2D g2;
boolean mustCreateBuffer;
do {
g2 = null;
mustCreateBuffer = false;
bs = this.getBufferStrategy();
if ( bs == null ) {
if ( ! this.isDrawable() ) {
return;
}
mustCreateBuffer = true;
} else {
g2 = this.getStrategyGraphics( bs );
if ( g2 == null ) {
return;
}
}
if ( mustCreateBuffer ) {
if ( ! this.createBufferStrategy() ) {
return;
}
}
if ( bs == null ) {
bs = this.getBufferStrategy();
}
try {
if ( g2 == null ) {
this.readLock.lock();
try {
g2 = (Graphics2D) ( ( bs == null ) ? this.drawingCanvas.getGraphics() : this.getStrategyGraphics( bs ) );
} finally {
this.readLock.unlock();
}
}
if ( g2 != null ) {
g2.setColor( this.drawingCanvas.getBackground() );
g2.fillRect( 0, 0, this.drawingCanvas.getWidth(), this.drawingCanvas.getHeight() );
g2.setColor( this.drawingCanvas.getForeground() );
this.doDraw( g2 );
this.applyFadeoutEffect( g2, this.getFadeoutStartTime() );
}
} catch ( Exception e ) {
this.setError( e );
this.doCallback( this.getObservers() );
return;
} finally {
if ( g2 != null && bs != null ) {
g2.dispose();
}
}
if ( bs != null ) {
bs.show();
}
} while ( bs != null && bs.contentsLost() && this.isDrawable() );
}
}