X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalviewLite.java;h=7057e3c01afaa2edd7e0c9d614f72bb1f4da11ad;hb=4232f0a5699af84c5361e6cea446a97e7bcc788e;hp=a263ed45b834df90e516a4b1b3b06b5c2854bee1;hpb=783520af519c958e10a2af29f1d4242e1ab890a3;p=jalview.git diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index a263ed4..7057e3c 100755 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -40,18 +40,18 @@ public class JalviewLite extends Applet { static int lastFrameX = 200; static int lastFrameY = 200; - static Applet applet; boolean fileFound = true; String file = "No file"; Button launcher = new Button("Start Jalview"); + AlignFrame currentAlignFrame; + + /** * init method for Jalview Applet */ public void init() { - applet = this; - int r = 255; int g = 255; int b = 255; @@ -75,13 +75,22 @@ public class JalviewLite extends Applet this.setBackground(new Color(r, g, b)); - file = getParameter("file"); + param = getParameter("features"); + if(param!=null) + { + if(param.indexOf("://")==-1) + param = getCodeBase() + param; + } + final String featuresFile = param; + + file = getParameter("file"); + final JalviewLite applet = this; if (file != null) { add(launcher); - if(!file.startsWith("http://") && !file.startsWith("file://")) - file = applet.getCodeBase() + file; + if(file.indexOf("://")==-1) + file = getCodeBase() + file; launcher.addActionListener(new java.awt.event.ActionListener() { @@ -89,8 +98,13 @@ public class JalviewLite extends Applet { String format = jalview.io.IdentifyFile.Identify(file, "URL"); - LoadFile(file, "URL", format); - } + LoadingThread loader = new LoadingThread(file, + "URL", + format, + featuresFile, + applet); + loader.start(); + } }); } else @@ -108,7 +122,6 @@ public class JalviewLite extends Applet System.exit(1); } - String format = jalview.io.IdentifyFile.Identify(args[0],"File"); SequenceI[] sequences = new AppletFormatAdapter().readFile(args[0], "File", format); @@ -119,50 +132,6 @@ public class JalviewLite extends Applet } } - /** - * Displays the given URL in a new browser window - * - * @param url URL to display in browser window. - *
New window will be named "HELP_WINDOW" - */ - public static void showURL(String url) - { - showURL(url, "HELP"); - } - - public static void showURL(String url, String target) - { - if(applet==null) - { - System.out.println("Not running as applet - no browser available."); - } - else - { - try - { - applet.getAppletContext().showDocument(new java.net.URL(url), - target); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - } - - - /** - * Starts a new LoadingThread for loading an alignment file - * - * @param file file name including full path to file - * @param protocol file or URL or paste - * @param format Fasta, Clustal, PFAM, MSF, PIR, BLC, Jalview - */ - public void LoadFile(String file, String protocol, String format) - { - LoadingThread loader = new LoadingThread(file, protocol, format, this); - loader.start(); - } /** * Initialises and displays a new java.awt.Frame @@ -190,6 +159,29 @@ public class JalviewLite extends Applet frame.setVisible(true); } + public String getAlignment(String format) + { + return getAlignment(format, "true"); + } + + public String getAlignment(String format, String suffix) + { + try + { + boolean seqlimits = suffix.equalsIgnoreCase("true"); + + String reply = new AppletFormatAdapter().formatSequences(format, + currentAlignFrame.viewport.getAlignment().getSequences(), + true, seqlimits); + return reply; + } + catch (Exception ex) + {ex.printStackTrace(); + return "Error retrieving alignment in " + format + " format. "; + + } + } + /** * This paints the background surrounding the "Launch Jalview button" *
@@ -215,15 +207,20 @@ public class JalviewLite extends Applet String file; String protocol; String format; - JalviewLite jlapplet; - - public LoadingThread(String file, String protocol, String format, - JalviewLite applet) + String featuresFile; + JalviewLite applet; + + public LoadingThread(String file, + String protocol, + String format, + String features, + JalviewLite applet) { this.file = file; this.protocol = protocol; this.format = format; - this.jlapplet = applet; + featuresFile = features; + this.applet = applet; } public void run() @@ -233,9 +230,12 @@ public class JalviewLite extends Applet if ((sequences != null) && (sequences.length > 0)) { - AlignFrame af = new AlignFrame(new Alignment(sequences), - jlapplet, file); - af.statusBar.setText("Successfully loaded file " + file); + currentAlignFrame = new AlignFrame(new Alignment(sequences), + applet, file); + currentAlignFrame.statusBar.setText("Successfully loaded file " + file); + + if(featuresFile!=null) + currentAlignFrame.parseFeaturesFile(featuresFile); } else {