|
JavaTM 2 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 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。