Search in sources :

Example 11 with DisplayMode

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);
}
Also used : DisplayMode(java.awt.DisplayMode) GraphicsDevice(java.awt.GraphicsDevice)

Example 12 with DisplayMode

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;
}
Also used : DisplayMode(java.awt.DisplayMode) Dimension(java.awt.Dimension) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 13 with DisplayMode

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);
}
Also used : DisplayMode(java.awt.DisplayMode) GraphicsDevice(java.awt.GraphicsDevice)

Example 14 with DisplayMode

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);
}
Also used : DisplayMode(java.awt.DisplayMode)

Example 15 with DisplayMode

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;
}
Also used : DisplayMode(java.awt.DisplayMode) GraphicsDevice(java.awt.GraphicsDevice) Dimension(java.awt.Dimension) Point(java.awt.Point) GraphicsEnvironment(java.awt.GraphicsEnvironment) Point(java.awt.Point)

Aggregations

DisplayMode (java.awt.DisplayMode)31 GraphicsDevice (java.awt.GraphicsDevice)20 GraphicsEnvironment (java.awt.GraphicsEnvironment)9 Dimension (java.awt.Dimension)6 Frame (java.awt.Frame)4 ArrayList (java.util.ArrayList)4 LionEngineException (com.b3dgs.lionengine.LionEngineException)3 Graphics (java.awt.Graphics)3 Rectangle (java.awt.Rectangle)3 Component (java.awt.Component)2 Point (java.awt.Point)2 Robot (java.awt.Robot)2 Window (java.awt.Window)2 WindowAdapter (java.awt.event.WindowAdapter)2 WindowEvent (java.awt.event.WindowEvent)2 BufferedImage (java.awt.image.BufferedImage)2 Config (com.b3dgs.lionengine.Config)1 Resolution (com.b3dgs.lionengine.Resolution)1 AWTException (java.awt.AWTException)1 Button (java.awt.Button)1