inprogress
[jalview.git] / forester / java / src / org / forester / archaeopteryx / phylogeny / data / RenderableDomainArchitecture.java
index df45fe5..3b2d563 100644 (file)
@@ -6,7 +6,7 @@
 // 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
 // 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: www.phylosoft.org/forester
+// WWW: https://sites.google.com/site/cmzmasek/home/software/forester
 
 package org.forester.archaeopteryx.phylogeny.data;
 
+import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Graphics2D;
+import java.awt.Stroke;
 import java.awt.geom.Rectangle2D;
 import java.io.IOException;
 import java.io.Writer;
+import java.math.BigDecimal;
 import java.util.Map;
 import java.util.SortedMap;
 
@@ -57,6 +60,7 @@ public final class RenderableDomainArchitecture extends DomainArchitecture imple
     private final DomainArchitecture  _domain_structure;
     private final Rectangle2D         _rectangle                    = new Rectangle2D.Float();
     private final Configuration       _configuration;
+    private static final BasicStroke  STROKE_1                      = new BasicStroke( 1f );
 
     public RenderableDomainArchitecture( final DomainArchitecture domain_structure, final Configuration configuration ) {
         _domain_structure = domain_structure;
@@ -135,7 +139,7 @@ public final class RenderableDomainArchitecture extends DomainArchitecture imple
     }
 
     @Override
-    public SortedMap<Double, ProteinDomain> getDomains() {
+    public SortedMap<BigDecimal, ProteinDomain> getDomains() {
         return _domain_structure.getDomains();
     }
 
@@ -144,10 +148,12 @@ public final class RenderableDomainArchitecture extends DomainArchitecture imple
         return _domain_structure.getNumberOfDomains();
     }
 
+    @Override
     public Dimension getOriginalSize() {
         return new Dimension( _domain_structure.getTotalLength(), ForesterUtil.roundToInt( _rendering_height ) );
     }
 
+    @Override
     public Object getParameter() {
         return new Integer( _e_value_threshold_exp );
     }
@@ -156,8 +162,9 @@ public final class RenderableDomainArchitecture extends DomainArchitecture imple
         return _rendering_factor_width;
     }
 
+    @Override
     public Dimension getRenderingSize() {
-        return new Dimension( ForesterUtil.roundToInt( _domain_structure.getTotalLength() * _rendering_factor_width ),
+        return new Dimension( ForesterUtil.roundToInt( _domain_structure.getTotalLength() * getRenderingFactorWidth() ),
                               ForesterUtil.roundToInt( _rendering_height ) );
     }
 
@@ -171,6 +178,7 @@ public final class RenderableDomainArchitecture extends DomainArchitecture imple
         return _domain_structure.isEqual( data );
     }
 
+    @Override
     public void render( final double x1,
                         final double y1,
                         final Graphics2D g,
@@ -179,14 +187,16 @@ public final class RenderableDomainArchitecture extends DomainArchitecture imple
         final double f = getRenderingFactorWidth();
         final double y = y1 + ( _rendering_height / 2 );
         final double start = x1 + 20.0;
+        final Stroke s = g.getStroke();
+        g.setStroke( STROKE_1 );
         g.setColor( getConfiguration().getDomainStructureFontColor() );
         _rectangle.setFrame( start, y - 0.5, _domain_structure.getTotalLength() * f, 1 );
         g.fill( _rectangle );
         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 double xa = start + ( d.getFrom() * f );
+                final double xb = xa + ( d.getLength() * f );
                 if ( tree_panel.getMainPanel().getOptions().isShowDomainLabels() ) {
                     g.setFont( tree_panel.getMainPanel().getTreeFontSet().getSmallFont() );
                     g.setColor( getConfiguration().getDomainStructureFontColor() );
@@ -196,8 +206,10 @@ public final class RenderableDomainArchitecture extends DomainArchitecture imple
                 drawDomain( xa, y1, xb - xa, _rendering_height, d.getName(), g, to_pdf );
             }
         }
+        g.setStroke( s );
     }
 
+    @Override
     public void setParameter( final double e_value_threshold_exp ) {
         _e_value_threshold_exp = ( int ) e_value_threshold_exp;
     }
@@ -206,6 +218,7 @@ public final class RenderableDomainArchitecture extends DomainArchitecture imple
         _rendering_factor_width = rendering_factor_width;
     }
 
+    @Override
     public void setRenderingHeight( final double rendering_height ) {
         _rendering_height = rendering_height;
     }