X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalview.java;h=e98ea638a5b8d0cc0844d8beca81dcd1612c6d79;hb=564c47bdd60cf84046269e45d2f85f39408e4441;hp=50e3559272b0c3054c979567f18a092288608304;hpb=55356b1071b5352edd68ce25a5d3dc3c60dcdc2d;p=jalview.git
diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java
index 50e3559..e98ea63 100755
--- a/src/jalview/bin/Jalview.java
+++ b/src/jalview/bin/Jalview.java
@@ -1,6 +1,6 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
@@ -20,64 +20,234 @@
*/
package jalview.bin;
-import jalview.gui.AlignFrame;
-import jalview.gui.Desktop;
-import jalview.io.HtmlSvgOutput;
-import jalview.util.MessageManager;
-import jalview.util.Platform;
-import jalview.ws.jws2.Jws2Discoverer;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
-import java.lang.reflect.Constructor;
import java.net.MalformedURLException;
import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
-import java.net.URLDecoder;
import java.security.AllPermission;
import java.security.CodeSource;
import java.security.PermissionCollection;
import java.security.Permissions;
import java.security.Policy;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import java.util.Vector;
+import javax.swing.LookAndFeel;
import javax.swing.UIManager;
+import com.threerings.getdown.util.LaunchUtil;
+
+import groovy.lang.Binding;
+import groovy.util.GroovyScriptEngine;
+import jalview.api.AlignCalcWorkerI;
+import jalview.api.AlignViewportI;
+import jalview.api.JalviewApp;
+import jalview.api.StructureSelectionManagerProvider;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.ext.so.SequenceOntology;
+import jalview.gui.AlignFrame;
+import jalview.gui.AlignViewport;
+import jalview.gui.AlignmentPanel;
+import jalview.gui.CalculationChooser;
+import jalview.gui.Desktop;
+import jalview.gui.Preferences;
+import jalview.gui.PromptUserConfig;
+import jalview.gui.StructureViewer;
+import jalview.io.AppletFormatAdapter;
+import jalview.io.BioJsHTMLOutput;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatException;
+import jalview.io.FileFormatI;
+import jalview.io.FileFormats;
+import jalview.io.FileLoader;
+import jalview.io.HtmlSvgOutput;
+import jalview.io.IdentifyFile;
+import jalview.io.NewickFile;
+import jalview.io.gff.SequenceOntologyFactory;
+import jalview.javascript.JSFunctionExec;
+import jalview.javascript.MouseOverStructureListener;
+import jalview.renderer.seqfeatures.FeatureRenderer;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.ColourSchemeProperty;
+import jalview.structure.SelectionSource;
+import jalview.structure.VamsasSource;
+import jalview.util.MessageManager;
+import jalview.util.Platform;
+import jalview.ws.jws2.Jws2Discoverer;
+import netscape.javascript.JSObject;
+
/**
* Main class for Jalview Application
*
- * start with java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview
+ * start with: java -classpath "$PATH_TO_LIB$/*:$PATH_TO_CLASSES$" \
+ * jalview.bin.Jalview
+ *
+ * or on Windows: java -classpath "$PATH_TO_LIB$/*;$PATH_TO_CLASSES$" \
+ * jalview.bin.Jalview jalview.bin.Jalview
+ *
+ * (ensure -classpath arg is quoted to avoid shell expansion of '*' and do not
+ * embellish '*' to e.g. '*.jar')
*
* @author $author$
* @version $Revision$
*/
-public class Jalview
+public class Jalview implements JalviewJSApi
{
static
{
- // grab all the rights we can the JVM
- Policy.setPolicy(new Policy()
+ Platform.getURLCommandArguments();
+ }
+
+ private boolean headless;
+
+ // singleton instance of this class
+
+ private static Jalview instance;
+
+ private Desktop desktop;
+
+ public static AlignFrame currentAlignFrame;
+
+ public boolean isJavaAppletTag;
+
+ public String appletResourcePath;
+
+ JalviewAppLoader appLoader;
+
+ protected JSFunctionExec jsFunctionExec;
+
+ private boolean noCalculation, noMenuBar, noStatus;
+
+ private boolean noAnnotation;
+
+ public boolean getStartCalculations()
+ {
+ return !noCalculation;
+ }
+
+ public boolean getAllowMenuBar()
+ {
+ return !noMenuBar;
+ }
+
+ public boolean getShowStatus()
+ {
+ return !noStatus;
+ }
+
+ public boolean getShowAnnotation()
+ {
+ return !noAnnotation;
+ }
+
+ static
+ {
+ if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
{
- public PermissionCollection getPermissions(CodeSource codesource)
+ // grab all the rights we can for the JVM
+ Policy.setPolicy(new Policy()
{
- Permissions perms = new Permissions();
- perms.add(new AllPermission());
- return (perms);
- }
+ @Override
+ public PermissionCollection getPermissions(CodeSource codesource)
+ {
+ Permissions perms = new Permissions();
+ perms.add(new AllPermission());
+ return (perms);
+ }
+
+ @Override
+ public void refresh()
+ {
+ }
+ });
+ }
+ }
+
+ /**
+ * keep track of feature fetching tasks.
+ *
+ * @author JimP
+ *
+ */
+ class FeatureFetcher
+ {
+ /*
+ * TODO: generalise to track all jalview events to orchestrate batch processing
+ * events.
+ */
+
+ private int queued = 0;
+
+ private int running = 0;
+
+ public FeatureFetcher()
+ {
- public void refresh()
+ }
+
+ public void addFetcher(final AlignFrame af,
+ final Vector dasSources)
+ {
+ final long id = System.currentTimeMillis();
+ queued++;
+ final FeatureFetcher us = this;
+ new Thread(new Runnable()
{
- }
- });
+
+ @Override
+ public void run()
+ {
+ synchronized (us)
+ {
+ queued--;
+ running++;
+ }
+
+ af.setProgressBar(MessageManager
+ .getString("status.das_features_being_retrived"), id);
+ af.featureSettings_actionPerformed(null);
+ af.setProgressBar(null, id);
+ synchronized (us)
+ {
+ running--;
+ }
+ }
+ }).start();
+ }
+
+ public synchronized boolean allFinished()
+ {
+ return queued == 0 && running == 0;
+ }
+
+ }
+
+ public static Jalview getInstance()
+ {
+ return instance;
}
+
+
+ private final static boolean doPlatformLogging = false;
/**
* main class for Jalview application
@@ -87,49 +257,122 @@ public class Jalview
*/
public static void main(String[] args)
{
- System.out.println("Java version: "
- + System.getProperty("java.version"));
+ if (doPlatformLogging)
+ {
+ Platform.startJavaLogging();
+ }
+
+ instance = new Jalview();
+ instance.doMain(args);
+ }
+
+ /**
+ * @param args
+ */
+ void doMain(String[] args)
+ {
+
+ boolean isJS = Platform.isJS();
+ if (isJS)
+ {
+ Platform.setAppClass(this);
+ }
+ else
+ {
+ System.setSecurityManager(null);
+ }
+
+ System.out
+ .println("Java version: " + System.getProperty("java.version"));
+ System.out.println("Java Home: " + System.getProperty("java.home"));
System.out.println(System.getProperty("os.arch") + " "
+ System.getProperty("os.name") + " "
+ System.getProperty("os.version"));
- if (new Platform().isAMac())
+ String val = System.getProperty("sys.install4jVersion");
+ if (val != null)
+ {
+ System.out.println("Install4j version: " + val);
+ }
+ val = System.getProperty("installer_template_version");
+ if (val != null)
+ {
+ System.out.println("Install4j template version: " + val);
+ }
+ val = System.getProperty("launcher_version");
+ if (val != null)
{
- System.setProperty("com.apple.mrj.application.apple.menu.about.name",
- "Jalview");
- System.setProperty("apple.laf.useScreenMenuBar", "true");
+ System.out.println("Launcher version: " + val);
}
+ // report Jalview version
+ Cache.loadBuildProperties(true);
+
ArgsParser aparser = new ArgsParser(args);
- boolean headless = false;
+ headless = false;
+
+ String usrPropsFile = aparser.getValue("props");
+
+ Cache.loadProperties(usrPropsFile); // must do this before
- if (aparser.contains("help") || aparser.contains("h"))
+ if (isJS)
{
- showUsage();
- System.exit(0);
+ isJavaAppletTag = aparser.isApplet();
+ if (isJavaAppletTag)
+ {
+ Preferences.setAppletDefaults();
+ Cache.loadProperties(usrPropsFile); // again, because we
+ // might be changing defaults here?
+ }
+ System.out.println(
+ "