1. /*
  2. * @(#)ImageObserver.java 1.26 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.awt.image;
  8. import java.awt.Image;
  9. /**
  10. * An asynchronous update interface for receiving notifications about
  11. * Image information as the Image is constructed.
  12. *
  13. * @version 1.26 01/23/03
  14. * @author Jim Graham
  15. */
  16. public interface ImageObserver {
  17. /**
  18. * This method is called when information about an image which was
  19. * previously requested using an asynchronous interface becomes
  20. * available. Asynchronous interfaces are method calls such as
  21. * getWidth(ImageObserver) and drawImage(img, x, y, ImageObserver)
  22. * which take an ImageObserver object as an argument. Those methods
  23. * register the caller as interested either in information about
  24. * the overall image itself (in the case of getWidth(ImageObserver))
  25. * or about an output version of an image (in the case of the
  26. * drawImage(img, x, y, [w, h,] ImageObserver) call).
  27. *
  28. * <p>This method
  29. * should return true if further updates are needed or false if the
  30. * required information has been acquired. The image which was being
  31. * tracked is passed in using the img argument. Various constants
  32. * are combined to form the infoflags argument which indicates what
  33. * information about the image is now available. The interpretation
  34. * of the x, y, width, and height arguments depends on the contents
  35. * of the infoflags argument.
  36. * <p>
  37. * The <code>infoflags</code> argument should be the bitwise inclusive
  38. * <b>OR</b> of the following flags: <code>WIDTH</code>,
  39. * <code>HEIGHT</code>, <code>PROPERTIES</code>, <code>SOMEBITS</code>,
  40. * <code>FRAMEBITS</code>, <code>ALLBITS</code>, <code>ERROR</code>,
  41. * <code>ABORT</code>.
  42. *
  43. * @param img the image being observed.
  44. * @param infoflags the bitwise inclusive OR of the following
  45. * flags: <code>WIDTH</code>, <code>HEIGHT</code>,
  46. * <code>PROPERTIES</code>, <code>SOMEBITS</code>,
  47. * <code>FRAMEBITS</code>, <code>ALLBITS</code>,
  48. * <code>ERROR</code>, <code>ABORT</code>.
  49. * @param x the <i>x</i> coordinate.
  50. * @param y the <i>y</i> coordinate.
  51. * @param width the width.
  52. * @param height the height.
  53. * @return <code>false</code> if the infoflags indicate that the
  54. * image is completely loaded; <code>true</code> otherwise.
  55. *
  56. * @see #WIDTH
  57. * @see #HEIGHT
  58. * @see #PROPERTIES
  59. * @see #SOMEBITS
  60. * @see #FRAMEBITS
  61. * @see #ALLBITS
  62. * @see #ERROR
  63. * @see #ABORT
  64. * @see Image#getWidth
  65. * @see Image#getHeight
  66. * @see java.awt.Graphics#drawImage
  67. */
  68. public boolean imageUpdate(Image img, int infoflags,
  69. int x, int y, int width, int height);
  70. /**
  71. * This flag in the infoflags argument to imageUpdate indicates that
  72. * the width of the base image is now available and can be taken
  73. * from the width argument to the imageUpdate callback method.
  74. * @see Image#getWidth
  75. * @see #imageUpdate
  76. */
  77. public static final int WIDTH = 1;
  78. /**
  79. * This flag in the infoflags argument to imageUpdate indicates that
  80. * the height of the base image is now available and can be taken
  81. * from the height argument to the imageUpdate callback method.
  82. * @see Image#getHeight
  83. * @see #imageUpdate
  84. */
  85. public static final int HEIGHT = 2;
  86. /**
  87. * This flag in the infoflags argument to imageUpdate indicates that
  88. * the properties of the image are now available.
  89. * @see Image#getProperty
  90. * @see #imageUpdate
  91. */
  92. public static final int PROPERTIES = 4;
  93. /**
  94. * This flag in the infoflags argument to imageUpdate indicates that
  95. * more pixels needed for drawing a scaled variation of the image
  96. * are available. The bounding box of the new pixels can be taken
  97. * from the x, y, width, and height arguments to the imageUpdate
  98. * callback method.
  99. * @see java.awt.Graphics#drawImage
  100. * @see #imageUpdate
  101. */
  102. public static final int SOMEBITS = 8;
  103. /**
  104. * This flag in the infoflags argument to imageUpdate indicates that
  105. * another complete frame of a multi-frame image which was previously
  106. * drawn is now available to be drawn again. The x, y, width, and height
  107. * arguments to the imageUpdate callback method should be ignored.
  108. * @see java.awt.Graphics#drawImage
  109. * @see #imageUpdate
  110. */
  111. public static final int FRAMEBITS = 16;
  112. /**
  113. * This flag in the infoflags argument to imageUpdate indicates that
  114. * a static image which was previously drawn is now complete and can
  115. * be drawn again in its final form. The x, y, width, and height
  116. * arguments to the imageUpdate callback method should be ignored.
  117. * @see java.awt.Graphics#drawImage
  118. * @see #imageUpdate
  119. */
  120. public static final int ALLBITS = 32;
  121. /**
  122. * This flag in the infoflags argument to imageUpdate indicates that
  123. * an image which was being tracked asynchronously has encountered
  124. * an error. No further information will become available and
  125. * drawing the image will fail.
  126. * As a convenience, the ABORT flag will be indicated at the same
  127. * time to indicate that the image production was aborted.
  128. * @see #imageUpdate
  129. */
  130. public static final int ERROR = 64;
  131. /**
  132. * This flag in the infoflags argument to imageUpdate indicates that
  133. * an image which was being tracked asynchronously was aborted before
  134. * production was complete. No more information will become available
  135. * without further action to trigger another image production sequence.
  136. * If the ERROR flag was not also set in this image update, then
  137. * accessing any of the data in the image will restart the production
  138. * again, probably from the beginning.
  139. * @see #imageUpdate
  140. */
  141. public static final int ABORT = 128;
  142. }