java.awt.GraphicsDevice Java Examples
The following examples show how to use
java.awt.GraphicsDevice.
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: JavaInfo.java From haxademic with MIT License | 6 votes |
public static void printDisplayInfo() { int g = 0; for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) { out.println("graphics device #"+(++g)+": "+gd.getIDstring()+" type "+gd.getType()); out.println("\tavailable accelerated memory " + gd.getAvailableAcceleratedMemory()); int c = 0; for (GraphicsConfiguration gc : gd.getConfigurations()) { out.println("\tgraphics configuration #"+(++c)+":"); out.println("\t\twidth "+gc.getBounds().getWidth()+" height "+gc.getBounds().getHeight()); out.println("\t\tfull screen "+gc.getBufferCapabilities().isFullScreenRequired()); ImageCapabilities ic = gc.getImageCapabilities(); out.println("\t\tis accelerated "+ic.isAccelerated()); } DisplayMode dm = gd.getDisplayMode(); out.println("\tdisplay mode bit width "+dm.getWidth()+" height "+dm.getHeight()+" bit depth "+dm.getBitDepth()+" refresh rate "+dm.getRefreshRate()); int m = 0; for (DisplayMode d : gd.getDisplayModes()) out.println("\talt display mode #"+(++m)+" bit width "+d.getWidth()+" height "+d.getHeight()+" bit depth "+d.getBitDepth()+" refresh rate "+d.getRefreshRate()); } }
Example #2
Source File: DisplayModeChanger.java From openjdk-jdk8u 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: DisplayChangeVITest.java From hottub with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { DisplayChangeVITest test = new DisplayChangeVITest(); GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice(); if (gd.isFullScreenSupported()) { gd.setFullScreenWindow(test); Thread t = new Thread(test); t.run(); synchronized (lock) { while (!done) { try { lock.wait(50); } catch (InterruptedException ex) { ex.printStackTrace(); } } } System.err.println("Test Passed."); } else { System.err.println("Full screen not supported. Test passed."); } }
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(); 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
Source File: bug8071705.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) { GraphicsDevice correctDevice = null; if (devices.length < 2) { return correctDevice; } Toolkit toolkit = Toolkit.getDefaultToolkit(); Rectangle screenBounds = new Rectangle(toolkit.getScreenSize()); int halfScreen = screenBounds.height/2; for(int i = 0; i < devices.length; i++) { if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) { GraphicsConfiguration conf = devices[i].getDefaultConfiguration(); Rectangle bounds = conf.getBounds(); if (bounds.y >= halfScreen) { // found correctDevice = devices[i]; break; } } } return correctDevice; }
Example #6
Source File: Canvas.java From freecol with GNU General Public License v2.0 | 6 votes |
/** * Determine whether to use full screen or windowed mode. * * @param gd The {@code GraphicsDevice} to display to. * @param desiredSize An optional window {@code Dimension}. * @return Null if full screen is to be used, otherwise a window * bounds {@code Rectangle} */ private static boolean checkWindowed(GraphicsDevice gd, Dimension desiredSize) { boolean ret; if (desiredSize == null) { if (gd.isFullScreenSupported()) { logger.info("Full screen mode used."); ret = false; } else { logger.warning("Full screen mode not supported."); System.err.println(Messages.message("client.fullScreen")); ret = true; } } else { logger.info("Windowed mode used."); ret = true; } return ret; }
Example #7
Source File: CPlatformLWWindow.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@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(); }
Example #8
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 #9
Source File: RobotMultiDPIScreenTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
static void initScreenBounds() { GraphicsDevice[] devices = GraphicsEnvironment .getLocalGraphicsEnvironment() .getScreenDevices(); screenBounds = new Rectangle[devices.length]; scales = new double[devices.length][2]; for (int i = 0; i < devices.length; i++) { GraphicsConfiguration gc = devices[i].getDefaultConfiguration(); screenBounds[i] = gc.getBounds(); AffineTransform tx = gc.getDefaultTransform(); scales[i][0] = tx.getScaleX(); scales[i][1] = tx.getScaleY(); } maxBounds = screenBounds[0]; for (int i = 0; i < screenBounds.length; i++) { maxBounds = maxBounds.union(screenBounds[i]); } }
Example #10
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 #11
Source File: bug8071705.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) { GraphicsDevice correctDevice = null; if (devices.length < 2) { return correctDevice; } Toolkit toolkit = Toolkit.getDefaultToolkit(); Rectangle screenBounds = new Rectangle(toolkit.getScreenSize()); int halfScreen = screenBounds.height/2; for(int i = 0; i < devices.length; i++) { if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) { GraphicsConfiguration conf = devices[i].getDefaultConfiguration(); Rectangle bounds = conf.getBounds(); if (bounds.y >= halfScreen) { // found correctDevice = devices[i]; break; } } } return correctDevice; }
Example #12
Source File: SplashScreen.java From freecol with GNU General Public License v2.0 | 6 votes |
/** * Initialize the splash screen. * * @param gd The {@code GraphicsDevice} to display on. * @param splashStream An {@code InputStream} to read content from. */ public SplashScreen(GraphicsDevice gd, InputStream splashStream) throws IOException { super(gd.getDefaultConfiguration()); BufferedImage im = ImageIO.read(splashStream); this.getContentPane().add(new JLabel(new ImageIcon(im))); this.pack(); this.setVisible(false); Point start = this.getLocation(); DisplayMode dm = gd.getDisplayMode(); int x = start.x + dm.getWidth()/2 - this.getWidth() / 2; int y = start.y + dm.getHeight()/2 - this.getHeight() / 2; this.setLocation(x, y); }
Example #13
Source File: DisplayChangeVITest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { DisplayChangeVITest test = new DisplayChangeVITest(); GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice(); if (gd.isFullScreenSupported()) { gd.setFullScreenWindow(test); Thread t = new Thread(test); t.run(); synchronized (lock) { while (!done) { try { lock.wait(50); } catch (InterruptedException ex) { ex.printStackTrace(); } } } System.err.println("Test Passed."); } else { System.err.println("Full screen not supported. Test passed."); } }
Example #14
Source File: bug8071705.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) { GraphicsDevice correctDevice = null; if (devices.length < 2) { return correctDevice; } Toolkit toolkit = Toolkit.getDefaultToolkit(); Rectangle screenBounds = new Rectangle(toolkit.getScreenSize()); int halfScreen = screenBounds.height/2; for(int i = 0; i < devices.length; i++) { if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) { GraphicsConfiguration conf = devices[i].getDefaultConfiguration(); Rectangle bounds = conf.getBounds(); if (bounds.y >= halfScreen) { // found correctDevice = devices[i]; break; } } } return correctDevice; }
Example #15
Source File: bug8071705.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) { GraphicsDevice correctDevice = null; if (devices.length < 2) { return correctDevice; } Toolkit toolkit = Toolkit.getDefaultToolkit(); Rectangle screenBounds = new Rectangle(toolkit.getScreenSize()); int halfScreen = screenBounds.height/2; for(int i = 0; i < devices.length; i++) { if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) { GraphicsConfiguration conf = devices[i].getDefaultConfiguration(); Rectangle bounds = conf.getBounds(); if (bounds.y >= halfScreen) { // found correctDevice = devices[i]; break; } } } return correctDevice; }
Example #16
Source File: bug8071705.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) { GraphicsDevice correctDevice = null; if (devices.length < 2) { return correctDevice; } Toolkit toolkit = Toolkit.getDefaultToolkit(); Rectangle screenBounds = new Rectangle(toolkit.getScreenSize()); int halfScreen = screenBounds.height/2; for(int i = 0; i < devices.length; i++) { if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) { GraphicsConfiguration conf = devices[i].getDefaultConfiguration(); Rectangle bounds = conf.getBounds(); if (bounds.y >= halfScreen) { // found correctDevice = devices[i]; break; } } } return correctDevice; }
Example #17
Source File: OpaqueImageToSurfaceBlitTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); VolatileImage vi = gc.createCompatibleVolatileImage(16, 16); vi.validate(gc); BufferedImage bi = new BufferedImage(2, 2, BufferedImage.TYPE_INT_RGB); int data[] = ((DataBufferInt)bi.getRaster().getDataBuffer()).getData(); data[0] = 0x0000007f; data[1] = 0x0000007f; data[2] = 0xff00007f; data[3] = 0xff00007f; Graphics2D g = vi.createGraphics(); g.setComposite(AlphaComposite.SrcOver.derive(0.999f)); g.drawImage(bi, 0, 0, null); bi = vi.getSnapshot(); if (bi.getRGB(0, 0) != bi.getRGB(1, 1)) { throw new RuntimeException("Test FAILED: color at 0x0 ="+ Integer.toHexString(bi.getRGB(0, 0))+" differs from 1x1 ="+ Integer.toHexString(bi.getRGB(1,1))); } System.out.println("Test PASSED."); }
Example #18
Source File: OpaqueImageToSurfaceBlitTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); VolatileImage vi = gc.createCompatibleVolatileImage(16, 16); vi.validate(gc); BufferedImage bi = new BufferedImage(2, 2, BufferedImage.TYPE_INT_RGB); int data[] = ((DataBufferInt)bi.getRaster().getDataBuffer()).getData(); data[0] = 0x0000007f; data[1] = 0x0000007f; data[2] = 0xff00007f; data[3] = 0xff00007f; Graphics2D g = vi.createGraphics(); g.setComposite(AlphaComposite.SrcOver.derive(0.999f)); g.drawImage(bi, 0, 0, null); bi = vi.getSnapshot(); if (bi.getRGB(0, 0) != bi.getRGB(1, 1)) { throw new RuntimeException("Test FAILED: color at 0x0 ="+ Integer.toHexString(bi.getRGB(0, 0))+" differs from 1x1 ="+ Integer.toHexString(bi.getRGB(1,1))); } System.out.println("Test PASSED."); }
Example #19
Source File: CGLSurfaceData.java From hottub with GNU General Public License v2.0 | 5 votes |
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(); } }
Example #20
Source File: SunGraphicsEnvironment.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Returns an array of all of the screen devices. */ public synchronized GraphicsDevice[] getScreenDevices() { GraphicsDevice[] ret = screens; if (ret == null) { int num = getNumScreens(); ret = new GraphicsDevice[num]; for (int i = 0; i < num; i++) { ret[i] = makeScreenDevice(i); } screens = ret; } return ret; }
Example #21
Source File: Win32GraphicsEnvironment.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public boolean isFlipStrategyPreferred(ComponentPeer peer) { GraphicsConfiguration gc; if (peer != null && (gc = peer.getGraphicsConfiguration()) != null) { GraphicsDevice gd = gc.getDevice(); if (gd instanceof D3DGraphicsDevice) { return ((D3DGraphicsDevice)gd).isD3DEnabledOnDevice(); } } return false; }
Example #22
Source File: TranslucentShapedFrameTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private void checkEffects() { GraphicsDevice gd = getGraphicsConfiguration().getDevice(); if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) { shapedCb.setEnabled(false); } if (!gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) { transparencySld.setEnabled(false); } if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) { nonOpaqueChb.setEnabled(false); } }
Example #23
Source File: SunGraphicsEnvironment.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Return the bounds of a GraphicsDevice, less its screen insets. * See also java.awt.GraphicsEnvironment.getUsableBounds(); */ public static Rectangle getUsableBounds(GraphicsDevice gd) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc); Rectangle usableBounds = gc.getBounds(); usableBounds.x += insets.left; usableBounds.y += insets.top; usableBounds.width -= (insets.left + insets.right); usableBounds.height -= (insets.top + insets.bottom); return usableBounds; }
Example #24
Source File: bug8071705.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { final CountDownLatch latch = new CountDownLatch(1); final boolean [] result = new boolean[1]; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JFrame frame = createGUI(); GraphicsDevice[] devices = checkScreens(); // check if we have more than one and if they are stacked // vertically GraphicsDevice device = checkConfigs(devices); if (device == null) { // just pass the test frame.dispose(); result[0] = true; latch.countDown(); } else { FrameListener listener = new FrameListener(device, latch, result); frame.addComponentListener(listener); frame.setVisible(true); } } }); latch.await(); if (result[0] == false) { throw new RuntimeException("popup menu rendered in wrong position"); } System.out.println("OK"); }
Example #25
Source File: RSLAPITest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); testGC(gc); if (failed) { throw new RuntimeException("Test FAILED. See err output for more"); } System.out.println("Test PASSED."); }
Example #26
Source File: TestCaseComponent.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
void showDebugDialog() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice defaultScreen = ge.getDefaultScreenDevice(); Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds(); pack(); setLocation((int) rect.getCenterX(), Canvas.Window.winStart.y); setAlwaysOnTop(true); setVisible(true); }
Example #27
Source File: Win32GraphicsEnvironment.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
protected GraphicsDevice makeScreenDevice(int screennum) { GraphicsDevice device = null; if (WindowsFlags.isD3DEnabled()) { device = D3DGraphicsDevice.createDevice(screennum); } if (device == null) { device = new Win32GraphicsDevice(screennum); } return device; }
Example #28
Source File: JavaInfo.java From haxademic with MIT License | 5 votes |
public static int totalScreenHeight() { int h = 0; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); for(GraphicsDevice curGs : gs) { DisplayMode dm = curGs.getDisplayMode(); h += dm.getHeight(); } return h; }
Example #29
Source File: TranslucentShapedFrameTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void checkEffects() { GraphicsDevice gd = getGraphicsConfiguration().getDevice(); if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) { shapedCb.setEnabled(false); } if (!gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) { transparencySld.setEnabled(false); } if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) { nonOpaqueChb.setEnabled(false); } }
Example #30
Source File: GLXSurfaceData.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static GLXGraphicsConfig getGC(X11ComponentPeer peer) { if (peer != null) { return (GLXGraphicsConfig)peer.getGraphicsConfiguration(); } else { // REMIND: this should rarely (never?) happen, but what if // default config is not GLX? GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = env.getDefaultScreenDevice(); return (GLXGraphicsConfig)gd.getDefaultConfiguration(); } }