1. /*
  2. * @(#)ContextualRenderedImageFactory.java 1.6 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. /* ********************************************************************
  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. */
  52. RenderContext mapRenderContext(int i,
  53. RenderContext renderContext,
  54. ParameterBlock paramBlock,
  55. RenderableImage image);
  56. /**
  57. * Creates a rendering, given a RenderContext and a ParameterBlock
  58. * containing the operation's sources and parameters. The output
  59. * is a RenderedImage that takes the RenderContext into account to
  60. * determine its dimensions and placement on the image plane.
  61. * This method houses the "intelligence" that allows a
  62. * rendering-independent operation to adapt to a specific
  63. * RenderContext.
  64. *
  65. * @param renderContext The RenderContext specifying the rendering.
  66. * @param paramBlock a ParameterBlock containing the operation's
  67. * sources and parameters.
  68. */
  69. RenderedImage create(RenderContext renderContext,
  70. ParameterBlock paramBlock);
  71. /**
  72. * Returns the bounding box for the output of the operation,
  73. * performed on a given set of sources, in rendering-independent
  74. * space. The bounds are returned as a Rectangle2D, that is, an
  75. * axis-aligned rectangle with floating-point corner coordinates.
  76. *
  77. * @param paramBlock a ParameterBlock containing the operation's
  78. * sources and parameters.
  79. * @return a Rectangle2D specifying the rendering-independent
  80. * bounding box of the output.
  81. */
  82. Rectangle2D getBounds2D(ParameterBlock paramBlock);
  83. /**
  84. * Gets the appropriate instance of the property specified by the name
  85. * parameter. This method must determine which instance of a property to
  86. * return when there are multiple sources that each specify the property.
  87. *
  88. * @param paramBlock a ParameterBlock containing the operation's
  89. * sources and parameters.
  90. * @param name a String naming the desired property.
  91. * @return an object reference to the value of the property requested.
  92. */
  93. Object getProperty(ParameterBlock paramBlock, String name);
  94. /**
  95. * Returns a list of names recognized by getProperty.
  96. */
  97. String[] getPropertyNames();
  98. /**
  99. * Returns true if successive renderings (that is, calls to
  100. * create(RenderContext, ParameterBlock)) with the same arguments
  101. * may produce different results. This method may be used to
  102. * determine whether an existing rendering may be cached and
  103. * reused. It is always safe to return true.
  104. */
  105. boolean isDynamic();
  106. }