X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Fthreedee%2FWindowFactory.java;fp=src%2Ftim%2Fprune%2Fthreedee%2FWindowFactory.java;h=42ff8a46b906c3030903eb0064ca6a5eac31f4c4;hp=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465 diff --git a/src/tim/prune/threedee/WindowFactory.java b/src/tim/prune/threedee/WindowFactory.java new file mode 100644 index 0000000..42ff8a4 --- /dev/null +++ b/src/tim/prune/threedee/WindowFactory.java @@ -0,0 +1,59 @@ +package tim.prune.threedee; + +import javax.swing.JFrame; + +/** + * Factory class for getting a Window + */ +public abstract class WindowFactory +{ + private static Java3DWindow _window = null; + + /** + * Get a Window object + * @param inFrame parent frame + * @return object if available, otherwise null + */ + public static ThreeDWindow getWindow(JFrame inFrame) + { + if (isJava3dEnabled()) + { + if (_window == null) { + _window = new Java3DWindow(inFrame); + } + else { + _window.dispose(); + } + return _window; + } + return null; + } + + + /** + * @return true if 3d capability is installed + */ + public static boolean isJava3dEnabled() + { + boolean has3d = false; + try + { + Class universeClass = Class.forName("com.sun.j3d.utils.universe.SimpleUniverse"); + has3d = (universeClass != null); + } + catch (ClassNotFoundException e) + { + // no java3d classes available + } + catch (NoClassDefFoundError nfe) + { + // no java3d classes available + } + catch (UnsatisfiedLinkError ule) + { + // java3d classes found but no native components + } + return has3d; + } + +}