Path: blob/master/src/java.desktop/share/classes/sun/print/ProxyPrintGraphics.java
41153 views
/*1* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.print;2627import java.awt.Graphics;28import java.awt.PrintGraphics;29import java.awt.PrintJob;3031/**32* A subclass of Graphics that can be printed to. The33* graphics calls are forwared to another Graphics instance34* that does the actual rendering.35*/3637public class ProxyPrintGraphics extends ProxyGraphics38implements PrintGraphics {3940private PrintJob printJob;4142public ProxyPrintGraphics(Graphics graphics, PrintJob thePrintJob) {43super(graphics);44printJob = thePrintJob;45}4647/**48* Returns the PrintJob object from which this PrintGraphics49* object originated.50*/51public PrintJob getPrintJob() {52return printJob;53}5455/**56* Creates a new {@code Graphics} object that is57* a copy of this {@code Graphics} object.58* @return a new graphics context that is a copy of59* this graphics context.60*/61public Graphics create() {62return new ProxyPrintGraphics(getGraphics().create(), printJob);63}646566/**67* Creates a new {@code Graphics} object based on this68* {@code Graphics} object, but with a new translation and69* clip area.70* Refer to71* {@link sun.print.ProxyGraphics#create(int, int, int, int)}72* for a complete description of this method.73* <p>74* @param x the <i>x</i> coordinate.75* @param y the <i>y</i> coordinate.76* @param width the width of the clipping rectangle.77* @param height the height of the clipping rectangle.78* @return a new graphics context.79* @see java.awt.Graphics#translate80* @see java.awt.Graphics#clipRect81*/82public Graphics create(int x, int y, int width, int height) {83Graphics g = getGraphics().create(x, y, width, height);84return new ProxyPrintGraphics(g, printJob);85}8687public Graphics getGraphics() {88return super.getGraphics();89}909192/* Spec implies dispose() should flush the page, but the implementation93* has in fact always done this on the getGraphics() call, thereby94* ensuring that multiple pages are cannot be rendered simultaneously.95* We will preserve that behaviour and there is consqeuently no need96* to take any action in this dispose method.97*/98public void dispose() {99super.dispose();100}101102}103104105