From 07750666120cf38c7ad4f3a3a583a8c4d582bb0e Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Tue, 23 Apr 2019 22:30:47 -0400 Subject: [PATCH] Cross-platform main. --- GrafreeD.java | 92 ++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 76 insertions(+), 16 deletions(-) diff --git a/GrafreeD.java b/GrafreeD.java index bc4d7f1..1527f55 100644 --- a/GrafreeD.java +++ b/GrafreeD.java @@ -50,7 +50,7 @@ universe.material = new cMaterial(); //god.addChild(universe); universe.name = "Applet"; - theApplet3D = this; + grafreeD = this; } /**/ @@ -597,27 +597,45 @@ { if (argv.length == 0) { - String javaPath = System.getProperty("java.home") + "/bin/java"; + String javaPath = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; + System.out.println("javaPath = " + javaPath); java.net.URL u = new GrafreeD().getClass().getResource("default.png"); - System.out.println(u); + System.out.println("URL = " + u); String jarfile = u.toString().split("file:")[1].split("default.png")[0]; + System.out.println("jarfile0 = " + jarfile); + String jarpath = u.toString().split("file:")[1].split("GrafreeD.jar")[0]; - System.out.println(jarfile); - System.out.println(jarpath); + System.out.println("jarpath0 = " + jarpath); jarfile = jarfile.substring(0, jarfile.length() - 2); - // -Djava.library.path=/Users/nbriere/Projects/shared/lib + System.out.println("jarfile = " + jarfile); + + String command = javaPath + " -Xmx1024m -Djava.library.path=" + jarpath; - String command = "" + javaPath + " -Xmx1024m -Djava.library.path=" + jarpath + "lib -jar " + jarfile + " dummyarg"; + // -Djava.library.path=/Users/nbriere/Projects/shared/lib + if (jarfile.charAt(2) == ':') + { + command = "\"" + javaPath + "\" -Xmx1024m -Djava.library.path=" + jarpath; + // On Windows systems, the path is /C:/ + jarfile = jarfile.substring(1, jarfile.length()); + System.out.println("jarfile = " + jarfile); + jarpath = jarpath.substring(1, jarpath.length()); + System.out.println("jarpath = " + jarpath); + command += "native" + File.separator + "windows_amd64"; + } + else + command += "native" + File.separator + "macosx"; + + command += " -jar " + jarfile + " dummyarg"; try { - System.out.println(command); + System.out.println("command = " + command); Runtime.getRuntime().exec(command); return; @@ -626,6 +644,44 @@ { e.printStackTrace(); } + + /* + if (argv.length == 0) + { + String javaPath = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; + System.out.println("javaPath = " + javaPath); + java.net.URL u = new Grafeme().getClass().getResource("grafeme.jpg"); + System.out.println("URL = " + u); + + String jarfile = u.toString().split("file:")[1].split("grafeme/grafeme.jpg")[0]; + System.out.println("jarfile0 = " + jarfile); + + jarfile = jarfile.substring(0, jarfile.length() - 2); // Remove "!/" after .jar + System.out.println("jarfile = " + jarfile); + + if (jarfile.charAt(2) == ':') + { + // On Windows systems, the path is /C:/ + jarfile = jarfile.substring(1, jarfile.length()); + System.out.println("jarfile = " + jarfile); + } + + String command = "\"" + javaPath + "\" -Xmx1024m -jar " + jarfile + " dummyarg"; + + try + { + System.out.println(command); + Runtime.getRuntime().exec(command); + + return; + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + */ } // InitDictionary(); @@ -742,24 +798,28 @@ try { MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme()); - //MetalLookAndFeel.setCurrentTheme(new Theme(Constants.beigeTheme)); + MetalLookAndFeel.setCurrentTheme(new Theme(Constants.yellowTheme)); UIManager.setLookAndFeel(new MetalLookAndFeel()); + //UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); + //UIManager.setLookAndFeel("com.apple.laf.AquaLookAndFeel"); + //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception e) { } //Monitor mon=MonitorFactory.start("myFirstMonitor"); standAlone = true; - theApplet3D = new GrafreeD(); - theApplet3D.universe = new Composite(); - theApplet3D.universe.name = "Scene"; - theApplet3D.universe.material = new cMaterial(); + grafreeD = new GrafreeD(); + grafreeD.universe = new Composite(); + grafreeD.universe.name = "Scene"; + grafreeD.universe.material = new cMaterial(); // theApplet3D.universe.textures = CameraPane.DEFAULT_TEXTURE; - theApplet3D.universe.root = true; - theApplet3D.universe.openEditWindow(null, true); //, true); + grafreeD.universe.root = true; + grafreeD.universe.openEditWindow(null, true); //, true); //mon.stop(); //System.out.println(mon); + //timeflow.app.TimeflowAppLauncher.GetTimeFlow(); } // Timer callback @@ -984,7 +1044,7 @@ } while (avail > 0 && numRead >= 0); return new String(data, 0, pos, "US-ASCII"); } - public static GrafreeD theApplet3D; + public static GrafreeD grafreeD; public static boolean standAlone = true; public Composite universe; public static Object3D clipboard = new Object3D(); -- Gitblit v1.6.2