fbda8f1c37442371742dda63beb7cd574b5ceaf6
[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 a generic phylogenetic tree, this does not necessarily have to
12  * be part of a tree panel.
13  * 
14  * @author kjvanderheide
15  *
16  */
17 public interface TreeI
18 {
19   /**
20    * Uses this tree as the basis for a new tree frame.
21    * 
22    * @param instanceTitle
23    *          name of the new tree frame.
24    * @return
25    */
26   TreeFrameI createTreeViewerFromTree(String instanceTitle);
27
28   public String[] getAllLeafNames();
29
30   public TreeNodeI[] getAllNodes();
31
32   public TreeNodeI getFurthestNode();
33
34   public double getHeight(boolean adjustForCollapsedSubtrees);
35
36   public List<SequenceI> getNodeSequences();
37
38   public TreeNodeI getNodeWithName(String name);
39
40   public TreeNodeI getRoot();
41
42   public String getTreeName();
43
44   /**
45    * Check if the tree actually contains any nodes.
46    * 
47    * @return true if tree has no nodes (or is deleted), false otherwise.
48    */
49   public boolean isEmpty();
50
51   public Iterator<TreeNodeI> iterateInLevelOrder();
52
53   public Iterator<TreeNodeI> iterateInPostOrder();
54
55   public Iterator<TreeNodeI> iterateInPreOrder();
56
57   /**
58    * This should write the tree to the richest file format available for
59    * compatibility reasons as this is the method used when Jalview saves a tree
60    * to its project.
61    * 
62    * @param outputFile
63    *          File that tree should be written to
64    * @throws IOException
65    */
66   public void outputAsFile(File outputFile) throws IOException;
67
68   public void setRerootable(boolean b);
69
70   public void setRoot(TreeNodeI rootNode);
71
72   public void setRooted(boolean b);
73
74   public void setTreeName(String treeTitle);
75
76 }