X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fjmol%2FJalviewJmolBinding.java;h=8cecf6eba5f3d47abb24fbe2590fd6c5003df90f;hb=6bf5604d306cbcd55289639967411ddbafcac682;hp=11354780db60bcc46903a963149c18020442690e;hpb=9644afe3c10e90365290d4b249d32635bccfad7f;p=jalview.git diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index 1135478..8cecf6e 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -20,20 +20,20 @@ */ package jalview.ext.jmol; +import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; import jalview.api.FeatureRenderer; -import jalview.api.SequenceRenderer; import jalview.datamodel.AlignmentI; import jalview.datamodel.HiddenColumns; import jalview.datamodel.PDBEntry; import jalview.datamodel.SequenceI; +import jalview.ext.rbvi.chimera.AtomSpecModel; import jalview.gui.IProgressIndicator; import jalview.io.DataSourceType; import jalview.io.StructureFile; import jalview.schemes.ColourSchemeI; import jalview.schemes.ResidueProperties; import jalview.structure.AtomSpec; -import jalview.structure.StructureMappingcommandSet; import jalview.structure.StructureSelectionManager; import jalview.structures.models.AAStructureBindingModel; import jalview.util.MessageManager; @@ -44,7 +44,6 @@ import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.io.File; import java.net.URL; -import java.security.AccessControlException; import java.util.ArrayList; import java.util.BitSet; import java.util.Hashtable; @@ -135,15 +134,12 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel /** * prepare the view for a given set of models/chains. chainList contains * strings of the form 'pdbfilename:Chaincode' - * - * @param chainList - * list of chains to make visible */ - public void centerViewer(Vector chainList) + public void centerViewer() { StringBuilder cmd = new StringBuilder(128); int mlength, p; - for (String lbl : chainList) + for (String lbl : chainsToShow) { mlength = 0; do @@ -159,7 +155,8 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel { cmd.setLength(cmd.length() - 4); } - evalStateCommand("select *;restrict " + cmd + ";cartoon;center " + cmd); + String command = "select *;restrict " + cmd + ";cartoon;center " + cmd; + evalStateCommand(command); } public void closeViewer() @@ -478,36 +475,47 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel lastCommand = command; } + Thread colourby = null; + /** * Sends a set of colour commands to the structure viewer * - * @param colourBySequenceCommands + * @param commands */ @Override - protected void colourBySequence( - StructureMappingcommandSet[] colourBySequenceCommands) + protected void colourBySequence(final String[] commands) { - 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 (String cmd : commands) + { + executeWhenReady(cmd); + } } - } + }); + colourby.start(); } /** * @param files - * @param sr * @param viewPanel * @return */ @Override - protected StructureMappingcommandSet[] getColourBySequenceCommands( - String[] files, SequenceRenderer sr, AlignmentViewPanel viewPanel) + protected String[] getColourBySequenceCommands( + String[] files, AlignmentViewPanel viewPanel) { - return JmolCommands.getColourBySequenceCommand(getSsm(), files, - getSequence(), sr, viewPanel); + Map map = buildColoursMap(viewPanel); + + return JmolCommands.getColourBySequenceCommand(map); } /** @@ -600,74 +608,6 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel */ private int _modelFileNameMap[]; - // //////////////////////////////// - // /StructureListener - // @Override - public synchronized String[] getPdbFilex() - { - if (viewer == null) - { - return new String[0]; - } - if (modelFileNames == null) - { - List mset = new ArrayList<>(); - _modelFileNameMap = new int[viewer.ms.mc]; - String m = viewer.ms.getModelFileName(0); - if (m != null) - { - String filePath = m; - try - { - filePath = new File(m).getAbsolutePath(); - } catch (AccessControlException x) - { - // usually not allowed to do this in applet - System.err.println( - "jmolBinding: Using local file string from Jmol: " + m); - } - if (filePath.indexOf("/file:") != -1) - { - // applet path with docroot - discard as format won't match pdbfile - filePath = m; - } - mset.add(filePath); - _modelFileNameMap[0] = 0; // filename index for first model is always 0. - } - int j = 1; - for (int i = 1; i < viewer.ms.mc; i++) - { - m = viewer.ms.getModelFileName(i); - String filePath = m; - if (m != null) - { - try - { - filePath = new File(m).getAbsolutePath(); - } catch (AccessControlException x) - { - // usually not allowed to do this in applet, so keep raw handle - // System.err.println("jmolBinding: Using local file string from - // Jmol: "+m); - } - } - - /* - * add this model unless it is read from a structure file we have - * already seen (example: 2MJW is an NMR structure with 10 models) - */ - if (!mset.contains(filePath)) - { - mset.add(filePath); - _modelFileNameMap[j] = i; // record the model index for the filename - j++; - } - } - modelFileNames = mset.toArray(new String[mset.size()]); - } - return modelFileNames; - } - @Override public synchronized String[] getStructureFiles() { @@ -862,7 +802,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel try { // recover PDB filename for the model hovered over. - int mnumber = new Integer(mdlId).intValue() - 1; + int mnumber = Integer.valueOf(mdlId).intValue() - 1; if (_modelFileNameMap != null) { int _mp = _modelFileNameMap.length - 1; @@ -1240,7 +1180,10 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel return chainNames; } - protected abstract IProgressIndicator getIProgressIndicator(); + protected IProgressIndicator getIProgressIndicator() + { + return null; + } public void notifyNewPickingModeMeasurement(int iatom, String strMeasure) { @@ -1468,4 +1411,40 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel { showConsole(false); } + + @Override + public void showStructures(AlignViewportI av, boolean refocus) + { + StringBuilder cmd = new StringBuilder(128); + + if (isShowAlignmentOnly()) + { + cmd.append("hide *;"); + + AtomSpecModel model = getShownResidues(av); + String atomSpec = JmolCommands.getAtomSpec(model); + + cmd.append("display ").append(atomSpec); + } + else + { + cmd.append("display *"); + } + cmd.append("; cartoon"); + if (refocus) + { + cmd.append("; zoom 100"); + } + evalStateCommand(cmd.toString()); + } + + /** + * Answers a Jmol syntax style structure model specification. Model number 0, 1, + * 2... is formatted as "1.1", "2.1", "3.1" etc. + */ + @Override + public String getModelSpec(int model) + { + return String.valueOf(model + 1) + ".1"; + } }