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");
}
}
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");
}
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;
}
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();
}
}
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();
}
}
Aggregations