01: /*
02: * @(#)OffScreenCanvas3D.java 1.0, 1 May 2000
03: *
04: * Copyright (c) 2000 Silvere Martin-Michiellot All Rights Reserved.
05: *
06: * Silvere Martin-Michiellot grants you ("Licensee") a non-exclusive,
07: * royalty free, license to use, modify and redistribute this
08: * software in source and binary code form,
09: * provided that i) this copyright notice and license appear on all copies of
10: * the software; and ii) Licensee does not utilize the software in a manner
11: * which is disparaging to Silvere Martin-Michiellot.
12: *
13: * This software is provided "AS IS," without a warranty of any kind. ALL
14: * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
15: * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
16: * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Silvere Martin-Michiellot
17: * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
18: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
19: * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
20: * Silvere Martin-Michiellot OR ITS LICENSORS BE LIABLE
21: * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
22: * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
23: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
24: * OR INABILITY TO USE SOFTWARE, EVEN IF Silvere Martin-Michiellot HAS BEEN
25: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
26: *
27: * This software is not designed or intended for use in on-line control of
28: * aircraft, air traffic, aircraft navigation or aircraft communications; or in
29: * the design, construction, operation or maintenance of any nuclear
30: * facility. Licensee represents and warrants that it will not use or
31: * redistribute the Software for such purposes.
32: *
33: * @Author: Silvere Martin-Michiellot
34: *
35: */
36:
37: package com.db.media.print;
38:
39: // This code is repackaged after the code from the Java3D SDK
40: // Site http://java.sun.com/
41: // Email java3d-interest@java.sun.com (mailing list)
42:
43: import java.awt.GraphicsConfiguration;
44: import java.awt.image.BufferedImage;
45: import javax.media.j3d.*;
46: import javax.vecmath.*;
47:
48: public class OffScreenCanvas3D extends Canvas3D {
49:
50: public OffScreenCanvas3D(
51: GraphicsConfiguration graphicsConfiguration,
52: boolean offScreen) {
53:
54: super (graphicsConfiguration, offScreen);
55:
56: }
57:
58: public BufferedImage doRender(int width, int height) {
59:
60: BufferedImage bImage = new BufferedImage(width, height,
61: BufferedImage.TYPE_INT_ARGB);
62:
63: ImageComponent2D buffer = new ImageComponent2D(
64: ImageComponent.FORMAT_RGBA, bImage);
65:
66: setOffScreenBuffer(buffer);
67: renderOffScreenBuffer();
68: waitForOffScreenRendering();
69: bImage = getOffScreenBuffer().getImage();
70:
71: return bImage;
72:
73: }
74:
75: public void postSwap() {
76:
77: // No-op since we always wait for off-screen rendering to complete
78:
79: }
80:
81: }
|