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为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 and Description |
|---|---|
protected |
GraphicsConfiguration()
这是一个无法直接实例化的抽象类。
|
| Modifier and Type | Method and Description |
|---|---|
BufferedImage |
createCompatibleImage(int width, int height)
返回一个 BufferedImage ,其数据布局和颜色模型与此GraphicsConfiguration 。
|
BufferedImage |
createCompatibleImage(int width, int height, int transparency)
返回
BufferedImage支持指定透明度,与此相适应的数据布局和颜色模型
GraphicsConfiguration 。
|
VolatileImage |
createCompatibleVolatileImage(int width, int height)
返回一个 VolatileImage ,具有与此GraphicsConfiguration的数据布局和颜色模型。
|
VolatileImage |
createCompatibleVolatileImage(int width, int height, ImageCapabilities caps)
使用指定的图像功能返回 VolatileImage ,其数据布局和颜色模型与此GraphicsConfiguration兼容。
|
VolatileImage |
createCompatibleVolatileImage(int width, int height, ImageCapabilities caps, int transparency)
使用指定的图像功能和透明度值返回 VolatileImage ,其中包含与此GraphicsConfiguration的数据布局和颜色模型。
|
VolatileImage |
createCompatibleVolatileImage(int width, int height, int transparency)
返回一个 VolatileImage与数据布局和颜色模型与此GraphicsConfiguration 。
|
abstract Rectangle |
getBounds()
返回的边界
GraphicsConfiguration在设备坐标。
|
BufferCapabilities |
getBufferCapabilities()
返回此
GraphicsConfiguration 。
|
abstract ColorModel |
getColorModel()
返回 ColorModel与此相关GraphicsConfiguration 。
|
abstract ColorModel |
getColorModel(int transparency)
返回
ColorModel与此相关
GraphicsConfiguration支持指定透明度。
|
abstract AffineTransform |
getDefaultTransform()
返回默认 AffineTransform这个GraphicsConfiguration 。
|
abstract GraphicsDevice |
getDevice()
返回 GraphicsDevice与此相关GraphicsConfiguration 。
|
ImageCapabilities |
getImageCapabilities()
返回此
GraphicsConfiguration的图像
GraphicsConfiguration 。
|
abstract AffineTransform |
getNormalizingTransform()
返回一个
AffineTransform可与默认级联
AffineTransform一个的
GraphicsConfiguration ,使得单元72在用户空间等于设备空间的1英寸。
|
boolean |
isTranslucencyCapable()
返回此
GraphicsConfiguration是否支持
PERPIXEL_TRANSLUCENT类型的半透明。
|
protected GraphicsConfiguration()
public abstract GraphicsDevice getDevice()
GraphicsDevice与此相关GraphicsConfiguration 。
GraphicsConfiguration的
GraphicsDevice对象。
public BufferedImage createCompatibleImage(int width, int height)
BufferedImage与数据布局和颜色模型与此GraphicsConfiguration 。
该方法与设备的内存映射无关。
返回的BufferedImage具有最接近此本机设备配置的布局和颜色模型,因此可以将其优化为该设备。
width - 返回的宽度
BufferedImage
height - 返回的高度
BufferedImage
BufferedImage的数据布局和颜色模型与此
GraphicsConfiguration 。
public BufferedImage createCompatibleImage(int width, int height, int transparency)
BufferedImage支持指定透明度,与此相适应的数据布局和颜色模型GraphicsConfiguration 。
该方法与设备的内存映射无关。
返回的BufferedImage具有布局和颜色模型,可以通过此GraphicsConfiguration地切换到设备。
width - 返回的宽度
BufferedImage
height - 返回的高度
BufferedImage
transparency - 指定的透明度模式
BufferedImage ,其数据布局和颜色模型与此
GraphicsConfiguration ,并且还支持指定的透明度。
IllegalArgumentException - 如果透明度不是有效值
Transparency.OPAQUE ,
Transparency.BITMASK ,
Transparency.TRANSLUCENT
public VolatileImage createCompatibleVolatileImage(int width, int height)
VolatileImage ,具有与此GraphicsConfiguration的数据布局和颜色模型。
返回的VolatileImage可能具有对底层图形设备进行最佳存储的数据,因此可能受益于平台特定的渲染加速。
width - 返回的宽度
VolatileImage
height - 返回的高度
VolatileImage
VolatileImage ,其数据布局和颜色模型与此
GraphicsConfiguration 。
Component.createVolatileImage(int, int)
public VolatileImage createCompatibleVolatileImage(int width, int height, int transparency)
VolatileImage ,其数据布局和颜色模型与此GraphicsConfiguration 。
返回的VolatileImage可能具有对底层图形设备进行最佳存储的数据,因此可能受益于平台特定的渲染加速。
width - 返回的宽度
VolatileImage
height - 返回的高度
VolatileImage
transparency - 指定的透明度模式
VolatileImage ,其数据布局和颜色模型与此
GraphicsConfiguration 。
IllegalArgumentException - 如果透明度不是有效值
Transparency.OPAQUE ,
Transparency.BITMASK ,
Transparency.TRANSLUCENT ,
Component.createVolatileImage(int, int)
public VolatileImage createCompatibleVolatileImage(int width, int height, ImageCapabilities caps) throws AWTException
VolatileImage ,其中包含与此GraphicsConfiguration的数据布局和颜色模型。
如果caps参数为null,则会被有效地忽略,并且此方法将创建一个VolatileImage,而不考虑ImageCapabilities约束。
返回的VolatileImage具有最接近此本机设备配置的布局和颜色模型,因此可以将其优化为该设备。
width - 返回的宽度为
VolatileImage
height - 返回的高度
VolatileImage
caps - 图像功能
VolatileImage ,其数据布局和颜色模型与此
GraphicsConfiguration 。
AWTException - 如果图形配置不能满足提供的图像功能
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 - 如果图形配置不能满足提供的图像功能
Transparency.OPAQUE ,
Transparency.BITMASK ,
Transparency.TRANSLUCENT ,
Component.createVolatileImage(int, int)
public abstract ColorModel getColorModel()
ColorModel与此相关GraphicsConfiguration 。
GraphicsConfiguration的
ColorModel对象。
public abstract ColorModel getColorModel(int transparency)
ColorModel与此相关
GraphicsConfiguration支持指定透明度。
transparency - 指定的透明度模式
GraphicsConfiguration并支持指定透明度的
ColorModel对象,如果透明度不是有效值,则为null。
Transparency.OPAQUE ,
Transparency.BITMASK ,
Transparency.TRANSLUCENT
public abstract AffineTransform getDefaultTransform()
AffineTransform这个GraphicsConfiguration 。
这个AffineTransform是大多数普通屏幕的身份转换。
默认AffineTransform将AffineTransform映射到设备上,使得72个用户空间坐标单位在设备空间中测量大约1英寸。
归一化变换可用于使此映射更精确。
屏幕和打印机设备默认AffineTransform定义的坐标空间中的坐标位于设备目标区域的左上角,X坐标向右增加,Y坐标向下增加。
对于不与设备相关联的图像缓冲区,例如不是由createCompatibleImage创建的createCompatibleImage ,此AffineTransform是Identity变换。
AffineTransform为这个
GraphicsConfiguration 。
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 ,以便在设备空间
AffineTransform用户空间中的72个单位映射到1英寸。
public abstract Rectangle getBounds()
GraphicsConfiguration的边界。
在具有虚拟设备的多屏幕环境中,边界可以具有负X或Y原点。
GraphicsConfiguration 。
public BufferCapabilities getBufferCapabilities()
GraphicsConfiguration 。
public ImageCapabilities getImageCapabilities()
GraphicsConfiguration的图像
GraphicsConfiguration 。
public boolean isTranslucencyCapable()
GraphicsConfiguration是否支持
PERPIXEL_TRANSLUCENT的半透明。
Window.setBackground(Color)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.