JAL-1953 2.11.2 with Archeopteryx!
[jalview.git] / src / jalview / ext / treeviewer / TreeI.java
diff --git a/src/jalview/ext/treeviewer/TreeI.java b/src/jalview/ext/treeviewer/TreeI.java
new file mode 100644 (file)
index 0000000..08c3d04
--- /dev/null
@@ -0,0 +1,89 @@
+package jalview.ext.treeviewer;
+
+import jalview.datamodel.SequenceI;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Interface for implementing a phylogenetic tree.
+ * 
+ * @author kjvanderheide
+ *
+ */
+public interface TreeI
+{
+  /**
+   * Uses this tree as the basis for a new tree frame.
+   * 
+   * @param instanceTitle
+   *          name of the new tree frame.
+   * @return
+   */
+  TreeFrameI createTreeViewerFromTree(String instanceTitle);
+
+  public String[] getAllLeafNames();
+
+  public TreeNodeI[] getAllNodes();
+
+  /**
+   * Gets the node that has the maximum branch length from the root (or top
+   * level node if tree is unrooted).
+   * 
+   * @return
+   */
+  public TreeNodeI getFurthestNode();
+
+  /**
+   * Returns the longest total branch length from the root to a leaf node.
+   * 
+   * @param adjustForCollapsedSubtrees
+   *          true if nodes part of a collapsed (hidden) subtree should be
+   *          considered.
+   * @return
+   */
+  public double getMaximumLength(boolean adjustForCollapsedSubtrees);
+
+  public List<SequenceI> getNodeSequences();
+
+  public TreeNodeI getNodeWithName(String name);
+
+  public TreeNodeI getRoot();
+
+  public String getTreeName();
+
+  /**
+   * Check if the tree actually contains any nodes.
+   * 
+   * @return true if tree has no nodes (or is deleted), false otherwise.
+   */
+  public boolean isEmpty();
+
+  public Iterator<TreeNodeI> iterateInLevelOrder();
+
+  public Iterator<TreeNodeI> iterateInPostOrder();
+
+  public Iterator<TreeNodeI> iterateInPreOrder();
+
+  /**
+   * This should write the tree to the richest file format available for
+   * compatibility reasons as this is the method used when Jalview saves a tree
+   * to its project.
+   * 
+   * @param outputFile
+   *          File that tree should be written to
+   * @throws IOException
+   */
+  public void outputAsFile(File outputFile) throws IOException;
+
+  public void setRerootable(boolean b);
+
+  public void setRoot(TreeNodeI rootNode);
+
+  public void setRooted(boolean b);
+
+  public void setTreeName(String treeTitle);
+
+}