/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
- * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
+ * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
public AlignFrame loadAlignment(String text, String title)
{
Alignment al = null;
+
String format = new IdentifyFile().Identify(text,
AppletFormatAdapter.PASTE);
try
boolean embedded = false;
private boolean checkForJmol = true;
+ private boolean checkedForJmol = false; // ensure we don't check for jmol every time the app is re-inited
public boolean jmolAvailable = false;
}
}
- LoadJmolThread jmolAvailable = new LoadJmolThread();
- jmolAvailable.start();
-
final JalviewLite applet = this;
if (getParameter("embedded") != null
&& getParameter("embedded").equalsIgnoreCase("true"))
class LoadJmolThread extends Thread
{
+ private boolean running=false;
+
public void run()
{
+ if (running || checkedForJmol) {
+ return;
+ }
+ running=true;
if (checkForJmol)
{
try
.println("Skipping Jmol check. Will use MCView (probably)");
}
}
+ checkedForJmol=true;
+ running=false;
+ }
+
+ public boolean notFinished()
+ {
+ return running || !checkedForJmol;
}
}
* State variable: format of file source
*/
String format;
-
+ String _file;
JalviewLite applet;
-
private void dbgMsg(String msg)
{
if (applet.debug)
dbgMsg("Protocol identified as '" + protocol + "'");
return file;
}
-
+
public LoadingThread(String _file, JalviewLite _applet)
{
- dbgMsg("Loading thread started with:\n>>file\n" + _file + ">>endfile");
- file = setProtocolState(_file);
-
- format = new jalview.io.IdentifyFile().Identify(file, protocol);
- dbgMsg("File identified as '" + format + "'");
+ this._file=_file;
applet = _applet;
}
public void run()
{
+ LoadJmolThread jmolchecker = new LoadJmolThread();
+ jmolchecker.start();
+ while (jmolchecker.notFinished())
+ {
+ // wait around until the Jmol check is complete.
+ try { Thread.sleep(2); } catch (Exception e) {};
+ }
startLoading();
}
private void startLoading()
{
+ AlignFrame newAlignFrame;
+ dbgMsg("Loading thread started with:\n>>file\n" + _file + ">>endfile");
+ file = setProtocolState(_file);
+
+ format = new jalview.io.IdentifyFile().Identify(file, protocol);
+ dbgMsg("File identified as '" + format + "'");
dbgMsg("Loading started.");
Alignment al = null;
try
if ((al != null) && (al.getHeight() > 0))
{
dbgMsg("Successfully loaded file.");
- initialAlignFrame = new AlignFrame(al, applet, file, embedded);
+ newAlignFrame = new AlignFrame(al, applet, file, embedded);
+ if (initialAlignFrame==null)
+ {
+ initialAlignFrame = newAlignFrame;
+ }
// update the focus.
- currentAlignFrame = initialAlignFrame;
+ currentAlignFrame = newAlignFrame;
if (protocol == jalview.io.AppletFormatAdapter.PASTE)
{
- currentAlignFrame.setTitle("Sequences from " + getDocumentBase());
+ newAlignFrame.setTitle("Sequences from " + getDocumentBase());
}
- currentAlignFrame.statusBar.setText("Successfully loaded file "
+ newAlignFrame.statusBar.setText("Successfully loaded file "
+ file);
String treeFile = applet.getParameter("tree");
if (fin.getTree() != null)
{
- currentAlignFrame.loadTree(fin, treeFile);
+ newAlignFrame.loadTree(fin, treeFile);
dbgMsg("Successfuly imported tree.");
}
else
{
param = setProtocolState(param);
- currentAlignFrame.parseFeaturesFile(param, protocol);
+ newAlignFrame.parseFeaturesFile(param, protocol);
}
param = getParameter("showFeatureSettings");
if (param != null && param.equalsIgnoreCase("true"))
{
- currentAlignFrame.viewport.showSequenceFeatures(true);
- new FeatureSettings(currentAlignFrame.alignPanel);
+ newAlignFrame.viewport.showSequenceFeatures(true);
+ new FeatureSettings(newAlignFrame.alignPanel);
}
param = getParameter("annotations");
param = setProtocolState(param);
if (new AnnotationFile().readAnnotationFile(
- currentAlignFrame.viewport.getAlignment(), param,
+ newAlignFrame.viewport.getAlignment(), param,
protocol))
{
- currentAlignFrame.alignPanel.fontChanged();
- currentAlignFrame.alignPanel.setScrollValues(0, 0);
+ newAlignFrame.alignPanel.fontChanged();
+ newAlignFrame.alignPanel.setScrollValues(0, 0);
}
else
{
jalview.io.JPredFile predictions = new jalview.io.JPredFile(
param, protocol);
JnetAnnotationMaker.add_annotation(predictions,
- currentAlignFrame.viewport.getAlignment(), 0, false); // false==do
+ newAlignFrame.viewport.getAlignment(), 0, false); // false==do
// not
// add
// sequence
// from
// concise
// output
- currentAlignFrame.alignPanel.fontChanged();
- currentAlignFrame.alignPanel.setScrollValues(0, 0);
+ newAlignFrame.alignPanel.fontChanged();
+ newAlignFrame.alignPanel.setScrollValues(0, 0);
} catch (Exception ex)
{
ex.printStackTrace();
String sequence = applet.getParameter("PDBSEQ");
if (sequence != null)
seqs = new SequenceI[]
- { (Sequence) currentAlignFrame.getAlignViewport()
+ { (Sequence) newAlignFrame.getAlignViewport()
.getAlignment().findName(sequence) };
}
tmp2.addElement(st2.nextToken());
seqstring = st2.nextToken();
}
- tmp.addElement((Sequence) currentAlignFrame
+ tmp.addElement((Sequence) newAlignFrame
.getAlignViewport().getAlignment().findName(
seqstring));
}
if (jmolAvailable)
{
new jalview.appletgui.AppletJmol(pdb, seqs, chains,
- currentAlignFrame.alignPanel, protocol);
+ newAlignFrame.alignPanel, protocol);
lastFrameX += 40;
lastFrameY += 40;
}
else
new MCview.AppletPDBViewer(pdb, seqs, chains,
- currentAlignFrame.alignPanel, protocol);
+ newAlignFrame.alignPanel, protocol);
}
}
param = getParameter("hidefeaturegroups");
if (param != null)
{
- applet.setFeatureGroupState(param, false);
+ applet.setFeatureGroupStateOn(newAlignFrame,param, false);
}
// show specific groups
param = getParameter("showfeaturegroups");
if (param != null)
{
- applet.setFeatureGroupState(param, true);
+ applet.setFeatureGroupStateOn(newAlignFrame,param, true);
}
}
else