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


Java GraphicsEnvironment.getDefaultScreenDevice方法代碼示例

本文整理匯總了Java中java.awt.GraphicsEnvironment.getDefaultScreenDevice方法的典型用法代碼示例。如果您正苦於以下問題:Java GraphicsEnvironment.getDefaultScreenDevice方法的具體用法?Java GraphicsEnvironment.getDefaultScreenDevice怎麽用?Java GraphicsEnvironment.getDefaultScreenDevice使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.GraphicsEnvironment的用法示例。


在下文中一共展示了GraphicsEnvironment.getDefaultScreenDevice方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import java.awt.GraphicsEnvironment; //導入方法依賴的package包/類
public static void main(final String[] args) {
    final GraphicsEnvironment lge = getLocalGraphicsEnvironment();
    final GraphicsDevice dev = lge.getDefaultScreenDevice();
    final GraphicsConfiguration config = dev.getDefaultConfiguration();

    test(config.createCompatibleImage(10, 10).getGraphics());
    test(config.createCompatibleImage(10, 10, OPAQUE).getGraphics());
    test(config.createCompatibleImage(10, 10, BITMASK).getGraphics());
    test(config.createCompatibleImage(10, 10, TRANSLUCENT).getGraphics());

    test(new BufferedImage(10, 10, TYPE_INT_ARGB).getGraphics());

    final Window frame = new Frame();
    frame.pack();
    try {
        test(frame.getGraphics());
        test(frame.createImage(10, 10).getGraphics());
    } finally {
        frame.dispose();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:SurfaceDestination.java

示例2: hasAppleRetinaDisplay

import java.awt.GraphicsEnvironment; //導入方法依賴的package包/類
/**
 * hack from
 * https://bulenkov.com/2013/06/23/retina-support-in-oracle-jdk-1-7/ used to
 * multiply mouse coordinates by two in case of retina display; see
 * http://forum.lwjgl.org/index.php?topic=5084.0
 *
 * @return true if running on platform with retina display. Value is cached
 * in VM to avoid runtime cost penalty of multiple calls.
 */
public static boolean hasAppleRetinaDisplay() {
    if (checkedRetinaDisplay) {
        return hasRetinaDisplayTrue;
    }
    checkedRetinaDisplay = true;
    //other OS and JVM specific checks...
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsDevice device = env.getDefaultScreenDevice();

    try {
        Field field = device.getClass().getDeclaredField("scale");

        if (field != null) {
            field.setAccessible(true);
            Object scale = field.get(device);

            if (scale instanceof Integer && ((Integer) scale).intValue() == 2) {
                hasRetinaDisplayTrue = true;
            }
        }
    } catch (Exception ignore) {
    }
    //...
    return hasRetinaDisplayTrue;
}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:35,代碼來源:ChipCanvas.java

示例3: iconToImage

import java.awt.GraphicsEnvironment; //導入方法依賴的package包/類
public static Image iconToImage(Icon icon) {
    if (icon instanceof ImageIcon) {
        return ((ImageIcon) icon).getImage();
    } else {
        int w = icon.getIconWidth();
        int h = icon.getIconHeight();
        GraphicsEnvironment ge
                = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = ge.getDefaultScreenDevice();
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        BufferedImage image = gc.createCompatibleImage(w, h);
        Graphics2D g = image.createGraphics();
        icon.paintIcon(null, g, 0, 0);
        g.dispose();
        return image;
    }
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:18,代碼來源:Canvas.java

示例4: main

import java.awt.GraphicsEnvironment; //導入方法依賴的package包/類
public static void main(String[] args) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice graphicDevice = ge.getDefaultScreenDevice();
    if (!graphicDevice.isDisplayChangeSupported()) {
        System.err.println("Display mode change is not supported on this host. Test is considered passed.");
        return;
    }
    DisplayMode defaultDisplayMode = graphicDevice.getDisplayMode();
    checkDisplayMode(defaultDisplayMode);
    graphicDevice.setDisplayMode(defaultDisplayMode);

    DisplayMode[] displayModes = graphicDevice.getDisplayModes();
    boolean isDefaultDisplayModeIncluded = false;
    for (DisplayMode displayMode : displayModes) {
        checkDisplayMode(displayMode);
        graphicDevice.setDisplayMode(displayMode);
        if (defaultDisplayMode.equals(displayMode)) {
            isDefaultDisplayModeIncluded = true;
        }
    }

    if (!isDefaultDisplayModeIncluded) {
        throw new RuntimeException("Default display mode is not included");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:CheckDisplayModes.java

示例5: main

import java.awt.GraphicsEnvironment; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {

       Frame frame = new Frame();
        final Toolkit toolkit = Toolkit.getDefaultToolkit();
        final GraphicsEnvironment graphicsEnvironment =
                GraphicsEnvironment.getLocalGraphicsEnvironment();
        final GraphicsDevice graphicsDevice =
                graphicsEnvironment.getDefaultScreenDevice();

        final Dimension screenSize = toolkit.getScreenSize();
        final Insets screenInsets = toolkit.getScreenInsets(
                graphicsDevice.getDefaultConfiguration());

        final Rectangle availableScreenBounds = new Rectangle(screenSize);

        availableScreenBounds.x += screenInsets.left;
        availableScreenBounds.y += screenInsets.top;
        availableScreenBounds.width -= (screenInsets.left + screenInsets.right);
        availableScreenBounds.height -= (screenInsets.top + screenInsets.bottom);

        frame.setBounds(availableScreenBounds.x, availableScreenBounds.y,
                availableScreenBounds.width, availableScreenBounds.height);
        frame.setVisible(true);

        Rectangle frameBounds = frame.getBounds();
        frame.setExtendedState(Frame.MAXIMIZED_BOTH);
        ((SunToolkit) toolkit).realSync();

        Rectangle maximizedFrameBounds = frame.getBounds();
        if (maximizedFrameBounds.width < frameBounds.width
                || maximizedFrameBounds.height < frameBounds.height) {
            throw new RuntimeException("Maximized frame is smaller than non maximized");
        }
    }
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:35,代碼來源:MaximizedToMaximized.java

示例6: main

import java.awt.GraphicsEnvironment; //導入方法依賴的package包/類
public static void main(String[] args) {

        GraphicsEnvironment ge =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = ge.getDefaultScreenDevice();
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        VolatileImage vi = gc.createCompatibleVolatileImage(16, 16);
        vi.validate(gc);

        BufferedImage bi =
            new BufferedImage(2, 2, BufferedImage.TYPE_INT_RGB);
        int data[] = ((DataBufferInt)bi.getRaster().getDataBuffer()).getData();
        data[0] = 0x0000007f;
        data[1] = 0x0000007f;
        data[2] = 0xff00007f;
        data[3] = 0xff00007f;
        Graphics2D g = vi.createGraphics();
        g.setComposite(AlphaComposite.SrcOver.derive(0.999f));
        g.drawImage(bi, 0, 0, null);

        bi = vi.getSnapshot();
        if (bi.getRGB(0, 0) != bi.getRGB(1, 1)) {
            throw new RuntimeException("Test FAILED: color at 0x0 ="+
                Integer.toHexString(bi.getRGB(0, 0))+" differs from 1x1 ="+
                Integer.toHexString(bi.getRGB(1,1)));
        }

        System.out.println("Test PASSED.");
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:30,代碼來源:OpaqueImageToSurfaceBlitTest.java

示例7: getCompatibleImage

import java.awt.GraphicsEnvironment; //導入方法依賴的package包/類
public static BufferedImage getCompatibleImage(final int width, final int height) {
  if (width == 0 && height == 0) {
    return null;
  }

  final GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
  final GraphicsDevice device = env.getDefaultScreenDevice();
  final GraphicsConfiguration config = device.getDefaultConfiguration();
  return config.createCompatibleImage(width, height, Transparency.TRANSLUCENT);
}
 
開發者ID:gurkenlabs,項目名稱:litiengine,代碼行數:11,代碼來源:ImageProcessing.java

示例8: main

import java.awt.GraphicsEnvironment; //導入方法依賴的package包/類
public static void main(final String[] args) {
    final GraphicsEnvironment ge =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsDevice gd = ge.getDefaultScreenDevice();
    final GraphicsConfiguration gc = gd.getDefaultConfiguration();
    final VolatileImage vi =
            gc.createCompatibleVolatileImage(SIZE, SIZE, TRANSLUCENT);
    final BufferedImage bi = makeUnmanagedBI(gc, TRANSLUCENT);
    final int expected = bi.getRGB(2, 2);

    int attempt = 0;
    BufferedImage snapshot;
    while (true) {
        if (++attempt > 10) {
            throw new RuntimeException("Too many attempts: " + attempt);
        }
        vi.validate(gc);
        final Graphics2D g2d = vi.createGraphics();
        g2d.setComposite(AlphaComposite.Src);
        g2d.scale(2, 2);
        g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                             RenderingHints.VALUE_INTERPOLATION_BICUBIC);
        g2d.drawImage(bi, 0, 0, null);
        g2d.dispose();

        snapshot = vi.getSnapshot();
        if (vi.contentsLost()) {
            continue;
        }
        break;
    }
    final int actual = snapshot.getRGB(2, 2);
    if (actual != expected) {
        System.err.println("Actual: " + Integer.toHexString(actual));
        System.err.println("Expected: " + Integer.toHexString(expected));
        throw new RuntimeException("Test failed");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:39,代碼來源:IncorrectAlphaConversionBicubic.java

示例9: getGC

import java.awt.GraphicsEnvironment; //導入方法依賴的package包/類
private static D3DGraphicsConfig getGC(WComponentPeer peer) {
    GraphicsConfiguration gc;
    if (peer != null) {
        gc =  peer.getGraphicsConfiguration();
    } else {
        GraphicsEnvironment env =
                GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = env.getDefaultScreenDevice();
        gc = gd.getDefaultConfiguration();
    }
    return (gc instanceof D3DGraphicsConfig) ? (D3DGraphicsConfig)gc : null;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:D3DSurfaceData.java

示例10: getGC

import java.awt.GraphicsEnvironment; //導入方法依賴的package包/類
public static CGLGraphicsConfig getGC(CPlatformView pView) {
    if (pView != null) {
        return (CGLGraphicsConfig)pView.getGraphicsConfiguration();
    } else {
        // REMIND: this should rarely (never?) happen, but what if
        // default config is not CGL?
        GraphicsEnvironment env = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
        GraphicsDevice gd = env.getDefaultScreenDevice();
        return (CGLGraphicsConfig) gd.getDefaultConfiguration();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:CGLSurfaceData.java

示例11: getGC

import java.awt.GraphicsEnvironment; //導入方法依賴的package包/類
public static GLXGraphicsConfig getGC(X11ComponentPeer peer) {
    if (peer != null) {
        return (GLXGraphicsConfig)peer.getGraphicsConfiguration();
    } else {
        // REMIND: this should rarely (never?) happen, but what if
        //         default config is not GLX?
        GraphicsEnvironment env =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = env.getDefaultScreenDevice();
        return (GLXGraphicsConfig)gd.getDefaultConfiguration();
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:13,代碼來源:GLXSurfaceData.java

示例12: makeVI

import java.awt.GraphicsEnvironment; //導入方法依賴的package包/類
private static VolatileImage makeVI(final int type) {
    final GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    final GraphicsDevice gd = ge.getDefaultScreenDevice();
    final GraphicsConfiguration gc = gd.getDefaultConfiguration();
    return gc.createCompatibleVolatileImage(SIZE, SIZE, type);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:8,代碼來源:UnmanagedDrawImagePerformance.java

示例13: showDebugDialog

import java.awt.GraphicsEnvironment; //導入方法依賴的package包/類
void showDebugDialog() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice defaultScreen = ge.getDefaultScreenDevice();
    Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds();
    pack();
    setLocation((int) rect.getCenterX(), Canvas.Window.winStart.y);
    setAlwaysOnTop(true);
    setVisible(true);
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:10,代碼來源:TestCaseComponent.java

示例14: getGC

import java.awt.GraphicsEnvironment; //導入方法依賴的package包/類
public static WGLGraphicsConfig getGC(WComponentPeer peer) {
    if (peer != null) {
        return (WGLGraphicsConfig)peer.getGraphicsConfiguration();
    } else {
        // REMIND: this should rarely (never?) happen, but what if
        //         default config is not WGL?
        GraphicsEnvironment env =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = env.getDefaultScreenDevice();
        return (WGLGraphicsConfig)gd.getDefaultConfiguration();
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:13,代碼來源:WGLSurfaceData.java

示例15: getGC

import java.awt.GraphicsEnvironment; //導入方法依賴的package包/類
public static X11GraphicsConfig getGC(X11ComponentPeer peer) {
    if (peer != null) {
        return (X11GraphicsConfig) peer.getGraphicsConfiguration();
    } else {
        GraphicsEnvironment env =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = env.getDefaultScreenDevice();
        return (X11GraphicsConfig)gd.getDefaultConfiguration();
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:11,代碼來源:X11SurfaceData.java


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