updated to jalview 2.1 and begun ArchiveClient/VamsasClient/VamsasStore updates.
[jalview.git] / src / jalview / datamodel / SequenceNode.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer
3  * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18  */
19 package jalview.datamodel;
20
21 import java.awt.*;
22
23
24 /**
25  * DOCUMENT ME!
26  *
27  * @author $author$
28  * @version $Revision$
29  */
30 public class SequenceNode extends BinaryNode
31 {
32     /** DOCUMENT ME!! */
33     public float dist;
34
35     /** DOCUMENT ME!! */
36     public int count;
37
38     /** DOCUMENT ME!! */
39     public float height;
40
41     /** DOCUMENT ME!! */
42     public float ycount;
43
44     /** DOCUMENT ME!! */
45     public Color color = Color.black;
46
47     /** DOCUMENT ME!! */
48     public boolean dummy = false;
49     private boolean placeholder = false;
50
51     /**
52      * Creates a new SequenceNode object.
53      */
54     public SequenceNode()
55     {
56         super();
57     }
58
59     /**
60      * Creates a new SequenceNode object.
61      *
62      * @param val DOCUMENT ME!
63      * @param parent DOCUMENT ME!
64      * @param dist DOCUMENT ME!
65      * @param name DOCUMENT ME!
66      */
67     public SequenceNode(Object val, SequenceNode parent, float dist, String name)
68     {
69         super(val, parent, name);
70         this.dist = dist;
71     }
72
73     /**
74      * Creates a new SequenceNode object.
75      *
76      * @param val DOCUMENT ME!
77      * @param parent DOCUMENT ME!
78      * @param name DOCUMENT ME!
79      * @param dist DOCUMENT ME!
80      * @param bootstrap DOCUMENT ME!
81      * @param dummy DOCUMENT ME!
82      */
83     public SequenceNode(Object val, SequenceNode parent, String name,
84         float dist, int bootstrap, boolean dummy)
85     {
86         super(val, parent, name);
87         this.dist = dist;
88         this.bootstrap = bootstrap;
89         this.dummy = dummy;
90     }
91
92     /**
93      * @param dummy true if node is created for the representation of polytomous trees
94      */
95     public boolean isDummy()
96     {
97         return dummy;
98     }
99
100     /* @param placeholder is true if the sequence refered to in the
101      *  element node is not actually present in the associated alignment
102      */
103     public boolean isPlaceholder()
104     {
105         return placeholder;
106     }
107
108     /**
109      * DOCUMENT ME!
110      *
111      * @param newstate DOCUMENT ME!
112      *
113      * @return DOCUMENT ME!
114      */
115     public boolean setDummy(boolean newstate)
116     {
117         boolean oldstate = dummy;
118         dummy = newstate;
119
120         return oldstate;
121     }
122
123     /**
124      * DOCUMENT ME!
125      *
126      * @param Placeholder DOCUMENT ME!
127      */
128     public void setPlaceholder(boolean Placeholder)
129     {
130         this.placeholder = Placeholder;
131     }
132
133     /**
134      * ascends the tree but doesn't stop until a non-dummy node is discovered.
135      * This will probably break if the tree is a mixture of BinaryNodes and SequenceNodes.
136      */
137     public SequenceNode AscendTree()
138     {
139         SequenceNode c = this;
140
141         do
142         {
143             c = (SequenceNode) c.parent();
144         }
145         while ((c != null) && c.dummy);
146
147         return c;
148     }
149 }