in progress
[jalview.git] / forester / java / src / org / forester / phylogeny / data / NodeVisualization.java
1 // $Id:
2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
4 //
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
7 // All rights reserved
8 //
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.
13 //
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.
18 //
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
22 //
23 // Contact: phylosoft @ gmail . com
24 // WWW: www.phylosoft.org
25
26 package org.forester.phylogeny.data;
27
28 import java.awt.Color;
29 import java.io.IOException;
30 import java.io.Writer;
31
32 public class NodeVisualization implements PhylogenyData {
33
34     public enum NodeFill {
35         NONE, GRADIENT, SOLID
36     }
37
38     public enum NodeShape {
39         CIRCLE, RECTANGLE
40     }
41     private NodeShape _shape;
42     private NodeFill  _fill_type;
43     private Color     _border_color;
44     private Color     _fill_color;
45     private double    _size;
46
47     public NodeVisualization() {
48         _shape = NodeShape.CIRCLE;
49         _fill_type = NodeFill.SOLID;
50         _border_color = null;
51         _fill_color = null;
52         _size = 0;
53     }
54
55     public NodeVisualization( final NodeShape shape,
56                               final NodeFill fill_type,
57                               final Color border_color,
58                               final Color fill_color,
59                               final double size ) {
60         _shape = shape;
61         _fill_type = fill_type;
62         _border_color = border_color;
63         _fill_color = fill_color;
64         _size = size;
65     }
66
67     @Override
68     public StringBuffer asSimpleText() {
69         return asText();
70     }
71
72     @Override
73     public StringBuffer asText() {
74         final StringBuffer sb = new StringBuffer();
75         return sb;
76     }
77
78     @Override
79     public PhylogenyData copy() {
80         return new NodeVisualization( getShape(),
81                                       getFillType(),
82                                       getBorderColor() != null ? new Color( getBorderColor().getRed(), getBorderColor()
83                                               .getGreen(), getBorderColor().getBlue() ) : null,
84                                       getFillColor() != null ? new Color( getFillColor().getRed(), getFillColor()
85                                               .getGreen(), getFillColor().getBlue() ) : null,
86                                       getSize() );
87     }
88
89     public Color getBorderColor() {
90         return _border_color;
91     }
92
93     public Color getFillColor() {
94         return _fill_color;
95     }
96
97     public NodeFill getFillType() {
98         return _fill_type;
99     }
100
101     public NodeShape getShape() {
102         return _shape;
103     }
104
105     public double getSize() {
106         return _size;
107     }
108
109     @Override
110     public boolean isEqual( final PhylogenyData data ) {
111         throw new UnsupportedOperationException();
112     }
113
114     public void setBorderColor( final Color border_color ) {
115         _border_color = border_color;
116     }
117
118     public void setFillColor( final Color fill_color ) {
119         _fill_color = fill_color;
120     }
121
122     public void setFillType( final NodeFill fill_type ) {
123         _fill_type = fill_type;
124     }
125
126     public void setShape( final NodeShape shape ) {
127         _shape = shape;
128     }
129
130     public void setSize( final double size ) {
131         _size = size;
132     }
133
134     @Override
135     public StringBuffer toNHX() {
136         throw new UnsupportedOperationException();
137     }
138
139     @Override
140     public void toPhyloXML( final Writer writer, final int level, final String indentation ) throws IOException {
141         throw new UnsupportedOperationException();
142     }
143
144     @Override
145     public String toString() {
146         return asText().toString();
147     }
148 }