01: /*
02: *
03: *
04: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: */
26: package com.sun.perseus.j2d;
27:
28: import com.sun.pisces.PiscesRenderer;
29:
30: /**
31: * All rendering in Perseus is done through the <tt>RenderGraphics</tt> class.
32: * <br />
33: * <tt>RenderGraphics</tt> is the combination of the traditional
34: * <tt>Graphics2D</tt> API to the rendering engine and the notion of
35: * graphical context found in SVG.<br />
36: * <br />
37: * A <tt>RenderGraphics</tt> object proxies invocation to a <tt>Graphics2D</tt>
38: * instance through its <tt>draw</tt> or <tt>fill</tt> method while capturing
39: * the current rendering context state by implementing the
40: * <tt>RenderContext</tt> interface.
41: * <br />
42: * <b>Note A</b>: the Java 2D graphic context values passed by the
43: * <tt>RenderGraphics</tt> to the proxied <tt>Graphics2D</tt> correspond to
44: * the CSS 2 <a href="http://www.w3.org/TR/REC-CSS2/cascade.html#actual-value">
45: * actual</a> values.
46: * <br />
47: * <b>Note B</b>: the initial values for the context properties (such
48: * as <tt>color</tt> or <tt>fill</tt>) correspond to the CSS 2
49: * <a href="http://www.w3.org/TR/REC-CSS2/about.html#q7">
50: * initial</a> values for these properties.
51: *
52: * @see RenderContext
53: * @see java.awt.Graphics2D
54: *
55: * @version $Id: RenderGraphics.java,v 1.5 2006/04/21 06:35:43 st125089 Exp $
56: */
57: public class RenderGraphics extends PiscesRenderGraphics {
58: /**
59: * Constructs a new <code>RenderGraphics</code> which will delegate painting
60: * operations to a <code>Graphics2D</code> built for the input
61: * BufferedImage.
62: *
63: * @param pr the <tt>PiscesRenderer</tt> to render to.
64: * @param width the rendering surface width. Should be greater than zero.
65: * @param height the rendering surface height. Should be greater than zero.
66: * @throws NullPointerException if bi is null
67: * @throws NullPointerException if bi is null
68: */
69: public RenderGraphics(final PiscesRenderer pr, final int width,
70: final int height) {
71: super (pr, width, height);
72: }
73:
74: /**
75: * Clears the specified rectangle. IMPORTANT NOTE: the coordinates are in
76: * device space. This method does not account for the current transformation
77: * set on the RenderGraphics. It operates on the target pixels.
78: *
79: * @param x - the x coordinate of the rectangle to clear.
80: * @param y - the y coordinate of the rectangle to clear.
81: * @param width - the width of the rectangle to clear.
82: * @param height - the height of the rectangle to clear.
83: * @param clearColor - the color to use to clear the rectangle.
84: */
85: public void clearRect(int x, int y, int width, int height,
86: RGB clearColor) {
87: pr.setColor(clearColor.getRed(), clearColor.getGreen(),
88: clearColor.getBlue(), clearColor.getAlpha());
89: pr.clearRect(x, y, width, height);
90: }
91:
92: }
|