inprogress
[jalview.git] / forester / java / src / org / forester / archaeopteryx / ArchaeopteryxE.java
index b1b6d9f..89e043f 100644 (file)
@@ -13,7 +13,6 @@ import java.io.IOException;
 import java.net.URL;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
 import java.util.NoSuchElementException;
 
 import javax.swing.ButtonGroup;
@@ -72,7 +71,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
     private JMenu                       _view_jmenu;
     private JMenuItem                   _view_as_XML_item;
     private JMenuItem                   _view_as_NH_item;
-    private JMenuItem                   _view_as_NHX_item;
     private JMenuItem                   _view_as_nexus_item;
     private JMenuItem                   _display_basic_information_item;
     private JMenu                       _type_menu;
@@ -92,7 +90,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
     private JMenuItem                   _phyloxml_ref_item;
     private JMenuItem                   _aptx_ref_item;
     private JMenuItem                   _remove_branch_color_item;
-    private JMenuItem                   _infer_common_sn_names_item;
     private JCheckBoxMenuItem           _show_domain_labels;
     private JCheckBoxMenuItem           _color_labels_same_as_parent_branch;
     private JCheckBoxMenuItem           _abbreviate_scientific_names;
@@ -115,7 +112,8 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
     private JMenuItem                   _collapse_species_specific_subtrees;
     private JMenuItem                   _overview_placment_mi;
     private ButtonGroup                 _radio_group_1;
-    private JCheckBoxMenuItem           _show_default_node_shapes_cbmi;
+    private JCheckBoxMenuItem           _show_default_node_shapes_internal_cbmi;
+    private JCheckBoxMenuItem           _show_default_node_shapes_external_cbmi;
     private JMenuItem                   _cycle_node_shape_mi;
     private JMenuItem                   _cycle_node_fill_mi;
     private JMenuItem                   _choose_node_size_mi;
@@ -154,9 +152,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         else if ( o == _view_as_NH_item ) {
             viewAsNH();
         }
-        else if ( o == _view_as_NHX_item ) {
-            viewAsNHX();
-        }
         else if ( o == _view_as_XML_item ) {
             viewAsXML();
         }
@@ -271,7 +266,10 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         else if ( o == _color_labels_same_as_parent_branch ) {
             updateOptions( getOptions() );
         }
-        else if ( o == _show_default_node_shapes_cbmi ) {
+        else if ( o == _show_default_node_shapes_internal_cbmi ) {
+            updateOptions( getOptions() );
+        }
+        else if ( o == _show_default_node_shapes_external_cbmi ) {
             updateOptions( getOptions() );
         }
         else if ( o == _taxonomy_colorize_node_shapes_cbmi ) {
@@ -281,7 +279,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
             MainFrame.about();
         }
         else if ( o == _help_item ) {
-            help( getConfiguration().getWebLinks() );
+            help();
         }
         else if ( o == _website_item ) {
             try {
@@ -339,7 +337,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString();
     }
 
-    public int getCurrentExternalNodesDataBufferCounter() {
+    public int getCurrentExternalNodesDataBufferChangeCounter() {
         return getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter();
     }
 
@@ -423,17 +421,17 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         setupUI();
         URL phys_url = null;
         Phylogeny[] phys = null;
-        final String phys_url_string = getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD );
-        AptxUtil.printAppletMessage( NAME, "URL for phylogenies is " + phys_url_string );
+        final String tree_url_str = getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD );
+        AptxUtil.printAppletMessage( NAME, "URL for phylogenies is " + tree_url_str );
         // Get URL to tree file
-        if ( phys_url_string != null ) {
+        if ( tree_url_str != null ) {
             try {
-                phys_url = new URL( phys_url_string );
+                phys_url = new URL( tree_url_str );
             }
             catch ( final Exception e ) {
                 ForesterUtil.printErrorMessage( NAME, "error: " + e );
                 e.printStackTrace();
-                JOptionPane.showMessageDialog( this, NAME + ": Could not create URL from: \"" + phys_url_string
+                JOptionPane.showMessageDialog( this, NAME + ": Could not create URL from: \"" + tree_url_str
                         + "\"\nException: " + e, "Failed to create URL", JOptionPane.ERROR_MESSAGE );
             }
         }
@@ -489,11 +487,14 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
             @Override
             public void componentResized( final ComponentEvent e ) {
                 if ( getMainPanel().getCurrentTreePanel() != null ) {
-                    getMainPanel().getCurrentTreePanel().setParametersForPainting( getMainPanel().getCurrentTreePanel()
-                                                                                           .getWidth(),
-                                                                                   getMainPanel().getCurrentTreePanel()
-                                                                                           .getHeight(),
-                                                                                   false );
+                    getMainPanel().getCurrentTreePanel().calcParametersForPainting( getMainPanel()
+                                                                                            .getCurrentTreePanel()
+                                                                                            .getWidth(),
+                                                                                    getMainPanel()
+                                                                                            .getCurrentTreePanel()
+                                                                                            .getHeight(),
+                                                                                    getOptions()
+                                                                                            .isAllowFontSizeChange() );
                 }
             }
         } );
@@ -625,7 +626,9 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
                 .add( _show_branch_length_values_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_BRANCH_LENGTH_VALUES_LABEL ) );
         _options_jmenu.add( _show_confidence_stddev_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_CONF_STDDEV_LABEL ) );
         _options_jmenu
-                .add( _show_default_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL ) );
+                .add( _show_default_node_shapes_internal_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_INT ) );
+        _options_jmenu
+                .add( _show_default_node_shapes_external_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_EXT ) );
         _options_jmenu
                 .add( _taxonomy_colorize_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.TAXONOMY_COLORIZE_NODE_SHAPES_LABEL ) );
         _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL ) );
@@ -664,7 +667,10 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );
         customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );
         customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );
-        customizeCheckBoxMenuItem( _show_default_node_shapes_cbmi, getOptions().isShowDefaultNodeShapes() );
+        customizeCheckBoxMenuItem( _show_default_node_shapes_external_cbmi, getOptions()
+                .isShowDefaultNodeShapesExternal() );
+        customizeCheckBoxMenuItem( _show_default_node_shapes_internal_cbmi, getOptions()
+                .isShowDefaultNodeShapesInternal() );
         customizeCheckBoxMenuItem( _taxonomy_colorize_node_shapes_cbmi, getOptions().isTaxonomyColorizeNodeShapes() );
         customizeJMenuItem( _cycle_node_shape_mi );
         customizeJMenuItem( _cycle_node_fill_mi );
@@ -699,9 +705,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         _tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) );
         customizeJMenuItem( _midpoint_root_item );
         _tools_menu.addSeparator();
-        _tools_menu
-                .add( _infer_common_sn_names_item = new JMenuItem( "Infer Common Parts of Internal Scientific Names" ) );
-        customizeJMenuItem( _infer_common_sn_names_item );
         _tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Species-Specific Subtrees" ) );
         customizeJMenuItem( _collapse_species_specific_subtrees );
         _jmenubar.add( _tools_menu );
@@ -737,11 +740,9 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         _view_jmenu.addSeparator();
         _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) );
         _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) );
-        _view_jmenu.add( _view_as_NHX_item = new JMenuItem( "View as NHX" ) );
         _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "View as Nexus" ) );
         customizeJMenuItem( _display_basic_information_item );
         customizeJMenuItem( _view_as_NH_item );
-        customizeJMenuItem( _view_as_NHX_item );
         customizeJMenuItem( _view_as_XML_item );
         customizeJMenuItem( _view_as_nexus_item );
         _jmenubar.add( _view_jmenu );
@@ -814,7 +815,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         return _options;
     }
 
-    void help( final Map<String, WebLink> weblinks ) {
+    void help() {
         final StringBuilder sb = new StringBuilder();
         sb.append( "Display options\n" );
         sb.append( "-------------------\n" );
@@ -852,15 +853,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
         sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
         sb.append( "the '-Xmx' Java command line option. For example:\n" );
-        sb.append( "java -Xms32m -Xmx256m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
-        if ( ( weblinks != null ) && ( weblinks.size() > 0 ) ) {
-            sb.append( "Active web links\n" );
-            sb.append( "--------------------\n" );
-            for( final String key : weblinks.keySet() ) {
-                sb.append( " " + weblinks.get( key ).toString() + "\n" );
-            }
-        }
-        sb.append( "\n" );
+        sb.append( "java -Xmx1024m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
         sb.append( "phyloXML\n" );
         sb.append( "-------------------\n" );
         sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
@@ -1027,8 +1020,10 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
                 && _abbreviate_scientific_names.isSelected() );
         options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
                 && _color_labels_same_as_parent_branch.isSelected() );
-        options.setShowDefaultNodeShapes( ( _show_default_node_shapes_cbmi != null )
-                && _show_default_node_shapes_cbmi.isSelected() );
+        options.setShowDefaultNodeShapesInternal( ( _show_default_node_shapes_internal_cbmi != null )
+                && _show_default_node_shapes_internal_cbmi.isSelected() );
+        options.setShowDefaultNodeShapesExternal( ( _show_default_node_shapes_external_cbmi != null )
+                && _show_default_node_shapes_external_cbmi.isSelected() );
         options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null )
                 && _taxonomy_colorize_node_shapes_cbmi.isSelected() );
         if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
@@ -1118,16 +1113,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         }
     }
 
-    void viewAsNHX() {
-        if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
-            String title = "NHX";
-            if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
-                title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
-            }
-            showTextFrame( getMainPanel().getCurrentPhylogeny().toNewHampshireX(), title );
-        }
-    }
-
     void viewAsXML() {
         if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
             String title = "phyloXML";