X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fjavascript%2FMouseOverStructureListener.java;h=dfe5c4fb4bedaed2744210f27dddb668aa75c59d;hb=63e93122d1722a69e997a9ac64502ef74c4a7a17;hp=2ecaf6c040bef02a3fec21a3182b1d513bfa1071;hpb=648f0d7f48b5865bd43b5edbe71f5e483f0cc455;p=jalview.git diff --git a/src/jalview/javascript/MouseOverStructureListener.java b/src/jalview/javascript/MouseOverStructureListener.java index 2ecaf6c..dfe5c4f 100644 --- a/src/jalview/javascript/MouseOverStructureListener.java +++ b/src/jalview/javascript/MouseOverStructureListener.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -20,21 +20,23 @@ */ package jalview.javascript; -import java.awt.Color; -import java.util.ArrayList; - import jalview.api.AlignmentViewPanel; import jalview.api.FeatureRenderer; import jalview.api.SequenceRenderer; import jalview.appletgui.AlignFrame; +import jalview.appletgui.AlignmentPanel; import jalview.bin.JalviewLite; import jalview.datamodel.SequenceI; import jalview.ext.jmol.JmolCommands; +import jalview.structure.AtomSpec; import jalview.structure.StructureListener; import jalview.structure.StructureMapping; import jalview.structure.StructureMappingcommandSet; import jalview.structure.StructureSelectionManager; +import java.util.ArrayList; +import java.util.List; + /** * Propagate events involving PDB structures associated with sequences to a * javascript function. Generally, the javascript handler is called with a @@ -133,7 +135,6 @@ public class MouseOverStructureListener extends JSFunctionExec implements return modelSet; } - @Override public void mouseOverStructure(int atomIndex, String strInfo) { @@ -144,24 +145,27 @@ public class MouseOverStructureListener extends JSFunctionExec implements } @Override - public void highlightAtom(int atomIndex, int pdbResNum, String chain, - String pdbId) + public void highlightAtoms(List atoms) { - String[] st = new String[0]; - try + for (AtomSpec atom : atoms) { - 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(); - + try + { + // TODO is this right? StructureSelectionManager passes pdbFile as the + // field that is interpreted (in 2.8.2) as pdbId? + // JBPComment: yep - this is right! the Javascript harness uses the + // absolute pdbFile URI to locate the PDB file in the external viewer + executeJavascriptFunction(_listenerfn, new String[] + { "mouseover", "" + atom.getPdbFile(), + "" + atom.getChain(), + "" + (atom.getPdbResNum()), "" + atom.getAtomIndex() }); + } catch (Exception ex) + { + System.err.println("Couldn't execute callback with " + _listenerfn + + " for atomSpec: " + atom); + ex.printStackTrace(); + } } - } @Override @@ -174,7 +178,7 @@ public class MouseOverStructureListener extends JSFunctionExec implements // { // ssm.reportMapping(); // } - if (source instanceof jalview.api.AlignmentViewPanel) + if (source instanceof AlignmentViewPanel) { SequenceI[][] sequence = new SequenceI[modelSet.length][]; for (int m = 0; m < modelSet.length; m++) @@ -199,15 +203,15 @@ public class MouseOverStructureListener extends JSFunctionExec implements // } } - SequenceRenderer sr = ((jalview.appletgui.AlignmentPanel) source) + SequenceRenderer sr = ((AlignmentPanel) source) .getSequenceRenderer(); - FeatureRenderer fr = ((jalview.appletgui.AlignmentPanel) source).av + FeatureRenderer fr = ((AlignmentPanel) source).av .isShowSequenceFeatures() ? new jalview.appletgui.FeatureRenderer( - ((jalview.appletgui.AlignmentPanel) source).av) : null; + ((AlignmentPanel) source).av) : null; if (fr != null) { ((jalview.appletgui.FeatureRenderer) fr) - .transferSettings(((jalview.appletgui.AlignmentPanel) source) + .transferSettings(((AlignmentPanel) source) .getFeatureRenderer()); } ; @@ -224,7 +228,7 @@ public class MouseOverStructureListener extends JSFunctionExec implements return; } int sz = 0; - for (jalview.structure.StructureMappingcommandSet ccset : colcommands) + for (StructureMappingcommandSet ccset : colcommands) { sz += ccset.commands.length; ccomands.add(ccset.commands); @@ -241,7 +245,7 @@ public class MouseOverStructureListener extends JSFunctionExec implements } if (jvlite.isJsMessageSetChanged( mclass = "colourstruct", - mhandle = ((jalview.appletgui.AlignmentPanel) source).av + mhandle = ((AlignmentPanel) source).av .getViewId(), ccomandset)) { jvlite.setJsMessageSet(mclass, mhandle, ccomandset); @@ -249,7 +253,7 @@ public class MouseOverStructureListener extends JSFunctionExec implements String st[] = new String[] { "colourstruct", - "" + ((jalview.appletgui.AlignmentPanel) source).av.getViewId(), + "" + ((AlignmentPanel) source).av.getViewId(), "" + ccomandset.length, jvlite.arrayToSeparatorList(pdbfn.toArray(new String[pdbfn .size()])) }; @@ -283,13 +287,6 @@ public class MouseOverStructureListener extends JSFunctionExec implements } @Override - public Color getColour(int atomIndex, int pdbResNum, String chain, - String pdbId) - { - return null; - } - - @Override public AlignFrame getAlignFrame() { // associated with all alignframes, always. @@ -316,4 +313,10 @@ public class MouseOverStructureListener extends JSFunctionExec implements } + @Override + public boolean isListeningFor(SequenceI seq) + { + return true; + } + }