added tree node property for sequence placeholders.
[jalview.git] / src / jalview / datamodel / SequenceNode.java
1 package jalview.datamodel;\r
2 \r
3 import java.awt.*;\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   private boolean placeholder = false;\r
14 \r
15   public SequenceNode() {\r
16     super();\r
17   }\r
18 \r
19   public SequenceNode(Object val, SequenceNode parent, float dist,String name) {\r
20     super(val,parent,name);\r
21     this.dist = dist;\r
22   }\r
23   public SequenceNode(Object val, SequenceNode parent, String name, float dist, int bootstrap, boolean dummy) {\r
24     super(val,parent,name);\r
25     this.dist = dist;\r
26     this.bootstrap = bootstrap;\r
27     this.dummy = dummy;\r
28   }\r
29 \r
30 \r
31   /**\r
32    * @param dummy true if node is created for the representation of polytomous trees\r
33    */\r
34 \r
35   public boolean isDummy() {\r
36     return dummy;\r
37   }\r
38   /* @param placeholder is true if the sequence refered to in the\r
39    *  element node is not actually present in the associated alignment\r
40    */\r
41   public boolean isPlaceholder()\r
42   {\r
43     return placeholder;\r
44   }\r
45 \r
46   public boolean setDummy(boolean newstate) {\r
47     boolean oldstate = dummy;\r
48     dummy = newstate;\r
49     return oldstate;\r
50   }\r
51 \r
52   public void setPlaceholder(boolean Placeholder)\r
53   {\r
54     this.placeholder = Placeholder;\r
55   }\r
56 \r
57   /**\r
58    * ascends the tree but doesn't stop until a non-dummy node is discovered.\r
59    * This will probably break if the tree is a mixture of BinaryNodes and SequenceNodes.\r
60    */\r
61 \r
62   public SequenceNode AscendTree() {\r
63     SequenceNode c = this;\r
64     do {\r
65       c = (SequenceNode) c.parent();\r
66     } while (c!=null && c.dummy);\r
67     return c;\r
68   }\r
69 }\r