74776ea5ddb237765a1aa15cce1b9762861d7b4e
[jalview.git] / src / jalview / datamodel / SequenceNode.java
1 /*\r
2 * Jalview - A Sequence Alignment Editor and Viewer\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
4 *\r
5 * This program is free software; you can redistribute it and/or\r
6 * modify it under the terms of the GNU General Public License\r
7 * as published by the Free Software Foundation; either version 2\r
8 * of the License, or (at your option) any later version.\r
9 *\r
10 * This program is distributed in the hope that it will be useful,\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 * GNU General Public License for more details.\r
14 *\r
15 * You should have received a copy of the GNU General Public License\r
16 * along with this program; if not, write to the Free Software\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
18 */\r
19 \r
20 package jalview.datamodel;\r
21 \r
22 import java.awt.*;\r
23 \r
24 public class SequenceNode extends BinaryNode {\r
25 \r
26   public float dist;\r
27   public int count;\r
28   public float height;\r
29   public float ycount;\r
30   public Color color = Color.black;\r
31   public boolean dummy = false;\r
32   private boolean placeholder = false;\r
33 \r
34   public SequenceNode() {\r
35     super();\r
36   }\r
37 \r
38   public SequenceNode(Object val, SequenceNode parent, float dist,String name) {\r
39     super(val,parent,name);\r
40     this.dist = dist;\r
41   }\r
42   public SequenceNode(Object val, SequenceNode parent, String name, float dist, int bootstrap, boolean dummy) {\r
43     super(val,parent,name);\r
44     this.dist = dist;\r
45     this.bootstrap = bootstrap;\r
46     this.dummy = dummy;\r
47   }\r
48 \r
49 \r
50   /**\r
51    * @param dummy true if node is created for the representation of polytomous trees\r
52    */\r
53 \r
54   public boolean isDummy() {\r
55     return dummy;\r
56   }\r
57   /* @param placeholder is true if the sequence refered to in the\r
58    *  element node is not actually present in the associated alignment\r
59    */\r
60   public boolean isPlaceholder()\r
61   {\r
62     return placeholder;\r
63   }\r
64 \r
65   public boolean setDummy(boolean newstate) {\r
66     boolean oldstate = dummy;\r
67     dummy = newstate;\r
68     return oldstate;\r
69   }\r
70 \r
71   public void setPlaceholder(boolean Placeholder)\r
72   {\r
73     this.placeholder = Placeholder;\r
74   }\r
75 \r
76   /**\r
77    * ascends the tree but doesn't stop until a non-dummy node is discovered.\r
78    * This will probably break if the tree is a mixture of BinaryNodes and SequenceNodes.\r
79    */\r
80 \r
81   public SequenceNode AscendTree() {\r
82     SequenceNode c = this;\r
83     do {\r
84       c = (SequenceNode) c.parent();\r
85     } while (c!=null && c.dummy);\r
86     return c;\r
87   }\r
88 }\r