From: kjvdheide Date: Fri, 2 Feb 2018 14:04:49 +0000 (+0000) Subject: JAL-2826 added action performed for hiding collapsed sequences X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fkjvdh%2Ffeatures%2FPhylogenyViewer;p=jalview.git JAL-2826 added action performed for hiding collapsed sequences --- diff --git a/src/jalview/ext/archaeopteryx/AptxFrame.java b/src/jalview/ext/archaeopteryx/AptxFrame.java index 2cf7953..e321c90 100644 --- a/src/jalview/ext/archaeopteryx/AptxFrame.java +++ b/src/jalview/ext/archaeopteryx/AptxFrame.java @@ -145,9 +145,12 @@ public class AptxFrame implements TreeFrameI else if (menu.getText().contains("View")) { menu.addSeparator(); + JMenuItem sortByTree = new JMenuItem("Sort alignment by tree"); JMenuItem refreshJalview = new JMenuItem( "Filter alignment to show only currently visible sequences"); + JMenuItem hideCollapsed = new JMenuItem( + "Hide sequences of collapsed nodes"); refreshJalview.setFont(menu.getFont()); refreshJalview.addActionListener(new ActionListener() { @@ -174,8 +177,23 @@ public class AptxFrame implements TreeFrameI }); + hideCollapsed.addActionListener(new ActionListener() + { + + @Override + public void actionPerformed(ActionEvent e) + { + TreeViewerBindingI bindingManager = TreeViewerUtils + .getActiveTreeViews().get(AptxFrame.this); + bindingManager.hideCollapsedSequences_actionPerformed(); + + } + + }); + menu.add(sortByTree); menu.add(refreshJalview); + menu.add(hideCollapsed); sortByTree.setFont(menu.getFont()); diff --git a/src/jalview/ext/treeviewer/JalviewBinding.java b/src/jalview/ext/treeviewer/JalviewBinding.java index 630d586..987e3a6 100644 --- a/src/jalview/ext/treeviewer/JalviewBinding.java +++ b/src/jalview/ext/treeviewer/JalviewBinding.java @@ -177,11 +177,13 @@ public final class JalviewBinding TreeViewerUtils.associateNodesWithJalviewSequences(aptxFrame, parentAvport, sequencesBoundToNodes, nodesBoundToSequences); + for (SequenceI seq : parentAvport.getAlignment().getSequencesArray()) { if (!sequencesBoundToNodes.containsKey(seq)) { parentAvport.hideSequence(new SequenceI[] { seq }); + } } } @@ -732,6 +734,28 @@ public final class JalviewBinding return nodesBoundToSequences; } + @Override + public void hideCollapsedSequences_actionPerformed() + { + parentAvport.showAllHiddenSeqs(); + + for (TreeNodeI node : treeView.getTree().getAllNodes()) + { + if (node.isCollapsed()) + { + SequenceI seqToHide = nodesBoundToSequences.get(node); + if (seqToHide != null) + { + parentAvport.hideSequence(new SequenceI[] { seqToHide }); + + + } + + } + } + + + } } diff --git a/src/jalview/ext/treeviewer/TreeFrameI.java b/src/jalview/ext/treeviewer/TreeFrameI.java index 51c897e..26f74c2 100644 --- a/src/jalview/ext/treeviewer/TreeFrameI.java +++ b/src/jalview/ext/treeviewer/TreeFrameI.java @@ -29,7 +29,7 @@ public interface TreeFrameI public void addFrameListener(InternalFrameListener listener); /** - * Method for adding the actual frame to Jalview, probably through + * Method for adding the actual frame to Jalview, probably by calling * {@link jalview.gui.Desktop#addInternalFrame(javax.swing.JInternalFrame, String, boolean, int, int, boolean, boolean)} * * @param title diff --git a/src/jalview/ext/treeviewer/TreeViewerBindingI.java b/src/jalview/ext/treeviewer/TreeViewerBindingI.java index afbceab..0c0af6f 100644 --- a/src/jalview/ext/treeviewer/TreeViewerBindingI.java +++ b/src/jalview/ext/treeviewer/TreeViewerBindingI.java @@ -102,12 +102,18 @@ public interface TreeViewerBindingI public CommandI sortAlignmentIn(AlignmentPanel alignPanel); /** - * This should be triggered when the user wants to sort the Jalview alignment - * by the sequence order of the tree. + * Is triggered when the user wants to sort the Jalview alignment by the + * sequence order of the tree. */ public void sortByTree_actionPerformed(); /** + * Is triggered when the users wants to hide sequences in the Jalview + * alignment view that are part of a currently collapsed sub tree. + */ + public void hideCollapsedSequences_actionPerformed(); + + /** * If the nodes that should be matched have changed (different one selected by * the user), this method notifies the Jalview alignment view that the * matching sequences have changed as well.