]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/threedee/WindowFactory.java
Version 6, October 2008
[GpsPrune.git] / tim / prune / threedee / WindowFactory.java
1 package tim.prune.threedee;
2
3 import javax.swing.JFrame;
4
5 import tim.prune.App;
6
7 /**
8  * Factory class for getting a Window
9  */
10 public abstract class WindowFactory
11 {
12         private static Java3DWindow _window = null;
13
14         /**
15          * Get a Window object
16          * @param inApp App object
17          * @param inFrame parent frame
18          * @return object if available, otherwise null
19          */
20         public static ThreeDWindow getWindow(App inApp, JFrame inFrame)
21         {
22                 if (isJava3dEnabled())
23                 {
24                         if (_window == null) {
25                                 _window = new Java3DWindow(inApp, inFrame);
26                         }
27                         else {
28                                 _window.dispose();
29                         }
30                         return _window;
31                 }
32                 return null;
33         }
34
35
36         /**
37          * @return true if 3d capability is installed
38          */
39         public static boolean isJava3dEnabled()
40         {
41                 boolean has3d = false;
42                 try
43                 {
44                         Class universeClass = Class.forName("com.sun.j3d.utils.universe.SimpleUniverse");
45                         has3d = (universeClass != null);
46                 }
47                 catch (ClassNotFoundException e)
48                 {
49                         // no java3d classes available
50                 }
51                 return has3d;
52         }
53
54 }