From 480ad70047e54b2b92f974e6c2ac5a6c0bdc5a5c Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Sun, 18 Aug 2019 13:56:09 -0400
Subject: [PATCH] Fix new + checkbox

---
 Grafreed.java |  168 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 152 insertions(+), 16 deletions(-)

diff --git a/Grafreed.java b/Grafreed.java
index ed3e880..8de12f4 100644
--- a/Grafreed.java
+++ b/Grafreed.java
@@ -5,6 +5,7 @@
 
 import java.io.*;
 
+import java.util.ArrayList;
 import javax.swing.UIManager;
 import javax.swing.plaf.metal.MetalLookAndFeel;
 import javax.swing.plaf.ColorUIResource;
@@ -14,9 +15,7 @@
 
 //import com.jamonapi.*;
 public class Grafreed extends Applet implements ActionListener
-{
-        static boolean NIMBUSLAF = true;
-        
+{        
     static int RENDERME = 0;
 
     static boolean epsequal = false;
@@ -62,7 +61,7 @@
     
     static void ParseFileSystem(java.io.File dir, iResourceCallBack callback, String prefix)
     {
-        callback.CallBack(RemovePrefix(dir.toString(),prefix).split("/"));
+        callback.ResourceCallBack(RemovePrefix(dir.toString(),prefix).split("/"));
         File[] listFiles = dir.listFiles();
         if (listFiles != null)
         {
@@ -75,7 +74,7 @@
         
     static interface iResourceCallBack
     {
-        void CallBack(String[] path);
+        void ResourceCallBack(String[] path);
     }
     
     static void ParseResources(String path, iResourceCallBack callback)
@@ -94,7 +93,7 @@
                     String name = entries.nextElement().getName();
                     
                     if (name.startsWith(path + "/"))
-                        callback.CallBack(RemovePrefix(name, path).split("/"));
+                        callback.ResourceCallBack(RemovePrefix(name, path + "/").split("/"));
                 }
                 jar.close();
             } catch (Exception ex)
@@ -110,7 +109,7 @@
                 try
                 {
                     java.io.File apps = new java.io.File(url.toURI());
-                    ParseFileSystem(apps, callback, RemovePrefix(url.toString(), "file:"));
+                    ParseFileSystem(apps, callback, RemovePrefix(url.toString() + "/", "file:"));
 //                    for (java.io.File app : apps.listFiles())
 //                    {
 //                        //System.out.println(RemovePrefix(app.toString(), RemovePrefix(url.toString(), "file:") + "/"));
@@ -676,7 +675,8 @@
     
     public static void main(String argv[])
     {
-                String osArch = System.getProperty("os.arch");
+         String osArch = System.getProperty("os.arch");
+        if (Globals.DEBUG)
                 System.out.println("os.arch = " + osArch);
                 
         if (argv.length == 0)
@@ -881,22 +881,31 @@
 //        try{Thread.sleep(5000);}catch(Exception e){}
 //        PlayAudio("/Users/nbriere/Downloads/Footsteps-6.wav", 4, 1);
         
-        
 /**/
-        if (NIMBUSLAF)
+        if (Globals.NIMBUSLAF)
         {
                 try
                 {
-                    Object o = UIManager.getInstalledLookAndFeels();
+                    //Object o = UIManager.getInstalledLookAndFeels();
                         
                     javax.swing.plaf.metal.MetalLookAndFeel.setCurrentTheme(new javax.swing.plaf.metal.DefaultMetalTheme());
                     //MetalLookAndFeel.setCurrentTheme(new Theme(Constants.beigeTheme));
-                    UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
+                    //UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
                     
                         UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
             //UIManager.setLookAndFeel("com.apple.laf.AquaLookAndFeel");
             //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
                         //UIManager.put("nimbusBase", new Color(0,0,0));
+                        
+                    javax.swing.UIDefaults ui = UIManager.getDefaults();
+                    
+                    ui.put("TabbedPane.tabInsets", new javax.swing.plaf.InsetsUIResource(0,8,0,0));
+                    
+                    for (java.util.Enumeration e = ui.keys(); e.hasMoreElements();)
+                    {
+                        Object key = e.nextElement();
+                        System.out.println(key + " --> " + ui.get(key));
+                    }
                 }
                 catch (Exception e)
                 {
@@ -906,12 +915,97 @@
         {
                 try
                 {
-                    MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
-                    MetalLookAndFeel.setCurrentTheme(new Theme(Constants.yellowTheme));
+                    //Object o = UIManager.getInstalledLookAndFeels();
+                    
+                    MetalLookAndFeel.setCurrentTheme(new javax.swing.plaf.metal.DefaultMetalTheme());
+                    //MetalLookAndFeel.setCurrentTheme(new Theme(Constants.yellowTheme));
+                    //UIManager.put("ScrollBar.background", new javax.swing.plaf.ColorUIResource(100,0,0));
+                    UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
+                    
+                    javax.swing.UIDefaults ui = UIManager.getDefaults();
+                    
+                    Object x = ui.get("TabbedPane.background");
+                    
                     UIManager.setLookAndFeel(new MetalLookAndFeel());
-                    //UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
                     //UIManager.setLookAndFeel("com.apple.laf.AquaLookAndFeel");
+                    //UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
                     //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
+                    
+                    ui = UIManager.getDefaults();
+                    
+                    x = ui.get("RadioButton.icon");
+                    
+                    ArrayList gradient = new java.util.ArrayList(5);
+                    gradient.add(1.0);
+                    gradient.add(0.0);
+                    gradient.add(new javax.swing.plaf.ColorUIResource(255,255,255));
+                    gradient.add(new javax.swing.plaf.ColorUIResource(192,192,192));
+                    gradient.add(new javax.swing.plaf.ColorUIResource(0,0,0));
+                    
+                    ui.put("Button.gradient", gradient);
+                    
+                    //ui.put("RadioButton.icon", new CheckBox()); //ObjEditor.GetIcon("icons/white-sphere-icon.png")));
+                    ui.put("CheckBox.icon", new CheckBox()); //ObjEditor.GetIcon("icons/white-sphere-icon.png")));
+                    //ui.put("CheckBoxMenuItem.checkIcon", ObjEditor.GetIcon("icons/white-sphere-icon.png"));
+                    
+                    ui.put("Slider.foreground", new javax.swing.plaf.ColorUIResource(0,0,0));
+                    ui.put("Slider.horizontalThumbIcon", ObjEditor.GetIcon("icons/white-sphere-icon.png"));
+                    
+                    /*
+TabbedPane.unselectedBackground	Color
+TabbedPane.unselectedTabBackground	Color
+TabbedPane.unselectedTabForeground	Color
+TabbedPane.unselectedTabHighlight	Color
+TabbedPane.unselectedTabShadow	
+                     */
+//                    ui.put("TabbedPane.contentAreaColor", new javax.swing.plaf.ColorUIResource(0,100,0));
+                    //ui.put("TabbedPane.selected", new javax.swing.plaf.ColorUIResource(200,0,200));
+                    
+                    ui.put("TabbedPane.background", new javax.swing.plaf.ColorUIResource(150,150,150));
+                    ui.put("TabbedPane.foreground", new javax.swing.plaf.ColorUIResource(50,50,50));
+                    ui.put("TabbedPane.light", new javax.swing.plaf.ColorUIResource(255,255,255));
+                    ui.put("TabbedPane.selectedForeground", new javax.swing.plaf.ColorUIResource(0,0,0));
+                    ui.put("TabbedPane.selectHighlight", new javax.swing.plaf.ColorUIResource(255,255,255));
+                    ui.put("TabbedPane.darkShadow", new javax.swing.plaf.ColorUIResource(0,0,0));
+                    
+//                    ui.put("TabbedPane.shadow", new javax.swing.plaf.ColorUIResource(200,0,0));
+//                    ui.put("TabbedPane.tabAreaBackground", new javax.swing.plaf.ColorUIResource(0,200,0));
+//                    ui.put("TabbedPane.unselectedBackground", new javax.swing.plaf.ColorUIResource(200,200,0));
+//                    ui.put("TabbedPane.unselectedTabBackground", new javax.swing.plaf.ColorUIResource(0,0,200));
+//                    ui.put("TabbedPane.unselectedTabForeground", new javax.swing.plaf.ColorUIResource(200,0,200));
+//                    ui.put("TabbedPane.unselectedTabHighlight", new javax.swing.plaf.ColorUIResource(0,200,200));
+//                    ui.put("TabbedPane.unselectedTabShadow", new javax.swing.plaf.ColorUIResource(200,200,200));
+                    
+                    ui.put("TabbedPane.textIconGap", 0);
+                    ui.put("TabbedPane.contentBorderInsets", new javax.swing.plaf.InsetsUIResource(0,0,0,0));
+                    ui.put("TabbedPane.tabAreaInsets", new javax.swing.plaf.InsetsUIResource(1,1,0,0));
+                    ui.put("TabbedPane.tabInsets", new javax.swing.plaf.InsetsUIResource(0,8,0,0));
+                    
+                    Object openIcon2 = ui.get("Tree.openIcon");
+                    
+                    ui.put("Tree.openIcon", ObjEditor.GetIcon("icons/folderopen.png"));
+                    ui.put("Tree.closedIcon", ObjEditor.GetIcon("icons/folderclose.png"));
+                    ui.put("Tree.leafIcon", ObjEditor.GetIcon("icons/file.png"));
+
+                    //javax.swing.plaf.metal.MetalIconFactory.getHorizontalSliderThumbIcon().
+                    Object o = ui.get("Slider.horizontalThumbIcon");
+                    
+                    gradient = new java.util.ArrayList(5);
+                    gradient.add(1.0);
+                    gradient.add(0.0);
+                    gradient.add(new javax.swing.plaf.ColorUIResource(192,192,192));
+                    gradient.add(new javax.swing.plaf.ColorUIResource(255,255,255));
+                    gradient.add(new javax.swing.plaf.ColorUIResource(0,0,0));
+                    
+                    ui.put("ToggleButton.gradient", gradient);
+                    //ui.put("Button[MouseOver].backgroundPainter", new com.sun.java.swing.plaf.nimbus.ButtonPainter());
+                    //ui.put("Button.highlight", new javax.swing.plaf.ColorUIResource(155,155,155));
+                    
+                    for (java.util.Enumeration e = ui.keys(); e.hasMoreElements();)
+                    {
+                        Object key = e.nextElement();
+                        //System.out.println(key + " --> " + ui.get(key));
+                    }
                 } catch (Exception e)
                 {
                 }
@@ -922,12 +1016,17 @@
         
         //Monitor mon=MonitorFactory.start("myFirstMonitor");
         standAlone = true;
-        grafreed = new Grafreed();
+        
+        grafreed = new Grafreed();   
+        
         grafreed.materials = ReadGFD(grafreed.getClass().getClassLoader().getResourceAsStream("gfd/materials.gfd"));
         
         grafreed.universe = new cGroup();
         grafreed.universe.name = "Grafreed";
         grafreed.universe.material = new cMaterial();
+        grafreed.universe.skyboxname = "cubemaps/penguins-skyboxes/yonder";
+        grafreed.universe.skyboxext = "jpg";
+        
         //   theApplet3D.universe.textures = CameraPane.DEFAULT_TEXTURE;
 
         grafreed.universe.root = true;
@@ -935,8 +1034,37 @@
         //mon.stop();
         //System.out.println(mon);
         //timeflow.app.TimeflowAppLauncher.GetTimeFlow();
+        
+        javax.swing.ToolTipManager.sharedInstance().setEnabled(Globals.TOOLTIPS);
     }
 
+    static class CheckBox extends javax.swing.plaf.metal.MetalCheckBoxIcon
+    {
+        java.awt.image.BufferedImage image;
+        
+        CheckBox()
+        {
+            try
+            {
+                image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream("icons/checkbox.png"));
+            }
+            catch (Exception e)
+            {
+            }
+        }
+        
+        protected void drawCheck(Component c, Graphics g, int x, int y)
+        {
+            super.drawCheck(c, g, x, y);
+        }
+        
+        public void paintIcon(Component c, Graphics g, int x, int y)
+        {
+            g.drawImage(image, x-1, y-1, 19, 19, null);
+            super.paintIcon(c, g, x+2, y+2);
+        }
+    }
+    
     static Object3D materials;
     
     static Object3D ReadGFD(java.io.InputStream istream)
@@ -950,6 +1078,8 @@
             java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
 
             readobj = (Object3D) p.readObject();
+            p.close();
+            zstream.close();
             istream.close();
 
             readobj.ResetDisplayList();
@@ -963,6 +1093,7 @@
                 java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
 
                 readobj = (Object3D) p.readObject();
+                p.close();
                 istream.close();
 
                 readobj.ResetDisplayList();
@@ -1096,6 +1227,11 @@
 
     static public Object clone(Object o)
     {
+        if (o instanceof Object3D)
+        {
+            assert(((Object3D)o).parent == null);
+        }
+        
         if (o == null)
             return null;
         

--
Gitblit v1.6.2