1. /*
  2. * @(#)ImageObserver.java 1.22 01/11/29
  3. *
  4. * Copyright 2002 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.22 11/29/01
  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 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. * @see #WIDTH
  43. * @see #HEIGHT
  44. * @see #PROPERTIES
  45. * @see #SOMEBITS
  46. * @see #FRAMEBITS
  47. * @see #ALLBITS
  48. * @see #ERROR
  49. * @see #ABORT
  50. * @see Image#getWidth
  51. * @see Image#getHeight
  52. * @see java.awt.Graphics#drawImage
  53. */
  54. public boolean imageUpdate(Image img, int infoflags,
  55. int x, int y, int width, int height);
  56. /**
  57. * This flag in the infoflags argument to imageUpdate indicates that
  58. * the width of the base image is now available and can be taken
  59. * from the width argument to the imageUpdate callback method.
  60. * @see Image#getWidth
  61. * @see #imageUpdate
  62. */
  63. public static final int WIDTH = 1;
  64. /**
  65. * This flag in the infoflags argument to imageUpdate indicates that
  66. * the height of the base image is now available and can be taken
  67. * from the height argument to the imageUpdate callback method.
  68. * @see Image#getHeight
  69. * @see #imageUpdate
  70. */
  71. public static final int HEIGHT = 2;
  72. /**
  73. * This flag in the infoflags argument to imageUpdate indicates that
  74. * the properties of the image are now available.
  75. * @see Image#getProperty
  76. * @see #imageUpdate
  77. */
  78. public static final int PROPERTIES = 4;
  79. /**
  80. * This flag in the infoflags argument to imageUpdate indicates that
  81. * more pixels needed for drawing a scaled variation of the image
  82. * are available. The bounding box of the new pixels can be taken
  83. * from the x, y, width, and height arguments to the imageUpdate
  84. * callback method.
  85. * @see java.awt.Graphics#drawImage
  86. * @see #imageUpdate
  87. */
  88. public static final int SOMEBITS = 8;
  89. /**
  90. * This flag in the infoflags argument to imageUpdate indicates that
  91. * another complete frame of a multi-frame image which was previously
  92. * drawn is now available to be drawn again. The x, y, width, and height
  93. * arguments to the imageUpdate callback method should be ignored.
  94. * @see java.awt.Graphics#drawImage
  95. * @see #imageUpdate
  96. */
  97. public static final int FRAMEBITS = 16;
  98. /**
  99. * This flag in the infoflags argument to imageUpdate indicates that
  100. * a static image which was previously drawn is now complete and can
  101. * be drawn again in its final form. The x, y, width, and height
  102. * arguments to the imageUpdate callback method should be ignored.
  103. * @see java.awt.Graphics#drawImage
  104. * @see #imageUpdate
  105. */
  106. public static final int ALLBITS = 32;
  107. /**
  108. * This flag in the infoflags argument to imageUpdate indicates that
  109. * an image which was being tracked asynchronously has encountered
  110. * an error. No further information will become available and
  111. * drawing the image will fail.
  112. * As a convenience, the ABORT flag will be indicated at the same
  113. * time to indicate that the image production was aborted.
  114. * @see #imageUpdate
  115. */
  116. public static final int ERROR = 64;
  117. /**
  118. * This flag in the infoflags argument to imageUpdate indicates that
  119. * an image which was being tracked asynchronously was aborted before
  120. * production was complete. No more information will become available
  121. * without further action to trigger another image production sequence.
  122. * If the ERROR flag was not also set in this image update, then
  123. * accessing any of the data in the image will restart the production
  124. * again, probably from the beginning.
  125. * @see #imageUpdate
  126. */
  127. public static final int ABORT = 128;
  128. }