@Override public String getName() { return device.getIDstring(); }
gd.toString() + " " + gd.getIDstring())); GraphicsConfiguration[] gc = gd.getConfigurations();
/** * Get the identifier of the screen. * * @return ID of the screen */ public String getName() { return screen.getIDstring(); }
public AWTGraphicsDevice(final GraphicsDevice device, final int unitID) { super(NativeWindowFactory.TYPE_AWT, device.getIDstring(), unitID); this.device = device; }
public String getMonitorID() { return graphicsDevice.getIDstring(); }
public static String[] getScreenDescriptions() { GraphicsDevice[] screens = getScreenDevices(); String[] descriptions = new String[screens.length]; for (int i = 0; i < screens.length; i++) { descriptions[i] = screens[i].getIDstring(); } return descriptions; } public static DisplayMode getDisplayMode(int screenNumber) {
static void appendScreenInfo(StringWriter sw) { sw.append("Screen info:\n"); sw.append("------------\n\n"); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); sw.append("screen size - width = "+screenSize.width+"\n"); sw.append("screen size - height = "+screenSize.height+"\n"); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); for (int i=0;i<gs.length;i++) { GraphicsDevice g =gs[i]; sw.append("graphics device ["+i+"] = "+g.getIDstring()+"\n"); } sw.append("default graphics device = "+ge.getDefaultScreenDevice().getIDstring()+"\n"); sw.append("\n\n"); }
public class ScreenTest { public static void main(String[] args) { GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment(); for(GraphicsDevice device : environment.getScreenDevices()) { System.out.println(device.getIDstring()); for(GraphicsConfiguration configuration : device.getConfigurations()) { System.out.println(configuration.getBounds()); } System.out.println(); } } }
public GraphicsDevice getScreenDevice() { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final String id = getValue(KEY_MONITOR_ID); if (id != null) { for (final GraphicsDevice gd : ge.getScreenDevices()) { if (gd.getIDstring().equals(id)) { return gd; } } } return ge.getDefaultScreenDevice(); } }
private static Dimension getScreenResolution() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] screenDevices = ge.getScreenDevices(); for (int i = 0; i < screenDevices.length; i++) { System.out.println(screenDevices[i].getIDstring()); DisplayMode dm = screenDevices[i].getDisplayMode(); int screenWidth = dm.getWidth(); int screenHeight = dm.getHeight(); System.out.println("Cake: " + screenWidth + " " + screenHeight); return new Dimension(screenWidth, screenHeight); } return null; }
public static void showOnScreen(Window frame) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gd = ge.getScreenDevices(); final GraphicsDevice frameDevice = frame.getParent().getGraphicsConfiguration().getDevice(); for (GraphicsDevice graphicsDevice : gd) { if (frameDevice.equals(graphicsDevice) || frameDevice.getIDstring().equals(graphicsDevice.getIDstring())) { final Rectangle monitorBounds = graphicsDevice.getDefaultConfiguration().getBounds(); final int x = monitorBounds.x + (monitorBounds.width - frame.getWidth()) /2; final int y = monitorBounds.y + (monitorBounds.height - frame.getHeight()) / 2; frame.setLocation(x, y); } } }
private void putPreferencesLocation() { int x = frame.getLocation().x; int y = frame.getLocation().y; if(getPreferencesX() == x && getPreferencesY() == y) return; preferences.putInt(X_PREFERENCE, x); preferences.putInt(Y_PREFERENCE, y); log.info("Storing frame location as " + frame.getLocation()); String deviceId = frame.getGraphicsConfiguration().getDevice().getIDstring(); preferences.put(DEVICE_PREFERENCE, deviceId); log.info("Storing graphics device as " + deviceId); }
private static Map desktopHints(Graphics2D g2) { if (isPrinting(g2)) { return null; } Toolkit toolkit = Toolkit.getDefaultToolkit(); GraphicsDevice device = g2.getDeviceConfiguration().getDevice(); String deviceId = device.getIDstring(); if (!desktopHintsCache.containsKey(deviceId)) { Map desktopHints = (Map) toolkit .getDesktopProperty(PROP_DESKTOPHINTS + '.' + device.getIDstring()); if (desktopHints == null) { desktopHints = (Map) toolkit .getDesktopProperty(PROP_DESKTOPHINTS); } // It is possible to get a non-empty map but with disabled AA. if (desktopHints != null) { Object aaHint = desktopHints .get(RenderingHints.KEY_TEXT_ANTIALIASING); if ((aaHint == RenderingHints.VALUE_TEXT_ANTIALIAS_OFF) || (aaHint == RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT)) { desktopHints = null; } } if (desktopHints == null) desktopHints = new HashMap(); desktopHintsCache.put(deviceId, desktopHints); } return desktopHintsCache.get(deviceId); }
public static void screenMultipleMonitors() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gDevs = ge.getScreenDevices(); for (GraphicsDevice gDev : gDevs) { DisplayMode mode = gDev.getDisplayMode(); Rectangle bounds = gDev.getDefaultConfiguration().getBounds(); System.out.println(gDev.getIDstring()); System.out.println("Min : (" + bounds.getMinX() + "," + bounds.getMinY() + ") ;Max : (" + bounds.getMaxX() + "," + bounds.getMaxY() + ")"); System.out.println("Width : " + mode.getWidth() + " ; Height :" + mode.getHeight()); try { Robot robot = new Robot(); BufferedImage image = robot.createScreenCapture(new Rectangle((int) bounds.getMinX(), (int) bounds.getMinY(), (int) bounds.getWidth(), (int) bounds.getHeight())); ImageIO.write(image, "png", new File("src/res/screen_" + gDev.getIDstring().replace("\\", "") + ".png")); } catch (AWTException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
private static Map desktopHints(Graphics2D g2) { if (isPrinting(g2)) { return null; } Toolkit toolkit = Toolkit.getDefaultToolkit(); GraphicsDevice device = g2.getDeviceConfiguration().getDevice(); Map desktopHints = (Map) toolkit.getDesktopProperty( PROP_DESKTOPHINTS + '.' + device.getIDstring()); if (desktopHints == null) { desktopHints = (Map) toolkit.getDesktopProperty(PROP_DESKTOPHINTS); } // It is possible to get a non-empty map but with disabled AA. if (desktopHints != null) { Object aaHint = desktopHints.get(RenderingHints.KEY_TEXT_ANTIALIASING); if ( aaHint == RenderingHints.VALUE_TEXT_ANTIALIAS_OFF || aaHint == RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT) { desktopHints = null; } } return desktopHints; }
private static Map desktopHints(Graphics2D g2) { if (isPrinting(g2)) { return null; } Toolkit toolkit = Toolkit.getDefaultToolkit(); GraphicsDevice device = g2.getDeviceConfiguration().getDevice(); Map desktopHints = (Map) toolkit.getDesktopProperty( PROP_DESKTOPHINTS + '.' + device.getIDstring()); if (desktopHints == null) { desktopHints = (Map) toolkit.getDesktopProperty(PROP_DESKTOPHINTS); } // It is possible to get a non-empty map but with disabled AA. if (desktopHints != null) { Object aaHint = desktopHints.get(RenderingHints.KEY_TEXT_ANTIALIASING); if (aaHint == RenderingHints.VALUE_TEXT_ANTIALIAS_OFF || aaHint == RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT) { desktopHints = null; } } return desktopHints; }
protected void createFrame(String frameTitle, String iconName, JPanel contentPane, JButton defaultButton, JMenuBar menuBar) { GraphicsConfiguration gc = null; String deviceId = preferences.get(DEVICE_PREFERENCE, null); if (deviceId != null) { GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); for (GraphicsDevice device : devices) { if (deviceId.equals(device.getIDstring())) { gc = device.getDefaultConfiguration(); log.info("Graphics device is " + deviceId); break; } } } frame = new JFrame(frameTitle, gc); Image image = loadImage(iconName); if (isMac()) setDockIconImage(image); else frame.setIconImage(image); frame.setContentPane(contentPane); if (defaultButton != null) frame.getRootPane().setDefaultButton(defaultButton); if (menuBar != null) { frame.getRootPane().setJMenuBar(menuBar); getContext().setMenuBar(menuBar); } }
log.info("GraphicsDevices: " + devices.length); for (GraphicsDevice device : devices) { log.info(" GraphicsDevice - id: " + device.getIDstring() + ", type: " + device.getType() + ", device: " + device);
/** * Returns the desktop hints for the specified graphics context. * * @param g2 * Graphics context. * @return The desktop hints for the specified graphics context. */ private static Map desktopHints(Graphics2D g2) { if (isPrinting(g2)) { return null; } Toolkit toolkit = Toolkit.getDefaultToolkit(); GraphicsDevice device = g2.getDeviceConfiguration().getDevice(); Map desktopHints = (Map) toolkit.getDesktopProperty(PROP_DESKTOPHINTS + '.' + device.getIDstring()); if (desktopHints == null) { desktopHints = (Map) toolkit.getDesktopProperty(PROP_DESKTOPHINTS); } // It is possible to get a non-empty map but with disabled AA. if (desktopHints != null) { Object aaHint = desktopHints .get(RenderingHints.KEY_TEXT_ANTIALIASING); if ((aaHint == RenderingHints.VALUE_TEXT_ANTIALIAS_OFF) || (aaHint == RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT)) { desktopHints = null; } } return desktopHints; }
setTitle( getGraphicsConfiguration().getDevice().getIDstring());