JAL-1953 2.11.2 with Archeopteryx!
[jalview.git] / src / jalview / ext / treeviewer / TreeViewerBindingI.java
diff --git a/src/jalview/ext/treeviewer/TreeViewerBindingI.java b/src/jalview/ext/treeviewer/TreeViewerBindingI.java
new file mode 100644 (file)
index 0000000..0c0af6f
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.ext.treeviewer;
+
+import jalview.commands.CommandI;
+import jalview.datamodel.SequenceI;
+import jalview.gui.AlignmentPanel;
+import jalview.structure.SelectionListener;
+import jalview.structure.SelectionSource;
+
+import java.awt.event.ActionListener;
+import java.awt.event.MouseListener;
+import java.util.Map;
+
+/**
+ * 
+ * Interface for associating the nodes of a tree viewer with Jalview alignment
+ * sequences and communicating between the two. Assumes a tree viewer will both
+ * want to receive and send selection events.
+ * 
+ * @author kjvanderheide
+ *
+ * 
+ */
+public interface TreeViewerBindingI
+        extends ActionListener, MouseListener, SelectionListener,
+        SelectionSource
+{
+  /**
+   * Gets the mapping for sequences with their associated tree nodes
+   * 
+   * @return
+   */
+  public Map<SequenceI, TreeNodeI> getAlignmentWithNodes();
+
+  /**
+   * Gets the mapping for tree nodes with their associated sequences
+   * 
+   * @return
+   */
+  public Map<TreeNodeI, SequenceI> getNodesWithAlignment();
+
+  /**
+   * Triggers a tree partition from the specified x coordinate.
+   * 
+   * @param x
+   * 
+   */
+  public void partitionTree(final int x);
+
+  /**
+   * Looks up the given TreeNodeI in the tree and highlights Jalview sequences
+   * that belong to it or its descendants.
+   * 
+   * @param parentNode
+   *          node from where the descendants should get matched, this node
+   *          should be internal.
+   */
+  public void showMatchingChildSequences(TreeNodeI parentNode);
+
+  /**
+   * Highlights the Jalview sequence belonging to the given TreeNodeI (if
+   * possible).
+   * 
+   * @param nodeToMatch
+   */
+  public void showMatchingSequence(TreeNodeI nodeToMatch);
+
+  /**
+   * If a node is selected in the tree panel this method highlights the
+   * corresponding sequence in the Jalview alignment view. If an internal node
+   * is selected all child sequences get highlighted as well.
+   */
+  public void showNodeSelectionOnAlign(TreeNodeI node);
+
+  /**
+   * Sorts the given alignment by the order in which the sequences appear in the
+   * tree.
+   * 
+   * @param alignPanel
+   *          panel containing the alignment to be sorted.
+   * @return the sorting Command
+   */
+  public CommandI sortAlignmentIn(AlignmentPanel alignPanel);
+
+  /**
+   * 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.
+   * 
+   * @param sequence
+   *          the new SequenceI that should be matched.
+   */
+  public void treeSelectionChanged(SequenceI sequence);
+
+}