X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fjmol%2FJalviewJmolBinding.java;fp=src%2Fjalview%2Fext%2Fjmol%2FJalviewJmolBinding.java;h=88322785ee9fbce68679087362a8bbfcaa40fe6c;hp=41bc116a224bab9bc4004d7f2dffb1baa9f4020d;hb=9f1f7839cfd50555efd3af1ff4102348f950c563;hpb=e34a4c5332c2d4d92651e0adc99ab7c5d262d13b diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index 41bc116..8832278 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -478,6 +478,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel lastCommand = command; } + Thread colourby = null; /** * Sends a set of colour commands to the structure viewer * @@ -485,15 +486,28 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel */ @Override protected void colourBySequence( - StructureMappingcommandSet[] colourBySequenceCommands) + final StructureMappingcommandSet[] colourBySequenceCommands) { - for (StructureMappingcommandSet cpdbbyseq : colourBySequenceCommands) + if (colourby != null) { - for (String cbyseq : cpdbbyseq.commands) + colourby.interrupt(); + colourby = null; + } + colourby = new Thread(new Runnable() + { + @Override + public void run() { - executeWhenReady(cbyseq); + for (StructureMappingcommandSet cpdbbyseq : colourBySequenceCommands) + { + for (String cbyseq : cpdbbyseq.commands) + { + executeWhenReady(cbyseq); + } + } } - } + }); + colourby.start(); } /** @@ -862,19 +876,30 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel try { // recover PDB filename for the model hovered over. - int _mp = _modelFileNameMap.length - 1, - mnumber = new Integer(mdlId).intValue() - 1; - while (mnumber < _modelFileNameMap[_mp]) + int mnumber = new Integer(mdlId).intValue() - 1; + if (_modelFileNameMap != null) { - _mp--; + int _mp = _modelFileNameMap.length - 1; + + while (mnumber < _modelFileNameMap[_mp]) + { + _mp--; + } + pdbfilename = modelFileNames[_mp]; } - pdbfilename = modelFileNames[_mp]; - if (pdbfilename == null) + else { - pdbfilename = new File(viewer.ms.getModelFileName(mnumber)) - .getAbsolutePath(); - } + if (mnumber >= 0 && mnumber < modelFileNames.length) + { + pdbfilename = modelFileNames[mnumber]; + } + if (pdbfilename == null) + { + pdbfilename = new File(viewer.ms.getModelFileName(mnumber)) + .getAbsolutePath(); + } + } } catch (Exception e) { }