.. | .. |
---|
5 | 5 | |
---|
6 | 6 | import java.io.*; |
---|
7 | 7 | |
---|
| 8 | +import java.util.ArrayList; |
---|
8 | 9 | import javax.swing.UIManager; |
---|
9 | 10 | import javax.swing.plaf.metal.MetalLookAndFeel; |
---|
10 | 11 | import javax.swing.plaf.ColorUIResource; |
---|
.. | .. |
---|
15 | 16 | //import com.jamonapi.*; |
---|
16 | 17 | public class Grafreed extends Applet implements ActionListener |
---|
17 | 18 | { |
---|
18 | | - static boolean NIMBUSLAF = true; |
---|
| 19 | + static boolean NIMBUSLAF = false; // true; |
---|
19 | 20 | |
---|
20 | 21 | static int RENDERME = 0; |
---|
21 | 22 | |
---|
.. | .. |
---|
49 | 50 | |
---|
50 | 51 | } |
---|
51 | 52 | } |
---|
| 53 | + |
---|
| 54 | + public static String RemovePrefix(String s, String prefix) |
---|
| 55 | + { |
---|
| 56 | + if (s != null && prefix != null && s.startsWith(prefix)) |
---|
| 57 | + { |
---|
| 58 | + return s.substring(prefix.length()); |
---|
| 59 | + } |
---|
| 60 | + |
---|
| 61 | + return s; |
---|
| 62 | + } |
---|
| 63 | + |
---|
| 64 | + static void ParseFileSystem(java.io.File dir, iResourceCallBack callback, String prefix) |
---|
| 65 | + { |
---|
| 66 | + callback.ResourceCallBack(RemovePrefix(dir.toString(),prefix).split("/")); |
---|
| 67 | + File[] listFiles = dir.listFiles(); |
---|
| 68 | + if (listFiles != null) |
---|
| 69 | + { |
---|
| 70 | + for (java.io.File file : listFiles) |
---|
| 71 | + { |
---|
| 72 | + ParseFileSystem(file, callback, prefix); |
---|
| 73 | + } |
---|
| 74 | + } |
---|
| 75 | + } |
---|
| 76 | + |
---|
| 77 | + static interface iResourceCallBack |
---|
| 78 | + { |
---|
| 79 | + void ResourceCallBack(String[] path); |
---|
| 80 | + } |
---|
| 81 | + |
---|
| 82 | + static void ParseResources(String path, iResourceCallBack callback) |
---|
| 83 | + { |
---|
| 84 | + java.io.File jarFile = new java.io.File(Grafreed.class.getProtectionDomain().getCodeSource().getLocation().getPath()); |
---|
| 85 | + |
---|
| 86 | + if (jarFile.isFile()) |
---|
| 87 | + { |
---|
| 88 | + // Run with JAR file |
---|
| 89 | + try |
---|
| 90 | + { |
---|
| 91 | + java.util.jar.JarFile jar = new java.util.jar.JarFile(jarFile); |
---|
| 92 | + java.util.Enumeration<java.util.jar.JarEntry> entries = jar.entries(); //gives ALL entries in jar |
---|
| 93 | + while (entries.hasMoreElements()) |
---|
| 94 | + { |
---|
| 95 | + String name = entries.nextElement().getName(); |
---|
| 96 | + |
---|
| 97 | + if (name.startsWith(path + "/")) |
---|
| 98 | + callback.ResourceCallBack(RemovePrefix(name, path + "/").split("/")); |
---|
| 99 | + } |
---|
| 100 | + jar.close(); |
---|
| 101 | + } catch (Exception ex) |
---|
| 102 | + { |
---|
| 103 | + ex.printStackTrace(); |
---|
| 104 | + } |
---|
| 105 | + } else |
---|
| 106 | + { |
---|
| 107 | + // Run with IDE |
---|
| 108 | + final java.net.URL url = Object3D.class.getResource("/" + path); |
---|
| 109 | + if (url != null) |
---|
| 110 | + { |
---|
| 111 | + try |
---|
| 112 | + { |
---|
| 113 | + java.io.File apps = new java.io.File(url.toURI()); |
---|
| 114 | + ParseFileSystem(apps, callback, RemovePrefix(url.toString() + "/", "file:")); |
---|
| 115 | +// for (java.io.File app : apps.listFiles()) |
---|
| 116 | +// { |
---|
| 117 | +// //System.out.println(RemovePrefix(app.toString(), RemovePrefix(url.toString(), "file:") + "/")); |
---|
| 118 | +// } |
---|
| 119 | + } catch (Exception ex) |
---|
| 120 | + { |
---|
| 121 | + ex.printStackTrace(); |
---|
| 122 | + } |
---|
| 123 | + } |
---|
| 124 | + } |
---|
| 125 | + } |
---|
52 | 126 | |
---|
53 | 127 | public void init() |
---|
54 | 128 | { |
---|
.. | .. |
---|
58 | 132 | universe.material = new cMaterial(); |
---|
59 | 133 | //god.addChild(universe); |
---|
60 | 134 | universe.name = "Applet"; |
---|
61 | | - grafreeD = this; |
---|
| 135 | + grafreed = this; |
---|
62 | 136 | } |
---|
63 | 137 | |
---|
64 | 138 | /**/ |
---|
.. | .. |
---|
603 | 677 | |
---|
604 | 678 | public static void main(String argv[]) |
---|
605 | 679 | { |
---|
606 | | - String osArch = System.getProperty("os.arch"); |
---|
| 680 | + String osArch = System.getProperty("os.arch"); |
---|
| 681 | + if (Globals.DEBUG) |
---|
607 | 682 | System.out.println("os.arch = " + osArch); |
---|
608 | 683 | |
---|
609 | 684 | if (argv.length == 0) |
---|
.. | .. |
---|
626 | 701 | |
---|
627 | 702 | System.out.println("jarfile = " + jarfile); |
---|
628 | 703 | |
---|
629 | | - String command = javaPath + " -Xmx2048m -Djava.library.path=" + jarpath; |
---|
| 704 | + String command = javaPath + " -Xmx1024m -Djava.library.path=" + jarpath; |
---|
630 | 705 | |
---|
631 | 706 | // -Djava.library.path=/Users/nbriere/Projects/shared/lib |
---|
632 | 707 | if (jarfile.charAt(2) == ':') |
---|
633 | 708 | { |
---|
634 | | - command = "\"" + javaPath + "\" -Xmx2048m -Djava.library.path=" + jarpath; |
---|
| 709 | + command = "\"" + javaPath + "\" -Xmx1024m -Djava.library.path=" + jarpath; |
---|
635 | 710 | // On Windows systems, the path is /C:/ |
---|
636 | 711 | jarfile = jarfile.substring(1, jarfile.length()); |
---|
637 | 712 | System.out.println("jarfile = " + jarfile); |
---|
.. | .. |
---|
824 | 899 | //UIManager.setLookAndFeel("com.apple.laf.AquaLookAndFeel"); |
---|
825 | 900 | //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); |
---|
826 | 901 | //UIManager.put("nimbusBase", new Color(0,0,0)); |
---|
| 902 | + |
---|
| 903 | + javax.swing.UIDefaults ui = UIManager.getDefaults(); |
---|
| 904 | + for (java.util.Enumeration e = ui.keys(); e.hasMoreElements();) |
---|
| 905 | + { |
---|
| 906 | + Object key = e.nextElement(); |
---|
| 907 | + System.out.println(key + " --> " + ui.get(key)); |
---|
| 908 | + } |
---|
827 | 909 | } |
---|
828 | 910 | catch (Exception e) |
---|
829 | 911 | { |
---|
.. | .. |
---|
833 | 915 | { |
---|
834 | 916 | try |
---|
835 | 917 | { |
---|
836 | | - MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme()); |
---|
837 | | - MetalLookAndFeel.setCurrentTheme(new Theme(Constants.yellowTheme)); |
---|
| 918 | + //Object o = UIManager.getInstalledLookAndFeels(); |
---|
| 919 | + |
---|
| 920 | + MetalLookAndFeel.setCurrentTheme(new javax.swing.plaf.metal.DefaultMetalTheme()); |
---|
| 921 | + //MetalLookAndFeel.setCurrentTheme(new Theme(Constants.yellowTheme)); |
---|
| 922 | + //UIManager.put("ScrollBar.background", new javax.swing.plaf.ColorUIResource(100,0,0)); |
---|
838 | 923 | UIManager.setLookAndFeel(new MetalLookAndFeel()); |
---|
839 | 924 | //UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); |
---|
840 | 925 | //UIManager.setLookAndFeel("com.apple.laf.AquaLookAndFeel"); |
---|
| 926 | + //UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel"); |
---|
841 | 927 | //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); |
---|
| 928 | + |
---|
| 929 | + javax.swing.UIDefaults ui = UIManager.getDefaults(); |
---|
| 930 | + ArrayList gradient = new java.util.ArrayList(5); |
---|
| 931 | + gradient.add(1.0); |
---|
| 932 | + gradient.add(0.0); |
---|
| 933 | + gradient.add(new javax.swing.plaf.ColorUIResource(255,255,255)); |
---|
| 934 | + gradient.add(new javax.swing.plaf.ColorUIResource(192,192,192)); |
---|
| 935 | + gradient.add(new javax.swing.plaf.ColorUIResource(0,0,0)); |
---|
| 936 | + |
---|
| 937 | + ui.put("Button.gradient", gradient); |
---|
| 938 | + ui.put("TabbedPane.tabInsets", new javax.swing.plaf.InsetsUIResource(0,8,0,0)); |
---|
| 939 | + ui.put("Slider.foreground", new javax.swing.plaf.ColorUIResource(0,0,0)); |
---|
| 940 | + ui.put("Slider.horizontalThumbIcon", ObjEditor.GetIcon("icons/white-sphere-icon.png")); |
---|
| 941 | + |
---|
| 942 | + //javax.swing.plaf.metal.MetalIconFactory.getHorizontalSliderThumbIcon(). |
---|
| 943 | + Object o = ui.get("Slider.horizontalThumbIcon"); |
---|
| 944 | + |
---|
| 945 | + gradient = new java.util.ArrayList(5); |
---|
| 946 | + gradient.add(1.0); |
---|
| 947 | + gradient.add(0.0); |
---|
| 948 | + gradient.add(new javax.swing.plaf.ColorUIResource(192,192,192)); |
---|
| 949 | + gradient.add(new javax.swing.plaf.ColorUIResource(255,255,255)); |
---|
| 950 | + gradient.add(new javax.swing.plaf.ColorUIResource(0,0,0)); |
---|
| 951 | + |
---|
| 952 | + ui.put("ToggleButton.gradient", gradient); |
---|
| 953 | + //ui.put("Button[MouseOver].backgroundPainter", new com.sun.java.swing.plaf.nimbus.ButtonPainter()); |
---|
| 954 | + //ui.put("Button.highlight", new javax.swing.plaf.ColorUIResource(155,155,155)); |
---|
| 955 | + |
---|
| 956 | + for (java.util.Enumeration e = ui.keys(); e.hasMoreElements();) |
---|
| 957 | + { |
---|
| 958 | + Object key = e.nextElement(); |
---|
| 959 | + //System.out.println(key + " --> " + ui.get(key)); |
---|
| 960 | + } |
---|
842 | 961 | } catch (Exception e) |
---|
843 | 962 | { |
---|
844 | 963 | } |
---|
.. | .. |
---|
849 | 968 | |
---|
850 | 969 | //Monitor mon=MonitorFactory.start("myFirstMonitor"); |
---|
851 | 970 | standAlone = true; |
---|
852 | | - grafreeD = new Grafreed(); |
---|
853 | | - grafreeD.universe = new cGroup(); |
---|
854 | | - grafreeD.universe.name = "Grafreed"; |
---|
855 | | - grafreeD.universe.material = new cMaterial(); |
---|
| 971 | + grafreed = new Grafreed(); |
---|
| 972 | + grafreed.materials = ReadGFD(grafreed.getClass().getClassLoader().getResourceAsStream("gfd/materials.gfd")); |
---|
| 973 | + |
---|
| 974 | + grafreed.universe = new cGroup(); |
---|
| 975 | + grafreed.universe.name = "Grafreed"; |
---|
| 976 | + grafreed.universe.material = new cMaterial(); |
---|
| 977 | + grafreed.universe.skyboxname = "cubemaps/penguins-skyboxes/yonder"; |
---|
| 978 | + grafreed.universe.skyboxext = "jpg"; |
---|
| 979 | + |
---|
856 | 980 | // theApplet3D.universe.textures = CameraPane.DEFAULT_TEXTURE; |
---|
857 | 981 | |
---|
858 | | - grafreeD.universe.root = true; |
---|
859 | | - grafreeD.universe.openEditWindow(null, true); //, true); |
---|
| 982 | + grafreed.universe.root = true; |
---|
| 983 | + grafreed.universe.openEditWindow(null, true); //, true); |
---|
860 | 984 | //mon.stop(); |
---|
861 | 985 | //System.out.println(mon); |
---|
862 | 986 | //timeflow.app.TimeflowAppLauncher.GetTimeFlow(); |
---|
| 987 | + |
---|
| 988 | + javax.swing.ToolTipManager.sharedInstance().setEnabled(Globals.TOOLTIPS); |
---|
863 | 989 | } |
---|
864 | 990 | |
---|
| 991 | + static Object3D materials; |
---|
| 992 | + |
---|
| 993 | + static Object3D ReadGFD(java.io.InputStream istream) |
---|
| 994 | + { |
---|
| 995 | + Object3D readobj = null; |
---|
| 996 | + |
---|
| 997 | + try |
---|
| 998 | + { |
---|
| 999 | + // Try compressed version first. |
---|
| 1000 | + java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream); |
---|
| 1001 | + java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream); |
---|
| 1002 | + |
---|
| 1003 | + readobj = (Object3D) p.readObject(); |
---|
| 1004 | + p.close(); |
---|
| 1005 | + zstream.close(); |
---|
| 1006 | + istream.close(); |
---|
| 1007 | + |
---|
| 1008 | + readobj.ResetDisplayList(); |
---|
| 1009 | + } catch (Exception e) |
---|
| 1010 | + { |
---|
| 1011 | + if (!e.toString().contains("GZIP")) |
---|
| 1012 | + e.printStackTrace(); |
---|
| 1013 | + |
---|
| 1014 | + try |
---|
| 1015 | + { |
---|
| 1016 | + java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream); |
---|
| 1017 | + |
---|
| 1018 | + readobj = (Object3D) p.readObject(); |
---|
| 1019 | + p.close(); |
---|
| 1020 | + istream.close(); |
---|
| 1021 | + |
---|
| 1022 | + readobj.ResetDisplayList(); |
---|
| 1023 | + } catch (Exception e2) |
---|
| 1024 | + { |
---|
| 1025 | + e2.printStackTrace(); |
---|
| 1026 | + } |
---|
| 1027 | + } |
---|
| 1028 | + |
---|
| 1029 | + return readobj; |
---|
| 1030 | + } |
---|
| 1031 | + |
---|
865 | 1032 | // Timer callback |
---|
866 | 1033 | public void actionPerformed(ActionEvent e) |
---|
867 | 1034 | { |
---|
.. | .. |
---|
1085 | 1252 | } while (avail > 0 && numRead >= 0); |
---|
1086 | 1253 | return new String(data, 0, pos, "US-ASCII"); |
---|
1087 | 1254 | } |
---|
1088 | | - public static Grafreed grafreeD; |
---|
| 1255 | + public static Grafreed grafreed; |
---|
1089 | 1256 | public static boolean standAlone = true; |
---|
1090 | 1257 | public Composite universe; |
---|
1091 | 1258 | public static Object3D clipboard = new Object3D(); |
---|