APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.awt

public abstract Class GraphicsConfiguration

extends Object
Class Inheritance
Known Direct Subclasses
sun.awt.X11GraphicsConfig, sun.print.PrinterGraphicsConfig, sun.awt.image.BufferedImageGraphicsConfig
Imports
java.awt.geom.AffineTransform, java.awt.image.BufferedImage, .ColorModel, .VolatileImage, .WritableRaster, sun.awt.image.SunVolatileImage

The GraphicsConfiguration class describes the characteristics of a graphics destination such as a printer or monitor. There can be many GraphicsConfiguration objects associated with a single graphics device, representing different drawing modes or capabilities. The corresponding native structure will vary from platform to platform. For example, on X11 windowing systems, each visual is a different GraphicsConfiguration. On Microsoft Windows, GraphicsConfigurations represent PixelFormats available in the current resolution and color depth.

In a virtual device multi-screen environment in which the desktop area could span multiple physical screen devices, the bounds of the GraphicsConfiguration objects are relative to the virtual coordinate system. When setting the location of a component, use getBounds to get the bounds of the desired GraphicsConfiguration and offset the location with the coordinates of the GraphicsConfiguration, as the following code sample illustrates:

     Frame f = new Frame(gc);  // where gc is a GraphicsConfiguration
     Rectangle bounds = gc.getBounds();
     f.setLocation(10 + bounds.x, 10 + bounds.y); 

To determine if your environment is a virtual device environment, call getBounds on all of the GraphicsConfiguration objects in your system. If any of the origins of the returned bounds is not (0, 0), your environment is a virtual device environment.

You can also use getBounds to determine the bounds of the virtual device. To do this, first call getBounds on all of the GraphicsConfiguration objects in your system. Then calculate the union of all of the bounds returned from the calls to getBounds. The union is the bounds of the virtual device. The following code sample calculates the bounds of the virtual device.

Rectangle virtualBounds = new Rectangle();
     GraphicsEnvironment ge = GraphicsEnvironment.
             getLocalGraphicsEnvironment();
     GraphicsDevice[] gs =
             ge.getScreenDevices();
     for (int j = 0; j < gs.length; j++) {
         GraphicsDevice gd = gs[j];
         GraphicsConfiguration[] gc =
             gd.getConfigurations();
         for (int i=0; i < gc.length; i++) {
             virtualBounds =
                 virtualBounds.union(gc[i].getBounds());
         }
     } 
See Also
Window, Frame, GraphicsEnvironment, GraphicsDevice

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static BufferCapabilities
private static ImageCapabilities

Constructor Summary

AccessConstructor and Description
protected
GraphicsConfiguration()

This is an abstract class that cannot be instantiated directly.

Method Summary

Modifier and TypeMethod and Description
public BufferedImage

Returns:

a BufferedImage whose data layout and color model is compatible with this GraphicsConfiguration.
createCompatibleImage
(int
the width of the returned BufferedImage
width
,
int
the height of the returned BufferedImage
height
)

Returns a BufferedImage with a data layout and color model compatible with this GraphicsConfiguration.

public BufferedImage

Returns:

a BufferedImage whose data layout and color model is compatible with this GraphicsConfiguration and also supports the specified transparency.
createCompatibleImage
(int
the width of the returned BufferedImage
width
,
int
the height of the returned BufferedImage
height
,
int
the specified transparency mode
transparency
)

Returns a BufferedImage that supports the specified transparency and has a data layout and color model compatible with this GraphicsConfiguration.

public VolatileImage

Returns:

a VolatileImage whose data layout and color model is compatible with this GraphicsConfiguration.
createCompatibleVolatileImage
(int
the width of the returned VolatileImage
width
,
int
the height of the returned VolatileImage
height
)

Returns a VolatileImage with a data layout and color model compatible with this GraphicsConfiguration.

public VolatileImage

Returns:

a VolatileImage whose data layout and color model is compatible with this GraphicsConfiguration.
createCompatibleVolatileImage
(int
the width of the returned VolatileImage
width
,
int
the height of the returned VolatileImage
height
,
int
the specified transparency mode
transparency
)

Returns a VolatileImage with a data layout and color model compatible with this GraphicsConfiguration.

public VolatileImage

Returns:

a VolatileImage whose data layout and color model is compatible with this GraphicsConfiguration.
createCompatibleVolatileImage
(int
the width of the returned VolatileImage
width
,
int
the height of the returned VolatileImage
height
,
ImageCapabilities
the image capabilities
caps
)

Returns a VolatileImage with a data layout and color model compatible with this GraphicsConfiguration, using the specified image capabilities.

public VolatileImage

Returns:

a VolatileImage whose data layout and color model is compatible with this GraphicsConfiguration.
createCompatibleVolatileImage
(int
the width of the returned VolatileImage
width
,
int
the height of the returned VolatileImage
height
,
ImageCapabilities
the image capabilities
caps
,
int
the specified transparency mode
transparency
)

Returns a VolatileImage with a data layout and color model compatible with this GraphicsConfiguration, using the specified image capabilities and transparency value.

public abstract Rectangle

Returns:

the bounds of the area covered by this GraphicsConfiguration.
getBounds
()

Returns the bounds of the GraphicsConfiguration in the device coordinates.

public BufferCapabilities

Returns:

the buffering capabilities of this graphics configuration object
getBufferCapabilities
()

Returns the buffering capabilities of this GraphicsConfiguration.

public abstract ColorModel

Returns:

a ColorModel object that is associated with this GraphicsConfiguration.
getColorModel
()

Returns the ColorModel associated with this GraphicsConfiguration.

public abstract ColorModel

Returns:

a ColorModel object that is associated with this GraphicsConfiguration and supports the specified transparency or null if the transparency is not a valid value.
getColorModel
(int
the specified transparency mode
transparency
)

Returns the ColorModel associated with this GraphicsConfiguration that supports the specified transparency.

public abstract AffineTransform

Returns:

the default AffineTransform for this GraphicsConfiguration.
getDefaultTransform
()

Returns the default AffineTransform for this GraphicsConfiguration.

public abstract GraphicsDevice

Returns:

a GraphicsDevice object that is associated with this GraphicsConfiguration.
getDevice
()

Returns the GraphicsDevice associated with this GraphicsConfiguration.

public ImageCapabilities

Returns:

the image capabilities of this graphics configuration object
getImageCapabilities
()

Returns the image capabilities of this GraphicsConfiguration.

public abstract AffineTransform

Returns:

an AffineTransform to concatenate to the default AffineTransform so that 72 units in user space is mapped to 1 inch in device space.
getNormalizingTransform
()

Returns an AffineTransform that can be concatenated with the default AffineTransform of a GraphicsConfiguration so that 72 units in user space equals 1 inch in device space.

public boolean

Returns:

whether the given GraphicsConfiguration supports the translucency effects.
isTranslucencyCapable
()

Returns whether this GraphicsConfiguration supports the PERPIXEL_TRANSLUCENT kind of translucency.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultBufferCapsback to summary
private static BufferCapabilities defaultBufferCaps
defaultImageCapsback to summary
private static ImageCapabilities defaultImageCaps

Constructor Detail

GraphicsConfigurationback to summary
protected GraphicsConfiguration()

This is an abstract class that cannot be instantiated directly. Instances must be obtained from a suitable factory or query method.

See Also
GraphicsDevice#getConfigurations, GraphicsDevice#getDefaultConfiguration, GraphicsDevice#getBestConfiguration, Graphics2D#getDeviceConfiguration

Method Detail

createCompatibleImageback to summary
public BufferedImage createCompatibleImage(int width, int height)

Returns a BufferedImage with a data layout and color model compatible with this GraphicsConfiguration. This method has nothing to do with memory-mapping a device. The returned BufferedImage has a layout and color model that is closest to this native device configuration and can therefore be optimally blitted to this device.

Parameters
width:int

the width of the returned BufferedImage

height:int

the height of the returned BufferedImage

Returns:BufferedImage

a BufferedImage whose data layout and color model is compatible with this GraphicsConfiguration.

createCompatibleImageback to summary
public BufferedImage createCompatibleImage(int width, int height, int transparency)

Returns a BufferedImage that supports the specified transparency and has a data layout and color model compatible with this GraphicsConfiguration. This method has nothing to do with memory-mapping a device. The returned BufferedImage has a layout and color model that can be optimally blitted to a device with this GraphicsConfiguration.

Parameters
width:int

the width of the returned BufferedImage

height:int

the height of the returned BufferedImage

transparency:int

the specified transparency mode

Returns:BufferedImage

a BufferedImage whose data layout and color model is compatible with this GraphicsConfiguration and also supports the specified transparency.

Exceptions
IllegalArgumentException:
if the transparency is not a valid value
See Also
Transparency#OPAQUE, Transparency#BITMASK, Transparency#TRANSLUCENT
createCompatibleVolatileImageback to summary
public VolatileImage createCompatibleVolatileImage(int width, int height)

Returns a VolatileImage with a data layout and color model compatible with this GraphicsConfiguration. The returned VolatileImage may have data that is stored optimally for the underlying graphics device and may therefore benefit from platform-specific rendering acceleration.

Parameters
width:int

the width of the returned VolatileImage

height:int

the height of the returned VolatileImage

Returns:VolatileImage

a VolatileImage whose data layout and color model is compatible with this GraphicsConfiguration.

Since
1.4
See Also
Component#createVolatileImage(int, int)
createCompatibleVolatileImageback to summary
public VolatileImage createCompatibleVolatileImage(int width, int height, int transparency)

Returns a VolatileImage with a data layout and color model compatible with this GraphicsConfiguration. The returned VolatileImage may have data that is stored optimally for the underlying graphics device and may therefore benefit from platform-specific rendering acceleration.

Parameters
width:int

the width of the returned VolatileImage

height:int

the height of the returned VolatileImage

transparency:int

the specified transparency mode

Returns:VolatileImage

a VolatileImage whose data layout and color model is compatible with this GraphicsConfiguration.

Exceptions
IllegalArgumentException:
if the transparency is not a valid value
Since
1.5
See Also
Transparency#OPAQUE, Transparency#BITMASK, Transparency#TRANSLUCENT, Component#createVolatileImage(int, int)
createCompatibleVolatileImageback to summary
public VolatileImage createCompatibleVolatileImage(int width, int height, ImageCapabilities caps) throws AWTException

Returns a VolatileImage with a data layout and color model compatible with this GraphicsConfiguration, using the specified image capabilities. If the caps parameter is null, it is effectively ignored and this method will create a VolatileImage without regard to ImageCapabilities constraints. The returned VolatileImage has a layout and color model that is closest to this native device configuration and can therefore be optimally blitted to this device.

Parameters
width:int

the width of the returned VolatileImage

height:int

the height of the returned VolatileImage

caps:ImageCapabilities

the image capabilities

Returns:VolatileImage

a VolatileImage whose data layout and color model is compatible with this GraphicsConfiguration.

Exceptions
AWTException:
if the supplied image capabilities could not be met by this graphics configuration
Since
1.4
createCompatibleVolatileImageback to summary
public VolatileImage createCompatibleVolatileImage(int width, int height, ImageCapabilities caps, int transparency) throws AWTException

Returns a VolatileImage with a data layout and color model compatible with this GraphicsConfiguration, using the specified image capabilities and transparency value. If the caps parameter is null, it is effectively ignored and this method will create a VolatileImage without regard to ImageCapabilities constraints. The returned VolatileImage has a layout and color model that is closest to this native device configuration and can therefore be optimally blitted to this device.

Parameters
width:int

the width of the returned VolatileImage

height:int

the height of the returned VolatileImage

caps:ImageCapabilities

the image capabilities

transparency:int

the specified transparency mode

Returns:VolatileImage

a VolatileImage whose data layout and color model is compatible with this GraphicsConfiguration.

Exceptions
AWTException:
if the supplied image capabilities could not be met by this graphics configuration
IllegalArgumentException:
if the transparency is not a valid value
Since
1.5
See Also
Transparency#OPAQUE, Transparency#BITMASK, Transparency#TRANSLUCENT, Component#createVolatileImage(int, int)
getBoundsback to summary
public abstract Rectangle getBounds()

Returns the bounds of the GraphicsConfiguration in the device coordinates. In a multi-screen environment with a virtual device, the bounds can have negative X or Y origins.

Returns:Rectangle

the bounds of the area covered by this GraphicsConfiguration.

Since
1.3
getBufferCapabilitiesback to summary
public BufferCapabilities getBufferCapabilities()

Returns the buffering capabilities of this GraphicsConfiguration.

Returns:BufferCapabilities

the buffering capabilities of this graphics configuration object

Since
1.4
getColorModelback to summary
public abstract ColorModel getColorModel()

Returns the ColorModel associated with this GraphicsConfiguration.

Returns:ColorModel

a ColorModel object that is associated with this GraphicsConfiguration.

getColorModelback to summary
public abstract ColorModel getColorModel(int transparency)

Returns the ColorModel associated with this GraphicsConfiguration that supports the specified transparency.

Parameters
transparency:int

the specified transparency mode

Returns:ColorModel

a ColorModel object that is associated with this GraphicsConfiguration and supports the specified transparency or null if the transparency is not a valid value.

See Also
Transparency#OPAQUE, Transparency#BITMASK, Transparency#TRANSLUCENT
getDefaultTransformback to summary
public abstract AffineTransform getDefaultTransform()

Returns the default AffineTransform for this GraphicsConfiguration. This AffineTransform is typically the Identity transform for most normal screens. The default AffineTransform maps coordinates onto the device such that 72 user space coordinate units measure approximately 1 inch in device space. The normalizing transform can be used to make this mapping more exact. Coordinates in the coordinate space defined by the default AffineTransform for screen and printer devices have the origin in the upper left-hand corner of the target region of the device, with X coordinates increasing to the right and Y coordinates increasing downwards. For image buffers not associated with a device, such as those not created by createCompatibleImage, this AffineTransform is the Identity transform.

Returns:AffineTransform

the default AffineTransform for this GraphicsConfiguration.

getDeviceback to summary
public abstract GraphicsDevice getDevice()

Returns the GraphicsDevice associated with this GraphicsConfiguration.

Returns:GraphicsDevice

a GraphicsDevice object that is associated with this GraphicsConfiguration.

getImageCapabilitiesback to summary
public ImageCapabilities getImageCapabilities()

Returns the image capabilities of this GraphicsConfiguration.

Returns:ImageCapabilities

the image capabilities of this graphics configuration object

Since
1.4
getNormalizingTransformback to summary
public abstract AffineTransform getNormalizingTransform()

Returns an AffineTransform that can be concatenated with the default AffineTransform of a GraphicsConfiguration so that 72 units in user space equals 1 inch in device space.

For a particular Graphics2D, g, one can reset the transformation to create such a mapping by using the following pseudocode:

     GraphicsConfiguration gc = g.getDeviceConfiguration();

     g.setTransform(gc.getDefaultTransform());
     g.transform(gc.getNormalizingTransform());
Note that sometimes this AffineTransform is identity, such as for printers or metafile output, and that this AffineTransform is only as accurate as the information supplied by the underlying system. For image buffers not associated with a device, such as those not created by createCompatibleImage, this AffineTransform is the Identity transform since there is no valid distance measurement.
Returns:AffineTransform

an AffineTransform to concatenate to the default AffineTransform so that 72 units in user space is mapped to 1 inch in device space.

isTranslucencyCapableback to summary
public boolean isTranslucencyCapable()

Returns whether this GraphicsConfiguration supports the PERPIXEL_TRANSLUCENT kind of translucency.

Returns:boolean

whether the given GraphicsConfiguration supports the translucency effects.

Since
1.7
See Also
Window#setBackground(Color)
java.awt back to summary

private Class GraphicsConfiguration.DefaultBufferCapabilities

extends BufferCapabilities
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from java.awt.BufferCapabilities:
clonegetBackBufferCapabilitiesgetFlipContentsgetFrontBufferCapabilitiesisFullScreenRequiredisMultiBufferAvailableisPageFlipping

Constructor Detail

DefaultBufferCapabilitiesback to summary
public DefaultBufferCapabilities(ImageCapabilities imageCaps)