3 // FORESTER -- software libraries and applications
4 // for evolutionary biology research and applications.
6 // Copyright (C) 2008-2009 Christian M. Zmasek
7 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 // Contact: phylosoft @ gmail . com
25 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
27 package org.forester.archaeopteryx.phylogeny.data;
29 import java.awt.Color;
30 import java.awt.Dimension;
31 import java.awt.Graphics2D;
32 import java.awt.geom.Rectangle2D;
33 import java.io.IOException;
34 import java.io.Writer;
35 import java.util.List;
37 import org.forester.archaeopteryx.AptxUtil;
38 import org.forester.archaeopteryx.Configuration;
39 import org.forester.archaeopteryx.TreePanel;
40 import org.forester.phylogeny.data.PhylogenyData;
41 import org.forester.phylogeny.data.PhylogenyDataUtil;
42 import org.forester.util.DescriptiveStatistics;
43 import org.forester.util.ForesterUtil;
45 public final class RenderableMsaSequence implements RenderablePhylogenyData {
47 final static int VECTOR_DEFAULT_HEIGHT = 12;
48 public final static int VECTOR_DEFAULT_WIDTH = 120;
49 private double _rendering_factor_width = 1.0;
51 private final Rectangle2D _rectangle = new Rectangle2D.Float();
52 private double _height = VECTOR_DEFAULT_HEIGHT;
56 private Color _min_color = Color.BLUE;
57 private Color _max_color = Color.YELLOW;
58 private Color _mean_color = Color.WHITE;
59 private int _width = VECTOR_DEFAULT_WIDTH;
60 private static RenderableMsaSequence _instance = null;
62 private RenderableMsaSequence() {
67 public StringBuffer asSimpleText() {
68 return new StringBuffer( _seq );
72 public StringBuffer asText() {
73 return asSimpleText();
77 public Object clone() {
78 throw new NoSuchMethodError();
82 public PhylogenyData copy() {
83 throw new NoSuchMethodError();
87 public Dimension getOriginalSize() {
88 return new Dimension( getTotalLength(), ( int ) getRenderingHeight() );
92 public Object getParameter() {
96 public double getRenderingFactorWidth() {
97 return _rendering_factor_width;
101 public Dimension getRenderingSize() {
102 return getOriginalSize();
105 public int getTotalLength() {
106 return _seq.length();
110 public boolean isEqual( final PhylogenyData data ) {
111 throw new NoSuchMethodError();
115 public void render( final float x1,
118 final TreePanel tree_panel,
119 final boolean to_pdf ) {
121 final double start = x1 + 20.0;
122 g.drawString( _seq, x1, y1
127 public void setParameter( final double parameter ) {
128 throw new NoSuchMethodError();
131 public void setRenderingFactorWidth( final double rendering_factor_width ) {
132 _rendering_factor_width = rendering_factor_width;
136 public void setRenderingHeight( final float height ) {
141 public StringBuffer toNHX() {
142 throw new NoSuchMethodError();
146 public void toPhyloXML( final Writer writer, final int level, final String indentation ) throws IOException {
147 throw new NoSuchMethodError();
150 private Color calculateColor( final double v ) {
151 return ForesterUtil.calcColor( v, _min, _max, _mean, _min_color, _max_color, _mean_color );
154 private double getRenderingHeight() {
158 public static RenderableMsaSequence createInstance( final String seq,
159 final Configuration configuration ) {
160 if ( _instance == null ) {
161 _instance = new RenderableMsaSequence();
163 _instance._seq = seq;
164 if ( configuration != null ) {