/** * Paints the image at the specified location. This method assumes * scaling has already been done, and simply paints the background * image "as-is." * * @param g The graphics context. * @param x The x-coordinate at which to paint. * @param y The y-coordinate at which to paint. */ @Override protected void paintImage(Graphics g, int x, int y) { if (bgImage != null) { do { int rc = bgImage.validate(null);//getGraphicsConfiguration()); if (rc==VolatileImage.IMAGE_RESTORED) { // FIXME: If the image needs to be restored are its width // and height still valid?? If not, we'll need to cache // these values... renderImage(bgImage.getWidth(), bgImage.getHeight(), getScalingHint()); } g.drawImage(bgImage, x,y, null); } while (bgImage.contentsLost()); } }
/** * Clears a volatile image */ public static void clearVolatileImage(@Nonnull VolatileImage volatileImage) { Graphics2D graphics = (Graphics2D) volatileImage.getGraphics(); try { graphics.setComposite(AlphaComposite.DstOut); graphics.fillRect(0, 0, volatileImage.getWidth(), volatileImage.getHeight()); } finally { graphics.dispose(); } }
private VolatileImage vImg; @Override public void paint(Graphics g) { if (gc==null) gc = this.getGraphicsConfiguration(); do { boolean sizeChanged = false; sizeChanged = (vImg!=null&&(vImg.getWidth()!=getWidth()|| vImg.getHeight()!=getHeight())); if (vImg == null || vImg.validate(gc) == VolatileImage.IMAGE_INCOMPATIBLE || sizeChanged) { vImg = gc.createCompatibleVolatileImage(getWidth(), getHeight()); vImg.setAccelerationPriority(1); } final Graphics gimg = vImg.getGraphics(); if (gimg instanceof Graphics2D) { renderContents((Graphics2D) gimg); gimg.dispose(); g.drawImage(vImg, 0, 0, null); } else { throw new UnsupportedOperationException("Rendering impossible, graphics are not of Graphics2D class"); } } while (vImg.contentsLost()); updateAnimationNo(); }
private void renderVolatileImage(BufferedImage bufferedImage) { do { int w = bufferedImage.getWidth(), h = bufferedImage.getHeight(); GraphicsConfiguration gc = getGraphicsConfiguration(); if (volatileImage == null || volatileImage.getWidth() != w || volatileImage.getHeight() != h || volatileImage.validate(gc) == VolatileImage.IMAGE_INCOMPATIBLE) { if (volatileImage != null) { volatileImage.flush(); } volatileImage = gc.createCompatibleVolatileImage(w, h); volatileImage.setAccelerationPriority(1.0f); } // // Now paint the BufferedImage into the accelerated image // Graphics2D g = volatileImage.createGraphics(); g.drawImage(bufferedImage, 0, 0, null); g.dispose(); } while (volatileImage.contentsLost()); }
/** * Paints the image at the specified location. This method assumes * scaling has already been done, and simply paints the background * image "as-is." * * @param g The graphics context. * @param x The x-coordinate at which to paint. * @param y The y-coordinate at which to paint. */ protected void paintImage(Graphics g, int x, int y) { if (bgImage != null) { do { int rc = bgImage.validate(null);//getGraphicsConfiguration()); if (rc==VolatileImage.IMAGE_RESTORED) { // FIXME: If the image needs to be restored are its width // and height still valid?? If not, we'll need to cache // these values... renderImage(bgImage.getWidth(), bgImage.getHeight(), getScalingHint()); } g.drawImage(bgImage, x,y, null); } while (bgImage.contentsLost()); } }
private void renderVolatileImage(final GraphicsConfiguration gc, final BufferedImage image) { do { if (volatileImage == null || volatileImage.getWidth() != SIDE || volatileImage.getHeight() != SIDE || volatileImage.validate(gc) == VolatileImage.IMAGE_INCOMPATIBLE) { if (volatileImage != null) { volatileImage.flush(); } volatileImage = gc.createCompatibleVolatileImage(SIDE, SIDE); volatileImage.setAccelerationPriority(1.0f); invalid_volatile = false; } // // Now paint the BufferedImage into the accelerated image // final Graphics2D g = volatileImage.createGraphics(); if (null != image) g.drawImage(image, 0, 0, SIDE, SIDE, null); // paint red rectangle indicating srcRect final Rectangle srcRect = display.getCanvas().getSrcRect(); g.setColor(Color.red); g.setStroke(new BasicStroke(2.0f)); int gw = (int)(srcRect.width * scale) -2; int gh = (int)(srcRect.height * scale) -2; if (gw < 5) gw = 5; if (gh < 5) gh = 5; g.drawRect((int)(srcRect.x * scale) +1, (int)(srcRect.y * scale) +1, gw, gh); } while (volatileImage.contentsLost()); }
/** * Paints the image at the specified location. This method assumes * scaling has already been done, and simply paints the background * image "as-is." * * @param g The graphics context. * @param x The x-coordinate at which to paint. * @param y The y-coordinate at which to paint. */ @Override protected void paintImage(Graphics g, int x, int y) { if (bgImage != null) { do { int rc = bgImage.validate(null);//getGraphicsConfiguration()); if (rc==VolatileImage.IMAGE_RESTORED) { // FIXME: If the image needs to be restored are its width // and height still valid?? If not, we'll need to cache // these values... renderImage(bgImage.getWidth(), bgImage.getHeight(), getScalingHint()); } g.drawImage(bgImage, x,y, null); } while (bgImage.contentsLost()); } }
/** * Paints the image at the specified location. This method assumes * scaling has already been done, and simply paints the background * image "as-is." * * @param g The graphics context. * @param x The x-coordinate at which to paint. * @param y The y-coordinate at which to paint. */ protected void paintImage(Graphics g, int x, int y) { if (bgImage != null) { do { int rc = bgImage.validate(null);//getGraphicsConfiguration()); if (rc==VolatileImage.IMAGE_RESTORED) { // FIXME: If the image needs to be restored are its width // and height still valid?? If not, we'll need to cache // these values... renderImage(bgImage.getWidth(), bgImage.getHeight(), getScalingHint()); } g.drawImage(bgImage, x,y, null); } while (bgImage.contentsLost()); } }
if (gc != null) { if (offscreen != null) { if (offscreen.getWidth() == getWidth() && offscreen.getHeight() == getHeight()) { if (offscreen.validate(gc) != VolatileImage.IMAGE_INCOMPATIBLE) { isIncompatiable = false; if (gc != null) { if (buffer != null) { if (buffer.getWidth() == getWidth() && buffer.getHeight() == getHeight()) { if (buffer.validate(gc) == VolatileImage.IMAGE_OK) { isOkay = true;
if (drawingBufferV != null && // (drawingBufferV.getWidth() != vr.width || drawingBufferV.getHeight() != vr.height)) { gBuf.copyArea(Math.max(0, -shift.x), Math.max(0, -shift.y), drawingBufferV.getWidth() - Math.abs(shift.x), drawingBufferV.getHeight() - Math.abs(shift.y), shift.x, shift.y); shift.x = shift.y = 0;
if (0 == w || 0 == h) return; if (null == volatileImage || volatileImage.getWidth() != w || volatileImage.getHeight() != h || volatileImage.validate(gc) == VolatileImage.IMAGE_INCOMPATIBLE) { if (null != volatileImage) volatileImage.flush(); volatileImage = gc.createCompatibleVolatileImage(w, h);
if (img == null || img.getWidth() != w || img.getHeight() != h)
private synchronized void paintBuffered(Graphics g) { do { GraphicsConfiguration config = getGraphicsConfiguration(); int width = getWidth(); int height = getHeight(); if (backBuffer == null || width != backBuffer.getWidth() || height != backBuffer.getHeight() || backBuffer.validate(config) == VolatileImage.IMAGE_INCOMPATIBLE) { if (backBuffer != null) { backBufferGraphics.dispose(); backBufferGraphics = null; backBuffer.flush(); backBuffer = null; } backBuffer = config.createCompatibleVolatileImage(width, height); backBufferGraphics = backBuffer.createGraphics(); } backBufferGraphics.setClip(g.getClip()); paintUnbuffered(backBufferGraphics); g.drawImage(backBuffer, 0, 0, this); } while (backBuffer.contentsLost()); }
if (buffer == null || buffer.getWidth() != w || buffer.getHeight() != h || bufferStatus == VolatileImage.IMAGE_INCOMPATIBLE) {
_backimg.getHeight() != _window.getHeight()) { createBackBuffer(gc);
_backimg.getHeight() != _window.getHeight()) { createBackBuffer(gc);