X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalviewLite.java;h=081efa66b3b39840e796e0aff4864823efa7d6e7;hb=76b6b31c53b099a3034e0622ec78d4c2b455a309;hp=858c391371a1ff9f65b53925898e0c887e01fb97;hpb=366b11bb8e79ff5bb1a9e6c50b648c3d4101862c;p=jalview.git diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index 858c391..081efa6 100755 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -28,7 +28,6 @@ import java.applet.*; import java.awt.*; import java.awt.event.*; -import jalview.appletgui.TreePanel; /** @@ -89,14 +88,26 @@ public class JalviewLite extends Applet file = getParameter("file"); + if(file==null) + { + //Maybe the sequences are added as parameters + StringBuffer data = new StringBuffer("PASTE"); + int i=1; + while( (file=getParameter("sequence"+i))!=null) + { + data.append(file.toString()+"\n"); + i++; + } + if(data.length()>5) + file = data.toString(); + } + final JalviewLite applet = this; if(getParameter("embedded")!=null && getParameter("embedded").equalsIgnoreCase("true")) { embedded = true; - LoadingThread loader = new LoadingThread(file, - AppletFormatAdapter.URL, - applet); + LoadingThread loader = new LoadingThread(file, applet); loader.start(); } else if (file != null) @@ -108,7 +119,6 @@ public class JalviewLite extends Applet public void actionPerformed(ActionEvent e) { LoadingThread loader = new LoadingThread(file, - AppletFormatAdapter.URL, applet); loader.start(); } @@ -141,7 +151,7 @@ public class JalviewLite extends Applet } if ( (sequences != null) && (sequences.length > 0)) { - AlignFrame af = new AlignFrame(new Alignment(sequences), null, args[0]); + AlignFrame af = new AlignFrame(new Alignment(sequences), null, args[0], false); af.statusBar.setText("Successfully loaded file " + args[0]); } } @@ -262,15 +272,21 @@ public class JalviewLite extends Applet JalviewLite applet; public LoadingThread(String _file, - String _protocol, JalviewLite _applet) { file = _file; - if(inArchive(file)) + if(file.startsWith("PASTE")) + { + file = file.substring(5); + protocol = AppletFormatAdapter.PASTE; + } + else if(inArchive(file)) protocol = AppletFormatAdapter.CLASSLOADER; else - protocol = _protocol; - + { + file = addProtocol(file); + protocol = AppletFormatAdapter.URL; + } format = new jalview.io.IdentifyFile().Identify(file, protocol); applet = _applet; } @@ -288,17 +304,21 @@ public class JalviewLite extends Applet if ((sequences != null) && (sequences.length > 0)) { currentAlignFrame = new AlignFrame(new Alignment(sequences), - applet, file); + applet, + file, + embedded); - initialAlignFrame = currentAlignFrame; + if(protocol==jalview.io.AppletFormatAdapter.PASTE) + currentAlignFrame.setTitle("Sequences from "+getDocumentBase()); - if (embedded) - currentAlignFrame.setEmbedded(); + initialAlignFrame = currentAlignFrame; currentAlignFrame.statusBar.setText("Successfully loaded file " + file); - String treeFile = applet.getParameter("treeFile"); + String treeFile = applet.getParameter("tree"); + if(treeFile==null) + applet.getParameter("treeFile"); if (treeFile != null) { try @@ -317,12 +337,7 @@ public class JalviewLite extends Applet if (fin.getTree() != null) { - TreePanel tp = null; - tp = new TreePanel(currentAlignFrame.viewport, - currentAlignFrame.viewport.getAlignment().getSequences(), - fin, "FromFile", treeFile); - addFrame(tp, treeFile, 600, 500); - currentAlignFrame.addTreeMenuItem(tp, treeFile); + currentAlignFrame.loadTree(fin, treeFile); } } catch (Exception ex) @@ -337,7 +352,14 @@ public class JalviewLite extends Applet if( !inArchive(param) ) param = addProtocol( param ); - currentAlignFrame.parseFeaturesFile(param); + currentAlignFrame.parseFeaturesFile(param, protocol); + } + + param = getParameter("showFeatureSettings"); + if(param !=null && param.equalsIgnoreCase("true")) + { + currentAlignFrame.viewport.showSequenceFeatures(true); + currentAlignFrame.featureSettings_actionPerformed(); } param = getParameter("annotations"); @@ -346,11 +368,38 @@ public class JalviewLite extends Applet if( !inArchive(param) ) param = addProtocol( param ); - new AnnotationReader().readAnnotationFile( + new AnnotationFile().readAnnotationFile( currentAlignFrame.viewport.getAlignment(), param); currentAlignFrame.alignPanel.fontChanged(); + currentAlignFrame.alignPanel.setScrollValues(0,0); + + } + + param = getParameter("jnetfile"); + if (param != null) + { + try + { + if (inArchive(param)) + protocol = AppletFormatAdapter.CLASSLOADER; + else + { + protocol = AppletFormatAdapter.URL; + param = addProtocol(param); + } + + jalview.io.JPredFile predictions = new jalview.io.JPredFile( + param, protocol); + new JnetAnnotationMaker().add_annotation(predictions, + currentAlignFrame.viewport.getAlignment(), + 0,false); // do not add sequence profile from concise output + currentAlignFrame.alignPanel.fontChanged(); + currentAlignFrame.alignPanel.setScrollValues(0, 0); + } catch (Exception ex) { + ex.printStackTrace(); + } } @@ -391,7 +440,15 @@ public class JalviewLite extends Applet */ boolean inArchive(String file) { - return ( getClass().getResourceAsStream("/" + file) != null ); + //This might throw a security exception in certain browsers + //Netscape Communicator for instance. + try{ + return (getClass().getResourceAsStream("/" + file) != null); + }catch(Exception ex) + { + System.out.println("Exception checking resources: "+file+" "+ex); + return false; + } } String addProtocol(String file)