|
Pageable and Flowable
|
|
[Pageable] [Flowable]
J2PrinterWorks printing is controlled by two primary printing classes,
Pageable and Flowable.
Pageable
Pageable is a standard class
that comes with Java, specifically java.awt.print.Pageable
. J2PrinterWorks can create and
print
any document consisting of one or more multi-page java.awt.print.Pageable
instances, where each Pageable starts and ends on page boundaries.
J2PrinterWorks comes with 7
Pageable
components of its own:
- J2TextPrinter -
paginates
any JTextComponent (e.g., JTextPane, JEditorPane, or JTextArea) instance or subclass
- J2TablePrinter -
paginates any
JTable instance or
subclass
- J2TreePrinter -
paginates
any JTree instance or
subclass
- J2ListPrinter -
paginates
any JList instance or
subclass
- J2PanelPrinter -
paginates any
JPanel instance or
subclass
- J2ComponentPrinter -
paginates
any Component instance
or subclass
- J2FlowPrinter -
paginates
any sequence
of Flowable instances (see below)
In addition you create and intermix
your
own custom java.awt.print.Pageable
instances with any of
the above.
J2PrinterWorks lets you specify
the headers, footers, margins, centering, orientation,
and scale separately for each instance of the Pageable components above. You can have one set of headers
and footers for the first page of any Pageable and a different set for
the remaining pages. Headers and footers support page numbering and
date/time
formatting. There are separate left, right, and center headers as well
as footers. Each header or footer can be a simple one-line String, or
it
can be a JLabel defined using HTML and thereby span multiple lines and
contain rich text and images.
Flowable
In addition to supporting
Pageables,
J2PrinterWorks introduces a new printing interface called Flowable,
specifically com.wildcrest.j2printerworks.Flowable
. Like
Pageables, Flowables are printable components that may span multiple
pages,
but unlike Pageables, they can also begin and end in the middle of any
page. A J2FlowPrinter instance can group together any number of
Flowable
instances, one immediately following after another back-to-back down
the
page. The resulting J2FlowPrinter instance is a Pageable (i.e.,
beginning
and ending on page boundaries) that represents a packed-together series
of Flowables. Every J2FlowPrinter instance is also a Flowable, so
that J2FlowPrinter instances can be strung together or nested.
The following Flowables are
provided
by J2PrinterWorks:
- J2TextPrinter - a
Flowable (as
well as a Pageable) for JTextPane, JEditorPane, and JTextArea
- J2TablePrinter - a
Flowable (as
well as a Pageable) for JTable
- J2TreePrinter - a
Flowable (as
well as a Pageable) for JTree
- J2ListPrinter - a
Flowable (as
well as a Pageable) for JList
- J2ComponentPrinter -
a
Flowable (as
well as a Pageable) for Component
- J2PanelPrinter - a
Flowable (as
well as a Pageable) for any JPanel
- J2FlowPrinter - is
itself
a Flowable
as well as a Pageable (i.e., you can nest J2FlowPrinter instances)
- VerticalGap - a
Flowable
for leaving
a gap between successive Flowables
- HorizontalLine - a
Flowable for
drawing a horizontal line between successive Flowables
- PageEject - a
Flowable
for starting
the next Flowable at the top of a new page
In addition you can create and
intermix
your own custom com.wildcrest.j2printerworks.Flowable instances, which
you create by implementing the Flowable interface.
See the Sample
Programs: Custom Flowables section for further details and sample
code for creating
your own custom Flowables.
By stringing together a series of
Flowables,
you can do things like include a JTable, a JTree, a JList, a
third-party Component, a drawing,
an Image, or
the contents of a program window (in a JPanel) within an overall
document
otherwise made up of JTextPane instances, placing titles above and/or a
captions below any of these components. Each Flowable can be scaled
independently,
horizontally
justified left, right, or center within the page width, and vertically
justified top, bottom, or center within the remaining space in the page.
© Copyright 2009, Wildcrest
Associates
(http://www.wildcrest.com)