APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.print

public Class PrintJobDelegate

extends Object
implements Printable, Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable, java.awt.print.Printable
Imports
java.awt.Dimension, .Frame, .Graphics, .Graphics2D, .PrintJob, .JobAttributes, java.awt.JobAttributes.*, .PageAttributes, java.awt.PageAttributes.*, java.awt.print.PageFormat, .Paper, .Printable, .PrinterException, .PrinterJob, java.io.File, .IOException, java.net.URI, .URISyntaxException, java.util.ArrayList, .Properties, javax.print.PrintService, javax.print.attribute.HashPrintRequestAttributeSet, .PrintRequestAttributeSet, .Size2DSyntax, javax.print.attribute.standard.Chromaticity, .Copies, .Destination, .DialogTypeSelection, .DialogOwner, .JobName, .MediaSize, .PrintQuality, .SheetCollate, .Sides, .Media, .OrientationRequested, .MediaSizeName, .PageRanges

A class which initiates and executes a print job using the underlying PrinterJob graphics conversions.
See Also
java.awt.Toolkit#getPrintJob

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final String
private PrintRequestAttributeSet
private Graphics2D
currentGraphics

The last Graphics returned to the application via getGraphics.

private static final String
private String
private static final String
private static final String
private static final String
private Frame
private PrintJobDelegate.MessageQ
graphicsDrawn

Used to communicate between the application's thread and the PrinterJob's thread this message queue holds the list of Graphics into which the application has finished drawing, but that have not yet been returned to the PrinterJob thread.

private PrintJobDelegate.MessageQ
graphicsToBeDrawn

The PrinterJob and the application run on different threads and communicate through a pair of message queues.

private static final MediaSizeName[]
private JobAttributes
private static final String
private static final String
private static final int[]
private static final String
private static final String
private String
private static final String
private static final String
private PageAttributes
private PageFormat
pageFormat

The size of the page being used for the PrintJob.

private int
pageIndex

The zero based index of the page currently being rendered by the application.

private static final String
private static final String
private static final String
private static final String
private PrinterJob
printerJob

The PrinterJob being uses to implement the PrintJob.

private Thread
printerJobThread

The thread on which PrinterJob is running.

private Properties
private static final PageAttributes.MediaType[]
private static final int[]

Constructor Summary

AccessConstructor and Description
public
PrintJobDelegate(Frame frame, String doctitle, final Properties props)

public
PrintJobDelegate(Frame frame, String doctitle, JobAttributes jobAttributes, PageAttributes pageAttributes)

Method Summary

Modifier and TypeMethod and Description
private void
private void
debugPrintAttributes(boolean ja, boolean pa)

public synchronized void
end()

Ends the print job and does any necessary cleanup.

public Graphics
getGraphics()

Gets a Graphics object that will draw to the next page.

public Dimension
getPageDimension()

Returns the dimensions of the page in pixels.

public int
getPageResolution()

Returns the resolution of the page in pixels per inch.

private double
private static int[]
private void
initPrintJob2D(Frame frame, String doctitle, JobAttributes jobAttributes, PageAttributes pageAttributes)

public boolean
lastPageFirst()

Returns true if the last page will be printed first.

public static MediaSizeName
public boolean
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

private void
private void
private void
public static PageAttributes.MediaType
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

A4back to summary
private static final String A4
attributesback to summary
private PrintRequestAttributeSet attributes
currentGraphicsback to summary
private Graphics2D currentGraphics

The last Graphics returned to the application via getGraphics. This is the Graphics into which the application is currently drawing.

DEST_PROPback to summary
private static final String DEST_PROP
docTitleback to summary
private String docTitle
EXECUTIVEback to summary
private static final String EXECUTIVE
FILEback to summary
private static final String FILE
FILENAME_PROPback to summary
private static final String FILENAME_PROP
frameback to summary
private Frame frame
graphicsDrawnback to summary
private PrintJobDelegate.MessageQ graphicsDrawn

Used to communicate between the application's thread and the PrinterJob's thread this message queue holds the list of Graphics into which the application has finished drawing, but that have not yet been returned to the PrinterJob thread. Again, in practice, the length of this message queue is always 0 or 1.

graphicsToBeDrawnback to summary
private PrintJobDelegate.MessageQ graphicsToBeDrawn

The PrinterJob and the application run on different threads and communicate through a pair of message queues. This queue is the list of Graphics that the PrinterJob has requested rendering for, but for which the application has not yet called getGraphics(). In practice the length of this message queue is always 0 or 1.

JAVAXSIZESback to summary
private static final MediaSizeName[] JAVAXSIZES
jobAttributesback to summary
private JobAttributes jobAttributes
LANDSCAPEback to summary
private static final String LANDSCAPE
LENGTHSback to summary
private static final int[] LENGTHS
LETTERback to summary
private static final String LETTER
NUMCOPIES_PROPback to summary
private static final String NUMCOPIES_PROP
optionsback to summary
private String options
OPTIONS_PROPback to summary
private static final String OPTIONS_PROP
ORIENT_PROPback to summary
private static final String ORIENT_PROP
pageAttributesback to summary
private PageAttributes pageAttributes
pageFormatback to summary
private PageFormat pageFormat

The size of the page being used for the PrintJob.

pageIndexback to summary
private int pageIndex

The zero based index of the page currently being rendered by the application.

PAPERSIZE_PROPback to summary
private static final String PAPERSIZE_PROP
PORTRAITback to summary
private static final String PORTRAIT
PRINTERback to summary
private static final String PRINTER
PRINTER_PROPback to summary
private static final String PRINTER_PROP
printerJobback to summary
private PrinterJob printerJob

The PrinterJob being uses to implement the PrintJob.

printerJobThreadback to summary
private Thread printerJobThread

The thread on which PrinterJob is running. This is different than the applications thread.

propsback to summary
private Properties props
SIZESback to summary
private static final PageAttributes.MediaType[] SIZES
WIDTHSback to summary
private static final int[] WIDTHS

Constructor Detail

PrintJobDelegateback to summary
public PrintJobDelegate(Frame frame, String doctitle, final Properties props)
PrintJobDelegateback to summary
public PrintJobDelegate(Frame frame, String doctitle, JobAttributes jobAttributes, PageAttributes pageAttributes)

Method Detail

copyAttributesback to summary
private void copyAttributes(PrintService printServ)
debugPrintAttributesback to summary
private void debugPrintAttributes(boolean ja, boolean pa)
endback to summary
public synchronized void end()

Ends the print job and does any necessary cleanup.

getGraphicsback to summary
public Graphics getGraphics()

Gets a Graphics object that will draw to the next page. The page is sent to the printer when the graphics object is disposed. This graphics object will also implement the PrintGraphics interface.

See Also
java.awt.PrintGraphics
getPageDimensionback to summary
public Dimension getPageDimension()

Returns the dimensions of the page in pixels. The resolution of the page is chosen so that it is similar to the screen resolution. Except (since 1.3) when the application specifies a resolution. In that case it is scaled accordingly.

getPageResolutionback to summary
public int getPageResolution()

Returns the resolution of the page in pixels per inch. Note that this doesn't have to correspond to the physical resolution of the printer.

getPageResolutionInternalback to summary
private double getPageResolutionInternal()
getSizeback to summary
private static int[] getSize(PageAttributes.MediaType mType)
initPrintJob2Dback to summary
private void initPrintJob2D(Frame frame, String doctitle, JobAttributes jobAttributes, PageAttributes pageAttributes)
lastPageFirstback to summary
public boolean lastPageFirst()

Returns true if the last page will be printed first.

mapMediaback to summary
public static MediaSizeName mapMedia(PageAttributes.MediaType mType)
printDialogback to summary
public boolean printDialog()
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

startPrinterJobThreadback to summary
private void startPrinterJobThread()
translateInputPropsback to summary
private void translateInputProps()
translateOutputPropsback to summary
private void translateOutputProps()
unMapMediaback to summary
public static PageAttributes.MediaType unMapMedia(MediaSizeName mSize)
updateAttributesback to summary
private void updateAttributes()
sun.print back to summary

private Class PrintJobDelegate.MessageQ

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private String
private ArrayList<Graphics2D>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv synchronized boolean
pack-priv synchronized void
pack-priv synchronized void
pack-priv synchronized boolean
pack-priv synchronized Graphics2D
pop()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

qidback to summary
private String qid
queueback to summary
private ArrayList<Graphics2D> queue

Constructor Detail

MessageQback to summary
pack-priv MessageQ(String id)

Method Detail

appendback to summary
pack-priv synchronized boolean append(Graphics2D g)
closeback to summary
pack-priv synchronized void close()
closeWhenEmptyback to summary
pack-priv synchronized void closeWhenEmpty()
isClosedback to summary
pack-priv synchronized boolean isClosed()
popback to summary
pack-priv synchronized Graphics2D pop()