JavaTM Platform
Standard Ed. 6

java.awt.image
クラス BufferStrategy

java.lang.Object
  上位を拡張 java.awt.image.BufferStrategy
直系の既知のサブクラス:
Component.BltBufferStrategy, Component.FlipBufferStrategy

public abstract class BufferStrategy
extends Object

BufferStrategy クラスは、特定の Canvas または Window 上の複雑なメモリーを編成するメカニズムを表します。特定のバッファーストラテジが実装可能かどうか、およびその実装方法は、ハードウェアとソフトウェアの制限事項によって決まります。これらの制限事項は、Canvas または Window を作成するときに使用する GraphicsConfiguration の機能を介して検出されます。  

「バッファー」および「表面」という語は同義であり、ビデオデバイスメモリー内またはシステムメモリー内での連続したメモリー領域を指します。  

複雑なバッファーストラテジには、順次リングバッファリング、Blit バッファリングなどいくつかの種類があります。もっとも一般的なのは、順次リングバッファリング (ダブルバッファリングまたはトリプルバッファリング) です。アプリケーションは単一の「バックバッファー」へ描画してから、データを複製するかビデオポインタを移動することにより単一ステップで内容をフロント (ディスプレイ) へ移動します。ビデオポインタを移動することでバッファーが交換され、最初に描画されたバッファーまたはデバイスに現在表示されているイメージが「フロントバッファー」になります。 これは「ページフリッピング」と呼ばれます。  

代わりに、ビデオポインタを移動するのではなく、チェーン内で先行してバックバッファーの内容を複製または「Blit」することができます。  

 Double buffering:

                    ***********         ***********
                    *         * ------> *         *
 [To display] <---- * Front B *   Show  * Back B. * <---- Rendering
                    *         * <------ *         *
                    ***********         ***********

 Triple buffering:

 [To      ***********         ***********        ***********
 display] *         * --------+---------+------> *         *
    <---- * Front B *   Show  * Mid. B. *        * Back B. * <---- Rendering
          *         * <------ *         * <----- *         *
          ***********         ***********        ***********

 

バッファーストラテジの作成と使用の例を示します。



 // Check the capabilities of the GraphicsConfiguration
 ...

 // Create our component
 Window w = new Window(gc);

 // Show our window
 w.setVisible(true);

 // Create a general double-buffering strategy
 w.createBufferStrategy(2);
 BufferStrategy strategy = w.getBufferStrategy();

 // Main loop
 while (!done) {
     // Prepare for rendering the next frame
     // ...

     // Render single frame
     do {
         // The following loop ensures that the contents of the drawing buffer
         // are consistent in case the underlying surface was recreated
         do {
             // Get a new graphics context every time through the loop
             // to make sure the strategy is validated
             Graphics graphics = strategy.getDrawGraphics();
     
             // Render to graphics
             // ...

             // Dispose the graphics
             graphics.dispose();

             // Repeat the rendering if the drawing buffer contents 
             // were restored
         } while (strategy.contentsRestored());

         // Display the buffer
         strategy.show();

         // Repeat the rendering if the drawing buffer was lost
     } while (strategy.contentsLost());
 }

 // Dispose the window
 w.setVisible(false);
 w.dispose();
 

導入されたバージョン:
1.4
関連項目:
Component, GraphicsConfiguration, VolatileImage

コンストラクタの概要
BufferStrategy()
           
 
メソッドの概要
abstract  boolean contentsLost()
          getDrawGraphics への最後の呼び出しのために描画バッファーが消失したかどうかを返します。
abstract  boolean contentsRestored()
          描画バッファーが消失状態から最近復元され、デフォルトのバックグラウンドカラー (白) に再初期化されたかどうかを返します。
 void dispose()
          この BufferStrategy が現在使用しているシステムリソースを解放し、関連する Component から削除します。
abstract  BufferCapabilities getCapabilities()
          この BufferStrategyBufferCapabilities を返します。
abstract  Graphics getDrawGraphics()
          描画バッファーのグラフィックスコンテキストを作成します。
abstract  void show()
          メモリーを複製 (Blit) するかディスプレイポインタを変更する (切り替える) ことにより、次に使用可能なバッファーを可視状態にします。
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

BufferStrategy

public BufferStrategy()
メソッドの詳細

getCapabilities

public abstract BufferCapabilities getCapabilities()
この BufferStrategyBufferCapabilities を返します。

戻り値:
この方針のバッファー容量

getDrawGraphics

public abstract Graphics getDrawGraphics()
描画バッファーのグラフィックスコンテキストを作成します。このメソッドはパフォーマンスの理由から同期しない場合があります。複数スレッドでこのメソッドを使用するには、アプリケーションレベルでの処理が必要です。取得したグラフィックスオブジェクトの処理は、アプリケーション側で行う必要があります。

戻り値:
描画バッファーのグラフィックスコンテキスト

contentsLost

public abstract boolean contentsLost()
getDrawGraphics への最後の呼び出しのために描画バッファーが消失したかどうかを返します。バッファーストラテジ内のバッファーは通常、VolatileImage 型であるため消失することがあります。消失バッファーについては、VolatileImage を参照してください。

戻り値:
getDrawGraphics への最後の呼び出しのために 描画バッファーが消失したかどうか
関連項目:
VolatileImage

contentsRestored

public abstract boolean contentsRestored()
描画バッファーが消失状態から最近復元され、デフォルトのバックグラウンドカラー (白) に再初期化されたかどうかを返します。バッファーストラテジ内のバッファーは通常、VolatileImage 型であるため消失することがあります。getDrawGraphics への最後の呼び出しのために消失状態にあった表面が最近復元された場合は、再ペイントが必要なこともあります。消失バッファーについては、VolatileImage を参照してください。

戻り値:
getDrawGraphics への最後の呼び出しのために 描画バッファーが復元されたかどうか
関連項目:
VolatileImage

show

public abstract void show()
メモリーを複製 (Blit) するかディスプレイポインタを変更する (切り替える) ことにより、次に使用可能なバッファーを可視状態にします。


dispose

public void dispose()
この BufferStrategy が現在使用しているシステムリソースを解放し、関連する Component から削除します。このメソッドを呼び出したあと、getBufferStrategy は null を返します。BufferStrategy を破棄したあとで再度使用しようとすると、定義されていない動作が発生します。

導入されたバージョン:
1.6
関連項目:
Component.createBufferStrategy(int), Component.getBufferStrategy()

JavaTM Platform
Standard Ed. 6

バグの報告と機能のリクエスト
さらに詳しい API リファレンスおよび開発者ドキュメントについては、Java SE 開発者用ドキュメントを参照してください。開発者向けの詳細な解説、概念の概要、用語の定義、バグの回避策、およびコード実例が含まれています。

Copyright 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Documentation Redistribution Policy も参照してください。