Search in sources :

Example 51 with GraphicsDevice

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

the class CPlatformLWWindow method getGraphicsDevice.

@Override
public GraphicsDevice getGraphicsDevice() {
    CGraphicsEnvironment ge = (CGraphicsEnvironment) GraphicsEnvironment.getLocalGraphicsEnvironment();
    LWLightweightFramePeer peer = (LWLightweightFramePeer) getPeer();
    int scale = ((LightweightFrame) peer.getTarget()).getScaleFactor();
    Rectangle bounds = ((LightweightFrame) peer.getTarget()).getHostBounds();
    for (GraphicsDevice d : ge.getScreenDevices()) {
        if (d.getDefaultConfiguration().getBounds().intersects(bounds) && ((CGraphicsDevice) d).getScaleFactor() == scale) {
            return d;
        }
    }
    // We shouldn't be here...
    return ge.getDefaultScreenDevice();
}
Also used : LightweightFrame(sun.awt.LightweightFrame) LWLightweightFramePeer(sun.lwawt.LWLightweightFramePeer) GraphicsDevice(java.awt.GraphicsDevice) CGraphicsDevice(sun.awt.CGraphicsDevice) Rectangle(java.awt.Rectangle) CGraphicsEnvironment(sun.awt.CGraphicsEnvironment) CGraphicsDevice(sun.awt.CGraphicsDevice) Point(java.awt.Point)

Example 52 with GraphicsDevice

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

the class CGLSurfaceData method getGC.

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

Example 53 with GraphicsDevice

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

the class MaximizedToMaximized method main.

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");
    }
}
Also used : Frame(java.awt.Frame) GraphicsDevice(java.awt.GraphicsDevice) Insets(java.awt.Insets) Rectangle(java.awt.Rectangle) SunToolkit(sun.awt.SunToolkit) SunToolkit(sun.awt.SunToolkit) Toolkit(java.awt.Toolkit) Dimension(java.awt.Dimension) GraphicsEnvironment(java.awt.GraphicsEnvironment)

Example 54 with GraphicsDevice

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

the class AltTabCrashTest method findDisplayMode.

private DisplayMode findDisplayMode() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    DisplayMode[] dms = gd.getDisplayModes();
    DisplayMode currentDM = gd.getDisplayMode();
    for (DisplayMode dm : dms) {
        if (dm.getBitDepth() > 8 && dm.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI && dm.getBitDepth() != currentDM.getBitDepth() && dm.getWidth() == currentDM.getWidth() && dm.getHeight() == currentDM.getHeight()) {
            // depth
            return dm;
        }
        if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI && (dm.getWidth() != currentDM.getWidth() || dm.getHeight() != currentDM.getHeight())) {
            // dimensions
            return dm;
        }
    }
    return null;
}
Also used : DisplayMode(java.awt.DisplayMode) GraphicsDevice(java.awt.GraphicsDevice)

Example 55 with GraphicsDevice

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

the class BufferStrategyExceptionTest method main.

public static void main(String[] args) {
    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    for (int i = 0; i < TEST_REPS; i++) {
        TestFrame f = new TestFrame();
        f.pack();
        f.setSize(400, 400);
        f.setVisible(true);
        if (i % 2 == 0) {
            gd.setFullScreenWindow(f);
        }
        // generate a resize event which will invalidate the peer's
        // surface data and hopefully cause an exception during
        // BufferStrategy creation in TestFrame.render()
        Dimension d = f.getSize();
        d.width -= 5;
        d.height -= 5;
        f.setSize(d);
        f.render();
        gd.setFullScreenWindow(null);
        sleep(100);
        f.dispose();
    }
    System.out.println("Test passed.");
}
Also used : GraphicsDevice(java.awt.GraphicsDevice) Dimension(java.awt.Dimension)

Aggregations

GraphicsDevice (java.awt.GraphicsDevice)75 GraphicsEnvironment (java.awt.GraphicsEnvironment)44 GraphicsConfiguration (java.awt.GraphicsConfiguration)23 Point (java.awt.Point)15 Frame (java.awt.Frame)13 Dimension (java.awt.Dimension)12 DisplayMode (java.awt.DisplayMode)12 Rectangle (java.awt.Rectangle)11 Insets (java.awt.Insets)7 Toolkit (java.awt.Toolkit)7 Graphics (java.awt.Graphics)6 BufferedImage (java.awt.image.BufferedImage)6 HeadlessException (java.awt.HeadlessException)4 Window (java.awt.Window)4 JFrame (javax.swing.JFrame)4 Test (org.junit.Test)4 MouseAdapter (java.awt.event.MouseAdapter)3 MouseEvent (java.awt.event.MouseEvent)3 WindowAdapter (java.awt.event.WindowAdapter)3 WindowEvent (java.awt.event.WindowEvent)3