use of java.awt.DisplayMode in project jdk8u_jdk by JetBrains.
the class DisplayChangeVITest method selectDisplayModes.
private void selectDisplayModes() {
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
dms = new ArrayList<DisplayMode>();
DisplayMode[] dmArray = gd.getDisplayModes();
boolean found8 = false, found16 = false, found24 = false, found32 = false;
for (DisplayMode dm : dmArray) {
if (!found8 && (dm.getBitDepth() == 8 || dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI) && (dm.getWidth() >= 800 && dm.getWidth() < 1024)) {
dms.add(dm);
found8 = true;
continue;
}
if (!found32 && (dm.getBitDepth() == 32 || dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI) && dm.getWidth() >= 1280) {
dms.add(dm);
found32 = true;
continue;
}
if (!found16 && dm.getBitDepth() == 16 && (dm.getWidth() >= 1024 && dm.getWidth() < 1280)) {
dms.add(dm);
found16 = true;
continue;
}
if (found8 && found16 && found32) {
break;
}
}
System.err.println("Found display modes:");
for (DisplayMode dm : dms) {
System.err.printf("DisplayMode[%dx%dx%d]\n", dm.getWidth(), dm.getHeight(), dm.getBitDepth());
}
}
use of java.awt.DisplayMode in project jdk8u_jdk by JetBrains.
the class NoResizeEventOnDMChangeTest method main.
public static void main(String[] args) {
final GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
if (!gd.isFullScreenSupported()) {
System.out.println("Full screen not supported, test passed");
return;
}
DisplayMode dm = gd.getDisplayMode();
final DisplayMode[] dms = new DisplayMode[2];
for (DisplayMode dm1 : gd.getDisplayModes()) {
if (dm1.getWidth() != dm.getWidth() || dm1.getHeight() != dm.getHeight()) {
dms[0] = dm1;
break;
}
}
if (dms[0] == null) {
System.out.println("Test Passed: all DMs have same dimensions");
return;
}
dms[1] = dm;
Frame f = new Frame() {
@Override
public void paint(Graphics g) {
g.setColor(Color.red);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.green);
g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
}
};
f.setUndecorated(true);
testFSWindow(gd, dms, f);
Window w = new Window(f) {
@Override
public void paint(Graphics g) {
g.setColor(Color.magenta);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.cyan);
g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
}
};
testFSWindow(gd, dms, w);
System.out.println("Test Passed.");
}
use of java.awt.DisplayMode in project jdk8u_jdk by JetBrains.
the class DisplayChangeVITest method run.
public void run() {
GraphicsDevice gd = getGraphicsConfiguration().getDevice();
if (gd.isDisplayChangeSupported() && dms.size() > 0) {
while (!done && reps++ < TEST_REPS) {
for (DisplayMode dm : dms) {
System.err.printf("Entering DisplayMode[%dx%dx%d]\n", dm.getWidth(), dm.getHeight(), dm.getBitDepth());
gd.setDisplayMode(dm);
initBackbuffer();
for (int i = 0; i < 10; i++) {
// render to the screen
render(getGraphics());
// ask Swing to repaint
repaint();
sleep(100);
}
sleep(1500);
}
}
} else {
System.err.println("Display mode change " + "not supported. Test passed.");
}
dispose();
synchronized (lock) {
done = true;
lock.notify();
}
}
use of java.awt.DisplayMode in project jdk8u_jdk by JetBrains.
the class Win32GraphicsDevice method getDisplayModes.
@Override
public synchronized DisplayMode[] getDisplayModes() {
ArrayList modes = new ArrayList();
enumDisplayModes(screen, modes);
int listSize = modes.size();
DisplayMode[] retArray = new DisplayMode[listSize];
for (int i = 0; i < listSize; i++) {
retArray[i] = (DisplayMode) modes.get(i);
}
return retArray;
}
use of java.awt.DisplayMode 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");
}
}
Aggregations