Search in sources :

Example 71 with GraphicsEnvironment

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

the class FullScreenInsets method main.

public static void main(final String[] args) {
    final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsDevice[] devices = ge.getScreenDevices();
    final Window wGreen = new Frame();
    wGreen.setBackground(Color.GREEN);
    wGreen.setSize(300, 300);
    wGreen.setVisible(true);
    sleep();
    final Insets iGreen = wGreen.getInsets();
    final Dimension sGreen = wGreen.getSize();
    final Window wRed = new Frame();
    wRed.setBackground(Color.RED);
    wRed.setSize(300, 300);
    wRed.setVisible(true);
    sleep();
    final Insets iRed = wGreen.getInsets();
    final Dimension sRed = wGreen.getSize();
    for (final GraphicsDevice device : devices) {
        if (!device.isFullScreenSupported()) {
            continue;
        }
        device.setFullScreenWindow(wGreen);
        sleep();
        testWindowBounds(device.getDisplayMode(), wGreen);
        testColor(wGreen, Color.GREEN);
        device.setFullScreenWindow(wRed);
        sleep();
        testWindowBounds(device.getDisplayMode(), wRed);
        testColor(wRed, Color.RED);
        device.setFullScreenWindow(null);
        sleep();
        testInsets(wGreen.getInsets(), iGreen);
        testInsets(wRed.getInsets(), iRed);
        testSize(wGreen.getSize(), sGreen);
        testSize(wRed.getSize(), sRed);
    }
    wGreen.dispose();
    wRed.dispose();
    if (!passed) {
        throw new RuntimeException("Test failed");
    }
}
Also used : Window(java.awt.Window) Frame(java.awt.Frame) GraphicsDevice(java.awt.GraphicsDevice) Insets(java.awt.Insets) Dimension(java.awt.Dimension) GraphicsEnvironment(java.awt.GraphicsEnvironment)

Example 72 with GraphicsEnvironment

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

the class IncorrectAlphaSurface2SW method main.

public static void main(final String[] args) throws IOException {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
    BufferedImage destVI;
    BufferedImage destBI;
    BufferedImage sourceBI;
    VolatileImage sourceVI;
    for (final int s : SIZES) {
        for (final int srcType : srcTypes) {
            for (final int dstType : dstTypes) {
                for (final int scale : SCALES) {
                    int sw = s * scale;
                    destVI = new BufferedImage(sw, sw, dstType);
                    destBI = new BufferedImage(sw, sw, dstType);
                    sourceBI = gc.createCompatibleImage(sw, sw, srcType);
                    sourceVI = gc.createCompatibleVolatileImage(s, s, srcType);
                    // draw to dest BI using compatible image
                    fill(sourceBI, s);
                    Graphics2D big = destBI.createGraphics();
                    big.setComposite(AlphaComposite.Src);
                    big.drawImage(sourceBI, 0, 0, sw, sw, null);
                    big.dispose();
                    // draw to dest BI using compatible image
                    fill(sourceVI, s);
                    drawVItoBI(gc, destVI, sourceVI);
                    validate(destVI, destBI);
                    sourceVI.flush();
                }
            }
        }
    }
    System.out.println("Test PASSED");
}
Also used : VolatileImage(java.awt.image.VolatileImage) GraphicsEnvironment(java.awt.GraphicsEnvironment) BufferedImage(java.awt.image.BufferedImage) GraphicsConfiguration(java.awt.GraphicsConfiguration) Graphics2D(java.awt.Graphics2D)

Example 73 with GraphicsEnvironment

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

the class XMouseInfoPeer method fillPointWithCoords.

public int fillPointWithCoords(Point point) {
    long display = XToolkit.getDisplay();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    int gdslen = gds.length;
    XToolkit.awtLock();
    try {
        for (int i = 0; i < gdslen; i++) {
            long screenRoot = XlibWrapper.RootWindow(display, i);
            boolean pointerFound = XlibWrapper.XQueryPointer(display, screenRoot, // root_return
            XlibWrapper.larg1, // child_return
            XlibWrapper.larg2, // xr_return
            XlibWrapper.larg3, // yr_return
            XlibWrapper.larg4, // xw_return
            XlibWrapper.larg5, // yw_return
            XlibWrapper.larg6, // mask_return
            XlibWrapper.larg7);
            if (pointerFound) {
                point.x = Native.getInt(XlibWrapper.larg3);
                point.y = Native.getInt(XlibWrapper.larg4);
                return i;
            }
        }
    } finally {
        XToolkit.awtUnlock();
    }
    // this should never happen
    assert false : "No pointer found in the system.";
    return 0;
}
Also used : GraphicsDevice(java.awt.GraphicsDevice) GraphicsEnvironment(java.awt.GraphicsEnvironment) Point(java.awt.Point)

Example 74 with GraphicsEnvironment

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

the class X11SurfaceData method getGC.

public static X11GraphicsConfig getGC(X11ComponentPeer peer) {
    if (peer != null) {
        return (X11GraphicsConfig) peer.getGraphicsConfiguration();
    } else {
        GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = env.getDefaultScreenDevice();
        return (X11GraphicsConfig) gd.getDefaultConfiguration();
    }
}
Also used : X11GraphicsConfig(sun.awt.X11GraphicsConfig) GraphicsDevice(java.awt.GraphicsDevice) GraphicsEnvironment(java.awt.GraphicsEnvironment) X11GraphicsEnvironment(sun.awt.X11GraphicsEnvironment) SunGraphicsEnvironment(sun.java2d.SunGraphicsEnvironment)

Example 75 with GraphicsEnvironment

use of java.awt.GraphicsEnvironment 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)

Aggregations

GraphicsEnvironment (java.awt.GraphicsEnvironment)93 GraphicsDevice (java.awt.GraphicsDevice)46 GraphicsConfiguration (java.awt.GraphicsConfiguration)44 BufferedImage (java.awt.image.BufferedImage)24 VolatileImage (java.awt.image.VolatileImage)21 Dimension (java.awt.Dimension)17 Graphics2D (java.awt.Graphics2D)17 Point (java.awt.Point)12 Font (java.awt.Font)11 Rectangle (java.awt.Rectangle)11 Insets (java.awt.Insets)7 File (java.io.File)7 Frame (java.awt.Frame)6 Toolkit (java.awt.Toolkit)6 AffineTransform (java.awt.geom.AffineTransform)6 HeadlessException (java.awt.HeadlessException)5 Color (java.awt.Color)3 Container (java.awt.Container)3 DisplayMode (java.awt.DisplayMode)3 GradientPaint (java.awt.GradientPaint)3