Klasse java.awt.image.VolatileImage | 1.4 |
java.lang.Object | +--java.awt.image.VolatileImage
// image creation VolatileImage vImg = createVolatileImage(w, h); // rendering to the image void renderOffscreen() { do { if (vImg.validate(getGraphicsConfiguration()) == VolatileImage.IMAGE_INCOMPATIBLE) { // old vImg doesn't work with new GraphicsConfig; re-create it vImg = createVolatileImage(w, h); } Graphics2D g = vImg.createGraphics(); // // miscellaneous rendering commands... // g.dispose(); } while (vImg.contentsLost()); } // copying from the image (here, gScreen is the Graphics // object for the onscreen window) do { int returnCode = vImg.validate(getGraphicsConfiguration()); if (returnCode == VolatileImage.IMAGE_RESTORED) { // Contents need to be restored renderOffscreen(); // restore contents } else if (returnCode == VolatileImage.IMAGE_INCOMPATIBLE) { // old vImg doesn't work with new GraphicsConfig; re-create it vImg = createVolatileImage(w, h); renderOffscreen(); } gScreen.drawImage(vImg, 0, 0, this); } while (vImg.contentsLost());
Datenelemente | |
---|---|
public final static int | IMAGE_INCOMPATIBLE |
public final static int | IMAGE_OK |
public final static int | IMAGE_RESTORED |
Konstruktoren | |
---|---|
public | VolatileImage() |
Methoden | |
---|---|
public abstract boolean | contentsLost() |
public abstract Graphics2D | createGraphics() |
public void | flush() |
public abstract ImageCapabilities | getCapabilities() |
public Graphics | getGraphics() |
public abstract int | getHeight() |
public abstract BufferedImage | getSnapshot() |
public ImageProducer | getSource() |
public abstract int | getWidth() |
public abstract int | validate(GraphicsConfiguration gc) |