X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fjmol%2FJalviewJmolBinding.java;h=61926dc32f7025f890a0842dc5f96f5ed39ee905;hb=f001dc68c5066e79837f0785c587043a2976e446;hp=b1b5ce4ecef8620d4db6f19b18c041e069ab53c9;hpb=ab889432b2f2ebea75aca36e814efc42ab50b9ac;p=jalview.git diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index b1b5ce4..61926dc 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -20,35 +20,18 @@ */ package jalview.ext.jmol; -import jalview.api.AlignmentViewPanel; -import jalview.api.FeatureRenderer; -import jalview.api.SequenceRenderer; -import jalview.datamodel.AlignmentI; -import jalview.datamodel.ColumnSelection; -import jalview.datamodel.PDBEntry; -import jalview.datamodel.SequenceI; -import jalview.io.AppletFormatAdapter; -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 java.awt.Color; import java.awt.Container; 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.Hashtable; +import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.StringTokenizer; import java.util.Vector; -import javajs.awt.Dimension; +import javax.swing.SwingUtilities; import org.jmol.adapter.smarter.SmarterJmolAdapter; import org.jmol.api.JmolAppConsoleInterface; @@ -56,14 +39,31 @@ import org.jmol.api.JmolSelectionListener; import org.jmol.api.JmolStatusListener; import org.jmol.api.JmolViewer; import org.jmol.c.CBK; -import org.jmol.script.T; 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; +import jalview.io.StructureFile; +import jalview.structure.AtomSpec; +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, - ComponentListener -{ - boolean allChainsSelected = false; + implements JmolStatusListener, JmolSelectionListener, ComponentListener { + private String lastMessage; /* * when true, try to search the associated datamodel for sequences that are @@ -71,59 +71,36 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel */ private boolean associateNewStructs = false; - Vector atomsPicked = new Vector(); - - public Vector chainNames; - - Hashtable chainFile; - - public String fileLoadingError; - - /* - * the default or current model displayed if the model cannot be identified - * from the selection message - */ - int frameNo = 0; - - // protected JmolGenericPopup jmolpopup; // not used - remove? - - String lastCommand; - - String lastMessage; + private Vector atomsPicked = new Vector<>(); - boolean loadedInline; + private String lastCommand; - /** - * current set of model filenames loaded in the Jmol instance - */ - String[] modelFileNames = null; + private boolean loadedInline; - StringBuffer resetLastRes = new StringBuffer(); + private StringBuffer resetLastRes = new StringBuffer(); - public Viewer viewer; + public Viewer jmolViewer; - public JalviewJmolBinding(StructureSelectionManager ssm, - PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains, - String protocol) - { - super(ssm, pdbentry, sequenceIs, chains, protocol); + public JalviewJmolBinding(StructureSelectionManager ssm, PDBEntry[] pdbentry, SequenceI[][] sequenceIs, + DataSourceType protocol) { + super(ssm, pdbentry, sequenceIs, protocol); + 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); */ } - public JalviewJmolBinding(StructureSelectionManager ssm, - SequenceI[][] seqs, Viewer theViewer) - { + public JalviewJmolBinding(StructureSelectionManager ssm, SequenceI[][] seqs, Viewer theViewer) { super(ssm, seqs); - viewer = theViewer; - viewer.setJmolStatusListener(this); - viewer.addSelectionListener(this); + jmolViewer = theViewer; + jmolViewer.setJmolStatusListener(this); + jmolViewer.addSelectionListener(this); + setStructureCommands(new JmolCommands()); } /** @@ -132,434 +109,45 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel * * @return */ - public String getViewerTitle() - { + public String getViewerTitle() { return getViewerTitle("Jmol", true); } - /** - * 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) - { - StringBuilder cmd = new StringBuilder(128); - int mlength, p; - for (String lbl : chainList) - { - mlength = 0; - do - { - p = mlength; - mlength = lbl.indexOf(":", p); - } while (p < mlength && mlength < (lbl.length() - 2)); - // TODO: lookup each pdb id and recover proper model number for it. - cmd.append(":" + lbl.substring(mlength + 1) + " /" - + (1 + getModelNum(chainFile.get(lbl))) + " or "); - } - if (cmd.length() > 0) - { - cmd.setLength(cmd.length() - 4); - } - evalStateCommand("select *;restrict " + cmd + ";cartoon;center " + cmd); - } - - public void closeViewer() - { - // remove listeners for all structures in viewer - getSsm().removeStructureViewerListener(this, this.getPdbFile()); - viewer.dispose(); - lastCommand = null; - viewer = null; - releaseUIResources(); - } - - public void colourByChain() - { - colourBySequence = false; - // TODO: colour by chain should colour each chain distinctly across all - // visible models - // TODO: http://issues.jalview.org/browse/JAL-628 - evalStateCommand("select *;color chain"); - } + private String jmolScript(String script) { + Cache.log.debug(">>Jmol>> " + script); + String s = jmolViewer.evalStringQuiet(script); // scriptWait(script); BH + Cache.log.debug("<