public class IlvPrintableDocument extends Object implements Printable, Pageable
IlvPrintableDocument
defines a set of pages to be printed.
An IlvPrintableDocument
maintains a set of pages,
defined by IlvPage
objects.
There are two ways to construct an IlvPrintableDocument
:
IlvPage
objects, doing the layout
yourself.IlvFlow
object and add pieces of text
and arbitrary IlvFlowObject
s to it. The
IlvFlow
object does its layout automatically.
To print or preview the content of a IlvPrintableDocument
you
must use an IlvPrintingController
, which is designed for this purpose.
Modifier and Type | Field and Description |
---|---|
static int |
ORDERED_BY_COLUMNS
A page order that indicates that pages are
organized by columns.
|
static int |
ORDERED_BY_ROWS
A page order that indicates that pages are
organized by rows.
|
NO_SUCH_PAGE, PAGE_EXISTS
UNKNOWN_NUMBER_OF_PAGES
Constructor and Description |
---|
IlvPrintableDocument(String name)
Deprecated.
Since JViews 8.8, please use a constructor which allows the
page format to depend on the printer or - if no printer is
available - on the current locale.
|
IlvPrintableDocument(String name,
int orientation)
Creates an initially empty
IlvPrintableDocument with the
given orientation. |
IlvPrintableDocument(String name,
int orientation,
Paper paperFormat)
Creates an initially empty
IlvPrintableDocument with the
given page format, given as an orientation and a paper format. |
IlvPrintableDocument(String name,
PageFormat pageFormat)
Creates an initially empty
IlvPrintableDocument with the
given page format. |
Modifier and Type | Method and Description |
---|---|
void |
addPage(IlvPage page)
Adds a page to the document.
|
void |
addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
Adds a listener to listen to the modification of all
properties.
|
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener propertyChangeListener)
Adds a listener to listen to the modification of the specified
property.
|
protected IlvPage[] |
createPages()
Creates the pages of this document.
|
void |
enablePrintStyle(boolean enable)
This method allows to display the contents of the document differently for
printing than for on-screen display.
|
protected void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Fires a
PropertyChangeEvent event for the specified property. |
String |
getAuthor()
Returns the name of the author of the document.
|
int |
getColumnCount()
Returns the number of pages in a column in this document.
|
Date |
getDate()
Returns the printing date.
|
IlvFlow |
getFlow()
Returns the flow of text contained in this document.
|
IlvFooter |
getFooter()
Returns the footer that is printed on each page.
|
IlvHeader |
getHeader()
Returns the header that is printed on each page.
|
IlvUnit.Rectangle |
getImageableBounds()
Returns the size of the page.
|
String |
getName()
Returns the name of the document.
|
int |
getNumberOfPages()
Returns the number of pages in the document.
|
int |
getOrientation()
Returns the orientation for all contained pages.
|
IlvPage |
getPage(int index)
Gets the page at the specified index.
|
PageFormat |
getPageFormat()
Returns the page format for all contained pages.
|
PageFormat |
getPageFormat(int pageIndex)
Returns the page format for the indexed page.
|
int |
getPageIndex(IlvPage page)
Gets the index of the specified page.
|
int |
getPageOrder()
Returns the order of pages.
|
Paper |
getPaperFormat()
Returns the paper format (paper size and imageable area) for all contained
pages.
|
Printable |
getPrintable(int pageIndex)
Returns the
Printable object for the indexed page. |
Sides |
getSides()
Returns the way pages are mapped on the sides of the paper sheets.
|
IlvPage |
getTemplatePage()
Returns the template page of the document.
|
void |
invalidateFlowLayout()
This method invalidates the layout of the
IlvFlow attached to this document if there is
one. |
protected void |
invalidatePages()
Marks the pages status as invalid.
|
boolean |
isFlowLayoutValid()
Indicates if the layout of the text flow is completed
or not.
|
protected void |
maybeInvalidatePages()
This method is called before accessing the pages of the document.
|
protected void |
prepareDocument()
This method is called before
printing the document, before showing the Print Preview dialog box or
opening the Page Setup dialog box.
|
int |
print(Graphics graphics,
PageFormat format,
int pageIndex)
This method is called to print the document.
|
void |
removeAll()
Removes all pages.
|
void |
removePage(IlvPage page)
Removes a page from the document.
|
void |
removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
Removes a listener so that it no longer listens to the
modification of the properties.
|
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener propertyChangeListener)
Removes a listener so that it no longer listens to the
modification of the specified property.
|
void |
setAuthor(String name)
Changes the name of the author of the document.
|
void |
setColumnCount(int nbColumns)
Indicates the number of pages in each column of this document.
|
void |
setDate(Date date)
Sets the printing date.
|
void |
setFooter(IlvFooter footer)
Changes the footer to be printed on each page.
|
void |
setHeader(IlvHeader header)
Changes the header to be printed on each page.
|
void |
setName(String name)
Changes the name of the document.
|
void |
setOrientation(int orientation)
Sets the orientation for all contained pages.
|
void |
setPageFormat(PageFormat pageFormat)
Specifies the page format for all contained pages.
|
void |
setPageOrder(int order)
Changes the order of pages.
|
void |
setPages(IlvPage[] pages)
Changes all the pages of the document.
|
void |
setPaperFormat(Paper paperFormat)
Sets the paper format (paper size and imageable area) for all contained
pages.
|
void |
setSides(Sides value)
Sets the way pages are mapped on the sides of the paper sheets.
|
void |
setTemplatePage(IlvPage template)
Specifies the template page for the document.
|
public static final int ORDERED_BY_COLUMNS
setPageOrder(int)
,
ORDERED_BY_ROWS
,
Constant Field Valuespublic static final int ORDERED_BY_ROWS
setPageOrder(int)
,
ORDERED_BY_COLUMNS
,
Constant Field Valuespublic IlvPrintableDocument(String name, PageFormat pageFormat)
IlvPrintableDocument
with the
given page format.name
- The name of the document.pageFormat
- The default page format for all pages. Because a fixed
page format is not apppropriate for all printers and
all locales, it is recommended that this argument be
constructed from
IlvPrintingController.getDefaultPageFormat()
or
IlvPrintingController.getDefaultPaperFormat()
.public IlvPrintableDocument(String name, int orientation, Paper paperFormat)
IlvPrintableDocument
with the
given page format, given as an orientation and a paper format.name
- The name of the document.orientation
- One of PageFormat.PORTRAIT
,
PageFormat.LANDSCAPE
,
PageFormat.REVERSE_LANDSCAPE
.paperFormat
- A paper format object, or null
if the paper
format shall be provided by the
IlvPrintingController
, depending on the default
printer or - if no printer is available - depending on
the current locale. Because a fixed page format is not
apppropriate for all printers and all locales, it is
recommended that this argument be null
or
constructed from
IlvPrintingController.getDefaultPaperFormat()
.public IlvPrintableDocument(String name, int orientation)
IlvPrintableDocument
with the
given orientation. The paper format shall be provided by the
IlvPrintingController
, depending on the default printer or
- if no printer is available - depending on the current locale.name
- The name of the document.orientation
- One of PageFormat.PORTRAIT
,
PageFormat.LANDSCAPE
,
PageFormat.REVERSE_LANDSCAPE
.@Deprecated public IlvPrintableDocument(String name)
IlvPrintableDocument
object with
portrait orientation and a page format that is a US Letter sized page with
one-inch margins.name
- The name of the document.public String getName()
null
if no name was set.setName(java.lang.String)
public void setName(String name)
PropertyChangeEvent
for the 'name' property.getName()
public Date getDate()
setDate(java.util.Date)
public void setDate(Date date)
getDate()
public String getAuthor()
null
if no author was set.setAuthor(java.lang.String)
public void setAuthor(String name)
PropertyChangeEvent
for the 'author' property.getAuthor()
public Sides getSides()
null
when it is unspecified and
up to the printer to arrange the pages.setSides(javax.print.attribute.standard.Sides)
public void setSides(Sides value)
null
means that it is unspecified and
up to the printer to arrange the pages.getSides()
public IlvPage getTemplatePage()
setTemplatePage(ilog.views.util.print.IlvPage)
public void setTemplatePage(IlvPage template)
PropertyChangeEvent
for the 'templatePage' property.template
- The template page.getTemplatePage()
public IlvHeader getHeader()
public void setHeader(IlvHeader header)
PropertyChangeEvent
for the 'header' property.public IlvFooter getFooter()
public void setFooter(IlvFooter footer)
PropertyChangeEvent
for the 'footer' property.public int getOrientation()
PageFormat.PORTRAIT
, PageFormat.LANDSCAPE
,
PageFormat.REVERSE_LANDSCAPE
.public void setOrientation(int orientation)
orientation
- One of PageFormat.PORTRAIT
,
PageFormat.LANDSCAPE
,
PageFormat.REVERSE_LANDSCAPE
.public Paper getPaperFormat()
null
if it has not been set through a constructor and
not yet been set by the IlvPrintingController
.null
if it has
not yet been set.public void setPaperFormat(Paper paperFormat)
paperFormat
- A paper format object, or null
if the paper
format shall be provided by the
IlvPrintingController
, depending on the default
printer or - if no printer is available - depending on
the current locale.public PageFormat getPageFormat()
This is initially the default page format or null
.
Once the IlvPrintingController
has set it, it is the real page
format.
This value is a combination of getOrientation()
and
getPaperFormat()
.
null
if
the paper format has not yet been set.setPageFormat(java.awt.print.PageFormat)
public void setPageFormat(PageFormat pageFormat)
pageFormat
- The page format for all contained pages.getPageFormat()
,
setOrientation(int)
,
setPaperFormat(Paper)
public IlvUnit.Rectangle getImageableBounds()
public void addPage(IlvPage page)
PropertyChangeEvent
for the 'pageCount' property.page
- The page to be added.public void removePage(IlvPage page)
PropertyChangeEvent
for the 'pageCount' property.page
- The page to be removed.public void removeAll()
PropertyChangeEvent
for the 'pageCount' property.public void setPages(IlvPage[] pages)
PropertyChangeEvent
for the 'pageCount' property.pages
- The new pages.public IlvFlow getFlow()
IlvFlow
) is created if the document
does not already have a flow.isFlowLayoutValid()
,
invalidateFlowLayout()
public boolean isFlowLayoutValid()
true
if the document
does not have a flow of text.IlvFlow
,
getFlow()
,
invalidateFlowLayout()
public void invalidateFlowLayout()
IlvFlow
attached to this document if there is
one.getFlow()
,
isFlowLayoutValid()
public int getColumnCount()
setColumnCount(int)
,
setPageOrder(int)
public void setColumnCount(int nbColumns)
getColumnCount()
,
setPageOrder(int)
public int getPageOrder()
ORDERED_BY_COLUMNS
or ORDERED_BY_ROWS
.
This parameter is only useful when the pages are
representing a document split in rows and columns.setPageOrder(int)
public void setPageOrder(int order)
ORDERED_BY_COLUMNS
or ORDERED_BY_ROWS
.
This parameter is only useful when the pages are
representing a document split in rows and columns.
Note that calling this method does not change the order of the page, but
only indicates in which order the pages have been added. It is the
responsibility of the programmer to add the pages in the correct order.
The method fires a PropertyChangeEvent
for the 'pageOrder' property.getPageOrder()
protected void prepareDocument()
protected void maybeInvalidatePages()
invalidatePages()
, if some parameters have changed that
influence the page layout.
The default implementation does nothing.
invalidatePages()
protected void invalidatePages()
This method should be called either when you change a parameter that
influences the page layout, or inside an override of
maybeInvalidatePages()
when such a parameter change is detected.
createPages()
protected IlvPage[] createPages()
null
.public IlvPage getPage(int index)
index
- The index of the page.public int getPageIndex(IlvPage page)
page
- The page.public int getNumberOfPages()
getNumberOfPages
in interface Pageable
public PageFormat getPageFormat(int pageIndex)
Pageable
interface.getPageFormat
in interface Pageable
pageIndex
- The index of the page.public Printable getPrintable(int pageIndex)
Printable
object for the indexed page.
This is a method of the Pageable
interface.getPrintable
in interface Pageable
pageIndex
- The index of the page.Printable
object for the indexed page.public int print(Graphics graphics, PageFormat format, int pageIndex) throws PrinterException
java.awt.print.Printable.print
method.print
in interface Printable
graphics
- The output device to which the document should be printed.format
- The page format used to print the indexed page.pageIndex
- The index of the page being printed.PrinterException
public void enablePrintStyle(boolean enable)
enable = true
when this document should be configured for
printing, or with enable = false
when it can be configured
for screen display again.
The default implementation does nothing. Subclasses can override it when the desired look or style for printing is different than for normal display.
enable
- true
for printing style, false
for
display styleprotected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
PropertyChangeEvent
event for the specified property.propertyName
- The name of the property.oldValue
- The old value of the property.newValue
- The new value of the property.public void addPropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
propertyName
- The name of the property.propertyChangeListener
- The listener.public void addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
propertyChangeListener
- The listener.public void removePropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
propertyName
- The name of the property.propertyChangeListener
- The listener.public void removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
propertyChangeListener
- The listener.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.