in progress
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Wed, 20 Aug 2014 01:00:25 +0000 (01:00 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Wed, 20 Aug 2014 01:00:25 +0000 (01:00 +0000)
forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java
forester/java/src/org/forester/archaeopteryx/Configuration.java
forester/java/src/org/forester/archaeopteryx/MainFrame.java
forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java
forester/java/src/org/forester/archaeopteryx/Options.java
forester/java/src/org/forester/archaeopteryx/TreePanel.java

index 37bec45..95f546c 100644 (file)
@@ -353,14 +353,22 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         else if ( o == _color_by_taxonomic_group_cbmi ) {
             updateOptions( getOptions() );
         }
-        else if ( o == _right_line_up_domains_cbmi ) {
+       
+        
+        
+        else if ( o == _line_up_renderable_data_cbmi ) {
+            if ( !_line_up_renderable_data_cbmi.isSelected() ) {
+                _right_line_up_domains_cbmi.setSelected( false );
+            }
             updateOptions( getOptions() );
         }
-        else if ( o == _line_up_renderable_data_cbmi ) {
+        else if ( o == _right_line_up_domains_cbmi ) {
+            if ( _right_line_up_domains_cbmi.isSelected() ) {
+                _line_up_renderable_data_cbmi.setSelected( true );
+            }
             updateOptions( getOptions() );
         }
         
-        
         repaint();
     }
 
index 271bdfa..c1a1096 100644 (file)
@@ -220,6 +220,9 @@ public final class Configuration {
     private Color                           _vector_data_mean_color                                = Color.WHITE;
     private double                          _vector_data_height                                    = 12;
     private int                             _vector_data_width                                     = 120;
+    private boolean _line_up_renderable_node_data;
+    private boolean _right_align_domains;
+    
     static {
         for( final String font_name : Constants.DEFAULT_FONT_CHOICES ) {
             if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font_name ) >= 0 ) {
@@ -1492,7 +1495,7 @@ public final class Configuration {
                         + "] for [ext_descendents_data_to_return_on]" );
             }
         }
-        //
+       
         else if ( key.equals( "vector_data_min_color" ) ) {
             _vector_data_min_color = Color.decode( ( String ) st.nextElement() );
         }
@@ -1502,7 +1505,7 @@ public final class Configuration {
         else if ( key.equals( "vector_data_mean_color" ) ) {
             _vector_data_mean_color = Color.decode( ( String ) st.nextElement() );
         }
-        //
+      
         else if ( key.equals( "vector_data_width" ) ) {
             _vector_data_width = parseShort( ( String ) st.nextElement() );
             if ( _vector_data_width < 1 ) {
@@ -1515,7 +1518,16 @@ public final class Configuration {
                 _vector_data_height = 12;
             }
         }
-        //
+       
+        else if ( key.equals( "line_up_renderable_data" ) ) {
+            setLineUpRendarableNodeData( parseBoolean( ( String ) st.nextElement() ) );
+        }
+        
+        else if ( key.equals( "right_align_domain_architectures" ) ) {
+            setRightLineUpDomains( parseBoolean( ( String ) st.nextElement() ) );
+        }
+        
+        
         else if ( st.countTokens() >= 2 ) { // counts the tokens that are not
             // yet retrieved!
             int key_index = -1;
@@ -1747,4 +1759,26 @@ public final class Configuration {
     public int getVectorDataWidth() {
         return _vector_data_width;
     }
+    
+    final public boolean isLineUpRendarableNodeData() {
+        
+        return _line_up_renderable_node_data;
+    }
+    
+    final public boolean isRightLineUpDomains() {
+        
+        return _right_align_domains;
+    }
+    
+    final public void setLineUpRendarableNodeData( final boolean line_up_renderable_node_data) {
+        
+         _line_up_renderable_node_data = line_up_renderable_node_data;
+    }
+    
+    final public void setRightLineUpDomains( final boolean right_align_domains ) {
+        
+        _right_align_domains = right_align_domains;
+    }
+    
+    
 }
index ac9bd6d..2a50296 100644 (file)
@@ -39,7 +39,6 @@ import java.util.Locale;
 import java.util.NoSuchElementException;\r
 \r
 import javax.swing.Box;\r
-import javax.swing.Icon;\r
 import javax.swing.JApplet;\r
 import javax.swing.JCheckBoxMenuItem;\r
 import javax.swing.JFrame;\r
@@ -492,9 +491,15 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             }\r
         }\r
         else if ( o == _line_up_renderable_data_cbmi ) {\r
+            if ( !_line_up_renderable_data_cbmi.isSelected() ) {\r
+                _right_line_up_domains_cbmi.setSelected( false );\r
+            }\r
             updateOptions( getOptions() );\r
         }\r
         else if ( o == _right_line_up_domains_cbmi ) {\r
+            if ( _right_line_up_domains_cbmi.isSelected() ) {\r
+                _line_up_renderable_data_cbmi.setSelected( true );\r
+            }\r
             updateOptions( getOptions() );\r
         }\r
         \r
@@ -548,6 +553,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );\r
             }\r
         }\r
+       \r
         else {\r
             if ( _load_phylogeny_from_webservice_menu_items != null ) {\r
                 for( int i = 0; i < _load_phylogeny_from_webservice_menu_items.length; ++i ) {\r
@@ -1420,9 +1426,8 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }\r
         if ( ( _right_line_up_domains_cbmi != null ) && _right_line_up_domains_cbmi.isEnabled() ) {\r
             options.setRightLineUpDomains( _right_line_up_domains_cbmi.isSelected() );\r
+           \r
         }\r
-        \r
-        \r
         if ( ( _line_up_renderable_data_cbmi != null ) && _line_up_renderable_data_cbmi.isEnabled() ) {\r
             options.setLineUpRendarableNodeData( _line_up_renderable_data_cbmi.isSelected() );\r
         }\r
index baec909..22332cd 100644 (file)
@@ -219,7 +219,10 @@ public final class MainFrameApplet extends MainFrame {
                 .add( _show_default_node_shapes_external_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_EXT ) );
         if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
             _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( MainFrame.SHOW_DOMAIN_LABELS_LABEL ) );
+            _options_jmenu.add( _right_line_up_domains_cbmi = new JCheckBoxMenuItem( MainFrame.RIGHT_LINE_UP_DOMAINS ) );
         }
+        _options_jmenu.add( _line_up_renderable_data_cbmi = new JCheckBoxMenuItem( MainFrame.LINE_UP_RENDERABLE_DATA ) );
+        
         _options_jmenu.add( _show_annotation_ref_source = new JCheckBoxMenuItem( MainFrame.SHOW_ANN_REF_SOURCE_LABEL ) );
         _options_jmenu.add( _show_confidence_stddev_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_CONF_STDDEV_LABEL ) );
         _options_jmenu
index bc9d19f..4d96164 100644 (file)
@@ -566,6 +566,9 @@ final public class Options {
             if ( configuration.getExtDescNodeDataToReturn() != null ) {
                 instance.setExtDescNodeDataToReturn( configuration.getExtDescNodeDataToReturn() );
             }
+            
+            instance.setRightLineUpDomains(  configuration.isRightLineUpDomains() );
+            instance.setLineUpRendarableNodeData(  configuration.isLineUpRendarableNodeData() );
             instance.setAllowErrorsInDistanceToParent( false );
         }
         return instance;
index a5b0582..4178b2a 100644 (file)
@@ -251,6 +251,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
     private float                        _x_correction_factor                               = 0.0f;
     private float                        _x_distance                                        = 0.0f;
     private float                        _y_distance                                        = 0.0f;
+    private int                          _length_of_longest_text;
+    private int                          _longest_domain;
     //  private Image                           offscreenImage;
     //  private Graphics                        offscreenGraphics;
     //  private Dimension                       offscreenDimension;
@@ -519,6 +521,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                         }
                     }
                 }
+                _length_of_longest_text = calcLengthOfLongestText();
             }
             int ext_nodes = _phylogeny.getRoot().getNumberOfExternalNodes();
             final int max_depth = PhylogenyMethods.calculateMaxDepth( _phylogeny );
@@ -600,6 +603,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         }
         int longest = 30;
         int longest_txt = 0;
+        _longest_domain = 0;
         PhylogenyNode longest_txt_node = _phylogeny.getFirstExternalNode();
         for( final PhylogenyNode node : _phylogeny.getExternalNodes() ) {
             int sum = 0;
@@ -647,6 +651,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 final DomainArchitecture d = node.getNodeData().getSequence().getDomainArchitecture();
                 sum += ( ( _domain_structure_width / ( ( RenderableDomainArchitecture ) d ).getOriginalSize()
                         .getWidth() ) * d.getTotalLength() ) + 10;
+                if ( d.getTotalLength() > _longest_domain ) {
+                    _longest_domain = d.getTotalLength();
+                }
             }
             if ( sum >= max_length ) {
                 _longest_ext_node_info = max_length;
@@ -4770,7 +4777,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         if ( ( !getControlPanel().isShowInternalData() && !node.isExternal() ) ) {
             return;
         }
-        int length_of_longest_text = -1;
         if ( getControlPanel().isShowDomainArchitectures() && node.getNodeData().isHasSequence()
                 && ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) {
             RenderableDomainArchitecture rds = null;
@@ -4790,21 +4796,44 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 rds.setRenderingHeight( h > 1 ? h : 2 );
                 if ( getControlPanel().isDrawPhylogram() ) {
                     if ( getOptions().isLineUpRendarableNodeData() ) {
-                        length_of_longest_text = calcLengthOfLongestText();
-                      
-                        rds.render( getMaxDistanceToRoot() * getXcorrectionFactor() + length_of_longest_text, node.getYcoord() - ( h / 2 ), g, this, to_pdf );
+                        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 );
+                        }
+                        else {
+                            rds.render( getMaxDistanceToRoot() * getXcorrectionFactor() + _length_of_longest_text,
+                                        node.getYcoord() - ( h / 2 ),
+                                        g,
+                                        this,
+                                        to_pdf );
+                        }
                     }
                     else {
                         rds.render( node.getXcoord() + x, node.getYcoord() - ( h / 2 ), g, this, to_pdf );
                     }
                 }
                 else {
-                    length_of_longest_text = calcLengthOfLongestText();
-                    rds.render( getPhylogeny().getFirstExternalNode().getXcoord() + length_of_longest_text,
-                                node.getYcoord() - ( h / 2 ),
-                                g,
-                                this,
-                                to_pdf );
+                    if ( getOptions().isRightLineUpDomains() ) {
+                        rds.render( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text
+                                            - 20 + ( _longest_domain - rds.getTotalLength() ) 
+                                            * rds.getRenderingFactorWidth(),
+                                    node.getYcoord() - ( h / 2 ),
+                                    g,
+                                    this,
+                                    to_pdf );
+                    }
+                    else {
+                        rds.render( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text,
+                                    node.getYcoord() - ( h / 2 ),
+                                    g,
+                                    this,
+                                    to_pdf );
+                    }
                 }
             }
         }
@@ -4823,10 +4852,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                     rv.render( node.getXcoord() + x + domain_add, node.getYcoord() - 3, g, this, to_pdf );
                 }
                 else {
-                    if ( length_of_longest_text < 0 ) {
-                        length_of_longest_text = calcLengthOfLongestText();
-                    }
-                    rv.render( getPhylogeny().getFirstExternalNode().getXcoord() + length_of_longest_text + domain_add,
+                    rv.render( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text + domain_add,
                                node.getYcoord() - 3,
                                g,
                                this,
@@ -4836,13 +4862,13 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         }
     }
 
-    private int calcLengthOfLongestText() {
+    final private int calcLengthOfLongestText() {
         final StringBuilder sb = new StringBuilder();
         nodeDataAsSB( _ext_node_with_longest_txt_info, sb );
         if ( _ext_node_with_longest_txt_info.getNodeData().isHasTaxonomy() ) {
             nodeTaxonomyDataAsSB( _ext_node_with_longest_txt_info.getNodeData().getTaxonomy(), sb );
         }
-        return getFontMetricsForLargeDefaultFont().stringWidth( sb.toString() + " " );
+        return getFontMetricsForLargeDefaultFont().stringWidth( sb.toString() );
     }
 
     final private void paintOvRectangle( final Graphics2D g ) {