2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3 * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
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.
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.
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
19 package jalview.datamodel;
29 public class SequenceNode
45 public Color color = Color.black;
48 public boolean dummy = false;
49 private boolean placeholder = false;
52 * Creates a new SequenceNode object.
60 * Creates a new SequenceNode object.
62 * @param val DOCUMENT ME!
63 * @param parent DOCUMENT ME!
64 * @param dist DOCUMENT ME!
65 * @param name DOCUMENT ME!
67 public SequenceNode(Object val, SequenceNode parent, float dist, String name)
69 super(val, parent, name);
74 * Creates a new SequenceNode object.
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!
83 public SequenceNode(Object val, SequenceNode parent, String name,
84 float dist, int bootstrap, boolean dummy)
86 super(val, parent, name);
88 this.bootstrap = bootstrap;
93 * @param dummy true if node is created for the representation of polytomous trees
95 public boolean isDummy()
100 /* @param placeholder is true if the sequence refered to in the
101 * element node is not actually present in the associated alignment
103 public boolean isPlaceholder()
111 * @param newstate DOCUMENT ME!
113 * @return DOCUMENT ME!
115 public boolean setDummy(boolean newstate)
117 boolean oldstate = dummy;
126 * @param Placeholder DOCUMENT ME!
128 public void setPlaceholder(boolean Placeholder)
130 this.placeholder = Placeholder;
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.
137 public SequenceNode AscendTree()
139 SequenceNode c = this;
143 c = (SequenceNode) c.parent();
145 while ( (c != null) && c.dummy);
150 * test if this node has a name that might be a label rather than a bootstrap value
151 * @return true if node has a non-numeric label
153 public boolean isSequenceLabel()
155 if (name!=null && name.length()>0)
157 for (int c=0,s=name.length(); c<s; c++)
159 char q = name.charAt(c);
160 if ('0'<=q && q<='9')