import org.jmol.api.JmolStatusListener;
import org.jmol.api.JmolViewer;
import org.jmol.c.CBK;
+import org.jmol.modelset.Atom;
+import org.jmol.modelset.Model;
import org.jmol.viewer.Viewer;
import jalview.api.AlignmentViewPanel;
// jmolpopup.jpiShow(x, y);
}
+ private List<AtomSpec> lastHighlight = new ArrayList<AtomSpec>();
+ private List<AtomSpec> resetLastHighlight = new ArrayList<AtomSpec>();
/**
* Highlight zero, one or more atoms on the structure
*/
{
if (atoms != null)
{
+ // make sure we ignore the next few selection events for these
+ lastHighlight.addAll(resetLastHighlight);
+ lastHighlight.addAll(atoms);
+ resetLastHighlight.clear();
+ resetLastHighlight.addAll(atoms);
if (resetLastRes.length() > 0)
{
jmolScript(resetLastRes.toString());
StringBuilder selection = new StringBuilder(32);
StringBuilder cmd = new StringBuilder(64);
+ // save existing selection.
+ // display halo
selection.append("select ").append(String.valueOf(pdbResNum));
selection.append(":");
if (!chain.equals(" "))
commandOptions, this);
jmolViewer.setJmolStatusListener(this); // extends JmolCallbackListener
-
+
+ jmolViewer.addSelectionListener(new JmolSelectionListener()
+ {
+
+ @Override
+ public void selectionChanged(BS arg0)
+ {
+ if (!isLoadingFinished())
+ {
+ return;
+ }
+ List<AtomSpec> lastH = lastHighlight;
+ lastHighlight = new ArrayList<AtomSpec>();
+ final AtomSpec[] lastHighlighted = lastH.toArray(new AtomSpec[0]); // copy of the int[] array
+ SwingUtilities.invokeLater(new Runnable() {
+
+ public void run() {
+
+ processselectionChanged(arg0, lastHighlighted);
+ }
+ });
+ }
+ });
try
{
console = createJmolConsole(consolePanel, buttonsToShow);
}
+ protected void processselectionChanged(BS arg0, AtomSpec[] lastHighlighted)
+ {
+ int atom = arg0.nextSetBit(0);
+ int modelNo=-1,resNo=-1;
+ String chainCode="NOCHAIN";
+ List<AtomSpec> toSelect = new ArrayList<AtomSpec>();
+ while (atom>-1 && arg0.get(atom)){
+ //
+ Model atomModel = jmolViewer.getModelForAtomIndex(atom);
+ Atom firstAtom = atomModel.ms.getAtom(atom);
+ String chcode = firstAtom.getChainIDStr();
+ if (atomModel.modelIndex!=modelNo || resNo != firstAtom.getResno() || !chainCode.equals(chcode))
+ {
+ resNo = firstAtom.getResno();
+ modelNo = atomModel.modelIndex;
+ chainCode = chcode;
+ boolean ignore=false;
+ String modelFile = getPdbEntry(modelNo).getFile();
+ if (lastHighlighted!=null)
+ {
+
+ for (AtomSpec hgh:lastHighlighted)
+ {
+ if (hgh.getPdbResNum() == resNo && chainCode.equals(hgh.getChain()) && hgh.getPdbFile().equals(modelFile))
+ {
+ ignore=true;
+ break;
+ }
+ }
+ }
+ if (!ignore)
+ {
+ AtomSpec atomspec = new AtomSpec(modelFile, chainCode, resNo, atomModel.firstAtomIndex);
+ toSelect.add(atomspec);
+ }
+ }
+ // look for next selected atom
+ atom = arg0.nextSetBit(++atom);
+ }
+ if (toSelect.size()>0 || arg0.isEmpty())
+ {
+ // if we have ignored everything we don't clear the existing highlight
+ getSsm().mouseOverStructure(toSelect);
+ }
+ }
+
+
protected abstract JmolAppConsoleInterface createJmolConsole(
Container consolePanel, String buttonsToShow);
import java.util.Map;
import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+import org.jmol.api.AtomIndexIterator;
import org.jmol.api.JmolAppConsoleInterface;
+import org.jmol.modelset.Atom;
+import org.jmol.modelset.Model;
import org.openscience.jmol.app.jmolpanel.console.AppConsole;
import jalview.api.AlignmentViewPanel;
import jalview.datamodel.SequenceI;
import jalview.ext.jmol.JalviewJmolBinding;
import jalview.io.DataSourceType;
+import jalview.structure.AtomSpec;
import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
import jalview.util.Platform;
@Override
public void selectionChanged(BS arg0)
{
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ }
+ });
}
-
+
@Override
public void showConsole(boolean b)
{