當前位置: 首頁>>代碼示例>>Java>>正文


Java DisplayMode.getRefreshRate方法代碼示例

本文整理匯總了Java中java.awt.DisplayMode.getRefreshRate方法的典型用法代碼示例。如果您正苦於以下問題:Java DisplayMode.getRefreshRate方法的具體用法?Java DisplayMode.getRefreshRate怎麽用?Java DisplayMode.getRefreshRate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.DisplayMode的用法示例。


在下文中一共展示了DisplayMode.getRefreshRate方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getScreenRefreshRate

import java.awt.DisplayMode; //導入方法依賴的package包/類
int getScreenRefreshRate() {
        int rate = 60;
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice[] gs = ge.getScreenDevices();
        for (int i = 0; i < gs.length; i++) {
            DisplayMode dm = gs[i].getDisplayMode();
            // Get refresh rate in Hz
            int refreshRate = dm.getRefreshRate();
            if (refreshRate == DisplayMode.REFRESH_RATE_UNKNOWN) {
//                log.warning("MotionViewer.getScreenRefreshRate: got unknown refresh rate for screen "+i+", assuming 60");
                refreshRate = 60;
            } else {
//                log.info("MotionViewer.getScreenRefreshRate: screen "+i+" has refresh rate "+refreshRate);
            }
            if (i == 0) {
                rate = refreshRate;
            }
        }
        return rate;
    }
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:21,代碼來源:MotionViewer.java

示例2: getScreenRefreshRate

import java.awt.DisplayMode; //導入方法依賴的package包/類
int getScreenRefreshRate() {
    int rate = 60;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    if (ge == null) {
        return rate;
    }
    GraphicsDevice[] gs = ge.getScreenDevices();
    for (int i = 0; i < gs.length; i++) {
        DisplayMode dm = gs[i].getDisplayMode();
        // Get refresh rate in Hz
        if (dm == null) {
            return rate;
        }
        int refreshRate = dm.getRefreshRate();
        if (refreshRate == DisplayMode.REFRESH_RATE_UNKNOWN) {
            log.warning("AEViewer.getScreenRefreshRate: got unknown refresh rate for screen " + i + ", assuming 60");
            refreshRate = 60;
        } else {
            //                log.info("AEViewer.getScreenRefreshRate: screen "+i+" has refresh rate "+refreshRate);
        }
        if (i == 0) {
            rate = refreshRate;
        }
    }
    return rate;
}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:27,代碼來源:AEViewer.java

示例3: getMatchingDisplayMode

import java.awt.DisplayMode; //導入方法依賴的package包/類
protected synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        return null;
    }
    DisplayMode[] modes = getDisplayModes();
    for (DisplayMode mode : modes) {
        if (dm.equals(mode) ||
            (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
             dm.getWidth() == mode.getWidth() &&
             dm.getHeight() == mode.getHeight() &&
             dm.getBitDepth() == mode.getBitDepth()))
        {
            return mode;
        }
    }
    return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:Win32GraphicsDevice.java

示例4: getMatchingDisplayMode

import java.awt.DisplayMode; //導入方法依賴的package包/類
private synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        return null;
    }
    DisplayMode[] modes = getDisplayModes();
    for (DisplayMode mode : modes) {
        if (dm.equals(mode) ||
            (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
             dm.getWidth() == mode.getWidth() &&
             dm.getHeight() == mode.getHeight() &&
             dm.getBitDepth() == mode.getBitDepth()))
        {
            return mode;
        }
    }
    return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:X11GraphicsDevice.java

示例5: findDisplayMode

import java.awt.DisplayMode; //導入方法依賴的package包/類
/**
 * Finds a display mode that is different from the current display
 * mode and is likely to cause a display change event.
 */
private static DisplayMode findDisplayMode(GraphicsDevice gd) {
    DisplayMode dms[] = gd.getDisplayModes();
    DisplayMode currentDM = gd.getDisplayMode();
    for (DisplayMode dm : dms) {
        if (!dm.equals(currentDM) &&
             dm.getRefreshRate() == currentDM.getRefreshRate())
        {
            // different from the current dm and refresh rate is the same
            // means that something else is different => more likely to
            // cause a DM change event
            return dm;
        }
    }
    return null;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:20,代碼來源:DisplayModeChanger.java

示例6: init

import java.awt.DisplayMode; //導入方法依賴的package包/類
private void init(int deviceID) throws Exception {
	if (deviceID < -1)
		throw new Exception("Unknown Device Handle");
	ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
	if (deviceID != -1) {
		screen = ge.getScreenDevices()[deviceID];
	}
	else {
		screen = ge.getDefaultScreenDevice();
	}
	
	DisplayMode mode = screen.getDisplayMode();
	refreshRate = mode.getRefreshRate();
	bitDepth = mode.getBitDepth();
	colors = (int) Math.pow(2, bitDepth);
	dimensions = new Vector2(mode.getWidth(), mode.getHeight());
}
 
開發者ID:nickclark2016,項目名稱:JavaGraphicsEngine,代碼行數:18,代碼來源:Device.java

示例7: compare

import java.awt.DisplayMode; //導入方法依賴的package包/類
/**
 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
 */
public int compare(DisplayMode a, DisplayMode b) {
    // Width
    if (a.getWidth() != b.getWidth()) {
        return (a.getWidth() > b.getWidth()) ? 1 : -1;
    }
    // Height
    if (a.getHeight() != b.getHeight()) {
        return (a.getHeight() > b.getHeight()) ? 1 : -1;
    }
    // Bit depth
    if (a.getBitDepth() != b.getBitDepth()) {
        return (a.getBitDepth() > b.getBitDepth()) ? 1 : -1;
    }
    // Refresh rate
    if (a.getRefreshRate() != b.getRefreshRate()) {
        return (a.getRefreshRate() > b.getRefreshRate()) ? 1 : -1;
    }
    // All fields are equal
    return 0;
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:24,代碼來源:SettingsDialog.java

示例8: deriveDepth

import java.awt.DisplayMode; //導入方法依賴的package包/類
private static DisplayMode deriveDepth(DisplayMode dm) {
    int depth;
    if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI) {
        depth = 77;
    } else {
        depth = DisplayMode.BIT_DEPTH_MULTI;
    }
    return new DisplayMode(dm.getWidth(), dm.getHeight(),
                           depth, dm.getRefreshRate());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:NonExistentDisplayModeTest.java

示例9: deriveSize

import java.awt.DisplayMode; //導入方法依賴的package包/類
private static DisplayMode deriveSize(DisplayMode dm) {
    int w = dm.getWidth() / 7;
    int h = dm.getHeight() / 3;
    return new DisplayMode(w, h, dm.getBitDepth(), dm.getRefreshRate());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:6,代碼來源:NonExistentDisplayModeTest.java


注:本文中的java.awt.DisplayMode.getRefreshRate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。