- 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来确定虚拟设备的边界。 为此,请getBounds在系统中的所有GraphicsConfiguration对象上调用getBounds。 然后计算从调用返回到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
-
-
构造方法摘要
构造方法 变量 构造器 描述 protectedGraphicsConfiguration()这是一个无法直接实例化的抽象类。
-
方法摘要
所有方法 实例方法 抽象方法 具体的方法 变量和类型 方法 描述 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具有最接近此本机设备配置的布局和颜色模型,因此可以最佳地对该设备进行blitting。- 参数
-
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参数为null,则会被忽略,并且此方法将创建VolatileImage而不考虑ImageCapabilities约束。 返回的VolatileImage具有最接近此本机设备配置的布局和颜色模型,因此可以最佳地对此设备进行blitting。- 参数
-
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参数为null,则会被忽略,并且此方法将创建VolatileImage,而不考虑ImageCapabilities约束。 返回的VolatileImage具有最接近此本机设备配置的布局和颜色模型,因此可以最佳地对该设备进行blitting。- 参数
-
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。- 结果
-
与此
GraphicsConfiguration相关联的ColorModel对象。
-
getColorModel
public abstract ColorModel getColorModel(int transparency)
返回与此ColorModel关联的GraphicsConfiguration,它支持指定的透明度。- 参数
-
transparency- 指定的透明度模式 - 结果
-
与此
GraphicsConfiguration关联的ColorModel对象,如果透明度不是有效值,则支持指定的透明度或null。 - 另请参见:
-
Transparency.OPAQUE,Transparency.BITMASK,Transparency.TRANSLUCENT
-
getDefaultTransform
public abstract AffineTransform getDefaultTransform()
返回默认的AffineTransform这个GraphicsConfiguration。AffineTransform通常是大多数普通屏幕的Identity变换。 默认的AffineTransform将坐标映射到设备上,使得72个用户空间坐标单位在设备空间中测量大约1英寸。 归一化变换可用于使该映射更精确。 屏幕和打印机设备的默认值AffineTransform定义的坐标空间中的坐标原点位于设备目标区域的左上角,X坐标向右增加,Y坐标向下增加。 对于与设备无关的图像缓冲区,例如那些不是由createCompatibleImage创建的图像缓冲区,此AffineTransform是Identity转换。- 结果
-
此
GraphicsConfiguration的默认AffineTransformGraphicsConfiguration。
-
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)
-
-