FileDocCategorySizeDatePackage
Book.javaAPI DocJava SE 5 API5946Fri Aug 26 14:56:56 BST 2005java.awt.print

Book

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 {@link Pageable} interface to interact with a {@link PrinterJob}.
see
Pageable
see
PrinterJob

Fields Summary
private Vector
mPages
The set of pages that make up the Book.
Constructors Summary
public Book()
Creates a new, empty Book.

    	mPages = new Vector();
    
Methods Summary
public voidappend(java.awt.print.Printable painter, java.awt.print.PageFormat page)
Appends a single page to the end of this Book.

param
painter the Printable instance that renders the page
param
page the size and orientation of the page
throws
NullPointerException If the painter or page argument is null

	mPages.addElement(new BookPage(painter, page));
    
public voidappend(java.awt.print.Printable painter, java.awt.print.PageFormat page, int numPages)
Appends numPages pages to the end of this Book. Each of the pages is associated with page.

param
painter the Printable instance that renders the page
param
page the size and orientation of the page
param
numPages the number of pages to be added to the this Book.
throws
NullPointerException If the painter or page argument is null

	BookPage bookPage = new BookPage(painter, page);
	int pageIndex = mPages.size();
	int newSize = pageIndex + numPages;

	mPages.setSize(newSize);
	for(int i = pageIndex; i < newSize; i++){
	    mPages.setElementAt(bookPage, i);
	}
    
public intgetNumberOfPages()
Returns the number of pages in this Book.

return
the number of pages this Book contains.

	return mPages.size();
    
private java.awt.print.Book$BookPagegetPage(int pageIndex)
Return the BookPage for the page specified by 'pageIndex'.

	return (BookPage) mPages.elementAt(pageIndex);
    
public java.awt.print.PageFormatgetPageFormat(int pageIndex)
Returns the {@link PageFormat} of the page specified by pageIndex.

param
pageIndex the zero based index of the page whose PageFormat is being requested
return
the PageFormat describing the size and orientation of the page.
throws
IndexOutOfBoundsException if the Pageable does not contain the requested page

	return getPage(pageIndex).getPageFormat();
    
public java.awt.print.PrintablegetPrintable(int pageIndex)
Returns the {@link Printable} instance responsible for rendering the page specified by pageIndex.

param
pageIndex the zero based index of the page whose Printable is being requested
return
the Printable that renders the page.
throws
IndexOutOfBoundsException if the Pageable does not contain the requested page

	return getPage(pageIndex).getPrintable();
    
public voidsetPage(int pageIndex, java.awt.print.Printable painter, java.awt.print.PageFormat page)
Sets the PageFormat and the Painter for a specified page number.

param
pageIndex the zero based index of the page whose painter and format is altered
param
painter the Printable instance that renders the page
param
page the size and orientation of the page
throws
IndexOutOfBoundsException if the specified page is not already in this Book
throws
NullPointerException if the painter or page argument is null

	if (painter == null) {
	    throw new NullPointerException("painter is null");
	}

	if (page == null) {
	    throw new NullPointerException("page is null");
	}

	mPages.setElementAt(new BookPage(painter, page), pageIndex);