import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.ArrayList; import javax.swing.UIManager; import javax.swing.plaf.metal.MetalLookAndFeel; import javax.swing.plaf.ColorUIResource; import javax.swing.plaf.metal.DefaultMetalTheme; import javax.sound.sampled.*; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; import java.security.cert.X509Certificate; import java.net.Authenticator; import java.net.PasswordAuthentication; //import com.jamonapi.*; public class Grafreed extends Applet implements ActionListener { static int RENDERME = 0; static boolean epsequal = false; static float epsvertex2 = 0.001f; static boolean linkUV = false; // not uniform at load time static boolean smoothmode = false; static Wav wav = new Wav("/Users/nbriere/0ut/wavs/monoformat"); // output"); static boolean hassound = false; static boolean savesound = false; public Grafreed() { javax.swing.Timer timer = new javax.swing.Timer(1000, this); //timer.start(); // wav.read(); // .save(); // wav.play(); } static void Assert(boolean b) { if (!b) { b = !!b; new Exception().printStackTrace(); // assert(b); } } 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 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() { add(openEditorButton = new Button("GrafreeD")); //Composite god = new Composite(); universe = new Composite(); universe.material = new cMaterial(); //god.addChild(universe); universe.name = "Applet"; grafreed = this; } /**/ public boolean action(Event evt, Object arg) { if (evt.target == openEditorButton) { universe.root = true; universe.openEditWindow(null, true); // , true); return true; } else { return super.action(evt, arg); } } /**/ //This method plays back audio data from an // audio file whose name is specified in the // text field. static PlayThread PlayAudio(String filename, double volume, double frequence) { try { PlayThread play = new PlayThread(); play.volume = volume; play.frequence = frequence; play.filename = filename; //Create a thread to play back the data and // start it running. It will run until the // end of file, or the Stop button is // clicked, whichever occurs first. // Because of the data buffers involved, // there will normally be a delay between // the click on the Stop button and the // actual termination of playback. play.start(); return play; } catch (Exception e) { e.printStackTrace(); return null; }//end catch }//end playAudio static PlayWordThread PlayWord(String word, double volume) { try { PlayWordThread play = new PlayWordThread(); play.volume = volume; play.words = word.split(" "); play.start(); return play; } catch (Exception e) { e.printStackTrace(); return null; }//end catch }//end playAudio //=============================================// //Inner class to play back the data from the // audio file. static class PlayThread extends Thread { String filename; byte tempbuffer[] = new byte[10000000]; short shortbuffer[] = new short[5000000]; short smoothbuffer[] = new short[5000000]; SourceDataLine sourceDataLine; AudioFormat audioFormat; AudioInputStream audioInputStream; double volume; double frequence; void Smooth(short[] buf) { short[] news = new short[buf.length]; System.arraycopy(buf, 0, news, 0, buf.length); for (int i=buf.length-1; --i>=1;) { news[i] = (short)(0.25*buf[i-1] + 0.5*buf[i] + 0.25*buf[i+1]); } System.arraycopy(news, 0, buf, 0, buf.length); } public void run() { try { while (true) // --count>=0) { File soundFile = new File(filename); audioInputStream = AudioSystem.getAudioInputStream(soundFile); audioFormat = audioInputStream.getFormat(); System.out.println(audioFormat); DataLine.Info dataLineInfo = new DataLine.Info( SourceDataLine.class, audioFormat); sourceDataLine = (SourceDataLine) AudioSystem.getLine( dataLineInfo); sourceDataLine.open(audioFormat); sourceDataLine.start(); int cnt; //Keep looping until the input read method // returns -1 for empty stream or the // user clicks the Stop button causing // stopPlayback to switch from false to // true. while ((cnt = audioInputStream.read( tempbuffer, 0, tempbuffer.length)) != -1) { for (int i=shortbuffer.length; --i>=0;) { int i2 = i*2; short value0 = (short)(tempbuffer[i2]&0xFF); short value1 = (short)(tempbuffer[i2+1]<<8); value0 *= volume; // seems useless... value1 *= volume; shortbuffer[i] = (short)(value0 | value1); // if (shortBuffer[i] != 0) // break; } System.arraycopy(shortbuffer, 0, smoothbuffer, 0, shortbuffer.length); // for (int loop=1000; --loop>=0;) // Smooth(smoothbuffer); // for (int loop=100; --loop>=0;) // Smooth(shortbuffer); // for (int i=shortbuffer.length; --i>=0;) // { // shortbuffer[i] -= smoothbuffer[i]; // } if (false) // frequence > 1) { // robot... // int base = 30; // for (int i=0; i*frequence=0;) { //shortBuffer[i] = (short)(shortBuffer[(int)(i*frequence)]); shortbuffer[i] = shortbuffer[i+1]; } } // for (int i=shortbuffer.length; --i>=0;) // { // shortbuffer[i] += smoothbuffer[i]; // } for (int i=shortbuffer.length; --i>=0;) { int i2 = i*2; byte tempBufferi2 = (byte)((shortbuffer[i]&0xFF) * 1); byte tempBufferi21 = (byte)(((shortbuffer[i]&0xFF00)>>8) * 1); // if (tempBufferi2 != tempBuffer[i2]) // break; // if (tempBufferi21 != tempBuffer[i2+1]) // break; tempbuffer[i2] = tempBufferi2; tempbuffer[i2+1] = tempBufferi21; } for (int loop=(int)frequence; --loop>=0;) if (cnt > 0) { //Write data to the internal buffer of // the data line where it will be // delivered to the speaker. sourceDataLine.write( tempbuffer, 0, cnt); }//end if }//end while //Block and wait for internal buffer of the // data line to empty. sourceDataLine.drain(); sourceDataLine.close(); } } catch (Exception e) { e.printStackTrace(); System.exit(0); }//end catch }//end run }//end inner class PlayThread static class PlayWordThread extends Thread { String[] words; byte tempbuffer[] = new byte[1000000]; byte tempbuffer1[] = new byte[1000000]; byte tempbuffer2[] = new byte[1000000]; byte tempbuffer3[] = new byte[1000000]; byte tempbuffer4[] = new byte[1000000]; byte tempbuffer5[] = new byte[1000000]; byte tempbuffer6[] = new byte[1000000]; byte temprotate[] = new byte[1000000]; SourceDataLine sourceDataLine; AudioFormat audioFormat; AudioInputStream audioInputStream; double volume; void Smooth(byte[] buf) { byte[] news = new byte[buf.length]; System.arraycopy(buf, 0, news, 0, buf.length); for (int i=buf.length-1; (i-=2)>=1;) { news[i] = (byte)(0.25*buf[i-1] + 0.5*buf[i] + 0.25*buf[i+1]); } System.arraycopy(news, 0, buf, 0, buf.length); } boolean IsZero(byte[] source) { for (int i=source.length; --i>=0;) { if (source[i] != 0) return false; } return true; } void Scale(byte[] source, double factor) { for (int i=source.length; --i>=0;) { source[i] *= factor; } } void Attract(byte[] source, byte[] target, int count) { double factor = 1; // Math.random() * 0.5; //if (factor > 0.25) // factor = 0.25; //if (factor > 0.25) // factor = 0.1; // 0.5; for (int i=count; --i>=0;) { int diff = target[i] - source[i]; source[i] += diff * factor; } } public void run() { try { while (true) { for (int wi=0; wi=0;) { int mod = (int)(Math.random() * 1); switch (mod) { case 0: Attract(tempbuffer, tempbuffer1, cnt); break; case 1: Attract(tempbuffer, tempbuffer2, cnt2); break; case 2: Attract(tempbuffer, tempbuffer3, cnt3); break; case 3: Attract(tempbuffer, tempbuffer4, cnt4); break; case 4: Attract(tempbuffer, tempbuffer5, cnt5); break; case 5: Attract(tempbuffer, tempbuffer6, cnt6); break; } sourceDataLine.write(tempbuffer, 0, cnt); } }//end while } java.util.Arrays.fill(tempbuffer1, (byte)0); while (!IsZero(tempbuffer)) { Attract(tempbuffer, tempbuffer1, mincount); // silence between words sourceDataLine.write( tempbuffer, 0, mincount); } Thread.sleep(1000); } //Block and wait for internal buffer of the // data line to empty. sourceDataLine.drain(); sourceDataLine.close(); sourceDataLine = null; Thread.sleep(3000); } } catch (Exception e) { e.printStackTrace(); System.exit(0); }//end catch }//end run }//end inner class PlayThread static java.util.Hashtable dictionary = new java.util.Hashtable(); static void InitDictionary() { try { // Open the file that is the first // command line parameter FileInputStream fstream = new FileInputStream("/Users/nbriere/Documents/dictionary/cmudict.0.7a"); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; //Read File Line By Line while ((strLine = br.readLine()) != null) { // Print the content on the console if (strLine.charAt(0) == ';') continue; //System.out.println(strLine); String[] words = strLine.split(" "); if (dictionary.get(words[0]) != null) assert(dictionary.get(words[0]) == null); dictionary.put(words[0], words); } //Close the input stream in.close(); } catch (Exception e) {//Catch exception if any System.err.println("Error: " + e.getMessage()); } } static void Spell(String word) { PlayWord(word, 1); } static boolean isWindows; public static void main(String argv[]) { String osArch = System.getProperty("os.arch"); if (Globals.DEBUG) System.out.println("os.arch = " + osArch); String osName = System.getProperty("os.name"); isWindows = !osName.equals("Mac OS X"); if (argv.length == 0) { String javaPath = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; System.out.println("javaPath = " + javaPath); java.net.URL u = new Grafreed().getClass().getResource("default.png"); System.out.println("URL = " + u); String jarfile = u.toString().split("file:")[1].split("default.png")[0]; System.out.println("jarfile0 = " + jarfile); String jarpath = u.toString().split("file:")[1].split("Grafreed.jar")[0]; System.out.println("jarpath0 = " + jarpath); jarfile = jarfile.substring(0, jarfile.length() - 2); System.out.println("jarfile = " + jarfile); String command = javaPath + " -Xmx1024m -Djava.library.path=" + jarpath; // -Djava.library.path=/Users/nbriere/Projects/shared/lib if (jarfile.charAt(2) == ':') { command = "\"" + javaPath + "\" -Xmx1024m -Djava.library.path=" + jarpath; // On Windows systems, the path is /C:/ jarfile = jarfile.substring(1, jarfile.length()); System.out.println("jarfile = " + jarfile); jarpath = jarpath.substring(1, jarpath.length()); System.out.println("jarpath = " + jarpath); command += "native" + File.separator; if (osArch.equals("amd64")) command += "windows_amd64"; else command += "windows_i586"; } else command += "native" + File.separator + "macosx"; command += " -jar " + jarfile + " dummyarg"; try { System.out.println("command = " + command); Runtime.getRuntime().exec(command); return; } catch (Exception e) { e.printStackTrace(); } /* if (argv.length == 0) { String javaPath = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; System.out.println("javaPath = " + javaPath); java.net.URL u = new Grafeme().getClass().getResource("grafeme.jpg"); System.out.println("URL = " + u); String jarfile = u.toString().split("file:")[1].split("grafeme/grafeme.jpg")[0]; System.out.println("jarfile0 = " + jarfile); jarfile = jarfile.substring(0, jarfile.length() - 2); // Remove "!/" after .jar System.out.println("jarfile = " + jarfile); if (jarfile.charAt(2) == ':') { // On Windows systems, the path is /C:/ jarfile = jarfile.substring(1, jarfile.length()); System.out.println("jarfile = " + jarfile); } String command = "\"" + javaPath + "\" -Xmx1024m -jar " + jarfile + " dummyarg"; try { System.out.println(command); Runtime.getRuntime().exec(command); return; } catch (Exception e) { e.printStackTrace(); } } */ } // InitDictionary(); // Spell("is over".toUpperCase()); //Spell("horse word the growth".toUpperCase()); //Spell("breath beard of three days growth".toUpperCase()); //Spell("mannequin misinterpret accomplishment apologize".toUpperCase()); //Spell("Block and wait for internal buffer".toUpperCase()); //Spell("Keep looping until the input read method".toUpperCase()); //Spell("formula anything Do you catch the thing".toUpperCase()); // //Spell("I know what you mean It is truly incredible".toUpperCase()); if (false) try { // java.applet.AudioClip clip = java.applet.Applet.newAudioClip( // new java.net.URL("file:/Users/nbriere/Documents/normand.wav")); // clip.play(); // clip = java.applet.Applet.newAudioClip( // new java.net.URL("file:/Users/nbriere/Downloads/crowd-talking-9.wav")); // clip.play(); // for (int loop=1; --loop>=0;) // { // javax.sound.sampled.AudioInputStream ais = javax.sound.sampled.AudioSystem.getAudioInputStream(new java.net.URL("file:/Users/nbriere/Downloads/boarding-accouncement-1.wav")); // javax.sound.sampled.Clip clip = javax.sound.sampled.AudioSystem.getClip(); // clip.open(ais); // clip.start(); // Thread.sleep(1000); // } // ais = javax.sound.sampled.AudioSystem.getAudioInputStream(new java.net.URL("file:/Users/nbriere/Documents/Footsteps.wav")); // clip = javax.sound.sampled.AudioSystem.getClip(); // clip.open(ais); // clip.loop(10); // try{ File soundFile = new File("/Users/nbriere/Documents/testcrowdboard.wav"); javax.sound.sampled.AudioInputStream audioInputStream = javax.sound.sampled.AudioSystem.getAudioInputStream(soundFile); javax.sound.sampled.AudioFormat audioFormat = audioInputStream.getFormat(); System.out.println(audioFormat); javax.sound.sampled.DataLine.Info dataLineInfo = new javax.sound.sampled.DataLine.Info( javax.sound.sampled.SourceDataLine.class, audioFormat); javax.sound.sampled.SourceDataLine sourceDataLine = (javax.sound.sampled.SourceDataLine) javax.sound.sampled.AudioSystem.getLine( dataLineInfo); //Create a thread to play back the data and // start it running. It will run until the // end of file, or the Stop button is // clicked, whichever occurs first. // Because of the data buffers involved, // there will normally be a delay between // the click on the Stop button and the // actual termination of playback. // new PlayThread().start(); sourceDataLine.open(audioFormat); sourceDataLine.start(); byte tempBuffer[] = new byte[10000]; int cnt; //Keep looping until the input read method // returns -1 for empty stream or the // user clicks the Stop button causing // stopPlayback to switch from false to // true. while ((cnt = audioInputStream.read( tempBuffer, 0, tempBuffer.length)) != -1 // && stopPlayback == false ) { if (cnt > 0) { //Write data to the internal buffer of // the data line where it will be // delivered to the speaker. sourceDataLine.write( tempBuffer, 0, cnt); }//end if }//end while //Block and wait for internal buffer of the // data line to empty. sourceDataLine.drain(); sourceDataLine.close(); // }catch (Exception e) { // e.printStackTrace(); // System.exit(0); // }//end catch } catch (Exception murle) { System.out.println(murle); } //PlayAudio("/Users/nbriere/Downloads/dictionary/a.wav", 1, 10); // PlayAudio("/Users/nbriere/Downloads/boarding-accouncement-1.wav", 2, 1); // PlayAudio("/Users/nbriere/Documents/poche.wav", 4, 1); //PlayAudio("/Users/nbriere/Downloads/tone1k-22-8.wav", 1, 1); //PlayAudio("/Users/nbriere/Documents/ocean-wave-1.wav", 1,1); // PlayAudio("/Users/nbriere/Downloads/house-heater-1.wav", 0.5, 1); //PlayAudio("/Users/nbriere/Documents/Footsteps.wav", 10); // PlayAudio("/Users/nbriere/Downloads/Footsteps-1.wav", 1, 1); // try{Thread.sleep(5000);}catch(Exception e){} // PlayAudio("/Users/nbriere/Downloads/Footsteps-6.wav", 4, 1); /**/ if (Globals.NIMBUSLAF) { try { //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("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) { } } else { try { //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.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) { } } /**/ // Create a trust manager that does not validate certificate chains final TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { @Override public void checkClientTrusted(final X509Certificate[] chain, final String authType) { } @Override public void checkServerTrusted(final X509Certificate[] chain, final String authType) { } @Override public X509Certificate[] getAcceptedIssuers() { return null; } } }; try { // Install the all-trusting trust manager final SSLContext sslContext = SSLContext.getInstance("SSL"); sslContext.init(null, trustAllCerts, null); // Create an ssl socket factory with our all-trusting manager HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory()); HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { public boolean verify(String urlHostName, SSLSession session) { return true; } }); // be authentic Authenticator.setDefault(new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("args[0]", "args[1]".toCharArray()); } }); } catch (Exception e) { e.printStackTrace(); } ///////////// // javax.swing.ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); //Monitor mon=MonitorFactory.start("myFirstMonitor"); standAlone = true; 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(); // theApplet3D.universe.textures = CameraPane.DEFAULT_TEXTURE; grafreed.universe.root = true; grafreed.universe.openEditWindow(null, true); //, true); grafreed.universe.editWindow.New(); //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) { Object3D readobj = null; try { // Try compressed version first. java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream); java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream); readobj = (Object3D) p.readObject(); p.close(); zstream.close(); istream.close(); readobj.ResetDisplayList(); } catch (Exception e) { if (!e.toString().contains("GZIP")) e.printStackTrace(); try { java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream); readobj = (Object3D) p.readObject(); p.close(); istream.close(); readobj.ResetDisplayList(); } catch (Exception e2) { e2.printStackTrace(); } } return readobj; } // Timer callback public void actionPerformed(ActionEvent e) { if (universe != null) { //System.out.print("."); universe.invariants(); //System.gc(); } } static int depth = 0; static java.util.Stack stack = new java.util.Stack(); static boolean traceoff = false; // true; static float[] colorV = new float[4]; // 5]; static void traceon() { traceoff = false; } static void traceoff() { traceoff = true; } static void tracein(Object m) { if (traceoff) { return; } tracein(m, ""); } static void tracein(Object call, Object data) { if (traceoff) { return; } stack.push(call); tabs(); System.err.println("" + call /*+ "-" + depth + " "*/ + data); tabs(); System.err.println("{"); depth++; } static void trace(Object call) { if (traceoff) { return; } tabs(); System.err.println("" + call /*+ "-" + depth + " "*/); } static void trace(Object call, Object data) { if (traceoff) { return; } tabs(); System.err.println("" + call /*+ "-" + depth + " "*/ + data); } static void traceout(Object call) { //traceout(); if (traceoff) { return; } depth--; tabs(); System.err.println("} // " + call /*+ "-" + depth + " "*/); stack.pop(); // assert == call } static void traceout(Object call, Object data) { //traceout(); if (traceoff) { return; } depth--; tabs(); System.err.println("} // " + call /*+ "-" + depth + " "*/ + data); stack.pop(); // assert == call } static void traceout() { if (traceoff) { return; } depth--; tabs(); System.err.println("} // " + stack.pop() /*+ "-" + depth + " "*/); } static void tabs() { for (int i = 0; i < depth; i++) { System.err.print(" "); } } static public void StackTrace() { (new Exception()).printStackTrace(System.err); } static public Object clone(Object o) { if (o instanceof Object3D) { assert(((Object3D)o).parent == null); } if (o == null) return null; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(o); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream in = new ObjectInputStream(bais); Object obj = in.readObject(); in.close(); out.close(); return obj; } catch (Exception e) { System.err.println(e); return null; } } static int mix3(int a, int b, int c) { a -= b; a -= c; a ^= (c >> 13); b -= c; b -= a; b ^= (a << 8); c -= a; c -= b; c ^= (b >> 13); a -= b; a -= c; a ^= (c >> 12); b -= c; b -= a; b ^= (a << 16); c -= a; c -= b; c ^= (b >> 5); a -= b; a -= c; a ^= (c >> 3); b -= c; b -= a; b ^= (a << 10); c -= a; c -= b; c ^= (b >> 15); return c; } static void AnalyzeObject(Object abc) { for (java.lang.reflect.Field field : abc.getClass().getDeclaredFields()) { field.setAccessible(true); String name = field.getName(); Object value = null; try { value = field.get(abc); } catch(Exception e) { e.printStackTrace(); } System.out.printf("Field name / value : %s = %s\n", name, value); } } public static String loadStreamIntoString(InputStream stream) throws IOException { if (stream == null) { throw new java.io.IOException("null stream"); } stream = new java.io.BufferedInputStream(stream); int avail = stream.available(); byte[] data = new byte[avail]; int numRead = 0; int pos = 0; do { if (pos + avail > data.length) { byte[] newData = new byte[pos + avail]; System.arraycopy(data, 0, newData, 0, pos); data = newData; } numRead = stream.read(data, pos, avail); if (numRead >= 0) { pos += numRead; } avail = stream.available(); } while (avail > 0 && numRead >= 0); return new String(data, 0, pos, "US-ASCII"); } public static Grafreed grafreed; public static boolean standAlone = true; public Composite universe; public static Object3D clipboard = new Object3D(); public static boolean clipboardIsTempGroup; private Button openEditorButton; }