import jalview.structure.StructureSelectionManager;
import jalview.structures.models.AAStructureBindingModel;
import jalview.util.MessageManager;
+import jalview.util.StructureCommands;
import java.awt.Color;
import java.awt.Container;
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;
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;
public abstract class JalviewJmolBinding extends AAStructureBindingModel
implements JmolStatusListener, JmolSelectionListener,
ComponentListener
{
+ private String lastMessage;
+
boolean allChainsSelected = false;
/*
Vector<String> atomsPicked = new Vector<>();
- private List<String> chainNames;
-
Hashtable<String, String> chainFile;
/*
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);
}
// System.out.println("Select regions:\n" + selectioncom.toString());
evalStateCommand("select *; cartoons off; backbone; select ("
- + selectioncom.toString() + "); cartoons; ");
+ + selectioncom.toString() + "); cartoons; zoom 0");
// evalStateCommand("select *; backbone; select "+selcom.toString()+";
// cartoons; center "+selcom.toString());
}
* @param commands
*/
@Override
- protected void colourBySequence(final String[] commands)
+ protected void colourBySequence(AlignmentViewPanel viewPanel)
{
+ Map<Object, AtomSpecModel> map = StructureCommands.buildColoursMap(this,
+ viewPanel);
+
+ String[] commands = JmolCommands.getColourBySequenceCommand(map);
+
if (colourby != null)
{
colourby.interrupt();
}
/**
- * @param files
- * @param viewPanel
- * @return
- */
- @Override
- protected String[] getColourBySequenceCommands(
- String[] files, AlignmentViewPanel viewPanel)
- {
- Map<Object, AtomSpecModel> map = buildColoursMap(viewPanel);
-
- return JmolCommands.getColourBySequenceCommand(map);
- }
-
- /**
* @param command
*/
protected void executeWhenReady(String command)
return null;
}
- public Color getColour(int atomIndex, int pdbResNum, String chain,
- String pdbfile)
- {
- if (getModelNum(pdbfile) < 0)
- {
- return null;
- }
- // TODO: verify atomIndex is selecting correct model.
- // return new Color(viewer.getAtomArgb(atomIndex)); Jmol 12.2.4
- int colour = viewer.ms.at[atomIndex].atomPropertyInt(T.color);
- return new Color(colour);
- }
-
/**
* instruct the Jalview binding to update the pdbentries vector if necessary
* prior to matching the jmol view's contents to the list of structure files
@Override
public synchronized String[] getStructureFiles()
{
- List<String> mset = new ArrayList<>();
if (viewer == null)
{
return new String[0];
if (modelFileNames == null)
{
+ List<String> mset = new ArrayList<>();
int modelCount = viewer.ms.mc;
String filePath = null;
for (int i = 0; i < modelCount; ++i)
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
setLoadingFromArchive(false);
}
- @Override
- public List<String> getChainNames()
- {
- return chainNames;
- }
-
protected IProgressIndicator getIProgressIndicator()
{
return null;
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);
+ AtomSpecModel model = getShownResidues(av);
+ String atomSpec = JmolCommands.getAtomSpec(model);
- cmd.append("display ").append(atomSpec);
+ cmd.append("hide *;display ").append(atomSpec)
+ .append("; select displayed");
}
else
{
- cmd.append("display *");
+ cmd.append(";display *");
}
- cmd.append("; cartoon");
+ cmd.append("; cartoon only");
if (refocus)
{
- cmd.append("; zoom 100");
+ cmd.append("; zoom 0");
}
evalStateCommand(cmd.toString());
}
{
return String.valueOf(model + 1) + ".1";
}
+
+ /**
+ * Sends a command to recentre the display
+ */
+ @Override
+ public void focusView()
+ {
+ /*
+ * don't use evalStateCommand because it ignores a command that is the same
+ * as the last command (why?); but user may have adjusted the display since
+ */
+ viewer.evalString("zoom 0");
+ }
+
+ @Override
+ public int getModelForPdbFile(String fileName, int fileIndex)
+ {
+ return fileIndex;
+ }
}