BufferStrategy.java 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* BufferStrategy.java -- describes image buffering resources
  2. Copyright (C) 2002, 2005 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package java.awt.image;
  32. import java.awt.BufferCapabilities;
  33. import java.awt.Graphics;
  34. /**
  35. * This class describes a strategy for managing image buffering
  36. * resources on a Canvas or Window. A given buffer strategy may make
  37. * use of hardware acceleration or take advantage of features of the
  38. * native graphics system. Examples of buffering strategies are
  39. * double or triple buffering using either flipping or blitting. For
  40. * the details of these algorithms see BufferCapabilities.
  41. *
  42. * To use a buffer strategy, you retrieve it from either the current
  43. * GraphicsConfiguration or from the Component on which you'd like to
  44. * draw. Then you can query the strategy's capabilities to make sure
  45. * they're suitable.
  46. *
  47. * If the strategy's capabilities are suitable, you can obtain a
  48. * graphics object and use it to draw with this strategy. Drawing
  49. * with a buffer strategy requires extra care, however. You'll need
  50. * to manually cause the next buffer to be shown on the output device.
  51. * And since buffer strategies are usually implemented with a
  52. * VolatileImage, you must frequently check that the contents of the
  53. * buffer are valid and that the buffer still exists.
  54. *
  55. * A buffer strategy is usually implemented using a VolatileImage.
  56. *
  57. * @see VolatileImage
  58. * @since 1.4
  59. */
  60. public abstract class BufferStrategy
  61. {
  62. /**
  63. * Creates a new buffer strategy.
  64. */
  65. public BufferStrategy()
  66. {
  67. }
  68. /**
  69. * Retrieves the capabilities of this buffer strategy.
  70. *
  71. * @return this buffer strategy's capabilities
  72. */
  73. public abstract BufferCapabilities getCapabilities();
  74. /**
  75. * Retrieves a graphics object that can be used to draw using this
  76. * buffer strategy. This method may not be synchronized so be
  77. * careful when calling it from multiple threads. You also must
  78. * manually dispose of this graphics object.
  79. *
  80. * @return a graphics object that can be used to draw using this
  81. * buffer strategy
  82. */
  83. public abstract Graphics getDrawGraphics();
  84. /**
  85. * Returns whether or not the buffer's resources have been reclaimed
  86. * by the native graphics system. If the buffer resources have been
  87. * lost then you'll need to obtain new resources before drawing
  88. * again. For details, see the documentation for VolatileImage.
  89. *
  90. * @return true if the contents were lost, false otherwise
  91. */
  92. public abstract boolean contentsLost();
  93. /**
  94. * Returns whether or not the buffer's resources were re-created and
  95. * cleared to the default background color. If the buffer's
  96. * resources have recently been re-created and initialized then the
  97. * buffer's image may need to be re-rendered. For details, see the
  98. * documentation for VolatileImage.
  99. *
  100. * @return true if the contents were restored, false otherwise
  101. */
  102. public abstract boolean contentsRestored();
  103. /**
  104. * Applies this buffer strategy. In other words, this method brings
  105. * the contents of the back or intermediate buffers to the front
  106. * buffer.
  107. */
  108. public abstract void show();
  109. }