當前位置: 首頁>>代碼示例>>Java>>正文


Java GraphicsConfiguration.getColorModel方法代碼示例

本文整理匯總了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");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:IsToolkitUseTheMainScreen.java

示例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));
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:58,代碼來源:DrawImageBilinear.java


注:本文中的java.awt.GraphicsConfiguration.getColorModel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。