List of usage examples for java.awt GraphicsEnvironment getDefaultScreenDevice
public abstract GraphicsDevice getDefaultScreenDevice() throws HeadlessException;
From source file:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java
/** * * @return/*from w w w . j a v a2 s . c o m*/ */ public GraphicsConfiguration getGraphicsConfiguration() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); return gs.getDefaultConfiguration(); }
From source file:Filter3dTest.java
/** * Creates a new ScreenManager object./*from w w w.j a v a 2s . c o m*/ */ public ScreenManager() { GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment(); device = environment.getDefaultScreenDevice(); }
From source file:com.freedomotic.jfrontend.MainWindow.java
private void setFullscreenMode() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); if (gd.isFullScreenSupported()) { frameMap.setVisible(false);/*w w w .ja v a 2s . co m*/ menuBar.setVisible(false); frameMap.dispose(); frameClient.setVisible(false); frameClient.dispose(); desktopPane.removeAll(); desktopPane.moveToBack(this); setVisible(false); dispose(); setUndecorated(true); setResizable(false); setLayout(new BorderLayout()); drawer = master.createRenderer(drawer.getCurrEnv()); if (drawer != null) { setDrawer(drawer); } else { LOG.error( "Unable to create a drawer to render the environment on the desktop frontend in fullscreen mode"); } add(drawer); Rectangle maximumWindowBounds = ge.getMaximumWindowBounds(); setBounds(maximumWindowBounds); drawer.setVisible(true); this.setVisible(true); gd.setFullScreenWindow(this); isFullscreen = true; Callout callout = new Callout(this.getClass().getCanonicalName(), "info", i18n.msg("esc_to_exit_fullscreen"), 100, 100, 0, 5000); drawer.createCallout(callout); } }
From source file:com.actelion.research.table.view.JVisualization.java
/** * Checks HiDPI support for Java 7 and newer. * * @return factor != 1 if HiDPI feature is enabled. *//* w w w . ja v a 2s . co m*/ public static float getContentScaleFactor() { /* with Apple-Java-6 this was: Object sContentScaleFactorObject = Toolkit.getDefaultToolkit().getDesktopProperty("apple.awt.contentScaleFactor"); private static final float sRetinaFactor = (sContentScaleFactorObject == null) ? 1f : ((Float)sContentScaleFactorObject).floatValue(); */ if (sRetinaFactor != -1f) return sRetinaFactor; sRetinaFactor = 1f; GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice device = env.getDefaultScreenDevice(); try { Field field = device.getClass().getDeclaredField("scale"); if (field != null) { field.setAccessible(true); Object scale = field.get(device); if (scale instanceof Integer) { sRetinaFactor = (Integer) scale; } } } catch (Throwable e) { } return sRetinaFactor; }
From source file:net.team2xh.crt.gui.util.GUIToolkit.java
/** * Provides a BufferedImage in the format most compatible with current graphics card. * * @param w Width of the image/*from w w w . ja v a 2s . com*/ * @param h Height of the image * @return Optimized BufferedImage */ public static BufferedImage getEfficientBuffer(int w, int h) { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice device = env.getDefaultScreenDevice(); GraphicsConfiguration config = device.getDefaultConfiguration(); return config.createCompatibleImage(w, h, Transparency.TRANSLUCENT); }
From source file:org.github.jipsg.sanselan.ManagedImageBufferedImageFactory.java
public BufferedImage getColorBufferedImage(final int width, final int height, final boolean hasAlpha) { final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice gd = ge.getDefaultScreenDevice(); final GraphicsConfiguration gc = gd.getDefaultConfiguration(); return gc.createCompatibleImage(width, height, Transparency.TRANSLUCENT); }
From source file:org.jas.dnd.Jdk6u10TransparencyManager.java
@Override public GraphicsConfiguration getTranslucencyCapableGC() { GraphicsEnvironment localGraphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice defaultScreenDevice = localGraphicsEnvironment.getDefaultScreenDevice(); GraphicsConfiguration translucencyCapableGC = defaultScreenDevice.getDefaultConfiguration(); if (!isTranslucencyCapable(translucencyCapableGC)) { translucencyCapableGC = null;/*from w w w. ja v a 2 s .c o m*/ log.info("Default graphics configuration does not support translucency"); GraphicsEnvironment env = localGraphicsEnvironment; GraphicsDevice[] devices = env.getScreenDevices(); for (int i = 0; i < devices.length && translucencyCapableGC == null; i++) { GraphicsConfiguration[] configs = devices[i].getConfigurations(); for (int j = 0; j < configs.length && translucencyCapableGC == null; j++) { if (isTranslucencyCapable(configs[j])) { translucencyCapableGC = configs[j]; } } } } if (translucencyCapableGC == null) { log.warn("Translucency capable graphics configuration not found"); } return translucencyCapableGC; }
From source file:org.yccheok.jstock.gui.Utils.java
public static BufferedImage toBufferedImage(Image image) { if (image instanceof BufferedImage) { return (BufferedImage) image; }//from w ww . ja v a 2 s.co m // This code ensures that all the pixels in the image are loaded image = new ImageIcon(image).getImage(); // Determine if the image has transparent pixels; for this method's // implementation, see e661 Determining If an Image Has Transparent Pixels boolean hasAlpha = hasAlpha(image); // Create a buffered image with a format that's compatible with the screen BufferedImage bimage = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { // Determine the type of transparency of the new buffered image int transparency = Transparency.OPAQUE; if (hasAlpha) { transparency = Transparency.BITMASK; } // Create the buffered image GraphicsDevice gs = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gs.getDefaultConfiguration(); bimage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency); } catch (HeadlessException e) { // The system does not have a screen } if (bimage == null) { // Create a buffered image using the default color model int type = BufferedImage.TYPE_INT_RGB; if (hasAlpha) { type = BufferedImage.TYPE_INT_ARGB; } bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); } // Copy image to buffered image Graphics g = bimage.createGraphics(); // Paint the image onto the buffered image g.drawImage(image, 0, 0, null); g.dispose(); return bimage; }
From source file:util.ui.UiUtilities.java
/** * Centers a window to its parent frame and shows it. * <p>/*ww w.jav a2s . c om*/ * If the window has no parent frame it will be centered to the screen. * * @param win * The window to center and show. */ public static void centerAndShow(Window win) { Dimension wD = win.getSize(); Dimension frameD; Point framePos; Frame frame = JOptionPane.getFrameForComponent(win); // Should this window be centered to its parent frame? boolean centerToParentFrame = (frame != null) && (frame != win) && frame.isShowing(); // Center to parent frame or to screen if (centerToParentFrame) { frameD = frame.getSize(); framePos = frame.getLocation(); } else { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); // dual head, use first screen if (ge.getScreenDevices().length > 1) { try { GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration config = gd.getConfigurations()[0]; frameD = config.getBounds().getSize(); framePos = config.getBounds().getLocation(); } catch (RuntimeException e) { frameD = Toolkit.getDefaultToolkit().getScreenSize(); framePos = new Point(0, 0); } } // single screen only else { frameD = Toolkit.getDefaultToolkit().getScreenSize(); framePos = new Point(0, 0); } } Point wPos = new Point(framePos.x + (frameD.width - wD.width) / 2, framePos.y + (frameD.height - wD.height) / 2); wPos.x = Math.max(0, wPos.x); // Make x > 0 wPos.y = Math.max(0, wPos.y); // Make y > 0 win.setLocation(wPos); win.setVisible(true); }
From source file:zz.pseas.ghost.utils.BrowserUtil.java
public static BufferedImage toBufferedImage(Image image) { if (image instanceof BufferedImage) { return (BufferedImage) image; }/* w ww . j a v a 2 s. c om*/ // This code ensures that all the pixels in the image are loaded image = new ImageIcon(image).getImage(); BufferedImage bimage = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { int transparency = Transparency.OPAQUE; GraphicsDevice gs = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gs.getDefaultConfiguration(); bimage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency); } catch (HeadlessException e) { // The system does not have a screen } if (bimage == null) { // Create a buffered image using the default color model int type = BufferedImage.TYPE_INT_RGB; bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); } // Copy image to buffered image Graphics g = bimage.createGraphics(); // Paint the image onto the buffered image g.drawImage(image, 0, 0, null); g.dispose(); return bimage; }