JAL-2826 added action performed for hiding collapsed sequences kjvdh/features/PhylogenyViewer spikes/koen
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Fri, 2 Feb 2018 14:04:49 +0000 (14:04 +0000)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Fri, 2 Feb 2018 14:05:07 +0000 (14:05 +0000)
src/jalview/ext/archaeopteryx/AptxFrame.java
src/jalview/ext/treeviewer/JalviewBinding.java
src/jalview/ext/treeviewer/TreeFrameI.java
src/jalview/ext/treeviewer/TreeViewerBindingI.java

index 2cf7953..e321c90 100644 (file)
@@ -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());
 
index 630d586..987e3a6 100644 (file)
@@ -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 });
+
+
+        }
+
+      }
+    }
+
+
+  }
 
 }
 
index 51c897e..26f74c2 100644 (file)
@@ -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
index afbceab..0c0af6f 100644 (file)
@@ -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.