/** * Returns the device configuration associated with this * <code>Graphics2D</code>. * @return the device configuration */ public GraphicsConfiguration getDeviceConfiguration() { return GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice().getDefaultConfiguration(); }
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice device = env.getDefaultScreenDevice(); GraphicsConfiguration config = device.getDefaultConfiguration(); BufferedImage buffy = config.createCompatibleImage(width, height, Transparency.TRANSLUCENT);
public LwjglAWTInput (LwjglAWTCanvas lwjglAwtCanvas) { this.lwjglAwtCanvas = lwjglAwtCanvas; setListeners(lwjglAwtCanvas.getCanvas()); try { robot = new Robot(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()); } catch (HeadlessException e) { } catch (AWTException e) { } }
/** * Helps client code place components on the center of the screen. It * handles multiple monitor configuration correctly * * @param gconf the GraphicsConfiguration of the monitor * @param componentSize the size of the component * @return bounds of the centered component */ private static Rectangle findCenterBounds(GraphicsConfiguration gconf, Dimension componentSize) { if (gconf == null) { gconf = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); } Rectangle bounds = gconf.getBounds(); return new Rectangle( bounds.x + ((bounds.width - componentSize.width) / 2), bounds.y + ((bounds.height - componentSize.height) / 2), componentSize.width, componentSize.height ); }
public LwjglAWTInput (LwjglAWTCanvas lwjglAwtCanvas) { this.lwjglAwtCanvas = lwjglAwtCanvas; setListeners(lwjglAwtCanvas.getCanvas()); try { robot = new Robot(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()); } catch (HeadlessException e) { } catch (AWTException e) { } }
private BufferedImage scale(BufferedImage source,double ratio) { int w = (int) (source.getWidth() * ratio); int h = (int) (source.getHeight() * ratio); BufferedImage bi = getCompatibleImage(w, h); Graphics2D g2d = bi.createGraphics(); double xScale = (double) w / source.getWidth(); double yScale = (double) h / source.getHeight(); AffineTransform at = AffineTransform.getScaleInstance(xScale,yScale); g2d.drawRenderedImage(source, at); g2d.dispose(); return bi; } private BufferedImage getCompatibleImage(int w, int h) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); BufferedImage image = gc.createCompatibleImage(w, h); return image; }
static private ColorModel colorModel(int transparency) { ColorModel model; try { model = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice().getDefaultConfiguration() .getColorModel(transparency); } catch(HeadlessException he) { model = ColorModel.getRGBdefault(); } return model; }
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)); }
BufferedImage image = ImageIO.read ( url ); BufferedImage convertedImage = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment (); GraphicsDevice gd = ge.getDefaultScreenDevice (); GraphicsConfiguration gc = gd.getDefaultConfiguration (); convertedImage = gc.createCompatibleImage (image.getWidth (), image.getHeight (), image.getTransparency () ); Graphics2D g2d = convertedImage.createGraphics (); g2d.drawImage ( image, 0, 0, image.getWidth (), image.getHeight (), null ); g2d.dispose()
gconf = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
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 BufferedImage rotate(BufferedImage image, double angle) { double sin = Math.abs(Math.sin(angle)), cos = Math.abs(Math.cos(angle)); int w = image.getWidth(), h = image.getHeight(); int neww = (int)Math.floor(w*cos+h*sin), newh = (int) Math.floor(h * cos + w * sin); GraphicsConfiguration gc = getDefaultConfiguration(); BufferedImage result = gc.createCompatibleImage(neww, newh, Transparency.TRANSLUCENT); Graphics2D g = result.createGraphics(); g.translate((neww - w) / 2, (newh - h) / 2); g.rotate(angle, w / 2, h / 2); g.drawRenderedImage(image, null); g.dispose(); return result; } private static GraphicsConfiguration getDefaultConfiguration() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); return gd.getDefaultConfiguration(); }
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration(); BufferedImage bi = gc.createCompatibleImage(w, h);
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()); }
/** * Finds out the monitor where the user currently has the input focus. * This method is usually used to help the client code to figure out on * which monitor it should place newly created windows/frames/dialogs. * * @return the GraphicsConfiguration of the monitor which currently has the * input focus */ private static GraphicsConfiguration getCurrentGraphicsConfiguration() { Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); if (focusOwner != null) { Window w = SwingUtilities.getWindowAncestor(focusOwner); if (w != null) { return w.getGraphicsConfiguration(); } else { //#217737 - try to find the main window which could be placed in secondary screen for( Frame f : Frame.getFrames() ) { if( "NbMainWindow".equals(f.getName())) { //NOI18N return f.getGraphicsConfiguration(); } } } } return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); }
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()); }
} else { GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsConfiguration gc = genv.getDefaultScreenDevice().getDefaultConfiguration();
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()]); } }
GraphicsEnvironment.getLocalGraphicsEnvironment(); private final GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration(); private final Random r = new Random();
valid = true; } else { GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); valid = device.isFullScreenSupported();