import java.util.StringTokenizer;
import java.util.Vector;
+import javax.swing.SwingUtilities;
import org.jmol.adapter.smarter.SmarterJmolAdapter;
import org.jmol.api.JmolAppConsoleInterface;
import org.jmol.api.JmolSelectionListener;
import org.jmol.c.CBK;
import org.jmol.viewer.Viewer;
+import jalview.api.AlignmentViewPanel;
import jalview.api.FeatureRenderer;
-import jalview.bin.Cache;
+import jalview.api.FeatureSettingsModelI;
+import jalview.api.SequenceRenderer;
+import jalview.bin.Console;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
+import jalview.gui.AppJmol;
import jalview.gui.IProgressIndicator;
import jalview.gui.StructureViewer.ViewerType;
import jalview.io.DataSourceType;
import jalview.structure.StructureCommandI;
import jalview.structure.StructureSelectionManager;
import jalview.structures.models.AAStructureBindingModel;
-
+import jalview.ws.dbsources.Pdb;
+import javajs.util.BS;
public abstract class JalviewJmolBinding extends AAStructureBindingModel
implements JmolStatusListener, JmolSelectionListener,
ComponentListener
{
private String lastMessage;
+
/*
* when true, try to search the associated datamodel for sequences that are
* associated with any unknown structures in the Jmol view.
setStructureCommands(new JmolCommands());
/*
* viewer = JmolViewer.allocateViewer(renderPanel, new SmarterJmolAdapter(),
- * "jalviewJmol", ap.av.applet .getDocumentBase(),
- * ap.av.applet.getCodeBase(), "", this);
+ * "jalviewJmol", ap.av.applet .getDocumentBase(), ap.av.applet.getCodeBase(),
+ * "", this);
*
* jmolpopup = JmolPopup.newJmolPopup(viewer, true, "Jmol", true);
*/
private String jmolScript(String script)
{
- Cache.log.debug(">>Jmol>> " + script);
- String s = jmolViewer.scriptWait(script);
- Cache.log.debug("<<Jmol<< " + s);
+ Console.debug(">>Jmol>> " + script);
+ String s = jmolViewer.evalStringQuiet(script); // scriptWait(script); BH
+ Console.debug("<<Jmol<< " + s);
return s;
}
{
return null;
}
+
String cmd = command.getCommand();
jmolHistory(false);
if (lastCommand == null || !lastCommand.equals(cmd))
return null;
}
+
/**
* map between index of model filename returned from getPdbFile and the first
* index of models from this file in the viewer. Note - this is not trimmed -
for (int i = 0; i < modelCount; ++i)
{
/*
- * defensive check for null as getModelFileName can return null
- * even when model count ms.mc is > 0
+ * defensive check for null as getModelFileName can return null even when model
+ * count ms.mc is > 0
*/
filePath = jmolViewer.ms.getModelFileName(i);
if (filePath != null && !mset.contains(filePath))
jmolScript(cmd.toString());
jmolHistory(true);
+
}
private boolean debug = true;
}
/*
- * highlight position on alignment(s); if some text is returned,
- * show this as a second line on the structure hover tooltip
+ * highlight position on alignment(s); if some text is returned, show this as a
+ * second line on the structure hover tooltip
*/
String label = getSsm().mouseOverStructure(pdbResNum, chainId,
pdbfilename);
/*
* { if (history != null && strStatus != null &&
- * !strStatus.equals("Script completed")) { history.append("\n" + strStatus);
- * } }
+ * !strStatus.equals("Script completed")) { history.append("\n" + strStatus); }
+ * }
*/
public void notifyAtomPicked(int atomIndex, String strInfo,
@Override
public void notifyCallback(CBK type, Object[] data)
{
+ /*
+ * ensure processed in AWT thread to avoid risk of deadlocks
+ */
+ SwingUtilities.invokeLater(new Runnable()
+ {
+
+ @Override
+ public void run()
+ {
+ processCallback(type, data);
+ }
+ });
+ }
+
+ /**
+ * Processes one callback notification from Jmol
+ *
+ * @param type
+ * @param data
+ */
+ protected void processCallback(CBK type, Object[] data)
+ {
try
{
switch (type)
modelFileNames = null;
boolean notifyLoaded = false;
String[] modelfilenames = getStructureFiles();
+ if (modelfilenames == null)
+ {
+ // Jmol is still loading files!
+ return;
+ }
// first check if we've lost any structures
if (oldmodels != null && oldmodels.length > 0)
{
FeatureRenderer fr = getFeatureRenderer(null);
if (fr != null)
{
- fr.featuresAdded();
+ FeatureSettingsModelI colours = new Pdb().getFeatureColourScheme();
+ ((AppJmol) getViewer()).getAlignmentPanel().av
+ .applyFeaturesStyle(colours);
}
refreshGUI();
loadNotifiesHandled++;
setLoadingFromArchive(false);
}
+
protected IProgressIndicator getIProgressIndicator()
{
return null;
public abstract void sendConsoleEcho(String strEcho); /*
* { showConsole(true);
*
- * history.append("\n" +
- * strEcho); }
+ * history.append("\n" + strEcho); }
*/
// /End JmolStatusListener
}
+
public void showHelp()
{
showUrl("http://wiki.jmol.org"
{
return ".spt";
}
+
+ @Override
+ public void selectionChanged(BS arg0)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public SequenceRenderer getSequenceRenderer(AlignmentViewPanel avp)
+ {
+ return new jalview.gui.SequenceRenderer(avp.getAlignViewport());
+ }
+
+ @Override
+ public String getHelpURL()
+ {
+ return "http://wiki.jmol.org"; // BH 2018
+ }
}