01: /*
02: * $RCSfile: NativeScreenInfo.java,v $
03: *
04: * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06: *
07: * This code is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU General Public License version 2 only, as
09: * published by the Free Software Foundation. Sun designates this
10: * particular file as subject to the "Classpath" exception as provided
11: * by Sun in the LICENSE file that accompanied this code.
12: *
13: * This code is distributed in the hope that it will be useful, but WITHOUT
14: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16: * version 2 for more details (a copy is included in the LICENSE file that
17: * accompanied this code).
18: *
19: * You should have received a copy of the GNU General Public License version
20: * 2 along with this work; if not, write to the Free Software Foundation,
21: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22: *
23: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24: * CA 95054 USA or visit www.sun.com if you need additional information or
25: * have any questions.
26: *
27: * $Revision: 1.2 $
28: * $Date: 2008/02/28 20:17:26 $
29: * $State: Exp $
30: */
31:
32: package javax.media.j3d;
33:
34: import java.awt.GraphicsDevice;
35:
36: /**
37: * Native screen info class. A singleton instance of the appropriate
38: * concrete subclass is created by a factory method using reflection.
39: */
40: abstract class NativeScreenInfo {
41: private static final String x11ClassName = "javax.media.j3d.X11NativeScreenInfo";
42: private static final String win32ClassName = "javax.media.j3d.Win32NativeScreenInfo";
43:
44: // The singleton instance of this class
45: private static NativeScreenInfo nativeScreenInfo = null;
46:
47: protected NativeScreenInfo() {
48: }
49:
50: // This method is called exactly once by the initialization method of
51: // the NativePipeline class
52: synchronized static void createNativeScreenInfo() {
53: String className;
54: if (MasterControl.isWindows()) {
55: className = win32ClassName;
56: } else {
57: className = x11ClassName;
58: }
59:
60: final String scrInfoClassName = className;
61: nativeScreenInfo = (NativeScreenInfo) java.security.AccessController
62: .doPrivileged(new java.security.PrivilegedAction() {
63: public Object run() {
64: try {
65: Class scrInfoClass = Class
66: .forName(scrInfoClassName);
67: return scrInfoClass.newInstance();
68: } catch (Exception e) {
69: throw new RuntimeException(e);
70: }
71: }
72: });
73: }
74:
75: static NativeScreenInfo getNativeScreenInfo() {
76: return nativeScreenInfo;
77: }
78:
79: /**
80: * Get the display handle
81: */
82: abstract long getDisplay();
83:
84: /**
85: * Get the screen number for the given graphics device
86: */
87: abstract int getScreen(GraphicsDevice graphicsDevice);
88: }
|