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.util.MessageManager;
26 import jalview.util.Platform;
27 import jalview.ws.jws2.Jws2Discoverer;
29 import java.awt.event.ActionEvent;
30 import java.awt.event.ActionListener;
31 import java.io.BufferedReader;
33 import java.io.FileOutputStream;
34 import java.io.IOException;
35 import java.io.OutputStreamWriter;
36 import java.io.PrintWriter;
37 import java.lang.reflect.Constructor;
38 import java.net.MalformedURLException;
41 import java.net.URLDecoder;
42 import java.security.AllPermission;
43 import java.security.CodeSource;
44 import java.security.PermissionCollection;
45 import java.security.Permissions;
46 import java.security.Policy;
47 import java.util.Hashtable;
49 import java.util.Vector;
51 import javax.swing.UIManager;
54 * Main class for Jalview Application <br>
56 * start with java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview
65 // grab all the rights we can the JVM
66 Policy.setPolicy(new Policy()
68 public PermissionCollection getPermissions(CodeSource codesource)
70 Permissions perms = new Permissions();
71 perms.add(new AllPermission());
82 * main class for Jalview application
85 * open <em>filename</em>
87 public static void main(String[] args)
89 System.out.println("Java version: "
90 + System.getProperty("java.version"));
91 System.out.println(System.getProperty("os.arch") + " "
92 + System.getProperty("os.name") + " "
93 + System.getProperty("os.version"));
94 if (new Platform().isAMac())
96 System.setProperty("com.apple.mrj.application.apple.menu.about.name",
98 System.setProperty("apple.laf.useScreenMenuBar", "true");
101 ArgsParser aparser = new ArgsParser(args);
102 boolean headless = false;
104 if (aparser.contains("help") || aparser.contains("h"))
109 if (aparser.contains("nodisplay") || aparser.contains("nogui")
110 || aparser.contains("headless"))
112 System.setProperty("java.awt.headless", "true");
115 Cache.loadProperties(aparser.getValue("props")); // must do this before
118 final String jabawsUrl = aparser.getValue("jabaws");
119 if (jabawsUrl != null)
123 Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
124 } catch (MalformedURLException e)
126 System.err.println("Invalid jabaws parameter: " + jabawsUrl
131 String defs = aparser.getValue("setprop");
134 int p = defs.indexOf('=');
137 System.err.println("Ignoring invalid setprop argument : " + defs);
141 System.out.println("Executing setprop argument: " + defs);
142 // DISABLED FOR SECURITY REASONS
143 // TODO: add a property to allow properties to be overriden by cli args
144 // Cache.setProperty(defs.substring(0,p), defs.substring(p+1));
146 defs = aparser.getValue("setprop");
148 if (System.getProperty("java.awt.headless") != null
149 && System.getProperty("java.awt.headless").equals("true"))
153 System.setProperty("http.agent",
154 "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
158 } catch (java.lang.NoClassDefFoundError error)
160 error.printStackTrace();
162 .println("\nEssential logging libraries not found."
163 + "\nUse: java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview");
167 Desktop desktop = null;
171 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
172 } catch (Exception ex)
178 desktop = new Desktop();
179 desktop.setInBatchMode(true); // indicate we are starting up
180 desktop.setVisible(true);
181 desktop.startServiceDiscovery();
182 if (!aparser.contains("nousagestats"))
184 startUsageStats(desktop);
186 if (!aparser.contains("noquestionnaire"))
188 String url = aparser.getValue("questionnaire");
191 // Start the desktop questionnaire prompter with the specified
193 Cache.log.debug("Starting questionnaire url at " + url);
194 desktop.checkForQuestionnaire(url);
198 if (Cache.getProperty("NOQUESTIONNAIRES") == null)
200 // Start the desktop questionnaire prompter with the specified
203 // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
205 String defurl = "http://www.jalview.org/cgi-bin/questionnaire.pl";
206 Cache.log.debug("Starting questionnaire with default url: "
208 desktop.checkForQuestionnaire(defurl);
213 desktop.checkForNews();
216 String file = null, protocol = null, format = null, data = null;
217 jalview.io.FileLoader fileLoader = new jalview.io.FileLoader();
218 Vector getFeatures = null; // vector of das source nicknames to fetch
221 String groovyscript = null; // script to execute after all loading is
222 // completed one way or another
223 // extract groovy argument and execute if necessary
224 groovyscript = aparser.getValue("groovy", true);
225 file = aparser.getValue("open", true);
227 if (file == null && desktop == null)
229 System.out.println("No files to open!");
232 String vamsasImport = aparser.getValue("vdoc"), vamsasSession = aparser
234 if (vamsasImport != null || vamsasSession != null)
236 if (desktop == null || headless)
239 .println("Headless vamsas sessions not yet supported. Sorry.");
242 // if we have a file, start a new session and import it.
243 boolean inSession = false;
244 if (vamsasImport != null)
248 String viprotocol = jalview.io.AppletFormatAdapter
249 .checkProtocol(vamsasImport);
250 if (viprotocol == jalview.io.FormatAdapter.FILE)
252 inSession = desktop.vamsasImport(new File(vamsasImport));
254 else if (viprotocol == jalview.io.FormatAdapter.URL)
256 inSession = desktop.vamsasImport(new URL(vamsasImport));
259 } catch (Exception e)
261 System.err.println("Exeption when importing " + vamsasImport
262 + " as a vamsas document.");
267 System.err.println("Failed to import " + vamsasImport
268 + " as a vamsas document.");
272 System.out.println("Imported Successfully into new session "
273 + desktop.getVamsasApplication().getCurrentSession());
276 if (vamsasSession != null)
278 if (vamsasImport != null)
280 // close the newly imported session and import the Jalview specific
281 // remnants into the new session later on.
282 desktop.vamsasStop_actionPerformed(null);
284 // now join the new session
287 if (desktop.joinVamsasSession(vamsasSession))
289 System.out.println("Successfully joined vamsas session "
294 System.err.println("WARNING: Failed to join vamsas session "
297 } catch (Exception e)
299 System.err.println("ERROR: Failed to join vamsas session "
303 if (vamsasImport != null)
305 // the Jalview specific remnants can now be imported into the new
306 // session at the user's leisure.
308 .info("Skipping Push for import of data into existing vamsas session."); // TODO:
313 // desktop.getVamsasApplication().push_update();
318 // Finally, deal with the remaining input data.
323 desktop.setProgressBar(MessageManager.getString("status.processing_commandline_args"),
324 progress = System.currentTimeMillis());
326 System.out.println("Opening file: " + file);
328 if (!file.startsWith("http://"))
330 if (!(new java.io.File(file)).exists())
332 System.out.println("Can't find " + file);
340 protocol = jalview.io.AppletFormatAdapter.checkProtocol(file);
342 format = new jalview.io.IdentifyFile().Identify(file, protocol);
344 AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol,
348 System.out.println("error");
353 data = aparser.getValue("colour", true);
356 data.replaceAll("%20", " ");
358 jalview.schemes.ColourSchemeI cs = jalview.schemes.ColourSchemeProperty
359 .getColour(af.getViewport().getAlignment(), data);
363 jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme(
365 ucs.parseAppletParameter(data);
369 System.out.println("colour is " + data);
373 // Must maintain ability to use the groups flag
374 data = aparser.getValue("groups", true);
377 af.parseFeaturesFile(data,
378 jalview.io.AppletFormatAdapter.checkProtocol(data));
379 System.out.println("Added " + data);
381 data = aparser.getValue("features", true);
384 af.parseFeaturesFile(data,
385 jalview.io.AppletFormatAdapter.checkProtocol(data));
386 System.out.println("Added " + data);
389 data = aparser.getValue("annotations", true);
392 af.loadJalviewDataFile(data, null, null, null);
393 System.out.println("Added " + data);
395 // set or clear the sortbytree flag.
396 if (aparser.contains("sortbytree"))
398 af.getViewport().setSortByTree(true);
400 if (aparser.contains("nosortbytree"))
402 af.getViewport().setSortByTree(false);
404 data = aparser.getValue("tree", true);
407 jalview.io.NewickFile fin = null;
410 fin = new jalview.io.NewickFile(data,
411 jalview.io.AppletFormatAdapter.checkProtocol(data));
414 af.getViewport().setCurrentTree(
415 af.ShowNewickTree(fin, data).getTree());
416 System.out.println("Added tree " + data);
418 } catch (IOException ex)
420 System.err.println("Couldn't add tree " + data);
421 ex.printStackTrace(System.err);
424 // TODO - load PDB structure(s) to alignment JAL-629
425 // (associate with identical sequence in alignment, or a specified
428 getFeatures = checkDasArguments(aparser);
429 if (af != null && getFeatures != null)
431 FeatureFetcher ff = startFeatureFetching(getFeatures);
434 while (!ff.allFinished() || af.operationInProgress())
436 // wait around until fetching is finished.
440 } catch (Exception e)
446 getFeatures = null; // have retrieved features - forget them now.
448 if (groovyscript != null)
450 // Execute the groovy script after we've done all the rendering stuff
451 // and before any images or figures are generated.
452 if (jalview.bin.Cache.groovyJarsPresent())
454 System.out.println("Executing script " + groovyscript);
455 executeGroovyScript(groovyscript, new Object[]
461 .println("Sorry. Groovy Support is not available, so ignoring the provided groovy script "
466 String imageName = "unnamed.png";
467 while (aparser.getSize() > 1)
469 format = aparser.nextValue();
470 file = aparser.nextValue();
472 if (format.equalsIgnoreCase("png"))
474 af.createPNG(new java.io.File(file));
475 imageName = (new java.io.File(file)).getName();
476 System.out.println("Creating PNG image: " + file);
479 else if (format.equalsIgnoreCase("svg"))
481 File imageFile = new java.io.File(file);
482 imageName = imageFile.getName();
483 af.createSVG(imageFile);
484 System.out.println("Creating SVG image: " + file);
487 else if (format.equalsIgnoreCase("imgMap"))
489 af.createImageMap(new java.io.File(file), imageName);
490 System.out.println("Creating image map: " + file);
493 else if (format.equalsIgnoreCase("eps"))
495 System.out.println("Creating EPS file: " + file);
496 af.createEPS(new java.io.File(file));
500 if (af.saveAlignment(file, format))
502 System.out.println("Written alignment in " + format
503 + " format to " + file);
507 System.out.println("Error writing file " + file + " in "
508 + format + " format!!");
513 while (aparser.getSize() > 0)
515 System.out.println("Unknown arg: " + aparser.nextValue());
519 AlignFrame startUpAlframe = null;
520 // We'll only open the default file if the desktop is visible.
522 // ////////////////////
524 if (!headless && file == null && vamsasImport == null
525 && jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true))
527 file = jalview.bin.Cache.getDefault(
529 jalview.bin.Cache.getDefault("www.jalview.org",
530 "http://www.jalview.org")
531 + "/examples/exampleFile_2_7.jar");
532 if (file.equals("http://www.jalview.org/examples/exampleFile_2_3.jar"))
534 // hardwire upgrade of the startup file
535 file.replace("_2_3.jar", "_2_7.jar");
536 // and remove the stale setting
537 jalview.bin.Cache.removeProperty("STARTUP_FILE");
542 if (file.indexOf("http:") > -1)
547 if (file.endsWith(".jar"))
553 format = new jalview.io.IdentifyFile().Identify(file, protocol);
556 startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
558 getFeatures = checkDasArguments(aparser);
559 // extract groovy arguments before anything else.
561 // If the user has specified features to be retrieved,
562 // or a groovy script to be executed, do them if they
563 // haven't been done already
564 // fetch features for the default alignment
565 if (getFeatures != null)
567 if (startUpAlframe != null)
569 startFeatureFetching(getFeatures);
572 // Once all other stuff is done, execute any groovy scripts (in order)
573 if (groovyscript != null)
575 if (jalview.bin.Cache.groovyJarsPresent())
577 System.out.println("Executing script " + groovyscript);
578 executeGroovyScript(groovyscript, new Object[]
579 { desktop, startUpAlframe });
584 .println("Sorry. Groovy Support is not available, so ignoring the provided groovy script "
588 // and finally, turn off batch mode indicator - if the desktop still exists
593 desktop.setProgressBar(null, progress);
595 desktop.setInBatchMode(false);
599 private static void showUsage()
602 .println("Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
603 + "-nodisplay\tRun Jalview without User Interface.\n"
604 + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
605 + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
606 + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
607 + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
608 + "-features FILE\tUse the given file to mark features on the alignment.\n"
609 + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
610 + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
611 + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
612 + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
613 + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
614 + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
615 + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
616 + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
617 + "-png FILE\tCreate PNG image FILE from alignment.\n"
618 + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
619 + "-eps FILE\tCreate EPS file FILE from alignment.\n"
620 + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
621 + "-noquestionnaire\tTurn off questionnaire check.\n"
622 + "-nousagestats\tTurn off google analytics tracking for this session.\n"
623 + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
625 // "-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)"
626 + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
627 + "-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"
628 + "\t\t\tSources that also support the sequence command may be specified by prepending the URL with sequence:\n"
629 + "\t\t\t e.g. sequence:http://localdas.somewhere.org/das/source)\n"
630 + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
632 // "-vdoc vamsas-document\tImport vamsas document into new session or join existing session with same URN\n"
633 // + "-vses vamsas-session\tJoin session with given URN\n"
634 + "-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"
635 + "\n~Read documentation in Application or visit http://www.jalview.org for description of Features and Annotations file~\n\n");
638 private static void startUsageStats(final Desktop desktop)
641 * start a User Config prompt asking if we can log usage statistics.
643 jalview.gui.PromptUserConfig prompter = new jalview.gui.PromptUserConfig(
646 "Jalview Usage Statistics",
647 "Do you want to help make Jalview better by enabling "
648 + "the collection of usage statistics with Google Analytics ?"
649 + "\n\n(you can enable or disable usage tracking in the preferences)",
655 .debug("Initialising googletracker for usage stats.");
656 Cache.initGoogleTracker();
657 Cache.log.debug("Tracking enabled.");
663 Cache.log.debug("Not enabling Google Tracking.");
666 desktop.addDialogThread(prompter);
670 * Locate the given string as a file and pass it to the groovy interpreter.
672 * @param groovyscript
673 * the script to execute
674 * @param jalviewContext
675 * the Jalview Desktop object passed in to the groovy binding as the
678 private static void executeGroovyScript(String groovyscript,
679 Object[] jalviewContext)
681 if (jalviewContext == null)
684 .println("Sorry. Groovy support is currently only available when running with the Jalview GUI enabled.");
687 * for scripts contained in files
694 if (groovyscript.trim().equals("STDIN"))
696 // read from stdin into a tempfile and execute it
699 tfile = File.createTempFile("jalview", "groovy");
700 PrintWriter outfile = new PrintWriter(new OutputStreamWriter(
701 new FileOutputStream(tfile)));
702 BufferedReader br = new BufferedReader(
703 new java.io.InputStreamReader(System.in));
705 while ((line = br.readLine()) != null)
707 outfile.write(line + "\n");
713 } catch (Exception ex)
715 System.err.println("Failed to read from STDIN into tempfile "
716 + ((tfile == null) ? "(tempfile wasn't created)" : tfile
718 ex.printStackTrace();
723 sfile = tfile.toURI().toURL();
724 } catch (Exception x)
727 .println("Unexpected Malformed URL Exception for temporary file created from STDIN: "
737 sfile = new URI(groovyscript).toURL();
738 } catch (Exception x)
740 tfile = new File(groovyscript);
743 System.err.println("File '" + groovyscript + "' does not exist.");
746 if (!tfile.canRead())
748 System.err.println("File '" + groovyscript + "' cannot be read.");
751 if (tfile.length() < 1)
753 System.err.println("File '" + groovyscript + "' is empty.");
758 sfile = tfile.getAbsoluteFile().toURI().toURL();
759 } catch (Exception ex)
761 System.err.println("Failed to create a file URL for "
762 + tfile.getAbsoluteFile());
767 boolean success = false;
771 * The following code performs the GroovyScriptEngine invocation using
772 * reflection, and is equivalent to this fragment from the embedding
773 * groovy documentation on the groovy site: <code> import
774 * groovy.lang.Binding; import groovy.util.GroovyScriptEngine;
776 * String[] roots = new String[] { "/my/groovy/script/path" };
777 * GroovyScriptEngine gse = new GroovyScriptEngine(roots); Binding binding
778 * = new Binding(); binding.setVariable("input", "world");
779 * gse.run("hello.groovy", binding); </code>
783 int blen = ((jalviewContext[0] == null) ? 0 : 1)
784 + ((jalviewContext[1] == null) ? 0 : 1);
785 String cnames[] = new String[]
786 { "Jalview", "currentAlFrame" };
787 bspec = new Class[blen * 2];
788 binding = new Object[blen * 2];
790 ClassLoader cl = null;
791 Map vbinding = new Hashtable();
792 for (int jc = 0; jc < jalviewContext.length; jc++)
794 if (jalviewContext[jc] != null)
798 cl = jalviewContext[jc].getClass().getClassLoader();
800 bspec[blen * 2] = String.class;
801 bspec[blen * 2 + 1] = Object.class;
802 binding[blen * 2] = cnames[jc];
803 binding[blen * 2 + 1] = jalviewContext[jc];
804 vbinding.put(cnames[jc], jalviewContext[jc]);
808 Class gbindingc = cl.loadClass("groovy.lang.Binding");
813 gbcons = gbindingc.getConstructor(Map.class);
814 gbinding = gbcons.newInstance(vbinding);
815 } catch (NoSuchMethodException x)
817 // old style binding config - using series of string/object values to
819 gbcons = gbindingc.getConstructor(null);
820 gbinding = gbcons.newInstance(null);
821 java.lang.reflect.Method setvar = gbindingc.getMethod(
822 "setVariable", bspec);
823 setvar.invoke(gbinding, binding);
826 Class gsec = cl.loadClass("groovy.util.GroovyScriptEngine");
827 Constructor gseccons = gsec.getConstructor(new Class[]
828 { URL[].class }); // String[].class });
829 Object gse = gseccons.newInstance(new Object[]
831 { sfile } }); // .toString() } });
832 java.lang.reflect.Method run = gsec.getMethod("run", new Class[]
833 { String.class, gbindingc });
834 run.invoke(gse, new Object[]
835 { sfile.toString(), gbinding });
837 } catch (Exception e)
839 System.err.println("Exception Whilst trying to execute file " + sfile
840 + " as a groovy script.");
841 e.printStackTrace(System.err);
844 if (success && groovyscript.equals("STDIN"))
846 // delete temp file that we made - but only if it was successfully
853 * Check commandline for any das server definitions or any fetchfrom switches
855 * @return vector of DAS source nicknames to retrieve from
857 private static Vector checkDasArguments(ArgsParser aparser)
859 Vector source = null;
861 String locsources = Cache.getProperty(Cache.DAS_LOCAL_SOURCE);
862 while ((data = aparser.getValue("dasserver", true)) != null)
864 String nickname = null;
866 boolean seq = false, feat = true;
867 int pos = data.indexOf('=');
868 // determine capabilities
871 nickname = data.substring(0, pos);
873 url = data.substring(pos + 1);
875 && (url.startsWith("http:") || url
876 .startsWith("sequence:http:")))
878 if (nickname == null)
882 if (locsources == null)
890 locsources = locsources + nickname + "|" + url;
892 .println("NOTE! dasserver parameter not yet really supported (got args of "
893 + nickname + "|" + url);
896 source = new Vector();
898 source.addElement(nickname);
900 } // loop until no more server entries are found.
901 if (locsources != null && locsources.indexOf('|') > -1)
903 Cache.log.debug("Setting local source list in properties file to:\n"
905 Cache.setProperty(Cache.DAS_LOCAL_SOURCE, locsources);
907 while ((data = aparser.getValue("fetchfrom", true)) != null)
909 System.out.println("adding source '" + data + "'");
912 source = new Vector();
914 source.addElement(data);
920 * start a feature fetcher for every alignment frame
924 private static FeatureFetcher startFeatureFetching(final Vector dasSources)
926 FeatureFetcher ff = new FeatureFetcher();
927 AlignFrame afs[] = Desktop.getAlignframes();
928 if (afs == null || afs.length == 0)
932 for (int i = 0; i < afs.length; i++)
934 ff.addFetcher(afs[i], dasSources);
941 * Notes: this argParser does not distinguish between parameter switches,
942 * parameter values and argument text. If an argument happens to be identical to
943 * a parameter, it will be taken as such (even though it didn't have a '-'
946 * @author Andrew Waterhouse and JBP documented.
950 class rnabuttonlistener implements ActionListener
952 public void actionPerformed(ActionEvent arg0)
954 System.out.println("Good idea ! ");
959 class pbuttonlistener implements ActionListener
961 public void actionPerformed(ActionEvent arg0)
971 public ArgsParser(String[] args)
973 vargs = new Vector();
974 for (int i = 0; i < args.length; i++)
976 String arg = args[i].trim();
977 if (arg.charAt(0) == '-')
979 arg = arg.substring(1);
981 vargs.addElement(arg);
986 * check for and remove first occurence of arg+parameter in arglist.
989 * @return return the argument following the given arg if arg was in list.
991 public String getValue(String arg)
993 return getValue(arg, false);
996 public String getValue(String arg, boolean utf8decode)
998 int index = vargs.indexOf(arg);
999 String dc = null, ret = null;
1002 ret = vargs.elementAt(index + 1).toString();
1003 vargs.removeElementAt(index);
1004 vargs.removeElementAt(index);
1005 if (utf8decode && ret != null)
1009 dc = URLDecoder.decode(ret, "UTF-8");
1011 } catch (Exception e)
1013 // TODO: log failure to decode
1021 * check for and remove first occurence of arg in arglist.
1024 * @return true if arg was present in argslist.
1026 public boolean contains(String arg)
1028 if (vargs.contains(arg))
1030 vargs.removeElement(arg);
1039 public String nextValue()
1041 return vargs.remove(0).toString();
1044 public int getSize()
1046 return vargs.size();
1052 * keep track of feature fetching tasks.
1057 class FeatureFetcher
1060 * TODO: generalise to track all jalview events to orchestrate batch
1061 * processing events.
1064 private int queued = 0;
1066 private int running = 0;
1068 public FeatureFetcher()
1073 public void addFetcher(final AlignFrame af, final Vector dasSources)
1075 final long id = System.currentTimeMillis();
1077 final FeatureFetcher us = this;
1078 new Thread(new Runnable()
1089 af.setProgressBar(MessageManager.getString("status.das_features_being_retrived"), id);
1090 af.featureSettings_actionPerformed(null);
1091 af.featureSettings.fetchDasFeatures(dasSources, true);
1092 af.setProgressBar(null, id);
1101 public synchronized boolean allFinished()
1103 return queued == 0 && running == 0;