CHANGE_NODE_FONT,
COLOR_NODE_FONT;
}
+
+ public boolean isShowSequences() {
+ // TODO Auto-generated method stub
+ return true;
+ }
}
import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
import org.forester.archaeopteryx.phylogeny.data.RenderableDomainArchitecture;
+import org.forester.archaeopteryx.phylogeny.data.RenderableMsaSequence;
import org.forester.archaeopteryx.phylogeny.data.RenderableVector;
import org.forester.archaeopteryx.tools.Blast;
import org.forester.archaeopteryx.tools.ImageLoader;
}
}
if ( getControlPanel().isShowDomainArchitectures() ) {
- final double ds_factor_width = _domain_structure_width / _max_original_domain_structure_width;
+ final float ds_factor_width = ( float ) ( _domain_structure_width / _max_original_domain_structure_width );
for( final PhylogenyNode node : _phylogeny.getExternalNodes() ) {
if ( node.getNodeData().isHasSequence()
&& ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) {
if ( getControlPanel().isDrawPhylogram() ) {
if ( getOptions().isLineUpRendarableNodeData() ) {
if ( getOptions().isRightLineUpDomains() ) {
- rds.render( ( getMaxDistanceToRoot() * getXcorrectionFactor() )
- + _length_of_longest_text
- + ( ( _longest_domain - rds.getTotalLength() ) * rds
- .getRenderingFactorWidth() ),
- node.getYcoord() - ( h / 2 ),
- g,
- this,
- to_pdf );
+ rds.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() )
+ + _length_of_longest_text + ( ( _longest_domain - rds.getTotalLength() ) * rds
+ .getRenderingFactorWidth() ) ), node.getYcoord() - ( h / 2 ), g, this, to_pdf );
}
else {
- rds.render( ( getMaxDistanceToRoot() * getXcorrectionFactor() ) + _length_of_longest_text,
+ rds.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() ) + _length_of_longest_text ),
node.getYcoord() - ( h / 2 ),
g,
this,
domain_add = _domain_structure_width + 10;
}
if ( getControlPanel().isDrawPhylogram() ) {
- rv.render( node.getXcoord() + x + domain_add, node.getYcoord() - 3, g, this, to_pdf );
+ rv.render( ( float ) ( node.getXcoord() + x + domain_add ), node.getYcoord() - 3, g, this, to_pdf );
}
else {
- rv.render( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text + domain_add,
+ rv.render( ( float ) ( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text + domain_add ),
node.getYcoord() - 3,
g,
this,
}
}
}
+ if ( getControlPanel().isShowSequences() && ( node.getNodeData().isHasSequence() )
+ && ( node.getNodeData().getSequence().isMolecularSequenceAligned() )
+ && ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) ) {
+ final RenderableMsaSequence rs = RenderableMsaSequence.createInstance( node.getNodeData().getSequence()
+ .getMolecularSequence(), getConfiguration() );
+ if ( rs != null ) {
+
+ final int default_height = 7;
+ float y = getYdistance();
+ if ( getControlPanel().isDynamicallyHideData() ) {
+ y = getTreeFontSet().getFontMetricsLarge().getHeight();
+ }
+ final int h = y < default_height ? ForesterUtil.roundToInt( y ) : default_height;
+ rs.setRenderingHeight( h > 1 ? h : 2 );
+ if ( getControlPanel().isDrawPhylogram() ) {
+ if ( getOptions().isLineUpRendarableNodeData() ) {
+ rs.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() ) + _length_of_longest_text ),
+ node.getYcoord() - ( h / 2 ),
+ g,
+ this,
+ to_pdf );
+ }
+ else {
+ rs.render( node.getXcoord() + x, node.getYcoord() - ( h / 2 ), g, this, to_pdf );
+ }
+ }
+ else {
+ rs.render( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text,
+ node.getYcoord() - ( h / 2 ),
+ g,
+ this,
+ to_pdf );
+ }
+
+ }
+ }
}
final private int calcLengthOfLongestText() {
private final DomainArchitecture _domain_structure;
private int _e_value_threshold_exp = E_VALUE_THRESHOLD_EXP_DEFAULT;
private final Rectangle2D _rectangle = new Rectangle2D.Float();
- private double _rendering_factor_width = 1.0;
- private double _rendering_height = 0;
+ private float _rendering_factor_width = 1;
+ private float _rendering_height = 0;
public RenderableDomainArchitecture( final DomainArchitecture domain_structure ) {
_domain_structure = domain_structure;
return new Integer( _e_value_threshold_exp );
}
- public double getRenderingFactorWidth() {
+ public float getRenderingFactorWidth() {
return _rendering_factor_width;
}
}
@Override
- public void render( final double x1,
- final double y1,
+ public void render( final float x1,
+ final float y1,
final Graphics2D g,
final TreePanel tree_panel,
final boolean to_pdf ) {
- final double f = getRenderingFactorWidth();
- final double y = y1 + ( _rendering_height / 2 );
- final double start = x1 + 20.0;
+ final float f = getRenderingFactorWidth();
+ final float y = y1 + ( _rendering_height / 2 );
+ final float start = x1 + 20;
final Stroke s = g.getStroke();
g.setStroke( STROKE_1 );
if ( !to_pdf ) {
for( int i = 0; i < _domain_structure.getDomains().size(); ++i ) {
final ProteinDomain d = _domain_structure.getDomain( i );
if ( d.getConfidence() <= Math.pow( 10, _e_value_threshold_exp ) ) {
- final double xa = start + ( d.getFrom() * f );
- final double xb = xa + ( d.getLength() * f );
+ final float xa = start + ( d.getFrom() * f );
+ final float xb = xa + ( d.getLength() * f );
if ( tree_panel.getMainPanel().getOptions().isShowDomainLabels()
&& ( tree_panel.getMainPanel().getTreeFontSet().getFontMetricsSmall().getHeight() > 4 ) ) {
g.setFont( tree_panel.getMainPanel().getTreeFontSet().getSmallFont() );
else {
g.setColor( Constants.DOMAIN_LABEL_COLOR_FOR_PDF );
}
- PhylogenyDataUtil.drawString( d.getName(), xa, y1
- + tree_panel.getMainPanel().getTreeFontSet().getFontMetricsSmall().getAscent()
- + _rendering_height, g );
+ g.drawString( d.getName(),
+ xa,
+ y1
+ + tree_panel.getMainPanel().getTreeFontSet().getFontMetricsSmall().getAscent()
+ + _rendering_height );
+
+
}
drawDomain( xa, y1, xb - xa, _rendering_height, d.getName(), g, to_pdf );
}
_e_value_threshold_exp = ( int ) e_value_threshold_exp;
}
- public void setRenderingFactorWidth( final double rendering_factor_width ) {
+ public void setRenderingFactorWidth( final float rendering_factor_width ) {
_rendering_factor_width = rendering_factor_width;
}
@Override
- public void setRenderingHeight( final double rendering_height ) {
+ public void setRenderingHeight( final float rendering_height ) {
_rendering_height = rendering_height;
}
--- /dev/null
+// $Id:
+// $
+// FORESTER -- software libraries and applications
+// for evolutionary biology research and applications.
+//
+// Copyright (C) 2008-2009 Christian M. Zmasek
+// Copyright (C) 2008-2009 Burnham Institute for Medical Research
+// All rights reserved
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+//
+// Contact: phylosoft @ gmail . com
+// WWW: https://sites.google.com/site/cmzmasek/home/software/forester
+
+package org.forester.archaeopteryx.phylogeny.data;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.geom.Rectangle2D;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.List;
+
+import org.forester.archaeopteryx.AptxUtil;
+import org.forester.archaeopteryx.Configuration;
+import org.forester.archaeopteryx.TreePanel;
+import org.forester.phylogeny.data.PhylogenyData;
+import org.forester.phylogeny.data.PhylogenyDataUtil;
+import org.forester.util.DescriptiveStatistics;
+import org.forester.util.ForesterUtil;
+
+public final class RenderableMsaSequence implements RenderablePhylogenyData {
+
+ final static int VECTOR_DEFAULT_HEIGHT = 12;
+ public final static int VECTOR_DEFAULT_WIDTH = 120;
+ private double _rendering_factor_width = 1.0;
+ private String _seq;
+ private final Rectangle2D _rectangle = new Rectangle2D.Float();
+ private double _height = VECTOR_DEFAULT_HEIGHT;
+ private double _min;
+ private double _max;
+ private double _mean;
+ private Color _min_color = Color.BLUE;
+ private Color _max_color = Color.YELLOW;
+ private Color _mean_color = Color.WHITE;
+ private int _width = VECTOR_DEFAULT_WIDTH;
+ private static RenderableMsaSequence _instance = null;
+
+ private RenderableMsaSequence() {
+ _seq = null;
+ }
+
+ @Override
+ public StringBuffer asSimpleText() {
+ return new StringBuffer( _seq );
+ }
+
+ @Override
+ public StringBuffer asText() {
+ return asSimpleText();
+ }
+
+ @Override
+ public Object clone() {
+ throw new NoSuchMethodError();
+ }
+
+ @Override
+ public PhylogenyData copy() {
+ throw new NoSuchMethodError();
+ }
+
+ @Override
+ public Dimension getOriginalSize() {
+ return new Dimension( getTotalLength(), ( int ) getRenderingHeight() );
+ }
+
+ @Override
+ public Object getParameter() {
+ return null;
+ }
+
+ public double getRenderingFactorWidth() {
+ return _rendering_factor_width;
+ }
+
+ @Override
+ public Dimension getRenderingSize() {
+ return getOriginalSize();
+ }
+
+ public int getTotalLength() {
+ return _seq.length();
+ }
+
+ @Override
+ public boolean isEqual( final PhylogenyData data ) {
+ throw new NoSuchMethodError();
+ }
+
+ @Override
+ public void render( final float x1,
+ final float y1,
+ final Graphics2D g,
+ final TreePanel tree_panel,
+ final boolean to_pdf ) {
+ final double y = y1;
+ final double start = x1 + 20.0;
+ g.drawString( _seq, x1, y1
+ );
+ }
+
+ @Override
+ public void setParameter( final double parameter ) {
+ throw new NoSuchMethodError();
+ }
+
+ public void setRenderingFactorWidth( final double rendering_factor_width ) {
+ _rendering_factor_width = rendering_factor_width;
+ }
+
+ @Override
+ public void setRenderingHeight( final float height ) {
+ _height = height;
+ }
+
+ @Override
+ public StringBuffer toNHX() {
+ throw new NoSuchMethodError();
+ }
+
+ @Override
+ public void toPhyloXML( final Writer writer, final int level, final String indentation ) throws IOException {
+ throw new NoSuchMethodError();
+ }
+
+ private Color calculateColor( final double v ) {
+ return ForesterUtil.calcColor( v, _min, _max, _mean, _min_color, _max_color, _mean_color );
+ }
+
+ private double getRenderingHeight() {
+ return _height;
+ }
+
+ public static RenderableMsaSequence createInstance( final String seq,
+ final Configuration configuration ) {
+ if ( _instance == null ) {
+ _instance = new RenderableMsaSequence();
+ }
+ _instance._seq = seq;
+ if ( configuration != null ) {
+
+ }
+
+ return _instance;
+ }
+}
* @param g
* the Graphics to render to
*/
- public void render( final double x, final double y, final Graphics2D g, final TreePanel tree_panel, boolean to_pdf );
+ public void render( final float x, final float y, final Graphics2D g, final TreePanel tree_panel, boolean to_pdf );
public void setParameter( final double parameter );
- public void setRenderingHeight( final double rendering_height );
+ public void setRenderingHeight( final float rendering_height );
}
}
@Override
- public void render( final double x1,
- final double y1,
+ public void render( final float x1,
+ final float y1,
final Graphics2D g,
final TreePanel tree_panel,
final boolean to_pdf ) {
}
@Override
- public void setRenderingHeight( final double height ) {
+ public void setRenderingHeight( final float height ) {
_height = height;
}
org.forester.util.ForesterUtil.roundToInt( y2 ) );
}
- public static void drawString( final String str, final double x, final double y, final Graphics g ) {
- g.drawString( str,
- org.forester.util.ForesterUtil.roundToInt( x ),
- org.forester.util.ForesterUtil.roundToInt( y ) );
- }
+
public static String replaceIllegalXmlCharacters( final String value ) {
String v = value.replaceAll( "&", "&" );