From 4b25259949fbc582a579aa91922cde6f838155ea Mon Sep 17 00:00:00 2001 From: kjvdheide Date: Fri, 10 Nov 2017 15:31:40 +0000 Subject: [PATCH] JAL-2794 reorganized node select code, added subtree selection support --- .../ext/archaeopteryx/JalviewAptxBinding.java | 64 ++++++++++++++------ 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/src/jalview/ext/archaeopteryx/JalviewAptxBinding.java b/src/jalview/ext/archaeopteryx/JalviewAptxBinding.java index 6a6b3f1..e0a143c 100644 --- a/src/jalview/ext/archaeopteryx/JalviewAptxBinding.java +++ b/src/jalview/ext/archaeopteryx/JalviewAptxBinding.java @@ -13,9 +13,11 @@ import java.awt.event.ActionEvent; import java.awt.event.InputEvent; import java.awt.event.MouseEvent; import java.util.HashSet; +import java.util.List; import java.util.Map; import org.forester.archaeopteryx.MainFrame; +import org.forester.phylogeny.PhylogenyMethods; import org.forester.phylogeny.PhylogenyNode; /** @@ -131,7 +133,8 @@ public final class JalviewAptxBinding implements JalviewTreeViewerBindingI /** * If a node is selected in the tree panel this method highlights the - * corresponding sequence in the Jalview alignment view. + * corresponding sequence in the Jalview alignment view. If an internal node + * is selected all child sequences get highlighted as well. */ @Override public void showNodeSelectionOnAlign(final MouseEvent e) @@ -139,32 +142,57 @@ public final class JalviewAptxBinding implements JalviewTreeViewerBindingI final PhylogenyNode node = treeView.findNode(e.getX(), e.getY()); if (node != null) { - SequenceI matchingSequence = nodesBoundToSequences.get(node); - if (matchingSequence != null) + if ((e.getModifiers() & InputEvent.SHIFT_MASK) == 0) // clear previous + // selection if shift + // IS NOT pressed { + parentAvport.setSelectionGroup(null); + } - if ((e.getModifiers() & InputEvent.SHIFT_MASK) != 0) // shift is pressed - // (so multiple nodes - // can be selected) - { - // something? + if (node.isInternal()) + { + showMatchingChildSequences(node); - } - else - { - parentAvport.setSelectionGroup(null); // reset selection if shift - // isn't pressed - } + } + else + { + showMatchingSequence(node); - treeSelectionChanged(matchingSequence); - parentAvport.sendSelection(); // not actually needed? - PaintRefresher.Refresh(treeView, parentAvport.getSequenceSetId()); + } + } + } - } + + + + public void showMatchingSequence(final PhylogenyNode nodeToMatch) + { + SequenceI matchingSequence = nodesBoundToSequences.get(nodeToMatch); + if (matchingSequence != null) + { + treeSelectionChanged(matchingSequence); + parentAvport.sendSelection(); + PaintRefresher.Refresh(treeView, parentAvport.getSequenceSetId()); } + } + + public void showMatchingChildSequences(final PhylogenyNode parentNode) + { + final List childNodes = PhylogenyMethods + .getAllDescendants(parentNode); + for (PhylogenyNode childNode : childNodes) + { + SequenceI matchingSequence = nodesBoundToSequences.get(childNode); + if (matchingSequence != null) + { + treeSelectionChanged(matchingSequence); + } + } + parentAvport.sendSelection(); + PaintRefresher.Refresh(treeView, parentAvport.getSequenceSetId()); } /** -- 1.7.10.2