JAL-2797 the big switch, all GUI method calls now go via the AptxFrame
[jalview.git] / forester / java / src / org / forester / archaeopteryx / MainFrame.java
index 0336c92..3cdbca2 100644 (file)
@@ -30,19 +30,22 @@ import java.awt.Container;
 import java.awt.Font;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentListener;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 import java.util.NoSuchElementException;
 
 import javax.swing.Box;
-import javax.swing.JApplet;
 import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JFileChooser;
 import javax.swing.JFrame;
+import javax.swing.JInternalFrame;
 import javax.swing.JLabel;
 import javax.swing.JMenu;
 import javax.swing.JMenuBar;
@@ -81,19 +84,19 @@ import org.forester.util.ForesterConstants;
 import org.forester.util.ForesterUtil;
 import org.forester.util.WindowsUtils;
 
-public abstract class MainFrame extends JFrame implements ActionListener {
-
-    final static NHFilter            nhfilter                                = new NHFilter();
-    final static NHXFilter           nhxfilter                               = new NHXFilter();
-    final static XMLFilter           xmlfilter                               = new XMLFilter();
-    final static TolFilter           tolfilter                               = new TolFilter();
-    final static NexusFilter         nexusfilter                             = new NexusFilter();
-    final static PdfFilter           pdffilter                               = new PdfFilter();
-    final static GraphicsFileFilter  graphicsfilefilter                      = new GraphicsFileFilter();
-    final static MsaFileFilter       msafilter                               = new MsaFileFilter();
-    final static SequencesFileFilter seqsfilter                              = new SequencesFileFilter();
-    final static DefaultFilter       defaultfilter                           = new DefaultFilter();
-    static final String              USE_MOUSEWHEEL_SHIFT_TO_ROTATE          = "In this display type, use mousewheel + Shift to rotate [or A and S]";
+public abstract class MainFrame implements ActionListener {
+
+    public final static NHFilter            nhfilter                                = new NHFilter();
+    public final static NHXFilter           nhxfilter                               = new NHXFilter();
+    public final static XMLFilter           xmlfilter                               = new XMLFilter();
+    public final static TolFilter           tolfilter                               = new TolFilter();
+    public final static NexusFilter         nexusfilter                             = new NexusFilter();
+    public final static PdfFilter           pdffilter                               = new PdfFilter();
+    public final static GraphicsFileFilter  graphicsfilefilter                      = new GraphicsFileFilter();
+    public final static MsaFileFilter       msafilter                               = new MsaFileFilter();
+    public final static SequencesFileFilter seqsfilter                              = new SequencesFileFilter();
+    public final static DefaultFilter       defaultfilter                           = new DefaultFilter();
+    static final String              USE_MOUSEWHEEL_SHIFT_TO_ROTATE          = "rotate with mousewheel + Shift (or A and S), D toggles between horizontal and radial labels";
     static final String              PHYLOXML_REF_TOOL_TIP                   = AptxConstants.PHYLOXML_REFERENCE;                                                                                                                                                //TODO //FIXME
     static final String              APTX_REF_TOOL_TIP                       = AptxConstants.APTX_REFERENCE;
     private static final long        serialVersionUID                        = 3655000897845508358L;
@@ -112,14 +115,13 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     static final String              OPTIONS_HEADER                          = "Options";
     static final String              SEARCH_SUBHEADER                        = "Search:";
     static final String              DISPLAY_SUBHEADER                       = "Display:";
-    static final String              SEARCH_TERMS_ONLY_LABEL                 = "Match Complete Terms Only";
-    static final String              SEARCH_REGEX_LABEL                      = "Search with Regular Expressions";
-    static final String              SEARCH_CASE_SENSITIVE_LABEL             = "Case Sensitive";
-    static final String              INVERSE_SEARCH_RESULT_LABEL             = "Negate Result";
+    static final String              SEARCH_TERMS_ONLY_LABEL                 = "Words";
+    static final String              SEARCH_REGEX_LABEL                      = "Regex";
+    static final String              SEARCH_CASE_SENSITIVE_LABEL             = "Match Case";
+    static final String              INVERSE_SEARCH_RESULT_LABEL             = "Inverse";
     static final String              COLOR_BY_TAXONOMIC_GROUP                = "Colorize by Taxonomic Group";
     static final String              DISPLAY_SCALE_LABEL                     = "Scale";
-    static final String              NON_LINED_UP_CLADOGRAMS_LABEL           = "Non-Lined Up Cladograms";
-    static final String              UNIFORM_CLADOGRAMS_LABEL                = "Total Node Sum Dependent Cladograms";
+    static final String              NON_LINED_UP_CLADOGRAMS_LABEL           = "Non-Lined Up Cladogram";
     static final String              LABEL_DIRECTION_LABEL                   = "Radial Labels";
     static final String              LABEL_DIRECTION_TIP                     = "To use radial node labels in radial and unrooted display types";
     static final String              SEARCH_WITH_REGEX_TIP                   = "To search using regular expressions (~Java/Perl syntax). For example, use \"^B.+\\d{2,}$\" to search for everything starting with a B and ending with at least two digits.";
@@ -131,7 +133,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     static final String              DISPLAY_NODE_BOXES_LABEL_MARKED         = "Shapes for Nodes with Visual Data";
     static final String              SHOW_OVERVIEW_LABEL                     = "Overview";
     static final String              FONT_SIZE_MENU_LABEL                    = "Font Size";
-    static final String              NONUNIFORM_CLADOGRAMS_LABEL             = "External Node Sum Dependent Cladograms";
+    static final String              NONUNIFORM_CLADOGRAMS_LABEL             = "Lined Up Cladogram";
     static final String              SHOW_DOMAIN_LABELS_LABEL                = "Domain Labels";
     static final String              SHOW_ANN_REF_SOURCE_LABEL               = "Seq Annotation Ref Sources";
     static final String              COLOR_LABELS_TIP                        = "To use parent branch colors for node labels as well, need to turn off taxonomy dependent colorization and turn on branch colorization for this to become apparent";
@@ -148,6 +150,8 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     static final String              LINE_UP_RENDERABLE_DATA                 = "Line Up Diagrams (such as Domain Architectures)";
     static final String              INFER_ANCESTOR_TAXONOMIES               = "Infer Ancestor Taxonomies";
     static final String              OBTAIN_DETAILED_TAXONOMIC_INFORMATION   = "Obtain Detailed Taxonomic Information";
+    
+    final AptxFrame                  _frame;
     JMenuBar                         _jmenubar;
     JMenu                            _file_jmenu;
     JMenu                            _tools_menu;
@@ -183,6 +187,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     JMenuItem                        _confcolor_item;
     JMenuItem                        _color_rank_jmi;
     JMenuItem                        _collapse_species_specific_subtrees;
+    
     JMenuItem                        _obtain_detailed_taxonomic_information_jmi;
     JMenuItem                        _obtain_detailed_taxonomic_information_deleting_jmi;
     JMenuItem                        _obtain_seq_information_jmi;
@@ -209,7 +214,6 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     JCheckBoxMenuItem                _screen_antialias_cbmi;
     JCheckBoxMenuItem                _background_gradient_cbmi;
     JRadioButtonMenuItem             _non_lined_up_cladograms_rbmi;
-    JRadioButtonMenuItem             _uniform_cladograms_rbmi;
     JRadioButtonMenuItem             _ext_node_dependent_cladogram_rbmi;
     JCheckBoxMenuItem                _color_by_taxonomic_group_cbmi;
     JCheckBoxMenuItem                _show_scale_cbmi;                                                                                                                                                                                                      //TODO fix me
@@ -230,6 +234,8 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     JCheckBoxMenuItem                _show_confidence_stddev_cbmi;
     JCheckBoxMenuItem                _right_line_up_domains_cbmi;
     JCheckBoxMenuItem                _line_up_renderable_data_cbmi;
+    JCheckBoxMenuItem                _collapsed_with_average_height_cbmi;
+    JCheckBoxMenuItem                _show_abbreviated_labels_for_collapsed_nodes_cbmi;
     // _  print
     JCheckBoxMenuItem                _graphics_export_visible_only_cbmi;
     JCheckBoxMenuItem                _antialias_print_cbmi;
@@ -272,6 +278,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     JMenuItem                        _about_item;
     JMenuItem                        _help_item;
     JMenuItem                        _website_item;
+    JMenuItem                        _aptxjs_website_item;
     JMenuItem                        _mailing_list_item;
     JMenuItem                        _phyloxml_website_item;
     JMenuItem                        _phyloxml_ref_item;
@@ -294,6 +301,15 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     private String                   _previous_node_annotation_ref;
 
     MainFrame() {
+        this(false);
+    }
+    MainFrame(boolean embedded){
+        if (embedded) {
+            _frame = new EmbeddedFrame();
+        }
+        else {
+            _frame = new StandaloneFrame();
+        } 
         _process_pool = ProcessPool.createInstance();
         _writetopdf_filechooser = new JFileChooser();
         _writetopdf_filechooser.setMultiSelectionEnabled( false );
@@ -318,21 +334,76 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             // Do nothing. Not important.
         }
     }
-
+    public void addComponentListener( ComponentListener componentListener ) {
+        _frame.addComponentListener( componentListener );
+        
+    }
+    
+    public void dispose() {
+        _frame.dispose();
+    }
+    public Container getContentPane() {
+        return _frame.getContentPane();
+    }
+    
+    public void repaint() {
+       _frame.repaint();
+    }
+    
+     
+    public void addFrameListener(FrameListener frameListener) {
+        _frame.addFrameListener(frameListener);
+    }
+    
+    public void setSize(int x, int y) {
+        _frame.setSize(x,y);
+    }
+    public Container getJMenuBar() {
+        return _frame.getJMenuBar();
+    }
+    public void setDefaultCloseOperation( int doNothingOnClose ) {
+        _frame.setDefaultCloseOperation(doNothingOnClose);
+        
+    }
+    public Container getParent() {
+        return _frame.getParent();
+    }
+    public void setVisible(boolean visible) {
+        _frame.setVisible(visible);
+    }
+    public void requestFocusInWindow() {
+        _frame.requestFocusInWindow();
+    }
+    public void setJMenuBar( JMenuBar jmenubar ) {
+        _frame.setJMenuBar(jmenubar);
+    }
+    public void setLocationRelativeTo( Component component ) {
+        _frame.setLocationRelativeTo(component);  
+    }
+    public void setTitle(String title) {
+       _frame.setTitle(title);
+    }
+    
+    public Container getThisFrame() {
+        return _frame.getThisFrame();
+    }
+    
+    public void validate() {
+        _frame.validate();
+    }
+    
+    
+    
+    
+    
+    
     /**
      * Action performed.
      */
     @Override
     public void actionPerformed( final ActionEvent e ) {
         final Object o = e.getSource();
-        boolean is_applet = false;
-        JApplet applet = null;
-        if ( getCurrentTreePanel() != null ) {
-            is_applet = getCurrentTreePanel().isApplet();
-            if ( is_applet ) {
-                applet = getCurrentTreePanel().obtainApplet();
-            }
-        }
+      
         if ( o == _exit_item ) {
             close();
         }
@@ -452,7 +523,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             chooseMinimalConfidence();
         }
         else if ( o == _choose_node_size_mi ) {
-            chooseNodeSize( getOptions(), this );
+            chooseNodeSize( getOptions(), _frame.getThisFrame() );
         }
         else if ( o == _overview_placment_mi ) {
             MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
@@ -498,15 +569,14 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             updateOptions( getOptions() );
             showWhole();
         }
-        else if ( o == _uniform_cladograms_rbmi ) {
-            updateOptions( getOptions() );
-            showWhole();
-        }
         else if ( o == _ext_node_dependent_cladogram_rbmi ) {
             updateOptions( getOptions() );
             showWhole();
         }
         else if ( o == _search_case_senstive_cbmi ) {
+            if ( ( _search_with_regex_cbmi != null ) && _search_case_senstive_cbmi.isSelected() ) {
+                _search_with_regex_cbmi.setSelected( false );
+            }
             updateOptions( getOptions() );
             getMainPanel().getControlPanel().search0();
             getMainPanel().getControlPanel().search1();
@@ -529,7 +599,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                 _search_whole_words_only_cbmi.setSelected( false );
             }
             if ( ( _search_case_senstive_cbmi != null ) && _search_with_regex_cbmi.isSelected() ) {
-                _search_case_senstive_cbmi.setSelected( true );
+                _search_case_senstive_cbmi.setSelected( false );
             }
             updateOptions( getOptions() );
             getMainPanel().getControlPanel().search0();
@@ -577,6 +647,19 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             }
             updateOptions( getOptions() );
         }
+        
+        else if ( o == _collapsed_with_average_height_cbmi ) {
+            if ( _collapsed_with_average_height_cbmi.isSelected() ) {
+                _collapsed_with_average_height_cbmi.setSelected( true );
+            }
+            updateOptions( getOptions() );
+        }
+        else if ( o == _show_abbreviated_labels_for_collapsed_nodes_cbmi ) {
+            if ( _show_abbreviated_labels_for_collapsed_nodes_cbmi.isSelected() ) {
+                _show_abbreviated_labels_for_collapsed_nodes_cbmi.setSelected( true );
+            }
+            updateOptions( getOptions() );
+        }
         else if ( o == _right_line_up_domains_cbmi ) {
             if ( _right_line_up_domains_cbmi.isSelected() ) {
                 _line_up_renderable_data_cbmi.setSelected( true );
@@ -593,7 +676,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }
         else if ( o == _help_item ) {
             try {
-                AptxUtil.openWebsite( AptxConstants.APTX_DOC_SITE, is_applet, applet );
+                AptxUtil.openWebsite( AptxConstants.APTX_DOC_SITE );
             }
             catch ( final IOException e1 ) {
                 ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
@@ -601,7 +684,15 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }
         else if ( o == _website_item ) {
             try {
-                AptxUtil.openWebsite( AptxConstants.APTX_WEB_SITE, is_applet, applet );
+                AptxUtil.openWebsite( AptxConstants.APTX_WEB_SITE);
+            }
+            catch ( final IOException e1 ) {
+                ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
+            }
+        }
+        else if ( o == _aptxjs_website_item ) {
+            try {
+                AptxUtil.openWebsite( AptxConstants.APTX_JS_WEB_SITE);;
             }
             catch ( final IOException e1 ) {
                 ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
@@ -609,7 +700,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }
         else if ( o == _mailing_list_item ) {
             try {
-                AptxUtil.openWebsite( AptxConstants.APTX_MAILING_LIST, is_applet, applet );
+                AptxUtil.openWebsite( AptxConstants.APTX_MAILING_LIST );
             }
             catch ( final IOException e1 ) {
                 ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
@@ -617,7 +708,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }
         else if ( o == _phyloxml_website_item ) {
             try {
-                AptxUtil.openWebsite( AptxConstants.PHYLOXML_WEB_SITE, is_applet, applet );
+                AptxUtil.openWebsite( AptxConstants.PHYLOXML_WEB_SITE );
             }
             catch ( final IOException e1 ) {
                 ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
@@ -625,7 +716,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }
         else if ( o == _aptx_ref_item ) {
             try {
-                AptxUtil.openWebsite( AptxConstants.APTX_REFERENCE_URL, is_applet, applet );
+                AptxUtil.openWebsite( AptxConstants.APTX_REFERENCE_URL );
             }
             catch ( final IOException e1 ) {
                 ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
@@ -633,7 +724,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }
         else if ( o == _phyloxml_ref_item ) {
             try {
-                AptxUtil.openWebsite( AptxConstants.PHYLOXML_REFERENCE_URL, is_applet, applet );
+                AptxUtil.openWebsite( AptxConstants.PHYLOXML_REFERENCE_URL );
             }
             catch ( final IOException e1 ) {
                 ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
@@ -645,7 +736,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                                               _writetopdf_filechooser,
                                               _current_dir,
                                               getContentPane(),
-                                              this );
+                                              getThisFrame() );
             if ( curr_dir != null ) {
                 setCurrentDir( curr_dir );
             }
@@ -658,7 +749,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                                                       GraphicsExportType.JPG,
                                                       _mainpanel,
                                                       _writetographics_filechooser,
-                                                      this,
+                                                      getThisFrame(),
                                                       getContentPane(),
                                                       _current_dir );
             if ( new_dir != null ) {
@@ -670,7 +761,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                                                       GraphicsExportType.GIF,
                                                       _mainpanel,
                                                       _writetographics_filechooser,
-                                                      this,
+                                                      getThisFrame(),
                                                       getContentPane(),
                                                       _current_dir );
             if ( new_dir != null ) {
@@ -682,7 +773,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                                                       GraphicsExportType.TIFF,
                                                       _mainpanel,
                                                       _writetographics_filechooser,
-                                                      this,
+                                                      getThisFrame(),
                                                       getContentPane(),
                                                       _current_dir );
             if ( new_dir != null ) {
@@ -694,7 +785,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                                                       GraphicsExportType.BMP,
                                                       _mainpanel,
                                                       _writetographics_filechooser,
-                                                      this,
+                                                      getThisFrame(),
                                                       getContentPane(),
                                                       _current_dir );
             if ( new_dir != null ) {
@@ -706,7 +797,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                                                       GraphicsExportType.PNG,
                                                       _mainpanel,
                                                       _writetographics_filechooser,
-                                                      this,
+                                                      getThisFrame(),
                                                       getContentPane(),
                                                       _current_dir );
             if ( new_dir != null ) {
@@ -714,7 +805,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             }
         }
         else if ( o == _print_item ) {
-            print( getCurrentTreePanel(), getOptions(), this );
+            print( getCurrentTreePanel(), getOptions(), _frame.getThisFrame() );
         }
         else if ( o == _save_item ) {
             final File new_dir = writeToFile( _mainpanel.getCurrentPhylogeny(),
@@ -722,7 +813,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                                               _save_filechooser,
                                               _current_dir,
                                               getContentPane(),
-                                              this );
+                                              _frame.getThisFrame() );
             if ( new_dir != null ) {
                 setCurrentDir( new_dir );
             }
@@ -741,7 +832,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }
         else if ( o == _lineage_inference ) {
             if ( isSubtreeDisplayed() ) {
-                JOptionPane.showMessageDialog( this,
+                JOptionPane.showMessageDialog( getThisFrame(),
                                                "Subtree is shown.",
                                                "Cannot infer ancestral taxonomies",
                                                JOptionPane.ERROR_MESSAGE );
@@ -761,6 +852,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         _contentpane.repaint();
     }
 
+
     public Configuration getConfiguration() {
         return _configuration;
     }
@@ -831,7 +923,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             }
             if ( ( nodes == null ) || nodes.isEmpty() ) {
                 JOptionPane
-                        .showMessageDialog( this,
+                        .showMessageDialog( getThisFrame(),
                                             "Need to select nodes, either via direct selection or via the \"Search\" function",
                                             "No nodes selected for annotation",
                                             JOptionPane.ERROR_MESSAGE );
@@ -862,7 +954,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                         ref = ref.replaceAll( "\\s+", " " );
                         if ( ( ref.indexOf( ':' ) < 1 ) || ( ref.indexOf( ':' ) > ( ref.length() - 2 ) )
                                 || ( ref.length() < 3 ) ) {
-                            JOptionPane.showMessageDialog( this,
+                            JOptionPane.showMessageDialog( getThisFrame(),
                                                            "Reference needs to be in the form of \"GO:1234567\"",
                                                            "Illegal Format for Annotation Reference",
                                                            JOptionPane.ERROR_MESSAGE );
@@ -896,7 +988,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     private void chooseFont() {
         final FontChooser fc = new FontChooser();
         fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
-        fc.showDialog( this, "Select the Base Font" );
+        fc.showDialog( getThisFrame(), "Select the Base Font" );
         getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
         getControlPanel().displayedPhylogenyMightHaveChanged( true );
         if ( getMainPanel().getCurrentTreePanel() != null ) {
@@ -909,7 +1001,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
 
     private void chooseMinimalConfidence() {
         final String s = ( String ) JOptionPane
-                .showInputDialog( this,
+                .showInputDialog( getThisFrame(),
                                   "Please enter the minimum for confidence values to be displayed.\n"
                                           + "[current value: " + getOptions().getMinConfidenceValue() + "]\n",
                                   "Minimal Confidence Value",
@@ -958,7 +1050,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }
         if ( ( nodes == null ) || nodes.isEmpty() ) {
             JOptionPane
-                    .showMessageDialog( this,
+                    .showMessageDialog( getThisFrame(),
                                         "Need to select external nodes, either via direct selection or via the \"Search\" function",
                                         "No external nodes selected to " + function.toLowerCase(),
                                         JOptionPane.ERROR_MESSAGE );
@@ -971,7 +1063,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             res = ext - todo;
         }
         if ( res < 1 ) {
-            JOptionPane.showMessageDialog( this,
+            JOptionPane.showMessageDialog( getThisFrame(),
                                            "Cannot delete all nodes",
                                            "Attempt to delete all nodes ",
                                            JOptionPane.ERROR_MESSAGE );
@@ -1016,7 +1108,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                 _process_menu.setForeground( Color.RED );
             }
             _process_menu.removeAll();
-            final String text = "processes running: " + _process_pool.size();
+            final String text = "Processes Running: " + _process_pool.size();
             _process_menu.setText( text );
             _jmenubar.add( _process_menu );
             for( int i = 0; i < _process_pool.size(); ++i ) {
@@ -1069,7 +1161,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         setCurrentDir( _save_filechooser.getCurrentDirectory() );
         if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) {
             if ( file.exists() ) {
-                final int i = JOptionPane.showConfirmDialog( this,
+                final int i = JOptionPane.showConfirmDialog( getThisFrame(),
                                                              file + " already exists. Overwrite?",
                                                              "Warning",
                                                              JOptionPane.OK_CANCEL_OPTION,
@@ -1082,7 +1174,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                         file.delete();
                     }
                     catch ( final Exception e ) {
-                        JOptionPane.showMessageDialog( this,
+                        JOptionPane.showMessageDialog( getThisFrame(),
                                                        "Failed to delete: " + file,
                                                        "Error",
                                                        JOptionPane.WARNING_MESSAGE );
@@ -1105,7 +1197,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                 writer.toPhyloXML( file, trees, 0, ForesterUtil.LINE_SEPARATOR );
             }
             catch ( final IOException e ) {
-                JOptionPane.showMessageDialog( this,
+                JOptionPane.showMessageDialog( getThisFrame(),
                                                "Failed to write to: " + file,
                                                "Error",
                                                JOptionPane.WARNING_MESSAGE );
@@ -1113,7 +1205,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }
     }
 
-    void activateSaveAllIfNeeded() {
+    public void activateSaveAllIfNeeded() {
         if ( ( getMainPanel().getTabbedPane() != null ) && ( getMainPanel().getTabbedPane().getTabCount() > 1 ) ) {
             _save_all_item.setEnabled( true );
         }
@@ -1174,6 +1266,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         _help_jmenu.add( _help_item = new JMenuItem( "Documentation" ) );
         _help_jmenu.addSeparator();
         _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
+        _help_jmenu.add( _aptxjs_website_item = new JMenuItem( "NEW! Archaeopteryx online version: Archaeopteryx.js" ) );
         _help_jmenu.add( _mailing_list_item = new JMenuItem( "Mailing List" ) );
         _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" ); //TODO need to add this...
         _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
@@ -1182,6 +1275,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
         customizeJMenuItem( _help_item );
         customizeJMenuItem( _website_item );
+        customizeJMenuItem( _aptxjs_website_item );
         customizeJMenuItem( _mailing_list_item );
         customizeJMenuItem( _phyloxml_website_item );
         customizeJMenuItem( _aptx_ref_item );
@@ -1210,6 +1304,8 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         customizeCheckBoxMenuItem( _convex_type_cbmi, false );
         customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
         customizeCheckBoxMenuItem( _circular_type_cbmi, false );
+        _triangular_type_cbmi.setToolTipText( "not suitable for phylograms" );
+        _curved_type_cbmi.setToolTipText( "not suitable for phylograms" );
         _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
         _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
         initializeTypeMenu( getOptions() );
@@ -1247,7 +1343,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     }
 
     void choosePdfWidth() {
-        final String s = ( String ) JOptionPane.showInputDialog( this,
+        final String s = ( String ) JOptionPane.showInputDialog( getThisFrame(),
                                                                  "Please enter the default line width for PDF export.\n"
                                                                          + "[current value: "
                                                                          + getOptions().getPrintLineWidth() + "]\n",
@@ -1291,9 +1387,10 @@ public abstract class MainFrame extends JFrame implements ActionListener {
 
     void colorRank() {
         if ( _mainpanel.getCurrentTreePanel() != null ) {
-            final String[] ranks = AptxUtil.getAllPossibleRanks();
-            final String rank = ( String ) JOptionPane
-                    .showInputDialog( this,
+            final Map<String, Integer> present_ranks = AptxUtil.getRankCounts( _mainpanel.getCurrentTreePanel().getPhylogeny());
+            final String[] ranks = AptxUtil.getAllPossibleRanks(present_ranks);
+            String rank = ( String ) JOptionPane
+                    .showInputDialog( getThisFrame(),
                                       "What rank should the colorization be based on",
                                       "Rank Selection",
                                       JOptionPane.QUESTION_MESSAGE,
@@ -1301,6 +1398,9 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                                       ranks,
                                       null );
             if ( !ForesterUtil.isEmpty( rank ) ) {
+                if ( rank.indexOf( '(' ) > 0 ) {
+                    rank = rank.substring( 0, rank.indexOf( '(' ) ).trim();
+                }
                 _mainpanel.getCurrentTreePanel().colorRank( rank );
             }
         }
@@ -1365,7 +1465,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         catch ( final Exception ex ) {
             // Do nothing.
         }
-        JOptionPane.showMessageDialog( this,
+        JOptionPane.showMessageDialog( getThisFrame(),
                                        ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
                                        "Error during File|Open",
                                        JOptionPane.ERROR_MESSAGE );
@@ -1376,7 +1476,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             return;
         }
         if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {
-            JOptionPane.showMessageDialog( this,
+            JOptionPane.showMessageDialog( getThisFrame(),
                                            "Gene tree is not rooted.",
                                            "Cannot execute GSDI",
                                            JOptionPane.ERROR_MESSAGE );
@@ -1391,7 +1491,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             gsdi = new GSDI( gene_tree, species_tree, false, true, true, true );
         }
         catch ( final SDIException e ) {
-            JOptionPane.showMessageDialog( this,
+            JOptionPane.showMessageDialog( getThisFrame(),
                                            e.getLocalizedMessage(),
                                            "Error during GSDI",
                                            JOptionPane.ERROR_MESSAGE );
@@ -1415,7 +1515,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         _mainpanel.getCurrentTreePanel().setEdited( true );
         final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
         if ( gsdi.getStrippedExternalGeneTreeNodes().size() > 0 ) {
-            JOptionPane.showMessageDialog( this,
+            JOptionPane.showMessageDialog( getThisFrame(),
                                            "Duplications: " + gsdi.getDuplicationsSum() + "\n"
                                                    + "Potential duplications: "
                                                    + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
@@ -1428,7 +1528,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                                            JOptionPane.WARNING_MESSAGE );
         }
         else {
-            JOptionPane.showMessageDialog( this,
+            JOptionPane.showMessageDialog( getThisFrame(),
                                            "Duplications: " + gsdi.getDuplicationsSum() + "\n"
                                                    + "Potential duplications: "
                                                    + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
@@ -1449,7 +1549,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         final int p = PhylogenyMethods.countNumberOfPolytomies( _mainpanel.getCurrentPhylogeny() );
         if ( ( p > 0 )
                 && !( ( p == 1 ) && ( _mainpanel.getCurrentPhylogeny().getRoot().getNumberOfDescendants() == 3 ) ) ) {
-            JOptionPane.showMessageDialog( this,
+            JOptionPane.showMessageDialog( getThisFrame(),
                                            "Gene tree is not completely binary",
                                            "Cannot execute GSDI",
                                            JOptionPane.ERROR_MESSAGE );
@@ -1464,7 +1564,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             gsdir = new GSDIR( gene_tree, species_tree, true, true, true );
         }
         catch ( final SDIException e ) {
-            JOptionPane.showMessageDialog( this,
+            JOptionPane.showMessageDialog( getThisFrame(),
                                            e.getLocalizedMessage(),
                                            "Error during GSDIR",
                                            JOptionPane.ERROR_MESSAGE );
@@ -1490,7 +1590,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         _mainpanel.getCurrentTreePanel().setEdited( true );
         final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
         if ( gsdir.getStrippedExternalGeneTreeNodes().size() > 0 ) {
-            JOptionPane.showMessageDialog( this,
+            JOptionPane.showMessageDialog( getThisFrame(),
                                            "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
                                                    + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
                                                    + "Stripped gene tree nodes: "
@@ -1501,7 +1601,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                                            JOptionPane.WARNING_MESSAGE );
         }
         else {
-            JOptionPane.showMessageDialog( this,
+            JOptionPane.showMessageDialog( getThisFrame(),
                                            "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
                                                    + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
                                                    + "Stripped gene tree nodes: "
@@ -1518,7 +1618,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             return;
         }
         if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {
-            JOptionPane.showMessageDialog( this,
+            JOptionPane.showMessageDialog( getThisFrame(),
                                            "Phylogeny is not rooted.",
                                            "Cannot infer ancestral taxonomies",
                                            JOptionPane.ERROR_MESSAGE );
@@ -1533,14 +1633,14 @@ public abstract class MainFrame extends JFrame implements ActionListener {
 
     boolean GAndSDoHaveMoreThanOneSpeciesInComman( final Phylogeny gene_tree ) {
         if ( ( gene_tree == null ) || gene_tree.isEmpty() ) {
-            JOptionPane.showMessageDialog( this,
+            JOptionPane.showMessageDialog( getThisFrame(),
                                            "Gene tree and species tree have no species in common.",
                                            "Error during SDI",
                                            JOptionPane.ERROR_MESSAGE );
             return false;
         }
         else if ( gene_tree.getNumberOfExternalNodes() < 2 ) {
-            JOptionPane.showMessageDialog( this,
+            JOptionPane.showMessageDialog( getThisFrame(),
                                            "Gene tree and species tree have only one species in common.",
                                            "Error during SDI",
                                            JOptionPane.ERROR_MESSAGE );
@@ -1632,21 +1732,21 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             return false;
         }
         else if ( ( getSpeciesTree() == null ) || getSpeciesTree().isEmpty() ) {
-            JOptionPane.showMessageDialog( this,
+            JOptionPane.showMessageDialog( getThisFrame(),
                                            "No species tree loaded",
                                            "Cannot execute GSDI",
                                            JOptionPane.ERROR_MESSAGE );
             return false;
         }
         else if ( species_tree_has_to_binary && !getSpeciesTree().isCompletelyBinary() ) {
-            JOptionPane.showMessageDialog( this,
+            JOptionPane.showMessageDialog( getThisFrame(),
                                            "Species tree is not completely binary",
                                            "Cannot execute GSDI",
                                            JOptionPane.ERROR_MESSAGE );
             return false;
         }
         else if ( gene_tree_has_to_binary && !_mainpanel.getCurrentPhylogeny().isCompletelyBinary() ) {
-            JOptionPane.showMessageDialog( this,
+            JOptionPane.showMessageDialog( getThisFrame(),
                                            "Gene tree is not completely binary",
                                            "Cannot execute GSDI",
                                            JOptionPane.ERROR_MESSAGE );
@@ -1661,7 +1761,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         if ( getCurrentTreePanel() != null ) {
             if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
                 JOptionPane
-                        .showMessageDialog( this,
+                        .showMessageDialog( getThisFrame(),
                                             "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",
                                             "Operation can not be exectuted on a sub-tree",
                                             JOptionPane.WARNING_MESSAGE );
@@ -1832,11 +1932,8 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
             options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
         }
-        else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
-            options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
-        }
         else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
-            options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
+            options.setCladogramType( CLADOGRAM_TYPE.LINED_UP );
         }
         options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
                 && _search_case_senstive_cbmi.isSelected() );
@@ -1933,6 +2030,13 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         if ( ( _parse_beast_style_extended_nexus_tags_cbmi != null ) && _parse_beast_style_extended_nexus_tags_cbmi.isEnabled() ) {
             options.setParseBeastStyleExtendedNexusTags(_parse_beast_style_extended_nexus_tags_cbmi.isSelected() );
         }
+        if ( ( _collapsed_with_average_height_cbmi != null ) && _collapsed_with_average_height_cbmi.isEnabled() ) {
+            options.setCollapsedWithAverageHeigh(_collapsed_with_average_height_cbmi.isSelected() );
+        }
+        if ( ( _show_abbreviated_labels_for_collapsed_nodes_cbmi != null ) && _show_abbreviated_labels_for_collapsed_nodes_cbmi.isEnabled() ) {
+            options.setShowAbbreviatedLabelsForCollapsedNodes(_show_abbreviated_labels_for_collapsed_nodes_cbmi.isSelected() );
+        }
+        
     }
 
     void updateTypeCheckboxes( final Options options, final Object o ) {
@@ -2592,6 +2696,8 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }
         return new_current_dir;
     }
+
 }
 
 class DefaultFilter extends FileFilter {