107 lines
3.4 KiB
Java
107 lines
3.4 KiB
Java
/*
|
|
Copyright (C) 2009, 2011 Volker Berlin (i-net software)
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
warranty. In no event will the authors be held liable for any damages
|
|
arising from the use of this software.
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
including commercial applications, and to alter it and redistribute it
|
|
freely, subject to the following restrictions:
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
claim that you wrote the original software. If you use this software
|
|
in a product, an acknowledgment in the product documentation would be
|
|
appreciated but is not required.
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
misrepresented as being the original software.
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
Jeroen Frijters
|
|
jeroen@frijters.net
|
|
|
|
*/
|
|
package sun.java2d;
|
|
|
|
import java.awt.GraphicsConfiguration;
|
|
import java.awt.GraphicsDevice;
|
|
import java.awt.GraphicsEnvironment;
|
|
import java.awt.Insets;
|
|
import java.awt.peer.ComponentPeer;
|
|
import java.awt.Rectangle;
|
|
import java.awt.Toolkit;
|
|
|
|
import sun.awt.DisplayChangedListener;
|
|
import sun.awt.SunDisplayChanger;
|
|
|
|
|
|
|
|
/**
|
|
* A replacement of the Sun implementation that will extends from from NetGraphicsEnvironment
|
|
*/
|
|
public abstract class SunGraphicsEnvironment extends GraphicsEnvironment{
|
|
|
|
/**
|
|
* Return the bounds of a GraphicsDevice, less its screen insets.
|
|
* See also java.awt.GraphicsEnvironment.getUsableBounds();
|
|
*/
|
|
public static Rectangle getUsableBounds(GraphicsDevice gd) {
|
|
GraphicsConfiguration gc = gd.getDefaultConfiguration();
|
|
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
|
|
Rectangle usableBounds = gc.getBounds();
|
|
|
|
usableBounds.x += insets.left;
|
|
usableBounds.y += insets.top;
|
|
usableBounds.width -= (insets.left + insets.right);
|
|
usableBounds.height -= (insets.top + insets.bottom);
|
|
|
|
return usableBounds;
|
|
}
|
|
|
|
/**
|
|
* Returns true when the display is local, false for remote displays.
|
|
*
|
|
* @return true when the display is local, false for remote displays
|
|
*/
|
|
public abstract boolean isDisplayLocal();
|
|
|
|
/*
|
|
* ----DISPLAY CHANGE SUPPORT----
|
|
*/
|
|
|
|
protected SunDisplayChanger displayChanger = new SunDisplayChanger();
|
|
|
|
/**
|
|
* Add a DisplayChangeListener to be notified when the display settings
|
|
* are changed.
|
|
*/
|
|
public void addDisplayChangedListener(DisplayChangedListener client) {
|
|
displayChanger.add(client);
|
|
}
|
|
|
|
/**
|
|
* Remove a DisplayChangeListener from Win32GraphicsEnvironment
|
|
*/
|
|
public void removeDisplayChangedListener(DisplayChangedListener client) {
|
|
displayChanger.remove(client);
|
|
}
|
|
|
|
/*
|
|
* ----END DISPLAY CHANGE SUPPORT----
|
|
*/
|
|
|
|
/**
|
|
* Returns true if FlipBufferStrategy with COPIED buffer contents
|
|
* is preferred for this peer's GraphicsConfiguration over
|
|
* BlitBufferStrategy, false otherwise.
|
|
*
|
|
* The reason FlipBS could be preferred is that in some configurations
|
|
* an accelerated copy to the screen is supported (like Direct3D 9)
|
|
*
|
|
* @return true if flip strategy should be used, false otherwise
|
|
*/
|
|
public boolean isFlipStrategyPreferred(ComponentPeer peer) {
|
|
return false;
|
|
}
|
|
}
|