Formatted source
[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 package jalview.datamodel;\r
20 \r
21 import java.awt.*;\r
22 \r
23 \r
24 public class SequenceNode extends BinaryNode {\r
25     public float dist;\r
26     public int count;\r
27     public float height;\r
28     public float ycount;\r
29     public Color color = Color.black;\r
30     public boolean dummy = false;\r
31     private boolean placeholder = false;\r
32 \r
33     public SequenceNode() {\r
34         super();\r
35     }\r
36 \r
37     public SequenceNode(Object val, SequenceNode parent, float dist, String name) {\r
38         super(val, parent, name);\r
39         this.dist = dist;\r
40     }\r
41 \r
42     public SequenceNode(Object val, SequenceNode parent, String name,\r
43         float dist, int bootstrap, boolean dummy) {\r
44         super(val, parent, name);\r
45         this.dist = dist;\r
46         this.bootstrap = bootstrap;\r
47         this.dummy = dummy;\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     public boolean isDummy() {\r
54         return dummy;\r
55     }\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         return placeholder;\r
62     }\r
63 \r
64     public boolean setDummy(boolean newstate) {\r
65         boolean oldstate = dummy;\r
66         dummy = newstate;\r
67 \r
68         return oldstate;\r
69     }\r
70 \r
71     public void setPlaceholder(boolean Placeholder) {\r
72         this.placeholder = Placeholder;\r
73     }\r
74 \r
75     /**\r
76      * ascends the tree but doesn't stop until a non-dummy node is discovered.\r
77      * This will probably break if the tree is a mixture of BinaryNodes and SequenceNodes.\r
78      */\r
79     public SequenceNode AscendTree() {\r
80         SequenceNode c = this;\r
81 \r
82         do {\r
83             c = (SequenceNode) c.parent();\r
84         } while ((c != null) && c.dummy);\r
85 \r
86         return c;\r
87     }\r
88 }\r