1. /*
  2. * @(#)Paint.java 1.27 03/12/19
  3. *
  4. * Copyright 2004 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. import java.awt.geom.AffineTransform;
  10. import java.awt.geom.Point2D;
  11. import java.awt.geom.Rectangle2D;
  12. /**
  13. * This <code>Paint</code> interface defines how color patterns
  14. * can be generated for {@link Graphics2D} operations. A class
  15. * implementing the <code>Paint</code> interface is added to the
  16. * <code>Graphics2D</code> context in order to define the color
  17. * pattern used by the <code>draw</code> and <code>fill</code> methods.
  18. * <p>
  19. * Instances of classes implementing <code>Paint</code> must be
  20. * read-only because the <code>Graphics2D</code> does not clone
  21. * these objects when they are set as an attribute with the
  22. * <code>setPaint</code> method or when the <code>Graphics2D</code>
  23. * object is itself cloned.
  24. * @see PaintContext
  25. * @see Color
  26. * @see GradientPaint
  27. * @see TexturePaint
  28. * @see Graphics2D#setPaint
  29. * @version 1.27, 12/19/03
  30. */
  31. public interface Paint extends Transparency {
  32. /**
  33. * Creates and returns a {@link PaintContext} used to
  34. * generate the color pattern.
  35. * Since the ColorModel argument to createContext is only a
  36. * hint, implementations of Paint should accept a null argument
  37. * for ColorModel. Note that if the application does not
  38. * prefer a specific ColorModel, the null ColorModel argument
  39. * will give the Paint implementation full leeway in using the
  40. * most efficient ColorModel it prefers for its raster processing.
  41. * <p>
  42. * Since the API documentation was not specific about this in
  43. * releases before 1.4, there may be implementations of
  44. * <code>Paint</code> that do not accept a null
  45. * <code>ColorModel</code> argument.
  46. * If a developer is writing code which passes a null
  47. * <code>ColorModel</code> argument to the
  48. * <code>createContext</code> method of <code>Paint</code>
  49. * objects from arbitrary sources it would be wise to code defensively
  50. * by manufacturing a non-null <code>ColorModel</code> for those
  51. * objects which throw a <code>NullPointerException</code>.
  52. * @param cm the {@link ColorModel} that receives the
  53. * <code>Paint</code> data. This is used only as a hint.
  54. * @param deviceBounds the device space bounding box
  55. * of the graphics primitive being rendered
  56. * @param userBounds the user space bounding box
  57. * of the graphics primitive being rendered
  58. * @param xform the {@link AffineTransform} from user
  59. * space into device space
  60. * @param hints the hint that the context object uses to
  61. * choose between rendering alternatives
  62. * @return the <code>PaintContext</code> for
  63. * generating color patterns
  64. * @see PaintContext
  65. */
  66. public PaintContext createContext(ColorModel cm,
  67. Rectangle deviceBounds,
  68. Rectangle2D userBounds,
  69. AffineTransform xform,
  70. RenderingHints hints);
  71. }