08c3d04c899f236ebef648987f43cbe55db7e1c0
[jalview.git] / src / jalview / ext / treeviewer / TreeI.java
1 package jalview.ext.treeviewer;
2
3 import jalview.datamodel.SequenceI;
4
5 import java.io.File;
6 import java.io.IOException;
7 import java.util.Iterator;
8 import java.util.List;
9
10 /**
11  * Interface for implementing a phylogenetic tree.
12  * 
13  * @author kjvanderheide
14  *
15  */
16 public interface TreeI
17 {
18   /**
19    * Uses this tree as the basis for a new tree frame.
20    * 
21    * @param instanceTitle
22    *          name of the new tree frame.
23    * @return
24    */
25   TreeFrameI createTreeViewerFromTree(String instanceTitle);
26
27   public String[] getAllLeafNames();
28
29   public TreeNodeI[] getAllNodes();
30
31   /**
32    * Gets the node that has the maximum branch length from the root (or top
33    * level node if tree is unrooted).
34    * 
35    * @return
36    */
37   public TreeNodeI getFurthestNode();
38
39   /**
40    * Returns the longest total branch length from the root to a leaf node.
41    * 
42    * @param adjustForCollapsedSubtrees
43    *          true if nodes part of a collapsed (hidden) subtree should be
44    *          considered.
45    * @return
46    */
47   public double getMaximumLength(boolean adjustForCollapsedSubtrees);
48
49   public List<SequenceI> getNodeSequences();
50
51   public TreeNodeI getNodeWithName(String name);
52
53   public TreeNodeI getRoot();
54
55   public String getTreeName();
56
57   /**
58    * Check if the tree actually contains any nodes.
59    * 
60    * @return true if tree has no nodes (or is deleted), false otherwise.
61    */
62   public boolean isEmpty();
63
64   public Iterator<TreeNodeI> iterateInLevelOrder();
65
66   public Iterator<TreeNodeI> iterateInPostOrder();
67
68   public Iterator<TreeNodeI> iterateInPreOrder();
69
70   /**
71    * This should write the tree to the richest file format available for
72    * compatibility reasons as this is the method used when Jalview saves a tree
73    * to its project.
74    * 
75    * @param outputFile
76    *          File that tree should be written to
77    * @throws IOException
78    */
79   public void outputAsFile(File outputFile) throws IOException;
80
81   public void setRerootable(boolean b);
82
83   public void setRoot(TreeNodeI rootNode);
84
85   public void setRooted(boolean b);
86
87   public void setTreeName(String treeTitle);
88
89 }