本文整理汇总了Java中java.awt.DisplayMode类的典型用法代码示例。如果您正苦于以下问题:Java DisplayMode类的具体用法?Java DisplayMode怎么用?Java DisplayMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DisplayMode类属于java.awt包,在下文中一共展示了DisplayMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例3: getCurrentDisplayMode
import java.awt.DisplayMode; //导入依赖的package包/类
@Override
protected DisplayMode getCurrentDisplayMode(final int screen) {
D3DRenderQueue rq = D3DRenderQueue.getInstance();
rq.lock();
try {
class Result {
DisplayMode dm = null;
};
final Result res = new Result();
rq.flushAndInvokeNow(new Runnable() {
public void run() {
res.dm = getCurrentDisplayModeNative(screen);
}
});
if (res.dm == null) {
return super.getCurrentDisplayMode(screen);
}
return res.dm;
} finally {
rq.unlock();
}
}
示例4: setDisplayMode
import java.awt.DisplayMode; //导入依赖的package包/类
@Override
public synchronized void setDisplayMode(DisplayMode dm) {
if (!isDisplayChangeSupported()) {
super.setDisplayMode(dm);
return;
}
if (dm == null || (dm = getMatchingDisplayMode(dm)) == null) {
throw new IllegalArgumentException("Invalid display mode");
}
if (getDisplayMode().equals(dm)) {
return;
}
Window w = getFullScreenWindow();
if (w != null) {
WWindowPeer peer = (WWindowPeer)w.getPeer();
configDisplayMode(screen, peer, dm.getWidth(), dm.getHeight(),
dm.getBitDepth(), dm.getRefreshRate());
// resize the fullscreen window to the dimensions of the new
// display mode
Rectangle screenBounds = getDefaultConfiguration().getBounds();
w.setBounds(screenBounds.x, screenBounds.y,
dm.getWidth(), dm.getHeight());
// Note: no call to replaceSurfaceData is required here since
// replacement will be caused by an upcoming display change event
} else {
throw new IllegalStateException("Must be in fullscreen mode " +
"in order to set display mode");
}
}
示例5: 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;
}
示例6: 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;
}
示例7: main
import java.awt.DisplayMode; //导入依赖的package包/类
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");
}
}
示例8: 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;
}
示例9: testWindowBounds
import java.awt.DisplayMode; //导入依赖的package包/类
private static void testWindowBounds(final DisplayMode dm, final Window w) {
if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
System.err.println(" Wrong window bounds:" +
" Expected: width = " + dm.getWidth()
+ ", height = " + dm.getHeight() + " Actual: "
+ w.getSize());
passed = false;
}
}
示例10: enumDisplayModes
import java.awt.DisplayMode; //导入依赖的package包/类
@Override
protected void enumDisplayModes(final int screen, final ArrayList<DisplayMode> modes) {
D3DRenderQueue rq = D3DRenderQueue.getInstance();
rq.lock();
try {
rq.flushAndInvokeNow(new Runnable() {
public void run() {
enumDisplayModesNative(screen, modes);
}
});
if (modes.size() == 0) {
modes.add(getCurrentDisplayModeNative(screen));
}
} finally {
rq.unlock();
}
}
示例11: setDisplayMode
import java.awt.DisplayMode; //导入依赖的package包/类
@Override
public synchronized void setDisplayMode(DisplayMode dm) {
if (!isDisplayChangeSupported()) {
super.setDisplayMode(dm);
return;
}
if (dm == null || (dm = getMatchingDisplayMode(dm)) == null) {
throw new IllegalArgumentException("Invalid display mode");
}
if (getDisplayMode().equals(dm)) {
return;
}
Window w = getFullScreenWindow();
if (w != null) {
WWindowPeer peer = AWTAccessor.getComponentAccessor().getPeer(w);
configDisplayMode(screen, peer, dm.getWidth(), dm.getHeight(),
dm.getBitDepth(), dm.getRefreshRate());
// resize the fullscreen window to the dimensions of the new
// display mode
Rectangle screenBounds = getDefaultConfiguration().getBounds();
w.setBounds(screenBounds.x, screenBounds.y,
dm.getWidth(), dm.getHeight());
// Note: no call to replaceSurfaceData is required here since
// replacement will be caused by an upcoming display change event
} else {
throw new IllegalStateException("Must be in fullscreen mode " +
"in order to set display mode");
}
}
示例12: ShowDisplayModes
import java.awt.DisplayMode; //导入依赖的package包/类
/**
* Creates new form ShowDisplayModes
*/
public ShowDisplayModes(Frame parent) {
this.parent = parent;
initComponents();
jToggleButton1.setSelected(doFullScreen);
GraphicsEnvironment environment =
GraphicsEnvironment.getLocalGraphicsEnvironment();
possibleModes = environment.getDefaultScreenDevice().getDisplayModes();
for (DisplayMode mode : possibleModes){
jComboBox1.addItem(
mode.getWidth()+ " x; "+mode.getHeight()+" y; "
+mode.getBitDepth() +" Bit; "+ mode.getRefreshRate()+" Hz");
}
}
示例13: loadWindowGeometryFromConfig
import java.awt.DisplayMode; //导入依赖的package包/类
public void loadWindowGeometryFromConfig() {
final Framework framework = Framework.getInstance();
String maximisedStr = framework.getConfigVar(CONFIG_GUI_MAIN_MAXIMISED, false);
String widthStr = framework.getConfigVar(CONFIG_GUI_MAIN_WIDTH, false);
String heightStr = framework.getConfigVar(CONFIG_GUI_MAIN_HEIGHT, false);
boolean maximised = (maximisedStr == null) ? true : Boolean.parseBoolean(maximisedStr);
setExtendedState(maximised ? JFrame.MAXIMIZED_BOTH : JFrame.NORMAL);
DisplayMode mode = getDisplayMode();
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(getGraphicsConfiguration());
int width = mode.getWidth() - insets.right - insets.left;
int height = mode.getHeight() - insets.top - insets.bottom;
if ((widthStr != null) && (heightStr != null)) {
width = Integer.parseInt(widthStr);
if (width < MIN_WIDTH) {
width = MIN_WIDTH;
}
height = Integer.parseInt(heightStr);
if (height < MIN_HEIGHT) {
height = MIN_HEIGHT;
}
}
setSize(width, height);
}
示例14: 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());
}
示例15: getBestDisplayMode
import java.awt.DisplayMode; //导入依赖的package包/类
/**
* Finds the best display mode the graphics device supports. Based on the
* preferred modes.
*
* @param device the device being inspected
*
* @return best display mode the given device supports
*/
protected DisplayMode getBestDisplayMode(final GraphicsDevice device) {
final Iterator itr = getPreferredDisplayModes(device).iterator();
while (itr.hasNext()) {
final DisplayMode each = (DisplayMode) itr.next();
final DisplayMode[] modes = device.getDisplayModes();
for (int i = 0; i < modes.length; i++) {
if (modes[i].getWidth() == each.getWidth() && modes[i].getHeight() == each.getHeight()
&& modes[i].getBitDepth() == each.getBitDepth()) {
return each;
}
}
}
return null;
}