1 /*
2  * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
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 import java.awt.*;
29 import java.awt.image.*;
30 import java.awt.print.*;
31 import sun.print.*;
32 
33 public class CPrinterGraphics extends ProxyGraphics2D {
34     // NOTE: This is a ProxyGraphics2D, and not a PathGraphics. However
35     // the RasterPrinterJob, upon which CPrinterJob is based, refers to
36     // PathGraphics. However, this is not a code path that will be
37     // encountered by CPrinterJob/CPrinterGraphics. This is because
38     // CPrinterGraphics wraps a SunGraphics2D that has a OSXSurfaceData
39     // based CPrinterSurfaceData. It can do "path graphics" because it
40     // is based upon CoreGraphics. See WPathGraphics and PSPathGraphics.
41 
CPrinterGraphics(Graphics2D graphics, PrinterJob printerJob)42     public CPrinterGraphics(Graphics2D graphics, PrinterJob printerJob) {
43         super(graphics, printerJob);
44     }
45 
drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)46     public boolean drawImage(Image img, int x, int y,
47                  Color bgcolor,
48                  ImageObserver observer) {
49         // ProxyGraphics2D works around a problem that shouldn't be
50         // a problem with CPrinterSurfaceData (and the decision method,
51         // needToCopyBgColorImage, is private instead of protected!)
52         return getDelegate().drawImage(img, x, y, bgcolor, observer);
53     }
54 
drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)55     public boolean drawImage(Image img, int x, int y,
56                  int width, int height,
57                  Color bgcolor,
58                  ImageObserver observer) {
59         // ProxyGraphics2D works around a problem that shouldn't be
60         // a problem with CPrinterSurfaceData (and the decision method,
61         // needToCopyBgColorImage, is private instead of protected!)
62         return getDelegate().drawImage(img, x, y, width, height, bgcolor, observer);
63     }
64 
drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer)65     public boolean drawImage(Image img,
66                  int dx1, int dy1, int dx2, int dy2,
67                  int sx1, int sy1, int sx2, int sy2,
68                  Color bgcolor,
69                  ImageObserver observer) {
70         // ProxyGraphics2D works around a problem that shouldn't be
71         // a problem with CPrinterSurfaceData (and the decision method,
72         // needToCopyBgColorImage, is private instead of protected!)
73         return getDelegate().drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer);
74     }
75 }
76