APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.awt.print

public Class Book

extends Object
implements Pageable
Class Inheritance
All Implemented Interfaces
java.awt.print.Pageable
Imports
java.util.Vector

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
Pageable, PrinterJob

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
Book.BookPage

The BookPage inner class describes an individual page in a Book through a PageFormat-Printable pair.

Field Summary

Modifier and TypeField and Description
private Vector<Book.BookPage>
mPages

The set of pages that make up the Book.

Constructor Summary

AccessConstructor and Description
public
Book()

Creates a new, empty Book.

Method Summary

Modifier and TypeMethod and Description
public void
append(Printable
the Printable instance that renders the page
painter
,
PageFormat
the size and orientation of the page
page
)

Appends a single page to the end of this Book.

public void
append(Printable
the Printable instance that renders the page
painter
,
PageFormat
the size and orientation of the page
page
,
int
the number of pages to be added to the this Book.
numPages
)

Appends numPages pages to the end of this Book.

public int

Returns:

the number of pages this Book contains.
getNumberOfPages
()

Implements java.awt.print.Pageable.getNumberOfPages.

Returns the number of pages in this Book.

private Book.BookPage
getPage(int pageIndex)

Return the BookPage for the page specified by 'pageIndex'.

public PageFormat

Returns:

the PageFormat describing the size and orientation of the page.
getPageFormat
(int
the zero based index of the page whose PageFormat is being requested
pageIndex
)

Implements java.awt.print.Pageable.getPageFormat.

Returns the PageFormat of the page specified by pageIndex.

public Printable

Returns:

the Printable that renders the page.
getPrintable
(int
the zero based index of the page whose Printable is being requested
pageIndex
)

Implements java.awt.print.Pageable.getPrintable.

Returns the Printable instance responsible for rendering the page specified by pageIndex.

public void
setPage(int
the zero based index of the page whose painter and format is altered
pageIndex
,
Printable
the Printable instance that renders the page
painter
,
PageFormat
the size and orientation of the page
page
)

Sets the PageFormat and the Painter for a specified page number.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mPagesback to summary
private Vector<Book.BookPage> mPages

The set of pages that make up the Book.

Constructor Detail

Bookback to summary
public Book()

Creates a new, empty Book.

Method Detail

appendback to summary
public void append(Printable painter, PageFormat page)

Appends a single page to the end of this Book.

Parameters
painter:Printable

the Printable instance that renders the page

page:PageFormat

the size and orientation of the page

Exceptions
NullPointerException:
If the painter or page argument is null
appendback to summary
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:Printable

the Printable instance that renders the page

page:PageFormat

the size and orientation of the page

numPages:int

the number of pages to be added to the this Book.

Exceptions
NullPointerException:
If the painter or page argument is null
getNumberOfPagesback to summary
public int getNumberOfPages()

Implements java.awt.print.Pageable.getNumberOfPages.

Returns the number of pages in this Book.

Returns:int

the number of pages this Book contains.

getPageback to summary
private Book.BookPage getPage(int pageIndex) throws ArrayIndexOutOfBoundsException

Return the BookPage for the page specified by 'pageIndex'.

getPageFormatback to summary
public PageFormat getPageFormat(int pageIndex) throws IndexOutOfBoundsException

Implements java.awt.print.Pageable.getPageFormat.

Returns the PageFormat of the page specified by pageIndex.

Parameters
pageIndex:int

the zero based index of the page whose PageFormat is being requested

Returns:PageFormat

the PageFormat describing the size and orientation of the page.

Exceptions
IndexOutOfBoundsException:
if the Pageable does not contain the requested page
getPrintableback to summary
public Printable getPrintable(int pageIndex) throws IndexOutOfBoundsException

Implements java.awt.print.Pageable.getPrintable.

Returns the Printable instance responsible for rendering the page specified by pageIndex.

Parameters
pageIndex:int

the zero based index of the page whose Printable is being requested

Returns:Printable

the Printable that renders the page.

Exceptions
IndexOutOfBoundsException:
if the Pageable does not contain the requested page
setPageback to summary
public void setPage(int pageIndex, Printable painter, PageFormat page) throws IndexOutOfBoundsException

Sets the PageFormat and the Painter for a specified page number.

Parameters
pageIndex:int

the zero based index of the page whose painter and format is altered

painter:Printable

the Printable instance that renders the page

page:PageFormat

the size and orientation of the page

Exceptions
IndexOutOfBoundsException:
if the specified page is not already in this Book
NullPointerException:
if the painter or page argument is null
java.awt.print back to summary

private Class Book.BookPage

extends Object
Class Inheritance

The BookPage inner class describes an individual page in a Book through a PageFormat-Printable pair.

Field Summary

Modifier and TypeField and Description
private PageFormat
mFormat

The size and orientation of the page.

private Printable
mPainter

The instance that will draw the page.

Constructor Summary

AccessConstructor and Description
pack-priv
BookPage(Printable painter, PageFormat format)

A new instance where 'format' describes the page's size and orientation and 'painter' is the instance that will draw the page's graphics.

Method Summary

Modifier and TypeMethod and Description
pack-priv PageFormat
getPageFormat()

Return the format of the page.

pack-priv Printable
getPrintable()

Return the instance that paints the page.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mFormatback to summary
private PageFormat mFormat

The size and orientation of the page.

mPainterback to summary
private Printable mPainter

The instance that will draw the page.

Constructor Detail

BookPageback to summary
pack-priv BookPage(Printable painter, PageFormat format)

A new instance where 'format' describes the page's size and orientation and 'painter' is the instance that will draw the page's graphics.

Exceptions
NullPointerException:
If the painter or format argument is null

Method Detail

getPageFormatback to summary
pack-priv PageFormat getPageFormat()

Return the format of the page.

getPrintableback to summary
pack-priv Printable getPrintable()

Return the instance that paints the page.