Tree io modifications, including support for polytomous trees by the
[jalview.git] / src / jalview / datamodel / SequenceNode.java
1 package jalview.datamodel;\r
2 \r
3 import java.awt.Color;\r
4 \r
5 public class SequenceNode extends BinaryNode {\r
6 \r
7   public float dist;\r
8   public int count;\r
9   public float height;\r
10   public float ycount;\r
11   public Color color = Color.black;\r
12   public boolean dummy = false;\r
13   public SequenceNode() {\r
14     super();\r
15   }\r
16 \r
17   public SequenceNode(Object val, SequenceNode parent, float dist,String name) {\r
18     super(val,parent,name);\r
19     this.dist = dist;\r
20   }\r
21   public SequenceNode(Object val, SequenceNode parent, String name, float dist, int bootstrap, boolean dummy) {\r
22     super(val,parent,name);\r
23     this.dist = dist;\r
24     this.bootstrap = bootstrap;\r
25     this.dummy = dummy;\r
26   }\r
27 \r
28 \r
29   /**\r
30    * @param dummy true if node is created for the representation of polytomous trees\r
31    */\r
32 \r
33   public boolean isDummy() {\r
34     return dummy;\r
35   }\r
36   public boolean setDummy(boolean newstate) {\r
37     boolean oldstate = dummy;\r
38     dummy = newstate;\r
39     return oldstate;\r
40   }\r
41 \r
42   /**\r
43    * ascends the tree but doesn't stop until a non-dummy node is discovered.\r
44    * This will probably break if the tree is a mixture of BinaryNodes and SequenceNodes.\r
45    */\r
46 \r
47   public SequenceNode AscendTree() {\r
48     SequenceNode c = this;\r
49     do {\r
50       c = (SequenceNode) c.parent();\r
51     } while (c!=null && c.dummy);\r
52     return c;\r
53   }\r
54 }\r