Takes AlignFrame as arg, to update progressbar
[jalview.git] / src / jalview / bin / JalviewLite.java
index 858c391..a0c7c2d 100755 (executable)
@@ -28,7 +28,6 @@ import java.applet.*;
 \r
 import java.awt.*;\r
 import java.awt.event.*;\r
-import jalview.appletgui.TreePanel;\r
 \r
 \r
 /**\r
@@ -94,9 +93,7 @@ public class JalviewLite extends Applet
            && getParameter("embedded").equalsIgnoreCase("true"))\r
         {\r
           embedded = true;\r
-          LoadingThread loader = new LoadingThread(file,\r
-                            AppletFormatAdapter.URL,\r
-                            applet);\r
+          LoadingThread loader = new LoadingThread(file, applet);\r
           loader.start();\r
         }\r
         else if (file != null)\r
@@ -108,7 +105,6 @@ public class JalviewLite extends Applet
                     public void actionPerformed(ActionEvent e)\r
                     {\r
                         LoadingThread loader = new LoadingThread(file,\r
-                            AppletFormatAdapter.URL,\r
                             applet);\r
                         loader.start();\r
                       }\r
@@ -141,7 +137,7 @@ public class JalviewLite extends Applet
      }\r
       if ( (sequences != null) && (sequences.length > 0))\r
       {\r
-        AlignFrame af = new AlignFrame(new Alignment(sequences), null, args[0]);\r
+        AlignFrame af = new AlignFrame(new Alignment(sequences), null, args[0], false);\r
         af.statusBar.setText("Successfully loaded file " + args[0]);\r
       }\r
     }\r
@@ -262,15 +258,16 @@ public class JalviewLite extends Applet
         JalviewLite applet;\r
 \r
         public LoadingThread(String _file,\r
-                             String _protocol,\r
                              JalviewLite _applet)\r
         {\r
             file = _file;\r
             if(inArchive(file))\r
               protocol = AppletFormatAdapter.CLASSLOADER;\r
             else\r
-              protocol = _protocol;\r
-\r
+            {\r
+              file = addProtocol(file);\r
+              protocol = AppletFormatAdapter.URL;\r
+            }\r
             format = new jalview.io.IdentifyFile().Identify(file, protocol);\r
             applet = _applet;\r
         }\r
@@ -288,12 +285,12 @@ public class JalviewLite extends Applet
             if ((sequences != null) && (sequences.length > 0))\r
             {\r
               currentAlignFrame = new AlignFrame(new Alignment(sequences),\r
-                                                 applet, file);\r
+                                                 applet,\r
+                                                 file,\r
+                                                 embedded);\r
 \r
-              initialAlignFrame = currentAlignFrame;\r
 \r
-              if (embedded)\r
-                currentAlignFrame.setEmbedded();\r
+              initialAlignFrame = currentAlignFrame;\r
 \r
               currentAlignFrame.statusBar.setText("Successfully loaded file " + file);\r
 \r
@@ -317,12 +314,7 @@ public class JalviewLite extends Applet
 \r
                     if (fin.getTree() != null)\r
                     {\r
-                      TreePanel tp = null;\r
-                      tp = new TreePanel(currentAlignFrame.viewport,\r
-                                         currentAlignFrame.viewport.getAlignment().getSequences(),\r
-                                         fin, "FromFile", treeFile);\r
-                      addFrame(tp, treeFile, 600, 500);\r
-                      currentAlignFrame.addTreeMenuItem(tp, treeFile);\r
+                      currentAlignFrame.loadTree(fin, treeFile);\r
                     }\r
                   }\r
                   catch (Exception ex)\r
@@ -340,17 +332,50 @@ public class JalviewLite extends Applet
                 currentAlignFrame.parseFeaturesFile(param);\r
               }\r
 \r
+              param = getParameter("showFeatureSettings");\r
+              if(param !=null && param.equalsIgnoreCase("true"))\r
+              {\r
+                currentAlignFrame.featureSettings_actionPerformed();\r
+              }\r
+\r
              param = getParameter("annotations");\r
              if (param != null)\r
              {\r
                if( !inArchive(param) )\r
                   param = addProtocol( param );\r
 \r
-               new AnnotationReader().readAnnotationFile(\r
+               new AnnotationFile().readAnnotationFile(\r
                    currentAlignFrame.viewport.getAlignment(),\r
                    param);\r
 \r
                currentAlignFrame.alignPanel.fontChanged();\r
+               currentAlignFrame.alignPanel.setScrollValues(0,0);\r
+\r
+             }\r
+\r
+             param = getParameter("jnetfile");\r
+             if (param != null)\r
+             {\r
+               try\r
+               {\r
+                 if (inArchive(param))\r
+                   protocol = AppletFormatAdapter.CLASSLOADER;\r
+                 else\r
+                 {\r
+                   protocol = AppletFormatAdapter.URL;\r
+                   param = addProtocol(param);\r
+                 }\r
+\r
+                 jalview.io.JPredFile predictions = new jalview.io.JPredFile(\r
+                     param, protocol);\r
+                 new JnetAnnotationMaker().add_annotation(predictions,\r
+                     currentAlignFrame.viewport.getAlignment(),\r
+                     0,false); // do not add sequence profile from concise output\r
+                 currentAlignFrame.alignPanel.fontChanged();\r
+                 currentAlignFrame.alignPanel.setScrollValues(0, 0);\r
+               } catch (Exception ex) {\r
+                 ex.printStackTrace();\r
+               }\r
              }\r
 \r
 \r
@@ -391,7 +416,15 @@ public class JalviewLite extends Applet
          */\r
         boolean inArchive(String file)\r
         {\r
-          return ( getClass().getResourceAsStream("/" + file) != null );\r
+          //This might throw a security exception in certain browsers\r
+          //Netscape Communicator for instance.\r
+          try{\r
+            return (getClass().getResourceAsStream("/" + file) != null);\r
+          }catch(Exception ex)\r
+          {\r
+            System.out.println("Exception checking resources: "+file+" "+ex);\r
+            return false;\r
+          }\r
         }\r
 \r
         String addProtocol(String file)\r