Side of Software
Print Preview Library 1.8.1

sos.preview
Class PageableAdapter

java.lang.Object
  |
  +--sos.preview.PageableAdapter
All Implemented Interfaces:
java.awt.print.Pageable

public class PageableAdapter
extends java.lang.Object
implements java.awt.print.Pageable

A class that converts a java.awt.print.Printable object into a java.awt.print.Pageable object. All pages use the same page format.

To treat an existing printable object as a pageable object, create an instance of PageableAdapter, passing the printable object and the desired page format.

An instance of PageableAdapter can be used anywhere a Pageable object is accepted. For instance, it can be passed to JPrintPreviewPane.setPageable(java.awt.print.Pageable).

PageableAdapter works by creating a one-time image of the Printable object at 100%. Therefore, if a PageableAdapter is used in a JPrintPreviewPane, the pages will become more and more pixilated as the user zooms in. For smooth zooming, use a custom Pageable object.

Since:
1.4
See Also:
ComponentPageable

Field Summary
 
Fields inherited from interface java.awt.print.Pageable
UNKNOWN_NUMBER_OF_PAGES
 
Constructor Summary
PageableAdapter(java.awt.print.Printable printable, java.awt.print.PageFormat pageFormat)
          Creates an instance of PageableAdapter with the specified Printable and PageFormat objects.
 
Method Summary
 int getNumberOfPages()
          Returns the number of pages in the set.
 java.awt.print.PageFormat getPageFormat(int pageIndex)
          Returns the PageFormat of the page specified by pageIndex.
 java.awt.print.Printable getPrintable(int pageIndex)
          Returns the Printable instance responsible for rendering the page specified by pageIndex.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PageableAdapter

public PageableAdapter(java.awt.print.Printable printable,
                       java.awt.print.PageFormat pageFormat)
                throws java.awt.print.PrinterException
Creates an instance of PageableAdapter with the specified Printable and PageFormat objects.

Parameters:
printable - object to be printed
pageFormat - format of each printed page
Throws:
java.lang.NullPointerException - if any argument is null
java.awt.print.PrinterException - if a print exception occurs
Method Detail

getNumberOfPages

public int getNumberOfPages()
Returns the number of pages in the set. To enable advanced printing features, it is recommended that Pageable implementations return the true number of pages rather than the UNKNOWN_NUMBER_OF_PAGES constant.

Specified by:
getNumberOfPages in interface java.awt.print.Pageable
Returns:
the number of pages in this Pageable.

getPageFormat

public java.awt.print.PageFormat getPageFormat(int pageIndex)
                                        throws java.lang.IndexOutOfBoundsException
Returns the PageFormat of the page specified by pageIndex.

Specified by:
getPageFormat in interface java.awt.print.Pageable
Parameters:
pageIndex - the zero based index of the page whose PageFormat is being requested
Returns:
the PageFormat describing the size and orientation.
Throws:
java.lang.IndexOutOfBoundsException - if the Pageable does not contain the requested page.

getPrintable

public java.awt.print.Printable getPrintable(int pageIndex)
                                      throws java.lang.IndexOutOfBoundsException
Returns the Printable instance responsible for rendering the page specified by pageIndex.

Specified by:
getPrintable in interface java.awt.print.Pageable
Parameters:
pageIndex - the zero based index of the page whose Printable is being requested
Returns:
the Printable that renders the page.
Throws:
java.lang.IndexOutOfBoundsException - if the Pageable does not contain the requested page.

Side of Software
Print Preview Library 1.8.1

Copyright 2003-07 Side of Software (SOS). All rights reserved.