- java.lang.Object
-
- java.awt.GraphicsConfiguration
-
public abstract class GraphicsConfiguration extends Object
TheGraphicsConfiguration
class describes the characteristics of a graphics destination such as a printer or monitor. There can be manyGraphicsConfiguration
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 differentGraphicsConfiguration
. On Microsoft Windows,GraphicsConfiguration
s 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, usegetBounds
to get the bounds of the desiredGraphicsConfiguration
and offset the location with the coordinates of theGraphicsConfiguration
, 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 theGraphicsConfiguration
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 callgetBounds
on all of theGraphicsConfiguration
objects in your system. Then calculate the union of all of the bounds returned from the calls togetBounds
. 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
Constructors Modifier Constructor and Description protected
GraphicsConfiguration()
This is an abstract class that cannot be instantiated directly.
-
Method Summary
Methods Modifier and Type Method and Description BufferedImage
createCompatibleImage(int width, int height)
Returns aBufferedImage
with a data layout and color model compatible with thisGraphicsConfiguration
.BufferedImage
createCompatibleImage(int width, int height, int transparency)
Returns aBufferedImage
that supports the specified transparency and has a data layout and color model compatible with thisGraphicsConfiguration
.VolatileImage
createCompatibleVolatileImage(int width, int height)
Returns aVolatileImage
with a data layout and color model compatible with thisGraphicsConfiguration
.VolatileImage
createCompatibleVolatileImage(int width, int height, ImageCapabilities caps)
Returns aVolatileImage
with a data layout and color model compatible with thisGraphicsConfiguration
, using the specified image capabilities.VolatileImage
createCompatibleVolatileImage(int width, int height, ImageCapabilities caps, int transparency)
Returns aVolatileImage
with a data layout and color model compatible with thisGraphicsConfiguration
, using the specified image capabilities and transparency value.VolatileImage
createCompatibleVolatileImage(int width, int height, int transparency)
Returns aVolatileImage
with a data layout and color model compatible with thisGraphicsConfiguration
.abstract Rectangle
getBounds()
Returns the bounds of theGraphicsConfiguration
in the device coordinates.BufferCapabilities
getBufferCapabilities()
Returns the buffering capabilities of thisGraphicsConfiguration
.abstract ColorModel
getColorModel()
Returns theColorModel
associated with thisGraphicsConfiguration
.abstract ColorModel
getColorModel(int transparency)
Returns theColorModel
associated with thisGraphicsConfiguration
that supports the specified transparency.abstract AffineTransform
getDefaultTransform()
Returns the defaultAffineTransform
for thisGraphicsConfiguration
.abstract GraphicsDevice
getDevice()
Returns theGraphicsDevice
associated with thisGraphicsConfiguration
.ImageCapabilities
getImageCapabilities()
Returns the image capabilities of thisGraphicsConfiguration
.abstract AffineTransform
getNormalizingTransform()
Returns aAffineTransform
that can be concatenated with the defaultAffineTransform
of aGraphicsConfiguration
so that 72 units in user space equals 1 inch in device space.boolean
isTranslucencyCapable()
Returns whether thisGraphicsConfiguration
supports thePERPIXEL_TRANSLUCENT
kind of translucency.
-
-
-
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.
-
-
Method Detail
-
getDevice
public abstract GraphicsDevice getDevice()
Returns theGraphicsDevice
associated with thisGraphicsConfiguration
.- Returns:
- a
GraphicsDevice
object that is associated with thisGraphicsConfiguration
.
-
createCompatibleImage
public BufferedImage createCompatibleImage(int width, int height)
Returns aBufferedImage
with a data layout and color model compatible with thisGraphicsConfiguration
. This method has nothing to do with memory-mapping a device. The returnedBufferedImage
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 returnedBufferedImage
height
- the height of the returnedBufferedImage
- Returns:
- a
BufferedImage
whose data layout and color model is compatible with thisGraphicsConfiguration
.
-
createCompatibleImage
public BufferedImage createCompatibleImage(int width, int height, int transparency)
Returns aBufferedImage
that supports the specified transparency and has a data layout and color model compatible with thisGraphicsConfiguration
. This method has nothing to do with memory-mapping a device. The returnedBufferedImage
has a layout and color model that can be optimally blitted to a device with thisGraphicsConfiguration
.- Parameters:
width
- the width of the returnedBufferedImage
height
- the height of the returnedBufferedImage
transparency
- the specified transparency mode- Returns:
- a
BufferedImage
whose data layout and color model is compatible with thisGraphicsConfiguration
and also supports the specified transparency. - Throws:
IllegalArgumentException
- if the transparency is not a valid value- See Also:
Transparency.OPAQUE
,Transparency.BITMASK
,Transparency.TRANSLUCENT
-
createCompatibleVolatileImage
public VolatileImage createCompatibleVolatileImage(int width, int height)
Returns aVolatileImage
with a data layout and color model compatible with thisGraphicsConfiguration
. The returnedVolatileImage
may have data that is stored optimally for the underlying graphics device and may therefore benefit from platform-specific rendering acceleration.- Parameters:
width
- the width of the returnedVolatileImage
height
- the height of the returnedVolatileImage
- Returns:
- a
VolatileImage
whose data layout and color model is compatible with thisGraphicsConfiguration
. - Since:
- 1.4
- See Also:
Component.createVolatileImage(int, int)
-
createCompatibleVolatileImage
public VolatileImage createCompatibleVolatileImage(int width, int height, int transparency)
Returns aVolatileImage
with a data layout and color model compatible with thisGraphicsConfiguration
. The returnedVolatileImage
may have data that is stored optimally for the underlying graphics device and may therefore benefit from platform-specific rendering acceleration.- Parameters:
width
- the width of the returnedVolatileImage
height
- the height of the returnedVolatileImage
transparency
- the specified transparency mode- Returns:
- a
VolatileImage
whose data layout and color model is compatible with thisGraphicsConfiguration
. - Throws:
IllegalArgumentException
- if the transparency is not a valid value- Since:
- 1.5
- See Also:
Transparency.OPAQUE
,Transparency.BITMASK
,Transparency.TRANSLUCENT
,Component.createVolatileImage(int, int)
-
createCompatibleVolatileImage
public VolatileImage createCompatibleVolatileImage(int width, int height, ImageCapabilities caps) throws AWTException
Returns aVolatileImage
with a data layout and color model compatible with thisGraphicsConfiguration
, using the specified image capabilities. If thecaps
parameter is null, it is effectively ignored and this method will create a VolatileImage without regard toImageCapabilities
constraints. The returnedVolatileImage
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 returnedVolatileImage
height
- the height of the returnedVolatileImage
caps
- the image capabilities- Returns:
- a
VolatileImage
whose data layout and color model is compatible with thisGraphicsConfiguration
. - Throws:
AWTException
- if the supplied image capabilities could not be met by this graphics configuration- Since:
- 1.4
-
createCompatibleVolatileImage
public VolatileImage createCompatibleVolatileImage(int width, int height, ImageCapabilities caps, int transparency) throws AWTException
Returns aVolatileImage
with a data layout and color model compatible with thisGraphicsConfiguration
, using the specified image capabilities and transparency value. If thecaps
parameter is null, it is effectively ignored and this method will create a VolatileImage without regard toImageCapabilities
constraints. The returnedVolatileImage
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 returnedVolatileImage
height
- the height of the returnedVolatileImage
caps
- the image capabilitiestransparency
- the specified transparency mode- Returns:
- a
VolatileImage
whose data layout and color model is compatible with thisGraphicsConfiguration
. - Throws:
IllegalArgumentException
- if the transparency is not a valid valueAWTException
- if the supplied image capabilities could not be met by this graphics configuration- Since:
- 1.5
- See Also:
Transparency.OPAQUE
,Transparency.BITMASK
,Transparency.TRANSLUCENT
,Component.createVolatileImage(int, int)
-
getColorModel
public abstract ColorModel getColorModel()
Returns theColorModel
associated with thisGraphicsConfiguration
.- Returns:
- a
ColorModel
object that is associated with thisGraphicsConfiguration
.
-
getColorModel
public abstract ColorModel getColorModel(int transparency)
Returns theColorModel
associated with thisGraphicsConfiguration
that supports the specified transparency.- Parameters:
transparency
- the specified transparency mode- Returns:
- a
ColorModel
object that is associated with thisGraphicsConfiguration
and supports the specified transparency or null if the transparency is not a valid value. - See Also:
Transparency.OPAQUE
,Transparency.BITMASK
,Transparency.TRANSLUCENT
-
getDefaultTransform
public abstract AffineTransform getDefaultTransform()
Returns the defaultAffineTransform
for thisGraphicsConfiguration
. ThisAffineTransform
is typically the Identity transform for most normal screens. The defaultAffineTransform
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 defaultAffineTransform
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 bycreateCompatibleImage
, thisAffineTransform
is the Identity transform.- Returns:
- the default
AffineTransform
for thisGraphicsConfiguration
.
-
getNormalizingTransform
public abstract AffineTransform getNormalizingTransform()
Returns aAffineTransform
that can be concatenated with the defaultAffineTransform
of aGraphicsConfiguration
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 thisAffineTransform
is identity, such as for printers or metafile output, and that thisAffineTransform
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 bycreateCompatibleImage
, thisAffineTransform
is the Identity transform since there is no valid distance measurement.- Returns:
- an
AffineTransform
to concatenate to the defaultAffineTransform
so that 72 units in user space is mapped to 1 inch in device space.
-
getBounds
public abstract Rectangle getBounds()
Returns the bounds of theGraphicsConfiguration
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
-
getBufferCapabilities
public BufferCapabilities getBufferCapabilities()
Returns the buffering capabilities of thisGraphicsConfiguration
.- Returns:
- the buffering capabilities of this graphics configuration object
- Since:
- 1.4
-
getImageCapabilities
public ImageCapabilities getImageCapabilities()
Returns the image capabilities of thisGraphicsConfiguration
.- Returns:
- the image capabilities of this graphics configuration object
- Since:
- 1.4
-
isTranslucencyCapable
public boolean isTranslucencyCapable()
Returns whether thisGraphicsConfiguration
supports thePERPIXEL_TRANSLUCENT
kind of translucency.- Returns:
- whether the given GraphicsConfiguration supports the translucency effects.
- Since:
- 1.7
- See Also:
Window.setBackground(Color)
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
22/11/2024 01:47:32 Cette version de la page est en cache (à la date du 22/11/2024 01:47:32) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 30/08/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-java/awt/GraphicsConfiguration.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.