本文整理汇总了Java中java.awt.DisplayMode.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java DisplayMode.getHeight方法的具体用法?Java DisplayMode.getHeight怎么用?Java DisplayMode.getHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.DisplayMode
的用法示例。
在下文中一共展示了DisplayMode.getHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
}
示例4: 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);
}
示例5: 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());
}
示例6: 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;
}
示例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;
}
示例8: findDisplayMode
import java.awt.DisplayMode; //导入方法依赖的package包/类
private DisplayMode findDisplayMode() {
GraphicsDevice gd = getGraphicsConfiguration().getDevice();
DisplayMode dms[] = gd.getDisplayModes();
DisplayMode currentDM = gd.getDisplayMode();
for (DisplayMode dm : dms) {
if (dm.getBitDepth() > 8 &&
dm.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI &&
dm.getBitDepth() != currentDM.getBitDepth() &&
dm.getWidth() == currentDM.getWidth() &&
dm.getHeight() == currentDM.getHeight())
{
// found a mode which has the same dimensions but different
// depth
return dm;
}
if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI &&
(dm.getWidth() != currentDM.getWidth() ||
dm.getHeight() != currentDM.getHeight()))
{
// found a mode which has the same depth but different
// dimensions
return dm;
}
}
return null;
}
示例9: 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());
}
示例10: ScreenResolution
import java.awt.DisplayMode; //导入方法依赖的package包/类
/**
* Constructor where the resolution is computed.
*
* @param comp - the frame of the gui - needed to get the resolution of the screen where the app is showed
*/
public ScreenResolution(Component comp) {
//set the current screen resolution
GraphicsConfiguration graphicsCfg = comp.getGraphicsConfiguration();
DisplayMode displayMode = graphicsCfg.getDevice().getDisplayMode();
resolution = new Dimension(displayMode.getWidth(), displayMode.getHeight());
}
示例11: setDisplayMode
import java.awt.DisplayMode; //导入方法依赖的package包/类
public void setDisplayMode(DisplayMode dm)
{
if (fixedDisplayMode != null)
throw new UnsupportedOperationException("Cannnot change display mode.");
if (dm == null)
throw new IllegalArgumentException("DisplayMode must not be null.");
synchronized (this)
{
if (displayModes == null)
displayModes = nativeGetDisplayModes(env);
}
for (int i=0; i<displayModes.length; i++)
if (displayModes[i].width == dm.getWidth()
&& displayModes[i].height == dm.getHeight())
{
synchronized (this)
{
nativeSetDisplayMode(env,
i,
(short) dm.getRefreshRate());
bounds = null;
}
return;
}
throw new IllegalArgumentException("Mode not supported by this device.");
}
示例12: getCenterToScreenLocation
import java.awt.DisplayMode; //导入方法依赖的package包/类
public static Point getCenterToScreenLocation(final DisplayMode displayMode, final Dimension size) {
if (displayMode == null) {
return new Point();
}
final int x = displayMode.getWidth() / 2 - size.width / 2;
final int y = displayMode.getHeight() / 2 - size.height / 2;
return new Point(x, y);
}
示例13: checkDisplayMode
import java.awt.DisplayMode; //导入方法依赖的package包/类
static void checkDisplayMode(DisplayMode displayMode) {
if (displayMode == null || displayMode.getWidth() <= 1 || displayMode.getHeight() <= 1) {
throw new RuntimeException("invalid display mode");
}
}
示例14: 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());
}
示例15: deriveRR
import java.awt.DisplayMode; //导入方法依赖的package包/类
private static DisplayMode deriveRR(DisplayMode dm) {
return new DisplayMode(dm.getWidth(), dm.getHeight(),
dm.getBitDepth(), 777);
}