2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.gui.AlignFrame;
24 import jalview.gui.Desktop;
25 import jalview.io.BioJsHTMLOutput;
26 import jalview.io.HtmlSvgOutput;
27 import jalview.util.MessageManager;
28 import jalview.util.Platform;
29 import jalview.ws.jws2.Jws2Discoverer;
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
33 import java.io.BufferedReader;
35 import java.io.FileOutputStream;
36 import java.io.IOException;
37 import java.io.OutputStreamWriter;
38 import java.io.PrintWriter;
39 import java.lang.reflect.Constructor;
40 import java.net.MalformedURLException;
43 import java.net.URLDecoder;
44 import java.security.AllPermission;
45 import java.security.CodeSource;
46 import java.security.PermissionCollection;
47 import java.security.Permissions;
48 import java.security.Policy;
49 import java.util.HashMap;
51 import java.util.Vector;
53 import javax.swing.UIManager;
54 import javax.swing.UnsupportedLookAndFeelException;
57 * Main class for Jalview Application <br>
59 * start with java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview
68 // grab all the rights we can the JVM
69 Policy.setPolicy(new Policy()
71 public PermissionCollection getPermissions(CodeSource codesource)
73 Permissions perms = new Permissions();
74 perms.add(new AllPermission());
85 * main class for Jalview application
88 * open <em>filename</em>
90 public static void main(String[] args)
92 System.out.println("Java version: "
93 + System.getProperty("java.version"));
94 System.out.println(System.getProperty("os.arch") + " "
95 + System.getProperty("os.name") + " "
96 + System.getProperty("os.version"));
98 ArgsParser aparser = new ArgsParser(args);
99 boolean headless = false;
101 if (aparser.contains("help") || aparser.contains("h"))
106 if (aparser.contains("nodisplay") || aparser.contains("nogui")
107 || aparser.contains("headless"))
109 System.setProperty("java.awt.headless", "true");
112 Cache.loadProperties(aparser.getValue("props")); // must do this before
115 final String jabawsUrl = aparser.getValue("jabaws");
116 if (jabawsUrl != null)
120 Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
121 } catch (MalformedURLException e)
123 System.err.println("Invalid jabaws parameter: " + jabawsUrl
128 String defs = aparser.getValue("setprop");
131 int p = defs.indexOf('=');
134 System.err.println("Ignoring invalid setprop argument : " + defs);
138 System.out.println("Executing setprop argument: " + defs);
139 // DISABLED FOR SECURITY REASONS
140 // TODO: add a property to allow properties to be overriden by cli args
141 // Cache.setProperty(defs.substring(0,p), defs.substring(p+1));
143 defs = aparser.getValue("setprop");
145 if (System.getProperty("java.awt.headless") != null
146 && System.getProperty("java.awt.headless").equals("true"))
150 System.setProperty("http.agent",
151 "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
155 } catch (java.lang.NoClassDefFoundError error)
157 error.printStackTrace();
159 .println("\nEssential logging libraries not found."
160 + "\nUse: java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview");
164 Desktop desktop = null;
168 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
169 } catch (Exception ex)
172 if (new Platform().isAMac())
174 System.setProperty("com.apple.mrj.application.apple.menu.about.name",
176 System.setProperty("apple.laf.useScreenMenuBar", "true");
179 UIManager.setLookAndFeel(ch.randelshofer.quaqua.QuaquaManager
181 } catch (UnsupportedLookAndFeelException e)
183 // TODO Auto-generated catch block
190 desktop = new Desktop();
191 desktop.setInBatchMode(true); // indicate we are starting up
192 desktop.setVisible(true);
193 desktop.startServiceDiscovery();
194 if (!aparser.contains("nousagestats"))
196 startUsageStats(desktop);
198 if (!aparser.contains("noquestionnaire"))
200 String url = aparser.getValue("questionnaire");
203 // Start the desktop questionnaire prompter with the specified
205 Cache.log.debug("Starting questionnaire url at " + url);
206 desktop.checkForQuestionnaire(url);
210 if (Cache.getProperty("NOQUESTIONNAIRES") == null)
212 // Start the desktop questionnaire prompter with the specified
215 // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
217 String defurl = "http://www.jalview.org/cgi-bin/questionnaire.pl";
218 Cache.log.debug("Starting questionnaire with default url: "
220 desktop.checkForQuestionnaire(defurl);
225 desktop.checkForNews();
228 BioJsHTMLOutput.updateBioJS();
230 String file = null, protocol = null, format = null, data = null;
231 jalview.io.FileLoader fileLoader = new jalview.io.FileLoader();
232 Vector getFeatures = null; // vector of das source nicknames to fetch
235 String groovyscript = null; // script to execute after all loading is
236 // completed one way or another
237 // extract groovy argument and execute if necessary
238 groovyscript = aparser.getValue("groovy", true);
239 file = aparser.getValue("open", true);
241 if (file == null && desktop == null)
243 System.out.println("No files to open!");
246 String vamsasImport = aparser.getValue("vdoc"), vamsasSession = aparser
248 if (vamsasImport != null || vamsasSession != null)
250 if (desktop == null || headless)
253 .println("Headless vamsas sessions not yet supported. Sorry.");
256 // if we have a file, start a new session and import it.
257 boolean inSession = false;
258 if (vamsasImport != null)
262 String viprotocol = jalview.io.AppletFormatAdapter
263 .checkProtocol(vamsasImport);
264 if (viprotocol == jalview.io.FormatAdapter.FILE)
266 inSession = desktop.vamsasImport(new File(vamsasImport));
268 else if (viprotocol == jalview.io.FormatAdapter.URL)
270 inSession = desktop.vamsasImport(new URL(vamsasImport));
273 } catch (Exception e)
275 System.err.println("Exeption when importing " + vamsasImport
276 + " as a vamsas document.");
281 System.err.println("Failed to import " + vamsasImport
282 + " as a vamsas document.");
286 System.out.println("Imported Successfully into new session "
287 + desktop.getVamsasApplication().getCurrentSession());
290 if (vamsasSession != null)
292 if (vamsasImport != null)
294 // close the newly imported session and import the Jalview specific
295 // remnants into the new session later on.
296 desktop.vamsasStop_actionPerformed(null);
298 // now join the new session
301 if (desktop.joinVamsasSession(vamsasSession))
303 System.out.println("Successfully joined vamsas session "
308 System.err.println("WARNING: Failed to join vamsas session "
311 } catch (Exception e)
313 System.err.println("ERROR: Failed to join vamsas session "
317 if (vamsasImport != null)
319 // the Jalview specific remnants can now be imported into the new
320 // session at the user's leisure.
322 .info("Skipping Push for import of data into existing vamsas session."); // TODO:
327 // desktop.getVamsasApplication().push_update();
332 // Finally, deal with the remaining input data.
337 desktop.setProgressBar(MessageManager.getString("status.processing_commandline_args"),
338 progress = System.currentTimeMillis());
340 System.out.println("Opening file: " + file);
342 if (!file.startsWith("http://"))
344 if (!(new java.io.File(file)).exists())
346 System.out.println("Can't find " + file);
354 protocol = jalview.io.AppletFormatAdapter.checkProtocol(file);
356 format = new jalview.io.IdentifyFile().Identify(file, protocol);
358 AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol,
362 System.out.println("error");
367 data = aparser.getValue("colour", true);
370 data.replaceAll("%20", " ");
372 jalview.schemes.ColourSchemeI cs = jalview.schemes.ColourSchemeProperty
373 .getColour(af.getViewport().getAlignment(), data);
377 jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme(
379 ucs.parseAppletParameter(data);
383 System.out.println("colour is " + data);
387 // Must maintain ability to use the groups flag
388 data = aparser.getValue("groups", true);
391 af.parseFeaturesFile(data,
392 jalview.io.AppletFormatAdapter.checkProtocol(data));
393 System.out.println("Added " + data);
395 data = aparser.getValue("features", true);
398 af.parseFeaturesFile(data,
399 jalview.io.AppletFormatAdapter.checkProtocol(data));
400 System.out.println("Added " + data);
403 data = aparser.getValue("annotations", true);
406 af.loadJalviewDataFile(data, null, null, null);
407 System.out.println("Added " + data);
409 // set or clear the sortbytree flag.
410 if (aparser.contains("sortbytree"))
412 af.getViewport().setSortByTree(true);
414 if (aparser.contains("no-annotation"))
416 af.getViewport().setShowAnnotation(false);
418 if (aparser.contains("nosortbytree"))
420 af.getViewport().setSortByTree(false);
422 data = aparser.getValue("tree", true);
425 jalview.io.NewickFile fin = null;
428 fin = new jalview.io.NewickFile(data,
429 jalview.io.AppletFormatAdapter.checkProtocol(data));
432 af.getViewport().setCurrentTree(
433 af.ShowNewickTree(fin, data).getTree());
434 System.out.println("Added tree " + data);
436 } catch (IOException ex)
438 System.err.println("Couldn't add tree " + data);
439 ex.printStackTrace(System.err);
442 // TODO - load PDB structure(s) to alignment JAL-629
443 // (associate with identical sequence in alignment, or a specified
446 getFeatures = checkDasArguments(aparser);
447 if (af != null && getFeatures != null)
449 FeatureFetcher ff = startFeatureFetching(getFeatures);
452 while (!ff.allFinished() || af.operationInProgress())
454 // wait around until fetching is finished.
458 } catch (Exception e)
464 getFeatures = null; // have retrieved features - forget them now.
466 if (groovyscript != null)
468 // Execute the groovy script after we've done all the rendering stuff
469 // and before any images or figures are generated.
470 if (jalview.bin.Cache.groovyJarsPresent())
472 System.out.println("Executing script " + groovyscript);
473 executeGroovyScript(groovyscript, new Object[]
479 .println("Sorry. Groovy Support is not available, so ignoring the provided groovy script "
484 String imageName = "unnamed.png";
485 while (aparser.getSize() > 1)
487 format = aparser.nextValue();
488 file = aparser.nextValue();
490 if (format.equalsIgnoreCase("png"))
492 af.createPNG(new java.io.File(file));
493 imageName = (new java.io.File(file)).getName();
494 System.out.println("Creating PNG image: " + file);
497 else if (format.equalsIgnoreCase("svg"))
499 File imageFile = new java.io.File(file);
500 imageName = imageFile.getName();
501 af.createSVG(imageFile);
502 System.out.println("Creating SVG image: " + file);
505 else if (format.equalsIgnoreCase("html"))
507 File imageFile = new java.io.File(file);
508 imageName = imageFile.getName();
509 new HtmlSvgOutput(new java.io.File(file), af.alignPanel);
510 System.out.println("Creating HTML image: " + file);
513 else if (format.equalsIgnoreCase("imgMap"))
515 af.createImageMap(new java.io.File(file), imageName);
516 System.out.println("Creating image map: " + file);
519 else if (format.equalsIgnoreCase("eps"))
521 System.out.println("Creating EPS file: " + file);
522 af.createEPS(new java.io.File(file));
526 if (af.saveAlignment(file, format))
528 System.out.println("Written alignment in " + format
529 + " format to " + file);
533 System.out.println("Error writing file " + file + " in "
534 + format + " format!!");
539 while (aparser.getSize() > 0)
541 System.out.println("Unknown arg: " + aparser.nextValue());
545 AlignFrame startUpAlframe = null;
546 // We'll only open the default file if the desktop is visible.
548 // ////////////////////
550 if (!headless && file == null && vamsasImport == null
551 && jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true))
553 file = jalview.bin.Cache.getDefault(
555 jalview.bin.Cache.getDefault("www.jalview.org",
556 "http://www.jalview.org")
557 + "/examples/exampleFile_2_7.jar");
558 if (file.equals("http://www.jalview.org/examples/exampleFile_2_3.jar"))
560 // hardwire upgrade of the startup file
561 file.replace("_2_3.jar", "_2_7.jar");
562 // and remove the stale setting
563 jalview.bin.Cache.removeProperty("STARTUP_FILE");
568 if (file.indexOf("http:") > -1)
573 if (file.endsWith(".jar"))
579 format = new jalview.io.IdentifyFile().Identify(file, protocol);
582 startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
584 getFeatures = checkDasArguments(aparser);
585 // extract groovy arguments before anything else.
587 // If the user has specified features to be retrieved,
588 // or a groovy script to be executed, do them if they
589 // haven't been done already
590 // fetch features for the default alignment
591 if (getFeatures != null)
593 if (startUpAlframe != null)
595 startFeatureFetching(getFeatures);
598 // Once all other stuff is done, execute any groovy scripts (in order)
599 if (groovyscript != null)
601 if (jalview.bin.Cache.groovyJarsPresent())
603 System.out.println("Executing script " + groovyscript);
604 executeGroovyScript(groovyscript, new Object[]
605 { desktop, startUpAlframe });
610 .println("Sorry. Groovy Support is not available, so ignoring the provided groovy script "
614 // and finally, turn off batch mode indicator - if the desktop still exists
619 desktop.setProgressBar(null, progress);
621 desktop.setInBatchMode(false);
625 private static void showUsage()
628 .println("Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
629 + "-nodisplay\tRun Jalview without User Interface.\n"
630 + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
631 + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
632 + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
633 + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
634 + "-features FILE\tUse the given file to mark features on the alignment.\n"
635 + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
636 + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
637 + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
638 + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
639 + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
640 + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
641 + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
642 + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
643 + "-png FILE\tCreate PNG image FILE from alignment.\n"
644 + "-svg FILE\tCreate SVG image FILE from alignment.\n"
645 + "-html FILE\tCreate HTML file from alignment.\n"
646 + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
647 + "-eps FILE\tCreate EPS file FILE from alignment.\n"
648 + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
649 + "-noquestionnaire\tTurn off questionnaire check.\n"
650 + "-nousagestats\tTurn off google analytics tracking for this session.\n"
651 + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
653 // "-setprop PROPERTY=VALUE\tSet the given Jalview property, after all other properties files have been read\n\t (quote the 'PROPERTY=VALUE' pair to ensure spaces are passed in correctly)"
654 + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
655 + "-dasserver nickname=URL\tAdd and enable a das server with given nickname\n\t\t\t(alphanumeric or underscores only) for retrieval of features for all alignments.\n"
656 + "\t\t\tSources that also support the sequence command may be specified by prepending the URL with sequence:\n"
657 + "\t\t\t e.g. sequence:http://localdas.somewhere.org/das/source)\n"
658 + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
660 // "-vdoc vamsas-document\tImport vamsas document into new session or join existing session with same URN\n"
661 // + "-vses vamsas-session\tJoin session with given URN\n"
662 + "-groovy FILE\tExecute groovy script in FILE, after all other arguments have been processed (if FILE is the text 'STDIN' then the file will be read from STDIN)\n"
663 + "\n~Read documentation in Application or visit http://www.jalview.org for description of Features and Annotations file~\n\n");
666 private static void startUsageStats(final Desktop desktop)
669 * start a User Config prompt asking if we can log usage statistics.
671 jalview.gui.PromptUserConfig prompter = new jalview.gui.PromptUserConfig(
674 "Jalview Usage Statistics",
675 "Do you want to help make Jalview better by enabling "
676 + "the collection of usage statistics with Google Analytics ?"
677 + "\n\n(you can enable or disable usage tracking in the preferences)",
683 .debug("Initialising googletracker for usage stats.");
684 Cache.initGoogleTracker();
685 Cache.log.debug("Tracking enabled.");
691 Cache.log.debug("Not enabling Google Tracking.");
694 desktop.addDialogThread(prompter);
698 * Locate the given string as a file and pass it to the groovy interpreter.
700 * @param groovyscript
701 * the script to execute
702 * @param jalviewContext
703 * the Jalview Desktop object passed in to the groovy binding as the
706 private static void executeGroovyScript(String groovyscript,
707 Object[] jalviewContext)
709 if (jalviewContext == null)
712 .println("Sorry. Groovy support is currently only available when running with the Jalview GUI enabled.");
715 * for scripts contained in files
722 if (groovyscript.trim().equals("STDIN"))
724 // read from stdin into a tempfile and execute it
727 tfile = File.createTempFile("jalview", "groovy");
728 PrintWriter outfile = new PrintWriter(new OutputStreamWriter(
729 new FileOutputStream(tfile)));
730 BufferedReader br = new BufferedReader(
731 new java.io.InputStreamReader(System.in));
733 while ((line = br.readLine()) != null)
735 outfile.write(line + "\n");
741 } catch (Exception ex)
743 System.err.println("Failed to read from STDIN into tempfile "
744 + ((tfile == null) ? "(tempfile wasn't created)" : tfile
746 ex.printStackTrace();
751 sfile = tfile.toURI().toURL();
752 } catch (Exception x)
755 .println("Unexpected Malformed URL Exception for temporary file created from STDIN: "
765 sfile = new URI(groovyscript).toURL();
766 } catch (Exception x)
768 tfile = new File(groovyscript);
771 System.err.println("File '" + groovyscript + "' does not exist.");
774 if (!tfile.canRead())
776 System.err.println("File '" + groovyscript + "' cannot be read.");
779 if (tfile.length() < 1)
781 System.err.println("File '" + groovyscript + "' is empty.");
786 sfile = tfile.getAbsoluteFile().toURI().toURL();
787 } catch (Exception ex)
789 System.err.println("Failed to create a file URL for "
790 + tfile.getAbsoluteFile());
795 boolean success = false;
799 * The following code performs the GroovyScriptEngine invocation using
800 * reflection, and is equivalent to this fragment from the embedding
801 * groovy documentation on the groovy site: <code> import
802 * groovy.lang.Binding; import groovy.util.GroovyScriptEngine;
804 * String[] roots = new String[] { "/my/groovy/script/path" };
805 * GroovyScriptEngine gse = new GroovyScriptEngine(roots); Binding binding
806 * = new Binding(); binding.setVariable("input", "world");
807 * gse.run("hello.groovy", binding); </code>
811 int blen = ((jalviewContext[0] == null) ? 0 : 1)
812 + ((jalviewContext[1] == null) ? 0 : 1);
813 String cnames[] = new String[]
814 { "Jalview", "currentAlFrame" };
815 bspec = new Class[blen * 2];
816 binding = new Object[blen * 2];
818 ClassLoader cl = null;
819 Map<String, Object> vbinding = new HashMap<String, Object>();
820 for (int jc = 0; jc < jalviewContext.length; jc++)
822 if (jalviewContext[jc] != null)
826 cl = jalviewContext[jc].getClass().getClassLoader();
828 bspec[blen * 2] = String.class;
829 bspec[blen * 2 + 1] = Object.class;
830 binding[blen * 2] = cnames[jc];
831 binding[blen * 2 + 1] = jalviewContext[jc];
832 vbinding.put(cnames[jc], jalviewContext[jc]);
836 Class<?> gbindingc = cl.loadClass("groovy.lang.Binding");
837 Constructor<?> gbcons;
841 gbcons = gbindingc.getConstructor(Map.class);
842 gbinding = gbcons.newInstance(vbinding);
843 } catch (NoSuchMethodException x)
845 // old style binding config - using series of string/object values to
847 gbcons = gbindingc.getConstructor();
848 gbinding = gbcons.newInstance();
849 java.lang.reflect.Method setvar = gbindingc.getMethod(
850 "setVariable", bspec);
851 setvar.invoke(gbinding, binding);
854 Class<?> gsec = cl.loadClass("groovy.util.GroovyScriptEngine");
855 Constructor<?> gseccons = gsec.getConstructor(new Class[]
856 { URL[].class }); // String[].class });
857 Object gse = gseccons.newInstance(new Object[]
859 { sfile } }); // .toString() } });
860 java.lang.reflect.Method run = gsec.getMethod("run", new Class[]
861 { String.class, gbindingc });
862 run.invoke(gse, new Object[]
863 { sfile.toString(), gbinding });
865 } catch (Exception e)
867 System.err.println("Exception Whilst trying to execute file " + sfile
868 + " as a groovy script.");
869 e.printStackTrace(System.err);
872 if (success && groovyscript.equals("STDIN"))
874 // delete temp file that we made - but only if it was successfully
881 * Check commandline for any das server definitions or any fetchfrom switches
883 * @return vector of DAS source nicknames to retrieve from
885 private static Vector checkDasArguments(ArgsParser aparser)
887 Vector source = null;
889 String locsources = Cache.getProperty(Cache.DAS_LOCAL_SOURCE);
890 while ((data = aparser.getValue("dasserver", true)) != null)
892 String nickname = null;
894 boolean seq = false, feat = true;
895 int pos = data.indexOf('=');
896 // determine capabilities
899 nickname = data.substring(0, pos);
901 url = data.substring(pos + 1);
903 && (url.startsWith("http:") || url
904 .startsWith("sequence:http:")))
906 if (nickname == null)
910 if (locsources == null)
918 locsources = locsources + nickname + "|" + url;
920 .println("NOTE! dasserver parameter not yet really supported (got args of "
921 + nickname + "|" + url);
924 source = new Vector();
926 source.addElement(nickname);
928 } // loop until no more server entries are found.
929 if (locsources != null && locsources.indexOf('|') > -1)
931 Cache.log.debug("Setting local source list in properties file to:\n"
933 Cache.setProperty(Cache.DAS_LOCAL_SOURCE, locsources);
935 while ((data = aparser.getValue("fetchfrom", true)) != null)
937 System.out.println("adding source '" + data + "'");
940 source = new Vector();
942 source.addElement(data);
948 * start a feature fetcher for every alignment frame
952 private static FeatureFetcher startFeatureFetching(final Vector dasSources)
954 FeatureFetcher ff = new FeatureFetcher();
955 AlignFrame afs[] = Desktop.getAlignFrames();
956 if (afs == null || afs.length == 0)
960 for (int i = 0; i < afs.length; i++)
962 ff.addFetcher(afs[i], dasSources);
969 * Notes: this argParser does not distinguish between parameter switches,
970 * parameter values and argument text. If an argument happens to be identical to
971 * a parameter, it will be taken as such (even though it didn't have a '-'
974 * @author Andrew Waterhouse and JBP documented.
978 class rnabuttonlistener implements ActionListener
980 public void actionPerformed(ActionEvent arg0)
982 System.out.println("Good idea ! ");
987 class pbuttonlistener implements ActionListener
989 public void actionPerformed(ActionEvent arg0)
999 public ArgsParser(String[] args)
1001 vargs = new Vector();
1002 for (int i = 0; i < args.length; i++)
1004 String arg = args[i].trim();
1005 if (arg.charAt(0) == '-')
1007 arg = arg.substring(1);
1009 vargs.addElement(arg);
1014 * check for and remove first occurence of arg+parameter in arglist.
1017 * @return return the argument following the given arg if arg was in list.
1019 public String getValue(String arg)
1021 return getValue(arg, false);
1024 public String getValue(String arg, boolean utf8decode)
1026 int index = vargs.indexOf(arg);
1027 String dc = null, ret = null;
1030 ret = vargs.elementAt(index + 1).toString();
1031 vargs.removeElementAt(index);
1032 vargs.removeElementAt(index);
1033 if (utf8decode && ret != null)
1037 dc = URLDecoder.decode(ret, "UTF-8");
1039 } catch (Exception e)
1041 // TODO: log failure to decode
1049 * check for and remove first occurence of arg in arglist.
1052 * @return true if arg was present in argslist.
1054 public boolean contains(String arg)
1056 if (vargs.contains(arg))
1058 vargs.removeElement(arg);
1067 public String nextValue()
1069 return vargs.remove(0).toString();
1072 public int getSize()
1074 return vargs.size();
1080 * keep track of feature fetching tasks.
1085 class FeatureFetcher
1088 * TODO: generalise to track all jalview events to orchestrate batch
1089 * processing events.
1092 private int queued = 0;
1094 private int running = 0;
1096 public FeatureFetcher()
1101 public void addFetcher(final AlignFrame af, final Vector dasSources)
1103 final long id = System.currentTimeMillis();
1105 final FeatureFetcher us = this;
1106 new Thread(new Runnable()
1117 af.setProgressBar(MessageManager.getString("status.das_features_being_retrived"), id);
1118 af.featureSettings_actionPerformed(null);
1119 af.featureSettings.fetchDasFeatures(dasSources, true);
1120 af.setProgressBar(null, id);
1129 public synchronized boolean allFinished()
1131 return queued == 0 && running == 0;