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