Normand Briere
2019-09-18 f9325048496d7cdbcad233f8a6b84c88e79adcc2
Grafreed.java
....@@ -13,11 +13,20 @@
1313
1414 import javax.sound.sampled.*;
1515
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
+
1627 //import com.jamonapi.*;
1728 public class Grafreed extends Applet implements ActionListener
18
-{
19
- static boolean NIMBUSLAF = false; // true;
20
-
29
+{
2130 static int RENDERME = 0;
2231
2332 static boolean epsequal = false;
....@@ -675,12 +684,18 @@
675684 PlayWord(word, 1);
676685 }
677686
687
+ static boolean isWindows;
688
+
678689 public static void main(String argv[])
679690 {
680
- String osArch = System.getProperty("os.arch");
691
+ String osArch = System.getProperty("os.arch");
681692 if (Globals.DEBUG)
682693 System.out.println("os.arch = " + osArch);
683694
695
+ String osName = System.getProperty("os.name");
696
+
697
+ isWindows = !osName.equals("Mac OS X");
698
+
684699 if (argv.length == 0)
685700 {
686701 String javaPath = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
....@@ -883,17 +898,16 @@
883898 // try{Thread.sleep(5000);}catch(Exception e){}
884899 // PlayAudio("/Users/nbriere/Downloads/Footsteps-6.wav", 4, 1);
885900
886
-
887901 /**/
888
- if (NIMBUSLAF)
902
+ if (Globals.NIMBUSLAF)
889903 {
890904 try
891905 {
892
- Object o = UIManager.getInstalledLookAndFeels();
906
+ //Object o = UIManager.getInstalledLookAndFeels();
893907
894908 javax.swing.plaf.metal.MetalLookAndFeel.setCurrentTheme(new javax.swing.plaf.metal.DefaultMetalTheme());
895909 //MetalLookAndFeel.setCurrentTheme(new Theme(Constants.beigeTheme));
896
- UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
910
+ //UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
897911
898912 UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
899913 //UIManager.setLookAndFeel("com.apple.laf.AquaLookAndFeel");
....@@ -901,6 +915,9 @@
901915 //UIManager.put("nimbusBase", new Color(0,0,0));
902916
903917 javax.swing.UIDefaults ui = UIManager.getDefaults();
918
+
919
+ ui.put("TabbedPane.tabInsets", new javax.swing.plaf.InsetsUIResource(0,8,0,0));
920
+
904921 for (java.util.Enumeration e = ui.keys(); e.hasMoreElements();)
905922 {
906923 Object key = e.nextElement();
....@@ -920,13 +937,21 @@
920937 MetalLookAndFeel.setCurrentTheme(new javax.swing.plaf.metal.DefaultMetalTheme());
921938 //MetalLookAndFeel.setCurrentTheme(new Theme(Constants.yellowTheme));
922939 //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
+
923946 UIManager.setLookAndFeel(new MetalLookAndFeel());
924
- //UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
925947 //UIManager.setLookAndFeel("com.apple.laf.AquaLookAndFeel");
926948 //UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
927949 //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
928950
929
- javax.swing.UIDefaults ui = UIManager.getDefaults();
951
+ ui = UIManager.getDefaults();
952
+
953
+ x = ui.get("RadioButton.icon");
954
+
930955 ArrayList gradient = new java.util.ArrayList(5);
931956 gradient.add(1.0);
932957 gradient.add(0.0);
....@@ -935,10 +960,50 @@
935960 gradient.add(new javax.swing.plaf.ColorUIResource(0,0,0));
936961
937962 ui.put("Button.gradient", gradient);
938
- ui.put("TabbedPane.tabInsets", new javax.swing.plaf.InsetsUIResource(0,8,0,0));
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
+
939968 ui.put("Slider.foreground", new javax.swing.plaf.ColorUIResource(0,0,0));
940969 ui.put("Slider.horizontalThumbIcon", ObjEditor.GetIcon("icons/white-sphere-icon.png"));
941970
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
+
9421007 //javax.swing.plaf.metal.MetalIconFactory.getHorizontalSliderThumbIcon().
9431008 Object o = ui.get("Slider.horizontalThumbIcon");
9441009
....@@ -963,24 +1028,70 @@
9631028 }
9641029 }
9651030 /**/
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
+ /////////////
9661075
9671076 // javax.swing.ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
9681077
9691078 //Monitor mon=MonitorFactory.start("myFirstMonitor");
9701079 standAlone = true;
971
- grafreed = new Grafreed();
1080
+
1081
+ grafreed = new Grafreed();
1082
+
9721083 grafreed.materials = ReadGFD(grafreed.getClass().getClassLoader().getResourceAsStream("gfd/materials.gfd"));
9731084
9741085 grafreed.universe = new cGroup();
9751086 grafreed.universe.name = "Grafreed";
9761087 grafreed.universe.material = new cMaterial();
977
- grafreed.universe.skyboxname = "cubemaps/penguins-skyboxes/yonder";
978
- grafreed.universe.skyboxext = "jpg";
9791088
9801089 // theApplet3D.universe.textures = CameraPane.DEFAULT_TEXTURE;
9811090
9821091 grafreed.universe.root = true;
9831092 grafreed.universe.openEditWindow(null, true); //, true);
1093
+ grafreed.universe.editWindow.New();
1094
+
9841095 //mon.stop();
9851096 //System.out.println(mon);
9861097 //timeflow.app.TimeflowAppLauncher.GetTimeFlow();
....@@ -988,6 +1099,33 @@
9881099 javax.swing.ToolTipManager.sharedInstance().setEnabled(Globals.TOOLTIPS);
9891100 }
9901101
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
+
9911129 static Object3D materials;
9921130
9931131 static Object3D ReadGFD(java.io.InputStream istream)
....@@ -1150,6 +1288,11 @@
11501288
11511289 static public Object clone(Object o)
11521290 {
1291
+ if (o instanceof Object3D)
1292
+ {
1293
+ assert(((Object3D)o).parent == null);
1294
+ }
1295
+
11531296 if (o == null)
11541297 return null;
11551298