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