public class

SunVolatileImage

extends VolatileImage
java.lang.Object
   ↳ java.awt.Image
     ↳ java.awt.image.VolatileImage
       ↳ sun.awt.image.SunVolatileImage

Class Overview

This class is the base implementation of the VolatileImage abstract class. The class implements most of the standard Image methods (width, height, etc.) but delegates all surface management issues to a platform-specific VolatileSurfaceManager. When a new instance of SunVolatileImage is created, it automatically creates an appropriate VolatileSurfaceManager for the GraphicsConfiguration under which this SunVolatileImage was created.

Summary

[Expand]
Inherited Constants
From class java.awt.image.VolatileImage
From class java.awt.Image
From interface java.awt.Transparency
Fields
protected Component comp
protected VolatileSurfaceManager volSurfaceManager
[Expand]
Inherited Fields
From class java.awt.image.VolatileImage
From class java.awt.Image
Public Constructors
SunVolatileImage(Component comp, int width, int height)
SunVolatileImage(Component comp, int width, int height, Object context)
SunVolatileImage(GraphicsConfiguration graphicsConfig, int width, int height, int transparency, ImageCapabilities caps)
Public Methods
boolean contentsLost()
Returns true if rendering data was lost since last validate call.
Graphics2D createGraphics()
Creates a Graphics2D, which can be used to draw into this VolatileImage.
BufferedImage getBackupImage()
This method creates a BufferedImage intended for use as a "snapshot" or a backup surface.
ImageCapabilities getCapabilities()
Returns an ImageCapabilities object which can be inquired as to the specific capabilities of this VolatileImage.
Component getComponent()
GraphicsConfiguration getGraphicsConfig()
int getHeight()
Returns the height of the VolatileImage.
int getHeight(ImageObserver observer)
Determines the height of the image.
Object getProperty(String name, ImageObserver observer)
Gets a property of this image by name.
BufferedImage getSnapshot()
Returns a static snapshot image of this object.
int getWidth()
Returns the width of the VolatileImage.
int getWidth(ImageObserver observer)
Determines the width of the image.
void updateGraphicsConfig()
int validate(GraphicsConfiguration gc)
Attempts to restore the drawing surface of the image if the surface had been lost since the last validate call.
Protected Methods
VolatileSurfaceManager createSurfaceManager(Object context, ImageCapabilities caps)
[Expand]
Inherited Methods
From class java.awt.image.VolatileImage
From class java.awt.Image
From class java.lang.Object
From interface java.awt.Transparency

Fields

protected Component comp

protected VolatileSurfaceManager volSurfaceManager

Public Constructors

public SunVolatileImage (Component comp, int width, int height)

public SunVolatileImage (Component comp, int width, int height, Object context)

public SunVolatileImage (GraphicsConfiguration graphicsConfig, int width, int height, int transparency, ImageCapabilities caps)

Public Methods

public boolean contentsLost ()

Returns true if rendering data was lost since last validate call. This method should be called by the application at the end of any series of rendering operations to or from the image to see whether the image needs to be validated and the rendering redone.

Returns
  • true if the drawing surface needs to be restored; false otherwise.

public Graphics2D createGraphics ()

Creates a Graphics2D, which can be used to draw into this VolatileImage.

Returns
  • a Graphics2D, used for drawing into this image.

public BufferedImage getBackupImage ()

This method creates a BufferedImage intended for use as a "snapshot" or a backup surface.

public ImageCapabilities getCapabilities ()

Returns an ImageCapabilities object which can be inquired as to the specific capabilities of this VolatileImage. This would allow programmers to find out more runtime information on the specific VolatileImage object that they have created. For example, the user might create a VolatileImage but the system may have no video memory left for creating an image of that size, so although the object is a VolatileImage, it is not as accelerated as other VolatileImage objects on this platform might be. The user might want that information to find other solutions to their problem.

Returns
  • an ImageCapabilities object that contains the capabilities of this VolatileImage.

public Component getComponent ()

public GraphicsConfiguration getGraphicsConfig ()

public int getHeight ()

Returns the height of the VolatileImage.

Returns
  • the height of this VolatileImage.

public int getHeight (ImageObserver observer)

Determines the height of the image. If the height is not yet known, this method returns -1 and the specified ImageObserver object is notified later.

Parameters
observer an object waiting for the image to be loaded.
Returns
  • the height of this image, or -1 if the height is not yet known.

public Object getProperty (String name, ImageObserver observer)

Gets a property of this image by name.

Individual property names are defined by the various image formats. If a property is not defined for a particular image, this method returns the UndefinedProperty object.

If the properties for this image are not yet known, this method returns null, and the ImageObserver object is notified later.

The property name "comment" should be used to store an optional comment which can be presented to the application as a description of the image, its source, or its author.

Parameters
name a property name.
observer an object waiting for this image to be loaded.
Returns
  • the value of the named property.

public BufferedImage getSnapshot ()

Returns a static snapshot image of this object. The BufferedImage returned is only current with the VolatileImage at the time of the request and will not be updated with any future changes to the VolatileImage.

Returns

public int getWidth ()

Returns the width of the VolatileImage.

Returns
  • the width of this VolatileImage.

public int getWidth (ImageObserver observer)

Determines the width of the image. If the width is not yet known, this method returns -1 and the specified ImageObserver object is notified later.

Parameters
observer an object waiting for the image to be loaded.
Returns
  • the width of this image, or -1 if the width is not yet known.

public void updateGraphicsConfig ()

public int validate (GraphicsConfiguration gc)

Attempts to restore the drawing surface of the image if the surface had been lost since the last validate call. Also validates this image against the given GraphicsConfiguration parameter to see whether operations from this image to the GraphicsConfiguration are compatible. An example of an incompatible combination might be a situation where a VolatileImage object was created on one graphics device and then was used to render to a different graphics device. Since VolatileImage objects tend to be very device-specific, this operation might not work as intended, so the return code from this validate call would note that incompatibility. A null or incorrect value for gc may cause incorrect values to be returned from validate and may cause later problems with rendering.

Parameters
gc a GraphicsConfiguration object for this image to be validated against. A null gc implies that the validate method should skip the compatibility test.
Returns
  • IMAGE_OK if the image did not need validation
    IMAGE_RESTORED if the image needed restoration. Restoration implies that the contents of the image may have been affected and the image may need to be re-rendered.
    IMAGE_INCOMPATIBLE if the image is incompatible with the GraphicsConfiguration object passed into the validate method. Incompatibility implies that the image may need to be recreated with a new Component or GraphicsConfiguration in order to get an image that can be used successfully with this GraphicsConfiguration. An incompatible image is not checked for whether restoration was necessary, so the state of the image is unchanged after a return value of IMAGE_INCOMPATIBLE and this return value implies nothing about whether the image needs to be restored.

Protected Methods

protected VolatileSurfaceManager createSurfaceManager (Object context, ImageCapabilities caps)