ilog.views.util.print
Class IlvPrintableDocument

java.lang.Object
  extended by ilog.views.util.print.IlvPrintableDocument
All Implemented Interfaces:
Pageable, Printable
Direct Known Subclasses:
IlvManagerPrintableDocument

public class IlvPrintableDocument
extends Object
implements Printable, Pageable

An IlvPrintableDocument defines a set of pages to be printed. An IlvPrintableDocument maintains a set of pages, defined by IlvPage objects. To print multiple pages, create an IlvPrintableDocument object and then add IlvPage objects to it. To print or preview the content of a IlvPrintableDocument you must use an IlvPrintingController, which is designed for this purpose.

Since:
JViews 5.5

Field Summary
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.
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.print.Pageable
UNKNOWN_NUMBER_OF_PAGES
 
Constructor Summary
IlvPrintableDocument(String name)
          Creates an empty IlvPrintableDocument object.
IlvPrintableDocument(String name, PageFormat pageFormat)
          Creates an empty IlvPrintableDocument to which to add IlvPage objects.
 
Method Summary
 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.
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.
 IlvPage getPage(int index)
          Gets the page at the specified index.
 PageFormat getPageFormat()
          Returns the default 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.
 Printable getPrintable(int pageIndex)
          Returns the Printable object for the indexed page.
 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 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 setPageFormat(PageFormat pageFormat)
          Specifies the default 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 setTemplatePage(IlvPage template)
          Specifies the template page for the document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ORDERED_BY_COLUMNS

public static final int ORDERED_BY_COLUMNS
A page order that indicates that pages are organized by columns. This order is useful only when the pages are representing a document split in rows and columns. In this page order the pages are organized so that all the pages of a column appear before the next column.

See Also:
setPageOrder(int), ORDERED_BY_ROWS, Constant Field Values

ORDERED_BY_ROWS

public static final int ORDERED_BY_ROWS
A page order that indicates that pages are organized by rows. This order is useful only when the pages are representing a document split in rows and columns. In this page order the pages are organized so that all the pages of a row appear before the next row.

See Also:
setPageOrder(int), ORDERED_BY_COLUMNS, Constant Field Values
Constructor Detail

IlvPrintableDocument

public IlvPrintableDocument(String name,
                            PageFormat pageFormat)
Creates an empty IlvPrintableDocument to which to add IlvPage objects.

Parameters:
name - The name of the document.
pageFormat - The default page format for all pages.

IlvPrintableDocument

public IlvPrintableDocument(String name)
Creates an empty IlvPrintableDocument object. The default page format is a letter-sized page with one-inch margins.

Parameters:
name - The name of the document.
Method Detail

getName

public String getName()
Returns the name of the document. The method may return null if no name was set.

See Also:
setName(java.lang.String)

setName

public void setName(String name)
Changes the name of the document. The method fires a PropertyChangeEvent for the 'name' property.

See Also:
getName()

getDate

public Date getDate()
Returns the printing date.

See Also:
setDate(java.util.Date)

setDate

public void setDate(Date date)
Sets the printing date. The method fires a 'PropertyChangeEvent' for the 'date' property.

See Also:
getDate()

getAuthor

public String getAuthor()
Returns the name of the author of the document. The method may return null if no author was set.

See Also:
setAuthor(java.lang.String)

setAuthor

public void setAuthor(String name)
Changes the name of the author of the document. The method fires a PropertyChangeEvent for the 'author' property.

See Also:
getAuthor()

getPageFormat

public PageFormat getPageFormat()
Returns the default page format for all contained pages.

Returns:
The default page format for all contained pages.
See Also:
setPageFormat(java.awt.print.PageFormat)

getPageFormat

public PageFormat getPageFormat(int pageIndex)
Returns the page format for the indexed page. This is a method of the Pageable interface.

Specified by:
getPageFormat in interface Pageable
Parameters:
pageIndex - The index of the page.
Returns:
The page format for the indexed page.

setPageFormat

public void setPageFormat(PageFormat pageFormat)
Specifies the default page format for all contained pages. The method fires a PropertyChangeEvent for the 'pageFormat' property.

Parameters:
pageFormat - The default page format for all contained pages.
See Also:
getPageFormat()

getImageableBounds

public IlvUnit.Rectangle getImageableBounds()
Returns the size of the page. This method takes into account the header and footer that might be attached to this document.


getFlow

public IlvFlow getFlow()
Returns the flow of text contained in this document. A new flow (IlvFlow) is created if the document does not already have a flow.

See Also:
isFlowLayoutValid(), invalidateFlowLayout()

isFlowLayoutValid

public boolean isFlowLayoutValid()
Indicates if the layout of the text flow is completed or not. The method will return true if the document does not have a flow of text.

See Also:
IlvFlow, getFlow(), invalidateFlowLayout()

invalidateFlowLayout

public void invalidateFlowLayout()
This method invalidates the layout of the IlvFlow attached to this document if there is one.

See Also:
getFlow(), isFlowLayoutValid()

createPages

protected IlvPage[] createPages()
Creates the pages of this document. Note that this factory method must not modify the structure of the document but rather return an array of the pages to add to this document. The default implementation returns null.


invalidatePages

protected void invalidatePages()
Marks the pages status as invalid. Invalid pages will be recreated when needed.

See Also:
createPages()

addPage

public void addPage(IlvPage page)
Adds a page to the document. The method fires a PropertyChangeEvent for the 'pageCount' property.

Parameters:
page - The page to be added.

setPages

public void setPages(IlvPage[] pages)
Changes all the pages of the document. The method fires a PropertyChangeEvent for the 'pageCount' property.

Parameters:
pages - The new pages.

removePage

public void removePage(IlvPage page)
Removes a page from the document. The method fires a PropertyChangeEvent for the 'pageCount' property.

Parameters:
page - The page to be removed.

removeAll

public void removeAll()
Removes all pages. The method fires a PropertyChangeEvent for the 'pageCount' property.


getPage

public IlvPage getPage(int index)
Gets the page at the specified index.

Parameters:
index - The index of the page.

getPageIndex

public int getPageIndex(IlvPage page)
Gets the index of the specified page.

Parameters:
page - The page.

getNumberOfPages

public int getNumberOfPages()
Returns the number of pages in the document.

Specified by:
getNumberOfPages in interface Pageable
Returns:
The number of pages.

getPrintable

public Printable getPrintable(int pageIndex)
Returns the Printable object for the indexed page. This is a method of the Pageable interface.

Specified by:
getPrintable in interface Pageable
Parameters:
pageIndex - The index of the page.
Returns:
The Printable object for the indexed page.

getColumnCount

public int getColumnCount()
Returns the number of pages in a column in this document. This parameter is only useful when the pages are representing a document split in rows and columns. This helps the Print Preview dialog box display the pages as rows and columns.

Returns:
The number of columns, or -1 if this document does not represent pages organized in rows and columns. The default value is -1.
See Also:
setColumnCount(int), setPageOrder(int)

setColumnCount

public void setColumnCount(int nbColumns)
Indicates the number of pages in each column of this document. Setting this parameter is only useful when the pages are representing a document split in rows and columns. This helps the Print Preview dialog box display the pages as rows and columns. You may set the value to -1 to indicate that the pages do not represent a document split in rows and columns.

See Also:
getColumnCount(), setPageOrder(int)

getPageOrder

public int getPageOrder()
Returns the order of pages. The order may be one of ORDERED_BY_COLUMNS or ORDERED_BY_ROWS. This parameter is only useful when the pages are representing a document split in rows and columns.

See Also:
setPageOrder(int)

setPageOrder

public void setPageOrder(int order)
Changes the order of pages. The order may be one of 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.

See Also:
getPageOrder()

getTemplatePage

public IlvPage getTemplatePage()
Returns the template page of the document.

Returns:
The template page.
See Also:
setTemplatePage(ilog.views.util.print.IlvPage)

setTemplatePage

public void setTemplatePage(IlvPage template)
Specifies the template page for the document. Before printing each contained page, the content of the template page is first printed. The template page is designed to put common print objects for all contained pages. The method fires a PropertyChangeEvent for the 'templatePage' property.

Parameters:
template - The template page.
See Also:
getTemplatePage()

getFooter

public IlvFooter getFooter()
Returns the footer that is printed on each page.

See Also:
setFooter(ilog.views.util.print.IlvFooter), getHeader()

setFooter

public void setFooter(IlvFooter footer)
Changes the footer to be printed on each page. The method fires a PropertyChangeEvent for the 'footer' property.

See Also:
getFooter(), setHeader(ilog.views.util.print.IlvHeader)

getHeader

public IlvHeader getHeader()
Returns the header that is printed on each page.

See Also:
setHeader(ilog.views.util.print.IlvHeader), getFooter()

setHeader

public void setHeader(IlvHeader header)
Changes the header to be printed on each page. The method fires a PropertyChangeEvent for the 'header' property.

See Also:
getHeader(), setFooter(ilog.views.util.print.IlvFooter)

prepareDocument

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. It allows you to validate and prepare the document before doing real printing operations. The default implementation is empty.


print

public int print(Graphics graphics,
                 PageFormat format,
                 int pageIndex)
          throws PrinterException
This method is called to print the document. It implements the java.awt.print.Printable.print method.

Specified by:
print in interface Printable
Parameters:
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.
Throws:
PrinterException

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  Object oldValue,
                                  Object newValue)
Fires a PropertyChangeEvent event for the specified property.

Parameters:
propertyName - The name of the property.
oldValue - The old value of the property.
newValue - The new value of the property.

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener propertyChangeListener)
Adds a listener to listen to the modification of the specified property.

Parameters:
propertyName - The name of the property.
propertyChangeListener - The listener.

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
Adds a listener to listen to the modification of all properties.

Parameters:
propertyChangeListener - The listener.

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener propertyChangeListener)
Removes a listener so that it no longer listens to the modification of the specified property.

Parameters:
propertyName - The name of the property.
propertyChangeListener - The listener.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
Removes a listener so that it no longer listens to the modification of the properties.

Parameters:
propertyChangeListener - The listener.


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.