setMouseoverListener(currentAlignFrame, listener);
}
- private Vector mouseoverListeners = new Vector();
+ private Vector javascriptListeners = new Vector();
public void setMouseoverListener(AlignFrame af, String listener)
{
}
jalview.javascript.MouseOverListener mol = new jalview.javascript.MouseOverListener(
this, af, listener);
- mouseoverListeners.addElement(mol);
+ javascriptListeners.addElement(mol);
StructureSelectionManager.getStructureSelectionManager()
.addStructureViewerListener(mol);
if (debug)
System.err.println("Added a mouseover listener for "
+ ((af == null) ? "All frames" : "Just views for "
+ af.getAlignViewport().getSequenceSetId()));
- System.err.println("There are now " + mouseoverListeners.size()
+ System.err.println("There are now " + javascriptListeners.size()
+ " listeners in total.");
}
}
}
jalview.javascript.JsSelectionSender mol = new jalview.javascript.JsSelectionSender(
this, af, listener);
- mouseoverListeners.addElement(mol);
+ javascriptListeners.addElement(mol);
StructureSelectionManager.getStructureSelectionManager()
.addSelectionListener(mol);
if (debug)
System.err.println("Added a selection listener for "
+ ((af == null) ? "All frames" : "Just views for "
+ af.getAlignViewport().getSequenceSetId()));
- System.err.println("There are now " + mouseoverListeners.size()
+ System.err.println("There are now " + javascriptListeners.size()
+ " listeners in total.");
}
}
+ public void setStructureListener(String listener)
+ {
+ if (listener != null)
+ {
+ listener = listener.trim();
+ if (listener.length() == 0)
+ {
+ System.err
+ .println("jalview Javascript error: Ignoring empty function for selection listener.");
+ return;
+ }
+ }
+ jalview.javascript.MouseOverStructureListener mol = new jalview.javascript.MouseOverStructureListener(this, listener);
+ javascriptListeners.addElement(mol);
+ StructureSelectionManager.getStructureSelectionManager()
+ .addStructureViewerListener(mol);
+ if (debug)
+ {
+ System.err.println("Added a javascript structure viewer listener '"+listener+"'");
+ System.err.println("There are now " + javascriptListeners.size()
+ + " listeners in total.");
+ }
+ }
/**
* remove any callback using the given listener function and associated with
* the given alignFrame (or null for all callbacks)
}
}
boolean rprt = false;
- for (int ms = 0, msSize = mouseoverListeners.size(); ms < msSize;)
+ for (int ms = 0, msSize = javascriptListeners.size(); ms < msSize;)
{
- Object lstn = mouseoverListeners.elementAt(ms);
+ Object lstn = javascriptListeners.elementAt(ms);
JsCallBack lstner = (JsCallBack) lstn;
if ((af == null || lstner.getAlignFrame() == af)
&& (listener == null || lstner.getListenerFunction().equals(
listener)))
{
- mouseoverListeners.removeElement(lstner);
+ javascriptListeners.removeElement(lstner);
msSize--;
if (lstner instanceof SelectionListener)
{
}
if (rprt)
{
- System.err.println("There are now " + mouseoverListeners.size()
+ System.err.println("There are now " + javascriptListeners.size()
+ " listeners in total.");
}
}
public void stop()
{
- if (mouseoverListeners != null)
+ if (javascriptListeners != null)
{
- while (mouseoverListeners.size() > 0)
+ while (javascriptListeners.size() > 0)
{
- Object mol = mouseoverListeners.elementAt(0);
- mouseoverListeners.removeElement(mol);
+ Object mol = javascriptListeners.elementAt(0);
+ javascriptListeners.removeElement(mol);
if (mol instanceof SelectionListener)
{
StructureSelectionManager.getStructureSelectionManager()
* @param chain
* @param pdbfile
*/
- public void mouseOverStructure(int pdbResNum, String chain, String pdbfile)
+ public void mouseOverStructure(String pdbResNum, String chain, String pdbfile)
{
+ try {
StructureSelectionManager.getStructureSelectionManager()
- .mouseOverStructure(pdbResNum, chain, pdbfile);
+ .mouseOverStructure(new Integer(pdbResNum).intValue(), chain, pdbfile);
+ if (debug)
+ {
+ System.err.println("mouseOver for '"+pdbResNum+"' in chain '"+chain+"' in structure '"+pdbfile+"'");
+ }
+ } catch (NumberFormatException e)
+ {
+ System.err.println("Ignoring invalid residue number string '"+pdbResNum+"'");
+ }
}
// //////////////////////////////////////////////
private boolean alignPdbStructures = false;
+ /**
+ * use an external structure viewer exclusively (no jmols or MCViews will be opened by JalviewLite itself)
+ */
+ public boolean useXtrnalSviewer=false;
+
public static boolean debug = false;
static String builddate = null, version = null;
System.err.println("Build Date : " + getBuildDate());
}
+ String externalsviewer = getParameter("externalstructureviewer");
+ if (externalsviewer!=null)
+ {
+ useXtrnalSviewer=externalsviewer.trim().toLowerCase().equals("true");
+ }
/**
* if true disable the check for jmol
*/
// Accumulate pdbs here if they are heading for the same view (if
// alignPdbStructures is true)
Vector pdbs = new Vector();
+ // create a lazy matcher if we're asked to
+ jalview.analysis.SequenceIdMatcher matcher = (applet.getDefaultParameter("relaxedidmatch", false)) ? new jalview.analysis.SequenceIdMatcher(
+ newAlignFrame.getAlignViewport().getAlignment().getSequencesArray()) : null;
+
do
{
if (pdbFileCount > 0)
String sequence = applet.getParameter("PDBSEQ");
if (sequence != null)
seqs = new SequenceI[]
- { (Sequence) newAlignFrame.getAlignViewport()
- .getAlignment().findName(sequence) };
+ { matcher==null ? (Sequence) newAlignFrame.getAlignViewport()
+ .getAlignment().findName(sequence) : matcher.findIdMatch(sequence) };
}
else
tmp2.addElement(st2.nextToken());
seqstring = st2.nextToken();
}
- tmp.addElement((Sequence) newAlignFrame.getAlignViewport()
- .getAlignment().findName(seqstring));
+ tmp.addElement(matcher==null ? (Sequence) newAlignFrame.getAlignViewport()
+ .getAlignment().findName(seqstring) : matcher.findIdMatch(seqstring));
}
seqs = new SequenceI[tmp.size()];
--- /dev/null
+package jalview.javascript;
+
+import java.awt.Color;
+
+import jalview.appletgui.AlignFrame;
+import jalview.bin.JalviewLite;
+import jalview.structure.StructureListener;
+import jalview.structure.StructureSelectionManager;
+
+public class MouseOverStructureListener extends JSFunctionExec implements
+ JsCallBack, StructureListener
+{
+
+ String _listenerfn;
+ public MouseOverStructureListener(JalviewLite applet, String listenerCb)
+ {
+ super(applet);
+ _listenerfn = listenerCb;
+
+ }
+ @Override
+ public String[] getPdbFile()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void mouseOverStructure(int atomIndex, String strInfo)
+ {
+
+ // StructureSelectionManager.getStructureSelectionManager().mouseOverStructure(atomIndex, chain, pdbfile)
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void highlightAtom(int atomIndex, int pdbResNum, String chain,
+ String pdbId)
+ {
+ String[] st=new String[0];
+ try {
+ executeJavascriptFunction(_listenerfn, st = new String[] { "mouseover",""+pdbId, ""+chain, ""+(pdbResNum), ""+atomIndex});
+ } catch (Exception ex)
+ {
+ System.err.println("Couldn't execute callback with "+_listenerfn+" using args { "+st[0]+", "+st[1]+", "+st[2]+","+st[3]+"\n");
+ ex.printStackTrace();
+
+ }
+
+ }
+
+ @Override
+ public void updateColours(Object source)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Color getColour(int atomIndex, int pdbResNum, String chain,
+ String pdbId)
+ {
+ return null;
+ }
+
+ @Override
+ public AlignFrame getAlignFrame()
+ {
+ // associated with all alignframes, always.
+ return null;
+ }
+
+ @Override
+ public String getListenerFunction()
+ {
+ return _listenerfn;
+ }
+
+}