本文整理汇总了Java中java.awt.BufferCapabilities类的典型用法代码示例。如果您正苦于以下问题:Java BufferCapabilities类的具体用法?Java BufferCapabilities怎么用?Java BufferCapabilities使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BufferCapabilities类属于java.awt包,在下文中一共展示了BufferCapabilities类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertOperationSupported
import java.awt.BufferCapabilities; //导入依赖的package包/类
@Override
public void assertOperationSupported(final int numBuffers,
final BufferCapabilities caps)
throws AWTException {
// Assume this method is never called with numBuffers != 2, as 0 is
// unsupported, and 1 corresponds to a SingleBufferStrategy which
// doesn't depend on the peer. Screen is considered as a separate
// "buffer".
if (numBuffers != 2) {
throw new AWTException("Only double buffering is supported");
}
final BufferCapabilities configCaps = getBufferCapabilities();
if (!configCaps.isPageFlipping()) {
throw new AWTException("Page flipping is not supported");
}
if (caps.getFlipContents() == BufferCapabilities.FlipContents.PRIOR) {
throw new AWTException("FlipContents.PRIOR is not supported");
}
}
示例2: flip
import java.awt.BufferCapabilities; //导入依赖的package包/类
@Override
public void flip(final LWComponentPeer<?, ?> peer, final Image backBuffer,
final int x1, final int y1, final int x2, final int y2,
final BufferCapabilities.FlipContents flipAction) {
final Graphics g = peer.getGraphics();
try {
g.drawImage(backBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
} finally {
g.dispose();
}
if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
final Graphics2D bg = (Graphics2D) backBuffer.getGraphics();
try {
bg.setBackground(peer.getBackground());
bg.clearRect(0, 0, backBuffer.getWidth(null),
backBuffer.getHeight(null));
} finally {
bg.dispose();
}
}
}
示例3: assertOperationSupported
import java.awt.BufferCapabilities; //导入依赖的package包/类
/**
* Checks that the requested configuration is natively supported; if not,
* an AWTException is thrown.
*/
@Override
public void assertOperationSupported(Component target,
int numBuffers,
BufferCapabilities caps)
throws AWTException
{
if (numBuffers < 2 || numBuffers > 4) {
throw new AWTException("Only 2-4 buffers supported");
}
if (caps.getFlipContents() == BufferCapabilities.FlipContents.COPIED &&
numBuffers != 2)
{
throw new AWTException("FlipContents.COPIED is only" +
"supported for 2 buffers");
}
}
示例4: createData
import java.awt.BufferCapabilities; //导入依赖的package包/类
/**
* Creates a SurfaceData object representing the back buffer of a
* double-buffered on-screen Window.
*/
public static D3DSurfaceData createData(WComponentPeer peer, Image image) {
D3DGraphicsConfig gc = getGC(peer);
if (gc == null || !peer.isAccelCapable()) {
return null;
}
BufferCapabilities caps = peer.getBackBufferCaps();
VSyncType vSyncType = VSYNC_DEFAULT;
if (caps instanceof ExtendedBufferCapabilities) {
vSyncType = ((ExtendedBufferCapabilities)caps).getVSync();
}
Rectangle r = peer.getBounds();
BufferCapabilities.FlipContents flip = caps.getFlipContents();
int swapEffect;
if (flip == FlipContents.COPIED) {
swapEffect = SWAP_COPY;
} else if (flip == FlipContents.PRIOR) {
swapEffect = SWAP_FLIP;
} else { // flip == FlipContents.UNDEFINED || .BACKGROUND
swapEffect = SWAP_DISCARD;
}
return new D3DSurfaceData(peer, gc, r.width, r.height,
image, peer.getColorModel(),
peer.getBackBuffersNum(),
swapEffect, vSyncType, FLIP_BACKBUFFER);
}
示例5: assertOperationSupported
import java.awt.BufferCapabilities; //导入依赖的package包/类
/**
* Checks that the requested configuration is natively supported; if not,
* an AWTException is thrown.
*/
@Override
public void assertOperationSupported(Component target,
int numBuffers,
BufferCapabilities caps)
throws AWTException
{
if (numBuffers > 2) {
throw new AWTException(
"Only double or single buffering is supported");
}
BufferCapabilities configCaps = getBufferCapabilities();
if (!configCaps.isPageFlipping()) {
throw new AWTException("Page flipping is not supported");
}
if (caps.getFlipContents() == BufferCapabilities.FlipContents.PRIOR) {
throw new AWTException("FlipContents.PRIOR is not supported");
}
}
示例6: createBackBuffer
import java.awt.BufferCapabilities; //导入依赖的package包/类
/**
* Attempts to create a GLX-based backbuffer for the given peer. If
* the requested configuration is not natively supported, an AWTException
* is thrown. Otherwise, if the backbuffer creation is successful, a
* value of 1 is returned.
*/
@Override
public long createBackBuffer(X11ComponentPeer peer,
int numBuffers, BufferCapabilities caps)
throws AWTException
{
if (numBuffers > 2) {
throw new AWTException(
"Only double or single buffering is supported");
}
BufferCapabilities configCaps = getBufferCapabilities();
if (!configCaps.isPageFlipping()) {
throw new AWTException("Page flipping is not supported");
}
if (caps.getFlipContents() == BufferCapabilities.FlipContents.PRIOR) {
throw new AWTException("FlipContents.PRIOR is not supported");
}
// non-zero return value means backbuffer creation was successful
// (checked in X11ComponentPeer.flip(), etc.)
return 1;
}
示例7: createBackBuffer
import java.awt.BufferCapabilities; //导入依赖的package包/类
/**
* Attempts to create an XDBE-based backbuffer for the given peer. If
* the requested configuration is not natively supported, an AWTException
* is thrown. Otherwise, if the backbuffer creation is successful, a
* handle to the native backbuffer is returned.
*/
public long createBackBuffer(X11ComponentPeer peer,
int numBuffers, BufferCapabilities caps)
throws AWTException
{
if (!X11GraphicsDevice.isDBESupported()) {
throw new AWTException("Page flipping is not supported");
}
if (numBuffers > 2) {
throw new AWTException(
"Only double or single buffering is supported");
}
BufferCapabilities configCaps = getBufferCapabilities();
if (!configCaps.isPageFlipping()) {
throw new AWTException("Page flipping is not supported");
}
long window = peer.getContentWindow();
int swapAction = getSwapAction(caps.getFlipContents());
return createBackBuffer(window, swapAction);
}
示例8: render
import java.awt.BufferCapabilities; //导入依赖的package包/类
public void render() {
ImageCapabilities imgBackBufCap = new ImageCapabilities(true);
ImageCapabilities imgFrontBufCap = new ImageCapabilities(true);
BufferCapabilities bufCap =
new BufferCapabilities(imgFrontBufCap,
imgBackBufCap, BufferCapabilities.FlipContents.COPIED);
try {
createBufferStrategy(2, bufCap);
} catch (AWTException ex) {
createBufferStrategy(2);
}
BufferStrategy bs = getBufferStrategy();
do {
Graphics g = bs.getDrawGraphics();
g.setColor(Color.green);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.red);
g.drawString("Rendering test", 20, 20);
g.drawImage(bi, 50, 50, null);
g.dispose();
bs.show();
} while (bs.contentsLost()||bs.contentsRestored());
}
示例9: flip
import java.awt.BufferCapabilities; //导入依赖的package包/类
public void flip (BufferCapabilities.FlipContents contents)
{
getGraphics().drawImage(backBuffer,
awtComponent.getWidth(),
awtComponent.getHeight(),
null);
// create new back buffer and clear it to the background color.
if (contents == BufferCapabilities.FlipContents.BACKGROUND)
{
backBuffer = createVolatileImage(awtComponent.getWidth(),
awtComponent.getHeight());
backBuffer.getGraphics().clearRect(0, 0,
awtComponent.getWidth(),
awtComponent.getHeight());
}
// FIXME: support BufferCapabilities.FlipContents.PRIOR
}