Class Book

java.lang.Object
java.awt.print.Book
All Implemented Interfaces:
Pageable

public class Book extends Object implements Pageable
The Book class provides a representation of a document in which pages may have different page formats and page painters. This class uses the Pageable interface to interact with a PrinterJob.
See Also:
  • Field Summary

    Fields declared in interface Pageable

    UNKNOWN_NUMBER_OF_PAGES
    Modifier and Type
    Field
    Description
    static final int
    This constant is returned from the getNumberOfPages method if a Pageable implementation does not know the number of pages in its set.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new, empty Book.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    append(Printable painter, PageFormat page)
    Appends a single page to the end of this Book.
    void
    append(Printable painter, PageFormat page, int numPages)
    Appends numPages pages to the end of this Book.
    int
    Returns the number of pages in this Book.
    getPageFormat(int pageIndex)
    Returns the PageFormat of the page specified by pageIndex.
    getPrintable(int pageIndex)
    Returns the Printable instance responsible for rendering the page specified by pageIndex.
    void
    setPage(int pageIndex, Printable painter, PageFormat page)
    Sets the PageFormat and the Painter for a specified page number.

    Methods declared in class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
    Creates and returns a copy of this object.
    boolean
    Indicates whether some other object is "equal to" this one.
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Finalization is deprecated and subject to removal in a future release.
    final Class<?>
    Returns the runtime class of this Object.
    int
    Returns a hash code value for this object.
    final void
    Wakes up a single thread that is waiting on this object's monitor.
    final void
    Wakes up all threads that are waiting on this object's monitor.
    Returns a string representation of the object.
    final void
    Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
    final void
    wait(long timeoutMillis)
    Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
    final void
    wait(long timeoutMillis, int nanos)
    Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
  • Constructor Details

    • Book

      public Book()
      Creates a new, empty Book.
  • Method Details

    • getNumberOfPages

      public int getNumberOfPages()
      Returns the number of pages in this Book.
      Specified by:
      getNumberOfPages in interface Pageable
      Returns:
      the number of pages this Book contains.
    • getPageFormat

      public PageFormat getPageFormat(int pageIndex) throws IndexOutOfBoundsException
      Returns the PageFormat of the page specified by pageIndex.
      Specified by:
      getPageFormat in interface Pageable
      Parameters:
      pageIndex - the zero based index of the page whose PageFormat is being requested
      Returns:
      the PageFormat describing the size and orientation of the page.
      Throws:
      IndexOutOfBoundsException - if the Pageable does not contain the requested page
    • getPrintable

      public Printable getPrintable(int pageIndex) throws IndexOutOfBoundsException
      Returns the Printable instance responsible for rendering the page specified by pageIndex.
      Specified by:
      getPrintable in interface Pageable
      Parameters:
      pageIndex - the zero based index of the page whose Printable is being requested
      Returns:
      the Printable that renders the page.
      Throws:
      IndexOutOfBoundsException - if the Pageable does not contain the requested page
    • setPage

      public void setPage(int pageIndex, Printable painter, PageFormat page) throws IndexOutOfBoundsException
      Sets the PageFormat and the Painter for a specified page number.
      Parameters:
      pageIndex - the zero based index of the page whose painter and format is altered
      painter - the Printable instance that renders the page
      page - the size and orientation of the page
      Throws:
      IndexOutOfBoundsException - if the specified page is not already in this Book
      NullPointerException - if the painter or page argument is null
    • append

      public void append(Printable painter, PageFormat page)
      Appends a single page to the end of this Book.
      Parameters:
      painter - the Printable instance that renders the page
      page - the size and orientation of the page
      Throws:
      NullPointerException - If the painter or page argument is null
    • append

      public void append(Printable painter, PageFormat page, int numPages)
      Appends numPages pages to the end of this Book. Each of the pages is associated with page.
      Parameters:
      painter - the Printable instance that renders the page
      page - the size and orientation of the page
      numPages - the number of pages to be added to the this Book.
      Throws:
      NullPointerException - If the painter or page argument is null