com.glaivestone.javax.awt.print
Class SimplePaginator

java.lang.Object
  |
  +--com.glaivestone.javax.awt.print.SimplePaginator
All Implemented Interfaces:
java.awt.print.Pageable
Direct Known Subclasses:
JComponentPrinter

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

A simple Pageable class that can split a large drawing canvas over multiple pages.

The pages in a canvas are laid out on pages going left to right and then top to bottom.

This class is used by JComponentPrinter and uses TranslatedPrintable.

Version:
1.0
Author:
Gary Gregory
See Also:
com.glaivestone.javax.swing.JComponentPrinter, TranslatedPrintable

Field Summary
 
Fields inherited from interface java.awt.print.Pageable
UNKNOWN_NUMBER_OF_PAGES
 
Constructor Summary
SimplePaginator(float width, float height, java.awt.print.Printable painter, java.awt.print.PageFormat format)
          Create a java.awt.Pageable that will print a canvas over as many pages as are needed.
 
Method Summary
 int getNumberOfPages()
          Returns the number of pages over which the canvas will be drawn.
 int getNumberOfPagesX()
          Get the number of "horizontal" pages to print.
 int getNumberOfPagesY()
          Get the number of "vertical" pages to print.
 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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimplePaginator

public SimplePaginator(float width,
                       float height,
                       java.awt.print.Printable painter,
                       java.awt.print.PageFormat format)
Create a java.awt.Pageable that will print a canvas over as many pages as are needed. A Vista can be passed to PrinterJob.setPageable.

Parameters:
width - The width, in 1/72nds of an inch, of the SimplePaginator's canvas.
height - The height, in 1/72nds of an inch, of the SimplePaginator's canvas.
painter - The object that will drawn the contents of the canvas.
format - The description of the pages on to which the canvas will be drawn.
Method Detail

getNumberOfPages

public int getNumberOfPages()
Returns the number of pages over which the canvas will be drawn.

Specified by:
getNumberOfPages in interface java.awt.print.Pageable

getNumberOfPagesX

public int getNumberOfPagesX()
Get the number of "horizontal" pages to print.


getNumberOfPagesY

public int getNumberOfPagesY()
Get the number of "vertical" pages to print.


getPageFormat

public java.awt.print.PageFormat getPageFormat(int pageIndex)
                                        throws java.lang.IndexOutOfBoundsException
Returns the PageFormat of the page specified by pageIndex. For a Vista the PageFormat is the same for all pages.

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 - 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. In a Vista, all of the pages are drawn with the same Printable. This method however creates a Printable which calls the canvas's Printable. This new Printable is responsible for translating the coordinate system so that the desired part of the canvas hits the page. The Vista's pages cover the canvas by going left to right and then top to bottom. In order to change this behavior, override this method.

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 - the Pageable does not contain the requested page.

GFL 1.1 API