1. /*
  2. * @(#)Composite.java 1.22 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 java.awt;
  8. import java.awt.image.ColorModel;
  9. /**
  10. * The <code>Composite</code> interface, along with
  11. * {@link CompositeContext}, defines the methods to compose a draw
  12. * primitive with the underlying graphics area.
  13. * After the <code>Composite</code> is set in the
  14. * {@link Graphics2D} context, it combines a shape, text, or an image
  15. * being rendered with the colors that have already been rendered
  16. * according to pre-defined rules. The classes
  17. * implementing this interface provide the rules and a method to create
  18. * the context for a particular operation.
  19. * <code>CompositeContext</code> is an environment used by the
  20. * compositing operation, which is created by the <code>Graphics2D</code>
  21. * prior to the start of the operation. <code>CompositeContext</code>
  22. * contains private information and resources needed for a compositing
  23. * operation. When the <code>CompositeContext</code> is no longer needed,
  24. * the <code>Graphics2D</code> object disposes of it in order to reclaim
  25. * resources allocated for the operation.
  26. * <p>
  27. * Instances of classes implementing <code>Composite</code> must be
  28. * immutable because the <code>Graphics2D</code> does not clone
  29. * these objects when they are set as an attribute with the
  30. * <code>setComposite</code> method or when the <code>Graphics2D</code>
  31. * object is cloned. This is to avoid undefined rendering behavior of
  32. * <code>Graphics2D</code>, resulting from the modification of
  33. * the <code>Composite</code> object after it has been set in the
  34. * <code>Graphics2D</code> context.
  35. * <p>
  36. * Since this interface must expose the contents of pixels on the
  37. * target device or image to potentially arbitrary code, the use of
  38. * custom objects which implement this interface when rendering directly
  39. * to a screen device is governed by the <code>readDisplayPixels</code>
  40. * {@link AWTPermission}. The permission check will occur when such
  41. * a custom object is passed to the <code>setComposite</code> method
  42. * of a <code>Graphics2D</code> retrieved from a {@link Component}.
  43. * @see AlphaComposite
  44. * @see CompositeContext
  45. * @see Graphics2D#setComposite
  46. * @version 10 Feb 1997
  47. */
  48. public interface Composite {
  49. /**
  50. * Creates a context containing state that is used to perform
  51. * the compositing operation. In a multi-threaded environment,
  52. * several contexts can exist simultaneously for a single
  53. * <code>Composite</code> object.
  54. * @param srcColorModel the {@link ColorModel} of the source
  55. * @param dstColorModel the <code>ColorModel</code> of the destination
  56. * @param hints the hint that the context object uses to choose between
  57. * rendering alternatives
  58. * @return the <code>CompositeContext</code> object used to perform the
  59. * compositing operation.
  60. */
  61. public CompositeContext createContext(ColorModel srcColorModel,
  62. ColorModel dstColorModel,
  63. RenderingHints hints);
  64. }