Search in sources :

Example 76 with GraphicsEnvironment

use of java.awt.GraphicsEnvironment in project jdk8u_jdk by JetBrains.

the class CheckDisplayModes method main.

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");
    }
}
Also used : DisplayMode(java.awt.DisplayMode) GraphicsDevice(java.awt.GraphicsDevice) GraphicsEnvironment(java.awt.GraphicsEnvironment)

Example 77 with GraphicsEnvironment

use of java.awt.GraphicsEnvironment in project jdk8u_jdk by JetBrains.

the class WGLSurfaceData method getGC.

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();
    }
}
Also used : GraphicsDevice(java.awt.GraphicsDevice) Win32GraphicsDevice(sun.awt.Win32GraphicsDevice) GraphicsEnvironment(java.awt.GraphicsEnvironment)

Example 78 with GraphicsEnvironment

use of java.awt.GraphicsEnvironment in project jdk8u_jdk by JetBrains.

the class D3DSurfaceData method getGC.

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;
}
Also used : GraphicsDevice(java.awt.GraphicsDevice) GraphicsEnvironment(java.awt.GraphicsEnvironment) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 79 with GraphicsEnvironment

use of java.awt.GraphicsEnvironment in project jdk8u_jdk by JetBrains.

the class MultiScreenInsetsTest method main.

public static void main(String[] args) throws InterruptedException {
    OSInfo.OSType type = OSInfo.getOSType();
    if (type != OSInfo.OSType.LINUX && type != OSInfo.OSType.SOLARIS) {
        System.out.println("This test is for Solaris and Linux only..." + "skipping!");
        return;
    }
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    if (gds.length < 2) {
        System.out.println("It's a multi-screen test... skipping!");
        return;
    }
    for (int screen = 0; screen < gds.length; ++screen) {
        GraphicsDevice gd = gds[screen];
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        Rectangle bounds = gc.getBounds();
        Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
        Frame frame = new Frame(gc);
        frame.setLocation(bounds.x + (bounds.width - SIZE) / 2, bounds.y + (bounds.height - SIZE) / 2);
        frame.setSize(SIZE, SIZE);
        frame.setUndecorated(true);
        frame.setVisible(true);
        // Maximize Frame to reach the struts
        frame.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
        Thread.sleep(2000);
        Rectangle frameBounds = frame.getBounds();
        frame.dispose();
        if (bounds.x + insets.left != frameBounds.x || bounds.y + insets.top != frameBounds.y || bounds.width - insets.right - insets.left != frameBounds.width || bounds.height - insets.bottom - insets.top != frameBounds.height) {
            throw new RuntimeException("Test FAILED! Wrong screen #" + screen + " insets: " + insets);
        }
    }
    System.out.println("Test PASSED!");
}
Also used : OSInfo(sun.awt.OSInfo) Frame(java.awt.Frame) GraphicsDevice(java.awt.GraphicsDevice) Insets(java.awt.Insets) Rectangle(java.awt.Rectangle) GraphicsEnvironment(java.awt.GraphicsEnvironment) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 80 with GraphicsEnvironment

use of java.awt.GraphicsEnvironment in project jdk8u_jdk by JetBrains.

the class MultiScreenLocationTest method main.

public static void main(String[] args) throws AWTException {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    if (gds.length < 2) {
        System.out.println("It's a multiscreen test... skipping!");
        return;
    }
    for (int i = 0; i < gds.length; ++i) {
        GraphicsDevice gd = gds[i];
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        Rectangle screen = gc.getBounds();
        Robot robot = new Robot(gd);
        // check Robot.mouseMove()
        robot.mouseMove(screen.x + mouseOffset.x, screen.y + mouseOffset.y);
        Point mouse = MouseInfo.getPointerInfo().getLocation();
        Point point = screen.getLocation();
        point.translate(mouseOffset.x, mouseOffset.y);
        if (!point.equals(mouse)) {
            throw new RuntimeException(getErrorText("Robot.mouseMove", i));
        }
        // check Robot.getPixelColor()
        Frame frame = new Frame(gc);
        frame.setUndecorated(true);
        frame.setSize(100, 100);
        frame.setLocation(screen.x + frameOffset.x, screen.y + frameOffset.y);
        frame.setBackground(color);
        frame.setVisible(true);
        robot.waitForIdle();
        Rectangle bounds = frame.getBounds();
        if (!Util.testBoundsColor(bounds, color, 5, 1000, robot)) {
            throw new RuntimeException(getErrorText("Robot.getPixelColor", i));
        }
        // check Robot.createScreenCapture()
        BufferedImage image = robot.createScreenCapture(bounds);
        int rgb = color.getRGB();
        if (image.getRGB(0, 0) != rgb || image.getRGB(image.getWidth() - 1, 0) != rgb || image.getRGB(image.getWidth() - 1, image.getHeight() - 1) != rgb || image.getRGB(0, image.getHeight() - 1) != rgb) {
            throw new RuntimeException(getErrorText("Robot.createScreenCapture", i));
        }
        frame.dispose();
    }
    System.out.println("Test PASSED!");
}
Also used : Frame(java.awt.Frame) GraphicsDevice(java.awt.GraphicsDevice) Rectangle(java.awt.Rectangle) Point(java.awt.Point) GraphicsEnvironment(java.awt.GraphicsEnvironment) Robot(java.awt.Robot) Point(java.awt.Point) BufferedImage(java.awt.image.BufferedImage) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Aggregations

GraphicsEnvironment (java.awt.GraphicsEnvironment)93 GraphicsDevice (java.awt.GraphicsDevice)46 GraphicsConfiguration (java.awt.GraphicsConfiguration)44 BufferedImage (java.awt.image.BufferedImage)24 VolatileImage (java.awt.image.VolatileImage)21 Dimension (java.awt.Dimension)17 Graphics2D (java.awt.Graphics2D)17 Point (java.awt.Point)12 Font (java.awt.Font)11 Rectangle (java.awt.Rectangle)11 Insets (java.awt.Insets)7 File (java.io.File)7 Frame (java.awt.Frame)6 Toolkit (java.awt.Toolkit)6 AffineTransform (java.awt.geom.AffineTransform)6 HeadlessException (java.awt.HeadlessException)5 Color (java.awt.Color)3 Container (java.awt.Container)3 DisplayMode (java.awt.DisplayMode)3 GradientPaint (java.awt.GradientPaint)3