2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 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.HtmlSvgOutput;
26 import jalview.util.MessageManager;
27 import jalview.util.Platform;
28 import jalview.ws.jws2.Jws2Discoverer;
30 import java.awt.event.ActionEvent;
31 import java.awt.event.ActionListener;
32 import java.io.BufferedReader;
34 import java.io.FileOutputStream;
35 import java.io.IOException;
36 import java.io.OutputStreamWriter;
37 import java.io.PrintWriter;
38 import java.lang.reflect.Constructor;
39 import java.net.MalformedURLException;
42 import java.net.URLDecoder;
43 import java.security.AllPermission;
44 import java.security.CodeSource;
45 import java.security.PermissionCollection;
46 import java.security.Permissions;
47 import java.security.Policy;
48 import java.util.Hashtable;
50 import java.util.Vector;
52 import javax.swing.UIManager;
55 * Main class for Jalview Application <br>
57 * start with java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview
66 // grab all the rights we can the JVM
67 Policy.setPolicy(new Policy()
69 public PermissionCollection getPermissions(CodeSource codesource)
71 Permissions perms = new Permissions();
72 perms.add(new AllPermission());
83 * main class for Jalview application
86 * open <em>filename</em>
88 public static void main(String[] args)
90 System.out.println("Java version: "
91 + System.getProperty("java.version"));
92 System.out.println(System.getProperty("os.arch") + " "
93 + System.getProperty("os.name") + " "
94 + System.getProperty("os.version"));
95 if (new Platform().isAMac())
97 System.setProperty("com.apple.mrj.application.apple.menu.about.name",
99 System.setProperty("apple.laf.useScreenMenuBar", "true");
102 ArgsParser aparser = new ArgsParser(args);
103 boolean headless = false;
105 if (aparser.contains("help") || aparser.contains("h"))
110 if (aparser.contains("nodisplay") || aparser.contains("nogui")
111 || aparser.contains("headless"))
113 System.setProperty("java.awt.headless", "true");
116 Cache.loadProperties(aparser.getValue("props")); // must do this before
119 final String jabawsUrl = aparser.getValue("jabaws");
120 if (jabawsUrl != null)
124 Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
125 } catch (MalformedURLException e)
127 System.err.println("Invalid jabaws parameter: " + jabawsUrl
132 String defs = aparser.getValue("setprop");
135 int p = defs.indexOf('=');
138 System.err.println("Ignoring invalid setprop argument : " + defs);
142 System.out.println("Executing setprop argument: " + defs);
143 // DISABLED FOR SECURITY REASONS
144 // TODO: add a property to allow properties to be overriden by cli args
145 // Cache.setProperty(defs.substring(0,p), defs.substring(p+1));
147 defs = aparser.getValue("setprop");
149 if (System.getProperty("java.awt.headless") != null
150 && System.getProperty("java.awt.headless").equals("true"))
154 System.setProperty("http.agent",
155 "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
159 } catch (java.lang.NoClassDefFoundError error)
161 error.printStackTrace();
163 .println("\nEssential logging libraries not found."
164 + "\nUse: java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview");
168 Desktop desktop = null;
172 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
173 } catch (Exception ex)
179 desktop = new Desktop();
180 desktop.setInBatchMode(true); // indicate we are starting up
181 desktop.setVisible(true);
182 desktop.startServiceDiscovery();
183 if (!aparser.contains("nousagestats"))
185 startUsageStats(desktop);
187 if (!aparser.contains("noquestionnaire"))
189 String url = aparser.getValue("questionnaire");
192 // Start the desktop questionnaire prompter with the specified
194 Cache.log.debug("Starting questionnaire url at " + url);
195 desktop.checkForQuestionnaire(url);
199 if (Cache.getProperty("NOQUESTIONNAIRES") == null)
201 // Start the desktop questionnaire prompter with the specified
204 // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
206 String defurl = "http://www.jalview.org/cgi-bin/questionnaire.pl";
207 Cache.log.debug("Starting questionnaire with default url: "
209 desktop.checkForQuestionnaire(defurl);
214 desktop.checkForNews();
217 String file = null, protocol = null, format = null, data = null;
218 jalview.io.FileLoader fileLoader = new jalview.io.FileLoader();
219 Vector getFeatures = null; // vector of das source nicknames to fetch
222 String groovyscript = null; // script to execute after all loading is
223 // completed one way or another
224 // extract groovy argument and execute if necessary
225 groovyscript = aparser.getValue("groovy", true);
226 file = aparser.getValue("open", true);
228 if (file == null && desktop == null)
230 System.out.println("No files to open!");
233 String vamsasImport = aparser.getValue("vdoc"), vamsasSession = aparser
235 if (vamsasImport != null || vamsasSession != null)
237 if (desktop == null || headless)
240 .println("Headless vamsas sessions not yet supported. Sorry.");
243 // if we have a file, start a new session and import it.
244 boolean inSession = false;
245 if (vamsasImport != null)
249 String viprotocol = jalview.io.AppletFormatAdapter
250 .checkProtocol(vamsasImport);
251 if (viprotocol == jalview.io.FormatAdapter.FILE)
253 inSession = desktop.vamsasImport(new File(vamsasImport));
255 else if (viprotocol == jalview.io.FormatAdapter.URL)
257 inSession = desktop.vamsasImport(new URL(vamsasImport));
260 } catch (Exception e)
262 System.err.println("Exeption when importing " + vamsasImport
263 + " as a vamsas document.");
268 System.err.println("Failed to import " + vamsasImport
269 + " as a vamsas document.");
273 System.out.println("Imported Successfully into new session "
274 + desktop.getVamsasApplication().getCurrentSession());
277 if (vamsasSession != null)
279 if (vamsasImport != null)
281 // close the newly imported session and import the Jalview specific
282 // remnants into the new session later on.
283 desktop.vamsasStop_actionPerformed(null);
285 // now join the new session
288 if (desktop.joinVamsasSession(vamsasSession))
290 System.out.println("Successfully joined vamsas session "
295 System.err.println("WARNING: Failed to join vamsas session "
298 } catch (Exception e)
300 System.err.println("ERROR: Failed to join vamsas session "
304 if (vamsasImport != null)
306 // the Jalview specific remnants can now be imported into the new
307 // session at the user's leisure.
309 .info("Skipping Push for import of data into existing vamsas session."); // TODO:
314 // desktop.getVamsasApplication().push_update();
319 // Finally, deal with the remaining input data.
324 desktop.setProgressBar(MessageManager.getString("status.processing_commandline_args"),
325 progress = System.currentTimeMillis());
327 System.out.println("Opening file: " + file);
329 if (!file.startsWith("http://"))
331 if (!(new java.io.File(file)).exists())
333 System.out.println("Can't find " + file);
341 protocol = jalview.io.AppletFormatAdapter.checkProtocol(file);
343 format = new jalview.io.IdentifyFile().Identify(file, protocol);
345 AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol,
349 System.out.println("error");
354 data = aparser.getValue("colour", true);
357 data.replaceAll("%20", " ");
359 jalview.schemes.ColourSchemeI cs = jalview.schemes.ColourSchemeProperty
360 .getColour(af.getViewport().getAlignment(), data);
364 jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme(
366 ucs.parseAppletParameter(data);
370 System.out.println("colour is " + data);
374 // Must maintain ability to use the groups flag
375 data = aparser.getValue("groups", true);
378 af.parseFeaturesFile(data,
379 jalview.io.AppletFormatAdapter.checkProtocol(data));
380 System.out.println("Added " + data);
382 data = aparser.getValue("features", true);
385 af.parseFeaturesFile(data,
386 jalview.io.AppletFormatAdapter.checkProtocol(data));
387 System.out.println("Added " + data);
390 data = aparser.getValue("annotations", true);
393 af.loadJalviewDataFile(data, null, null, null);
394 System.out.println("Added " + data);
396 // set or clear the sortbytree flag.
397 if (aparser.contains("sortbytree"))
399 af.getViewport().setSortByTree(true);
401 if (aparser.contains("nosortbytree"))
403 af.getViewport().setSortByTree(false);
405 data = aparser.getValue("tree", true);
408 jalview.io.NewickFile fin = null;
411 fin = new jalview.io.NewickFile(data,
412 jalview.io.AppletFormatAdapter.checkProtocol(data));
415 af.getViewport().setCurrentTree(
416 af.ShowNewickTree(fin, data).getTree());
417 System.out.println("Added tree " + data);
419 } catch (IOException ex)
421 System.err.println("Couldn't add tree " + data);
422 ex.printStackTrace(System.err);
425 // TODO - load PDB structure(s) to alignment JAL-629
426 // (associate with identical sequence in alignment, or a specified
429 getFeatures = checkDasArguments(aparser);
430 if (af != null && getFeatures != null)
432 FeatureFetcher ff = startFeatureFetching(getFeatures);
435 while (!ff.allFinished() || af.operationInProgress())
437 // wait around until fetching is finished.
441 } catch (Exception e)
447 getFeatures = null; // have retrieved features - forget them now.
449 if (groovyscript != null)
451 // Execute the groovy script after we've done all the rendering stuff
452 // and before any images or figures are generated.
453 if (jalview.bin.Cache.groovyJarsPresent())
455 System.out.println("Executing script " + groovyscript);
456 executeGroovyScript(groovyscript, new Object[]
462 .println("Sorry. Groovy Support is not available, so ignoring the provided groovy script "
467 String imageName = "unnamed.png";
468 while (aparser.getSize() > 1)
470 format = aparser.nextValue();
471 file = aparser.nextValue();
473 if (format.equalsIgnoreCase("png"))
475 af.createPNG(new java.io.File(file));
476 imageName = (new java.io.File(file)).getName();
477 System.out.println("Creating PNG image: " + file);
480 else if (format.equalsIgnoreCase("svg"))
482 File imageFile = new java.io.File(file);
483 imageName = imageFile.getName();
484 af.createSVG(imageFile);
485 System.out.println("Creating SVG image: " + file);
488 else if (format.equalsIgnoreCase("html"))
490 File imageFile = new java.io.File(file);
491 imageName = imageFile.getName();
492 new HtmlSvgOutput(new java.io.File(file), af.alignPanel);
493 System.out.println("Creating HTML image: " + file);
496 else if (format.equalsIgnoreCase("imgMap"))
498 af.createImageMap(new java.io.File(file), imageName);
499 System.out.println("Creating image map: " + file);
502 else if (format.equalsIgnoreCase("eps"))
504 System.out.println("Creating EPS file: " + file);
505 af.createEPS(new java.io.File(file));
509 if (af.saveAlignment(file, format))
511 System.out.println("Written alignment in " + format
512 + " format to " + file);
516 System.out.println("Error writing file " + file + " in "
517 + format + " format!!");
522 while (aparser.getSize() > 0)
524 System.out.println("Unknown arg: " + aparser.nextValue());
528 AlignFrame startUpAlframe = null;
529 // We'll only open the default file if the desktop is visible.
531 // ////////////////////
533 if (!headless && file == null && vamsasImport == null
534 && jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true))
536 file = jalview.bin.Cache.getDefault(
538 jalview.bin.Cache.getDefault("www.jalview.org",
539 "http://www.jalview.org")
540 + "/examples/exampleFile_2_7.jar");
541 if (file.equals("http://www.jalview.org/examples/exampleFile_2_3.jar"))
543 // hardwire upgrade of the startup file
544 file.replace("_2_3.jar", "_2_7.jar");
545 // and remove the stale setting
546 jalview.bin.Cache.removeProperty("STARTUP_FILE");
551 if (file.indexOf("http:") > -1)
556 if (file.endsWith(".jar"))
562 format = new jalview.io.IdentifyFile().Identify(file, protocol);
565 startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
567 getFeatures = checkDasArguments(aparser);
568 // extract groovy arguments before anything else.
570 // If the user has specified features to be retrieved,
571 // or a groovy script to be executed, do them if they
572 // haven't been done already
573 // fetch features for the default alignment
574 if (getFeatures != null)
576 if (startUpAlframe != null)
578 startFeatureFetching(getFeatures);
581 // Once all other stuff is done, execute any groovy scripts (in order)
582 if (groovyscript != null)
584 if (jalview.bin.Cache.groovyJarsPresent())
586 System.out.println("Executing script " + groovyscript);
587 executeGroovyScript(groovyscript, new Object[]
588 { desktop, startUpAlframe });
593 .println("Sorry. Groovy Support is not available, so ignoring the provided groovy script "
597 // and finally, turn off batch mode indicator - if the desktop still exists
602 desktop.setProgressBar(null, progress);
604 desktop.setInBatchMode(false);
608 private static void showUsage()
611 .println("Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
612 + "-nodisplay\tRun Jalview without User Interface.\n"
613 + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
614 + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
615 + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
616 + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
617 + "-features FILE\tUse the given file to mark features on the alignment.\n"
618 + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
619 + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
620 + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
621 + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
622 + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
623 + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
624 + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
625 + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
626 + "-png FILE\tCreate PNG image FILE from alignment.\n"
627 + "-svg FILE\tCreate SVG image FILE from alignment.\n"
628 + "-html FILE\tCreate HTML file from alignment.\n"
629 + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
630 + "-eps FILE\tCreate EPS file FILE from alignment.\n"
631 + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
632 + "-noquestionnaire\tTurn off questionnaire check.\n"
633 + "-nousagestats\tTurn off google analytics tracking for this session.\n"
634 + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
636 // "-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)"
637 + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
638 + "-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"
639 + "\t\t\tSources that also support the sequence command may be specified by prepending the URL with sequence:\n"
640 + "\t\t\t e.g. sequence:http://localdas.somewhere.org/das/source)\n"
641 + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
643 // "-vdoc vamsas-document\tImport vamsas document into new session or join existing session with same URN\n"
644 // + "-vses vamsas-session\tJoin session with given URN\n"
645 + "-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"
646 + "\n~Read documentation in Application or visit http://www.jalview.org for description of Features and Annotations file~\n\n");
649 private static void startUsageStats(final Desktop desktop)
652 * start a User Config prompt asking if we can log usage statistics.
654 jalview.gui.PromptUserConfig prompter = new jalview.gui.PromptUserConfig(
657 "Jalview Usage Statistics",
658 "Do you want to help make Jalview better by enabling "
659 + "the collection of usage statistics with Google Analytics ?"
660 + "\n\n(you can enable or disable usage tracking in the preferences)",
666 .debug("Initialising googletracker for usage stats.");
667 Cache.initGoogleTracker();
668 Cache.log.debug("Tracking enabled.");
674 Cache.log.debug("Not enabling Google Tracking.");
677 desktop.addDialogThread(prompter);
681 * Locate the given string as a file and pass it to the groovy interpreter.
683 * @param groovyscript
684 * the script to execute
685 * @param jalviewContext
686 * the Jalview Desktop object passed in to the groovy binding as the
689 private static void executeGroovyScript(String groovyscript,
690 Object[] jalviewContext)
692 if (jalviewContext == null)
695 .println("Sorry. Groovy support is currently only available when running with the Jalview GUI enabled.");
698 * for scripts contained in files
705 if (groovyscript.trim().equals("STDIN"))
707 // read from stdin into a tempfile and execute it
710 tfile = File.createTempFile("jalview", "groovy");
711 PrintWriter outfile = new PrintWriter(new OutputStreamWriter(
712 new FileOutputStream(tfile)));
713 BufferedReader br = new BufferedReader(
714 new java.io.InputStreamReader(System.in));
716 while ((line = br.readLine()) != null)
718 outfile.write(line + "\n");
724 } catch (Exception ex)
726 System.err.println("Failed to read from STDIN into tempfile "
727 + ((tfile == null) ? "(tempfile wasn't created)" : tfile
729 ex.printStackTrace();
734 sfile = tfile.toURI().toURL();
735 } catch (Exception x)
738 .println("Unexpected Malformed URL Exception for temporary file created from STDIN: "
748 sfile = new URI(groovyscript).toURL();
749 } catch (Exception x)
751 tfile = new File(groovyscript);
754 System.err.println("File '" + groovyscript + "' does not exist.");
757 if (!tfile.canRead())
759 System.err.println("File '" + groovyscript + "' cannot be read.");
762 if (tfile.length() < 1)
764 System.err.println("File '" + groovyscript + "' is empty.");
769 sfile = tfile.getAbsoluteFile().toURI().toURL();
770 } catch (Exception ex)
772 System.err.println("Failed to create a file URL for "
773 + tfile.getAbsoluteFile());
778 boolean success = false;
782 * The following code performs the GroovyScriptEngine invocation using
783 * reflection, and is equivalent to this fragment from the embedding
784 * groovy documentation on the groovy site: <code> import
785 * groovy.lang.Binding; import groovy.util.GroovyScriptEngine;
787 * String[] roots = new String[] { "/my/groovy/script/path" };
788 * GroovyScriptEngine gse = new GroovyScriptEngine(roots); Binding binding
789 * = new Binding(); binding.setVariable("input", "world");
790 * gse.run("hello.groovy", binding); </code>
794 int blen = ((jalviewContext[0] == null) ? 0 : 1)
795 + ((jalviewContext[1] == null) ? 0 : 1);
796 String cnames[] = new String[]
797 { "Jalview", "currentAlFrame" };
798 bspec = new Class[blen * 2];
799 binding = new Object[blen * 2];
801 ClassLoader cl = null;
802 Map vbinding = new Hashtable();
803 for (int jc = 0; jc < jalviewContext.length; jc++)
805 if (jalviewContext[jc] != null)
809 cl = jalviewContext[jc].getClass().getClassLoader();
811 bspec[blen * 2] = String.class;
812 bspec[blen * 2 + 1] = Object.class;
813 binding[blen * 2] = cnames[jc];
814 binding[blen * 2 + 1] = jalviewContext[jc];
815 vbinding.put(cnames[jc], jalviewContext[jc]);
819 Class gbindingc = cl.loadClass("groovy.lang.Binding");
824 gbcons = gbindingc.getConstructor(Map.class);
825 gbinding = gbcons.newInstance(vbinding);
826 } catch (NoSuchMethodException x)
828 // old style binding config - using series of string/object values to
830 gbcons = gbindingc.getConstructor(null);
831 gbinding = gbcons.newInstance(null);
832 java.lang.reflect.Method setvar = gbindingc.getMethod(
833 "setVariable", bspec);
834 setvar.invoke(gbinding, binding);
837 Class gsec = cl.loadClass("groovy.util.GroovyScriptEngine");
838 Constructor gseccons = gsec.getConstructor(new Class[]
839 { URL[].class }); // String[].class });
840 Object gse = gseccons.newInstance(new Object[]
842 { sfile } }); // .toString() } });
843 java.lang.reflect.Method run = gsec.getMethod("run", new Class[]
844 { String.class, gbindingc });
845 run.invoke(gse, new Object[]
846 { sfile.toString(), gbinding });
848 } catch (Exception e)
850 System.err.println("Exception Whilst trying to execute file " + sfile
851 + " as a groovy script.");
852 e.printStackTrace(System.err);
855 if (success && groovyscript.equals("STDIN"))
857 // delete temp file that we made - but only if it was successfully
864 * Check commandline for any das server definitions or any fetchfrom switches
866 * @return vector of DAS source nicknames to retrieve from
868 private static Vector checkDasArguments(ArgsParser aparser)
870 Vector source = null;
872 String locsources = Cache.getProperty(Cache.DAS_LOCAL_SOURCE);
873 while ((data = aparser.getValue("dasserver", true)) != null)
875 String nickname = null;
877 boolean seq = false, feat = true;
878 int pos = data.indexOf('=');
879 // determine capabilities
882 nickname = data.substring(0, pos);
884 url = data.substring(pos + 1);
886 && (url.startsWith("http:") || url
887 .startsWith("sequence:http:")))
889 if (nickname == null)
893 if (locsources == null)
901 locsources = locsources + nickname + "|" + url;
903 .println("NOTE! dasserver parameter not yet really supported (got args of "
904 + nickname + "|" + url);
907 source = new Vector();
909 source.addElement(nickname);
911 } // loop until no more server entries are found.
912 if (locsources != null && locsources.indexOf('|') > -1)
914 Cache.log.debug("Setting local source list in properties file to:\n"
916 Cache.setProperty(Cache.DAS_LOCAL_SOURCE, locsources);
918 while ((data = aparser.getValue("fetchfrom", true)) != null)
920 System.out.println("adding source '" + data + "'");
923 source = new Vector();
925 source.addElement(data);
931 * start a feature fetcher for every alignment frame
935 private static FeatureFetcher startFeatureFetching(final Vector dasSources)
937 FeatureFetcher ff = new FeatureFetcher();
938 AlignFrame afs[] = Desktop.getAlignframes();
939 if (afs == null || afs.length == 0)
943 for (int i = 0; i < afs.length; i++)
945 ff.addFetcher(afs[i], dasSources);
952 * Notes: this argParser does not distinguish between parameter switches,
953 * parameter values and argument text. If an argument happens to be identical to
954 * a parameter, it will be taken as such (even though it didn't have a '-'
957 * @author Andrew Waterhouse and JBP documented.
961 class rnabuttonlistener implements ActionListener
963 public void actionPerformed(ActionEvent arg0)
965 System.out.println("Good idea ! ");
970 class pbuttonlistener implements ActionListener
972 public void actionPerformed(ActionEvent arg0)
982 public ArgsParser(String[] args)
984 vargs = new Vector();
985 for (int i = 0; i < args.length; i++)
987 String arg = args[i].trim();
988 if (arg.charAt(0) == '-')
990 arg = arg.substring(1);
992 vargs.addElement(arg);
997 * check for and remove first occurence of arg+parameter in arglist.
1000 * @return return the argument following the given arg if arg was in list.
1002 public String getValue(String arg)
1004 return getValue(arg, false);
1007 public String getValue(String arg, boolean utf8decode)
1009 int index = vargs.indexOf(arg);
1010 String dc = null, ret = null;
1013 ret = vargs.elementAt(index + 1).toString();
1014 vargs.removeElementAt(index);
1015 vargs.removeElementAt(index);
1016 if (utf8decode && ret != null)
1020 dc = URLDecoder.decode(ret, "UTF-8");
1022 } catch (Exception e)
1024 // TODO: log failure to decode
1032 * check for and remove first occurence of arg in arglist.
1035 * @return true if arg was present in argslist.
1037 public boolean contains(String arg)
1039 if (vargs.contains(arg))
1041 vargs.removeElement(arg);
1050 public String nextValue()
1052 return vargs.remove(0).toString();
1055 public int getSize()
1057 return vargs.size();
1063 * keep track of feature fetching tasks.
1068 class FeatureFetcher
1071 * TODO: generalise to track all jalview events to orchestrate batch
1072 * processing events.
1075 private int queued = 0;
1077 private int running = 0;
1079 public FeatureFetcher()
1084 public void addFetcher(final AlignFrame af, final Vector dasSources)
1086 final long id = System.currentTimeMillis();
1088 final FeatureFetcher us = this;
1089 new Thread(new Runnable()
1100 af.setProgressBar(MessageManager.getString("status.das_features_being_retrived"), id);
1101 af.featureSettings_actionPerformed(null);
1102 af.featureSettings.fetchDasFeatures(dasSources, true);
1103 af.setProgressBar(null, id);
1112 public synchronized boolean allFinished()
1114 return queued == 0 && running == 0;