From 33504fc9a180903aace77613264550754fba5706 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Thu, 15 Aug 2019 12:03:58 -0400
Subject: [PATCH] Shadow RGB

---
 Grafreed.java |   81 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/Grafreed.java b/Grafreed.java
index a463511..8896325 100644
--- a/Grafreed.java
+++ b/Grafreed.java
@@ -49,6 +49,79 @@
             
         }
     }
+
+    public static String RemovePrefix(String s, String prefix)
+    {
+        if (s != null && prefix != null && s.startsWith(prefix))
+        {
+            return s.substring(prefix.length());
+        }
+
+        return s;
+    }
+    
+    static void ParseFileSystem(java.io.File dir, iResourceCallBack callback, String prefix)
+    {
+        callback.ResourceCallBack(RemovePrefix(dir.toString(),prefix).split("/"));
+        File[] listFiles = dir.listFiles();
+        if (listFiles != null)
+        {
+            for (java.io.File file : listFiles)
+            {
+                ParseFileSystem(file, callback, prefix);
+            }
+        }
+    }
+        
+    static interface iResourceCallBack
+    {
+        void ResourceCallBack(String[] path);
+    }
+    
+    static void ParseResources(String path, iResourceCallBack callback)
+    {
+        java.io.File jarFile = new java.io.File(Grafreed.class.getProtectionDomain().getCodeSource().getLocation().getPath());
+
+        if (jarFile.isFile())
+        {
+            // Run with JAR file
+            try
+            {
+                java.util.jar.JarFile jar = new java.util.jar.JarFile(jarFile);
+                java.util.Enumeration<java.util.jar.JarEntry> entries = jar.entries(); //gives ALL entries in jar
+                while (entries.hasMoreElements())
+                {
+                    String name = entries.nextElement().getName();
+                    
+                    if (name.startsWith(path + "/"))
+                        callback.ResourceCallBack(RemovePrefix(name, path + "/").split("/"));
+                }
+                jar.close();
+            } catch (Exception ex)
+            {
+                ex.printStackTrace();
+            }
+        } else
+        {
+            // Run with IDE
+            final java.net.URL url = Object3D.class.getResource("/" + path);
+            if (url != null)
+            {
+                try
+                {
+                    java.io.File apps = new java.io.File(url.toURI());
+                    ParseFileSystem(apps, callback, RemovePrefix(url.toString() + "/", "file:"));
+//                    for (java.io.File app : apps.listFiles())
+//                    {
+//                        //System.out.println(RemovePrefix(app.toString(), RemovePrefix(url.toString(), "file:") + "/"));
+//                    }
+                } catch (Exception ex)
+                {
+                    ex.printStackTrace();
+                }
+            }
+        }
+    }
     
     public void init()
     {
@@ -855,6 +928,9 @@
         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;
@@ -862,6 +938,8 @@
         //mon.stop();
         //System.out.println(mon);
         //timeflow.app.TimeflowAppLauncher.GetTimeFlow();
+        
+        javax.swing.ToolTipManager.sharedInstance().setEnabled(Globals.TOOLTIPS);
     }
 
     static Object3D materials;
@@ -877,6 +955,8 @@
             java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
 
             readobj = (Object3D) p.readObject();
+            p.close();
+            zstream.close();
             istream.close();
 
             readobj.ResetDisplayList();
@@ -890,6 +970,7 @@
                 java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
 
                 readobj = (Object3D) p.readObject();
+                p.close();
                 istream.close();
 
                 readobj.ResetDisplayList();

--
Gitblit v1.6.2