1. /*
  2. * @(#)IIOWriteProgressListener.java 1.17 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 javax.imageio.event;
  8. import java.util.EventListener;
  9. import javax.imageio.ImageWriter;
  10. /**
  11. * An interface used by <code>ImageWriter</code> implementations to notify
  12. * callers of their image writing methods of progress.
  13. *
  14. * @see javax.imageio.ImageWriter#write
  15. *
  16. * @version 0.5
  17. */
  18. public interface IIOWriteProgressListener extends EventListener {
  19. /**
  20. * Reports that an image write operation is beginning. All
  21. * <code>ImageWriter</code> implementations are required to call
  22. * this method exactly once when beginning an image write
  23. * operation.
  24. *
  25. * @param source the <code>ImageWriter</code> object calling this
  26. * method.
  27. * @param imageIndex the index of the image being written within
  28. * its containing input file or stream.
  29. */
  30. void imageStarted(ImageWriter source, int imageIndex);
  31. /**
  32. * Reports the approximate degree of completion of the current
  33. * <code>write</code> call within the associated
  34. * <code>ImageWriter</code>.
  35. *
  36. * <p> The degree of completion is expressed as an index
  37. * indicating which image is being written, and a percentage
  38. * varying from <code>0.0F</code> to <code>100.0F</code>
  39. * indicating how much of the current image has been output. The
  40. * percentage should ideally be calculated in terms of the
  41. * remaining time to completion, but it is usually more practical
  42. * to use a more well-defined metric such as pixels decoded or
  43. * portion of input stream consumed. In any case, a sequence of
  44. * calls to this method during a given read operation should
  45. * supply a monotonically increasing sequence of percentage
  46. * values. It is not necessary to supply the exact values
  47. * <code>0</code> and <code>100</code>, as these may be inferred
  48. * by the callee from other methods.
  49. *
  50. * <p> Each particular <code>ImageWriter</code> implementation may
  51. * call this method at whatever frequency it desires. A rule of
  52. * thumb is to call it around each 5 percent mark.
  53. *
  54. * @param source the <code>ImageWriter</code> object calling this method.
  55. * @param percentageDone the approximate percentage of decoding that
  56. * has been completed.
  57. */
  58. void imageProgress(ImageWriter source,
  59. float percentageDone);
  60. /**
  61. * Reports that the image write operation has completed. All
  62. * <code>ImageWriter</code> implementations are required to call
  63. * this method exactly once upon completion of each image write
  64. * operation.
  65. *
  66. * @param source the <code>ImageWriter</code> object calling this method.
  67. */
  68. void imageComplete(ImageWriter source);
  69. /**
  70. * Reports that a thumbnail write operation is beginning. All
  71. * <code>ImageWriter</code> implementations are required to call
  72. * this method exactly once when beginning a thumbnail write
  73. * operation.
  74. *
  75. * @param source the <code>ImageWrite</code> object calling this method.
  76. * @param imageIndex the index of the image being written within its
  77. * containing input file or stream.
  78. * @param thumbnailIndex the index of the thumbnail being written.
  79. */
  80. void thumbnailStarted(ImageWriter source,
  81. int imageIndex, int thumbnailIndex);
  82. /**
  83. * Reports the approximate degree of completion of the current
  84. * thumbnail write within the associated <code>ImageWriter</code>.
  85. * The semantics are identical to those of
  86. * <code>imageProgress</code>.
  87. *
  88. * @param source the <code>ImageWriter</code> object calling this
  89. * method.
  90. * @param percentageDone the approximate percentage of decoding that
  91. * has been completed.
  92. */
  93. void thumbnailProgress(ImageWriter source, float percentageDone);
  94. /**
  95. * Reports that a thumbnail write operation has completed. All
  96. * <code>ImageWriter</code> implementations are required to call
  97. * this method exactly once upon completion of each thumbnail
  98. * write operation.
  99. *
  100. * @param source the <code>ImageWriter</code> object calling this
  101. * method.
  102. */
  103. void thumbnailComplete(ImageWriter source);
  104. /**
  105. * Reports that a write has been aborted via the writer's
  106. * <code>abort</code> method. No further notifications will be
  107. * given.
  108. *
  109. * @param source the <code>ImageWriter</code> object calling this
  110. * method.
  111. */
  112. void writeAborted(ImageWriter source);
  113. }