use of java.awt.DisplayMode in project Purus-Pasta by puruscor.
the class MainFrame method findmode.
DisplayMode findmode(int w, int h) {
GraphicsDevice dev = getGraphicsConfiguration().getDevice();
if (!dev.isFullScreenSupported())
return (null);
DisplayMode b = null;
for (DisplayMode m : dev.getDisplayModes()) {
int d = m.getBitDepth();
if ((m.getWidth() == w) && (m.getHeight() == h) && ((d == 24) || (d == 32) || (d == DisplayMode.BIT_DEPTH_MULTI))) {
if ((b == null) || (d > b.getBitDepth()) || ((d == b.getBitDepth()) && (m.getRefreshRate() > b.getRefreshRate())))
b = m;
}
}
return (b);
}
use of java.awt.DisplayMode in project javacv by bytedeco.
the class ProjectorDevice method createCanvasFrame.
public CanvasFrame createCanvasFrame() throws CanvasFrame.Exception {
if (settings.getScreenNumber() < 0) {
return null;
}
DisplayMode d = new DisplayMode(settings.getImageWidth(), settings.getImageHeight(), settings.getBitDepth(), settings.getRefreshRate());
CanvasFrame c = null;
Throwable cause = null;
try {
c = Class.forName(CanvasFrame.class.getPackage().getName() + (settings.isUseOpenGL() ? ".GLCanvasFrame" : ".CanvasFrame")).asSubclass(CanvasFrame.class).getConstructor(String.class, int.class, DisplayMode.class, double.class).newInstance(settings.getName(), settings.getScreenNumber(), d, settings.getResponseGamma());
} catch (ClassNotFoundException ex) {
cause = ex;
} catch (InstantiationException ex) {
cause = ex;
} catch (IllegalAccessException ex) {
cause = ex;
} catch (IllegalArgumentException ex) {
cause = ex;
} catch (NoSuchMethodException ex) {
cause = ex;
} catch (InvocationTargetException ex) {
cause = ex.getCause();
}
if (cause != null) {
if (cause instanceof CanvasFrame.Exception) {
throw (CanvasFrame.Exception) cause;
} else {
throw new CanvasFrame.Exception("Failed to create CanvasFrame", cause);
}
}
c.setLatency(settings.getLatency());
Dimension size = c.getCanvasSize();
if (size.width != imageWidth || size.height != imageHeight) {
rescale(size.width, size.height);
}
return c;
}
use of java.awt.DisplayMode in project jadx by skylot.
the class MainWindow method setLocationAndPosition.
public void setLocationAndPosition() {
if (settings.loadWindowPos(this)) {
return;
}
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
DisplayMode mode = gd.getDisplayMode();
int w = mode.getWidth();
int h = mode.getHeight();
setBounds((int) (w * BORDER_RATIO), (int) (h * BORDER_RATIO), (int) (w * WINDOW_RATIO), (int) (h * WINDOW_RATIO));
setLocationRelativeTo(null);
}
use of java.awt.DisplayMode in project open-ecard by ecsec.
the class SwingDialogWrapper method show.
/**
* This function is executed after the root panel has been set up with the contents of the user consent.
*/
public void show() {
screenDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
DisplayMode fsMode = null;
if (screenDevice.isFullScreenSupported() && needsFullscreen()) {
// check if resolution should be changed
if (screenDevice.isDisplayChangeSupported() && isChangeResolution()) {
fsMode = getBestFullscreenMode();
}
// change mode if it is supported
if (fsMode != null) {
dialog.setUndecorated(true);
screenDevice.setFullScreenWindow(dialog);
screenDevice.setDisplayMode(fsMode);
} else {
dialog.setUndecorated(true);
screenDevice.setFullScreenWindow(dialog);
}
} else {
dialog.setUndecorated(false);
}
dialog.setVisible(true);
dialog.toFront();
dialog.requestFocus();
dialog.setAlwaysOnTop(true);
}
use of java.awt.DisplayMode in project vft-capture by videofirst.
the class VfCaptureFrame method getCentredLocation.
private 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