|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jwo.utils.gui.PrintUtilities
public class PrintUtilities
Handles the printing of any printable object. Includes a method for creating a print preview based on default printer settings.
Constructor Summary | |
---|---|
PrintUtilities()
Sets up the print services for possible printing. |
|
PrintUtilities(DocFlavor flavour)
Sets up the print services for possible printing. |
Method Summary | |
---|---|
int |
calcNumPages(Dimension objectSize,
PageFormat pageFormat)
Calculates the number of pages that would be expected to print content of a given size assuming the given page format. |
static Paper |
createA3()
Returns an object representing A3 paper with 2cm margins. |
static Paper |
createA4()
Returns an object representing A4 paper with 2cm margins. |
float |
getPageScale(Dimension objectSize,
PageFormat pageFormat)
Reports the scaling that would be applied if an object of the given size was to be printed to be as large as possible on a single page. |
float |
getWidthScale(Dimension objectSize,
PageFormat pageFormat)
Reports the scaling that would be applied if an object of the given size was to be printed so its width matched the supplied page format printable width. |
void |
print(Printable printableObject,
boolean showDialogue)
Prints the given printable object. |
void |
printDataTransferCompleted(PrintJobEvent e)
Reports that the transfer of data to print job has been completed, but currently ignored. |
void |
printJobCanceled(PrintJobEvent e)
Reports that the print job has been cancelled for some reason. |
void |
printJobCompleted(PrintJobEvent e)
Reports that the print job has been completed, but currently ignored. |
void |
printJobFailed(PrintJobEvent e)
Reports that there has been some problem with the print job. |
void |
printJobNoMoreEvents(PrintJobEvent e)
Reports that there will be no more events generated by this print job, but currently ignored. |
void |
printJobRequiresAttention(PrintJobEvent e)
Reports that print job requires attention of some kind. |
void |
printPreview(Frame parent,
Printable printable)
Provides a print preview of the given printable object. |
void |
run()
Queries the available print services. |
Graphics2D |
scalePage(Graphics g,
Dimension objectSize,
PageFormat pageFormat)
Scales the given graphics to fit on a single page with the given printer page dimensions. |
Graphics2D |
scaleWidth(Graphics g,
Dimension objectSize,
PageFormat pageFormat,
int pageIndex)
Scales the given graphics to the required printer page dimensions. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PrintUtilities()
public PrintUtilities(DocFlavor flavour)
flavour
- Type of document to print.Method Detail |
---|
public void run()
run
in interface Runnable
public void print(Printable printableObject, boolean showDialogue)
printableObject
- Printable object.showDialogue
- Will ask for printer type if true.public void printPreview(Frame parent, Printable printable)
parent
- Parent GUI requesting print preview.printable
- Printable object.public Graphics2D scaleWidth(Graphics g, Dimension objectSize, PageFormat pageFormat, int pageIndex)
g
- Graphics context to print.objectSize
- Size of object to print.pageFormat
- Page format for printing (includes paper dimensions, margins etc).pageIndex
- Page index (for multiple pages).
public Graphics2D scalePage(Graphics g, Dimension objectSize, PageFormat pageFormat)
g
- Graphics context to print.objectSize
- Size of object to print.pageFormat
- Page format for printing (includes paper dimensions, margins etc).
public int calcNumPages(Dimension objectSize, PageFormat pageFormat)
objectSize
- Size of object to print.pageFormat
- Page format for printing.
public float getWidthScale(Dimension objectSize, PageFormat pageFormat)
objectSize
- Size of object to print.pageFormat
- Page format for printing.
public float getPageScale(Dimension objectSize, PageFormat pageFormat)
objectSize
- Size of object to print.pageFormat
- Page format for printing.
public void printDataTransferCompleted(PrintJobEvent e)
printDataTransferCompleted
in interface PrintJobListener
e
- Event monitoring print job.public void printJobCompleted(PrintJobEvent e)
printJobCompleted
in interface PrintJobListener
e
- Event monitoring print job.public void printJobFailed(PrintJobEvent e)
printJobFailed
in interface PrintJobListener
e
- Event monitoring print job.public void printJobCanceled(PrintJobEvent e)
printJobCanceled
in interface PrintJobListener
e
- Event monitoring print job.public void printJobNoMoreEvents(PrintJobEvent e)
printJobNoMoreEvents
in interface PrintJobListener
e
- Event monitoring print job.public void printJobRequiresAttention(PrintJobEvent e)
printJobRequiresAttention
in interface PrintJobListener
e
- Event monitoring print job.public static Paper createA4()
public static Paper createA3()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |