use of java.awt.GraphicsEnvironment in project jdk8u_jdk by JetBrains.
the class CheckDisplayModes method main.
public static void main(String[] args) {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice graphicDevice = ge.getDefaultScreenDevice();
if (!graphicDevice.isDisplayChangeSupported()) {
System.err.println("Display mode change is not supported on this host. Test is considered passed.");
return;
}
DisplayMode defaultDisplayMode = graphicDevice.getDisplayMode();
checkDisplayMode(defaultDisplayMode);
graphicDevice.setDisplayMode(defaultDisplayMode);
DisplayMode[] displayModes = graphicDevice.getDisplayModes();
boolean isDefaultDisplayModeIncluded = false;
for (DisplayMode displayMode : displayModes) {
checkDisplayMode(displayMode);
graphicDevice.setDisplayMode(displayMode);
if (defaultDisplayMode.equals(displayMode)) {
isDefaultDisplayModeIncluded = true;
}
}
if (!isDefaultDisplayModeIncluded) {
throw new RuntimeException("Default display mode is not included");
}
}
use of java.awt.GraphicsEnvironment in project jdk8u_jdk by JetBrains.
the class WGLSurfaceData method getGC.
public static WGLGraphicsConfig getGC(WComponentPeer peer) {
if (peer != null) {
return (WGLGraphicsConfig) peer.getGraphicsConfiguration();
} else {
// REMIND: this should rarely (never?) happen, but what if
// default config is not WGL?
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = env.getDefaultScreenDevice();
return (WGLGraphicsConfig) gd.getDefaultConfiguration();
}
}
use of java.awt.GraphicsEnvironment 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;
}
use of java.awt.GraphicsEnvironment in project jdk8u_jdk by JetBrains.
the class MultiScreenInsetsTest method main.
public static void main(String[] args) throws InterruptedException {
OSInfo.OSType type = OSInfo.getOSType();
if (type != OSInfo.OSType.LINUX && type != OSInfo.OSType.SOLARIS) {
System.out.println("This test is for Solaris and Linux only..." + "skipping!");
return;
}
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gds = ge.getScreenDevices();
if (gds.length < 2) {
System.out.println("It's a multi-screen test... skipping!");
return;
}
for (int screen = 0; screen < gds.length; ++screen) {
GraphicsDevice gd = gds[screen];
GraphicsConfiguration gc = gd.getDefaultConfiguration();
Rectangle bounds = gc.getBounds();
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
Frame frame = new Frame(gc);
frame.setLocation(bounds.x + (bounds.width - SIZE) / 2, bounds.y + (bounds.height - SIZE) / 2);
frame.setSize(SIZE, SIZE);
frame.setUndecorated(true);
frame.setVisible(true);
// Maximize Frame to reach the struts
frame.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
Thread.sleep(2000);
Rectangle frameBounds = frame.getBounds();
frame.dispose();
if (bounds.x + insets.left != frameBounds.x || bounds.y + insets.top != frameBounds.y || bounds.width - insets.right - insets.left != frameBounds.width || bounds.height - insets.bottom - insets.top != frameBounds.height) {
throw new RuntimeException("Test FAILED! Wrong screen #" + screen + " insets: " + insets);
}
}
System.out.println("Test PASSED!");
}
use of java.awt.GraphicsEnvironment in project jdk8u_jdk by JetBrains.
the class MultiScreenLocationTest method main.
public static void main(String[] args) throws AWTException {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gds = ge.getScreenDevices();
if (gds.length < 2) {
System.out.println("It's a multiscreen test... skipping!");
return;
}
for (int i = 0; i < gds.length; ++i) {
GraphicsDevice gd = gds[i];
GraphicsConfiguration gc = gd.getDefaultConfiguration();
Rectangle screen = gc.getBounds();
Robot robot = new Robot(gd);
// check Robot.mouseMove()
robot.mouseMove(screen.x + mouseOffset.x, screen.y + mouseOffset.y);
Point mouse = MouseInfo.getPointerInfo().getLocation();
Point point = screen.getLocation();
point.translate(mouseOffset.x, mouseOffset.y);
if (!point.equals(mouse)) {
throw new RuntimeException(getErrorText("Robot.mouseMove", i));
}
// check Robot.getPixelColor()
Frame frame = new Frame(gc);
frame.setUndecorated(true);
frame.setSize(100, 100);
frame.setLocation(screen.x + frameOffset.x, screen.y + frameOffset.y);
frame.setBackground(color);
frame.setVisible(true);
robot.waitForIdle();
Rectangle bounds = frame.getBounds();
if (!Util.testBoundsColor(bounds, color, 5, 1000, robot)) {
throw new RuntimeException(getErrorText("Robot.getPixelColor", i));
}
// check Robot.createScreenCapture()
BufferedImage image = robot.createScreenCapture(bounds);
int rgb = color.getRGB();
if (image.getRGB(0, 0) != rgb || image.getRGB(image.getWidth() - 1, 0) != rgb || image.getRGB(image.getWidth() - 1, image.getHeight() - 1) != rgb || image.getRGB(0, image.getHeight() - 1) != rgb) {
throw new RuntimeException(getErrorText("Robot.createScreenCapture", i));
}
frame.dispose();
}
System.out.println("Test PASSED!");
}
Aggregations