001/* BufferStrategy.java -- describes image buffering resources
002   Copyright (C) 2002, 2005 Free Software Foundation, Inc.
003
004This file is part of GNU Classpath.
005
006GNU Classpath is free software; you can redistribute it and/or modify
007it under the terms of the GNU General Public License as published by
008the Free Software Foundation; either version 2, or (at your option)
009any later version.
010
011GNU Classpath is distributed in the hope that it will be useful, but
012WITHOUT ANY WARRANTY; without even the implied warranty of
013MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014General Public License for more details.
015
016You should have received a copy of the GNU General Public License
017along with GNU Classpath; see the file COPYING.  If not, write to the
018Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
01902110-1301 USA.
020
021Linking this library statically or dynamically with other modules is
022making a combined work based on this library.  Thus, the terms and
023conditions of the GNU General Public License cover the whole
024combination.
025
026As a special exception, the copyright holders of this library give you
027permission to link this library with independent modules to produce an
028executable, regardless of the license terms of these independent
029modules, and to copy and distribute the resulting executable under
030terms of your choice, provided that you also meet, for each linked
031independent module, the terms and conditions of the license of that
032module.  An independent module is a module which is not derived from
033or based on this library.  If you modify this library, you may extend
034this exception to your version of the library, but you are not
035obligated to do so.  If you do not wish to do so, delete this
036exception statement from your version. */
037
038
039package java.awt.image;
040
041import java.awt.BufferCapabilities;
042import java.awt.Graphics;
043
044/**
045 * This class describes a strategy for managing image buffering
046 * resources on a Canvas or Window.  A given buffer strategy may make
047 * use of hardware acceleration or take advantage of features of the
048 * native graphics system.  Examples of buffering strategies are
049 * double or triple buffering using either flipping or blitting.  For
050 * the details of these algorithms see BufferCapabilities.
051 *
052 * To use a buffer strategy, you retrieve it from either the current
053 * GraphicsConfiguration or from the Component on which you'd like to
054 * draw.  Then you can query the strategy's capabilities to make sure
055 * they're suitable.
056 *
057 * If the strategy's capabilities are suitable, you can obtain a
058 * graphics object and use it to draw with this strategy.  Drawing
059 * with a buffer strategy requires extra care, however.  You'll need
060 * to manually cause the next buffer to be shown on the output device.
061 * And since buffer strategies are usually implemented with a
062 * VolatileImage, you must frequently check that the contents of the
063 * buffer are valid and that the buffer still exists.
064 *
065 * A buffer strategy is usually implemented using a VolatileImage.
066 *
067 * @see VolatileImage
068 * @since 1.4
069 */
070public abstract class BufferStrategy
071{
072  /**
073   * Creates a new buffer strategy.
074   */
075  public BufferStrategy()
076  {
077  }
078
079  /**
080   * Retrieves the capabilities of this buffer strategy.
081   *
082   * @return this buffer strategy's capabilities
083   */
084  public abstract BufferCapabilities getCapabilities();
085
086  /**
087   * Retrieves a graphics object that can be used to draw using this
088   * buffer strategy.  This method may not be synchronized so be
089   * careful when calling it from multiple threads.  You also must
090   * manually dispose of this graphics object.
091   *
092   * @return a graphics object that can be used to draw using this
093   * buffer strategy
094   */
095  public abstract Graphics getDrawGraphics();
096
097  /**
098   * Returns whether or not the buffer's resources have been reclaimed
099   * by the native graphics system.  If the buffer resources have been
100   * lost then you'll need to obtain new resources before drawing
101   * again.  For details, see the documentation for VolatileImage.
102   *
103   * @return true if the contents were lost, false otherwise
104   */
105  public abstract boolean contentsLost();
106
107  /**
108   * Returns whether or not the buffer's resources were re-created and
109   * cleared to the default background color.  If the buffer's
110   * resources have recently been re-created and initialized then the
111   * buffer's image may need to be re-rendered.  For details, see the
112   * documentation for VolatileImage.
113   *
114   * @return true if the contents were restored, false otherwise
115   */
116  public abstract boolean contentsRestored();
117
118  /**
119   * Applies this buffer strategy.  In other words, this method brings
120   * the contents of the back or intermediate buffers to the front
121   * buffer.
122   */
123  public abstract void show();
124}