X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalviewLite.java;h=1a2ba27e0876bf8737f3b73c0f23d8da855fec5e;hb=32ccffc95209f230faacf6f27394669c0dc8b271;hp=c9ec3918e3f65231aced553aeaf2cc9372c6ed6d;hpb=9344c308a62c48e2ddedd12247edab74e581c2e7;p=jalview.git diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index c9ec391..1a2ba27 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; @@ -73,22 +73,42 @@ public class JalviewLite extends Applet } } + param = getParameter("label"); + if(param != null) + launcher.setLabel(param); + 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); - file = applet.getCodeBase() + file; + if(file.indexOf("://")==-1) + file = getCodeBase() + file; + launcher.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { String format = jalview.io.IdentifyFile.Identify(file, "URL"); - LoadFile(file, "URL", format); - } + LoadingThread loader = new LoadingThread(file, + "URL", + format, + featuresFile, + applet); + loader.start(); + } }); } else @@ -98,6 +118,7 @@ public class JalviewLite extends Applet } } + public static void main(String [] args) { if(args.length!=1) @@ -107,61 +128,15 @@ public class JalviewLite extends Applet } String format = jalview.io.IdentifyFile.Identify(args[0],"File"); - SequenceI[] sequences = FormatAdapter.readFile(args[0], "File", format); + SequenceI[] sequences = new AppletFormatAdapter().readFile(args[0], "File", format); if ( (sequences != null) && (sequences.length > 0)) { - AlignFrame af = new AlignFrame(new Alignment(sequences), null); - addFrame(af, args[0], AlignFrame.NEW_WINDOW_WIDTH, - AlignFrame.NEW_WINDOW_HEIGHT); + AlignFrame af = new AlignFrame(new Alignment(sequences), null, args[0]); af.statusBar.setText("Successfully loaded file " + args[0]); } } - /** - * 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 @@ -189,6 +164,28 @@ 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(), seqlimits); + return reply; + } + catch (Exception ex) + {ex.printStackTrace(); + return "Error retrieving alignment in " + format + " format. "; + + } + } + /** * This paints the background surrounding the "Launch Jalview button" *
@@ -214,29 +211,35 @@ 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() { SequenceI[] sequences = null; - sequences = FormatAdapter.readFile(file, protocol, format); + sequences = new AppletFormatAdapter().readFile(file, protocol, format); if ((sequences != null) && (sequences.length > 0)) { - AlignFrame af = new AlignFrame(new Alignment(sequences), - jlapplet); - addFrame(af, file, AlignFrame.NEW_WINDOW_WIDTH, - AlignFrame.NEW_WINDOW_HEIGHT); - 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 {