Search in sources :

Example 61 with GraphicsDevice

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

the class NoResizeEventOnDMChangeTest method main.

public static void main(String[] args) {
    final GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    if (!gd.isFullScreenSupported()) {
        System.out.println("Full screen not supported, test passed");
        return;
    }
    DisplayMode dm = gd.getDisplayMode();
    final DisplayMode[] dms = new DisplayMode[2];
    for (DisplayMode dm1 : gd.getDisplayModes()) {
        if (dm1.getWidth() != dm.getWidth() || dm1.getHeight() != dm.getHeight()) {
            dms[0] = dm1;
            break;
        }
    }
    if (dms[0] == null) {
        System.out.println("Test Passed: all DMs have same dimensions");
        return;
    }
    dms[1] = dm;
    Frame f = new Frame() {

        @Override
        public void paint(Graphics g) {
            g.setColor(Color.red);
            g.fillRect(0, 0, getWidth(), getHeight());
            g.setColor(Color.green);
            g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
        }
    };
    f.setUndecorated(true);
    testFSWindow(gd, dms, f);
    Window w = new Window(f) {

        @Override
        public void paint(Graphics g) {
            g.setColor(Color.magenta);
            g.fillRect(0, 0, getWidth(), getHeight());
            g.setColor(Color.cyan);
            g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
        }
    };
    testFSWindow(gd, dms, w);
    System.out.println("Test Passed.");
}
Also used : DisplayMode(java.awt.DisplayMode) Graphics(java.awt.Graphics) Window(java.awt.Window) Frame(java.awt.Frame) GraphicsDevice(java.awt.GraphicsDevice)

Example 62 with GraphicsDevice

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

the class DisplayChangeVITest method run.

public void run() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    if (gd.isDisplayChangeSupported() && dms.size() > 0) {
        while (!done && reps++ < TEST_REPS) {
            for (DisplayMode dm : dms) {
                System.err.printf("Entering DisplayMode[%dx%dx%d]\n", dm.getWidth(), dm.getHeight(), dm.getBitDepth());
                gd.setDisplayMode(dm);
                initBackbuffer();
                for (int i = 0; i < 10; i++) {
                    // render to the screen
                    render(getGraphics());
                    // ask Swing to repaint
                    repaint();
                    sleep(100);
                }
                sleep(1500);
            }
        }
    } else {
        System.err.println("Display mode change " + "not supported. Test passed.");
    }
    dispose();
    synchronized (lock) {
        done = true;
        lock.notify();
    }
}
Also used : DisplayMode(java.awt.DisplayMode) GraphicsDevice(java.awt.GraphicsDevice)

Example 63 with GraphicsDevice

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

the class FullScreenInsets method main.

public static void main(final String[] args) {
    final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsDevice[] devices = ge.getScreenDevices();
    final Window wGreen = new Frame();
    wGreen.setBackground(Color.GREEN);
    wGreen.setSize(300, 300);
    wGreen.setVisible(true);
    sleep();
    final Insets iGreen = wGreen.getInsets();
    final Dimension sGreen = wGreen.getSize();
    final Window wRed = new Frame();
    wRed.setBackground(Color.RED);
    wRed.setSize(300, 300);
    wRed.setVisible(true);
    sleep();
    final Insets iRed = wGreen.getInsets();
    final Dimension sRed = wGreen.getSize();
    for (final GraphicsDevice device : devices) {
        if (!device.isFullScreenSupported()) {
            continue;
        }
        device.setFullScreenWindow(wGreen);
        sleep();
        testWindowBounds(device.getDisplayMode(), wGreen);
        testColor(wGreen, Color.GREEN);
        device.setFullScreenWindow(wRed);
        sleep();
        testWindowBounds(device.getDisplayMode(), wRed);
        testColor(wRed, Color.RED);
        device.setFullScreenWindow(null);
        sleep();
        testInsets(wGreen.getInsets(), iGreen);
        testInsets(wRed.getInsets(), iRed);
        testSize(wGreen.getSize(), sGreen);
        testSize(wRed.getSize(), sRed);
    }
    wGreen.dispose();
    wRed.dispose();
    if (!passed) {
        throw new RuntimeException("Test failed");
    }
}
Also used : Window(java.awt.Window) Frame(java.awt.Frame) GraphicsDevice(java.awt.GraphicsDevice) Insets(java.awt.Insets) Dimension(java.awt.Dimension) GraphicsEnvironment(java.awt.GraphicsEnvironment)

Example 64 with GraphicsDevice

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

the class XMouseInfoPeer method fillPointWithCoords.

public int fillPointWithCoords(Point point) {
    long display = XToolkit.getDisplay();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    int gdslen = gds.length;
    XToolkit.awtLock();
    try {
        for (int i = 0; i < gdslen; i++) {
            long screenRoot = XlibWrapper.RootWindow(display, i);
            boolean pointerFound = XlibWrapper.XQueryPointer(display, screenRoot, // root_return
            XlibWrapper.larg1, // child_return
            XlibWrapper.larg2, // xr_return
            XlibWrapper.larg3, // yr_return
            XlibWrapper.larg4, // xw_return
            XlibWrapper.larg5, // yw_return
            XlibWrapper.larg6, // mask_return
            XlibWrapper.larg7);
            if (pointerFound) {
                point.x = Native.getInt(XlibWrapper.larg3);
                point.y = Native.getInt(XlibWrapper.larg4);
                return i;
            }
        }
    } finally {
        XToolkit.awtUnlock();
    }
    // this should never happen
    assert false : "No pointer found in the system.";
    return 0;
}
Also used : GraphicsDevice(java.awt.GraphicsDevice) GraphicsEnvironment(java.awt.GraphicsEnvironment) Point(java.awt.Point)

Example 65 with GraphicsDevice

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

the class X11SurfaceData method getGC.

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

Aggregations

GraphicsDevice (java.awt.GraphicsDevice)80 GraphicsEnvironment (java.awt.GraphicsEnvironment)46 GraphicsConfiguration (java.awt.GraphicsConfiguration)25 Point (java.awt.Point)17 Dimension (java.awt.Dimension)15 Frame (java.awt.Frame)13 DisplayMode (java.awt.DisplayMode)12 Rectangle (java.awt.Rectangle)11 Graphics (java.awt.Graphics)7 Insets (java.awt.Insets)7 Toolkit (java.awt.Toolkit)7 BufferedImage (java.awt.image.BufferedImage)7 HeadlessException (java.awt.HeadlessException)5 Window (java.awt.Window)4 JFrame (javax.swing.JFrame)4 Test (org.junit.Test)4 MouseAdapter (java.awt.event.MouseAdapter)3 WindowAdapter (java.awt.event.WindowAdapter)3 WindowEvent (java.awt.event.WindowEvent)3 VolatileImage (java.awt.image.VolatileImage)3