This is an implementation of a GraphicsEnvironment object for the
default local GraphicsEnvironment used by the Java Runtime Environment
for Windows.
Method from sun.awt.Win32GraphicsEnvironment Detail: |
public void displayChanged() {
// getNumScreens() will return the correct current number of screens
GraphicsDevice newDevices[] = new GraphicsDevice[getNumScreens()];
GraphicsDevice oldScreens[] = screens;
// go through the list of current devices and determine if they
// could be reused, or will have to be replaced
if (oldScreens != null) {
for (int i = 0; i < oldScreens.length; i++) {
if (!(screens[i] instanceof Win32GraphicsDevice)) {
// REMIND: can we ever have anything other than Win32GD?
assert (false) : oldScreens[i];
continue;
}
Win32GraphicsDevice gd = (Win32GraphicsDevice)oldScreens[i];
// devices may be invalidated from the native code when the
// display change happens (device add/removal also causes a
// display change)
if (!gd.isValid()) {
if (oldDevices == null) {
oldDevices =
new ArrayList< WeakReference< Win32GraphicsDevice > >();
}
oldDevices.add(new WeakReference< Win32GraphicsDevice >(gd));
} else if (i < newDevices.length) {
// reuse the device
newDevices[i] = gd;
}
}
oldScreens = null;
}
// create the new devices (those that weren't reused)
for (int i = 0; i < newDevices.length; i++) {
if (newDevices[i] == null) {
newDevices[i] = makeScreenDevice(i);
}
}
// install the new array of devices
// Note: no synchronization here, it doesn't matter if a thread gets
// a new or an old array this time around
screens = newDevices;
for (GraphicsDevice gd : screens) {
if (gd instanceof DisplayChangedListener) {
((DisplayChangedListener)gd).displayChanged();
}
}
// re-invalidate all old devices. It's needed because those in the list
// may become "invalid" again - if the current default device is removed,
// for example. Also, they need to be notified about display
// changes as well.
if (oldDevices != null) {
int defScreen = getDefaultScreen();
for (ListIterator< WeakReference< Win32GraphicsDevice > > it =
oldDevices.listIterator(); it.hasNext();)
{
Win32GraphicsDevice gd = it.next().get();
if (gd != null) {
gd.invalidate(defScreen);
gd.displayChanged();
} else {
// no more references to this device, remove it
it.remove();
}
}
}
// Reset the static GC for the (possibly new) default screen
WToolkit.resetGC();
// notify SunDisplayChanger list (e.g. VolatileSurfaceManagers and
// CachingSurfaceManagers) about the display change event
displayChanger.notifyListeners();
// note: do not call super.displayChanged, we've already done everything
}
|
protected native int getDefaultScreen()
|
public GraphicsDevice getDefaultScreenDevice() {
return getScreenDevices()[getDefaultScreen()];
}
|
protected native int getNumScreens()
|
public native int getXResolution()
Returns the number of pixels per logical inch along the screen width.
In a system with multiple display monitors, this value is the same for
all monitors. |
public native int getYResolution()
Returns the number of pixels per logical inch along the screen height.
In a system with multiple display monitors, this value is the same for
all monitors. |
public static void initDisplayWrapper() {
if (!displayInitialized) {
displayInitialized = true;
initDisplay();
}
}
|
public static boolean isDWMCompositionEnabled() {
return isDWMCompositionEnabled;
}
Returns true if dwm composition is currently enabled, false otherwise. |
public boolean isDisplayLocal() {
return true;
}
|
public boolean isFlipStrategyPreferred(ComponentPeer peer) {
GraphicsConfiguration gc;
if (peer != null && (gc = peer.getGraphicsConfiguration()) != null) {
GraphicsDevice gd = gc.getDevice();
if (gd instanceof D3DGraphicsDevice) {
return ((D3DGraphicsDevice)gd).isD3DEnabledOnDevice();
}
}
return false;
}
|
public static native boolean isVistaOS()
Used to find out if the OS is Windows Vista or later. |
protected GraphicsDevice makeScreenDevice(int screennum) {
GraphicsDevice device = null;
if (WindowsFlags.isD3DEnabled()) {
device = D3DGraphicsDevice.createDevice(screennum);
}
if (device == null) {
device = new Win32GraphicsDevice(screennum);
}
return device;
}
|