src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java

Print this page




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.lwawt.macosx;
  27 
  28 
  29 import java.awt.*;
  30 import java.awt.geom.Rectangle2D;
  31 import java.awt.image.BufferedImage;
  32 import java.awt.print.*;
  33 
  34 import javax.print.*;
  35 import javax.print.attribute.PrintRequestAttributeSet;

  36 
  37 import sun.java2d.*;
  38 import sun.print.*;
  39 
  40 public class CPrinterJob extends RasterPrinterJob {
  41     // NOTE: This uses RasterPrinterJob as a base, but it doesn't use
  42     // all of the RasterPrinterJob functions. RasterPrinterJob will
  43     // break down printing to pieces that aren't necessary under MacOSX
  44     // printing, such as controlling the # of copies and collating. These
  45     // are handled by the native printing. RasterPrinterJob is kept for
  46     // future compatibility and the state keeping that it handles.
  47 
  48     private static String sShouldNotReachHere = "Should not reach here.";
  49 
  50     private boolean noDefaultPrinter = false;
  51 
  52     private static Font defaultFont;
  53 
  54     // This is the NSPrintInfo for this PrinterJob. Protect multi thread
  55     //  access to it. It is used by the pageDialog, jobDialog, and printLoop.


 128 
 129         PageFormat pageClone = (PageFormat) page.clone();
 130         boolean doIt = pageSetup(pageClone, null);
 131         return doIt ? pageClone : page;
 132     }
 133 
 134     /**
 135      * Clones the <code>PageFormat</code> argument and alters the
 136      * clone to describe a default page size and orientation.
 137      * @param page the <code>PageFormat</code> to be cloned and altered
 138      * @return clone of <code>page</code>, altered to describe a default
 139      *                      <code>PageFormat</code>.
 140      */
 141     public PageFormat defaultPage(PageFormat page) {
 142         PageFormat newPage = (PageFormat)page.clone();
 143         getDefaultPage(newPage);
 144         return newPage;
 145     }
 146 
 147     protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {











 148         super.setAttributes(attributes);
 149 
 150         if (attributes == null) {
 151             return;
 152         }
 153 
 154         // See if this has an NSPrintInfo in it.
 155         NSPrintInfo nsPrintInfo = (NSPrintInfo)attributes.get(NSPrintInfo.class);
 156         if (nsPrintInfo != null) {
 157             fNSPrintInfo = nsPrintInfo.getValue();
 158         }
 159     }
 160 
 161     volatile boolean onEventThread;
 162 
 163     private void completePrintLoop() {
 164         Runnable r = new Runnable() { public void run() {
 165             synchronized(this) {
 166                 performingPrinting = false;
 167             }




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.lwawt.macosx;
  27 
  28 
  29 import java.awt.*;
  30 import java.awt.geom.Rectangle2D;
  31 import java.awt.image.BufferedImage;
  32 import java.awt.print.*;
  33 
  34 import javax.print.*;
  35 import javax.print.attribute.PrintRequestAttributeSet;
  36 import javax.print.attribute.standard.PageRanges;
  37 
  38 import sun.java2d.*;
  39 import sun.print.*;
  40 
  41 public class CPrinterJob extends RasterPrinterJob {
  42     // NOTE: This uses RasterPrinterJob as a base, but it doesn't use
  43     // all of the RasterPrinterJob functions. RasterPrinterJob will
  44     // break down printing to pieces that aren't necessary under MacOSX
  45     // printing, such as controlling the # of copies and collating. These
  46     // are handled by the native printing. RasterPrinterJob is kept for
  47     // future compatibility and the state keeping that it handles.
  48 
  49     private static String sShouldNotReachHere = "Should not reach here.";
  50 
  51     private boolean noDefaultPrinter = false;
  52 
  53     private static Font defaultFont;
  54 
  55     // This is the NSPrintInfo for this PrinterJob. Protect multi thread
  56     //  access to it. It is used by the pageDialog, jobDialog, and printLoop.


 129 
 130         PageFormat pageClone = (PageFormat) page.clone();
 131         boolean doIt = pageSetup(pageClone, null);
 132         return doIt ? pageClone : page;
 133     }
 134 
 135     /**
 136      * Clones the <code>PageFormat</code> argument and alters the
 137      * clone to describe a default page size and orientation.
 138      * @param page the <code>PageFormat</code> to be cloned and altered
 139      * @return clone of <code>page</code>, altered to describe a default
 140      *                      <code>PageFormat</code>.
 141      */
 142     public PageFormat defaultPage(PageFormat page) {
 143         PageFormat newPage = (PageFormat)page.clone();
 144         getDefaultPage(newPage);
 145         return newPage;
 146     }
 147 
 148     protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
 149         if (attributes != null) {
 150             PageRanges pageRangesAttr =
 151                 (PageRanges)attributes.get(PageRanges.class);
 152             if (pageRangesAttr != null) {
 153                 SunPageSelection psel = (SunPageSelection)attributes.get(SunPageSelection.class);
 154                 if (psel == null) {
 155                     attributes.add(SunPageSelection.RANGE);
 156                 }
 157             }
 158         }
 159 
 160         super.setAttributes(attributes);
 161 
 162         if (attributes == null) {
 163             return;
 164         }
 165 
 166         // See if this has an NSPrintInfo in it.
 167         NSPrintInfo nsPrintInfo = (NSPrintInfo)attributes.get(NSPrintInfo.class);
 168         if (nsPrintInfo != null) {
 169             fNSPrintInfo = nsPrintInfo.getValue();
 170         }
 171     }
 172 
 173     volatile boolean onEventThread;
 174 
 175     private void completePrintLoop() {
 176         Runnable r = new Runnable() { public void run() {
 177             synchronized(this) {
 178                 performingPrinting = false;
 179             }