java.awt.DisplayMode Java Examples
The following examples show how to use
java.awt.DisplayMode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: D3DGraphicsDevice.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@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 #2
Source File: DisplayModeChanger.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * 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 #3
Source File: X11GraphicsDevice.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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 #4
Source File: CheckDisplayModes.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
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 #5
Source File: X11GraphicsDevice.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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 #6
Source File: DisplayModeChanger.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * 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
Source File: CheckDisplayModes.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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 #8
Source File: CheckDisplayModes.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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 #9
Source File: CheckDisplayModes.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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 #10
Source File: PDFRenderer.java From gcs with Mozilla Public License 2.0 | 6 votes |
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 #11
Source File: Win32GraphicsDevice.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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 #12
Source File: DisplayModeChanger.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * 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 #13
Source File: DisplayModeChanger.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * 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 #14
Source File: D3DGraphicsDevice.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@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 #15
Source File: Win32GraphicsDevice.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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 #16
Source File: DisplayModeChanger.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * 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
Source File: Win32GraphicsDevice.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@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 #18
Source File: X11GraphicsDevice.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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 #19
Source File: ScreenResolution.java From Pixie with MIT License | 5 votes |
/** * 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 #20
Source File: FullScreenInsets.java From hottub with GNU General Public License v2.0 | 5 votes |
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 #21
Source File: AltTabCrashTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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
Source File: FullScreenInsets.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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 #23
Source File: DisplayChangeVITest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 #24
Source File: FullScreenInsets.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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 #25
Source File: FullScreenInsets.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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 #26
Source File: X11GraphicsDevice.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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 #27
Source File: X11GraphicsDevice.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@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 #28
Source File: CGraphicsDevice.java From hottub with GNU General Public License v2.0 | 5 votes |
@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 #29
Source File: Win32GraphicsDevice.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@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 #30
Source File: X11GraphicsDevice.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@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); }