2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // Contact: phylosoft @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
26 package org.forester.phylogeny.data;
28 import java.io.IOException;
29 import java.io.Writer;
31 import org.forester.io.parsers.phyloxml.PhyloXmlMapping;
32 import org.forester.util.ForesterUtil;
34 public class BranchWidth implements PhylogenyData {
36 public final static double BRANCH_WIDTH_DEFAULT_VALUE = 1.0;
37 private final double _value;
39 public BranchWidth() {
40 _value = BRANCH_WIDTH_DEFAULT_VALUE;
43 public BranchWidth( final double value ) {
48 public StringBuffer asSimpleText() {
49 return new StringBuffer( getValue() + "" );
53 public StringBuffer asText() {
54 return asSimpleText();
58 public PhylogenyData copy() {
59 return new BranchWidth( getValue() );
62 public double getValue() {
67 public boolean isEqual( final PhylogenyData data ) {
68 return getValue() == ( ( BranchWidth ) data ).getValue();
72 public StringBuffer toNHX() {
73 throw new UnsupportedOperationException();
77 public void toPhyloXML( final Writer w, final int level, final String indentation ) throws IOException {
78 w.write( ForesterUtil.LINE_SEPARATOR );
79 w.write( indentation );
80 PhylogenyDataUtil.appendElement( w, PhyloXmlMapping.WIDTH, getValue() + "" );
84 public String toString() {
85 return asText().toString();