1. /*
  2. * @(#)ImageProducer.java 1.20 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.awt.image;
  8. /**
  9. * The interface for objects which can produce the image data for Images.
  10. * Each image contains an ImageProducer which is used to reconstruct
  11. * the image whenever it is needed, for example, when a new size of the
  12. * Image is scaled, or when the width or height of the Image is being
  13. * requested.
  14. *
  15. * @see ImageConsumer
  16. *
  17. * @version 1.20 12/19/03
  18. * @author Jim Graham
  19. */
  20. public interface ImageProducer {
  21. /**
  22. * Registers an <code>ImageConsumer</code> with the
  23. * <code>ImageProducer</code> for access to the image data
  24. * during a later reconstruction of the <code>Image</code>.
  25. * The <code>ImageProducer</code> may, at its discretion,
  26. * start delivering the image data to the consumer
  27. * using the <code>ImageConsumer</code> interface immediately,
  28. * or when the next available image reconstruction is triggered
  29. * by a call to the <code>startProduction</code> method.
  30. * @param ic the specified <code>ImageConsumer</code>
  31. * @see #startProduction
  32. */
  33. public void addConsumer(ImageConsumer ic);
  34. /**
  35. * Determines if a specified <code>ImageConsumer</code>
  36. * object is currently registered with this
  37. * <code>ImageProducer</code> as one of its consumers.
  38. * @param ic the specified <code>ImageConsumer</code>
  39. * @return <code>true</code> if the specified
  40. * <code>ImageConsumer</code> is registered with
  41. * this <code>ImageProducer</code>
  42. * <code>false</code> otherwise.
  43. */
  44. public boolean isConsumer(ImageConsumer ic);
  45. /**
  46. * Removes the specified <code>ImageConsumer</code> object
  47. * from the list of consumers currently registered to
  48. * receive image data. It is not considered an error
  49. * to remove a consumer that is not currently registered.
  50. * The <code>ImageProducer</code> should stop sending data
  51. * to this consumer as soon as is feasible.
  52. * @param ic the specified <code>ImageConsumer</code>
  53. */
  54. public void removeConsumer(ImageConsumer ic);
  55. /**
  56. * Registers the specified <code>ImageConsumer</code> object
  57. * as a consumer and starts an immediate reconstruction of
  58. * the image data which will then be delivered to this
  59. * consumer and any other consumer which might have already
  60. * been registered with the producer. This method differs
  61. * from the addConsumer method in that a reproduction of
  62. * the image data should be triggered as soon as possible.
  63. * @param ic the specified <code>ImageConsumer</code>
  64. * @see #addConsumer
  65. */
  66. public void startProduction(ImageConsumer ic);
  67. /**
  68. * Requests, on behalf of the <code>ImageConsumer</code>,
  69. * that the <code>ImageProducer</code> attempt to resend
  70. * the image data one more time in TOPDOWNLEFTRIGHT order
  71. * so that higher quality conversion algorithms which
  72. * depend on receiving pixels in order can be used to
  73. * produce a better output version of the image. The
  74. * <code>ImageProducer</code> is free to
  75. * ignore this call if it cannot resend the data in that
  76. * order. If the data can be resent, the
  77. * <code>ImageProducer</code> should respond by executing
  78. * the following minimum set of <code>ImageConsumer</code>
  79. * method calls:
  80. * <pre>
  81. * ic.setHints(TOPDOWNLEFTRIGHT | < otherhints >);
  82. * ic.setPixels(...); // As many times as needed
  83. * ic.imageComplete();
  84. * </pre>
  85. * @param ic the specified <code>ImageConsumer</code>
  86. * @see ImageConsumer#setHints
  87. */
  88. public void requestTopDownLeftRightResend(ImageConsumer ic);
  89. }