JSR-62 (Final)

java.awt
Class GraphicsConfiguration

java.lang.Object
  |
  +--java.awt.GraphicsConfiguration

public abstract class GraphicsConfiguration
extends Object

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 win32, 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(GraphicsConfiguration gc);
      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 are not (0, 0), your environment is a virtual device environment.

You can also use getBounds to determine the bounds of the virtual device. 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

Constructor Summary
protected GraphicsConfiguration()
          This is an abstract class that cannot be instantiated directly.
 
Method Summary
abstract  BufferedImage createCompatibleImage(int width, int height)
          Returns a BufferedImage with a data layout and color model compatible with this GraphicsConfiguration.
abstract  Rectangle getBounds()
          Returns the bounds of the GraphicsConfiguration in the device coordinates.
abstract  ColorModel getColorModel()
          Returns the ColorModel associated with this GraphicsConfiguration.
abstract  GraphicsDevice getDevice()
          Returns the GraphicsDevice associated with this GraphicsConfiguration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphicsConfiguration

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(), Graphics2D.getDeviceConfiguration()
Method Detail

getDevice

public abstract GraphicsDevice getDevice()
Returns the GraphicsDevice associated with this GraphicsConfiguration.

Returns:
a GraphicsDevice object that is associated with this GraphicsConfiguration.

createCompatibleImage

public abstract 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 - the width of the returned BufferedImage
height - the height of the returned BufferedImage
Returns:
a BufferedImage whose data layout and color model is compatible with this GraphicsConfiguration.

getColorModel

public abstract ColorModel getColorModel()
Returns the ColorModel associated with this GraphicsConfiguration.

Returns:
a ColorModel object that is associated with this GraphicsConfiguration.

getBounds

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:
the bounds of the area covered by this GraphicsConfiguration.
Since:
1.3

JSR-62 (Final)

Java and Java 2D are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
Copyright 1993 - 2002 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, California 94303, U.S.A. All Rights Reserved.
Use of this specification is subject to this license.