本文整理匯總了Java中java.awt.DisplayMode.getBitDepth方法的典型用法代碼示例。如果您正苦於以下問題:Java DisplayMode.getBitDepth方法的具體用法?Java DisplayMode.getBitDepth怎麽用?Java DisplayMode.getBitDepth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.DisplayMode
的用法示例。
在下文中一共展示了DisplayMode.getBitDepth方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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());
}
示例4: 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;
}
示例5: 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;
}
示例6: checkGraphicsEnvironment
import java.awt.DisplayMode; //導入方法依賴的package包/類
static boolean checkGraphicsEnvironment() {
if (GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadless()) {
System.err.println("Cannot run test in a headless environment");
}
DisplayMode dm =
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode();
int i = dm.getBitDepth();
if (i == dm.BIT_DEPTH_MULTI || i >= 16) {
return true;
}
return false;
}
示例7: checkGraphicsEnvironment
import java.awt.DisplayMode; //導入方法依賴的package包/類
static boolean checkGraphicsEnvironment() {
if (GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadless()) {
System.err.println("Cannot run test in a headless environment");
}
DisplayMode dm =
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode();
int i = dm.getBitDepth();
if (i == dm.BIT_DEPTH_MULTI || i >= 16) {
return true;
}
return false;
}
示例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: SystemNode
import java.awt.DisplayMode; //導入方法依賴的package包/類
public SystemNode(GraphicsDevice device) {
super("System", device);
addStringChild("Java version", System.getProperty("java.version"));
addStringChild("Java vendor", System.getProperty("java.vendor"));
addStringChild("OS name", System.getProperty("os.name"));
DisplayMode displayMode = device.getDisplayMode();
int width = displayMode.getWidth();
int height = displayMode.getHeight();
int bitDepth = displayMode.getBitDepth();
addIntChild("display width", width);
addIntChild("display height", height);
addIntChild("display bit depth", bitDepth);
PixelitorWindow pw = PixelitorWindow.getInstance();
addIntChild("app window width", pw.getWidth());
addIntChild("app window height", pw.getHeight());
addStringChild("max memory", Utils.getMaxHeapInMegabytes() + " Mb");
addStringChild("used memory", Utils.getUsedMemoryInMegabytes() + " Mb");
GraphicsConfiguration configuration = device.getDefaultConfiguration();
ColorModel defaultColorModel = configuration.getColorModel();
ColorModelNode colorModelNode = new ColorModelNode("Default Color Model", defaultColorModel);
add(colorModelNode);
}
示例11: canSafelyRunPixelTests
import java.awt.DisplayMode; //導入方法依賴的package包/類
/** Determine if the graphics environment is 24 bit and has standard fonts,
* so pixel position and color tests will not erroneously fail. This method is
* thread safe.
*/
public static boolean canSafelyRunPixelTests() {
if (graphicsTestsSafe != null) {
return graphicsTestsSafe.booleanValue();
}
try {
boolean result = false;
if (GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadless()) {
System.err.println("Cannot run test in a headless environment");
graphicsTestsSafe = Boolean.FALSE;
return false;
}
DisplayMode dm =
GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getDisplayMode();
int i = dm.getBitDepth();
if (i == dm.BIT_DEPTH_MULTI || i >= 16) {
result = true;
Font f = UIManager.getFont("controlFont");
if (f == null) {
f = new JTable().getFont();
}
Graphics g = GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getDefaultConfiguration().
createCompatibleImage(10,10).getGraphics();
FontMetrics fm = g.getFontMetrics(f);
if (fm.getHeight() != 16) {
System.err.println("Cannot run this test - default font size is not " + 16 + " pixels in height - could lead to false fails");
System.err.println("Basic font size is " + fm.getHeight());
//Some environments, such as Mandrake linux or Windows with
//large fonts will supply fonts bigger than the error icon,
//causing the pixel tests to fail due to icon positioning
//differences
result = false;
}
}
if (result) {
result = tryPrototypePixelTest();
}
return result;
} catch (Exception e) {
graphicsTestsSafe = Boolean.FALSE;
e.printStackTrace();
return false;
}
}
示例12: 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());
}
示例13: deriveRR
import java.awt.DisplayMode; //導入方法依賴的package包/類
private static DisplayMode deriveRR(DisplayMode dm) {
return new DisplayMode(dm.getWidth(), dm.getHeight(),
dm.getBitDepth(), 777);
}