Java Code Examples for java.awt.DisplayMode

The following examples show how to use java.awt.DisplayMode. These examples are extracted from open source projects.
Example 1
Project: openjdk-jdk8u-backup   File: Win32GraphicsDevice.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        return null;
    }
    DisplayMode[] modes = getDisplayModes();
    for (DisplayMode mode : modes) {
        if (dm.equals(mode) ||
            (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
             dm.getWidth() == mode.getWidth() &&
             dm.getHeight() == mode.getHeight() &&
             dm.getBitDepth() == mode.getBitDepth()))
        {
            return mode;
        }
    }
    return null;
}
 
Example 2
Project: dragonwell8_jdk   File: D3DGraphicsDevice.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected DisplayMode getCurrentDisplayMode(final int screen) {
    D3DRenderQueue rq = D3DRenderQueue.getInstance();
    rq.lock();
    try {
        class Result {
            DisplayMode dm = null;
        };
        final Result res = new Result();
        rq.flushAndInvokeNow(new Runnable() {
            public void run() {
                res.dm = getCurrentDisplayModeNative(screen);
            }
        });
        if (res.dm == null) {
            return super.getCurrentDisplayMode(screen);
        }
        return res.dm;
    } finally {
        rq.unlock();
    }
}
 
Example 3
Project: dragonwell8_jdk   File: Win32GraphicsDevice.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        return null;
    }
    DisplayMode[] modes = getDisplayModes();
    for (DisplayMode mode : modes) {
        if (dm.equals(mode) ||
            (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
             dm.getWidth() == mode.getWidth() &&
             dm.getHeight() == mode.getHeight() &&
             dm.getBitDepth() == mode.getBitDepth()))
        {
            return mode;
        }
    }
    return null;
}
 
Example 4
Project: openjdk-8   File: CheckDisplayModes.java    License: GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example 5
Project: openjdk-jdk8u-backup   File: CheckDisplayModes.java    License: GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example 6
Project: hottub   File: DisplayModeChanger.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds a display mode that is different from the current display
 * mode and is likely to cause a display change event.
 */
private static DisplayMode findDisplayMode(GraphicsDevice gd) {
    DisplayMode dms[] = gd.getDisplayModes();
    DisplayMode currentDM = gd.getDisplayMode();
    for (DisplayMode dm : dms) {
        if (!dm.equals(currentDM) &&
             dm.getRefreshRate() == currentDM.getRefreshRate())
        {
            // different from the current dm and refresh rate is the same
            // means that something else is different => more likely to
            // cause a DM change event
            return dm;
        }
    }
    return null;
}
 
Example 7
Project: openjdk-8-source   File: D3DGraphicsDevice.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected DisplayMode getCurrentDisplayMode(final int screen) {
    D3DRenderQueue rq = D3DRenderQueue.getInstance();
    rq.lock();
    try {
        class Result {
            DisplayMode dm = null;
        };
        final Result res = new Result();
        rq.flushAndInvokeNow(new Runnable() {
            public void run() {
                res.dm = getCurrentDisplayModeNative(screen);
            }
        });
        if (res.dm == null) {
            return super.getCurrentDisplayMode(screen);
        }
        return res.dm;
    } finally {
        rq.unlock();
    }
}
 
Example 8
Project: jdk8u_jdk   File: CheckDisplayModes.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    for (GraphicsDevice graphicDevice : ge.getScreenDevices()) {
        if (!graphicDevice.isDisplayChangeSupported()) {
            System.err.println("Display mode change is not supported on this host. Test is considered passed.");
            continue;
        }
        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");
        }
    }
}
 
Example 9
Project: openjdk-8   File: DisplayModeChanger.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds a display mode that is different from the current display
 * mode and is likely to cause a display change event.
 */
private static DisplayMode findDisplayMode(GraphicsDevice gd) {
    DisplayMode dms[] = gd.getDisplayModes();
    DisplayMode currentDM = gd.getDisplayMode();
    for (DisplayMode dm : dms) {
        if (!dm.equals(currentDM) &&
             dm.getRefreshRate() == currentDM.getRefreshRate())
        {
            // different from the current dm and refresh rate is the same
            // means that something else is different => more likely to
            // cause a DM change event
            return dm;
        }
    }
    return null;
}
 
Example 10
Project: openjdk-jdk8u-backup   File: X11GraphicsDevice.java    License: GNU General Public License v2.0 6 votes vote down vote up
private synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        return null;
    }
    DisplayMode[] modes = getDisplayModes();
    for (DisplayMode mode : modes) {
        if (dm.equals(mode) ||
            (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
             dm.getWidth() == mode.getWidth() &&
             dm.getHeight() == mode.getHeight() &&
             dm.getBitDepth() == mode.getBitDepth()))
        {
            return mode;
        }
    }
    return null;
}
 
Example 11
Project: jdk8u_jdk   File: DisplayModeChanger.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds a display mode that is different from the current display
 * mode and is likely to cause a display change event.
 */
private static DisplayMode findDisplayMode(GraphicsDevice gd) {
    DisplayMode dms[] = gd.getDisplayModes();
    DisplayMode currentDM = gd.getDisplayMode();
    for (DisplayMode dm : dms) {
        if (!dm.equals(currentDM) &&
             dm.getRefreshRate() == currentDM.getRefreshRate())
        {
            // different from the current dm and refresh rate is the same
            // means that something else is different => more likely to
            // cause a DM change event
            return dm;
        }
    }
    return null;
}
 
Example 12
Project: gcs   File: PDFRenderer.java    License: Mozilla Public License 2.0 6 votes vote down vote up
private boolean isBitonal(Graphics2D graphics)
{
    GraphicsConfiguration deviceConfiguration = graphics.getDeviceConfiguration();
    if (deviceConfiguration == null)
    {
        return false;
    }
    GraphicsDevice device = deviceConfiguration.getDevice();
    if (device == null)
    {
        return false;
    }
    DisplayMode displayMode = device.getDisplayMode();
    if (displayMode == null)
    {
        return false;
    }
    return displayMode.getBitDepth() == 1;
}
 
Example 13
Project: openjdk-jdk8u   File: X11GraphicsDevice.java    License: GNU General Public License v2.0 6 votes vote down vote up
private synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        return null;
    }
    DisplayMode[] modes = getDisplayModes();
    for (DisplayMode mode : modes) {
        if (dm.equals(mode) ||
            (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
             dm.getWidth() == mode.getWidth() &&
             dm.getHeight() == mode.getHeight() &&
             dm.getBitDepth() == mode.getBitDepth()))
        {
            return mode;
        }
    }
    return null;
}
 
Example 14
Project: jdk8u60   File: CheckDisplayModes.java    License: GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example 15
Project: jdk8u-jdk   File: DisplayModeChanger.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds a display mode that is different from the current display
 * mode and is likely to cause a display change event.
 */
private static DisplayMode findDisplayMode(GraphicsDevice gd) {
    DisplayMode dms[] = gd.getDisplayModes();
    DisplayMode currentDM = gd.getDisplayMode();
    for (DisplayMode dm : dms) {
        if (!dm.equals(currentDM) &&
             dm.getRefreshRate() == currentDM.getRefreshRate())
        {
            // different from the current dm and refresh rate is the same
            // means that something else is different => more likely to
            // cause a DM change event
            return dm;
        }
    }
    return null;
}
 
Example 16
Project: jdk8u60   File: DisplayModeChanger.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds a display mode that is different from the current display
 * mode and is likely to cause a display change event.
 */
private static DisplayMode findDisplayMode(GraphicsDevice gd) {
    DisplayMode dms[] = gd.getDisplayModes();
    DisplayMode currentDM = gd.getDisplayMode();
    for (DisplayMode dm : dms) {
        if (!dm.equals(currentDM) &&
             dm.getRefreshRate() == currentDM.getRefreshRate())
        {
            // different from the current dm and refresh rate is the same
            // means that something else is different => more likely to
            // cause a DM change event
            return dm;
        }
    }
    return null;
}
 
Example 17
Project: dragonwell8_jdk   File: CGraphicsDevice.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setDisplayMode(final DisplayMode dm) {
    if (dm == null) {
        throw new IllegalArgumentException("Invalid display mode");
    }
    if (!Objects.equals(dm, getDisplayMode())) {
        nativeSetDisplayMode(displayID, dm.getWidth(), dm.getHeight(),
                dm.getBitDepth(), dm.getRefreshRate());
        if (isFullScreenSupported() && getFullScreenWindow() != null) {
            getFullScreenWindow().setSize(dm.getWidth(), dm.getHeight());
        }
    }
}
 
Example 18
Project: openjdk-jdk8u-backup   File: Win32GraphicsDevice.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized DisplayMode[] getDisplayModes() {
    ArrayList modes = new ArrayList();
    enumDisplayModes(screen, modes);
    int listSize = modes.size();
    DisplayMode[] retArray = new DisplayMode[listSize];
    for (int i = 0; i < listSize; i++) {
        retArray[i] = (DisplayMode)modes.get(i);
    }
    return retArray;
}
 
Example 19
Project: hottub   File: X11GraphicsDevice.java    License: GNU General Public License v2.0 5 votes vote down vote up
private DisplayMode getDefaultDisplayMode() {
    GraphicsConfiguration gc = getDefaultConfiguration();
    Rectangle r = gc.getBounds();
    return new DisplayMode(r.width, r.height,
                           DisplayMode.BIT_DEPTH_MULTI,
                           DisplayMode.REFRESH_RATE_UNKNOWN);
}
 
Example 20
Project: openjdk-jdk8u-backup   File: Win32GraphicsDevice.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void windowIconified(WindowEvent e) {
    // restore the default display mode for this device
    DisplayMode ddm = device.defaultDisplayMode;
    if (ddm != null) {
        dm = device.getDisplayMode();
        device.setDisplayMode(ddm);
    }
}
 
Example 21
Project: openjdk-jdk8u-backup   File: AltTabCrashTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
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())
        {
            // found a mode which has the same dimensions but different
            // depth
            return dm;
        }
        if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI &&
            (dm.getWidth() != currentDM.getWidth() ||
             dm.getHeight() != currentDM.getHeight()))
        {
            // found a mode which has the same depth but different
            // dimensions
            return dm;
        }
    }

    return null;
}
 
Example 22
Project: jdk8u_jdk   File: AltTabCrashTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
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())
        {
            // found a mode which has the same dimensions but different
            // depth
            return dm;
        }
        if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI &&
            (dm.getWidth() != currentDM.getWidth() ||
             dm.getHeight() != currentDM.getHeight()))
        {
            // found a mode which has the same depth but different
            // dimensions
            return dm;
        }
    }

    return null;
}
 
Example 23
Project: dragonwell8_jdk   File: X11GraphicsDevice.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized DisplayMode[] getDisplayModes() {
    if (!isFullScreenSupported()) {
        return super.getDisplayModes();
    }
    ArrayList<DisplayMode> modes = new ArrayList<DisplayMode>();
    enumDisplayModes(screen, modes);
    DisplayMode[] retArray = new DisplayMode[modes.size()];
    return modes.toArray(retArray);
}
 
Example 24
Project: jdk8u-jdk   File: AltTabCrashTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
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())
        {
            // found a mode which has the same dimensions but different
            // depth
            return dm;
        }
        if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI &&
            (dm.getWidth() != currentDM.getWidth() ||
             dm.getHeight() != currentDM.getHeight()))
        {
            // found a mode which has the same depth but different
            // dimensions
            return dm;
        }
    }

    return null;
}
 
Example 25
Project: openjdk-8-source   File: Win32GraphicsDevice.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void setDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        super.setDisplayMode(dm);
        return;
    }
    if (dm == null || (dm = getMatchingDisplayMode(dm)) == null) {
        throw new IllegalArgumentException("Invalid display mode");
    }
    if (getDisplayMode().equals(dm)) {
        return;
    }
    Window w = getFullScreenWindow();
    if (w != null) {
        WWindowPeer peer = (WWindowPeer)w.getPeer();
        configDisplayMode(screen, peer, dm.getWidth(), dm.getHeight(),
            dm.getBitDepth(), dm.getRefreshRate());
        // resize the fullscreen window to the dimensions of the new
        // display mode
        Rectangle screenBounds = getDefaultConfiguration().getBounds();
        w.setBounds(screenBounds.x, screenBounds.y,
                    dm.getWidth(), dm.getHeight());
        // Note: no call to replaceSurfaceData is required here since
        // replacement will be caused by an upcoming display change event
    } else {
        throw new IllegalStateException("Must be in fullscreen mode " +
                                        "in order to set display mode");
    }
}
 
Example 26
Project: dragonwell8_jdk   File: DisplayChangeVITest.java    License: GNU General Public License v2.0 5 votes vote down vote up
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();
    }
}
 
Example 27
Project: dragonwell8_jdk   File: AltTabCrashTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
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())
        {
            // found a mode which has the same dimensions but different
            // depth
            return dm;
        }
        if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI &&
            (dm.getWidth() != currentDM.getWidth() ||
             dm.getHeight() != currentDM.getHeight()))
        {
            // found a mode which has the same depth but different
            // dimensions
            return dm;
        }
    }

    return null;
}
 
Example 28
Project: Pixie   File: ScreenResolution.java    License: MIT License 5 votes vote down vote up
/**
 * Constructor where the resolution is computed.
 *
 * @param comp - the frame of the gui - needed to get the resolution of the screen where the app is showed
 */
public ScreenResolution(Component comp) {
    //set the current screen resolution                
    GraphicsConfiguration graphicsCfg = comp.getGraphicsConfiguration();
    DisplayMode displayMode = graphicsCfg.getDevice().getDisplayMode();
    resolution = new Dimension(displayMode.getWidth(), displayMode.getHeight());
}
 
Example 29
Project: openjdk-jdk8u-backup   File: X11GraphicsDevice.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized DisplayMode[] getDisplayModes() {
    if (!isFullScreenSupported()) {
        return super.getDisplayModes();
    }
    ArrayList<DisplayMode> modes = new ArrayList<DisplayMode>();
    enumDisplayModes(screen, modes);
    DisplayMode[] retArray = new DisplayMode[modes.size()];
    return modes.toArray(retArray);
}
 
Example 30
Project: hottub   File: CGraphicsDevice.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setDisplayMode(final DisplayMode dm) {
    if (dm == null) {
        throw new IllegalArgumentException("Invalid display mode");
    }
    if (!Objects.equals(dm, getDisplayMode())) {
        nativeSetDisplayMode(displayID, dm.getWidth(), dm.getHeight(),
                dm.getBitDepth(), dm.getRefreshRate());
        if (isFullScreenSupported() && getFullScreenWindow() != null) {
            getFullScreenWindow().setSize(dm.getWidth(), dm.getHeight());
        }
    }
}
 
Example 31
Project: TencentKona-8   File: Win32GraphicsDevice.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized DisplayMode[] getDisplayModes() {
    ArrayList modes = new ArrayList();
    enumDisplayModes(screen, modes);
    int listSize = modes.size();
    DisplayMode[] retArray = new DisplayMode[listSize];
    for (int i = 0; i < listSize; i++) {
        retArray[i] = (DisplayMode)modes.get(i);
    }
    return retArray;
}
 
Example 32
Project: openjdk-jdk8u   File: X11GraphicsDevice.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized DisplayMode[] getDisplayModes() {
    if (!isFullScreenSupported()) {
        return super.getDisplayModes();
    }
    ArrayList<DisplayMode> modes = new ArrayList<DisplayMode>();
    enumDisplayModes(screen, modes);
    DisplayMode[] retArray = new DisplayMode[modes.size()];
    return modes.toArray(retArray);
}
 
Example 33
Project: openjdk-8   File: FullScreenInsets.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void testWindowBounds(final DisplayMode dm, final Window w) {
    if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
        System.err.println(" Wrong window bounds:" +
                           " Expected: width = " + dm.getWidth()
                           + ", height = " + dm.getHeight() + " Actual: "
                           + w.getSize());
        passed = false;
    }
}
 
Example 34
Project: openjdk-jdk9   File: AltTabCrashTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
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())
        {
            // found a mode which has the same dimensions but different
            // depth
            return dm;
        }
        if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI &&
            (dm.getWidth() != currentDM.getWidth() ||
             dm.getHeight() != currentDM.getHeight()))
        {
            // found a mode which has the same depth but different
            // dimensions
            return dm;
        }
    }

    return null;
}
 
Example 35
Project: openjdk-jdk8u   File: X11GraphicsDevice.java    License: GNU General Public License v2.0 5 votes vote down vote up
private DisplayMode getDefaultDisplayMode() {
    GraphicsConfiguration gc = getDefaultConfiguration();
    Rectangle r = gc.getBounds();
    return new DisplayMode(r.width, r.height,
                           DisplayMode.BIT_DEPTH_MULTI,
                           DisplayMode.REFRESH_RATE_UNKNOWN);
}
 
Example 36
Project: openjdk-jdk8u   File: Win32GraphicsDevice.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void windowIconified(WindowEvent e) {
    // restore the default display mode for this device
    DisplayMode ddm = device.defaultDisplayMode;
    if (ddm != null) {
        dm = device.getDisplayMode();
        device.setDisplayMode(ddm);
    }
}
 
Example 37
Project: openjdk-8   File: X11GraphicsDevice.java    License: GNU General Public License v2.0 5 votes vote down vote up
private DisplayMode getDefaultDisplayMode() {
    GraphicsConfiguration gc = getDefaultConfiguration();
    Rectangle r = gc.getBounds();
    return new DisplayMode(r.width, r.height,
                           DisplayMode.BIT_DEPTH_MULTI,
                           DisplayMode.REFRESH_RATE_UNKNOWN);
}
 
Example 38
Project: jdk8u-jdk   File: FullScreenInsets.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void testWindowBounds(final DisplayMode dm, final Window w) {
    if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
        System.err.println(" Wrong window bounds:" +
                           " Expected: width = " + dm.getWidth()
                           + ", height = " + dm.getHeight() + " Actual: "
                           + w.getSize());
        passed = false;
    }
}
 
Example 39
Project: openjdk-jdk8u   File: AltTabCrashTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
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())
        {
            // found a mode which has the same dimensions but different
            // depth
            return dm;
        }
        if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI &&
            (dm.getWidth() != currentDM.getWidth() ||
             dm.getHeight() != currentDM.getHeight()))
        {
            // found a mode which has the same depth but different
            // dimensions
            return dm;
        }
    }

    return null;
}
 
Example 40
Project: TencentKona-8   File: FullScreenInsets.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void testWindowBounds(final DisplayMode dm, final Window w) {
    if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
        System.err.println(" Wrong window bounds:" +
                           " Expected: width = " + dm.getWidth()
                           + ", height = " + dm.getHeight() + " Actual: "
                           + w.getSize());
        passed = false;
    }
}