/**
* Farthest JComponent ancestor for the current paint/copyArea.
*/
private JComponent rootJ;
/**
* Parent Applet/Window for the current paint/copyArea
*/
private Container root;
/**
* Location of component being painted relative to root.
*/
private int xOffset;
/**
* Location of component being painted relative to root.
*/
private int yOffset;
/**
* Graphics from the BufferStrategy.
*/
private Graphics bsg;
/**
* BufferStrategy currently being used.
*/
private BufferStrategy bufferStrategy;
/**
* BufferInfo corresponding to root.
*/
private BufferInfo bufferInfo;
/**
* Set to true if the bufferInfo needs to be disposed when current
* paint loop is done.
*/
private boolean disposeBufferOnEnd;
static {
TRY_FLIP = "true".equals(AccessController.doPrivileged(
new GetPropertyAction("swing.useFlipBufferStrategy", "false")));
}
private static Method getGetBufferStrategyMethod() {
if (COMPONENT_GET_BUFFER_STRATEGY_METHOD == null) {
getMethods();
}
return COMPONENT_GET_BUFFER_STRATEGY_METHOD;
}
private static Method getCreateBufferStrategyMethod() {
if (COMPONENT_CREATE_BUFFER_STRATEGY_METHOD == null) {
getMethods();
}
return COMPONENT_CREATE_BUFFER_STRATEGY_METHOD;
}
private static void getMethods() {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Object>() {
public Object run() {
try {
COMPONENT_CREATE_BUFFER_STRATEGY_METHOD = Component.class.
getDeclaredMethod("createBufferStrategy",
new Class[] { int.class,
BufferCapabilities.class });
COMPONENT_CREATE_BUFFER_STRATEGY_METHOD.
setAccessible(true);
COMPONENT_GET_BUFFER_STRATEGY_METHOD = Component.class.
getDeclaredMethod("getBufferStrategy");
COMPONENT_GET_BUFFER_STRATEGY_METHOD.setAccessible(true);
} catch (SecurityException e) {
assert false;
} catch (NoSuchMethodException nsme) {
assert false;
}
return null;
}
});
}
BufferStrategyPaintManager() {
bufferInfos = new ArrayList<BufferInfo>(1);
}
//
// PaintManager methods
//
/**
* Cleans up any created BufferStrategies.
*/
protected void dispose() {
// dipose can be invoked at any random time. To avoid
// threading dependancies we do the actual diposing via an
// invokeLater.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
java.util.List<BufferInfo> bufferInfos;
synchronized(BufferStrategyPaintManager.this) {
while (showing) {
=2= |