Normand Briere
2019-05-05 631719825b865aaf9fa1cb124d9fc5bd9dd78bd4
GrafreeD.java
....@@ -15,6 +15,8 @@
1515 //import com.jamonapi.*;
1616 public class GrafreeD extends Applet implements ActionListener
1717 {
18
+ static boolean NIMBUSLAF = true;
19
+
1820 static int RENDERME = 0;
1921
2022 static boolean epsequal = false;
....@@ -50,7 +52,7 @@
5052 universe.material = new cMaterial();
5153 //god.addChild(universe);
5254 universe.name = "Applet";
53
- theApplet3D = this;
55
+ grafreeD = this;
5456 }
5557
5658 /**/
....@@ -595,29 +597,54 @@
595597
596598 public static void main(String argv[])
597599 {
598
- if (false) // argv.length == 0)
600
+ String osArch = System.getProperty("os.arch");
601
+ System.out.println("os.arch = " + osArch);
602
+
603
+ if (argv.length == 0)
599604 {
600
- String javaPath = System.getProperty("java.home") + "/bin/java";
605
+ String javaPath = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
606
+ System.out.println("javaPath = " + javaPath);
601607 java.net.URL u = new GrafreeD().getClass().getResource("default.png");
602608
603
- System.out.println(u);
609
+ System.out.println("URL = " + u);
604610
605611 String jarfile = u.toString().split("file:")[1].split("default.png")[0];
606612
607
- String jarpath = u.toString().split("file:")[1].split("GrafreeD.jar")[0];
613
+ System.out.println("jarfile0 = " + jarfile);
614
+
615
+ String jarpath = u.toString().split("file:")[1].split("Grafreed.jar")[0];
608616
609
- System.out.println(jarfile);
610
- System.out.println(jarpath);
617
+ System.out.println("jarpath0 = " + jarpath);
611618
612619 jarfile = jarfile.substring(0, jarfile.length() - 2);
613620
614
- // -Djava.library.path=/Users/nbriere/Projects/shared/lib
621
+ System.out.println("jarfile = " + jarfile);
622
+
623
+ String command = javaPath + " -Xmx1024m -Djava.library.path=" + jarpath;
615624
616
- String command = "" + javaPath + " -Xmx1024m -Djava.library.path=" + jarpath + "lib -jar " + jarfile + " dummyarg";
625
+ // -Djava.library.path=/Users/nbriere/Projects/shared/lib
626
+ if (jarfile.charAt(2) == ':')
627
+ {
628
+ command = "\"" + javaPath + "\" -Xmx1024m -Djava.library.path=" + jarpath;
629
+ // On Windows systems, the path is /C:/
630
+ jarfile = jarfile.substring(1, jarfile.length());
631
+ System.out.println("jarfile = " + jarfile);
632
+ jarpath = jarpath.substring(1, jarpath.length());
633
+ System.out.println("jarpath = " + jarpath);
634
+ command += "native" + File.separator;
635
+ if (osArch.equals("amd64"))
636
+ command += "windows_amd64";
637
+ else
638
+ command += "windows_i586";
639
+ }
640
+ else
641
+ command += "native" + File.separator + "macosx";
642
+
643
+ command += " -jar " + jarfile + " dummyarg";
617644
618645 try
619646 {
620
- System.out.println(command);
647
+ System.out.println("command = " + command);
621648 Runtime.getRuntime().exec(command);
622649
623650 return;
....@@ -626,6 +653,44 @@
626653 {
627654 e.printStackTrace();
628655 }
656
+
657
+ /*
658
+ if (argv.length == 0)
659
+ {
660
+ String javaPath = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
661
+ System.out.println("javaPath = " + javaPath);
662
+ java.net.URL u = new Grafeme().getClass().getResource("grafeme.jpg");
663
+ System.out.println("URL = " + u);
664
+
665
+ String jarfile = u.toString().split("file:")[1].split("grafeme/grafeme.jpg")[0];
666
+ System.out.println("jarfile0 = " + jarfile);
667
+
668
+ jarfile = jarfile.substring(0, jarfile.length() - 2); // Remove "!/" after .jar
669
+ System.out.println("jarfile = " + jarfile);
670
+
671
+ if (jarfile.charAt(2) == ':')
672
+ {
673
+ // On Windows systems, the path is /C:/
674
+ jarfile = jarfile.substring(1, jarfile.length());
675
+ System.out.println("jarfile = " + jarfile);
676
+ }
677
+
678
+ String command = "\"" + javaPath + "\" -Xmx1024m -jar " + jarfile + " dummyarg";
679
+
680
+ try
681
+ {
682
+ System.out.println(command);
683
+ Runtime.getRuntime().exec(command);
684
+
685
+ return;
686
+ }
687
+ catch (Exception e)
688
+ {
689
+ e.printStackTrace();
690
+ }
691
+ }
692
+
693
+ */
629694 }
630695
631696 // InitDictionary();
....@@ -738,28 +803,57 @@
738803 // PlayAudio("/Users/nbriere/Downloads/Footsteps-6.wav", 4, 1);
739804
740805
741
-
742
- try
806
+/**/
807
+ if (NIMBUSLAF)
743808 {
744
- MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
745
- //MetalLookAndFeel.setCurrentTheme(new Theme(Constants.beigeTheme));
746
- UIManager.setLookAndFeel(new MetalLookAndFeel());
747
- } catch (Exception e)
748
- {
809
+ try
810
+ {
811
+ Object o = UIManager.getInstalledLookAndFeels();
812
+
813
+ javax.swing.plaf.metal.MetalLookAndFeel.setCurrentTheme(new javax.swing.plaf.metal.DefaultMetalTheme());
814
+ //MetalLookAndFeel.setCurrentTheme(new Theme(Constants.beigeTheme));
815
+ UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
816
+
817
+ UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
818
+ //UIManager.setLookAndFeel("com.apple.laf.AquaLookAndFeel");
819
+ //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
820
+ //UIManager.put("nimbusBase", new Color(0,0,0));
821
+ }
822
+ catch (Exception e)
823
+ {
824
+ }
749825 }
826
+ else
827
+ {
828
+ try
829
+ {
830
+ MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
831
+ MetalLookAndFeel.setCurrentTheme(new Theme(Constants.yellowTheme));
832
+ UIManager.setLookAndFeel(new MetalLookAndFeel());
833
+ //UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
834
+ //UIManager.setLookAndFeel("com.apple.laf.AquaLookAndFeel");
835
+ //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
836
+ } catch (Exception e)
837
+ {
838
+ }
839
+ }
840
+/**/
750841
842
+// javax.swing.ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
843
+
751844 //Monitor mon=MonitorFactory.start("myFirstMonitor");
752845 standAlone = true;
753
- theApplet3D = new GrafreeD();
754
- theApplet3D.universe = new Composite();
755
- theApplet3D.universe.name = "Scene";
756
- theApplet3D.universe.material = new cMaterial();
846
+ grafreeD = new GrafreeD();
847
+ grafreeD.universe = new Composite();
848
+ grafreeD.universe.name = "Grafreed";
849
+ grafreeD.universe.material = new cMaterial();
757850 // theApplet3D.universe.textures = CameraPane.DEFAULT_TEXTURE;
758851
759
- theApplet3D.universe.root = true;
760
- theApplet3D.universe.openEditWindow(null, true); //, true);
852
+ grafreeD.universe.root = true;
853
+ grafreeD.universe.openEditWindow(null, true); //, true);
761854 //mon.stop();
762855 //System.out.println(mon);
856
+ //timeflow.app.TimeflowAppLauncher.GetTimeFlow();
763857 }
764858
765859 // Timer callback
....@@ -984,7 +1078,7 @@
9841078 } while (avail > 0 && numRead >= 0);
9851079 return new String(data, 0, pos, "US-ASCII");
9861080 }
987
- public static GrafreeD theApplet3D;
1081
+ public static GrafreeD grafreeD;
9881082 public static boolean standAlone = true;
9891083 public Composite universe;
9901084 public static Object3D clipboard = new Object3D();