Formatted source
[jalview.git] / src / jalview / bin / Jalview.java
index 56c923a..07958b4 100755 (executable)
-/********************\r
- * 2004 Jalview Reengineered\r
- * Barton Group\r
- * Dundee University\r
- *\r
- * AM Waterhouse\r
- *******************/\r
-\r
-\r
+/*\r
+* Jalview - A Sequence Alignment Editor and Viewer\r
+* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+*\r
+* This program is free software; you can redistribute it and/or\r
+* modify it under the terms of the GNU General Public License\r
+* as published by the Free Software Foundation; either version 2\r
+* of the License, or (at your option) any later version.\r
+*\r
+* This program is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+* GNU General Public License for more details.\r
+*\r
+* You should have received a copy of the GNU General Public License\r
+* along with this program; if not, write to the Free Software\r
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
+*/\r
 package jalview.bin;\r
 \r
 import jalview.gui.*;\r
-import javax.swing.*;\r
-import java.awt.event.*;\r
+\r
 import jalview.io.*;\r
 \r
 import org.apache.log4j.*;\r
 \r
-public class Jalview extends JApplet\r
-{\r
-  public static JApplet applet;\r
-  Desktop frame;\r
-  public void init()\r
-  {\r
-    applet = this;\r
-    Cache.loadProperties();\r
-\r
-    frame = new Desktop();\r
-    frame.setResizable(true);\r
-    frame.setVisible(true);\r
-    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);\r
-    frame.addWindowListener(new WindowAdapter()\r
-    {\r
-      public void windowClosing(WindowEvent e)\r
-      {\r
-          applet.stop();\r
-          applet.destroy();\r
-      }\r
-    });\r
-\r
-    String file = getParameter("alignment");\r
-\r
-    if(file!=null)\r
-    {\r
-      jalview.bin.Cache.setProperty("LAST_DIRECTORY", file);\r
-      String protocol = "File";\r
-      if (file.indexOf("http:") > -1)\r
-        protocol = "URL";\r
-\r
-      String format = jalview.io.IdentifyFile.Identify(file, protocol);\r
-\r
-      frame.LoadFile(file, protocol, format);\r
-    }\r
-  }\r
-\r
-  public void destroy()\r
-  {\r
-    if(applet!=null)\r
-      applet.stop();\r
-    else\r
-      System.exit(0);\r
-    frame.setVisible(false);\r
-  }\r
-\r
-  private static void initLogger() {\r
-    Logger l = Logger.getLogger("org.apache.axis");\r
-    if (Cache.getProperty("logs.Axis.Level")==null) {\r
-      Cache.setProperty("logs.Axis.Level", Level.INFO.toString());\r
-    }\r
+import java.awt.event.*;\r
 \r
-    l.setLevel(Level.toLevel(Cache.getProperty("logs.Axis.Level")));\r
-    ConsoleAppender ap = new ConsoleAppender(new SimpleLayout(),"System.err");\r
-    ap.setName("Axis");\r
-    l.addAppender(ap);\r
-  }\r
-   public static void main(String[] args) {\r
-\r
-    Cache.loadProperties();\r
-    try {\r
-      initLogger();\r
-    } catch (Exception e) {\r
-      System.out.println("Problems initializing the log4j system\n"+e);\r
-    }\r
-    try{\r
-       UIManager.setLookAndFeel(\r
-   //   "javax.swing.plaf.metal.MetalLookAndFeel"\r
-    //  "javax.swing.plaf.multi.MultiLookAndFeel"\r
-         UIManager.getSystemLookAndFeelClassName()\r
-     //    UIManager.getCrossPlatformLookAndFeelClassName()\r
-       // "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"\r
-       //   "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"\r
-       //  "com.sun.java.swing.plaf.motif.MotifLookAndFeel"\r
-     );\r
-     }\r
-     catch (Exception ex)\r
-     {}\r
+import javax.swing.*;\r
 \r
-     Desktop frame = new Desktop();\r
-     frame.setResizable(true);\r
-     frame.setVisible(true);\r
 \r
+public class Jalview extends JApplet {\r
+    public static JApplet applet;\r
+    Desktop frame;\r
 \r
+    public void init() {\r
+        applet = this;\r
+        Cache.loadProperties();\r
+        jalview.gui.Preferences.initPreferences();\r
 \r
-     if(args!=null && args.length>0)\r
-     {\r
-         String file=null;\r
-         if(args[0].equals("-open"))\r
-           file = args[1];\r
-         else\r
-           file = args[0];\r
+        frame = new Desktop();\r
+        frame.setResizable(true);\r
+        frame.setVisible(true);\r
+        frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);\r
+        frame.addWindowListener(new WindowAdapter() {\r
+                public void windowClosing(WindowEvent e) {\r
+                    applet.stop();\r
+                    applet.destroy();\r
+                }\r
+            });\r
 \r
-         String protocol = "File";\r
-         if(file.indexOf("http:")>-1)\r
-           protocol = "URL";\r
+        String file = getParameter("alignment");\r
 \r
-         String format = jalview.io.IdentifyFile.Identify(file, protocol);\r
+        if (file != null) {\r
+            jalview.bin.Cache.setProperty("LAST_DIRECTORY", file);\r
 \r
-         frame.LoadFile(file, protocol, format);\r
-     }\r
+            String protocol = "File";\r
 \r
-   }\r
+            if (file.indexOf("http:") > -1) {\r
+                protocol = "URL";\r
+            }\r
 \r
-}\r
+            String format = jalview.io.IdentifyFile.Identify(file, protocol);\r
 \r
+            frame.LoadFile(file, protocol, format);\r
+        }\r
+    }\r
+\r
+    public void destroy() {\r
+        if (applet != null) {\r
+            applet.stop();\r
+        } else {\r
+            System.exit(0);\r
+        }\r
+\r
+        frame.setVisible(false);\r
+    }\r
+\r
+    private static void initLogger() {\r
+        Logger l = Logger.getLogger("org.apache.axis");\r
+\r
+        if (Cache.getProperty("logs.Axis.Level") == null) {\r
+            Cache.setProperty("logs.Axis.Level", Level.INFO.toString());\r
+        }\r
+\r
+        l.setLevel(Level.toLevel(Cache.getProperty("logs.Axis.Level")));\r
+\r
+        ConsoleAppender ap = new ConsoleAppender(new SimpleLayout(),\r
+                "System.err");\r
+        ap.setName("Axis");\r
+        l.addAppender(ap);\r
+    }\r
+\r
+    public static void main(String[] args) {\r
+        Cache.loadProperties();\r
+        jalview.gui.Preferences.initPreferences();\r
+\r
+        try {\r
+            initLogger();\r
+        } catch (Exception e) {\r
+            System.err.println("Problems initializing the log4j system\n");\r
+            e.printStackTrace();\r
+        }\r
+\r
+        try {\r
+            UIManager.setLookAndFeel(\r
+            //   "javax.swing.plaf.metal.MetalLookAndFeel"\r
+            //  "javax.swing.plaf.multi.MultiLookAndFeel"\r
+            UIManager.getSystemLookAndFeelClassName());\r
+        } catch (Exception ex) {\r
+        }\r
+\r
+        Desktop frame = new Desktop();\r
+        frame.setResizable(true);\r
+        frame.setVisible(true);\r
+\r
+        if ((args != null) && (args.length > 0)) {\r
+            String file = null;\r
+\r
+            if (args[0].equals("-open")) {\r
+                file = args[1];\r
+            } else {\r
+                file = args[0];\r
+            }\r
+\r
+            String protocol = "File";\r
+\r
+            if (file.indexOf("http:") > -1) {\r
+                protocol = "URL";\r
+            }\r
+\r
+            String format = jalview.io.IdentifyFile.Identify(file, protocol);\r
+\r
+            frame.LoadFile(file, protocol, format);\r
+        }\r
+\r
+        if (jalview.gui.Preferences.showStartupFile &&\r
+                (jalview.gui.Preferences.startupFile != null)) {\r
+            String file = jalview.gui.Preferences.startupFile;\r
+            String protocol = "File";\r
+\r
+            if (file.indexOf("http:") > -1) {\r
+                protocol = "URL";\r
+            }\r
+\r
+            if (file.endsWith(".jar")) {\r
+                Jalview2XML.LoadJalviewAlign(file);\r
+            } else {\r
+                String format = jalview.io.IdentifyFile.Identify(file, protocol);\r
+                frame.LoadFile(file, protocol, format);\r
+            }\r
+        }\r
+    }\r
+}\r