|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjava.awt.GraphicsConfiguration
public abstract class GraphicsConfiguration
GraphicsConfiguration 类描述图形目标(如打印机或监视器)的特征。有许多与单一图形设备关联的 GraphicsConfiguration 对象,表示不同的绘图模式或能力。相应的本机结构也将因平台而异。例如,在 X11 窗口系统上,每个可视组件都是一个不同的 GraphicsConfiguration。在 Microsoft Windows 系统上,GraphicsConfiguration 表示当前分辨率和颜色深度下可用的 PixelFormat。
在虚拟设备多屏幕环境中(其中桌面区域可以跨越多个物理屏幕设备),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| 构造方法摘要 | |
|---|---|
protected |
GraphicsConfiguration()
这是一个不可直接实例化的抽象类。 |
| 方法摘要 | |
|---|---|
abstract BufferedImage |
createCompatibleImage(int width,
int height)
返回一个数据布局和颜色模型与此 GraphicsConfiguration 兼容的 BufferedImage。 |
BufferedImage |
createCompatibleImage(int width,
int height,
int transparency)
返回一个支持指定透明度,并且数据布局和颜色模型与此 GraphicsConfiguration 兼容的 BufferedImage。 |
VolatileImage |
createCompatibleVolatileImage(int width,
int height)
返回一个数据布局和颜色模型与此 GraphicsConfiguration 兼容的 VolatileImage。 |
VolatileImage |
createCompatibleVolatileImage(int width,
int height,
ImageCapabilities caps)
返回一个数据布局和颜色模型与此 GraphicsConfiguration 兼容并使用指定图像能力的 VolatileImage。 |
VolatileImage |
createCompatibleVolatileImage(int width,
int height,
ImageCapabilities caps,
int transparency)
返回一个数据布局和颜色模型与此 GraphicsConfiguration 兼容并使用指定图像能力和透明度值的 VolatileImage。 |
VolatileImage |
createCompatibleVolatileImage(int width,
int height,
int transparency)
返回一个数据布局和颜色模型与此 GraphicsConfiguration 兼容的 VolatileImage。 |
abstract Rectangle |
getBounds()
返回 GraphicsConfiguration 在设备坐标中的边界。 |
BufferCapabilities |
getBufferCapabilities()
返回此 GraphicsConfiguration 的缓冲区能力。 |
abstract ColorModel |
getColorModel()
返回与此 GraphicsConfiguration 关联的 ColorModel。 |
abstract ColorModel |
getColorModel(int transparency)
返回与此 GraphicsConfiguration 关联并支持指定透明度的 ColorModel。 |
abstract AffineTransform |
getDefaultTransform()
返回此 GraphicsConfiguration 的默认 AffineTransform。 |
abstract GraphicsDevice |
getDevice()
返回与此 GraphicsConfiguration 关联的 GraphicsDevice。 |
ImageCapabilities |
getImageCapabilities()
返回此 GraphicsConfiguration 的图像能力。 |
abstract AffineTransform |
getNormalizingTransform()
返回可与 GraphicsConfiguration 的默认 AffineTransform 连接的 AffineTransform,从而用户空间的 72 单位等于设备空间的 1 英寸。 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
protected GraphicsConfiguration()
GraphicsDevice.getConfigurations(),
GraphicsDevice.getDefaultConfiguration(),
GraphicsDevice.getBestConfiguration(java.awt.GraphicsConfigTemplate),
Graphics2D.getDeviceConfiguration()| 方法详细信息 |
|---|
public abstract GraphicsDevice getDevice()
GraphicsConfiguration 关联的 GraphicsDevice。
GraphicsConfiguration 关联的 GraphicsDevice 对象。
public abstract BufferedImage createCompatibleImage(int width,
int height)
GraphicsConfiguration 兼容的 BufferedImage。此方法与设备的内存映射无关。返回 BufferedImage 的数据布局和颜色模型与本机设备配置最接近,因此最适合于位图传输 (blitted) 到此设备上。
width - 返回的 BufferedImage 宽度height - 返回的 BufferedImage 高度
GraphicsConfiguration 兼容的 BufferedImage。
public BufferedImage createCompatibleImage(int width,
int height,
int transparency)
GraphicsConfiguration 兼容的 BufferedImage。此方法与设备的内存映射无关。返回 BufferedImage 的数据布局和颜色模型最适合于位图传输 (blitted) 到利用此 GraphicsConfiguration 的设备上。
width - 返回的 BufferedImage 宽度height - 返回的 BufferedImage 高度transparency - 指定的透明度模式
GraphicsConfiguration 兼容且支持指定透明度的 BufferedImage。
IllegalArgumentException - 如果透明度不是一个有效值Transparency.OPAQUE,
Transparency.BITMASK,
Transparency.TRANSLUCENT
public VolatileImage createCompatibleVolatileImage(int width,
int height)
GraphicsConfiguration 兼容的 VolatileImage。返回的 VolatileImage 可能有最适合于底层图形设备的存储数据,因此可能从特定于平台的呈现加速中受益。
width - 返回的 VolatileImage 宽度height - 返回的 VolatileImage 高度
GraphicsConfiguration 兼容的 VolatileImage。Component.createVolatileImage(int, int)
public VolatileImage createCompatibleVolatileImage(int width,
int height,
int transparency)
GraphicsConfiguration 兼容的 VolatileImage。返回的 VolatileImage 可能有最适合于底层图形设备的存储数据,因此可能从特定于平台的呈现加速中受益。
width - 返回的 VolatileImage 宽度height - 返回的 VolatileImage 高度transparency - 指定的透明度模式
GraphicsConfiguration 兼容的 VolatileImage。
IllegalArgumentException - 如果透明度不是一个有效值Transparency.OPAQUE,
Transparency.BITMASK,
Transparency.TRANSLUCENT,
Component.createVolatileImage(int, int)
public VolatileImage createCompatibleVolatileImage(int width,
int height,
ImageCapabilities caps)
throws AWTException
GraphicsConfiguration 兼容并使用指定图像能力的 VolatileImage。如果该 caps 参数为 null,则有效地忽略它,此方法还将创建一个 VolatileImage,而不考虑 ImageCapabilities 约束。
返回 VolatileImage 的数据布局和颜色模型与本机设备配置最接近,因此最适合于位图传输 (blitted) 到此设备上。
width - 返回的 VolatileImage 宽度height - 返回的 VolatileImage 高度caps - 图像能力
GraphicsConfiguration 兼容的 VolatileImage。
AWTException - 如果此图形配置无法满足提供的图像能力
public VolatileImage createCompatibleVolatileImage(int width,
int height,
ImageCapabilities caps,
int transparency)
throws AWTException
GraphicsConfiguration 兼容并使用指定图像能力和透明度值的 VolatileImage。如果该 caps 参数为 null,则有效地忽略它,此方法还将创建一个 VolatileImage,而不考虑 ImageCapabilities 约束。
返回 VolatileImage 的数据布局和颜色模型与本机设备配置最接近,因此最适合于位图传输 (blitted) 到此设备上。
width - 返回的 VolatileImage 宽度height - 返回的 VolatileImage 高度caps - 图像能力transparency - 指定的透明度模式
GraphicsConfiguration 兼容的 VolatileImage。
IllegalArgumentException - 如果透明度不是一个有效值
AWTException - 如果此图形配置无法满足提供的图像能力Transparency.OPAQUE,
Transparency.BITMASK,
Transparency.TRANSLUCENT,
Component.createVolatileImage(int, int)public abstract ColorModel getColorModel()
GraphicsConfiguration 关联的 ColorModel。
GraphicsConfiguration 关联的 ColorModel 对象。public abstract ColorModel getColorModel(int transparency)
GraphicsConfiguration 关联并支持指定透明度的 ColorModel。
transparency - 指定的透明度模式
GraphicsConfiguration 关联并支持指定透明度的 ColorModel 对象;如果透明度不是一个有效值,则返回 null。Transparency.OPAQUE,
Transparency.BITMASK,
Transparency.TRANSLUCENTpublic abstract AffineTransform getDefaultTransform()
GraphicsConfiguration 的默认 AffineTransform。此 AffineTransform 通常是大多数正常屏幕的 Identity 转换。默认的 AffineTransform 将坐标映射到设备上:72 用户空间坐标单位在尺度上近似于设备空间的 1 英寸。标准化的转换可使映射关系更准确。坐标空间中默认 AffineTransform 为屏幕和打印机设备定义的坐标如下:原点在设备目标区域的左上角,X 坐标方向向右,Y 坐标方向向下。对于与此设备无关的图像缓冲区,如那些非 createCompatibleImage 创建的缓冲区,此 AffineTransform 即为 Identity 转换。
GraphicsConfiguration 的默认 AffineTransform。public abstract AffineTransform getNormalizingTransform()
GraphicsConfiguration 的默认 AffineTransform 连接的 AffineTransform,从而用户空间的 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 英寸。public abstract Rectangle getBounds()
GraphicsConfiguration 在设备坐标中的边界。在虚拟设备的多屏环境中,边界可以有负 X 或 Y 原点。
GraphicsConfiguration 覆盖的区域边界。public BufferCapabilities getBufferCapabilities()
GraphicsConfiguration 的缓冲区能力。
public ImageCapabilities getImageCapabilities()
GraphicsConfiguration 的图像能力。
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。