public void paintScreen() { try { Graphics g = this.getGraphics(); if ((g != null) && dbImage != null) { g.drawImage(dbImage, 0, 0, null); Toolkit.getDefaultToolkit().sync(); g.dispose(); } } catch (AWTError e) { log.error("Graphics context error", e); } } }
try { strategy.show(); Toolkit.getDefaultToolkit().sync(); return (!strategy.contentsLost());
private static void sync() { if (animationNeedsSync) Toolkit.getDefaultToolkit().sync(); }
public void paintScreen() { try { Graphics g = this.getGraphics(); if ((g != null) && dbImage != null) { g.drawImage(dbImage, 0, 0, null); Toolkit.getDefaultToolkit().sync(); g.dispose(); } } catch (AWTError e) { log.error("Graphics context error", e); } } }
public void sync() { getUnderlyingToolkit().sync(); }
@Override public void paint(Graphics g){ super.paint(g); for(Animation animation : animations){ Graphics2D g2d = (Graphics2D)g.create(); animation.drawUpdate(g2d, this); g2d.dispose(); } Toolkit.getDefaultToolkit().sync(); g.dispose(); }
/** * Use active rendering to replace the off screen image on the screen */ private void paintScreen() // use active rendering to put the buffered image on-screen { Graphics g; try { g = this.getGraphics(); if ((g != null) && (dbImage != null)){ // counter++; g.drawImage(dbImage, 0, 0, null); } // Sync the display on some systems. // (on Linux, this fixes event queue problems) Toolkit.getDefaultToolkit().sync(); g.dispose(); } catch (Exception e) // quite commonly seen at applet destruction { logger.warn("Graphics error", e); } }
/** Sample the color at the given point on the screen. */ public Color sample(int x, int y) { // Service mode always returns black when sampled if (robot != null && !serviceMode) { // Make sure we sync the graphics Toolkit.getDefaultToolkit().sync(); // return robot.getPixelColor(x, y); } String msg = Strings.get("tester.Robot.no_sample"); throw new UnsupportedOperationException(msg); }
/** * Use active rendering to replace the off screen image on the screen */ private void paintScreen() // use active rendering to put the buffered image on-screen { Graphics g; try { g = this.getGraphics(); BufferedImage img = new BufferedImage(dbImage.getWidth(this), dbImage.getHeight(this), BufferedImage.TYPE_INT_RGB); Graphics gr = img.getGraphics(); gr.drawImage(dbImage, 0, 0, this); ImageIO.write(img, "png", new File("renderedImage.png")); if ((g != null) && (dbImage != null)){ // counter++; g.drawImage(dbImage, 0, 0, null); } // Sync the display on some systems. // (on Linux, this fixes event queue problems) Toolkit.getDefaultToolkit().sync(); g.dispose(); } catch (Exception e) // quite commonly seen at applet destruction { logger.warn("Graphics error", e); } }
/** * Pauses for a given amount of milliseconds. * * @param time The number of milliseconds to pause for. */ public static void pause (int time) { int t = time; int dt = 15; while (t > dt) { moveEvents(dt); Toolkit.getDefaultToolkit().sync(); try { Thread.currentThread().sleep(dt); } catch (InterruptedException e) { System.out.println("Error sleeping"); } t -= dt; } moveEvents(t); if (t == 0) return; try { Thread.currentThread().sleep(t); } catch (InterruptedException e) { System.out.println("Error sleeping"); } //while (!renderedOnce) { // try { Thread.currentThread().sleep(1); } // catch (InterruptedException e) { System.out.println("Error sleeping"); } // //renderedOnce = false; //showedOnce = true; }
/** * Pauses for a given amount of milliseconds. * * @param time The number of milliseconds to pause for. */ public static void pause (int time) { int t = time; int dt = 15; while (t > dt) { moveEvents(dt); Toolkit.getDefaultToolkit().sync(); try { Thread.currentThread().sleep(dt); } catch (InterruptedException e) { System.out.println("Error sleeping"); } t -= dt; } moveEvents(t); if (t == 0) return; try { Thread.currentThread().sleep(t); } catch (InterruptedException e) { System.out.println("Error sleeping"); } //while (!renderedOnce) { // try { Thread.currentThread().sleep(1); } // catch (InterruptedException e) { System.out.println("Error sleeping"); } // //renderedOnce = false; //showedOnce = true; }
public void setCursor(int cursor) { getFrame(serverBrowser).setCursor(new Cursor(cursor)); Toolkit.getDefaultToolkit().sync(); }
/* private final*/ public void setCursor(int cursor) { getFrame(this).setCursor(new Cursor(cursor)); Toolkit.getDefaultToolkit().sync(); }
super.paint(g); Graphics2D g2d = (Graphics2D) g; Toolkit.getDefaultToolkit().sync(); System.out.println("drawing line"); g2d.drawLine(10, 10, 40, 40);
/** * 渲染界面 */ public void render() { if (player == null || player.getMap() == null) { return; } if (getWidth() <= 0 || getHeight() <= 0) { System.out.println(this.getClass().getSimpleName() + ": width &/or height <= 0!!!"); return; } if (backImage == null || getWidth() != backImage.getWidth(null) || getHeight() != backImage.getHeight(null)) { backImage = new BufferedImage(getWidth(), getHeight(), BufferedImage.TRANSLUCENT); } backImageGraphics2D = (Graphics2D) backImage.getGraphics(); renderWorld(); backImageGraphics2D.dispose(); if (getGraphics() != null) { getGraphics().drawImage(backImage, 0, 0, null); Toolkit.getDefaultToolkit().sync(); } }
/** * 渲染界面 */ public void render() { if (player == null || player.getMap() == null) { return; } if (getWidth() <= 0 || getHeight() <= 0) { System.out.println(this.getClass().getSimpleName() + ": width &/or height <= 0!!!"); return; } if (backImage == null || getWidth() != backImage.getWidth(null) || getHeight() != backImage.getHeight(null)) { backImage = new BufferedImage(getWidth(), getHeight(), BufferedImage.TRANSLUCENT); } backImageGraphics2D = (Graphics2D) backImage.getGraphics(); renderWorld(); backImageGraphics2D.dispose(); if (getGraphics() != null) { getGraphics().drawImage(backImage, 0, 0, null); Toolkit.getDefaultToolkit().sync(); } }
public void render() { if (player == null || player.getMap() == null) { return; } if (poly == null) { poly = this.player.getMap().getKPolygon(center, 0, direction, 30, 80); } center.y += 0.5; if (center.y > 360) { center.y = 0; } translate = center.unityTranslate(direction, (float) (center.y), 60); if (getWidth() <= 0 || getHeight() <= 0) { System.out.println(this.getClass().getSimpleName() + ": width &/or height <= 0!!!"); return; } if (backImage == null || getWidth() != backImage.getWidth(null) || getHeight() != backImage.getHeight(null)) { backImage = new BufferedImage(getWidth(), getHeight(), BufferedImage.TRANSLUCENT); } backImageGraphics2D = (Graphics2D) backImage.getGraphics(); renderWorld(); backImageGraphics2D.dispose(); if (getGraphics() != null) { getGraphics().drawImage(backImage, 0, 0, null); Toolkit.getDefaultToolkit().sync(); } }
public void render() { if (player == null || player.getMap() == null) { return; } if (poly == null) { poly = this.player.getMap().getKPolygon(center, 0, direction, 30, 80); } center.y += 0.5; if (center.y > 360) { center.y = 0; } translate = center.unityTranslate(direction, (float) (center.y), 60); if (getWidth() <= 0 || getHeight() <= 0) { System.out.println(this.getClass().getSimpleName() + ": width &/or height <= 0!!!"); return; } if (backImage == null || getWidth() != backImage.getWidth(null) || getHeight() != backImage.getHeight(null)) { backImage = new BufferedImage(getWidth(), getHeight(), BufferedImage.TRANSLUCENT); } backImageGraphics2D = (Graphics2D) backImage.getGraphics(); renderWorld(); backImageGraphics2D.dispose(); if (getGraphics() != null) { getGraphics().drawImage(backImage, 0, 0, null); Toolkit.getDefaultToolkit().sync(); } }
private void update(ITurnSnapshot snapshot) { if (!initialized) { initialize(); } if (windowManager.isIconified() || !isDisplayable() || (getWidth() <= 0) || (getHeight() <= 0)) { return; } if (bufferStrategy != null) { try { Graphics2D g2 = (Graphics2D) bufferStrategy.getDrawGraphics(); if (g2 != null) { do { try { g2.setRenderingHints(renderingHints); drawBattle(g2, snapshot); } finally { g2.dispose(); } bufferStrategy.show(); } while (bufferStrategy.contentsLost()); Toolkit.getDefaultToolkit().sync(); // Update like... now! } } catch (NullPointerException e) {} } }
/** * Push the logical screen to the physical device. */ @Override public void flushPhysical() { // See if it is time to flip the blink time. long nowTime = System.currentTimeMillis(); if (nowTime >= blinkMillis + lastBlinkTime) { lastBlinkTime = nowTime; cursorBlinkVisible = !cursorBlinkVisible; // System.err.println("New lastBlinkTime: " + lastBlinkTime); } if ((swing.getFrame() != null) && (swing.getBufferStrategy() != null) ) { do { do { drawToSwing(); } while (swing.getBufferStrategy().contentsRestored()); swing.getBufferStrategy().show(); Toolkit.getDefaultToolkit().sync(); } while (swing.getBufferStrategy().contentsLost()); } else { // Non-triple-buffered, call drawToSwing() once drawToSwing(); } }