From 43b415c68805f3dec44a6ddc666d52220483c120 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 5 Jun 2015 16:26:15 +0100 Subject: [PATCH] JAL-1752 structure highlight scoped to only its mapped sequences --- src/MCview/AppletPDBCanvas.java | 16 ++++++++++++++ src/MCview/PDBCanvas.java | 16 ++++++++++++++ src/jalview/gui/AppVarnaBinding.java | 13 +++++++++--- .../javascript/MouseOverStructureListener.java | 12 ++++++++--- src/jalview/structure/StructureListener.java | 10 +++++++++ .../structure/StructureSelectionManager.java | 4 ++++ .../structures/models/AAStructureBindingModel.java | 22 ++++++++++++++++++++ 7 files changed, 87 insertions(+), 6 deletions(-) diff --git a/src/MCview/AppletPDBCanvas.java b/src/MCview/AppletPDBCanvas.java index c1c4b2f..dc69f43 100644 --- a/src/MCview/AppletPDBCanvas.java +++ b/src/MCview/AppletPDBCanvas.java @@ -1227,4 +1227,20 @@ public class AppletPDBCanvas extends Panel implements MouseListener, // TODO Auto-generated method stub } + + @Override + public boolean isListeningFor(SequenceI seq) + { + if (sequence != null) + { + for (SequenceI s : sequence) + { + if (s == seq) + { + return true; + } + } + } + return false; + } } diff --git a/src/MCview/PDBCanvas.java b/src/MCview/PDBCanvas.java index 76bf59b..406d9f1 100644 --- a/src/MCview/PDBCanvas.java +++ b/src/MCview/PDBCanvas.java @@ -1185,4 +1185,20 @@ public class PDBCanvas extends JPanel implements MouseListener, // TODO Auto-generated method stub } + + @Override + public boolean isListeningFor(SequenceI seq) + { + if (sequence != null) + { + for (SequenceI s : sequence) + { + if (s == seq) + { + return true; + } + } + } + return false; + } } diff --git a/src/jalview/gui/AppVarnaBinding.java b/src/jalview/gui/AppVarnaBinding.java index 7894ee2..38385f0 100644 --- a/src/jalview/gui/AppVarnaBinding.java +++ b/src/jalview/gui/AppVarnaBinding.java @@ -20,9 +20,6 @@ */ package jalview.gui; -import jalview.structure.AtomSpec; -import jalview.util.MessageManager; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -72,6 +69,10 @@ import fr.orsay.lri.varna.models.VARNAConfig; import fr.orsay.lri.varna.models.rna.Mapping; import fr.orsay.lri.varna.models.rna.RNA; +import jalview.datamodel.SequenceI; +import jalview.structure.AtomSpec; +import jalview.util.MessageManager; + public class AppVarnaBinding extends jalview.ext.varna.JalviewVarnaBinding implements DropTargetListener, InterfaceVARNAListener, MouseListener @@ -920,4 +921,10 @@ public class AppVarnaBinding extends jalview.ext.varna.JalviewVarnaBinding public void highlightAtoms(List atoms) { } + + @Override + public boolean isListeningFor(SequenceI seq) + { + return true; + } } diff --git a/src/jalview/javascript/MouseOverStructureListener.java b/src/jalview/javascript/MouseOverStructureListener.java index f46cd90..4b1c9ce 100644 --- a/src/jalview/javascript/MouseOverStructureListener.java +++ b/src/jalview/javascript/MouseOverStructureListener.java @@ -20,6 +20,9 @@ */ package jalview.javascript; +import java.util.ArrayList; +import java.util.List; + import jalview.api.AlignmentViewPanel; import jalview.api.FeatureRenderer; import jalview.api.SequenceRenderer; @@ -33,9 +36,6 @@ 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 @@ -312,4 +312,10 @@ public class MouseOverStructureListener extends JSFunctionExec implements } + @Override + public boolean isListeningFor(SequenceI seq) + { + return true; + } + } diff --git a/src/jalview/structure/StructureListener.java b/src/jalview/structure/StructureListener.java index 69658bf..2364549 100644 --- a/src/jalview/structure/StructureListener.java +++ b/src/jalview/structure/StructureListener.java @@ -22,6 +22,8 @@ package jalview.structure; import java.util.List; +import jalview.datamodel.SequenceI; + public interface StructureListener { /** @@ -56,4 +58,12 @@ public interface StructureListener * @param svl */ public void releaseReferences(Object svl); + + /** + * Answers true if this listener is interested in the given sequence + * + * @param seq + * @return + */ + public boolean isListeningFor(SequenceI seq); } diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index ef4a7a5..0253a7e 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -756,6 +756,10 @@ public class StructureSelectionManager protected void highlightStructure(StructureListener sl, SequenceI seq, int index) { + if (!sl.isListeningFor(seq)) + { + return; + } int atomNo; List atoms = new ArrayList(); for (StructureMapping sm : mappings) diff --git a/src/jalview/structures/models/AAStructureBindingModel.java b/src/jalview/structures/models/AAStructureBindingModel.java index 86c9a21..e77a23c 100644 --- a/src/jalview/structures/models/AAStructureBindingModel.java +++ b/src/jalview/structures/models/AAStructureBindingModel.java @@ -601,4 +601,26 @@ public abstract class AAStructureBindingModel extends } return true; } + + @Override + public boolean isListeningFor(SequenceI seq) + { + if (sequence != null) + { + for (SequenceI[] seqs : sequence) + { + if (seqs != null) + { + for (SequenceI s : seqs) + { + if (s == seq) + { + return true; + } + } + } + } + } + return false; + } } \ No newline at end of file -- 1.7.10.2