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.awt.Color;
29 import java.io.IOException;
30 import java.io.Writer;
32 import org.forester.io.parsers.phyloxml.PhyloXmlMapping;
33 import org.forester.util.ForesterUtil;
35 public class BranchColor implements PhylogenyData {
39 public BranchColor() {
43 public BranchColor( final Color color ) {
48 public StringBuffer asSimpleText() {
49 return new StringBuffer( getValue().toString() );
53 public StringBuffer asText() {
54 return new StringBuffer( getValue().toString() );
62 public PhylogenyData copy() {
63 final BranchColor bc = new BranchColor();
64 bc.setValue( getValue() );
68 public Color getValue() {
73 public boolean isEqual( final PhylogenyData data ) {
74 return getValue().equals( ( ( BranchColor ) data ).getValue() );
77 public void setValue( final Color color ) {
82 public StringBuffer toNHX() {
83 throw new UnsupportedOperationException();
87 public void toPhyloXML( final Writer writer, final int level, final String indentation ) throws IOException {
88 writer.write( ForesterUtil.LINE_SEPARATOR );
89 writer.write( indentation );
90 PhylogenyDataUtil.appendOpen( writer, PhyloXmlMapping.COLOR );
91 PhylogenyDataUtil.appendElement( writer, PhyloXmlMapping.COLOR_RED, getValue().getRed() + "", indentation );
92 PhylogenyDataUtil.appendElement( writer, PhyloXmlMapping.COLOR_GREEN, getValue().getGreen() + "", indentation );
93 PhylogenyDataUtil.appendElement( writer, PhyloXmlMapping.COLOR_BLUE, getValue().getBlue() + "", indentation );
94 writer.write( ForesterUtil.LINE_SEPARATOR );
95 writer.write( indentation );
96 PhylogenyDataUtil.appendClose( writer, PhyloXmlMapping.COLOR );
100 public String toString() {
101 return asText().toString();