DefaultPrintDriver Class

com.bea.ide.document
DefaultPrintDriver Class

public abstract class DefaultPrintDriver

    extends Object
    implements IPrintDriver, Printable

This is an implementation of the IPrintDriver interface.


Hierarchy
Object
  DefaultPrintDriver
All Implemented Interfaces

IPrintDriver, Pageable, Printable

Constructor Summary

DefaultPrintDriver()

 

Method Summary

protected abstract Component
getComponent()
This method must be implemented to return the component that should be printed.
public int
getNumberOfPages()
This implementation simply uses getXPageCount and getYPageCount
public PageFormat
getPageFormat(int pageNumber)
public Printable
getPrintable(int pageNumber)
protected int
getXPageCount(PageFormat format)
This method uses the imageable width of the given format and the bounds of the component to compute the number of pages that will be needed in the x-dimension.
protected double
getXScale()
This method allows customization of the horizontal size of the printed image by a particular scale.
protected int
getYPageCount(PageFormat format)
This method uses the imageable height of the given format and the bounds of the component to compute the number of pages that will be needed in the y-dimension.
protected double
getYScale()
This method allows customization of the vertical size of the printed image by a particular scale.
public int
print(Graphics graphics, PageFormat format, int pageNumber)
Default implementation of the print method.
public void
setDefaultFormat(PageFormat pf)
Set the default format for printing to the current printer.
protected void
translateToPage(Graphics graphics, PageFormat format, int pageNumber)
Translates the graphics object to print the nth page of the Component.
 
Methods from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
   
Methods from interface com.bea.ide.document.IPrintDriver
getNumberOfPages, getPageFormat, getPrintable, setDefaultFormat
 
Methods from interface java.awt.print.Pageable
getNumberOfPages, getPageFormat, getPrintable
 
Methods from interface java.awt.print.Printable
print
 

Constructor Detail

DefaultPrintDriver

public DefaultPrintDriver()
 

Method Detail

getComponent() Method

protected abstract Component getComponent()
This method must be implemented to return the component that should be printed.

Returns

Component to print

getNumberOfPages() Method

public int getNumberOfPages()
This implementation simply uses getXPageCount and getYPageCount

Returns

Number of pages needed to print the component

getPageFormat(int) Method

public PageFormat getPageFormat(int pageNumber)

getPrintable(int) Method

public Printable getPrintable(int pageNumber)

getXPageCount(PageFormat) Method

protected int getXPageCount(PageFormat format)
This method uses the imageable width of the given format and the bounds of the component to compute the number of pages that will be needed in the x-dimension.

Parameters

format
PageFormat that will be used for printing

Returns

Number of pages needed to contain the printed version of this component in the horizontal axis

getXScale() Method

protected double getXScale()
This method allows customization of the horizontal size of the printed image by a particular scale.

Returns

Percentage value to use in scaling the printed image as a double (i.e. 100% == 1.0), defaults to 1.0

getYPageCount(PageFormat) Method

protected int getYPageCount(PageFormat format)
This method uses the imageable height of the given format and the bounds of the component to compute the number of pages that will be needed in the y-dimension.

Parameters

format
PageFormat that will be used for printing

Returns

Number of pages needed to contain the printed version of this component in the vertical axis

getYScale() Method

protected double getYScale()
This method allows customization of the vertical size of the printed image by a particular scale.

Returns

Percentage value to use in scaling the printed image as a double (i.e. 100% == 1.0), defaults to 1.0

print(Graphics, PageFormat, int) Method

public int print(Graphics graphics, 
                 PageFormat format, 
                 int pageNumber)
Default implementation of the print method. For simplicity, this object also implements printable and simply returns itself from the getPrintable method. The default print method translates the graphics object to print a particular page, then calls the component to print it.

Parameters

graphics
Graphics object for printing
format
PageFormat to use for printing
pageNumber
Page to print

Returns

Printable.PAGE_EXISTS if pageNumber is less than getNumberOfPages(), otherwise, NO_SUCH_PAGE

setDefaultFormat(PageFormat) Method

public void setDefaultFormat(PageFormat pf)
Description copied from IPrintDriver.setDefaultFormat(PageFormat)
Set the default format for printing to the current printer.


translateToPage(Graphics, PageFormat, int) Method

protected void translateToPage(Graphics graphics, 
                               PageFormat format, 
                               int pageNumber)
Translates the graphics object to print the nth page of the Component. Pages are printed first horizontally, then vertically. Thus, if a component's printed size is 2 by 3 pages, pages 0 and 1 will be the top two sections of the document.

Parameters

graphics
Printing graphics object to translate
format
PageFormat used for printing
pageNumber
Page number that needs to be printed