]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/threedee/WindowFactory.java
Version 14.1, January 2013
[GpsPrune.git] / tim / prune / threedee / WindowFactory.java
index 89560efa1b2b7e592c8c7dfa2412bc8bf4b72a23..549c11a1ef97439899d759c22fa1a9fa84cfab90 100644 (file)
@@ -2,26 +2,28 @@ package tim.prune.threedee;
 
 import javax.swing.JFrame;
 
-import tim.prune.App;
-
 /**
  * Factory class for getting a Window
  */
 public abstract class WindowFactory
 {
-       private static ThreeDWindow _window = null;
+       private static Java3DWindow _window = null;
 
        /**
         * Get a Window object
-        * @param inApp App object
         * @param inFrame parent frame
         * @return object if available, otherwise null
         */
-       public static ThreeDWindow getWindow(App inApp, JFrame inFrame)
+       public static ThreeDWindow getWindow(JFrame inFrame)
        {
                if (isJava3dEnabled())
                {
-                       if (_window == null) _window = new Java3DWindow(inApp, inFrame);
+                       if (_window == null) {
+                               _window = new Java3DWindow(inFrame);
+                       }
+                       else {
+                               _window.dispose();
+                       }
                        return _window;
                }
                return null;
@@ -31,18 +33,22 @@ public abstract class WindowFactory
        /**
         * @return true if 3d capability is installed
         */
-       private static boolean isJava3dEnabled()
+       public static boolean isJava3dEnabled()
        {
                boolean has3d = false;
                try
                {
-                       Class universeClass = Class.forName("com.sun.j3d.utils.universe.SimpleUniverse");
-                       has3d = true;
+                       Class<?> universeClass = Class.forName("com.sun.j3d.utils.universe.SimpleUniverse");
+                       has3d = (universeClass != null);
                }
                catch (ClassNotFoundException e)
                {
                        // no java3d classes available
                }
+               catch (UnsatisfiedLinkError ule)
+               {
+                       // java3d available but somehow incompatible?
+               }
                return has3d;
        }