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