use of java.awt.DisplayMode 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);
}
use of java.awt.DisplayMode in project karaf by apache.
the class ScreenshotDumpProvider method createDump.
/**
* {@inheritDoc}
*/
public void createDump(DumpDestination destination) throws Exception {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
// get all graphic devices attached to computer
GraphicsDevice[] gs = ge.getScreenDevices();
// create dump entry for each device
for (int i = 0; i < gs.length; i++) {
DisplayMode mode = gs[i].getDisplayMode();
Rectangle bounds = new Rectangle(0, 0, mode.getWidth(), mode.getHeight());
BufferedImage screenshot = new Robot(gs[i]).createScreenCapture(bounds);
// to attach your entry to destination you have to execute this line
OutputStream outputStream = destination.add("screenshot/display_" + i + ".png");
ImageIO.write(screenshot, "PNG", outputStream);
outputStream.close();
}
}
use of java.awt.DisplayMode in project javacv by bytedeco.
the class CanvasFrame method init.
private void init(final boolean fullScreen, final DisplayMode displayMode, final double gamma) {
Runnable r = new Runnable() {
public void run() {
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(keyEventDispatch);
GraphicsDevice gd = getGraphicsConfiguration().getDevice();
DisplayMode d = gd.getDisplayMode(), d2 = null;
if (displayMode != null && d != null) {
int w = displayMode.getWidth();
int h = displayMode.getHeight();
int b = displayMode.getBitDepth();
int r = displayMode.getRefreshRate();
d2 = new DisplayMode(w > 0 ? w : d.getWidth(), h > 0 ? h : d.getHeight(), b > 0 ? b : d.getBitDepth(), r > 0 ? r : d.getRefreshRate());
}
if (fullScreen) {
setUndecorated(true);
getRootPane().setWindowDecorationStyle(JRootPane.NONE);
setResizable(false);
gd.setFullScreenWindow(CanvasFrame.this);
} else {
setLocationByPlatform(true);
}
if (d2 != null && !d2.equals(d)) {
gd.setDisplayMode(d2);
}
double g = gamma == 0.0 ? getGamma(gd) : gamma;
inverseGamma = g == 0.0 ? 1.0 : 1.0 / g;
// Must be called after the fullscreen stuff, but before
// getting our BufferStrategy or even creating our Canvas
setVisible(true);
initCanvas(fullScreen, displayMode, gamma);
}
};
if (EventQueue.isDispatchThread()) {
r.run();
} else {
try {
EventQueue.invokeAndWait(r);
} catch (java.lang.Exception ex) {
}
}
}
use of java.awt.DisplayMode in project TeachingInSimulation by ScOrPiOzzy.
the class TestReslution method display1.
@Test
public void display1() {
GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice sd = g.getDefaultScreenDevice();
DisplayMode[] dm = sd.getDisplayModes();
List<String> resolution = new ArrayList<>();
for (int i = 0; i < dm.length; i++) {
String res = String.format("%sx%s", dm[i].getWidth(), dm[i].getHeight());
if (resolution.indexOf(res) == -1) {
resolution.add(res);
}
}
resolution.forEach(System.out::println);
}
use of java.awt.DisplayMode in project vft-capture by videofirst.
the class HideToSystemTray method getCentredLocation.
public static Point getCentredLocation(Window window, Dimension componentSize) {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < gs.length; i++) {
DisplayMode dm = gs[i].getDisplayMode();
sb.append(i + ", width: " + dm.getWidth() + ", height: " + dm.getHeight() + "\n");
}
System.out.println(sb.toString());
// int currentScreenWidth = gs[0].getDisplayMode().getWidth();
// //int currentScreenHeight = gs[0].getDisplayMode().getWidth();
Dimension screenSize = window.getToolkit().getScreenSize();
Point p = new Point((int) (screenSize.getWidth() / 2 - componentSize.getWidth() / 2), (int) (screenSize.getHeight() / 2 - componentSize.getHeight() / 2));
return p;
}
Aggregations