in progress
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Tue, 19 Aug 2014 20:29:06 +0000 (20:29 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Tue, 19 Aug 2014 20:29:06 +0000 (20:29 +0000)
forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java
forester/java/src/org/forester/archaeopteryx/MainFrame.java
forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java
forester/java/src/org/forester/archaeopteryx/Options.java
forester/java/src/org/forester/archaeopteryx/TreePanel.java
forester/java/src/org/forester/phylogeny/PhylogenyMethods.java

index b43c9c4..37bec45 100644 (file)
@@ -132,6 +132,10 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
     private JMenuItem                   _gsdi_item;
     private JMenuItem                   _gsdir_item;
     private Phylogeny                   _species_tree;
+    
+    private JCheckBoxMenuItem _right_line_up_domains_cbmi;
+    private JCheckBoxMenuItem _line_up_renderable_data_cbmi;
+    
 
     @Override
     public void actionPerformed( final ActionEvent e ) {
@@ -349,6 +353,14 @@ 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 ) {
+            updateOptions( getOptions() );
+        }
+        else if ( o == _line_up_renderable_data_cbmi ) {
+            updateOptions( getOptions() );
+        }
+        
+        
         repaint();
     }
 
@@ -744,7 +756,9 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
                 .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
@@ -1350,6 +1364,17 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         if ( ( _color_by_taxonomic_group_cbmi != null ) && _color_by_taxonomic_group_cbmi.isEnabled() ) {
             options.setColorByTaxonomicGroup( _color_by_taxonomic_group_cbmi.isSelected() );
         }
+        
+       
+        if ( ( _right_line_up_domains_cbmi != null ) && _right_line_up_domains_cbmi.isEnabled() ) {
+            options.setRightLineUpDomains( _right_line_up_domains_cbmi.isSelected() );
+        }
+        
+        
+        if ( ( _line_up_renderable_data_cbmi != null ) && _line_up_renderable_data_cbmi.isEnabled() ) {
+            options.setLineUpRendarableNodeData( _line_up_renderable_data_cbmi.isSelected() );
+        }
+        
     }
 
     void updateTypeCheckboxes( final Options options, final Object o ) {
index e95c1c8..ac9bd6d 100644 (file)
@@ -39,6 +39,7 @@ 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
@@ -125,6 +126,8 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     static final String         USE_BRACKETS_FOR_CONF_IN_NH_LABEL       = "Use Brackets for Confidence Values";\r
     static final String         USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL = "Use Internal Node Names for Confidence Values";\r
     static final String         SHOW_BASIC_TREE_INFORMATION_LABEL       = "Basic Tree Information";\r
+    static final String RIGHT_LINE_UP_DOMAINS = "Right-align Domain Architectures";\r
+    static final String LINE_UP_RENDERABLE_DATA = "Line Up Node Diagrams";\r
     JMenuBar                    _jmenubar;\r
     JMenu                       _file_jmenu;\r
     JMenu                       _tools_menu;\r
@@ -198,6 +201,8 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     JMenuItem                   _cycle_node_fill_mi;\r
     JMenuItem                   _choose_node_size_mi;\r
     JCheckBoxMenuItem           _show_confidence_stddev_cbmi;\r
+   JCheckBoxMenuItem _right_line_up_domains_cbmi;\r
+    JCheckBoxMenuItem _line_up_renderable_data_cbmi;\r
     // _  print\r
     JCheckBoxMenuItem           _graphics_export_visible_only_cbmi;\r
     JCheckBoxMenuItem           _antialias_print_cbmi;\r
@@ -486,6 +491,14 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                 getCurrentTreePanel().updateOvSizes();\r
             }\r
         }\r
+        else if ( o == _line_up_renderable_data_cbmi ) {\r
+            updateOptions( getOptions() );\r
+        }\r
+        else if ( o == _right_line_up_domains_cbmi ) {\r
+            updateOptions( getOptions() );\r
+        }\r
+        \r
+        \r
         else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )\r
                 || ( o == _convex_type_cbmi ) || ( o == _euro_type_cbmi ) || ( o == _rounded_type_cbmi )\r
                 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {\r
@@ -1405,6 +1418,14 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {\r
             options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );\r
         }\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
+        if ( ( _line_up_renderable_data_cbmi != null ) && _line_up_renderable_data_cbmi.isEnabled() ) {\r
+            options.setLineUpRendarableNodeData( _line_up_renderable_data_cbmi.isSelected() );\r
+        }\r
     }\r
 \r
     void updateTypeCheckboxes( final Options options, final Object o ) {\r
index 444dd94..9c4c701 100644 (file)
@@ -157,6 +157,7 @@ public final class MainFrameApplication extends MainFrame {
     private File                             _seqs_file                            = null;\r
     JMenuItem                                _read_values_jmi;\r
     JMenuItem                                _read_seqs_jmi;\r
+   \r
 \r
     private MainFrameApplication( final Phylogeny[] phys, final Configuration config ) {\r
         _configuration = config;\r
@@ -900,7 +901,10 @@ public final class MainFrameApplication extends MainFrame {
                 .add( _show_default_node_shapes_external_cbmi = new JCheckBoxMenuItem( DISPLAY_NODE_BOXES_LABEL_EXT ) );\r
         if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {\r
             _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( SHOW_DOMAIN_LABELS_LABEL ) );\r
-        }\r
+            _options_jmenu.add( _right_line_up_domains_cbmi = new JCheckBoxMenuItem( MainFrame.RIGHT_LINE_UP_DOMAINS ) );\r
+         }\r
+        _options_jmenu.add( _line_up_renderable_data_cbmi = new JCheckBoxMenuItem( MainFrame.LINE_UP_RENDERABLE_DATA ) );\r
\r
         _options_jmenu.add( _show_annotation_ref_source = new JCheckBoxMenuItem( SHOW_ANN_REF_SOURCE_LABEL ) );\r
         _options_jmenu.add( _show_confidence_stddev_cbmi = new JCheckBoxMenuItem( SHOW_CONF_STDDEV_LABEL ) );\r
         _options_jmenu.add( _color_by_taxonomic_group_cbmi = new JCheckBoxMenuItem( COLOR_BY_TAXONOMIC_GROUP ) );\r
@@ -1029,6 +1033,12 @@ public final class MainFrameApplication extends MainFrame {
                 .getNhConversionSupportValueStyle() == NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );\r
         customizeCheckBoxMenuItem( _use_internal_names_for_conf_in_nh_export_cbmi, getOptions()\r
                 .getNhConversionSupportValueStyle() == NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES );\r
+      \r
+        \r
+        customizeCheckBoxMenuItem( _line_up_renderable_data_cbmi, getOptions().isLineUpRendarableNodeData()\r
+                                    );\r
+        \r
+        customizeCheckBoxMenuItem( _right_line_up_domains_cbmi, getOptions().isRightLineUpDomains() );\r
         _jmenubar.add( _options_jmenu );\r
     }\r
 \r
index 6e83bf1..bc9d19f 100644 (file)
@@ -35,6 +35,7 @@ import org.forester.phylogeny.data.NodeVisualData;
 import org.forester.phylogeny.data.NodeVisualData.NodeFill;
 import org.forester.phylogeny.data.NodeVisualData.NodeShape;
 import org.forester.util.ForesterUtil;
+import org.omg.stub.java.rmi._Remote_Stub;
 
 /*
  * This is to hold changeable options.
@@ -85,6 +86,8 @@ final public class Options {
     private boolean                           _show_overview;
     private boolean                           _show_scale;
     private TAXONOMY_EXTRACTION               _taxonomy_extraction;
+    private boolean _line_up_renderable_node_data;
+    private boolean _right_align_domains;
 
     private Options() {
         init();
@@ -488,6 +491,8 @@ final public class Options {
         _show_confidence_stddev = true;
         _nh_conversion_support_value_style = NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE;
         _ext_desc_data_to_return = NODE_DATA.UNKNOWN;
+        _line_up_renderable_node_data = false;
+        _right_align_domains = false;
     }
 
     final private void setNumberOfDigitsAfterCommaForBranchLength( final short number_of_digits_after_comma_for_branch_length_values ) {
@@ -603,4 +608,25 @@ final public class Options {
             return toString().replaceAll( " ", "_" );
         }
     }
+
+    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 9de7d2f..a5b0582 100644 (file)
@@ -4789,7 +4789,14 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 final int h = y < default_height ? ForesterUtil.roundToInt( y ) : default_height;
                 rds.setRenderingHeight( h > 1 ? h : 2 );
                 if ( getControlPanel().isDrawPhylogram() ) {
-                    rds.render( node.getXcoord() + x, node.getYcoord() - ( h / 2 ), g, this, to_pdf );
+                    if ( getOptions().isLineUpRendarableNodeData() ) {
+                        length_of_longest_text = calcLengthOfLongestText();
+                      
+                        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();
index 5ffa89c..eba76de 100644 (file)
@@ -277,6 +277,20 @@ public class PhylogenyMethods {
         }\r
         return max;\r
     }\r
+    \r
+    public static PhylogenyNode calculateNodeWithMaxDistanceToRoot( final Phylogeny phy ) {\r
+        double max = 0.0;\r
+        PhylogenyNode max_node = phy.getFirstExternalNode();\r
+        for( final PhylogenyNodeIterator iter = phy.iteratorExternalForward(); iter.hasNext(); ) {\r
+            final PhylogenyNode node = iter.next();\r
+            final double d = node.calculateDistanceToRoot();\r
+            if ( d > max ) {\r
+                max = d;\r
+                max_node = node;\r
+            }\r
+        }\r
+        return max_node;\r
+    }\r
 \r
     public static int calculateNumberOfExternalNodesWithoutTaxonomy( final PhylogenyNode node ) {\r
         final List<PhylogenyNode> descs = node.getAllExternalDescendants();\r