- java.lang.Object
-
- java.awt.GraphicsConfiguration
-
public abstract class GraphicsConfiguration extends Object
GraphicsConfiguration类描述了诸如打印机或显示器之类的图形目的地的特征。 可以有许多GraphicsConfiguration对象与单个图形设备相关联,表示不同的绘图模式或功能。 平台对应的本机结构将有所不同。 例如,在X11窗口系统中,每个视觉是不同的GraphicsConfiguration。 在Microsoft Windows上,GraphicsConfiguration表示当前分辨率和颜色深度可用的PixelFormats。在虚拟设备多屏幕环境中,桌面区域可跨越多个物理屏幕设备,
GraphicsConfiguration对象的界限相对于虚拟坐标系。 当设置的部件的位置,使用getBounds以获得所需的边界GraphicsConfiguration和偏移与所述的坐标位置GraphicsConfiguration,如下面的代码示例说明:Frame f = new Frame(gc); // where gc is a GraphicsConfiguration Rectangle bounds = gc.getBounds(); f.setLocation(10 + bounds.x, 10 + bounds.y);要确定您的环境是否是虚拟设备环境,请在系统中的所有
GraphicsConfiguration对象上调用getBounds。 如果返回范围的任何一个起始点不是(0,0),则您的环境是虚拟设备环境。您还可以使用
getBounds来确定虚拟设备的边界。 为此,首先在系统中的所有GraphicsConfiguration对象上调用getBounds。 然后计算从调用返回的所有界限的并集为getBounds。 联合是虚拟设备的界限。 以下代码示例计算虚拟设备的边界。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()); } }- 另请参见:
-
Window,Frame,GraphicsEnvironment,GraphicsDevice
-
-
构造方法摘要
构造方法 Modifier Constructor 描述 protectedGraphicsConfiguration()这是一个无法直接实例化的抽象类。
-
方法摘要
所有方法 接口方法 抽象方法 具体的方法 Modifier and Type 方法 描述 BufferedImagecreateCompatibleImage(int width, int height)返回BufferedImage,其数据布局和颜色模型与此GraphicsConfiguration兼容。BufferedImagecreateCompatibleImage(int width, int height, int transparency)返回支持指定透明度的BufferedImage,并具有与该GraphicsConfiguration兼容的数据布局和颜色模型。VolatileImagecreateCompatibleVolatileImage(int width, int height)返回一个VolatileImage,具有与该GraphicsConfiguration兼容的数据布局和颜色模型。VolatileImagecreateCompatibleVolatileImage(int width, int height, int transparency)返回一个VolatileImage,具有与此GraphicsConfiguration兼容的数据布局和颜色模型。VolatileImagecreateCompatibleVolatileImage(int width, int height, ImageCapabilities caps)使用指定的图像功能返回VolatileImage,其数据布局和颜色模型与此GraphicsConfiguration兼容。VolatileImagecreateCompatibleVolatileImage(int width, int height, ImageCapabilities caps, int transparency)使用指定的图像功能和透明度值返回VolatileImage,其数据布局和颜色模型与此GraphicsConfiguration兼容。abstract RectanglegetBounds()返回设备坐标中的GraphicsConfiguration的界限。BufferCapabilitiesgetBufferCapabilities()返回此GraphicsConfiguration的缓冲功能。abstract ColorModelgetColorModel()返回ColorModel与此相关GraphicsConfiguration。abstract ColorModelgetColorModel(int transparency)返回与支持指定透明度的ColorModel相关联的GraphicsConfiguration。abstract AffineTransformgetDefaultTransform()返回AffineTransform的默认值GraphicsConfiguration。abstract GraphicsDevicegetDevice()返回GraphicsDevice与此相关GraphicsConfiguration。ImageCapabilitiesgetImageCapabilities()返回此GraphicsConfiguration的图像功能。abstract AffineTransformgetNormalizingTransform()返回一个AffineTransform可以与默认级联AffineTransform一个的GraphicsConfiguration,使得单元72在用户空间等于设备空间的1英寸。booleanisTranslucencyCapable()返回这个GraphicsConfiguration是否支持PERPIXEL_TRANSLUCENT类半透明。
-
-
-
方法详细信息
-
getDevice
public abstract GraphicsDevice getDevice()
返回GraphicsDevice与此相关GraphicsConfiguration。- 结果
-
一个
GraphicsDevice对象与该GraphicsConfiguration相关联。
-
createCompatibleImage
public BufferedImage createCompatibleImage(int width, int height)
返回BufferedImage,其数据布局和颜色模型与此GraphicsConfiguration兼容。 该方法与设备的内存映射无关。 返回的BufferedImage具有最接近此本机设备配置的布局和颜色模型,因此可以将其优化为该设备。- 参数
-
width- 返回的宽度为BufferedImage -
height- 返回的高度为BufferedImage - 结果
-
一个
BufferedImage其数据布局和颜色模型与此GraphicsConfiguration兼容。
-
createCompatibleImage
public BufferedImage createCompatibleImage(int width, int height, int transparency)
返回支持指定透明度的BufferedImage,并具有与该GraphicsConfiguration兼容的数据布局和颜色模型。 该方法与设备的内存映射无关。 返回的BufferedImage有一个布局和颜色模型,可以最佳地与这个GraphicsConfiguration的设备配合GraphicsConfiguration。- 参数
-
width- 返回的宽度为BufferedImage -
height- 返回的高度是BufferedImage -
transparency- 指定的透明度模式 - 结果
-
一个
BufferedImage其数据布局和颜色模型与此GraphicsConfiguration兼容,并且还支持指定的透明度。 - 异常
-
IllegalArgumentException- 如果透明度不是有效值 - 另请参见:
-
Transparency.OPAQUE,Transparency.BITMASK,Transparency.TRANSLUCENT
-
createCompatibleVolatileImage
public VolatileImage createCompatibleVolatileImage(int width, int height)
返回一个VolatileImage,具有与该GraphicsConfiguration兼容的数据布局和颜色模型。 返回的VolatileImage可能具有对底层图形设备进行最佳存储的数据,因此可能受益于平台特定的渲染加速。- 参数
-
width- 返回的宽度为VolatileImage -
height- 返回的高度是VolatileImage - 结果
-
一个
VolatileImage其数据布局和颜色模型与此GraphicsConfiguration兼容。 - 从以下版本开始:
- 1.4
- 另请参见:
-
Component.createVolatileImage(int, int)
-
createCompatibleVolatileImage
public VolatileImage createCompatibleVolatileImage(int width, int height, int transparency)
返回一个VolatileImage,具有与此GraphicsConfiguration兼容的数据布局和颜色模型。 返回的VolatileImage可能具有最佳存储底层图形设备的数据,因此可能受益于平台特定的渲染加速。- 参数
-
width- 返回的宽度为VolatileImage -
height- 返回的高度为VolatileImage -
transparency- 指定的透明度模式 - 结果
-
一个
VolatileImage其数据布局和颜色模型与此GraphicsConfiguration兼容。 - 异常
-
IllegalArgumentException- 如果透明度不是有效值 - 从以下版本开始:
- 1.5
- 另请参见:
-
Transparency.OPAQUE,Transparency.BITMASK,Transparency.TRANSLUCENT,Component.createVolatileImage(int, int)
-
createCompatibleVolatileImage
public VolatileImage createCompatibleVolatileImage(int width, int height, ImageCapabilities caps) throws AWTException
使用指定的图像功能返回VolatileImage,其数据布局和颜色模型与此GraphicsConfiguration兼容。 如果caps参数为空,则会被有效地忽略,此方法将创建一个VolatileImage,而不考虑ImageCapabilities约束。 返回的VolatileImage具有最接近此本机设备配置的布局和颜色模型,因此可以将其优化为该设备。- 参数
-
width- 返回的宽度为VolatileImage -
height- 返回的高度是VolatileImage -
caps- 图像功能 - 结果
-
一个
VolatileImage其数据布局和颜色模型与此GraphicsConfiguration兼容。 - 异常
-
AWTException- 如果图形配置不能满足提供的图像功能 - 从以下版本开始:
- 1.4
-
createCompatibleVolatileImage
public VolatileImage createCompatibleVolatileImage(int width, int height, ImageCapabilities caps, int transparency) throws AWTException
返回一个VolatileImage,其数据布局和颜色模型与此GraphicsConfiguration兼容,使用指定的图像功能和透明度值。 如果caps参数为空,则会被有效地忽略,此方法将创建一个VolatileImage,而不考虑ImageCapabilities约束。 返回的VolatileImage具有最接近此本机设备配置的布局和颜色模型,因此可以将其最佳地排除在此设备上。- 参数
-
width- 返回的宽度为VolatileImage -
height- 返回的高度为VolatileImage -
caps- 图像功能 -
transparency- 指定的透明度模式 - 结果
-
一个
VolatileImage其数据布局和颜色模型与此GraphicsConfiguration兼容。 - 异常
-
IllegalArgumentException- 如果透明度不是有效值 -
AWTException- 如果图形配置不能满足提供的图像功能 - 从以下版本开始:
- 1.5
- 另请参见:
-
Transparency.OPAQUE,Transparency.BITMASK,Transparency.TRANSLUCENT,Component.createVolatileImage(int, int)
-
getColorModel
public abstract ColorModel getColorModel()
返回ColorModel与该GraphicsConfiguration相关联。- 结果
-
一个
ColorModel对象与该GraphicsConfiguration相关联。
-
getColorModel
public abstract ColorModel getColorModel(int transparency)
返回与支持指定透明度的ColorModel相关联的GraphicsConfiguration。- 参数
-
transparency- 指定的透明度模式 - 结果
-
一个与此
GraphicsConfiguration相关联的ColorModel对象,并且如果透明度不是有效值,则支持指定的透明度或为null。 - 另请参见:
-
Transparency.OPAQUE,Transparency.BITMASK,Transparency.TRANSLUCENT
-
getDefaultTransform
public abstract AffineTransform getDefaultTransform()
返回这个GraphicsConfiguration的默认值为GraphicsConfiguration。 这个AffineTransform通常是大多数正常屏幕的标识变换。 默认的AffineTransform将坐标映射到设备上,使得72个用户空间坐标单位在设备空间中测量大约1英寸。 归一化变换可用于使此映射更精确。 用于屏幕和打印机设备的默认AffineTransform定义的坐标空间中的坐标具有设备目标区域左上角的原点,X坐标向右增加,Y坐标向下增加。 对于与设备无关的图像缓冲区(如createCompatibleImage未创建的图像缓冲区),该标识变换是AffineTransform。- 结果
-
默认
AffineTransform为这个GraphicsConfiguration。
-
getNormalizingTransform
public abstract AffineTransform getNormalizingTransform()
返回一个AffineTransform可以与默认级联AffineTransform一个的GraphicsConfiguration,使得单元72在用户空间等于设备空间的1英寸。对于特定的
Graphics2D,g,可以通过使用以下伪代码来重置转换以创建此类映射:GraphicsConfiguration gc = g.getDeviceConfiguration(); g.setTransform(gc.getDefaultTransform()); g.transform(gc.getNormalizingTransform());请注意,有时这个AffineTransform是身份,例如打印机或图元文件输出,而且这个AffineTransform只是与底层系统提供的信息一样准确。 对于与设备不相关的图像缓冲区(如createCompatibleImage未创建的图像缓冲区),该AffineTransform是Identity变换,因为没有有效的距离测量。- 结果
-
一个
AffineTransform连接到默认的AffineTransform使用户空间中的72个单位映射到设备空间的1英寸。
-
getBounds
public abstract Rectangle getBounds()
返回设备坐标中的GraphicsConfiguration的范围。 在具有虚拟设备的多屏幕环境中,边界可以具有负X或Y原点。- 结果
-
该地区覆盖的范围
GraphicsConfiguration。 - 从以下版本开始:
- 1.3
-
getBufferCapabilities
public BufferCapabilities getBufferCapabilities()
返回这个GraphicsConfiguration的缓冲功能。- 结果
- 该图形配置对象的缓冲功能
- 从以下版本开始:
- 1.4
-
getImageCapabilities
public ImageCapabilities getImageCapabilities()
返回此GraphicsConfiguration的图像功能。- 结果
- 该图形配置对象的图像功能
- 从以下版本开始:
- 1.4
-
isTranslucencyCapable
public boolean isTranslucencyCapable()
返回这个GraphicsConfiguration是否支持PERPIXEL_TRANSLUCENT的半透明。- 结果
- 给定的GraphicsConfiguration是否支持半透明效果。
- 从以下版本开始:
- 1.7
- 另请参见:
-
Window.setBackground(Color)
-
-