From: cmzmasek@gmail.com Date: Tue, 19 Aug 2014 20:29:06 +0000 (+0000) Subject: in progress X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=9e1353590a88991e7593d38c8e307f713a0f3d5b;p=jalview.git in progress --- diff --git a/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java b/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java index b43c9c4..37bec45 100644 --- a/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java +++ b/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java @@ -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 ) { diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrame.java b/forester/java/src/org/forester/archaeopteryx/MainFrame.java index e95c1c8..ac9bd6d 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrame.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrame.java @@ -39,6 +39,7 @@ import java.util.Locale; import java.util.NoSuchElementException; import javax.swing.Box; +import javax.swing.Icon; import javax.swing.JApplet; import javax.swing.JCheckBoxMenuItem; import javax.swing.JFrame; @@ -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"; static final String USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL = "Use Internal Node Names for Confidence Values"; static final String SHOW_BASIC_TREE_INFORMATION_LABEL = "Basic Tree Information"; + static final String RIGHT_LINE_UP_DOMAINS = "Right-align Domain Architectures"; + static final String LINE_UP_RENDERABLE_DATA = "Line Up Node Diagrams"; JMenuBar _jmenubar; JMenu _file_jmenu; JMenu _tools_menu; @@ -198,6 +201,8 @@ public abstract class MainFrame extends JFrame implements ActionListener { JMenuItem _cycle_node_fill_mi; JMenuItem _choose_node_size_mi; JCheckBoxMenuItem _show_confidence_stddev_cbmi; + JCheckBoxMenuItem _right_line_up_domains_cbmi; + JCheckBoxMenuItem _line_up_renderable_data_cbmi; // _ print JCheckBoxMenuItem _graphics_export_visible_only_cbmi; JCheckBoxMenuItem _antialias_print_cbmi; @@ -486,6 +491,14 @@ public abstract class MainFrame extends JFrame implements ActionListener { getCurrentTreePanel().updateOvSizes(); } } + else if ( o == _line_up_renderable_data_cbmi ) { + updateOptions( getOptions() ); + } + else if ( o == _right_line_up_domains_cbmi ) { + updateOptions( getOptions() ); + } + + else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi ) || ( o == _convex_type_cbmi ) || ( o == _euro_type_cbmi ) || ( o == _rounded_type_cbmi ) || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) { @@ -1405,6 +1418,14 @@ public abstract class MainFrame extends JFrame implements ActionListener { else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) { options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ); } + 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 ) { diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java index 444dd94..9c4c701 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java @@ -157,6 +157,7 @@ public final class MainFrameApplication extends MainFrame { private File _seqs_file = null; JMenuItem _read_values_jmi; JMenuItem _read_seqs_jmi; + private MainFrameApplication( final Phylogeny[] phys, final Configuration config ) { _configuration = config; @@ -900,7 +901,10 @@ public final class MainFrameApplication extends MainFrame { .add( _show_default_node_shapes_external_cbmi = new JCheckBoxMenuItem( DISPLAY_NODE_BOXES_LABEL_EXT ) ); if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) { _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( 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( SHOW_ANN_REF_SOURCE_LABEL ) ); _options_jmenu.add( _show_confidence_stddev_cbmi = new JCheckBoxMenuItem( SHOW_CONF_STDDEV_LABEL ) ); _options_jmenu.add( _color_by_taxonomic_group_cbmi = new JCheckBoxMenuItem( COLOR_BY_TAXONOMIC_GROUP ) ); @@ -1029,6 +1033,12 @@ public final class MainFrameApplication extends MainFrame { .getNhConversionSupportValueStyle() == NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ); customizeCheckBoxMenuItem( _use_internal_names_for_conf_in_nh_export_cbmi, getOptions() .getNhConversionSupportValueStyle() == NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES ); + + + customizeCheckBoxMenuItem( _line_up_renderable_data_cbmi, getOptions().isLineUpRendarableNodeData() + ); + + customizeCheckBoxMenuItem( _right_line_up_domains_cbmi, getOptions().isRightLineUpDomains() ); _jmenubar.add( _options_jmenu ); } diff --git a/forester/java/src/org/forester/archaeopteryx/Options.java b/forester/java/src/org/forester/archaeopteryx/Options.java index 6e83bf1..bc9d19f 100644 --- a/forester/java/src/org/forester/archaeopteryx/Options.java +++ b/forester/java/src/org/forester/archaeopteryx/Options.java @@ -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; + } + } diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index 9de7d2f..a5b0582 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -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(); diff --git a/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java b/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java index 5ffa89c..eba76de 100644 --- a/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java +++ b/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java @@ -277,6 +277,20 @@ public class PhylogenyMethods { } return max; } + + public static PhylogenyNode calculateNodeWithMaxDistanceToRoot( final Phylogeny phy ) { + double max = 0.0; + PhylogenyNode max_node = phy.getFirstExternalNode(); + for( final PhylogenyNodeIterator iter = phy.iteratorExternalForward(); iter.hasNext(); ) { + final PhylogenyNode node = iter.next(); + final double d = node.calculateDistanceToRoot(); + if ( d > max ) { + max = d; + max_node = node; + } + } + return max_node; + } public static int calculateNumberOfExternalNodesWithoutTaxonomy( final PhylogenyNode node ) { final List descs = node.getAllExternalDescendants();