Search in sources :

Example 81 with GraphicsConfiguration

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

the class MoveToOtherScreenTest method main.

public static void main(String[] args) throws InterruptedException, InvocationTargetException {
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice[] gds = ge.getScreenDevices();
            if (gds.length < 2) {
                System.out.println("Test requires at least 2 displays");
                twoDisplays = false;
                return;
            }
            for (int i = 0; i < 2; i++) {
                GraphicsConfiguration conf = gds[i].getConfigurations()[0];
                JFrame frm = new JFrame("Frame " + i);
                // On first screen
                frm.setLocation(conf.getBounds().x, 0);
                frm.setSize(new Dimension(400, 400));
                frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frm.setVisible(true);
                frms[i] = frm;
            }
            canvas.setBackground(Color.red);
            frms[0].add(canvas);
        }
    });
    if (!twoDisplays) {
        return;
    }
    Thread.sleep(200);
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            frms[1].add(canvas);
        }
    });
    for (Frame frm : frms) {
        frm.dispose();
    }
}
Also used : Frame(java.awt.Frame) JFrame(javax.swing.JFrame) JFrame(javax.swing.JFrame) Dimension(java.awt.Dimension) GraphicsEnvironment(java.awt.GraphicsEnvironment) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 82 with GraphicsConfiguration

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

the class NormalizingTransformTest method main.

public static void main(String[] args) {
    GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
    AffineTransform normTransform = gc.getNormalizingTransform();
    int dpiX = Toolkit.getDefaultToolkit().getScreenResolution();
    int normDpiX = (int) (normTransform.getScaleX() * 72.0);
    if (dpiX != normDpiX) {
        throw new RuntimeException("Test FAILED. Toolkit.getScreenResolution()=" + dpiX + " GraphicsConfiguration.getNormalizingTransform()=" + normDpiX);
    }
    System.out.println("Test PASSED. DPI=" + normDpiX);
}
Also used : AffineTransform(java.awt.geom.AffineTransform) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 83 with GraphicsConfiguration

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

the class X11GraphicsDevice method makeConfigurations.

private void makeConfigurations() {
    if (configs == null) {
        // Index 0 is always the default config
        int i = 1;
        int num = getNumConfigs(screen);
        GraphicsConfiguration[] ret = new GraphicsConfiguration[num];
        if (defaultConfig == null) {
            ret[0] = getDefaultConfiguration();
        } else {
            ret[0] = defaultConfig;
        }
        boolean glxSupported = X11GraphicsEnvironment.isGLXAvailable();
        boolean xrenderSupported = X11GraphicsEnvironment.isXRenderAvailable();
        boolean dbeSupported = isDBESupported();
        if (dbeSupported && doubleBufferVisuals == null) {
            doubleBufferVisuals = new HashSet();
            getDoubleBufferVisuals(screen);
        }
        for (; i < num; i++) {
            int visNum = getConfigVisualId(i, screen);
            int depth = getConfigDepth(i, screen);
            if (glxSupported) {
                ret[i] = GLXGraphicsConfig.getConfig(this, visNum);
            }
            if (ret[i] == null) {
                boolean doubleBuffer = (dbeSupported && doubleBufferVisuals.contains(Integer.valueOf(visNum)));
                if (xrenderSupported) {
                    ret[i] = XRGraphicsConfig.getConfig(this, visNum, depth, getConfigColormap(i, screen), doubleBuffer);
                } else {
                    ret[i] = X11GraphicsConfig.getConfig(this, visNum, depth, getConfigColormap(i, screen), doubleBuffer);
                }
            }
        }
        configs = ret;
    }
}
Also used : GraphicsConfiguration(java.awt.GraphicsConfiguration) HashSet(java.util.HashSet)

Example 84 with GraphicsConfiguration

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

the class X11GraphicsDevice method getDefaultDisplayMode.

private DisplayMode getDefaultDisplayMode() {
    GraphicsConfiguration gc = getDefaultConfiguration();
    Rectangle r = gc.getBounds();
    return new DisplayMode(r.width, r.height, DisplayMode.BIT_DEPTH_MULTI, DisplayMode.REFRESH_RATE_UNKNOWN);
}
Also used : DisplayMode(java.awt.DisplayMode) Rectangle(java.awt.Rectangle) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 85 with GraphicsConfiguration

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

the class D3DSurfaceData method getGC.

private static D3DGraphicsConfig getGC(WComponentPeer peer) {
    GraphicsConfiguration gc;
    if (peer != null) {
        gc = peer.getGraphicsConfiguration();
    } else {
        GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = env.getDefaultScreenDevice();
        gc = gd.getDefaultConfiguration();
    }
    return (gc instanceof D3DGraphicsConfig) ? (D3DGraphicsConfig) gc : null;
}
Also used : GraphicsDevice(java.awt.GraphicsDevice) GraphicsEnvironment(java.awt.GraphicsEnvironment) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Aggregations

GraphicsConfiguration (java.awt.GraphicsConfiguration)134 GraphicsEnvironment (java.awt.GraphicsEnvironment)55 BufferedImage (java.awt.image.BufferedImage)46 Rectangle (java.awt.Rectangle)43 GraphicsDevice (java.awt.GraphicsDevice)38 Graphics2D (java.awt.Graphics2D)33 VolatileImage (java.awt.image.VolatileImage)31 Point (java.awt.Point)29 Dimension (java.awt.Dimension)21 Insets (java.awt.Insets)16 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