+ ArgsParser aparser = new ArgsParser(args);\r
+ boolean headless = false;\r
+\r
+ if( aparser.contains("help") || aparser.contains("h") )\r
+ {\r
+ 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
+ +"-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
+ +"-msf FILE\tCreate alignment file FILE in MSF format.\n"\r
+ +"-pileup FILE\tCreate alignment file FILE in Pileup format\n"\r
+ +"-pir FILE\tCreate alignment file FILE in PIR format.\n"\r
+ +"-blc FILE\tCreate alignment file FILE in BLC format.\n"\r
+ +"-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
+ +"\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
+ Cache.loadProperties(aparser.getValue("props")); // must do this before anything else!\r
+\r
+ if (aparser.contains("nodisplay"))\r
+ {\r
+ System.setProperty("java.awt.headless", "true");\r
+ }\r
+ if (System.getProperty("java.awt.headless") != null\r
+ && System.getProperty("java.awt.headless").equals("true"))\r
+ {\r
+ headless = true;\r
+ }\r
+\r
+ try\r
+ {\r
+ Cache.initLogger();\r
+ }\r
+ catch (java.lang.NoClassDefFoundError error)\r
+ {\r
+ error.printStackTrace();\r
+ System.out.println(\r
+ "\nEssential logging libraries not found."\r
+ +"\nUse: java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview");\r
+ System.exit(0);\r
+ }\r
+\r
+ Desktop desktop = null;\r
+ if( !headless )\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
+ {\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, data=null;\r
+ jalview.io.FileLoader fileLoader = new jalview.io.FileLoader();\r
+\r
+ file = aparser.getValue("open");\r
+\r
+ if (file == null && desktop==null)\r
+ {\r
+ System.out.println("No files to open!");\r
+ System.exit(1);\r
+ }\r
+\r
+ if(file!=null)\r
+ {\r
+\r
+ if (!file.startsWith("http://"))\r
+ {\r
+ if (! (new java.io.File(file)).exists())\r
+ {\r
+ System.out.println("Can't find " + file);\r
+ if(headless)\r
+ System.exit(1);\r
+ }\r
+ }\r
+\r
+ protocol = "File";\r
+\r
+ if (file.indexOf("http:") > -1 || file.indexOf("file:") >-1)\r
+ {\r
+ protocol = "URL";\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
+ AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol, format);\r
+\r
+ data = aparser.getValue("colour");\r
+ if(data!=null)\r
+ {\r
+ data.replaceAll("%20", " ");\r