Normand Briere
2019-09-18 f9325048496d7cdbcad233f8a6b84c88e79adcc2
Grafreed.java
....@@ -5,6 +5,7 @@
55
66 import java.io.*;
77
8
+import java.util.ArrayList;
89 import javax.swing.UIManager;
910 import javax.swing.plaf.metal.MetalLookAndFeel;
1011 import javax.swing.plaf.ColorUIResource;
....@@ -12,11 +13,20 @@
1213
1314 import javax.sound.sampled.*;
1415
16
+import javax.net.ssl.HostnameVerifier;
17
+import javax.net.ssl.HttpsURLConnection;
18
+import javax.net.ssl.SSLContext;
19
+import javax.net.ssl.SSLSession;
20
+import javax.net.ssl.TrustManager;
21
+import javax.net.ssl.X509TrustManager;
22
+
23
+import java.security.cert.X509Certificate;
24
+import java.net.Authenticator;
25
+import java.net.PasswordAuthentication;
26
+
1527 //import com.jamonapi.*;
1628 public class Grafreed extends Applet implements ActionListener
17
-{
18
- static boolean NIMBUSLAF = true;
19
-
29
+{
2030 static int RENDERME = 0;
2131
2232 static boolean epsequal = false;
....@@ -674,11 +684,18 @@
674684 PlayWord(word, 1);
675685 }
676686
687
+ static boolean isWindows;
688
+
677689 public static void main(String argv[])
678690 {
679
- String osArch = System.getProperty("os.arch");
691
+ String osArch = System.getProperty("os.arch");
692
+ if (Globals.DEBUG)
680693 System.out.println("os.arch = " + osArch);
681694
695
+ String osName = System.getProperty("os.name");
696
+
697
+ isWindows = !osName.equals("Mac OS X");
698
+
682699 if (argv.length == 0)
683700 {
684701 String javaPath = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
....@@ -881,22 +898,31 @@
881898 // try{Thread.sleep(5000);}catch(Exception e){}
882899 // PlayAudio("/Users/nbriere/Downloads/Footsteps-6.wav", 4, 1);
883900
884
-
885901 /**/
886
- if (NIMBUSLAF)
902
+ if (Globals.NIMBUSLAF)
887903 {
888904 try
889905 {
890
- Object o = UIManager.getInstalledLookAndFeels();
906
+ //Object o = UIManager.getInstalledLookAndFeels();
891907
892908 javax.swing.plaf.metal.MetalLookAndFeel.setCurrentTheme(new javax.swing.plaf.metal.DefaultMetalTheme());
893909 //MetalLookAndFeel.setCurrentTheme(new Theme(Constants.beigeTheme));
894
- UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
910
+ //UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
895911
896912 UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
897913 //UIManager.setLookAndFeel("com.apple.laf.AquaLookAndFeel");
898914 //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
899915 //UIManager.put("nimbusBase", new Color(0,0,0));
916
+
917
+ javax.swing.UIDefaults ui = UIManager.getDefaults();
918
+
919
+ ui.put("TabbedPane.tabInsets", new javax.swing.plaf.InsetsUIResource(0,8,0,0));
920
+
921
+ for (java.util.Enumeration e = ui.keys(); e.hasMoreElements();)
922
+ {
923
+ Object key = e.nextElement();
924
+ System.out.println(key + " --> " + ui.get(key));
925
+ }
900926 }
901927 catch (Exception e)
902928 {
....@@ -906,35 +932,166 @@
906932 {
907933 try
908934 {
909
- MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
910
- MetalLookAndFeel.setCurrentTheme(new Theme(Constants.yellowTheme));
935
+ //Object o = UIManager.getInstalledLookAndFeels();
936
+
937
+ MetalLookAndFeel.setCurrentTheme(new javax.swing.plaf.metal.DefaultMetalTheme());
938
+ //MetalLookAndFeel.setCurrentTheme(new Theme(Constants.yellowTheme));
939
+ //UIManager.put("ScrollBar.background", new javax.swing.plaf.ColorUIResource(100,0,0));
940
+ UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
941
+
942
+ javax.swing.UIDefaults ui = UIManager.getDefaults();
943
+
944
+ Object x = ui.get("TabbedPane.background");
945
+
911946 UIManager.setLookAndFeel(new MetalLookAndFeel());
912
- //UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
913947 //UIManager.setLookAndFeel("com.apple.laf.AquaLookAndFeel");
948
+ //UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
914949 //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
950
+
951
+ ui = UIManager.getDefaults();
952
+
953
+ x = ui.get("RadioButton.icon");
954
+
955
+ ArrayList gradient = new java.util.ArrayList(5);
956
+ gradient.add(1.0);
957
+ gradient.add(0.0);
958
+ gradient.add(new javax.swing.plaf.ColorUIResource(255,255,255));
959
+ gradient.add(new javax.swing.plaf.ColorUIResource(192,192,192));
960
+ gradient.add(new javax.swing.plaf.ColorUIResource(0,0,0));
961
+
962
+ ui.put("Button.gradient", gradient);
963
+
964
+ //ui.put("RadioButton.icon", new CheckBox()); //ObjEditor.GetIcon("icons/white-sphere-icon.png")));
965
+ ui.put("CheckBox.icon", new CheckBox()); //ObjEditor.GetIcon("icons/white-sphere-icon.png")));
966
+ //ui.put("CheckBoxMenuItem.checkIcon", ObjEditor.GetIcon("icons/white-sphere-icon.png"));
967
+
968
+ ui.put("Slider.foreground", new javax.swing.plaf.ColorUIResource(0,0,0));
969
+ ui.put("Slider.horizontalThumbIcon", ObjEditor.GetIcon("icons/white-sphere-icon.png"));
970
+
971
+ /*
972
+TabbedPane.unselectedBackground Color
973
+TabbedPane.unselectedTabBackground Color
974
+TabbedPane.unselectedTabForeground Color
975
+TabbedPane.unselectedTabHighlight Color
976
+TabbedPane.unselectedTabShadow
977
+ */
978
+// ui.put("TabbedPane.contentAreaColor", new javax.swing.plaf.ColorUIResource(0,100,0));
979
+ //ui.put("TabbedPane.selected", new javax.swing.plaf.ColorUIResource(200,0,200));
980
+
981
+ ui.put("TabbedPane.background", new javax.swing.plaf.ColorUIResource(150,150,150));
982
+ ui.put("TabbedPane.foreground", new javax.swing.plaf.ColorUIResource(50,50,50));
983
+ ui.put("TabbedPane.light", new javax.swing.plaf.ColorUIResource(255,255,255));
984
+ ui.put("TabbedPane.selectedForeground", new javax.swing.plaf.ColorUIResource(0,0,0));
985
+ ui.put("TabbedPane.selectHighlight", new javax.swing.plaf.ColorUIResource(255,255,255));
986
+ ui.put("TabbedPane.darkShadow", new javax.swing.plaf.ColorUIResource(0,0,0));
987
+
988
+// ui.put("TabbedPane.shadow", new javax.swing.plaf.ColorUIResource(200,0,0));
989
+// ui.put("TabbedPane.tabAreaBackground", new javax.swing.plaf.ColorUIResource(0,200,0));
990
+// ui.put("TabbedPane.unselectedBackground", new javax.swing.plaf.ColorUIResource(200,200,0));
991
+// ui.put("TabbedPane.unselectedTabBackground", new javax.swing.plaf.ColorUIResource(0,0,200));
992
+// ui.put("TabbedPane.unselectedTabForeground", new javax.swing.plaf.ColorUIResource(200,0,200));
993
+// ui.put("TabbedPane.unselectedTabHighlight", new javax.swing.plaf.ColorUIResource(0,200,200));
994
+// ui.put("TabbedPane.unselectedTabShadow", new javax.swing.plaf.ColorUIResource(200,200,200));
995
+
996
+ ui.put("TabbedPane.textIconGap", 0);
997
+ ui.put("TabbedPane.contentBorderInsets", new javax.swing.plaf.InsetsUIResource(0,0,0,0));
998
+ ui.put("TabbedPane.tabAreaInsets", new javax.swing.plaf.InsetsUIResource(1,1,0,0));
999
+ ui.put("TabbedPane.tabInsets", new javax.swing.plaf.InsetsUIResource(0,8,0,0));
1000
+
1001
+ Object openIcon2 = ui.get("Tree.openIcon");
1002
+
1003
+ ui.put("Tree.openIcon", ObjEditor.GetIcon("icons/folderopen.png"));
1004
+ ui.put("Tree.closedIcon", ObjEditor.GetIcon("icons/folderclose.png"));
1005
+ ui.put("Tree.leafIcon", ObjEditor.GetIcon("icons/file.png"));
1006
+
1007
+ //javax.swing.plaf.metal.MetalIconFactory.getHorizontalSliderThumbIcon().
1008
+ Object o = ui.get("Slider.horizontalThumbIcon");
1009
+
1010
+ gradient = new java.util.ArrayList(5);
1011
+ gradient.add(1.0);
1012
+ gradient.add(0.0);
1013
+ gradient.add(new javax.swing.plaf.ColorUIResource(192,192,192));
1014
+ gradient.add(new javax.swing.plaf.ColorUIResource(255,255,255));
1015
+ gradient.add(new javax.swing.plaf.ColorUIResource(0,0,0));
1016
+
1017
+ ui.put("ToggleButton.gradient", gradient);
1018
+ //ui.put("Button[MouseOver].backgroundPainter", new com.sun.java.swing.plaf.nimbus.ButtonPainter());
1019
+ //ui.put("Button.highlight", new javax.swing.plaf.ColorUIResource(155,155,155));
1020
+
1021
+ for (java.util.Enumeration e = ui.keys(); e.hasMoreElements();)
1022
+ {
1023
+ Object key = e.nextElement();
1024
+ //System.out.println(key + " --> " + ui.get(key));
1025
+ }
9151026 } catch (Exception e)
9161027 {
9171028 }
9181029 }
9191030 /**/
1031
+
1032
+ // Create a trust manager that does not validate certificate chains
1033
+ final TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
1034
+ @Override
1035
+ public void checkClientTrusted(final X509Certificate[] chain, final String authType) {
1036
+ }
1037
+
1038
+ @Override
1039
+ public void checkServerTrusted(final X509Certificate[] chain, final String authType) {
1040
+ }
1041
+
1042
+ @Override
1043
+ public X509Certificate[] getAcceptedIssuers() {
1044
+ return null;
1045
+ }
1046
+ } };
1047
+
1048
+ try
1049
+ {
1050
+ // Install the all-trusting trust manager
1051
+ final SSLContext sslContext = SSLContext.getInstance("SSL");
1052
+ sslContext.init(null, trustAllCerts, null);
1053
+ // Create an ssl socket factory with our all-trusting manager
1054
+ HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
1055
+ HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
1056
+ public boolean verify(String urlHostName, SSLSession session) {
1057
+ return true;
1058
+ }
1059
+ });
1060
+ // be authentic
1061
+ Authenticator.setDefault(new Authenticator() {
1062
+ @Override
1063
+ protected PasswordAuthentication getPasswordAuthentication() {
1064
+ return new PasswordAuthentication("args[0]", "args[1]".toCharArray());
1065
+ }
1066
+ });
1067
+ }
1068
+ catch (Exception e)
1069
+ {
1070
+ e.printStackTrace();
1071
+ }
1072
+
1073
+
1074
+ /////////////
9201075
9211076 // javax.swing.ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
9221077
9231078 //Monitor mon=MonitorFactory.start("myFirstMonitor");
9241079 standAlone = true;
925
- grafreed = new Grafreed();
1080
+
1081
+ grafreed = new Grafreed();
1082
+
9261083 grafreed.materials = ReadGFD(grafreed.getClass().getClassLoader().getResourceAsStream("gfd/materials.gfd"));
9271084
9281085 grafreed.universe = new cGroup();
9291086 grafreed.universe.name = "Grafreed";
9301087 grafreed.universe.material = new cMaterial();
931
- grafreed.universe.skyboxname = "cubemaps/penguins-skyboxes/tropic";
932
- grafreed.universe.skyboxext = "jpg";
9331088
9341089 // theApplet3D.universe.textures = CameraPane.DEFAULT_TEXTURE;
9351090
9361091 grafreed.universe.root = true;
9371092 grafreed.universe.openEditWindow(null, true); //, true);
1093
+ grafreed.universe.editWindow.New();
1094
+
9381095 //mon.stop();
9391096 //System.out.println(mon);
9401097 //timeflow.app.TimeflowAppLauncher.GetTimeFlow();
....@@ -942,6 +1099,33 @@
9421099 javax.swing.ToolTipManager.sharedInstance().setEnabled(Globals.TOOLTIPS);
9431100 }
9441101
1102
+ static class CheckBox extends javax.swing.plaf.metal.MetalCheckBoxIcon
1103
+ {
1104
+ java.awt.image.BufferedImage image;
1105
+
1106
+ CheckBox()
1107
+ {
1108
+ try
1109
+ {
1110
+ image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream("icons/checkbox.png"));
1111
+ }
1112
+ catch (Exception e)
1113
+ {
1114
+ }
1115
+ }
1116
+
1117
+ protected void drawCheck(Component c, Graphics g, int x, int y)
1118
+ {
1119
+ super.drawCheck(c, g, x, y);
1120
+ }
1121
+
1122
+ public void paintIcon(Component c, Graphics g, int x, int y)
1123
+ {
1124
+ g.drawImage(image, x-1, y-1, 19, 19, null);
1125
+ super.paintIcon(c, g, x+2, y+2);
1126
+ }
1127
+ }
1128
+
9451129 static Object3D materials;
9461130
9471131 static Object3D ReadGFD(java.io.InputStream istream)
....@@ -955,6 +1139,8 @@
9551139 java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
9561140
9571141 readobj = (Object3D) p.readObject();
1142
+ p.close();
1143
+ zstream.close();
9581144 istream.close();
9591145
9601146 readobj.ResetDisplayList();
....@@ -968,6 +1154,7 @@
9681154 java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
9691155
9701156 readobj = (Object3D) p.readObject();
1157
+ p.close();
9711158 istream.close();
9721159
9731160 readobj.ResetDisplayList();
....@@ -1101,6 +1288,11 @@
11011288
11021289 static public Object clone(Object o)
11031290 {
1291
+ if (o instanceof Object3D)
1292
+ {
1293
+ assert(((Object3D)o).parent == null);
1294
+ }
1295
+
11041296 if (o == null)
11051297 return null;
11061298