本文整理匯總了Java中java.awt.GraphicsConfiguration.getColorModel方法的典型用法代碼示例。如果您正苦於以下問題:Java GraphicsConfiguration.getColorModel方法的具體用法?Java GraphicsConfiguration.getColorModel怎麽用?Java GraphicsConfiguration.getColorModel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.GraphicsConfiguration
的用法示例。
在下文中一共展示了GraphicsConfiguration.getColorModel方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testHeadful
import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
private static void testHeadful() {
GraphicsEnvironment ge
= GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsConfiguration gc
= ge.getDefaultScreenDevice().getDefaultConfiguration();
Dimension gcSize = gc.getBounds().getSize();
ColorModel gcCM = gc.getColorModel();
Dimension toolkitSize = Toolkit.getDefaultToolkit().getScreenSize();
ColorModel toolkitCM = Toolkit.getDefaultToolkit().getColorModel();
if (!gcSize.equals(toolkitSize)) {
System.err.println("Toolkit size = " + toolkitSize);
System.err.println("GraphicsConfiguration size = " + gcSize);
throw new RuntimeException("Incorrect size");
}
if (!gcCM.equals(toolkitCM)) {
System.err.println("Toolkit color model = " + toolkitCM);
System.err.println("GraphicsConfiguration color model = " + gcCM);
throw new RuntimeException("Incorrect color model");
}
}
示例2: main
import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
public static void main(String[] args) {
boolean show = false;
for (String arg : args) {
if ("-show".equals(arg)) {
show = true;
}
}
String arch = System.getProperty("os.arch");
boolean isOglEnabled = Boolean.getBoolean("sun.java2d.opengl");
skipOglTextureTest = isOglEnabled && ("sparc".equals(arch));
System.out.println("Skip OpenGL texture test: " + skipOglTextureTest);
DrawImageBilinear test = new DrawImageBilinear();
Frame frame = new Frame();
frame.add(test);
frame.pack();
frame.setVisible(true);
// Wait until the component's been painted
synchronized (test) {
while (!done) {
try {
test.wait();
} catch (InterruptedException e) {
throw new RuntimeException("Failed: Interrupted");
}
}
}
GraphicsConfiguration gc = frame.getGraphicsConfiguration();
if (gc.getColorModel() instanceof IndexColorModel) {
System.out.println("IndexColorModel detected: " +
"test considered PASSED");
frame.dispose();
return;
}
if (!show) {
frame.dispose();
}
if (capture == null) {
throw new RuntimeException("Failed: capture is null");
}
// Test background color
int pixel = capture.getRGB(5, 5);
if (pixel != 0xffffffff) {
throw new RuntimeException("Failed: Incorrect color for " +
"background");
}
// Test pixels
testRegion(capture, new Rectangle(10, 10, 40, 40));
testRegion(capture, new Rectangle(80, 10, 40, 40));
testRegion(capture, new Rectangle(150, 10, 40, 40));
}