本文整理匯總了Java中java.awt.GraphicsConfiguration.getDefaultTransform方法的典型用法代碼示例。如果您正苦於以下問題:Java GraphicsConfiguration.getDefaultTransform方法的具體用法?Java GraphicsConfiguration.getDefaultTransform怎麽用?Java GraphicsConfiguration.getDefaultTransform使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.GraphicsConfiguration
的用法示例。
在下文中一共展示了GraphicsConfiguration.getDefaultTransform方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getBackupSurface
import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
/**
* Creates a software-based surface (of type BufImgSurfaceData).
* The software representation is only created when needed, which
* is only during some situation in which the hardware surface
* cannot be allocated. This allows apps to at least run,
* albeit more slowly than they would otherwise.
*/
protected SurfaceData getBackupSurface() {
if (sdBackup == null) {
GraphicsConfiguration gc = vImg.getGraphicsConfig();
AffineTransform tx = gc.getDefaultTransform();
double scaleX = tx.getScaleX();
double scaleY = tx.getScaleY();
BufferedImage bImg = vImg.getBackupImage(scaleX, scaleY);
// Sabotage the acceleration capabilities of the BufImg surface
SunWritableRaster.stealTrackable(bImg
.getRaster()
.getDataBuffer()).setUntrackable();
sdBackup = BufImgSurfaceData.createData(bImg, scaleX, scaleY);
}
return sdBackup;
}
示例2: initScreenBounds
import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
static void initScreenBounds() {
GraphicsDevice[] devices = GraphicsEnvironment
.getLocalGraphicsEnvironment()
.getScreenDevices();
screenBounds = new Rectangle[devices.length];
scales = new double[devices.length][2];
for (int i = 0; i < devices.length; i++) {
GraphicsConfiguration gc = devices[i].getDefaultConfiguration();
screenBounds[i] = gc.getBounds();
AffineTransform tx = gc.getDefaultTransform();
scales[i][0] = tx.getScaleX();
scales[i][1] = tx.getScaleY();
}
maxBounds = screenBounds[0];
for (int i = 0; i < screenBounds.length; i++) {
maxBounds = maxBounds.union(screenBounds[i]);
}
}
示例3: initScreenBounds
import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
static void initScreenBounds() {
GraphicsDevice[] devices = GraphicsEnvironment
.getLocalGraphicsEnvironment()
.getScreenDevices();
screenBounds = new Rectangle[devices.length];
scales = new double[devices.length][2];
for (int i = 0; i < devices.length; i++) {
GraphicsConfiguration gc = devices[i].getDefaultConfiguration();
screenBounds[i] = gc.getBounds();
AffineTransform tx = gc.getDefaultTransform();
scales[i][0] = tx.getScaleX();
scales[i][1] = tx.getScaleY();
}
for (int i = 0; i < devices.length; i++) {
for (int j = i + 1; j < devices.length; j++) {
if (scales[i][0] != scales[j][0] || scales[i][1] != scales[j][1]) {
screen1 = i;
screen2 = j;
}
}
}
}
示例4: testScaleFactor
import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
private static void testScaleFactor(final GraphicsConfiguration gc) {
final Dialog dialog = new Dialog((Frame) null, "Test", true, gc);
try {
dialog.setSize(100, 100);
Panel panel = new Panel() {
@Override
public void paint(Graphics g) {
if (g instanceof Graphics2D) {
AffineTransform gcTx = gc.getDefaultTransform();
AffineTransform gTx
= ((Graphics2D) g).getTransform();
passed = gcTx.getScaleX() == gTx.getScaleX()
&& gcTx.getScaleY() == gTx.getScaleY();
} else {
passed = true;
}
dialog.setVisible(false);
}
};
dialog.add(panel);
dialog.setVisible(true);
if (!passed) {
throw new RuntimeException("Transform is not scaled!");
}
} finally {
dialog.dispose();
}
}
示例5: getDefaultTransform
import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
private AffineTransform getDefaultTransform() {
GraphicsConfiguration gc = getDeviceConfiguration();
return (gc == null) ? new AffineTransform() : gc.getDefaultTransform();
}