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