| 282 | |
| 283 | |
| 284 | synchronized protected void render() { |
| 285 | if (canvas.isDisplayable() && |
| 286 | graphics.image != null) { |
| 287 | if (canvas.getBufferStrategy() == null) { |
| 288 | canvas.createBufferStrategy(2); |
| 289 | } |
| 290 | BufferStrategy strategy = canvas.getBufferStrategy(); |
| 291 | if (strategy != null) { |
| 292 | // Render single frame |
| 293 | // try { |
| 294 | do { |
| 295 | // The following loop ensures that the contents of the drawing buffer |
| 296 | // are consistent in case the underlying surface was recreated |
| 297 | do { |
| 298 | Graphics2D draw = (Graphics2D) strategy.getDrawGraphics(); |
| 299 | // draw to width/height, since this may be a 2x image |
| 300 | draw.drawImage(graphics.image, 0, 0, sketchWidth, sketchHeight, null); |
| 301 | draw.dispose(); |
| 302 | } while (strategy.contentsRestored()); |
| 303 | |
| 304 | // Display the buffer |
| 305 | strategy.show(); |
| 306 | |
| 307 | // Repeat the rendering if the drawing buffer was lost |
| 308 | } while (strategy.contentsLost()); |
| 309 | } |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | |
| 314 | /* |