01: /*
02: * $RCSfile: CanvasJAI.java,v $
03: *
04: * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
05: *
06: * Use is subject to license terms.
07: *
08: * $Revision: 1.1 $
09: * $Date: 2005/02/11 04:57:05 $
10: * $State: Exp $
11: */
12: package javax.media.jai;
13:
14: import java.awt.Canvas;
15: import java.awt.Graphics;
16: import java.awt.Graphics2D;
17: import java.awt.GraphicsConfiguration;
18:
19: /**
20: * An extension of <code>java.awt.Canvas</code> for use with JAI.
21: * <code>CanvasJAI</code> automatically returns an instance of
22: * <code>GraphicsJAI</code> from its <code>getGraphics()</code>
23: * method. This guarantees that the <code>update(Graphics g)</code>
24: * and <code>paint(Graphics g)</code> methods will receive a
25: * <code>GraphicsJAI</code> instance for accelerated rendering of
26: * <code>JAI</code> images.
27: *
28: * <p> In circumstances where it is not possible to use
29: * <code>CanvasJAI</code>, a similar effect may be obtained by
30: * manually calling <code>GraphicsJAI.createGraphicsJAI()</code> to
31: * "wrap" a <code>Graphics2D</code> object.
32: *
33: * @see GraphicsJAI
34: */
35: public class CanvasJAI extends Canvas {
36:
37: /**
38: * Constructs an instance of <code>CanvasJAI</code> using the
39: * given <code>GraphicsConfiguration</code>.
40: */
41: public CanvasJAI(GraphicsConfiguration config) {
42: super (config);
43: }
44:
45: /**
46: * Returns an instance of <code>GraphicsJAI</code> for drawing to
47: * this canvas.
48: */
49: public Graphics getGraphics() {
50: Graphics2D g = (Graphics2D) super.getGraphics();
51: return GraphicsJAI.createGraphicsJAI(g, this);
52: }
53: }
|