1. /*
  2. * @(#)ContextualRenderedImageFactory.java 1.10 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. /* ********************************************************************
  8. **********************************************************************
  9. **********************************************************************
  10. *** COPYRIGHT (c) Eastman Kodak Company, 1997 ***
  11. *** As an unpublished work pursuant to Title 17 of the United ***
  12. *** States Code. All rights reserved. ***
  13. **********************************************************************
  14. **********************************************************************
  15. **********************************************************************/
  16. package java.awt.image.renderable;
  17. import java.awt.geom.Rectangle2D;
  18. import java.awt.image.RenderedImage;
  19. /**
  20. * ContextualRenderedImageFactory provides an interface for the
  21. * functionality that may differ between instances of
  22. * RenderableImageOp. Thus different operations on RenderableImages
  23. * may be performed by a single class such as RenderedImageOp through
  24. * the use of multiple instances of ContextualRenderedImageFactory.
  25. * The name ContextualRenderedImageFactory is commonly shortened to
  26. * "CRIF."
  27. *
  28. * <p> All operations that are to be used in a rendering-independent
  29. * chain must implement ContextualRenderedImageFactory.
  30. *
  31. * <p> Classes that implement this interface must provide a
  32. * constructor with no arguments.
  33. */
  34. public interface ContextualRenderedImageFactory extends RenderedImageFactory {
  35. /**
  36. * Maps the operation's output RenderContext into a RenderContext
  37. * for each of the operation's sources. This is useful for
  38. * operations that can be expressed in whole or in part simply as
  39. * alterations in the RenderContext, such as an affine mapping, or
  40. * operations that wish to obtain lower quality renderings of
  41. * their sources in order to save processing effort or
  42. * transmission bandwith. Some operations, such as blur, can also
  43. * use this mechanism to avoid obtaining sources of higher quality
  44. * than necessary.
  45. *
  46. * @param i the index of the source image.
  47. * @param renderContext the RenderContext being applied to the operation.
  48. * @param paramBlock a ParameterBlock containing the operation's
  49. * sources and parameters.
  50. * @param image the RenderableImage being rendered.
  51. * @return a <code>RenderContext</code> for
  52. * the source at the specified index of the parameters
  53. * Vector contained in the specified ParameterBlock.
  54. */
  55. RenderContext mapRenderContext(int i,
  56. RenderContext renderContext,
  57. ParameterBlock paramBlock,
  58. RenderableImage image);
  59. /**
  60. * Creates a rendering, given a RenderContext and a ParameterBlock
  61. * containing the operation's sources and parameters. The output
  62. * is a RenderedImage that takes the RenderContext into account to
  63. * determine its dimensions and placement on the image plane.
  64. * This method houses the "intelligence" that allows a
  65. * rendering-independent operation to adapt to a specific
  66. * RenderContext.
  67. *
  68. * @param renderContext The RenderContext specifying the rendering
  69. * @param paramBlock a ParameterBlock containing the operation's
  70. * sources and parameters
  71. * @return a <code>RenderedImage</code> from the sources and parameters
  72. * in the specified ParameterBlock and according to the
  73. * rendering instructions in the specified RenderContext.
  74. */
  75. RenderedImage create(RenderContext renderContext,
  76. ParameterBlock paramBlock);
  77. /**
  78. * Returns the bounding box for the output of the operation,
  79. * performed on a given set of sources, in rendering-independent
  80. * space. The bounds are returned as a Rectangle2D, that is, an
  81. * axis-aligned rectangle with floating-point corner coordinates.
  82. *
  83. * @param paramBlock a ParameterBlock containing the operation's
  84. * sources and parameters.
  85. * @return a Rectangle2D specifying the rendering-independent
  86. * bounding box of the output.
  87. */
  88. Rectangle2D getBounds2D(ParameterBlock paramBlock);
  89. /**
  90. * Gets the appropriate instance of the property specified by the name
  91. * parameter. This method must determine which instance of a property to
  92. * return when there are multiple sources that each specify the property.
  93. *
  94. * @param paramBlock a ParameterBlock containing the operation's
  95. * sources and parameters.
  96. * @param name a String naming the desired property.
  97. * @return an object reference to the value of the property requested.
  98. */
  99. Object getProperty(ParameterBlock paramBlock, String name);
  100. /**
  101. * Returns a list of names recognized by getProperty.
  102. * @return the list of property names.
  103. */
  104. String[] getPropertyNames();
  105. /**
  106. * Returns true if successive renderings (that is, calls to
  107. * create(RenderContext, ParameterBlock)) with the same arguments
  108. * may produce different results. This method may be used to
  109. * determine whether an existing rendering may be cached and
  110. * reused. It is always safe to return true.
  111. * @return <code>true</code> if successive renderings with the
  112. * same arguments might produce different results;
  113. * <code>false</code> otherwise.
  114. */
  115. boolean isDynamic();
  116. }