JAL-2826 added action performed for hiding collapsed sequences
[jalview.git] / src / jalview / ext / treeviewer / TreeViewerBindingI.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.ext.treeviewer;
22
23 import jalview.commands.CommandI;
24 import jalview.datamodel.SequenceI;
25 import jalview.gui.AlignmentPanel;
26 import jalview.structure.SelectionListener;
27 import jalview.structure.SelectionSource;
28
29 import java.awt.event.ActionListener;
30 import java.awt.event.MouseListener;
31 import java.util.Map;
32
33 /**
34  * 
35  * Interface for associating the nodes of a tree viewer with Jalview alignment
36  * sequences and communicating between the two. Assumes a tree viewer will both
37  * want to receive and send selection events.
38  * 
39  * @author kjvanderheide
40  *
41  * 
42  */
43 public interface TreeViewerBindingI
44         extends ActionListener, MouseListener, SelectionListener,
45         SelectionSource
46 {
47   /**
48    * Gets the mapping for sequences with their associated tree nodes
49    * 
50    * @return
51    */
52   public Map<SequenceI, TreeNodeI> getAlignmentWithNodes();
53
54   /**
55    * Gets the mapping for tree nodes with their associated sequences
56    * 
57    * @return
58    */
59   public Map<TreeNodeI, SequenceI> getNodesWithAlignment();
60
61   /**
62    * Triggers a tree partition from the specified x coordinate.
63    * 
64    * @param x
65    * 
66    */
67   public void partitionTree(final int x);
68
69   /**
70    * Looks up the given TreeNodeI in the tree and highlights Jalview sequences
71    * that belong to it or its descendants.
72    * 
73    * @param parentNode
74    *          node from where the descendants should get matched, this node
75    *          should be internal.
76    */
77   public void showMatchingChildSequences(TreeNodeI parentNode);
78
79   /**
80    * Highlights the Jalview sequence belonging to the given TreeNodeI (if
81    * possible).
82    * 
83    * @param nodeToMatch
84    */
85   public void showMatchingSequence(TreeNodeI nodeToMatch);
86
87   /**
88    * If a node is selected in the tree panel this method highlights the
89    * corresponding sequence in the Jalview alignment view. If an internal node
90    * is selected all child sequences get highlighted as well.
91    */
92   public void showNodeSelectionOnAlign(TreeNodeI node);
93
94   /**
95    * Sorts the given alignment by the order in which the sequences appear in the
96    * tree.
97    * 
98    * @param alignPanel
99    *          panel containing the alignment to be sorted.
100    * @return the sorting Command
101    */
102   public CommandI sortAlignmentIn(AlignmentPanel alignPanel);
103
104   /**
105    * Is triggered when the user wants to sort the Jalview alignment by the
106    * sequence order of the tree.
107    */
108   public void sortByTree_actionPerformed();
109
110   /**
111    * Is triggered when the users wants to hide sequences in the Jalview
112    * alignment view that are part of a currently collapsed sub tree.
113    */
114   public void hideCollapsedSequences_actionPerformed();
115
116   /**
117    * If the nodes that should be matched have changed (different one selected by
118    * the user), this method notifies the Jalview alignment view that the
119    * matching sequences have changed as well.
120    * 
121    * @param sequence
122    *          the new SequenceI that should be matched.
123    */
124   public void treeSelectionChanged(SequenceI sequence);
125
126 }