X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fjmol%2FJalviewJmolBinding.java;h=903d9b7c53faed57f0b58f2490c44f61758de5d2;hb=931c66e5efd8c066326b6db713b4db498657ebe6;hp=54eb59975166a034d435e48395e109489a243be7;hpb=4f30214e8098748469c6a4269ac2ed6c5750e4b0;p=jalview.git diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index 54eb599..903d9b7 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -31,6 +31,8 @@ import java.util.Map; 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; @@ -39,10 +41,14 @@ import org.jmol.api.JmolViewer; import org.jmol.c.CBK; import org.jmol.viewer.Viewer; +import jalview.api.AlignmentViewPanel; import jalview.api.FeatureRenderer; +import jalview.api.FeatureSettingsModelI; +import jalview.api.SequenceRenderer; import jalview.bin.Cache; 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; @@ -52,6 +58,8 @@ import jalview.structure.StructureCommand; 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, @@ -83,8 +91,8 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel 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); */ @@ -115,7 +123,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel private String jmolScript(String script) { Cache.log.debug(">>Jmol>> " + script); - String s = jmolViewer.evalStringQuiet(script); + String s = jmolViewer.evalStringQuiet(script); // scriptWait(script); BH Cache.log.debug("< 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)) @@ -210,7 +218,10 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel mset.add(filePath); } } - modelFileNames = mset.toArray(new String[mset.size()]); + if (!mset.isEmpty()) + { + modelFileNames = mset.toArray(new String[mset.size()]); + } } return modelFileNames; @@ -392,8 +403,8 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel } /* - * 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); @@ -429,8 +440,8 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel /* * { 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, @@ -491,6 +502,28 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel @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) @@ -592,6 +625,11 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel 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) { @@ -734,7 +772,9 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel FeatureRenderer fr = getFeatureRenderer(null); if (fr != null) { - fr.featuresAdded(); + FeatureSettingsModelI colours = new Pdb().getFeatureColourScheme(); + ((AppJmol) getViewer()).getAlignmentPanel().av + .applyFeaturesStyle(colours); } refreshGUI(); loadNotifiesHandled++; @@ -763,8 +803,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel public abstract void sendConsoleEcho(String strEcho); /* * { showConsole(true); * - * history.append("\n" + - * strEcho); } + * history.append("\n" + strEcho); } */ // /End JmolStatusListener @@ -994,4 +1033,23 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel { 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 + } }