.getScreenDevices () ) if ( gd.getType () == GraphicsDevice.TYPE_RASTER_SCREEN )
graphics.getDeviceConfiguration().getDevice() != null) deviceType = graphics.getDeviceConfiguration().getDevice().getType();
public static GraphicsConfiguration getGraphicsDeviceConfig(Point p) { GraphicsConfiguration gc = null; // Try to find GraphicsConfiguration, that includes mouse // pointer position GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gd = ge.getScreenDevices(); for (int i = 0; i < gd.length; i++) { if (gd[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) { GraphicsConfiguration dgc = gd[i].getDefaultConfiguration(); if (dgc.getBounds().contains(p)) { gc = dgc; break; } } } return gc; }
/** * @return The available graphics devices with the default in position 0 */ private List<GraphicsDevice> getGraphicsDevices() { List<GraphicsDevice> devices = Lists.newArrayList(); // Get the default screen device GraphicsDevice defaultScreenDevice = GraphicsEnvironment .getLocalGraphicsEnvironment() .getDefaultScreenDevice(); for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) { if (GraphicsDevice.TYPE_RASTER_SCREEN == gd.getType()) { if (defaultScreenDevice == gd) { devices.add(0, gd); } else { devices.add(gd); } } } Preconditions.checkState(!devices.isEmpty(), "'devices' must not be empty. Is machine in headless mode?"); return devices; }
/** * Get the best graphics configuration for the specified point and component. */ private GraphicsConfiguration graphicsConfigurationForComponent(Component component) { Point point = component.getLocationOnScreen(); // try to find the graphics configuration for our point of interest GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gd = ge.getScreenDevices(); for(int i = 0; i < gd.length; i++) { if(gd[i].getType() != GraphicsDevice.TYPE_RASTER_SCREEN) continue; GraphicsConfiguration defaultGraphicsConfiguration = gd[i].getDefaultConfiguration(); if(!defaultGraphicsConfiguration.getBounds().contains(point)) continue; return defaultGraphicsConfiguration; } // we couldn't find a graphics configuration, use the component's return component.getGraphicsConfiguration(); }
/** * Get the best graphics configuration for the specified point and component. */ private GraphicsConfiguration graphicsConfigurationForComponent(Component component) { Point point = component.getLocationOnScreen(); // try to find the graphics configuration for our point of interest GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gd = ge.getScreenDevices(); for(int i = 0; i < gd.length; i++) { if(gd[i].getType() != GraphicsDevice.TYPE_RASTER_SCREEN) continue; GraphicsConfiguration defaultGraphicsConfiguration = gd[i].getDefaultConfiguration(); if(!defaultGraphicsConfiguration.getBounds().contains(point)) continue; return defaultGraphicsConfiguration; } // we couldn't find a graphics configuration, use the component's return component.getGraphicsConfiguration(); }
/** * Get the best graphics configuration for the specified point and component. */ private GraphicsConfiguration graphicsConfigurationForComponent(Component component) { Point point = component.getLocationOnScreen(); // try to find the graphics configuration for our point of interest GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gd = ge.getScreenDevices(); for(int i = 0; i < gd.length; i++) { if(gd[i].getType() != GraphicsDevice.TYPE_RASTER_SCREEN) continue; GraphicsConfiguration defaultGraphicsConfiguration = gd[i].getDefaultConfiguration(); if(!defaultGraphicsConfiguration.getBounds().contains(point)) continue; return defaultGraphicsConfiguration; } // we couldn't find a graphics configuration, use the component's return component.getGraphicsConfiguration(); }
/** * Get the best graphics configuration for the specified point and component. */ private GraphicsConfiguration graphicsConfigurationForComponent(Component component) { Point point = component.getLocationOnScreen(); // try to find the graphics configuration for our point of interest GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gd = ge.getScreenDevices(); for(int i = 0; i < gd.length; i++) { if(gd[i].getType() != GraphicsDevice.TYPE_RASTER_SCREEN) continue; GraphicsConfiguration defaultGraphicsConfiguration = gd[i].getDefaultConfiguration(); if(!defaultGraphicsConfiguration.getBounds().contains(point)) continue; return defaultGraphicsConfiguration; } // we couldn't find a graphics configuration, use the component's return component.getGraphicsConfiguration(); }
/** * Get the best graphics configuration for the specified point and component. */ private GraphicsConfiguration graphicsConfigurationForComponent(Component component) { Point point = component.getLocationOnScreen(); // try to find the graphics configuration for our point of interest GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gd = ge.getScreenDevices(); for(int i = 0; i < gd.length; i++) { if(gd[i].getType() != GraphicsDevice.TYPE_RASTER_SCREEN) continue; GraphicsConfiguration defaultGraphicsConfiguration = gd[i].getDefaultConfiguration(); if(!defaultGraphicsConfiguration.getBounds().contains(point)) continue; return defaultGraphicsConfiguration; } // we couldn't find a graphics configuration, use the component's return component.getGraphicsConfiguration(); }
/** * Get the best graphics configuration for the specified point and component. */ private GraphicsConfiguration graphicsConfigurationForComponent(Component component) { Point point = component.getLocationOnScreen(); // try to find the graphics configuration for our point of interest GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gd = ge.getScreenDevices(); for(int i = 0; i < gd.length; i++) { if(gd[i].getType() != GraphicsDevice.TYPE_RASTER_SCREEN) continue; GraphicsConfiguration defaultGraphicsConfiguration = gd[i].getDefaultConfiguration(); if(!defaultGraphicsConfiguration.getBounds().contains(point)) continue; return defaultGraphicsConfiguration; } // we couldn't find a graphics configuration, use the component's return component.getGraphicsConfiguration(); }
public static Rectangle getDestinationBounds(Graphics2D g2d) { BufferedImage bi = getDestination(g2d); if (bi != null) { return new Rectangle(0, 0, bi.getWidth(), bi.getHeight()); } GraphicsConfiguration gc = g2d.getDeviceConfiguration(); if (gc == null) { return null; } // We are going to a BufferedImage but no hint was provided // so we can't determine the destination bounds. if (gc.getDevice().getType() == GraphicsDevice.TYPE_IMAGE_BUFFER) { return null; } // This is a JDK 1.3ism, so we will just return null... // return gc.getBounds(); return null; }
public static Rectangle getDestinationBounds(Graphics2D g2d) { BufferedImage bi = getDestination(g2d); if (bi != null) { return new Rectangle(0, 0, bi.getWidth(), bi.getHeight()); } GraphicsConfiguration gc = g2d.getDeviceConfiguration(); if (gc == null) { return null; } // We are going to a BufferedImage but no hint was provided // so we can't determine the destination bounds. if (gc.getDevice().getType() == GraphicsDevice.TYPE_IMAGE_BUFFER) { return null; } // This is a JDK 1.3ism, so we will just return null... // return gc.getBounds(); return null; }
public static Rectangle getDestinationBounds(Graphics2D g2d) { BufferedImage bi = getDestination(g2d); if (bi != null) { return new Rectangle(0, 0, bi.getWidth(), bi.getHeight()); } GraphicsConfiguration gc = g2d.getDeviceConfiguration(); if (gc == null) { return null; } // We are going to a BufferedImage but no hint was provided // so we can't determine the destination bounds. if (gc.getDevice().getType() == GraphicsDevice.TYPE_IMAGE_BUFFER) { return null; } // This is a JDK 1.3ism, so we will just return null... // return gc.getBounds(); return null; }
public void initMonitors() { monitors.clear(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gd = ge.getScreenDevices(); for (int i = 0; i < gd.length; i++) { final GraphicsConfiguration config = gd[i].getDefaultConfiguration(); if (config == null || gd[i].getType() != GraphicsDevice.TYPE_RASTER_SCREEN) { continue; } Monitor monitor = new Monitor(gd[i]); StringBuilder buf = new StringBuilder("screen."); //$NON-NLS-1$ buf.append(monitor.getMonitorID()); Rectangle b = monitor.getBounds(); buf.append("."); //$NON-NLS-1$ buf.append(b.width); buf.append("x"); //$NON-NLS-1$ buf.append(b.height); buf.append(".pitch"); //$NON-NLS-1$ double pitch = BundleTools.LOCAL_PERSISTENCE.getDoubleProperty(buf.toString(), 0.0); monitor.setRealScaleFactor(pitch); monitors.add(monitor); } }
public static BufferedImage getDestination(Graphics2D g2d) { Object o = g2d.getRenderingHint (RenderingHintsKeyExt.KEY_BUFFERED_IMAGE); if (o != null) return (BufferedImage)(((Reference)o).get()); // Check if this is a BufferedImage G2d if so throw an error... GraphicsConfiguration gc = g2d.getDeviceConfiguration(); if (gc == null) { return null; } GraphicsDevice gd = gc.getDevice(); if (WARN_DESTINATION && (gd.getType() == GraphicsDevice.TYPE_IMAGE_BUFFER) && (g2d.getRenderingHint(RenderingHintsKeyExt.KEY_TRANSCODING) != RenderingHintsKeyExt.VALUE_TRANSCODING_PRINTING)) // throw new IllegalArgumentException System.err.println ("Graphics2D from BufferedImage lacks BUFFERED_IMAGE hint"); return null; }
public static BufferedImage getDestination(Graphics2D g2d) { Object o = g2d.getRenderingHint (RenderingHintsKeyExt.KEY_BUFFERED_IMAGE); if (o != null) return (BufferedImage)(((Reference)o).get()); // Check if this is a BufferedImage G2d if so throw an error... GraphicsConfiguration gc = g2d.getDeviceConfiguration(); if (gc == null) { return null; } GraphicsDevice gd = gc.getDevice(); if (WARN_DESTINATION && (gd.getType() == GraphicsDevice.TYPE_IMAGE_BUFFER) && (g2d.getRenderingHint(RenderingHintsKeyExt.KEY_TRANSCODING) != RenderingHintsKeyExt.VALUE_TRANSCODING_PRINTING)) // throw new IllegalArgumentException System.err.println ("Graphics2D from BufferedImage lacks BUFFERED_IMAGE hint"); return null; }
public static BufferedImage getDestination(Graphics2D g2d) { Object o = g2d.getRenderingHint (RenderingHintsKeyExt.KEY_BUFFERED_IMAGE); if (o != null) return (BufferedImage)(((Reference)o).get()); // Check if this is a BufferedImage G2d if so throw an error... GraphicsConfiguration gc = g2d.getDeviceConfiguration(); if (gc == null) { return null; } GraphicsDevice gd = gc.getDevice(); if (WARN_DESTINATION && (gd.getType() == GraphicsDevice.TYPE_IMAGE_BUFFER) && (g2d.getRenderingHint(RenderingHintsKeyExt.KEY_TRANSCODING) != RenderingHintsKeyExt.VALUE_TRANSCODING_PRINTING)) // throw new IllegalArgumentException System.err.println ("Graphics2D from BufferedImage lacks BUFFERED_IMAGE hint"); return null; }
public static ColorModel getDestinationColorModel(Graphics2D g2d) { BufferedImage bi = getDestination(g2d); if (bi != null) { return bi.getColorModel(); } GraphicsConfiguration gc = g2d.getDeviceConfiguration(); if (gc == null) { return null; // Can't tell } // We are going to a BufferedImage but no hint was provided // so we can't determine the destination Color Model. if (gc.getDevice().getType() == GraphicsDevice.TYPE_IMAGE_BUFFER) { if (g2d.getRenderingHint(RenderingHintsKeyExt.KEY_TRANSCODING) == RenderingHintsKeyExt.VALUE_TRANSCODING_PRINTING) return sRGB_Unpre; // System.out.println("CM: " + gc.getColorModel()); // System.out.println("CS: " + gc.getColorModel().getColorSpace()); return null; } return gc.getColorModel(); }
public static ColorModel getDestinationColorModel(Graphics2D g2d) { BufferedImage bi = getDestination(g2d); if (bi != null) { return bi.getColorModel(); } GraphicsConfiguration gc = g2d.getDeviceConfiguration(); if (gc == null) { return null; // Can't tell } // We are going to a BufferedImage but no hint was provided // so we can't determine the destination Color Model. if (gc.getDevice().getType() == GraphicsDevice.TYPE_IMAGE_BUFFER) { if (g2d.getRenderingHint(RenderingHintsKeyExt.KEY_TRANSCODING) == RenderingHintsKeyExt.VALUE_TRANSCODING_PRINTING) return sRGB_Unpre; // System.out.println("CM: " + gc.getColorModel()); // System.out.println("CS: " + gc.getColorModel().getColorSpace()); return null; } return gc.getColorModel(); }
public static ColorModel getDestinationColorModel(Graphics2D g2d) { BufferedImage bi = getDestination(g2d); if (bi != null) { return bi.getColorModel(); } GraphicsConfiguration gc = g2d.getDeviceConfiguration(); if (gc == null) { return null; // Can't tell } // We are going to a BufferedImage but no hint was provided // so we can't determine the destination Color Model. if (gc.getDevice().getType() == GraphicsDevice.TYPE_IMAGE_BUFFER) { if (g2d.getRenderingHint(RenderingHintsKeyExt.KEY_TRANSCODING) == RenderingHintsKeyExt.VALUE_TRANSCODING_PRINTING) return sRGB_Unpre; // System.out.println("CM: " + gc.getColorModel()); // System.out.println("CS: " + gc.getColorModel().getColorSpace()); return null; } return gc.getColorModel(); }