public void setLocationAndPosition() { if (this.settings.loadWindowPos(this)) { return; } GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); DisplayMode mode = gd.getDisplayMode(); int w = mode.getWidth(); int h = mode.getHeight(); setLocation((int) (w * BORDER_RATIO), (int) (h * BORDER_RATIO)); setSize((int) (w * WINDOW_RATIO), (int) (h * WINDOW_RATIO)); }
public static DisplayMode getDesktopDisplayMode () { GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice device = genv.getDefaultScreenDevice(); java.awt.DisplayMode mode = device.getDisplayMode(); return new LwjglApplicationConfigurationDisplayMode(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getBitDepth()); }
public static DisplayMode getDesktopDisplayMode () { GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice device = genv.getDefaultScreenDevice(); java.awt.DisplayMode mode = device.getDisplayMode(); return new LwjglApplicationConfigurationDisplayMode(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getBitDepth()); }
public static DisplayMode[] getDisplayModes () { GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice device = genv.getDefaultScreenDevice(); java.awt.DisplayMode desktopMode = device.getDisplayMode(); java.awt.DisplayMode[] displayModes = device.getDisplayModes(); ArrayList<DisplayMode> modes = new ArrayList<DisplayMode>(); int idx = 0; for (java.awt.DisplayMode mode : displayModes) { boolean duplicate = false; for (int i = 0; i < modes.size(); i++) { if (modes.get(i).width == mode.getWidth() && modes.get(i).height == mode.getHeight() && modes.get(i).bitsPerPixel == mode.getBitDepth()) { duplicate = true; break; } } if (duplicate) continue; if (mode.getBitDepth() != desktopMode.getBitDepth()) continue; modes.add(new LwjglApplicationConfigurationDisplayMode(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode .getBitDepth())); } return modes.toArray(new DisplayMode[modes.size()]); } }
public static DisplayMode[] getDisplayModes () { GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice device = genv.getDefaultScreenDevice(); java.awt.DisplayMode desktopMode = device.getDisplayMode(); java.awt.DisplayMode[] displayModes = device.getDisplayModes(); ArrayList<DisplayMode> modes = new ArrayList<DisplayMode>(); int idx = 0; for (java.awt.DisplayMode mode : displayModes) { boolean duplicate = false; for (int i = 0; i < modes.size(); i++) { if (modes.get(i).width == mode.getWidth() && modes.get(i).height == mode.getHeight() && modes.get(i).bitsPerPixel == mode.getBitDepth()) { duplicate = true; break; } } if (duplicate) continue; if (mode.getBitDepth() != desktopMode.getBitDepth()) continue; modes.add(new LwjglApplicationConfigurationDisplayMode(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode .getBitDepth())); } return modes.toArray(new DisplayMode[modes.size()]); } }
/** * Returns every unique resolution from an array of <code>DisplayMode</code>s * where the resolution is greater than the configured minimums and the height * is less than the current screen resolution. */ private String[] getWindowedResolutions(DisplayMode[] modes) { int maxHeight = 0; int maxWidth = 0; for (int i = 0; i < modes.length; i++) { if (maxHeight < modes[i].getHeight()) { maxHeight = modes[i].getHeight(); } if (maxWidth < modes[i].getWidth()) { maxWidth = modes[i].getWidth(); } } return getResolutions(modes, maxHeight, maxWidth); }
/** * Returns every possible refresh rate for the given resolution. */ private static String[] getFrequencies(String resolution, DisplayMode[] modes) { ArrayList<String> freqs = new ArrayList<String>(4); for (int i = 0; i < modes.length; i++) { String res = modes[i].getWidth() + " x " + modes[i].getHeight(); String freq; if (modes[i].getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN) { freq = "???"; } else { freq = modes[i].getRefreshRate() + " Hz"; } if (res.equals(resolution) && !freqs.contains(freq)) { freqs.add(freq); } } String[] res = new String[freqs.size()]; freqs.toArray(res); return res; }
for (int i = 0; i < modes.length; i++) { int height = modes[i].getHeight(); int width = modes[i].getWidth(); if (width >= minWidth && height >= minHeight) { if (height >= heightLimit) {
/** * Returns every possible bit depth for the given resolution. */ private static String[] getDepths(String resolution, DisplayMode[] modes) { ArrayList<String> depths = new ArrayList<String>(4); for (int i = 0; i < modes.length; i++) { // Filter out all bit depths lower than 16 - Java incorrectly // reports // them as valid depths though the monitor does not support them if (modes[i].getBitDepth() < 16 && modes[i].getBitDepth() > 0) { continue; } String res = modes[i].getWidth() + " x " + modes[i].getHeight(); String depth = modes[i].getBitDepth() + " bpp"; if (res.equals(resolution) && !depths.contains(depth)) { depths.add(depth); } } if (depths.size() == 1 && depths.contains("-1 bpp")) { // add some default depths, possible system is multi-depth supporting depths.clear(); depths.add("24 bpp"); } String[] res = new String[depths.size()]; depths.toArray(res); return res; }
/** * Chooses the closest frequency to 60 Hz. * * @param resolution * @param modes * @return */ private static String getBestFrequency(String resolution, DisplayMode[] modes) { int closest = Integer.MAX_VALUE; int desired = 60; for (int i = 0; i < modes.length; i++) { String res = modes[i].getWidth() + " x " + modes[i].getHeight(); int freq = modes[i].getRefreshRate(); if (freq != DisplayMode.REFRESH_RATE_UNKNOWN && res.equals(resolution)) { if (Math.abs(freq - desired) < Math.abs(closest - desired)) { closest = modes[i].getRefreshRate(); } } } if (closest != Integer.MAX_VALUE) { return closest + " Hz"; } else { return null; } }
public FullscreenDisplayHandler() { gfxDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); displayMode = gfxDevice.getDisplayMode(); frame = new GridPanelFrame(displayMode.getWidth(), displayMode.getHeight()); MediaRenderer.APP.log( Level.INFO, "Enabling fullscreen handler (press ESC to exit) with resolution: " + displayMode.getWidth() + "x" + displayMode.getHeight() ); frame.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ESCAPE) MediaRenderer.APP.getMediaRenderer().stopAllMediaPlayers(); } public void keyReleased(KeyEvent keyEvent) { } public void keyTyped(KeyEvent keyEvent) { } }); }
public ScreenCaptureDevice(final GraphicsDevice device) { this.device = device; this.mode = device.getDisplayMode(); this.resolution = new Dimension(mode.getWidth(), mode.getHeight()); this.resolutions = new Dimension[] { this.resolution }; try { this.robot = new Robot(device); } catch (AWTException e) { throw new WebcamException("Unable to create robot", e); } LOG.trace("Screen device {} with resolution {} has been created", getName(), getResolution()); }
/** * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(DisplayMode a, DisplayMode b) { // Width if (a.getWidth() != b.getWidth()) { return (a.getWidth() > b.getWidth()) ? 1 : -1; } // Height if (a.getHeight() != b.getHeight()) { return (a.getHeight() > b.getHeight()) ? 1 : -1; } // Bit depth if (a.getBitDepth() != b.getBitDepth()) { return (a.getBitDepth() > b.getBitDepth()) ? 1 : -1; } // Refresh rate if (a.getRefreshRate() != b.getRefreshRate()) { return (a.getRefreshRate() > b.getRefreshRate()) ? 1 : -1; } // All fields are equal return 0; } }
} else if (wdIndex >= windowDefaults.length) { merged[mergedIndex] = modes[dmIndex++]; } else if (modes[dmIndex].getWidth() < windowDefaults[wdIndex].getWidth()) { merged[mergedIndex] = modes[dmIndex++]; } else if (modes[dmIndex].getWidth() == windowDefaults[wdIndex].getWidth()) { if (modes[dmIndex].getHeight() < windowDefaults[wdIndex].getHeight()) { merged[mergedIndex] = modes[dmIndex++];
/** * Get the ratio between the {@link #getCanvasSize() GUI canvas size} and the application main windows (if available) or the screen size. * @return the ratio between the {@link #getCanvasSize() GUI canvas size} and the application main windows (if available). * @see #getCanvasSize() */ public Vector2f getCanvasToWindowRatio() { if (environment != null){ if (environment.getApplication() != null){ if( ratio == null ) { ratio = new Vector2f(); Vector2f canvas = getCanvasSize(); int width = Integer.min(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode().getWidth(), environment.getApplication().getContext().getSettings().getWidth()); int height = Integer.min(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode().getHeight(), environment.getApplication().getContext().getSettings().getHeight()); ratio.x = Float.max(1f, canvas.x / width); ratio.y = Float.max(1f, canvas.y / height); } return ratio; } else { throw new IllegalStateException("VR GUI manager underlying environment is not attached to any application."); } } else { throw new IllegalStateException("VR GUI manager is not attached to any environment."); } }
int max = 0; for(java.awt.DisplayMode dm : VRdev.getDisplayModes()) { int check = dm.getHeight() + dm.getWidth() + dm.getRefreshRate() + dm.getBitDepth(); if( check > max ) { max = check; settings.setWidth(useDM.getWidth()); settings.setHeight(useDM.getHeight()); settings.setBitsPerPixel(useDM.getBitDepth());
int origWidth = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode().getWidth(); int origHeight = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode().getHeight(); long window = ((LwjglWindow)environment.getApplication().getContext()).getWindowHandle();
int max = 0; for(java.awt.DisplayMode dm : VRdev.getDisplayModes()) { int check = dm.getHeight() + dm.getWidth() + dm.getRefreshRate() + dm.getBitDepth(); if( check > max ) { max = check; settings.setWidth(useDM.getWidth()); settings.setHeight(useDM.getHeight()); settings.setBitsPerPixel(useDM.getBitDepth());
if (currentDisplayMode.getWidth() == settings.getWidth() && currentDisplayMode.getHeight() == settings.getHeight()) { if (currentDisplayMode.getBitDepth() == settings.getBitsPerPixel()) { new Object[]{gd.getDisplayMode().getWidth(), gd.getDisplayMode().getHeight(), gd.getDisplayMode().getBitDepth(),
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); // Get size of each screen for (int i=0; i<gs.length; i++) { DisplayMode dm = gs[i].getDisplayMode(); int screenWidth = dm.getWidth(); int screenHeight = dm.getHeight(); }