Formatting
[jalview.git] / src / jalview / datamodel / SequenceNode.java
1 /*\r
2  * Jalview - A Sequence Alignment Editor and Viewer\r
3  * Copyright (C) 2007 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 package jalview.datamodel;\r
20 \r
21 import java.awt.*;\r
22 \r
23 /**\r
24  * DOCUMENT ME!\r
25  *\r
26  * @author $author$\r
27  * @version $Revision$\r
28  */\r
29 public class SequenceNode\r
30     extends BinaryNode\r
31 {\r
32   /** DOCUMENT ME!! */\r
33   public float dist;\r
34 \r
35   /** DOCUMENT ME!! */\r
36   public int count;\r
37 \r
38   /** DOCUMENT ME!! */\r
39   public float height;\r
40 \r
41   /** DOCUMENT ME!! */\r
42   public float ycount;\r
43 \r
44   /** DOCUMENT ME!! */\r
45   public Color color = Color.black;\r
46 \r
47   /** DOCUMENT ME!! */\r
48   public boolean dummy = false;\r
49   private boolean placeholder = false;\r
50 \r
51   /**\r
52    * Creates a new SequenceNode object.\r
53    */\r
54   public SequenceNode()\r
55   {\r
56     super();\r
57   }\r
58 \r
59   /**\r
60    * Creates a new SequenceNode object.\r
61    *\r
62    * @param val DOCUMENT ME!\r
63    * @param parent DOCUMENT ME!\r
64    * @param dist DOCUMENT ME!\r
65    * @param name DOCUMENT ME!\r
66    */\r
67   public SequenceNode(Object val, SequenceNode parent, float dist, String name)\r
68   {\r
69     super(val, parent, name);\r
70     this.dist = dist;\r
71   }\r
72 \r
73   /**\r
74    * Creates a new SequenceNode object.\r
75    *\r
76    * @param val DOCUMENT ME!\r
77    * @param parent DOCUMENT ME!\r
78    * @param name DOCUMENT ME!\r
79    * @param dist DOCUMENT ME!\r
80    * @param bootstrap DOCUMENT ME!\r
81    * @param dummy DOCUMENT ME!\r
82    */\r
83   public SequenceNode(Object val, SequenceNode parent, String name,\r
84                       float dist, int bootstrap, boolean dummy)\r
85   {\r
86     super(val, parent, name);\r
87     this.dist = dist;\r
88     this.bootstrap = bootstrap;\r
89     this.dummy = dummy;\r
90   }\r
91 \r
92   /**\r
93    * @param dummy true if node is created for the representation of polytomous trees\r
94    */\r
95   public boolean isDummy()\r
96   {\r
97     return dummy;\r
98   }\r
99 \r
100   /* @param placeholder is true if the sequence refered to in the\r
101    *  element node is not actually present in the associated alignment\r
102    */\r
103   public boolean isPlaceholder()\r
104   {\r
105     return placeholder;\r
106   }\r
107 \r
108   /**\r
109    * DOCUMENT ME!\r
110    *\r
111    * @param newstate DOCUMENT ME!\r
112    *\r
113    * @return DOCUMENT ME!\r
114    */\r
115   public boolean setDummy(boolean newstate)\r
116   {\r
117     boolean oldstate = dummy;\r
118     dummy = newstate;\r
119 \r
120     return oldstate;\r
121   }\r
122 \r
123   /**\r
124    * DOCUMENT ME!\r
125    *\r
126    * @param Placeholder DOCUMENT ME!\r
127    */\r
128   public void setPlaceholder(boolean Placeholder)\r
129   {\r
130     this.placeholder = Placeholder;\r
131   }\r
132 \r
133   /**\r
134    * ascends the tree but doesn't stop until a non-dummy node is discovered.\r
135    * This will probably break if the tree is a mixture of BinaryNodes and SequenceNodes.\r
136    */\r
137   public SequenceNode AscendTree()\r
138   {\r
139     SequenceNode c = this;\r
140 \r
141     do\r
142     {\r
143       c = (SequenceNode) c.parent();\r
144     }\r
145     while ( (c != null) && c.dummy);\r
146 \r
147     return c;\r
148   }\r
149 }\r