Search in sources :

Example 21 with GraphicsConfiguration

use of java.awt.GraphicsConfiguration in project processing by processing.

the class EditorState method defaultConfig.

GraphicsConfiguration defaultConfig() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice device = ge.getDefaultScreenDevice();
    GraphicsConfiguration config = device.getDefaultConfiguration();
    //      deviceName = device.getIDstring();
    deviceBounds = config.getBounds();
    return config;
}
Also used : GraphicsDevice(java.awt.GraphicsDevice) GraphicsEnvironment(java.awt.GraphicsEnvironment) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 22 with GraphicsConfiguration

use of java.awt.GraphicsConfiguration in project processing by processing.

the class EditorState method checkConfig.

/**
   * Returns a GraphicsConfiguration so that a new Editor Frame can be
   * constructed. First tries to match the bounds for this state information
   * to an existing config (nominally, a display) and if that doesn't work,
   * then returns the default configuration/default display.
   */
GraphicsConfiguration checkConfig() {
    if (deviceBounds != null) {
        GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice[] screenDevices = graphicsEnvironment.getScreenDevices();
        for (GraphicsDevice device : screenDevices) {
            GraphicsConfiguration[] configurations = device.getConfigurations();
            for (GraphicsConfiguration config : configurations) {
                //          if (config.getDevice().getIDstring().equals(deviceName)) {
                if (config.getBounds().equals(deviceBounds)) {
                    return config;
                }
            }
        }
    }
    // otherwise go to the default config
    return defaultConfig();
}
Also used : GraphicsDevice(java.awt.GraphicsDevice) GraphicsEnvironment(java.awt.GraphicsEnvironment) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 23 with GraphicsConfiguration

use of java.awt.GraphicsConfiguration in project processing by processing.

the class PSurfaceAWT method getDisplaySpan.

//public void initImage(PGraphics gr, int wide, int high) {
/*
  @Override
  public void initImage(PGraphics graphics) {
    GraphicsConfiguration gc = canvas.getGraphicsConfiguration();
    // If not realized (off-screen, i.e the Color Selector Tool), gc will be null.
    if (gc == null) {
      System.err.println("GraphicsConfiguration null in initImage()");
      GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
    }

    // Formerly this was broken into separate versions based on offscreen or
    // not, but we may as well create a compatible image; it won't hurt, right?
    int wide = graphics.width * graphics.pixelFactor;
    int high = graphics.height * graphics.pixelFactor;
    graphics.image = gc.createCompatibleImage(wide, high);
  }
  */
//  @Override
//  public Component getComponent() {
//    return canvas;
//  }
//  @Override
//  public void setSmooth(int level) {
//  }
/*
  private boolean checkRetina() {
    if (PApplet.platform == PConstants.MACOSX) {
      // This should probably be reset each time there's a display change.
      // A 5-minute search didn't turn up any such event in the Java 7 API.
      // Also, should we use the Toolkit associated with the editor window?
      final String javaVendor = System.getProperty("java.vendor");
      if (javaVendor.contains("Oracle")) {
        GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
        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 && ((Integer)scale).intValue() == 2) {
              return true;
            }
          }
        } catch (Exception ignore) { }
      }
    }
    return false;
  }
  */
/** Get the bounds rectangle for all displays. */
static Rectangle getDisplaySpan() {
    Rectangle bounds = new Rectangle();
    GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    for (GraphicsDevice device : environment.getScreenDevices()) {
        for (GraphicsConfiguration config : device.getConfigurations()) {
            Rectangle2D.union(bounds, config.getBounds(), bounds);
        }
    }
    return bounds;
}
Also used : GraphicsDevice(java.awt.GraphicsDevice) Rectangle(java.awt.Rectangle) GraphicsEnvironment(java.awt.GraphicsEnvironment) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 24 with GraphicsConfiguration

use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.

the class FontPanel method getDefaultLCDContrast.

static Integer getDefaultLCDContrast() {
    if (defaultContrast == null) {
        GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
        Graphics2D g2d = (Graphics2D) (gc.createCompatibleImage(1, 1).getGraphics());
        defaultContrast = (Integer) g2d.getRenderingHint(RenderingHints.KEY_TEXT_LCD_CONTRAST);
    }
    return defaultContrast;
}
Also used : GraphicsConfiguration(java.awt.GraphicsConfiguration) Graphics2D(java.awt.Graphics2D)

Example 25 with GraphicsConfiguration

use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.

the class TranslucentWindowPainter method createInstance.

/**
     * Creates an instance of the painter for particular peer.
     */
public static TranslucentWindowPainter createInstance(WWindowPeer peer) {
    GraphicsConfiguration gc = peer.getGraphicsConfiguration();
    if (!forceSW && gc instanceof AccelGraphicsConfig) {
        String gcName = gc.getClass().getSimpleName();
        AccelGraphicsConfig agc = (AccelGraphicsConfig) gc;
        // (those have higher transfer rate from gpu to cpu)
        if ((agc.getContextCapabilities().getCaps() & CAPS_PS30) != 0 || forceOpt) {
            // a pipeline isn't enabled
            if (gcName.startsWith("D3D")) {
                return new VIOptD3DWindowPainter(peer);
            } else if (forceOpt && gcName.startsWith("WGL")) {
                // unless forced
                return new VIOptWGLWindowPainter(peer);
            }
        }
    }
    return new BIWindowPainter(peer);
}
Also used : AccelGraphicsConfig(sun.java2d.pipe.hw.AccelGraphicsConfig) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Aggregations

GraphicsConfiguration (java.awt.GraphicsConfiguration)136 GraphicsEnvironment (java.awt.GraphicsEnvironment)55 BufferedImage (java.awt.image.BufferedImage)46 Rectangle (java.awt.Rectangle)44 GraphicsDevice (java.awt.GraphicsDevice)38 Graphics2D (java.awt.Graphics2D)34 VolatileImage (java.awt.image.VolatileImage)31 Point (java.awt.Point)30 Dimension (java.awt.Dimension)21 Insets (java.awt.Insets)17 File (java.io.File)16 Graphics (java.awt.Graphics)13 IOException (java.io.IOException)13 Frame (java.awt.Frame)11 JFrame (javax.swing.JFrame)8 HeadlessException (java.awt.HeadlessException)7 Window (java.awt.Window)7 ImageIcon (javax.swing.ImageIcon)7 Color (java.awt.Color)6 AffineTransform (java.awt.geom.AffineTransform)6