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;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
+import java.util.StringTokenizer;
import java.util.Vector;
import org.jmol.adapter.smarter.SmarterJmolAdapter;
implements JmolStatusListener, JmolSelectionListener,
ComponentListener
{
+ private String lastMessage;
+
boolean allChainsSelected = false;
/*
String lastCommand;
- String lastMessage;
-
boolean loadedInline;
StringBuffer resetLastRes = new StringBuffer();
}
/**
- * prepare the view for a given set of models/chains. chainList contains
- * strings of the form 'pdbfilename:Chaincode'
+ * prepare the view for a given set of models/chains. chainList contains strings
+ * of the form 'pdbfilename:Chaincode'
+ *
+ * @deprecated now only used by applet code
*/
+ @Deprecated
public void centerViewer()
{
StringBuilder cmd = new StringBuilder(128);
}
Thread colourby = null;
+
/**
* Sends a set of colour commands to the structure viewer
*
- * @param colourBySequenceCommands
+ * @param commands
*/
@Override
- protected void colourBySequence(
- final StructureMappingcommandSet[] colourBySequenceCommands)
+ protected void colourBySequence(final String[] commands)
{
if (colourby != null)
{
@Override
public void run()
{
- for (StructureMappingcommandSet cpdbbyseq : colourBySequenceCommands)
+ for (String cmd : commands)
{
- for (String cbyseq : cpdbbyseq.commands)
- {
- executeWhenReady(cbyseq);
- }
+ executeWhenReady(cmd);
}
}
});
* @return
*/
@Override
- protected StructureMappingcommandSet[] getColourBySequenceCommands(
+ protected String[] getColourBySequenceCommands(
String[] files, AlignmentViewPanel viewPanel)
{
- return JmolCommands.getColourBySequenceCommand(getSsm(), files,
- this, viewPanel);
+ Map<Object, AtomSpecModel> map = buildColoursMap(viewPanel);
+
+ return JmolCommands.getColourBySequenceCommand(map);
}
/**
viewer.openStringInline(string);
}
- public void mouseOverStructure(int atomIndex, String strInfo)
+ protected void mouseOverStructure(int atomIndex, final String strInfo)
{
int pdbResNum;
int alocsep = strInfo.indexOf("^");
} catch (Exception e)
{
}
- ;
}
- if (lastMessage == null || !lastMessage.equals(strInfo))
+
+ /*
+ * highlight position on alignment(s); if some text is returned,
+ * show this as a second line on the structure hover tooltip
+ */
+ String label = getSsm().mouseOverStructure(pdbResNum, chainId,
+ pdbfilename);
+ if (label != null)
{
- getSsm().mouseOverStructure(pdbResNum, chainId, pdbfilename);
+ // change comma to pipe separator (newline token for Jmol)
+ label = label.replace(',', '|');
+ StringTokenizer toks = new StringTokenizer(strInfo, " ");
+ StringBuilder sb = new StringBuilder();
+ sb.append("select ").append(String.valueOf(pdbResNum)).append(":")
+ .append(chainId).append("/1");
+ sb.append(";set hoverLabel \"").append(toks.nextToken()).append(" ")
+ .append(toks.nextToken());
+ sb.append("|").append(label).append("\"");
+ evalStateCommand(sb.toString());
}
-
- lastMessage = strInfo;
}
public void notifyAtomHovered(int atomIndex, String strInfo, String data)
{
+ if (strInfo.equals(lastMessage))
+ {
+ return;
+ }
+ lastMessage = strInfo;
if (data != null)
{
System.err.println("Ignoring additional hover info: " + data
@Override
public void showStructures(AlignViewportI av, boolean refocus)
{
- // TODO show Jmol structure optionally restricted to visible alignment
- // and/or selected chains
+ 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 0");
+ }
+ 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";
}
}