1. /*
  2. * @(#)Printable.java 1.10 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. package java.awt.print;
  8. import java.awt.Graphics;
  9. /**
  10. * The <code>Printable</code> interface is implemented
  11. * by the <code>print</code> methods of the current
  12. * page painter, which is called by the printing
  13. * systemto render a page. When building a
  14. * {@link Pageable}, pairs of {@link PageFormat}
  15. * instances and instances that implement
  16. * this interface are used to describe each page. The
  17. * instance implementing <code>Printable</code> is called to
  18. * print the page's graphics.
  19. * @see java.awt.print.Pageable
  20. * @see java.awt.print.PageFormat
  21. * @see java.awt.print.PrinterJob
  22. */
  23. public interface Printable {
  24. /**
  25. * Returned from {@link #print(Graphics, PageFormat, int)}
  26. * to signify that the requested page was rendered.
  27. */
  28. int PAGE_EXISTS = 0;
  29. /**
  30. * Returned from <code>print</code> to signify that the
  31. * <code>pageIndex</code> is too large and that the requested page
  32. * does not exist.
  33. */
  34. int NO_SUCH_PAGE = 1;
  35. /**
  36. * Prints the page at the specified index into the specified
  37. * {@link Graphics} context in the specified
  38. * format. A <code>PrinterJob</code> calls the
  39. * <code>Printable</code> interface to request that a page be
  40. * rendered into the context specified by
  41. * <code>graphics</code>. The format of the page to be drawn is
  42. * specified by <code>pageFormat</code>. The zero based index
  43. * of the requested page is specified by <code>pageIndex</code>.
  44. * If the requested page does not exist then this method returns
  45. * NO_SUCH_PAGE; otherwise PAGE_EXISTS is returned.
  46. * The <code>Graphics</code> class or subclass implements the
  47. * {@link PrinterGraphics} interface to provide additional
  48. * information. If the <code>Printable</code> object
  49. * aborts the print job then it throws a {@link PrinterException}.
  50. * @param graphics the context into which the page is drawn
  51. * @param pageFormat the size and orientation of the page being drawn
  52. * @param pageIndex the zero based index of the page to be drawn
  53. * @return PAGE_EXISTS if the page is rendered successfully
  54. * or NO_SUCH_PAGE if <code>pageIndex</code> specifies a
  55. * non-existent page.
  56. * @exception java.awt.print.PrinterException
  57. * thrown when the print job is terminated.
  58. */
  59. int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
  60. throws PrinterException;
  61. }