/** * This method returns a {@link Graphics2D}, but is here * for backwards compatibility. {@link #createGraphics() createGraphics} is more * convenient, since it is declared to return a * <code>Graphics2D</code>. * @return a <code>Graphics2D</code>, which can be used to draw into * this image. */ public Graphics getGraphics() { return createGraphics(); }
@Override protected Graphics2D createGraphics () { return _backimg.createGraphics(); }
@Override protected Graphics2D createGraphics () { return _backimg.createGraphics(); }
/** * Converts an image to a volatile image. * * @param image the image to convert * @return the converted image */ public static VolatileImage convertToVolatileImage(BufferedImage image) { VolatileImage result = ImageUtils.createVolatileImage(image.getWidth(), image.getHeight()); Graphics2D g2 = result.createGraphics(); g2.drawImage(image, null, 0, 0); return result; }
/** * Transfers the image to the volatile image */ @AnyThread private void transferImageToVolatileImage() { lock.lock(); try { //Clear the volatile image SwingHelper.clearVolatileImage(volatileImage); Graphics2D g2d = volatileImage.createGraphics(); try { g2d.drawImage(image, 0, 0, null); } finally { g2d.dispose(); } } finally { lock.unlock(); } }
graphic = ((TiledImage) preparedImage).createGraphics(); } else if (preparedImage instanceof VolatileImage) { graphic = ((VolatileImage) preparedImage).createGraphics(); } else { throw new ServiceException("Unrecognized back-end image type");
public void defineSize(int width, int height) { component.setSize(width, height); volatileImage = createBackBuffer(width, height); if (volatileImage != null) { graphic.setScreen(volatileImage.createGraphics()); } }
public void validateVolatileImage() { int valCode = volatileImage.validate(configuration); // This means the device doesn't match up to this hardware accelerated image. if (valCode == VolatileImage.IMAGE_INCOMPATIBLE) { volatileImage = createBackBuffer(width, height); // recreate the hardware accelerated image. graphic.setScreen(volatileImage.createGraphics()); } }
public void defineSize(int width, int height) { component.setSize(width, height); volatileImage = createBackBuffer(width, height); if (volatileImage != null) { graphic.setScreen(volatileImage.createGraphics()); } }
public void validateVolatileImage() { int valCode = volatileImage.validate(configuration); // This means the device doesn't match up to this hardware accelerated image. if (valCode == VolatileImage.IMAGE_INCOMPATIBLE) { volatileImage = createBackBuffer(width, height); // recreate the hardware accelerated image. graphic.setScreen(volatileImage.createGraphics()); } }
at.rotate(-Math.PI / 2); Graphics2D rotg = biRot.createGraphics(); if (at != null) rotg.setTransform(at);
at.rotate(-Math.PI / 2); Graphics2D rotg = biRot.createGraphics(); if (at != null) rotg.setTransform(at);
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()); }
@Override public void run() { while (true && !dispose) { if(dispose){ break; } if (mustupdate) { mustupdate = false; setPainting(true); VolatileImage img = createBackBuffer(); comp.setBuffer(img); renderOn(img.createGraphics()); setPainting(false); } block(); } }
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()); }
|| valid == java.awt.image.VolatileImage.IMAGE_RESTORED) { java.awt.Rectangle clipBounds = graphics.getClipBounds(); Graphics2D volatileImageGraphics = volatileImage.createGraphics(); volatileImageGraphics.setClip(clipBounds.x, clipBounds.y, clipBounds.width, clipBounds.height);
|| valid == java.awt.image.VolatileImage.IMAGE_RESTORED) { java.awt.Rectangle clipBounds = graphics.getClipBounds(); Graphics2D volatileImageGraphics = volatileImage.createGraphics(); volatileImageGraphics.setClip(clipBounds.x, clipBounds.y, clipBounds.width, clipBounds.height);
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()); }
_bgfx.dispose(); _bgfx = _backimg.createGraphics(); if (_fgfx != null) { _fgfx.dispose();
_bgfx.dispose(); _bgfx = _backimg.createGraphics(); if (_fgfx != null) { _fgfx.dispose();