/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A class which initiates and executes a print job using
* the underlying PrinterJob graphics conversions.
*
* @see Toolkit#getPrintJob
*
*/
};
/* This array maps the above array to the objects used by the
* javax.print APIs
*/
};
// widths and lengths in PostScript points (1/72 in.)
private static final int WIDTHS[] = {
/*iso-4a0*/ 4768, /*iso-2a0*/ 3370, /*iso-a0*/ 2384, /*iso-a1*/ 1684,
/*iso-a2*/ 1191, /*iso-a3*/ 842, /*iso-a4*/ 595, /*iso-a5*/ 420,
/*iso-a6*/ 298, /*iso-a7*/ 210, /*iso-a8*/ 147, /*iso-a9*/ 105,
/*iso-a10*/ 74, /*iso-b0*/ 2835, /*iso-b1*/ 2004, /*iso-b2*/ 1417,
/*iso-b3*/ 1001, /*iso-b4*/ 709, /*iso-b5*/ 499, /*iso-b6*/ 354,
/*iso-b7*/ 249, /*iso-b8*/ 176, /*iso-b9*/ 125, /*iso-b10*/ 88,
/*jis-b0*/ 2920, /*jis-b1*/ 2064, /*jis-b2*/ 1460, /*jis-b3*/ 1032,
/*jis-b4*/ 729, /*jis-b5*/ 516, /*jis-b6*/ 363, /*jis-b7*/ 258,
/*jis-b8*/ 181, /*jis-b9*/ 128, /*jis-b10*/ 91, /*iso-c0*/ 2599,
/*iso-c1*/ 1837, /*iso-c2*/ 1298, /*iso-c3*/ 918, /*iso-c4*/ 649,
/*iso-c5*/ 459, /*iso-c6*/ 323, /*iso-c7*/ 230, /*iso-c8*/ 162,
/*iso-c9*/ 113, /*iso-c10*/ 79, /*iso-designated-long*/ 312,
/*executive*/ 522, /*folio*/ 612, /*invoice*/ 396, /*ledger*/ 792,
/*na-letter*/ 612, /*na-legal*/ 612, /*quarto*/ 609, /*a*/ 612,
/*b*/ 792, /*c*/ 1224, /*d*/ 1584, /*e*/ 2448,
/*na-10x15-envelope*/ 720, /*na-10x14-envelope*/ 720,
/*na-10x13-envelope*/ 720, /*na-9x12-envelope*/ 648,
/*na-9x11-envelope*/ 648, /*na-7x9-envelope*/ 504,
/*na-6x9-envelope*/ 432, /*na-number-9-envelope*/ 279,
/*na-number-10-envelope*/ 297, /*na-number-11-envelope*/ 324,
/*na-number-12-envelope*/ 342, /*na-number-14-envelope*/ 360,
/*invite-envelope*/ 624, /*italy-envelope*/ 312,
/*monarch-envelope*/ 279, /*personal-envelope*/ 261
};
private static final int LENGTHS[] = {
/*iso-4a0*/ 6741, /*iso-2a0*/ 4768, /*iso-a0*/ 3370, /*iso-a1*/ 2384,
/*iso-a2*/ 1684, /*iso-a3*/ 1191, /*iso-a4*/ 842, /*iso-a5*/ 595,
/*iso-a6*/ 420, /*iso-a7*/ 298, /*iso-a8*/ 210, /*iso-a9*/ 147,
/*iso-a10*/ 105, /*iso-b0*/ 4008, /*iso-b1*/ 2835, /*iso-b2*/ 2004,
/*iso-b3*/ 1417, /*iso-b4*/ 1001, /*iso-b5*/ 729, /*iso-b6*/ 499,
/*iso-b7*/ 354, /*iso-b8*/ 249, /*iso-b9*/ 176, /*iso-b10*/ 125,
/*jis-b0*/ 4127, /*jis-b1*/ 2920, /*jis-b2*/ 2064, /*jis-b3*/ 1460,
/*jis-b4*/ 1032, /*jis-b5*/ 729, /*jis-b6*/ 516, /*jis-b7*/ 363,
/*jis-b8*/ 258, /*jis-b9*/ 181, /*jis-b10*/ 128, /*iso-c0*/ 3677,
/*iso-c1*/ 2599, /*iso-c2*/ 1837, /*iso-c3*/ 1298, /*iso-c4*/ 918,
/*iso-c5*/ 649, /*iso-c6*/ 459, /*iso-c7*/ 323, /*iso-c8*/ 230,
/*iso-c9*/ 162, /*iso-c10*/ 113, /*iso-designated-long*/ 624,
/*executive*/ 756, /*folio*/ 936, /*invoice*/ 612, /*ledger*/ 1224,
/*na-letter*/ 792, /*na-legal*/ 1008, /*quarto*/ 780, /*a*/ 792,
/*b*/ 1224, /*c*/ 1584, /*d*/ 2448, /*e*/ 3168,
/*na-10x15-envelope*/ 1080, /*na-10x14-envelope*/ 1008,
/*na-10x13-envelope*/ 936, /*na-9x12-envelope*/ 864,
/*na-9x11-envelope*/ 792, /*na-7x9-envelope*/ 648,
/*na-6x9-envelope*/ 648, /*na-number-9-envelope*/ 639,
/*na-number-10-envelope*/ 684, /*na-number-11-envelope*/ 747,
/*na-number-12-envelope*/ 792, /*na-number-14-envelope*/ 828,
/*invite-envelope*/ 624, /*italy-envelope*/ 652,
/*monarch-envelope*/ 540, /*personal-envelope*/ 468
};
/*
* Displays the native or cross-platform dialog and allows the
* user to update job & page attributes
*/
/**
* The PrinterJob being uses to implement the PrintJob.
*/
/**
* The size of the page being used for the PrintJob.
*/
/**
* 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.
*/
/**
* 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.
*/
/**
* The last Graphics returned to the application via
* getGraphics. This is the Graphics into which the
* application is currently drawing.
*/
/**
* The zero based index of the page currently being rendered
* by the application.
*/
// The following Strings are maintained for backward-compatibility with
// Properties based print control.
/**
* The thread on which PrinterJob is running.
* This is different than the applications thread.
*/
final Properties props) {
this.jobAttributes = new JobAttributes();
this.pageAttributes = new PageAttributes();
this.jobAttributes, this.pageAttributes);
}
}
}
(jobAttributes == null ||
throw new NullPointerException("Frame must not be null");
}
? jobAttributes : new JobAttributes();
? pageAttributes : new PageAttributes();
// Currently, we always reduce page ranges to xxx or xxx-xxx
this.jobAttributes.setPageRanges(new int[][] {
});
// Verify that the cross feed and feed resolutions are the same
throw new IllegalArgumentException("Differing cross feed and feed"+
" resolutions not supported.");
}
// Verify that the app has access to the file system
// check if given filename is valid
try {
// check if this is a new file and if filename chars are valid
// createNewFile returns false if file exists
if (f.createNewFile()) {
f.delete();
}
} catch (IOException ioe) {
throw new IllegalArgumentException("Cannot write to file:"+
destStr);
} catch (SecurityException se) {
// only delete access is denied. Just ignore it because in
// most cases the file created in createNewFile gets overwritten
// anyway.
}
if ((f.exists() &&
throw new IllegalArgumentException("Cannot write to file:"+
destStr);
}
}
}
}
public boolean printDialog() {
boolean proceedWithPrint = false;
if (printerJob == null) {
return false;
}
return false;
}
this.jobAttributes.getDefaultSelection();
} else {
}
}
if ( d == DialogType.NONE) {
proceedWithPrint = true;
} else {
if (d == DialogType.NATIVE) {
} else { // (d == DialogType.COMMON)
}
// Windows gives an option to install a service
// when it detects there are no printers so
// we make sure we get the updated print service.
return false;
}
}
}
}
if (proceedWithPrint) {
}
pageFormat = new PageFormat();
}
}
// AWT uses 1/4" borders by default
p.getWidth()-36.0,
p.getHeight()-36.0);
} else {
}
pageFormat.setPaper(p);
} else {
}
}
return proceedWithPrint;
}
private void updateAttributes() {
} else {
}
} else {
}
}
} else {
}
} else {
}
// PageAttributes
} else {
}
} else {
}
} else { // NORMAL
}
}
}
debugPrintAttributes(false, false);
}
if (ja) {
"\nselection = "+
"\ncollation "+
);
}
if (pa) {
"\norientation = "+
);
}
}
/* From JobAttributes we will copy job name and duplex printing
* and destination.
* The majority of the rest of the attributes are reflected
* attributes.
*
* From PageAttributes we copy color, media size, orientation,
* origin type, resolution and print quality.
* We use the media, orientation in creating the page format, and
* the origin type to set its imageable area.
*
* REMIND: Interpretation of resolution, additional media sizes.
*/
attributes = new HashPrintRequestAttributeSet();
// Search for the given printerName in the list of PrintServices
try {
break;
}
}
} catch (PrinterException pe) {
}
}
} else {
try {
fileName = ".";
}
} else {
// defaultDest should not be null. The following code
// is only added to safeguard against a possible
// buggy implementation of a PrintService having a
// null default Destination.
fileName = "out.prn";
}
} catch (SecurityException se) {
try {
// '\\' file separator is illegal character in opaque
// part and causes URISyntaxException, so we replace
// it with '/'
} catch (URISyntaxException e) {
}
}
}
}
}
jobAttributes.getMaxPage()));
}
if (hType ==
} else {
}
jobAttributes.getToPage()));
} else {
}
if (pageAttributes.getOrientationRequested() ==
} else {
}
}
}
}
/**
* 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 PrintGraphics
*/
synchronized (this) {
++pageIndex;
// Thread should not be created after end has been called.
// One way to detect this is if any of the graphics queue
// has been closed.
/* We start a thread on which the PrinterJob will run.
* The PrinterJob will ask for pages on that thread
* and will use a message queue to fulfill the application's
* requests for a Graphics on the application's
* thread.
*/
}
notify();
}
/* If the application has already been handed back
* a graphics then we need to put that graphics into
* the drawn queue so that the PrinterJob thread can
* return to the print system.
*/
if (currentGraphics != null) {
}
/* We'll block here until a new graphics becomes
* available.
*/
if (currentGraphics instanceof PeekGraphics) {
}
if (currentGraphics != null) {
/* In the PrintJob API, the origin is at the upper-
* left of the imageable area when using the new "printable"
* origin attribute, otherwise its the physical origin (for
* backwards compatibility. We emulate this by createing
* a PageFormat which matches and then performing the
* translate to the origin. This is a no-op if physical
* origin is specified.
*/
/* Scale to accomodate AWT's notion of printer resolution */
/* The caller wants a Graphics instance but we do
* not want them to make 2D calls. We can't hand
* back a Graphics2D. The returned Graphics also
* needs to implement PrintGraphics, so we wrap
* the Graphics2D instance. The PrintJob API has
* the application dispose of the Graphics so
* we create a copy of the one returned by PrinterJob.
*/
this);
}
return printGraphics;
}
/**
* 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 it scaled accordingly.
*/
if (pageAttributes != null &&
} else {
}
}
private double getPageResolutionInternal() {
if (pageAttributes != null) {
return res[0];
} else /* if (res[2] == 4) */ {
}
} else {
return 72.0;
}
}
/**
* 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.
*/
public int getPageResolution() {
return (int)getPageResolutionInternal();
}
/**
* Returns true if the last page will be printed first.
*/
public boolean lastPageFirst() {
return false;
}
/**
* Ends the print job and does any necessary cleanup.
*/
public synchronized void end() {
/* Prevent the PrinterJob thread from appending any more
* graphics to the to-be-drawn queue
*/
/* If we have a currentGraphics it was the last one returned to the
* PrintJob client. Append it to the drawn queue so that print()
* will return allowing the page to be flushed.
* This really ought to happen in dispose() but for whatever reason
* that isn't how the old PrintJob worked even though its spec
* said dispose() flushed the page.
*/
if (currentGraphics != null) {
}
/* Wait for the PrinterJob.print() thread to terminate, ensuring
* that RasterPrinterJob has made its end doc call, and resources
* are released, files closed etc.
*/
try {
} catch (InterruptedException e) {
}
}
}
/**
* Ends this print job once it is no longer referenced.
* @see #end
*/
public void finalize() {
end();
}
/**
* Prints the page at the specified index into the specified
* {@link Graphics} context in the specified
* format. A <code>PrinterJob</code> calls the
* <code>Printable</code> interface to request that a page be
* rendered into the context specified by
* <code>graphics</code>. The format of the page to be drawn is
* specified by <code>pageFormat</code>. The zero based index
* of the requested page is specified by <code>pageIndex</code>.
* If the requested page does not exist then this method returns
* NO_SUCH_PAGE; otherwise PAGE_EXISTS is returned.
* The <code>Graphics</code> class or subclass implements the
* {@link PrinterGraphics} interface to provide additional
* information. If the <code>Printable</code> object
* aborts the print job then it throws a {@link PrinterException}.
* @param graphics the context into which the page is drawn
* @param pageFormat the size and orientation of the page being drawn
* @param pageIndex the zero based index of the page to be drawn
* @return PAGE_EXISTS if the page is rendered successfully
* or NO_SUCH_PAGE if <code>pageIndex</code> specifies a
* non-existent page.
* @exception java.awt.print.PrinterException
* thrown when the print job is terminated.
*/
throws PrinterException {
int result;
/* This method will be called by the PrinterJob on a thread other
* that the application's thread. We hold on to the graphics
* until we can rendevous with the application's thread and
* hand over the graphics. The application then does all the
* drawing. When the application is done drawing we rendevous
* again with the PrinterJob thread and release the Graphics
* so that it knows we are done.
*/
/* Add the graphics to the message queue of graphics to
* be rendered. This is really a one slot queue. The
* application's thread will come along and remove the
* graphics from the queue when the app asks for a graphics.
*/
/* We now wait for the app's thread to finish drawing on
* the Graphics. This thread will sleep until the application
* release the graphics by placing it in the graphics drawn
* message queue. If the application signals that it is
* finished drawing the entire document then we'll get null
* returned when we try and pop a finished graphic.
*/
} else {
}
return result;
}
private void startPrinterJobThread() {
}
public void run() {
try {
} catch (PrinterException e) {
//REMIND: need to store this away and not rethrow it.
}
/* Close the message queues so that nobody is stuck
* waiting for one.
*/
}
private class MessageQ {
}
synchronized void closeWhenEmpty() {
try {
wait(1000);
} catch (InterruptedException e) {
// do nothing.
}
}
notifyAll();
}
synchronized void close() {
notifyAll();
}
boolean queued = false;
queued = true;
notify();
}
return queued;
}
Graphics2D g = null;
notify();
} else {
try {
wait(2000);
} catch (InterruptedException e) {
// do nothing.
}
}
}
return g;
}
synchronized boolean isClosed() {
}
}
int []dim = new int[2];
break;
}
}
return dim;
}
// JAVAXSIZES.length and SIZES.length must be equal!
// Attempt to recover by getting the smaller size.
for (int i=0; i < length; i++) {
if ((JAVAXSIZES[i] != null) &&
media = JAVAXSIZES[i];
break;
} else {
/* create Custom Media */
if (w > 0.0 && h > 0.0) {
// add new created MediaSize to our static map
// so it will be found when we call findMedia
}
break;
}
}
}
return media;
}
// JAVAXSIZES.length and SIZES.length must be equal!
// Attempt to recover by getting the smaller size.
for (int i=0; i < length; i++) {
if (JAVAXSIZES[i] == mSize) {
break;
}
}
}
return media;
}
private void translateInputProps() {
return;
}
}
}
}
}
}
}
}
}
}
}
private void translateOutputProps() {
return;
}
}
}
if (copies > 0) {
}
}
} else {
}
}
private void throwPrintToFile() {
if (printToFilePermission == null) {
}
}
}
}