com.developmentontheedge.print
Class LargePageable
- Direct Known Subclasses:
- JPrintableComponent
- public class LargePageable
- implements 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.
| Inner Class Summary |
public class | LargePageable.TranslatedPrintable This inner class's sole responsibility is to translate
the coordinate system before invoking a canvas's
painter. |
| Constructor Summary |
LargePageable(float width, float height, Printable painter, 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. |
PageFormat | getPageFormat(int pageIndex) Returns the PageFormat of the page specified by
pageIndex. |
Printable | getPrintable(int pageIndex) Returns the Printable instance responsible for
rendering the page specified by pageIndex. |
LargePageable
public LargePageable(float width, float height, Printable painter, PageFormat format)
- Create a java.awt.Pageable that will print
a canvas over as many pages as are needed.
A LargePageable can be passed to PrinterJob.setPageable.
- Parameters:
- width - The width, in 1/72nds of an inch,
of the area to print.
- height - The height, in 1/72nds of an inch,
of the area to print.
- 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.
getNumberOfPages
public int getNumberOfPages()
- Returns the number of pages over which the canvas
will be drawn.
getPageFormat
public PageFormat getPageFormat(int pageIndex)
throws java.lang.IndexOutOfBoundsException
- Returns the PageFormat of the page specified by
pageIndex. For a LargePageable the PageFormat
is the same for all pages.
- Parameters:
- pageIndex - the zero based index of the page whose
PageFormat is being requested
- Returns: the PageFormat describing the size and
orientation.
- Throws:
- IndexOutOfBoundsException
the - Pageable does not contain the requested
page.
getPrintable
public Printable getPrintable(int pageIndex)
throws java.lang.IndexOutOfBoundsException
- Returns the
Printable instance responsible for
rendering the page specified by pageIndex.
In a LargePageable, 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 LargePageable's pages cover the canvas by going left to
right and then top to bottom. In order to change this
behavior, override this method.- Parameters:
- pageIndex - the zero based index of the page whose
Printable is being requested
- Returns: the Printable that renders the page.
- Throws:
- IndexOutOfBoundsException
the - Pageable does not contain the requested
page.
to Class java.awt.print.Printable
to Class java.awt.print.PageFormat
BOTTOM