LookandFeel must be set in headless state as window sizes will be affected
[jalview.git] / src / jalview / bin / Jalview.java
index e244d67..30f91ac 100755 (executable)
@@ -1,6 +1,6 @@
 /*\r
  * Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * Copyright (C) 2006 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
@@ -57,14 +57,8 @@ public class Jalview
         System.out.println("Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"\r
                            +"-nodisplay\tRun Jalview without User Interface.\n"\r
                            +"-props FILE\tUse the given Jalview properties file instead of users default.\n"\r
-                           +"-groups FILE\tUse the given file to mark groups on the alignment."\r
-                           +"\nThe first lines of the groups file lists the GroupName and GroupColours"\r
-                           +" to be used in the alignment. Use the GROUPNAME label for each of your sequences. "\r
-                           +"\nGROUPNAME<tab>GROUPCOLOUR\n"\r
-                           +"TEXT<tab>SEQUENCE_ID<tab>SEQUENCE_INDEX<tab>START_RESIDUE<tab>END_RESIDUE<tab>GROUPNAME\n"\r
-                           +"SequenceID is used in preference to SequenceIndex if both are provided.\n"\r
-                           +"Enter ID_NOT_SPECIFIED for SEQUENCE_ID or -1 for SEQUENCE_INDEX if unknown.\n"\r
-                           +"COLOUR can be hexadecimal RGB or 'red', 'blue' etc.\n\n"\r
+                           +"-annotations FILE\tAdd precalculated annotations to the alignment.\n"\r
+                           +"-features FILE\tUse the given file to mark features on the alignment.\n"\r
                            +"-fasta FILE\tCreate alignment file FILE in Fasta format.\n"\r
                            +"-clustal FILE\tCreate alignment file FILE in Clustal format.\n"\r
                            +"-pfam FILE\tCreate alignment file FILE in PFAM format.\n"\r
@@ -75,7 +69,8 @@ public class Jalview
                            +"-jalview FILE\tCreate alignment file FILE in Jalview format.\n"\r
                            +"-png FILE\tCreate PNG image FILE from alignment.\n"\r
                            +"-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"\r
-                           +"-eps FILE\tCreate EPS file FILE from alignment.");\r
+                           +"-eps FILE\tCreate EPS file FILE from alignment."\r
+            +"\n\n~Read documentation in Application or visit http://www.jalview.org for description of Features and Annotations file~\n\n");\r
         System.exit(0);\r
           }\r
 \r
@@ -105,31 +100,32 @@ public class Jalview
           }\r
 \r
         Desktop desktop = null;\r
-        if( !headless )\r
+\r
+\r
+        try\r
         {\r
-          try\r
-          {\r
-            UIManager.setLookAndFeel(\r
-                   UIManager.getSystemLookAndFeelClassName()\r
-            //        UIManager.getCrossPlatformLookAndFeelClassName()\r
-//"com.sun.java.swing.plaf.gtk.GTKLookAndFeel"\r
-//"javax.swing.plaf.metal.MetalLookAndFeel"\r
-//"com.sun.java.swing.plaf.windows.WindowsLookAndFeel"\r
-//"com.sun.java.swing.plaf.motif.MotifLookAndFeel"\r
-\r
-                );\r
-          }\r
-          catch (Exception ex)\r
+          UIManager.setLookAndFeel(\r
+              UIManager.getSystemLookAndFeelClassName()\r
+              //        UIManager.getCrossPlatformLookAndFeelClassName()\r
+      //"com.sun.java.swing.plaf.gtk.GTKLookAndFeel"\r
+      //"javax.swing.plaf.metal.MetalLookAndFeel"\r
+      //"com.sun.java.swing.plaf.windows.WindowsLookAndFeel"\r
+      //"com.sun.java.swing.plaf.motif.MotifLookAndFeel"\r
+\r
+              );\r
+        }\r
+        catch (Exception ex)\r
+        {}\r
+\r
+          if (!headless)\r
           {\r
+            desktop = new Desktop();\r
+            desktop.setVisible(true);\r
+            desktop.discoverer.start();\r
           }\r
 \r
-          desktop = new Desktop();\r
-          desktop.setVisible(true);\r
-          desktop.discoverer.start();\r
-        }\r
-\r
 \r
-         String file = null, protocol = null, format = null, groups=null;\r
+         String file = null, protocol = null, format = null, data=null;\r
          jalview.io.FileLoader fileLoader = new jalview.io.FileLoader();\r
 \r
           file = aparser.getValue("open");\r
@@ -142,6 +138,7 @@ public class Jalview
 \r
           if(file!=null)\r
           {\r
+            System.out.println("Opening file: " + file);\r
 \r
             if (!file.startsWith("http://"))\r
             {\r
@@ -155,26 +152,72 @@ public class Jalview
 \r
             protocol = "File";\r
 \r
-            if (file.indexOf("http:") > -1)\r
+            if (file.indexOf("http:") > -1 || file.indexOf("file:") >-1)\r
             {\r
               protocol = "URL";\r
             }\r
 \r
+\r
+\r
             if (file.endsWith(".jar"))\r
               format = "Jalview";\r
             else\r
               format = new jalview.io.IdentifyFile().Identify(file, protocol);\r
 \r
-            System.out.println("Opening: " + format + " file " + file);\r
+\r
 \r
             AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol, format);\r
 \r
-            groups = aparser.getValue("groups");\r
-            if (groups != null)\r
+            if(af==null)\r
+            {\r
+              System.out.println("error");\r
+              return;\r
+            }\r
+\r
+            data = aparser.getValue("colour");\r
+            if(data!=null)\r
+            {\r
+              data.replaceAll("%20", " ");\r
+\r
+              jalview.schemes.ColourSchemeI cs =\r
+                  jalview.schemes.ColourSchemeProperty.getColour(af.getViewport().\r
+                  getAlignment(), data);\r
+\r
+              if(cs == null)\r
+              {\r
+                jalview.schemes.UserColourScheme ucs\r
+                    = new jalview.schemes.UserColourScheme("white");\r
+                ucs.parseAppletParameter(data);\r
+                cs = ucs;\r
+              }\r
+\r
+              System.out.println("colour is " + data);\r
+              af.changeColour( cs );\r
+            }\r
+\r
+\r
+            // Must maintain ability to use the groups flag\r
+            data = aparser.getValue("groups");\r
+            if (data != null)\r
             {\r
-              af.parseGroupsFile(groups);\r
+              af.parseFeaturesFile(data, protocol);\r
+              System.out.println("Added "+data);\r
+            }\r
+            data = aparser.getValue("features");\r
+            if (data != null)\r
+            {\r
+              af.parseFeaturesFile(data, protocol);\r
+              System.out.println("Added "+data);\r
+            }\r
+\r
+            data = aparser.getValue("annotations");\r
+            if (data != null)\r
+            {\r
+              af.loadJalviewDataFile(data);\r
+              System.out.println("Added "+data);\r
             }\r
 \r
+\r
             String imageName = "unnamed.png";\r
             while (aparser.getSize() > 1)\r
             {\r
@@ -217,9 +260,11 @@ public class Jalview
           }\r
 \r
         // We'll only open the default file if the desktop is visible.\r
+        // And the user\r
         //////////////////////\r
           if (\r
               !headless\r
+          && file==null\r
           && jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true)\r
                     )\r
           {\r
@@ -236,13 +281,15 @@ public class Jalview
 \r
             if (file.endsWith(".jar"))\r
             {\r
-              new Jalview2XML().LoadJalviewAlign(file);\r
+              format = "Jalview";\r
             }\r
             else\r
             {\r
               format = new jalview.io.IdentifyFile().Identify(file, protocol);\r
-              desktop.LoadFile(file, protocol, format);\r
             }\r
+\r
+            fileLoader.LoadFile(file, protocol, format);\r
+\r
           }\r
     }\r
 }\r