From 9f91642f99bc1a3f01d7c97a7a109d4694a88049 Mon Sep 17 00:00:00 2001 From: James Procter Date: Fri, 13 Oct 2023 17:45:17 +0100 Subject: [PATCH] =?utf8?q?JAL-4295=20concatenate=20all=20mouseover=20highlig?= =?utf8?q?hts=20into=20one=20call=20to=20jmolScript=20-=20so=20we=20don=E2=80?= =?utf8?q?=99t=20need=20to=20invoke=20scriptWait=20and=20risk=20blocking=20U?= =?utf8?q?I?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/ext/jmol/JalviewJmolBinding.java | 33 +++++++++++++++++--------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index 870db65..dc18369 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -267,16 +267,30 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel { if (atoms != null) { - boolean useScriptWait = atoms.size() > 1; if (resetLastRes.length() > 0) { - jmolScript(resetLastRes.toString(), useScriptWait); + jmolScript(resetLastRes.toString()); resetLastRes.setLength(0); } + StringBuilder highlightCommands=null; for (AtomSpec atom : atoms) { - highlightAtom(atom.getAtomIndex(), atom.getPdbResNum(), - atom.getChain(), atom.getPdbFile(), useScriptWait); + StringBuilder thisAtom = highlightAtom(atom.getAtomIndex(), atom.getPdbResNum(), + atom.getChain(), atom.getPdbFile()); + if (thisAtom!=null) { + if (highlightCommands==null) + { + highlightCommands=thisAtom; + } else { + highlightCommands.append(thisAtom); + } + } + } + if (highlightCommands!=null) + { + jmolHistory(false); + jmolScript(highlightCommands.toString()); + jmolHistory(true); } // Highlight distances between atoms with a 'measure' command - not yet // working @@ -306,17 +320,15 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel } // jmol/ssm only - public void highlightAtom(int atomIndex, int pdbResNum, String chain, - String pdbfile, boolean useScriptWait) + private StringBuilder highlightAtom(int atomIndex, int pdbResNum, String chain, + String pdbfile) { String modelId = getModelIdForFile(pdbfile); if (modelId.isEmpty()) { - return; + return null; } - jmolHistory(false, useScriptWait); - StringBuilder selection = new StringBuilder(32); StringBuilder cmd = new StringBuilder(64); selection.append("select ").append(String.valueOf(pdbResNum)); @@ -333,8 +345,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel resetLastRes.append(selection).append(";wireframe 0;").append(selection) .append(" and not hetero; spacefill 0;"); - jmolScript(cmd.toString(), useScriptWait); - jmolHistory(true, useScriptWait); + return cmd; } private boolean debug = true; -- 1.7.10.2