X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fbin%2FJalviewLite.java;h=7057e3c01afaa2edd7e0c9d614f72bb1f4da11ad;hb=4232f0a5699af84c5361e6cea446a97e7bcc788e;hp=b99d642ecc6128158bb6e57445f53696f5ed6319;hpb=ac233160f70bacfd484e371af9433a7ed226ceb4;p=jalview.git
diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java
index b99d642..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,20 +75,36 @@ 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);
- 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,44 +114,25 @@ 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)
+ public static void main(String [] args)
{
- showURL(url, "HELP");
- }
-
- public static void showURL(String url, String target)
+ if(args.length!=1)
{
- try
- {
- applet.getAppletContext().showDocument(new java.net.URL(url),
- target);
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
+ System.out.println("\nUsage: java -jar jalviewApplet.jar fileName\n");
+ System.exit(1);
}
+ String format = jalview.io.IdentifyFile.Identify(args[0],"File");
+ SequenceI[] sequences = new AppletFormatAdapter().readFile(args[0], "File", format);
- /**
- * 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();
+ if ( (sequences != null) && (sequences.length > 0))
+ {
+ AlignFrame af = new AlignFrame(new Alignment(sequences), null, args[0]);
+ af.statusBar.setText("Successfully loaded file " + args[0]);
+ }
}
+
/**
* Initialises and displays a new java.awt.Frame
*
@@ -162,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"
*
@@ -187,29 +207,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
{