From 937fb5ceb241d72ce5e829bf36a1382d6e13510c Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 27 Oct 2005 11:13:42 +0000 Subject: [PATCH] Remove static refs to applet --- src/jalview/bin/JalviewLite.java | 96 +++++++++++++++----------------------- 1 file changed, 38 insertions(+), 58 deletions(-) diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index a263ed4..8f48385 100755 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -40,17 +40,20 @@ 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"); + public static boolean AWT1 = false; + /** * init method for Jalview Applet */ public void init() { - applet = this; + String version = System.getProperty("java.version"); + if (version.indexOf("1.1") == 0) + AWT1 = true; int r = 255; int g = 255; @@ -75,13 +78,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 +101,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 +125,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 +135,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 @@ -215,15 +187,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() @@ -234,8 +211,11 @@ public class JalviewLite extends Applet if ((sequences != null) && (sequences.length > 0)) { AlignFrame af = new AlignFrame(new Alignment(sequences), - jlapplet, file); + applet, file); af.statusBar.setText("Successfully loaded file " + file); + + if(featuresFile!=null) + af.parseFeaturesFile(featuresFile); } else { -- 1.7.10.2