in progress
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Wed, 11 Mar 2015 02:24:33 +0000 (02:24 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Wed, 11 Mar 2015 02:24:33 +0000 (02:24 +0000)
24 files changed:
forester/java/src/org/forester/archaeopteryx/AptxUtil.java
forester/java/src/org/forester/archaeopteryx/Archaeopteryx.java
forester/java/src/org/forester/archaeopteryx/ArchaeopteryxA.java
forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java
forester/java/src/org/forester/archaeopteryx/ColorSchemeChooser.java
forester/java/src/org/forester/archaeopteryx/Configuration.java
forester/java/src/org/forester/archaeopteryx/Constants.java
forester/java/src/org/forester/archaeopteryx/ControlPanel.java
forester/java/src/org/forester/archaeopteryx/FontChooser.java
forester/java/src/org/forester/archaeopteryx/MainFrame.java
forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java
forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java
forester/java/src/org/forester/archaeopteryx/MainPanel.java
forester/java/src/org/forester/archaeopteryx/MainPanelApplets.java
forester/java/src/org/forester/archaeopteryx/NodeEditPanel.java
forester/java/src/org/forester/archaeopteryx/NodePanel.java
forester/java/src/org/forester/archaeopteryx/Options.java
forester/java/src/org/forester/archaeopteryx/PdfExporter.java
forester/java/src/org/forester/archaeopteryx/TextFrame.java
forester/java/src/org/forester/archaeopteryx/TreeColorSet.java
forester/java/src/org/forester/archaeopteryx/TreeFontSet.java
forester/java/src/org/forester/archaeopteryx/TreePanel.java
forester/java/src/org/forester/archaeopteryx/TreePanelUtil.java
forester/java/src/org/forester/archaeopteryx/UrlTreeReader.java

index 3ac6c56..14bcc07 100644 (file)
@@ -83,12 +83,64 @@ import org.forester.util.ForesterUtil;
 
 public final class AptxUtil {
 
+    public static enum GraphicsExportType {
+        BMP( "bmp" ), GIF( "gif" ), JPG( "jpg" ), PDF( "pdf" ), PNG( "png" ), TIFF( "tif" );
+
+        private final String _suffix;
+
+        private GraphicsExportType( final String suffix ) {
+            _suffix = suffix;
+        }
+
+        @Override
+        public String toString() {
+            return _suffix;
+        }
+    }
     private final static String[] AVAILABLE_FONT_FAMILIES_SORTED = GraphicsEnvironment.getLocalGraphicsEnvironment()
-                                                                         .getAvailableFontFamilyNames();
+            .getAvailableFontFamilyNames();
     static {
         Arrays.sort( AVAILABLE_FONT_FAMILIES_SORTED );
     }
 
+    final public static Color calculateColorFromString( final String str, final boolean is_taxonomy ) {
+        final String my_str = str.toUpperCase();
+        char first = my_str.charAt( 0 );
+        char second = ' ';
+        char third = ' ';
+        if ( my_str.length() > 1 ) {
+            if ( is_taxonomy ) {
+                second = my_str.charAt( 1 );
+            }
+            else {
+                second = my_str.charAt( my_str.length() - 1 );
+            }
+            if ( is_taxonomy ) {
+                if ( my_str.length() > 2 ) {
+                    if ( my_str.indexOf( " " ) > 0 ) {
+                        third = my_str.charAt( my_str.indexOf( " " ) + 1 );
+                    }
+                    else {
+                        third = my_str.charAt( 2 );
+                    }
+                }
+            }
+            else if ( my_str.length() > 2 ) {
+                third = my_str.charAt( ( my_str.length() - 1 ) / 2 );
+            }
+        }
+        first = normalizeCharForRGB( first );
+        second = normalizeCharForRGB( second );
+        third = normalizeCharForRGB( third );
+        if ( ( first > 235 ) && ( second > 235 ) && ( third > 235 ) ) {
+            first = 0;
+        }
+        else if ( ( first < 60 ) && ( second < 60 ) && ( third < 60 ) ) {
+            second = 255;
+        }
+        return new Color( first, second, third );
+    }
+
     public static MaskFormatter createMaskFormatter( final String s ) {
         MaskFormatter formatter = null;
         try {
@@ -126,16 +178,6 @@ public final class AptxUtil {
         return false;
     }
 
-    final static public boolean isHasAtLeastOneBranchWithSupportValues( final Phylogeny phy ) {
-        final PhylogenyNodeIterator it = phy.iteratorPostorder();
-        while ( it.hasNext() ) {
-            if ( it.next().getBranchData().isHasConfidences() ) {
-                return true;
-            }
-        }
-        return false;
-    }
-
     final static public boolean isHasAtLeastOneBranchWithSupportSD( final Phylogeny phy ) {
         final PhylogenyNodeIterator it = phy.iteratorPostorder();
         while ( it.hasNext() ) {
@@ -152,6 +194,16 @@ public final class AptxUtil {
         return false;
     }
 
+    final static public boolean isHasAtLeastOneBranchWithSupportValues( final Phylogeny phy ) {
+        final PhylogenyNodeIterator it = phy.iteratorPostorder();
+        while ( it.hasNext() ) {
+            if ( it.next().getBranchData().isHasConfidences() ) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     final static public boolean isHasAtLeastOneNodeWithScientificName( final Phylogeny phy ) {
         final PhylogenyNodeIterator it = phy.iteratorPostorder();
         while ( it.hasNext() ) {
@@ -232,10 +284,61 @@ public final class AptxUtil {
         System.out.println( "[" + name + "] > " + message );
     }
 
+    final public static Phylogeny[] readPhylogeniesFromUrl( final URL url,
+                                                            final boolean phyloxml_validate_against_xsd,
+                                                            final boolean replace_underscores,
+                                                            final boolean internal_numbers_are_confidences,
+                                                            final TAXONOMY_EXTRACTION taxonomy_extraction,
+                                                            final boolean midpoint_reroot )
+                                                                    throws FileNotFoundException, IOException {
+        final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
+        final PhylogenyParser parser;
+        boolean nhx_or_nexus = false;
+        if ( url.getHost().toLowerCase().indexOf( "tolweb" ) >= 0 ) {
+            parser = new TolParser();
+        }
+        else {
+            parser = ParserUtils.createParserDependingOnUrlContents( url, phyloxml_validate_against_xsd );
+            if ( parser instanceof NHXParser ) {
+                nhx_or_nexus = true;
+                final NHXParser nhx = ( NHXParser ) parser;
+                nhx.setReplaceUnderscores( replace_underscores );
+                nhx.setIgnoreQuotes( false );
+                nhx.setTaxonomyExtraction( taxonomy_extraction );
+            }
+            else if ( parser instanceof NexusPhylogeniesParser ) {
+                nhx_or_nexus = true;
+                final NexusPhylogeniesParser nex = ( NexusPhylogeniesParser ) parser;
+                nex.setReplaceUnderscores( replace_underscores );
+                nex.setIgnoreQuotes( false );
+            }
+        }
+        AptxUtil.printAppletMessage( "Archaeopteryx", "parser is " + parser.getName() );
+        final URLConnection url_connection = url.openConnection();
+        url_connection.setDefaultUseCaches( false );
+        final InputStream i = url_connection.getInputStream();
+        final Phylogeny[] phys = factory.create( i, parser );
+        i.close();
+        if ( phys != null ) {
+            if ( nhx_or_nexus && internal_numbers_are_confidences ) {
+                for( final Phylogeny phy : phys ) {
+                    PhylogenyMethods.transferInternalNodeNamesToConfidence( phy, "" );
+                }
+            }
+            if ( midpoint_reroot ) {
+                for( final Phylogeny phy : phys ) {
+                    PhylogenyMethods.midpointRoot( phy );
+                    PhylogenyMethods.orderAppearance( phy.getRoot(), true, true, DESCENDANT_SORT_PRIORITY.NODE_NAME );
+                }
+            }
+        }
+        return phys;
+    }
+
     final public static void showErrorMessage( final Component parent, final String error_msg ) {
         printAppletMessage( Constants.PRG_NAME, error_msg );
         JOptionPane.showMessageDialog( parent, error_msg, "[" + Constants.PRG_NAME + " " + Constants.VERSION
-                + "] Error", JOptionPane.ERROR_MESSAGE );
+                                       + "] Error", JOptionPane.ERROR_MESSAGE );
     }
 
     public static void writePhylogenyToGraphicsFile( final File intree,
@@ -260,7 +363,7 @@ public final class AptxUtil {
         phys[ 0 ] = phy;
         final MainFrameApplication mf = MainFrameApplication.createInstance( phys, config );
         AptxUtil.writePhylogenyToGraphicsFileNonInteractive( outfile, width, height, mf.getMainPanel()
-                .getCurrentTreePanel(), mf.getMainPanel().getControlPanel(), type, mf.getOptions() );
+                                                             .getCurrentTreePanel(), mf.getMainPanel().getControlPanel(), type, mf.getOptions() );
         mf.end();
     }
 
@@ -305,6 +408,44 @@ public final class AptxUtil {
         g2d.dispose();
     }
 
+    final private static char normalizeCharForRGB( char c ) {
+        c -= 65;
+        c *= 10.2;
+        c = c > 255 ? 255 : c;
+        c = c < 0 ? 0 : c;
+        return c;
+    }
+
+    final private static void openUrlInWebBrowser( final String url ) throws IOException, ClassNotFoundException,
+    SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException,
+    InvocationTargetException, InterruptedException {
+        final String os = System.getProperty( "os.name" );
+        final Runtime runtime = Runtime.getRuntime();
+        if ( os.toLowerCase().startsWith( "win" ) ) {
+            Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler " + url );
+        }
+        else if ( ForesterUtil.isMac() ) {
+            final Class<?> file_mgr = Class.forName( "com.apple.eio.FileManager" );
+            final Method open_url = file_mgr.getDeclaredMethod( "openURL", new Class[] { String.class } );
+            open_url.invoke( null, new Object[] { url } );
+        }
+        else {
+            final String[] browsers = { "firefox", "opera", "konqueror", "mozilla", "netscape", "epiphany" };
+            String browser = null;
+            for( int i = 0; ( i < browsers.length ) && ( browser == null ); ++i ) {
+                if ( runtime.exec( new String[] { "which", browsers[ i ] } ).waitFor() == 0 ) {
+                    browser = browsers[ i ];
+                }
+            }
+            if ( browser == null ) {
+                throw new IOException( "could not find a web browser to open [" + url + "] in" );
+            }
+            else {
+                runtime.exec( new String[] { browser, url } );
+            }
+        }
+    }
+
     final static void addPhylogeniesToTabs( final Phylogeny[] phys,
                                             final String default_name,
                                             final String full_path,
@@ -312,8 +453,8 @@ public final class AptxUtil {
                                             final MainPanel main_panel ) {
         if ( phys.length > Constants.MAX_TREES_TO_LOAD ) {
             JOptionPane.showMessageDialog( main_panel, "Attempt to load " + phys.length
-                    + " phylogenies,\ngoing to load only the first " + Constants.MAX_TREES_TO_LOAD, Constants.PRG_NAME
-                    + " more than " + Constants.MAX_TREES_TO_LOAD + " phylogenies", JOptionPane.WARNING_MESSAGE );
+                                           + " phylogenies,\ngoing to load only the first " + Constants.MAX_TREES_TO_LOAD, Constants.PRG_NAME
+                                           + " more than " + Constants.MAX_TREES_TO_LOAD + " phylogenies", JOptionPane.WARNING_MESSAGE );
         }
         int i = 1;
         for( final Phylogeny phy : phys ) {
@@ -684,8 +825,8 @@ public final class AptxUtil {
         JOptionPane.showMessageDialog( null,
                                        "Java memory allocation might be too small, try \"-Xmx2048m\" java command line option"
                                                + "\n\nError: " + e.getLocalizedMessage(),
-                                       "Out of Memory Error [" + Constants.PRG_NAME + " " + Constants.VERSION + "]",
-                                       JOptionPane.ERROR_MESSAGE );
+                                               "Out of Memory Error [" + Constants.PRG_NAME + " " + Constants.VERSION + "]",
+                                               JOptionPane.ERROR_MESSAGE );
         System.exit( -1 );
     }
 
@@ -693,57 +834,6 @@ public final class AptxUtil {
         System.out.println( "[" + applet_name + "] > " + message );
     }
 
-    final public static Phylogeny[] readPhylogeniesFromUrl( final URL url,
-                                                            final boolean phyloxml_validate_against_xsd,
-                                                            final boolean replace_underscores,
-                                                            final boolean internal_numbers_are_confidences,
-                                                            final TAXONOMY_EXTRACTION taxonomy_extraction,
-                                                            final boolean midpoint_reroot )
-            throws FileNotFoundException, IOException {
-        final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
-        final PhylogenyParser parser;
-        boolean nhx_or_nexus = false;
-        if ( url.getHost().toLowerCase().indexOf( "tolweb" ) >= 0 ) {
-            parser = new TolParser();
-        }
-        else {
-            parser = ParserUtils.createParserDependingOnUrlContents( url, phyloxml_validate_against_xsd );
-            if ( parser instanceof NHXParser ) {
-                nhx_or_nexus = true;
-                final NHXParser nhx = ( NHXParser ) parser;
-                nhx.setReplaceUnderscores( replace_underscores );
-                nhx.setIgnoreQuotes( false );
-                nhx.setTaxonomyExtraction( taxonomy_extraction );
-            }
-            else if ( parser instanceof NexusPhylogeniesParser ) {
-                nhx_or_nexus = true;
-                final NexusPhylogeniesParser nex = ( NexusPhylogeniesParser ) parser;
-                nex.setReplaceUnderscores( replace_underscores );
-                nex.setIgnoreQuotes( false );
-            }
-        }
-        AptxUtil.printAppletMessage( "Archaeopteryx", "parser is " + parser.getName() );
-        final URLConnection url_connection = url.openConnection();
-        url_connection.setDefaultUseCaches( false );
-        final InputStream i = url_connection.getInputStream();
-        final Phylogeny[] phys = factory.create( i, parser );
-        i.close();
-        if ( phys != null ) {
-            if ( nhx_or_nexus && internal_numbers_are_confidences ) {
-                for( final Phylogeny phy : phys ) {
-                    PhylogenyMethods.transferInternalNodeNamesToConfidence( phy, "" );
-                }
-            }
-            if ( midpoint_reroot ) {
-                for( final Phylogeny phy : phys ) {
-                    PhylogenyMethods.midpointRoot( phy );
-                    PhylogenyMethods.orderAppearance( phy.getRoot(), true, true, DESCENDANT_SORT_PRIORITY.NODE_NAME );
-                }
-            }
-        }
-        return phys;
-    }
-
     final static void removeBranchColors( final Phylogeny phy ) {
         for( final PhylogenyNodeIterator it = phy.iteratorPreorder(); it.hasNext(); ) {
             it.next().getBranchData().setBranchColor( null );
@@ -765,10 +855,10 @@ public final class AptxUtil {
             sb.append( s + "\n" );
         }
         JOptionPane
-                .showMessageDialog( null,
-                                    "An unexpected (possibly severe) error has occured - terminating. \nPlease contact: "
-                                            + Constants.AUTHOR_EMAIL + " \nError: " + e.getLocalizedMessage() + "\n"
-                                            + sb,
+        .showMessageDialog( null,
+                            "An unexpected (possibly severe) error has occured - terminating. \nPlease contact: "
+                                    + Constants.AUTHOR_EMAIL + " \nError: " + e.getLocalizedMessage() + "\n"
+                                    + sb,
                                     "Unexpected Severe Error [" + Constants.PRG_NAME + " " + Constants.VERSION + "]",
                                     JOptionPane.ERROR_MESSAGE );
         System.exit( -1 );
@@ -786,8 +876,8 @@ public final class AptxUtil {
                                        "An unexpected exception has occured. \nPlease contact: "
                                                + Constants.AUTHOR_EMAIL + " \nException: " + e.getLocalizedMessage()
                                                + "\n" + sb,
-                                       "Unexpected Exception [" + Constants.PRG_NAME + Constants.VERSION + "]",
-                                       JOptionPane.ERROR_MESSAGE );
+                                               "Unexpected Exception [" + Constants.PRG_NAME + Constants.VERSION + "]",
+                                               JOptionPane.ERROR_MESSAGE );
     }
 
     final static String writePhylogenyToGraphicsByteArrayOutputStream( final ByteArrayOutputStream baos,
@@ -957,95 +1047,4 @@ public final class AptxUtil {
         final IIOImage iio_image = new IIOImage( image, null, null );
         writer.write( null, iio_image, image_write_param );
     }
-
-    final private static void openUrlInWebBrowser( final String url ) throws IOException, ClassNotFoundException,
-            SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException,
-            InvocationTargetException, InterruptedException {
-        final String os = System.getProperty( "os.name" );
-        final Runtime runtime = Runtime.getRuntime();
-        if ( os.toLowerCase().startsWith( "win" ) ) {
-            Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler " + url );
-        }
-        else if ( ForesterUtil.isMac() ) {
-            final Class<?> file_mgr = Class.forName( "com.apple.eio.FileManager" );
-            final Method open_url = file_mgr.getDeclaredMethod( "openURL", new Class[] { String.class } );
-            open_url.invoke( null, new Object[] { url } );
-        }
-        else {
-            final String[] browsers = { "firefox", "opera", "konqueror", "mozilla", "netscape", "epiphany" };
-            String browser = null;
-            for( int i = 0; ( i < browsers.length ) && ( browser == null ); ++i ) {
-                if ( runtime.exec( new String[] { "which", browsers[ i ] } ).waitFor() == 0 ) {
-                    browser = browsers[ i ];
-                }
-            }
-            if ( browser == null ) {
-                throw new IOException( "could not find a web browser to open [" + url + "] in" );
-            }
-            else {
-                runtime.exec( new String[] { browser, url } );
-            }
-        }
-    }
-
-    public static enum GraphicsExportType {
-        BMP( "bmp" ), GIF( "gif" ), JPG( "jpg" ), PDF( "pdf" ), PNG( "png" ), TIFF( "tif" );
-
-        private final String _suffix;
-
-        private GraphicsExportType( final String suffix ) {
-            _suffix = suffix;
-        }
-
-        @Override
-        public String toString() {
-            return _suffix;
-        }
-    }
-
-    final public static Color calculateColorFromString( final String str, final boolean is_taxonomy ) {
-        final String my_str = str.toUpperCase();
-        char first = my_str.charAt( 0 );
-        char second = ' ';
-        char third = ' ';
-        if ( my_str.length() > 1 ) {
-            if ( is_taxonomy ) {
-                second = my_str.charAt( 1 );
-            }
-            else {
-                second = my_str.charAt( my_str.length() - 1 );
-            }
-            if ( is_taxonomy ) {
-                if ( my_str.length() > 2 ) {
-                    if ( my_str.indexOf( " " ) > 0 ) {
-                        third = my_str.charAt( my_str.indexOf( " " ) + 1 );
-                    }
-                    else {
-                        third = my_str.charAt( 2 );
-                    }
-                }
-            }
-            else if ( my_str.length() > 2 ) {
-                third = my_str.charAt( ( my_str.length() - 1 ) / 2 );
-            }
-        }
-        first = normalizeCharForRGB( first );
-        second = normalizeCharForRGB( second );
-        third = normalizeCharForRGB( third );
-        if ( ( first > 235 ) && ( second > 235 ) && ( third > 235 ) ) {
-            first = 0;
-        }
-        else if ( ( first < 60 ) && ( second < 60 ) && ( third < 60 ) ) {
-            second = 255;
-        }
-        return new Color( first, second, third );
-    }
-
-    final private static char normalizeCharForRGB( char c ) {
-        c -= 65;
-        c *= 10.2;
-        c = c > 255 ? 255 : c;
-        c = c < 0 ? 0 : c;
-        return c;
-    }
 }
index 8a3eed6..e1a8a47 100644 (file)
@@ -44,6 +44,12 @@ public final class Archaeopteryx {
         return createApplication( phylogenies, "", "" );
     }
 
+    public static MainFrame createApplication( final Phylogeny phylogeny, final Configuration config, final String title ) {
+        final Phylogeny[] phylogenies = new Phylogeny[ 1 ];
+        phylogenies[ 0 ] = phylogeny;
+        return MainFrameApplication.createInstance( phylogenies, config, title );
+    }
+
     public static MainFrame createApplication( final Phylogeny[] phylogenies ) {
         return createApplication( phylogenies, "", "" );
     }
@@ -54,12 +60,6 @@ public final class Archaeopteryx {
         return MainFrameApplication.createInstance( phylogenies, config_file_name, title );
     }
 
-    public static MainFrame createApplication( final Phylogeny phylogeny, final Configuration config, final String title ) {
-        final Phylogeny[] phylogenies = new Phylogeny[ 1 ];
-        phylogenies[ 0 ] = phylogeny;
-        return MainFrameApplication.createInstance( phylogenies, config, title );
-    }
-    
     public static void main( final String args[] ) {
         Phylogeny[] phylogenies = null;
         String config_filename = null;
@@ -88,7 +88,7 @@ public final class Archaeopteryx {
                     }
                     boolean nhx_or_nexus = false;
                     final PhylogenyParser p = ParserUtils.createParserDependingOnFileType( f, conf
-                            .isValidatePhyloXmlAgainstSchema() );
+                                                                                           .isValidatePhyloXmlAgainstSchema() );
                     if ( p instanceof NHXParser ) {
                         nhx_or_nexus = true;
                         final NHXParser nhx = ( NHXParser ) p;
index d204f5f..87ba7b7 100644 (file)
@@ -60,8 +60,6 @@ public class ArchaeopteryxA extends JApplet {
             getMainFrameApplet().close();
         }
     }
-    
-    
 
     /**
      * This method returns the current external node data which
@@ -140,9 +138,9 @@ public class ArchaeopteryxA extends JApplet {
             _mainframe_applet = new MainFrameApplet( this, configuration, getSpeciesTreeUrlStr() );
             final URL tree_url = new URL( getTreeUrlStr() );
             final Phylogeny[] phys = AptxUtil.readPhylogeniesFromUrl( tree_url, configuration
-                    .isValidatePhyloXmlAgainstSchema(), configuration.isReplaceUnderscoresInNhParsing(), configuration
-                    .isInternalNumberAreConfidenceForNhParsing(), configuration.getTaxonomyExtraction(), configuration
-                    .isMidpointReroot() );
+                                                                      .isValidatePhyloXmlAgainstSchema(), configuration.isReplaceUnderscoresInNhParsing(), configuration
+                                                                      .isInternalNumberAreConfidenceForNhParsing(), configuration.getTaxonomyExtraction(), configuration
+                                                                      .isMidpointReroot() );
             if ( phys == null ) {
                 ForesterUtil.printErrorMessage( NAME, "phylogenies from [" + tree_url + "] are null" );
             }
@@ -185,12 +183,12 @@ public class ArchaeopteryxA extends JApplet {
         final String default_relation = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_SEQUENCE_RELATION_TYPE );
         if ( default_relation != null ) {
             getMainFrameApplet().getMainPanel().getControlPanel().getSequenceRelationTypeBox()
-                    .setSelectedItem( default_relation );
+            .setSelectedItem( default_relation );
         }
         final String default_sequence = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_QUERY_SEQUENCE );
         if ( default_sequence != null ) {
             getMainFrameApplet().getMainPanel().getControlPanel().getSequenceRelationBox()
-                    .setSelectedItem( default_sequence );
+            .setSelectedItem( default_sequence );
         }
         /* GUILHEM_END */
     }
index daa0147..4321360 100644 (file)
@@ -138,13 +138,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
     private JCheckBoxMenuItem           _right_line_up_domains_cbmi;
     private JCheckBoxMenuItem           _line_up_renderable_data_cbmi;
     // file menu:
-    private JMenuItem                   _open_item;
-    private JMenuItem                   _open_url_item;
     private JMenuItem                   _save_item;
-    private JMenuItem                   _save_all_item;
-    private JMenuItem                   _close_item;
-    private JMenuItem                   _exit_item;
-    private JMenuItem                   _new_item;
     private JMenuItem                   _print_item;
     private JMenuItem                   _write_to_pdf_item;
     private JMenuItem                   _write_to_jpg_item;
@@ -158,64 +152,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
     private JFileChooser                _save_filechooser;
     private JFileChooser                _writetographics_filechooser;
 
-    void setCurrentDir( final File current_dir ) {
-        _current_dir = current_dir;
-    }
-
-    File getCurrentDir() {
-        if ( ( _current_dir == null ) || !_current_dir.canRead() ) {
-            if ( ForesterUtil.isWindows() ) {
-                try {
-                    _current_dir = new File( WindowsUtils.getCurrentUserDesktopPath() );
-                }
-                catch ( final Exception e ) {
-                    _current_dir = null;
-                }
-            }
-        }
-        if ( ( _current_dir == null ) || !_current_dir.canRead() ) {
-            if ( System.getProperty( "user.home" ) != null ) {
-                _current_dir = new File( System.getProperty( "user.home" ) );
-            }
-            else if ( System.getProperty( "user.dir" ) != null ) {
-                _current_dir = new File( System.getProperty( "user.dir" ) );
-            }
-        }
-        return _current_dir;
-    }
-
-    void buildFileMenu() {
-        _file_jmenu = MainFrame.createMenu( "File", getConfiguration() );
-        _file_jmenu.add( _save_item = new JMenuItem( "Save Tree As..." ) );
-        _file_jmenu.addSeparator();
-        _file_jmenu.add( _write_to_pdf_item = new JMenuItem( "Export to PDF file ..." ) );
-        if ( AptxUtil.canWriteFormat( "tif" ) || AptxUtil.canWriteFormat( "tiff" ) || AptxUtil.canWriteFormat( "TIF" ) ) {
-            _file_jmenu.add( _write_to_tif_item = new JMenuItem( "Export to TIFF file..." ) );
-        }
-        _file_jmenu.add( _write_to_png_item = new JMenuItem( "Export to PNG file..." ) );
-        _file_jmenu.add( _write_to_jpg_item = new JMenuItem( "Export to JPG file..." ) );
-        if ( AptxUtil.canWriteFormat( "gif" ) ) {
-            _file_jmenu.add( _write_to_gif_item = new JMenuItem( "Export to GIF file..." ) );
-        }
-        if ( AptxUtil.canWriteFormat( "bmp" ) ) {
-            _file_jmenu.add( _write_to_bmp_item = new JMenuItem( "Export to BMP file..." ) );
-        }
-        _file_jmenu.addSeparator();
-        _file_jmenu.add( _print_item = new JMenuItem( "Print..." ) );
-        _file_jmenu.addSeparator();
-        _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );
-        customizeJMenuItem( _save_item );
-        customizeJMenuItem( _write_to_pdf_item );
-        customizeJMenuItem( _write_to_png_item );
-        customizeJMenuItem( _write_to_jpg_item );
-        customizeJMenuItem( _write_to_gif_item );
-        customizeJMenuItem( _write_to_tif_item );
-        customizeJMenuItem( _write_to_bmp_item );
-        customizeJMenuItem( _print_item );
-        customizeJMenuItem( _exit_item );
-        _jmenubar.add( _file_jmenu );
-    }
-
     @Override
     public void actionPerformed( final ActionEvent e ) {
         final Object o = e.getSource();
@@ -532,22 +468,20 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
             MainFrame.print( getCurrentTreePanel(), getOptions(), this );
         }
         else if ( o == _save_item ) {
-            
-            final File new_dir = MainFrame.writeToFile( _mainpanel.getCurrentPhylogeny() ,
-                                              getMainPanel(), _save_filechooser, _current_dir, getContentPane(), this );
-                           
-                                 if ( new_dir != null ) {
-                                     setCurrentDir( new_dir ); 
-                                 }
-            
-            
+            final File new_dir = MainFrame.writeToFile( _mainpanel.getCurrentPhylogeny(),
+                                                        getMainPanel(),
+                                                        _save_filechooser,
+                                                        _current_dir,
+                                                        getContentPane(),
+                                                        this );
+            if ( new_dir != null ) {
+                setCurrentDir( new_dir );
+            }
         } // TODO
-        // TODO
-        // TODO
-        // TODO
-        // TODO
-        
-        
+          // TODO
+          // TODO
+          // TODO
+          // TODO
         //        else if ( o == _graphics_export_visible_only_cbmi ) {
         //            updateOptions( getOptions() );
         //        }
@@ -669,8 +603,25 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
 
     @Override
     public void init() {
+        _writetographics_filechooser = new JFileChooser();
         _writetopdf_filechooser = new JFileChooser();
+        _save_filechooser = new JFileChooser();
+        _save_filechooser.setMultiSelectionEnabled( false );
+        _save_filechooser.setFileFilter( MainFrame.xmlfilter );
+        _save_filechooser.addChoosableFileFilter( MainFrame.nhfilter );
+        _save_filechooser.addChoosableFileFilter( MainFrame.nexusfilter );
+        _save_filechooser.addChoosableFileFilter( _save_filechooser.getAcceptAllFileFilter() );
         _writetographics_filechooser = new JFileChooser();
+        _writetographics_filechooser.addChoosableFileFilter( MainFrame.graphicsfilefilter );
+        try {
+            final String home_dir = System.getProperty( "user.home" );
+            _save_filechooser.setCurrentDirectory( new File( home_dir ) );
+            _writetopdf_filechooser.setCurrentDirectory( new File( home_dir ) );
+            _writetographics_filechooser.setCurrentDirectory( new File( home_dir ) );
+        }
+        catch ( final Exception e ) {
+            // Do nothing. Not important.
+        }
         final String config_filename = getParameter( Constants.APPLET_PARAM_NAME_FOR_CONFIG_FILE_URL );
         AptxUtil.printAppletMessage( NAME, "URL for configuration file is: " + config_filename );
         final Configuration configuration = new Configuration( config_filename, true, true, true );
@@ -695,7 +646,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
             ForesterUtil.printErrorMessage( NAME, "error: " + e );
             e.printStackTrace();
             JOptionPane.showMessageDialog( this, NAME + ": Could not create URL from: \"" + tree_url_str
-                    + "\"\nException: " + e, "Failed to create URL", JOptionPane.ERROR_MESSAGE );
+                                           + "\"\nException: " + e, "Failed to create URL", JOptionPane.ERROR_MESSAGE );
         }
         if ( phys_url == null ) {
             ForesterUtil.printErrorMessage( NAME, "failed to get tree URL from "
@@ -759,7 +710,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
             }
             catch ( final IOException e ) {
                 ForesterUtil.printErrorMessage( NAME, "could not read species tree from  [" + species_tree_url_str
-                        + "]" );
+                                                + "]" );
                 JOptionPane.showMessageDialog( this, NAME + ": could not read species tree from  ["
                         + species_tree_url_str + "]", "Failed to read species tree", JOptionPane.ERROR_MESSAGE );
             }
@@ -807,11 +758,11 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
                 public void componentResized( final ComponentEvent e ) {
                     if ( getMainPanel().getCurrentTreePanel() != null ) {
                         getMainPanel().getCurrentTreePanel().calcParametersForPainting( getMainPanel()
-                                                                                                .getCurrentTreePanel()
-                                                                                                .getWidth(),
+                                                                                        .getCurrentTreePanel()
+                                                                                        .getWidth(),
                                                                                         getMainPanel()
-                                                                                                .getCurrentTreePanel()
-                                                                                                .getHeight() );
+                                                                                        .getCurrentTreePanel()
+                                                                                        .getHeight() );
                     }
                 }
             } );
@@ -833,7 +784,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
                 AptxUtil.printAppletMessage( NAME, "not using tabbed display" );
                 if ( getSpeciesTree() != null ) {
                     AptxUtil.printAppletMessage( NAME,
-                                                 "Warning: gsdi (gene duplication inference) only available tabbed display" );
+                            "Warning: gsdi (gene duplication inference) only available tabbed display" );
                 }
                 AptxUtil.addPhylogenyToPanel( phys, getConfiguration(), getMainPanel() );
             }
@@ -882,6 +833,110 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         AptxUtil.printAppletMessage( NAME, "started" );
     }
 
+    private void chooseFont() {
+        final FontChooser fc = new FontChooser();
+        fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
+        fc.showDialog( this, "Select the Base Font" );
+        getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
+    }
+
+    private void chooseMinimalConfidence() {
+        final String s = ( String ) JOptionPane
+                .showInputDialog( this,
+                                  "Please the minimum for confidence values to be displayed.\n" + "[current value: "
+                                          + getOptions().getMinConfidenceValue() + "]\n",
+                                          "Minimal Confidence Value",
+                                          JOptionPane.QUESTION_MESSAGE,
+                                          null,
+                                          null,
+                                          getOptions().getMinConfidenceValue() );
+        if ( !ForesterUtil.isEmpty( s ) ) {
+            boolean success = true;
+            double m = 0.0;
+            final String m_str = s.trim();
+            if ( !ForesterUtil.isEmpty( m_str ) ) {
+                try {
+                    m = Double.parseDouble( m_str );
+                }
+                catch ( final Exception ex ) {
+                    success = false;
+                }
+            }
+            else {
+                success = false;
+            }
+            if ( success && ( m >= 0.0 ) ) {
+                getOptions().setMinConfidenceValue( m );
+            }
+        }
+    }
+
+    private void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
+        if ( item != null ) {
+            item.setFont( MainFrame.menu_font );
+            if ( !getConfiguration().isUseNativeUI() ) {
+                item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
+                item.setForeground( getConfiguration().getGuiMenuTextColor() );
+            }
+            item.setSelected( is_selected );
+            item.addActionListener( this );
+        }
+    }
+
+    private Phylogeny getSpeciesTree() {
+        return _species_tree;
+    }
+
+    private boolean isScreenAntialias() {
+        return true;
+    }
+
+    private void removeBranchColors() {
+        if ( getMainPanel().getCurrentPhylogeny() != null ) {
+            AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
+        }
+    }
+
+    private void removeVisualStyles() {
+        if ( getMainPanel().getCurrentPhylogeny() != null ) {
+            AptxUtil.removeVisualStyles( getMainPanel().getCurrentPhylogeny() );
+        }
+    }
+
+    private void setMainPanel( final MainPanelApplets main_panel ) {
+        _mainpanel = main_panel;
+    }
+
+    private void setSpeciesTree( final Phylogeny species_tree ) {
+        _species_tree = species_tree;
+    }
+
+    private void setupUI() {
+        try {
+            if ( getConfiguration().isUseNativeUI() ) {
+                UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
+            }
+            else {
+                UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
+            }
+        }
+        catch ( final UnsupportedLookAndFeelException e ) {
+            AptxUtil.dieWithSystemError( "UnsupportedLookAndFeelException: " + e.toString() );
+        }
+        catch ( final ClassNotFoundException e ) {
+            AptxUtil.dieWithSystemError( "ClassNotFoundException: " + e.toString() );
+        }
+        catch ( final InstantiationException e ) {
+            AptxUtil.dieWithSystemError( "InstantiationException: " + e.toString() );
+        }
+        catch ( final IllegalAccessException e ) {
+            AptxUtil.dieWithSystemError( "IllegalAccessException: " + e.toString() );
+        }
+        catch ( final Exception e ) {
+            AptxUtil.dieWithSystemError( e.toString() );
+        }
+    }
+
     void buildAnalysisMenu() {
         _analysis_menu = MainFrame.createMenu( "Analysis", getConfiguration() );
         _analysis_menu.add( _gsdi_item = new JMenuItem( "GSDI (Generalized Speciation Duplication Inference)" ) );
@@ -895,6 +950,35 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         _jmenubar.add( _analysis_menu );
     }
 
+    void buildFileMenu() {
+        _file_jmenu = MainFrame.createMenu( "File", getConfiguration() );
+        _file_jmenu.add( _save_item = new JMenuItem( "Save Tree As..." ) );
+        _file_jmenu.addSeparator();
+        _file_jmenu.add( _write_to_pdf_item = new JMenuItem( "Export to PDF file ..." ) );
+        if ( AptxUtil.canWriteFormat( "tif" ) || AptxUtil.canWriteFormat( "tiff" ) || AptxUtil.canWriteFormat( "TIF" ) ) {
+            _file_jmenu.add( _write_to_tif_item = new JMenuItem( "Export to TIFF file..." ) );
+        }
+        _file_jmenu.add( _write_to_png_item = new JMenuItem( "Export to PNG file..." ) );
+        _file_jmenu.add( _write_to_jpg_item = new JMenuItem( "Export to JPG file..." ) );
+        if ( AptxUtil.canWriteFormat( "gif" ) ) {
+            _file_jmenu.add( _write_to_gif_item = new JMenuItem( "Export to GIF file..." ) );
+        }
+        if ( AptxUtil.canWriteFormat( "bmp" ) ) {
+            _file_jmenu.add( _write_to_bmp_item = new JMenuItem( "Export to BMP file..." ) );
+        }
+        _file_jmenu.addSeparator();
+        _file_jmenu.add( _print_item = new JMenuItem( "Print..." ) );
+        customizeJMenuItem( _save_item );
+        customizeJMenuItem( _write_to_pdf_item );
+        customizeJMenuItem( _write_to_png_item );
+        customizeJMenuItem( _write_to_jpg_item );
+        customizeJMenuItem( _write_to_gif_item );
+        customizeJMenuItem( _write_to_tif_item );
+        customizeJMenuItem( _write_to_bmp_item );
+        customizeJMenuItem( _print_item );
+        _jmenubar.add( _file_jmenu );
+    }
+
     void buildFontSizeMenu() {
         _font_size_menu = MainFrame.createMenu( MainFrame.FONT_SIZE_MENU_LABEL, getConfiguration() );
         _font_size_menu.add( _super_tiny_fonts_mi = new JMenuItem( "Super tiny fonts" ) );
@@ -940,9 +1024,9 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
                 MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getOptions() );
                 MainFrame.setTextColorChooseMenuItem( _switch_colors_mi, getCurrentTreePanel() );
                 MainFrame
-                        .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() );
+                .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() );
                 MainFrame.setTextForFontChooserMenuItem( _choose_font_mi, MainFrame
-                        .createCurrentFontDesc( getMainPanel().getTreeFontSet() ) );
+                                                         .createCurrentFontDesc( getMainPanel().getTreeFontSet() ) );
                 MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() );
                 MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() );
                 MainFrame.setTextNodeSizeMenuItem( _choose_node_size_mi, getOptions() );
@@ -958,10 +1042,10 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.DISPLAY_SUBHEADER ),
                                                                 getConfiguration() ) );
         _options_jmenu
-                .add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );
+        .add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );
         _options_jmenu.add( _uniform_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.UNIFORM_CLADOGRAMS_LABEL ) );
         _options_jmenu
-                .add( _non_lined_up_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.NON_LINED_UP_CLADOGRAMS_LABEL ) );
+        .add( _non_lined_up_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.NON_LINED_UP_CLADOGRAMS_LABEL ) );
         _radio_group_1 = new ButtonGroup();
         _radio_group_1.add( _ext_node_dependent_cladogram_rbmi );
         _radio_group_1.add( _uniform_cladograms_rbmi );
@@ -969,11 +1053,11 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         _options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_OVERVIEW_LABEL ) );
         _options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_SCALE_LABEL ) );
         _options_jmenu
-                .add( _show_default_node_shapes_internal_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_INT ) );
+        .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 ) );
+        .add( _show_default_node_shapes_external_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_EXT ) );
         _options_jmenu
-                .add( _show_default_node_shapes_for_marked_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_MARKED ) );
+        .add( _show_default_node_shapes_for_marked_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_MARKED ) );
         _options_jmenu.add( _line_up_renderable_data_cbmi = new JCheckBoxMenuItem( MainFrame.LINE_UP_RENDERABLE_DATA ) );
         if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
             _options_jmenu.add( _right_line_up_domains_cbmi = new JCheckBoxMenuItem( MainFrame.RIGHT_LINE_UP_DOMAINS ) );
@@ -982,9 +1066,9 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         _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
-                .add( _color_by_taxonomic_group_cbmi = new JCheckBoxMenuItem( MainFrame.COLOR_BY_TAXONOMIC_GROUP ) );
+        .add( _color_by_taxonomic_group_cbmi = new JCheckBoxMenuItem( MainFrame.COLOR_BY_TAXONOMIC_GROUP ) );
         _options_jmenu
-                .add( _color_labels_same_as_parent_branch = new JCheckBoxMenuItem( MainFrame.COLOR_LABELS_LABEL ) );
+        .add( _color_labels_same_as_parent_branch = new JCheckBoxMenuItem( MainFrame.COLOR_LABELS_LABEL ) );
         _color_labels_same_as_parent_branch.setToolTipText( MainFrame.COLOR_LABELS_TIP );
         _options_jmenu.add( _abbreviate_scientific_names = new JCheckBoxMenuItem( MainFrame.ABBREV_SN_LABEL ) );
         _options_jmenu.add( _label_direction_cbmi = new JCheckBoxMenuItem( MainFrame.LABEL_DIRECTION_LABEL ) );
@@ -1002,12 +1086,12 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.SEARCH_SUBHEADER ),
                                                                 getConfiguration() ) );
         _options_jmenu
-                .add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_CASE_SENSITIVE_LABEL ) );
+        .add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_CASE_SENSITIVE_LABEL ) );
         _options_jmenu.add( _search_whole_words_only_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_TERMS_ONLY_LABEL ) );
         _options_jmenu.add( _search_with_regex_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_REGEX_LABEL ) );
         _search_with_regex_cbmi.setToolTipText( MainFrame.SEARCH_WITH_REGEX_TIP );
         _options_jmenu
-                .add( _inverse_search_result_cbmi = new JCheckBoxMenuItem( MainFrame.INVERSE_SEARCH_RESULT_LABEL ) );
+        .add( _inverse_search_result_cbmi = new JCheckBoxMenuItem( MainFrame.INVERSE_SEARCH_RESULT_LABEL ) );
         customizeJMenuItem( _choose_font_mi );
         customizeJMenuItem( _choose_minimal_confidence_mi );
         customizeJMenuItem( _switch_colors_mi );
@@ -1021,11 +1105,11 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         customizeCheckBoxMenuItem( _show_annotation_ref_source, getOptions().isShowAnnotationRefSource() );
         customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );
         customizeCheckBoxMenuItem( _show_default_node_shapes_external_cbmi, getOptions()
-                .isShowDefaultNodeShapesExternal() );
+                                   .isShowDefaultNodeShapesExternal() );
         customizeCheckBoxMenuItem( _show_default_node_shapes_internal_cbmi, getOptions()
-                .isShowDefaultNodeShapesInternal() );
+                                   .isShowDefaultNodeShapesInternal() );
         customizeCheckBoxMenuItem( _show_default_node_shapes_for_marked_cbmi, getOptions()
-                .isShowDefaultNodeShapesForMarkedNodes() );
+                                   .isShowDefaultNodeShapesForMarkedNodes() );
         customizeJMenuItem( _cycle_node_shape_mi );
         customizeJMenuItem( _cycle_node_fill_mi );
         customizeJMenuItem( _choose_node_size_mi );
@@ -1057,7 +1141,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         _tools_menu.addSeparator();
         _tools_menu.add( _remove_visual_styles_item = new JMenuItem( "Delete All Visual Styles From Nodes" ) );
         _remove_visual_styles_item
-                .setToolTipText( "To remove all node visual styles (fonts, colors) from the current phylogeny." );
+        .setToolTipText( "To remove all node visual styles (fonts, colors) from the current phylogeny." );
         customizeJMenuItem( _remove_visual_styles_item );
         _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete All Colors From Branches" ) );
         _remove_branch_color_item.setToolTipText( "To remove all branch color values from the current phylogeny." );
@@ -1098,7 +1182,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
     void buildViewMenu() {
         _view_jmenu = MainFrame.createMenu( "View", getConfiguration() );
         _view_jmenu
-                .add( _display_basic_information_item = new JMenuItem( MainFrame.SHOW_BASIC_TREE_INFORMATION_LABEL ) );
+        .add( _display_basic_information_item = new JMenuItem( MainFrame.SHOW_BASIC_TREE_INFORMATION_LABEL ) );
         _view_jmenu.addSeparator();
         _view_jmenu.add( _view_as_XML_item = new JMenuItem( "as phyloXML" ) );
         _view_jmenu.add( _view_as_NH_item = new JMenuItem( "as Newick" ) );
@@ -1217,8 +1301,8 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
                                                    + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
                                                    + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
                                                    + "Number of polytomies in species tree used: " + poly + "\n",
-                                           "GSDI successfully completed",
-                                           JOptionPane.WARNING_MESSAGE );
+                                                   "GSDI successfully completed",
+                                                   JOptionPane.WARNING_MESSAGE );
         }
         else {
             JOptionPane.showMessageDialog( this,
@@ -1230,8 +1314,8 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
                                                    + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
                                                    + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
                                                    + "Number of polytomies in species tree used: " + poly + "\n",
-                                           "GSDI successfully completed",
-                                           JOptionPane.INFORMATION_MESSAGE );
+                                                   "GSDI successfully completed",
+                                                   JOptionPane.INFORMATION_MESSAGE );
         }
     }
 
@@ -1290,8 +1374,8 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
                                                    + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
                                                    + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
                                                    + "Number of polytomies in species tree used: " + poly + "\n",
-                                           "GSDIR successfully completed",
-                                           JOptionPane.WARNING_MESSAGE );
+                                                   "GSDIR successfully completed",
+                                                   JOptionPane.WARNING_MESSAGE );
         }
         else {
             JOptionPane.showMessageDialog( this,
@@ -1301,8 +1385,8 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
                                                    + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
                                                    + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
                                                    + "Number of polytomies in species tree used: " + poly + "\n",
-                                           "GSDIR successfully completed",
-                                           JOptionPane.INFORMATION_MESSAGE );
+                                                   "GSDIR successfully completed",
+                                                   JOptionPane.INFORMATION_MESSAGE );
         }
     }
 
@@ -1310,6 +1394,28 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         return _configuration;
     }
 
+    File getCurrentDir() {
+        if ( ( _current_dir == null ) || !_current_dir.canRead() ) {
+            if ( ForesterUtil.isWindows() ) {
+                try {
+                    _current_dir = new File( WindowsUtils.getCurrentUserDesktopPath() );
+                }
+                catch ( final Exception e ) {
+                    _current_dir = null;
+                }
+            }
+        }
+        if ( ( _current_dir == null ) || !_current_dir.canRead() ) {
+            if ( System.getProperty( "user.home" ) != null ) {
+                _current_dir = new File( System.getProperty( "user.home" ) );
+            }
+            else if ( System.getProperty( "user.dir" ) != null ) {
+                _current_dir = new File( System.getProperty( "user.dir" ) );
+            }
+        }
+        return _current_dir;
+    }
+
     TreePanel getCurrentTreePanel() {
         return getMainPanel().getCurrentTreePanel();
     }
@@ -1318,6 +1424,10 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         return _label_direction_cbmi;
     }
 
+    MainPanel getMainPanel() {
+        return _mainpanel;
+    }
+
     Options getOtions() {
         return _options;
     }
@@ -1391,10 +1501,10 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         if ( getCurrentTreePanel() != null ) {
             if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
                 JOptionPane
-                        .showMessageDialog( this,
-                                            "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 );
+                .showMessageDialog( this,
+                                    "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 );
                 return true;
             }
         }
@@ -1414,6 +1524,10 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         _configuration = configuration;
     }
 
+    void setCurrentDir( final File current_dir ) {
+        _current_dir = current_dir;
+    }
+
     void setOptions( final Options options ) {
         _options = options;
     }
@@ -1519,20 +1633,20 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
     void updateOptions( final Options options ) {
         options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
         options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
-                && _background_gradient_cbmi.isSelected() );
+                                            && _background_gradient_cbmi.isSelected() );
         options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
         options.setShowAnnotationRefSource( ( _show_annotation_ref_source != null )
-                && _show_annotation_ref_source.isSelected() );
+                                            && _show_annotation_ref_source.isSelected() );
         options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
-                && _abbreviate_scientific_names.isSelected() );
+                                                   && _abbreviate_scientific_names.isSelected() );
         options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
-                && _color_labels_same_as_parent_branch.isSelected() );
+                                                  && _color_labels_same_as_parent_branch.isSelected() );
         options.setShowDefaultNodeShapesInternal( ( _show_default_node_shapes_internal_cbmi != null )
-                && _show_default_node_shapes_internal_cbmi.isSelected() );
+                                                  && _show_default_node_shapes_internal_cbmi.isSelected() );
         options.setShowDefaultNodeShapesExternal( ( _show_default_node_shapes_external_cbmi != null )
-                && _show_default_node_shapes_external_cbmi.isSelected() );
+                                                  && _show_default_node_shapes_external_cbmi.isSelected() );
         options.setShowDefaultNodeShapesForMarkedNodes( ( _show_default_node_shapes_for_marked_cbmi != null )
-                && _show_default_node_shapes_for_marked_cbmi.isSelected() );
+                                                        && _show_default_node_shapes_for_marked_cbmi.isSelected() );
         if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
             options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
         }
@@ -1543,7 +1657,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
             options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
         }
         options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
-                && _search_case_senstive_cbmi.isSelected() );
+                                        && _search_case_senstive_cbmi.isSelected() );
         if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
             options.setShowScale( _show_scale_cbmi.isSelected() );
         }
@@ -1557,12 +1671,12 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         }
         options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
         options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )
-                && _show_confidence_stddev_cbmi.isSelected() );
+                                         && _show_confidence_stddev_cbmi.isSelected() );
         options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
-                && _search_whole_words_only_cbmi.isSelected() );
+                                        && _search_whole_words_only_cbmi.isSelected() );
         options.setSearchWithRegex( ( _search_with_regex_cbmi != null ) && _search_with_regex_cbmi.isSelected() );
         options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
-                && _inverse_search_result_cbmi.isSelected() );
+                                        && _inverse_search_result_cbmi.isSelected() );
         if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
             options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
         }
@@ -1610,8 +1724,8 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
                 title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;
             }
             showTextFrame( getMainPanel().getCurrentPhylogeny().toNexus( getOptions()
-                                   .getNhConversionSupportValueStyle() ),
-                           title );
+                                                                         .getNhConversionSupportValueStyle() ),
+                                                                         title );
         }
     }
 
@@ -1622,8 +1736,8 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
                 title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;
             }
             showTextFrame( getMainPanel().getCurrentPhylogeny().toNewHampshire( getOptions()
-                                   .getNhConversionSupportValueStyle() ),
-                           title );
+                                                                                .getNhConversionSupportValueStyle() ),
+                                                                                title );
         }
     }
 
@@ -1637,114 +1751,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         }
     }
 
-    private void chooseFont() {
-        final FontChooser fc = new FontChooser();
-        fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
-        fc.showDialog( this, "Select the Base Font" );
-        getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
-    }
-
-    private void chooseMinimalConfidence() {
-        final String s = ( String ) JOptionPane
-                .showInputDialog( this,
-                                  "Please the minimum for confidence values to be displayed.\n" + "[current value: "
-                                          + getOptions().getMinConfidenceValue() + "]\n",
-                                  "Minimal Confidence Value",
-                                  JOptionPane.QUESTION_MESSAGE,
-                                  null,
-                                  null,
-                                  getOptions().getMinConfidenceValue() );
-        if ( !ForesterUtil.isEmpty( s ) ) {
-            boolean success = true;
-            double m = 0.0;
-            final String m_str = s.trim();
-            if ( !ForesterUtil.isEmpty( m_str ) ) {
-                try {
-                    m = Double.parseDouble( m_str );
-                }
-                catch ( final Exception ex ) {
-                    success = false;
-                }
-            }
-            else {
-                success = false;
-            }
-            if ( success && ( m >= 0.0 ) ) {
-                getOptions().setMinConfidenceValue( m );
-            }
-        }
-    }
-
-    private void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
-        if ( item != null ) {
-            item.setFont( MainFrame.menu_font );
-            if ( !getConfiguration().isUseNativeUI() ) {
-                item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
-                item.setForeground( getConfiguration().getGuiMenuTextColor() );
-            }
-            item.setSelected( is_selected );
-            item.addActionListener( this );
-        }
-    }
-
-    MainPanel getMainPanel() {
-        return _mainpanel;
-    }
-
-    private Phylogeny getSpeciesTree() {
-        return _species_tree;
-    }
-
-    private boolean isScreenAntialias() {
-        return true;
-    }
-
-    private void removeBranchColors() {
-        if ( getMainPanel().getCurrentPhylogeny() != null ) {
-            AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
-        }
-    }
-
-    private void removeVisualStyles() {
-        if ( getMainPanel().getCurrentPhylogeny() != null ) {
-            AptxUtil.removeVisualStyles( getMainPanel().getCurrentPhylogeny() );
-        }
-    }
-
-    private void setMainPanel( final MainPanelApplets main_panel ) {
-        _mainpanel = main_panel;
-    }
-
-    private void setSpeciesTree( final Phylogeny species_tree ) {
-        _species_tree = species_tree;
-    }
-
-    private void setupUI() {
-        try {
-            if ( getConfiguration().isUseNativeUI() ) {
-                UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
-            }
-            else {
-                UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
-            }
-        }
-        catch ( final UnsupportedLookAndFeelException e ) {
-            AptxUtil.dieWithSystemError( "UnsupportedLookAndFeelException: " + e.toString() );
-        }
-        catch ( final ClassNotFoundException e ) {
-            AptxUtil.dieWithSystemError( "ClassNotFoundException: " + e.toString() );
-        }
-        catch ( final InstantiationException e ) {
-            AptxUtil.dieWithSystemError( "InstantiationException: " + e.toString() );
-        }
-        catch ( final IllegalAccessException e ) {
-            AptxUtil.dieWithSystemError( "IllegalAccessException: " + e.toString() );
-        }
-        catch ( final Exception e ) {
-            AptxUtil.dieWithSystemError( e.toString() );
-        }
-    }
-
     static void setupScreenTextAntialias( final List<TreePanel> treepanels, final boolean antialias ) {
         for( final TreePanel tree_panel : treepanels ) {
             tree_panel.setTextAntialias();
index 027b316..9eafb0d 100644 (file)
@@ -49,16 +49,16 @@ import javax.swing.event.ListDataListener;
 
 final class ColorSchemeChooser extends JDialog implements ActionListener {
 
-    private static final long  serialVersionUID = 6150960100859081126L;
-    private final TreeColorSet _colorset;
-    private final JComboBox<String>    _selector;
-    private final JPanel       _color_panel;
-    private final JPanel       _color_labels[];
-    private final JButton      _ok_btn;
-    private final JButton      _cancel_btn;
-    private final MainPanel    _main_panel;
-    private final int          _prev_selected_scheme;
-    private int                _selected_scheme;
+    private static final long       serialVersionUID = 6150960100859081126L;
+    private final TreeColorSet      _colorset;
+    private final JComboBox<String> _selector;
+    private final JPanel            _color_panel;
+    private final JPanel            _color_labels[];
+    private final JButton           _ok_btn;
+    private final JButton           _cancel_btn;
+    private final MainPanel         _main_panel;
+    private final int               _prev_selected_scheme;
+    private int                     _selected_scheme;
 
     ColorSchemeChooser( final MainPanel parent, final TreeColorSet colorset ) {
         setName( "Color Scheme Chooser" );
index 350bd0d..8ec94ab 100644 (file)
@@ -59,40 +59,40 @@ public final class Configuration {
         BUFFER_ONLY, CONSOLE, WINODW;
     }
 
-    static enum TRIPLET {
-        FALSE, TRUE, UNKNOWN
-    }
-
     public enum UI {
         CROSSPLATFORM, NATIVE, NIMBUS, UNKNOWN
     }
+
+    static enum TRIPLET {
+        FALSE, TRUE, UNKNOWN
+    }
     final static String                     clickto_options[][]                                    = {
-        { "Display Node Data", "display" }, { "Collapse/Uncollapse", "display" }, { "Root/Reroot", "display" },
-        { "Go to Sub-/Super-Tree", "display" }, { "Swap Descendants", "display" },
-        { "Colorize Node(s)", "display" }, { "Change Node Font(s)", "display" },
-        { "Colorize Subtree(s)", "display" }, { "Open Sequence DB", "display" }, { "Open PDB", "display" },
-        { "Open Taxonomy DB", "display" }, { "Launch BLAST", "display" }, { "Cut Subtree", "display" },
-        { "Copy Subtree", "display" }, { "Paste Subtree", "display" }, { "Delete Subtree/Node", "display" },
-        { "Add New Node", "display" }, { "Edit Node Data", "display" }, { "Sort Descendants", "display" },
-        { "List Node Data", "display" }, { "Select Node(s)", "display" }                      };
+            { "Display Node Data", "display" }, { "Collapse/Uncollapse", "display" }, { "Root/Reroot", "display" },
+            { "Go to Sub-/Super-Tree", "display" }, { "Swap Descendants", "display" },
+            { "Colorize Node(s)", "display" }, { "Change Node Font(s)", "display" },
+            { "Colorize Subtree(s)", "display" }, { "Open Sequence DB", "display" }, { "Open PDB", "display" },
+            { "Open Taxonomy DB", "display" }, { "Launch BLAST", "display" }, { "Cut Subtree", "display" },
+            { "Copy Subtree", "display" }, { "Paste Subtree", "display" }, { "Delete Subtree/Node", "display" },
+            { "Add New Node", "display" }, { "Edit Node Data", "display" }, { "Sort Descendants", "display" },
+            { "List Node Data", "display" }, { "Select Node(s)", "display" }                      };
     private final static String             DEFAULT_SPECIES_COLORS[][]                             = {
-        { "BRAFL", "0x00FFFF" }, { "SPHGR", "0x9620F0" }, { "STRPU", "0x9620F0" }, { "CIOIN", "0xFF1CAE" },
-        { "CIOSA", "0xFF2CAE" }, { "BOVIN", "0x5C3317" }, { "CANFA", "0x8B2323" }, { "HUMAN", "0xFF2400" },
-        { "PANTR", "0xCC2400" }, { "MOUSE", "0xFF7F00" }, { "RAT", "0xFFEF00" }, { "MONDO", "0xEE9A49" },
-        { "ORNAN", "0xCD853F" }, { "XENLA", "0x6BAA23" }, { "XENTR", "0x6BAA23" }, { "CHICK", "0xFFC125" },
-        { "FUGRU", "0x0000FF" }, { "BRARE", "0x0000DD" }, { "DANRE", "0x0000BB" }, { "TETNG", "0x0000AA" },
-        { "ORYLA", "0x000088" }, { "GASAC", "0x000066" }, { "CAEEL", "0x666699" }, { "CAEBR", "0xB0B0B0" },
-        { "DROME", "0x663366" }, { "DROPS", "0x996699" }, { "APIME", "0x7A7700" }, { "AEDAE", "0x8C5900" },
-        { "TRICA", "0x918E00" }, { "NEMVE", "0x0066CC" }, { "HYDVU", "0x3399FF" }, { "LUBBA", "0xF7B5CB" },
-        { "GEOCY", "0xF5A0BD" }, { "AMPQE", "0x009966" }, { "SUBDO", "0xC790B9" }, { "MONBE", "0xFC0FC0" },
-        { "DICPU", "0xFFCC33" }, { "DICDI", "0xFFCC00" }, { "ENTHI", "0x5959AB" }, { "ARATH", "0x00FF00" },
-        { "POPTR", "0x006400" }, { "VITVI", "0x00CD00" }, { "GLYMA", "0x00FF7F" }, { "ORYSA", "0x008B00" },
-        { "ORYSJ", "0x008C00" }, { "SORBI", "0x00EE76" }, { "SELMO", "0x238E23" }, { "PHYPA", "0x09F911" },
-        { "OSTLU", "0x7FFF00" }, { "OSTTA", "0x7FFF00" }, { "OSTRC", "0x7FFF00" }, { "MICPU", "0x66CD00" },
-        { "MIC99", "0x66CD00" }, { "CHLRE", "0xB3EE3A" }, { "VOLCA", "0xC0FF3E" }, { "CHLSP", "0x6B8E23" },
-        { "CYAME", "0xD02090" }, { "YEAST", "0xAAAAAA" }, { "BACFR", "0xFF0000" }, { "BACTN", "0xFFFF00" },
-        { "MYXXD", "0x0000FF" }, { "STIAU", "0x00FFFF" }, { "BACOV", "0x8C5900" }, { "BACUN", "0x66CD00" },
-        { "PORGI", "0x918E00" }                                                               };
+            { "BRAFL", "0x00FFFF" }, { "SPHGR", "0x9620F0" }, { "STRPU", "0x9620F0" }, { "CIOIN", "0xFF1CAE" },
+            { "CIOSA", "0xFF2CAE" }, { "BOVIN", "0x5C3317" }, { "CANFA", "0x8B2323" }, { "HUMAN", "0xFF2400" },
+            { "PANTR", "0xCC2400" }, { "MOUSE", "0xFF7F00" }, { "RAT", "0xFFEF00" }, { "MONDO", "0xEE9A49" },
+            { "ORNAN", "0xCD853F" }, { "XENLA", "0x6BAA23" }, { "XENTR", "0x6BAA23" }, { "CHICK", "0xFFC125" },
+            { "FUGRU", "0x0000FF" }, { "BRARE", "0x0000DD" }, { "DANRE", "0x0000BB" }, { "TETNG", "0x0000AA" },
+            { "ORYLA", "0x000088" }, { "GASAC", "0x000066" }, { "CAEEL", "0x666699" }, { "CAEBR", "0xB0B0B0" },
+            { "DROME", "0x663366" }, { "DROPS", "0x996699" }, { "APIME", "0x7A7700" }, { "AEDAE", "0x8C5900" },
+            { "TRICA", "0x918E00" }, { "NEMVE", "0x0066CC" }, { "HYDVU", "0x3399FF" }, { "LUBBA", "0xF7B5CB" },
+            { "GEOCY", "0xF5A0BD" }, { "AMPQE", "0x009966" }, { "SUBDO", "0xC790B9" }, { "MONBE", "0xFC0FC0" },
+            { "DICPU", "0xFFCC33" }, { "DICDI", "0xFFCC00" }, { "ENTHI", "0x5959AB" }, { "ARATH", "0x00FF00" },
+            { "POPTR", "0x006400" }, { "VITVI", "0x00CD00" }, { "GLYMA", "0x00FF7F" }, { "ORYSA", "0x008B00" },
+            { "ORYSJ", "0x008C00" }, { "SORBI", "0x00EE76" }, { "SELMO", "0x238E23" }, { "PHYPA", "0x09F911" },
+            { "OSTLU", "0x7FFF00" }, { "OSTTA", "0x7FFF00" }, { "OSTRC", "0x7FFF00" }, { "MICPU", "0x66CD00" },
+            { "MIC99", "0x66CD00" }, { "CHLRE", "0xB3EE3A" }, { "VOLCA", "0xC0FF3E" }, { "CHLSP", "0x6B8E23" },
+            { "CYAME", "0xD02090" }, { "YEAST", "0xAAAAAA" }, { "BACFR", "0xFF0000" }, { "BACTN", "0xFFFF00" },
+            { "MYXXD", "0x0000FF" }, { "STIAU", "0x00FFFF" }, { "BACOV", "0x8C5900" }, { "BACUN", "0x66CD00" },
+            { "PORGI", "0x918E00" }                                                               };
     final static int                        display_node_data                                      = 0;
     final static int                        collapse_uncollapse                                    = 1;
     final static int                        reroot                                                 = 2;
@@ -118,20 +118,20 @@ public final class Configuration {
     // Click-to options
     // ------------------
     final static String                     display_options[][]                                    = {
-        { "Phylogram", "display", "?" }, { "Node Name", "display", "yes" }, { "Taxonomy Code", "display", "yes" },
-        { "Seq Annotations", "display", "no" }, { "Confidence Values", "display", "?" },
-        { "Node Events", "display", "?" }, { "Colorize by Taxonomy", "display", "no" },
-        { "Colorize by Sequence", "display", "no" }, { "Visual Styles/Branch Colors", "display", "no" },
-        { "Branch Widths", "display", "no" }, { "Domain Architectures", "display", "no" },
-        { "Binary Characters", "nodisplay", "no" }, { "Binary Char Counts", "nodisplay", "no" },
-        { "Seq Name", "display", "yes" }, { "Seq Accession", "display", "no" },
-        { "Show Internal Data", "display", "yes" }, { "Dyna Hide", "display", "yes" },
-        { "Taxonomy Scientific", "display", "yes" }, { "Taxonomy Common", "display", "no" },
-        { "Colorize by Annotation", "display", "no" }, { "Seq Symbol", "display", "yes" },
-        { "Rollover", "display", "yes" }, { "Relation Confidence", "nodisplay", "no" },
-        { "Vector Data", "nodisplay", "no" }, { "Taxonomy Images", "display", "no" },
-        { "Properties", "display", "no" }, { "Gene Name", "display", "yes" },
-        { "Multiple Seq Alignment", "display", "no" }, { "Branch Length Values", "display", "no" } };
+            { "Phylogram", "display", "?" }, { "Node Name", "display", "yes" }, { "Taxonomy Code", "display", "yes" },
+            { "Seq Annotations", "display", "no" }, { "Confidence Values", "display", "?" },
+            { "Node Events", "display", "?" }, { "Colorize by Taxonomy", "display", "no" },
+            { "Colorize by Sequence", "display", "no" }, { "Visual Styles/Branch Colors", "display", "no" },
+            { "Branch Widths", "display", "no" }, { "Domain Architectures", "display", "no" },
+            { "Binary Characters", "nodisplay", "no" }, { "Binary Char Counts", "nodisplay", "no" },
+            { "Seq Name", "display", "yes" }, { "Seq Accession", "display", "no" },
+            { "Show Internal Data", "display", "yes" }, { "Dyna Hide", "display", "yes" },
+            { "Taxonomy Scientific", "display", "yes" }, { "Taxonomy Common", "display", "no" },
+            { "Colorize by Annotation", "display", "no" }, { "Seq Symbol", "display", "yes" },
+            { "Rollover", "display", "yes" }, { "Relation Confidence", "nodisplay", "no" },
+            { "Vector Data", "nodisplay", "no" }, { "Taxonomy Images", "display", "no" },
+            { "Properties", "display", "no" }, { "Gene Name", "display", "yes" },
+            { "Multiple Seq Alignment", "display", "no" }, { "Branch Length Values", "display", "no" } };
     final static int                        display_as_phylogram                                   = 0;
     final static int                        show_node_names                                        = 1;
     final static int                        show_tax_code                                          = 2;
@@ -267,10 +267,6 @@ public final class Configuration {
         }
     }
 
-    static String getDefaultFontFamilyName() {
-        return DEFAULT_FONT_FAMILY;
-    }
-
     public Configuration() {
         this( null, false, false, false );
     }
@@ -335,158 +331,14 @@ public final class Configuration {
         }
     }
 
-    boolean displaySequenceRelations() {
-        return _display_sequence_relations;
-    }
-
-    boolean doCheckOption( final int which ) {
-        return ( display_options[ which ][ 2 ].equalsIgnoreCase( "yes" ) )
-                || ( display_options[ which ][ 2 ].equalsIgnoreCase( "true" ) );
-    }
-
-    boolean doDisplayClickToOption( final int which ) {
-        return clickto_options[ which ][ 1 ].equalsIgnoreCase( "display" );
-    }
-
-    boolean doDisplayOption( final int which ) {
-        return display_options[ which ][ 1 ].equalsIgnoreCase( "display" );
-    }
-
-    /**
-     * Will attempt to use the phylogeny to determine whether to check
-     * this or not (e.g. phylogram)
-     *
-     */
-    boolean doGuessCheckOption( final int which ) {
-        return display_options[ which ][ 2 ].equals( "?" );
-    }
-
-    Map<String, Color> getAnnotationColors() {
-        if ( _annotation_colors == null ) {
-            _annotation_colors = new Hashtable<String, Color>();
-        }
-        return _annotation_colors;
-    }
-
     public String getBaseFontFamilyName() {
         return _base_font_family_name;
     }
 
-    int getBaseFontSize() {
-        return _base_font_size;
-    }
-
-    CLADOGRAM_TYPE getCladogramType() {
-        return _cladogram_type;
-    }
-
-    private int getClickToIndex( final String name ) {
-        int index = -1;
-        if ( name.equals( "edit_info" ) ) {
-            index = Configuration.display_node_data;
-            ForesterUtil
-            .printWarningMessage( Constants.PRG_NAME,
-                                  "configuration key [edit_info] is deprecated, use [display node data] instead" );
-        }
-        else if ( name.equals( "display_node_data" ) ) {
-            index = Configuration.display_node_data;
-        }
-        else if ( name.equals( "collapse_uncollapse" ) ) {
-            index = Configuration.collapse_uncollapse;
-        }
-        else if ( name.equals( "reroot" ) ) {
-            index = Configuration.reroot;
-        }
-        else if ( name.equals( "subtree" ) ) {
-            index = Configuration.subtree;
-        }
-        else if ( name.equals( "swap" ) ) {
-            index = Configuration.swap;
-        }
-        else if ( name.equals( "sort_descendants" ) ) {
-            index = Configuration.sort_descendents;
-        }
-        else if ( name.equals( "get_ext_descendents_data" ) ) {
-            index = Configuration.get_ext_desc_data;
-        }
-        else if ( name.equals( "display_sequences" ) ) {
-            ForesterUtil
-            .printWarningMessage( Constants.PRG_NAME, "configuration key [display_sequences] is deprecated" );
-            return DEPRECATED;
-        }
-        else if ( name.equals( "open_seq_web" ) ) {
-            index = Configuration.open_seq_web;
-        }
-        else if ( name.equals( "open_pdb_web" ) ) {
-            index = Configuration.open_pdb_web;
-        }
-        else if ( name.equals( "open_tax_web" ) ) {
-            index = Configuration.open_tax_web;
-        }
-        else if ( name.equals( "blast" ) ) {
-            index = Configuration.blast;
-        }
-        else if ( name.equals( "cut_subtree" ) ) {
-            index = Configuration.cut_subtree;
-        }
-        else if ( name.equals( "copy_subtree" ) ) {
-            index = Configuration.copy_subtree;
-        }
-        else if ( name.equals( "paste_subtree" ) ) {
-            index = Configuration.paste_subtree;
-        }
-        else if ( name.equals( "delete" ) ) {
-            index = Configuration.delete_subtree_or_node;
-        }
-        else if ( name.equals( "add_new_node" ) ) {
-            index = Configuration.add_new_node;
-        }
-        else if ( name.equals( "edit_node_data" ) ) {
-            index = Configuration.edit_node_data;
-        }
-        else if ( name.equals( "select_nodes" ) ) {
-            index = Configuration.select_nodes;
-        }
-        else if ( name.equals( "display_node_popup" ) ) {
-            ForesterUtil.printWarningMessage( Constants.PRG_NAME,
-                    "configuration key [display_node_popup] is deprecated" );
-            return DEPRECATED;
-        }
-        else if ( name.equals( "custom_option" ) ) {
-            ForesterUtil.printWarningMessage( Constants.PRG_NAME, "configuration key [custom_option] is deprecated" );
-            return DEPRECATED;
-        }
-        else if ( name.equals( "color_subtree" ) ) {
-            index = Configuration.color_subtree;
-        }
-        else if ( name.equals( "change_node_font" ) ) {
-            index = Configuration.change_node_font;
-        }
-        else if ( name.equals( "color_node_font" ) ) {
-            index = Configuration.color_node_font;
-        }
-        else if ( name.equals( "color_subtree" ) ) {
-            index = Configuration.color_subtree;
-        }
-        return index;
-    }
-
-    int getClickToOptionsCount() {
-        return clickto_options.length;
-    }
-
-    String getClickToTitle( final int which ) {
-        return clickto_options[ which ][ 0 ];
-    }
-
     public int getDefaultBootstrapSamples() {
         return _default_bootstrap_samples;
     }
 
-    int getDefaultDisplayClicktoOption() {
-        return default_clickto;
-    }
-
     public NodeFill getDefaultNodeFill() {
         return _default_node_fill;
     }
@@ -499,21 +351,6 @@ public final class Configuration {
         return _default_node_shape_size;
     }
 
-    SortedMap<String, Color> getDisplayColors() {
-        return _display_colors;
-    }
-
-    String getDisplayTitle( final int which ) {
-        return display_options[ which ][ 0 ];
-    }
-
-    Map<String, Color> getDomainColors() {
-        if ( _domain_colors == null ) {
-            _domain_colors = new Hashtable<String, Color>();
-        }
-        return _domain_colors;
-    }
-
     public NodeDataField getExtDescNodeDataToReturn() {
         return _ext_desc_data_to_return;
     }
@@ -530,495 +367,492 @@ public final class Configuration {
         return _frame_y_size;
     }
 
-    int getGraphicsExportX() {
-        return _graphics_export_x;
+    public String getLabelForGetExtDescendentsData() {
+        return _label_for_get_ext_descendents_data;
     }
 
-    int getGraphicsExportY() {
-        return _graphics_export_y;
+    public File getPathToLocalFastme() {
+        return _path_to_local_fastme;
     }
 
-    Color getGuiBackgroundColor() {
-        return _gui_background_color;
+    public File getPathToLocalMafft() {
+        return _path_to_local_mafft;
     }
 
-    Color getGuiButtonBackgroundColor() {
-        return _gui_button_background_color;
+    public File getPathToLocalRaxml() {
+        return _path_to_local_raxml;
     }
 
-    Color getGuiButtonBorderColor() {
-        return _gui_button_border_color;
+    public double getVectorDataHeight() {
+        return _vector_data_height;
     }
 
-    Color getGuiButtonTextColor() {
-        return _gui_button_text_color;
+    public Color getVectorDataMaxColor() {
+        return _vector_data_max_color;
     }
 
-    Color getGuiCheckboxAndButtonActiveColor() {
-        return _gui_checkbox_and_button_active_color;
+    public Color getVectorDataMeanColor() {
+        return _vector_data_mean_color;
     }
 
-    Color getGuiCheckboxTextColor() {
-        return _gui_checkbox_text_color;
+    public Color getVectorDataMinColor() {
+        return _vector_data_min_color;
     }
 
-    Color getGuiMenuBackgroundColor() {
-        return _gui_menu_background_color;
+    public int getVectorDataWidth() {
+        return _vector_data_width;
     }
 
-    Color getGuiMenuTextColor() {
-        return _gui_menu_text_color;
+    public boolean isAbbreviateScientificTaxonNames() {
+        return _abbreviate_scientific_names;
     }
 
-    public String getLabelForGetExtDescendentsData() {
-        return _label_for_get_ext_descendents_data;
+    public boolean isAllowThickStrokes() {
+        return _allow_thick_strokes;
     }
 
-    int getMaxBaseFontSize() {
-        return _max_base_font_size;
+    public boolean isBackgroundColorGradient() {
+        return _background_color_gradient;
     }
 
-    int getMinBaseFontSize() {
-        return _min_base_font_size;
+    public boolean isColorByTaxonomicGroup() {
+        return false;
     }
 
-    double getMinConfidenceValue() {
-        return _min_confidence_value;
+    public boolean isColorLabelsSameAsParentBranch() {
+        return _color_labels_same_as_parent_branch;
     }
 
-    NODE_LABEL_DIRECTION getNodeLabelDirection() {
-        return _node_label_direction;
+    final public boolean isLineUpRendarableNodeData() {
+        return _line_up_renderable_node_data;
     }
 
-    short getNumberOfDigitsAfterCommaForBranchLengthValues() {
-        return _number_of_digits_after_comma_for_branch_length_values;
+    public boolean isMidpointReroot() {
+        return _midpoint_root;
     }
 
-    short getNumberOfDigitsAfterCommaForConfidenceValues() {
-        return _number_of_digits_after_comma_for_confidence_values;
+    final public boolean isRightLineUpDomains() {
+        return _right_align_domains;
     }
 
-    short getOvMaxHeight() {
-        return _ov_max_height;
+    public boolean isShowAnnotationRefSource() {
+        return _show_annotation_ref_source;
     }
 
-    short getOvMaxWidth() {
-        return _ov_max_width;
+    public boolean isShowDefaultNodeShapesExternal() {
+        return _show_default_node_shapes_external;
     }
 
-    OVERVIEW_PLACEMENT_TYPE getOvPlacement() {
-        return _ov_placement;
+    public boolean isShowDefaultNodeShapesForMarkedNodes() {
+        return _show_default_node_shapes_for_marked_nodes;
     }
 
-    public File getPathToLocalFastme() {
-        return _path_to_local_fastme;
+    public boolean isShowDefaultNodeShapesInternal() {
+        return _show_default_node_shapes_internal;
     }
 
-    public File getPathToLocalMafft() {
-        return _path_to_local_mafft;
+    public boolean isShowDomainLabels() {
+        return _show_domain_labels;
     }
 
-    public File getPathToLocalRaxml() {
-        return _path_to_local_raxml;
+    public void putDisplayColors( final String key, final Color color ) {
+        getDisplayColors().put( key, color );
     }
 
-    PHYLOGENY_GRAPHICS_TYPE getPhylogenyGraphicsType() {
-        return _phylogeny_graphics_type;
+    public void setAbbreviateScientificTaxonNames( final boolean abbreviate_scientific_names ) {
+        _abbreviate_scientific_names = abbreviate_scientific_names;
     }
 
-    float getPrintLineWidth() {
-        return _print_line_width;
+    public void setAddTaxonomyImagesCB( final boolean b ) {
+        display_options[ show_taxonomy_images ][ 1 ] = b ? "yes" : "no";
     }
 
-    Hashtable<String, Color> getSequenceColors() {
-        if ( _sequence_colors == null ) {
-            _sequence_colors = new Hashtable<String, Color>();
-        }
-        return _sequence_colors;
+    public void setBackgroundColorGradient( final boolean background_color_gradient ) {
+        _background_color_gradient = background_color_gradient;
     }
 
-    Hashtable<String, Color> getSpeciesColors() {
-        if ( _species_colors == null ) {
-            initSpeciesColors();
-        }
-        return _species_colors;
+    public void setBaseFontFamilyName( final String base_font_family_name ) {
+        _base_font_family_name = base_font_family_name;
     }
 
-    final TAXONOMY_EXTRACTION getTaxonomyExtraction() {
-        return _taxonomy_extraction;
+    public void setBaseFontSize( final int base_font_size ) {
+        _base_font_size = base_font_size;
     }
 
-    public double getVectorDataHeight() {
-        return _vector_data_height;
+    public void setColorizeBranches( final boolean b ) {
+        display_options[ use_style ][ 2 ] = b ? "yes" : "no";
     }
 
-    public Color getVectorDataMaxColor() {
-        return _vector_data_max_color;
+    public void setColorLabelsSameAsParentBranch( final boolean color_labels_same_as_parent_branch ) {
+        _color_labels_same_as_parent_branch = color_labels_same_as_parent_branch;
     }
 
-    public Color getVectorDataMeanColor() {
-        return _vector_data_mean_color;
+    public void setDefaultNodeFill( final NodeFill default_node_fill ) {
+        _default_node_fill = default_node_fill;
     }
 
-    public Color getVectorDataMinColor() {
-        return _vector_data_min_color;
+    public void setDefaultNodeShape( final NodeShape default_node_shape ) {
+        _default_node_shape = default_node_shape;
     }
 
-    public int getVectorDataWidth() {
-        return _vector_data_width;
+    public void setDefaultNodeShapeSize( final short default_node_shape_size ) {
+        _default_node_shape_size = default_node_shape_size;
     }
 
-    private final void initSpeciesColors() {
-        _species_colors = new Hashtable<String, Color>();
-        for( final String[] s : DEFAULT_SPECIES_COLORS ) {
-            _species_colors.put( s[ 0 ], Color.decode( s[ 1 ] ) );
-        }
+    public void setDisplayAsPhylogram( final boolean b ) {
+        display_options[ display_as_phylogram ][ 2 ] = b ? "yes" : "no";
     }
 
-    public boolean isAbbreviateScientificTaxonNames() {
-        return _abbreviate_scientific_names;
+    public void setDisplayColors( final SortedMap<String, Color> display_colors ) {
+        _display_colors = display_colors;
     }
 
-    boolean isAntialiasScreen() {
-        return _antialias_screen;
+    public void setDisplayConfidenceValues( final boolean b ) {
+        display_options[ write_confidence_values ][ 2 ] = b ? "yes" : "no";
     }
 
-    public boolean isBackgroundColorGradient() {
-        return _background_color_gradient;
+    public void setDisplayGeneNames( final boolean b ) {
+        display_options[ show_gene_names ][ 2 ] = b ? "yes" : "no";
     }
 
-    public boolean isColorByTaxonomicGroup() {
-        return false;
+    public void setDisplayInternalData( final boolean b ) {
+        display_options[ display_internal_data ][ 2 ] = b ? "yes" : "no";
     }
 
-    public boolean isColorLabelsSameAsParentBranch() {
-        return _color_labels_same_as_parent_branch;
+    public void setDisplayMultipleSequenceAlignment( final boolean b ) {
+        display_options[ show_mol_seqs ][ 2 ] = b ? "yes" : "no";
     }
 
-    /**
-     * Convenience method.
-     *
-     * @return true if value in configuration file was 'yes'
-     */
-    boolean isDrawAsPhylogram() {
-        return doCheckOption( display_as_phylogram );
+    public void setDisplayNodeNames( final boolean b ) {
+        display_options[ show_node_names ][ 2 ] = b ? "yes" : "no";
     }
 
-    boolean isEditable() {
-        return _editable;
+    public void setDisplaySequenceAcc( final boolean b ) {
+        display_options[ show_sequence_acc ][ 2 ] = b ? "yes" : "no";
     }
 
-    /**
-     * Only used by ArchaeoptryxE.
-     *
-     */
-    boolean isHideControlPanelAndMenubar() {
-        return _hide_controls_and_menus;
+    public void setDisplaySequenceNames( final boolean b ) {
+        display_options[ show_seq_names ][ 2 ] = b ? "yes" : "no";
     }
 
-    boolean isInternalNumberAreConfidenceForNhParsing() {
-        return _internal_number_are_confidence_for_nh_parsing;
+    public void setDisplaySequenceRelations( final boolean display_sequence_relations ) {
+        _display_sequence_relations = display_sequence_relations;
     }
 
-    final public boolean isLineUpRendarableNodeData() {
-        return _line_up_renderable_node_data;
+    public void setDisplaySequenceSymbols( final boolean b ) {
+        display_options[ show_seq_symbols ][ 2 ] = b ? "yes" : "no";
     }
 
-    public boolean isMidpointReroot() {
-        return _midpoint_root;
+    public void setDisplayTaxonomyCode( final boolean b ) {
+        display_options[ show_tax_code ][ 2 ] = b ? "yes" : "no";
     }
 
-    boolean isReplaceUnderscoresInNhParsing() {
-        return _nh_parsing_replace_underscores;
+    public void setDisplayTaxonomyCommonNames( final boolean b ) {
+        display_options[ show_taxonomy_common_names ][ 2 ] = b ? "yes" : "no";
     }
 
-    final public boolean isRightLineUpDomains() {
-        return _right_align_domains;
+    public void setDisplayTaxonomyImages( final boolean b ) {
+        display_options[ show_taxonomy_images ][ 2 ] = b ? "yes" : "no";
     }
 
-    public boolean isShowAnnotationRefSource() {
-        return _show_annotation_ref_source;
+    public void setDisplayTaxonomyScientificNames( final boolean b ) {
+        display_options[ show_taxonomy_scientific_names ][ 2 ] = b ? "yes" : "no";
     }
 
-    public boolean isShowDefaultNodeShapesExternal() {
-        return _show_default_node_shapes_external;
+    public void setDynamicallyHideData( final boolean b ) {
+        display_options[ dynamically_hide_data ][ 2 ] = b ? "yes" : "no";
     }
 
-    public boolean isShowDefaultNodeShapesForMarkedNodes() {
-        return _show_default_node_shapes_for_marked_nodes;
+    public void setExtDescNodeDataToReturn( final NodeDataField ext_desc_data_to_return ) {
+        _ext_desc_data_to_return = ext_desc_data_to_return;
     }
 
-    public boolean isShowDefaultNodeShapesInternal() {
-        return _show_default_node_shapes_internal;
+    public void setFrameXSize( final int frame_x_size ) {
+        _frame_x_size = frame_x_size;
     }
 
-    public boolean isShowDomainLabels() {
-        return _show_domain_labels;
+    public void setFrameYSize( final int frame_y_size ) {
+        _frame_y_size = frame_y_size;
     }
 
-    boolean isShowOverview() {
-        return _show_overview;
+    final public void setLineUpRendarableNodeData( final boolean line_up_renderable_node_data ) {
+        _line_up_renderable_node_data = line_up_renderable_node_data;
     }
 
-    boolean isShowScale() {
-        return _show_scale;
+    public void setMidpointReroot( final boolean midpoint_root ) {
+        _midpoint_root = midpoint_root;
     }
 
-    final boolean isUseNativeUI() {
-        if ( ( _ui == UI.UNKNOWN ) && ForesterUtil.isMac() ) {
-            _ui = UI.NATIVE;
-        }
-        return _ui == UI.NATIVE;
+    public void setMinConfidenceValue( final double min_confidence_value ) {
+        _min_confidence_value = min_confidence_value;
     }
 
-    /**
-     * Only used by ArchaeoptryxE.
-     *
-     */
-    boolean isUseTabbedDisplay() {
-        return _use_tabbed_display;
+    public void setNodeLabelDirection( final NODE_LABEL_DIRECTION node_label_direction ) {
+        _node_label_direction = node_label_direction;
     }
 
-    boolean isValidatePhyloXmlAgainstSchema() {
-        return _validate_against_phyloxml_xsd_schema;
+    public void setNumberOfDigitsAfterCommaForBranchLengthValue( final short number_of_digits_after_comma_for_branch_length_values ) {
+        _number_of_digits_after_comma_for_branch_length_values = number_of_digits_after_comma_for_branch_length_values;
     }
 
-    private boolean parseBoolean( final String str ) {
-        final String my_str = str.trim().toLowerCase();
-        if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
-            return true;
-        }
-        else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
-            return false;
-        }
-        else {
-            ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse boolean value from [" + str + "]" );
-            return false;
-        }
+    public void setNumberOfDigitsAfterCommaForConfidenceValues( final short number_of_digits_after_comma_for_confidence_values ) {
+        _number_of_digits_after_comma_for_confidence_values = number_of_digits_after_comma_for_confidence_values;
     }
 
-    private double parseDouble( final String str ) {
-        double d = 0.0;
-        try {
-            d = Double.parseDouble( str.trim() );
-        }
-        catch ( final Exception e ) {
-            ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse double from [" + str + "]" );
-            d = 0.0;
-        }
-        return d;
+    public void setPhylogenyGraphicsType( final PHYLOGENY_GRAPHICS_TYPE phylogeny_graphics_type ) {
+        _phylogeny_graphics_type = phylogeny_graphics_type;
     }
 
-    private float parseFloat( final String str ) {
-        float f = 0.0f;
-        try {
-            f = Float.parseFloat( str.trim() );
-        }
-        catch ( final Exception e ) {
-            ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse float from [" + str + "]" );
-            f = 0.0f;
-        }
-        return f;
+    public void setPrintLineWidth( final float print_line_width ) {
+        _print_line_width = print_line_width;
     }
 
-    private int parseInt( final String str ) {
-        int i = -1;
-        try {
-            i = Integer.parseInt( str.trim() );
-        }
-        catch ( final Exception e ) {
-            ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse integer from [" + str + "]" );
-            i = -1;
-        }
-        return i;
+    public void setReplaceUnderscoresInNhParsing( final boolean nh_parsing_replace_underscores ) {
+        _nh_parsing_replace_underscores = nh_parsing_replace_underscores;
     }
 
-    private short parseShort( final String str ) {
-        short i = -1;
-        try {
-            i = Short.parseShort( str.trim() );
-        }
-        catch ( final Exception e ) {
-            ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse short from [" + str + "]" );
-            i = -1;
-        }
-        return i;
+    final public void setRightLineUpDomains( final boolean right_align_domains ) {
+        _right_align_domains = right_align_domains;
     }
 
-    private void processFontFamily( final StringTokenizer st ) {
-        setBaseFontFamilyName( "" );
-        final String font_str = ( ( String ) st.nextElement() ).trim();
-        final String[] fonts = font_str.split( ",+" );
-        for( String font : fonts ) {
-            font = font.replace( '_', ' ' ).trim();
-            if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font ) >= 0 ) {
-                setBaseFontFamilyName( font );
-                break;
-            }
-        }
+    public void setShowDefaultNodeShapesExternal( final boolean show_default_node_shapes_external ) {
+        _show_default_node_shapes_external = show_default_node_shapes_external;
     }
 
-    public void putDisplayColors( final String key, final Color color ) {
-        getDisplayColors().put( key, color );
+    public void setShowDefaultNodeShapesForMarkedNodes( final boolean show_default_node_shapes_for_marked_nodes ) {
+        _show_default_node_shapes_for_marked_nodes = show_default_node_shapes_for_marked_nodes;
     }
 
-    /**
-     * read each line of config file, process non-comment lines
-     * @throws IOException
-     */
-    private void readConfig( final BufferedReader conf_in ) throws IOException {
-        String line;
-        do {
-            line = conf_in.readLine();
-            if ( line != null ) {
-                line = line.trim();
-                // skip comments and blank lines
-                if ( !line.startsWith( "#" ) && ( !ForesterUtil.isEmpty( line ) ) ) {
-                    // convert runs of spaces to tabs
-                    line = line.replaceAll( "\\s+", "\t" );
-                    final StringTokenizer st = new StringTokenizer( line, "\t" );
-                    setKeyValue( st );
-                }
-            }
-        } while ( line != null );
-    }
-
-    public void setAbbreviateScientificTaxonNames( final boolean abbreviate_scientific_names ) {
-        _abbreviate_scientific_names = abbreviate_scientific_names;
-    }
-
-    public void setAddTaxonomyImagesCB( final boolean b ) {
-        display_options[ show_taxonomy_images ][ 1 ] = b ? "yes" : "no";
-    }
-
-    private void setAntialiasScreen( final boolean antialias_screen ) {
-        _antialias_screen = antialias_screen;
-    }
-
-    public void setBackgroundColorGradient( final boolean background_color_gradient ) {
-        _background_color_gradient = background_color_gradient;
-    }
-
-    public void setBaseFontFamilyName( final String base_font_family_name ) {
-        _base_font_family_name = base_font_family_name;
+    public void setShowDefaultNodeShapesInternal( final boolean show_default_node_shapes_internal ) {
+        _show_default_node_shapes_internal = show_default_node_shapes_internal;
     }
 
-    public void setBaseFontSize( final int base_font_size ) {
-        _base_font_size = base_font_size;
+    public void setShowDomainLabels( final boolean show_domain_labels ) {
+        _show_domain_labels = show_domain_labels;
     }
 
-    private void setCladogramType( final CLADOGRAM_TYPE cladogram_type ) {
-        _cladogram_type = cladogram_type;
+    public void setShowScale( final boolean show_scale ) {
+        _show_scale = show_scale;
     }
 
-    public void setColorizeBranches( final boolean b ) {
+    public void setUseStyle( final boolean b ) {
         display_options[ use_style ][ 2 ] = b ? "yes" : "no";
     }
 
-    public void setColorLabelsSameAsParentBranch( final boolean color_labels_same_as_parent_branch ) {
-        _color_labels_same_as_parent_branch = color_labels_same_as_parent_branch;
-    }
-
-    private void setDefaultBootstrapSamples( final int default_bootstrap_samples ) {
-        _default_bootstrap_samples = default_bootstrap_samples;
-    }
-
-    public void setDefaultNodeFill( final NodeFill default_node_fill ) {
-        _default_node_fill = default_node_fill;
-    }
-
-    public void setDefaultNodeShape( final NodeShape default_node_shape ) {
-        _default_node_shape = default_node_shape;
-    }
-
-    public void setDefaultNodeShapeSize( final short default_node_shape_size ) {
-        _default_node_shape_size = default_node_shape_size;
-    }
-
-    public void setDisplayAsPhylogram( final boolean b ) {
-        display_options[ display_as_phylogram ][ 2 ] = b ? "yes" : "no";
-    }
-
-    public void setDisplayColors( final SortedMap<String, Color> display_colors ) {
-        _display_colors = display_colors;
-    }
-
-    public void setDisplayConfidenceValues( final boolean b ) {
-        display_options[ write_confidence_values ][ 2 ] = b ? "yes" : "no";
-    }
-
-    public void setDisplayGeneNames( final boolean b ) {
-        display_options[ show_gene_names ][ 2 ] = b ? "yes" : "no";
+    private int getClickToIndex( final String name ) {
+        int index = -1;
+        if ( name.equals( "edit_info" ) ) {
+            index = Configuration.display_node_data;
+            ForesterUtil
+                    .printWarningMessage( Constants.PRG_NAME,
+                                          "configuration key [edit_info] is deprecated, use [display node data] instead" );
+        }
+        else if ( name.equals( "display_node_data" ) ) {
+            index = Configuration.display_node_data;
+        }
+        else if ( name.equals( "collapse_uncollapse" ) ) {
+            index = Configuration.collapse_uncollapse;
+        }
+        else if ( name.equals( "reroot" ) ) {
+            index = Configuration.reroot;
+        }
+        else if ( name.equals( "subtree" ) ) {
+            index = Configuration.subtree;
+        }
+        else if ( name.equals( "swap" ) ) {
+            index = Configuration.swap;
+        }
+        else if ( name.equals( "sort_descendants" ) ) {
+            index = Configuration.sort_descendents;
+        }
+        else if ( name.equals( "get_ext_descendents_data" ) ) {
+            index = Configuration.get_ext_desc_data;
+        }
+        else if ( name.equals( "display_sequences" ) ) {
+            ForesterUtil
+                    .printWarningMessage( Constants.PRG_NAME, "configuration key [display_sequences] is deprecated" );
+            return DEPRECATED;
+        }
+        else if ( name.equals( "open_seq_web" ) ) {
+            index = Configuration.open_seq_web;
+        }
+        else if ( name.equals( "open_pdb_web" ) ) {
+            index = Configuration.open_pdb_web;
+        }
+        else if ( name.equals( "open_tax_web" ) ) {
+            index = Configuration.open_tax_web;
+        }
+        else if ( name.equals( "blast" ) ) {
+            index = Configuration.blast;
+        }
+        else if ( name.equals( "cut_subtree" ) ) {
+            index = Configuration.cut_subtree;
+        }
+        else if ( name.equals( "copy_subtree" ) ) {
+            index = Configuration.copy_subtree;
+        }
+        else if ( name.equals( "paste_subtree" ) ) {
+            index = Configuration.paste_subtree;
+        }
+        else if ( name.equals( "delete" ) ) {
+            index = Configuration.delete_subtree_or_node;
+        }
+        else if ( name.equals( "add_new_node" ) ) {
+            index = Configuration.add_new_node;
+        }
+        else if ( name.equals( "edit_node_data" ) ) {
+            index = Configuration.edit_node_data;
+        }
+        else if ( name.equals( "select_nodes" ) ) {
+            index = Configuration.select_nodes;
+        }
+        else if ( name.equals( "display_node_popup" ) ) {
+            ForesterUtil.printWarningMessage( Constants.PRG_NAME,
+                                              "configuration key [display_node_popup] is deprecated" );
+            return DEPRECATED;
+        }
+        else if ( name.equals( "custom_option" ) ) {
+            ForesterUtil.printWarningMessage( Constants.PRG_NAME, "configuration key [custom_option] is deprecated" );
+            return DEPRECATED;
+        }
+        else if ( name.equals( "color_subtree" ) ) {
+            index = Configuration.color_subtree;
+        }
+        else if ( name.equals( "change_node_font" ) ) {
+            index = Configuration.change_node_font;
+        }
+        else if ( name.equals( "color_node_font" ) ) {
+            index = Configuration.color_node_font;
+        }
+        else if ( name.equals( "color_subtree" ) ) {
+            index = Configuration.color_subtree;
+        }
+        return index;
     }
 
-    public void setDisplayInternalData( final boolean b ) {
-        display_options[ display_internal_data ][ 2 ] = b ? "yes" : "no";
+    private final void initSpeciesColors() {
+        _species_colors = new Hashtable<String, Color>();
+        for( final String[] s : DEFAULT_SPECIES_COLORS ) {
+            _species_colors.put( s[ 0 ], Color.decode( s[ 1 ] ) );
+        }
     }
 
-    public void setDisplayNodeNames( final boolean b ) {
-        display_options[ show_node_names ][ 2 ] = b ? "yes" : "no";
+    private boolean parseBoolean( final String str ) {
+        final String my_str = str.trim().toLowerCase();
+        if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
+            return true;
+        }
+        else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
+            return false;
+        }
+        else {
+            ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse boolean value from [" + str + "]" );
+            return false;
+        }
     }
 
-    public void setDisplaySequenceAcc( final boolean b ) {
-        display_options[ show_sequence_acc ][ 2 ] = b ? "yes" : "no";
+    private double parseDouble( final String str ) {
+        double d = 0.0;
+        try {
+            d = Double.parseDouble( str.trim() );
+        }
+        catch ( final Exception e ) {
+            ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse double from [" + str + "]" );
+            d = 0.0;
+        }
+        return d;
     }
 
-    public void setDisplaySequenceNames( final boolean b ) {
-        display_options[ show_seq_names ][ 2 ] = b ? "yes" : "no";
+    private float parseFloat( final String str ) {
+        float f = 0.0f;
+        try {
+            f = Float.parseFloat( str.trim() );
+        }
+        catch ( final Exception e ) {
+            ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse float from [" + str + "]" );
+            f = 0.0f;
+        }
+        return f;
     }
 
-    public void setDisplaySequenceRelations( final boolean display_sequence_relations ) {
-        _display_sequence_relations = display_sequence_relations;
+    private int parseInt( final String str ) {
+        int i = -1;
+        try {
+            i = Integer.parseInt( str.trim() );
+        }
+        catch ( final Exception e ) {
+            ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse integer from [" + str + "]" );
+            i = -1;
+        }
+        return i;
     }
 
-    public void setDisplaySequenceSymbols( final boolean b ) {
-        display_options[ show_seq_symbols ][ 2 ] = b ? "yes" : "no";
+    private short parseShort( final String str ) {
+        short i = -1;
+        try {
+            i = Short.parseShort( str.trim() );
+        }
+        catch ( final Exception e ) {
+            ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse short from [" + str + "]" );
+            i = -1;
+        }
+        return i;
     }
 
-    public void setDisplayTaxonomyCode( final boolean b ) {
-        display_options[ show_tax_code ][ 2 ] = b ? "yes" : "no";
+    private void processFontFamily( final StringTokenizer st ) {
+        setBaseFontFamilyName( "" );
+        final String font_str = ( ( String ) st.nextElement() ).trim();
+        final String[] fonts = font_str.split( ",+" );
+        for( String font : fonts ) {
+            font = font.replace( '_', ' ' ).trim();
+            if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font ) >= 0 ) {
+                setBaseFontFamilyName( font );
+                break;
+            }
+        }
     }
 
-    public void setDisplayTaxonomyCommonNames( final boolean b ) {
-        display_options[ show_taxonomy_common_names ][ 2 ] = b ? "yes" : "no";
+    /**
+     * read each line of config file, process non-comment lines
+     * @throws IOException
+     */
+    private void readConfig( final BufferedReader conf_in ) throws IOException {
+        String line;
+        do {
+            line = conf_in.readLine();
+            if ( line != null ) {
+                line = line.trim();
+                // skip comments and blank lines
+                if ( !line.startsWith( "#" ) && ( !ForesterUtil.isEmpty( line ) ) ) {
+                    // convert runs of spaces to tabs
+                    line = line.replaceAll( "\\s+", "\t" );
+                    final StringTokenizer st = new StringTokenizer( line, "\t" );
+                    setKeyValue( st );
+                }
+            }
+        } while ( line != null );
     }
 
-    public void setDisplayTaxonomyImages( final boolean b ) {
-        display_options[ show_taxonomy_images ][ 2 ] = b ? "yes" : "no";
+    private void setAntialiasScreen( final boolean antialias_screen ) {
+        _antialias_screen = antialias_screen;
     }
 
-    public void setDisplayTaxonomyScientificNames( final boolean b ) {
-        display_options[ show_taxonomy_scientific_names ][ 2 ] = b ? "yes" : "no";
+    private void setCladogramType( final CLADOGRAM_TYPE cladogram_type ) {
+        _cladogram_type = cladogram_type;
     }
 
-    public void setDynamicallyHideData( final boolean b ) {
-        display_options[ dynamically_hide_data ][ 2 ] = b ? "yes" : "no";
-    }
-    
-    public void setDisplayMultipleSequenceAlignment( final boolean b ) {
-        display_options[ show_mol_seqs ][ 2 ] = b ? "yes" : "no";
+    private void setDefaultBootstrapSamples( final int default_bootstrap_samples ) {
+        _default_bootstrap_samples = default_bootstrap_samples;
     }
 
     private void setEditable( final boolean editable ) {
         _editable = editable;
     }
 
-    public void setExtDescNodeDataToReturn( final NodeDataField ext_desc_data_to_return ) {
-        _ext_desc_data_to_return = ext_desc_data_to_return;
-    }
-
     private void setExtNodeDataReturnOn( final EXT_NODE_DATA_RETURN_ON ext_node_data_return_on ) {
         _ext_node_data_return_on = ext_node_data_return_on;
     }
 
-    public void setFrameXSize( final int frame_x_size ) {
-        _frame_x_size = frame_x_size;
-    }
-
-    public void setFrameYSize( final int frame_y_size ) {
-        _frame_y_size = frame_y_size;
-    }
-
     private void setGraphicsExportX( final int graphics_export_x ) {
         _graphics_export_x = graphics_export_x;
     }
@@ -1045,7 +879,7 @@ public final class Configuration {
             default_clickto = getClickToIndex( clickto_name );
             if ( default_clickto == -1 ) {
                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "invalid value [" + clickto_name
-                                                  + "] for [default_click_to]" );
+                        + "] for [default_click_to]" );
                 default_clickto = 0;
             }
             else if ( default_clickto == DEPRECATED ) {
@@ -1065,7 +899,7 @@ public final class Configuration {
             }
             else {
                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse yes/no/? value from [" + my_str
-                                                  + "]" );
+                        + "]" );
                 _ui = UI.UNKNOWN;
             }
         }
@@ -1104,7 +938,7 @@ public final class Configuration {
             else {
                 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
-                                                  + "] for [phylogeny_graphics_type]" );
+                        + "] for [phylogeny_graphics_type]" );
             }
         }
         else if ( key.equals( "min_confidence_value" ) ) {
@@ -1158,7 +992,7 @@ public final class Configuration {
             }
             else {
                 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
-                        "value for [pdf_export_line_width] cannot be zero or negative" );
+                                                  "value for [pdf_export_line_width] cannot be zero or negative" );
             }
         }
         else if ( key.equals( "window_initial_size_x" ) ) {
@@ -1183,8 +1017,8 @@ public final class Configuration {
             }
             else {
                 ForesterUtil
-                .printWarningMessage( Constants.PRG_NAME,
-                                      "value for [default_number_of_bootstrap_resamples] cannot be negative" );
+                        .printWarningMessage( Constants.PRG_NAME,
+                                              "value for [default_number_of_bootstrap_resamples] cannot be negative" );
             }
         }
         else if ( key.equals( "mafft_local" ) ) {
@@ -1239,13 +1073,13 @@ public final class Configuration {
             }
             else {
                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
-                                                  + "] for [cladogram_type]" );
+                        + "] for [cladogram_type]" );
             }
         }
         else if ( key.equals( "non_lined_up_cladogram" ) ) {
             ForesterUtil
-            .printWarningMessage( Constants.PRG_NAME,
-                                  "configuration key [non_lined_up_cladogram] is deprecated, use [cladogram_type] instead" );
+                    .printWarningMessage( Constants.PRG_NAME,
+                                          "configuration key [non_lined_up_cladogram] is deprecated, use [cladogram_type] instead" );
         }
         else if ( key.equals( "hide_controls_and_menus" ) ) {
             _hide_controls_and_menus = parseBoolean( ( String ) st.nextElement() );
@@ -1278,7 +1112,7 @@ public final class Configuration {
             else {
                 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
-                                                  + "] for [overview_placement_type]" );
+                        + "] for [overview_placement_type]" );
             }
         }
         else if ( key.equals( "node_label_direction" ) ) {
@@ -1292,7 +1126,7 @@ public final class Configuration {
             else {
                 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
-                                                  + "] for [node_label_direction]" );
+                        + "] for [node_label_direction]" );
             }
         }
         else if ( key.equals( "branch_length_value_digits" ) ) {
@@ -1302,7 +1136,7 @@ public final class Configuration {
             }
             else {
                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
-                                                  + "] for [branch_length_value_digits]" );
+                        + "] for [branch_length_value_digits]" );
             }
         }
         else if ( key.equals( "confidence_value_digits" ) ) {
@@ -1312,7 +1146,7 @@ public final class Configuration {
             }
             else {
                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
-                                                  + "] for [confidence_value_digits]" );
+                        + "] for [confidence_value_digits]" );
             }
         }
         else if ( key.equals( "allow_editing" ) ) {
@@ -1325,8 +1159,8 @@ public final class Configuration {
             final boolean r = parseBoolean( ( String ) st.nextElement() );
             if ( r && ( getTaxonomyExtraction() != TAXONOMY_EXTRACTION.NO ) ) {
                 ForesterUtil
-                .printWarningMessage( Constants.PRG_NAME,
-                                      "attempt to extract taxonomies and replace underscores at the same time" );
+                        .printWarningMessage( Constants.PRG_NAME,
+                                              "attempt to extract taxonomies and replace underscores at the same time" );
             }
             else {
                 setReplaceUnderscoresInNhParsing( r );
@@ -1348,15 +1182,15 @@ public final class Configuration {
             }
             else {
                 ForesterUtil
-                .printWarningMessage( Constants.PRG_NAME,
-                                      "unknown value for \"taxonomy_extraction_in_nh_parsing\": "
-                                              + s
-                                              + " (must be either: no, pfam_relaxed, pfam_strict, or aggressive)" );
+                        .printWarningMessage( Constants.PRG_NAME,
+                                              "unknown value for \"taxonomy_extraction_in_nh_parsing\": "
+                                                      + s
+                                                      + " (must be either: no, pfam_relaxed, pfam_strict, or aggressive)" );
             }
             if ( ( getTaxonomyExtraction() != TAXONOMY_EXTRACTION.NO ) && isReplaceUnderscoresInNhParsing() ) {
                 ForesterUtil
-                .printWarningMessage( Constants.PRG_NAME,
-                                      "attempt to extract taxonomies and replace underscores at the same time" );
+                        .printWarningMessage( Constants.PRG_NAME,
+                                              "attempt to extract taxonomies and replace underscores at the same time" );
             }
         }
         else if ( key.equals( "internal_labels_are_confidence_values" ) ) {
@@ -1412,7 +1246,7 @@ public final class Configuration {
             }
             else {
                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + fill_str
-                                                  + "] for [default_node_fill]" );
+                        + "] for [default_node_fill]" );
             }
         }
         else if ( key.equals( "default_node_shape" ) ) {
@@ -1425,7 +1259,7 @@ public final class Configuration {
             }
             else {
                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + shape_str
-                                                  + "] for [default_node_shape]" );
+                        + "] for [default_node_shape]" );
             }
         }
         else if ( key.equals( "midpoint_reroot" ) ) {
@@ -1474,7 +1308,7 @@ public final class Configuration {
             }
             else {
                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + s
-                                                  + "] for [ext_descendents_data_to_return]" );
+                        + "] for [ext_descendents_data_to_return]" );
             }
         }
         else if ( key.equals( "list_node_data_custom_label" ) || key.equals( "label_for_get_ext_descendents_data" ) ) {
@@ -1496,7 +1330,7 @@ public final class Configuration {
             }
             else {
                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + s
-                                                  + "] for [ext_descendents_data_to_return_on]" );
+                        + "] for [ext_descendents_data_to_return_on]" );
             }
         }
         else if ( key.equals( "vector_data_min_color" ) ) {
@@ -1565,8 +1399,8 @@ public final class Configuration {
             else if ( key.equals( "color_branches" ) ) {
                 key_index = Configuration.use_style;
                 ForesterUtil
-                .printWarningMessage( Constants.PRG_NAME,
-                                      "configuration key [color_branches] is deprecated, use [use_visual_styles] instead" );
+                        .printWarningMessage( Constants.PRG_NAME,
+                                              "configuration key [color_branches] is deprecated, use [use_visual_styles] instead" );
             }
             else if ( key.equals( "width_branches" ) ) {
                 key_index = Configuration.width_branches;
@@ -1662,144 +1496,310 @@ public final class Configuration {
                 }
                 else if ( key.equals( "annotation_color" ) ) {
                     getAnnotationColors()
-                    .put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
+                            .put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
                 }
                 else if ( key.equals( "function_color" ) ) {
                     ForesterUtil.printWarningMessage( Constants.PRG_NAME,
-                            "configuration key [function_color] is deprecated" );
+                                                      "configuration key [function_color] is deprecated" );
                 }
                 else if ( key.equals( DISPLAY_COLOR_KEY ) ) {
                     putDisplayColors( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
                 }
                 else {
                     ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key
-                                                      + "] in: " + config_filename );
+                            + "] in: " + config_filename );
                 }
             }
         }
-        else {
-            ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key + "] in: "
-                    + config_filename );
+        else {
+            ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key + "] in: "
+                    + config_filename );
+        }
+    }
+
+    private void setLabelForGetExtDescendentsData( final String label_for_get_ext_descendents_data ) {
+        _label_for_get_ext_descendents_data = label_for_get_ext_descendents_data;
+    }
+
+    private void setMaxBaseFontSize( final int max_base_font_size ) {
+        _max_base_font_size = max_base_font_size;
+    }
+
+    private void setMinBaseFontSize( final int min_base_font_size ) {
+        _min_base_font_size = min_base_font_size;
+    }
+
+    private void setOvMaxHeight( final short ov_max_height ) {
+        _ov_max_height = ov_max_height;
+    }
+
+    private void setOvMaxWidth( final short ov_max_width ) {
+        _ov_max_width = ov_max_width;
+    }
+
+    private void setOvPlacement( final OVERVIEW_PLACEMENT_TYPE ov_placement ) {
+        _ov_placement = ov_placement;
+    }
+
+    private void setPathToLocalFastme( final File path_to_local_fastme ) {
+        _path_to_local_fastme = path_to_local_fastme;
+    }
+
+    private void setPathToLocalMafft( final File path_to_local_mafft ) {
+        _path_to_local_mafft = path_to_local_mafft;
+    }
+
+    private void setPathToLocalRaxml( final File path_to_local_raxml ) {
+        _path_to_local_raxml = path_to_local_raxml;
+    }
+
+    private void setShowAnnotationRefSource( final boolean b ) {
+        _show_annotation_ref_source = b;
+    }
+
+    private void setShowOverview( final boolean show_overview ) {
+        _show_overview = show_overview;
+    }
+
+    private void setValidatePhyloXmlAgainstSchema( final boolean validate_against_phyloxml_xsd_schema ) {
+        _validate_against_phyloxml_xsd_schema = validate_against_phyloxml_xsd_schema;
+    }
+
+    boolean displaySequenceRelations() {
+        return _display_sequence_relations;
+    }
+
+    boolean doCheckOption( final int which ) {
+        return ( display_options[ which ][ 2 ].equalsIgnoreCase( "yes" ) )
+                || ( display_options[ which ][ 2 ].equalsIgnoreCase( "true" ) );
+    }
+
+    boolean doDisplayClickToOption( final int which ) {
+        return clickto_options[ which ][ 1 ].equalsIgnoreCase( "display" );
+    }
+
+    boolean doDisplayOption( final int which ) {
+        return display_options[ which ][ 1 ].equalsIgnoreCase( "display" );
+    }
+
+    /**
+     * Will attempt to use the phylogeny to determine whether to check
+     * this or not (e.g. phylogram)
+     *
+     */
+    boolean doGuessCheckOption( final int which ) {
+        return display_options[ which ][ 2 ].equals( "?" );
+    }
+
+    Map<String, Color> getAnnotationColors() {
+        if ( _annotation_colors == null ) {
+            _annotation_colors = new Hashtable<String, Color>();
+        }
+        return _annotation_colors;
+    }
+
+    int getBaseFontSize() {
+        return _base_font_size;
+    }
+
+    CLADOGRAM_TYPE getCladogramType() {
+        return _cladogram_type;
+    }
+
+    int getClickToOptionsCount() {
+        return clickto_options.length;
+    }
+
+    String getClickToTitle( final int which ) {
+        return clickto_options[ which ][ 0 ];
+    }
+
+    int getDefaultDisplayClicktoOption() {
+        return default_clickto;
+    }
+
+    SortedMap<String, Color> getDisplayColors() {
+        return _display_colors;
+    }
+
+    String getDisplayTitle( final int which ) {
+        return display_options[ which ][ 0 ];
+    }
+
+    Map<String, Color> getDomainColors() {
+        if ( _domain_colors == null ) {
+            _domain_colors = new Hashtable<String, Color>();
         }
+        return _domain_colors;
     }
 
-    private void setLabelForGetExtDescendentsData( final String label_for_get_ext_descendents_data ) {
-        _label_for_get_ext_descendents_data = label_for_get_ext_descendents_data;
+    int getGraphicsExportX() {
+        return _graphics_export_x;
     }
 
-    final public void setLineUpRendarableNodeData( final boolean line_up_renderable_node_data ) {
-        _line_up_renderable_node_data = line_up_renderable_node_data;
+    int getGraphicsExportY() {
+        return _graphics_export_y;
     }
 
-    private void setMaxBaseFontSize( final int max_base_font_size ) {
-        _max_base_font_size = max_base_font_size;
+    Color getGuiBackgroundColor() {
+        return _gui_background_color;
     }
 
-    public void setMidpointReroot( final boolean midpoint_root ) {
-        _midpoint_root = midpoint_root;
+    Color getGuiButtonBackgroundColor() {
+        return _gui_button_background_color;
     }
 
-    private void setMinBaseFontSize( final int min_base_font_size ) {
-        _min_base_font_size = min_base_font_size;
+    Color getGuiButtonBorderColor() {
+        return _gui_button_border_color;
     }
 
-    public void setMinConfidenceValue( final double min_confidence_value ) {
-        _min_confidence_value = min_confidence_value;
+    Color getGuiButtonTextColor() {
+        return _gui_button_text_color;
     }
 
-    public void setNodeLabelDirection( final NODE_LABEL_DIRECTION node_label_direction ) {
-        _node_label_direction = node_label_direction;
+    Color getGuiCheckboxAndButtonActiveColor() {
+        return _gui_checkbox_and_button_active_color;
     }
 
-    public void setNumberOfDigitsAfterCommaForBranchLengthValue( final short number_of_digits_after_comma_for_branch_length_values ) {
-        _number_of_digits_after_comma_for_branch_length_values = number_of_digits_after_comma_for_branch_length_values;
+    Color getGuiCheckboxTextColor() {
+        return _gui_checkbox_text_color;
     }
 
-    public void setNumberOfDigitsAfterCommaForConfidenceValues( final short number_of_digits_after_comma_for_confidence_values ) {
-        _number_of_digits_after_comma_for_confidence_values = number_of_digits_after_comma_for_confidence_values;
+    Color getGuiMenuBackgroundColor() {
+        return _gui_menu_background_color;
     }
 
-    private void setOvMaxHeight( final short ov_max_height ) {
-        _ov_max_height = ov_max_height;
+    Color getGuiMenuTextColor() {
+        return _gui_menu_text_color;
     }
 
-    private void setOvMaxWidth( final short ov_max_width ) {
-        _ov_max_width = ov_max_width;
+    int getMaxBaseFontSize() {
+        return _max_base_font_size;
     }
 
-    private void setOvPlacement( final OVERVIEW_PLACEMENT_TYPE ov_placement ) {
-        _ov_placement = ov_placement;
+    int getMinBaseFontSize() {
+        return _min_base_font_size;
     }
 
-    private void setPathToLocalFastme( final File path_to_local_fastme ) {
-        _path_to_local_fastme = path_to_local_fastme;
+    double getMinConfidenceValue() {
+        return _min_confidence_value;
     }
 
-    private void setPathToLocalMafft( final File path_to_local_mafft ) {
-        _path_to_local_mafft = path_to_local_mafft;
+    NODE_LABEL_DIRECTION getNodeLabelDirection() {
+        return _node_label_direction;
     }
 
-    private void setPathToLocalRaxml( final File path_to_local_raxml ) {
-        _path_to_local_raxml = path_to_local_raxml;
+    short getNumberOfDigitsAfterCommaForBranchLengthValues() {
+        return _number_of_digits_after_comma_for_branch_length_values;
     }
 
-    public void setPhylogenyGraphicsType( final PHYLOGENY_GRAPHICS_TYPE phylogeny_graphics_type ) {
-        _phylogeny_graphics_type = phylogeny_graphics_type;
+    short getNumberOfDigitsAfterCommaForConfidenceValues() {
+        return _number_of_digits_after_comma_for_confidence_values;
     }
 
-    public void setPrintLineWidth( final float print_line_width ) {
-        _print_line_width = print_line_width;
+    short getOvMaxHeight() {
+        return _ov_max_height;
     }
 
-    public void setReplaceUnderscoresInNhParsing( final boolean nh_parsing_replace_underscores ) {
-        _nh_parsing_replace_underscores = nh_parsing_replace_underscores;
+    short getOvMaxWidth() {
+        return _ov_max_width;
     }
 
-    final public void setRightLineUpDomains( final boolean right_align_domains ) {
-        _right_align_domains = right_align_domains;
+    OVERVIEW_PLACEMENT_TYPE getOvPlacement() {
+        return _ov_placement;
     }
 
-    private void setShowAnnotationRefSource( final boolean b ) {
-        _show_annotation_ref_source = b;
+    PHYLOGENY_GRAPHICS_TYPE getPhylogenyGraphicsType() {
+        return _phylogeny_graphics_type;
     }
 
-    public void setShowDefaultNodeShapesExternal( final boolean show_default_node_shapes_external ) {
-        _show_default_node_shapes_external = show_default_node_shapes_external;
+    float getPrintLineWidth() {
+        return _print_line_width;
     }
 
-    public void setShowDefaultNodeShapesForMarkedNodes( final boolean show_default_node_shapes_for_marked_nodes ) {
-        _show_default_node_shapes_for_marked_nodes = show_default_node_shapes_for_marked_nodes;
+    Hashtable<String, Color> getSequenceColors() {
+        if ( _sequence_colors == null ) {
+            _sequence_colors = new Hashtable<String, Color>();
+        }
+        return _sequence_colors;
     }
 
-    public void setShowDefaultNodeShapesInternal( final boolean show_default_node_shapes_internal ) {
-        _show_default_node_shapes_internal = show_default_node_shapes_internal;
+    Hashtable<String, Color> getSpeciesColors() {
+        if ( _species_colors == null ) {
+            initSpeciesColors();
+        }
+        return _species_colors;
     }
 
-    public void setShowDomainLabels( final boolean show_domain_labels ) {
-        _show_domain_labels = show_domain_labels;
+    final TAXONOMY_EXTRACTION getTaxonomyExtraction() {
+        return _taxonomy_extraction;
     }
 
-    private void setShowOverview( final boolean show_overview ) {
-        _show_overview = show_overview;
+    boolean isAntialiasScreen() {
+        return _antialias_screen;
     }
 
-    public void setShowScale( final boolean show_scale ) {
-        _show_scale = show_scale;
+    /**
+     * Convenience method.
+     *
+     * @return true if value in configuration file was 'yes'
+     */
+    boolean isDrawAsPhylogram() {
+        return doCheckOption( display_as_phylogram );
     }
 
-    final void setTaxonomyExtraction( final TAXONOMY_EXTRACTION taxonomy_extraction ) {
-        _taxonomy_extraction = taxonomy_extraction;
+    boolean isEditable() {
+        return _editable;
     }
 
-    public void setUseStyle( final boolean b ) {
-        display_options[ use_style ][ 2 ] = b ? "yes" : "no";
+    /**
+     * Only used by ArchaeoptryxE.
+     *
+     */
+    boolean isHideControlPanelAndMenubar() {
+        return _hide_controls_and_menus;
     }
 
-    private void setValidatePhyloXmlAgainstSchema( final boolean validate_against_phyloxml_xsd_schema ) {
-        _validate_against_phyloxml_xsd_schema = validate_against_phyloxml_xsd_schema;
+    boolean isInternalNumberAreConfidenceForNhParsing() {
+        return _internal_number_are_confidence_for_nh_parsing;
     }
 
-    public boolean isAllowThickStrokes() {
-        return _allow_thick_strokes;
+    boolean isReplaceUnderscoresInNhParsing() {
+        return _nh_parsing_replace_underscores;
+    }
+
+    boolean isShowOverview() {
+        return _show_overview;
+    }
+
+    boolean isShowScale() {
+        return _show_scale;
+    }
+
+    final boolean isUseNativeUI() {
+        if ( ( _ui == UI.UNKNOWN ) && ForesterUtil.isMac() ) {
+            _ui = UI.NATIVE;
+        }
+        return _ui == UI.NATIVE;
+    }
+
+    /**
+     * Only used by ArchaeoptryxE.
+     *
+     */
+    boolean isUseTabbedDisplay() {
+        return _use_tabbed_display;
+    }
+
+    boolean isValidatePhyloXmlAgainstSchema() {
+        return _validate_against_phyloxml_xsd_schema;
+    }
+
+    final void setTaxonomyExtraction( final TAXONOMY_EXTRACTION taxonomy_extraction ) {
+        _taxonomy_extraction = taxonomy_extraction;
+    }
+
+    static String getDefaultFontFamilyName() {
+        return DEFAULT_FONT_FAMILY;
     }
 }
index cd43a92..22dc4a3 100644 (file)
@@ -46,7 +46,7 @@ public final class Constants {
     final static String         PRG_DATE                                                      = "150306";
     final static String         DEFAULT_CONFIGURATION_FILE_NAME                               = "_aptx_configuration_file";
     final static String[]       DEFAULT_FONT_CHOICES                                          = { "Arial", "Helvetica",
-            "Verdana", "Tahoma", "Dialog", "Lucida Sans", "SansSerif", "Sans-serif", "Sans"  };
+        "Verdana", "Tahoma", "Dialog", "Lucida Sans", "SansSerif", "Sans-serif", "Sans"  };
     final static boolean        VERBOSE_DEFAULT                                               = false;
     final static int            DOMAIN_STRUCTURE_DEFAULT_WIDTH                                = 100;
     final static String         AUTHOR_EMAIL                                                  = "phyloxml@gmail.com";
index 3bd8738..1bc7d4b 100644 (file)
@@ -72,6 +72,29 @@ import org.forester.util.ForesterUtil;
 
 final class ControlPanel extends JPanel implements ActionListener {
 
+    enum NodeClickAction {
+        ADD_NEW_NODE,
+        BLAST,
+        COLLAPSE,
+        COLOR_SUBTREE,
+        COPY_SUBTREE,
+        CUT_SUBTREE,
+        DELETE_NODE_OR_SUBTREE,
+        EDIT_NODE_DATA,
+        GET_EXT_DESC_DATA,
+        OPEN_PDB_WEB,
+        OPEN_SEQ_WEB,
+        OPEN_TAX_WEB,
+        PASTE_SUBTREE,
+        REROOT,
+        SELECT_NODES,
+        SHOW_DATA,
+        SORT_DESCENDENTS,
+        SUBTREE,
+        SWAP,
+        CHANGE_NODE_FONT,
+        COLOR_NODE_FONT;
+    }
     final static Font                         jcb_bold_font             = new Font( Configuration.getDefaultFontFamilyName(),
                                                                                     Font.BOLD,
                                                                                     9 );
@@ -331,16 +354,12 @@ final class ControlPanel extends JPanel implements ActionListener {
         }
     }
 
-    public JCheckBox getColorAccSpeciesCb() {
-        return _color_acc_species;
-    }
-
     public JCheckBox getColorAccSequenceCb() {
         return _color_acc_sequence;
     }
 
-    public JCheckBox getUseVisualStylesCb() {
-        return _use_visual_styles_cb;
+    public JCheckBox getColorAccSpeciesCb() {
+        return _color_acc_species;
     }
 
     public JCheckBox getDisplayAsPhylogramCb() {
@@ -399,10 +418,18 @@ final class ControlPanel extends JPanel implements ActionListener {
         return _show_events;
     }
 
+    public JCheckBox getUseVisualStylesCb() {
+        return _use_visual_styles_cb;
+    }
+
     public JCheckBox getWriteConfidenceCb() {
         return _write_confidence;
     }
 
+    public boolean isShowMolSequences() {
+        return ( ( _show_mol_seqs != null ) && _show_mol_seqs.isSelected() );
+    }
+
     public boolean isShowProperties() {
         return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
     }
@@ -461,1870 +488,1661 @@ final class ControlPanel extends JPanel implements ActionListener {
         } );
     }
 
-    void activateButtonToReturnToSuperTree( int index ) {
-        --index;
-        if ( index > 0 ) {
-            _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
-        }
-        else {
-            _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
+    private void addClickToOption( final int which, final String title ) {
+        _click_to_combobox.addItem( title );
+        _click_to_names.add( title );
+        _all_click_to_names.put( new Integer( which ), title );
+        if ( !_configuration.isUseNativeUI() ) {
+            _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
+            _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
         }
-        _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
-        _return_to_super_tree.setEnabled( true );
     }
 
-    /**
-     * Add zoom and quick edit buttons. (Last modified 8/9/04)
-     */
-    void addButtons() {
+    /* GUILHEM_BEG */
+    private void addSequenceRelationBlock() {
         final JLabel spacer = new JLabel( "" );
-        spacer.setOpaque( false );
+        spacer.setSize( 1, 1 );
         add( spacer );
-        final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
-        final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
-        final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
-        if ( !getConfiguration().isUseNativeUI() ) {
-            x_panel.setBackground( getBackground() );
-            y_panel.setBackground( getBackground() );
-            z_panel.setBackground( getBackground() );
+        final JLabel mainLabel = new JLabel( "Sequence relations to display" );
+        final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
+        typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
+        getSequenceRelationTypeBox().setFocusable( false );
+        _sequence_relation_type_box.setFont( ControlPanel.js_font );
+        if ( !_configuration.isUseNativeUI() ) {
+            _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
+            _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
         }
-        add( _zoom_label = new JLabel( "Zoom:" ) );
-        customizeLabel( _zoom_label, getConfiguration() );
-        add( x_panel );
-        add( y_panel );
-        add( z_panel );
-        if ( getConfiguration().isUseNativeUI() ) {
-            _zoom_in_x = new JButton( "+" );
-            _zoom_out_x = new JButton( "-" );
+        _sequence_relation_type_box.setRenderer( new ListCellRenderer<Object>() {
+
+            @Override
+            public Component getListCellRendererComponent( final JList<?> list,
+                                                           final Object value,
+                                                           final int index,
+                                                           final boolean isSelected,
+                                                           final boolean cellHasFocus ) {
+                final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
+                                                                                                        value,
+                                                                                                        index,
+                                                                                                        isSelected,
+                                                                                                        cellHasFocus );
+                if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
+                    ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
+                                                                       .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
+                }
+                return component;
+            }
+        } );
+        final GridBagLayout gbl = new GridBagLayout();
+        _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
+        _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
+        final JPanel horizGrid = new JPanel( gbl );
+        horizGrid.setBackground( getBackground() );
+        horizGrid.add( typeLabel );
+        horizGrid.add( _sequence_relation_type_box );
+        add( customizeLabel( mainLabel, getConfiguration() ) );
+        add( horizGrid );
+        add( getSequenceRelationBox() );
+        if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
+            addCheckbox( Configuration.show_relation_confidence,
+                         _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
+            setCheckbox( Configuration.show_relation_confidence,
+                         _configuration.doCheckOption( Configuration.show_relation_confidence ) );
         }
-        else {
-            _zoom_in_x = new JButton( "X+" );
-            _zoom_out_x = new JButton( "X-" );
+    }// addSequenceRelationBlock
+
+    /* GUILHEM_END */
+    private List<Boolean> getIsDrawPhylogramList() {
+        return _draw_phylogram;
+    }
+
+    // This takes care of ArchaeopteryxE-issue.
+    // Can, and will, return null prior to  ArchaeopteryxE initialization completion.
+    final private MainFrame getMainFrame() {
+        MainFrame mf = getMainPanel().getMainFrame();
+        if ( mf == null ) {
+            // Must be "E" applet version.
+            final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
+            if ( e.getMainPanel() == null ) {
+                return null;
+            }
+            mf = e.getMainPanel().getMainFrame();
         }
-        _zoom_in_y = new JButton( "Y+" );
-        _zoom_out_y = new JButton( "Y-" );
-        _show_whole = new JButton( "F" );
-        _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [F or Home]" );
-        _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+cursor-right]" );
-        _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+cursor-up]" );
-        _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+cursor-left]" );
-        _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+cursor-down]" );
-        if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) {
-            _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
-            _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
+        return mf;
+    }
+
+    private void init() {
+        _draw_phylogram = new ArrayList<Boolean>();
+        setSpeciesColors( new HashMap<String, Color>() );
+        setSequenceColors( new HashMap<String, Color>() );
+        setAnnotationColors( new HashMap<String, Color>() );
+    }
+
+    private boolean isDrawPhylogram( final int index ) {
+        return getIsDrawPhylogramList().get( index );
+    }
+
+    private void search0( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
+        getSearchFoundCountsLabel0().setVisible( true );
+        getSearchResetButton0().setEnabled( true );
+        getSearchResetButton0().setVisible( true );
+        String[] queries = null;
+        Set<PhylogenyNode> nodes = null;
+        if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
+            queries = query_str.split( ",+" );
         }
         else {
-            _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
-            _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
+            queries = new String[ 1 ];
+            queries[ 0 ] = query_str.trim();
         }
-        _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
-        _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
-        _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
-        _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
-        _return_to_super_tree.setEnabled( false );
-        _order = new JButton( "Order Subtrees" );
-        _uncollapse_all = new JButton( "Uncollapse All" );
-        addJButton( _zoom_in_y, x_panel );
-        addJButton( _zoom_out_x, y_panel );
-        addJButton( _show_whole, y_panel );
-        addJButton( _zoom_in_x, y_panel );
-        addJButton( _zoom_out_y, z_panel );
-        if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
-            setUpControlsForDomainStrucures();
+        if ( ( queries != null ) && ( queries.length > 0 ) ) {
+            nodes = new HashSet<PhylogenyNode>();
+            for( String query : queries ) {
+                if ( ForesterUtil.isEmpty( query ) ) {
+                    continue;
+                }
+                query = query.trim();
+                final TreePanel tp = getMainPanel().getCurrentTreePanel();
+                if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
+                    nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
+                                                                         tree,
+                                                                         getOptions().isSearchCaseSensitive(),
+                                                                         !getOptions().isMatchWholeTermsOnly(),
+                                                                         isShowDomainArchitectures(),
+                                                                         tp != null ? Math.pow( 10,
+                                                                                                tp.getDomainStructureEvalueThresholdExp() )
+                                                                                 : 0 ) );
+                }
+                else {
+                    nodes.addAll( PhylogenyMethods.searchData( query,
+                                                               tree,
+                                                               getOptions().isSearchCaseSensitive(),
+                                                               !getOptions().isMatchWholeTermsOnly(),
+                                                               getOptions().isSearchWithRegex(),
+                                                               isShowDomainArchitectures(),
+                                                               tp != null ? Math.pow( 10, tp
+                                                                       .getDomainStructureEvalueThresholdExp() ) : 0 ) );
+                }
+            }
+            if ( getOptions().isInverseSearchResult() ) {
+                final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
+                all.removeAll( nodes );
+                nodes = new HashSet<PhylogenyNode>();
+                nodes.addAll( all );
+            }
+        }
+        if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
+            main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet<Long>() );
+            for( final PhylogenyNode node : nodes ) {
+                main_panel.getCurrentTreePanel().getFoundNodes0().add( node.getId() );
+            }
+            setSearchFoundCountsOnLabel0( nodes.size() );
+        }
+        else {
+            setSearchFoundCountsOnLabel0( 0 );
+            searchReset0();
         }
-        final JLabel spacer2 = new JLabel( "" );
-        add( spacer2 );
-        addJButton( _return_to_super_tree, this );
-        addJButton( _order, this );
-        addJButton( _uncollapse_all, this );
-        final JLabel spacer3 = new JLabel( "" );
-        add( spacer3 );
-        setVisibilityOfDomainStrucureControls();
     }
 
-    void addCheckbox( final int which, final String title ) {
-        final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
-        switch ( which ) {
-            case Configuration.display_as_phylogram:
-                _display_as_phylogram_cb = new JCheckBox( title );
-                getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
-                addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.display_internal_data:
-                _display_internal_data = new JCheckBox( title );
-                _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
-                addJCheckBox( _display_internal_data, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.color_according_to_species:
-                _color_acc_species = new JCheckBox( title );
-                _color_acc_species.setToolTipText( "To colorize node labels as a function of taxonomy" );
-                addJCheckBox( _color_acc_species, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.color_according_to_sequence:
-                _color_acc_sequence = new JCheckBox( title );
-                _color_acc_sequence.setToolTipText( "To colorize node labels as a function of sequence name" );
-                addJCheckBox( _color_acc_sequence, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.color_according_to_annotation:
-                _color_according_to_annotation = new JCheckBox( title );
-                _color_according_to_annotation
-                        .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
-                addJCheckBox( _color_according_to_annotation, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.show_node_names:
-                _show_node_names = new JCheckBox( title );
-                addJCheckBox( _show_node_names, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.show_taxonomy_scientific_names:
-                _show_taxo_scientific_names = new JCheckBox( title );
-                addJCheckBox( _show_taxo_scientific_names, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.show_taxonomy_common_names:
-                _show_taxo_common_names = new JCheckBox( title );
-                addJCheckBox( _show_taxo_common_names, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.show_tax_code:
-                _show_taxo_code = new JCheckBox( title );
-                addJCheckBox( _show_taxo_code, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.show_taxonomy_images:
-                _show_taxo_images_cb = new JCheckBox( title );
-                addJCheckBox( _show_taxo_images_cb, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.show_binary_characters:
-                _show_binary_characters = new JCheckBox( title );
-                addJCheckBox( _show_binary_characters, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.show_annotation:
-                _show_annotation = new JCheckBox( title );
-                addJCheckBox( _show_annotation, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.show_binary_character_counts:
-                _show_binary_character_counts = new JCheckBox( title );
-                addJCheckBox( _show_binary_character_counts, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.write_confidence_values:
-                _write_confidence = new JCheckBox( title );
-                addJCheckBox( getWriteConfidenceCb(), ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.write_events:
-                _show_events = new JCheckBox( title );
-                addJCheckBox( getShowEventsCb(), ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.use_style:
-                _use_visual_styles_cb = new JCheckBox( title );
-                getUseVisualStylesCb()
-                        .setToolTipText( "To use visual styles (node colors, fonts) and branch colors, if present" );
-                addJCheckBox( getUseVisualStylesCb(), ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.width_branches:
-                _width_branches = new JCheckBox( title );
-                _width_branches.setToolTipText( "To use branch width values, if present" );
-                addJCheckBox( _width_branches, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.write_branch_length_values:
-                _write_branch_length_values = new JCheckBox( title );
-                addJCheckBox( _write_branch_length_values, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.show_domain_architectures:
-                _show_domain_architectures = new JCheckBox( title );
-                addJCheckBox( _show_domain_architectures, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.show_mol_seqs:
-                _show_mol_seqs = new JCheckBox( title );
-                addJCheckBox( _show_mol_seqs, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.show_seq_names:
-                _show_seq_names = new JCheckBox( title );
-                addJCheckBox( _show_seq_names, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.show_gene_names:
-                _show_gene_names = new JCheckBox( title );
-                addJCheckBox( _show_gene_names, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.show_seq_symbols:
-                _show_seq_symbols = new JCheckBox( title );
-                addJCheckBox( _show_seq_symbols, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.show_sequence_acc:
-                _show_sequence_acc = new JCheckBox( title );
-                addJCheckBox( _show_sequence_acc, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.dynamically_hide_data:
-                _dynamically_hide_data = new JCheckBox( title );
-                getDynamicallyHideData().setToolTipText( "To hide labels depending on expected visibility" );
-                addJCheckBox( getDynamicallyHideData(), ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.node_data_popup:
-                _node_desc_popup_cb = new JCheckBox( title );
-                getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
-                addJCheckBox( getNodeDescPopupCb(), ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.show_relation_confidence:
-                _seq_relation_confidence_switch = new JCheckBox( title );
-                addJCheckBox( _seq_relation_confidence_switch, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.show_vector_data:
-                _show_vector_data_cb = new JCheckBox( title );
-                addJCheckBox( _show_vector_data_cb, ch_panel );
-                add( ch_panel );
-                break;
-            case Configuration.show_properties:
-                _show_properties_cb = new JCheckBox( title );
-                addJCheckBox( _show_properties_cb, ch_panel );
-                add( ch_panel );
-                break;
-            default:
-                throw new RuntimeException( "unknown checkbox: " + which );
+    private void search1( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
+        getSearchFoundCountsLabel1().setVisible( true );
+        getSearchResetButton1().setEnabled( true );
+        getSearchResetButton1().setVisible( true );
+        String[] queries = null;
+        Set<PhylogenyNode> nodes = null;
+        if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
+            queries = query_str.split( ",+" );
         }
-    }// addCheckbox
-
-    void addJButton( final JButton jb, final JPanel p ) {
-        jb.setFocusPainted( false );
-        jb.setFont( ControlPanel.jcb_font );
-        if ( !_configuration.isUseNativeUI() ) {
-            jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
-            jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
-            jb.setForeground( getConfiguration().getGuiButtonTextColor() );
+        else {
+            queries = new String[ 1 ];
+            queries[ 0 ] = query_str.trim();
         }
-        p.add( jb );
-        jb.addActionListener( this );
-    }
-
-    void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
-        jcb.setFocusPainted( false );
-        jcb.setFont( ControlPanel.jcb_font );
-        if ( !_configuration.isUseNativeUI() ) {
-            jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
-            jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
+        if ( ( queries != null ) && ( queries.length > 0 ) ) {
+            nodes = new HashSet<PhylogenyNode>();
+            for( String query : queries ) {
+                if ( ForesterUtil.isEmpty( query ) ) {
+                    continue;
+                }
+                query = query.trim();
+                final TreePanel tp = getMainPanel().getCurrentTreePanel();
+                if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
+                    nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
+                                                                         tree,
+                                                                         getOptions().isSearchCaseSensitive(),
+                                                                         !getOptions().isMatchWholeTermsOnly(),
+                                                                         isShowDomainArchitectures(),
+                                                                         tp != null ? Math.pow( 10,
+                                                                                                tp.getDomainStructureEvalueThresholdExp() )
+                                                                                 : 0 ) );
+                }
+                else {
+                    nodes.addAll( PhylogenyMethods.searchData( query,
+                                                               tree,
+                                                               getOptions().isSearchCaseSensitive(),
+                                                               !getOptions().isMatchWholeTermsOnly(),
+                                                               getOptions().isSearchWithRegex(),
+                                                               isShowDomainArchitectures(),
+                                                               tp != null ? Math.pow( 10, tp
+                                                                       .getDomainStructureEvalueThresholdExp() ) : 0 ) );
+                }
+            }
+            if ( getOptions().isInverseSearchResult() ) {
+                final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
+                all.removeAll( nodes );
+                nodes = new HashSet<PhylogenyNode>();
+                nodes.addAll( all );
+            }
         }
-        p.add( jcb, "Center" );
-        jcb.addActionListener( this );
-    }
-
-    void addJTextField( final JTextField tf, final JPanel p ) {
-        if ( !_configuration.isUseNativeUI() ) {
-            tf.setForeground( getConfiguration().getGuiBackgroundColor() );
-            tf.setFont( ControlPanel.jcb_font );
+        if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
+            main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet<Long>() );
+            for( final PhylogenyNode node : nodes ) {
+                main_panel.getCurrentTreePanel().getFoundNodes1().add( node.getId() );
+            }
+            setSearchFoundCountsOnLabel1( nodes.size() );
+        }
+        else {
+            setSearchFoundCountsOnLabel1( 0 );
+            searchReset1();
         }
-        p.add( tf );
-        tf.addActionListener( this );
     }
 
-    void deactivateButtonToReturnToSuperTree() {
-        _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
-        _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
-        _return_to_super_tree.setEnabled( false );
+    private void setDrawPhylogram( final int index, final boolean b ) {
+        getIsDrawPhylogramList().set( index, b );
     }
 
-    void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
-        if ( ( _mainpanel != null )
-                && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
-            if ( getOptions().isShowOverview() ) {
-                _mainpanel.getCurrentTreePanel().updateOvSizes();
+    private void setupClickToOptions() {
+        final int default_option = _configuration.getDefaultDisplayClicktoOption();
+        int selected_index = 0;
+        int cb_index = 0;
+        if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
+            _show_data_item = cb_index;
+            addClickToOption( Configuration.display_node_data,
+                              _configuration.getClickToTitle( Configuration.display_node_data ) );
+            if ( default_option == Configuration.display_node_data ) {
+                selected_index = cb_index;
             }
-            _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
-            setVisibilityOfDomainStrucureControls();
-            updateDomainStructureEvaluethresholdDisplay();
-            _mainpanel.getCurrentTreePanel().calculateScaleDistance();
-            _mainpanel.getCurrentTreePanel().calcMaxDepth();
-            _mainpanel.adjustJScrollPane();
-            if ( recalc_longest_ext_node_info ) {
-                _mainpanel.getCurrentTreePanel().initNodeData();
-                _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
+            cb_index++;
+        }
+        if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
+            _collapse_cb_item = cb_index;
+            addClickToOption( Configuration.collapse_uncollapse,
+                              _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
+            if ( default_option == Configuration.collapse_uncollapse ) {
+                selected_index = cb_index;
             }
-            _mainpanel.getCurrentTreePanel().repaint();
-            // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
+            cb_index++;
         }
+        if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
+            _reroot_cb_item = cb_index;
+            addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
+            if ( default_option == Configuration.reroot ) {
+                selected_index = cb_index;
+            }
+            cb_index++;
+        }
+        if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
+            _subtree_cb_item = cb_index;
+            addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
+            if ( default_option == Configuration.subtree ) {
+                selected_index = cb_index;
+            }
+            cb_index++;
+        }
+        if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
+            _swap_cb_item = cb_index;
+            addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
+            if ( default_option == Configuration.swap ) {
+                selected_index = cb_index;
+            }
+            cb_index++;
+        }
+        if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
+            _sort_descendents_item = cb_index;
+            addClickToOption( Configuration.sort_descendents,
+                              _configuration.getClickToTitle( Configuration.sort_descendents ) );
+            if ( default_option == Configuration.sort_descendents ) {
+                selected_index = cb_index;
+            }
+            cb_index++;
+        }
+        if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) {
+            _color_node_font_item = cb_index;
+            addClickToOption( Configuration.color_node_font,
+                              _configuration.getClickToTitle( Configuration.color_node_font ) );
+            if ( default_option == Configuration.color_node_font ) {
+                selected_index = cb_index;
+            }
+            cb_index++;
+        }
+        if ( _configuration.doDisplayClickToOption( Configuration.change_node_font ) ) {
+            _change_node_font_item = cb_index;
+            addClickToOption( Configuration.change_node_font,
+                              _configuration.getClickToTitle( Configuration.change_node_font ) );
+            if ( default_option == Configuration.change_node_font ) {
+                selected_index = cb_index;
+            }
+            cb_index++;
+        }
+        if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
+            _color_subtree_cb_item = cb_index;
+            addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
+            if ( default_option == Configuration.color_subtree ) {
+                selected_index = cb_index;
+            }
+            cb_index++;
+        }
+        if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
+            _open_seq_web_item = cb_index;
+            addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
+            if ( default_option == Configuration.open_seq_web ) {
+                selected_index = cb_index;
+            }
+            cb_index++;
+        }
+        if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
+            _open_pdb_item = cb_index;
+            addClickToOption( Configuration.open_pdb_web, _configuration.getClickToTitle( Configuration.open_pdb_web ) );
+            if ( default_option == Configuration.open_pdb_web ) {
+                selected_index = cb_index;
+            }
+            cb_index++;
+        }
+        if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
+            _open_tax_web_item = cb_index;
+            addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
+            if ( default_option == Configuration.open_tax_web ) {
+                selected_index = cb_index;
+            }
+            cb_index++;
+        }
+        if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
+            _blast_item = cb_index;
+            addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
+            if ( default_option == Configuration.blast ) {
+                selected_index = cb_index;
+            }
+            cb_index++;
+        }
+        if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
+            _select_nodes_item = cb_index;
+            addClickToOption( Configuration.select_nodes, _configuration.getClickToTitle( Configuration.select_nodes ) );
+            if ( default_option == Configuration.select_nodes ) {
+                selected_index = cb_index;
+            }
+            cb_index++;
+        }
+        if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
+            _get_ext_desc_data = cb_index;
+            if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
+                addClickToOption( Configuration.get_ext_desc_data, getConfiguration()
+                        .getLabelForGetExtDescendentsData() );
+            }
+            else {
+                addClickToOption( Configuration.get_ext_desc_data,
+                                  getConfiguration().getClickToTitle( Configuration.get_ext_desc_data ) );
+            }
+            if ( default_option == Configuration.get_ext_desc_data ) {
+                selected_index = cb_index;
+            }
+            cb_index++;
+        }
+        if ( getOptions().isEditable() ) {
+            if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
+                _cut_subtree_item = cb_index;
+                addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
+                if ( default_option == Configuration.cut_subtree ) {
+                    selected_index = cb_index;
+                }
+                cb_index++;
+            }
+            if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
+                _copy_subtree_item = cb_index;
+                addClickToOption( Configuration.copy_subtree,
+                                  _configuration.getClickToTitle( Configuration.copy_subtree ) );
+                if ( default_option == Configuration.copy_subtree ) {
+                    selected_index = cb_index;
+                }
+                cb_index++;
+            }
+            if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
+                _paste_subtree_item = cb_index;
+                addClickToOption( Configuration.paste_subtree,
+                                  _configuration.getClickToTitle( Configuration.paste_subtree ) );
+                if ( default_option == Configuration.paste_subtree ) {
+                    selected_index = cb_index;
+                }
+                cb_index++;
+            }
+            if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
+                _delete_node_or_subtree_item = cb_index;
+                addClickToOption( Configuration.delete_subtree_or_node,
+                                  _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
+                if ( default_option == Configuration.delete_subtree_or_node ) {
+                    selected_index = cb_index;
+                }
+                cb_index++;
+            }
+            if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
+                _add_new_node_item = cb_index;
+                addClickToOption( Configuration.add_new_node,
+                                  _configuration.getClickToTitle( Configuration.add_new_node ) );
+                if ( default_option == Configuration.add_new_node ) {
+                    selected_index = cb_index;
+                }
+                cb_index++;
+            }
+            if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
+                _edit_node_data_item = cb_index;
+                addClickToOption( Configuration.edit_node_data,
+                                  _configuration.getClickToTitle( Configuration.edit_node_data ) );
+                if ( default_option == Configuration.edit_node_data ) {
+                    selected_index = cb_index;
+                }
+                cb_index++;
+            }
+        }
+        // Set default selection and its action
+        _click_to_combobox.setSelectedIndex( selected_index );
+        setClickToAction( selected_index );
     }
 
-    void endClickToOptions() {
-        _click_to_combobox.addActionListener( this );
-    }
-
-    /**
-     * Indicates what action should be execute when a node is clicked
-     *
-     * @return the click-on action
-     */
-    NodeClickAction getActionWhenNodeClicked() {
-        return _action_when_node_clicked;
-    }
-
-    Map<Integer, String> getAllClickToItems() {
-        return _all_click_to_names;
-    }
-
-    Map<String, Color> getAnnotationColors() {
-        return _annotation_colors;
-    }
-
-    Configuration getConfiguration() {
-        return _configuration;
-    }
-
-    TreePanel getCurrentTreePanel() {
-        return getMainPanel().getCurrentTreePanel();
-    }
-
-    MainPanel getMainPanel() {
-        return _mainpanel;
-    }
-
-    Options getOptions() {
-        return getMainPanel().getOptions();
-    }
-
-    JLabel getSearchFoundCountsLabel0() {
-        return _search_found_label_0;
-    }
-
-    JLabel getSearchFoundCountsLabel1() {
-        return _search_found_label_1;
-    }
-
-    JButton getSearchResetButton0() {
-        return _search_reset_button_0;
-    }
-
-    JButton getSearchResetButton1() {
-        return _search_reset_button_1;
-    }
-
-    JTextField getSearchTextField0() {
-        return _search_tf_0;
-    }
-
-    JTextField getSearchTextField1() {
-        return _search_tf_1;
-    }
-
-    List<String> getSingleClickToNames() {
-        return _click_to_names;
-    }
-
-    Map<String, Color> getSpeciesColors() {
-        return _species_colors;
-    }
-
-    Map<String, Color> getSequenceColors() {
-        return _sequence_colors;
-    }
-
-    boolean isAntialiasScreenText() {
-        return true;
-    }
-
-    boolean isColorAccordingToAnnotation() {
-        return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
-    }
-
-    boolean isColorAccordingToTaxonomy() {
-        return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
-    }
-
-    boolean isColorAccordingToSequence() {
-        return ( ( _color_acc_sequence != null ) && _color_acc_sequence.isSelected() );
-    }
-
-    boolean isUseVisualStyles() {
-        return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() ) || ( ( getUseVisualStylesCb() == null ) && _color_branches ) );
-    }
-
-    boolean isDrawPhylogram() {
-        return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
-    }
-
-    boolean isDynamicallyHideData() {
-        return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
-    }
-
-    boolean isEvents() {
-        return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
-    }
-
-    boolean isNodeDescPopup() {
-        return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
-    }
-
-    boolean isShowAnnotation() {
-        return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
-    }
-
-    boolean isShowBinaryCharacterCounts() {
-        return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
-    }
-
-    boolean isShowBinaryCharacters() {
-        return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
-    }
-
-    boolean isShowConfidenceValues() {
-        return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
-    }
-
-    boolean isWriteBranchLengthValues() {
-        return ( ( _write_branch_length_values != null ) && _write_branch_length_values.isSelected() );
-    }
-
-    boolean isShowDomainArchitectures() {
-        return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
-    }
-
-    public boolean isShowMolSequences() {
-        return ( ( _show_mol_seqs != null ) && _show_mol_seqs.isSelected() );
-    }
-
-    boolean isShowGeneNames() {
-        return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
-    }
-
-    boolean isShowInternalData() {
-        return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
-    }
-
-    boolean isShowNodeNames() {
-        return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
-    }
-
-    boolean isShowSeqNames() {
-        return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
-    }
-
-    boolean isShowSeqSymbols() {
-        return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
-    }
-
-    boolean isShowSequenceAcc() {
-        return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
-    }
-
-    boolean isShowSequenceRelationConfidence() {
-        return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
-    }
-
-    boolean isShowSequenceRelations() {
-        return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
-    }
-
-    boolean isShowTaxonomyCode() {
-        return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
-    }
-
-    boolean isShowTaxonomyCommonNames() {
-        return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
-    }
-
-    boolean isShowTaxonomyScientificNames() {
-        return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
-    }
-
-    boolean isWidthBranches() {
-        return ( ( _width_branches != null ) && _width_branches.isSelected() );
-    }
-
-    void phylogenyAdded( final Configuration configuration ) {
-        getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
+    private void setupDisplayCheckboxes() {
+        if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
+            addCheckbox( Configuration.display_as_phylogram,
+                         _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
+            setCheckbox( Configuration.display_as_phylogram,
+                         _configuration.doCheckOption( Configuration.display_as_phylogram ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
+            addCheckbox( Configuration.dynamically_hide_data,
+                         _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
+            setCheckbox( Configuration.dynamically_hide_data,
+                         _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
+            addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
+            setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
+            addCheckbox( Configuration.display_internal_data,
+                         _configuration.getDisplayTitle( Configuration.display_internal_data ) );
+            setCheckbox( Configuration.display_internal_data,
+                         _configuration.doCheckOption( Configuration.display_internal_data ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.color_according_to_sequence ) ) {
+            addCheckbox( Configuration.color_according_to_sequence,
+                         _configuration.getDisplayTitle( Configuration.color_according_to_sequence ) );
+            setCheckbox( Configuration.color_according_to_sequence,
+                         _configuration.doCheckOption( Configuration.color_according_to_sequence ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
+            addCheckbox( Configuration.color_according_to_species,
+                         _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
+            setCheckbox( Configuration.color_according_to_species,
+                         _configuration.doCheckOption( Configuration.color_according_to_species ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
+            addCheckbox( Configuration.color_according_to_annotation,
+                         _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
+            setCheckbox( Configuration.color_according_to_annotation,
+                         _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.use_style ) ) {
+            addCheckbox( Configuration.use_style, _configuration.getDisplayTitle( Configuration.use_style ) );
+            setCheckbox( Configuration.use_style, _configuration.doCheckOption( Configuration.use_style ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
+            addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
+            setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
+        }
+        final JLabel label = new JLabel( "Display Data:" );
+        label.setFont( ControlPanel.jcb_bold_font );
+        if ( !getConfiguration().isUseNativeUI() ) {
+            label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
+        }
+        add( label );
+        if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
+            addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
+            setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
+            addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
+            setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
+            addCheckbox( Configuration.show_taxonomy_scientific_names,
+                         _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
+            setCheckbox( Configuration.show_taxonomy_scientific_names,
+                         _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
+            addCheckbox( Configuration.show_taxonomy_common_names,
+                         _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
+            setCheckbox( Configuration.show_taxonomy_common_names,
+                         _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
+            addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
+            setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
+            addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
+            setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
+            addCheckbox( Configuration.show_seq_symbols,
+                         _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
+            setCheckbox( Configuration.show_seq_symbols, _configuration.doCheckOption( Configuration.show_seq_symbols ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
+            addCheckbox( Configuration.show_sequence_acc,
+                         _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
+            setCheckbox( Configuration.show_sequence_acc,
+                         _configuration.doCheckOption( Configuration.show_sequence_acc ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
+            addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
+            setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
+            addCheckbox( Configuration.write_confidence_values,
+                         _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
+            setCheckbox( Configuration.write_confidence_values,
+                         _configuration.doCheckOption( Configuration.write_confidence_values ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.write_branch_length_values ) ) {
+            addCheckbox( Configuration.write_branch_length_values,
+                         _configuration.getDisplayTitle( Configuration.write_branch_length_values ) );
+            setCheckbox( Configuration.write_branch_length_values,
+                         _configuration.doCheckOption( Configuration.write_branch_length_values ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
+            addCheckbox( Configuration.show_binary_characters,
+                         _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
+            setCheckbox( Configuration.show_binary_characters,
+                         _configuration.doCheckOption( Configuration.show_binary_characters ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
+            addCheckbox( Configuration.show_binary_character_counts,
+                         _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
+            setCheckbox( Configuration.show_binary_character_counts,
+                         _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
+            addCheckbox( Configuration.show_domain_architectures,
+                         _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
+            setCheckbox( Configuration.show_domain_architectures,
+                         _configuration.doCheckOption( Configuration.show_domain_architectures ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.show_mol_seqs ) ) {
+            addCheckbox( Configuration.show_mol_seqs, _configuration.getDisplayTitle( Configuration.show_mol_seqs ) );
+            setCheckbox( Configuration.show_mol_seqs, _configuration.doCheckOption( Configuration.show_mol_seqs ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
+            addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
+            setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
+            addCheckbox( Configuration.show_vector_data,
+                         _configuration.getDisplayTitle( Configuration.show_vector_data ) );
+            setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
+            addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
+            setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
+        }
+        if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
+            addCheckbox( Configuration.show_taxonomy_images,
+                         _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
+            setCheckbox( Configuration.show_taxonomy_images,
+                         _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
+        }
     }
 
-    void phylogenyRemoved( final int index ) {
-        getIsDrawPhylogramList().remove( index );
+    private void setVisibilityOfDomainStrucureControls() {
+        if ( _zoom_in_domain_structure != null ) {
+            final MainFrame mf = getMainFrame();
+            if ( mf != null ) {
+                if ( isShowDomainArchitectures() ) {
+                    _domain_display_label.setVisible( true );
+                    _zoom_in_domain_structure.setVisible( true );
+                    _zoom_out_domain_structure.setVisible( true );
+                    _decr_domain_structure_evalue_thr.setVisible( true );
+                    _incr_domain_structure_evalue_thr.setVisible( true );
+                    _domain_structure_evalue_thr_tf.setVisible( true );
+                    if ( mf._right_line_up_domains_cbmi != null ) {
+                        mf._right_line_up_domains_cbmi.setVisible( true );
+                    }
+                    if ( mf._show_domain_labels != null ) {
+                        mf._show_domain_labels.setVisible( true );
+                    }
+                }
+                else {
+                    _domain_display_label.setVisible( false );
+                    _zoom_in_domain_structure.setVisible( false );
+                    _zoom_out_domain_structure.setVisible( false );
+                    _decr_domain_structure_evalue_thr.setVisible( false );
+                    _incr_domain_structure_evalue_thr.setVisible( false );
+                    _domain_structure_evalue_thr_tf.setVisible( false );
+                    if ( mf._right_line_up_domains_cbmi != null ) {
+                        mf._right_line_up_domains_cbmi.setVisible( false );
+                    }
+                    if ( mf._show_domain_labels != null ) {
+                        mf._show_domain_labels.setVisible( false );
+                    }
+                }
+            }
+        }
     }
 
-    void search0() {
-        final MainPanel main_panel = getMainPanel();
-        final Phylogeny tree = main_panel.getCurrentPhylogeny();
-        if ( ( tree == null ) || tree.isEmpty() ) {
-            return;
-        }
-        String query = getSearchTextField0().getText();
-        if ( query != null ) {
-            query = query.trim();
-        }
-        if ( !ForesterUtil.isEmpty( query ) ) {
-            search0( main_panel, tree, query );
+    void activateButtonToReturnToSuperTree( int index ) {
+        --index;
+        if ( index > 0 ) {
+            _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
         }
         else {
-            getSearchFoundCountsLabel0().setVisible( false );
-            getSearchResetButton0().setEnabled( false );
-            getSearchResetButton0().setVisible( false );
-            searchReset0();
+            _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
         }
+        _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
+        _return_to_super_tree.setEnabled( true );
     }
 
-    void search1() {
-        final MainPanel main_panel = getMainPanel();
-        final Phylogeny tree = main_panel.getCurrentPhylogeny();
-        if ( ( tree == null ) || tree.isEmpty() ) {
-            return;
-        }
-        String query = getSearchTextField1().getText();
-        if ( query != null ) {
-            query = query.trim();
+    /**
+     * Add zoom and quick edit buttons. (Last modified 8/9/04)
+     */
+    void addButtons() {
+        final JLabel spacer = new JLabel( "" );
+        spacer.setOpaque( false );
+        add( spacer );
+        final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
+        final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
+        final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
+        if ( !getConfiguration().isUseNativeUI() ) {
+            x_panel.setBackground( getBackground() );
+            y_panel.setBackground( getBackground() );
+            z_panel.setBackground( getBackground() );
         }
-        if ( !ForesterUtil.isEmpty( query ) ) {
-            search1( main_panel, tree, query );
+        add( _zoom_label = new JLabel( "Zoom:" ) );
+        customizeLabel( _zoom_label, getConfiguration() );
+        add( x_panel );
+        add( y_panel );
+        add( z_panel );
+        if ( getConfiguration().isUseNativeUI() ) {
+            _zoom_in_x = new JButton( "+" );
+            _zoom_out_x = new JButton( "-" );
         }
         else {
-            getSearchFoundCountsLabel1().setVisible( false );
-            getSearchResetButton1().setEnabled( false );
-            getSearchResetButton1().setVisible( false );
-            searchReset1();
+            _zoom_in_x = new JButton( "X+" );
+            _zoom_out_x = new JButton( "X-" );
         }
-    }
-
-    void searchReset0() {
-        if ( getMainPanel().getCurrentTreePanel() != null ) {
-            getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
+        _zoom_in_y = new JButton( "Y+" );
+        _zoom_out_y = new JButton( "Y-" );
+        _show_whole = new JButton( "F" );
+        _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [F or Home]" );
+        _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+cursor-right]" );
+        _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+cursor-up]" );
+        _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+cursor-left]" );
+        _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+cursor-down]" );
+        if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) {
+            _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
+            _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
         }
-    }
-
-    void searchReset1() {
-        if ( getMainPanel().getCurrentTreePanel() != null ) {
-            getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
+        else {
+            _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
+            _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
         }
+        _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
+        _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
+        _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
+        _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
+        _return_to_super_tree.setEnabled( false );
+        _order = new JButton( "Order Subtrees" );
+        _uncollapse_all = new JButton( "Uncollapse All" );
+        addJButton( _zoom_in_y, x_panel );
+        addJButton( _zoom_out_x, y_panel );
+        addJButton( _show_whole, y_panel );
+        addJButton( _zoom_in_x, y_panel );
+        addJButton( _zoom_out_y, z_panel );
+        if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
+            setUpControlsForDomainStrucures();
+        }
+        final JLabel spacer2 = new JLabel( "" );
+        add( spacer2 );
+        addJButton( _return_to_super_tree, this );
+        addJButton( _order, this );
+        addJButton( _uncollapse_all, this );
+        final JLabel spacer3 = new JLabel( "" );
+        add( spacer3 );
+        setVisibilityOfDomainStrucureControls();
     }
 
-    void setActionWhenNodeClicked( final NodeClickAction action ) {
-        _action_when_node_clicked = action;
-    }
-
-    void setAnnotationColors( final Map<String, Color> annotation_colors ) {
-        _annotation_colors = annotation_colors;
-    }
-
-    void setCheckbox( final int which, final boolean state ) {
+    void addCheckbox( final int which, final String title ) {
+        final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
         switch ( which ) {
             case Configuration.display_as_phylogram:
-                if ( getDisplayAsPhylogramCb() != null ) {
-                    getDisplayAsPhylogramCb().setSelected( state );
-                }
+                _display_as_phylogram_cb = new JCheckBox( title );
+                getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
+                addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.display_internal_data:
-                if ( _display_internal_data != null ) {
-                    _display_internal_data.setSelected( state );
-                }
+                _display_internal_data = new JCheckBox( title );
+                _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
+                addJCheckBox( _display_internal_data, ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.color_according_to_species:
-                if ( _color_acc_species != null ) {
-                    _color_acc_species.setSelected( state );
-                }
+                _color_acc_species = new JCheckBox( title );
+                _color_acc_species.setToolTipText( "To colorize node labels as a function of taxonomy" );
+                addJCheckBox( _color_acc_species, ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.color_according_to_sequence:
-                if ( _color_acc_sequence != null ) {
-                    _color_acc_sequence.setSelected( state );
-                }
+                _color_acc_sequence = new JCheckBox( title );
+                _color_acc_sequence.setToolTipText( "To colorize node labels as a function of sequence name" );
+                addJCheckBox( _color_acc_sequence, ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.color_according_to_annotation:
-                if ( _color_according_to_annotation != null ) {
-                    _color_according_to_annotation.setSelected( state );
-                }
+                _color_according_to_annotation = new JCheckBox( title );
+                _color_according_to_annotation
+                .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
+                addJCheckBox( _color_according_to_annotation, ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.show_node_names:
-                if ( _show_node_names != null ) {
-                    _show_node_names.setSelected( state );
-                }
+                _show_node_names = new JCheckBox( title );
+                addJCheckBox( _show_node_names, ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.show_taxonomy_scientific_names:
-                if ( _show_taxo_scientific_names != null ) {
-                    _show_taxo_scientific_names.setSelected( state );
-                }
+                _show_taxo_scientific_names = new JCheckBox( title );
+                addJCheckBox( _show_taxo_scientific_names, ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.show_taxonomy_common_names:
-                if ( _show_taxo_common_names != null ) {
-                    _show_taxo_common_names.setSelected( state );
-                }
+                _show_taxo_common_names = new JCheckBox( title );
+                addJCheckBox( _show_taxo_common_names, ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.show_tax_code:
-                if ( _show_taxo_code != null ) {
-                    _show_taxo_code.setSelected( state );
-                }
+                _show_taxo_code = new JCheckBox( title );
+                addJCheckBox( _show_taxo_code, ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.show_taxonomy_images:
-                if ( _show_taxo_images_cb != null ) {
-                    _show_taxo_images_cb.setSelected( state );
-                }
-                break;
-            case Configuration.show_annotation:
-                if ( _show_annotation != null ) {
-                    _show_annotation.setSelected( state );
-                }
+                _show_taxo_images_cb = new JCheckBox( title );
+                addJCheckBox( _show_taxo_images_cb, ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.show_binary_characters:
-                if ( _show_binary_characters != null ) {
-                    _show_binary_characters.setSelected( state );
-                }
+                _show_binary_characters = new JCheckBox( title );
+                addJCheckBox( _show_binary_characters, ch_panel );
+                add( ch_panel );
+                break;
+            case Configuration.show_annotation:
+                _show_annotation = new JCheckBox( title );
+                addJCheckBox( _show_annotation, ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.show_binary_character_counts:
-                if ( _show_binary_character_counts != null ) {
-                    _show_binary_character_counts.setSelected( state );
-                }
+                _show_binary_character_counts = new JCheckBox( title );
+                addJCheckBox( _show_binary_character_counts, ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.write_confidence_values:
-                if ( getWriteConfidenceCb() != null ) {
-                    getWriteConfidenceCb().setSelected( state );
-                }
+                _write_confidence = new JCheckBox( title );
+                addJCheckBox( getWriteConfidenceCb(), ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.write_events:
-                if ( getShowEventsCb() != null ) {
-                    getShowEventsCb().setSelected( state );
-                }
+                _show_events = new JCheckBox( title );
+                addJCheckBox( getShowEventsCb(), ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.use_style:
-                if ( getUseVisualStylesCb() != null ) {
-                    getUseVisualStylesCb().setSelected( state );
-                }
+                _use_visual_styles_cb = new JCheckBox( title );
+                getUseVisualStylesCb()
+                .setToolTipText( "To use visual styles (node colors, fonts) and branch colors, if present" );
+                addJCheckBox( getUseVisualStylesCb(), ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.width_branches:
-                if ( _width_branches != null ) {
-                    _width_branches.setSelected( state );
-                }
-                break;
-            case Configuration.show_domain_architectures:
-                if ( _show_domain_architectures != null ) {
-                    _show_domain_architectures.setSelected( state );
-                }
+                _width_branches = new JCheckBox( title );
+                _width_branches.setToolTipText( "To use branch width values, if present" );
+                addJCheckBox( _width_branches, ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.write_branch_length_values:
-                if ( _write_branch_length_values != null ) {
-                    _write_branch_length_values.setSelected( state );
-                }
+                _write_branch_length_values = new JCheckBox( title );
+                addJCheckBox( _write_branch_length_values, ch_panel );
+                add( ch_panel );
+                break;
+            case Configuration.show_domain_architectures:
+                _show_domain_architectures = new JCheckBox( title );
+                addJCheckBox( _show_domain_architectures, ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.show_mol_seqs:
-                if ( _show_mol_seqs != null ) {
-                    _show_mol_seqs.setSelected( state );
-                }
+                _show_mol_seqs = new JCheckBox( title );
+                addJCheckBox( _show_mol_seqs, ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.show_seq_names:
-                if ( _show_seq_names != null ) {
-                    _show_seq_names.setSelected( state );
-                }
+                _show_seq_names = new JCheckBox( title );
+                addJCheckBox( _show_seq_names, ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.show_gene_names:
-                if ( _show_gene_names != null ) {
-                    _show_gene_names.setSelected( state );
-                }
+                _show_gene_names = new JCheckBox( title );
+                addJCheckBox( _show_gene_names, ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.show_seq_symbols:
-                if ( _show_seq_symbols != null ) {
-                    _show_seq_symbols.setSelected( state );
-                }
-                break;
-            case Configuration.show_vector_data:
-                if ( _show_vector_data_cb != null ) {
-                    _show_vector_data_cb.setSelected( state );
-                }
-                break;
-            case Configuration.show_properties:
-                if ( _show_properties_cb != null ) {
-                    _show_properties_cb.setSelected( state );
-                }
+                _show_seq_symbols = new JCheckBox( title );
+                addJCheckBox( _show_seq_symbols, ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.show_sequence_acc:
-                if ( _show_sequence_acc != null ) {
-                    _show_sequence_acc.setSelected( state );
-                }
+                _show_sequence_acc = new JCheckBox( title );
+                addJCheckBox( _show_sequence_acc, ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.dynamically_hide_data:
-                if ( getDynamicallyHideData() != null ) {
-                    getDynamicallyHideData().setSelected( state );
-                }
+                _dynamically_hide_data = new JCheckBox( title );
+                getDynamicallyHideData().setToolTipText( "To hide labels depending on expected visibility" );
+                addJCheckBox( getDynamicallyHideData(), ch_panel );
+                add( ch_panel );
                 break;
             case Configuration.node_data_popup:
-                if ( getNodeDescPopupCb() != null ) {
-                    getNodeDescPopupCb().setSelected( state );
-                }
+                _node_desc_popup_cb = new JCheckBox( title );
+                getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
+                addJCheckBox( getNodeDescPopupCb(), ch_panel );
+                add( ch_panel );
+                break;
+            case Configuration.show_relation_confidence:
+                _seq_relation_confidence_switch = new JCheckBox( title );
+                addJCheckBox( _seq_relation_confidence_switch, ch_panel );
+                add( ch_panel );
+                break;
+            case Configuration.show_vector_data:
+                _show_vector_data_cb = new JCheckBox( title );
+                addJCheckBox( _show_vector_data_cb, ch_panel );
+                add( ch_panel );
                 break;
-            /* GUILHEM_BEG */
-            case Configuration.show_relation_confidence:
-                if ( _seq_relation_confidence_switch != null ) {
-                    _seq_relation_confidence_switch.setSelected( state );
-                }
+            case Configuration.show_properties:
+                _show_properties_cb = new JCheckBox( title );
+                addJCheckBox( _show_properties_cb, ch_panel );
+                add( ch_panel );
                 break;
-            /* GUILHEM_END */
             default:
-                throw new AssertionError( "unknown checkbox: " + which );
+                throw new RuntimeException( "unknown checkbox: " + which );
         }
-    }
+    }// addCheckbox
 
-    /**
-     * Set this checkbox state. Not all checkboxes have been instantiated
-     * depending on the config.
-     */
-    void setCheckbox( final JCheckBox cb, final boolean state ) {
-        if ( cb != null ) {
-            cb.setSelected( state );
+    void addJButton( final JButton jb, final JPanel p ) {
+        jb.setFocusPainted( false );
+        jb.setFont( ControlPanel.jcb_font );
+        if ( !_configuration.isUseNativeUI() ) {
+            jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
+            jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
+            jb.setForeground( getConfiguration().getGuiButtonTextColor() );
         }
+        p.add( jb );
+        jb.addActionListener( this );
     }
 
-    void setClickToAction( final int action ) {
-        // Set click-to action
-        if ( action == _show_data_item ) {
-            setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
-        }
-        else if ( action == _collapse_cb_item ) {
-            setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
-        }
-        else if ( action == _reroot_cb_item ) {
-            setActionWhenNodeClicked( NodeClickAction.REROOT );
-        }
-        else if ( action == _subtree_cb_item ) {
-            setActionWhenNodeClicked( NodeClickAction.SUBTREE );
-        }
-        else if ( action == _swap_cb_item ) {
-            setActionWhenNodeClicked( NodeClickAction.SWAP );
-        }
-        else if ( action == _color_subtree_cb_item ) {
-            setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
-        }
-        else if ( action == _open_seq_web_item ) {
-            setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
-        }
-        else if ( action == _sort_descendents_item ) {
-            setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
-        }
-        else if ( action == _blast_item ) {
-            setActionWhenNodeClicked( NodeClickAction.BLAST );
-        }
-        else if ( action == _open_tax_web_item ) {
-            setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
-        }
-        else if ( action == _cut_subtree_item ) {
-            setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
-        }
-        else if ( action == _copy_subtree_item ) {
-            setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
-        }
-        else if ( action == _delete_node_or_subtree_item ) {
-            setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
-        }
-        else if ( action == _paste_subtree_item ) {
-            setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
-        }
-        else if ( action == _add_new_node_item ) {
-            setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
-        }
-        else if ( action == _edit_node_data_item ) {
-            setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
-        }
-        else if ( action == _select_nodes_item ) {
-            setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
-        }
-        else if ( action == _get_ext_desc_data ) {
-            setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
-        }
-        else if ( action == _open_pdb_item ) {
-            setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
-        }
-        else if ( action == _color_node_font_item ) {
-            setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
+    void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
+        jcb.setFocusPainted( false );
+        jcb.setFont( ControlPanel.jcb_font );
+        if ( !_configuration.isUseNativeUI() ) {
+            jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
+            jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
         }
-        else if ( action == _change_node_font_item ) {
-            setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT );
+        p.add( jcb, "Center" );
+        jcb.addActionListener( this );
+    }
+
+    void addJTextField( final JTextField tf, final JPanel p ) {
+        if ( !_configuration.isUseNativeUI() ) {
+            tf.setForeground( getConfiguration().getGuiBackgroundColor() );
+            tf.setFont( ControlPanel.jcb_font );
         }
-        else {
-            throw new RuntimeException( "unknown action: " + action );
+        p.add( tf );
+        tf.addActionListener( this );
+    }
+
+    void deactivateButtonToReturnToSuperTree() {
+        _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
+        _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
+        _return_to_super_tree.setEnabled( false );
+    }
+
+    void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
+        if ( ( _mainpanel != null )
+                && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
+            if ( getOptions().isShowOverview() ) {
+                _mainpanel.getCurrentTreePanel().updateOvSizes();
+            }
+            _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
+            setVisibilityOfDomainStrucureControls();
+            updateDomainStructureEvaluethresholdDisplay();
+            _mainpanel.getCurrentTreePanel().calculateScaleDistance();
+            _mainpanel.getCurrentTreePanel().calcMaxDepth();
+            _mainpanel.adjustJScrollPane();
+            if ( recalc_longest_ext_node_info ) {
+                _mainpanel.getCurrentTreePanel().initNodeData();
+                _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
+            }
+            _mainpanel.getCurrentTreePanel().repaint();
+            // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
         }
-        // make sure drop down is displaying the correct action
-        // in case this was called from outside the class
-        _click_to_combobox.setSelectedIndex( action );
     }
 
-    void setColorBranches( final boolean color_branches ) {
-        _color_branches = color_branches;
+    void endClickToOptions() {
+        _click_to_combobox.addActionListener( this );
     }
 
-    void setDrawPhylogram( final boolean b ) {
-        getDisplayAsPhylogramCb().setSelected( b );
-        setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
+    /**
+     * Indicates what action should be execute when a node is clicked
+     *
+     * @return the click-on action
+     */
+    NodeClickAction getActionWhenNodeClicked() {
+        return _action_when_node_clicked;
     }
 
-    void setDrawPhylogramEnabled( final boolean b ) {
-        getDisplayAsPhylogramCb().setEnabled( b );
+    Map<Integer, String> getAllClickToItems() {
+        return _all_click_to_names;
     }
 
-    void setDynamicHidingIsOn( final boolean is_on ) {
-        if ( is_on ) {
-            getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
-        }
-        else {
-            if ( !_configuration.isUseNativeUI() ) {
-                getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
-            }
-            else {
-                getDynamicallyHideData().setForeground( Color.BLACK );
-            }
-        }
+    Map<String, Color> getAnnotationColors() {
+        return _annotation_colors;
     }
 
-    void setSearchFoundCountsOnLabel0( final int counts ) {
-        getSearchFoundCountsLabel0().setText( "Found: " + counts );
+    Configuration getConfiguration() {
+        return _configuration;
     }
 
-    void setSearchFoundCountsOnLabel1( final int counts ) {
-        getSearchFoundCountsLabel1().setText( "Found: " + counts );
+    TreePanel getCurrentTreePanel() {
+        return getMainPanel().getCurrentTreePanel();
     }
 
-    void setShowEvents( final boolean show_events ) {
-        if ( getShowEventsCb() == null ) {
-            _show_events = new JCheckBox( "" );
-        }
-        getShowEventsCb().setSelected( show_events );
+    MainPanel getMainPanel() {
+        return _mainpanel;
     }
 
-    void setSpeciesColors( final Map<String, Color> species_colors ) {
-        _species_colors = species_colors;
+    Options getOptions() {
+        return getMainPanel().getOptions();
     }
 
-    void setSequenceColors( final Map<String, Color> sequence_colors ) {
-        _sequence_colors = sequence_colors;
+    JLabel getSearchFoundCountsLabel0() {
+        return _search_found_label_0;
     }
 
-    void setupControls() {
-        // The tree display options:
-        setupDisplayCheckboxes();
-        /* GUILHEM_BEG */
-        // The sequence relation query selection combo-box
-        if ( _configuration.displaySequenceRelations() ) {
-            addSequenceRelationBlock();
-        }
-        /* GUILHEM_END */
-        // Click-to options
-        startClickToOptions();
-        setupClickToOptions();
-        endClickToOptions();
-        // Zoom and quick edit buttons
-        addButtons();
-        setupSearchTools0();
-        setupSearchTools1();
+    JLabel getSearchFoundCountsLabel1() {
+        return _search_found_label_1;
     }
 
-    void setUpControlsForDomainStrucures() {
-        _domain_display_label = new JLabel( "Domain Architectures:" );
-        add( customizeLabel( _domain_display_label, getConfiguration() ) );
-        add( _domain_display_label );
-        _zoom_in_domain_structure = new JButton( "d+" );
-        _zoom_out_domain_structure = new JButton( "d-" );
-        _decr_domain_structure_evalue_thr = new JButton( "-" );
-        _incr_domain_structure_evalue_thr = new JButton( "+" );
-        _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
-        _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
-        _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
-        _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
-        _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
-        _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
-        _domain_structure_evalue_thr_tf = new JTextField( 3 );
-        _domain_structure_evalue_thr_tf.setEditable( false );
-        if ( !getConfiguration().isUseNativeUI() ) {
-            _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
-            _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
-            _domain_structure_evalue_thr_tf.setBorder( null );
-        }
-        final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
-        final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
-        if ( !_configuration.isUseNativeUI() ) {
-            d1_panel.setBackground( getBackground() );
-            d2_panel.setBackground( getBackground() );
-        }
-        add( d1_panel );
-        add( d2_panel );
-        addJButton( _zoom_out_domain_structure, d1_panel );
-        addJButton( _zoom_in_domain_structure, d1_panel );
-        addJButton( _decr_domain_structure_evalue_thr, d2_panel );
-        addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
-        addJButton( _incr_domain_structure_evalue_thr, d2_panel );
+    JButton getSearchResetButton0() {
+        return _search_reset_button_0;
+    }
+
+    JButton getSearchResetButton1() {
+        return _search_reset_button_1;
     }
 
-    void setupSearchTools0() {
-        final JLabel search_label = new JLabel( "Search (A):" );
-        search_label.setFont( ControlPanel.jcb_bold_font );
-        if ( !getConfiguration().isUseNativeUI() ) {
-            search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
-        }
-        add( search_label );
-        search_label.setToolTipText( SEARCH_TIP_TEXT );
-        _search_found_label_0 = new JLabel();
-        getSearchFoundCountsLabel0().setVisible( false );
-        _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
-        if ( !getConfiguration().isUseNativeUI() ) {
-            _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
-        }
-        _search_tf_0 = new JTextField( 3 );
-        _search_tf_0.setToolTipText( SEARCH_TIP_TEXT );
-        _search_tf_0.setEditable( true );
-        if ( !getConfiguration().isUseNativeUI() ) {
-            _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
-            _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
-            _search_tf_0.setBorder( null );
-        }
-        _search_reset_button_0 = new JButton();
-        getSearchResetButton0().setText( "Reset" );
-        getSearchResetButton0().setEnabled( false );
-        getSearchResetButton0().setVisible( false );
-        final JPanel s_panel_1 = new JPanel( new BorderLayout() );
-        final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
-        s_panel_1.setBackground( getBackground() );
-        add( s_panel_1 );
-        s_panel_2.setBackground( getBackground() );
-        add( s_panel_2 );
-        final KeyAdapter key_adapter = new KeyAdapter() {
+    JTextField getSearchTextField0() {
+        return _search_tf_0;
+    }
 
-            @Override
-            public void keyReleased( final KeyEvent key_event ) {
-                search0();
-                displayedPhylogenyMightHaveChanged( true );
-            }
-        };
-        final ActionListener action_listener = new ActionListener() {
+    JTextField getSearchTextField1() {
+        return _search_tf_1;
+    }
 
-            @Override
-            public void actionPerformed( final ActionEvent e ) {
-                searchReset0();
-                setSearchFoundCountsOnLabel0( 0 );
-                getSearchFoundCountsLabel0().setVisible( false );
-                getSearchTextField0().setText( "" );
-                getSearchResetButton0().setEnabled( false );
-                getSearchResetButton0().setVisible( false );
-                displayedPhylogenyMightHaveChanged( true );
-            }
-        };
-        _search_reset_button_0.addActionListener( action_listener );
-        _search_tf_0.addKeyListener( key_adapter );
-        addJTextField( _search_tf_0, s_panel_1 );
-        s_panel_2.add( _search_found_label_0 );
-        addJButton( _search_reset_button_0, s_panel_2 );
+    Map<String, Color> getSequenceColors() {
+        return _sequence_colors;
     }
 
-    void setupSearchTools1() {
-        final JLabel search_label = new JLabel( "Search (B):" );
-        search_label.setFont( ControlPanel.jcb_bold_font );
-        if ( !getConfiguration().isUseNativeUI() ) {
-            search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
-        }
-        add( search_label );
-        search_label.setToolTipText( SEARCH_TIP_TEXT );
-        _search_found_label_1 = new JLabel();
-        getSearchFoundCountsLabel1().setVisible( false );
-        _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
-        if ( !getConfiguration().isUseNativeUI() ) {
-            _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
-        }
-        _search_tf_1 = new JTextField( 3 );
-        _search_tf_1.setToolTipText( SEARCH_TIP_TEXT );
-        _search_tf_1.setEditable( true );
-        if ( !getConfiguration().isUseNativeUI() ) {
-            _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
-            _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
-            _search_tf_1.setBorder( null );
-        }
-        _search_reset_button_1 = new JButton();
-        getSearchResetButton1().setText( "Reset" );
-        getSearchResetButton1().setEnabled( false );
-        getSearchResetButton1().setVisible( false );
-        final JPanel s_panel_1 = new JPanel( new BorderLayout() );
-        final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
-        s_panel_1.setBackground( getBackground() );
-        add( s_panel_1 );
-        s_panel_2.setBackground( getBackground() );
-        add( s_panel_2 );
-        final KeyAdapter key_adapter = new KeyAdapter() {
+    List<String> getSingleClickToNames() {
+        return _click_to_names;
+    }
 
-            @Override
-            public void keyReleased( final KeyEvent key_event ) {
-                search1();
-                displayedPhylogenyMightHaveChanged( true );
-            }
-        };
-        final ActionListener action_listener = new ActionListener() {
+    Map<String, Color> getSpeciesColors() {
+        return _species_colors;
+    }
 
-            @Override
-            public void actionPerformed( final ActionEvent e ) {
-                searchReset1();
-                setSearchFoundCountsOnLabel1( 0 );
-                getSearchFoundCountsLabel1().setVisible( false );
-                getSearchTextField1().setText( "" );
-                getSearchResetButton1().setEnabled( false );
-                getSearchResetButton1().setVisible( false );
-                displayedPhylogenyMightHaveChanged( true );
-            }
-        };
-        _search_reset_button_1.addActionListener( action_listener );
-        _search_tf_1.addKeyListener( key_adapter );
-        addJTextField( _search_tf_1, s_panel_1 );
-        s_panel_2.add( _search_found_label_1 );
-        addJButton( _search_reset_button_1, s_panel_2 );
+    boolean isAntialiasScreenText() {
+        return true;
     }
 
-    void showAnnotations() {
-        if ( _show_annotation != null ) {
-            _show_annotation.setSelected( true );
-        }
-        if ( _color_according_to_annotation != null ) {
-            _color_according_to_annotation.setSelected( true );
-        }
-        if ( _color_acc_species != null ) {
-            _color_acc_species.setSelected( false );
-        }
-        if ( _color_acc_sequence != null ) {
-            _color_acc_sequence.setSelected( false );
-        }
-        _mainpanel.getCurrentTreePanel().repaint();
+    boolean isColorAccordingToAnnotation() {
+        return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
     }
 
-    /**
-     * Fit entire tree into window.
-     */
-    void showWhole() {
-        if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
-            return;
-        }
-        getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
-        displayedPhylogenyMightHaveChanged( true );
-        _mainpanel.getCurrentTreePanel().updateOvSettings();
-        _mainpanel.getCurrentTreePanel().validate();
-        _mainpanel.validate();
-        _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
-                                                                    _mainpanel.getSizeOfViewport().height );
-        _mainpanel.getCurrentTreePanel().resetPreferredSize();
-        _mainpanel.adjustJScrollPane();
-        _mainpanel.getCurrentTreePanel().repaint();
-        _mainpanel.getCurrentTreePanel().validate();
-        _mainpanel.validate();
-        _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
-                                                                    _mainpanel.getSizeOfViewport().height );
-        _mainpanel.getCurrentTreePanel().resetPreferredSize();
-        _mainpanel.adjustJScrollPane();
-        _mainpanel.getCurrentTreePanel().repaint();
-        _mainpanel.getCurrentTreePanel().updateOvSizes();
+    boolean isColorAccordingToSequence() {
+        return ( ( _color_acc_sequence != null ) && _color_acc_sequence.isSelected() );
     }
 
-    void showWholeAll() {
-        for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
-            if ( tree_panel != null ) {
-                tree_panel.validate();
-                tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
-                                                      _mainpanel.getSizeOfViewport().height );
-                tree_panel.resetPreferredSize();
-                tree_panel.repaint();
-            }
-        }
+    boolean isColorAccordingToTaxonomy() {
+        return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
     }
 
-    // Create header for click-to combo box.
-    void startClickToOptions() {
-        final JLabel spacer = new JLabel( "" );
-        spacer.setFont( ControlPanel.jcb_font );
-        add( spacer );
-        _click_to_label = new JLabel( "Click on Node to:" );
-        add( customizeLabel( _click_to_label, getConfiguration() ) );
-        _click_to_combobox = new JComboBox<String>();
-        _click_to_combobox.setFocusable( false );
-        _click_to_combobox.setMaximumRowCount( 14 );
-        _click_to_combobox.setFont( ControlPanel.js_font );
-        if ( !_configuration.isUseNativeUI() ) {
-            _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
-        }
-        // don't add listener until all items are set (or each one will trigger
-        // an event)
-        // click_to_list.addActionListener(this);
-        add( _click_to_combobox );
-        // Correlates option names to titles
-        _all_click_to_names = new HashMap<Integer, String>();
-        _click_to_names = new ArrayList<String>();
+    boolean isDrawPhylogram() {
+        return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
     }
 
-    void tabChanged() {
-        if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
-            if ( getCurrentTreePanel().isPhyHasBranchLengths()
-                    && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
-                setDrawPhylogramEnabled( true );
-                setDrawPhylogram( isDrawPhylogram() );
-            }
-            else {
-                setDrawPhylogramEnabled( false );
-                setDrawPhylogram( false );
-            }
-            if ( getMainPanel().getMainFrame() == null ) {
-                // Must be "E" applet version.
-                final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
-                e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
-            }
-            else {
-                getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
-                        .getPhylogenyGraphicsType() );
-            }
-            getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
-            getMainPanel().getControlPanel().search0();
-            getMainPanel().getControlPanel().search1();
-            getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
-            getSequenceRelationTypeBox().removeAllItems();
-            for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
-                    .getRelevantSequenceRelationTypes() ) {
-                _sequence_relation_type_box.addItem( type );
-            }
-            getMainPanel().getCurrentTreePanel().repaint();
-            //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
-            // according to GUILHEM the line above can be removed.
-        }
+    boolean isDynamicallyHideData() {
+        return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
+    }
+
+    boolean isEvents() {
+        return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
+    }
+
+    boolean isNodeDescPopup() {
+        return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
+    }
+
+    boolean isShowAnnotation() {
+        return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
+    }
+
+    boolean isShowBinaryCharacterCounts() {
+        return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
     }
 
-    /**
-     * Uncollapse all nodes.
-     */
-    void uncollapseAll( final TreePanel tp ) {
-        final Phylogeny t = tp.getPhylogeny();
-        if ( ( t != null ) && !t.isEmpty() ) {
-            for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
-                final PhylogenyNode node = iter.next();
-                node.setCollapse( false );
-            }
-            tp.resetNodeIdToDistToLeafMap();
-            tp.updateSetOfCollapsedExternalNodes();
-            t.recalculateNumberOfExternalDescendants( false );
-            tp.setNodeInPreorderToNull();
-            t.clearHashIdToNodeMap();
-            showWhole();
-        }
+    boolean isShowBinaryCharacters() {
+        return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
     }
 
-    void updateDomainStructureEvaluethresholdDisplay() {
-        if ( _domain_structure_evalue_thr_tf != null ) {
-            _domain_structure_evalue_thr_tf.setText( "10^"
-                    + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThresholdExp() );
-        }
+    boolean isShowConfidenceValues() {
+        return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
     }
 
-    void zoomInX( final float factor, final float x_correction_factor ) {
-        final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
-        final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
-        treepanel.multiplyUrtFactor( 1f );
-        if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
-                || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
-                || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
-                || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
-            final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
-            treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
-            treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
-            getMainPanel().adjustJScrollPane();
-            treepanel.resetPreferredSize();
-            getMainPanel().getCurrentScrollPane().getViewport().validate();
-            sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
-                    - ( sb.getVisibleAmount() / 2.0 ) ) );
-        }
-        else {
-            final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
-            treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
-            treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
-            getMainPanel().adjustJScrollPane();
-            treepanel.resetPreferredSize();
-            getMainPanel().getCurrentScrollPane().getViewport().validate();
-            sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
-        }
-        treepanel.resetPreferredSize();
-        treepanel.updateOvSizes();
+    boolean isShowDomainArchitectures() {
+        return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
     }
 
-    void zoomInY( final float factor ) {
-        final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
-        final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
-        treepanel.multiplyUrtFactor( 1.1f );
-        final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
-        treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
-        getMainPanel().adjustJScrollPane();
-        treepanel.resetPreferredSize();
-        getMainPanel().getCurrentScrollPane().getViewport().validate();
-        sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
-                - ( sb.getVisibleAmount() / 2.0 ) ) );
-        treepanel.resetPreferredSize();
-        treepanel.updateOvSizes();
+    boolean isShowGeneNames() {
+        return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
     }
 
-    void zoomOutX( final float factor, final float x_correction_factor ) {
-        final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
-        treepanel.multiplyUrtFactor( 1f );
-        if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
-            final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
-            if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
-                    || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
-                    || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
-                    || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
-                getMainPanel().adjustJScrollPane();
-                treepanel.resetPreferredSize();
-                getMainPanel().getCurrentScrollPane().getViewport().validate();
-                final double x = ( sb.getMaximum() - sb.getMinimum() )
-                        / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
-                treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
-                treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
-                getMainPanel().adjustJScrollPane();
-                treepanel.resetPreferredSize();
-                getMainPanel().getCurrentScrollPane().getViewport().validate();
-                sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
-                        - ( sb.getVisibleAmount() / 2.0 ) ) );
-            }
-            else {
-                final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
-                treepanel.setXdistance( treepanel.getXdistance() * factor );
-                treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
-                if ( x > 0 ) {
-                    getMainPanel().adjustJScrollPane();
-                    treepanel.resetPreferredSize();
-                    getMainPanel().getCurrentScrollPane().getViewport().validate();
-                    sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
-                }
-            }
-            treepanel.resetPreferredSize();
-            treepanel.updateOvSizes();
-        }
+    boolean isShowInternalData() {
+        return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
     }
 
-    void zoomOutY( final float factor ) {
-        final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
-        treepanel.multiplyUrtFactor( 0.9f );
-        if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
-            final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
-            final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
-            treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
-            getMainPanel().adjustJScrollPane();
-            treepanel.resetPreferredSize();
-            getMainPanel().getCurrentScrollPane().getViewport().validate();
-            sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
-                    - ( sb.getVisibleAmount() / 2.0 ) ) );
-            treepanel.resetPreferredSize();
-            treepanel.updateOvSizes();
-        }
+    boolean isShowNodeNames() {
+        return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
     }
 
-    private void addClickToOption( final int which, final String title ) {
-        _click_to_combobox.addItem( title );
-        _click_to_names.add( title );
-        _all_click_to_names.put( new Integer( which ), title );
-        if ( !_configuration.isUseNativeUI() ) {
-            _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
-            _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
-        }
+    boolean isShowSeqNames() {
+        return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
     }
 
-    /* GUILHEM_BEG */
-    private void addSequenceRelationBlock() {
-        final JLabel spacer = new JLabel( "" );
-        spacer.setSize( 1, 1 );
-        add( spacer );
-        final JLabel mainLabel = new JLabel( "Sequence relations to display" );
-        final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
-        typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
-        getSequenceRelationTypeBox().setFocusable( false );
-        _sequence_relation_type_box.setFont( ControlPanel.js_font );
-        if ( !_configuration.isUseNativeUI() ) {
-            _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
-            _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
-        }
-        _sequence_relation_type_box.setRenderer( new ListCellRenderer<Object>() {
+    boolean isShowSeqSymbols() {
+        return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
+    }
 
-            @Override
-            public Component getListCellRendererComponent( final JList<?> list,
-                                                           final Object value,
-                                                           final int index,
-                                                           final boolean isSelected,
-                                                           final boolean cellHasFocus ) {
-                final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
-                                                                                                        value,
-                                                                                                        index,
-                                                                                                        isSelected,
-                                                                                                        cellHasFocus );
-                if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
-                    ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
-                            .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
-                }
-                return component;
-            }
-        } );
-        final GridBagLayout gbl = new GridBagLayout();
-        _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
-        _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
-        final JPanel horizGrid = new JPanel( gbl );
-        horizGrid.setBackground( getBackground() );
-        horizGrid.add( typeLabel );
-        horizGrid.add( _sequence_relation_type_box );
-        add( customizeLabel( mainLabel, getConfiguration() ) );
-        add( horizGrid );
-        add( getSequenceRelationBox() );
-        if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
-            addCheckbox( Configuration.show_relation_confidence,
-                         _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
-            setCheckbox( Configuration.show_relation_confidence,
-                         _configuration.doCheckOption( Configuration.show_relation_confidence ) );
-        }
-    }// addSequenceRelationBlock
+    boolean isShowSequenceAcc() {
+        return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
+    }
 
-    /* GUILHEM_END */
-    private List<Boolean> getIsDrawPhylogramList() {
-        return _draw_phylogram;
+    boolean isShowSequenceRelationConfidence() {
+        return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
     }
 
-    private void init() {
-        _draw_phylogram = new ArrayList<Boolean>();
-        setSpeciesColors( new HashMap<String, Color>() );
-        setSequenceColors( new HashMap<String, Color>() );
-        setAnnotationColors( new HashMap<String, Color>() );
+    boolean isShowSequenceRelations() {
+        return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
     }
 
-    private boolean isDrawPhylogram( final int index ) {
-        return getIsDrawPhylogramList().get( index );
+    boolean isShowTaxonomyCode() {
+        return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
     }
 
-    private void search0( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
-        getSearchFoundCountsLabel0().setVisible( true );
-        getSearchResetButton0().setEnabled( true );
-        getSearchResetButton0().setVisible( true );
-        String[] queries = null;
-        Set<PhylogenyNode> nodes = null;
-        if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
-            queries = query_str.split( ",+" );
-        }
-        else {
-            queries = new String[ 1 ];
-            queries[ 0 ] = query_str.trim();
-        }
-        if ( ( queries != null ) && ( queries.length > 0 ) ) {
-            nodes = new HashSet<PhylogenyNode>();
-            for( String query : queries ) {
-                if ( ForesterUtil.isEmpty( query ) ) {
-                    continue;
-                }
-                query = query.trim();
-                final TreePanel tp = getMainPanel().getCurrentTreePanel();
-                if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
-                    nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
-                                                                         tree,
-                                                                         getOptions().isSearchCaseSensitive(),
-                                                                         !getOptions().isMatchWholeTermsOnly(),
-                                                                         isShowDomainArchitectures(),
-                                                                         tp != null ? Math.pow( 10,
-                                                                                                tp.getDomainStructureEvalueThresholdExp() )
-                                                                                                : 0 ) );
-                }
-                else {
-                    nodes.addAll( PhylogenyMethods.searchData( query,
-                                                               tree,
-                                                               getOptions().isSearchCaseSensitive(),
-                                                               !getOptions().isMatchWholeTermsOnly(),
-                                                               getOptions().isSearchWithRegex(),
-                                                               isShowDomainArchitectures(),
-                                                               tp != null ? Math.pow( 10, tp
-                                                                                      .getDomainStructureEvalueThresholdExp() ) : 0 ) );
-                }
-            }
-            if ( getOptions().isInverseSearchResult() ) {
-                final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
-                all.removeAll( nodes );
-                nodes = new HashSet<PhylogenyNode>();
-                nodes.addAll( all );
-            }
+    boolean isShowTaxonomyCommonNames() {
+        return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
+    }
+
+    boolean isShowTaxonomyScientificNames() {
+        return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
+    }
+
+    boolean isUseVisualStyles() {
+        return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() ) || ( ( getUseVisualStylesCb() == null ) && _color_branches ) );
+    }
+
+    boolean isWidthBranches() {
+        return ( ( _width_branches != null ) && _width_branches.isSelected() );
+    }
+
+    boolean isWriteBranchLengthValues() {
+        return ( ( _write_branch_length_values != null ) && _write_branch_length_values.isSelected() );
+    }
+
+    void phylogenyAdded( final Configuration configuration ) {
+        getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
+    }
+
+    void phylogenyRemoved( final int index ) {
+        getIsDrawPhylogramList().remove( index );
+    }
+
+    void search0() {
+        final MainPanel main_panel = getMainPanel();
+        final Phylogeny tree = main_panel.getCurrentPhylogeny();
+        if ( ( tree == null ) || tree.isEmpty() ) {
+            return;
         }
-        if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
-            main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet<Long>() );
-            for( final PhylogenyNode node : nodes ) {
-                main_panel.getCurrentTreePanel().getFoundNodes0().add( node.getId() );
-            }
-            setSearchFoundCountsOnLabel0( nodes.size() );
+        String query = getSearchTextField0().getText();
+        if ( query != null ) {
+            query = query.trim();
+        }
+        if ( !ForesterUtil.isEmpty( query ) ) {
+            search0( main_panel, tree, query );
         }
         else {
-            setSearchFoundCountsOnLabel0( 0 );
+            getSearchFoundCountsLabel0().setVisible( false );
+            getSearchResetButton0().setEnabled( false );
+            getSearchResetButton0().setVisible( false );
             searchReset0();
         }
     }
 
-    private void search1( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
-        getSearchFoundCountsLabel1().setVisible( true );
-        getSearchResetButton1().setEnabled( true );
-        getSearchResetButton1().setVisible( true );
-        String[] queries = null;
-        Set<PhylogenyNode> nodes = null;
-        if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
-            queries = query_str.split( ",+" );
-        }
-        else {
-            queries = new String[ 1 ];
-            queries[ 0 ] = query_str.trim();
+    void search1() {
+        final MainPanel main_panel = getMainPanel();
+        final Phylogeny tree = main_panel.getCurrentPhylogeny();
+        if ( ( tree == null ) || tree.isEmpty() ) {
+            return;
         }
-        if ( ( queries != null ) && ( queries.length > 0 ) ) {
-            nodes = new HashSet<PhylogenyNode>();
-            for( String query : queries ) {
-                if ( ForesterUtil.isEmpty( query ) ) {
-                    continue;
-                }
-                query = query.trim();
-                final TreePanel tp = getMainPanel().getCurrentTreePanel();
-                if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
-                    nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
-                                                                         tree,
-                                                                         getOptions().isSearchCaseSensitive(),
-                                                                         !getOptions().isMatchWholeTermsOnly(),
-                                                                         isShowDomainArchitectures(),
-                                                                         tp != null ? Math.pow( 10,
-                                                                                                tp.getDomainStructureEvalueThresholdExp() )
-                                                                                                : 0 ) );
-                }
-                else {
-                    nodes.addAll( PhylogenyMethods.searchData( query,
-                                                               tree,
-                                                               getOptions().isSearchCaseSensitive(),
-                                                               !getOptions().isMatchWholeTermsOnly(),
-                                                               getOptions().isSearchWithRegex(),
-                                                               isShowDomainArchitectures(),
-                                                               tp != null ? Math.pow( 10, tp
-                                                                                      .getDomainStructureEvalueThresholdExp() ) : 0 ) );
-                }
-            }
-            if ( getOptions().isInverseSearchResult() ) {
-                final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
-                all.removeAll( nodes );
-                nodes = new HashSet<PhylogenyNode>();
-                nodes.addAll( all );
-            }
+        String query = getSearchTextField1().getText();
+        if ( query != null ) {
+            query = query.trim();
         }
-        if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
-            main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet<Long>() );
-            for( final PhylogenyNode node : nodes ) {
-                main_panel.getCurrentTreePanel().getFoundNodes1().add( node.getId() );
-            }
-            setSearchFoundCountsOnLabel1( nodes.size() );
+        if ( !ForesterUtil.isEmpty( query ) ) {
+            search1( main_panel, tree, query );
         }
         else {
-            setSearchFoundCountsOnLabel1( 0 );
+            getSearchFoundCountsLabel1().setVisible( false );
+            getSearchResetButton1().setEnabled( false );
+            getSearchResetButton1().setVisible( false );
             searchReset1();
         }
     }
 
-    private void setDrawPhylogram( final int index, final boolean b ) {
-        getIsDrawPhylogramList().set( index, b );
+    void searchReset0() {
+        if ( getMainPanel().getCurrentTreePanel() != null ) {
+            getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
+        }
     }
 
-    private void setupClickToOptions() {
-        final int default_option = _configuration.getDefaultDisplayClicktoOption();
-        int selected_index = 0;
-        int cb_index = 0;
-        if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
-            _show_data_item = cb_index;
-            addClickToOption( Configuration.display_node_data,
-                              _configuration.getClickToTitle( Configuration.display_node_data ) );
-            if ( default_option == Configuration.display_node_data ) {
-                selected_index = cb_index;
-            }
-            cb_index++;
-        }
-        if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
-            _collapse_cb_item = cb_index;
-            addClickToOption( Configuration.collapse_uncollapse,
-                              _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
-            if ( default_option == Configuration.collapse_uncollapse ) {
-                selected_index = cb_index;
-            }
-            cb_index++;
-        }
-        if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
-            _reroot_cb_item = cb_index;
-            addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
-            if ( default_option == Configuration.reroot ) {
-                selected_index = cb_index;
-            }
-            cb_index++;
-        }
-        if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
-            _subtree_cb_item = cb_index;
-            addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
-            if ( default_option == Configuration.subtree ) {
-                selected_index = cb_index;
-            }
-            cb_index++;
-        }
-        if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
-            _swap_cb_item = cb_index;
-            addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
-            if ( default_option == Configuration.swap ) {
-                selected_index = cb_index;
-            }
-            cb_index++;
-        }
-        if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
-            _sort_descendents_item = cb_index;
-            addClickToOption( Configuration.sort_descendents,
-                              _configuration.getClickToTitle( Configuration.sort_descendents ) );
-            if ( default_option == Configuration.sort_descendents ) {
-                selected_index = cb_index;
-            }
-            cb_index++;
-        }
-        if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) {
-            _color_node_font_item = cb_index;
-            addClickToOption( Configuration.color_node_font,
-                              _configuration.getClickToTitle( Configuration.color_node_font ) );
-            if ( default_option == Configuration.color_node_font ) {
-                selected_index = cb_index;
-            }
-            cb_index++;
-        }
-        if ( _configuration.doDisplayClickToOption( Configuration.change_node_font ) ) {
-            _change_node_font_item = cb_index;
-            addClickToOption( Configuration.change_node_font,
-                              _configuration.getClickToTitle( Configuration.change_node_font ) );
-            if ( default_option == Configuration.change_node_font ) {
-                selected_index = cb_index;
-            }
-            cb_index++;
-        }
-        if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
-            _color_subtree_cb_item = cb_index;
-            addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
-            if ( default_option == Configuration.color_subtree ) {
-                selected_index = cb_index;
-            }
-            cb_index++;
-        }
-        if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
-            _open_seq_web_item = cb_index;
-            addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
-            if ( default_option == Configuration.open_seq_web ) {
-                selected_index = cb_index;
-            }
-            cb_index++;
-        }
-        if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
-            _open_pdb_item = cb_index;
-            addClickToOption( Configuration.open_pdb_web, _configuration.getClickToTitle( Configuration.open_pdb_web ) );
-            if ( default_option == Configuration.open_pdb_web ) {
-                selected_index = cb_index;
-            }
-            cb_index++;
-        }
-        if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
-            _open_tax_web_item = cb_index;
-            addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
-            if ( default_option == Configuration.open_tax_web ) {
-                selected_index = cb_index;
-            }
-            cb_index++;
-        }
-        if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
-            _blast_item = cb_index;
-            addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
-            if ( default_option == Configuration.blast ) {
-                selected_index = cb_index;
-            }
-            cb_index++;
-        }
-        if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
-            _select_nodes_item = cb_index;
-            addClickToOption( Configuration.select_nodes, _configuration.getClickToTitle( Configuration.select_nodes ) );
-            if ( default_option == Configuration.select_nodes ) {
-                selected_index = cb_index;
-            }
-            cb_index++;
-        }
-        if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
-            _get_ext_desc_data = cb_index;
-            if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
-                addClickToOption( Configuration.get_ext_desc_data, getConfiguration()
-                                  .getLabelForGetExtDescendentsData() );
-            }
-            else {
-                addClickToOption( Configuration.get_ext_desc_data,
-                                  getConfiguration().getClickToTitle( Configuration.get_ext_desc_data ) );
-            }
-            if ( default_option == Configuration.get_ext_desc_data ) {
-                selected_index = cb_index;
-            }
-            cb_index++;
-        }
-        if ( getOptions().isEditable() ) {
-            if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
-                _cut_subtree_item = cb_index;
-                addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
-                if ( default_option == Configuration.cut_subtree ) {
-                    selected_index = cb_index;
+    void searchReset1() {
+        if ( getMainPanel().getCurrentTreePanel() != null ) {
+            getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
+        }
+    }
+
+    void setActionWhenNodeClicked( final NodeClickAction action ) {
+        _action_when_node_clicked = action;
+    }
+
+    void setAnnotationColors( final Map<String, Color> annotation_colors ) {
+        _annotation_colors = annotation_colors;
+    }
+
+    void setCheckbox( final int which, final boolean state ) {
+        switch ( which ) {
+            case Configuration.display_as_phylogram:
+                if ( getDisplayAsPhylogramCb() != null ) {
+                    getDisplayAsPhylogramCb().setSelected( state );
                 }
-                cb_index++;
-            }
-            if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
-                _copy_subtree_item = cb_index;
-                addClickToOption( Configuration.copy_subtree,
-                                  _configuration.getClickToTitle( Configuration.copy_subtree ) );
-                if ( default_option == Configuration.copy_subtree ) {
-                    selected_index = cb_index;
+                break;
+            case Configuration.display_internal_data:
+                if ( _display_internal_data != null ) {
+                    _display_internal_data.setSelected( state );
                 }
-                cb_index++;
-            }
-            if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
-                _paste_subtree_item = cb_index;
-                addClickToOption( Configuration.paste_subtree,
-                                  _configuration.getClickToTitle( Configuration.paste_subtree ) );
-                if ( default_option == Configuration.paste_subtree ) {
-                    selected_index = cb_index;
+                break;
+            case Configuration.color_according_to_species:
+                if ( _color_acc_species != null ) {
+                    _color_acc_species.setSelected( state );
                 }
-                cb_index++;
-            }
-            if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
-                _delete_node_or_subtree_item = cb_index;
-                addClickToOption( Configuration.delete_subtree_or_node,
-                                  _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
-                if ( default_option == Configuration.delete_subtree_or_node ) {
-                    selected_index = cb_index;
+                break;
+            case Configuration.color_according_to_sequence:
+                if ( _color_acc_sequence != null ) {
+                    _color_acc_sequence.setSelected( state );
                 }
-                cb_index++;
-            }
-            if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
-                _add_new_node_item = cb_index;
-                addClickToOption( Configuration.add_new_node,
-                                  _configuration.getClickToTitle( Configuration.add_new_node ) );
-                if ( default_option == Configuration.add_new_node ) {
-                    selected_index = cb_index;
+                break;
+            case Configuration.color_according_to_annotation:
+                if ( _color_according_to_annotation != null ) {
+                    _color_according_to_annotation.setSelected( state );
                 }
-                cb_index++;
-            }
-            if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
-                _edit_node_data_item = cb_index;
-                addClickToOption( Configuration.edit_node_data,
-                                  _configuration.getClickToTitle( Configuration.edit_node_data ) );
-                if ( default_option == Configuration.edit_node_data ) {
-                    selected_index = cb_index;
+                break;
+            case Configuration.show_node_names:
+                if ( _show_node_names != null ) {
+                    _show_node_names.setSelected( state );
                 }
-                cb_index++;
-            }
+                break;
+            case Configuration.show_taxonomy_scientific_names:
+                if ( _show_taxo_scientific_names != null ) {
+                    _show_taxo_scientific_names.setSelected( state );
+                }
+                break;
+            case Configuration.show_taxonomy_common_names:
+                if ( _show_taxo_common_names != null ) {
+                    _show_taxo_common_names.setSelected( state );
+                }
+                break;
+            case Configuration.show_tax_code:
+                if ( _show_taxo_code != null ) {
+                    _show_taxo_code.setSelected( state );
+                }
+                break;
+            case Configuration.show_taxonomy_images:
+                if ( _show_taxo_images_cb != null ) {
+                    _show_taxo_images_cb.setSelected( state );
+                }
+                break;
+            case Configuration.show_annotation:
+                if ( _show_annotation != null ) {
+                    _show_annotation.setSelected( state );
+                }
+                break;
+            case Configuration.show_binary_characters:
+                if ( _show_binary_characters != null ) {
+                    _show_binary_characters.setSelected( state );
+                }
+                break;
+            case Configuration.show_binary_character_counts:
+                if ( _show_binary_character_counts != null ) {
+                    _show_binary_character_counts.setSelected( state );
+                }
+                break;
+            case Configuration.write_confidence_values:
+                if ( getWriteConfidenceCb() != null ) {
+                    getWriteConfidenceCb().setSelected( state );
+                }
+                break;
+            case Configuration.write_events:
+                if ( getShowEventsCb() != null ) {
+                    getShowEventsCb().setSelected( state );
+                }
+                break;
+            case Configuration.use_style:
+                if ( getUseVisualStylesCb() != null ) {
+                    getUseVisualStylesCb().setSelected( state );
+                }
+                break;
+            case Configuration.width_branches:
+                if ( _width_branches != null ) {
+                    _width_branches.setSelected( state );
+                }
+                break;
+            case Configuration.show_domain_architectures:
+                if ( _show_domain_architectures != null ) {
+                    _show_domain_architectures.setSelected( state );
+                }
+                break;
+            case Configuration.write_branch_length_values:
+                if ( _write_branch_length_values != null ) {
+                    _write_branch_length_values.setSelected( state );
+                }
+                break;
+            case Configuration.show_mol_seqs:
+                if ( _show_mol_seqs != null ) {
+                    _show_mol_seqs.setSelected( state );
+                }
+                break;
+            case Configuration.show_seq_names:
+                if ( _show_seq_names != null ) {
+                    _show_seq_names.setSelected( state );
+                }
+                break;
+            case Configuration.show_gene_names:
+                if ( _show_gene_names != null ) {
+                    _show_gene_names.setSelected( state );
+                }
+                break;
+            case Configuration.show_seq_symbols:
+                if ( _show_seq_symbols != null ) {
+                    _show_seq_symbols.setSelected( state );
+                }
+                break;
+            case Configuration.show_vector_data:
+                if ( _show_vector_data_cb != null ) {
+                    _show_vector_data_cb.setSelected( state );
+                }
+                break;
+            case Configuration.show_properties:
+                if ( _show_properties_cb != null ) {
+                    _show_properties_cb.setSelected( state );
+                }
+                break;
+            case Configuration.show_sequence_acc:
+                if ( _show_sequence_acc != null ) {
+                    _show_sequence_acc.setSelected( state );
+                }
+                break;
+            case Configuration.dynamically_hide_data:
+                if ( getDynamicallyHideData() != null ) {
+                    getDynamicallyHideData().setSelected( state );
+                }
+                break;
+            case Configuration.node_data_popup:
+                if ( getNodeDescPopupCb() != null ) {
+                    getNodeDescPopupCb().setSelected( state );
+                }
+                break;
+                /* GUILHEM_BEG */
+            case Configuration.show_relation_confidence:
+                if ( _seq_relation_confidence_switch != null ) {
+                    _seq_relation_confidence_switch.setSelected( state );
+                }
+                break;
+                /* GUILHEM_END */
+            default:
+                throw new AssertionError( "unknown checkbox: " + which );
         }
-        // Set default selection and its action
-        _click_to_combobox.setSelectedIndex( selected_index );
-        setClickToAction( selected_index );
     }
 
-    private void setupDisplayCheckboxes() {
-        if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
-            addCheckbox( Configuration.display_as_phylogram,
-                         _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
-            setCheckbox( Configuration.display_as_phylogram,
-                         _configuration.doCheckOption( Configuration.display_as_phylogram ) );
+    /**
+     * Set this checkbox state. Not all checkboxes have been instantiated
+     * depending on the config.
+     */
+    void setCheckbox( final JCheckBox cb, final boolean state ) {
+        if ( cb != null ) {
+            cb.setSelected( state );
         }
-        if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
-            addCheckbox( Configuration.dynamically_hide_data,
-                         _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
-            setCheckbox( Configuration.dynamically_hide_data,
-                         _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
+    }
+
+    void setClickToAction( final int action ) {
+        // Set click-to action
+        if ( action == _show_data_item ) {
+            setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
         }
-        if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
-            addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
-            setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
+        else if ( action == _collapse_cb_item ) {
+            setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
         }
-        if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
-            addCheckbox( Configuration.display_internal_data,
-                         _configuration.getDisplayTitle( Configuration.display_internal_data ) );
-            setCheckbox( Configuration.display_internal_data,
-                         _configuration.doCheckOption( Configuration.display_internal_data ) );
+        else if ( action == _reroot_cb_item ) {
+            setActionWhenNodeClicked( NodeClickAction.REROOT );
         }
-        if ( _configuration.doDisplayOption( Configuration.color_according_to_sequence ) ) {
-            addCheckbox( Configuration.color_according_to_sequence,
-                         _configuration.getDisplayTitle( Configuration.color_according_to_sequence ) );
-            setCheckbox( Configuration.color_according_to_sequence,
-                         _configuration.doCheckOption( Configuration.color_according_to_sequence ) );
+        else if ( action == _subtree_cb_item ) {
+            setActionWhenNodeClicked( NodeClickAction.SUBTREE );
+        }
+        else if ( action == _swap_cb_item ) {
+            setActionWhenNodeClicked( NodeClickAction.SWAP );
+        }
+        else if ( action == _color_subtree_cb_item ) {
+            setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
+        }
+        else if ( action == _open_seq_web_item ) {
+            setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
+        }
+        else if ( action == _sort_descendents_item ) {
+            setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
+        }
+        else if ( action == _blast_item ) {
+            setActionWhenNodeClicked( NodeClickAction.BLAST );
         }
-        if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
-            addCheckbox( Configuration.color_according_to_species,
-                         _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
-            setCheckbox( Configuration.color_according_to_species,
-                         _configuration.doCheckOption( Configuration.color_according_to_species ) );
+        else if ( action == _open_tax_web_item ) {
+            setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
         }
-        if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
-            addCheckbox( Configuration.color_according_to_annotation,
-                         _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
-            setCheckbox( Configuration.color_according_to_annotation,
-                         _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
+        else if ( action == _cut_subtree_item ) {
+            setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
         }
-        if ( _configuration.doDisplayOption( Configuration.use_style ) ) {
-            addCheckbox( Configuration.use_style, _configuration.getDisplayTitle( Configuration.use_style ) );
-            setCheckbox( Configuration.use_style, _configuration.doCheckOption( Configuration.use_style ) );
+        else if ( action == _copy_subtree_item ) {
+            setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
         }
-        if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
-            addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
-            setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
+        else if ( action == _delete_node_or_subtree_item ) {
+            setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
         }
-        final JLabel label = new JLabel( "Display Data:" );
-        label.setFont( ControlPanel.jcb_bold_font );
-        if ( !getConfiguration().isUseNativeUI() ) {
-            label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
+        else if ( action == _paste_subtree_item ) {
+            setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
         }
-        add( label );
-        if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
-            addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
-            setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
+        else if ( action == _add_new_node_item ) {
+            setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
         }
-        if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
-            addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
-            setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
+        else if ( action == _edit_node_data_item ) {
+            setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
         }
-        if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
-            addCheckbox( Configuration.show_taxonomy_scientific_names,
-                         _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
-            setCheckbox( Configuration.show_taxonomy_scientific_names,
-                         _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
+        else if ( action == _select_nodes_item ) {
+            setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
         }
-        if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
-            addCheckbox( Configuration.show_taxonomy_common_names,
-                         _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
-            setCheckbox( Configuration.show_taxonomy_common_names,
-                         _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
+        else if ( action == _get_ext_desc_data ) {
+            setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
         }
-        if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
-            addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
-            setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
+        else if ( action == _open_pdb_item ) {
+            setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
         }
-        if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
-            addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
-            setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
+        else if ( action == _color_node_font_item ) {
+            setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
         }
-        if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
-            addCheckbox( Configuration.show_seq_symbols,
-                         _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
-            setCheckbox( Configuration.show_seq_symbols, _configuration.doCheckOption( Configuration.show_seq_symbols ) );
+        else if ( action == _change_node_font_item ) {
+            setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT );
         }
-        if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
-            addCheckbox( Configuration.show_sequence_acc,
-                         _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
-            setCheckbox( Configuration.show_sequence_acc,
-                         _configuration.doCheckOption( Configuration.show_sequence_acc ) );
+        else {
+            throw new RuntimeException( "unknown action: " + action );
         }
-        if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
-            addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
-            setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
+        // make sure drop down is displaying the correct action
+        // in case this was called from outside the class
+        _click_to_combobox.setSelectedIndex( action );
+    }
+
+    void setColorBranches( final boolean color_branches ) {
+        _color_branches = color_branches;
+    }
+
+    void setDrawPhylogram( final boolean b ) {
+        getDisplayAsPhylogramCb().setSelected( b );
+        setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
+    }
+
+    void setDrawPhylogramEnabled( final boolean b ) {
+        getDisplayAsPhylogramCb().setEnabled( b );
+    }
+
+    void setDynamicHidingIsOn( final boolean is_on ) {
+        if ( is_on ) {
+            getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
         }
-        if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
-            addCheckbox( Configuration.write_confidence_values,
-                         _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
-            setCheckbox( Configuration.write_confidence_values,
-                         _configuration.doCheckOption( Configuration.write_confidence_values ) );
+        else {
+            if ( !_configuration.isUseNativeUI() ) {
+                getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
+            }
+            else {
+                getDynamicallyHideData().setForeground( Color.BLACK );
+            }
         }
-        if ( _configuration.doDisplayOption( Configuration.write_branch_length_values ) ) {
-            addCheckbox( Configuration.write_branch_length_values,
-                         _configuration.getDisplayTitle( Configuration.write_branch_length_values ) );
-            setCheckbox( Configuration.write_branch_length_values,
-                         _configuration.doCheckOption( Configuration.write_branch_length_values ) );
+    }
+
+    void setSearchFoundCountsOnLabel0( final int counts ) {
+        getSearchFoundCountsLabel0().setText( "Found: " + counts );
+    }
+
+    void setSearchFoundCountsOnLabel1( final int counts ) {
+        getSearchFoundCountsLabel1().setText( "Found: " + counts );
+    }
+
+    void setSequenceColors( final Map<String, Color> sequence_colors ) {
+        _sequence_colors = sequence_colors;
+    }
+
+    void setShowEvents( final boolean show_events ) {
+        if ( getShowEventsCb() == null ) {
+            _show_events = new JCheckBox( "" );
         }
-        if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
-            addCheckbox( Configuration.show_binary_characters,
-                         _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
-            setCheckbox( Configuration.show_binary_characters,
-                         _configuration.doCheckOption( Configuration.show_binary_characters ) );
+        getShowEventsCb().setSelected( show_events );
+    }
+
+    void setSpeciesColors( final Map<String, Color> species_colors ) {
+        _species_colors = species_colors;
+    }
+
+    void setupControls() {
+        // The tree display options:
+        setupDisplayCheckboxes();
+        /* GUILHEM_BEG */
+        // The sequence relation query selection combo-box
+        if ( _configuration.displaySequenceRelations() ) {
+            addSequenceRelationBlock();
         }
-        if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
-            addCheckbox( Configuration.show_binary_character_counts,
-                         _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
-            setCheckbox( Configuration.show_binary_character_counts,
-                         _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
+        /* GUILHEM_END */
+        // Click-to options
+        startClickToOptions();
+        setupClickToOptions();
+        endClickToOptions();
+        // Zoom and quick edit buttons
+        addButtons();
+        setupSearchTools0();
+        setupSearchTools1();
+    }
+
+    void setUpControlsForDomainStrucures() {
+        _domain_display_label = new JLabel( "Domain Architectures:" );
+        add( customizeLabel( _domain_display_label, getConfiguration() ) );
+        add( _domain_display_label );
+        _zoom_in_domain_structure = new JButton( "d+" );
+        _zoom_out_domain_structure = new JButton( "d-" );
+        _decr_domain_structure_evalue_thr = new JButton( "-" );
+        _incr_domain_structure_evalue_thr = new JButton( "+" );
+        _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
+        _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
+        _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
+        _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
+        _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
+        _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
+        _domain_structure_evalue_thr_tf = new JTextField( 3 );
+        _domain_structure_evalue_thr_tf.setEditable( false );
+        if ( !getConfiguration().isUseNativeUI() ) {
+            _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
+            _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
+            _domain_structure_evalue_thr_tf.setBorder( null );
         }
-        if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
-            addCheckbox( Configuration.show_domain_architectures,
-                         _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
-            setCheckbox( Configuration.show_domain_architectures,
-                         _configuration.doCheckOption( Configuration.show_domain_architectures ) );
+        final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
+        final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
+        if ( !_configuration.isUseNativeUI() ) {
+            d1_panel.setBackground( getBackground() );
+            d2_panel.setBackground( getBackground() );
         }
-        if ( _configuration.doDisplayOption( Configuration.show_mol_seqs ) ) {
-            addCheckbox( Configuration.show_mol_seqs, _configuration.getDisplayTitle( Configuration.show_mol_seqs ) );
-            setCheckbox( Configuration.show_mol_seqs, _configuration.doCheckOption( Configuration.show_mol_seqs ) );
+        add( d1_panel );
+        add( d2_panel );
+        addJButton( _zoom_out_domain_structure, d1_panel );
+        addJButton( _zoom_in_domain_structure, d1_panel );
+        addJButton( _decr_domain_structure_evalue_thr, d2_panel );
+        addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
+        addJButton( _incr_domain_structure_evalue_thr, d2_panel );
+    }
+
+    void setupSearchTools0() {
+        final JLabel search_label = new JLabel( "Search (A):" );
+        search_label.setFont( ControlPanel.jcb_bold_font );
+        if ( !getConfiguration().isUseNativeUI() ) {
+            search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
         }
-        if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
-            addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
-            setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
+        add( search_label );
+        search_label.setToolTipText( SEARCH_TIP_TEXT );
+        _search_found_label_0 = new JLabel();
+        getSearchFoundCountsLabel0().setVisible( false );
+        _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
+        if ( !getConfiguration().isUseNativeUI() ) {
+            _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
         }
-        if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
-            addCheckbox( Configuration.show_vector_data,
-                         _configuration.getDisplayTitle( Configuration.show_vector_data ) );
-            setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
+        _search_tf_0 = new JTextField( 3 );
+        _search_tf_0.setToolTipText( SEARCH_TIP_TEXT );
+        _search_tf_0.setEditable( true );
+        if ( !getConfiguration().isUseNativeUI() ) {
+            _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
+            _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
+            _search_tf_0.setBorder( null );
+        }
+        _search_reset_button_0 = new JButton();
+        getSearchResetButton0().setText( "Reset" );
+        getSearchResetButton0().setEnabled( false );
+        getSearchResetButton0().setVisible( false );
+        final JPanel s_panel_1 = new JPanel( new BorderLayout() );
+        final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
+        s_panel_1.setBackground( getBackground() );
+        add( s_panel_1 );
+        s_panel_2.setBackground( getBackground() );
+        add( s_panel_2 );
+        final KeyAdapter key_adapter = new KeyAdapter() {
+
+            @Override
+            public void keyReleased( final KeyEvent key_event ) {
+                search0();
+                displayedPhylogenyMightHaveChanged( true );
+            }
+        };
+        final ActionListener action_listener = new ActionListener() {
+
+            @Override
+            public void actionPerformed( final ActionEvent e ) {
+                searchReset0();
+                setSearchFoundCountsOnLabel0( 0 );
+                getSearchFoundCountsLabel0().setVisible( false );
+                getSearchTextField0().setText( "" );
+                getSearchResetButton0().setEnabled( false );
+                getSearchResetButton0().setVisible( false );
+                displayedPhylogenyMightHaveChanged( true );
+            }
+        };
+        _search_reset_button_0.addActionListener( action_listener );
+        _search_tf_0.addKeyListener( key_adapter );
+        addJTextField( _search_tf_0, s_panel_1 );
+        s_panel_2.add( _search_found_label_0 );
+        addJButton( _search_reset_button_0, s_panel_2 );
+    }
+
+    void setupSearchTools1() {
+        final JLabel search_label = new JLabel( "Search (B):" );
+        search_label.setFont( ControlPanel.jcb_bold_font );
+        if ( !getConfiguration().isUseNativeUI() ) {
+            search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
         }
-        if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
-            addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
-            setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
+        add( search_label );
+        search_label.setToolTipText( SEARCH_TIP_TEXT );
+        _search_found_label_1 = new JLabel();
+        getSearchFoundCountsLabel1().setVisible( false );
+        _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
+        if ( !getConfiguration().isUseNativeUI() ) {
+            _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
         }
-        if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
-            addCheckbox( Configuration.show_taxonomy_images,
-                         _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
-            setCheckbox( Configuration.show_taxonomy_images,
-                         _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
+        _search_tf_1 = new JTextField( 3 );
+        _search_tf_1.setToolTipText( SEARCH_TIP_TEXT );
+        _search_tf_1.setEditable( true );
+        if ( !getConfiguration().isUseNativeUI() ) {
+            _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
+            _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
+            _search_tf_1.setBorder( null );
         }
+        _search_reset_button_1 = new JButton();
+        getSearchResetButton1().setText( "Reset" );
+        getSearchResetButton1().setEnabled( false );
+        getSearchResetButton1().setVisible( false );
+        final JPanel s_panel_1 = new JPanel( new BorderLayout() );
+        final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
+        s_panel_1.setBackground( getBackground() );
+        add( s_panel_1 );
+        s_panel_2.setBackground( getBackground() );
+        add( s_panel_2 );
+        final KeyAdapter key_adapter = new KeyAdapter() {
+
+            @Override
+            public void keyReleased( final KeyEvent key_event ) {
+                search1();
+                displayedPhylogenyMightHaveChanged( true );
+            }
+        };
+        final ActionListener action_listener = new ActionListener() {
+
+            @Override
+            public void actionPerformed( final ActionEvent e ) {
+                searchReset1();
+                setSearchFoundCountsOnLabel1( 0 );
+                getSearchFoundCountsLabel1().setVisible( false );
+                getSearchTextField1().setText( "" );
+                getSearchResetButton1().setEnabled( false );
+                getSearchResetButton1().setVisible( false );
+                displayedPhylogenyMightHaveChanged( true );
+            }
+        };
+        _search_reset_button_1.addActionListener( action_listener );
+        _search_tf_1.addKeyListener( key_adapter );
+        addJTextField( _search_tf_1, s_panel_1 );
+        s_panel_2.add( _search_found_label_1 );
+        addJButton( _search_reset_button_1, s_panel_2 );
     }
 
-    private void setVisibilityOfDomainStrucureControls() {
-        if ( _zoom_in_domain_structure != null ) {
-            final MainFrame mf = getMainFrame();
-            if ( mf != null ) {
-                if ( isShowDomainArchitectures() ) {
-                    _domain_display_label.setVisible( true );
-                    _zoom_in_domain_structure.setVisible( true );
-                    _zoom_out_domain_structure.setVisible( true );
-                    _decr_domain_structure_evalue_thr.setVisible( true );
-                    _incr_domain_structure_evalue_thr.setVisible( true );
-                    _domain_structure_evalue_thr_tf.setVisible( true );
-                    if ( mf._right_line_up_domains_cbmi != null ) {
-                        mf._right_line_up_domains_cbmi.setVisible( true );
-                    }
-                    if ( mf._show_domain_labels != null ) {
-                        mf._show_domain_labels.setVisible( true );
-                    }
+    void setVisibilityOfDomainStrucureCB() {
+        try {
+            if ( ( getCurrentTreePanel() != null )
+                    && ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( getCurrentTreePanel()
+                            .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
+                if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
+                    getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
                 }
-                else {
-                    _domain_display_label.setVisible( false );
-                    _zoom_in_domain_structure.setVisible( false );
-                    _zoom_out_domain_structure.setVisible( false );
-                    _decr_domain_structure_evalue_thr.setVisible( false );
-                    _incr_domain_structure_evalue_thr.setVisible( false );
-                    _domain_structure_evalue_thr_tf.setVisible( false );
-                    if ( mf._right_line_up_domains_cbmi != null ) {
-                        mf._right_line_up_domains_cbmi.setVisible( false );
-                    }
-                    if ( mf._show_domain_labels != null ) {
-                        mf._show_domain_labels.setVisible( false );
-                    }
+                if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
+                    getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
                 }
             }
-        }
-    }
-
-    // This takes care of ArchaeopteryxE-issue.
-    // Can, and will, return null prior to  ArchaeopteryxE initialization completion.
-    final private MainFrame getMainFrame() {
-        MainFrame mf = getMainPanel().getMainFrame();
-        if ( mf == null ) {
-            // Must be "E" applet version.
-            final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
-            if ( e.getMainPanel() == null ) {
-                return null;
+            else if ( isShowDomainArchitectures() ) {
+                if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
+                    getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( true );
+                }
+                if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
+                    getMainPanel().getMainFrame()._show_domain_labels.setVisible( true );
+                }
+            }
+            else {
+                if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
+                    getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
+                }
+                if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
+                    getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
+                }
             }
-            mf = e.getMainPanel().getMainFrame();
         }
-        return mf;
+        catch ( final Exception ignore ) {
+            //not important...
+        }
     }
 
     void setVisibilityOfX() {
@@ -2362,87 +2180,292 @@ final class ControlPanel extends JPanel implements ActionListener {
                     }
                 }
             }
-            if ( isDrawPhylogram()
-                    || ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( getCurrentTreePanel()
-                            .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) ) {
-                if ( mf._non_lined_up_cladograms_rbmi != null ) {
-                    mf._non_lined_up_cladograms_rbmi.setVisible( false );
-                }
-                if ( mf._uniform_cladograms_rbmi != null ) {
-                    mf._uniform_cladograms_rbmi.setVisible( false );
-                }
-                if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
-                    mf._ext_node_dependent_cladogram_rbmi.setVisible( false );
-                }
+            if ( isDrawPhylogram()
+                    || ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( getCurrentTreePanel()
+                            .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) ) {
+                if ( mf._non_lined_up_cladograms_rbmi != null ) {
+                    mf._non_lined_up_cladograms_rbmi.setVisible( false );
+                }
+                if ( mf._uniform_cladograms_rbmi != null ) {
+                    mf._uniform_cladograms_rbmi.setVisible( false );
+                }
+                if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
+                    mf._ext_node_dependent_cladogram_rbmi.setVisible( false );
+                }
+            }
+            else {
+                if ( mf._non_lined_up_cladograms_rbmi != null ) {
+                    mf._non_lined_up_cladograms_rbmi.setVisible( true );
+                }
+                if ( mf._uniform_cladograms_rbmi != null ) {
+                    mf._uniform_cladograms_rbmi.setVisible( true );
+                }
+                if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
+                    mf._ext_node_dependent_cladogram_rbmi.setVisible( true );
+                }
+            }
+            if ( isDrawPhylogram() ) {
+                if ( mf._show_scale_cbmi != null ) {
+                    mf._show_scale_cbmi.setVisible( true );
+                }
+            }
+            else {
+                if ( mf._show_scale_cbmi != null ) {
+                    mf._show_scale_cbmi.setVisible( false );
+                }
+            }
+            if ( getCurrentTreePanel() != null ) {
+                if ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
+                        || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
+                    if ( mf._label_direction_cbmi != null ) {
+                        mf._label_direction_cbmi.setVisible( true );
+                    }
+                }
+                else {
+                    if ( mf._label_direction_cbmi != null ) {
+                        mf._label_direction_cbmi.setVisible( false );
+                    }
+                }
+            }
+        }
+    }
+
+    void showAnnotations() {
+        if ( _show_annotation != null ) {
+            _show_annotation.setSelected( true );
+        }
+        if ( _color_according_to_annotation != null ) {
+            _color_according_to_annotation.setSelected( true );
+        }
+        if ( _color_acc_species != null ) {
+            _color_acc_species.setSelected( false );
+        }
+        if ( _color_acc_sequence != null ) {
+            _color_acc_sequence.setSelected( false );
+        }
+        _mainpanel.getCurrentTreePanel().repaint();
+    }
+
+    /**
+     * Fit entire tree into window.
+     */
+    void showWhole() {
+        if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
+            return;
+        }
+        getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
+        displayedPhylogenyMightHaveChanged( true );
+        _mainpanel.getCurrentTreePanel().updateOvSettings();
+        _mainpanel.getCurrentTreePanel().validate();
+        _mainpanel.validate();
+        _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
+                                                                    _mainpanel.getSizeOfViewport().height );
+        _mainpanel.getCurrentTreePanel().resetPreferredSize();
+        _mainpanel.adjustJScrollPane();
+        _mainpanel.getCurrentTreePanel().repaint();
+        _mainpanel.getCurrentTreePanel().validate();
+        _mainpanel.validate();
+        _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
+                                                                    _mainpanel.getSizeOfViewport().height );
+        _mainpanel.getCurrentTreePanel().resetPreferredSize();
+        _mainpanel.adjustJScrollPane();
+        _mainpanel.getCurrentTreePanel().repaint();
+        _mainpanel.getCurrentTreePanel().updateOvSizes();
+    }
+
+    void showWholeAll() {
+        for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
+            if ( tree_panel != null ) {
+                tree_panel.validate();
+                tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
+                                                      _mainpanel.getSizeOfViewport().height );
+                tree_panel.resetPreferredSize();
+                tree_panel.repaint();
+            }
+        }
+    }
+
+    // Create header for click-to combo box.
+    void startClickToOptions() {
+        final JLabel spacer = new JLabel( "" );
+        spacer.setFont( ControlPanel.jcb_font );
+        add( spacer );
+        _click_to_label = new JLabel( "Click on Node to:" );
+        add( customizeLabel( _click_to_label, getConfiguration() ) );
+        _click_to_combobox = new JComboBox<String>();
+        _click_to_combobox.setFocusable( false );
+        _click_to_combobox.setMaximumRowCount( 14 );
+        _click_to_combobox.setFont( ControlPanel.js_font );
+        if ( !_configuration.isUseNativeUI() ) {
+            _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
+        }
+        // don't add listener until all items are set (or each one will trigger
+        // an event)
+        // click_to_list.addActionListener(this);
+        add( _click_to_combobox );
+        // Correlates option names to titles
+        _all_click_to_names = new HashMap<Integer, String>();
+        _click_to_names = new ArrayList<String>();
+    }
+
+    void tabChanged() {
+        if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
+            if ( getCurrentTreePanel().isPhyHasBranchLengths()
+                    && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
+                setDrawPhylogramEnabled( true );
+                setDrawPhylogram( isDrawPhylogram() );
             }
             else {
-                if ( mf._non_lined_up_cladograms_rbmi != null ) {
-                    mf._non_lined_up_cladograms_rbmi.setVisible( true );
-                }
-                if ( mf._uniform_cladograms_rbmi != null ) {
-                    mf._uniform_cladograms_rbmi.setVisible( true );
-                }
-                if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
-                    mf._ext_node_dependent_cladogram_rbmi.setVisible( true );
-                }
+                setDrawPhylogramEnabled( false );
+                setDrawPhylogram( false );
             }
-            if ( isDrawPhylogram() ) {
-                if ( mf._show_scale_cbmi != null ) {
-                    mf._show_scale_cbmi.setVisible( true );
-                }
+            if ( getMainPanel().getMainFrame() == null ) {
+                // Must be "E" applet version.
+                final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
+                e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
             }
             else {
-                if ( mf._show_scale_cbmi != null ) {
-                    mf._show_scale_cbmi.setVisible( false );
-                }
+                getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
+                                                                         .getPhylogenyGraphicsType() );
             }
-            if ( getCurrentTreePanel() != null ) {
-                if ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
-                        || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
-                    if ( mf._label_direction_cbmi != null ) {
-                        mf._label_direction_cbmi.setVisible( true );
-                    }
-                }
-                else {
-                    if ( mf._label_direction_cbmi != null ) {
-                        mf._label_direction_cbmi.setVisible( false );
-                    }
-                }
+            getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
+            getMainPanel().getControlPanel().search0();
+            getMainPanel().getControlPanel().search1();
+            getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
+            getSequenceRelationTypeBox().removeAllItems();
+            for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
+                    .getRelevantSequenceRelationTypes() ) {
+                _sequence_relation_type_box.addItem( type );
             }
+            getMainPanel().getCurrentTreePanel().repaint();
+            //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
+            // according to GUILHEM the line above can be removed.
         }
     }
 
-    void setVisibilityOfDomainStrucureCB() {
-        try {
-            if ( ( getCurrentTreePanel() != null )
-                    && ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( getCurrentTreePanel()
-                            .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
-                if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
-                    getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
-                }
-                if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
-                    getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
-                }
+    /**
+     * Uncollapse all nodes.
+     */
+    void uncollapseAll( final TreePanel tp ) {
+        final Phylogeny t = tp.getPhylogeny();
+        if ( ( t != null ) && !t.isEmpty() ) {
+            for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
+                final PhylogenyNode node = iter.next();
+                node.setCollapse( false );
             }
-            else if ( isShowDomainArchitectures() ) {
-                if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
-                    getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( true );
-                }
-                if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
-                    getMainPanel().getMainFrame()._show_domain_labels.setVisible( true );
-                }
+            tp.resetNodeIdToDistToLeafMap();
+            tp.updateSetOfCollapsedExternalNodes();
+            t.recalculateNumberOfExternalDescendants( false );
+            tp.setNodeInPreorderToNull();
+            t.clearHashIdToNodeMap();
+            showWhole();
+        }
+    }
+
+    void updateDomainStructureEvaluethresholdDisplay() {
+        if ( _domain_structure_evalue_thr_tf != null ) {
+            _domain_structure_evalue_thr_tf.setText( "10^"
+                    + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThresholdExp() );
+        }
+    }
+
+    void zoomInX( final float factor, final float x_correction_factor ) {
+        final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
+        final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
+        treepanel.multiplyUrtFactor( 1f );
+        if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
+                || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
+                || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
+                || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
+            final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
+            treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
+            treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
+            getMainPanel().adjustJScrollPane();
+            treepanel.resetPreferredSize();
+            getMainPanel().getCurrentScrollPane().getViewport().validate();
+            sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
+                                                  - ( sb.getVisibleAmount() / 2.0 ) ) );
+        }
+        else {
+            final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
+            treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
+            treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
+            getMainPanel().adjustJScrollPane();
+            treepanel.resetPreferredSize();
+            getMainPanel().getCurrentScrollPane().getViewport().validate();
+            sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
+        }
+        treepanel.resetPreferredSize();
+        treepanel.updateOvSizes();
+    }
+
+    void zoomInY( final float factor ) {
+        final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
+        final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
+        treepanel.multiplyUrtFactor( 1.1f );
+        final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
+        treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
+        getMainPanel().adjustJScrollPane();
+        treepanel.resetPreferredSize();
+        getMainPanel().getCurrentScrollPane().getViewport().validate();
+        sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
+                                              - ( sb.getVisibleAmount() / 2.0 ) ) );
+        treepanel.resetPreferredSize();
+        treepanel.updateOvSizes();
+    }
+
+    void zoomOutX( final float factor, final float x_correction_factor ) {
+        final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
+        treepanel.multiplyUrtFactor( 1f );
+        if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
+            final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
+            if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
+                    || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
+                    || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
+                    || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
+                getMainPanel().adjustJScrollPane();
+                treepanel.resetPreferredSize();
+                getMainPanel().getCurrentScrollPane().getViewport().validate();
+                final double x = ( sb.getMaximum() - sb.getMinimum() )
+                        / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
+                treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
+                treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
+                getMainPanel().adjustJScrollPane();
+                treepanel.resetPreferredSize();
+                getMainPanel().getCurrentScrollPane().getViewport().validate();
+                sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
+                                                      - ( sb.getVisibleAmount() / 2.0 ) ) );
             }
             else {
-                if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
-                    getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
-                }
-                if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
-                    getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
+                final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
+                treepanel.setXdistance( treepanel.getXdistance() * factor );
+                treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
+                if ( x > 0 ) {
+                    getMainPanel().adjustJScrollPane();
+                    treepanel.resetPreferredSize();
+                    getMainPanel().getCurrentScrollPane().getViewport().validate();
+                    sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
                 }
             }
+            treepanel.resetPreferredSize();
+            treepanel.updateOvSizes();
         }
-        catch ( final Exception ignore ) {
-            //not important...
+    }
+
+    void zoomOutY( final float factor ) {
+        final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
+        treepanel.multiplyUrtFactor( 0.9f );
+        if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
+            final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
+            final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
+            treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
+            getMainPanel().adjustJScrollPane();
+            treepanel.resetPreferredSize();
+            getMainPanel().getCurrentScrollPane().getViewport().validate();
+            sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
+                                                  - ( sb.getVisibleAmount() / 2.0 ) ) );
+            treepanel.resetPreferredSize();
+            treepanel.updateOvSizes();
         }
     }
 
@@ -2454,28 +2477,4 @@ final class ControlPanel extends JPanel implements ActionListener {
         }
         return label;
     }
-
-    enum NodeClickAction {
-        ADD_NEW_NODE,
-        BLAST,
-        COLLAPSE,
-        COLOR_SUBTREE,
-        COPY_SUBTREE,
-        CUT_SUBTREE,
-        DELETE_NODE_OR_SUBTREE,
-        EDIT_NODE_DATA,
-        GET_EXT_DESC_DATA,
-        OPEN_PDB_WEB,
-        OPEN_SEQ_WEB,
-        OPEN_TAX_WEB,
-        PASTE_SUBTREE,
-        REROOT,
-        SELECT_NODES,
-        SHOW_DATA,
-        SORT_DESCENDENTS,
-        SUBTREE,
-        SWAP,
-        CHANGE_NODE_FONT,
-        COLOR_NODE_FONT;
-    }
 }
index 232737a..f8b2f17 100644 (file)
@@ -41,7 +41,7 @@ public class FontChooser extends JDialog implements ActionListener, ListSelectio
     public static final long      serialVersionUID  = 62256323L;
     private static final String[] STYLE             = { REGULAR, BOLD, ITALIC, BOLD_ITALIC };
     private static final String[] SIZE              = { "3", "4", "6", "8", "10", "12", "14", "16", "18", "20", "22",
-            "24", "26", "28", "36", "72"           };
+        "24", "26", "28", "36", "72"           };
     private static final int      OK_OPTION         = 1;
     private static final int      CANCEL_OPTION     = 2;
     private Font                  _font;
@@ -49,9 +49,9 @@ public class FontChooser extends JDialog implements ActionListener, ListSelectio
     private String                _type;
     private int                   _style;
     private int                   _size;
-    private final JList<String>           _font_list        = new JList<String>( AptxUtil.getAvailableFontFamiliesSorted() );
-    private final JList<String>           _style_list       = new JList<String>( STYLE );
-    private final JList<String>           _size_list        = new JList<String>( SIZE );
+    private final JList<String>   _font_list        = new JList<String>( AptxUtil.getAvailableFontFamiliesSorted() );
+    private final JList<String>   _style_list       = new JList<String>( STYLE );
+    private final JList<String>   _size_list        = new JList<String>( SIZE );
     private final JTextField      _fonts_tf         = new JTextField();
     private final JTextField      _style_tf         = new JTextField();
     private final JTextField      _size_tf          = new JTextField();
@@ -132,7 +132,7 @@ public class FontChooser extends JDialog implements ActionListener, ListSelectio
             boolean found = false;
             _type = _fonts_tf.getText();
             for( int i = 0; i < _font_list.getModel().getSize(); i++ ) {
-                if ( ( ( String ) _font_list.getModel().getElementAt( i ) ).startsWith( _fonts_tf.getText().trim() ) ) {
+                if ( _font_list.getModel().getElementAt( i ).startsWith( _fonts_tf.getText().trim() ) ) {
                     _font_list.setSelectedIndex( i );
                     setScrollPos( _font_jsp, _font_list, i );
                     found = true;
@@ -207,28 +207,11 @@ public class FontChooser extends JDialog implements ActionListener, ListSelectio
         return _font.getStyle();
     }
 
-    private void parseSize() {
-        try {
-            _size = ( Integer.parseInt( _size_tf.getText().trim() ) );
-        }
-        catch ( final Exception ex ) {
-            // Ignore.
-        }
-        if ( _size < 1 ) {
-            _size = 1;
-        }
-    }
-
     @Override
     public void setFont( final Font font ) {
         _font = font;
     }
 
-    private void setScrollPos( final JScrollPane sp, final JList<String> list, final int index ) {
-        final int unit_size = sp.getVerticalScrollBar().getMaximum() / list.getModel().getSize();
-        sp.getVerticalScrollBar().setValue( ( index - 2 ) * unit_size );
-    }
-
     public int showDialog( final Component parent, final String title ) {
         boolean found = false;
         _option = CANCEL_OPTION;
@@ -249,7 +232,7 @@ public class FontChooser extends JDialog implements ActionListener, ListSelectio
         found = false;
         for( int i = 0; i < _size_list.getModel().getSize(); i++ ) {
             _size_list.setSelectedIndex( i );
-            if ( _font.getSize() <= Integer.parseInt( ( String ) _size_list.getSelectedValue() ) ) {
+            if ( _font.getSize() <= Integer.parseInt( _size_list.getSelectedValue() ) ) {
                 found = true;
                 setScrollPos( _size_jsp, _size_list, i );
                 break;
@@ -267,13 +250,13 @@ public class FontChooser extends JDialog implements ActionListener, ListSelectio
     public void valueChanged( final ListSelectionEvent e ) {
         if ( e.getSource() == _font_list ) {
             if ( _font_list.getSelectedValue() != null ) {
-                _fonts_tf.setText( ( ( String ) ( _font_list.getSelectedValue() ) ) );
+                _fonts_tf.setText( ( ( _font_list.getSelectedValue() ) ) );
             }
             _type = _fonts_tf.getText();
             _test_tf.setFont( new Font( _type, _style, _size ) );
         }
         else if ( e.getSource() == _style_list ) {
-            _style_tf.setText( ( ( String ) ( _style_list.getSelectedValue() ) ) );
+            _style_tf.setText( ( ( _style_list.getSelectedValue() ) ) );
             if ( _style_tf.getText().equals( REGULAR ) ) {
                 _style = 0;
             }
@@ -290,10 +273,27 @@ public class FontChooser extends JDialog implements ActionListener, ListSelectio
         }
         else if ( e.getSource() == _size_list ) {
             if ( _size_list.getSelectedValue() != null ) {
-                _size_tf.setText( ( ( String ) ( _size_list.getSelectedValue() ) ) );
+                _size_tf.setText( ( ( _size_list.getSelectedValue() ) ) );
             }
             _size = ( Integer.parseInt( _size_tf.getText().trim() ) );
             _test_tf.setFont( new Font( _type, _style, _size ) );
         }
     }
+
+    private void parseSize() {
+        try {
+            _size = ( Integer.parseInt( _size_tf.getText().trim() ) );
+        }
+        catch ( final Exception ex ) {
+            // Ignore.
+        }
+        if ( _size < 1 ) {
+            _size = 1;
+        }
+    }
+
+    private void setScrollPos( final JScrollPane sp, final JList<String> list, final int index ) {
+        final int unit_size = sp.getVerticalScrollBar().getMaximum() / list.getModel().getSize();
+        sp.getVerticalScrollBar().setValue( ( index - 2 ) * unit_size );
+    }
 }
index d3ef951..80a5ac7 100644 (file)
@@ -296,7 +296,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         _save_filechooser = new JFileChooser();\r
         _save_filechooser.setCurrentDirectory( new File( "." ) );\r
         _save_filechooser.setMultiSelectionEnabled( false );\r
-        _save_filechooser.setFileFilter( MainFrame.xmlfilter );\r
+        _save_filechooser.setFileFilter( xmlfilter );\r
         _save_filechooser.addChoosableFileFilter( nhfilter );\r
         _save_filechooser.addChoosableFileFilter( nexusfilter );\r
         _save_filechooser.addChoosableFileFilter( _save_filechooser.getAcceptAllFileFilter() );\r
@@ -647,7 +647,6 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             if ( new_dir != null ) {\r
                 setCurrentDir( new_dir );\r
             }\r
-           \r
         }\r
         else if ( o == _write_to_tif_item ) {\r
             final File new_dir = writeToGraphicsFile( _mainpanel.getCurrentPhylogeny(),\r
@@ -660,7 +659,6 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             if ( new_dir != null ) {\r
                 setCurrentDir( new_dir );\r
             }\r
-           \r
         }\r
         else if ( o == _write_to_bmp_item ) {\r
             final File new_dir = writeToGraphicsFile( _mainpanel.getCurrentPhylogeny(),\r
@@ -673,7 +671,6 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             if ( new_dir != null ) {\r
                 setCurrentDir( new_dir );\r
             }\r
-          \r
         }\r
         else if ( o == _write_to_png_item ) {\r
             final File new_dir = writeToGraphicsFile( _mainpanel.getCurrentPhylogeny(),\r
@@ -691,16 +688,16 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             print( getCurrentTreePanel(), getOptions(), this );\r
         }\r
         else if ( o == _save_item ) {\r
-           \r
-            final File new_dir = writeToFile( _mainpanel.getCurrentPhylogeny() ,\r
-                         getMainPanel(), _save_filechooser, _current_dir, getContentPane(), this );\r
-      \r
+            final File new_dir = writeToFile( _mainpanel.getCurrentPhylogeny(),\r
+                                              getMainPanel(),\r
+                                              _save_filechooser,\r
+                                              _current_dir,\r
+                                              getContentPane(),\r
+                                              this );\r
             if ( new_dir != null ) {\r
-                setCurrentDir( new_dir ); \r
+                setCurrentDir( new_dir );\r
             }\r
-           \r
         }\r
-       \r
         else if ( o == _graphics_export_visible_only_cbmi ) {\r
             updateOptions( getOptions() );\r
         }\r
@@ -795,154 +792,101 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         } );\r
     }\r
 \r
-    void activateSaveAllIfNeeded() {\r
-        if ( ( getMainPanel().getTabbedPane() != null ) && ( getMainPanel().getTabbedPane().getTabCount() > 1 ) ) {\r
-            _save_all_item.setEnabled( true );\r
-        }\r
-        else {\r
-            _save_all_item.setEnabled( false );\r
-        }\r
-    }\r
-\r
-    void buildFileMenu() {\r
-        _file_jmenu = MainFrame.createMenu( "File", getConfiguration() );\r
-        _file_jmenu.add( _save_item = new JMenuItem( "Save Tree As..." ) );\r
-        _file_jmenu.addSeparator();\r
-        _file_jmenu.add( _write_to_pdf_item = new JMenuItem( "Export to PDF file ..." ) );\r
-        if ( AptxUtil.canWriteFormat( "tif" ) || AptxUtil.canWriteFormat( "tiff" ) || AptxUtil.canWriteFormat( "TIF" ) ) {\r
-            _file_jmenu.add( _write_to_tif_item = new JMenuItem( "Export to TIFF file..." ) );\r
-        }\r
-        _file_jmenu.add( _write_to_png_item = new JMenuItem( "Export to PNG file..." ) );\r
-        _file_jmenu.add( _write_to_jpg_item = new JMenuItem( "Export to JPG file..." ) );\r
-        if ( AptxUtil.canWriteFormat( "gif" ) ) {\r
-            _file_jmenu.add( _write_to_gif_item = new JMenuItem( "Export to GIF file..." ) );\r
-        }\r
-        if ( AptxUtil.canWriteFormat( "bmp" ) ) {\r
-            _file_jmenu.add( _write_to_bmp_item = new JMenuItem( "Export to BMP file..." ) );\r
-        }\r
-        _file_jmenu.addSeparator();\r
-        _file_jmenu.add( _print_item = new JMenuItem( "Print..." ) );\r
-        _file_jmenu.addSeparator();\r
-        _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );\r
-        customizeJMenuItem( _save_item );\r
-        customizeJMenuItem( _write_to_pdf_item );\r
-        customizeJMenuItem( _write_to_png_item );\r
-        customizeJMenuItem( _write_to_jpg_item );\r
-        customizeJMenuItem( _write_to_gif_item );\r
-        customizeJMenuItem( _write_to_tif_item );\r
-        customizeJMenuItem( _write_to_bmp_item );\r
-        customizeJMenuItem( _print_item );\r
-        customizeJMenuItem( _exit_item );\r
-        _jmenubar.add( _file_jmenu );\r
-    }\r
-\r
-    void buildFontSizeMenu() {\r
-        _font_size_menu = createMenu( FONT_SIZE_MENU_LABEL, getConfiguration() );\r
-        _font_size_menu.add( _super_tiny_fonts_item = new JMenuItem( "Super Tiny Fonts" ) );\r
-        _font_size_menu.add( _tiny_fonts_item = new JMenuItem( "Tiny Fonts" ) );\r
-        _font_size_menu.add( _small_fonts_item = new JMenuItem( "Small Fonts" ) );\r
-        _font_size_menu.add( _medium_fonts_item = new JMenuItem( "Medium Fonts" ) );\r
-        _font_size_menu.add( _large_fonts_item = new JMenuItem( "Large Fonts" ) );\r
-        customizeJMenuItem( _super_tiny_fonts_item );\r
-        customizeJMenuItem( _tiny_fonts_item );\r
-        customizeJMenuItem( _small_fonts_item );\r
-        customizeJMenuItem( _medium_fonts_item );\r
-        customizeJMenuItem( _large_fonts_item );\r
-        _jmenubar.add( _font_size_menu );\r
-    }\r
-\r
-    void buildHelpMenu() {\r
-        _help_jmenu = createMenu( "Help", getConfiguration() );\r
-        _help_jmenu.add( _help_item = new JMenuItem( "Documentation" ) );\r
-        _help_jmenu.addSeparator();\r
-        _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );\r
-        _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" ); //TODO need to add this...\r
-        _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );\r
-        _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );\r
-        _help_jmenu.addSeparator();\r
-        _help_jmenu.add( _about_item = new JMenuItem( "About" ) );\r
-        customizeJMenuItem( _help_item );\r
-        customizeJMenuItem( _website_item );\r
-        customizeJMenuItem( _phyloxml_website_item );\r
-        customizeJMenuItem( _aptx_ref_item );\r
-        customizeJMenuItem( _phyloxml_ref_item );\r
-        customizeJMenuItem( _about_item );\r
-        _phyloxml_ref_item.setToolTipText( PHYLOXML_REF_TOOL_TIP );\r
-        _aptx_ref_item.setToolTipText( APTX_REF_TOOL_TIP );\r
-        _jmenubar.add( _help_jmenu );\r
-    }\r
-\r
-    void buildTypeMenu() {\r
-        _type_menu = createMenu( TYPE_MENU_HEADER, getConfiguration() );\r
-        _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );\r
-        _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );\r
-        _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );\r
-        _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );\r
-        _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );\r
-        _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );\r
-        _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );\r
-        _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );\r
-        customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );\r
-        customizeCheckBoxMenuItem( _triangular_type_cbmi, false );\r
-        customizeCheckBoxMenuItem( _euro_type_cbmi, false );\r
-        customizeCheckBoxMenuItem( _rounded_type_cbmi, false );\r
-        customizeCheckBoxMenuItem( _curved_type_cbmi, false );\r
-        customizeCheckBoxMenuItem( _convex_type_cbmi, false );\r
-        customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );\r
-        customizeCheckBoxMenuItem( _circular_type_cbmi, false );\r
-        _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );\r
-        _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );\r
-        initializeTypeMenu( getOptions() );\r
-        _jmenubar.add( _type_menu );\r
-    }\r
-\r
-    void buildViewMenu() {\r
-        _view_jmenu = createMenu( "View", getConfiguration() );\r
-        _view_jmenu.add( _display_basic_information_item = new JMenuItem( SHOW_BASIC_TREE_INFORMATION_LABEL ) );\r
-        _view_jmenu.addSeparator();\r
-        _view_jmenu.add( _view_as_XML_item = new JMenuItem( "as phyloXML" ) );\r
-        _view_jmenu.add( _view_as_NH_item = new JMenuItem( "as Newick" ) );\r
-        _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "as Nexus" ) );\r
-        customizeJMenuItem( _display_basic_information_item );\r
-        customizeJMenuItem( _view_as_NH_item );\r
-        customizeJMenuItem( _view_as_XML_item );\r
-        customizeJMenuItem( _view_as_nexus_item );\r
-        _jmenubar.add( _view_jmenu );\r
-    }\r
-\r
-    void checkTextFrames() {\r
-        if ( _textframes.size() > 5 ) {\r
-            try {\r
-                if ( _textframes.getFirst() != null ) {\r
-                    _textframes.getFirst().removeMe();\r
-                }\r
-                else {\r
-                    _textframes.removeFirst();\r
-                }\r
+    private void annotateSequences() {\r
+        if ( getCurrentTreePanel() != null ) {\r
+            List<PhylogenyNode> nodes = null;\r
+            if ( ( getCurrentTreePanel().getFoundNodes0() != null )\r
+                    || ( getCurrentTreePanel().getFoundNodes1() != null ) ) {\r
+                nodes = getCurrentTreePanel().getFoundNodesAsListOfPhylogenyNodes();\r
             }\r
-            catch ( final NoSuchElementException e ) {\r
-                // Ignore.\r
+            if ( ( nodes == null ) || nodes.isEmpty() ) {\r
+                JOptionPane\r
+                .showMessageDialog( this,\r
+                                    "Need to select nodes, either via direct selection or via the \"Search\" function",\r
+                                    "No nodes selected for annotation",\r
+                                    JOptionPane.ERROR_MESSAGE );\r
+                return;\r
+            }\r
+            final Phylogeny phy = getMainPanel().getCurrentPhylogeny();\r
+            if ( ( phy != null ) && !phy.isEmpty() ) {\r
+                final JTextField ref_field = new JTextField( 10 );\r
+                final JTextField desc_filed = new JTextField( 20 );\r
+                ref_field.setText( ForesterUtil.isEmpty( getPreviousNodeAnnotationReference() ) ? ""\r
+                        : getPreviousNodeAnnotationReference() );\r
+                final JPanel my_panel = new JPanel();\r
+                my_panel.add( new JLabel( "Reference " ) );\r
+                my_panel.add( ref_field );\r
+                my_panel.add( Box.createHorizontalStrut( 15 ) );\r
+                my_panel.add( new JLabel( "Description " ) );\r
+                my_panel.add( desc_filed );\r
+                final int result = JOptionPane.showConfirmDialog( null,\r
+                                                                  my_panel,\r
+                                                                  "Enter the sequence annotation(s) for the "\r
+                                                                          + nodes.size() + " selected nodes",\r
+                                                                          JOptionPane.OK_CANCEL_OPTION );\r
+                if ( result == JOptionPane.OK_OPTION ) {\r
+                    String ref = ref_field.getText();\r
+                    String desc = desc_filed.getText();\r
+                    if ( !ForesterUtil.isEmpty( ref ) ) {\r
+                        ref = ref.trim();\r
+                        ref = ref.replaceAll( "\\s+", " " );\r
+                        if ( ( ref.indexOf( ':' ) < 1 ) || ( ref.indexOf( ':' ) > ( ref.length() - 2 ) )\r
+                                || ( ref.length() < 3 ) ) {\r
+                            JOptionPane.showMessageDialog( this,\r
+                                                           "Reference needs to be in the form of \"GO:1234567\"",\r
+                                                           "Illegal Format for Annotation Reference",\r
+                                                           JOptionPane.ERROR_MESSAGE );\r
+                            return;\r
+                        }\r
+                    }\r
+                    if ( ref != null ) {\r
+                        setPreviousNodeAnnotationReference( ref );\r
+                    }\r
+                    if ( desc != null ) {\r
+                        desc = desc.trim();\r
+                        desc = desc.replaceAll( "\\s+", " " );\r
+                    }\r
+                    if ( !ForesterUtil.isEmpty( ref ) || !ForesterUtil.isEmpty( desc ) ) {\r
+                        for( final PhylogenyNode n : nodes ) {\r
+                            ForesterUtil.ensurePresenceOfSequence( n );\r
+                            final Annotation ann = ForesterUtil.isEmpty( ref ) ? new Annotation()\r
+                            : new Annotation( ref );\r
+                            if ( !ForesterUtil.isEmpty( desc ) ) {\r
+                                ann.setDesc( desc );\r
+                            }\r
+                            n.getNodeData().getSequence().addAnnotation( ann );\r
+                        }\r
+                    }\r
+                    getMainPanel().getControlPanel().showAnnotations();\r
+                }\r
             }\r
         }\r
     }\r
 \r
-    void choosePdfWidth() {\r
-        final String s = ( String ) JOptionPane.showInputDialog( this,\r
-                                                                 "Please enter the default line width for PDF export.\n"\r
-                                                                         + "[current value: "\r
-                                                                         + getOptions().getPrintLineWidth() + "]\n",\r
-                                                                 "Line Width for PDF Export",\r
-                                                                 JOptionPane.QUESTION_MESSAGE,\r
-                                                                 null,\r
-                                                                 null,\r
-                                                                 getOptions().getPrintLineWidth() );\r
+    private void chooseFont() {\r
+        final FontChooser fc = new FontChooser();\r
+        fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );\r
+        fc.showDialog( this, "Select the Base Font" );\r
+        getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );\r
+    }\r
+\r
+    private void chooseMinimalConfidence() {\r
+        final String s = ( String ) JOptionPane\r
+                .showInputDialog( this,\r
+                                  "Please enter the minimum for confidence values to be displayed.\n"\r
+                                          + "[current value: " + getOptions().getMinConfidenceValue() + "]\n",\r
+                                          "Minimal Confidence Value",\r
+                                          JOptionPane.QUESTION_MESSAGE,\r
+                                          null,\r
+                                          null,\r
+                                          getOptions().getMinConfidenceValue() );\r
         if ( !ForesterUtil.isEmpty( s ) ) {\r
             boolean success = true;\r
-            float f = 0.0f;\r
+            double m = 0.0;\r
             final String m_str = s.trim();\r
             if ( !ForesterUtil.isEmpty( m_str ) ) {\r
                 try {\r
-                    f = Float.parseFloat( m_str );\r
+                    m = Double.parseDouble( m_str );\r
                 }\r
                 catch ( final Exception ex ) {\r
                     success = false;\r
@@ -951,190 +895,515 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             else {\r
                 success = false;\r
             }\r
-            if ( success && ( f > 0.0 ) ) {\r
-                getOptions().setPrintLineWidth( f );\r
+            if ( success && ( m >= 0.0 ) ) {\r
+                getOptions().setMinConfidenceValue( m );\r
             }\r
         }\r
     }\r
 \r
-    void choosePrintSize() {\r
-        final String s = ( String ) JOptionPane.showInputDialog( this,\r
-                                                                 "Please enter values for width and height,\nseparated by a comma.\n"\r
-                                                                         + "[current values: "\r
-                                                                         + getOptions().getPrintSizeX() + ", "\r
-                                                                         + getOptions().getPrintSizeY() + "]\n"\r
-                                                                         + "[A4: " + Constants.A4_SIZE_X + ", "\r
-                                                                         + Constants.A4_SIZE_Y + "]\n" + "[US Letter: "\r
-                                                                         + Constants.US_LETTER_SIZE_X + ", "\r
-                                                                         + Constants.US_LETTER_SIZE_Y + "]",\r
-                                                                 "Default Size for Graphics Export",\r
-                                                                 JOptionPane.QUESTION_MESSAGE,\r
-                                                                 null,\r
-                                                                 null,\r
-                                                                 getOptions().getPrintSizeX() + ", "\r
-                                                                         + getOptions().getPrintSizeY() );\r
-        if ( !ForesterUtil.isEmpty( s ) && ( s.indexOf( ',' ) > 0 ) ) {\r
-            boolean success = true;\r
-            int x = 0;\r
-            int y = 0;\r
-            final String[] str_ary = s.split( "," );\r
-            if ( str_ary.length == 2 ) {\r
-                final String x_str = str_ary[ 0 ].trim();\r
-                final String y_str = str_ary[ 1 ].trim();\r
-                if ( !ForesterUtil.isEmpty( x_str ) && !ForesterUtil.isEmpty( y_str ) ) {\r
-                    try {\r
-                        x = Integer.parseInt( x_str );\r
-                        y = Integer.parseInt( y_str );\r
-                    }\r
-                    catch ( final Exception ex ) {\r
-                        success = false;\r
-                    }\r
-                }\r
-                else {\r
-                    success = false;\r
+    private void deleteSelectedNodes( final boolean delete ) {\r
+        final Phylogeny phy = getMainPanel().getCurrentPhylogeny();\r
+        if ( ( phy == null ) || ( phy.getNumberOfExternalNodes() < 2 ) ) {\r
+            return;\r
+        }\r
+        final List<PhylogenyNode> nodes = new ArrayList<PhylogenyNode>();\r
+        if ( ( getCurrentTreePanel().getFoundNodes0() != null ) || ( getCurrentTreePanel().getFoundNodes1() != null ) ) {\r
+            final List<PhylogenyNode> all_selected_nodes = getCurrentTreePanel().getFoundNodesAsListOfPhylogenyNodes();\r
+            for( final PhylogenyNode n : all_selected_nodes ) {\r
+                if ( n.isExternal() ) {\r
+                    nodes.add( n );\r
                 }\r
             }\r
-            else {\r
-                success = false;\r
+        }\r
+        String function = "Retain";\r
+        if ( delete ) {\r
+            function = "Delete";\r
+        }\r
+        if ( ( nodes == null ) || nodes.isEmpty() ) {\r
+            JOptionPane\r
+            .showMessageDialog( this,\r
+                                "Need to select external nodes, either via direct selection or via the \"Search\" function",\r
+                                "No external nodes selected to " + function.toLowerCase(),\r
+                                JOptionPane.ERROR_MESSAGE );\r
+            return;\r
+        }\r
+        final int todo = nodes.size();\r
+        final int ext = phy.getNumberOfExternalNodes();\r
+        int res = todo;\r
+        if ( delete ) {\r
+            res = ext - todo;\r
+        }\r
+        if ( res < 1 ) {\r
+            JOptionPane.showMessageDialog( this,\r
+                                           "Cannot delete all nodes",\r
+                                           "Attempt to delete all nodes ",\r
+                                           JOptionPane.ERROR_MESSAGE );\r
+            return;\r
+        }\r
+        final int result = JOptionPane.showConfirmDialog( null, function + " " + todo\r
+                                                          + " external node(s), from a total of " + ext + " external nodes," + "\nresulting in tree with " + res\r
+                                                          + " nodes?", function + " external nodes", JOptionPane.OK_CANCEL_OPTION );\r
+        if ( result == JOptionPane.OK_OPTION ) {\r
+            if ( !delete ) {\r
+                final List<PhylogenyNode> to_delete = new ArrayList<PhylogenyNode>();\r
+                for( final PhylogenyNodeIterator it = phy.iteratorExternalForward(); it.hasNext(); ) {\r
+                    final PhylogenyNode n = it.next();\r
+                    if ( !nodes.contains( n ) ) {\r
+                        to_delete.add( n );\r
+                    }\r
+                }\r
+                for( final PhylogenyNode n : to_delete ) {\r
+                    phy.deleteSubtree( n, true );\r
+                }\r
             }\r
-            if ( success && ( x > 1 ) && ( y > 1 ) ) {\r
-                getOptions().setPrintSizeX( x );\r
-                getOptions().setPrintSizeY( y );\r
+            else {\r
+                for( final PhylogenyNode n : nodes ) {\r
+                    phy.deleteSubtree( n, true );\r
+                }\r
             }\r
+            resetSearch();\r
+            getCurrentTreePanel().setNodeInPreorderToNull();\r
+            phy.externalNodesHaveChanged();\r
+            phy.clearHashIdToNodeMap();\r
+            phy.recalculateNumberOfExternalDescendants( true );\r
+            getCurrentTreePanel().resetNodeIdToDistToLeafMap();\r
+            getCurrentTreePanel().setEdited( true );\r
+            repaint();\r
         }\r
     }\r
 \r
-    void close() {\r
-        removeAllTextFrames();\r
-        if ( _mainpanel != null ) {\r
-            _mainpanel.terminate();\r
-        }\r
-        if ( _contentpane != null ) {\r
-            _contentpane.removeAll();\r
+    private void doUpdateProcessMenu() {\r
+        if ( _process_pool.size() > 0 ) {\r
+            if ( _process_menu == null ) {\r
+                _process_menu = createMenu( "", getConfiguration() );\r
+                _process_menu.setForeground( Color.RED );\r
+            }\r
+            _process_menu.removeAll();\r
+            final String text = "processes running: " + _process_pool.size();\r
+            _process_menu.setText( text );\r
+            _jmenubar.add( _process_menu );\r
+            for( int i = 0; i < _process_pool.size(); ++i ) {\r
+                final ProcessRunning p = _process_pool.getProcessByIndex( i );\r
+                _process_menu.add( customizeJMenuItem( new JMenuItem( p.getName() + " [" + p.getStart() + "]" ) ) );\r
+            }\r
         }\r
-        setVisible( false );\r
-        dispose();\r
-    }\r
-\r
-    void colorRank() {\r
-        if ( _mainpanel.getCurrentTreePanel() != null ) {\r
-            final String[] ranks = AptxUtil.getAllPossibleRanks();\r
-            final String rank = ( String ) JOptionPane\r
-                    .showInputDialog( this,\r
-                                      "What rank should the colorization be based on",\r
-                                      "Rank Selection",\r
-                                      JOptionPane.QUESTION_MESSAGE,\r
-                                      null,\r
-                                      ranks,\r
-                                      null );\r
-            if ( !ForesterUtil.isEmpty( rank ) ) {\r
-                _mainpanel.getCurrentTreePanel().colorRank( rank );\r
+        else {\r
+            if ( _process_menu != null ) {\r
+                _process_menu.removeAll();\r
+                _jmenubar.remove( _process_menu );\r
             }\r
         }\r
+        _jmenubar.validate();\r
+        _jmenubar.repaint();\r
+        repaint();\r
     }\r
 \r
-    void confColor() {\r
-        if ( _mainpanel.getCurrentTreePanel() != null ) {\r
-            _mainpanel.getCurrentTreePanel().confColor();\r
-        }\r
+    private String getPreviousNodeAnnotationReference() {\r
+        return _previous_node_annotation_ref;\r
     }\r
 \r
-    void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {\r
-        if ( item != null ) {\r
-            item.setFont( MainFrame.menu_font );\r
-            if ( !getConfiguration().isUseNativeUI() ) {\r
-                item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );\r
-                item.setForeground( getConfiguration().getGuiMenuTextColor() );\r
-            }\r
-            item.setSelected( is_selected );\r
-            item.addActionListener( this );\r
+    private void removeBranchColors() {\r
+        if ( getMainPanel().getCurrentPhylogeny() != null ) {\r
+            AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );\r
         }\r
     }\r
 \r
-    JMenuItem customizeJMenuItem( final JMenuItem jmi ) {\r
-        if ( jmi != null ) {\r
-            jmi.setFont( MainFrame.menu_font );\r
-            if ( !getConfiguration().isUseNativeUI() ) {\r
-                jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );\r
-                jmi.setForeground( getConfiguration().getGuiMenuTextColor() );\r
-            }\r
-            jmi.addActionListener( this );\r
+    private void removeVisualStyles() {\r
+        if ( getMainPanel().getCurrentPhylogeny() != null ) {\r
+            AptxUtil.removeVisualStyles( getMainPanel().getCurrentPhylogeny() );\r
         }\r
-        return jmi;\r
     }\r
 \r
-    void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {\r
-        if ( item != null ) {\r
-            item.setFont( MainFrame.menu_font );\r
-            if ( !getConfiguration().isUseNativeUI() ) {\r
-                item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );\r
-                item.setForeground( getConfiguration().getGuiMenuTextColor() );\r
-            }\r
-            item.setSelected( is_selected );\r
-            item.addActionListener( this );\r
-        }\r
+    private void setPreviousNodeAnnotationReference( final String previous_node_annotation_ref ) {\r
+        _previous_node_annotation_ref = previous_node_annotation_ref;\r
     }\r
 \r
-    void displayBasicInformation( final File treefile ) {\r
-        if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {\r
-            String title = "Basic Information";\r
-            if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {\r
-                title = title + " for \"" + _mainpanel.getCurrentPhylogeny().getName() + "\"";\r
-            }\r
-            showTextFrame( AptxUtil.createBasicInformation( _mainpanel.getCurrentPhylogeny(), treefile ), title );\r
+    private void writeAllToFile() {\r
+        if ( ( getMainPanel().getTabbedPane() == null ) || ( getMainPanel().getTabbedPane().getTabCount() < 1 ) ) {\r
+            return;\r
         }\r
-    }\r
-\r
-    void exceptionOccuredDuringOpenFile( final Exception e ) {\r
-        try {\r
-            _mainpanel.getCurrentTreePanel().setArrowCursor();\r
+        final File my_dir = getCurrentDir();\r
+        if ( my_dir != null ) {\r
+            _save_filechooser.setCurrentDirectory( my_dir );\r
         }\r
-        catch ( final Exception ex ) {\r
-            // Do nothing.\r
+        _save_filechooser.setSelectedFile( new File( "" ) );\r
+        final int result = _save_filechooser.showSaveDialog( _contentpane );\r
+        final File file = _save_filechooser.getSelectedFile();\r
+        setCurrentDir( _save_filechooser.getCurrentDirectory() );\r
+        if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
+            if ( file.exists() ) {\r
+                final int i = JOptionPane.showConfirmDialog( this,\r
+                                                             file + " already exists. Overwrite?",\r
+                                                             "Warning",\r
+                                                             JOptionPane.OK_CANCEL_OPTION,\r
+                                                             JOptionPane.WARNING_MESSAGE );\r
+                if ( i != JOptionPane.OK_OPTION ) {\r
+                    return;\r
+                }\r
+                else {\r
+                    try {\r
+                        file.delete();\r
+                    }\r
+                    catch ( final Exception e ) {\r
+                        JOptionPane.showMessageDialog( this,\r
+                                                       "Failed to delete: " + file,\r
+                                                       "Error",\r
+                                                       JOptionPane.WARNING_MESSAGE );\r
+                    }\r
+                }\r
+            }\r
+            final int count = getMainPanel().getTabbedPane().getTabCount();\r
+            final List<Phylogeny> trees = new ArrayList<Phylogeny>();\r
+            for( int i = 0; i < count; ++i ) {\r
+                final Phylogeny phy = getMainPanel().getPhylogeny( i );\r
+                if ( ForesterUtil.isEmpty( phy.getName() )\r
+                        && !ForesterUtil.isEmpty( getMainPanel().getTabbedPane().getTitleAt( i ) ) ) {\r
+                    phy.setName( getMainPanel().getTabbedPane().getTitleAt( i ) );\r
+                }\r
+                trees.add( phy );\r
+                getMainPanel().getTreePanels().get( i ).setEdited( false );\r
+            }\r
+            final PhylogenyWriter writer = new PhylogenyWriter();\r
+            try {\r
+                writer.toPhyloXML( file, trees, 0, ForesterUtil.LINE_SEPARATOR );\r
+            }\r
+            catch ( final IOException e ) {\r
+                JOptionPane.showMessageDialog( this,\r
+                                               "Failed to write to: " + file,\r
+                                               "Error",\r
+                                               JOptionPane.WARNING_MESSAGE );\r
+            }\r
         }\r
-        JOptionPane.showMessageDialog( this,\r
-                                       ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),\r
-                                       "Error during File|Open",\r
-                                       JOptionPane.ERROR_MESSAGE );\r
     }\r
 \r
-    static void exceptionOccuredDuringSaveAs( final Exception e, \r
-                                              final TreePanel tp,\r
-                                              final Component comp ) {\r
-        try {\r
-            tp.setArrowCursor();\r
+    void activateSaveAllIfNeeded() {\r
+        if ( ( getMainPanel().getTabbedPane() != null ) && ( getMainPanel().getTabbedPane().getTabCount() > 1 ) ) {\r
+            _save_all_item.setEnabled( true );\r
         }\r
-        catch ( final Exception ex ) {\r
-            // Do nothing.\r
+        else {\r
+            _save_all_item.setEnabled( false );\r
         }\r
-        JOptionPane.showMessageDialog( comp, "Exception" + e, "Error during File|SaveAs", JOptionPane.ERROR_MESSAGE );\r
     }\r
 \r
-    void executeGSDI() {\r
-        if ( !isOKforSDI( false, true ) ) {\r
-            return;\r
-        }\r
-        if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {\r
-            JOptionPane.showMessageDialog( this,\r
-                                           "Gene tree is not rooted.",\r
-                                           "Cannot execute GSDI",\r
-                                           JOptionPane.ERROR_MESSAGE );\r
-            return;\r
+    void buildFileMenu() {\r
+        _file_jmenu = MainFrame.createMenu( "File", getConfiguration() );\r
+        _file_jmenu.add( _save_item = new JMenuItem( "Save Tree As..." ) );\r
+        _file_jmenu.addSeparator();\r
+        _file_jmenu.add( _write_to_pdf_item = new JMenuItem( "Export to PDF file ..." ) );\r
+        if ( AptxUtil.canWriteFormat( "tif" ) || AptxUtil.canWriteFormat( "tiff" ) || AptxUtil.canWriteFormat( "TIF" ) ) {\r
+            _file_jmenu.add( _write_to_tif_item = new JMenuItem( "Export to TIFF file..." ) );\r
         }\r
-        final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();\r
-        gene_tree.setAllNodesToNotCollapse();\r
-        gene_tree.recalculateNumberOfExternalDescendants( false );\r
-        GSDI gsdi = null;\r
-        final Phylogeny species_tree = getSpeciesTree().copy();\r
-        try {\r
-            gsdi = new GSDI( gene_tree, species_tree, false, true, true, true );\r
+        _file_jmenu.add( _write_to_png_item = new JMenuItem( "Export to PNG file..." ) );\r
+        _file_jmenu.add( _write_to_jpg_item = new JMenuItem( "Export to JPG file..." ) );\r
+        if ( AptxUtil.canWriteFormat( "gif" ) ) {\r
+            _file_jmenu.add( _write_to_gif_item = new JMenuItem( "Export to GIF file..." ) );\r
         }\r
-        catch ( final SDIException e ) {\r
-            JOptionPane.showMessageDialog( this,\r
-                                           e.getLocalizedMessage(),\r
-                                           "Error during GSDI",\r
-                                           JOptionPane.ERROR_MESSAGE );\r
-            return;\r
+        if ( AptxUtil.canWriteFormat( "bmp" ) ) {\r
+            _file_jmenu.add( _write_to_bmp_item = new JMenuItem( "Export to BMP file..." ) );\r
+        }\r
+        _file_jmenu.addSeparator();\r
+        _file_jmenu.add( _print_item = new JMenuItem( "Print..." ) );\r
+        _file_jmenu.addSeparator();\r
+        _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );\r
+        customizeJMenuItem( _save_item );\r
+        customizeJMenuItem( _write_to_pdf_item );\r
+        customizeJMenuItem( _write_to_png_item );\r
+        customizeJMenuItem( _write_to_jpg_item );\r
+        customizeJMenuItem( _write_to_gif_item );\r
+        customizeJMenuItem( _write_to_tif_item );\r
+        customizeJMenuItem( _write_to_bmp_item );\r
+        customizeJMenuItem( _print_item );\r
+        customizeJMenuItem( _exit_item );\r
+        _jmenubar.add( _file_jmenu );\r
+    }\r
+\r
+    void buildFontSizeMenu() {\r
+        _font_size_menu = createMenu( FONT_SIZE_MENU_LABEL, getConfiguration() );\r
+        _font_size_menu.add( _super_tiny_fonts_item = new JMenuItem( "Super Tiny Fonts" ) );\r
+        _font_size_menu.add( _tiny_fonts_item = new JMenuItem( "Tiny Fonts" ) );\r
+        _font_size_menu.add( _small_fonts_item = new JMenuItem( "Small Fonts" ) );\r
+        _font_size_menu.add( _medium_fonts_item = new JMenuItem( "Medium Fonts" ) );\r
+        _font_size_menu.add( _large_fonts_item = new JMenuItem( "Large Fonts" ) );\r
+        customizeJMenuItem( _super_tiny_fonts_item );\r
+        customizeJMenuItem( _tiny_fonts_item );\r
+        customizeJMenuItem( _small_fonts_item );\r
+        customizeJMenuItem( _medium_fonts_item );\r
+        customizeJMenuItem( _large_fonts_item );\r
+        _jmenubar.add( _font_size_menu );\r
+    }\r
+\r
+    void buildHelpMenu() {\r
+        _help_jmenu = createMenu( "Help", getConfiguration() );\r
+        _help_jmenu.add( _help_item = new JMenuItem( "Documentation" ) );\r
+        _help_jmenu.addSeparator();\r
+        _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );\r
+        _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" ); //TODO need to add this...\r
+        _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );\r
+        _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );\r
+        _help_jmenu.addSeparator();\r
+        _help_jmenu.add( _about_item = new JMenuItem( "About" ) );\r
+        customizeJMenuItem( _help_item );\r
+        customizeJMenuItem( _website_item );\r
+        customizeJMenuItem( _phyloxml_website_item );\r
+        customizeJMenuItem( _aptx_ref_item );\r
+        customizeJMenuItem( _phyloxml_ref_item );\r
+        customizeJMenuItem( _about_item );\r
+        _phyloxml_ref_item.setToolTipText( PHYLOXML_REF_TOOL_TIP );\r
+        _aptx_ref_item.setToolTipText( APTX_REF_TOOL_TIP );\r
+        _jmenubar.add( _help_jmenu );\r
+    }\r
+\r
+    void buildTypeMenu() {\r
+        _type_menu = createMenu( TYPE_MENU_HEADER, getConfiguration() );\r
+        _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );\r
+        _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );\r
+        _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );\r
+        _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );\r
+        _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );\r
+        _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );\r
+        _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );\r
+        _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );\r
+        customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );\r
+        customizeCheckBoxMenuItem( _triangular_type_cbmi, false );\r
+        customizeCheckBoxMenuItem( _euro_type_cbmi, false );\r
+        customizeCheckBoxMenuItem( _rounded_type_cbmi, false );\r
+        customizeCheckBoxMenuItem( _curved_type_cbmi, false );\r
+        customizeCheckBoxMenuItem( _convex_type_cbmi, false );\r
+        customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );\r
+        customizeCheckBoxMenuItem( _circular_type_cbmi, false );\r
+        _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );\r
+        _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );\r
+        initializeTypeMenu( getOptions() );\r
+        _jmenubar.add( _type_menu );\r
+    }\r
+\r
+    void buildViewMenu() {\r
+        _view_jmenu = createMenu( "View", getConfiguration() );\r
+        _view_jmenu.add( _display_basic_information_item = new JMenuItem( SHOW_BASIC_TREE_INFORMATION_LABEL ) );\r
+        _view_jmenu.addSeparator();\r
+        _view_jmenu.add( _view_as_XML_item = new JMenuItem( "as phyloXML" ) );\r
+        _view_jmenu.add( _view_as_NH_item = new JMenuItem( "as Newick" ) );\r
+        _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "as Nexus" ) );\r
+        customizeJMenuItem( _display_basic_information_item );\r
+        customizeJMenuItem( _view_as_NH_item );\r
+        customizeJMenuItem( _view_as_XML_item );\r
+        customizeJMenuItem( _view_as_nexus_item );\r
+        _jmenubar.add( _view_jmenu );\r
+    }\r
+\r
+    void checkTextFrames() {\r
+        if ( _textframes.size() > 5 ) {\r
+            try {\r
+                if ( _textframes.getFirst() != null ) {\r
+                    _textframes.getFirst().removeMe();\r
+                }\r
+                else {\r
+                    _textframes.removeFirst();\r
+                }\r
+            }\r
+            catch ( final NoSuchElementException e ) {\r
+                // Ignore.\r
+            }\r
+        }\r
+    }\r
+\r
+    void choosePdfWidth() {\r
+        final String s = ( String ) JOptionPane.showInputDialog( this,\r
+                                                                 "Please enter the default line width for PDF export.\n"\r
+                                                                         + "[current value: "\r
+                                                                         + getOptions().getPrintLineWidth() + "]\n",\r
+                                                                         "Line Width for PDF Export",\r
+                                                                         JOptionPane.QUESTION_MESSAGE,\r
+                                                                         null,\r
+                                                                         null,\r
+                                                                         getOptions().getPrintLineWidth() );\r
+        if ( !ForesterUtil.isEmpty( s ) ) {\r
+            boolean success = true;\r
+            float f = 0.0f;\r
+            final String m_str = s.trim();\r
+            if ( !ForesterUtil.isEmpty( m_str ) ) {\r
+                try {\r
+                    f = Float.parseFloat( m_str );\r
+                }\r
+                catch ( final Exception ex ) {\r
+                    success = false;\r
+                }\r
+            }\r
+            else {\r
+                success = false;\r
+            }\r
+            if ( success && ( f > 0.0 ) ) {\r
+                getOptions().setPrintLineWidth( f );\r
+            }\r
+        }\r
+    }\r
+\r
+    void choosePrintSize() {\r
+        final String s = ( String ) JOptionPane.showInputDialog( this,\r
+                                                                 "Please enter values for width and height,\nseparated by a comma.\n"\r
+                                                                         + "[current values: "\r
+                                                                         + getOptions().getPrintSizeX() + ", "\r
+                                                                         + getOptions().getPrintSizeY() + "]\n"\r
+                                                                         + "[A4: " + Constants.A4_SIZE_X + ", "\r
+                                                                         + Constants.A4_SIZE_Y + "]\n" + "[US Letter: "\r
+                                                                         + Constants.US_LETTER_SIZE_X + ", "\r
+                                                                         + Constants.US_LETTER_SIZE_Y + "]",\r
+                                                                         "Default Size for Graphics Export",\r
+                                                                         JOptionPane.QUESTION_MESSAGE,\r
+                                                                         null,\r
+                                                                         null,\r
+                                                                         getOptions().getPrintSizeX() + ", "\r
+                                                                                 + getOptions().getPrintSizeY() );\r
+        if ( !ForesterUtil.isEmpty( s ) && ( s.indexOf( ',' ) > 0 ) ) {\r
+            boolean success = true;\r
+            int x = 0;\r
+            int y = 0;\r
+            final String[] str_ary = s.split( "," );\r
+            if ( str_ary.length == 2 ) {\r
+                final String x_str = str_ary[ 0 ].trim();\r
+                final String y_str = str_ary[ 1 ].trim();\r
+                if ( !ForesterUtil.isEmpty( x_str ) && !ForesterUtil.isEmpty( y_str ) ) {\r
+                    try {\r
+                        x = Integer.parseInt( x_str );\r
+                        y = Integer.parseInt( y_str );\r
+                    }\r
+                    catch ( final Exception ex ) {\r
+                        success = false;\r
+                    }\r
+                }\r
+                else {\r
+                    success = false;\r
+                }\r
+            }\r
+            else {\r
+                success = false;\r
+            }\r
+            if ( success && ( x > 1 ) && ( y > 1 ) ) {\r
+                getOptions().setPrintSizeX( x );\r
+                getOptions().setPrintSizeY( y );\r
+            }\r
+        }\r
+    }\r
+\r
+    void close() {\r
+        removeAllTextFrames();\r
+        if ( _mainpanel != null ) {\r
+            _mainpanel.terminate();\r
+        }\r
+        if ( _contentpane != null ) {\r
+            _contentpane.removeAll();\r
+        }\r
+        setVisible( false );\r
+        dispose();\r
+    }\r
+\r
+    void colorRank() {\r
+        if ( _mainpanel.getCurrentTreePanel() != null ) {\r
+            final String[] ranks = AptxUtil.getAllPossibleRanks();\r
+            final String rank = ( String ) JOptionPane\r
+                    .showInputDialog( this,\r
+                                      "What rank should the colorization be based on",\r
+                                      "Rank Selection",\r
+                                      JOptionPane.QUESTION_MESSAGE,\r
+                                      null,\r
+                                      ranks,\r
+                                      null );\r
+            if ( !ForesterUtil.isEmpty( rank ) ) {\r
+                _mainpanel.getCurrentTreePanel().colorRank( rank );\r
+            }\r
+        }\r
+    }\r
+\r
+    void confColor() {\r
+        if ( _mainpanel.getCurrentTreePanel() != null ) {\r
+            _mainpanel.getCurrentTreePanel().confColor();\r
+        }\r
+    }\r
+\r
+    void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {\r
+        if ( item != null ) {\r
+            item.setFont( MainFrame.menu_font );\r
+            if ( !getConfiguration().isUseNativeUI() ) {\r
+                item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );\r
+                item.setForeground( getConfiguration().getGuiMenuTextColor() );\r
+            }\r
+            item.setSelected( is_selected );\r
+            item.addActionListener( this );\r
+        }\r
+    }\r
+\r
+    JMenuItem customizeJMenuItem( final JMenuItem jmi ) {\r
+        if ( jmi != null ) {\r
+            jmi.setFont( MainFrame.menu_font );\r
+            if ( !getConfiguration().isUseNativeUI() ) {\r
+                jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );\r
+                jmi.setForeground( getConfiguration().getGuiMenuTextColor() );\r
+            }\r
+            jmi.addActionListener( this );\r
+        }\r
+        return jmi;\r
+    }\r
+\r
+    void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {\r
+        if ( item != null ) {\r
+            item.setFont( MainFrame.menu_font );\r
+            if ( !getConfiguration().isUseNativeUI() ) {\r
+                item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );\r
+                item.setForeground( getConfiguration().getGuiMenuTextColor() );\r
+            }\r
+            item.setSelected( is_selected );\r
+            item.addActionListener( this );\r
+        }\r
+    }\r
+\r
+    void displayBasicInformation( final File treefile ) {\r
+        if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {\r
+            String title = "Basic Information";\r
+            if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {\r
+                title = title + " for \"" + _mainpanel.getCurrentPhylogeny().getName() + "\"";\r
+            }\r
+            showTextFrame( AptxUtil.createBasicInformation( _mainpanel.getCurrentPhylogeny(), treefile ), title );\r
+        }\r
+    }\r
+\r
+    void exceptionOccuredDuringOpenFile( final Exception e ) {\r
+        try {\r
+            _mainpanel.getCurrentTreePanel().setArrowCursor();\r
+        }\r
+        catch ( final Exception ex ) {\r
+            // Do nothing.\r
+        }\r
+        JOptionPane.showMessageDialog( this,\r
+                                       ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),\r
+                                       "Error during File|Open",\r
+                                       JOptionPane.ERROR_MESSAGE );\r
+    }\r
+\r
+    void executeGSDI() {\r
+        if ( !isOKforSDI( false, true ) ) {\r
+            return;\r
+        }\r
+        if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {\r
+            JOptionPane.showMessageDialog( this,\r
+                                           "Gene tree is not rooted.",\r
+                                           "Cannot execute GSDI",\r
+                                           JOptionPane.ERROR_MESSAGE );\r
+            return;\r
+        }\r
+        final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();\r
+        gene_tree.setAllNodesToNotCollapse();\r
+        gene_tree.recalculateNumberOfExternalDescendants( false );\r
+        GSDI gsdi = null;\r
+        final Phylogeny species_tree = getSpeciesTree().copy();\r
+        try {\r
+            gsdi = new GSDI( gene_tree, species_tree, false, true, true, true );\r
+        }\r
+        catch ( final SDIException e ) {\r
+            JOptionPane.showMessageDialog( this,\r
+                                           e.getLocalizedMessage(),\r
+                                           "Error during GSDI",\r
+                                           JOptionPane.ERROR_MESSAGE );\r
+            return;\r
         }\r
         catch ( final Exception e ) {\r
             AptxUtil.unexpectedException( e );\r
@@ -1163,8 +1432,8 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                                                    + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"\r
                                                    + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"\r
                                                    + "Number of polytomies in species tree used: " + poly + "\n",\r
-                                           "GSDI successfully completed",\r
-                                           JOptionPane.WARNING_MESSAGE );\r
+                                                   "GSDI successfully completed",\r
+                                                   JOptionPane.WARNING_MESSAGE );\r
         }\r
         else {\r
             JOptionPane.showMessageDialog( this,\r
@@ -1176,8 +1445,8 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                                                    + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"\r
                                                    + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"\r
                                                    + "Number of polytomies in species tree used: " + poly + "\n",\r
-                                           "GSDI successfully completed",\r
-                                           JOptionPane.INFORMATION_MESSAGE );\r
+                                                   "GSDI successfully completed",\r
+                                                   JOptionPane.INFORMATION_MESSAGE );\r
         }\r
     }\r
 \r
@@ -1236,8 +1505,8 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                                                    + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"\r
                                                    + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"\r
                                                    + "Number of polytomies in species tree used: " + poly + "\n",\r
-                                           "GSDIR successfully completed",\r
-                                           JOptionPane.WARNING_MESSAGE );\r
+                                                   "GSDIR successfully completed",\r
+                                                   JOptionPane.WARNING_MESSAGE );\r
         }\r
         else {\r
             JOptionPane.showMessageDialog( this,\r
@@ -1247,8 +1516,8 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                                                    + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"\r
                                                    + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"\r
                                                    + "Number of polytomies in species tree used: " + poly + "\n",\r
-                                           "GSDIR successfully completed",\r
-                                           JOptionPane.INFORMATION_MESSAGE );\r
+                                                   "GSDIR successfully completed",\r
+                                                   JOptionPane.INFORMATION_MESSAGE );\r
         }\r
     }\r
 \r
@@ -1272,229 +1541,55 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }\r
     }\r
 \r
-    ControlPanel getControlPanel() {\r
-        return getMainPanel().getControlPanel();\r
-    }\r
-\r
-    File getCurrentDir() {\r
-        if ( ( _current_dir == null ) || !_current_dir.canRead() ) {\r
-            if ( ForesterUtil.isWindows() ) {\r
-                try {\r
-                    _current_dir = new File( WindowsUtils.getCurrentUserDesktopPath() );\r
-                }\r
-                catch ( final Exception e ) {\r
-                    _current_dir = null;\r
-                }\r
-            }\r
-        }\r
-        if ( ( _current_dir == null ) || !_current_dir.canRead() ) {\r
-            if ( System.getProperty( "user.home" ) != null ) {\r
-                _current_dir = new File( System.getProperty( "user.home" ) );\r
-            }\r
-            else if ( System.getProperty( "user.dir" ) != null ) {\r
-                _current_dir = new File( System.getProperty( "user.dir" ) );\r
-            }\r
-        }\r
-        return _current_dir;\r
-    }\r
-\r
-    TreePanel getCurrentTreePanel() {\r
-        return getMainPanel().getCurrentTreePanel();\r
-    }\r
-\r
-    JMenu getHelpMenu() {\r
-        return _help_jmenu;\r
-    }\r
-\r
-    JCheckBoxMenuItem getlabelDirectionCbmi() {\r
-        return _label_direction_cbmi;\r
-    }\r
-\r
-    JMenuBar getMenuBarOfMainFrame() {\r
-        return _jmenubar;\r
-    }\r
-\r
-    final Phylogeny getSpeciesTree() {\r
-        return _species_tree;\r
-    }\r
-\r
-    void initializeTypeMenu( final Options options ) {\r
-        setTypeMenuToAllUnselected();\r
-        switch ( options.getPhylogenyGraphicsType() ) {\r
-            case CONVEX:\r
-                _convex_type_cbmi.setSelected( true );\r
-                break;\r
-            case CURVED:\r
-                _curved_type_cbmi.setSelected( true );\r
-                break;\r
-            case EURO_STYLE:\r
-                _euro_type_cbmi.setSelected( true );\r
-                break;\r
-            case ROUNDED:\r
-                _rounded_type_cbmi.setSelected( true );\r
-                break;\r
-            case TRIANGULAR:\r
-                _triangular_type_cbmi.setSelected( true );\r
-                break;\r
-            case UNROOTED:\r
-                _unrooted_type_cbmi.setSelected( true );\r
-                break;\r
-            case CIRCULAR:\r
-                _circular_type_cbmi.setSelected( true );\r
-                break;\r
-            default:\r
-                _rectangular_type_cbmi.setSelected( true );\r
-                break;\r
-        }\r
-    }\r
-\r
-    boolean isOKforSDI( final boolean species_tree_has_to_binary, final boolean gene_tree_has_to_binary ) {\r
-        if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty() ) {\r
-            return false;\r
-        }\r
-        else if ( ( getSpeciesTree() == null ) || getSpeciesTree().isEmpty() ) {\r
-            JOptionPane.showMessageDialog( this,\r
-                                           "No species tree loaded",\r
-                                           "Cannot execute GSDI",\r
-                                           JOptionPane.ERROR_MESSAGE );\r
-            return false;\r
-        }\r
-        else if ( species_tree_has_to_binary && !getSpeciesTree().isCompletelyBinary() ) {\r
-            JOptionPane.showMessageDialog( this,\r
-                                           "Species tree is not completely binary",\r
-                                           "Cannot execute GSDI",\r
-                                           JOptionPane.ERROR_MESSAGE );\r
-            return false;\r
-        }\r
-        else if ( gene_tree_has_to_binary && !_mainpanel.getCurrentPhylogeny().isCompletelyBinary() ) {\r
-            JOptionPane.showMessageDialog( this,\r
-                                           "Gene tree is not completely binary",\r
-                                           "Cannot execute GSDI",\r
-                                           JOptionPane.ERROR_MESSAGE );\r
-            return false;\r
-        }\r
-        else {\r
-            return true;\r
-        }\r
-    }\r
-\r
-    boolean isSubtreeDisplayed() {\r
-        if ( getCurrentTreePanel() != null ) {\r
-            if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {\r
-                JOptionPane\r
-                        .showMessageDialog( this,\r
-                                            "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",\r
-                                            "Operation can not be exectuted on a sub-tree",\r
-                                            JOptionPane.WARNING_MESSAGE );\r
-                return true;\r
-            }\r
-        }\r
-        return false;\r
-    }\r
-\r
-    void midpointRoot() {\r
-        if ( _mainpanel.getCurrentTreePanel() != null ) {\r
-            _mainpanel.getCurrentTreePanel().midpointRoot();\r
-        }\r
-    }\r
-\r
-    static void printPhylogenyToPdf( final String file_name,\r
-                                     final Options opts,\r
-                                     final TreePanel tp,\r
-                                     final Component comp ) {\r
-        if ( !opts.isPrintUsingActualSize() ) {\r
-            tp.calcParametersForPainting( opts.getPrintSizeX(), opts.getPrintSizeY() );\r
-            tp.resetPreferredSize();\r
-            tp.repaint();\r
-        }\r
-        String pdf_written_to = "";\r
-        boolean error = false;\r
-        try {\r
-            if ( opts.isPrintUsingActualSize() ) {\r
-                pdf_written_to = PdfExporter.writePhylogenyToPdf( file_name, tp, tp.getWidth(), tp.getHeight() );\r
-            }\r
-            else {\r
-                pdf_written_to = PdfExporter.writePhylogenyToPdf( file_name,\r
-                                                                  tp,\r
-                                                                  opts.getPrintSizeX(),\r
-                                                                  opts.getPrintSizeY() );\r
-            }\r
-        }\r
-        catch ( final IOException e ) {\r
-            error = true;\r
-            JOptionPane.showMessageDialog( comp, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE );\r
-        }\r
-        if ( !error ) {\r
-            if ( !ForesterUtil.isEmpty( pdf_written_to ) ) {\r
-                JOptionPane.showMessageDialog( comp,\r
-                                               "Wrote PDF to: " + pdf_written_to,\r
-                                               "Information",\r
-                                               JOptionPane.INFORMATION_MESSAGE );\r
-            }\r
-            else {\r
-                JOptionPane.showMessageDialog( comp,\r
-                                               "There was an unknown problem when attempting to write to PDF file: \""\r
-                                                       + file_name + "\"",\r
-                                               "Error",\r
-                                               JOptionPane.ERROR_MESSAGE );\r
-            }\r
-        }\r
-        if ( !opts.isPrintUsingActualSize() ) {\r
-            tp.getControlPanel().showWhole();\r
-        }\r
-    }\r
-\r
-    void readPhylogeniesFromWebservice( final int i ) {\r
-        final UrlTreeReader reader = new UrlTreeReader( this, i );\r
-        new Thread( reader ).start();\r
+    ControlPanel getControlPanel() {\r
+        return getMainPanel().getControlPanel();\r
     }\r
 \r
-    void removeAllTextFrames() {\r
-        for( final TextFrame tf : _textframes ) {\r
-            if ( tf != null ) {\r
-                tf.close();\r
+    File getCurrentDir() {\r
+        if ( ( _current_dir == null ) || !_current_dir.canRead() ) {\r
+            if ( ForesterUtil.isWindows() ) {\r
+                try {\r
+                    _current_dir = new File( WindowsUtils.getCurrentUserDesktopPath() );\r
+                }\r
+                catch ( final Exception e ) {\r
+                    _current_dir = null;\r
+                }\r
             }\r
         }\r
-        _textframes.clear();\r
+        if ( ( _current_dir == null ) || !_current_dir.canRead() ) {\r
+            if ( System.getProperty( "user.home" ) != null ) {\r
+                _current_dir = new File( System.getProperty( "user.home" ) );\r
+            }\r
+            else if ( System.getProperty( "user.dir" ) != null ) {\r
+                _current_dir = new File( System.getProperty( "user.dir" ) );\r
+            }\r
+        }\r
+        return _current_dir;\r
     }\r
 \r
-    void resetSearch() {\r
-        getMainPanel().getCurrentTreePanel().setFoundNodes0( null );\r
-        getMainPanel().getCurrentTreePanel().setFoundNodes1( null );\r
-        getMainPanel().getControlPanel().setSearchFoundCountsOnLabel0( 0 );\r
-        getMainPanel().getControlPanel().getSearchFoundCountsLabel0().setVisible( false );\r
-        getMainPanel().getControlPanel().getSearchTextField0().setText( "" );\r
-        getMainPanel().getControlPanel().getSearchResetButton0().setEnabled( false );\r
-        getMainPanel().getControlPanel().getSearchResetButton0().setVisible( false );\r
-        getMainPanel().getControlPanel().setSearchFoundCountsOnLabel1( 0 );\r
-        getMainPanel().getControlPanel().getSearchFoundCountsLabel1().setVisible( false );\r
-        getMainPanel().getControlPanel().getSearchTextField1().setText( "" );\r
-        getMainPanel().getControlPanel().getSearchResetButton1().setEnabled( false );\r
-        getMainPanel().getControlPanel().getSearchResetButton1().setVisible( false );\r
+    TreePanel getCurrentTreePanel() {\r
+        return getMainPanel().getCurrentTreePanel();\r
     }\r
 \r
-    void setConfiguration( final Configuration configuration ) {\r
-        _configuration = configuration;\r
+    JMenu getHelpMenu() {\r
+        return _help_jmenu;\r
     }\r
 \r
-    void setCurrentDir( final File current_dir ) {\r
-        _current_dir = current_dir;\r
+    JCheckBoxMenuItem getlabelDirectionCbmi() {\r
+        return _label_direction_cbmi;\r
     }\r
 \r
-    void setInferenceManager( final InferenceManager i ) {\r
-        _inference_manager = i;\r
+    JMenuBar getMenuBarOfMainFrame() {\r
+        return _jmenubar;\r
     }\r
 \r
-    void setOptions( final Options options ) {\r
-        _options = options;\r
+    final Phylogeny getSpeciesTree() {\r
+        return _species_tree;\r
     }\r
 \r
-    void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {\r
+    void initializeTypeMenu( final Options options ) {\r
         setTypeMenuToAllUnselected();\r
-        switch ( type ) {\r
-            case CIRCULAR:\r
-                _circular_type_cbmi.setSelected( true );\r
-                break;\r
+        switch ( options.getPhylogenyGraphicsType() ) {\r
             case CONVEX:\r
                 _convex_type_cbmi.setSelected( true );\r
                 break;\r
@@ -1507,861 +1602,404 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             case ROUNDED:\r
                 _rounded_type_cbmi.setSelected( true );\r
                 break;\r
-            case RECTANGULAR:\r
-                _rectangular_type_cbmi.setSelected( true );\r
-                break;\r
             case TRIANGULAR:\r
                 _triangular_type_cbmi.setSelected( true );\r
                 break;\r
             case UNROOTED:\r
                 _unrooted_type_cbmi.setSelected( true );\r
                 break;\r
+            case CIRCULAR:\r
+                _circular_type_cbmi.setSelected( true );\r
+                break;\r
             default:\r
-                throw new IllegalArgumentException( "unknown type: " + type );\r
-        }\r
-    }\r
-\r
-    final void setSpeciesTree( final Phylogeny species_tree ) {\r
-        _species_tree = species_tree;\r
-    }\r
-\r
-    void setTypeMenuToAllUnselected() {\r
-        _convex_type_cbmi.setSelected( false );\r
-        _curved_type_cbmi.setSelected( false );\r
-        _euro_type_cbmi.setSelected( false );\r
-        _rounded_type_cbmi.setSelected( false );\r
-        _triangular_type_cbmi.setSelected( false );\r
-        _rectangular_type_cbmi.setSelected( false );\r
-        _unrooted_type_cbmi.setSelected( false );\r
-        _circular_type_cbmi.setSelected( false );\r
-    }\r
-\r
-    void switchColors() {\r
-        final TreeColorSet colorset = _mainpanel.getTreeColorSet();\r
-        final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );\r
-        csc.setVisible( true );\r
-    }\r
-\r
-    void taxColor() {\r
-        if ( _mainpanel.getCurrentTreePanel() != null ) {\r
-            _mainpanel.getCurrentTreePanel().taxColor();\r
-        }\r
-    }\r
-\r
-    void typeChanged( final Object o ) {\r
-        updateTypeCheckboxes( getOptions(), o );\r
-        updateOptions( getOptions() );\r
-        if ( getCurrentTreePanel() != null ) {\r
-            final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();\r
-            final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();\r
-            if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )\r
-                    || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )\r
-                    || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )\r
-                    || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {\r
-                getCurrentTreePanel().getControlPanel().showWhole();\r
-            }\r
-            if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {\r
-                getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );\r
-            }\r
-            else {\r
-                getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );\r
-            }\r
-            getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );\r
-            updateScreenTextAntialias( getMainPanel().getTreePanels() );\r
-            if ( getCurrentTreePanel().getControlPanel().getDynamicallyHideData() != null ) {\r
-                if ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {\r
-                    getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( false );\r
-                }\r
-                else {\r
-                    getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( true );\r
-                }\r
-            }\r
+                _rectangular_type_cbmi.setSelected( true );\r
+                break;\r
         }\r
     }\r
 \r
-    void updateOptions( final Options options ) {\r
-        options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );\r
-        options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )\r
-                && _background_gradient_cbmi.isSelected() );\r
-        options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );\r
-        options.setShowAnnotationRefSource( ( _show_annotation_ref_source != null )\r
-                && _show_annotation_ref_source.isSelected() );\r
-        options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )\r
-                && _abbreviate_scientific_names.isSelected() );\r
-        options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )\r
-                && _color_labels_same_as_parent_branch.isSelected() );\r
-        options.setShowDefaultNodeShapesInternal( ( _show_default_node_shapes_internal_cbmi != null )\r
-                && _show_default_node_shapes_internal_cbmi.isSelected() );\r
-        options.setShowDefaultNodeShapesExternal( ( _show_default_node_shapes_external_cbmi != null )\r
-                && _show_default_node_shapes_external_cbmi.isSelected() );\r
-        options.setShowDefaultNodeShapesForMarkedNodes( ( _show_default_node_shapes_for_marked_cbmi != null )\r
-                && _show_default_node_shapes_for_marked_cbmi.isSelected() );\r
-        if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {\r
-            options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );\r
-        }\r
-        else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {\r
-            options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );\r
-        }\r
-        else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {\r
-            options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );\r
-        }\r
-        options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )\r
-                && _search_case_senstive_cbmi.isSelected() );\r
-        if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {\r
-            options.setShowScale( _show_scale_cbmi.isSelected() );\r
-        }\r
-        if ( _label_direction_cbmi != null ) {\r
-            if ( _label_direction_cbmi.isSelected() ) {\r
-                options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );\r
-            }\r
-            else {\r
-                options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );\r
-            }\r
-        }\r
-        options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );\r
-        options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )\r
-                && _show_confidence_stddev_cbmi.isSelected() );\r
-        if ( ( _color_by_taxonomic_group_cbmi != null ) && _color_by_taxonomic_group_cbmi.isEnabled() ) {\r
-            options.setColorByTaxonomicGroup( _color_by_taxonomic_group_cbmi.isSelected() );\r
-        }\r
-        options.setPrintUsingActualSize( ( _print_using_actual_size_cbmi != null )\r
-                && ( _print_using_actual_size_cbmi.isSelected() ) );\r
-        options.setGraphicsExportUsingActualSize( ( _graphics_export_using_actual_size_cbmi != null )\r
-                && ( _graphics_export_using_actual_size_cbmi.isSelected() ) );\r
-        options.setAntialiasPrint( ( _antialias_print_cbmi != null ) && _antialias_print_cbmi.isSelected() );\r
-        if ( ( _use_brackets_for_conf_in_nh_export_cbmi != null )\r
-                && _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {\r
-            options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );\r
-        }\r
-        else if ( ( _use_internal_names_for_conf_in_nh_export_cbmi != null )\r
-                && _use_internal_names_for_conf_in_nh_export_cbmi.isSelected() ) {\r
-            options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES );\r
-        }\r
-        else {\r
-            options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE );\r
-        }\r
-        options.setPrintBlackAndWhite( ( _print_black_and_white_cbmi != null )\r
-                && _print_black_and_white_cbmi.isSelected() );\r
-        options.setInternalNumberAreConfidenceForNhParsing( ( _internal_number_are_confidence_for_nh_parsing_cbmi != null )\r
-                && _internal_number_are_confidence_for_nh_parsing_cbmi.isSelected() );\r
-        if ( ( _extract_taxonomy_pfam_strict_rbmi != null ) && _extract_taxonomy_pfam_strict_rbmi.isSelected() ) {\r
-            options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );\r
-        }\r
-        else if ( ( _extract_taxonomy_pfam_relaxed_rbmi != null ) && _extract_taxonomy_pfam_relaxed_rbmi.isSelected() ) {\r
-            options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );\r
-        }\r
-        else if ( ( _extract_taxonomy_agressive_rbmi != null ) && _extract_taxonomy_agressive_rbmi.isSelected() ) {\r
-            options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.AGGRESSIVE );\r
-        }\r
-        else if ( ( _extract_taxonomy_no_rbmi != null ) && _extract_taxonomy_no_rbmi.isSelected() ) {\r
-            options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.NO );\r
-        }\r
-        options.setReplaceUnderscoresInNhParsing( ( _replace_underscores_cbmi != null )\r
-                && _replace_underscores_cbmi.isSelected() );\r
-        options.setAllowErrorsInDistanceToParent( ( _allow_errors_in_distance_to_parent_cbmi != null )\r
-                && _allow_errors_in_distance_to_parent_cbmi.isSelected() );\r
-        options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )\r
-                && _search_whole_words_only_cbmi.isSelected() );\r
-        options.setSearchWithRegex( ( _search_with_regex_cbmi != null ) && _search_with_regex_cbmi.isSelected() );\r
-        options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )\r
-                && _inverse_search_result_cbmi.isSelected() );\r
-        if ( _graphics_export_visible_only_cbmi != null ) {\r
-            options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() );\r
-            if ( _graphics_export_visible_only_cbmi.isSelected() && ( _graphics_export_using_actual_size_cbmi != null ) ) {\r
-                _graphics_export_using_actual_size_cbmi.setSelected( true );\r
-                _graphics_export_using_actual_size_cbmi.setEnabled( false );\r
-            }\r
-            else {\r
-                _graphics_export_using_actual_size_cbmi.setEnabled( true );\r
-            }\r
-        }\r
-        if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {\r
-            options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );\r
-        }\r
-        else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {\r
-            options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );\r
-        }\r
-        else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {\r
-            options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );\r
-        }\r
-        else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {\r
-            options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );\r
-        }\r
-        else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {\r
-            options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );\r
-        }\r
-        else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {\r
-            options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );\r
+    boolean isOKforSDI( final boolean species_tree_has_to_binary, final boolean gene_tree_has_to_binary ) {\r
+        if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty() ) {\r
+            return false;\r
         }\r
-        else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {\r
-            options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );\r
+        else if ( ( getSpeciesTree() == null ) || getSpeciesTree().isEmpty() ) {\r
+            JOptionPane.showMessageDialog( this,\r
+                                           "No species tree loaded",\r
+                                           "Cannot execute GSDI",\r
+                                           JOptionPane.ERROR_MESSAGE );\r
+            return false;\r
         }\r
-        else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {\r
-            options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );\r
+        else if ( species_tree_has_to_binary && !getSpeciesTree().isCompletelyBinary() ) {\r
+            JOptionPane.showMessageDialog( this,\r
+                                           "Species tree is not completely binary",\r
+                                           "Cannot execute GSDI",\r
+                                           JOptionPane.ERROR_MESSAGE );\r
+            return false;\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
+        else if ( gene_tree_has_to_binary && !_mainpanel.getCurrentPhylogeny().isCompletelyBinary() ) {\r
+            JOptionPane.showMessageDialog( this,\r
+                                           "Gene tree is not completely binary",\r
+                                           "Cannot execute GSDI",\r
+                                           JOptionPane.ERROR_MESSAGE );\r
+            return false;\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
+        else {\r
+            return true;\r
         }\r
     }\r
 \r
-    void updateTypeCheckboxes( final Options options, final Object o ) {\r
-        setTypeMenuToAllUnselected();\r
-        ( ( JCheckBoxMenuItem ) o ).setSelected( true );\r
-    }\r
-\r
-    void viewAsNexus() {\r
-        if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {\r
-            String title = "Nexus";\r
-            if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {\r
-                title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;\r
+    boolean isSubtreeDisplayed() {\r
+        if ( getCurrentTreePanel() != null ) {\r
+            if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {\r
+                JOptionPane\r
+                .showMessageDialog( this,\r
+                                    "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",\r
+                                    "Operation can not be exectuted on a sub-tree",\r
+                                    JOptionPane.WARNING_MESSAGE );\r
+                return true;\r
             }\r
-            showTextFrame( _mainpanel.getCurrentPhylogeny().toNexus( getOptions().getNhConversionSupportValueStyle() ),\r
-                           title );\r
         }\r
+        return false;\r
     }\r
 \r
-    void viewAsNH() {\r
-        if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {\r
-            String title = "New Hampshire";\r
-            if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {\r
-                title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;\r
-            }\r
-            showTextFrame( _mainpanel.getCurrentPhylogeny().toNewHampshire( getOptions()\r
-                                   .getNhConversionSupportValueStyle() ),\r
-                           title );\r
+    void midpointRoot() {\r
+        if ( _mainpanel.getCurrentTreePanel() != null ) {\r
+            _mainpanel.getCurrentTreePanel().midpointRoot();\r
         }\r
     }\r
 \r
-    void viewAsXML() {\r
-        if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {\r
-            String title = "phyloXML";\r
-            if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {\r
-                title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;\r
+    void readPhylogeniesFromWebservice( final int i ) {\r
+        final UrlTreeReader reader = new UrlTreeReader( this, i );\r
+        new Thread( reader ).start();\r
+    }\r
+\r
+    void removeAllTextFrames() {\r
+        for( final TextFrame tf : _textframes ) {\r
+            if ( tf != null ) {\r
+                tf.close();\r
             }\r
-            showTextFrame( _mainpanel.getCurrentPhylogeny().toPhyloXML( 0 ), title );\r
         }\r
+        _textframes.clear();\r
     }\r
 \r
-    static boolean writeAsNewHampshire( final TreePanel tp,\r
-                                        final Options op,\r
-                                        boolean exception,\r
-                                        final File file ) {\r
-        try {\r
-            final PhylogenyWriter writer = new PhylogenyWriter();\r
-            writer.toNewHampshire( tp.getPhylogeny(), true, op.getNhConversionSupportValueStyle(), file );\r
-        }\r
-        catch ( final Exception e ) {\r
-            exception = true;\r
-            exceptionOccuredDuringSaveAs( e, tp, tp);\r
-        }\r
-        return exception;\r
+    void resetSearch() {\r
+        getMainPanel().getCurrentTreePanel().setFoundNodes0( null );\r
+        getMainPanel().getCurrentTreePanel().setFoundNodes1( null );\r
+        getMainPanel().getControlPanel().setSearchFoundCountsOnLabel0( 0 );\r
+        getMainPanel().getControlPanel().getSearchFoundCountsLabel0().setVisible( false );\r
+        getMainPanel().getControlPanel().getSearchTextField0().setText( "" );\r
+        getMainPanel().getControlPanel().getSearchResetButton0().setEnabled( false );\r
+        getMainPanel().getControlPanel().getSearchResetButton0().setVisible( false );\r
+        getMainPanel().getControlPanel().setSearchFoundCountsOnLabel1( 0 );\r
+        getMainPanel().getControlPanel().getSearchFoundCountsLabel1().setVisible( false );\r
+        getMainPanel().getControlPanel().getSearchTextField1().setText( "" );\r
+        getMainPanel().getControlPanel().getSearchResetButton1().setEnabled( false );\r
+        getMainPanel().getControlPanel().getSearchResetButton1().setVisible( false );\r
     }\r
 \r
-   \r
-    \r
-    \r
-    static boolean writeAsNexus( final TreePanel tp,\r
-                                        final Options op,\r
-                                        boolean exception,\r
-                                        final File file ) {\r
-        try {\r
-            final PhylogenyWriter writer = new PhylogenyWriter();\r
-            writer.toNexus(file , tp.getPhylogeny(),  op.getNhConversionSupportValueStyle());\r
-        }\r
-        catch ( final Exception e ) {\r
-            exception = true;\r
-            exceptionOccuredDuringSaveAs( e, tp, tp);\r
-        }\r
-        return exception;\r
+    void setConfiguration( final Configuration configuration ) {\r
+        _configuration = configuration;\r
     }\r
-    \r
-    \r
-    \r
 \r
-    static boolean writeAsPhyloXml( final TreePanel tp,\r
-                             final Options op,\r
-                             boolean exception,\r
-                             final File file ) {\r
-        try {\r
-            final PhylogenyWriter writer = new PhylogenyWriter();\r
-            writer.toPhyloXML( file, tp.getPhylogeny(), 0 );\r
-        }\r
-        catch ( final Exception e ) {\r
-            exception = true;\r
-            exceptionOccuredDuringSaveAs( e, tp, tp);\r
-        }\r
-        return exception;\r
+    void setCurrentDir( final File current_dir ) {\r
+        _current_dir = current_dir;\r
     }\r
 \r
-    static void writePhylogenyToGraphicsFile( final String file_name,\r
-                                              final GraphicsExportType type,\r
-                                              final MainPanel mp,\r
-                                              final Component comp,\r
-                                              final Container contentpane ) {\r
-        mp.getCurrentTreePanel().calcParametersForPainting( mp.getCurrentTreePanel().getWidth(),\r
-                                                            mp.getCurrentTreePanel().getHeight() );\r
-        String file_written_to = "";\r
-        boolean error = false;\r
-        try {\r
-            file_written_to = AptxUtil.writePhylogenyToGraphicsFile( file_name,\r
-                                                                     mp.getCurrentTreePanel().getWidth(),\r
-                                                                     mp.getCurrentTreePanel().getHeight(),\r
-                                                                     mp.getCurrentTreePanel(),\r
-                                                                     mp.getControlPanel(),\r
-                                                                     type,\r
-                                                                     mp.getOptions() );\r
-        }\r
-        catch ( final IOException e ) {\r
-            error = true;\r
-            JOptionPane.showMessageDialog( comp, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE );\r
-        }\r
-        if ( !error ) {\r
-            if ( ( file_written_to != null ) && ( file_written_to.length() > 0 ) ) {\r
-                JOptionPane.showMessageDialog( comp,\r
-                                               "Wrote image to: " + file_written_to,\r
-                                               "Graphics Export",\r
-                                               JOptionPane.INFORMATION_MESSAGE );\r
-            }\r
-            else {\r
-                JOptionPane.showMessageDialog( comp,\r
-                                               "There was an unknown problem when attempting to write to an image file: \""\r
-                                                       + file_name + "\"",\r
-                                               "Error",\r
-                                               JOptionPane.ERROR_MESSAGE );\r
-            }\r
-        }\r
-        contentpane.repaint();\r
+    void setInferenceManager( final InferenceManager i ) {\r
+        _inference_manager = i;\r
     }\r
 \r
-    static File writeToFile( final Phylogeny t,\r
-                             final MainPanel mp,\r
-                             final JFileChooser save_filechooser,\r
-                             final File current_dir,\r
-                             Container contentpane,\r
-                             Component comp\r
-            \r
-            ) {\r
-        File  new_file = null;\r
-        if ( t == null ) {\r
-            return null;\r
-        }\r
-        String initial_filename = null;\r
-        if ( mp.getCurrentTreePanel().getTreeFile() != null ) {\r
-            try {\r
-                initial_filename = mp.getCurrentTreePanel().getTreeFile().getCanonicalPath();\r
-            }\r
-            catch ( final IOException e ) {\r
-                initial_filename = null;\r
-            }\r
-        }\r
-        if ( !ForesterUtil.isEmpty( initial_filename ) ) {\r
-            save_filechooser.setSelectedFile( new File( initial_filename ) );\r
-        }\r
-        else {\r
-            save_filechooser.setSelectedFile( new File( "" ) );\r
-        }\r
-        final File my_dir = current_dir;\r
-        if ( my_dir != null ) {\r
-            save_filechooser.setCurrentDirectory( my_dir );\r
-        }\r
-        final int result = save_filechooser.showSaveDialog( contentpane );\r
-        final File file = save_filechooser.getSelectedFile();\r
-      \r
-        new_file =  save_filechooser.getCurrentDirectory();\r
-        boolean exception = false;\r
-        if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
-            if ( file.exists() ) {\r
-                final int i = JOptionPane.showConfirmDialog( comp,\r
-                                                             file + " already exists.\nOverwrite?",\r
-                                                             "Overwrite?",\r
-                                                             JOptionPane.OK_CANCEL_OPTION,\r
-                                                             JOptionPane.QUESTION_MESSAGE );\r
-                if ( i != JOptionPane.OK_OPTION ) {\r
-                    return null;\r
-                }\r
-                else {\r
-                    final File to = new File( file.getAbsoluteFile().toString() + Constants.BACKUP_FILE_SUFFIX );\r
-                    try {\r
-                        ForesterUtil.copyFile( file, to );\r
-                    }\r
-                    catch ( final Exception e ) {\r
-                        JOptionPane.showMessageDialog( comp,\r
-                                                       "Failed to create backup copy " + to,\r
-                                                       "Failed to Create Backup Copy",\r
-                                                       JOptionPane.WARNING_MESSAGE );\r
-                    }\r
-                    try {\r
-                        file.delete();\r
-                    }\r
-                    catch ( final Exception e ) {\r
-                        JOptionPane.showMessageDialog( comp,\r
-                                                       "Failed to delete: " + file,\r
-                                                       "Failed to Delete",\r
-                                                       JOptionPane.WARNING_MESSAGE );\r
-                    }\r
-                }\r
-            }\r
-            if ( save_filechooser.getFileFilter() == MainFrame.nhfilter ) {\r
-               \r
-                \r
-                exception = writeAsNewHampshire( mp.getCurrentTreePanel(), mp.getOptions(), exception, file );\r
-            }\r
-            else if ( save_filechooser.getFileFilter() == MainFrame.xmlfilter ) {\r
-                \r
-                exception =  writeAsPhyloXml(   mp.getCurrentTreePanel(), mp.getOptions(),\r
-                                 exception,\r
-                                  file ) ;\r
-                \r
-            }\r
-            else if ( save_filechooser.getFileFilter() == MainFrame.nexusfilter ) {\r
-                \r
-               exception = writeAsNexus( mp.getCurrentTreePanel(), mp.getOptions(), exception, file );\r
-            }\r
-            // "*.*":\r
-            else {\r
-                final String file_name = file.getName().trim().toLowerCase();\r
-                if ( file_name.endsWith( ".nh" ) || file_name.endsWith( ".newick" ) || file_name.endsWith( ".phy" )\r
-                        || file_name.endsWith( ".tree" ) ) {\r
-                    exception = writeAsNewHampshire( mp.getCurrentTreePanel(), mp.getOptions(), exception, file );\r
-                    \r
-                }\r
-                else if ( file_name.endsWith( ".nex" ) || file_name.endsWith( ".nexus" ) ) {\r
-                    exception = writeAsNexus(  mp.getCurrentTreePanel(), mp.getOptions(), exception, file );\r
-                }\r
-                // XML is default:\r
-                else {\r
-                    exception =  writeAsPhyloXml(   mp.getCurrentTreePanel(), mp.getOptions(),\r
-                                                    exception,\r
-                                                     file ) ;\r
-                }\r
-            }\r
-            if ( !exception ) {\r
-                mp.setTitleOfSelectedTab( file.getName() );\r
-                mp.getCurrentTreePanel().setTreeFile( file );\r
-                mp.getCurrentTreePanel().setEdited( false );\r
-            }\r
+    void setOptions( final Options options ) {\r
+        _options = options;\r
+    }\r
+\r
+    void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {\r
+        setTypeMenuToAllUnselected();\r
+        switch ( type ) {\r
+            case CIRCULAR:\r
+                _circular_type_cbmi.setSelected( true );\r
+                break;\r
+            case CONVEX:\r
+                _convex_type_cbmi.setSelected( true );\r
+                break;\r
+            case CURVED:\r
+                _curved_type_cbmi.setSelected( true );\r
+                break;\r
+            case EURO_STYLE:\r
+                _euro_type_cbmi.setSelected( true );\r
+                break;\r
+            case ROUNDED:\r
+                _rounded_type_cbmi.setSelected( true );\r
+                break;\r
+            case RECTANGULAR:\r
+                _rectangular_type_cbmi.setSelected( true );\r
+                break;\r
+            case TRIANGULAR:\r
+                _triangular_type_cbmi.setSelected( true );\r
+                break;\r
+            case UNROOTED:\r
+                _unrooted_type_cbmi.setSelected( true );\r
+                break;\r
+            default:\r
+                throw new IllegalArgumentException( "unknown type: " + type );\r
         }\r
-        return new_file;\r
     }\r
 \r
-    static File writeToGraphicsFile( final Phylogeny t,\r
-                                     final GraphicsExportType type,\r
-                                     final MainPanel mp,\r
-                                     final JFileChooser writetographics_filechooser,\r
-                                     final Component component,\r
-                                     final Container contentpane,\r
-                                     final File current_dir ) {\r
-        File new_dir = null;\r
-        if ( ( t == null ) || t.isEmpty() ) {\r
-            return null;\r
-        }\r
-        String initial_filename = "";\r
-        if ( mp.getCurrentTreePanel().getTreeFile() != null ) {\r
-            initial_filename = mp.getCurrentTreePanel().getTreeFile().toString();\r
-        }\r
-        if ( initial_filename.indexOf( '.' ) > 0 ) {\r
-            initial_filename = initial_filename.substring( 0, initial_filename.lastIndexOf( '.' ) );\r
-        }\r
-        initial_filename = initial_filename + "." + type;\r
-        writetographics_filechooser.setSelectedFile( new File( initial_filename ) );\r
-        final File my_dir = current_dir;\r
-        if ( my_dir != null ) {\r
-            writetographics_filechooser.setCurrentDirectory( my_dir );\r
+    final void setSpeciesTree( final Phylogeny species_tree ) {\r
+        _species_tree = species_tree;\r
+    }\r
+\r
+    void setTypeMenuToAllUnselected() {\r
+        _convex_type_cbmi.setSelected( false );\r
+        _curved_type_cbmi.setSelected( false );\r
+        _euro_type_cbmi.setSelected( false );\r
+        _rounded_type_cbmi.setSelected( false );\r
+        _triangular_type_cbmi.setSelected( false );\r
+        _rectangular_type_cbmi.setSelected( false );\r
+        _unrooted_type_cbmi.setSelected( false );\r
+        _circular_type_cbmi.setSelected( false );\r
+    }\r
+\r
+    void switchColors() {\r
+        final TreeColorSet colorset = _mainpanel.getTreeColorSet();\r
+        final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );\r
+        csc.setVisible( true );\r
+    }\r
+\r
+    void taxColor() {\r
+        if ( _mainpanel.getCurrentTreePanel() != null ) {\r
+            _mainpanel.getCurrentTreePanel().taxColor();\r
         }\r
-        final int result = writetographics_filechooser.showSaveDialog( contentpane );\r
-        File file = writetographics_filechooser.getSelectedFile();\r
-        //setCurrentDir( writetographics_filechooser.getCurrentDirectory() );\r
-        new_dir = writetographics_filechooser.getCurrentDirectory();\r
-        if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
-            if ( !file.toString().toLowerCase().endsWith( type.toString() ) ) {\r
-                file = new File( file.toString() + "." + type );\r
+    }\r
+\r
+    void typeChanged( final Object o ) {\r
+        updateTypeCheckboxes( getOptions(), o );\r
+        updateOptions( getOptions() );\r
+        if ( getCurrentTreePanel() != null ) {\r
+            final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();\r
+            final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();\r
+            if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )\r
+                    || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )\r
+                    || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )\r
+                    || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {\r
+                getCurrentTreePanel().getControlPanel().showWhole();\r
             }\r
-            if ( file.exists() ) {\r
-                final int i = JOptionPane.showConfirmDialog( component,\r
-                                                             file + " already exists. Overwrite?",\r
-                                                             "Warning",\r
-                                                             JOptionPane.OK_CANCEL_OPTION,\r
-                                                             JOptionPane.WARNING_MESSAGE );\r
-                if ( i != JOptionPane.OK_OPTION ) {\r
-                    return null;\r
+            if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {\r
+                getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );\r
+            }\r
+            else {\r
+                getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );\r
+            }\r
+            getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );\r
+            updateScreenTextAntialias( getMainPanel().getTreePanels() );\r
+            if ( getCurrentTreePanel().getControlPanel().getDynamicallyHideData() != null ) {\r
+                if ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {\r
+                    getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( false );\r
                 }\r
                 else {\r
-                    try {\r
-                        file.delete();\r
-                    }\r
-                    catch ( final Exception e ) {\r
-                        JOptionPane.showMessageDialog( component,\r
-                                                       "Failed to delete: " + file,\r
-                                                       "Error",\r
-                                                       JOptionPane.WARNING_MESSAGE );\r
-                    }\r
+                    getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( true );\r
                 }\r
             }\r
-            writePhylogenyToGraphicsFile( file.toString(), type, mp, component, contentpane );\r
         }\r
-        return new_dir;\r
     }\r
 \r
-    static File writeToPdf( final Phylogeny t,\r
-                            final MainPanel mp,\r
-                            final JFileChooser writetopdf_filechooser,\r
-                            final File curr_dir,\r
-                            final Container contentpane,\r
-                            final Component component ) {\r
-        if ( ( t == null ) || t.isEmpty() ) {\r
-            return null;\r
+    void updateOptions( final Options options ) {\r
+        options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );\r
+        options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )\r
+                                            && _background_gradient_cbmi.isSelected() );\r
+        options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );\r
+        options.setShowAnnotationRefSource( ( _show_annotation_ref_source != null )\r
+                                            && _show_annotation_ref_source.isSelected() );\r
+        options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )\r
+                                                   && _abbreviate_scientific_names.isSelected() );\r
+        options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )\r
+                                                  && _color_labels_same_as_parent_branch.isSelected() );\r
+        options.setShowDefaultNodeShapesInternal( ( _show_default_node_shapes_internal_cbmi != null )\r
+                                                  && _show_default_node_shapes_internal_cbmi.isSelected() );\r
+        options.setShowDefaultNodeShapesExternal( ( _show_default_node_shapes_external_cbmi != null )\r
+                                                  && _show_default_node_shapes_external_cbmi.isSelected() );\r
+        options.setShowDefaultNodeShapesForMarkedNodes( ( _show_default_node_shapes_for_marked_cbmi != null )\r
+                                                        && _show_default_node_shapes_for_marked_cbmi.isSelected() );\r
+        if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {\r
+            options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );\r
         }\r
-        String initial_filename = "";\r
-        if ( mp.getCurrentTreePanel().getTreeFile() != null ) {\r
-            initial_filename = mp.getCurrentTreePanel().getTreeFile().toString();\r
+        else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {\r
+            options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );\r
         }\r
-        if ( initial_filename.indexOf( '.' ) > 0 ) {\r
-            initial_filename = initial_filename.substring( 0, initial_filename.lastIndexOf( '.' ) );\r
+        else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {\r
+            options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );\r
         }\r
-        initial_filename = initial_filename + ".pdf";\r
-        writetopdf_filechooser.setSelectedFile( new File( initial_filename ) );\r
-        final File my_dir = curr_dir;\r
-        if ( my_dir != null ) {\r
-            writetopdf_filechooser.setCurrentDirectory( my_dir );\r
+        options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )\r
+                                        && _search_case_senstive_cbmi.isSelected() );\r
+        if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {\r
+            options.setShowScale( _show_scale_cbmi.isSelected() );\r
         }\r
-        final int result = writetopdf_filechooser.showSaveDialog( contentpane );\r
-        File file = writetopdf_filechooser.getSelectedFile();\r
-        // setCurrentDir( writetopdf_filechooser.getCurrentDirectory() );\r
-        final File new_current_dir = writetopdf_filechooser.getCurrentDirectory();\r
-        if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
-            if ( !file.toString().toLowerCase().endsWith( ".pdf" ) ) {\r
-                file = new File( file.toString() + ".pdf" );\r
+        if ( _label_direction_cbmi != null ) {\r
+            if ( _label_direction_cbmi.isSelected() ) {\r
+                options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );\r
             }\r
-            if ( file.exists() ) {\r
-                final int i = JOptionPane.showConfirmDialog( component,\r
-                                                             file + " already exists. Overwrite?",\r
-                                                             "WARNING",\r
-                                                             JOptionPane.OK_CANCEL_OPTION,\r
-                                                             JOptionPane.WARNING_MESSAGE );\r
-                if ( i != JOptionPane.OK_OPTION ) {\r
-                    return null;\r
-                }\r
+            else {\r
+                options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );\r
             }\r
-            printPhylogenyToPdf( file.toString(), mp.getOptions(), mp.getCurrentTreePanel(), component );\r
         }\r
-        return new_current_dir;\r
-    }\r
-\r
-    private void annotateSequences() {\r
-        if ( getCurrentTreePanel() != null ) {\r
-            List<PhylogenyNode> nodes = null;\r
-            if ( ( getCurrentTreePanel().getFoundNodes0() != null )\r
-                    || ( getCurrentTreePanel().getFoundNodes1() != null ) ) {\r
-                nodes = getCurrentTreePanel().getFoundNodesAsListOfPhylogenyNodes();\r
-            }\r
-            if ( ( nodes == null ) || nodes.isEmpty() ) {\r
-                JOptionPane\r
-                        .showMessageDialog( this,\r
-                                            "Need to select nodes, either via direct selection or via the \"Search\" function",\r
-                                            "No nodes selected for annotation",\r
-                                            JOptionPane.ERROR_MESSAGE );\r
-                return;\r
-            }\r
-            final Phylogeny phy = getMainPanel().getCurrentPhylogeny();\r
-            if ( ( phy != null ) && !phy.isEmpty() ) {\r
-                final JTextField ref_field = new JTextField( 10 );\r
-                final JTextField desc_filed = new JTextField( 20 );\r
-                ref_field.setText( ForesterUtil.isEmpty( getPreviousNodeAnnotationReference() ) ? ""\r
-                        : getPreviousNodeAnnotationReference() );\r
-                final JPanel my_panel = new JPanel();\r
-                my_panel.add( new JLabel( "Reference " ) );\r
-                my_panel.add( ref_field );\r
-                my_panel.add( Box.createHorizontalStrut( 15 ) );\r
-                my_panel.add( new JLabel( "Description " ) );\r
-                my_panel.add( desc_filed );\r
-                final int result = JOptionPane.showConfirmDialog( null,\r
-                                                                  my_panel,\r
-                                                                  "Enter the sequence annotation(s) for the "\r
-                                                                          + nodes.size() + " selected nodes",\r
-                                                                  JOptionPane.OK_CANCEL_OPTION );\r
-                if ( result == JOptionPane.OK_OPTION ) {\r
-                    String ref = ref_field.getText();\r
-                    String desc = desc_filed.getText();\r
-                    if ( !ForesterUtil.isEmpty( ref ) ) {\r
-                        ref = ref.trim();\r
-                        ref = ref.replaceAll( "\\s+", " " );\r
-                        if ( ( ref.indexOf( ':' ) < 1 ) || ( ref.indexOf( ':' ) > ( ref.length() - 2 ) )\r
-                                || ( ref.length() < 3 ) ) {\r
-                            JOptionPane.showMessageDialog( this,\r
-                                                           "Reference needs to be in the form of \"GO:1234567\"",\r
-                                                           "Illegal Format for Annotation Reference",\r
-                                                           JOptionPane.ERROR_MESSAGE );\r
-                            return;\r
-                        }\r
-                    }\r
-                    if ( ref != null ) {\r
-                        setPreviousNodeAnnotationReference( ref );\r
-                    }\r
-                    if ( desc != null ) {\r
-                        desc = desc.trim();\r
-                        desc = desc.replaceAll( "\\s+", " " );\r
-                    }\r
-                    if ( !ForesterUtil.isEmpty( ref ) || !ForesterUtil.isEmpty( desc ) ) {\r
-                        for( final PhylogenyNode n : nodes ) {\r
-                            ForesterUtil.ensurePresenceOfSequence( n );\r
-                            final Annotation ann = ForesterUtil.isEmpty( ref ) ? new Annotation()\r
-                                    : new Annotation( ref );\r
-                            if ( !ForesterUtil.isEmpty( desc ) ) {\r
-                                ann.setDesc( desc );\r
-                            }\r
-                            n.getNodeData().getSequence().addAnnotation( ann );\r
-                        }\r
-                    }\r
-                    getMainPanel().getControlPanel().showAnnotations();\r
-                }\r
-            }\r
+        options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );\r
+        options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )\r
+                                         && _show_confidence_stddev_cbmi.isSelected() );\r
+        if ( ( _color_by_taxonomic_group_cbmi != null ) && _color_by_taxonomic_group_cbmi.isEnabled() ) {\r
+            options.setColorByTaxonomicGroup( _color_by_taxonomic_group_cbmi.isSelected() );\r
         }\r
-    }\r
-\r
-    private void chooseFont() {\r
-        final FontChooser fc = new FontChooser();\r
-        fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );\r
-        fc.showDialog( this, "Select the Base Font" );\r
-        getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );\r
-    }\r
-\r
-    private void chooseMinimalConfidence() {\r
-        final String s = ( String ) JOptionPane\r
-                .showInputDialog( this,\r
-                                  "Please enter the minimum for confidence values to be displayed.\n"\r
-                                          + "[current value: " + getOptions().getMinConfidenceValue() + "]\n",\r
-                                  "Minimal Confidence Value",\r
-                                  JOptionPane.QUESTION_MESSAGE,\r
-                                  null,\r
-                                  null,\r
-                                  getOptions().getMinConfidenceValue() );\r
-        if ( !ForesterUtil.isEmpty( s ) ) {\r
-            boolean success = true;\r
-            double m = 0.0;\r
-            final String m_str = s.trim();\r
-            if ( !ForesterUtil.isEmpty( m_str ) ) {\r
-                try {\r
-                    m = Double.parseDouble( m_str );\r
-                }\r
-                catch ( final Exception ex ) {\r
-                    success = false;\r
-                }\r
-            }\r
-            else {\r
-                success = false;\r
-            }\r
-            if ( success && ( m >= 0.0 ) ) {\r
-                getOptions().setMinConfidenceValue( m );\r
-            }\r
+        options.setPrintUsingActualSize( ( _print_using_actual_size_cbmi != null )\r
+                                         && ( _print_using_actual_size_cbmi.isSelected() ) );\r
+        options.setGraphicsExportUsingActualSize( ( _graphics_export_using_actual_size_cbmi != null )\r
+                                                  && ( _graphics_export_using_actual_size_cbmi.isSelected() ) );\r
+        options.setAntialiasPrint( ( _antialias_print_cbmi != null ) && _antialias_print_cbmi.isSelected() );\r
+        if ( ( _use_brackets_for_conf_in_nh_export_cbmi != null )\r
+                && _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {\r
+            options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );\r
         }\r
-    }\r
-\r
-    private void deleteSelectedNodes( final boolean delete ) {\r
-        final Phylogeny phy = getMainPanel().getCurrentPhylogeny();\r
-        if ( ( phy == null ) || ( phy.getNumberOfExternalNodes() < 2 ) ) {\r
-            return;\r
+        else if ( ( _use_internal_names_for_conf_in_nh_export_cbmi != null )\r
+                && _use_internal_names_for_conf_in_nh_export_cbmi.isSelected() ) {\r
+            options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES );\r
         }\r
-        final List<PhylogenyNode> nodes = new ArrayList<PhylogenyNode>();\r
-        if ( ( getCurrentTreePanel().getFoundNodes0() != null ) || ( getCurrentTreePanel().getFoundNodes1() != null ) ) {\r
-            final List<PhylogenyNode> all_selected_nodes = getCurrentTreePanel().getFoundNodesAsListOfPhylogenyNodes();\r
-            for( final PhylogenyNode n : all_selected_nodes ) {\r
-                if ( n.isExternal() ) {\r
-                    nodes.add( n );\r
-                }\r
-            }\r
+        else {\r
+            options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE );\r
         }\r
-        String function = "Retain";\r
-        if ( delete ) {\r
-            function = "Delete";\r
+        options.setPrintBlackAndWhite( ( _print_black_and_white_cbmi != null )\r
+                                       && _print_black_and_white_cbmi.isSelected() );\r
+        options.setInternalNumberAreConfidenceForNhParsing( ( _internal_number_are_confidence_for_nh_parsing_cbmi != null )\r
+                                                            && _internal_number_are_confidence_for_nh_parsing_cbmi.isSelected() );\r
+        if ( ( _extract_taxonomy_pfam_strict_rbmi != null ) && _extract_taxonomy_pfam_strict_rbmi.isSelected() ) {\r
+            options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );\r
         }\r
-        if ( ( nodes == null ) || nodes.isEmpty() ) {\r
-            JOptionPane\r
-                    .showMessageDialog( this,\r
-                                        "Need to select external nodes, either via direct selection or via the \"Search\" function",\r
-                                        "No external nodes selected to " + function.toLowerCase(),\r
-                                        JOptionPane.ERROR_MESSAGE );\r
-            return;\r
+        else if ( ( _extract_taxonomy_pfam_relaxed_rbmi != null ) && _extract_taxonomy_pfam_relaxed_rbmi.isSelected() ) {\r
+            options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );\r
         }\r
-        final int todo = nodes.size();\r
-        final int ext = phy.getNumberOfExternalNodes();\r
-        int res = todo;\r
-        if ( delete ) {\r
-            res = ext - todo;\r
+        else if ( ( _extract_taxonomy_agressive_rbmi != null ) && _extract_taxonomy_agressive_rbmi.isSelected() ) {\r
+            options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.AGGRESSIVE );\r
         }\r
-        if ( res < 1 ) {\r
-            JOptionPane.showMessageDialog( this,\r
-                                           "Cannot delete all nodes",\r
-                                           "Attempt to delete all nodes ",\r
-                                           JOptionPane.ERROR_MESSAGE );\r
-            return;\r
+        else if ( ( _extract_taxonomy_no_rbmi != null ) && _extract_taxonomy_no_rbmi.isSelected() ) {\r
+            options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.NO );\r
         }\r
-        final int result = JOptionPane.showConfirmDialog( null, function + " " + todo\r
-                + " external node(s), from a total of " + ext + " external nodes," + "\nresulting in tree with " + res\r
-                + " nodes?", function + " external nodes", JOptionPane.OK_CANCEL_OPTION );\r
-        if ( result == JOptionPane.OK_OPTION ) {\r
-            if ( !delete ) {\r
-                final List<PhylogenyNode> to_delete = new ArrayList<PhylogenyNode>();\r
-                for( final PhylogenyNodeIterator it = phy.iteratorExternalForward(); it.hasNext(); ) {\r
-                    final PhylogenyNode n = it.next();\r
-                    if ( !nodes.contains( n ) ) {\r
-                        to_delete.add( n );\r
-                    }\r
-                }\r
-                for( final PhylogenyNode n : to_delete ) {\r
-                    phy.deleteSubtree( n, true );\r
-                }\r
+        options.setReplaceUnderscoresInNhParsing( ( _replace_underscores_cbmi != null )\r
+                                                  && _replace_underscores_cbmi.isSelected() );\r
+        options.setAllowErrorsInDistanceToParent( ( _allow_errors_in_distance_to_parent_cbmi != null )\r
+                                                  && _allow_errors_in_distance_to_parent_cbmi.isSelected() );\r
+        options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )\r
+                                        && _search_whole_words_only_cbmi.isSelected() );\r
+        options.setSearchWithRegex( ( _search_with_regex_cbmi != null ) && _search_with_regex_cbmi.isSelected() );\r
+        options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )\r
+                                        && _inverse_search_result_cbmi.isSelected() );\r
+        if ( _graphics_export_visible_only_cbmi != null ) {\r
+            options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() );\r
+            if ( _graphics_export_visible_only_cbmi.isSelected() && ( _graphics_export_using_actual_size_cbmi != null ) ) {\r
+                _graphics_export_using_actual_size_cbmi.setSelected( true );\r
+                _graphics_export_using_actual_size_cbmi.setEnabled( false );\r
             }\r
             else {\r
-                for( final PhylogenyNode n : nodes ) {\r
-                    phy.deleteSubtree( n, true );\r
-                }\r
+                _graphics_export_using_actual_size_cbmi.setEnabled( true );\r
             }\r
-            resetSearch();\r
-            getCurrentTreePanel().setNodeInPreorderToNull();\r
-            phy.externalNodesHaveChanged();\r
-            phy.clearHashIdToNodeMap();\r
-            phy.recalculateNumberOfExternalDescendants( true );\r
-            getCurrentTreePanel().resetNodeIdToDistToLeafMap();\r
-            getCurrentTreePanel().setEdited( true );\r
-            repaint();\r
         }\r
-    }\r
-\r
-    private void doUpdateProcessMenu() {\r
-        if ( _process_pool.size() > 0 ) {\r
-            if ( _process_menu == null ) {\r
-                _process_menu = createMenu( "", getConfiguration() );\r
-                _process_menu.setForeground( Color.RED );\r
-            }\r
-            _process_menu.removeAll();\r
-            final String text = "processes running: " + _process_pool.size();\r
-            _process_menu.setText( text );\r
-            _jmenubar.add( _process_menu );\r
-            for( int i = 0; i < _process_pool.size(); ++i ) {\r
-                final ProcessRunning p = _process_pool.getProcessByIndex( i );\r
-                _process_menu.add( customizeJMenuItem( new JMenuItem( p.getName() + " [" + p.getStart() + "]" ) ) );\r
-            }\r
+        if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {\r
+            options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );\r
         }\r
-        else {\r
-            if ( _process_menu != null ) {\r
-                _process_menu.removeAll();\r
-                _jmenubar.remove( _process_menu );\r
-            }\r
+        else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {\r
+            options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );\r
         }\r
-        _jmenubar.validate();\r
-        _jmenubar.repaint();\r
-        repaint();\r
-    }\r
-\r
-    private String getPreviousNodeAnnotationReference() {\r
-        return _previous_node_annotation_ref;\r
-    }\r
-\r
-    static void print( final TreePanel tp, final Options op, final Component c ) {\r
-        if ( ( tp == null ) || ( tp.getPhylogeny() == null ) || tp.getPhylogeny().isEmpty() ) {\r
-            return;\r
+        else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {\r
+            options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );\r
         }\r
-        if ( !op.isPrintUsingActualSize() ) {\r
-            tp.calcParametersForPainting( op.getPrintSizeX() - 80, op.getPrintSizeY() - 140 );\r
-            tp.resetPreferredSize();\r
-            tp.repaint();\r
+        else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {\r
+            options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );\r
         }\r
-        final String job_name = Constants.PRG_NAME;\r
-        boolean error = false;\r
-        String printer_name = null;\r
-        try {\r
-            printer_name = Printer.print( tp, job_name );\r
+        else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {\r
+            options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );\r
         }\r
-        catch ( final Exception e ) {\r
-            error = true;\r
-            JOptionPane.showMessageDialog( c, e.getMessage(), "Printing Error", JOptionPane.ERROR_MESSAGE );\r
+        else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {\r
+            options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );\r
         }\r
-        if ( !error && ( printer_name != null ) ) {\r
-            String msg = "Printing data sent to printer";\r
-            if ( printer_name.length() > 1 ) {\r
-                msg += " [" + printer_name + "]";\r
-            }\r
-            JOptionPane.showMessageDialog( c, msg, "Printing...", JOptionPane.INFORMATION_MESSAGE );\r
+        else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {\r
+            options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );\r
         }\r
-        if ( !op.isPrintUsingActualSize() ) {\r
-            tp.getControlPanel().showWhole();\r
+        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
+        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
-    private void removeBranchColors() {\r
-        if ( getMainPanel().getCurrentPhylogeny() != null ) {\r
-            AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );\r
-        }\r
+    void updateTypeCheckboxes( final Options options, final Object o ) {\r
+        setTypeMenuToAllUnselected();\r
+        ( ( JCheckBoxMenuItem ) o ).setSelected( true );\r
     }\r
 \r
-    private void removeVisualStyles() {\r
-        if ( getMainPanel().getCurrentPhylogeny() != null ) {\r
-            AptxUtil.removeVisualStyles( getMainPanel().getCurrentPhylogeny() );\r
+    void viewAsNexus() {\r
+        if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {\r
+            String title = "Nexus";\r
+            if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {\r
+                title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;\r
+            }\r
+            showTextFrame( _mainpanel.getCurrentPhylogeny().toNexus( getOptions().getNhConversionSupportValueStyle() ),\r
+                           title );\r
         }\r
     }\r
 \r
-    private void setPreviousNodeAnnotationReference( final String previous_node_annotation_ref ) {\r
-        _previous_node_annotation_ref = previous_node_annotation_ref;\r
+    void viewAsNH() {\r
+        if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {\r
+            String title = "New Hampshire";\r
+            if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {\r
+                title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;\r
+            }\r
+            showTextFrame( _mainpanel.getCurrentPhylogeny().toNewHampshire( getOptions()\r
+                                                                            .getNhConversionSupportValueStyle() ),\r
+                                                                            title );\r
+        }\r
     }\r
 \r
-    private void writeAllToFile() {\r
-        if ( ( getMainPanel().getTabbedPane() == null ) || ( getMainPanel().getTabbedPane().getTabCount() < 1 ) ) {\r
-            return;\r
-        }\r
-        final File my_dir = getCurrentDir();\r
-        if ( my_dir != null ) {\r
-            _save_filechooser.setCurrentDirectory( my_dir );\r
+    void viewAsXML() {\r
+        if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {\r
+            String title = "phyloXML";\r
+            if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {\r
+                title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;\r
+            }\r
+            showTextFrame( _mainpanel.getCurrentPhylogeny().toPhyloXML( 0 ), title );\r
         }\r
-        _save_filechooser.setSelectedFile( new File( "" ) );\r
-        final int result = _save_filechooser.showSaveDialog( _contentpane );\r
-        final File file = _save_filechooser.getSelectedFile();\r
-        setCurrentDir( _save_filechooser.getCurrentDirectory() );\r
-        if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
-            if ( file.exists() ) {\r
-                final int i = JOptionPane.showConfirmDialog( this,\r
-                                                             file + " already exists. Overwrite?",\r
-                                                             "Warning",\r
-                                                             JOptionPane.OK_CANCEL_OPTION,\r
-                                                             JOptionPane.WARNING_MESSAGE );\r
-                if ( i != JOptionPane.OK_OPTION ) {\r
-                    return;\r
+    }\r
+\r
+    private static void cycleNodeDataReturn( final Options op, final Configuration conf ) {\r
+        switch ( op.getExtDescNodeDataToReturn() ) {\r
+            case UNKNOWN:\r
+                op.setExtDescNodeDataToReturn( NodeDataField.DOMAINS_ALL );\r
+                break;\r
+            case DOMAINS_ALL:\r
+                op.setExtDescNodeDataToReturn( NodeDataField.DOMAINS_COLLAPSED_PER_PROTEIN );\r
+                break;\r
+            case DOMAINS_COLLAPSED_PER_PROTEIN:\r
+                op.setExtDescNodeDataToReturn( NodeDataField.SEQ_ANNOTATIONS );\r
+                break;\r
+            case SEQ_ANNOTATIONS:\r
+                op.setExtDescNodeDataToReturn( NodeDataField.GO_TERM_IDS );\r
+                break;\r
+            case GO_TERM_IDS:\r
+                op.setExtDescNodeDataToReturn( NodeDataField.SEQUENCE_MOL_SEQ_FASTA );\r
+                break;\r
+            case SEQUENCE_MOL_SEQ_FASTA:\r
+                if ( ( conf != null ) && ( conf.getExtDescNodeDataToReturn() != null )\r
+                        && ( conf.getExtDescNodeDataToReturn() != NodeDataField.DOMAINS_ALL )\r
+                        && ( conf.getExtDescNodeDataToReturn() != NodeDataField.DOMAINS_COLLAPSED_PER_PROTEIN )\r
+                        && ( conf.getExtDescNodeDataToReturn() != NodeDataField.SEQ_ANNOTATIONS )\r
+                        && ( conf.getExtDescNodeDataToReturn() != NodeDataField.GO_TERM_IDS )\r
+                        && ( conf.getExtDescNodeDataToReturn() != NodeDataField.SEQUENCE_MOL_SEQ_FASTA ) ) {\r
+                    op.setExtDescNodeDataToReturn( conf.getExtDescNodeDataToReturn() );\r
                 }\r
                 else {\r
-                    try {\r
-                        file.delete();\r
-                    }\r
-                    catch ( final Exception e ) {\r
-                        JOptionPane.showMessageDialog( this,\r
-                                                       "Failed to delete: " + file,\r
-                                                       "Error",\r
-                                                       JOptionPane.WARNING_MESSAGE );\r
-                    }\r
-                }\r
-            }\r
-            final int count = getMainPanel().getTabbedPane().getTabCount();\r
-            final List<Phylogeny> trees = new ArrayList<Phylogeny>();\r
-            for( int i = 0; i < count; ++i ) {\r
-                final Phylogeny phy = getMainPanel().getPhylogeny( i );\r
-                if ( ForesterUtil.isEmpty( phy.getName() )\r
-                        && !ForesterUtil.isEmpty( getMainPanel().getTabbedPane().getTitleAt( i ) ) ) {\r
-                    phy.setName( getMainPanel().getTabbedPane().getTitleAt( i ) );\r
+                    op.setExtDescNodeDataToReturn( NodeDataField.UNKNOWN );\r
                 }\r
-                trees.add( phy );\r
-                getMainPanel().getTreePanels().get( i ).setEdited( false );\r
-            }\r
-            final PhylogenyWriter writer = new PhylogenyWriter();\r
-            try {\r
-                writer.toPhyloXML( file, trees, 0, ForesterUtil.LINE_SEPARATOR );\r
-            }\r
-            catch ( final IOException e ) {\r
-                JOptionPane.showMessageDialog( this,\r
-                                               "Failed to write to: " + file,\r
-                                               "Error",\r
-                                               JOptionPane.WARNING_MESSAGE );\r
-            }\r
+                break;\r
+            default:\r
+                op.setExtDescNodeDataToReturn( NodeDataField.UNKNOWN );\r
         }\r
     }\r
 \r
@@ -2405,11 +2043,11 @@ public abstract class MainFrame extends JFrame implements ActionListener {
                                                                  "Please enter the default size for node shapes.\n"\r
                                                                          + "[current value: "\r
                                                                          + options.getDefaultNodeShapeSize() + "]\n",\r
-                                                                 "Node Shape Size",\r
-                                                                 JOptionPane.QUESTION_MESSAGE,\r
-                                                                 null,\r
-                                                                 null,\r
-                                                                 options.getDefaultNodeShapeSize() );\r
+                                                                         "Node Shape Size",\r
+                                                                         JOptionPane.QUESTION_MESSAGE,\r
+                                                                         null,\r
+                                                                         null,\r
+                                                                         options.getDefaultNodeShapeSize() );\r
         if ( !ForesterUtil.isEmpty( s ) ) {\r
             boolean success = true;\r
             double m = 0.0;\r
@@ -2511,123 +2149,452 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }\r
     }\r
 \r
+    static void exceptionOccuredDuringSaveAs( final Exception e, final TreePanel tp, final Component comp ) {\r
+        try {\r
+            tp.setArrowCursor();\r
+        }\r
+        catch ( final Exception ex ) {\r
+            // Do nothing.\r
+        }\r
+        JOptionPane.showMessageDialog( comp, "Exception" + e, "Error during File|SaveAs", JOptionPane.ERROR_MESSAGE );\r
+    }\r
+\r
+    static void print( final TreePanel tp, final Options op, final Component c ) {\r
+        if ( ( tp == null ) || ( tp.getPhylogeny() == null ) || tp.getPhylogeny().isEmpty() ) {\r
+            return;\r
+        }\r
+        if ( !op.isPrintUsingActualSize() ) {\r
+            tp.calcParametersForPainting( op.getPrintSizeX() - 80, op.getPrintSizeY() - 140 );\r
+            tp.resetPreferredSize();\r
+            tp.repaint();\r
+        }\r
+        final String job_name = Constants.PRG_NAME;\r
+        boolean error = false;\r
+        String printer_name = null;\r
+        try {\r
+            printer_name = Printer.print( tp, job_name );\r
+        }\r
+        catch ( final Exception e ) {\r
+            error = true;\r
+            JOptionPane.showMessageDialog( c, e.getMessage(), "Printing Error", JOptionPane.ERROR_MESSAGE );\r
+        }\r
+        if ( !error && ( printer_name != null ) ) {\r
+            String msg = "Printing data sent to printer";\r
+            if ( printer_name.length() > 1 ) {\r
+                msg += " [" + printer_name + "]";\r
+            }\r
+            JOptionPane.showMessageDialog( c, msg, "Printing...", JOptionPane.INFORMATION_MESSAGE );\r
+        }\r
+        if ( !op.isPrintUsingActualSize() ) {\r
+            tp.getControlPanel().showWhole();\r
+        }\r
+    }\r
+\r
+    static void printPhylogenyToPdf( final String file_name,\r
+                                     final Options opts,\r
+                                     final TreePanel tp,\r
+                                     final Component comp ) {\r
+        if ( !opts.isPrintUsingActualSize() ) {\r
+            tp.calcParametersForPainting( opts.getPrintSizeX(), opts.getPrintSizeY() );\r
+            tp.resetPreferredSize();\r
+            tp.repaint();\r
+        }\r
+        String pdf_written_to = "";\r
+        boolean error = false;\r
+        try {\r
+            if ( opts.isPrintUsingActualSize() ) {\r
+                pdf_written_to = PdfExporter.writePhylogenyToPdf( file_name, tp, tp.getWidth(), tp.getHeight() );\r
+            }\r
+            else {\r
+                pdf_written_to = PdfExporter.writePhylogenyToPdf( file_name,\r
+                                                                  tp,\r
+                                                                  opts.getPrintSizeX(),\r
+                                                                  opts.getPrintSizeY() );\r
+            }\r
+        }\r
+        catch ( final IOException e ) {\r
+            error = true;\r
+            JOptionPane.showMessageDialog( comp, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE );\r
+        }\r
+        if ( !error ) {\r
+            if ( !ForesterUtil.isEmpty( pdf_written_to ) ) {\r
+                JOptionPane.showMessageDialog( comp,\r
+                                               "Wrote PDF to: " + pdf_written_to,\r
+                                               "Information",\r
+                                               JOptionPane.INFORMATION_MESSAGE );\r
+            }\r
+            else {\r
+                JOptionPane.showMessageDialog( comp,\r
+                                               "There was an unknown problem when attempting to write to PDF file: \""\r
+                                                       + file_name + "\"",\r
+                                                       "Error",\r
+                                                       JOptionPane.ERROR_MESSAGE );\r
+            }\r
+        }\r
+        if ( !opts.isPrintUsingActualSize() ) {\r
+            tp.getControlPanel().showWhole();\r
+        }\r
+    }\r
+\r
     static void setCycleDataReturnMenuItem( final JMenuItem mi, final Options options ) {\r
         if ( ( options != null ) && ( options.getExtDescNodeDataToReturn() != null ) ) {\r
             mi.setText( "Cycle Node Return Data... (current: " + options.getExtDescNodeDataToReturn().toString() + ")" );\r
         }\r
-        else {\r
-            mi.setText( "Cycle Node Return Data..." );\r
+        else {\r
+            mi.setText( "Cycle Node Return Data..." );\r
+        }\r
+    }\r
+\r
+    static void setCycleNodeFillMenuItem( final JMenuItem mi, final Options options ) {\r
+        if ( ( options != null ) && ( options.getDefaultNodeFill() != null ) ) {\r
+            mi.setText( "Cycle Node Shape Fill Type... (current: "\r
+                    + options.getDefaultNodeFill().toString().toLowerCase() + ")" );\r
+        }\r
+        else {\r
+            mi.setText( "Cycle Node Shape Fill Type..." );\r
+        }\r
+    }\r
+\r
+    static void setCycleNodeShapeMenuItem( final JMenuItem mi, final Options options ) {\r
+        if ( ( options != null ) && ( options.getDefaultNodeShape() != null ) ) {\r
+            mi.setText( "Cycle Node Shape Fill Type... (current: "\r
+                    + options.getDefaultNodeShape().toString().toLowerCase() + ")" );\r
+        }\r
+        else {\r
+            mi.setText( "Cycle Node Shape Fill Type..." );\r
+        }\r
+    }\r
+\r
+    static void setOvPlacementColorChooseMenuItem( final JMenuItem mi, final Options options ) {\r
+        if ( ( options != null ) && ( options.getOvPlacement() != null ) ) {\r
+            mi.setText( "Cycle Overview Placement... (current: " + options.getOvPlacement() + ")" );\r
+        }\r
+        else {\r
+            mi.setText( "Cycle Overview Placement..." );\r
+        }\r
+    }\r
+\r
+    static void setTextColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {\r
+        if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {\r
+            mi.setText( "Select Color Scheme... (current: " + tree_panel.getTreeColorSet().getCurrentColorSchemeName()\r
+                        + ")" );\r
+        }\r
+        else {\r
+            mi.setText( "Select Color Scheme..." );\r
+        }\r
+    }\r
+\r
+    static void setTextForFontChooserMenuItem( final JMenuItem mi, final String font_desc ) {\r
+        mi.setText( "Select Default Font... (current: " + font_desc + ")" );\r
+    }\r
+\r
+    static void setTextForGraphicsSizeChooserMenuItem( final JMenuItem mi, final Options o ) {\r
+        mi.setText( "Enter Default Size for Graphics Export... (current: " + o.getPrintSizeX() + ", "\r
+                + o.getPrintSizeY() + ")" );\r
+    }\r
+\r
+    static void setTextForPdfLineWidthChooserMenuItem( final JMenuItem mi, final Options o ) {\r
+        mi.setText( "Enter Default Line Width for PDF Export... (current: " + o.getPrintLineWidth() + ")" );\r
+    }\r
+\r
+    static void setTextMinSupportMenuItem( final JMenuItem mi, final Options options, final TreePanel current_tree_panel ) {\r
+        if ( ( current_tree_panel == null ) || ( current_tree_panel.getPhylogeny() == null ) ) {\r
+            mi.setEnabled( true );\r
+        }\r
+        else if ( AptxUtil.isHasAtLeastOneBranchWithSupportValues( current_tree_panel.getPhylogeny() ) ) {\r
+            mi.setEnabled( true );\r
+        }\r
+        else {\r
+            mi.setEnabled( false );\r
+        }\r
+        mi.setText( "Enter Min Confidence Value... (current: " + options.getMinConfidenceValue() + ")" );\r
+    }\r
+\r
+    static void setTextNodeSizeMenuItem( final JMenuItem mi, final Options options ) {\r
+        mi.setText( "Enter Default Node Shape Size... (current: " + options.getDefaultNodeShapeSize() + ")" );\r
+    }\r
+\r
+    static void updateScreenTextAntialias( final List<TreePanel> treepanels ) {\r
+        for( final TreePanel tree_panel : treepanels ) {\r
+            tree_panel.setTextAntialias();\r
+        }\r
+    }\r
+\r
+    static boolean writeAsNewHampshire( final TreePanel tp, final Options op, boolean exception, final File file ) {\r
+        try {\r
+            final PhylogenyWriter writer = new PhylogenyWriter();\r
+            writer.toNewHampshire( tp.getPhylogeny(), true, op.getNhConversionSupportValueStyle(), file );\r
+        }\r
+        catch ( final Exception e ) {\r
+            exception = true;\r
+            exceptionOccuredDuringSaveAs( e, tp, tp );\r
+        }\r
+        return exception;\r
+    }\r
+\r
+    static boolean writeAsNexus( final TreePanel tp, final Options op, boolean exception, final File file ) {\r
+        try {\r
+            final PhylogenyWriter writer = new PhylogenyWriter();\r
+            writer.toNexus( file, tp.getPhylogeny(), op.getNhConversionSupportValueStyle() );\r
+        }\r
+        catch ( final Exception e ) {\r
+            exception = true;\r
+            exceptionOccuredDuringSaveAs( e, tp, tp );\r
+        }\r
+        return exception;\r
+    }\r
+\r
+    static boolean writeAsPhyloXml( final TreePanel tp, final Options op, boolean exception, final File file ) {\r
+        try {\r
+            final PhylogenyWriter writer = new PhylogenyWriter();\r
+            writer.toPhyloXML( file, tp.getPhylogeny(), 0 );\r
+        }\r
+        catch ( final Exception e ) {\r
+            exception = true;\r
+            exceptionOccuredDuringSaveAs( e, tp, tp );\r
+        }\r
+        return exception;\r
+    }\r
+\r
+    static void writePhylogenyToGraphicsFile( final String file_name,\r
+                                              final GraphicsExportType type,\r
+                                              final MainPanel mp,\r
+                                              final Component comp,\r
+                                              final Container contentpane ) {\r
+        mp.getCurrentTreePanel().calcParametersForPainting( mp.getCurrentTreePanel().getWidth(),\r
+                                                            mp.getCurrentTreePanel().getHeight() );\r
+        String file_written_to = "";\r
+        boolean error = false;\r
+        try {\r
+            file_written_to = AptxUtil.writePhylogenyToGraphicsFile( file_name,\r
+                                                                     mp.getCurrentTreePanel().getWidth(),\r
+                                                                     mp.getCurrentTreePanel().getHeight(),\r
+                                                                     mp.getCurrentTreePanel(),\r
+                                                                     mp.getControlPanel(),\r
+                                                                     type,\r
+                                                                     mp.getOptions() );\r
+        }\r
+        catch ( final IOException e ) {\r
+            error = true;\r
+            JOptionPane.showMessageDialog( comp, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE );\r
+        }\r
+        if ( !error ) {\r
+            if ( ( file_written_to != null ) && ( file_written_to.length() > 0 ) ) {\r
+                JOptionPane.showMessageDialog( comp,\r
+                                               "Wrote image to: " + file_written_to,\r
+                                               "Graphics Export",\r
+                                               JOptionPane.INFORMATION_MESSAGE );\r
+            }\r
+            else {\r
+                JOptionPane.showMessageDialog( comp,\r
+                                               "There was an unknown problem when attempting to write to an image file: \""\r
+                                                       + file_name + "\"",\r
+                                                       "Error",\r
+                                                       JOptionPane.ERROR_MESSAGE );\r
+            }\r
+        }\r
+        contentpane.repaint();\r
+    }\r
+\r
+    static File writeToFile( final Phylogeny t,\r
+                             final MainPanel mp,\r
+                             final JFileChooser save_filechooser,\r
+                             final File current_dir,\r
+                             final Container contentpane,\r
+                             final Component comp ) {\r
+        File new_file = null;\r
+        if ( t == null ) {\r
+            return null;\r
+        }\r
+        String initial_filename = null;\r
+        if ( mp.getCurrentTreePanel().getTreeFile() != null ) {\r
+            try {\r
+                initial_filename = mp.getCurrentTreePanel().getTreeFile().getCanonicalPath();\r
+            }\r
+            catch ( final IOException e ) {\r
+                initial_filename = null;\r
+            }\r
         }\r
-    }\r
-\r
-    static void setCycleNodeFillMenuItem( final JMenuItem mi, final Options options ) {\r
-        if ( ( options != null ) && ( options.getDefaultNodeFill() != null ) ) {\r
-            mi.setText( "Cycle Node Shape Fill Type... (current: "\r
-                    + options.getDefaultNodeFill().toString().toLowerCase() + ")" );\r
+        if ( !ForesterUtil.isEmpty( initial_filename ) ) {\r
+            save_filechooser.setSelectedFile( new File( initial_filename ) );\r
         }\r
         else {\r
-            mi.setText( "Cycle Node Shape Fill Type..." );\r
+            save_filechooser.setSelectedFile( new File( "" ) );\r
         }\r
-    }\r
-\r
-    static void setCycleNodeShapeMenuItem( final JMenuItem mi, final Options options ) {\r
-        if ( ( options != null ) && ( options.getDefaultNodeShape() != null ) ) {\r
-            mi.setText( "Cycle Node Shape Fill Type... (current: "\r
-                    + options.getDefaultNodeShape().toString().toLowerCase() + ")" );\r
+        final File my_dir = current_dir;\r
+        if ( my_dir != null ) {\r
+            save_filechooser.setCurrentDirectory( my_dir );\r
         }\r
-        else {\r
-            mi.setText( "Cycle Node Shape Fill Type..." );\r
+        final int result = save_filechooser.showSaveDialog( contentpane );\r
+        final File file = save_filechooser.getSelectedFile();\r
+        new_file = save_filechooser.getCurrentDirectory();\r
+        boolean exception = false;\r
+        if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
+            if ( file.exists() ) {\r
+                final int i = JOptionPane.showConfirmDialog( comp,\r
+                                                             file + " already exists.\nOverwrite?",\r
+                                                             "Overwrite?",\r
+                                                             JOptionPane.OK_CANCEL_OPTION,\r
+                                                             JOptionPane.QUESTION_MESSAGE );\r
+                if ( i != JOptionPane.OK_OPTION ) {\r
+                    return null;\r
+                }\r
+                else {\r
+                    final File to = new File( file.getAbsoluteFile().toString() + Constants.BACKUP_FILE_SUFFIX );\r
+                    try {\r
+                        ForesterUtil.copyFile( file, to );\r
+                    }\r
+                    catch ( final Exception e ) {\r
+                        JOptionPane.showMessageDialog( comp,\r
+                                                       "Failed to create backup copy " + to,\r
+                                                       "Failed to Create Backup Copy",\r
+                                                       JOptionPane.WARNING_MESSAGE );\r
+                    }\r
+                    try {\r
+                        file.delete();\r
+                    }\r
+                    catch ( final Exception e ) {\r
+                        JOptionPane.showMessageDialog( comp,\r
+                                                       "Failed to delete: " + file,\r
+                                                       "Failed to Delete",\r
+                                                       JOptionPane.WARNING_MESSAGE );\r
+                    }\r
+                }\r
+            }\r
+            if ( save_filechooser.getFileFilter() == MainFrame.nhfilter ) {\r
+                exception = writeAsNewHampshire( mp.getCurrentTreePanel(), mp.getOptions(), exception, file );\r
+            }\r
+            else if ( save_filechooser.getFileFilter() == MainFrame.xmlfilter ) {\r
+                exception = writeAsPhyloXml( mp.getCurrentTreePanel(), mp.getOptions(), exception, file );\r
+            }\r
+            else if ( save_filechooser.getFileFilter() == MainFrame.nexusfilter ) {\r
+                exception = writeAsNexus( mp.getCurrentTreePanel(), mp.getOptions(), exception, file );\r
+            }\r
+            // "*.*":\r
+            else {\r
+                final String file_name = file.getName().trim().toLowerCase();\r
+                if ( file_name.endsWith( ".nh" ) || file_name.endsWith( ".newick" ) || file_name.endsWith( ".phy" )\r
+                        || file_name.endsWith( ".tree" ) ) {\r
+                    exception = writeAsNewHampshire( mp.getCurrentTreePanel(), mp.getOptions(), exception, file );\r
+                }\r
+                else if ( file_name.endsWith( ".nex" ) || file_name.endsWith( ".nexus" ) ) {\r
+                    exception = writeAsNexus( mp.getCurrentTreePanel(), mp.getOptions(), exception, file );\r
+                }\r
+                // XML is default:\r
+                else {\r
+                    exception = writeAsPhyloXml( mp.getCurrentTreePanel(), mp.getOptions(), exception, file );\r
+                }\r
+            }\r
+            if ( !exception ) {\r
+                mp.setTitleOfSelectedTab( file.getName() );\r
+                mp.getCurrentTreePanel().setTreeFile( file );\r
+                mp.getCurrentTreePanel().setEdited( false );\r
+            }\r
         }\r
+        return new_file;\r
     }\r
 \r
-    static void setOvPlacementColorChooseMenuItem( final JMenuItem mi, final Options options ) {\r
-        if ( ( options != null ) && ( options.getOvPlacement() != null ) ) {\r
-            mi.setText( "Cycle Overview Placement... (current: " + options.getOvPlacement() + ")" );\r
+    static File writeToGraphicsFile( final Phylogeny t,\r
+                                     final GraphicsExportType type,\r
+                                     final MainPanel mp,\r
+                                     final JFileChooser writetographics_filechooser,\r
+                                     final Component component,\r
+                                     final Container contentpane,\r
+                                     final File current_dir ) {\r
+        File new_dir = null;\r
+        if ( ( t == null ) || t.isEmpty() ) {\r
+            return null;\r
         }\r
-        else {\r
-            mi.setText( "Cycle Overview Placement..." );\r
+        String initial_filename = "";\r
+        if ( mp.getCurrentTreePanel().getTreeFile() != null ) {\r
+            initial_filename = mp.getCurrentTreePanel().getTreeFile().toString();\r
         }\r
-    }\r
-\r
-    static void setTextColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {\r
-        if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {\r
-            mi.setText( "Select Color Scheme... (current: " + tree_panel.getTreeColorSet().getCurrentColorSchemeName()\r
-                    + ")" );\r
+        if ( initial_filename.indexOf( '.' ) > 0 ) {\r
+            initial_filename = initial_filename.substring( 0, initial_filename.lastIndexOf( '.' ) );\r
         }\r
-        else {\r
-            mi.setText( "Select Color Scheme..." );\r
+        initial_filename = initial_filename + "." + type;\r
+        writetographics_filechooser.setSelectedFile( new File( initial_filename ) );\r
+        final File my_dir = current_dir;\r
+        if ( my_dir != null ) {\r
+            writetographics_filechooser.setCurrentDirectory( my_dir );\r
         }\r
+        final int result = writetographics_filechooser.showSaveDialog( contentpane );\r
+        File file = writetographics_filechooser.getSelectedFile();\r
+        //setCurrentDir( writetographics_filechooser.getCurrentDirectory() );\r
+        new_dir = writetographics_filechooser.getCurrentDirectory();\r
+        if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
+            if ( !file.toString().toLowerCase().endsWith( type.toString() ) ) {\r
+                file = new File( file.toString() + "." + type );\r
+            }\r
+            if ( file.exists() ) {\r
+                final int i = JOptionPane.showConfirmDialog( component,\r
+                                                             file + " already exists. Overwrite?",\r
+                                                             "Warning",\r
+                                                             JOptionPane.OK_CANCEL_OPTION,\r
+                                                             JOptionPane.WARNING_MESSAGE );\r
+                if ( i != JOptionPane.OK_OPTION ) {\r
+                    return null;\r
+                }\r
+                else {\r
+                    try {\r
+                        file.delete();\r
+                    }\r
+                    catch ( final Exception e ) {\r
+                        JOptionPane.showMessageDialog( component,\r
+                                                       "Failed to delete: " + file,\r
+                                                       "Error",\r
+                                                       JOptionPane.WARNING_MESSAGE );\r
+                    }\r
+                }\r
+            }\r
+            writePhylogenyToGraphicsFile( file.toString(), type, mp, component, contentpane );\r
+        }\r
+        return new_dir;\r
     }\r
 \r
-    static void setTextForFontChooserMenuItem( final JMenuItem mi, final String font_desc ) {\r
-        mi.setText( "Select Default Font... (current: " + font_desc + ")" );\r
-    }\r
-\r
-    static void setTextForGraphicsSizeChooserMenuItem( final JMenuItem mi, final Options o ) {\r
-        mi.setText( "Enter Default Size for Graphics Export... (current: " + o.getPrintSizeX() + ", "\r
-                + o.getPrintSizeY() + ")" );\r
-    }\r
-\r
-    static void setTextForPdfLineWidthChooserMenuItem( final JMenuItem mi, final Options o ) {\r
-        mi.setText( "Enter Default Line Width for PDF Export... (current: " + o.getPrintLineWidth() + ")" );\r
-    }\r
-\r
-    static void setTextMinSupportMenuItem( final JMenuItem mi, final Options options, final TreePanel current_tree_panel ) {\r
-        if ( ( current_tree_panel == null ) || ( current_tree_panel.getPhylogeny() == null ) ) {\r
-            mi.setEnabled( true );\r
+    static File writeToPdf( final Phylogeny t,\r
+                            final MainPanel mp,\r
+                            final JFileChooser writetopdf_filechooser,\r
+                            final File curr_dir,\r
+                            final Container contentpane,\r
+                            final Component component ) {\r
+        if ( ( t == null ) || t.isEmpty() ) {\r
+            return null;\r
         }\r
-        else if ( AptxUtil.isHasAtLeastOneBranchWithSupportValues( current_tree_panel.getPhylogeny() ) ) {\r
-            mi.setEnabled( true );\r
+        String initial_filename = "";\r
+        if ( mp.getCurrentTreePanel().getTreeFile() != null ) {\r
+            initial_filename = mp.getCurrentTreePanel().getTreeFile().toString();\r
         }\r
-        else {\r
-            mi.setEnabled( false );\r
+        if ( initial_filename.indexOf( '.' ) > 0 ) {\r
+            initial_filename = initial_filename.substring( 0, initial_filename.lastIndexOf( '.' ) );\r
         }\r
-        mi.setText( "Enter Min Confidence Value... (current: " + options.getMinConfidenceValue() + ")" );\r
-    }\r
-\r
-    static void setTextNodeSizeMenuItem( final JMenuItem mi, final Options options ) {\r
-        mi.setText( "Enter Default Node Shape Size... (current: " + options.getDefaultNodeShapeSize() + ")" );\r
-    }\r
-\r
-    static void updateScreenTextAntialias( final List<TreePanel> treepanels ) {\r
-        for( final TreePanel tree_panel : treepanels ) {\r
-            tree_panel.setTextAntialias();\r
+        initial_filename = initial_filename + ".pdf";\r
+        writetopdf_filechooser.setSelectedFile( new File( initial_filename ) );\r
+        final File my_dir = curr_dir;\r
+        if ( my_dir != null ) {\r
+            writetopdf_filechooser.setCurrentDirectory( my_dir );\r
         }\r
-    }\r
-\r
-    private static void cycleNodeDataReturn( final Options op, final Configuration conf ) {\r
-        switch ( op.getExtDescNodeDataToReturn() ) {\r
-            case UNKNOWN:\r
-                op.setExtDescNodeDataToReturn( NodeDataField.DOMAINS_ALL );\r
-                break;\r
-            case DOMAINS_ALL:\r
-                op.setExtDescNodeDataToReturn( NodeDataField.DOMAINS_COLLAPSED_PER_PROTEIN );\r
-                break;\r
-            case DOMAINS_COLLAPSED_PER_PROTEIN:\r
-                op.setExtDescNodeDataToReturn( NodeDataField.SEQ_ANNOTATIONS );\r
-                break;\r
-            case SEQ_ANNOTATIONS:\r
-                op.setExtDescNodeDataToReturn( NodeDataField.GO_TERM_IDS );\r
-                break;\r
-            case GO_TERM_IDS:\r
-                op.setExtDescNodeDataToReturn( NodeDataField.SEQUENCE_MOL_SEQ_FASTA );\r
-                break;\r
-            case SEQUENCE_MOL_SEQ_FASTA:\r
-                if ( ( conf != null ) && ( conf.getExtDescNodeDataToReturn() != null )\r
-                        && ( conf.getExtDescNodeDataToReturn() != NodeDataField.DOMAINS_ALL )\r
-                        && ( conf.getExtDescNodeDataToReturn() != NodeDataField.DOMAINS_COLLAPSED_PER_PROTEIN )\r
-                        && ( conf.getExtDescNodeDataToReturn() != NodeDataField.SEQ_ANNOTATIONS )\r
-                        && ( conf.getExtDescNodeDataToReturn() != NodeDataField.GO_TERM_IDS )\r
-                        && ( conf.getExtDescNodeDataToReturn() != NodeDataField.SEQUENCE_MOL_SEQ_FASTA ) ) {\r
-                    op.setExtDescNodeDataToReturn( conf.getExtDescNodeDataToReturn() );\r
-                }\r
-                else {\r
-                    op.setExtDescNodeDataToReturn( NodeDataField.UNKNOWN );\r
+        final int result = writetopdf_filechooser.showSaveDialog( contentpane );\r
+        File file = writetopdf_filechooser.getSelectedFile();\r
+        // setCurrentDir( writetopdf_filechooser.getCurrentDirectory() );\r
+        final File new_current_dir = writetopdf_filechooser.getCurrentDirectory();\r
+        if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
+            if ( !file.toString().toLowerCase().endsWith( ".pdf" ) ) {\r
+                file = new File( file.toString() + ".pdf" );\r
+            }\r
+            if ( file.exists() ) {\r
+                final int i = JOptionPane.showConfirmDialog( component,\r
+                                                             file + " already exists. Overwrite?",\r
+                                                             "WARNING",\r
+                                                             JOptionPane.OK_CANCEL_OPTION,\r
+                                                             JOptionPane.WARNING_MESSAGE );\r
+                if ( i != JOptionPane.OK_OPTION ) {\r
+                    return null;\r
                 }\r
-                break;\r
-            default:\r
-                op.setExtDescNodeDataToReturn( NodeDataField.UNKNOWN );\r
+            }\r
+            printPhylogenyToPdf( file.toString(), mp.getOptions(), mp.getCurrentTreePanel(), component );\r
         }\r
+        return new_current_dir;\r
     }\r
 }\r
 \r
index d742229..6374275 100644 (file)
@@ -99,7 +99,7 @@ public final class MainFrameApplet extends MainFrame {
         _contentpane.setLayout( new BorderLayout() );
         _contentpane.add( _mainpanel, BorderLayout.CENTER );
         setSize( getConfiguration().getFrameXSize() > 40 ? getConfiguration().getFrameXSize() : DEFAULT_FRAME_X_SIZE,
-                 getConfiguration().getFrameYSize() > 40 ? getConfiguration().getFrameYSize() : DEFAULT_FRAME_Y_SIZE );
+                getConfiguration().getFrameYSize() > 40 ? getConfiguration().getFrameYSize() : DEFAULT_FRAME_Y_SIZE );
         addWindowListener( new WindowAdapter() {
 
             @Override
@@ -113,9 +113,9 @@ public final class MainFrameApplet extends MainFrame {
             public void componentResized( final ComponentEvent e ) {
                 if ( _mainpanel.getCurrentTreePanel() != null ) {
                     _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getCurrentTreePanel()
-                                                                                        .getWidth(),
+                                                                                .getWidth(),
                                                                                 _mainpanel.getCurrentTreePanel()
-                                                                                        .getHeight() );
+                                                                                .getHeight() );
                 }
             }
         } );
@@ -126,6 +126,41 @@ public final class MainFrameApplet extends MainFrame {
         System.gc();
     }
 
+    @Override
+    public MainPanel getMainPanel() {
+        return _mainpanel;
+    }
+
+    private void readSpeciesTree( final Configuration configuration, final String species_tree_url_str )
+            throws MalformedURLException, FileNotFoundException, IOException {
+        final URL species_tree_url = new URL( species_tree_url_str );
+        final Phylogeny[] species_trees = AptxUtil.readPhylogeniesFromUrl( species_tree_url,
+                                                                           configuration
+                                                                           .isValidatePhyloXmlAgainstSchema(),
+                                                                           configuration
+                                                                           .isReplaceUnderscoresInNhParsing(),
+                                                                           false,
+                                                                           TAXONOMY_EXTRACTION.NO,
+                                                                           false );
+        if ( ( species_trees != null ) && ( species_trees.length > 0 ) ) {
+            AptxUtil.printAppletMessage( ArchaeopteryxA.NAME, "successfully read species tree" );
+            if ( species_trees[ 0 ].isEmpty() ) {
+                ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, "species tree is empty" );
+            }
+            else if ( !species_trees[ 0 ].isRooted() ) {
+                ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, "species tree is not rooted" );
+            }
+            else {
+                setSpeciesTree( species_trees[ 0 ] );
+                AptxUtil.printAppletMessage( ArchaeopteryxA.NAME, "species tree OK" );
+            }
+        }
+        else {
+            ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, "failed to read species tree from "
+                    + species_tree_url_str );
+        }
+    }
+
     void buildAnalysisMenu() {
         _analysis_menu = MainFrame.createMenu( "Analysis", getConfiguration() );
         _analysis_menu.add( _gsdi_item = new JMenuItem( "GSDI (Generalized Speciation Duplication Inference)" ) );
@@ -148,9 +183,9 @@ public final class MainFrameApplet extends MainFrame {
                 MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getOptions() );
                 MainFrame.setTextColorChooseMenuItem( _switch_colors_mi, getCurrentTreePanel() );
                 MainFrame
-                        .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() );
+                .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() );
                 MainFrame.setTextForFontChooserMenuItem( _choose_font_mi, createCurrentFontDesc( getMainPanel()
-                        .getTreeFontSet() ) );
+                                                                                                 .getTreeFontSet() ) );
                 setTextForGraphicsSizeChooserMenuItem( _print_size_mi, getOptions() );
                 setTextForPdfLineWidthChooserMenuItem( _choose_pdf_width_mi, getOptions() );
                 MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() );
@@ -168,7 +203,7 @@ public final class MainFrameApplet extends MainFrame {
         _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.DISPLAY_SUBHEADER ),
                                                                 getConfiguration() ) );
         _options_jmenu
-                .add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );
+        .add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );
         _options_jmenu.add( _uniform_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.UNIFORM_CLADOGRAMS_LABEL ) );
         _options_jmenu.add( _non_lined_up_cladograms_rbmi = new JRadioButtonMenuItem( NON_LINED_UP_CLADOGRAMS_LABEL ) );
         _radio_group_1 = new ButtonGroup();
@@ -178,11 +213,11 @@ public final class MainFrameApplet extends MainFrame {
         _options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_OVERVIEW_LABEL ) );
         _options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_SCALE_LABEL ) );
         _options_jmenu
-                .add( _show_default_node_shapes_internal_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_INT ) );
+        .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 ) );
+        .add( _show_default_node_shapes_external_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_EXT ) );
         _options_jmenu
-                .add( _show_default_node_shapes_for_marked_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_MARKED ) );
+        .add( _show_default_node_shapes_for_marked_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_MARKED ) );
         _options_jmenu.add( _line_up_renderable_data_cbmi = new JCheckBoxMenuItem( MainFrame.LINE_UP_RENDERABLE_DATA ) );
         if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
             _options_jmenu.add( _right_line_up_domains_cbmi = new JCheckBoxMenuItem( MainFrame.RIGHT_LINE_UP_DOMAINS ) );
@@ -191,9 +226,9 @@ public final class MainFrameApplet extends MainFrame {
         _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
-                .add( _color_by_taxonomic_group_cbmi = new JCheckBoxMenuItem( MainFrame.COLOR_BY_TAXONOMIC_GROUP ) );
+        .add( _color_by_taxonomic_group_cbmi = new JCheckBoxMenuItem( MainFrame.COLOR_BY_TAXONOMIC_GROUP ) );
         _options_jmenu
-                .add( _color_labels_same_as_parent_branch = new JCheckBoxMenuItem( MainFrame.COLOR_LABELS_LABEL ) );
+        .add( _color_labels_same_as_parent_branch = new JCheckBoxMenuItem( MainFrame.COLOR_LABELS_LABEL ) );
         _color_labels_same_as_parent_branch.setToolTipText( MainFrame.COLOR_LABELS_TIP );
         _options_jmenu.add( _abbreviate_scientific_names = new JCheckBoxMenuItem( MainFrame.ABBREV_SN_LABEL ) );
         _options_jmenu.add( _label_direction_cbmi = new JCheckBoxMenuItem( MainFrame.LABEL_DIRECTION_LABEL ) );
@@ -211,7 +246,7 @@ public final class MainFrameApplet extends MainFrame {
         _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.SEARCH_SUBHEADER ),
                                                                 getConfiguration() ) );
         _options_jmenu
-                .add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_CASE_SENSITIVE_LABEL ) );
+        .add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_CASE_SENSITIVE_LABEL ) );
         _options_jmenu.add( _search_whole_words_only_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_TERMS_ONLY_LABEL ) );
         _options_jmenu.add( _search_with_regex_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_REGEX_LABEL ) );
         _search_with_regex_cbmi.setToolTipText( MainFrame.SEARCH_WITH_REGEX_TIP );
@@ -223,11 +258,11 @@ public final class MainFrameApplet extends MainFrame {
         _options_jmenu.add( _antialias_print_cbmi = new JCheckBoxMenuItem( "Antialias" ) );
         _options_jmenu.add( _print_black_and_white_cbmi = new JCheckBoxMenuItem( "Export in Black and White" ) );
         _options_jmenu
-                .add( _print_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PDF export and Printing" ) );
+        .add( _print_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PDF export and Printing" ) );
         _options_jmenu
-                .add( _graphics_export_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PNG, JPG, and GIF export" ) );
+        .add( _graphics_export_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PNG, JPG, and GIF export" ) );
         _options_jmenu
-                .add( _graphics_export_visible_only_cbmi = new JCheckBoxMenuItem( "Limit to Visible ('Screenshot') for PNG, JPG, and GIF export" ) );
+        .add( _graphics_export_visible_only_cbmi = new JCheckBoxMenuItem( "Limit to Visible ('Screenshot') for PNG, JPG, and GIF export" ) );
         _options_jmenu.add( _print_size_mi = new JMenuItem( "" ) );
         _options_jmenu.add( _choose_pdf_width_mi = new JMenuItem( "" ) );
         //
@@ -236,7 +271,7 @@ public final class MainFrameApplet extends MainFrame {
         customizeCheckBoxMenuItem( _graphics_export_visible_only_cbmi, getOptions().isGraphicsExportVisibleOnly() );
         customizeCheckBoxMenuItem( _print_using_actual_size_cbmi, getOptions().isPrintUsingActualSize() );
         customizeCheckBoxMenuItem( _graphics_export_using_actual_size_cbmi, getOptions()
-                .isGraphicsExportUsingActualSize() );
+                                   .isGraphicsExportUsingActualSize() );
         customizeJMenuItem( _print_size_mi );
         customizeJMenuItem( _choose_pdf_width_mi );
         //
@@ -245,11 +280,11 @@ public final class MainFrameApplet extends MainFrame {
         customizeJMenuItem( _choose_minimal_confidence_mi );
         customizeJMenuItem( _overview_placment_mi );
         customizeCheckBoxMenuItem( _show_default_node_shapes_internal_cbmi, getOptions()
-                .isShowDefaultNodeShapesInternal() );
+                                   .isShowDefaultNodeShapesInternal() );
         customizeCheckBoxMenuItem( _show_default_node_shapes_external_cbmi, getOptions()
-                .isShowDefaultNodeShapesExternal() );
+                                   .isShowDefaultNodeShapesExternal() );
         customizeCheckBoxMenuItem( _show_default_node_shapes_for_marked_cbmi, getOptions()
-                .isShowDefaultNodeShapesForMarkedNodes() );
+                                   .isShowDefaultNodeShapesForMarkedNodes() );
         customizeJMenuItem( _cycle_node_shape_mi );
         customizeJMenuItem( _cycle_node_fill_mi );
         customizeJMenuItem( _choose_node_size_mi );
@@ -289,7 +324,7 @@ public final class MainFrameApplet extends MainFrame {
         _tools_menu.addSeparator();
         _tools_menu.add( _remove_visual_styles_item = new JMenuItem( "Delete All Visual Styles From Nodes" ) );
         _remove_visual_styles_item
-                .setToolTipText( "To remove all node visual styles (fonts, colors) from the current phylogeny." );
+        .setToolTipText( "To remove all node visual styles (fonts, colors) from the current phylogeny." );
         customizeJMenuItem( _remove_visual_styles_item );
         _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete All Colors From Branches" ) );
         _remove_branch_color_item.setToolTipText( "To remove all branch color values from the current phylogeny." );
@@ -306,39 +341,4 @@ public final class MainFrameApplet extends MainFrame {
     JApplet getApplet() {
         return _applet;
     }
-
-    @Override
-    public MainPanel getMainPanel() {
-        return _mainpanel;
-    }
-
-    private void readSpeciesTree( final Configuration configuration, final String species_tree_url_str )
-            throws MalformedURLException, FileNotFoundException, IOException {
-        final URL species_tree_url = new URL( species_tree_url_str );
-        final Phylogeny[] species_trees = AptxUtil.readPhylogeniesFromUrl( species_tree_url,
-                                                                           configuration
-                                                                                   .isValidatePhyloXmlAgainstSchema(),
-                                                                           configuration
-                                                                                   .isReplaceUnderscoresInNhParsing(),
-                                                                           false,
-                                                                           TAXONOMY_EXTRACTION.NO,
-                                                                           false );
-        if ( ( species_trees != null ) && ( species_trees.length > 0 ) ) {
-            AptxUtil.printAppletMessage( ArchaeopteryxA.NAME, "successfully read species tree" );
-            if ( species_trees[ 0 ].isEmpty() ) {
-                ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, "species tree is empty" );
-            }
-            else if ( !species_trees[ 0 ].isRooted() ) {
-                ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, "species tree is not rooted" );
-            }
-            else {
-                setSpeciesTree( species_trees[ 0 ] );
-                AptxUtil.printAppletMessage( ArchaeopteryxA.NAME, "species tree OK" );
-            }
-        }
-        else {
-            ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, "failed to read species tree from "
-                    + species_tree_url_str );
-        }
-    }
 }
index 2588e95..6b2c76c 100644 (file)
@@ -60,7 +60,6 @@ import javax.swing.event.ChangeListener;
 import javax.swing.plaf.synth.SynthLookAndFeel;\r
 \r
 import org.forester.analysis.TaxonomyDataManager;\r
-import org.forester.archaeopteryx.AptxUtil.GraphicsExportType;\r
 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;\r
 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;\r
 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;\r
@@ -83,7 +82,6 @@ import org.forester.io.parsers.phyloxml.PhyloXmlParser;
 import org.forester.io.parsers.phyloxml.PhyloXmlUtil;\r
 import org.forester.io.parsers.tol.TolParser;\r
 import org.forester.io.parsers.util.ParserUtils;\r
-import org.forester.io.writers.PhylogenyWriter;\r
 import org.forester.io.writers.SequenceWriter;\r
 import org.forester.msa.Msa;\r
 import org.forester.msa.MsaFormatException;\r
@@ -107,36 +105,6 @@ import org.forester.util.ForesterUtil;
 \r
 public final class MainFrameApplication extends MainFrame {\r
 \r
-    public static MainFrameApplication createInstance( final Phylogeny[] phys, final Configuration config ) {\r
-        return new MainFrameApplication( phys, config );\r
-    }\r
-\r
-    static MainFrame createInstance( final Phylogeny[] phys, final Configuration config, final String title ) {\r
-        return new MainFrameApplication( phys, config, title );\r
-    }\r
-\r
-    public static MainFrame createInstance( final Phylogeny[] phys,\r
-                                            final Configuration config,\r
-                                            final String title,\r
-                                            final File current_dir ) {\r
-        return new MainFrameApplication( phys, config, title, current_dir );\r
-    }\r
-\r
-    static MainFrame createInstance( final Phylogeny[] phys, final String config_file_name, final String title ) {\r
-        return new MainFrameApplication( phys, config_file_name, title );\r
-    }\r
-\r
-    static void warnIfNotPhyloXmlValidation( final Configuration c ) {\r
-        if ( !c.isValidatePhyloXmlAgainstSchema() ) {\r
-            JOptionPane\r
-                    .showMessageDialog( null,\r
-                                        ForesterUtil\r
-                                                .wordWrap( "phyloXML XSD-based validation is turned off [enable with line 'validate_against_phyloxml_xsd_schem: true' in configuration file]",\r
-                                                           80 ),\r
-                                        "Warning",\r
-                                        JOptionPane.WARNING_MESSAGE );\r
-        }\r
-    }\r
     static final String                  INFER_ANCESTOR_TAXONOMIES             = "Infer Ancestor Taxonomies";\r
     static final String                  OBTAIN_DETAILED_TAXONOMIC_INFORMATION = "Obtain Detailed Taxonomic Information";\r
     private final static int             FRAME_X_SIZE                          = 800;\r
@@ -394,9 +362,9 @@ public final class MainFrameApplication extends MainFrame {
             public void componentResized( final ComponentEvent e ) {\r
                 if ( _mainpanel.getCurrentTreePanel() != null ) {\r
                     _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getCurrentTreePanel()\r
-                                                                                        .getWidth(),\r
+                                                                                .getWidth(),\r
                                                                                 _mainpanel.getCurrentTreePanel()\r
-                                                                                        .getHeight() );\r
+                                                                                .getHeight() );\r
                 }\r
             }\r
         } );\r
@@ -435,11 +403,9 @@ public final class MainFrameApplication extends MainFrame {
             else if ( o == _new_item ) {\r
                 newTree();\r
             }\r
-           \r
             else if ( o == _close_item ) {\r
                 closeCurrentPane();\r
             }\r
-          \r
             else if ( o == _load_species_tree_item ) {\r
                 readSpeciesTreeFromFile();\r
             }\r
@@ -539,6 +505,206 @@ public final class MainFrameApplication extends MainFrame {
         }\r
     }\r
 \r
+    public void end() {\r
+        _mainpanel.terminate();\r
+        _contentpane.removeAll();\r
+        setVisible( false );\r
+        dispose();\r
+    }\r
+\r
+    @Override\r
+    public MainPanel getMainPanel() {\r
+        return _mainpanel;\r
+    }\r
+\r
+    public Msa getMsa() {\r
+        return _msa;\r
+    }\r
+\r
+    public File getMsaFile() {\r
+        return _msa_file;\r
+    }\r
+\r
+    public List<MolecularSequence> getSeqs() {\r
+        return _seqs;\r
+    }\r
+\r
+    public File getSeqsFile() {\r
+        return _seqs_file;\r
+    }\r
+\r
+    public void readMsaFromFile() {\r
+        // Set an initial directory if none set yet\r
+        final File my_dir = getCurrentDir();\r
+        _msa_filechooser.setMultiSelectionEnabled( false );\r
+        // Open file-open dialog and set current directory\r
+        if ( my_dir != null ) {\r
+            _msa_filechooser.setCurrentDirectory( my_dir );\r
+        }\r
+        final int result = _msa_filechooser.showOpenDialog( _contentpane );\r
+        // All done: get the msa\r
+        final File file = _msa_filechooser.getSelectedFile();\r
+        setCurrentDir( _msa_filechooser.getCurrentDirectory() );\r
+        if ( ( file != null ) && !file.isDirectory() && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
+            setMsaFile( null );\r
+            setMsa( null );\r
+            Msa msa = null;\r
+            try {\r
+                final InputStream is = new FileInputStream( file );\r
+                if ( FastaParser.isLikelyFasta( file ) ) {\r
+                    msa = FastaParser.parseMsa( is );\r
+                }\r
+                else {\r
+                    msa = GeneralMsaParser.parse( is );\r
+                }\r
+            }\r
+            catch ( final MsaFormatException e ) {\r
+                setArrowCursor();\r
+                JOptionPane.showMessageDialog( this,\r
+                                               e.getLocalizedMessage(),\r
+                                               "Multiple sequence alignment format error",\r
+                                               JOptionPane.ERROR_MESSAGE );\r
+                return;\r
+            }\r
+            catch ( final IOException e ) {\r
+                setArrowCursor();\r
+                JOptionPane.showMessageDialog( this,\r
+                                               e.getLocalizedMessage(),\r
+                                               "Failed to read multiple sequence alignment",\r
+                                               JOptionPane.ERROR_MESSAGE );\r
+                return;\r
+            }\r
+            catch ( final IllegalArgumentException e ) {\r
+                setArrowCursor();\r
+                JOptionPane.showMessageDialog( this,\r
+                                               e.getLocalizedMessage(),\r
+                                               "Unexpected error during reading of multiple sequence alignment",\r
+                                               JOptionPane.ERROR_MESSAGE );\r
+                return;\r
+            }\r
+            catch ( final Exception e ) {\r
+                setArrowCursor();\r
+                e.printStackTrace();\r
+                JOptionPane.showMessageDialog( this,\r
+                                               e.getLocalizedMessage(),\r
+                                               "Unexpected error during reading of multiple sequence alignment",\r
+                                               JOptionPane.ERROR_MESSAGE );\r
+                return;\r
+            }\r
+            if ( ( msa == null ) || ( msa.getNumberOfSequences() < 1 ) ) {\r
+                JOptionPane.showMessageDialog( this,\r
+                                               "Multiple sequence alignment is empty",\r
+                                               "Illegal Multiple Sequence Alignment",\r
+                                               JOptionPane.ERROR_MESSAGE );\r
+                return;\r
+            }\r
+            if ( msa.getNumberOfSequences() < 4 ) {\r
+                JOptionPane.showMessageDialog( this,\r
+                                               "Multiple sequence alignment needs to contain at least 3 sequences",\r
+                                               "Illegal multiple sequence alignment",\r
+                                               JOptionPane.ERROR_MESSAGE );\r
+                return;\r
+            }\r
+            if ( msa.getLength() < 2 ) {\r
+                JOptionPane.showMessageDialog( this,\r
+                                               "Multiple sequence alignment needs to contain at least 2 residues",\r
+                                               "Illegal multiple sequence alignment",\r
+                                               JOptionPane.ERROR_MESSAGE );\r
+                return;\r
+            }\r
+            System.gc();\r
+            setMsaFile( _msa_filechooser.getSelectedFile() );\r
+            setMsa( msa );\r
+        }\r
+    }\r
+\r
+    public void readSeqsFromFileforPI() {\r
+        // Set an initial directory if none set yet\r
+        final File my_dir = getCurrentDir();\r
+        _seqs_pi_filechooser.setMultiSelectionEnabled( false );\r
+        // Open file-open dialog and set current directory\r
+        if ( my_dir != null ) {\r
+            _seqs_pi_filechooser.setCurrentDirectory( my_dir );\r
+        }\r
+        final int result = _seqs_pi_filechooser.showOpenDialog( _contentpane );\r
+        // All done: get the seqs\r
+        final File file = _seqs_pi_filechooser.getSelectedFile();\r
+        setCurrentDir( _seqs_pi_filechooser.getCurrentDirectory() );\r
+        if ( ( file != null ) && !file.isDirectory() && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
+            setSeqsFile( null );\r
+            setSeqs( null );\r
+            List<MolecularSequence> seqs = null;\r
+            try {\r
+                if ( FastaParser.isLikelyFasta( new FileInputStream( file ) ) ) {\r
+                    seqs = FastaParser.parse( new FileInputStream( file ) );\r
+                    for( final MolecularSequence seq : seqs ) {\r
+                        System.out.println( SequenceWriter.toFasta( seq, 60 ) );\r
+                    }\r
+                }\r
+                else {\r
+                    //TODO error\r
+                }\r
+            }\r
+            catch ( final MsaFormatException e ) {\r
+                setArrowCursor();\r
+                JOptionPane.showMessageDialog( this,\r
+                                               e.getLocalizedMessage(),\r
+                                               "Multiple sequence file format error",\r
+                                               JOptionPane.ERROR_MESSAGE );\r
+                return;\r
+            }\r
+            catch ( final IOException e ) {\r
+                setArrowCursor();\r
+                JOptionPane.showMessageDialog( this,\r
+                                               e.getLocalizedMessage(),\r
+                                               "Failed to read multiple sequence file",\r
+                                               JOptionPane.ERROR_MESSAGE );\r
+                return;\r
+            }\r
+            catch ( final IllegalArgumentException e ) {\r
+                setArrowCursor();\r
+                JOptionPane.showMessageDialog( this,\r
+                                               e.getLocalizedMessage(),\r
+                                               "Unexpected error during reading of multiple sequence file",\r
+                                               JOptionPane.ERROR_MESSAGE );\r
+                return;\r
+            }\r
+            catch ( final Exception e ) {\r
+                setArrowCursor();\r
+                e.printStackTrace();\r
+                JOptionPane.showMessageDialog( this,\r
+                                               e.getLocalizedMessage(),\r
+                                               "Unexpected error during reading of multiple sequence file",\r
+                                               JOptionPane.ERROR_MESSAGE );\r
+                return;\r
+            }\r
+            if ( ( seqs == null ) || ( seqs.size() < 1 ) ) {\r
+                JOptionPane.showMessageDialog( this,\r
+                                               "Multiple sequence file is empty",\r
+                                               "Illegal multiple sequence file",\r
+                                               JOptionPane.ERROR_MESSAGE );\r
+                return;\r
+            }\r
+            if ( seqs.size() < 4 ) {\r
+                JOptionPane.showMessageDialog( this,\r
+                                               "Multiple sequence file needs to contain at least 3 sequences",\r
+                                               "Illegal multiple sequence file",\r
+                                               JOptionPane.ERROR_MESSAGE );\r
+                return;\r
+            }\r
+            //  if ( msa.getLength() < 2 ) {\r
+            //       JOptionPane.showMessageDialog( this,\r
+            //                                      "Multiple sequence alignment needs to contain at least 2 residues",\r
+            //                                      "Illegal multiple sequence file",\r
+            //                                      JOptionPane.ERROR_MESSAGE );\r
+            //       return;\r
+            //   }\r
+            System.gc();\r
+            setSeqsFile( _seqs_pi_filechooser.getSelectedFile() );\r
+            setSeqs( seqs );\r
+        }\r
+    }\r
+\r
     private void addExpressionValuesFromFile() {\r
         if ( ( getCurrentTreePanel() == null ) || ( getCurrentTreePanel().getPhylogeny() == null ) ) {\r
             JOptionPane.showMessageDialog( this,\r
@@ -590,8 +756,8 @@ public final class MainFrameApplication extends MainFrame {
                 JOptionPane.showMessageDialog( this,\r
                                                "Table contains " + t.getNumberOfRows() + " rows, but tree contains "\r
                                                        + phy.getNumberOfExternalNodes() + " external nodes",\r
-                                               "Warning",\r
-                                               JOptionPane.WARNING_MESSAGE );\r
+                                                       "Warning",\r
+                                                       JOptionPane.WARNING_MESSAGE );\r
             }\r
             final DescriptiveStatistics stats = new BasicDescriptiveStatistics();\r
             int not_found = 0;\r
@@ -605,10 +771,10 @@ public final class MainFrameApplication extends MainFrame {
                     }\r
                     catch ( final IllegalArgumentException e ) {\r
                         JOptionPane\r
-                                .showMessageDialog( this,\r
-                                                    e.getMessage(),\r
-                                                    "Error Mapping Node Identifiers to Expression Value Identifiers",\r
-                                                    JOptionPane.ERROR_MESSAGE );\r
+                        .showMessageDialog( this,\r
+                                            e.getMessage(),\r
+                                            "Error Mapping Node Identifiers to Expression Value Identifiers",\r
+                                            JOptionPane.ERROR_MESSAGE );\r
                         return;\r
                     }\r
                     if ( row < 0 ) {\r
@@ -626,7 +792,7 @@ public final class MainFrameApplication extends MainFrame {
                         catch ( final NumberFormatException e ) {\r
                             JOptionPane.showMessageDialog( this,\r
                                                            "Could not parse \"" + t.getValueAsString( col, row )\r
-                                                                   + "\" into a decimal value",\r
+                                                           + "\" into a decimal value",\r
                                                            "Issue with Expression Value Table",\r
                                                            JOptionPane.ERROR_MESSAGE );\r
                             return;\r
@@ -637,7 +803,7 @@ public final class MainFrameApplication extends MainFrame {
                     if ( !l.isEmpty() ) {\r
                         if ( node.getNodeData().getProperties() != null ) {\r
                             node.getNodeData().getProperties()\r
-                                    .removePropertiesWithGivenReferencePrefix( PhyloXmlUtil.VECTOR_PROPERTY_REF );\r
+                            .removePropertiesWithGivenReferencePrefix( PhyloXmlUtil.VECTOR_PROPERTY_REF );\r
                         }\r
                         node.getNodeData().setVector( l );\r
                     }\r
@@ -645,7 +811,7 @@ public final class MainFrameApplication extends MainFrame {
             }\r
             if ( not_found > 0 ) {\r
                 JOptionPane.showMessageDialog( this, "Could not fine expression values for " + not_found\r
-                        + " external node(s)", "Warning", JOptionPane.WARNING_MESSAGE );\r
+                                               + " external node(s)", "Warning", JOptionPane.WARNING_MESSAGE );\r
             }\r
             getCurrentTreePanel().setStatisticsForExpressionValues( stats );\r
         }\r
@@ -754,7 +920,7 @@ public final class MainFrameApplication extends MainFrame {
                         }\r
                         if ( nodes.size() > 1 ) {\r
                             JOptionPane.showMessageDialog( this, "Split sequence name \"" + seq_name_split\r
-                                    + "\" is not unique", "Sequence name not unique", JOptionPane.ERROR_MESSAGE );\r
+                                                           + "\" is not unique", "Sequence name not unique", JOptionPane.ERROR_MESSAGE );\r
                             setArrowCursor();\r
                             return;\r
                         }\r
@@ -799,451 +965,187 @@ public final class MainFrameApplication extends MainFrame {
                 }\r
                 else {\r
                     JOptionPane.showMessageDialog( this, "Attached " + attached_counter\r
-                            + " sequences out of a total of " + total_counter + " sequences.\n" + s, attached_counter\r
-                            + " sequences attached", JOptionPane.WARNING_MESSAGE );\r
+                                                   + " sequences out of a total of " + total_counter + " sequences.\n" + s, attached_counter\r
+                                                   + " sequences attached", JOptionPane.WARNING_MESSAGE );\r
                 }\r
             }\r
             else {\r
                 JOptionPane.showMessageDialog( this, "No maching tree node for any of the " + total_counter\r
-                        + " sequences", "Could not attach any sequences", JOptionPane.ERROR_MESSAGE );\r
+                                               + " sequences", "Could not attach any sequences", JOptionPane.ERROR_MESSAGE );\r
             }\r
         }\r
     }\r
 \r
-    void buildAnalysisMenu() {\r
-        _analysis_menu = MainFrame.createMenu( "Analysis", getConfiguration() );\r
-        _analysis_menu.add( _gsdi_item = new JMenuItem( "GSDI (Generalized Speciation Duplication Inference)" ) );\r
-        _analysis_menu.add( _gsdir_item = new JMenuItem( "GSDIR (GSDI with re-rooting)" ) );\r
-        _analysis_menu.add( _load_species_tree_item = new JMenuItem( "Load Species Tree..." ) );\r
-        customizeJMenuItem( _gsdi_item );\r
-        customizeJMenuItem( _gsdir_item );\r
-        customizeJMenuItem( _load_species_tree_item );\r
-        _analysis_menu.addSeparator();\r
-        _analysis_menu.add( _lineage_inference = new JMenuItem( INFER_ANCESTOR_TAXONOMIES ) );\r
-        customizeJMenuItem( _lineage_inference );\r
-        _lineage_inference.setToolTipText( "Inference of ancestor taxonomies/lineages" );\r
-        _jmenubar.add( _analysis_menu );\r
+    private void closeCurrentPane() {\r
+        if ( getMainPanel().getCurrentTreePanel() != null ) {\r
+            if ( getMainPanel().getCurrentTreePanel().isEdited() ) {\r
+                final int r = JOptionPane.showConfirmDialog( this,\r
+                                                             "Close tab despite potentially unsaved changes?",\r
+                                                             "Close Tab?",\r
+                                                             JOptionPane.YES_NO_OPTION );\r
+                if ( r != JOptionPane.YES_OPTION ) {\r
+                    return;\r
+                }\r
+            }\r
+            getMainPanel().closeCurrentPane();\r
+            activateSaveAllIfNeeded();\r
+        }\r
     }\r
 \r
-    @Override\r
-    void buildFileMenu() {\r
-        _file_jmenu = MainFrame.createMenu( "File", getConfiguration() );\r
-        _file_jmenu.add( _open_item = new JMenuItem( "Read Tree from File..." ) );\r
-        _file_jmenu.addSeparator();\r
-        _file_jmenu.add( _open_url_item = new JMenuItem( "Read Tree from URL/Webservice..." ) );\r
-        _file_jmenu.addSeparator();\r
-        final WebservicesManager webservices_manager = WebservicesManager.getInstance();\r
-        _load_phylogeny_from_webservice_menu_items = new JMenuItem[ webservices_manager\r
-                .getAvailablePhylogeniesWebserviceClients().size() ];\r
-        for( int i = 0; i < webservices_manager.getAvailablePhylogeniesWebserviceClients().size(); ++i ) {\r
-            final PhylogeniesWebserviceClient client = webservices_manager.getAvailablePhylogeniesWebserviceClient( i );\r
-            _load_phylogeny_from_webservice_menu_items[ i ] = new JMenuItem( client.getMenuName() );\r
-            _file_jmenu.add( _load_phylogeny_from_webservice_menu_items[ i ] );\r
-        }\r
-        if ( getConfiguration().isEditable() ) {\r
-            _file_jmenu.addSeparator();\r
-            _file_jmenu.add( _new_item = new JMenuItem( "New" ) );\r
-            _new_item.setToolTipText( "to create a new tree with one node, as source for manual tree construction" );\r
-        }\r
-        _file_jmenu.addSeparator();\r
-        _file_jmenu.add( _save_item = new JMenuItem( "Save Tree As..." ) );\r
-        _file_jmenu.add( _save_all_item = new JMenuItem( "Save All Trees As..." ) );\r
-        _save_all_item.setToolTipText( "Write all phylogenies to one file." );\r
-        _save_all_item.setEnabled( false );\r
-        _file_jmenu.addSeparator();\r
-        _file_jmenu.add( _write_to_pdf_item = new JMenuItem( "Export to PDF file ..." ) );\r
-        if ( AptxUtil.canWriteFormat( "tif" ) || AptxUtil.canWriteFormat( "tiff" ) || AptxUtil.canWriteFormat( "TIF" ) ) {\r
-            _file_jmenu.add( _write_to_tif_item = new JMenuItem( "Export to TIFF file..." ) );\r
-        }\r
-        _file_jmenu.add( _write_to_png_item = new JMenuItem( "Export to PNG file..." ) );\r
-        _file_jmenu.add( _write_to_jpg_item = new JMenuItem( "Export to JPG file..." ) );\r
-        if ( AptxUtil.canWriteFormat( "gif" ) ) {\r
-            _file_jmenu.add( _write_to_gif_item = new JMenuItem( "Export to GIF file..." ) );\r
-        }\r
-        if ( AptxUtil.canWriteFormat( "bmp" ) ) {\r
-            _file_jmenu.add( _write_to_bmp_item = new JMenuItem( "Export to BMP file..." ) );\r
+    private void collapse( final Phylogeny phy ) {\r
+        final PhylogenyNodeIterator it = phy.iteratorPostorder();\r
+        final List<PhylogenyNode> to_be_removed = new ArrayList<PhylogenyNode>();\r
+        double min_support = Double.MAX_VALUE;\r
+        boolean conf_present = false;\r
+        while ( it.hasNext() ) {\r
+            final PhylogenyNode n = it.next();\r
+            if ( !n.isExternal() && !n.isRoot() ) {\r
+                final List<Confidence> c = n.getBranchData().getConfidences();\r
+                if ( ( c != null ) && ( c.size() > 0 ) ) {\r
+                    conf_present = true;\r
+                    double max = 0;\r
+                    for( final Confidence confidence : c ) {\r
+                        if ( confidence.getValue() > max ) {\r
+                            max = confidence.getValue();\r
+                        }\r
+                    }\r
+                    if ( max < getMinNotCollapseConfidenceValue() ) {\r
+                        to_be_removed.add( n );\r
+                    }\r
+                    if ( max < min_support ) {\r
+                        min_support = max;\r
+                    }\r
+                }\r
+            }\r
         }\r
-        _file_jmenu.addSeparator();\r
-        _file_jmenu.add( _print_item = new JMenuItem( "Print..." ) );\r
-        _file_jmenu.addSeparator();\r
-        _file_jmenu.add( _close_item = new JMenuItem( "Close Tab" ) );\r
-        _close_item.setToolTipText( "To close the current pane." );\r
-        _close_item.setEnabled( true );\r
-        _file_jmenu.addSeparator();\r
-        _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );\r
-        customizeJMenuItem( _open_item );\r
-        _open_item\r
-                .setFont( new Font( _open_item.getFont().getFontName(), Font.BOLD, _open_item.getFont().getSize() + 4 ) );\r
-        customizeJMenuItem( _open_url_item );\r
-        for( int i = 0; i < webservices_manager.getAvailablePhylogeniesWebserviceClients().size(); ++i ) {\r
-            customizeJMenuItem( _load_phylogeny_from_webservice_menu_items[ i ] );\r
+        if ( conf_present ) {\r
+            for( final PhylogenyNode node : to_be_removed ) {\r
+                PhylogenyMethods.removeNode( node, phy );\r
+            }\r
+            if ( to_be_removed.size() > 0 ) {\r
+                phy.externalNodesHaveChanged();\r
+                phy.clearHashIdToNodeMap();\r
+                phy.recalculateNumberOfExternalDescendants( true );\r
+                getCurrentTreePanel().resetNodeIdToDistToLeafMap();\r
+                getCurrentTreePanel().updateSetOfCollapsedExternalNodes();\r
+                getCurrentTreePanel().calculateLongestExtNodeInfo();\r
+                getCurrentTreePanel().setNodeInPreorderToNull();\r
+                getCurrentTreePanel().recalculateMaxDistanceToRoot();\r
+                getCurrentTreePanel().resetPreferredSize();\r
+                getCurrentTreePanel().setEdited( true );\r
+                getCurrentTreePanel().repaint();\r
+                repaint();\r
+            }\r
+            if ( to_be_removed.size() > 0 ) {\r
+                JOptionPane.showMessageDialog( this, "Collapsed " + to_be_removed.size()\r
+                                               + " branches with\nconfidence values below " + getMinNotCollapseConfidenceValue(), "Collapsed "\r
+                                                       + to_be_removed.size() + " branches", JOptionPane.INFORMATION_MESSAGE );\r
+            }\r
+            else {\r
+                JOptionPane.showMessageDialog( this, "No branch collapsed,\nminimum confidence value per branch is "\r
+                        + min_support, "No branch collapsed", JOptionPane.INFORMATION_MESSAGE );\r
+            }\r
         }\r
-        customizeJMenuItem( _save_item );\r
-        if ( getConfiguration().isEditable() ) {\r
-            customizeJMenuItem( _new_item );\r
+        else {\r
+            JOptionPane.showMessageDialog( this,\r
+                                           "No branch collapsed because no confidence values present",\r
+                                           "No confidence values present",\r
+                                           JOptionPane.INFORMATION_MESSAGE );\r
         }\r
-        customizeJMenuItem( _close_item );\r
-        customizeJMenuItem( _save_all_item );\r
-        customizeJMenuItem( _write_to_pdf_item );\r
-        customizeJMenuItem( _write_to_png_item );\r
-        customizeJMenuItem( _write_to_jpg_item );\r
-        customizeJMenuItem( _write_to_gif_item );\r
-        customizeJMenuItem( _write_to_tif_item );\r
-        customizeJMenuItem( _write_to_bmp_item );\r
-        customizeJMenuItem( _print_item );\r
-        customizeJMenuItem( _exit_item );\r
-        _jmenubar.add( _file_jmenu );\r
     }\r
 \r
-    void buildOptionsMenu() {\r
-        _options_jmenu = MainFrame.createMenu( OPTIONS_HEADER, getConfiguration() );\r
-        _options_jmenu.addChangeListener( new ChangeListener() {\r
+    private void collapseBelowBranchLengthThreshold() {\r
+        if ( getCurrentTreePanel() != null ) {\r
+            final Phylogeny phy = getCurrentTreePanel().getPhylogeny();\r
+            if ( ( phy != null ) && !phy.isEmpty() ) {\r
+                final String s = ( String ) JOptionPane\r
+                        .showInputDialog( this,\r
+                                          "Please enter the minimum branch length value\n",\r
+                                          "Minimal Branch Length Value",\r
+                                          JOptionPane.QUESTION_MESSAGE,\r
+                                          null,\r
+                                          null,\r
+                                          getMinNotCollapseBlValue() );\r
+                if ( !ForesterUtil.isEmpty( s ) ) {\r
+                    boolean success = true;\r
+                    double m = 0.0;\r
+                    final String m_str = s.trim();\r
+                    if ( !ForesterUtil.isEmpty( m_str ) ) {\r
+                        try {\r
+                            m = Double.parseDouble( m_str );\r
+                        }\r
+                        catch ( final Exception ex ) {\r
+                            success = false;\r
+                        }\r
+                    }\r
+                    else {\r
+                        success = false;\r
+                    }\r
+                    if ( success && ( m >= 0.0 ) ) {\r
+                        setMinNotCollapseBlValue( m );\r
+                        collapseBl( phy );\r
+                    }\r
+                }\r
+            }\r
+        }\r
+    }\r
 \r
-            @Override\r
-            public void stateChanged( final ChangeEvent e ) {\r
-                MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getOptions() );\r
-                MainFrame.setTextColorChooseMenuItem( _switch_colors_mi, getCurrentTreePanel() );\r
-                MainFrame\r
-                        .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() );\r
-                MainFrame.setTextForFontChooserMenuItem( _choose_font_mi, MainFrame\r
-                        .createCurrentFontDesc( getMainPanel().getTreeFontSet() ) );\r
-                MainFrame.setTextForGraphicsSizeChooserMenuItem( _print_size_mi, getOptions() );\r
-                MainFrame.setTextForPdfLineWidthChooserMenuItem( _choose_pdf_width_mi, getOptions() );\r
-                MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() );\r
-                MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() );\r
-                MainFrame.setCycleDataReturnMenuItem( _cycle_data_return, getOptions() );\r
-                MainFrame.setTextNodeSizeMenuItem( _choose_node_size_mi, getOptions() );\r
-                try {\r
-                    getMainPanel().getControlPanel().setVisibilityOfDomainStrucureCB();\r
-                    getMainPanel().getControlPanel().setVisibilityOfX();\r
+    private void collapseBelowThreshold() {\r
+        if ( getCurrentTreePanel() != null ) {\r
+            final Phylogeny phy = getCurrentTreePanel().getPhylogeny();\r
+            if ( ( phy != null ) && !phy.isEmpty() ) {\r
+                final String s = ( String ) JOptionPane.showInputDialog( this,\r
+                                                                         "Please enter the minimum confidence value\n",\r
+                                                                         "Minimal Confidence Value",\r
+                                                                         JOptionPane.QUESTION_MESSAGE,\r
+                                                                         null,\r
+                                                                         null,\r
+                                                                         getMinNotCollapseConfidenceValue() );\r
+                if ( !ForesterUtil.isEmpty( s ) ) {\r
+                    boolean success = true;\r
+                    double m = 0.0;\r
+                    final String m_str = s.trim();\r
+                    if ( !ForesterUtil.isEmpty( m_str ) ) {\r
+                        try {\r
+                            m = Double.parseDouble( m_str );\r
+                        }\r
+                        catch ( final Exception ex ) {\r
+                            success = false;\r
+                        }\r
+                    }\r
+                    else {\r
+                        success = false;\r
+                    }\r
+                    if ( success && ( m >= 0.0 ) ) {\r
+                        setMinNotCollapseConfidenceValue( m );\r
+                        collapse( phy );\r
+                    }\r
                 }\r
-                catch ( final Exception ignore ) {\r
-                    // do nothing, not important.\r
+            }\r
+        }\r
+    }\r
+\r
+    private void collapseBl( final Phylogeny phy ) {\r
+        final PhylogenyNodeIterator it = phy.iteratorPostorder();\r
+        final List<PhylogenyNode> to_be_removed = new ArrayList<PhylogenyNode>();\r
+        double min_bl = Double.MAX_VALUE;\r
+        boolean bl_present = false;\r
+        while ( it.hasNext() ) {\r
+            final PhylogenyNode n = it.next();\r
+            if ( !n.isExternal() && !n.isRoot() ) {\r
+                final double bl = n.getDistanceToParent();\r
+                if ( bl != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {\r
+                    bl_present = true;\r
+                    if ( bl < getMinNotCollapseBlValue() ) {\r
+                        to_be_removed.add( n );\r
+                    }\r
+                    if ( bl < min_bl ) {\r
+                        min_bl = bl;\r
+                    }\r
                 }\r
             }\r
-        } );\r
-        _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( DISPLAY_SUBHEADER ), getConfiguration() ) );\r
-        _options_jmenu\r
-                .add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );\r
-        _options_jmenu.add( _uniform_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.UNIFORM_CLADOGRAMS_LABEL ) );\r
-        _options_jmenu.add( _non_lined_up_cladograms_rbmi = new JRadioButtonMenuItem( NON_LINED_UP_CLADOGRAMS_LABEL ) );\r
-        _radio_group_1 = new ButtonGroup();\r
-        _radio_group_1.add( _ext_node_dependent_cladogram_rbmi );\r
-        _radio_group_1.add( _uniform_cladograms_rbmi );\r
-        _radio_group_1.add( _non_lined_up_cladograms_rbmi );\r
-        _options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( SHOW_OVERVIEW_LABEL ) );\r
-        _options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( DISPLAY_SCALE_LABEL ) );\r
-        _options_jmenu\r
-                .add( _show_default_node_shapes_internal_cbmi = new JCheckBoxMenuItem( DISPLAY_NODE_BOXES_LABEL_INT ) );\r
-        _options_jmenu\r
-                .add( _show_default_node_shapes_external_cbmi = new JCheckBoxMenuItem( DISPLAY_NODE_BOXES_LABEL_EXT ) );\r
-        _options_jmenu\r
-                .add( _show_default_node_shapes_for_marked_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_MARKED ) );\r
-        _options_jmenu.add( _line_up_renderable_data_cbmi = new JCheckBoxMenuItem( MainFrame.LINE_UP_RENDERABLE_DATA ) );\r
-        if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {\r
-            _options_jmenu.add( _right_line_up_domains_cbmi = new JCheckBoxMenuItem( MainFrame.RIGHT_LINE_UP_DOMAINS ) );\r
-            _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( MainFrame.SHOW_DOMAIN_LABELS_LABEL ) );\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
-        _options_jmenu.add( _color_labels_same_as_parent_branch = new JCheckBoxMenuItem( COLOR_LABELS_LABEL ) );\r
-        _color_labels_same_as_parent_branch.setToolTipText( MainFrame.COLOR_LABELS_TIP );\r
-        _options_jmenu.add( _abbreviate_scientific_names = new JCheckBoxMenuItem( ABBREV_SN_LABEL ) );\r
-        _options_jmenu.add( _label_direction_cbmi = new JCheckBoxMenuItem( LABEL_DIRECTION_LABEL ) );\r
-        _label_direction_cbmi.setToolTipText( LABEL_DIRECTION_TIP );\r
-        _options_jmenu.add( _screen_antialias_cbmi = new JCheckBoxMenuItem( SCREEN_ANTIALIAS_LABEL ) );\r
-        _options_jmenu.add( _background_gradient_cbmi = new JCheckBoxMenuItem( BG_GRAD_LABEL ) );\r
-        _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL ) );\r
-        _options_jmenu.add( _cycle_node_fill_mi = new JMenuItem( MainFrame.CYCLE_NODE_FILL_LABEL ) );\r
-        _options_jmenu.add( _choose_node_size_mi = new JMenuItem( MainFrame.CHOOSE_NODE_SIZE_LABEL ) );\r
-        _options_jmenu.add( _choose_minimal_confidence_mi = new JMenuItem( "" ) );\r
-        _options_jmenu.add( _overview_placment_mi = new JMenuItem( "" ) );\r
-        _options_jmenu.add( _switch_colors_mi = new JMenuItem( "" ) );\r
-        _options_jmenu.add( _choose_font_mi = new JMenuItem( "" ) );\r
-        _options_jmenu.addSeparator();\r
-        _options_jmenu.add( _cycle_data_return = new JMenuItem( "Cycle Data Return" ) );\r
-        _options_jmenu.addSeparator();\r
-        _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( SEARCH_SUBHEADER ), getConfiguration() ) );\r
-        _options_jmenu.add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( SEARCH_CASE_SENSITIVE_LABEL ) );\r
-        _options_jmenu.add( _search_whole_words_only_cbmi = new JCheckBoxMenuItem( SEARCH_TERMS_ONLY_LABEL ) );\r
-        _options_jmenu.add( _search_with_regex_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_REGEX_LABEL ) );\r
-        _search_with_regex_cbmi.setToolTipText( MainFrame.SEARCH_WITH_REGEX_TIP );\r
-        _options_jmenu.add( _inverse_search_result_cbmi = new JCheckBoxMenuItem( INVERSE_SEARCH_RESULT_LABEL ) );\r
-        _options_jmenu.addSeparator();\r
-        _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( "Graphics Export & Printing:" ),\r
-                                                      getConfiguration() ) );\r
-        _options_jmenu.add( _antialias_print_cbmi = new JCheckBoxMenuItem( "Antialias" ) );\r
-        _options_jmenu.add( _print_black_and_white_cbmi = new JCheckBoxMenuItem( "Export in Black and White" ) );\r
-        _options_jmenu\r
-                .add( _print_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PDF export and Printing" ) );\r
-        _options_jmenu\r
-                .add( _graphics_export_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PNG, JPG, and GIF export" ) );\r
-        _options_jmenu\r
-                .add( _graphics_export_visible_only_cbmi = new JCheckBoxMenuItem( "Limit to Visible ('Screenshot') for PNG, JPG, and GIF export" ) );\r
-        _options_jmenu.add( _print_size_mi = new JMenuItem( "" ) );\r
-        _options_jmenu.add( _choose_pdf_width_mi = new JMenuItem( "" ) );\r
-        _options_jmenu.addSeparator();\r
-        _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( "Newick/NHX/Nexus Input:" ), getConfiguration() ) );\r
-        _options_jmenu\r
-                .add( _internal_number_are_confidence_for_nh_parsing_cbmi = new JCheckBoxMenuItem( "Internal Node Names are Confidence Values" ) );\r
-        _options_jmenu.add( _replace_underscores_cbmi = new JCheckBoxMenuItem( "Replace Underscores with Spaces" ) );\r
-        _options_jmenu\r
-                .add( _allow_errors_in_distance_to_parent_cbmi = new JCheckBoxMenuItem( "Ignore Distance Values Format Errors" ) );\r
-        _options_jmenu.add( _extract_taxonomy_no_rbmi = new JRadioButtonMenuItem( "No Taxonomy Extraction" ) );\r
-        _options_jmenu\r
-                .add( _extract_taxonomy_pfam_strict_rbmi = new JRadioButtonMenuItem( "Extract Taxonomy Codes/Ids from Pfam-style Node Names" ) );\r
-        _options_jmenu\r
-                .add( _extract_taxonomy_pfam_relaxed_rbmi = new JRadioButtonMenuItem( "Extract Taxonomy Codes/Ids from Pfam-style like Node Names" ) );\r
-        _options_jmenu\r
-                .add( _extract_taxonomy_agressive_rbmi = new JRadioButtonMenuItem( "Extract Taxonomy Codes/Ids/Scientific Names from Node Names" ) );\r
-        _extract_taxonomy_pfam_strict_rbmi\r
-                .setToolTipText( "To extract taxonomy codes/ids from node names in the form of e.g. \"BCL2_MOUSE/123-304\" or \"BCL2_10090/123-304\"" );\r
-        _extract_taxonomy_pfam_relaxed_rbmi\r
-                .setToolTipText( "To extract taxonomy codes/ids from node names in the form of e.g. \"bax_MOUSE\" or \"bax_10090\"" );\r
-        _extract_taxonomy_agressive_rbmi\r
-                .setToolTipText( "To extract taxonomy codes/ids or scientific names from node names in the form of e.g. \"MOUSE\" or \"10090\" or \"xyz_Nematostella_vectensis\"" );\r
-        _radio_group_2 = new ButtonGroup();\r
-        _radio_group_2.add( _extract_taxonomy_no_rbmi );\r
-        _radio_group_2.add( _extract_taxonomy_pfam_strict_rbmi );\r
-        _radio_group_2.add( _extract_taxonomy_pfam_relaxed_rbmi );\r
-        _radio_group_2.add( _extract_taxonomy_agressive_rbmi );\r
-        _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( "Newick/Nexus Output:" ), getConfiguration() ) );\r
-        _options_jmenu\r
-                .add( _use_brackets_for_conf_in_nh_export_cbmi = new JCheckBoxMenuItem( USE_BRACKETS_FOR_CONF_IN_NH_LABEL ) );\r
-        _use_brackets_for_conf_in_nh_export_cbmi\r
-                .setToolTipText( "e.g. \"0.1[90]\" for a branch with support 90 and a length of 0.1" );\r
-        _options_jmenu\r
-                .add( _use_internal_names_for_conf_in_nh_export_cbmi = new JCheckBoxMenuItem( USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL ) );\r
-        customizeJMenuItem( _choose_font_mi );\r
-        customizeJMenuItem( _choose_minimal_confidence_mi );\r
-        customizeJMenuItem( _switch_colors_mi );\r
-        customizeJMenuItem( _print_size_mi );\r
-        customizeJMenuItem( _choose_pdf_width_mi );\r
-        customizeJMenuItem( _overview_placment_mi );\r
-        customizeCheckBoxMenuItem( _show_default_node_shapes_external_cbmi, getOptions()\r
-                .isShowDefaultNodeShapesExternal() );\r
-        customizeCheckBoxMenuItem( _show_default_node_shapes_internal_cbmi, getOptions()\r
-                .isShowDefaultNodeShapesInternal() );\r
-        customizeCheckBoxMenuItem( _show_default_node_shapes_for_marked_cbmi, getOptions()\r
-                .isShowDefaultNodeShapesForMarkedNodes() );\r
-        customizeJMenuItem( _cycle_node_shape_mi );\r
-        customizeJMenuItem( _cycle_node_fill_mi );\r
-        customizeJMenuItem( _choose_node_size_mi );\r
-        customizeJMenuItem( _cycle_data_return );\r
-        customizeCheckBoxMenuItem( _color_labels_same_as_parent_branch, getOptions().isColorLabelsSameAsParentBranch() );\r
-        customizeCheckBoxMenuItem( _color_by_taxonomic_group_cbmi, getOptions().isColorByTaxonomicGroup() );\r
-        customizeCheckBoxMenuItem( _screen_antialias_cbmi, getOptions().isAntialiasScreen() );\r
-        customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );\r
-        customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );\r
-        customizeCheckBoxMenuItem( _show_annotation_ref_source, getOptions().isShowAnnotationRefSource() );\r
-        customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );\r
-        customizeCheckBoxMenuItem( _search_case_senstive_cbmi, getOptions().isSearchCaseSensitive() );\r
-        customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );\r
-        customizeRadioButtonMenuItem( _non_lined_up_cladograms_rbmi,\r
-                                      getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP );\r
-        customizeRadioButtonMenuItem( _uniform_cladograms_rbmi,\r
-                                      getOptions().getCladogramType() == CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );\r
-        customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi,\r
-                                      getOptions().getCladogramType() == CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );\r
-        customizeCheckBoxMenuItem( _show_overview_cbmi, getOptions().isShowOverview() );\r
-        customizeCheckBoxMenuItem( _label_direction_cbmi,\r
-                                   getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL );\r
-        customizeCheckBoxMenuItem( _antialias_print_cbmi, getOptions().isAntialiasPrint() );\r
-        customizeCheckBoxMenuItem( _print_black_and_white_cbmi, getOptions().isPrintBlackAndWhite() );\r
-        customizeCheckBoxMenuItem( _internal_number_are_confidence_for_nh_parsing_cbmi, getOptions()\r
-                .isInternalNumberAreConfidenceForNhParsing() );\r
-        customizeRadioButtonMenuItem( _extract_taxonomy_no_rbmi,\r
-                                      getOptions().getTaxonomyExtraction() == TAXONOMY_EXTRACTION.NO );\r
-        customizeRadioButtonMenuItem( _extract_taxonomy_pfam_strict_rbmi,\r
-                                      getOptions().getTaxonomyExtraction() == TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );\r
-        customizeRadioButtonMenuItem( _extract_taxonomy_pfam_relaxed_rbmi,\r
-                                      getOptions().getTaxonomyExtraction() == TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );\r
-        customizeRadioButtonMenuItem( _extract_taxonomy_agressive_rbmi,\r
-                                      getOptions().getTaxonomyExtraction() == TAXONOMY_EXTRACTION.AGGRESSIVE );\r
-        customizeCheckBoxMenuItem( _replace_underscores_cbmi, getOptions().isReplaceUnderscoresInNhParsing() );\r
-        customizeCheckBoxMenuItem( _allow_errors_in_distance_to_parent_cbmi, getOptions()\r
-                .isReplaceUnderscoresInNhParsing() );\r
-        customizeCheckBoxMenuItem( _search_with_regex_cbmi, getOptions().isSearchWithRegex() );\r
-        customizeCheckBoxMenuItem( _search_whole_words_only_cbmi, getOptions().isMatchWholeTermsOnly() );\r
-        customizeCheckBoxMenuItem( _inverse_search_result_cbmi, getOptions().isInverseSearchResult() );\r
-        customizeCheckBoxMenuItem( _graphics_export_visible_only_cbmi, getOptions().isGraphicsExportVisibleOnly() );\r
-        customizeCheckBoxMenuItem( _print_using_actual_size_cbmi, getOptions().isPrintUsingActualSize() );\r
-        customizeCheckBoxMenuItem( _graphics_export_using_actual_size_cbmi, getOptions()\r
-                .isGraphicsExportUsingActualSize() );\r
-        customizeCheckBoxMenuItem( _show_confidence_stddev_cbmi, getOptions().isShowConfidenceStddev() );\r
-        customizeCheckBoxMenuItem( _use_brackets_for_conf_in_nh_export_cbmi, getOptions()\r
-                .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
-        customizeCheckBoxMenuItem( _line_up_renderable_data_cbmi, getOptions().isLineUpRendarableNodeData() );\r
-        customizeCheckBoxMenuItem( _right_line_up_domains_cbmi, getOptions().isRightLineUpDomains() );\r
-        _jmenubar.add( _options_jmenu );\r
-    }\r
-\r
-    void buildPhylogeneticInferenceMenu() {\r
-        final InferenceManager im = getInferenceManager();\r
-        _inference_menu = MainFrame.createMenu( "Inference", getConfiguration() );\r
-        _inference_menu.add( _inference_from_msa_item = new JMenuItem( "From Multiple Sequence Alignment..." ) );\r
-        customizeJMenuItem( _inference_from_msa_item );\r
-        _inference_from_msa_item.setToolTipText( "Basic phylogenetic inference from MSA" );\r
-        if ( im.canDoMsa() ) {\r
-            _inference_menu.add( _inference_from_seqs_item = new JMenuItem( "From Unaligned Sequences..." ) );\r
-            customizeJMenuItem( _inference_from_seqs_item );\r
-            _inference_from_seqs_item\r
-                    .setToolTipText( "Basic phylogenetic inference including multiple sequence alignment" );\r
-        }\r
-        else {\r
-            _inference_menu\r
-                    .add( _inference_from_seqs_item = new JMenuItem( "From Unaligned Sequences (no program found)" ) );\r
-            customizeJMenuItem( _inference_from_seqs_item );\r
-            _inference_from_seqs_item.setEnabled( false );\r
-        }\r
-        _jmenubar.add( _inference_menu );\r
-    }\r
-\r
-    void buildToolsMenu() {\r
-        _tools_menu = createMenu( "Tools", getConfiguration() );\r
-        _tools_menu.add( _confcolor_item = new JMenuItem( "Colorize Branches Depending on Confidence" ) );\r
-        customizeJMenuItem( _confcolor_item );\r
-        _tools_menu.add( _color_rank_jmi = new JMenuItem( "Colorize Subtrees via Taxonomic Rank" ) );\r
-        customizeJMenuItem( _color_rank_jmi );\r
-        _color_rank_jmi.setToolTipText( "for example, at \"Class\" level, colorize mammal specific subtree red" );\r
-        _tools_menu.add( _taxcolor_item = new JMenuItem( "Taxonomy Colorize Branches" ) );\r
-        customizeJMenuItem( _taxcolor_item );\r
-        _tools_menu.addSeparator();\r
-        _tools_menu.add( _remove_visual_styles_item = new JMenuItem( "Delete All Visual Styles From Nodes" ) );\r
-        _remove_visual_styles_item\r
-                .setToolTipText( "To remove all node visual styles (fonts, colors) from the current phylogeny" );\r
-        customizeJMenuItem( _remove_visual_styles_item );\r
-        _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete All Colors From Branches" ) );\r
-        _remove_branch_color_item.setToolTipText( "To remove all branch color values from the current phylogeny" );\r
-        customizeJMenuItem( _remove_branch_color_item );\r
-        _tools_menu.addSeparator();\r
-        _tools_menu.add( _annotate_item = new JMenuItem( "Annotate Sequences of Selected Nodes" ) );\r
-        customizeJMenuItem( _annotate_item );\r
-        _tools_menu.addSeparator();\r
-        _tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) );\r
-        customizeJMenuItem( _midpoint_root_item );\r
-        _tools_menu.addSeparator();\r
-        _tools_menu.add( _delete_selected_nodes_item = new JMenuItem( "Delete Selected Nodes" ) );\r
-        _delete_selected_nodes_item.setToolTipText( "To delete all selected external nodes" );\r
-        customizeJMenuItem( _delete_selected_nodes_item );\r
-        _tools_menu.add( _delete_not_selected_nodes_item = new JMenuItem( "Retain Selected Nodes" ) );\r
-        _delete_not_selected_nodes_item.setToolTipText( "To delete all not selected external nodes" );\r
-        customizeJMenuItem( _delete_not_selected_nodes_item );\r
-        _tools_menu.addSeparator();\r
-        _tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Species-Specific Subtrees" ) );\r
-        customizeJMenuItem( _collapse_species_specific_subtrees );\r
-        _collapse_species_specific_subtrees.setToolTipText( "To (reversibly) collapse species-specific subtrees" );\r
-        _tools_menu\r
-                .add( _collapse_below_threshold = new JMenuItem( "Collapse Branches with Confidence Below Threshold into Multifurcations" ) );\r
-        customizeJMenuItem( _collapse_below_threshold );\r
-        _collapse_below_threshold\r
-                .setToolTipText( "To (permanently) collapse branches with confidence values below a threshold into multifurcations (in the case of multiple confidences per branch: without at least one confidence value above a threshold)" );\r
-        //\r
-        _tools_menu\r
-                .add( _collapse_below_branch_length = new JMenuItem( "Collapse Branches with Branch Lengths Below Threshold into Multifurcations" ) );\r
-        customizeJMenuItem( _collapse_below_branch_length );\r
-        _collapse_below_branch_length\r
-                .setToolTipText( "To (permanently) collapse branches with branches with branch lengths below a threshold into multifurcations" );\r
-        //\r
-        _tools_menu.addSeparator();\r
-        _tools_menu\r
-                .add( _extract_tax_code_from_node_names_jmi = new JMenuItem( "Extract Taxonomic Data from Node Names" ) );\r
-        customizeJMenuItem( _extract_tax_code_from_node_names_jmi );\r
-        _extract_tax_code_from_node_names_jmi\r
-                .setToolTipText( "To extract SwissProt/Uniprot taxonomic codes (mnemonics) from nodes names in the form of 'xyz_CAEEL', Uniprot/NCBI identifiers form of 'xyz_6239', or scientific names form of 'xyz_Caenorhabditis_elegans'" );\r
-        _tools_menu\r
-                .add( _move_node_names_to_tax_sn_jmi = new JMenuItem( "Transfer Node Names to Taxonomic Scientific Names" ) );\r
-        customizeJMenuItem( _move_node_names_to_tax_sn_jmi );\r
-        _move_node_names_to_tax_sn_jmi.setToolTipText( "To interpret node names as taxonomic scientific names" );\r
-        _tools_menu.add( _move_node_names_to_seq_names_jmi = new JMenuItem( "Transfer Node Names to Sequence Names" ) );\r
-        customizeJMenuItem( _move_node_names_to_seq_names_jmi );\r
-        _move_node_names_to_seq_names_jmi.setToolTipText( "To interpret node names as sequence (protein, gene) names" );\r
-        _tools_menu.addSeparator();\r
-        _tools_menu.add( _obtain_seq_information_jmi = new JMenuItem( "Obtain Sequence Information" ) );\r
-        customizeJMenuItem( _obtain_seq_information_jmi );\r
-        _obtain_seq_information_jmi.setToolTipText( "To add additional sequence information" );\r
-        _tools_menu\r
-                .add( _obtain_detailed_taxonomic_information_jmi = new JMenuItem( OBTAIN_DETAILED_TAXONOMIC_INFORMATION ) );\r
-        customizeJMenuItem( _obtain_detailed_taxonomic_information_jmi );\r
-        _obtain_detailed_taxonomic_information_jmi\r
-                .setToolTipText( "To add additional taxonomic information (from UniProt Taxonomy)" );\r
-        _tools_menu\r
-                .add( _obtain_detailed_taxonomic_information_deleting_jmi = new JMenuItem( "Obtain Detailed Taxonomic Information (deletes nodes!)" ) );\r
-        customizeJMenuItem( _obtain_detailed_taxonomic_information_deleting_jmi );\r
-        _obtain_detailed_taxonomic_information_deleting_jmi\r
-                .setToolTipText( "To add additional taxonomic information, deletes nodes for which taxonomy cannot found (from UniProt Taxonomy)" );\r
-        _tools_menu.addSeparator();\r
-        _tools_menu.add( _read_values_jmi = new JMenuItem( "Attach Vector/Expression Values" ) );\r
-        customizeJMenuItem( _read_values_jmi );\r
-        _read_values_jmi.setToolTipText( "To attach vector (e.g. gene expression) values to tree nodes (beta)" );\r
-        _jmenubar.add( _tools_menu );\r
-        _tools_menu.add( _read_seqs_jmi = new JMenuItem( "Attach Molecular Sequences" ) );\r
-        customizeJMenuItem( _read_seqs_jmi );\r
-        _read_seqs_jmi\r
-                .setToolTipText( "To attach molecular sequences to tree nodes (from Fasta-formatted file) (beta)" );\r
-        _jmenubar.add( _tools_menu );\r
-    }\r
-\r
-    @Override\r
-    void close() {\r
-        if ( isUnsavedDataPresent() ) {\r
-            final int r = JOptionPane.showConfirmDialog( this,\r
-                                                         "Exit despite potentially unsaved changes?",\r
-                                                         "Exit?",\r
-                                                         JOptionPane.YES_NO_OPTION );\r
-            if ( r != JOptionPane.YES_OPTION ) {\r
-                return;\r
-            }\r
-        }\r
-        exit();\r
-    }\r
-\r
-    private void closeCurrentPane() {\r
-        if ( getMainPanel().getCurrentTreePanel() != null ) {\r
-            if ( getMainPanel().getCurrentTreePanel().isEdited() ) {\r
-                final int r = JOptionPane.showConfirmDialog( this,\r
-                                                             "Close tab despite potentially unsaved changes?",\r
-                                                             "Close Tab?",\r
-                                                             JOptionPane.YES_NO_OPTION );\r
-                if ( r != JOptionPane.YES_OPTION ) {\r
-                    return;\r
-                }\r
-            }\r
-            getMainPanel().closeCurrentPane();\r
-            activateSaveAllIfNeeded();\r
-        }\r
-    }\r
-\r
-    private void collapse( final Phylogeny phy ) {\r
-        final PhylogenyNodeIterator it = phy.iteratorPostorder();\r
-        final List<PhylogenyNode> to_be_removed = new ArrayList<PhylogenyNode>();\r
-        double min_support = Double.MAX_VALUE;\r
-        boolean conf_present = false;\r
-        while ( it.hasNext() ) {\r
-            final PhylogenyNode n = it.next();\r
-            if ( !n.isExternal() && !n.isRoot() ) {\r
-                final List<Confidence> c = n.getBranchData().getConfidences();\r
-                if ( ( c != null ) && ( c.size() > 0 ) ) {\r
-                    conf_present = true;\r
-                    double max = 0;\r
-                    for( final Confidence confidence : c ) {\r
-                        if ( confidence.getValue() > max ) {\r
-                            max = confidence.getValue();\r
-                        }\r
-                    }\r
-                    if ( max < getMinNotCollapseConfidenceValue() ) {\r
-                        to_be_removed.add( n );\r
-                    }\r
-                    if ( max < min_support ) {\r
-                        min_support = max;\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        if ( conf_present ) {\r
+        if ( bl_present ) {\r
             for( final PhylogenyNode node : to_be_removed ) {\r
                 PhylogenyMethods.removeNode( node, phy );\r
             }\r
@@ -1263,147 +1165,20 @@ public final class MainFrameApplication extends MainFrame {
             }\r
             if ( to_be_removed.size() > 0 ) {\r
                 JOptionPane.showMessageDialog( this, "Collapsed " + to_be_removed.size()\r
-                        + " branches with\nconfidence values below " + getMinNotCollapseConfidenceValue(), "Collapsed "\r
-                        + to_be_removed.size() + " branches", JOptionPane.INFORMATION_MESSAGE );\r
+                                               + " branches with\nbranch length values below " + getMinNotCollapseBlValue(), "Collapsed "\r
+                                                       + to_be_removed.size() + " branches", JOptionPane.INFORMATION_MESSAGE );\r
             }\r
             else {\r
-                JOptionPane.showMessageDialog( this, "No branch collapsed,\nminimum confidence value per branch is "\r
-                        + min_support, "No branch collapsed", JOptionPane.INFORMATION_MESSAGE );\r
+                JOptionPane.showMessageDialog( this,\r
+                                               "No branch collapsed,\nminimum branch length is " + min_bl,\r
+                                               "No branch collapsed",\r
+                                               JOptionPane.INFORMATION_MESSAGE );\r
             }\r
         }\r
         else {\r
             JOptionPane.showMessageDialog( this,\r
-                                           "No branch collapsed because no confidence values present",\r
-                                           "No confidence values present",\r
-                                           JOptionPane.INFORMATION_MESSAGE );\r
-        }\r
-    }\r
-\r
-    private void collapseBelowBranchLengthThreshold() {\r
-        if ( getCurrentTreePanel() != null ) {\r
-            final Phylogeny phy = getCurrentTreePanel().getPhylogeny();\r
-            if ( ( phy != null ) && !phy.isEmpty() ) {\r
-                final String s = ( String ) JOptionPane\r
-                        .showInputDialog( this,\r
-                                          "Please enter the minimum branch length value\n",\r
-                                          "Minimal Branch Length Value",\r
-                                          JOptionPane.QUESTION_MESSAGE,\r
-                                          null,\r
-                                          null,\r
-                                          getMinNotCollapseBlValue() );\r
-                if ( !ForesterUtil.isEmpty( s ) ) {\r
-                    boolean success = true;\r
-                    double m = 0.0;\r
-                    final String m_str = s.trim();\r
-                    if ( !ForesterUtil.isEmpty( m_str ) ) {\r
-                        try {\r
-                            m = Double.parseDouble( m_str );\r
-                        }\r
-                        catch ( final Exception ex ) {\r
-                            success = false;\r
-                        }\r
-                    }\r
-                    else {\r
-                        success = false;\r
-                    }\r
-                    if ( success && ( m >= 0.0 ) ) {\r
-                        setMinNotCollapseBlValue( m );\r
-                        collapseBl( phy );\r
-                    }\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    private void collapseBelowThreshold() {\r
-        if ( getCurrentTreePanel() != null ) {\r
-            final Phylogeny phy = getCurrentTreePanel().getPhylogeny();\r
-            if ( ( phy != null ) && !phy.isEmpty() ) {\r
-                final String s = ( String ) JOptionPane.showInputDialog( this,\r
-                                                                         "Please enter the minimum confidence value\n",\r
-                                                                         "Minimal Confidence Value",\r
-                                                                         JOptionPane.QUESTION_MESSAGE,\r
-                                                                         null,\r
-                                                                         null,\r
-                                                                         getMinNotCollapseConfidenceValue() );\r
-                if ( !ForesterUtil.isEmpty( s ) ) {\r
-                    boolean success = true;\r
-                    double m = 0.0;\r
-                    final String m_str = s.trim();\r
-                    if ( !ForesterUtil.isEmpty( m_str ) ) {\r
-                        try {\r
-                            m = Double.parseDouble( m_str );\r
-                        }\r
-                        catch ( final Exception ex ) {\r
-                            success = false;\r
-                        }\r
-                    }\r
-                    else {\r
-                        success = false;\r
-                    }\r
-                    if ( success && ( m >= 0.0 ) ) {\r
-                        setMinNotCollapseConfidenceValue( m );\r
-                        collapse( phy );\r
-                    }\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    private void collapseBl( final Phylogeny phy ) {\r
-        final PhylogenyNodeIterator it = phy.iteratorPostorder();\r
-        final List<PhylogenyNode> to_be_removed = new ArrayList<PhylogenyNode>();\r
-        double min_bl = Double.MAX_VALUE;\r
-        boolean bl_present = false;\r
-        while ( it.hasNext() ) {\r
-            final PhylogenyNode n = it.next();\r
-            if ( !n.isExternal() && !n.isRoot() ) {\r
-                final double bl = n.getDistanceToParent();\r
-                if ( bl != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {\r
-                    bl_present = true;\r
-                    if ( bl < getMinNotCollapseBlValue() ) {\r
-                        to_be_removed.add( n );\r
-                    }\r
-                    if ( bl < min_bl ) {\r
-                        min_bl = bl;\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        if ( bl_present ) {\r
-            for( final PhylogenyNode node : to_be_removed ) {\r
-                PhylogenyMethods.removeNode( node, phy );\r
-            }\r
-            if ( to_be_removed.size() > 0 ) {\r
-                phy.externalNodesHaveChanged();\r
-                phy.clearHashIdToNodeMap();\r
-                phy.recalculateNumberOfExternalDescendants( true );\r
-                getCurrentTreePanel().resetNodeIdToDistToLeafMap();\r
-                getCurrentTreePanel().updateSetOfCollapsedExternalNodes();\r
-                getCurrentTreePanel().calculateLongestExtNodeInfo();\r
-                getCurrentTreePanel().setNodeInPreorderToNull();\r
-                getCurrentTreePanel().recalculateMaxDistanceToRoot();\r
-                getCurrentTreePanel().resetPreferredSize();\r
-                getCurrentTreePanel().setEdited( true );\r
-                getCurrentTreePanel().repaint();\r
-                repaint();\r
-            }\r
-            if ( to_be_removed.size() > 0 ) {\r
-                JOptionPane.showMessageDialog( this, "Collapsed " + to_be_removed.size()\r
-                        + " branches with\nbranch length values below " + getMinNotCollapseBlValue(), "Collapsed "\r
-                        + to_be_removed.size() + " branches", JOptionPane.INFORMATION_MESSAGE );\r
-            }\r
-            else {\r
-                JOptionPane.showMessageDialog( this,\r
-                                               "No branch collapsed,\nminimum branch length is " + min_bl,\r
-                                               "No branch collapsed",\r
-                                               JOptionPane.INFORMATION_MESSAGE );\r
-            }\r
-        }\r
-        else {\r
-            JOptionPane.showMessageDialog( this,\r
-                                           "No branch collapsed because no branch length values present",\r
-                                           "No branch length values present",\r
+                                           "No branch collapsed because no branch length values present",\r
+                                           "No branch length values present",\r
                                            JOptionPane.INFORMATION_MESSAGE );\r
         }\r
     }\r
@@ -1427,31 +1202,6 @@ public final class MainFrameApplication extends MainFrame {
         return xml_parser;\r
     }\r
 \r
-    public void end() {\r
-        _mainpanel.terminate();\r
-        _contentpane.removeAll();\r
-        setVisible( false );\r
-        dispose();\r
-    }\r
-\r
-    void executeLineageInference() {\r
-        if ( ( _mainpanel.getCurrentPhylogeny() == null ) || ( _mainpanel.getCurrentPhylogeny().isEmpty() ) ) {\r
-            return;\r
-        }\r
-        if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {\r
-            JOptionPane.showMessageDialog( this,\r
-                                           "Phylogeny is not rooted.",\r
-                                           "Cannot infer ancestral taxonomies",\r
-                                           JOptionPane.ERROR_MESSAGE );\r
-            return;\r
-        }\r
-        final AncestralTaxonomyInferrer inferrer = new AncestralTaxonomyInferrer( this,\r
-                                                                                  _mainpanel.getCurrentTreePanel(),\r
-                                                                                  _mainpanel.getCurrentPhylogeny()\r
-                                                                                          .copy() );\r
-        new Thread( inferrer ).start();\r
-    }\r
-\r
     private void executePhyleneticInference( final boolean from_unaligned_seqs ) {\r
         final PhyloInferenceDialog dialog = new PhyloInferenceDialog( this,\r
                                                                       getPhylogeneticInferenceOptions(),\r
@@ -1462,7 +1212,7 @@ public final class MainFrameApplication extends MainFrame {
                 if ( getMsa() != null ) {\r
                     final PhylogeneticInferrer inferrer = new PhylogeneticInferrer( getMsa(),\r
                                                                                     getPhylogeneticInferenceOptions()\r
-                                                                                            .copy(), this );\r
+                                                                                    .copy(), this );\r
                     new Thread( inferrer ).start();\r
                 }\r
                 else {\r
@@ -1476,7 +1226,7 @@ public final class MainFrameApplication extends MainFrame {
                 if ( getSeqs() != null ) {\r
                     final PhylogeneticInferrer inferrer = new PhylogeneticInferrer( getSeqs(),\r
                                                                                     getPhylogeneticInferenceOptions()\r
-                                                                                            .copy(), this );\r
+                                                                                    .copy(), this );\r
                     new Thread( inferrer ).start();\r
                 }\r
                 else {\r
@@ -1489,15 +1239,6 @@ public final class MainFrameApplication extends MainFrame {
         }\r
     }\r
 \r
-    void exit() {\r
-        removeAllTextFrames();\r
-        _mainpanel.terminate();\r
-        _contentpane.removeAll();\r
-        setVisible( false );\r
-        dispose();\r
-        // System.exit( 0 ); //TODO reconfirm that this is OK, then remove.\r
-    }\r
-\r
     private void extractTaxDataFromNodeNames() throws PhyloXmlDataFormatException {\r
         final StringBuilder sb = new StringBuilder();\r
         final StringBuilder sb_failed = new StringBuilder();\r
@@ -1543,17 +1284,17 @@ public final class MainFrameApplication extends MainFrame {
                     }\r
                     JOptionPane.showMessageDialog( this,\r
                                                    "Extracted taxonomic data from " + all + counter\r
-                                                           + " named external nodes:\n" + sb.toString() + failed,\r
+                                                   + " named external nodes:\n" + sb.toString() + failed,\r
                                                    "Taxonomic Data Extraction Completed",\r
                                                    counter_failed > 0 ? JOptionPane.WARNING_MESSAGE\r
                                                            : JOptionPane.INFORMATION_MESSAGE );\r
                 }\r
                 else {\r
                     JOptionPane\r
-                            .showMessageDialog( this,\r
-                                                "Could not extract any taxonomic data.\nMaybe node names are empty\n"\r
-                                                        + "or not in the forms \"XYZ_CAEEL\", \"XYZ_6239\", or \"XYZ_Caenorhabditis_elegans\"\n"\r
-                                                        + "or nodes already have taxonomic data?\n",\r
+                    .showMessageDialog( this,\r
+                                        "Could not extract any taxonomic data.\nMaybe node names are empty\n"\r
+                                                + "or not in the forms \"XYZ_CAEEL\", \"XYZ_6239\", or \"XYZ_Caenorhabditis_elegans\"\n"\r
+                                                + "or nodes already have taxonomic data?\n",\r
                                                 "No Taxonomic Data Extracted",\r
                                                 JOptionPane.ERROR_MESSAGE );\r
                 }\r
@@ -1561,11 +1302,6 @@ public final class MainFrameApplication extends MainFrame {
         }\r
     }\r
 \r
-    @Override\r
-    public MainPanel getMainPanel() {\r
-        return _mainpanel;\r
-    }\r
-\r
     private double getMinNotCollapseBlValue() {\r
         return _min_not_collapse_bl;\r
     }\r
@@ -1574,14 +1310,6 @@ public final class MainFrameApplication extends MainFrame {
         return _min_not_collapse;\r
     }\r
 \r
-    public Msa getMsa() {\r
-        return _msa;\r
-    }\r
-\r
-    public File getMsaFile() {\r
-        return _msa_file;\r
-    }\r
-\r
     private PhylogeneticInferenceOptions getPhylogeneticInferenceOptions() {\r
         if ( _phylogenetic_inference_options == null ) {\r
             _phylogenetic_inference_options = new PhylogeneticInferenceOptions();\r
@@ -1589,14 +1317,6 @@ public final class MainFrameApplication extends MainFrame {
         return _phylogenetic_inference_options;\r
     }\r
 \r
-    public List<MolecularSequence> getSeqs() {\r
-        return _seqs;\r
-    }\r
-\r
-    public File getSeqsFile() {\r
-        return _seqs_file;\r
-    }\r
-\r
     private boolean isUnsavedDataPresent() {\r
         final List<TreePanel> tps = getMainPanel().getTreePanels();\r
         for( final TreePanel tp : tps ) {\r
@@ -1612,7 +1332,7 @@ public final class MainFrameApplication extends MainFrame {
             final Phylogeny phy = getCurrentTreePanel().getPhylogeny();\r
             if ( ( phy != null ) && !phy.isEmpty() ) {\r
                 PhylogenyMethods\r
-                        .transferNodeNameToField( phy, PhylogenyMethods.PhylogenyNodeField.SEQUENCE_NAME, false );\r
+                .transferNodeNameToField( phy, PhylogenyMethods.PhylogenyNodeField.SEQUENCE_NAME, false );\r
             }\r
         }\r
     }\r
@@ -1642,7 +1362,7 @@ public final class MainFrameApplication extends MainFrame {
         if ( getMainPanel().getMainFrame() == null ) {\r
             // Must be "E" applet version.\r
             ( ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet() )\r
-                    .setSelectedTypeInTypeMenu( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );\r
+            .setSelectedTypeInTypeMenu( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );\r
         }\r
         else {\r
             getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );\r
@@ -1715,102 +1435,15 @@ public final class MainFrameApplication extends MainFrame {
         }\r
     }\r
 \r
-   \r
-\r
-    public void readMsaFromFile() {\r
+    private void readPhylogeniesFromFile() {\r
+        boolean exception = false;\r
+        Phylogeny[] phys = null;\r
         // Set an initial directory if none set yet\r
         final File my_dir = getCurrentDir();\r
-        _msa_filechooser.setMultiSelectionEnabled( false );\r
+        _open_filechooser.setMultiSelectionEnabled( true );\r
         // Open file-open dialog and set current directory\r
         if ( my_dir != null ) {\r
-            _msa_filechooser.setCurrentDirectory( my_dir );\r
-        }\r
-        final int result = _msa_filechooser.showOpenDialog( _contentpane );\r
-        // All done: get the msa\r
-        final File file = _msa_filechooser.getSelectedFile();\r
-        setCurrentDir( _msa_filechooser.getCurrentDirectory() );\r
-        if ( ( file != null ) && !file.isDirectory() && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
-            setMsaFile( null );\r
-            setMsa( null );\r
-            Msa msa = null;\r
-            try {\r
-                final InputStream is = new FileInputStream( file );\r
-                if ( FastaParser.isLikelyFasta( file ) ) {\r
-                    msa = FastaParser.parseMsa( is );\r
-                }\r
-                else {\r
-                    msa = GeneralMsaParser.parse( is );\r
-                }\r
-            }\r
-            catch ( final MsaFormatException e ) {\r
-                setArrowCursor();\r
-                JOptionPane.showMessageDialog( this,\r
-                                               e.getLocalizedMessage(),\r
-                                               "Multiple sequence alignment format error",\r
-                                               JOptionPane.ERROR_MESSAGE );\r
-                return;\r
-            }\r
-            catch ( final IOException e ) {\r
-                setArrowCursor();\r
-                JOptionPane.showMessageDialog( this,\r
-                                               e.getLocalizedMessage(),\r
-                                               "Failed to read multiple sequence alignment",\r
-                                               JOptionPane.ERROR_MESSAGE );\r
-                return;\r
-            }\r
-            catch ( final IllegalArgumentException e ) {\r
-                setArrowCursor();\r
-                JOptionPane.showMessageDialog( this,\r
-                                               e.getLocalizedMessage(),\r
-                                               "Unexpected error during reading of multiple sequence alignment",\r
-                                               JOptionPane.ERROR_MESSAGE );\r
-                return;\r
-            }\r
-            catch ( final Exception e ) {\r
-                setArrowCursor();\r
-                e.printStackTrace();\r
-                JOptionPane.showMessageDialog( this,\r
-                                               e.getLocalizedMessage(),\r
-                                               "Unexpected error during reading of multiple sequence alignment",\r
-                                               JOptionPane.ERROR_MESSAGE );\r
-                return;\r
-            }\r
-            if ( ( msa == null ) || ( msa.getNumberOfSequences() < 1 ) ) {\r
-                JOptionPane.showMessageDialog( this,\r
-                                               "Multiple sequence alignment is empty",\r
-                                               "Illegal Multiple Sequence Alignment",\r
-                                               JOptionPane.ERROR_MESSAGE );\r
-                return;\r
-            }\r
-            if ( msa.getNumberOfSequences() < 4 ) {\r
-                JOptionPane.showMessageDialog( this,\r
-                                               "Multiple sequence alignment needs to contain at least 3 sequences",\r
-                                               "Illegal multiple sequence alignment",\r
-                                               JOptionPane.ERROR_MESSAGE );\r
-                return;\r
-            }\r
-            if ( msa.getLength() < 2 ) {\r
-                JOptionPane.showMessageDialog( this,\r
-                                               "Multiple sequence alignment needs to contain at least 2 residues",\r
-                                               "Illegal multiple sequence alignment",\r
-                                               JOptionPane.ERROR_MESSAGE );\r
-                return;\r
-            }\r
-            System.gc();\r
-            setMsaFile( _msa_filechooser.getSelectedFile() );\r
-            setMsa( msa );\r
-        }\r
-    }\r
-\r
-    private void readPhylogeniesFromFile() {\r
-        boolean exception = false;\r
-        Phylogeny[] phys = null;\r
-        // Set an initial directory if none set yet\r
-        final File my_dir = getCurrentDir();\r
-        _open_filechooser.setMultiSelectionEnabled( true );\r
-        // Open file-open dialog and set current directory\r
-        if ( my_dir != null ) {\r
-            _open_filechooser.setCurrentDirectory( my_dir );\r
+            _open_filechooser.setCurrentDirectory( my_dir );\r
         }\r
         final int result = _open_filechooser.showOpenDialog( _contentpane );\r
         // All done: get the file\r
@@ -1876,7 +1509,7 @@ public final class MainFrameApplication extends MainFrame {
                         try {\r
                             final PhylogenyParser parser = ParserUtils\r
                                     .createParserDependingOnFileType( file, getConfiguration()\r
-                                            .isValidatePhyloXmlAgainstSchema() );\r
+                                                                      .isValidatePhyloXmlAgainstSchema() );\r
                             if ( parser instanceof NexusPhylogeniesParser ) {\r
                                 final NexusPhylogeniesParser nex = ( NexusPhylogeniesParser ) parser;\r
                                 setSpecialOptionsForNexParser( nex );\r
@@ -1927,10 +1560,10 @@ public final class MainFrameApplication extends MainFrame {
                         _mainpanel.getControlPanel().showWhole();\r
                         if ( nhx_or_nexus && one_desc ) {\r
                             JOptionPane\r
-                                    .showMessageDialog( this,\r
-                                                        "One or more trees contain (a) node(s) with one descendant, "\r
-                                                                + ForesterUtil.LINE_SEPARATOR\r
-                                                                + "possibly indicating illegal parentheses within node names.",\r
+                            .showMessageDialog( this,\r
+                                                "One or more trees contain (a) node(s) with one descendant, "\r
+                                                        + ForesterUtil.LINE_SEPARATOR\r
+                                                        + "possibly indicating illegal parentheses within node names.",\r
                                                         "Warning: Possible Error in New Hampshire Formatted Data",\r
                                                         JOptionPane.WARNING_MESSAGE );\r
                         }\r
@@ -1938,8 +1571,554 @@ public final class MainFrameApplication extends MainFrame {
                 }\r
             }\r
         }\r
-        activateSaveAllIfNeeded();\r
-        System.gc();\r
+        activateSaveAllIfNeeded();\r
+        System.gc();\r
+    }\r
+\r
+    private void readSpeciesTreeFromFile() {\r
+        Phylogeny t = null;\r
+        boolean exception = false;\r
+        final File my_dir = getCurrentDir();\r
+        _open_filechooser_for_species_tree.setSelectedFile( new File( "" ) );\r
+        if ( my_dir != null ) {\r
+            _open_filechooser_for_species_tree.setCurrentDirectory( my_dir );\r
+        }\r
+        final int result = _open_filechooser_for_species_tree.showOpenDialog( _contentpane );\r
+        final File file = _open_filechooser_for_species_tree.getSelectedFile();\r
+        if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
+            if ( _open_filechooser_for_species_tree.getFileFilter() == MainFrame.xmlfilter ) {\r
+                try {\r
+                    final Phylogeny[] trees = PhylogenyMethods.readPhylogenies( PhyloXmlParser\r
+                                                                                .createPhyloXmlParserXsdValidating(), file );\r
+                    t = trees[ 0 ];\r
+                }\r
+                catch ( final Exception e ) {\r
+                    exception = true;\r
+                    exceptionOccuredDuringOpenFile( e );\r
+                }\r
+            }\r
+            else if ( _open_filechooser_for_species_tree.getFileFilter() == MainFrame.tolfilter ) {\r
+                try {\r
+                    final Phylogeny[] trees = PhylogenyMethods.readPhylogenies( new TolParser(), file );\r
+                    t = trees[ 0 ];\r
+                }\r
+                catch ( final Exception e ) {\r
+                    exception = true;\r
+                    exceptionOccuredDuringOpenFile( e );\r
+                }\r
+            }\r
+            // "*.*":\r
+            else {\r
+                try {\r
+                    final Phylogeny[] trees = PhylogenyMethods.readPhylogenies( PhyloXmlParser\r
+                                                                                .createPhyloXmlParserXsdValidating(), file );\r
+                    t = trees[ 0 ];\r
+                }\r
+                catch ( final Exception e ) {\r
+                    exception = true;\r
+                    exceptionOccuredDuringOpenFile( e );\r
+                }\r
+            }\r
+            if ( !exception && ( t != null ) && !t.isRooted() ) {\r
+                exception = true;\r
+                t = null;\r
+                JOptionPane.showMessageDialog( this,\r
+                                               "Species tree is not rooted",\r
+                                               "Species tree not loaded",\r
+                                               JOptionPane.ERROR_MESSAGE );\r
+            }\r
+            if ( !exception && ( t != null ) ) {\r
+                final Set<Taxonomy> tax_set = new HashSet<Taxonomy>();\r
+                for( final PhylogenyNodeIterator it = t.iteratorExternalForward(); it.hasNext(); ) {\r
+                    final PhylogenyNode node = it.next();\r
+                    if ( !node.getNodeData().isHasTaxonomy() ) {\r
+                        exception = true;\r
+                        t = null;\r
+                        JOptionPane\r
+                        .showMessageDialog( this,\r
+                                            "Species tree contains external node(s) without taxonomy information",\r
+                                            "Species tree not loaded",\r
+                                            JOptionPane.ERROR_MESSAGE );\r
+                        break;\r
+                    }\r
+                    else {\r
+                        if ( tax_set.contains( node.getNodeData().getTaxonomy() ) ) {\r
+                            exception = true;\r
+                            t = null;\r
+                            JOptionPane.showMessageDialog( this,\r
+                                                           "Taxonomy ["\r
+                                                                   + node.getNodeData().getTaxonomy().asSimpleText()\r
+                                                                   + "] is not unique in species tree",\r
+                                                                   "Species tree not loaded",\r
+                                                                   JOptionPane.ERROR_MESSAGE );\r
+                            break;\r
+                        }\r
+                        else {\r
+                            tax_set.add( node.getNodeData().getTaxonomy() );\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+            if ( !exception && ( t != null ) ) {\r
+                setSpeciesTree( t );\r
+                JOptionPane.showMessageDialog( this,\r
+                                               "Species tree successfully loaded",\r
+                                               "Species tree loaded",\r
+                                               JOptionPane.INFORMATION_MESSAGE );\r
+            }\r
+            _contentpane.repaint();\r
+            System.gc();\r
+        }\r
+    }\r
+\r
+    private void setArrowCursor() {\r
+        try {\r
+            _mainpanel.getCurrentTreePanel().setArrowCursor();\r
+        }\r
+        catch ( final Exception ex ) {\r
+            // Do nothing.\r
+        }\r
+    }\r
+\r
+    private void setMinNotCollapseBlValue( final double min_not_collapse_bl ) {\r
+        _min_not_collapse_bl = min_not_collapse_bl;\r
+    }\r
+\r
+    private void setMinNotCollapseConfidenceValue( final double min_not_collapse ) {\r
+        _min_not_collapse = min_not_collapse;\r
+    }\r
+\r
+    private void setPhylogeneticInferenceOptions( final PhylogeneticInferenceOptions phylogenetic_inference_options ) {\r
+        _phylogenetic_inference_options = phylogenetic_inference_options;\r
+    }\r
+\r
+    private void setSpecialOptionsForNexParser( final NexusPhylogeniesParser nex ) {\r
+        nex.setReplaceUnderscores( getOptions().isReplaceUnderscoresInNhParsing() );\r
+        nex.setTaxonomyExtraction( getOptions().getTaxonomyExtraction() );\r
+    }\r
+\r
+    private void setSpecialOptionsForNhxParser( final NHXParser nhx ) {\r
+        nhx.setReplaceUnderscores( getOptions().isReplaceUnderscoresInNhParsing() );\r
+        nhx.setTaxonomyExtraction( getOptions().getTaxonomyExtraction() );\r
+        nhx.setAllowErrorsInDistanceToParent( getOptions().isAllowErrorsInDistanceToParent() );\r
+    }\r
+\r
+    void buildAnalysisMenu() {\r
+        _analysis_menu = MainFrame.createMenu( "Analysis", getConfiguration() );\r
+        _analysis_menu.add( _gsdi_item = new JMenuItem( "GSDI (Generalized Speciation Duplication Inference)" ) );\r
+        _analysis_menu.add( _gsdir_item = new JMenuItem( "GSDIR (GSDI with re-rooting)" ) );\r
+        _analysis_menu.add( _load_species_tree_item = new JMenuItem( "Load Species Tree..." ) );\r
+        customizeJMenuItem( _gsdi_item );\r
+        customizeJMenuItem( _gsdir_item );\r
+        customizeJMenuItem( _load_species_tree_item );\r
+        _analysis_menu.addSeparator();\r
+        _analysis_menu.add( _lineage_inference = new JMenuItem( INFER_ANCESTOR_TAXONOMIES ) );\r
+        customizeJMenuItem( _lineage_inference );\r
+        _lineage_inference.setToolTipText( "Inference of ancestor taxonomies/lineages" );\r
+        _jmenubar.add( _analysis_menu );\r
+    }\r
+\r
+    @Override\r
+    void buildFileMenu() {\r
+        _file_jmenu = MainFrame.createMenu( "File", getConfiguration() );\r
+        _file_jmenu.add( _open_item = new JMenuItem( "Read Tree from File..." ) );\r
+        _file_jmenu.addSeparator();\r
+        _file_jmenu.add( _open_url_item = new JMenuItem( "Read Tree from URL/Webservice..." ) );\r
+        _file_jmenu.addSeparator();\r
+        final WebservicesManager webservices_manager = WebservicesManager.getInstance();\r
+        _load_phylogeny_from_webservice_menu_items = new JMenuItem[ webservices_manager\r
+                                                                    .getAvailablePhylogeniesWebserviceClients().size() ];\r
+        for( int i = 0; i < webservices_manager.getAvailablePhylogeniesWebserviceClients().size(); ++i ) {\r
+            final PhylogeniesWebserviceClient client = webservices_manager.getAvailablePhylogeniesWebserviceClient( i );\r
+            _load_phylogeny_from_webservice_menu_items[ i ] = new JMenuItem( client.getMenuName() );\r
+            _file_jmenu.add( _load_phylogeny_from_webservice_menu_items[ i ] );\r
+        }\r
+        if ( getConfiguration().isEditable() ) {\r
+            _file_jmenu.addSeparator();\r
+            _file_jmenu.add( _new_item = new JMenuItem( "New" ) );\r
+            _new_item.setToolTipText( "to create a new tree with one node, as source for manual tree construction" );\r
+        }\r
+        _file_jmenu.addSeparator();\r
+        _file_jmenu.add( _save_item = new JMenuItem( "Save Tree As..." ) );\r
+        _file_jmenu.add( _save_all_item = new JMenuItem( "Save All Trees As..." ) );\r
+        _save_all_item.setToolTipText( "Write all phylogenies to one file." );\r
+        _save_all_item.setEnabled( false );\r
+        _file_jmenu.addSeparator();\r
+        _file_jmenu.add( _write_to_pdf_item = new JMenuItem( "Export to PDF file ..." ) );\r
+        if ( AptxUtil.canWriteFormat( "tif" ) || AptxUtil.canWriteFormat( "tiff" ) || AptxUtil.canWriteFormat( "TIF" ) ) {\r
+            _file_jmenu.add( _write_to_tif_item = new JMenuItem( "Export to TIFF file..." ) );\r
+        }\r
+        _file_jmenu.add( _write_to_png_item = new JMenuItem( "Export to PNG file..." ) );\r
+        _file_jmenu.add( _write_to_jpg_item = new JMenuItem( "Export to JPG file..." ) );\r
+        if ( AptxUtil.canWriteFormat( "gif" ) ) {\r
+            _file_jmenu.add( _write_to_gif_item = new JMenuItem( "Export to GIF file..." ) );\r
+        }\r
+        if ( AptxUtil.canWriteFormat( "bmp" ) ) {\r
+            _file_jmenu.add( _write_to_bmp_item = new JMenuItem( "Export to BMP file..." ) );\r
+        }\r
+        _file_jmenu.addSeparator();\r
+        _file_jmenu.add( _print_item = new JMenuItem( "Print..." ) );\r
+        _file_jmenu.addSeparator();\r
+        _file_jmenu.add( _close_item = new JMenuItem( "Close Tab" ) );\r
+        _close_item.setToolTipText( "To close the current pane." );\r
+        _close_item.setEnabled( true );\r
+        _file_jmenu.addSeparator();\r
+        _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );\r
+        customizeJMenuItem( _open_item );\r
+        _open_item\r
+        .setFont( new Font( _open_item.getFont().getFontName(), Font.BOLD, _open_item.getFont().getSize() + 4 ) );\r
+        customizeJMenuItem( _open_url_item );\r
+        for( int i = 0; i < webservices_manager.getAvailablePhylogeniesWebserviceClients().size(); ++i ) {\r
+            customizeJMenuItem( _load_phylogeny_from_webservice_menu_items[ i ] );\r
+        }\r
+        customizeJMenuItem( _save_item );\r
+        if ( getConfiguration().isEditable() ) {\r
+            customizeJMenuItem( _new_item );\r
+        }\r
+        customizeJMenuItem( _close_item );\r
+        customizeJMenuItem( _save_all_item );\r
+        customizeJMenuItem( _write_to_pdf_item );\r
+        customizeJMenuItem( _write_to_png_item );\r
+        customizeJMenuItem( _write_to_jpg_item );\r
+        customizeJMenuItem( _write_to_gif_item );\r
+        customizeJMenuItem( _write_to_tif_item );\r
+        customizeJMenuItem( _write_to_bmp_item );\r
+        customizeJMenuItem( _print_item );\r
+        customizeJMenuItem( _exit_item );\r
+        _jmenubar.add( _file_jmenu );\r
+    }\r
+\r
+    void buildOptionsMenu() {\r
+        _options_jmenu = MainFrame.createMenu( OPTIONS_HEADER, getConfiguration() );\r
+        _options_jmenu.addChangeListener( new ChangeListener() {\r
+\r
+            @Override\r
+            public void stateChanged( final ChangeEvent e ) {\r
+                MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getOptions() );\r
+                MainFrame.setTextColorChooseMenuItem( _switch_colors_mi, getCurrentTreePanel() );\r
+                MainFrame\r
+                .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() );\r
+                MainFrame.setTextForFontChooserMenuItem( _choose_font_mi, MainFrame\r
+                                                         .createCurrentFontDesc( getMainPanel().getTreeFontSet() ) );\r
+                MainFrame.setTextForGraphicsSizeChooserMenuItem( _print_size_mi, getOptions() );\r
+                MainFrame.setTextForPdfLineWidthChooserMenuItem( _choose_pdf_width_mi, getOptions() );\r
+                MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() );\r
+                MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() );\r
+                MainFrame.setCycleDataReturnMenuItem( _cycle_data_return, getOptions() );\r
+                MainFrame.setTextNodeSizeMenuItem( _choose_node_size_mi, getOptions() );\r
+                try {\r
+                    getMainPanel().getControlPanel().setVisibilityOfDomainStrucureCB();\r
+                    getMainPanel().getControlPanel().setVisibilityOfX();\r
+                }\r
+                catch ( final Exception ignore ) {\r
+                    // do nothing, not important.\r
+                }\r
+            }\r
+        } );\r
+        _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( DISPLAY_SUBHEADER ), getConfiguration() ) );\r
+        _options_jmenu\r
+        .add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );\r
+        _options_jmenu.add( _uniform_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.UNIFORM_CLADOGRAMS_LABEL ) );\r
+        _options_jmenu.add( _non_lined_up_cladograms_rbmi = new JRadioButtonMenuItem( NON_LINED_UP_CLADOGRAMS_LABEL ) );\r
+        _radio_group_1 = new ButtonGroup();\r
+        _radio_group_1.add( _ext_node_dependent_cladogram_rbmi );\r
+        _radio_group_1.add( _uniform_cladograms_rbmi );\r
+        _radio_group_1.add( _non_lined_up_cladograms_rbmi );\r
+        _options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( SHOW_OVERVIEW_LABEL ) );\r
+        _options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( DISPLAY_SCALE_LABEL ) );\r
+        _options_jmenu\r
+        .add( _show_default_node_shapes_internal_cbmi = new JCheckBoxMenuItem( DISPLAY_NODE_BOXES_LABEL_INT ) );\r
+        _options_jmenu\r
+        .add( _show_default_node_shapes_external_cbmi = new JCheckBoxMenuItem( DISPLAY_NODE_BOXES_LABEL_EXT ) );\r
+        _options_jmenu\r
+        .add( _show_default_node_shapes_for_marked_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_MARKED ) );\r
+        _options_jmenu.add( _line_up_renderable_data_cbmi = new JCheckBoxMenuItem( MainFrame.LINE_UP_RENDERABLE_DATA ) );\r
+        if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {\r
+            _options_jmenu.add( _right_line_up_domains_cbmi = new JCheckBoxMenuItem( MainFrame.RIGHT_LINE_UP_DOMAINS ) );\r
+            _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( MainFrame.SHOW_DOMAIN_LABELS_LABEL ) );\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
+        _options_jmenu.add( _color_labels_same_as_parent_branch = new JCheckBoxMenuItem( COLOR_LABELS_LABEL ) );\r
+        _color_labels_same_as_parent_branch.setToolTipText( MainFrame.COLOR_LABELS_TIP );\r
+        _options_jmenu.add( _abbreviate_scientific_names = new JCheckBoxMenuItem( ABBREV_SN_LABEL ) );\r
+        _options_jmenu.add( _label_direction_cbmi = new JCheckBoxMenuItem( LABEL_DIRECTION_LABEL ) );\r
+        _label_direction_cbmi.setToolTipText( LABEL_DIRECTION_TIP );\r
+        _options_jmenu.add( _screen_antialias_cbmi = new JCheckBoxMenuItem( SCREEN_ANTIALIAS_LABEL ) );\r
+        _options_jmenu.add( _background_gradient_cbmi = new JCheckBoxMenuItem( BG_GRAD_LABEL ) );\r
+        _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL ) );\r
+        _options_jmenu.add( _cycle_node_fill_mi = new JMenuItem( MainFrame.CYCLE_NODE_FILL_LABEL ) );\r
+        _options_jmenu.add( _choose_node_size_mi = new JMenuItem( MainFrame.CHOOSE_NODE_SIZE_LABEL ) );\r
+        _options_jmenu.add( _choose_minimal_confidence_mi = new JMenuItem( "" ) );\r
+        _options_jmenu.add( _overview_placment_mi = new JMenuItem( "" ) );\r
+        _options_jmenu.add( _switch_colors_mi = new JMenuItem( "" ) );\r
+        _options_jmenu.add( _choose_font_mi = new JMenuItem( "" ) );\r
+        _options_jmenu.addSeparator();\r
+        _options_jmenu.add( _cycle_data_return = new JMenuItem( "Cycle Data Return" ) );\r
+        _options_jmenu.addSeparator();\r
+        _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( SEARCH_SUBHEADER ), getConfiguration() ) );\r
+        _options_jmenu.add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( SEARCH_CASE_SENSITIVE_LABEL ) );\r
+        _options_jmenu.add( _search_whole_words_only_cbmi = new JCheckBoxMenuItem( SEARCH_TERMS_ONLY_LABEL ) );\r
+        _options_jmenu.add( _search_with_regex_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_REGEX_LABEL ) );\r
+        _search_with_regex_cbmi.setToolTipText( MainFrame.SEARCH_WITH_REGEX_TIP );\r
+        _options_jmenu.add( _inverse_search_result_cbmi = new JCheckBoxMenuItem( INVERSE_SEARCH_RESULT_LABEL ) );\r
+        _options_jmenu.addSeparator();\r
+        _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( "Graphics Export & Printing:" ),\r
+                                                      getConfiguration() ) );\r
+        _options_jmenu.add( _antialias_print_cbmi = new JCheckBoxMenuItem( "Antialias" ) );\r
+        _options_jmenu.add( _print_black_and_white_cbmi = new JCheckBoxMenuItem( "Export in Black and White" ) );\r
+        _options_jmenu\r
+        .add( _print_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PDF export and Printing" ) );\r
+        _options_jmenu\r
+        .add( _graphics_export_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PNG, JPG, and GIF export" ) );\r
+        _options_jmenu\r
+        .add( _graphics_export_visible_only_cbmi = new JCheckBoxMenuItem( "Limit to Visible ('Screenshot') for PNG, JPG, and GIF export" ) );\r
+        _options_jmenu.add( _print_size_mi = new JMenuItem( "" ) );\r
+        _options_jmenu.add( _choose_pdf_width_mi = new JMenuItem( "" ) );\r
+        _options_jmenu.addSeparator();\r
+        _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( "Newick/NHX/Nexus Input:" ), getConfiguration() ) );\r
+        _options_jmenu\r
+        .add( _internal_number_are_confidence_for_nh_parsing_cbmi = new JCheckBoxMenuItem( "Internal Node Names are Confidence Values" ) );\r
+        _options_jmenu.add( _replace_underscores_cbmi = new JCheckBoxMenuItem( "Replace Underscores with Spaces" ) );\r
+        _options_jmenu\r
+        .add( _allow_errors_in_distance_to_parent_cbmi = new JCheckBoxMenuItem( "Ignore Distance Values Format Errors" ) );\r
+        _options_jmenu.add( _extract_taxonomy_no_rbmi = new JRadioButtonMenuItem( "No Taxonomy Extraction" ) );\r
+        _options_jmenu\r
+        .add( _extract_taxonomy_pfam_strict_rbmi = new JRadioButtonMenuItem( "Extract Taxonomy Codes/Ids from Pfam-style Node Names" ) );\r
+        _options_jmenu\r
+        .add( _extract_taxonomy_pfam_relaxed_rbmi = new JRadioButtonMenuItem( "Extract Taxonomy Codes/Ids from Pfam-style like Node Names" ) );\r
+        _options_jmenu\r
+        .add( _extract_taxonomy_agressive_rbmi = new JRadioButtonMenuItem( "Extract Taxonomy Codes/Ids/Scientific Names from Node Names" ) );\r
+        _extract_taxonomy_pfam_strict_rbmi\r
+        .setToolTipText( "To extract taxonomy codes/ids from node names in the form of e.g. \"BCL2_MOUSE/123-304\" or \"BCL2_10090/123-304\"" );\r
+        _extract_taxonomy_pfam_relaxed_rbmi\r
+        .setToolTipText( "To extract taxonomy codes/ids from node names in the form of e.g. \"bax_MOUSE\" or \"bax_10090\"" );\r
+        _extract_taxonomy_agressive_rbmi\r
+        .setToolTipText( "To extract taxonomy codes/ids or scientific names from node names in the form of e.g. \"MOUSE\" or \"10090\" or \"xyz_Nematostella_vectensis\"" );\r
+        _radio_group_2 = new ButtonGroup();\r
+        _radio_group_2.add( _extract_taxonomy_no_rbmi );\r
+        _radio_group_2.add( _extract_taxonomy_pfam_strict_rbmi );\r
+        _radio_group_2.add( _extract_taxonomy_pfam_relaxed_rbmi );\r
+        _radio_group_2.add( _extract_taxonomy_agressive_rbmi );\r
+        _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( "Newick/Nexus Output:" ), getConfiguration() ) );\r
+        _options_jmenu\r
+        .add( _use_brackets_for_conf_in_nh_export_cbmi = new JCheckBoxMenuItem( USE_BRACKETS_FOR_CONF_IN_NH_LABEL ) );\r
+        _use_brackets_for_conf_in_nh_export_cbmi\r
+        .setToolTipText( "e.g. \"0.1[90]\" for a branch with support 90 and a length of 0.1" );\r
+        _options_jmenu\r
+        .add( _use_internal_names_for_conf_in_nh_export_cbmi = new JCheckBoxMenuItem( USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL ) );\r
+        customizeJMenuItem( _choose_font_mi );\r
+        customizeJMenuItem( _choose_minimal_confidence_mi );\r
+        customizeJMenuItem( _switch_colors_mi );\r
+        customizeJMenuItem( _print_size_mi );\r
+        customizeJMenuItem( _choose_pdf_width_mi );\r
+        customizeJMenuItem( _overview_placment_mi );\r
+        customizeCheckBoxMenuItem( _show_default_node_shapes_external_cbmi, getOptions()\r
+                                   .isShowDefaultNodeShapesExternal() );\r
+        customizeCheckBoxMenuItem( _show_default_node_shapes_internal_cbmi, getOptions()\r
+                                   .isShowDefaultNodeShapesInternal() );\r
+        customizeCheckBoxMenuItem( _show_default_node_shapes_for_marked_cbmi, getOptions()\r
+                                   .isShowDefaultNodeShapesForMarkedNodes() );\r
+        customizeJMenuItem( _cycle_node_shape_mi );\r
+        customizeJMenuItem( _cycle_node_fill_mi );\r
+        customizeJMenuItem( _choose_node_size_mi );\r
+        customizeJMenuItem( _cycle_data_return );\r
+        customizeCheckBoxMenuItem( _color_labels_same_as_parent_branch, getOptions().isColorLabelsSameAsParentBranch() );\r
+        customizeCheckBoxMenuItem( _color_by_taxonomic_group_cbmi, getOptions().isColorByTaxonomicGroup() );\r
+        customizeCheckBoxMenuItem( _screen_antialias_cbmi, getOptions().isAntialiasScreen() );\r
+        customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );\r
+        customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );\r
+        customizeCheckBoxMenuItem( _show_annotation_ref_source, getOptions().isShowAnnotationRefSource() );\r
+        customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );\r
+        customizeCheckBoxMenuItem( _search_case_senstive_cbmi, getOptions().isSearchCaseSensitive() );\r
+        customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );\r
+        customizeRadioButtonMenuItem( _non_lined_up_cladograms_rbmi,\r
+                                      getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP );\r
+        customizeRadioButtonMenuItem( _uniform_cladograms_rbmi,\r
+                                      getOptions().getCladogramType() == CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );\r
+        customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi,\r
+                                      getOptions().getCladogramType() == CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );\r
+        customizeCheckBoxMenuItem( _show_overview_cbmi, getOptions().isShowOverview() );\r
+        customizeCheckBoxMenuItem( _label_direction_cbmi,\r
+                                   getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL );\r
+        customizeCheckBoxMenuItem( _antialias_print_cbmi, getOptions().isAntialiasPrint() );\r
+        customizeCheckBoxMenuItem( _print_black_and_white_cbmi, getOptions().isPrintBlackAndWhite() );\r
+        customizeCheckBoxMenuItem( _internal_number_are_confidence_for_nh_parsing_cbmi, getOptions()\r
+                                   .isInternalNumberAreConfidenceForNhParsing() );\r
+        customizeRadioButtonMenuItem( _extract_taxonomy_no_rbmi,\r
+                                      getOptions().getTaxonomyExtraction() == TAXONOMY_EXTRACTION.NO );\r
+        customizeRadioButtonMenuItem( _extract_taxonomy_pfam_strict_rbmi,\r
+                                      getOptions().getTaxonomyExtraction() == TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );\r
+        customizeRadioButtonMenuItem( _extract_taxonomy_pfam_relaxed_rbmi,\r
+                                      getOptions().getTaxonomyExtraction() == TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );\r
+        customizeRadioButtonMenuItem( _extract_taxonomy_agressive_rbmi,\r
+                                      getOptions().getTaxonomyExtraction() == TAXONOMY_EXTRACTION.AGGRESSIVE );\r
+        customizeCheckBoxMenuItem( _replace_underscores_cbmi, getOptions().isReplaceUnderscoresInNhParsing() );\r
+        customizeCheckBoxMenuItem( _allow_errors_in_distance_to_parent_cbmi, getOptions()\r
+                                   .isReplaceUnderscoresInNhParsing() );\r
+        customizeCheckBoxMenuItem( _search_with_regex_cbmi, getOptions().isSearchWithRegex() );\r
+        customizeCheckBoxMenuItem( _search_whole_words_only_cbmi, getOptions().isMatchWholeTermsOnly() );\r
+        customizeCheckBoxMenuItem( _inverse_search_result_cbmi, getOptions().isInverseSearchResult() );\r
+        customizeCheckBoxMenuItem( _graphics_export_visible_only_cbmi, getOptions().isGraphicsExportVisibleOnly() );\r
+        customizeCheckBoxMenuItem( _print_using_actual_size_cbmi, getOptions().isPrintUsingActualSize() );\r
+        customizeCheckBoxMenuItem( _graphics_export_using_actual_size_cbmi, getOptions()\r
+                                   .isGraphicsExportUsingActualSize() );\r
+        customizeCheckBoxMenuItem( _show_confidence_stddev_cbmi, getOptions().isShowConfidenceStddev() );\r
+        customizeCheckBoxMenuItem( _use_brackets_for_conf_in_nh_export_cbmi, getOptions()\r
+                                   .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
+        customizeCheckBoxMenuItem( _line_up_renderable_data_cbmi, getOptions().isLineUpRendarableNodeData() );\r
+        customizeCheckBoxMenuItem( _right_line_up_domains_cbmi, getOptions().isRightLineUpDomains() );\r
+        _jmenubar.add( _options_jmenu );\r
+    }\r
+\r
+    void buildPhylogeneticInferenceMenu() {\r
+        final InferenceManager im = getInferenceManager();\r
+        _inference_menu = MainFrame.createMenu( "Inference", getConfiguration() );\r
+        _inference_menu.add( _inference_from_msa_item = new JMenuItem( "From Multiple Sequence Alignment..." ) );\r
+        customizeJMenuItem( _inference_from_msa_item );\r
+        _inference_from_msa_item.setToolTipText( "Basic phylogenetic inference from MSA" );\r
+        if ( im.canDoMsa() ) {\r
+            _inference_menu.add( _inference_from_seqs_item = new JMenuItem( "From Unaligned Sequences..." ) );\r
+            customizeJMenuItem( _inference_from_seqs_item );\r
+            _inference_from_seqs_item\r
+            .setToolTipText( "Basic phylogenetic inference including multiple sequence alignment" );\r
+        }\r
+        else {\r
+            _inference_menu\r
+            .add( _inference_from_seqs_item = new JMenuItem( "From Unaligned Sequences (no program found)" ) );\r
+            customizeJMenuItem( _inference_from_seqs_item );\r
+            _inference_from_seqs_item.setEnabled( false );\r
+        }\r
+        _jmenubar.add( _inference_menu );\r
+    }\r
+\r
+    void buildToolsMenu() {\r
+        _tools_menu = createMenu( "Tools", getConfiguration() );\r
+        _tools_menu.add( _confcolor_item = new JMenuItem( "Colorize Branches Depending on Confidence" ) );\r
+        customizeJMenuItem( _confcolor_item );\r
+        _tools_menu.add( _color_rank_jmi = new JMenuItem( "Colorize Subtrees via Taxonomic Rank" ) );\r
+        customizeJMenuItem( _color_rank_jmi );\r
+        _color_rank_jmi.setToolTipText( "for example, at \"Class\" level, colorize mammal specific subtree red" );\r
+        _tools_menu.add( _taxcolor_item = new JMenuItem( "Taxonomy Colorize Branches" ) );\r
+        customizeJMenuItem( _taxcolor_item );\r
+        _tools_menu.addSeparator();\r
+        _tools_menu.add( _remove_visual_styles_item = new JMenuItem( "Delete All Visual Styles From Nodes" ) );\r
+        _remove_visual_styles_item\r
+        .setToolTipText( "To remove all node visual styles (fonts, colors) from the current phylogeny" );\r
+        customizeJMenuItem( _remove_visual_styles_item );\r
+        _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete All Colors From Branches" ) );\r
+        _remove_branch_color_item.setToolTipText( "To remove all branch color values from the current phylogeny" );\r
+        customizeJMenuItem( _remove_branch_color_item );\r
+        _tools_menu.addSeparator();\r
+        _tools_menu.add( _annotate_item = new JMenuItem( "Annotate Sequences of Selected Nodes" ) );\r
+        customizeJMenuItem( _annotate_item );\r
+        _tools_menu.addSeparator();\r
+        _tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) );\r
+        customizeJMenuItem( _midpoint_root_item );\r
+        _tools_menu.addSeparator();\r
+        _tools_menu.add( _delete_selected_nodes_item = new JMenuItem( "Delete Selected Nodes" ) );\r
+        _delete_selected_nodes_item.setToolTipText( "To delete all selected external nodes" );\r
+        customizeJMenuItem( _delete_selected_nodes_item );\r
+        _tools_menu.add( _delete_not_selected_nodes_item = new JMenuItem( "Retain Selected Nodes" ) );\r
+        _delete_not_selected_nodes_item.setToolTipText( "To delete all not selected external nodes" );\r
+        customizeJMenuItem( _delete_not_selected_nodes_item );\r
+        _tools_menu.addSeparator();\r
+        _tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Species-Specific Subtrees" ) );\r
+        customizeJMenuItem( _collapse_species_specific_subtrees );\r
+        _collapse_species_specific_subtrees.setToolTipText( "To (reversibly) collapse species-specific subtrees" );\r
+        _tools_menu\r
+        .add( _collapse_below_threshold = new JMenuItem( "Collapse Branches with Confidence Below Threshold into Multifurcations" ) );\r
+        customizeJMenuItem( _collapse_below_threshold );\r
+        _collapse_below_threshold\r
+        .setToolTipText( "To (permanently) collapse branches with confidence values below a threshold into multifurcations (in the case of multiple confidences per branch: without at least one confidence value above a threshold)" );\r
+        //\r
+        _tools_menu\r
+        .add( _collapse_below_branch_length = new JMenuItem( "Collapse Branches with Branch Lengths Below Threshold into Multifurcations" ) );\r
+        customizeJMenuItem( _collapse_below_branch_length );\r
+        _collapse_below_branch_length\r
+        .setToolTipText( "To (permanently) collapse branches with branches with branch lengths below a threshold into multifurcations" );\r
+        //\r
+        _tools_menu.addSeparator();\r
+        _tools_menu\r
+        .add( _extract_tax_code_from_node_names_jmi = new JMenuItem( "Extract Taxonomic Data from Node Names" ) );\r
+        customizeJMenuItem( _extract_tax_code_from_node_names_jmi );\r
+        _extract_tax_code_from_node_names_jmi\r
+        .setToolTipText( "To extract SwissProt/Uniprot taxonomic codes (mnemonics) from nodes names in the form of 'xyz_CAEEL', Uniprot/NCBI identifiers form of 'xyz_6239', or scientific names form of 'xyz_Caenorhabditis_elegans'" );\r
+        _tools_menu\r
+        .add( _move_node_names_to_tax_sn_jmi = new JMenuItem( "Transfer Node Names to Taxonomic Scientific Names" ) );\r
+        customizeJMenuItem( _move_node_names_to_tax_sn_jmi );\r
+        _move_node_names_to_tax_sn_jmi.setToolTipText( "To interpret node names as taxonomic scientific names" );\r
+        _tools_menu.add( _move_node_names_to_seq_names_jmi = new JMenuItem( "Transfer Node Names to Sequence Names" ) );\r
+        customizeJMenuItem( _move_node_names_to_seq_names_jmi );\r
+        _move_node_names_to_seq_names_jmi.setToolTipText( "To interpret node names as sequence (protein, gene) names" );\r
+        _tools_menu.addSeparator();\r
+        _tools_menu.add( _obtain_seq_information_jmi = new JMenuItem( "Obtain Sequence Information" ) );\r
+        customizeJMenuItem( _obtain_seq_information_jmi );\r
+        _obtain_seq_information_jmi.setToolTipText( "To add additional sequence information" );\r
+        _tools_menu\r
+        .add( _obtain_detailed_taxonomic_information_jmi = new JMenuItem( OBTAIN_DETAILED_TAXONOMIC_INFORMATION ) );\r
+        customizeJMenuItem( _obtain_detailed_taxonomic_information_jmi );\r
+        _obtain_detailed_taxonomic_information_jmi\r
+        .setToolTipText( "To add additional taxonomic information (from UniProt Taxonomy)" );\r
+        _tools_menu\r
+        .add( _obtain_detailed_taxonomic_information_deleting_jmi = new JMenuItem( "Obtain Detailed Taxonomic Information (deletes nodes!)" ) );\r
+        customizeJMenuItem( _obtain_detailed_taxonomic_information_deleting_jmi );\r
+        _obtain_detailed_taxonomic_information_deleting_jmi\r
+        .setToolTipText( "To add additional taxonomic information, deletes nodes for which taxonomy cannot found (from UniProt Taxonomy)" );\r
+        _tools_menu.addSeparator();\r
+        _tools_menu.add( _read_values_jmi = new JMenuItem( "Attach Vector/Expression Values" ) );\r
+        customizeJMenuItem( _read_values_jmi );\r
+        _read_values_jmi.setToolTipText( "To attach vector (e.g. gene expression) values to tree nodes (beta)" );\r
+        _jmenubar.add( _tools_menu );\r
+        _tools_menu.add( _read_seqs_jmi = new JMenuItem( "Attach Molecular Sequences" ) );\r
+        customizeJMenuItem( _read_seqs_jmi );\r
+        _read_seqs_jmi\r
+        .setToolTipText( "To attach molecular sequences to tree nodes (from Fasta-formatted file) (beta)" );\r
+        _jmenubar.add( _tools_menu );\r
+    }\r
+\r
+    @Override\r
+    void close() {\r
+        if ( isUnsavedDataPresent() ) {\r
+            final int r = JOptionPane.showConfirmDialog( this,\r
+                                                         "Exit despite potentially unsaved changes?",\r
+                                                         "Exit?",\r
+                                                         JOptionPane.YES_NO_OPTION );\r
+            if ( r != JOptionPane.YES_OPTION ) {\r
+                return;\r
+            }\r
+        }\r
+        exit();\r
+    }\r
+\r
+    void executeLineageInference() {\r
+        if ( ( _mainpanel.getCurrentPhylogeny() == null ) || ( _mainpanel.getCurrentPhylogeny().isEmpty() ) ) {\r
+            return;\r
+        }\r
+        if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {\r
+            JOptionPane.showMessageDialog( this,\r
+                                           "Phylogeny is not rooted.",\r
+                                           "Cannot infer ancestral taxonomies",\r
+                                           JOptionPane.ERROR_MESSAGE );\r
+            return;\r
+        }\r
+        final AncestralTaxonomyInferrer inferrer = new AncestralTaxonomyInferrer( this,\r
+                                                                                  _mainpanel.getCurrentTreePanel(),\r
+                                                                                  _mainpanel.getCurrentPhylogeny()\r
+                                                                                  .copy() );\r
+        new Thread( inferrer ).start();\r
+    }\r
+\r
+    void exit() {\r
+        removeAllTextFrames();\r
+        _mainpanel.terminate();\r
+        _contentpane.removeAll();\r
+        setVisible( false );\r
+        dispose();\r
+        // System.exit( 0 ); //TODO reconfirm that this is OK, then remove.\r
     }\r
 \r
     void readPhylogeniesFromURL() {\r
@@ -1960,7 +2139,7 @@ public final class MainFrameApplication extends MainFrame {
                 }\r
                 else {\r
                     parser = ParserUtils.createParserDependingOnUrlContents( url, getConfiguration()\r
-                            .isValidatePhyloXmlAgainstSchema() );\r
+                                                                             .isValidatePhyloXmlAgainstSchema() );\r
                 }\r
                 if ( parser instanceof NexusPhylogeniesParser ) {\r
                     nhx_or_nexus = true;\r
@@ -1987,8 +2166,8 @@ public final class MainFrameApplication extends MainFrame {
                 JOptionPane.showMessageDialog( this,\r
                                                "Could not read from " + url + "\n"\r
                                                        + ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),\r
-                                               "Failed to read URL",\r
-                                               JOptionPane.ERROR_MESSAGE );\r
+                                                       "Failed to read URL",\r
+                                                       JOptionPane.ERROR_MESSAGE );\r
             }\r
             catch ( final Exception e ) {\r
                 JOptionPane.showMessageDialog( this,\r
@@ -2022,206 +2201,6 @@ public final class MainFrameApplication extends MainFrame {
         System.gc();\r
     }\r
 \r
-    public void readSeqsFromFileforPI() {\r
-        // Set an initial directory if none set yet\r
-        final File my_dir = getCurrentDir();\r
-        _seqs_pi_filechooser.setMultiSelectionEnabled( false );\r
-        // Open file-open dialog and set current directory\r
-        if ( my_dir != null ) {\r
-            _seqs_pi_filechooser.setCurrentDirectory( my_dir );\r
-        }\r
-        final int result = _seqs_pi_filechooser.showOpenDialog( _contentpane );\r
-        // All done: get the seqs\r
-        final File file = _seqs_pi_filechooser.getSelectedFile();\r
-        setCurrentDir( _seqs_pi_filechooser.getCurrentDirectory() );\r
-        if ( ( file != null ) && !file.isDirectory() && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
-            setSeqsFile( null );\r
-            setSeqs( null );\r
-            List<MolecularSequence> seqs = null;\r
-            try {\r
-                if ( FastaParser.isLikelyFasta( new FileInputStream( file ) ) ) {\r
-                    seqs = FastaParser.parse( new FileInputStream( file ) );\r
-                    for( final MolecularSequence seq : seqs ) {\r
-                        System.out.println( SequenceWriter.toFasta( seq, 60 ) );\r
-                    }\r
-                }\r
-                else {\r
-                    //TODO error\r
-                }\r
-            }\r
-            catch ( final MsaFormatException e ) {\r
-                setArrowCursor();\r
-                JOptionPane.showMessageDialog( this,\r
-                                               e.getLocalizedMessage(),\r
-                                               "Multiple sequence file format error",\r
-                                               JOptionPane.ERROR_MESSAGE );\r
-                return;\r
-            }\r
-            catch ( final IOException e ) {\r
-                setArrowCursor();\r
-                JOptionPane.showMessageDialog( this,\r
-                                               e.getLocalizedMessage(),\r
-                                               "Failed to read multiple sequence file",\r
-                                               JOptionPane.ERROR_MESSAGE );\r
-                return;\r
-            }\r
-            catch ( final IllegalArgumentException e ) {\r
-                setArrowCursor();\r
-                JOptionPane.showMessageDialog( this,\r
-                                               e.getLocalizedMessage(),\r
-                                               "Unexpected error during reading of multiple sequence file",\r
-                                               JOptionPane.ERROR_MESSAGE );\r
-                return;\r
-            }\r
-            catch ( final Exception e ) {\r
-                setArrowCursor();\r
-                e.printStackTrace();\r
-                JOptionPane.showMessageDialog( this,\r
-                                               e.getLocalizedMessage(),\r
-                                               "Unexpected error during reading of multiple sequence file",\r
-                                               JOptionPane.ERROR_MESSAGE );\r
-                return;\r
-            }\r
-            if ( ( seqs == null ) || ( seqs.size() < 1 ) ) {\r
-                JOptionPane.showMessageDialog( this,\r
-                                               "Multiple sequence file is empty",\r
-                                               "Illegal multiple sequence file",\r
-                                               JOptionPane.ERROR_MESSAGE );\r
-                return;\r
-            }\r
-            if ( seqs.size() < 4 ) {\r
-                JOptionPane.showMessageDialog( this,\r
-                                               "Multiple sequence file needs to contain at least 3 sequences",\r
-                                               "Illegal multiple sequence file",\r
-                                               JOptionPane.ERROR_MESSAGE );\r
-                return;\r
-            }\r
-            //  if ( msa.getLength() < 2 ) {\r
-            //       JOptionPane.showMessageDialog( this,\r
-            //                                      "Multiple sequence alignment needs to contain at least 2 residues",\r
-            //                                      "Illegal multiple sequence file",\r
-            //                                      JOptionPane.ERROR_MESSAGE );\r
-            //       return;\r
-            //   }\r
-            System.gc();\r
-            setSeqsFile( _seqs_pi_filechooser.getSelectedFile() );\r
-            setSeqs( seqs );\r
-        }\r
-    }\r
-\r
-    private void readSpeciesTreeFromFile() {\r
-        Phylogeny t = null;\r
-        boolean exception = false;\r
-        final File my_dir = getCurrentDir();\r
-        _open_filechooser_for_species_tree.setSelectedFile( new File( "" ) );\r
-        if ( my_dir != null ) {\r
-            _open_filechooser_for_species_tree.setCurrentDirectory( my_dir );\r
-        }\r
-        final int result = _open_filechooser_for_species_tree.showOpenDialog( _contentpane );\r
-        final File file = _open_filechooser_for_species_tree.getSelectedFile();\r
-        if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
-            if ( _open_filechooser_for_species_tree.getFileFilter() == MainFrame.xmlfilter ) {\r
-                try {\r
-                    final Phylogeny[] trees = PhylogenyMethods.readPhylogenies( PhyloXmlParser\r
-                            .createPhyloXmlParserXsdValidating(), file );\r
-                    t = trees[ 0 ];\r
-                }\r
-                catch ( final Exception e ) {\r
-                    exception = true;\r
-                    exceptionOccuredDuringOpenFile( e );\r
-                }\r
-            }\r
-            else if ( _open_filechooser_for_species_tree.getFileFilter() == MainFrame.tolfilter ) {\r
-                try {\r
-                    final Phylogeny[] trees = PhylogenyMethods.readPhylogenies( new TolParser(), file );\r
-                    t = trees[ 0 ];\r
-                }\r
-                catch ( final Exception e ) {\r
-                    exception = true;\r
-                    exceptionOccuredDuringOpenFile( e );\r
-                }\r
-            }\r
-            // "*.*":\r
-            else {\r
-                try {\r
-                    final Phylogeny[] trees = PhylogenyMethods.readPhylogenies( PhyloXmlParser\r
-                            .createPhyloXmlParserXsdValidating(), file );\r
-                    t = trees[ 0 ];\r
-                }\r
-                catch ( final Exception e ) {\r
-                    exception = true;\r
-                    exceptionOccuredDuringOpenFile( e );\r
-                }\r
-            }\r
-            if ( !exception && ( t != null ) && !t.isRooted() ) {\r
-                exception = true;\r
-                t = null;\r
-                JOptionPane.showMessageDialog( this,\r
-                                               "Species tree is not rooted",\r
-                                               "Species tree not loaded",\r
-                                               JOptionPane.ERROR_MESSAGE );\r
-            }\r
-            if ( !exception && ( t != null ) ) {\r
-                final Set<Taxonomy> tax_set = new HashSet<Taxonomy>();\r
-                for( final PhylogenyNodeIterator it = t.iteratorExternalForward(); it.hasNext(); ) {\r
-                    final PhylogenyNode node = it.next();\r
-                    if ( !node.getNodeData().isHasTaxonomy() ) {\r
-                        exception = true;\r
-                        t = null;\r
-                        JOptionPane\r
-                                .showMessageDialog( this,\r
-                                                    "Species tree contains external node(s) without taxonomy information",\r
-                                                    "Species tree not loaded",\r
-                                                    JOptionPane.ERROR_MESSAGE );\r
-                        break;\r
-                    }\r
-                    else {\r
-                        if ( tax_set.contains( node.getNodeData().getTaxonomy() ) ) {\r
-                            exception = true;\r
-                            t = null;\r
-                            JOptionPane.showMessageDialog( this,\r
-                                                           "Taxonomy ["\r
-                                                                   + node.getNodeData().getTaxonomy().asSimpleText()\r
-                                                                   + "] is not unique in species tree",\r
-                                                           "Species tree not loaded",\r
-                                                           JOptionPane.ERROR_MESSAGE );\r
-                            break;\r
-                        }\r
-                        else {\r
-                            tax_set.add( node.getNodeData().getTaxonomy() );\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-            if ( !exception && ( t != null ) ) {\r
-                setSpeciesTree( t );\r
-                JOptionPane.showMessageDialog( this,\r
-                                               "Species tree successfully loaded",\r
-                                               "Species tree loaded",\r
-                                               JOptionPane.INFORMATION_MESSAGE );\r
-            }\r
-            _contentpane.repaint();\r
-            System.gc();\r
-        }\r
-    }\r
-\r
-    private void setArrowCursor() {\r
-        try {\r
-            _mainpanel.getCurrentTreePanel().setArrowCursor();\r
-        }\r
-        catch ( final Exception ex ) {\r
-            // Do nothing.\r
-        }\r
-    }\r
-\r
-    private void setMinNotCollapseBlValue( final double min_not_collapse_bl ) {\r
-        _min_not_collapse_bl = min_not_collapse_bl;\r
-    }\r
-\r
-    private void setMinNotCollapseConfidenceValue( final double min_not_collapse ) {\r
-        _min_not_collapse = min_not_collapse;\r
-    }\r
-\r
     void setMsa( final Msa msa ) {\r
         _msa = msa;\r
     }\r
@@ -2230,10 +2209,6 @@ public final class MainFrameApplication extends MainFrame {
         _msa_file = msa_file;\r
     }\r
 \r
-    private void setPhylogeneticInferenceOptions( final PhylogeneticInferenceOptions phylogenetic_inference_options ) {\r
-        _phylogenetic_inference_options = phylogenetic_inference_options;\r
-    }\r
-\r
     void setSeqs( final List<MolecularSequence> seqs ) {\r
         _seqs = seqs;\r
     }\r
@@ -2242,16 +2217,34 @@ public final class MainFrameApplication extends MainFrame {
         _seqs_file = seqs_file;\r
     }\r
 \r
-    private void setSpecialOptionsForNexParser( final NexusPhylogeniesParser nex ) {\r
-        nex.setReplaceUnderscores( getOptions().isReplaceUnderscoresInNhParsing() );\r
-        nex.setTaxonomyExtraction( getOptions().getTaxonomyExtraction() );\r
+    public static MainFrameApplication createInstance( final Phylogeny[] phys, final Configuration config ) {\r
+        return new MainFrameApplication( phys, config );\r
     }\r
 \r
-    private void setSpecialOptionsForNhxParser( final NHXParser nhx ) {\r
-        nhx.setReplaceUnderscores( getOptions().isReplaceUnderscoresInNhParsing() );\r
-        nhx.setTaxonomyExtraction( getOptions().getTaxonomyExtraction() );\r
-        nhx.setAllowErrorsInDistanceToParent( getOptions().isAllowErrorsInDistanceToParent() );\r
+    public static MainFrame createInstance( final Phylogeny[] phys,\r
+                                            final Configuration config,\r
+                                            final String title,\r
+                                            final File current_dir ) {\r
+        return new MainFrameApplication( phys, config, title, current_dir );\r
+    }\r
+\r
+    static MainFrame createInstance( final Phylogeny[] phys, final Configuration config, final String title ) {\r
+        return new MainFrameApplication( phys, config, title );\r
+    }\r
+\r
+    static MainFrame createInstance( final Phylogeny[] phys, final String config_file_name, final String title ) {\r
+        return new MainFrameApplication( phys, config_file_name, title );\r
     }\r
 \r
-   \r
+    static void warnIfNotPhyloXmlValidation( final Configuration c ) {\r
+        if ( !c.isValidatePhyloXmlAgainstSchema() ) {\r
+            JOptionPane\r
+            .showMessageDialog( null,\r
+                                ForesterUtil\r
+                                .wordWrap( "phyloXML XSD-based validation is turned off [enable with line 'validate_against_phyloxml_xsd_schem: true' in configuration file]",\r
+                                           80 ),\r
+                                           "Warning",\r
+                                           JOptionPane.WARNING_MESSAGE );\r
+        }\r
+    }\r
 } // MainFrameApplication.\r
index 6551f1b..cc03467 100644 (file)
@@ -70,9 +70,6 @@ public class MainPanel extends JPanel implements ComponentListener {
     private Hashtable<String, BufferedImage> _image_map;
     private static Map<String, String>       _lineage_to_rank_map;
 
-    MainPanel() {
-    }
-
     public MainPanel( final Configuration configuration, final MainFrame parent ) {
         if ( configuration == null ) {
             throw new IllegalArgumentException( "configuration is null" );
@@ -88,6 +85,9 @@ public class MainPanel extends JPanel implements ComponentListener {
         getControlPanel().showWhole();
     }
 
+    MainPanel() {
+    }
+
     public void addPhylogenyInNewTab( final Phylogeny phy,
                                       final Configuration config,
                                       final String default_name,
@@ -143,6 +143,78 @@ public class MainPanel extends JPanel implements ComponentListener {
         getControlPanel().showWhole();
     }
 
+    @Override
+    public void componentHidden( final ComponentEvent e ) {
+        // Do nothing.
+    }
+
+    @Override
+    public void componentMoved( final ComponentEvent e ) {
+        // Do nothing.
+    }
+
+    @Override
+    public void componentResized( final ComponentEvent e ) {
+        if ( getCurrentTreePanel() != null ) {
+            getCurrentTreePanel().updateOvSettings();
+            getCurrentTreePanel().updateOvSizes();
+        }
+    }
+
+    @Override
+    public void componentShown( final ComponentEvent e ) {
+        // Do nothing.
+    }
+
+    public ControlPanel getControlPanel() {
+        return _control_panel;
+    }
+
+    public Set<Long> getCopiedAndPastedNodes() {
+        return _copied_and_pasted_nodes;
+    }
+
+    public TreePanel getCurrentTreePanel() {
+        final int selected = getTabbedPane().getSelectedIndex();
+        if ( selected >= 0 ) {
+            return _treepanels.get( selected );
+        }
+        else {
+            if ( _treepanels.size() == 1 ) {
+                return _treepanels.get( 0 );
+            }
+            else {
+                return null;
+            }
+        }
+    }
+
+    public Options getOptions() {
+        return _mainframe.getOptions();
+    }
+
+    public JTabbedPane getTabbedPane() {
+        return _tabbed_pane;
+    }
+
+    public TreeFontSet getTreeFontSet() {
+        return _fontset;
+    }
+
+    public void setArrowCursor() {
+        setCursor( TreePanel.ARROW_CURSOR );
+        repaint();
+    }
+
+    public void setCopiedAndPastedNodes( final Set<Long> node_ids ) {
+        _copied_and_pasted_nodes = node_ids;
+    }
+
+    public void setWaitCursor() {
+        setCursor( TreePanel.WAIT_CURSOR );
+        repaint();
+    }
+
     void addPhylogenyInPanel( final Phylogeny phy, final Configuration config ) {
         final TreePanel treepanel = new TreePanel( phy, config, this );
         getControlPanel().phylogenyAdded( config );
@@ -199,41 +271,10 @@ public class MainPanel extends JPanel implements ComponentListener {
         }
     }
 
-    @Override
-    public void componentHidden( final ComponentEvent e ) {
-        // Do nothing.
-    }
-
-    @Override
-    public void componentMoved( final ComponentEvent e ) {
-        // Do nothing.
-    }
-
-    @Override
-    public void componentResized( final ComponentEvent e ) {
-        if ( getCurrentTreePanel() != null ) {
-            getCurrentTreePanel().updateOvSettings();
-            getCurrentTreePanel().updateOvSizes();
-        }
-    }
-
-    @Override
-    public void componentShown( final ComponentEvent e ) {
-        // Do nothing.
-    }
-
     Configuration getConfiguration() {
         return _configuration;
     }
 
-    public ControlPanel getControlPanel() {
-        return _control_panel;
-    }
-
-    public Set<Long> getCopiedAndPastedNodes() {
-        return _copied_and_pasted_nodes;
-    }
-
     Phylogeny getCurrentPhylogeny() {
         if ( getCurrentTreePanel() == null ) {
             return null;
@@ -276,38 +317,16 @@ public class MainPanel extends JPanel implements ComponentListener {
         }
     }
 
-    void setTitleOfSelectedTab( final String title ) {
-        final int selected = getTabbedPane().getSelectedIndex();
-        if ( selected >= 0 ) {
-            getTabbedPane().setTitleAt( selected, title );
-        }
-    }
-
-    public TreePanel getCurrentTreePanel() {
-        final int selected = getTabbedPane().getSelectedIndex();
-        if ( selected >= 0 ) {
-            return _treepanels.get( selected );
-        }
-        else {
-            if ( _treepanels.size() == 1 ) {
-                return _treepanels.get( 0 );
-            }
-            else {
-                return null;
-            }
-        }
-    }
-
     Phylogeny getCutOrCopiedTree() {
         return _cut_or_copied_tree;
     }
 
-    MainFrame getMainFrame() {
-        return _mainframe;
+    synchronized Hashtable<String, BufferedImage> getImageMap() {
+        return _image_map;
     }
 
-    public Options getOptions() {
-        return _mainframe.getOptions();
+    MainFrame getMainFrame() {
+        return _mainframe;
     }
 
     Phylogeny getPhylogeny( final int index ) {
@@ -321,18 +340,10 @@ public class MainPanel extends JPanel implements ComponentListener {
         return getCurrentScrollPane().getViewport().getExtentSize();
     }
 
-    public JTabbedPane getTabbedPane() {
-        return _tabbed_pane;
-    }
-
     TreeColorSet getTreeColorSet() {
         return _colorset;
     }
 
-    public TreeFontSet getTreeFontSet() {
-        return _fontset;
-    }
-
     List<TreePanel> getTreePanels() {
         return _treepanels;
     }
@@ -383,17 +394,19 @@ public class MainPanel extends JPanel implements ComponentListener {
         add( _tabbed_pane, BorderLayout.CENTER );
     }
 
-    public void setArrowCursor() {
-        setCursor( TreePanel.ARROW_CURSOR );
-        repaint();
+    void setCutOrCopiedTree( final Phylogeny cut_or_copied_tree ) {
+        _cut_or_copied_tree = cut_or_copied_tree;
     }
 
-    public void setCopiedAndPastedNodes( final Set<Long> node_ids ) {
-        _copied_and_pasted_nodes = node_ids;
+    synchronized void setImageMap( final Hashtable<String, BufferedImage> image_map ) {
+        _image_map = image_map;
     }
 
-    void setCutOrCopiedTree( final Phylogeny cut_or_copied_tree ) {
-        _cut_or_copied_tree = cut_or_copied_tree;
+    void setTitleOfSelectedTab( final String title ) {
+        final int selected = getTabbedPane().getSelectedIndex();
+        if ( selected >= 0 ) {
+            getTabbedPane().setTitleAt( selected, title );
+        }
     }
 
     void setTreeColorSet( final TreeColorSet colorset ) {
@@ -414,25 +427,12 @@ public class MainPanel extends JPanel implements ComponentListener {
         RenderableDomainArchitecture.setColorMap( config_settings.getDomainColors() );
     }
 
-    public void setWaitCursor() {
-        setCursor( TreePanel.WAIT_CURSOR );
-        repaint();
-    }
-
     void terminate() {
         for( final TreePanel atvtreepanel : _treepanels ) {
             atvtreepanel.removeAllEditNodeJFrames();
         }
     }
 
-    synchronized void setImageMap( final Hashtable<String, BufferedImage> image_map ) {
-        _image_map = image_map;
-    }
-
-    synchronized Hashtable<String, BufferedImage> getImageMap() {
-        return _image_map;
-    }
-
     public synchronized static Map<String, String> getLineageToRankMap() {
         if ( _lineage_to_rank_map == null ) {
             _lineage_to_rank_map = new HashMap<String, String>();
index 80a96c0..cfd54d7 100644 (file)
@@ -70,14 +70,6 @@ final class MainPanelApplets extends MainPanel {
         setupTreeGraphic( configuration, getControlPanel() );
     }
 
-    JApplet getApplet() {
-        return _applet;
-    }
-
-    MainFrameApplet getAppletFrame() {
-        return ( MainFrameApplet ) _mainframe;
-    }
-
     @Override
     public Options getOptions() {
         if ( _mainframe != null ) {
@@ -87,4 +79,12 @@ final class MainPanelApplets extends MainPanel {
             return ( ( ArchaeopteryxE ) _applet ).getOptions();
         }
     }
+
+    JApplet getApplet() {
+        return _applet;
+    }
+
+    MainFrameApplet getAppletFrame() {
+        return ( MainFrameApplet ) _mainframe;
+    }
 }
\ No newline at end of file
index f593a78..31189dd 100644 (file)
@@ -71,6 +71,71 @@ import org.forester.util.ForesterUtil;
 
 class NodeEditPanel extends JPanel {
 
+    private enum PHYLOXML_TAG {
+        NODE_NAME,
+        NODE_BRANCH_LENGTH,
+        NODE_BRANCH_WIDTH,
+        TAXONOMY_CODE,
+        TAXONOMY_SCIENTIFIC_NAME,
+        TAXONOMY_AUTHORITY,
+        TAXONOMY_COMMON_NAME,
+        TAXONOMY_SYNONYM,
+        TAXONOMY_RANK,
+        TAXONOMY_URI,
+        SEQ_SYMBOL,
+        SEQ_NAME,
+        SEQ_GENE_NAME,
+        SEQ_LOCATION,
+        SEQ_TYPE,
+        SEQ_MOL_SEQ,
+        SEQ_URI,
+        DATE_DESCRIPTION,
+        DATE_VALUE,
+        DATE_MIN,
+        DATE_MAX,
+        DATE_UNIT,
+        TAXONOMY_ID_VALUE,
+        TAXONOMY_ID_PROVIDER,
+        SEQ_ACC_VALUE,
+        SEQ_ACC_SOURCE,
+        CONFIDENCE_VALUE,
+        CONFIDENCE_TYPE,
+        LIT_REFERENCE_DESC,
+        LIT_REFERENCE_DOI,
+        EVENTS_DUPLICATIONS,
+        EVENTS_SPECIATIONS,
+        EVENTS_GENE_LOSSES,
+        DIST_DESC,
+        DIST_GEODETIC,
+        DIST_LAT,
+        DIST_LONG,
+        DIST_ALT,
+        DIST_ALT_UNIT
+    }
+
+    private class TagNumber {
+
+        final private PHYLOXML_TAG _tag;
+        final private int          _number;
+
+        TagNumber( final PHYLOXML_TAG tag, final int number ) {
+            _tag = tag;
+            _number = number;
+        }
+
+        @Override
+        public String toString() {
+            return getTag() + "_" + getNumber();
+        }
+
+        int getNumber() {
+            return _number;
+        }
+
+        PHYLOXML_TAG getTag() {
+            return _tag;
+        }
+    }
     private static final long                            serialVersionUID = 5120159904388100771L;
     private final JTree                                  _tree;
     private final JEditorPane                            _pane;
@@ -290,12 +355,12 @@ class NodeEditPanel extends JPanel {
                                NodePanel.EVENTS_DUPLICATIONS,
                                String.valueOf( events.getNumberOfDuplications() >= 0 ? events.getNumberOfDuplications()
                                        : 0 ),
-                               PHYLOXML_TAG.EVENTS_DUPLICATIONS );
+                                       PHYLOXML_TAG.EVENTS_DUPLICATIONS );
         addSubelementEditable( category,
                                NodePanel.EVENTS_SPECIATIONS,
                                String.valueOf( events.getNumberOfSpeciations() >= 0 ? events.getNumberOfSpeciations()
                                        : 0 ),
-                               PHYLOXML_TAG.EVENTS_SPECIATIONS );
+                                       PHYLOXML_TAG.EVENTS_SPECIATIONS );
         addSubelementEditable( category,
                                NodePanel.EVENTS_GENE_LOSSES,
                                String.valueOf( events.getNumberOfGeneLosses() >= 0 ? events.getNumberOfGeneLosses() : 0 ),
@@ -353,7 +418,7 @@ class NodeEditPanel extends JPanel {
             for( final Uri uri : seq.getUris() ) {
                 if ( uri != null ) {
                     addSubelementEditable( category, NodePanel.SEQ_URI + " [" + uri_counter + "]", uri.getValue()
-                            .toString(), PHYLOXML_TAG.SEQ_URI, uri_counter++ );
+                                           .toString(), PHYLOXML_TAG.SEQ_URI, uri_counter++ );
                 }
             }
         }
@@ -480,7 +545,7 @@ class NodeEditPanel extends JPanel {
             for( final Uri uri : tax.getUris() ) {
                 if ( uri != null ) {
                     addSubelementEditable( category, NodePanel.TAXONOMY_URI + " [" + uri_counter + "]", uri.getValue()
-                            .toString(), PHYLOXML_TAG.TAXONOMY_URI, uri_counter++ );
+                                           .toString(), PHYLOXML_TAG.TAXONOMY_URI, uri_counter++ );
                 }
             }
         }
@@ -491,6 +556,25 @@ class NodeEditPanel extends JPanel {
                                uri_counter );
     }
 
+    private void addUri( final DefaultMutableTreeNode mtn, final Uri uri, final int number, final MultipleUris mu ) {
+        if ( uri != null ) {
+            if ( mu.getUris() == null ) {
+                mu.setUris( new ArrayList<Uri>() );
+            }
+        }
+        if ( ( uri != null ) && ( mu.getUris() == null ) ) {
+            mu.setUris( new ArrayList<Uri>() );
+        }
+        if ( ( uri != null ) && ( mu.getUris().size() == number ) ) {
+            mu.getUris().add( uri );
+        }
+        if ( ( mu.getUris() != null ) && ( mu.getUris().size() != number ) ) {
+            mu.getUris().set( number, uri );
+        }
+        final ImageLoader il = new ImageLoader( getTreePanel() );
+        new Thread( il ).start();
+    }
+
     private void collapsePath( final String name ) {
         final TreePath tp = getJTree().getNextMatch( name, 0, Position.Bias.Forward );
         if ( tp != null ) {
@@ -541,10 +625,6 @@ class NodeEditPanel extends JPanel {
         return getMap().get( mtn );
     }
 
-    PhylogenyNode getMyNode() {
-        return _my_node;
-    }
-
     private DefaultMutableTreeNode getSelectedTreeNode() {
         final TreePath selectionPath = getJTree().getSelectionPath();
         if ( selectionPath != null ) {
@@ -617,13 +697,6 @@ class NodeEditPanel extends JPanel {
         return i;
     }
 
-    void writeAll() {
-        for( int i = 0; i < getJTree().getRowCount(); i++ ) {
-            final TreePath p = getJTree().getPathForRow( i );
-            writeBack( ( DefaultMutableTreeNode ) p.getLastPathComponent() );
-        }
-    }
-
     private void writeBack( final DefaultMutableTreeNode mtn ) {
         if ( !getMap().containsKey( mtn ) ) {
             final DefaultMutableTreeNode parent = ( DefaultMutableTreeNode ) mtn.getParent();
@@ -1035,88 +1108,14 @@ class NodeEditPanel extends JPanel {
         getTreePanel().repaint();
     }
 
-    private void addUri( final DefaultMutableTreeNode mtn, final Uri uri, final int number, final MultipleUris mu ) {
-        if ( uri != null ) {
-            if ( mu.getUris() == null ) {
-                mu.setUris( new ArrayList<Uri>() );
-            }
-        }
-        if ( ( uri != null ) && ( mu.getUris() == null ) ) {
-            mu.setUris( new ArrayList<Uri>() );
-        }
-        if ( ( uri != null ) && ( mu.getUris().size() == number ) ) {
-            mu.getUris().add( uri );
-        }
-        if ( ( mu.getUris() != null ) && ( mu.getUris().size() != number ) ) {
-            mu.getUris().set( number, uri );
-        }
-        final ImageLoader il = new ImageLoader( getTreePanel() );
-        new Thread( il ).start();
-    }
-
-    private enum PHYLOXML_TAG {
-        NODE_NAME,
-        NODE_BRANCH_LENGTH,
-        NODE_BRANCH_WIDTH,
-        TAXONOMY_CODE,
-        TAXONOMY_SCIENTIFIC_NAME,
-        TAXONOMY_AUTHORITY,
-        TAXONOMY_COMMON_NAME,
-        TAXONOMY_SYNONYM,
-        TAXONOMY_RANK,
-        TAXONOMY_URI,
-        SEQ_SYMBOL,
-        SEQ_NAME,
-        SEQ_GENE_NAME,
-        SEQ_LOCATION,
-        SEQ_TYPE,
-        SEQ_MOL_SEQ,
-        SEQ_URI,
-        DATE_DESCRIPTION,
-        DATE_VALUE,
-        DATE_MIN,
-        DATE_MAX,
-        DATE_UNIT,
-        TAXONOMY_ID_VALUE,
-        TAXONOMY_ID_PROVIDER,
-        SEQ_ACC_VALUE,
-        SEQ_ACC_SOURCE,
-        CONFIDENCE_VALUE,
-        CONFIDENCE_TYPE,
-        LIT_REFERENCE_DESC,
-        LIT_REFERENCE_DOI,
-        EVENTS_DUPLICATIONS,
-        EVENTS_SPECIATIONS,
-        EVENTS_GENE_LOSSES,
-        DIST_DESC,
-        DIST_GEODETIC,
-        DIST_LAT,
-        DIST_LONG,
-        DIST_ALT,
-        DIST_ALT_UNIT
+    PhylogenyNode getMyNode() {
+        return _my_node;
     }
 
-    private class TagNumber {
-
-        final private PHYLOXML_TAG _tag;
-        final private int          _number;
-
-        TagNumber( final PHYLOXML_TAG tag, final int number ) {
-            _tag = tag;
-            _number = number;
-        }
-
-        int getNumber() {
-            return _number;
-        }
-
-        PHYLOXML_TAG getTag() {
-            return _tag;
-        }
-
-        @Override
-        public String toString() {
-            return getTag() + "_" + getNumber();
+    void writeAll() {
+        for( int i = 0; i < getJTree().getRowCount(); i++ ) {
+            final TreePath p = getJTree().getPathForRow( i );
+            writeBack( ( DefaultMutableTreeNode ) p.getLastPathComponent() );
         }
     }
 }
index e39b580..0511476 100644 (file)
@@ -351,7 +351,7 @@ class NodePanel extends JPanel implements TreeSelectionListener {
         for( final String key : properties_map.keySet() ) {
             final Property prop = properties_map.get( key );
             category.add( new DefaultMutableTreeNode( prop.getRef() + "=" + prop.getValue() + " " + prop.getUnit()
-                    + " [" + prop.getAppliesTo().toString() + "]" ) );
+                                                      + " [" + prop.getAppliesTo().toString() + "]" ) );
         }
     }
 
index 80f0861..6d55014 100644 (file)
@@ -40,6 +40,39 @@ import org.forester.util.ForesterUtil;
  */
 final public class Options {
 
+    public static enum CLADOGRAM_TYPE {
+        EXT_NODE_SUM_DEP, NON_LINED_UP, TOTAL_NODE_SUM_DEP;
+    }
+
+    public static enum NODE_LABEL_DIRECTION {
+        HORIZONTAL, RADIAL;
+    }
+
+    public static enum PHYLOGENY_GRAPHICS_TYPE {
+        CIRCULAR, CONVEX, CURVED, EURO_STYLE, RECTANGULAR, ROUNDED, TRIANGULAR, UNROOTED;
+    }
+
+    static enum OVERVIEW_PLACEMENT_TYPE {
+        LOWER_LEFT( "lower left" ),
+        LOWER_RIGHT( "lower right" ),
+        UPPER_LEFT( "upper left" ),
+        UPPER_RIGHT( "upper right" );
+
+        private final String _name;
+
+        private OVERVIEW_PLACEMENT_TYPE( final String name ) {
+            _name = name;
+        }
+
+        @Override
+        public String toString() {
+            return _name;
+        }
+
+        public String toTag() {
+            return toString().replaceAll( " ", "_" );
+        }
+    }
     static final double                       MIN_CONFIDENCE_DEFAULT = 0.0;
     private boolean                           _abbreviate_scientific_names;
     private boolean                           _allow_errors_in_distance_to_parent;
@@ -54,7 +87,7 @@ final public class Options {
     private NodeVisualData.NodeShape          _default_node_shape;
     private short                             _default_node_shape_size;
     private boolean                           _editable;
-    private NodeDataField                         _ext_desc_data_to_return;
+    private NodeDataField                     _ext_desc_data_to_return;
     private boolean                           _graphics_export_using_actual_size;
     private boolean                           _graphics_export_visible_only;
     private boolean                           _internal_number_are_confidence_for_nh_parsing;
@@ -100,6 +133,14 @@ final public class Options {
         return _allow_errors_in_distance_to_parent;
     }
 
+    final public boolean isLineUpRendarableNodeData() {
+        return _line_up_renderable_node_data;
+    }
+
+    final public boolean isRightLineUpDomains() {
+        return _right_align_domains;
+    }
+
     public final boolean isShowAnnotationRefSource() {
         return _show_annotation_ref_source;
     }
@@ -124,6 +165,14 @@ final public class Options {
         _ext_desc_data_to_return = ext_desc_data_to_return;
     }
 
+    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;
+    }
+
     public final void setShowAnnotationRefSource( final boolean show_annotation_ref_source ) {
         _show_annotation_ref_source = show_annotation_ref_source;
     }
@@ -132,6 +181,67 @@ final public class Options {
         _show_domain_labels = show_domain_labels;
     }
 
+    final private void init() {
+        _default_node_shape = NodeShape.CIRCLE;
+        _default_node_fill = NodeFill.GRADIENT;
+        _default_node_shape_size = Constants.DEFAULT_NODE_SHAPE_SIZE_DEFAULT;
+        _internal_number_are_confidence_for_nh_parsing = false;
+        _show_scale = false;
+        _antialias_screen = true;
+        _antialias_print = true;
+        _graphics_export_visible_only = false;
+        _editable = true;
+        _background_color_gradient = false;
+        _show_default_node_shapes_internal = false;
+        _show_default_node_shapes_external = false;
+        _show_default_node_shapes_for_marked_nodes = false;
+        if ( AptxUtil.isUsOrCanada() ) {
+            _print_size_x = Constants.US_LETTER_SIZE_X;
+            _print_size_y = Constants.US_LETTER_SIZE_Y;
+        }
+        else {
+            _print_size_x = Constants.A4_SIZE_X;
+            _print_size_y = Constants.A4_SIZE_Y;
+        }
+        _min_confidence_value = MIN_CONFIDENCE_DEFAULT;
+        _print_black_and_white = false;
+        _print_using_actual_size = true;
+        _graphics_export_using_actual_size = true;
+        _phylogeny_graphics_type = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR;
+        _base_font = new Font( Configuration.getDefaultFontFamilyName(), Font.PLAIN, 10 );
+        _match_whole_terms_only = false;
+        _search_with_regex = false;
+        _search_case_sensitive = false;
+        _print_line_width = Constants.PDF_LINE_WIDTH_DEFAULT;
+        _show_overview = true;
+        _ov_placement = OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT;
+        _node_label_direction = NODE_LABEL_DIRECTION.HORIZONTAL;
+        _inverse_search_result = false;
+        _scale_bar_length = 0.0;
+        _number_of_digits_after_comma_for_branch_length_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_BRANCH_LENGTH_VALUES_DEFAULT;
+        _number_of_digits_after_comma_for_confidence_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_CONFIDENCE_VALUES_DEFAULT;
+        _nh_parsing_replace_underscores = false;
+        _taxonomy_extraction = TAXONOMY_EXTRACTION.NO;
+        _cladogram_type = Constants.CLADOGRAM_TYPE_DEFAULT;
+        _show_domain_labels = true;
+        _show_annotation_ref_source = true;
+        setAbbreviateScientificTaxonNames( false );
+        _color_labels_same_as_parent_branch = false;
+        _show_confidence_stddev = false;
+        _nh_conversion_support_value_style = NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE;
+        _ext_desc_data_to_return = NodeDataField.UNKNOWN;
+        _line_up_renderable_node_data = true;
+        _right_align_domains = false;
+    }
+
+    final private void setNumberOfDigitsAfterCommaForBranchLength( final short number_of_digits_after_comma_for_branch_length_values ) {
+        _number_of_digits_after_comma_for_branch_length_values = number_of_digits_after_comma_for_branch_length_values;
+    }
+
+    final private void setNumberOfDigitsAfterCommaForConfidenceValues( final short number_of_digits_after_comma_for_confidence_values ) {
+        _number_of_digits_after_comma_for_confidence_values = number_of_digits_after_comma_for_confidence_values;
+    }
+
     final Font getBaseFont() {
         return _base_font;
     }
@@ -252,10 +362,6 @@ final public class Options {
         return _match_whole_terms_only;
     }
 
-    final boolean isSearchWithRegex() {
-        return _search_with_regex;
-    }
-
     final boolean isPrintBlackAndWhite() {
         return _print_black_and_white;
     }
@@ -272,6 +378,10 @@ final public class Options {
         return _search_case_sensitive;
     }
 
+    final boolean isSearchWithRegex() {
+        return _search_with_regex;
+    }
+
     boolean isShowConfidenceStddev() {
         return _show_confidence_stddev;
     }
@@ -362,10 +472,6 @@ final public class Options {
         _match_whole_terms_only = search_whole_words_only;
     }
 
-    final void setSearchWithRegex( final boolean search_with_regex ) {
-        _search_with_regex = search_with_regex;
-    }
-
     final void setMinConfidenceValue( final double min_confidence_value ) {
         _min_confidence_value = min_confidence_value;
     }
@@ -418,6 +524,10 @@ final public class Options {
         _search_case_sensitive = search_case_sensitive;
     }
 
+    final void setSearchWithRegex( final boolean search_with_regex ) {
+        _search_with_regex = search_with_regex;
+    }
+
     void setShowConfidenceStddev( final boolean show_confidence_stddev ) {
         _show_confidence_stddev = show_confidence_stddev;
     }
@@ -426,14 +536,14 @@ final public class Options {
         _show_default_node_shapes_external = show_default_node_shapes_external;
     }
 
-    void setShowDefaultNodeShapesInternal( final boolean show_default_node_shapes_internal ) {
-        _show_default_node_shapes_internal = show_default_node_shapes_internal;
-    }
-
     void setShowDefaultNodeShapesForMarkedNodes( final boolean show_default_node_shapes_for_marked_nodes ) {
         _show_default_node_shapes_for_marked_nodes = show_default_node_shapes_for_marked_nodes;
     }
 
+    void setShowDefaultNodeShapesInternal( final boolean show_default_node_shapes_internal ) {
+        _show_default_node_shapes_internal = show_default_node_shapes_internal;
+    }
+
     final void setShowOverview( final boolean show_overview ) {
         _show_overview = show_overview;
     }
@@ -446,67 +556,6 @@ final public class Options {
         _taxonomy_extraction = taxonomy_extraction;
     }
 
-    final private void init() {
-        _default_node_shape = NodeShape.CIRCLE;
-        _default_node_fill = NodeFill.GRADIENT;
-        _default_node_shape_size = Constants.DEFAULT_NODE_SHAPE_SIZE_DEFAULT;
-        _internal_number_are_confidence_for_nh_parsing = false;
-        _show_scale = false;
-        _antialias_screen = true;
-        _antialias_print = true;
-        _graphics_export_visible_only = false;
-        _editable = true;
-        _background_color_gradient = false;
-        _show_default_node_shapes_internal = false;
-        _show_default_node_shapes_external = false;
-        _show_default_node_shapes_for_marked_nodes = false;
-        if ( AptxUtil.isUsOrCanada() ) {
-            _print_size_x = Constants.US_LETTER_SIZE_X;
-            _print_size_y = Constants.US_LETTER_SIZE_Y;
-        }
-        else {
-            _print_size_x = Constants.A4_SIZE_X;
-            _print_size_y = Constants.A4_SIZE_Y;
-        }
-        _min_confidence_value = MIN_CONFIDENCE_DEFAULT;
-        _print_black_and_white = false;
-        _print_using_actual_size = true;
-        _graphics_export_using_actual_size = true;
-        _phylogeny_graphics_type = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR;
-        _base_font = new Font( Configuration.getDefaultFontFamilyName(), Font.PLAIN, 10 );
-        _match_whole_terms_only = false;
-        _search_with_regex = false;
-        _search_case_sensitive = false;
-        _print_line_width = Constants.PDF_LINE_WIDTH_DEFAULT;
-        _show_overview = true;
-        _ov_placement = OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT;
-        _node_label_direction = NODE_LABEL_DIRECTION.HORIZONTAL;
-        _inverse_search_result = false;
-        _scale_bar_length = 0.0;
-        _number_of_digits_after_comma_for_branch_length_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_BRANCH_LENGTH_VALUES_DEFAULT;
-        _number_of_digits_after_comma_for_confidence_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_CONFIDENCE_VALUES_DEFAULT;
-        _nh_parsing_replace_underscores = false;
-        _taxonomy_extraction = TAXONOMY_EXTRACTION.NO;
-        _cladogram_type = Constants.CLADOGRAM_TYPE_DEFAULT;
-        _show_domain_labels = true;
-        _show_annotation_ref_source = true;
-        setAbbreviateScientificTaxonNames( false );
-        _color_labels_same_as_parent_branch = false;
-        _show_confidence_stddev = false;
-        _nh_conversion_support_value_style = NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE;
-        _ext_desc_data_to_return = NodeDataField.UNKNOWN;
-        _line_up_renderable_node_data = true;
-        _right_align_domains = false;
-    }
-
-    final private void setNumberOfDigitsAfterCommaForBranchLength( final short number_of_digits_after_comma_for_branch_length_values ) {
-        _number_of_digits_after_comma_for_branch_length_values = number_of_digits_after_comma_for_branch_length_values;
-    }
-
-    final private void setNumberOfDigitsAfterCommaForConfidenceValues( final short number_of_digits_after_comma_for_confidence_values ) {
-        _number_of_digits_after_comma_for_confidence_values = number_of_digits_after_comma_for_confidence_values;
-    }
-
     public final static Options createInstance( final Configuration configuration ) {
         final Options instance = createDefaultInstance();
         if ( configuration != null ) {
@@ -521,16 +570,16 @@ final public class Options {
             instance.setBackgroundColorGradient( configuration.isBackgroundColorGradient() );
             if ( configuration.getNumberOfDigitsAfterCommaForBranchLengthValues() >= 0 ) {
                 instance.setNumberOfDigitsAfterCommaForBranchLength( configuration
-                        .getNumberOfDigitsAfterCommaForBranchLengthValues() );
+                                                                     .getNumberOfDigitsAfterCommaForBranchLengthValues() );
             }
             if ( configuration.getNumberOfDigitsAfterCommaForConfidenceValues() >= 0 ) {
                 instance.setNumberOfDigitsAfterCommaForConfidenceValues( configuration
-                        .getNumberOfDigitsAfterCommaForConfidenceValues() );
+                                                                         .getNumberOfDigitsAfterCommaForConfidenceValues() );
             }
             instance.setTaxonomyExtraction( configuration.getTaxonomyExtraction() );
             instance.setReplaceUnderscoresInNhParsing( configuration.isReplaceUnderscoresInNhParsing() );
             instance.setInternalNumberAreConfidenceForNhParsing( configuration
-                    .isInternalNumberAreConfidenceForNhParsing() );
+                                                                 .isInternalNumberAreConfidenceForNhParsing() );
             instance.setEditable( configuration.isEditable() );
             instance.setColorLabelsSameAsParentBranch( configuration.isColorLabelsSameAsParentBranch() );
             instance.setShowDomainLabels( configuration.isShowDomainLabels() );
@@ -550,7 +599,7 @@ final public class Options {
             }
             if ( !ForesterUtil.isEmpty( configuration.getBaseFontFamilyName() ) ) {
                 instance.setBaseFont( new Font( configuration.getBaseFontFamilyName(), Font.PLAIN, instance
-                        .getBaseFont().getSize() ) );
+                                                .getBaseFont().getSize() ) );
             }
             if ( configuration.getPhylogenyGraphicsType() != null ) {
                 instance.setPhylogenyGraphicsType( configuration.getPhylogenyGraphicsType() );
@@ -580,54 +629,4 @@ final public class Options {
     final static Options createDefaultInstance() {
         return new Options();
     }
-
-    public static enum CLADOGRAM_TYPE {
-        EXT_NODE_SUM_DEP, NON_LINED_UP, TOTAL_NODE_SUM_DEP;
-    }
-
-    public static enum NODE_LABEL_DIRECTION {
-        HORIZONTAL, RADIAL;
-    }
-
-    public static enum PHYLOGENY_GRAPHICS_TYPE {
-        CIRCULAR, CONVEX, CURVED, EURO_STYLE, RECTANGULAR, ROUNDED, TRIANGULAR, UNROOTED;
-    }
-
-    static enum OVERVIEW_PLACEMENT_TYPE {
-        LOWER_LEFT( "lower left" ),
-        LOWER_RIGHT( "lower right" ),
-        UPPER_LEFT( "upper left" ),
-        UPPER_RIGHT( "upper right" );
-
-        private final String _name;
-
-        private OVERVIEW_PLACEMENT_TYPE( final String name ) {
-            _name = name;
-        }
-
-        @Override
-        public String toString() {
-            return _name;
-        }
-
-        public String toTag() {
-            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 9a422d3..21f20d3 100644 (file)
@@ -45,11 +45,11 @@ import com.itextpdf.text.pdf.PdfContentByte;
 import com.itextpdf.text.pdf.PdfWriter;
 
 /*
- * 
+ *
  * This uses iText.
- * 
+ *
  * See: http://www.lowagie.com/iText/
- * 
+ *
  * Current version: iText-2.1.7
  */
 final class PdfExporter {
index 8f99054..b2a35ea 100644 (file)
@@ -42,7 +42,6 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
-import java.security.acl.Permission;
 import java.util.LinkedList;
 
 import javax.swing.JButton;
@@ -139,17 +138,8 @@ final class TextFrame extends JFrame implements ActionListener, ClipboardOwner {
         }
     }
 
-    void close() {
-        setVisible( false );
-        dispose();
-    }
-
-    void removeMe() {
-        final int i = _tframes.indexOf( this );
-        if ( i >= 0 ) {
-            _tframes.remove( i );
-        }
-        close();
+    @Override
+    public void lostOwnership( final Clipboard clipboard, final Transferable contents ) {
     }
 
     private void copy() {
@@ -162,8 +152,17 @@ final class TextFrame extends JFrame implements ActionListener, ClipboardOwner {
         sys_clipboard.setContents( contents, this );
     }
 
-    @Override
-    public void lostOwnership( final Clipboard clipboard, final Transferable contents ) {
+    void close() {
+        setVisible( false );
+        dispose();
+    }
+
+    void removeMe() {
+        final int i = _tframes.indexOf( this );
+        if ( i >= 0 ) {
+            _tframes.remove( i );
+        }
+        close();
     }
 
     static TextFrame instantiate( final String s, final String title, final LinkedList<TextFrame> tframes ) {
index 4dcf9f1..c83d135 100644 (file)
@@ -54,233 +54,233 @@ public final class TreeColorSet {
     public static final String SPECIATION                 = "Speciation";
     public static final String TAXONOMY                   = "Taxonomy";
     static final String[]      COLOR_FIELDS               = { BACKGROUND, BACKGROUND_GRADIENT_BOTTOM, SEQUENCE,
-            TAXONOMY, CONFIDENCE, BRANCH_LENGTH, BRANCH, NODE_BOX, COLLAPSED, MATCHING_NODES_A, MATCHING_NODES_B,
-            MATCHING_NODES_A_AND_B, DUPLICATION, SPECIATION, DUPLICATION_OR_SPECATION, DOMAIN_LABEL, DOMAIN_BASE,
-            BINARY_DOMAIN_COMBINATIONS, ANNOTATION, OVERVIEW };
+        TAXONOMY, CONFIDENCE, BRANCH_LENGTH, BRANCH, NODE_BOX, COLLAPSED, MATCHING_NODES_A, MATCHING_NODES_B,
+        MATCHING_NODES_A_AND_B, DUPLICATION, SPECIATION, DUPLICATION_OR_SPECATION, DOMAIN_LABEL, DOMAIN_BASE,
+        BINARY_DOMAIN_COMBINATIONS, ANNOTATION, OVERVIEW };
     static final String[]      SCHEME_NAMES               = { "Default", "Black", "Black & White", "Silver", "Green",
-            "White & Blue", "Cyan", "Orange", "Blue", "Blue & White", "Neon" };
+        "White & Blue", "Cyan", "Orange", "Blue", "Blue & White", "Neon" };
     private int                _color_scheme;
     private final Color[][]    _color_schemes             = { { new Color( 0, 0, 0 ), // background_color
-            new Color( 0, 100, 100 ), // background_color_gradient_bottom
-            new Color( 230, 230, 230 ), // sequence  __ Default (same as Black)
-            new Color( 180, 180, 180 ), // taxonomy
-            new Color( 180, 180, 180 ), // support
-            new Color( 140, 140, 140 ), // branch_length_color
-            new Color( 255, 255, 255 ), // branch_color
-            new Color( 255, 255, 255 ), // box_color
-            new Color( 255, 255, 255 ), // collapesed_fill_color
-            new Color( 0, 255, 0 ), // found_color 0
-            new Color( 255, 0, 0 ), // found_color 1
-            new Color( 255, 255, 0 ), // found_color 1 + 2
-            new Color( 255, 0, 0 ), // duplication_box_color
-            new Color( 0, 255, 0 ), // speciation_box_color
-            new Color( 255, 255, 0 ), // duplication_speciation_color
-            new Color( 230, 230, 230 ), // domain_label
-            new Color( 100, 100, 100 ), // domains_base
-            new Color( 65, 105, 255 ), // binary_domain_combinations_color
-            new Color( 173, 255, 47 ) // annotation
-            , new Color( 130, 130, 130 )                 // overview
-            }, { new Color( 0, 0, 0 ), // background_color
-            new Color( 0, 255, 255 ), // background_color_gradient_bottom
-            new Color( 230, 230, 230 ), // sequence  __ Black
-            new Color( 180, 180, 180 ), // taxonomy
-            new Color( 180, 180, 180 ), // support
-            new Color( 140, 140, 140 ), // branch_length_color
-            new Color( 255, 255, 255 ), // branch_color
-            new Color( 255, 255, 255 ), // box_color
-            new Color( 255, 255, 255 ), // collapesed_fill_color
-            new Color( 0, 255, 0 ), // found_color 0
-            new Color( 255, 0, 0 ), // found_color 1
-            new Color( 255, 255, 0 ), // found_color 1 + 2
-            new Color( 255, 0, 0 ), // duplication_box_color
-            new Color( 0, 255, 0 ), // speciation_box_color
-            new Color( 255, 255, 0 ), // duplication_speciation_color
-            new Color( 230, 230, 230 ), // domain_label
-            new Color( 100, 100, 100 ), // domains_base
-            new Color( 65, 105, 255 ), // binary_domain_combinations_color
-            new Color( 173, 255, 47 ) // annotation
-            , new Color( 130, 130, 130 ) // ov
-            }, { new Color( 255, 255, 255 ), // background_color
-            new Color( 0, 255, 255 ), // background_color_gradient_bottom
-            new Color( 0, 0, 0 ), // sequence  __ Black & White
-            new Color( 0, 0, 0 ), // taxonomy
-            new Color( 0, 0, 0 ), // support
-            new Color( 0, 0, 0 ), // branch_length_color
-            new Color( 0, 0, 0 ), // branch_color
-            new Color( 0, 0, 0 ), // box_color
-            new Color( 0, 0, 0 ), // collapesed_fill_color
-            new Color( 255, 0, 0 ), // found_color 0
-            new Color( 0, 255, 0 ), // found_color 1
-            new Color( 0, 0, 255 ), // found_color 1 + 2
-            new Color( 255, 0, 0 ), // duplication_box_color
-            new Color( 0, 255, 0 ), // speciation_box_color
-            new Color( 255, 255, 0 ), // duplication_speciation_color
-            new Color( 0, 0, 0 ), // domain_label
-            new Color( 100, 100, 100 ), // domains_base
-            new Color( 0, 0, 0 ), // binary_domain_combinations_color
-            new Color( 0, 0, 0 ) // annotation
-            , new Color( 220, 220, 220 ) // ov
-            }, { new Color( 0, 0, 0 ), // background_color
-            new Color( 0, 255, 255 ), // background_color_gradient_bottom
-            new Color( 220, 220, 220 ), // sequence __ Silver
-            new Color( 180, 180, 180 ), // taxonomy
-            new Color( 140, 140, 140 ), // support
-            new Color( 140, 140, 140 ), // branch_length_color
-            new Color( 240, 240, 240 ), // branch_color
-            new Color( 140, 140, 140 ), // box_color
-            new Color( 240, 240, 240 ), // collapesed_fill_color
-            new Color( 255, 0, 0 ), // found_color 0
-            new Color( 0, 255, 0 ), // found_color 1
-            new Color( 255, 255, 0 ), // found_color 1 + 2
-            new Color( 255, 0, 0 ), // duplication_box_color
-            new Color( 0, 255, 0 ), // speciation_box_color
-            new Color( 255, 255, 0 ), // duplication_speciation_color
-            new Color( 230, 230, 230 ), // domain_label
-            new Color( 100, 100, 100 ), // domains_base
-            new Color( 180, 180, 180 ), // binary_domain_combinations_color
-            new Color( 140, 140, 140 ) // annotation
-            , new Color( 40, 40, 40 ) // ov
-            }, { new Color( 0, 10, 0 ), // background_color
-            new Color( 0, 255, 255 ), // background_color_gradient_bottom
-            new Color( 0, 255, 0 ), // sequence __ the Matrix
-            new Color( 30, 200, 30 ), // taxonomy
-            new Color( 0, 155, 0 ), // support
-            new Color( 0, 100, 0 ), // branch_length_color
-            new Color( 0, 155, 0 ), // branch_color
-            new Color( 0, 255, 0 ), // box_color
-            new Color( 0, 155, 0 ), // collapesed_fill_color
-            new Color( 255, 0, 0 ), // found_color 0
-            new Color( 0, 255, 0 ), // found_color 1
-            new Color( 255, 255, 0 ), // found_color 1 + 2
-            new Color( 255, 0, 0 ), // duplication_box_color
-            new Color( 0, 255, 0 ), // speciation_box_color
-            new Color( 255, 255, 0 ), // duplication_speciation_color
-            new Color( 230, 230, 230 ), // domain_label
-            new Color( 100, 100, 100 ), // domains_base
-            new Color( 0, 235, 0 ), // binary_domain_combinations_color
-            new Color( 0, 235, 0 ) // annotation
-            , new Color( 40, 40, 40 ) // ov
-            }, { new Color( 255, 255, 255 ), // background_color
-            new Color( 0, 255, 255 ), // background_color_gradient_bottom
-            new Color( 0, 0, 0 ), //sequence __ White & Blue
-            new Color( 40, 40, 40 ), // taxonomy
-            new Color( 0, 125, 0 ), // support
-            new Color( 70, 70, 0 ), // branch_length_color
-            new Color( 0, 20, 200 ), // branch_color
-            new Color( 0, 20, 200 ), // box_color
-            new Color( 0, 20, 200 ), // collapesed_fill_color
-            new Color( 0, 255, 0 ), // found_color 0
-            new Color( 255, 0, 0 ), // found_color 1
-            new Color( 0, 0, 255 ), // found_color 0 + 1
-            new Color( 255, 0, 0 ), // duplication_box_color
-            new Color( 0, 255, 0 ), // speciation_box_color
-            new Color( 255, 255, 0 ), // duplication_speciation_color
-            new Color( 0, 0, 0 ), // domain_label
-            new Color( 50, 50, 50 ), // domains_base
-            new Color( 65, 105, 225 ), // binary_domain_combinations_color
-            new Color( 173, 255, 47 ) // annotation
-            , new Color( 220, 220, 220 ) // ov
-            }, { new Color( 0, 0, 0 ), // background_color
-            new Color( 0, 255, 255 ), // background_color_gradient_bottom
-            new Color( 255, 255, 255 ), // sequence __ Cyan
-            new Color( 200, 200, 200 ), // taxonomy
-            new Color( 255, 255, 255 ), // support
-            new Color( 200, 200, 200 ), // branch_length_color
-            new Color( 0, 255, 255 ), // branch_color
-            new Color( 0, 255, 255 ), // box_color
-            new Color( 0, 255, 255 ), // collapesed_fill_color
-            new Color( 0, 255, 0 ), // found_color 0
-            new Color( 0, 0, 255 ), // found_color 1
-            new Color( 0, 255, 255 ), // found_color 0 + 1
-            new Color( 255, 0, 0 ), // duplication_box_color
-            new Color( 0, 255, 0 ), // speciation_box_color
-            new Color( 255, 255, 0 ), // duplication_speciation_color
-            new Color( 230, 230, 230 ), // domain_label
-            new Color( 100, 100, 100 ), // domains_base
-            new Color( 65, 105, 225 ), // binary_domain_combinations_color
-            new Color( 173, 255, 47 ) // annotation
-            , new Color( 0, 120, 120 ) // ov
-            }, { new Color( 0, 0, 0 ), // background_color
-            new Color( 0, 255, 255 ), // background_color_gradient_bottom
-            new Color( 255, 200, 0 ), // sequence __ Clockwork
-            new Color( 255, 200, 0 ), // taxonomy
-            new Color( 255, 200, 0 ), // support
-            new Color( 255, 200, 0 ), // branch_length_color
-            new Color( 255, 200, 0 ), // branch_color
-            new Color( 255, 200, 0 ), // box_color
-            new Color( 255, 200, 0 ), // collapesed_fill_color
-            new Color( 255, 255, 0 ), // found_color 0
-            new Color( 0, 255, 255 ), // found_color 1
-            new Color( 255, 255, 255 ), // found_color 0 + 1
-            new Color( 255, 0, 0 ), // duplication_box_color
-            new Color( 0, 255, 0 ), // speciation_box_color
-            new Color( 255, 255, 0 ), // duplication_speciation_color
-            new Color( 255, 200, 0 ), // domain_label
-            new Color( 255, 200, 0 ), // domains_base
-            new Color( 150, 150, 150 ), // binary_domain_combinations_color
-            new Color( 150, 150, 150 ) // annotation
-            , new Color( 150, 150, 150 ) // ov
-            }, { new Color( 0, 0, 100 ), // background_color
-            new Color( 0, 255, 255 ), // background_color_gradient_bottom
-            new Color( 255, 255, 255 ), // sequence __ Blue
-            new Color( 255, 255, 255 ), // taxonomy
-            new Color( 255, 0, 0 ), // support
-            new Color( 255, 0, 0 ), // branch_length_color
-            new Color( 255, 0, 0 ), // branch_color
-            new Color( 255, 0, 0 ), // box_color
-            new Color( 255, 0, 0 ), // collapesed_fill_color
-            new Color( 0, 255, 0 ), // found_color
-            new Color( 255, 0, 0 ), // found_color 1
-            new Color( 255, 255, 0 ), // found_color 1 + 2
-            new Color( 255, 0, 0 ), // duplication_box_color
-            new Color( 0, 255, 0 ), // speciation_box_color
-            new Color( 255, 255, 0 ), // duplication_speciation_color
-            new Color( 255, 255, 255 ), // domain_label
-            new Color( 100, 100, 100 ), // domains_base
-            new Color( 255, 255, 255 ), // binary_domain_combinations_color
-            new Color( 255, 255, 255 ) // annotation
-            , new Color( 77, 77, 255 ) // ov
-            }, { new Color( 0, 0, 0 ), // background_color
-            new Color( 0, 255, 255 ), // background_color_gradient_bottom
-            new Color( 255, 255, 255 ), // sequence __ blue &  white
-            new Color( 255, 255, 255 ), // taxonomy
-            new Color( 255, 255, 255 ), // support
-            new Color( 0, 191, 255 ), // branch_length_color
-            new Color( 0, 191, 255 ), // branch_color
-            new Color( 0, 191, 255 ), // box_color
-            new Color( 0, 191, 255 ), // collapesed_fill_color
-            new Color( 255, 0, 0 ), // found_color 0
-            new Color( 0, 255, 0 ), // found_color 1
-            new Color( 255, 255, 0 ), // found_color 0 + 1
-            new Color( 255, 0, 0 ), // duplication_box_color
-            new Color( 0, 255, 0 ), // speciation_box_color
-            new Color( 255, 255, 0 ), // duplication_speciation_color
-            new Color( 255, 255, 255 ), // domain_label
-            new Color( 150, 150, 150 ), // domains_base
-            new Color( 255, 255, 255 ), // binary_domain_combinations_color
-            new Color( 255, 255, 255 ) // annotation
-            , new Color( 170, 187, 204 ) // ov
-            }, { new Color( 0, 0, 0 ), // background_color
-            new Color( 255, 255, 0 ), // background_color_gradient_bottom
-            new Color( 127, 255, 0 ), // sequence __ Neon
-            new Color( 255, 110, 199 ), // taxonomy
-            new Color( 234, 173, 234 ), // support
-            new Color( 77, 77, 255 ), // branch_length_color
-            new Color( 234, 173, 234 ), // branch_color
-            new Color( 77, 77, 255 ), // box_color
-            new Color( 234, 173, 234 ), // collapsed_fill_color
-            new Color( 243, 243, 21 ), // found_color 0
-            new Color( 255, 20, 147 ), // found_color 1
-            new Color( 255, 255, 255 ), // found_color 1 + 2
-            new Color( 255, 0, 0 ), // duplication_box_color
-            new Color( 0, 255, 0 ), // speciation_box_color
-            new Color( 255, 255, 0 ), // duplication_speciation_color
-            new Color( 127, 255, 0 ), // domain_label
-            new Color( 234, 173, 234 ), // domains_base
-            new Color( 27, 255, 0 ), // binary_domain_combinations_color
-            new Color( 27, 255, 0 ) // annotation
-            , new Color( 77, 77, 255 ) // ov
-            }                                            };
+        new Color( 0, 100, 100 ), // background_color_gradient_bottom
+        new Color( 230, 230, 230 ), // sequence  __ Default (same as Black)
+        new Color( 180, 180, 180 ), // taxonomy
+        new Color( 180, 180, 180 ), // support
+        new Color( 140, 140, 140 ), // branch_length_color
+        new Color( 255, 255, 255 ), // branch_color
+        new Color( 255, 255, 255 ), // box_color
+        new Color( 255, 255, 255 ), // collapesed_fill_color
+        new Color( 0, 255, 0 ), // found_color 0
+        new Color( 255, 0, 0 ), // found_color 1
+        new Color( 255, 255, 0 ), // found_color 1 + 2
+        new Color( 255, 0, 0 ), // duplication_box_color
+        new Color( 0, 255, 0 ), // speciation_box_color
+        new Color( 255, 255, 0 ), // duplication_speciation_color
+        new Color( 230, 230, 230 ), // domain_label
+        new Color( 100, 100, 100 ), // domains_base
+        new Color( 65, 105, 255 ), // binary_domain_combinations_color
+        new Color( 173, 255, 47 ) // annotation
+    , new Color( 130, 130, 130 )                 // overview
+    }, { new Color( 0, 0, 0 ), // background_color
+        new Color( 0, 255, 255 ), // background_color_gradient_bottom
+        new Color( 230, 230, 230 ), // sequence  __ Black
+        new Color( 180, 180, 180 ), // taxonomy
+        new Color( 180, 180, 180 ), // support
+        new Color( 140, 140, 140 ), // branch_length_color
+        new Color( 255, 255, 255 ), // branch_color
+        new Color( 255, 255, 255 ), // box_color
+        new Color( 255, 255, 255 ), // collapesed_fill_color
+        new Color( 0, 255, 0 ), // found_color 0
+        new Color( 255, 0, 0 ), // found_color 1
+        new Color( 255, 255, 0 ), // found_color 1 + 2
+        new Color( 255, 0, 0 ), // duplication_box_color
+        new Color( 0, 255, 0 ), // speciation_box_color
+        new Color( 255, 255, 0 ), // duplication_speciation_color
+        new Color( 230, 230, 230 ), // domain_label
+        new Color( 100, 100, 100 ), // domains_base
+        new Color( 65, 105, 255 ), // binary_domain_combinations_color
+        new Color( 173, 255, 47 ) // annotation
+    , new Color( 130, 130, 130 ) // ov
+    }, { new Color( 255, 255, 255 ), // background_color
+        new Color( 0, 255, 255 ), // background_color_gradient_bottom
+        new Color( 0, 0, 0 ), // sequence  __ Black & White
+        new Color( 0, 0, 0 ), // taxonomy
+        new Color( 0, 0, 0 ), // support
+        new Color( 0, 0, 0 ), // branch_length_color
+        new Color( 0, 0, 0 ), // branch_color
+        new Color( 0, 0, 0 ), // box_color
+        new Color( 0, 0, 0 ), // collapesed_fill_color
+        new Color( 255, 0, 0 ), // found_color 0
+        new Color( 0, 255, 0 ), // found_color 1
+        new Color( 0, 0, 255 ), // found_color 1 + 2
+        new Color( 255, 0, 0 ), // duplication_box_color
+        new Color( 0, 255, 0 ), // speciation_box_color
+        new Color( 255, 255, 0 ), // duplication_speciation_color
+        new Color( 0, 0, 0 ), // domain_label
+        new Color( 100, 100, 100 ), // domains_base
+        new Color( 0, 0, 0 ), // binary_domain_combinations_color
+        new Color( 0, 0, 0 ) // annotation
+    , new Color( 220, 220, 220 ) // ov
+    }, { new Color( 0, 0, 0 ), // background_color
+        new Color( 0, 255, 255 ), // background_color_gradient_bottom
+        new Color( 220, 220, 220 ), // sequence __ Silver
+        new Color( 180, 180, 180 ), // taxonomy
+        new Color( 140, 140, 140 ), // support
+        new Color( 140, 140, 140 ), // branch_length_color
+        new Color( 240, 240, 240 ), // branch_color
+        new Color( 140, 140, 140 ), // box_color
+        new Color( 240, 240, 240 ), // collapesed_fill_color
+        new Color( 255, 0, 0 ), // found_color 0
+        new Color( 0, 255, 0 ), // found_color 1
+        new Color( 255, 255, 0 ), // found_color 1 + 2
+        new Color( 255, 0, 0 ), // duplication_box_color
+        new Color( 0, 255, 0 ), // speciation_box_color
+        new Color( 255, 255, 0 ), // duplication_speciation_color
+        new Color( 230, 230, 230 ), // domain_label
+        new Color( 100, 100, 100 ), // domains_base
+        new Color( 180, 180, 180 ), // binary_domain_combinations_color
+        new Color( 140, 140, 140 ) // annotation
+    , new Color( 40, 40, 40 ) // ov
+    }, { new Color( 0, 10, 0 ), // background_color
+        new Color( 0, 255, 255 ), // background_color_gradient_bottom
+        new Color( 0, 255, 0 ), // sequence __ the Matrix
+        new Color( 30, 200, 30 ), // taxonomy
+        new Color( 0, 155, 0 ), // support
+        new Color( 0, 100, 0 ), // branch_length_color
+        new Color( 0, 155, 0 ), // branch_color
+        new Color( 0, 255, 0 ), // box_color
+        new Color( 0, 155, 0 ), // collapesed_fill_color
+        new Color( 255, 0, 0 ), // found_color 0
+        new Color( 0, 255, 0 ), // found_color 1
+        new Color( 255, 255, 0 ), // found_color 1 + 2
+        new Color( 255, 0, 0 ), // duplication_box_color
+        new Color( 0, 255, 0 ), // speciation_box_color
+        new Color( 255, 255, 0 ), // duplication_speciation_color
+        new Color( 230, 230, 230 ), // domain_label
+        new Color( 100, 100, 100 ), // domains_base
+        new Color( 0, 235, 0 ), // binary_domain_combinations_color
+        new Color( 0, 235, 0 ) // annotation
+    , new Color( 40, 40, 40 ) // ov
+    }, { new Color( 255, 255, 255 ), // background_color
+        new Color( 0, 255, 255 ), // background_color_gradient_bottom
+        new Color( 0, 0, 0 ), //sequence __ White & Blue
+        new Color( 40, 40, 40 ), // taxonomy
+        new Color( 0, 125, 0 ), // support
+        new Color( 70, 70, 0 ), // branch_length_color
+        new Color( 0, 20, 200 ), // branch_color
+        new Color( 0, 20, 200 ), // box_color
+        new Color( 0, 20, 200 ), // collapesed_fill_color
+        new Color( 0, 255, 0 ), // found_color 0
+        new Color( 255, 0, 0 ), // found_color 1
+        new Color( 0, 0, 255 ), // found_color 0 + 1
+        new Color( 255, 0, 0 ), // duplication_box_color
+        new Color( 0, 255, 0 ), // speciation_box_color
+        new Color( 255, 255, 0 ), // duplication_speciation_color
+        new Color( 0, 0, 0 ), // domain_label
+        new Color( 50, 50, 50 ), // domains_base
+        new Color( 65, 105, 225 ), // binary_domain_combinations_color
+        new Color( 173, 255, 47 ) // annotation
+    , new Color( 220, 220, 220 ) // ov
+    }, { new Color( 0, 0, 0 ), // background_color
+        new Color( 0, 255, 255 ), // background_color_gradient_bottom
+        new Color( 255, 255, 255 ), // sequence __ Cyan
+        new Color( 200, 200, 200 ), // taxonomy
+        new Color( 255, 255, 255 ), // support
+        new Color( 200, 200, 200 ), // branch_length_color
+        new Color( 0, 255, 255 ), // branch_color
+        new Color( 0, 255, 255 ), // box_color
+        new Color( 0, 255, 255 ), // collapesed_fill_color
+        new Color( 0, 255, 0 ), // found_color 0
+        new Color( 0, 0, 255 ), // found_color 1
+        new Color( 0, 255, 255 ), // found_color 0 + 1
+        new Color( 255, 0, 0 ), // duplication_box_color
+        new Color( 0, 255, 0 ), // speciation_box_color
+        new Color( 255, 255, 0 ), // duplication_speciation_color
+        new Color( 230, 230, 230 ), // domain_label
+        new Color( 100, 100, 100 ), // domains_base
+        new Color( 65, 105, 225 ), // binary_domain_combinations_color
+        new Color( 173, 255, 47 ) // annotation
+    , new Color( 0, 120, 120 ) // ov
+    }, { new Color( 0, 0, 0 ), // background_color
+        new Color( 0, 255, 255 ), // background_color_gradient_bottom
+        new Color( 255, 200, 0 ), // sequence __ Clockwork
+        new Color( 255, 200, 0 ), // taxonomy
+        new Color( 255, 200, 0 ), // support
+        new Color( 255, 200, 0 ), // branch_length_color
+        new Color( 255, 200, 0 ), // branch_color
+        new Color( 255, 200, 0 ), // box_color
+        new Color( 255, 200, 0 ), // collapesed_fill_color
+        new Color( 255, 255, 0 ), // found_color 0
+        new Color( 0, 255, 255 ), // found_color 1
+        new Color( 255, 255, 255 ), // found_color 0 + 1
+        new Color( 255, 0, 0 ), // duplication_box_color
+        new Color( 0, 255, 0 ), // speciation_box_color
+        new Color( 255, 255, 0 ), // duplication_speciation_color
+        new Color( 255, 200, 0 ), // domain_label
+        new Color( 255, 200, 0 ), // domains_base
+        new Color( 150, 150, 150 ), // binary_domain_combinations_color
+        new Color( 150, 150, 150 ) // annotation
+    , new Color( 150, 150, 150 ) // ov
+    }, { new Color( 0, 0, 100 ), // background_color
+        new Color( 0, 255, 255 ), // background_color_gradient_bottom
+        new Color( 255, 255, 255 ), // sequence __ Blue
+        new Color( 255, 255, 255 ), // taxonomy
+        new Color( 255, 0, 0 ), // support
+        new Color( 255, 0, 0 ), // branch_length_color
+        new Color( 255, 0, 0 ), // branch_color
+        new Color( 255, 0, 0 ), // box_color
+        new Color( 255, 0, 0 ), // collapesed_fill_color
+        new Color( 0, 255, 0 ), // found_color
+        new Color( 255, 0, 0 ), // found_color 1
+        new Color( 255, 255, 0 ), // found_color 1 + 2
+        new Color( 255, 0, 0 ), // duplication_box_color
+        new Color( 0, 255, 0 ), // speciation_box_color
+        new Color( 255, 255, 0 ), // duplication_speciation_color
+        new Color( 255, 255, 255 ), // domain_label
+        new Color( 100, 100, 100 ), // domains_base
+        new Color( 255, 255, 255 ), // binary_domain_combinations_color
+        new Color( 255, 255, 255 ) // annotation
+    , new Color( 77, 77, 255 ) // ov
+    }, { new Color( 0, 0, 0 ), // background_color
+        new Color( 0, 255, 255 ), // background_color_gradient_bottom
+        new Color( 255, 255, 255 ), // sequence __ blue &  white
+        new Color( 255, 255, 255 ), // taxonomy
+        new Color( 255, 255, 255 ), // support
+        new Color( 0, 191, 255 ), // branch_length_color
+        new Color( 0, 191, 255 ), // branch_color
+        new Color( 0, 191, 255 ), // box_color
+        new Color( 0, 191, 255 ), // collapesed_fill_color
+        new Color( 255, 0, 0 ), // found_color 0
+        new Color( 0, 255, 0 ), // found_color 1
+        new Color( 255, 255, 0 ), // found_color 0 + 1
+        new Color( 255, 0, 0 ), // duplication_box_color
+        new Color( 0, 255, 0 ), // speciation_box_color
+        new Color( 255, 255, 0 ), // duplication_speciation_color
+        new Color( 255, 255, 255 ), // domain_label
+        new Color( 150, 150, 150 ), // domains_base
+        new Color( 255, 255, 255 ), // binary_domain_combinations_color
+        new Color( 255, 255, 255 ) // annotation
+    , new Color( 170, 187, 204 ) // ov
+    }, { new Color( 0, 0, 0 ), // background_color
+        new Color( 255, 255, 0 ), // background_color_gradient_bottom
+        new Color( 127, 255, 0 ), // sequence __ Neon
+        new Color( 255, 110, 199 ), // taxonomy
+        new Color( 234, 173, 234 ), // support
+        new Color( 77, 77, 255 ), // branch_length_color
+        new Color( 234, 173, 234 ), // branch_color
+        new Color( 77, 77, 255 ), // box_color
+        new Color( 234, 173, 234 ), // collapsed_fill_color
+        new Color( 243, 243, 21 ), // found_color 0
+        new Color( 255, 20, 147 ), // found_color 1
+        new Color( 255, 255, 255 ), // found_color 1 + 2
+        new Color( 255, 0, 0 ), // duplication_box_color
+        new Color( 0, 255, 0 ), // speciation_box_color
+        new Color( 255, 255, 0 ), // duplication_speciation_color
+        new Color( 127, 255, 0 ), // domain_label
+        new Color( 234, 173, 234 ), // domains_base
+        new Color( 27, 255, 0 ), // binary_domain_combinations_color
+        new Color( 27, 255, 0 ) // annotation
+    , new Color( 77, 77, 255 ) // ov
+    }                                            };
     private Color              annotation_color;
     private Color              background_color;
     private Color              background_color_gradient_bottom;
@@ -307,6 +307,18 @@ public final class TreeColorSet {
         // Hidden constructor.
     }
 
+    public Color getDomainBaseColor() {
+        return domain_base_color;
+    }
+
+    public Color getDomainLabelColor() {
+        return domain_label_color;
+    }
+
+    private void setColorForDefault( final int i, final Color color ) {
+        _color_schemes[ 0 ][ i ] = color;
+    }
+
     void cycleColorScheme() {
         if ( getCurrentColorScheme() >= ( _color_schemes.length - 1 ) ) {
             setColorSchema( 0 );
@@ -371,14 +383,6 @@ public final class TreeColorSet {
         return SCHEME_NAMES[ getCurrentColorScheme() ];
     }
 
-    public Color getDomainBaseColor() {
-        return domain_base_color;
-    }
-
-    public Color getDomainLabelColor() {
-        return domain_label_color;
-    }
-
     Color getDuplicationBoxColor() {
         return dup_box_color;
     }
@@ -471,10 +475,6 @@ public final class TreeColorSet {
         _color_scheme = color_scheme;
     }
 
-    private void setColorForDefault( final int i, final Color color ) {
-        _color_schemes[ 0 ][ i ] = color;
-    }
-
     static TreeColorSet createInstance() {
         final TreeColorSet tcs = new TreeColorSet();
         tcs.setColorSchema( 0 );
index 0a1c59d..47fd94e 100644 (file)
@@ -87,6 +87,36 @@ public final class TreeFontSet {
         return _small_max_descent;
     }
 
+    private Font getLargeFontSystem() {
+        return _large_font_system;
+    }
+
+    private void intializeFonts() {
+        final int small_size = getBaseFont().getSize() - 2;
+        int italic = Font.ITALIC;
+        if ( getBaseFont().getStyle() == Font.BOLD ) {
+            italic = italic + Font.BOLD;
+        }
+        _small_font = new Font( getBaseFont().getFontName(), getBaseFont().getStyle(), small_size );
+        _large_font = new Font( getBaseFont().getFontName(), getBaseFont().getStyle(), getBaseFont().getSize() );
+        _small_font_system = new Font( getBaseFont().getFontName(), getBaseFont().getStyle(), small_size );
+        _large_font_system = new Font( getBaseFont().getFontName(), getBaseFont().getStyle(), getBaseFont().getSize() );
+        _small_font_memory = _small_font;
+        _large_font_memory = _large_font;
+        setupFontMetrics();
+    }
+
+    private void setDecreasedSizeBySystem( final boolean decreased_size_by_system ) {
+        _decreased_size_by_system = decreased_size_by_system;
+    }
+
+    private void setupFontMetrics() {
+        _fm_small = _owner.getFontMetrics( _small_font );
+        _fm_large = _owner.getFontMetrics( _large_font );
+        _small_max_descent = _fm_small.getMaxDescent();
+        _small_max_ascent = _fm_small.getMaxAscent() + 1;
+    }
+
     void decreaseFontSize( final int min, final boolean decreased_size_by_system ) {
         if ( decreased_size_by_system && !isDecreasedSizeBySystem() ) {
             _small_font_memory = _small_font;
@@ -169,34 +199,4 @@ public final class TreeFontSet {
         _large_font = _large_font.deriveFont( 6f );
         setupFontMetrics();
     }
-
-    private Font getLargeFontSystem() {
-        return _large_font_system;
-    }
-
-    private void intializeFonts() {
-        final int small_size = getBaseFont().getSize() - 2;
-        int italic = Font.ITALIC;
-        if ( getBaseFont().getStyle() == Font.BOLD ) {
-            italic = italic + Font.BOLD;
-        }
-        _small_font = new Font( getBaseFont().getFontName(), getBaseFont().getStyle(), small_size );
-        _large_font = new Font( getBaseFont().getFontName(), getBaseFont().getStyle(), getBaseFont().getSize() );
-        _small_font_system = new Font( getBaseFont().getFontName(), getBaseFont().getStyle(), small_size );
-        _large_font_system = new Font( getBaseFont().getFontName(), getBaseFont().getStyle(), getBaseFont().getSize() );
-        _small_font_memory = _small_font;
-        _large_font_memory = _large_font;
-        setupFontMetrics();
-    }
-
-    private void setDecreasedSizeBySystem( final boolean decreased_size_by_system ) {
-        _decreased_size_by_system = decreased_size_by_system;
-    }
-
-    private void setupFontMetrics() {
-        _fm_small = _owner.getFontMetrics( _small_font );
-        _fm_large = _owner.getFontMetrics( _large_font );
-        _small_max_descent = _fm_small.getMaxDescent();
-        _small_max_ascent = _fm_small.getMaxAscent() + 1;
-    }
 }
index 38afbce..c6c8a67 100644 (file)
@@ -137,6 +137,61 @@ import org.forester.util.TaxonomyUtil;
 
 public final class TreePanel extends JPanel implements ActionListener, MouseWheelListener, Printable {
 
+    final private class NodeColorizationActionListener implements ActionListener {
+
+        List<PhylogenyNode> _additional_nodes = null;
+        JColorChooser       _chooser          = null;
+        PhylogenyNode       _node             = null;
+
+        NodeColorizationActionListener( final JColorChooser chooser, final PhylogenyNode node ) {
+            _chooser = chooser;
+            _node = node;
+        }
+
+        NodeColorizationActionListener( final JColorChooser chooser,
+                                        final PhylogenyNode node,
+                                        final List<PhylogenyNode> additional_nodes ) {
+            _chooser = chooser;
+            _node = node;
+            _additional_nodes = additional_nodes;
+        }
+
+        @Override
+        public void actionPerformed( final ActionEvent e ) {
+            final Color c = _chooser.getColor();
+            if ( c != null ) {
+                colorizeNodes( c, _node, _additional_nodes );
+            }
+        }
+    }
+
+    final private class SubtreeColorizationActionListener implements ActionListener {
+
+        List<PhylogenyNode> _additional_nodes = null;
+        JColorChooser       _chooser          = null;
+        PhylogenyNode       _node             = null;
+
+        SubtreeColorizationActionListener( final JColorChooser chooser, final PhylogenyNode node ) {
+            _chooser = chooser;
+            _node = node;
+        }
+
+        SubtreeColorizationActionListener( final JColorChooser chooser,
+                                           final PhylogenyNode node,
+                                           final List<PhylogenyNode> additional_nodes ) {
+            _chooser = chooser;
+            _node = node;
+            _additional_nodes = additional_nodes;
+        }
+
+        @Override
+        public void actionPerformed( final ActionEvent e ) {
+            final Color c = _chooser.getColor();
+            if ( c != null ) {
+                colorizeSubtree( c, _node, _additional_nodes );
+            }
+        }
+    }
     public final static boolean          SPECIAL_DOMAIN_COLORING                            = true;
     final static Cursor                  ARROW_CURSOR                                       = Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR );
     final static Cursor                  CUT_CURSOR                                         = Cursor.getPredefinedCursor( Cursor.CROSSHAIR_CURSOR );
@@ -176,7 +231,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
     private static final BasicStroke     STROKE_2                                           = new BasicStroke( 2f );
     private static final double          TWO_PI                                             = 2 * Math.PI;
     private final static int             WIGGLE                                             = 2;
-    private static final String          SHOW_ONLY_THIS_CONF_TYPE                           = null;    //TODO remove me
+    private static final String          SHOW_ONLY_THIS_CONF_TYPE                           = null;                                                     //TODO remove me
     HashMap<Long, Short>                 _nodeid_dist_to_leaf                               = new HashMap<Long, Short>();
     final private Arc2D                  _arc                                               = new Arc2D.Double();
     private AffineTransform              _at;
@@ -306,7 +361,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         calculateScaleDistance();
         FORMATTER_CONFIDENCE.setMaximumFractionDigits( configuration.getNumberOfDigitsAfterCommaForConfidenceValues() );
         FORMATTER_BRANCH_LENGTH.setMaximumFractionDigits( configuration
-                                                          .getNumberOfDigitsAfterCommaForBranchLengthValues() );
+                .getNumberOfDigitsAfterCommaForBranchLengthValues() );
     }
 
     @Override
@@ -346,6 +401,10 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         return _phylogeny;
     }
 
+    public final TreeColorSet getTreeColorSet() {
+        return getMainPanel().getTreeColorSet();
+    }
+
     @Override
     final public void mouseWheelMoved( final MouseWheelEvent e ) {
         final int notches = e.getWheelRotation();
@@ -491,5519 +550,5512 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         paint( g );
     }
 
-    final void calcMaxDepth() {
-        if ( _phylogeny != null ) {
-            _circ_max_depth = PhylogenyMethods.calculateMaxDepth( _phylogeny );
-        }
-    }
-
-    /**
-     * Set parameters for printing the displayed tree
-     *
-     */
-    final void calcParametersForPainting( final int x, final int y ) {
-        // updateStyle(); not needed?
-        if ( ( _phylogeny != null ) && !_phylogeny.isEmpty() ) {
-            initNodeData();
-            calculateLongestExtNodeInfo();
-            if ( ( getLongestExtNodeInfo() > ( x * 0.6 ) )
-                    && ( getTreeFontSet().getLargeFont().getSize() > ( 2 + TreeFontSet.FONT_SIZE_CHANGE_STEP ) ) ) {
-                while ( ( getLongestExtNodeInfo() > ( x * 0.7 ) ) && ( getTreeFontSet().getLargeFont().getSize() > 2 ) ) {
-                    getMainPanel().getTreeFontSet().decreaseFontSize( getConfiguration().getMinBaseFontSize(), true );
-                    calculateLongestExtNodeInfo();
-                }
-            }
-            else {
-                while ( ( getLongestExtNodeInfo() < ( x * 0.6 ) )
-                        && ( getTreeFontSet().getLargeFont().getSize() <= ( getTreeFontSet().getLargeFontMemory()
-                                .getSize() - TreeFontSet.FONT_SIZE_CHANGE_STEP ) ) ) {
-                    getMainPanel().getTreeFontSet().increaseFontSize();
-                    calculateLongestExtNodeInfo();
-                }
-            }
-            //_length_of_longest_text = calcLengthOfLongestText();
-            int ext_nodes = _phylogeny.getRoot().getNumberOfExternalNodes();
-            final int max_depth = PhylogenyMethods.calculateMaxDepth( _phylogeny );
-            if ( ext_nodes == 1 ) {
-                ext_nodes = max_depth;
-                if ( ext_nodes < 1 ) {
-                    ext_nodes = 1;
-                }
-            }
-            updateOvSizes();
-            float xdist = 0;
-            float ov_xdist = 0;
-            if ( !isNonLinedUpCladogram() && !isUniformBranchLengthsForCladogram() ) {
-                xdist = ( float ) ( ( x - getLongestExtNodeInfo() - TreePanel.MOVE ) / ( ext_nodes + 3.0 ) );
-                ov_xdist = ( float ) ( getOvMaxWidth() / ( ext_nodes + 3.0 ) );
-            }
-            else {
-                xdist = ( ( x - getLongestExtNodeInfo() - TreePanel.MOVE ) / ( max_depth + 1 ) );
-                ov_xdist = ( getOvMaxWidth() / ( max_depth + 1 ) );
-            }
-            float ydist = ( float ) ( ( y - TreePanel.MOVE ) / ( ext_nodes * 2.0 ) );
-            if ( xdist < 0.0 ) {
-                xdist = 0.0f;
-            }
-            if ( ov_xdist < 0.0 ) {
-                ov_xdist = 0.0f;
-            }
-            if ( ydist < 0.0 ) {
-                ydist = 0.0f;
-            }
-            setXdistance( xdist );
-            setYdistance( ydist );
-            setOvXDistance( ov_xdist );
-            final double height = _phylogeny.getHeight();
-            if ( height > 0 ) {
-                final float corr = ( float ) ( ( x - TreePanel.MOVE - getLongestExtNodeInfo() - getXdistance() ) / height );
-                setXcorrectionFactor( corr > 0 ? corr : 0 );
-                final float ov_corr = ( float ) ( ( getOvMaxWidth() - getOvXDistance() ) / height );
-                setOvXcorrectionFactor( ov_corr > 0 ? ov_corr : 0 );
-            }
-            else {
-                setXcorrectionFactor( 0 );
-                setOvXcorrectionFactor( 0 );
-            }
-            _circ_max_depth = max_depth;
-            setUpUrtFactor();
-            //
-            if ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
-                    && ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
-                //                int dynamic_hiding_factor = calcDynamicHidingFactor();
-                //                if ( dynamic_hiding_factor > 1 ) {
-                //                    while ( dynamic_hiding_factor > 1
-                //                            && getTreeFontSet()._fm_large.getHeight() > TreeFontSet.SMALL_FONTS_BASE ) {
-                //                        getTreeFontSet().decreaseFontSize( 1, true );
-                //                        dynamic_hiding_factor = calcDynamicHidingFactor();
-                //                    }
-                //                }
-                //                else if ( getTreeFontSet().isDecreasedSizeBySystem() ) {
-                //                    while ( dynamic_hiding_factor < 1 && getTreeFontSet()._fm_large.getHeight() < 12 ) {
-                //                        getTreeFontSet().increaseFontSize();
-                //                        dynamic_hiding_factor = calcDynamicHidingFactor();
-                //                    }
-                //                }
+    private void abbreviateScientificName( final String sn, final StringBuilder sb ) {
+        final String[] a = sn.split( "\\s+" );
+        sb.append( a[ 0 ].substring( 0, 1 ) );
+        sb.append( a[ 1 ].substring( 0, 2 ) );
+        if ( a.length > 2 ) {
+            for( int i = 2; i < a.length; i++ ) {
+                sb.append( " " );
+                sb.append( a[ i ] );
             }
-            //
         }
     }
 
-    final void calculateLongestExtNodeInfo() {
-        if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
+    final private void addEmptyNode( final PhylogenyNode node ) {
+        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
+            errorMessageNoCutCopyPasteInUnrootedDisplay();
             return;
         }
-        int max_length = ForesterUtil.roundToInt( ( getSize().getWidth() - MOVE )
-                                                  * Constants.EXT_NODE_INFO_LENGTH_MAX_RATIO );
-        if ( max_length < 40 ) {
-            max_length = 40;
-        }
-        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;
-            if ( node.isCollapse() ) {
-                continue;
-            }
-            final StringBuilder sb = new StringBuilder();
-            nodeDataAsSB( node, sb );
-            if ( node.getNodeData().isHasTaxonomy() ) {
-                nodeTaxonomyDataAsSB( node.getNodeData().getTaxonomy(), sb );
-            }
-            final int txt = sb.length();
-            if ( txt > longest_txt ) {
-                longest_txt = txt;
-                longest_txt_node = node;
-            }
-            boolean use_vis = false;
-            final Graphics2D g = ( Graphics2D ) getGraphics();
-            if ( getControlPanel().isUseVisualStyles() ) {
-                use_vis = setFont( g, node, false );
-            }
-            if ( !use_vis ) {
-                sum = getFontMetricsForLargeDefaultFont().stringWidth( sb.toString() );
-            }
-            else {
-                sum = getFontMetrics( g.getFont() ).stringWidth( sb.toString() );
-            }
-            if ( getControlPanel().isShowBinaryCharacters() && node.getNodeData().isHasBinaryCharacters() ) {
-                sum += getFontMetricsForLargeDefaultFont().stringWidth( node.getNodeData().getBinaryCharacters()
-                                                                        .getGainedCharactersAsStringBuffer().toString() );
-            }
-            if ( getControlPanel().isShowVectorData() && ( node.getNodeData().getVector() != null )
-                    && ( node.getNodeData().getVector().size() > 0 ) ) {
-                if ( getConfiguration() != null ) {
-                    sum += getConfiguration().getVectorDataWidth() + 10;
-                }
-                else {
-                    sum += RenderableVector.VECTOR_DEFAULT_WIDTH + 10;
-                }
-            }
-            if ( getControlPanel().isShowDomainArchitectures() && node.getNodeData().isHasSequence()
-                    && ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) {
-                // FIXME
-                // TODO this might need some clean up
-                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 ( getControlPanel().isShowMolSequences() && ( node.getNodeData().isHasSequence() )
-                    && ( node.getNodeData().getSequence().isMolecularSequenceAligned() )
-                    && ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) ) {
-                // FIXME
-                sum += RenderableMsaSequence.DEFAULT_WIDTH + 30;
-            }
-            if ( sum >= max_length ) {
-                _longest_ext_node_info = max_length;
-                // return; //FIXME why?
-            }
-            if ( sum > longest ) {
-                longest = sum;
-            }
-        }
-        _ext_node_with_longest_txt_info = longest_txt_node;
-        if ( longest >= max_length ) {
-            _longest_ext_node_info = max_length;
+        final String label = createASimpleTextRepresentationOfANode( node );
+        String msg = "";
+        if ( ForesterUtil.isEmpty( label ) ) {
+            msg = "How to add the new, empty node?";
         }
         else {
-            _longest_ext_node_info = longest;
-        }
-        _length_of_longest_text = calcLengthOfLongestText();
-    }
-
-    final void calculateScaleDistance() {
-        if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
-            return;
+            msg = "How to add the new, empty node to node" + label + "?";
         }
-        final double height = getMaxDistanceToRoot();
-        if ( height > 0 ) {
-            if ( ( height <= 0.5 ) ) {
-                setScaleDistance( 0.01 );
-            }
-            else if ( height <= 5.0 ) {
-                setScaleDistance( 0.1 );
-            }
-            else if ( height <= 50.0 ) {
-                setScaleDistance( 1 );
-            }
-            else if ( height <= 500.0 ) {
-                setScaleDistance( 10 );
-            }
-            else {
-                setScaleDistance( 100 );
+        final Object[] options = { "As sibling", "As descendant", "Cancel" };
+        final int r = JOptionPane.showOptionDialog( this,
+                                                    msg,
+                                                    "Addition of Empty New Node",
+                                                    JOptionPane.CLOSED_OPTION,
+                                                    JOptionPane.QUESTION_MESSAGE,
+                                                    null,
+                                                    options,
+                                                    options[ 2 ] );
+        boolean add_as_sibling = true;
+        if ( r == 1 ) {
+            add_as_sibling = false;
+        }
+        else if ( r != 0 ) {
+            return;
+        }
+        final Phylogeny phy = new Phylogeny();
+        phy.setRoot( new PhylogenyNode() );
+        phy.setRooted( true );
+        if ( add_as_sibling ) {
+            if ( node.isRoot() ) {
+                JOptionPane.showMessageDialog( this,
+                                               "Cannot add sibling to root",
+                                               "Attempt to add sibling to root",
+                                               JOptionPane.ERROR_MESSAGE );
+                return;
             }
+            phy.addAsSibling( node );
         }
         else {
-            setScaleDistance( 0.0 );
-        }
-        String scale_label = String.valueOf( getScaleDistance() );
-        if ( !ForesterUtil.isEmpty( _phylogeny.getDistanceUnit() ) ) {
-            scale_label += " [" + _phylogeny.getDistanceUnit() + "]";
+            phy.addAsChild( node );
         }
-        setScaleLabel( scale_label );
+        setNodeInPreorderToNull();
+        _phylogeny.externalNodesHaveChanged();
+        _phylogeny.clearHashIdToNodeMap();
+        _phylogeny.recalculateNumberOfExternalDescendants( true );
+        resetNodeIdToDistToLeafMap();
+        setEdited( true );
+        repaint();
     }
 
-    final Color calculateTaxonomyBasedColor( final Taxonomy tax ) {
-        if ( getOptions().isColorByTaxonomicGroup() ) {
-            if ( !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) {
-                boolean ex = false;
-                String group = null;
-                try {
-                    group = TaxonomyUtil.getTaxGroupByTaxCode( tax.getTaxonomyCode() );
-                }
-                catch ( final Exception e ) {
-                    ex = true;
-                }
-                if ( !ex && !ForesterUtil.isEmpty( group ) ) {
-                    final Color c = ForesterUtil.obtainColorDependingOnTaxonomyGroup( group );
-                    if ( c != null ) {
-                        return c;
-                    }
-                }
-            }
-            return getTreeColorSet().getTaxonomyColor();
-        }
-        else {
-            if ( ForesterUtil.isEmpty( tax.getTaxonomyCode() ) && ForesterUtil.isEmpty( tax.getScientificName() ) ) {
-                return getTreeColorSet().getTaxonomyColor();
-            }
-            Color c = null;
-            if ( !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) {
-                c = getControlPanel().getSpeciesColors().get( tax.getTaxonomyCode() );
-            }
-            if ( ( c == null ) && !ForesterUtil.isEmpty( tax.getScientificName() ) ) {
-                c = getControlPanel().getSpeciesColors().get( tax.getScientificName() );
-            }
-            if ( c == null ) {
-                if ( !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) {
-                    c = AptxUtil.calculateColorFromString( tax.getTaxonomyCode(), true );
-                    getControlPanel().getSpeciesColors().put( tax.getTaxonomyCode(), c );
-                }
-                else {
-                    c = AptxUtil.calculateColorFromString( tax.getScientificName(), true );
-                    getControlPanel().getSpeciesColors().put( tax.getScientificName(), c );
-                }
-            }
-            return c;
+    final private void addToCurrentExternalNodes( final long i ) {
+        if ( _current_external_nodes == null ) {
+            _current_external_nodes = new HashSet<Long>();
         }
+        _current_external_nodes.add( i );
     }
 
-    final Color calculateSequenceBasedColor( final Sequence seq ) {
-        if ( ForesterUtil.isEmpty( seq.getName() ) ) {
-            return getTreeColorSet().getSequenceColor();
+    final private void assignGraphicsForBranchWithColorForParentBranch( final PhylogenyNode node,
+                                                                        final boolean is_vertical,
+                                                                        final Graphics g,
+                                                                        final boolean to_pdf,
+                                                                        final boolean to_graphics_file ) {
+        final NodeClickAction action = _control_panel.getActionWhenNodeClicked();
+        if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
+            g.setColor( Color.BLACK );
         }
-        Color c = null;
-        final String seq_name = seq.getName();
-        c = getControlPanel().getSequenceColors().get( seq_name );
-        if ( c == null ) {
-            c = AptxUtil.calculateColorFromString( seq_name, false );
-            getControlPanel().getSequenceColors().put( seq_name, c );
+        else if ( ( ( action == NodeClickAction.COPY_SUBTREE ) || ( action == NodeClickAction.CUT_SUBTREE )
+                || ( action == NodeClickAction.DELETE_NODE_OR_SUBTREE ) || ( action == NodeClickAction.PASTE_SUBTREE ) || ( action == NodeClickAction.ADD_NEW_NODE ) )
+                && ( getCutOrCopiedTree() != null )
+                && ( getCopiedAndPastedNodes() != null )
+                && !to_pdf
+                && !to_graphics_file && getCopiedAndPastedNodes().contains( node.getId() ) ) {
+            g.setColor( getTreeColorSet().getFoundColor0() );
+        }
+        else if ( getControlPanel().isUseVisualStyles() && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) {
+            g.setColor( PhylogenyMethods.getBranchColorValue( node ) );
+        }
+        else if ( to_pdf ) {
+            g.setColor( getTreeColorSet().getBranchColorForPdf() );
+        }
+        else {
+            g.setColor( getTreeColorSet().getBranchColor() );
         }
-        return c;
     }
 
-    void checkForVectorProperties( final Phylogeny phy ) {
-        final DescriptiveStatistics stats = new BasicDescriptiveStatistics();
-        for( final PhylogenyNodeIterator iter = phy.iteratorPreorder(); iter.hasNext(); ) {
-            final PhylogenyNode node = iter.next();
-            if ( node.getNodeData().getProperties() != null ) {
-                final PropertiesMap pm = node.getNodeData().getProperties();
-                final double[] vector = new double[ pm.getProperties().size() ];
-                int counter = 0;
-                for( final String ref : pm.getProperties().keySet() ) {
-                    if ( ref.startsWith( PhyloXmlUtil.VECTOR_PROPERTY_REF ) ) {
-                        final Property p = pm.getProperty( ref );
-                        final String value_str = p.getValue();
-                        final String index_str = ref
-                                .substring( PhyloXmlUtil.VECTOR_PROPERTY_REF.length(), ref.length() );
-                        double d = -100;
-                        try {
-                            d = Double.parseDouble( value_str );
-                        }
-                        catch ( final NumberFormatException e ) {
-                            JOptionPane.showMessageDialog( this, "Could not parse \"" + value_str
-                                                           + "\" into a decimal value", "Problem with Vector Data", JOptionPane.ERROR_MESSAGE );
-                            return;
+    final private void blast( final PhylogenyNode node ) {
+        if ( !isCanBlast( node ) ) {
+            JOptionPane.showMessageDialog( this,
+                                           "Insufficient information present",
+                                           "Cannot Blast",
+                                           JOptionPane.INFORMATION_MESSAGE );
+            return;
+        }
+        else {
+            final String query = Blast.obtainQueryForBlast( node );
+            System.out.println( "query for BLAST is: " + query );
+            char type = '?';
+            if ( !ForesterUtil.isEmpty( query ) ) {
+                if ( node.getNodeData().isHasSequence() ) {
+                    if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getType() ) ) {
+                        if ( node.getNodeData().getSequence().getType().toLowerCase()
+                                .equals( PhyloXmlUtil.SEQ_TYPE_PROTEIN ) ) {
+                            type = 'p';
                         }
-                        int i = -1;
-                        try {
-                            i = Integer.parseInt( index_str );
+                        else {
+                            type = 'n';
                         }
-                        catch ( final NumberFormatException e ) {
-                            JOptionPane.showMessageDialog( this,
-                                                           "Could not parse \"" + index_str
-                                                           + "\" into index for vector data",
-                                                           "Problem with Vector Data",
-                                                           JOptionPane.ERROR_MESSAGE );
-                            return;
+                    }
+                    else if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) {
+                        if ( ForesterUtil.seqIsLikelyToBeAa( node.getNodeData().getSequence().getMolecularSequence() ) ) {
+                            type = 'p';
                         }
-                        if ( i < 0 ) {
-                            JOptionPane.showMessageDialog( this,
-                                                           "Attempt to use negative index for vector data",
-                                                           "Problem with Vector Data",
-                                                           JOptionPane.ERROR_MESSAGE );
-                            return;
+                        else {
+                            type = 'n';
                         }
-                        vector[ i ] = d;
-                        ++counter;
-                        stats.addValue( d );
                     }
                 }
-                final List<Double> vector_l = new ArrayList<Double>( counter );
-                for( int i = 0; i < counter; ++i ) {
-                    vector_l.add( vector[ i ] );
+                if ( type == '?' ) {
+                    if ( SequenceAccessionTools.isProteinDbQuery( query ) ) {
+                        type = 'p';
+                    }
+                    else {
+                        type = 'n';
+                    }
+                }
+                JApplet applet = null;
+                if ( isApplet() ) {
+                    applet = obtainApplet();
+                }
+                try {
+                    Blast.openNcbiBlastWeb( query, type == 'n', applet, this );
+                }
+                catch ( final Exception e ) {
+                    e.printStackTrace();
+                }
+                if ( Constants.ALLOW_DDBJ_BLAST ) {
+                    try {
+                        System.out.println( "trying: " + query );
+                        final Blast s = new Blast();
+                        s.ddbjBlast( query );
+                    }
+                    catch ( final Exception e ) {
+                        e.printStackTrace();
+                    }
                 }
-                node.getNodeData().setVector( vector_l );
             }
         }
-        if ( stats.getN() > 0 ) {
-            _statistics_for_vector_data = stats;
-        }
     }
 
-    void clearCurrentExternalNodesDataBuffer() {
-        setCurrentExternalNodesDataBuffer( new StringBuilder() );
+    private final int calcDynamicHidingFactor() {
+        return ( int ) ( 0.5 + ( getFontMetricsForLargeDefaultFont().getHeight() / ( 1.5 * getYdistance() ) ) );
+    }
+
+    final private int calcLengthOfLongestText() {
+        final StringBuilder sb = new StringBuilder();
+        if ( _ext_node_with_longest_txt_info != null ) {
+            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() );
     }
 
     /**
-     * Collapse the tree from the given node
+     * Calculate the length of the distance between the given node and its
+     * parent.
      *
      * @param node
-     *            a PhylogenyNode
+     * @param ext_node_x
+     * @factor
+     * @return the distance value
      */
-    final void collapse( final PhylogenyNode node ) {
-        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
-            JOptionPane.showMessageDialog( this,
-                                           "Cannot collapse in unrooted display type",
-                                           "Attempt to collapse in unrooted display",
-                                           JOptionPane.WARNING_MESSAGE );
-            return;
+    final private float calculateBranchLengthToParent( final PhylogenyNode node, final float factor ) {
+        if ( getControlPanel().isDrawPhylogram() ) {
+            if ( node.getDistanceToParent() < 0.0 ) {
+                return 0.0f;
+            }
+            return ( float ) ( getXcorrectionFactor() * node.getDistanceToParent() );
         }
-        if ( !node.isExternal() && !node.isRoot() ) {
-            final boolean collapse = !node.isCollapse();
-            TreePanelUtil.collapseSubtree( node, collapse );
-            updateSetOfCollapsedExternalNodes();
-            _phylogeny.recalculateNumberOfExternalDescendants( true );
-            resetNodeIdToDistToLeafMap();
-            calculateLongestExtNodeInfo();
-            setNodeInPreorderToNull();
-            _control_panel.displayedPhylogenyMightHaveChanged( true );
-            resetPreferredSize();
-            updateOvSizes();
-            _main_panel.adjustJScrollPane();
-            repaint();
+        else {
+            if ( ( factor == 0 ) || isNonLinedUpCladogram() ) {
+                return getXdistance();
+            }
+            return getXdistance() * factor;
         }
     }
 
-    final void collapseSpeciesSpecificSubtrees() {
-        if ( ( _phylogeny == null ) || ( _phylogeny.getNumberOfExternalNodes() < 2 ) ) {
-            return;
+    final private Color calculateColorForAnnotation( final SortedSet<Annotation> ann ) {
+        Color c = getTreeColorSet().getAnnotationColor();
+        if ( getControlPanel().isColorAccordingToAnnotation() && ( getControlPanel().getAnnotationColors() != null ) ) {
+            final StringBuilder sb = new StringBuilder();
+            for( final Annotation a : ann ) {
+                sb.append( !ForesterUtil.isEmpty( a.getRefValue() ) ? a.getRefValue() : a.getDesc() );
+            }
+            final String ann_str = sb.toString();
+            if ( !ForesterUtil.isEmpty( ann_str ) ) {
+                c = getControlPanel().getAnnotationColors().get( ann_str );
+                if ( c == null ) {
+                    c = AptxUtil.calculateColorFromString( ann_str, false );
+                    getControlPanel().getAnnotationColors().put( ann_str, c );
+                }
+                if ( c == null ) {
+                    c = getTreeColorSet().getAnnotationColor();
+                }
+            }
         }
-        setWaitCursor();
-        TreePanelUtil.collapseSpeciesSpecificSubtrees( _phylogeny );
-        updateSetOfCollapsedExternalNodes();
-        _phylogeny.recalculateNumberOfExternalDescendants( true );
-        resetNodeIdToDistToLeafMap();
-        calculateLongestExtNodeInfo();
-        setNodeInPreorderToNull();
-        resetPreferredSize();
-        _main_panel.adjustJScrollPane();
-        setArrowCursor();
-        repaint();
+        return c;
     }
 
-    final void colorRank( final String rank ) {
-        if ( ( _phylogeny == null ) || ( _phylogeny.getNumberOfExternalNodes() < 2 ) ) {
-            return;
-        }
-        setWaitCursor();
-        AptxUtil.removeBranchColors( _phylogeny );
-        final int colorizations = TreePanelUtil.colorPhylogenyAccordingToRanks( _phylogeny, rank, this );
-        if ( colorizations > 0 ) {
-            _control_panel.setColorBranches( true );
-            if ( _control_panel.getUseVisualStylesCb() != null ) {
-                _control_panel.getUseVisualStylesCb().setSelected( true );
-            }
-            if ( _control_panel.getColorAccSpeciesCb() != null ) {
-                _control_panel.getColorAccSpeciesCb().setSelected( false );
-            }
-            _options.setColorLabelsSameAsParentBranch( true );
-            if ( getMainPanel().getMainFrame()._color_labels_same_as_parent_branch != null ) {
-                getMainPanel().getMainFrame()._color_labels_same_as_parent_branch.setSelected( true );
+    final private float calculateOvBranchLengthToParent( final PhylogenyNode node, final int factor ) {
+        if ( getControlPanel().isDrawPhylogram() ) {
+            if ( node.getDistanceToParent() < 0.0 ) {
+                return 0.0f;
             }
-            _control_panel.repaint();
+            return ( float ) ( getOvXcorrectionFactor() * node.getDistanceToParent() );
         }
-        setArrowCursor();
-        repaint();
-        if ( colorizations > 0 ) {
-            String msg = "Taxonomy colorization via " + rank + " completed:\n";
-            if ( colorizations > 1 ) {
-                msg += "colorized " + colorizations + " subtrees";
-            }
-            else {
-                msg += "colorized one subtree";
+        else {
+            if ( ( factor == 0 ) || isNonLinedUpCladogram() ) {
+                return getOvXDistance();
             }
-            setEdited( true );
-            JOptionPane.showMessageDialog( this,
-                                           msg,
-                                           "Taxonomy Colorization Completed (" + rank + ")",
-                                           JOptionPane.INFORMATION_MESSAGE );
+            return getOvXDistance() * factor;
+        }
+    }
+
+    final private void cannotOpenBrowserWarningMessage( final String type_type ) {
+        JOptionPane.showMessageDialog( this,
+                                       "Cannot launch web browser for " + type_type + " data of this node",
+                                       "Cannot launch web browser",
+                                       JOptionPane.WARNING_MESSAGE );
+    }
+
+    private void changeNodeFont( final PhylogenyNode node ) {
+        final FontChooser fc = new FontChooser();
+        Font f = null;
+        if ( ( node.getNodeData().getNodeVisualData() != null ) && !node.getNodeData().getNodeVisualData().isEmpty() ) {
+            f = node.getNodeData().getNodeVisualData().getFont();
+        }
+        if ( f != null ) {
+            fc.setFont( f );
         }
         else {
-            String msg = "Could not taxonomy colorize any subtree via " + rank + ".\n";
-            msg += "Possible solutions (given that suitable taxonomic information is present):\n";
-            msg += "select a different rank (e.g. phylum, genus, ...)\n";
-            msg += "  and/or\n";
-            msg += "execute:\n";
-            msg += "1. \"" + MainFrameApplication.OBTAIN_DETAILED_TAXONOMIC_INFORMATION + "\" (Tools)\n";
-            msg += "2. \"" + MainFrameApplication.INFER_ANCESTOR_TAXONOMIES + "\" (Analysis)";
-            JOptionPane.showMessageDialog( this, msg, "Taxonomy Colorization Failed", JOptionPane.WARNING_MESSAGE );
+            fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
+        }
+        List<PhylogenyNode> nodes = new ArrayList<PhylogenyNode>();
+        if ( ( getFoundNodes0() != null ) || ( getFoundNodes1() != null ) ) {
+            nodes = getFoundNodesAsListOfPhylogenyNodes();
+        }
+        if ( !nodes.contains( node ) ) {
+            nodes.add( node );
+        }
+        final int count = nodes.size();
+        String title = "Change the font for ";
+        if ( count == 1 ) {
+            title += "one node";
+        }
+        else {
+            title += ( count + " nodes" );
+        }
+        fc.showDialog( this, title );
+        if ( ( fc.getFont() != null ) && !ForesterUtil.isEmpty( fc.getFont().getFamily().trim() ) ) {
+            for( final PhylogenyNode n : nodes ) {
+                if ( n.getNodeData().getNodeVisualData() == null ) {
+                    n.getNodeData().setNodeVisualData( new NodeVisualData() );
+                }
+                final NodeVisualData vd = n.getNodeData().getNodeVisualData();
+                final Font ff = fc.getFont();
+                vd.setFontName( ff.getFamily().trim() );
+                int s = ff.getSize();
+                if ( s < 0 ) {
+                    s = 0;
+                }
+                if ( s > Byte.MAX_VALUE ) {
+                    s = Byte.MAX_VALUE;
+                }
+                vd.setFontSize( s );
+                vd.setFontStyle( ff.getStyle() );
+            }
+            if ( _control_panel.getUseVisualStylesCb() != null ) {
+                getControlPanel().getUseVisualStylesCb().setSelected( true );
+            }
         }
+        setEdited( true );
+        repaint();
     }
 
-    final void confColor() {
-        if ( ( _phylogeny == null ) || ( _phylogeny.getNumberOfExternalNodes() < 2 ) ) {
-            return;
-        }
-        setWaitCursor();
-        AptxUtil.removeBranchColors( _phylogeny );
-        TreePanelUtil.colorPhylogenyAccordingToConfidenceValues( _phylogeny, this );
+    final private void colorizeNodes( final Color c,
+                                      final PhylogenyNode node,
+                                      final List<PhylogenyNode> additional_nodes ) {
         _control_panel.setColorBranches( true );
         if ( _control_panel.getUseVisualStylesCb() != null ) {
             _control_panel.getUseVisualStylesCb().setSelected( true );
         }
-        setArrowCursor();
+        if ( node != null ) {
+            colorizeNodesHelper( c, node );
+        }
+        if ( additional_nodes != null ) {
+            for( final PhylogenyNode n : additional_nodes ) {
+                colorizeNodesHelper( c, n );
+            }
+        }
         repaint();
     }
 
-    final void decreaseDomainStructureEvalueThresholdExp() {
-        if ( _domain_structure_e_value_thr_exp > -20 ) {
-            _domain_structure_e_value_thr_exp -= 1;
+    final private void colorizeSubtree( final Color c,
+                                        final PhylogenyNode node,
+                                        final List<PhylogenyNode> additional_nodes ) {
+        _control_panel.setColorBranches( true );
+        if ( _control_panel.getUseVisualStylesCb() != null ) {
+            _control_panel.getUseVisualStylesCb().setSelected( true );
         }
-    }
-
-    /**
-     * Find the node, if any, at the given location
-     *
-     * @param x
-     * @param y
-     * @return pointer to the node at x,y, null if not found
-     */
-    final PhylogenyNode findNode( final int x, final int y ) {
-        if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
-            return null;
+        if ( node != null ) {
+            for( final PreorderTreeIterator it = new PreorderTreeIterator( node ); it.hasNext(); ) {
+                it.next().getBranchData().setBranchColor( new BranchColor( c ) );
+            }
         }
-        final int half_box_size_plus_wiggle = ( getOptions().getDefaultNodeShapeSize() / 2 ) + WIGGLE;
-        for( final PhylogenyNodeIterator iter = _phylogeny.iteratorPostorder(); iter.hasNext(); ) {
-            final PhylogenyNode node = iter.next();
-            if ( ( _phylogeny.isRooted() || !node.isRoot() || ( node.getNumberOfDescendants() > 2 ) )
-                    && ( ( node.getXcoord() - half_box_size_plus_wiggle ) <= x )
-                    && ( ( node.getXcoord() + half_box_size_plus_wiggle ) >= x )
-                    && ( ( node.getYcoord() - half_box_size_plus_wiggle ) <= y )
-                    && ( ( node.getYcoord() + half_box_size_plus_wiggle ) >= y ) ) {
-                return node;
+        if ( additional_nodes != null ) {
+            for( final PhylogenyNode an : additional_nodes ) {
+                for( final PreorderTreeIterator it = new PreorderTreeIterator( an ); it.hasNext(); ) {
+                    it.next().getBranchData().setBranchColor( new BranchColor( c ) );
+                }
             }
         }
-        return null;
-    }
-
-    final Configuration getConfiguration() {
-        return _configuration;
-    }
-
-    final ControlPanel getControlPanel() {
-        return _control_panel;
-    }
-
-    String getCurrentExternalNodesDataBufferAsString() {
-        return _current_external_nodes_data_buffer.toString();
-    }
-
-    int getCurrentExternalNodesDataBufferChangeCounter() {
-        return _current_external_nodes_data_buffer_change_counter;
-    }
-
-    final int getDomainStructureEvalueThresholdExp() {
-        return _domain_structure_e_value_thr_exp;
-    }
-
-    final Set<Long> getFoundNodes0() {
-        return _found_nodes_0;
+        repaint();
     }
 
-    final Set<Long> getFoundNodes1() {
-        return _found_nodes_1;
+    private void colorNodeFont( final PhylogenyNode node ) {
+        _color_chooser.setPreviewPanel( new JPanel() );
+        NodeColorizationActionListener al;
+        int count = 1;
+        if ( ( getFoundNodes0() != null ) || ( getFoundNodes1() != null ) ) {
+            final List<PhylogenyNode> additional_nodes = getFoundNodesAsListOfPhylogenyNodes();
+            al = new NodeColorizationActionListener( _color_chooser, node, additional_nodes );
+            count = additional_nodes.size();
+            if ( !additional_nodes.contains( node ) ) {
+                count++;
+            }
+        }
+        else {
+            al = new NodeColorizationActionListener( _color_chooser, node );
+        }
+        String title = "Change the (node and font) color for ";
+        if ( count == 1 ) {
+            title += "one node";
+        }
+        else {
+            title += ( count + " nodes" );
+        }
+        final JDialog dialog = JColorChooser.createDialog( this, title, true, _color_chooser, al, null );
+        setEdited( true );
+        dialog.setVisible( true );
     }
 
-    final Color getGraphicsForNodeBoxWithColorForParentBranch( final PhylogenyNode node ) {
-        if ( getControlPanel().isUseVisualStyles() && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) {
-            return ( PhylogenyMethods.getBranchColorValue( node ) );
+    final private void colorSubtree( final PhylogenyNode node ) {
+        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
+            JOptionPane.showMessageDialog( this,
+                                           "Cannot colorize subtree in unrooted display type",
+                                           "Attempt to colorize subtree in unrooted display",
+                                           JOptionPane.WARNING_MESSAGE );
+            return;
+        }
+        _color_chooser.setPreviewPanel( new JPanel() );
+        SubtreeColorizationActionListener al;
+        if ( ( getFoundNodes0() != null ) || ( getFoundNodes1() != null ) ) {
+            final List<PhylogenyNode> additional_nodes = getFoundNodesAsListOfPhylogenyNodes();
+            al = new SubtreeColorizationActionListener( _color_chooser, node, additional_nodes );
         }
         else {
-            return ( getTreeColorSet().getBranchColor() );
+            al = new SubtreeColorizationActionListener( _color_chooser, node );
         }
+        final JDialog dialog = JColorChooser
+                .createDialog( this, "Subtree colorization", true, _color_chooser, al, null );
+        setEdited( true );
+        dialog.setVisible( true );
     }
 
-    final int getLongestExtNodeInfo() {
-        return _longest_ext_node_info;
+    final private void copySubtree( final PhylogenyNode node ) {
+        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
+            errorMessageNoCutCopyPasteInUnrootedDisplay();
+            return;
+        }
+        setNodeInPreorderToNull();
+        setCutOrCopiedTree( _phylogeny.copy( node ) );
+        final List<PhylogenyNode> nodes = PhylogenyMethods.getAllDescendants( node );
+        final Set<Long> node_ids = new HashSet<Long>( nodes.size() );
+        for( final PhylogenyNode n : nodes ) {
+            node_ids.add( n.getId() );
+        }
+        node_ids.add( node.getId() );
+        setCopiedAndPastedNodes( node_ids );
+        repaint();
     }
 
-    final Options getOptions() {
-        if ( _options == null ) {
-            _options = getControlPanel().getOptions();
+    final private String createASimpleTextRepresentationOfANode( final PhylogenyNode node ) {
+        final String tax = PhylogenyMethods.getSpecies( node );
+        String label = node.getName();
+        if ( !ForesterUtil.isEmpty( label ) && !ForesterUtil.isEmpty( tax ) ) {
+            label = label + " " + tax;
         }
-        return _options;
+        else if ( !ForesterUtil.isEmpty( tax ) ) {
+            label = tax;
+        }
+        else {
+            label = "";
+        }
+        if ( !ForesterUtil.isEmpty( label ) ) {
+            label = " [" + label + "]";
+        }
+        return label;
     }
 
-    final Rectangle2D getOvRectangle() {
-        return _ov_rectangle;
+    final private void cutSubtree( final PhylogenyNode node ) {
+        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
+            errorMessageNoCutCopyPasteInUnrootedDisplay();
+            return;
+        }
+        if ( node.isRoot() ) {
+            JOptionPane.showMessageDialog( this,
+                                           "Cannot cut entire tree as subtree",
+                                           "Attempt to cut entire tree",
+                                           JOptionPane.ERROR_MESSAGE );
+            return;
+        }
+        final String label = createASimpleTextRepresentationOfANode( node );
+        final int r = JOptionPane.showConfirmDialog( null,
+                                                     "Cut subtree" + label + "?",
+                                                     "Confirm Cutting of Subtree",
+                                                     JOptionPane.YES_NO_OPTION );
+        if ( r != JOptionPane.OK_OPTION ) {
+            return;
+        }
+        setNodeInPreorderToNull();
+        setCopiedAndPastedNodes( null );
+        setCutOrCopiedTree( _phylogeny.copy( node ) );
+        _phylogeny.deleteSubtree( node, true );
+        _phylogeny.clearHashIdToNodeMap();
+        _phylogeny.recalculateNumberOfExternalDescendants( true );
+        resetNodeIdToDistToLeafMap();
+        setEdited( true );
+        repaint();
     }
 
-    final Rectangle getOvVirtualRectangle() {
-        return _ov_virtual_rectangle;
+    final private void cycleColors() {
+        getMainPanel().getTreeColorSet().cycleColorScheme();
+        for( final TreePanel tree_panel : getMainPanel().getTreePanels() ) {
+            tree_panel.setBackground( getMainPanel().getTreeColorSet().getBackgroundColor() );
+        }
     }
 
-    final PHYLOGENY_GRAPHICS_TYPE getPhylogenyGraphicsType() {
-        return _graphics_type;
+    final private void decreaseOvSize() {
+        if ( ( getOvMaxWidth() > 20 ) && ( getOvMaxHeight() > 20 ) ) {
+            setOvMaxWidth( getOvMaxWidth() - 5 );
+            setOvMaxHeight( getOvMaxHeight() - 5 );
+            updateOvSettings();
+            getControlPanel().displayedPhylogenyMightHaveChanged( false );
+        }
     }
 
-    final double getStartingAngle() {
-        return _urt_starting_angle;
+    final private void deleteNodeOrSubtree( final PhylogenyNode node ) {
+        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
+            errorMessageNoCutCopyPasteInUnrootedDisplay();
+            return;
+        }
+        if ( node.isRoot() && ( node.getNumberOfDescendants() != 1 ) ) {
+            JOptionPane.showMessageDialog( this,
+                                           "Cannot delete entire tree",
+                                           "Attempt to delete entire tree",
+                                           JOptionPane.ERROR_MESSAGE );
+            return;
+        }
+        final String label = createASimpleTextRepresentationOfANode( node );
+        final Object[] options = { "Node only", "Entire subtree", "Cancel" };
+        final int r = JOptionPane.showOptionDialog( this,
+                                                    "Delete" + label + "?",
+                                                    "Delete Node/Subtree",
+                                                    JOptionPane.CLOSED_OPTION,
+                                                    JOptionPane.QUESTION_MESSAGE,
+                                                    null,
+                                                    options,
+                                                    options[ 2 ] );
+        setNodeInPreorderToNull();
+        boolean node_only = true;
+        if ( r == 1 ) {
+            node_only = false;
+        }
+        else if ( r != 0 ) {
+            return;
+        }
+        if ( node_only ) {
+            PhylogenyMethods.removeNode( node, _phylogeny );
+        }
+        else {
+            _phylogeny.deleteSubtree( node, true );
+        }
+        _phylogeny.externalNodesHaveChanged();
+        _phylogeny.clearHashIdToNodeMap();
+        _phylogeny.recalculateNumberOfExternalDescendants( true );
+        resetNodeIdToDistToLeafMap();
+        setEdited( true );
+        repaint();
     }
 
-    DescriptiveStatistics getStatisticsForExpressionValues() {
-        return _statistics_for_vector_data;
+    final private void displayNodePopupMenu( final PhylogenyNode node, final int x, final int y ) {
+        makePopupMenus( node );
+        _node_popup_menu.putClientProperty( NODE_POPMENU_NODE_CLIENT_PROPERTY, node );
+        _node_popup_menu.show( this, x, y );
     }
 
-    final Color getTaxonomyBasedColor( final PhylogenyNode node ) {
-        if ( node.isExternal() && node.getNodeData().isHasTaxonomy() ) {
-            return calculateTaxonomyBasedColor( node.getNodeData().getTaxonomy() );
-        }
-        // return non-colorized color
-        return getTreeColorSet().getTaxonomyColor();
+    final private void drawArc( final double x,
+                                final double y,
+                                final double width,
+                                final double heigth,
+                                final double start_angle,
+                                final double arc_angle,
+                                final Graphics2D g ) {
+        _arc.setArc( x, y, width, heigth, _180_OVER_PI * start_angle, _180_OVER_PI * arc_angle, Arc2D.OPEN );
+        g.draw( _arc );
     }
 
-    final Color getSequenceBasedColor( final PhylogenyNode node ) {
-        if ( node.getNodeData().isHasSequence() ) {
-            return calculateSequenceBasedColor( node.getNodeData().getSequence() );
+    final private void drawLine( final double x1, final double y1, final double x2, final double y2, final Graphics2D g ) {
+        if ( ( x1 == x2 ) && ( y1 == y2 ) ) {
+            return;
         }
-        // return non-colorized color
-        return getTreeColorSet().getSequenceColor();
+        _line.setLine( x1, y1, x2, y2 );
+        g.draw( _line );
     }
 
-    public final TreeColorSet getTreeColorSet() {
-        return getMainPanel().getTreeColorSet();
+    final private void drawOval( final double x,
+                                 final double y,
+                                 final double width,
+                                 final double heigth,
+                                 final Graphics2D g ) {
+        _ellipse.setFrame( x, y, width, heigth );
+        g.draw( _ellipse );
     }
 
-    final File getTreeFile() {
-        return _treefile;
+    final private void drawOvalFilled( final double x,
+                                       final double y,
+                                       final double width,
+                                       final double heigth,
+                                       final Graphics2D g ) {
+        _ellipse.setFrame( x, y, width, heigth );
+        g.fill( _ellipse );
     }
 
-    final float getXcorrectionFactor() {
-        return _x_correction_factor;
+    final private void drawOvalGradient( final float x,
+                                         final float y,
+                                         final float width,
+                                         final float heigth,
+                                         final Graphics2D g,
+                                         final Color color_1,
+                                         final Color color_2,
+                                         final Color color_border ) {
+        _ellipse.setFrame( x, y, width, heigth );
+        g.setPaint( new GradientPaint( x, y, color_1, ( x + width ), ( y + heigth ), color_2, false ) );
+        g.fill( _ellipse );
+        if ( color_border != null ) {
+            g.setPaint( color_border );
+            g.draw( _ellipse );
+        }
     }
 
-    final float getXdistance() {
-        return _x_distance;
+    final private void drawRect( final float x, final float y, final float width, final float heigth, final Graphics2D g ) {
+        _rectangle.setFrame( x, y, width, heigth );
+        g.draw( _rectangle );
     }
 
-    final float getYdistance() {
-        return _y_distance;
+    final private void drawRectFilled( final double x,
+                                       final double y,
+                                       final double width,
+                                       final double heigth,
+                                       final Graphics2D g ) {
+        _rectangle.setFrame( x, y, width, heigth );
+        g.fill( _rectangle );
     }
 
-    final void increaseDomainStructureEvalueThresholdExp() {
-        if ( _domain_structure_e_value_thr_exp < 3 ) {
-            _domain_structure_e_value_thr_exp += 1;
+    final private void drawRectGradient( final float x,
+                                         final float y,
+                                         final float width,
+                                         final float heigth,
+                                         final Graphics2D g,
+                                         final Color color_1,
+                                         final Color color_2,
+                                         final Color color_border ) {
+        _rectangle.setFrame( x, y, width, heigth );
+        g.setPaint( new GradientPaint( x, y, color_1, ( x + width ), ( y + heigth ), color_2, false ) );
+        g.fill( _rectangle );
+        if ( color_border != null ) {
+            g.setPaint( color_border );
+            g.draw( _rectangle );
         }
     }
 
-    final void initNodeData() {
-        if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
-            return;
-        }
-        double _max_original_domain_structure_width = 0.0;
-        for( final PhylogenyNode node : _phylogeny.getExternalNodes() ) {
-            if ( node.getNodeData().isHasSequence()
-                    && ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) {
-                RenderableDomainArchitecture rds = null;
-                if ( !( node.getNodeData().getSequence().getDomainArchitecture() instanceof RenderableDomainArchitecture ) ) {
-                    if ( SPECIAL_DOMAIN_COLORING ) {
-                        rds = new RenderableDomainArchitecture( node.getNodeData().getSequence()
-                                                                .getDomainArchitecture(), node.getName() );
-                    }
-                    else {
-                        rds = new RenderableDomainArchitecture( node.getNodeData().getSequence()
-                                                                .getDomainArchitecture() );
-                    }
-                    node.getNodeData().getSequence().setDomainArchitecture( rds );
-                }
-                else {
-                    rds = ( RenderableDomainArchitecture ) node.getNodeData().getSequence().getDomainArchitecture();
-                }
-                if ( getControlPanel().isShowDomainArchitectures() ) {
-                    final double dsw = rds.getOriginalSize().getWidth();
-                    if ( dsw > _max_original_domain_structure_width ) {
-                        _max_original_domain_structure_width = dsw;
-                    }
-                }
+    private double drawTaxonomyImage( final double x, final double y, final PhylogenyNode node, final Graphics2D g ) {
+        final List<Uri> us = new ArrayList<Uri>();
+        for( final Taxonomy t : node.getNodeData().getTaxonomies() ) {
+            for( final Uri uri : t.getUris() ) {
+                us.add( uri );
             }
         }
-        if ( getControlPanel().isShowDomainArchitectures() ) {
-            final float ds_factor_width = ( float ) ( _domain_structure_width / _max_original_domain_structure_width );
-            for( final PhylogenyNode node : _phylogeny.getExternalNodes() ) {
-                if ( node.getNodeData().isHasSequence()
-                        && ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) {
-                    final RenderableDomainArchitecture rds = ( RenderableDomainArchitecture ) node.getNodeData()
-                            .getSequence().getDomainArchitecture();
-                    rds.setRenderingFactorWidth( ds_factor_width );
-                    rds.setParameter( _domain_structure_e_value_thr_exp );
+        double offset = 0;
+        for( final Uri uri : us ) {
+            if ( uri != null ) {
+                final String uri_str = uri.getValue().toString().toLowerCase();
+                if ( getImageMap().containsKey( uri_str ) ) {
+                    final BufferedImage bi = getImageMap().get( uri_str );
+                    if ( ( bi != null ) && ( bi.getHeight() > 5 ) && ( bi.getWidth() > 5 ) ) {
+                        double scaling_factor = 1;
+                        if ( getOptions().isAllowMagnificationOfTaxonomyImages()
+                                || ( bi.getHeight() > ( 1.8 * getYdistance() ) ) ) {
+                            scaling_factor = ( 1.8 * getYdistance() ) / bi.getHeight();
+                        }
+                        // y = y - ( 0.9 * getYdistance() );
+                        final double hs = bi.getHeight() * scaling_factor;
+                        double ws = ( bi.getWidth() * scaling_factor ) + offset;
+                        final double my_y = y - ( 0.5 * hs );
+                        final int x_w = ( int ) ( x + ws + 0.5 );
+                        final int y_h = ( int ) ( my_y + hs + 0.5 );
+                        if ( ( ( x_w - x ) > 7 ) && ( ( y_h - my_y ) > 7 ) ) {
+                            g.drawImage( bi,
+                                         ( int ) ( x + 0.5 + offset ),
+                                         ( int ) ( my_y + 0.5 ),
+                                         x_w,
+                                         y_h,
+                                         0,
+                                         0,
+                                         bi.getWidth(),
+                                         bi.getHeight(),
+                                         null );
+                            ws += 8;
+                        }
+                        else {
+                            ws = 0.0;
+                        }
+                        offset = ws;
+                    }
                 }
             }
         }
+        return offset;
     }
 
-    final boolean inOv( final MouseEvent e ) {
-        return ( ( e.getX() > ( getVisibleRect().x + getOvXPosition() + 1 ) )
-                && ( e.getX() < ( ( getVisibleRect().x + getOvXPosition() + getOvMaxWidth() ) - 1 ) )
-                && ( e.getY() > ( getVisibleRect().y + getOvYPosition() + 1 ) ) && ( e.getY() < ( ( getVisibleRect().y
-                        + getOvYPosition() + getOvMaxHeight() ) - 1 ) ) );
+    final private void errorMessageNoCutCopyPasteInUnrootedDisplay() {
+        JOptionPane.showMessageDialog( this,
+                                       "Cannot cut, copy, paste, add, or delete subtrees/nodes in unrooted display",
+                                       "Attempt to cut/copy/paste/add/delete in unrooted display",
+                                       JOptionPane.ERROR_MESSAGE );
     }
 
-    final boolean inOvRectangle( final MouseEvent e ) {
-        return ( ( e.getX() >= ( getOvRectangle().getX() - 1 ) )
-                && ( e.getX() <= ( getOvRectangle().getX() + getOvRectangle().getWidth() + 1 ) )
-                && ( e.getY() >= ( getOvRectangle().getY() - 1 ) ) && ( e.getY() <= ( getOvRectangle().getY()
-                        + getOvRectangle().getHeight() + 1 ) ) );
+    private final Color getColorForFoundNode( final PhylogenyNode n ) {
+        if ( isInCurrentExternalNodes( n ) ) {
+            return getTreeColorSet().getFoundColor0();
+        }
+        else if ( isInFoundNodes0( n ) && !isInFoundNodes1( n ) ) {
+            return getTreeColorSet().getFoundColor0();
+        }
+        else if ( !isInFoundNodes0( n ) && isInFoundNodes1( n ) ) {
+            return getTreeColorSet().getFoundColor1();
+        }
+        else {
+            return getTreeColorSet().getFoundColor0and1();
+        }
     }
 
-    final boolean isApplet() {
-        return getMainPanel() instanceof MainPanelApplets;
+    final private Set<Long> getCopiedAndPastedNodes() {
+        return getMainPanel().getCopiedAndPastedNodes();
     }
 
-    final boolean isCanCollapse() {
-        return ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
+    final private Set<Long> getCurrentExternalNodes() {
+        return _current_external_nodes;
     }
 
-    final boolean isCanColorSubtree() {
-        return ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
+    final private Phylogeny getCutOrCopiedTree() {
+        return getMainPanel().getCutOrCopiedTree();
     }
 
-    final boolean isCanCopy() {
-        return ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && getOptions().isEditable() );
+    private FontMetrics getFontMetricsForLargeDefaultFont() {
+        return getTreeFontSet().getFontMetricsLarge();
     }
 
-    final boolean isCanCut( final PhylogenyNode node ) {
-        return ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && getOptions().isEditable() && !node
-                .isRoot() );
+    final private float getLastDragPointX() {
+        return _last_drag_point_x;
     }
 
-    final boolean isCanDelete() {
-        return ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && getOptions().isEditable() );
+    final private float getLastDragPointY() {
+        return _last_drag_point_y;
     }
 
-    final boolean isCanPaste() {
-        return ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && getOptions().isEditable()
-                && ( getCutOrCopiedTree() != null ) && !getCutOrCopiedTree().isEmpty() );
+    final private short getMaxBranchesToLeaf( final PhylogenyNode node ) {
+        if ( !_nodeid_dist_to_leaf.containsKey( node.getId() ) ) {
+            final short m = PhylogenyMethods.calculateMaxBranchesToLeaf( node );
+            _nodeid_dist_to_leaf.put( node.getId(), m );
+            return m;
+        }
+        else {
+            return _nodeid_dist_to_leaf.get( node.getId() );
+        }
     }
 
-    final boolean isCanReroot() {
-        return ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( _subtree_index < 1 ) );
+    final private double getMaxDistanceToRoot() {
+        if ( _max_distance_to_root < 0 ) {
+            recalculateMaxDistanceToRoot();
+        }
+        return _max_distance_to_root;
     }
 
-    final boolean isCanSubtree( final PhylogenyNode node ) {
-        return ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && !node.isExternal() && ( !node
-                .isRoot() || ( _subtree_index > 0 ) ) );
+    final private float getOvMaxHeight() {
+        return _ov_max_height;
     }
 
-    final boolean isCurrentTreeIsSubtree() {
-        return ( _subtree_index > 0 );
+    final private float getOvMaxWidth() {
+        return _ov_max_width;
     }
 
-    final boolean isEdited() {
-        return _edited;
+    final private float getOvXcorrectionFactor() {
+        return _ov_x_correction_factor;
     }
 
-    final boolean isInOvRect() {
-        return _in_ov_rect;
+    final private float getOvXDistance() {
+        return _ov_x_distance;
     }
 
-    final boolean isOvOn() {
-        return _ov_on;
+    final private int getOvXPosition() {
+        return _ov_x_position;
     }
 
-    final boolean isPhyHasBranchLengths() {
-        return _phy_has_branch_lengths;
+    final private float getOvYDistance() {
+        return _ov_y_distance;
     }
 
-    final void midpointRoot() {
-        if ( ( _phylogeny == null ) || ( _phylogeny.getNumberOfExternalNodes() < 2 ) ) {
-            return;
-        }
-        if ( !_phylogeny.isRerootable() ) {
-            JOptionPane.showMessageDialog( this,
-                                           "This is not rerootable",
-                                           "Not rerootable",
-                                           JOptionPane.WARNING_MESSAGE );
-            return;
-        }
-        setNodeInPreorderToNull();
-        setWaitCursor();
-        PhylogenyMethods.midpointRoot( _phylogeny );
-        resetNodeIdToDistToLeafMap();
-        setArrowCursor();
-        setEdited( true );
-        repaint();
+    final private int getOvYPosition() {
+        return _ov_y_position;
     }
 
-    final void mouseClicked( final MouseEvent e ) {
-        if ( getOptions().isShowOverview() && isOvOn() && isInOv() ) {
-            final double w_ratio = getVisibleRect().width / getOvRectangle().getWidth();
-            final double h_ratio = getVisibleRect().height / getOvRectangle().getHeight();
-            double x = ( e.getX() - getVisibleRect().x - getOvXPosition() - ( getOvRectangle().getWidth() / 2.0 ) )
-                    * w_ratio;
-            double y = ( e.getY() - getVisibleRect().y - getOvYPosition() - ( getOvRectangle().getHeight() / 2.0 ) )
-                    * h_ratio;
-            if ( x < 0 ) {
-                x = 0;
-            }
-            if ( y < 0 ) {
-                y = 0;
-            }
-            final double max_x = getWidth() - getVisibleRect().width;
-            final double max_y = getHeight() - getVisibleRect().height;
-            if ( x > max_x ) {
-                x = max_x;
-            }
-            if ( y > max_y ) {
-                y = max_y;
+    final private int getOvYStart() {
+        return _ov_y_start;
+    }
+
+    final private List<Accession> getPdbAccs( final PhylogenyNode node ) {
+        final List<Accession> pdb_ids = new ArrayList<Accession>();
+        if ( node.getNodeData().isHasSequence() ) {
+            final Sequence seq = node.getNodeData().getSequence();
+            if ( !ForesterUtil.isEmpty( seq.getCrossReferences() ) ) {
+                final SortedSet<Accession> cross_refs = seq.getCrossReferences();
+                for( final Accession acc : cross_refs ) {
+                    if ( acc.getSource().equalsIgnoreCase( "pdb" ) ) {
+                        pdb_ids.add( acc );
+                    }
+                }
             }
-            getMainPanel().getCurrentScrollPane().getViewport()
-            .setViewPosition( new Point( ForesterUtil.roundToInt( x ), ForesterUtil.roundToInt( y ) ) );
-            setInOvRect( true );
-            repaint();
         }
-        else {
-            final PhylogenyNode node = findNode( e.getX(), e.getY() );
-            if ( node != null ) {
-                if ( !node.isRoot() && node.getParent().isCollapse() ) {
-                    return;
-                }
-                _highlight_node = node;
-                // Check if shift key is down
-                if ( ( e.getModifiers() & InputEvent.SHIFT_MASK ) != 0 ) {
-                    // Yes, so add to _found_nodes
-                    if ( getFoundNodes0() == null ) {
-                        setFoundNodes0( new HashSet<Long>() );
-                    }
-                    getFoundNodes0().add( node.getId() );
-                    // Check if control key is down
-                }
-                else if ( ( e.getModifiers() & InputEvent.CTRL_MASK ) != 0 ) {
-                    // Yes, so pop-up menu
-                    displayNodePopupMenu( node, e.getX(), e.getY() );
-                    // Handle unadorned click
-                }
-                else {
-                    // Check for right mouse button
-                    if ( e.getModifiers() == 4 ) {
-                        displayNodePopupMenu( node, e.getX(), e.getY() );
-                    }
-                    else {
-                        // if not in _found_nodes, clear _found_nodes
-                        handleClickToAction( _control_panel.getActionWhenNodeClicked(), node );
-                    }
-                }
-            }
-            else {
-                // no node was clicked
-                _highlight_node = null;
-            }
-        }
-        repaint();
+        return pdb_ids;
     }
 
-    final void mouseDragInBrowserPanel( final MouseEvent e ) {
-        setCursor( MOVE_CURSOR );
-        final Point scroll_position = getMainPanel().getCurrentScrollPane().getViewport().getViewPosition();
-        scroll_position.x -= ( e.getX() - getLastDragPointX() );
-        scroll_position.y -= ( e.getY() - getLastDragPointY() );
-        if ( scroll_position.x < 0 ) {
-            scroll_position.x = 0;
-        }
-        else {
-            final int max_x = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getMaximum()
-                    - getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getVisibleAmount();
-            if ( scroll_position.x > max_x ) {
-                scroll_position.x = max_x;
-            }
-        }
-        if ( scroll_position.y < 0 ) {
-            scroll_position.y = 0;
-        }
-        else {
-            final int max_y = getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getMaximum()
-                    - getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getVisibleAmount();
-            if ( scroll_position.y > max_y ) {
-                scroll_position.y = max_y;
-            }
-        }
-        if ( isOvOn() || getOptions().isShowScale() ) {
-            repaint();
-        }
-        getMainPanel().getCurrentScrollPane().getViewport().setViewPosition( scroll_position );
+    final private double getScaleDistance() {
+        return _scale_distance;
     }
 
-    final void mouseDragInOvRectangle( final MouseEvent e ) {
-        setCursor( HAND_CURSOR );
-        final double w_ratio = getVisibleRect().width / getOvRectangle().getWidth();
-        final double h_ratio = getVisibleRect().height / getOvRectangle().getHeight();
-        final Point scroll_position = getMainPanel().getCurrentScrollPane().getViewport().getViewPosition();
-        double dx = ( ( w_ratio * e.getX() ) - ( w_ratio * getLastDragPointX() ) );
-        double dy = ( ( h_ratio * e.getY() ) - ( h_ratio * getLastDragPointY() ) );
-        scroll_position.x = ForesterUtil.roundToInt( scroll_position.x + dx );
-        scroll_position.y = ForesterUtil.roundToInt( scroll_position.y + dy );
-        if ( scroll_position.x <= 0 ) {
-            scroll_position.x = 0;
-            dx = 0;
-        }
-        else {
-            final int max_x = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getMaximum()
-                    - getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getVisibleAmount();
-            if ( scroll_position.x >= max_x ) {
-                dx = 0;
-                scroll_position.x = max_x;
-            }
-        }
-        if ( scroll_position.y <= 0 ) {
-            dy = 0;
-            scroll_position.y = 0;
-        }
-        else {
-            final int max_y = getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getMaximum()
-                    - getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getVisibleAmount();
-            if ( scroll_position.y >= max_y ) {
-                dy = 0;
-                scroll_position.y = max_y;
-            }
-        }
-        repaint();
-        getMainPanel().getCurrentScrollPane().getViewport().setViewPosition( scroll_position );
-        setLastMouseDragPointX( ( float ) ( e.getX() + dx ) );
-        setLastMouseDragPointY( ( float ) ( e.getY() + dy ) );
+    final private String getScaleLabel() {
+        return _scale_label;
     }
 
-    final void mouseMoved( final MouseEvent e ) {
-        requestFocusInWindow();
-        if ( _current_external_nodes != null ) {
-            _current_external_nodes = null;
-            repaint();
-        }
-        if ( getControlPanel().isNodeDescPopup() ) {
-            if ( _node_desc_popup != null ) {
-                _node_desc_popup.hide();
-                _node_desc_popup = null;
-            }
-        }
-        if ( getOptions().isShowOverview() && isOvOn() ) {
-            if ( inOvVirtualRectangle( e ) ) {
-                if ( !isInOvRect() ) {
-                    setInOvRect( true );
-                    repaint();
-                }
-            }
-            else {
-                if ( isInOvRect() ) {
-                    setInOvRect( false );
-                    repaint();
-                }
-            }
-        }
-        if ( inOv( e ) && getOptions().isShowOverview() && isOvOn() ) {
-            if ( !isInOv() ) {
-                setInOv( true );
-            }
-        }
-        else {
-            if ( isInOv() ) {
-                setInOv( false );
-            }
-            final PhylogenyNode node = findNode( e.getX(), e.getY() );
-            if ( ( node != null ) && ( node.isRoot() || !node.getParent().isCollapse() ) ) {
-                if ( ( getControlPanel().getActionWhenNodeClicked() == NodeClickAction.GET_EXT_DESC_DATA ) ) {
-                    for( final PhylogenyNode n : node.getAllExternalDescendants() ) {
-                        addToCurrentExternalNodes( n.getId() );
-                    }
-                    setCursor( HAND_CURSOR );
-                    repaint();
-                }
-                else if ( ( getControlPanel().getActionWhenNodeClicked() == NodeClickAction.CUT_SUBTREE )
-                        || ( getControlPanel().getActionWhenNodeClicked() == NodeClickAction.COPY_SUBTREE )
-                        || ( getControlPanel().getActionWhenNodeClicked() == NodeClickAction.PASTE_SUBTREE )
-                        || ( getControlPanel().getActionWhenNodeClicked() == NodeClickAction.DELETE_NODE_OR_SUBTREE )
-                        || ( getControlPanel().getActionWhenNodeClicked() == NodeClickAction.REROOT )
-                        || ( getControlPanel().getActionWhenNodeClicked() == NodeClickAction.ADD_NEW_NODE ) ) {
-                    setCursor( CUT_CURSOR );
-                }
-                else {
-                    setCursor( HAND_CURSOR );
-                    if ( getControlPanel().isNodeDescPopup() ) {
-                        showNodeDataPopup( e, node );
-                    }
-                }
-            }
-            else {
-                setCursor( ARROW_CURSOR );
-            }
-        }
+    final private TreeFontSet getTreeFontSet() {
+        return getMainPanel().getTreeFontSet();
     }
 
-    final void mouseReleasedInBrowserPanel( final MouseEvent e ) {
-        setCursor( ARROW_CURSOR );
+    final private float getUrtFactor() {
+        return _urt_factor;
     }
 
-    final void multiplyUrtFactor( final float f ) {
-        _urt_factor *= f;
+    final private float getUrtFactorOv() {
+        return _urt_factor_ov;
     }
 
-    final JApplet obtainApplet() {
-        return ( ( MainPanelApplets ) getMainPanel() ).getApplet();
+    final private void handleClickToAction( final NodeClickAction action, final PhylogenyNode node ) {
+        switch ( action ) {
+            case SHOW_DATA:
+                showNodeFrame( node );
+                break;
+            case COLLAPSE:
+                collapse( node );
+                break;
+            case REROOT:
+                reRoot( node );
+                break;
+            case SUBTREE:
+                subTree( node );
+                break;
+            case SWAP:
+                swap( node );
+                break;
+            case COLOR_SUBTREE:
+                colorSubtree( node );
+                break;
+            case COLOR_NODE_FONT:
+                colorNodeFont( node );
+                break;
+            case CHANGE_NODE_FONT:
+                changeNodeFont( node );
+                break;
+            case OPEN_SEQ_WEB:
+                openSeqWeb( node );
+                break;
+            case BLAST:
+                blast( node );
+                break;
+            case OPEN_TAX_WEB:
+                openTaxWeb( node );
+                break;
+            case OPEN_PDB_WEB:
+                openPdbWeb( node );
+                break;
+            case CUT_SUBTREE:
+                cutSubtree( node );
+                break;
+            case COPY_SUBTREE:
+                copySubtree( node );
+                break;
+            case PASTE_SUBTREE:
+                pasteSubtree( node );
+                break;
+            case DELETE_NODE_OR_SUBTREE:
+                deleteNodeOrSubtree( node );
+                break;
+            case ADD_NEW_NODE:
+                addEmptyNode( node );
+                break;
+            case EDIT_NODE_DATA:
+                showNodeEditFrame( node );
+                break;
+            case SELECT_NODES:
+                selectNode( node );
+                break;
+            case SORT_DESCENDENTS:
+                sortDescendants( node );
+                break;
+            case GET_EXT_DESC_DATA:
+                showExtDescNodeData( node );
+                break;
+            default:
+                throw new IllegalArgumentException( "unknown action: " + action );
+        }
     }
 
-    final void paintBranchCircular( final PhylogenyNode p,
-                                    final PhylogenyNode c,
-                                    final Graphics2D g,
-                                    final boolean radial_labels,
-                                    final boolean to_pdf,
-                                    final boolean to_graphics_file ) {
-        final double angle = _urt_nodeid_angle_map.get( c.getId() );
-        final double root_x = _root.getXcoord();
-        final double root_y = _root.getYcoord();
-        final double dx = root_x - p.getXcoord();
-        final double dy = root_y - p.getYcoord();
-        final double parent_radius = Math.sqrt( ( dx * dx ) + ( dy * dy ) );
-        final double arc = ( _urt_nodeid_angle_map.get( p.getId() ) ) - angle;
-        assignGraphicsForBranchWithColorForParentBranch( c, false, g, to_pdf, to_graphics_file );
-        if ( ( c.isFirstChildNode() || c.isLastChildNode() )
-                && ( ( Math.abs( parent_radius * arc ) > 1.5 ) || to_pdf || to_graphics_file ) ) {
-            final double r2 = 2.0 * parent_radius;
-            drawArc( root_x - parent_radius, root_y - parent_radius, r2, r2, ( -angle - arc ), arc, g );
-        }
-        drawLine( c.getXcoord(),
-                  c.getYcoord(),
-                  root_x + ( Math.cos( angle ) * parent_radius ),
-                  root_y + ( Math.sin( angle ) * parent_radius ),
-                  g );
-        paintNodeBox( c.getXcoord(), c.getYcoord(), c, g, to_pdf, to_graphics_file );
-        if ( c.isExternal() ) {
-            final boolean is_in_found_nodes = isInFoundNodes0( c ) || isInFoundNodes1( c )
-                    || isInCurrentExternalNodes( c );
-            if ( ( _dynamic_hiding_factor > 1 ) && !is_in_found_nodes
-                    && ( ( _urt_nodeid_index_map.get( c.getId() ) % _dynamic_hiding_factor ) != 1 ) ) {
-                return;
-            }
-            paintNodeDataUnrootedCirc( g, c, to_pdf, to_graphics_file, radial_labels, 0, is_in_found_nodes );
-        }
+    final private void increaseCurrentExternalNodesDataBufferChangeCounter() {
+        _current_external_nodes_data_buffer_change_counter++;
     }
 
-    final void paintBranchCircularLite( final PhylogenyNode p, final PhylogenyNode c, final Graphics2D g ) {
-        final double angle = _urt_nodeid_angle_map.get( c.getId() );
-        final double root_x = _root.getXSecondary();
-        final double root_y = _root.getYSecondary();
-        final double dx = root_x - p.getXSecondary();
-        final double dy = root_y - p.getYSecondary();
-        final double arc = ( _urt_nodeid_angle_map.get( p.getId() ) ) - angle;
-        final double parent_radius = Math.sqrt( ( dx * dx ) + ( dy * dy ) );
-        g.setColor( getTreeColorSet().getOvColor() );
-        if ( ( c.isFirstChildNode() || c.isLastChildNode() ) && ( Math.abs( arc ) > 0.02 ) ) {
-            final double r2 = 2.0 * parent_radius;
-            drawArc( root_x - parent_radius, root_y - parent_radius, r2, r2, ( -angle - arc ), arc, g );
-        }
-        drawLine( c.getXSecondary(),
-                  c.getYSecondary(),
-                  root_x + ( Math.cos( angle ) * parent_radius ),
-                  root_y + ( Math.sin( angle ) * parent_radius ),
-                  g );
-        if ( isInFoundNodes( c ) || isInCurrentExternalNodes( c ) ) {
-            g.setColor( getColorForFoundNode( c ) );
-            drawRectFilled( c.getXSecondary() - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF, c.getYSecondary()
-                            - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF, OVERVIEW_FOUND_NODE_BOX_SIZE, OVERVIEW_FOUND_NODE_BOX_SIZE, g );
+    final private void increaseOvSize() {
+        if ( ( getOvMaxWidth() < ( getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect().getWidth() / 2 ) )
+                && ( getOvMaxHeight() < ( getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect()
+                        .getHeight() / 2 ) ) ) {
+            setOvMaxWidth( getOvMaxWidth() + 5 );
+            setOvMaxHeight( getOvMaxHeight() + 5 );
+            updateOvSettings();
+            getControlPanel().displayedPhylogenyMightHaveChanged( false );
         }
     }
 
-    final void paintCircular( final Phylogeny phy,
-                              final double starting_angle,
-                              final int center_x,
-                              final int center_y,
-                              final int radius,
-                              final Graphics2D g,
-                              final boolean to_pdf,
-                              final boolean to_graphics_file ) {
-        final int circ_num_ext_nodes = phy.getNumberOfExternalNodes() - _collapsed_external_nodeid_set.size();
-        System.out.println( "# collapsed external = " + _collapsed_external_nodeid_set.size() );
-        _root = phy.getRoot();
-        _root.setXcoord( center_x );
-        _root.setYcoord( center_y );
-        final boolean radial_labels = getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL;
-        double current_angle = starting_angle;
-        int i = 0;
-        for( final PhylogenyNodeIterator it = phy.iteratorExternalForward(); it.hasNext(); ) {
-            final PhylogenyNode n = it.next();
-            if ( !n.isCollapse() ) {
-                n.setXcoord( ( float ) ( center_x + ( radius * Math.cos( current_angle ) ) ) );
-                n.setYcoord( ( float ) ( center_y + ( radius * Math.sin( current_angle ) ) ) );
-                _urt_nodeid_angle_map.put( n.getId(), current_angle );
-                _urt_nodeid_index_map.put( n.getId(), i++ );
-                current_angle += ( TWO_PI / circ_num_ext_nodes );
-            }
-            else {
-                //TODO remove me
-                System.out.println( "is collapse" + n.getName() );
-            }
+    final private void init() {
+        _color_chooser = new JColorChooser();
+        _rollover_popup = new JTextArea();
+        _rollover_popup.setFont( POPUP_FONT );
+        resetNodeIdToDistToLeafMap();
+        setTextAntialias();
+        setTreeFile( null );
+        setEdited( false );
+        initializeOvSettings();
+        setStartingAngle( ( TWO_PI * 3 ) / 4 );
+        final ImageLoader il = new ImageLoader( this );
+        new Thread( il ).start();
+    }
+
+    final private void initializeOvSettings() {
+        setOvMaxHeight( getConfiguration().getOvMaxHeight() );
+        setOvMaxWidth( getConfiguration().getOvMaxWidth() );
+    }
+
+    final private boolean inOvVirtualRectangle( final int x, final int y ) {
+        return ( ( x >= ( getOvVirtualRectangle().x - 1 ) )
+                && ( x <= ( getOvVirtualRectangle().x + getOvVirtualRectangle().width + 1 ) )
+                && ( y >= ( getOvVirtualRectangle().y - 1 ) ) && ( y <= ( getOvVirtualRectangle().y
+                + getOvVirtualRectangle().height + 1 ) ) );
+    }
+
+    final private boolean inOvVirtualRectangle( final MouseEvent e ) {
+        return ( inOvVirtualRectangle( e.getX(), e.getY() ) );
+    }
+
+    final private boolean isCanBlast( final PhylogenyNode node ) {
+        if ( !node.getNodeData().isHasSequence() && ForesterUtil.isEmpty( node.getName() ) ) {
+            return false;
         }
-        paintCirculars( phy.getRoot(), phy, center_x, center_y, radius, radial_labels, g, to_pdf, to_graphics_file );
-        paintNodeBox( _root.getXcoord(), _root.getYcoord(), _root, g, to_pdf, to_graphics_file );
+        return Blast.isContainsQueryForBlast( node );
     }
 
-    final void paintCircularLite( final Phylogeny phy,
-                                  final double starting_angle,
-                                  final int center_x,
-                                  final int center_y,
-                                  final int radius,
-                                  final Graphics2D g ) {
-        final int circ_num_ext_nodes = phy.getNumberOfExternalNodes();
-        _root = phy.getRoot();
-        _root.setXSecondary( center_x );
-        _root.setYSecondary( center_y );
-        double current_angle = starting_angle;
-        for( final PhylogenyNodeIterator it = phy.iteratorExternalForward(); it.hasNext(); ) {
-            final PhylogenyNode n = it.next();
-            n.setXSecondary( ( float ) ( center_x + ( radius * Math.cos( current_angle ) ) ) );
-            n.setYSecondary( ( float ) ( center_y + ( radius * Math.sin( current_angle ) ) ) );
-            _urt_nodeid_angle_map.put( n.getId(), current_angle );
-            current_angle += ( TWO_PI / circ_num_ext_nodes );
+    final private String isCanOpenSeqWeb( final PhylogenyNode node ) {
+        final Accession a = SequenceAccessionTools.obtainAccessorFromDataFields( node );
+        if ( a != null ) {
+            return a.getValue();
         }
-        paintCircularsLite( phy.getRoot(), phy, center_x, center_y, radius, g );
+        return null;
     }
 
-    final void paintPhylogeny( final Graphics2D g,
-                               final boolean to_pdf,
-                               final boolean to_graphics_file,
-                               final int graphics_file_width,
-                               final int graphics_file_height,
-                               final int graphics_file_x,
-                               final int graphics_file_y ) {
-        if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
-            return;
+    final private boolean isCanOpenTaxWeb( final PhylogenyNode node ) {
+        if ( node.getNodeData().isHasTaxonomy()
+                && ( ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getScientificName() ) )
+                        || ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getTaxonomyCode() ) )
+                        || ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getCommonName() ) ) || ( ( node
+                        .getNodeData().getTaxonomy().getIdentifier() != null ) && !ForesterUtil.isEmpty( node
+                        .getNodeData().getTaxonomy().getIdentifier().getValue() ) ) ) ) {
+            return true;
         }
-        if ( _control_panel.isShowSequenceRelations() ) {
-            _query_sequence = _control_panel.getSelectedQuerySequence();
+        else {
+            return false;
         }
-        // Color the background
-        if ( !to_pdf ) {
-            final Rectangle r = getVisibleRect();
-            if ( !getOptions().isBackgroundColorGradient() || getOptions().isPrintBlackAndWhite() ) {
-                g.setColor( getTreeColorSet().getBackgroundColor() );
-                if ( !to_graphics_file ) {
-                    g.fill( r );
-                }
-                else {
-                    if ( getOptions().isPrintBlackAndWhite() ) {
-                        g.setColor( Color.WHITE );
-                    }
-                    g.fillRect( graphics_file_x, graphics_file_y, graphics_file_width, graphics_file_height );
+    }
+
+    final private boolean isInCurrentExternalNodes( final PhylogenyNode node ) {
+        return ( ( getCurrentExternalNodes() != null ) && getCurrentExternalNodes().contains( node.getId() ) );
+    }
+
+    private boolean isInFoundNodes( final PhylogenyNode n ) {
+        return isInFoundNodes0( n ) || isInFoundNodes1( n );
+    }
+
+    final private boolean isInFoundNodes0( final PhylogenyNode node ) {
+        return ( ( getFoundNodes0() != null ) && getFoundNodes0().contains( node.getId() ) );
+    }
+
+    final private boolean isInFoundNodes1( final PhylogenyNode node ) {
+        return ( ( getFoundNodes1() != null ) && getFoundNodes1().contains( node.getId() ) );
+    }
+
+    final private boolean isInOv() {
+        return _in_ov;
+    }
+
+    final private boolean isNodeDataInvisible( final PhylogenyNode node ) {
+        int y_dist = 40;
+        if ( getControlPanel().isShowTaxonomyImages() ) {
+            y_dist = 40 + ( int ) getYdistance();
+        }
+        return ( ( node.getYcoord() < ( getVisibleRect().getMinY() - y_dist ) )
+                || ( node.getYcoord() > ( getVisibleRect().getMaxY() + y_dist ) ) || ( ( node.getParent() != null ) && ( node
+                .getParent().getXcoord() > getVisibleRect().getMaxX() ) ) );
+    }
+
+    final private boolean isNodeDataInvisibleUnrootedCirc( final PhylogenyNode node ) {
+        return ( ( node.getYcoord() < ( getVisibleRect().getMinY() - 20 ) )
+                || ( node.getYcoord() > ( getVisibleRect().getMaxY() + 20 ) )
+                || ( node.getXcoord() < ( getVisibleRect().getMinX() - 20 ) ) || ( node.getXcoord() > ( getVisibleRect()
+                .getMaxX() + 20 ) ) );
+    }
+
+    final private boolean isNonLinedUpCladogram() {
+        return getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP;
+    }
+
+    final private boolean isUniformBranchLengthsForCladogram() {
+        return getOptions().getCladogramType() == CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP;
+    }
+
+    final private void keyPressedCalls( final KeyEvent e ) {
+        if ( isOvOn() && ( getMousePosition() != null ) && ( getMousePosition().getLocation() != null ) ) {
+            if ( inOvVirtualRectangle( getMousePosition().x, getMousePosition().y ) ) {
+                if ( !isInOvRect() ) {
+                    setInOvRect( true );
                 }
             }
-            else {
-                if ( !to_graphics_file ) {
-                    g.setPaint( new GradientPaint( r.x, r.y, getTreeColorSet().getBackgroundColor(), r.x, r.y
-                                                   + r.height, getTreeColorSet().getBackgroundColorGradientBottom() ) );
-                    g.fill( r );
-                }
-                else {
-                    g.setPaint( new GradientPaint( graphics_file_x,
-                                                   graphics_file_y,
-                                                   getTreeColorSet().getBackgroundColor(),
-                                                   graphics_file_x,
-                                                   graphics_file_y + graphics_file_height,
-                                                   getTreeColorSet().getBackgroundColorGradientBottom() ) );
-                    g.fillRect( graphics_file_x, graphics_file_y, graphics_file_width, graphics_file_height );
-                }
+            else if ( isInOvRect() ) {
+                setInOvRect( false );
             }
-            setupStroke( g );
         }
-        else {
-            g.setStroke( new BasicStroke( getOptions().getPrintLineWidth() ) );
-        }
-        if ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
-                && ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
-            _external_node_index = 0;
-            // Position starting X of tree
-            if ( !_phylogeny.isRooted() /*|| ( _subtree_index > 0 )*/) {
-                _phylogeny.getRoot().setXcoord( TreePanel.MOVE );
+        if ( e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK ) {
+            if ( ( e.getKeyCode() == KeyEvent.VK_DELETE ) || ( e.getKeyCode() == KeyEvent.VK_HOME )
+                    || ( e.getKeyCode() == KeyEvent.VK_F ) ) {
+                getMainPanel().getTreeFontSet().mediumFonts();
+                getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( true );
             }
-            else if ( ( _phylogeny.getRoot().getDistanceToParent() > 0.0 ) && getControlPanel().isDrawPhylogram() ) {
-                _phylogeny.getRoot().setXcoord( ( float ) ( TreePanel.MOVE + ( _phylogeny.getRoot()
-                        .getDistanceToParent() * getXcorrectionFactor() ) ) );
+            else if ( ( e.getKeyCode() == KeyEvent.VK_SUBTRACT ) || ( e.getKeyCode() == KeyEvent.VK_MINUS ) ) {
+                getMainPanel().getTreeFontSet().decreaseFontSize( 1, false );
+                getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( true );
             }
-            else {
-                _phylogeny.getRoot().setXcoord( TreePanel.MOVE + getXdistance() );
+            else if ( plusPressed( e.getKeyCode() ) ) {
+                getMainPanel().getTreeFontSet().increaseFontSize();
+                getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( true );
             }
-            // Position starting Y of tree
-            _phylogeny.getRoot().setYcoord( ( getYdistance() * _phylogeny.getRoot().getNumberOfExternalNodes() )
-                                            + ( TreePanel.MOVE / 2.0f ) );
-            final int dynamic_hiding_factor = calcDynamicHidingFactor();
-            if ( getControlPanel().isDynamicallyHideData() ) {
-                if ( dynamic_hiding_factor > 1 ) {
-                    getControlPanel().setDynamicHidingIsOn( true );
+        }
+        else {
+            if ( ( e.getKeyCode() == KeyEvent.VK_DELETE ) || ( e.getKeyCode() == KeyEvent.VK_HOME )
+                    || ( e.getKeyCode() == KeyEvent.VK_F ) ) {
+                getControlPanel().showWhole();
+            }
+            else if ( ( e.getKeyCode() == KeyEvent.VK_UP ) || ( e.getKeyCode() == KeyEvent.VK_DOWN )
+                    || ( e.getKeyCode() == KeyEvent.VK_LEFT ) || ( e.getKeyCode() == KeyEvent.VK_RIGHT ) ) {
+                if ( e.getModifiersEx() == InputEvent.SHIFT_DOWN_MASK ) {
+                    if ( e.getKeyCode() == KeyEvent.VK_UP ) {
+                        getMainPanel().getControlPanel().zoomInY( Constants.WHEEL_ZOOM_IN_FACTOR );
+                        getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
+                    }
+                    else if ( e.getKeyCode() == KeyEvent.VK_DOWN ) {
+                        getMainPanel().getControlPanel().zoomOutY( Constants.WHEEL_ZOOM_OUT_FACTOR );
+                        getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
+                    }
+                    else if ( e.getKeyCode() == KeyEvent.VK_LEFT ) {
+                        getMainPanel().getControlPanel().zoomOutX( Constants.WHEEL_ZOOM_OUT_FACTOR,
+                                                                   Constants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR );
+                        getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
+                    }
+                    else if ( e.getKeyCode() == KeyEvent.VK_RIGHT ) {
+                        getMainPanel().getControlPanel().zoomInX( Constants.WHEEL_ZOOM_IN_FACTOR,
+                                                                  Constants.WHEEL_ZOOM_IN_FACTOR );
+                        getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
+                    }
                 }
                 else {
-                    getControlPanel().setDynamicHidingIsOn( false );
+                    final int d = 80;
+                    int dx = 0;
+                    int dy = -d;
+                    if ( e.getKeyCode() == KeyEvent.VK_DOWN ) {
+                        dy = d;
+                    }
+                    else if ( e.getKeyCode() == KeyEvent.VK_LEFT ) {
+                        dx = -d;
+                        dy = 0;
+                    }
+                    else if ( e.getKeyCode() == KeyEvent.VK_RIGHT ) {
+                        dx = d;
+                        dy = 0;
+                    }
+                    final Point scroll_position = getMainPanel().getCurrentScrollPane().getViewport().getViewPosition();
+                    scroll_position.x = scroll_position.x + dx;
+                    scroll_position.y = scroll_position.y + dy;
+                    if ( scroll_position.x <= 0 ) {
+                        scroll_position.x = 0;
+                    }
+                    else {
+                        final int max_x = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getMaximum()
+                                - getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getVisibleAmount();
+                        if ( scroll_position.x >= max_x ) {
+                            scroll_position.x = max_x;
+                        }
+                    }
+                    if ( scroll_position.y <= 0 ) {
+                        scroll_position.y = 0;
+                    }
+                    else {
+                        final int max_y = getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getMaximum()
+                                - getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getVisibleAmount();
+                        if ( scroll_position.y >= max_y ) {
+                            scroll_position.y = max_y;
+                        }
+                    }
+                    repaint();
+                    getMainPanel().getCurrentScrollPane().getViewport().setViewPosition( scroll_position );
                 }
             }
-            if ( _nodes_in_preorder == null ) {
-                _nodes_in_preorder = new PhylogenyNode[ _phylogeny.getNodeCount() ];
-                int i = 0;
-                for( final PhylogenyNodeIterator it = _phylogeny.iteratorPreorder(); it.hasNext(); ) {
-                    _nodes_in_preorder[ i++ ] = it.next();
-                }
+            else if ( ( e.getKeyCode() == KeyEvent.VK_SUBTRACT ) || ( e.getKeyCode() == KeyEvent.VK_MINUS ) ) {
+                getMainPanel().getControlPanel().zoomOutY( Constants.WHEEL_ZOOM_OUT_FACTOR );
+                getMainPanel().getControlPanel().zoomOutX( Constants.WHEEL_ZOOM_OUT_FACTOR,
+                                                           Constants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR );
+                getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
             }
-            final boolean disallow_shortcutting = ( dynamic_hiding_factor < 40 )
-                    || getControlPanel().isUseVisualStyles() || getOptions().isShowDefaultNodeShapesForMarkedNodes()
-                    || ( ( getFoundNodes0() != null ) && !getFoundNodes0().isEmpty() )
-                    || ( ( getFoundNodes1() != null ) && !getFoundNodes1().isEmpty() )
-                    || ( ( getCurrentExternalNodes() != null ) && !getCurrentExternalNodes().isEmpty() )
-                    || to_graphics_file || to_pdf;
-            for( final PhylogenyNode element : _nodes_in_preorder ) {
-                paintNodeRectangular( g,
-                                      element,
-                                      to_pdf,
-                                      getControlPanel().isDynamicallyHideData() && ( dynamic_hiding_factor > 1 ),
-                                      dynamic_hiding_factor,
-                                      to_graphics_file,
-                                      disallow_shortcutting );
+            else if ( plusPressed( e.getKeyCode() ) ) {
+                getMainPanel().getControlPanel().zoomInX( Constants.WHEEL_ZOOM_IN_FACTOR,
+                                                          Constants.WHEEL_ZOOM_IN_FACTOR );
+                getMainPanel().getControlPanel().zoomInY( Constants.WHEEL_ZOOM_IN_FACTOR );
+                getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
             }
-            if ( getOptions().isShowScale() && getControlPanel().isDrawPhylogram() && ( getScaleDistance() > 0.0 ) ) {
-                if ( !( to_graphics_file || to_pdf ) ) {
-                    paintScale( g,
-                                getVisibleRect().x,
-                                getVisibleRect().y + getVisibleRect().height,
-                                to_pdf,
-                                to_graphics_file );
-                }
-                else {
-                    paintScale( g, graphics_file_x, graphics_file_y + graphics_file_height, to_pdf, to_graphics_file );
+            else if ( e.getKeyCode() == KeyEvent.VK_S ) {
+                if ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
+                        || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
+                    setStartingAngle( ( getStartingAngle() % TWO_PI ) + ANGLE_ROTATION_UNIT );
+                    getControlPanel().displayedPhylogenyMightHaveChanged( false );
                 }
             }
-            if ( getOptions().isShowOverview() && isOvOn() && !to_graphics_file && !to_pdf ) {
-                paintPhylogenyLite( g );
-            }
-        }
-        else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
-            if ( getControlPanel().getDynamicallyHideData() != null ) {
-                getControlPanel().setDynamicHidingIsOn( false );
-            }
-            final double angle = getStartingAngle();
-            final boolean radial_labels = getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL;
-            _dynamic_hiding_factor = 0;
-            if ( getControlPanel().isDynamicallyHideData() ) {
-                _dynamic_hiding_factor = ( int ) ( ( getFontMetricsForLargeDefaultFont().getHeight() * 1.5 * getPhylogeny()
-                        .getNumberOfExternalNodes() ) / ( TWO_PI * 10 ) );
+            else if ( e.getKeyCode() == KeyEvent.VK_A ) {
+                if ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
+                        || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
+                    setStartingAngle( ( getStartingAngle() % TWO_PI ) - ANGLE_ROTATION_UNIT );
+                    if ( getStartingAngle() < 0 ) {
+                        setStartingAngle( TWO_PI + getStartingAngle() );
+                    }
+                    getControlPanel().displayedPhylogenyMightHaveChanged( false );
+                }
             }
-            if ( getControlPanel().getDynamicallyHideData() != null ) {
-                if ( _dynamic_hiding_factor > 1 ) {
-                    getControlPanel().setDynamicHidingIsOn( true );
+            else if ( e.getKeyCode() == KeyEvent.VK_D ) {
+                boolean selected = false;
+                if ( getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.HORIZONTAL ) {
+                    getOptions().setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
+                    selected = true;
                 }
                 else {
-                    getControlPanel().setDynamicHidingIsOn( false );
+                    getOptions().setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
                 }
-            }
-            paintUnrooted( _phylogeny.getRoot(),
-                           angle,
-                           ( float ) ( angle + ( 2 * Math.PI ) ),
-                           radial_labels,
-                           g,
-                           to_pdf,
-                           to_graphics_file );
-            if ( getOptions().isShowScale() ) {
-                if ( !( to_graphics_file || to_pdf ) ) {
-                    paintScale( g,
-                                getVisibleRect().x,
-                                getVisibleRect().y + getVisibleRect().height,
-                                to_pdf,
-                                to_graphics_file );
+                if ( getMainPanel().getMainFrame() == null ) {
+                    // Must be "E" applet version.
+                    final ArchaeopteryxE ae = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
+                    if ( ae.getlabelDirectionCbmi() != null ) {
+                        ae.getlabelDirectionCbmi().setSelected( selected );
+                    }
                 }
                 else {
-                    paintScale( g, graphics_file_x, graphics_file_y + graphics_file_height, to_pdf, to_graphics_file );
+                    getMainPanel().getMainFrame().getlabelDirectionCbmi().setSelected( selected );
                 }
+                repaint();
             }
-            if ( getOptions().isShowOverview() && isOvOn() && !to_graphics_file && !to_pdf ) {
-                g.setColor( getTreeColorSet().getOvColor() );
-                paintUnrootedLite( _phylogeny.getRoot(),
-                                   angle,
-                                   angle + ( 2 * Math.PI ),
-                                   g,
-                                   ( getUrtFactorOv() / ( getVisibleRect().width / getOvMaxWidth() ) ) );
-                paintOvRectangle( g );
+            else if ( e.getKeyCode() == KeyEvent.VK_X ) {
+                switchDisplaygetPhylogenyGraphicsType();
+                repaint();
             }
-        }
-        else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
-            final int radius = ( int ) ( ( Math.min( getPreferredSize().getWidth(), getPreferredSize().getHeight() ) / 2 ) - ( MOVE + getLongestExtNodeInfo() ) );
-            final int d = radius + MOVE + getLongestExtNodeInfo();
-            _dynamic_hiding_factor = 0;
-            if ( getControlPanel().isDynamicallyHideData() && ( radius > 0 ) ) {
-                _dynamic_hiding_factor = ( int ) ( ( getFontMetricsForLargeDefaultFont().getHeight() * 1.5 * getPhylogeny()
-                        .getNumberOfExternalNodes() ) / ( TWO_PI * radius ) );
+            else if ( e.getKeyCode() == KeyEvent.VK_C ) {
+                cycleColors();
+                repaint();
             }
-            if ( getControlPanel().getDynamicallyHideData() != null ) {
-                if ( _dynamic_hiding_factor > 1 ) {
-                    getControlPanel().setDynamicHidingIsOn( true );
-                }
-                else {
-                    getControlPanel().setDynamicHidingIsOn( false );
-                }
+            else if ( getOptions().isShowOverview() && isOvOn() && ( e.getKeyCode() == KeyEvent.VK_O ) ) {
+                MainFrame.cycleOverview( getOptions(), this );
+                repaint();
             }
-            paintCircular( _phylogeny, getStartingAngle(), d, d, radius > 0 ? radius : 0, g, to_pdf, to_graphics_file );
-            if ( getOptions().isShowOverview() && isOvOn() && !to_graphics_file && !to_pdf ) {
-                final int radius_ov = ( int ) ( getOvMaxHeight() < getOvMaxWidth() ? getOvMaxHeight() / 2
-                        : getOvMaxWidth() / 2 );
-                double x_scale = 1.0;
-                double y_scale = 1.0;
-                int x_pos = getVisibleRect().x + getOvXPosition();
-                int y_pos = getVisibleRect().y + getOvYPosition();
-                if ( getWidth() > getHeight() ) {
-                    x_scale = ( double ) getHeight() / getWidth();
-                    x_pos = ForesterUtil.roundToInt( x_pos / x_scale );
-                }
-                else {
-                    y_scale = ( double ) getWidth() / getHeight();
-                    y_pos = ForesterUtil.roundToInt( y_pos / y_scale );
-                }
-                _at = g.getTransform();
-                g.scale( x_scale, y_scale );
-                paintCircularLite( _phylogeny,
-                                   getStartingAngle(),
-                                   x_pos + radius_ov,
-                                   y_pos + radius_ov,
-                                   ( int ) ( radius_ov - ( getLongestExtNodeInfo() / ( getVisibleRect().width / getOvRectangle()
-                                           .getWidth() ) ) ),
-                                           g );
-                g.setTransform( _at );
-                paintOvRectangle( g );
+            else if ( getOptions().isShowOverview() && isOvOn() && ( e.getKeyCode() == KeyEvent.VK_I ) ) {
+                increaseOvSize();
             }
+            else if ( getOptions().isShowOverview() && isOvOn() && ( e.getKeyCode() == KeyEvent.VK_U ) ) {
+                decreaseOvSize();
+            }
+            e.consume();
         }
     }
 
-    final void recalculateMaxDistanceToRoot() {
-        _max_distance_to_root = PhylogenyMethods.calculateMaxDistanceToRoot( getPhylogeny() );
-    }
-
-    /**
-     * Remove all edit-node frames
-     */
-    final void removeAllEditNodeJFrames() {
-        for( int i = 0; i <= ( TreePanel.MAX_NODE_FRAMES - 1 ); i++ ) {
-            if ( _node_frames[ i ] != null ) {
-                _node_frames[ i ].dispose();
-                _node_frames[ i ] = null;
+    final private void makePopupMenus( final PhylogenyNode node ) {
+        _node_popup_menu = new JPopupMenu();
+        final List<String> clickto_names = _main_panel.getControlPanel().getSingleClickToNames();
+        _node_popup_menu_items = new JMenuItem[ clickto_names.size() ];
+        for( int i = 0; i < clickto_names.size(); i++ ) {
+            final String title = clickto_names.get( i );
+            _node_popup_menu_items[ i ] = new JMenuItem( title );
+            if ( title.equals( Configuration.clickto_options[ Configuration.open_seq_web ][ 0 ] ) ) {
+                final String id = isCanOpenSeqWeb( node );
+                if ( !ForesterUtil.isEmpty( id ) ) {
+                    _node_popup_menu_items[ i ].setText( _node_popup_menu_items[ i ].getText() + " [" + id + "]" );
+                    _node_popup_menu_items[ i ].setEnabled( true );
+                }
+                else {
+                    _node_popup_menu_items[ i ].setEnabled( false );
+                }
+            }
+            else if ( title.equals( Configuration.clickto_options[ Configuration.open_pdb_web ][ 0 ] ) ) {
+                final List<Accession> accs = getPdbAccs( node );
+                _node_popup_menu_items[ i ] = new JMenuItem( title );
+                if ( !ForesterUtil.isEmpty( accs ) ) {
+                    if ( accs.size() == 1 ) {
+                        _node_popup_menu_items[ i ].setText( _node_popup_menu_items[ i ].getText() + " ["
+                                + TreePanelUtil.pdbAccToString( accs, 0 ) + "]" );
+                        _node_popup_menu_items[ i ].setEnabled( true );
+                    }
+                    else if ( accs.size() == 2 ) {
+                        _node_popup_menu_items[ i ].setText( _node_popup_menu_items[ i ].getText() + " ["
+                                + TreePanelUtil.pdbAccToString( accs, 0 ) + ", "
+                                + TreePanelUtil.pdbAccToString( accs, 1 ) + "]" );
+                        _node_popup_menu_items[ i ].setEnabled( true );
+                    }
+                    else if ( accs.size() == 3 ) {
+                        _node_popup_menu_items[ i ].setText( _node_popup_menu_items[ i ].getText() + " ["
+                                + TreePanelUtil.pdbAccToString( accs, 0 ) + ", "
+                                + TreePanelUtil.pdbAccToString( accs, 1 ) + ", "
+                                + TreePanelUtil.pdbAccToString( accs, 2 ) + "]" );
+                        _node_popup_menu_items[ i ].setEnabled( true );
+                    }
+                    else {
+                        _node_popup_menu_items[ i ].setText( _node_popup_menu_items[ i ].getText() + " ["
+                                + TreePanelUtil.pdbAccToString( accs, 0 ) + ", "
+                                + TreePanelUtil.pdbAccToString( accs, 1 ) + ", "
+                                + TreePanelUtil.pdbAccToString( accs, 2 ) + ", + " + ( accs.size() - 3 ) + " more]" );
+                        _node_popup_menu_items[ i ].setEnabled( true );
+                    }
+                }
+                else {
+                    _node_popup_menu_items[ i ].setEnabled( false );
+                }
+            }
+            else if ( title.startsWith( Configuration.clickto_options[ Configuration.get_ext_desc_data ][ 0 ] ) ) {
+                _node_popup_menu_items[ i ]
+                        .setText( Configuration.clickto_options[ Configuration.get_ext_desc_data ][ 0 ] + ": "
+                                + getOptions().getExtDescNodeDataToReturn().toString() );
+            }
+            else if ( title.equals( Configuration.clickto_options[ Configuration.open_tax_web ][ 0 ] ) ) {
+                _node_popup_menu_items[ i ].setEnabled( isCanOpenTaxWeb( node ) );
+            }
+            else if ( title.equals( Configuration.clickto_options[ Configuration.blast ][ 0 ] ) ) {
+                _node_popup_menu_items[ i ].setEnabled( isCanBlast( node ) );
+            }
+            else if ( title.equals( Configuration.clickto_options[ Configuration.delete_subtree_or_node ][ 0 ] ) ) {
+                if ( !getOptions().isEditable() ) {
+                    continue;
+                }
+                _node_popup_menu_items[ i ].setEnabled( isCanDelete() );
+            }
+            else if ( title.equals( Configuration.clickto_options[ Configuration.cut_subtree ][ 0 ] ) ) {
+                if ( !getOptions().isEditable() ) {
+                    continue;
+                }
+                _node_popup_menu_items[ i ].setEnabled( isCanCut( node ) );
+            }
+            else if ( title.equals( Configuration.clickto_options[ Configuration.copy_subtree ][ 0 ] ) ) {
+                if ( !getOptions().isEditable() ) {
+                    continue;
+                }
+                _node_popup_menu_items[ i ].setEnabled( isCanCopy() );
+            }
+            else if ( title.equals( Configuration.clickto_options[ Configuration.paste_subtree ][ 0 ] ) ) {
+                if ( !getOptions().isEditable() ) {
+                    continue;
+                }
+                _node_popup_menu_items[ i ].setEnabled( isCanPaste() );
+            }
+            else if ( title.equals( Configuration.clickto_options[ Configuration.edit_node_data ][ 0 ] ) ) {
+                if ( !getOptions().isEditable() ) {
+                    continue;
+                }
+            }
+            else if ( title.equals( Configuration.clickto_options[ Configuration.add_new_node ][ 0 ] ) ) {
+                if ( !getOptions().isEditable() ) {
+                    continue;
+                }
+            }
+            else if ( title.equals( Configuration.clickto_options[ Configuration.reroot ][ 0 ] ) ) {
+                _node_popup_menu_items[ i ].setEnabled( isCanReroot() );
+            }
+            else if ( title.equals( Configuration.clickto_options[ Configuration.collapse_uncollapse ][ 0 ] ) ) {
+                _node_popup_menu_items[ i ].setEnabled( ( isCanCollapse() && !node.isExternal() ) );
+            }
+            else if ( title.equals( Configuration.clickto_options[ Configuration.color_subtree ][ 0 ] ) ) {
+                _node_popup_menu_items[ i ].setEnabled( isCanColorSubtree() );
+            }
+            else if ( title.equals( Configuration.clickto_options[ Configuration.subtree ][ 0 ] ) ) {
+                _node_popup_menu_items[ i ].setEnabled( isCanSubtree( node ) );
+            }
+            else if ( title.equals( Configuration.clickto_options[ Configuration.swap ][ 0 ] ) ) {
+                _node_popup_menu_items[ i ].setEnabled( node.getNumberOfDescendants() == 2 );
+            }
+            else if ( title.equals( Configuration.clickto_options[ Configuration.sort_descendents ][ 0 ] ) ) {
+                _node_popup_menu_items[ i ].setEnabled( node.getNumberOfDescendants() > 1 );
             }
+            _node_popup_menu_items[ i ].addActionListener( this );
+            _node_popup_menu.add( _node_popup_menu_items[ i ] );
         }
-        _node_frame_index = 0;
     }
 
-    /**
-     * Remove a node-edit frame.
-     */
-    final void removeEditNodeFrame( final int i ) {
-        _node_frame_index--;
-        _node_frames[ i ] = null;
-        if ( i < _node_frame_index ) {
-            for( int j = 0; j < ( _node_frame_index - 1 ); j++ ) {
-                _node_frames[ j ] = _node_frames[ j + 1 ];
+    private final void nodeDataAsSB( final PhylogenyNode node, final StringBuilder sb ) {
+        if ( node != null ) {
+            if ( getControlPanel().isShowNodeNames() && ( !ForesterUtil.isEmpty( node.getName() ) ) ) {
+                if ( sb.length() > 0 ) {
+                    sb.append( " " );
+                }
+                sb.append( node.getName() );
+            }
+            if ( node.getNodeData().isHasSequence() ) {
+                if ( getControlPanel().isShowSeqSymbols()
+                        && ( node.getNodeData().getSequence().getSymbol().length() > 0 ) ) {
+                    if ( sb.length() > 0 ) {
+                        sb.append( " " );
+                    }
+                    sb.append( node.getNodeData().getSequence().getSymbol() );
+                }
+                if ( getControlPanel().isShowGeneNames()
+                        && ( node.getNodeData().getSequence().getGeneName().length() > 0 ) ) {
+                    if ( sb.length() > 0 ) {
+                        sb.append( " " );
+                    }
+                    sb.append( node.getNodeData().getSequence().getGeneName() );
+                }
+                if ( getControlPanel().isShowSeqNames() && ( node.getNodeData().getSequence().getName().length() > 0 ) ) {
+                    if ( sb.length() > 0 ) {
+                        sb.append( " " );
+                    }
+                    sb.append( node.getNodeData().getSequence().getName() );
+                }
+                if ( getControlPanel().isShowSequenceAcc()
+                        && ( node.getNodeData().getSequence().getAccession() != null ) ) {
+                    if ( sb.length() > 0 ) {
+                        sb.append( " " );
+                    }
+                    if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getSource() ) ) {
+                        sb.append( node.getNodeData().getSequence().getAccession().getSource() );
+                        sb.append( ":" );
+                    }
+                    sb.append( node.getNodeData().getSequence().getAccession().getValue() );
+                }
+            }
+            if ( getControlPanel().isShowProperties() && node.getNodeData().isHasProperties() ) {
+                if ( sb.length() > 0 ) {
+                    sb.append( " " );
+                }
+                sb.append( propertiesToString( node ) );
             }
-            _node_frames[ _node_frame_index ] = null;
         }
     }
 
-    final void reRoot( final PhylogenyNode node ) {
-        if ( !getPhylogeny().isRerootable() ) {
-            JOptionPane.showMessageDialog( this,
-                                           "This is not rerootable",
-                                           "Not rerootable",
-                                           JOptionPane.WARNING_MESSAGE );
-            return;
+    private final void nodeTaxonomyDataAsSB( final Taxonomy taxonomy, final StringBuilder sb ) {
+        if ( _control_panel.isShowTaxonomyCode() && !ForesterUtil.isEmpty( taxonomy.getTaxonomyCode() ) ) {
+            sb.append( taxonomy.getTaxonomyCode() );
+            sb.append( " " );
         }
-        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
-            JOptionPane.showMessageDialog( this,
-                                           "Cannot reroot in unrooted display type",
-                                           "Attempt to reroot tree in unrooted display",
-                                           JOptionPane.WARNING_MESSAGE );
-            return;
+        if ( _control_panel.isShowTaxonomyScientificNames() && _control_panel.isShowTaxonomyCommonNames() ) {
+            if ( !ForesterUtil.isEmpty( taxonomy.getScientificName() )
+                    && !ForesterUtil.isEmpty( taxonomy.getCommonName() ) ) {
+                if ( getOptions().isAbbreviateScientificTaxonNames()
+                        && ( taxonomy.getScientificName().indexOf( ' ' ) > 0 ) ) {
+                    abbreviateScientificName( taxonomy.getScientificName(), sb );
+                }
+                else {
+                    sb.append( taxonomy.getScientificName() );
+                }
+                sb.append( " (" );
+                sb.append( taxonomy.getCommonName() );
+                sb.append( ") " );
+            }
+            else if ( !ForesterUtil.isEmpty( taxonomy.getScientificName() ) ) {
+                if ( getOptions().isAbbreviateScientificTaxonNames()
+                        && ( taxonomy.getScientificName().indexOf( ' ' ) > 0 ) ) {
+                    abbreviateScientificName( taxonomy.getScientificName(), sb );
+                }
+                else {
+                    sb.append( taxonomy.getScientificName() );
+                }
+                sb.append( " " );
+            }
+            else if ( !ForesterUtil.isEmpty( taxonomy.getCommonName() ) ) {
+                sb.append( taxonomy.getCommonName() );
+                sb.append( " " );
+            }
         }
-        getPhylogeny().reRoot( node );
-        getPhylogeny().recalculateNumberOfExternalDescendants( true );
-        resetNodeIdToDistToLeafMap();
-        setNodeInPreorderToNull();
-        resetPreferredSize();
-        getMainPanel().adjustJScrollPane();
-        setEdited( true );
-        repaint();
-        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
-            getControlPanel().showWhole();
+        else if ( _control_panel.isShowTaxonomyScientificNames() ) {
+            if ( !ForesterUtil.isEmpty( taxonomy.getScientificName() ) ) {
+                if ( getOptions().isAbbreviateScientificTaxonNames()
+                        && ( taxonomy.getScientificName().indexOf( ' ' ) > 0 ) ) {
+                    abbreviateScientificName( taxonomy.getScientificName(), sb );
+                }
+                else {
+                    sb.append( taxonomy.getScientificName() );
+                }
+                sb.append( " " );
+            }
+        }
+        else if ( _control_panel.isShowTaxonomyCommonNames() ) {
+            if ( !ForesterUtil.isEmpty( taxonomy.getCommonName() ) ) {
+                sb.append( taxonomy.getCommonName() );
+                sb.append( " " );
+            }
         }
     }
 
-    final void resetNodeIdToDistToLeafMap() {
-        _nodeid_dist_to_leaf = new HashMap<Long, Short>();
+    private final String obtainTitleForExtDescNodeData() {
+        return getOptions().getExtDescNodeDataToReturn().toString();
     }
 
-    final void resetPreferredSize() {
-        if ( ( getPhylogeny() == null ) || getPhylogeny().isEmpty() ) {
-            return;
-        }
-        int x = 0;
-        int y = 0;
-        y = TreePanel.MOVE
-                + ForesterUtil.roundToInt( getYdistance() * getPhylogeny().getRoot().getNumberOfExternalNodes() * 2 );
-        if ( getControlPanel().isDrawPhylogram() ) {
-            x = TreePanel.MOVE
-                    + getLongestExtNodeInfo()
-                    + ForesterUtil
-                    .roundToInt( ( getXcorrectionFactor() * getPhylogeny().getHeight() ) + getXdistance() );
-        }
-        else {
-            if ( !isNonLinedUpCladogram() && !isUniformBranchLengthsForCladogram() ) {
-                x = TreePanel.MOVE
-                        + getLongestExtNodeInfo()
-                        + ForesterUtil.roundToInt( getXdistance()
-                                                   * ( getPhylogeny().getRoot().getNumberOfExternalNodes() + 2 ) );
-            }
-            else {
-                x = TreePanel.MOVE
-                        + getLongestExtNodeInfo()
-                        + ForesterUtil.roundToInt( getXdistance()
-                                                   * ( PhylogenyMethods.calculateMaxDepth( getPhylogeny() ) + 1 ) );
-            }
+    final private void openPdbWeb( final PhylogenyNode node ) {
+        final List<Accession> pdb_ids = getPdbAccs( node );
+        if ( ForesterUtil.isEmpty( pdb_ids ) ) {
+            cannotOpenBrowserWarningMessage( "PDB" );
+            return;
         }
-        setPreferredSize( new Dimension( x, y ) );
-    }
-
-    final void selectNode( final PhylogenyNode node ) {
-        if ( ( getFoundNodes0() != null ) && getFoundNodes0().contains( node.getId() ) ) {
-            getFoundNodes0().remove( node.getId() );
-            getControlPanel().setSearchFoundCountsOnLabel0( getFoundNodes0().size() );
-            if ( getFoundNodes0().size() < 1 ) {
-                getControlPanel().searchReset0();
+        final List<String> uri_strs = TreePanelUtil.createUrisForPdbWeb( node, pdb_ids, getConfiguration(), this );
+        if ( !ForesterUtil.isEmpty( uri_strs ) ) {
+            for( final String uri_str : uri_strs ) {
+                try {
+                    AptxUtil.launchWebBrowser( new URI( uri_str ),
+                                               isApplet(),
+                                               isApplet() ? obtainApplet() : null,
+                                               "_aptx_seq" );
+                }
+                catch ( final IOException e ) {
+                    AptxUtil.showErrorMessage( this, e.toString() );
+                    e.printStackTrace();
+                }
+                catch ( final URISyntaxException e ) {
+                    AptxUtil.showErrorMessage( this, e.toString() );
+                    e.printStackTrace();
+                }
             }
         }
         else {
-            getControlPanel().getSearchFoundCountsLabel0().setVisible( true );
-            getControlPanel().getSearchResetButton0().setEnabled( true );
-            getControlPanel().getSearchResetButton0().setVisible( true );
-            if ( getFoundNodes0() == null ) {
-                setFoundNodes0( new HashSet<Long>() );
-            }
-            getFoundNodes0().add( node.getId() );
-            getControlPanel().setSearchFoundCountsOnLabel0( getFoundNodes0().size() );
+            cannotOpenBrowserWarningMessage( "PDB" );
         }
     }
 
-    final void setArrowCursor() {
-        setCursor( ARROW_CURSOR );
-        repaint();
-    }
-
-    final void setControlPanel( final ControlPanel atv_control ) {
-        _control_panel = atv_control;
-    }
-
-    void setCurrentExternalNodesDataBuffer( final StringBuilder sb ) {
-        increaseCurrentExternalNodesDataBufferChangeCounter();
-        _current_external_nodes_data_buffer = sb;
-    }
-
-    final void setFoundNodes0( final Set<Long> found_nodes ) {
-        _found_nodes_0 = found_nodes;
-    }
-
-    final void setFoundNodes1( final Set<Long> found_nodes ) {
-        _found_nodes_1 = found_nodes;
-    }
-
-    final void setInOvRect( final boolean in_ov_rect ) {
-        _in_ov_rect = in_ov_rect;
-    }
-
-    final void setLargeFonts() {
-        getTreeFontSet().largeFonts();
-    }
-
-    final void setLastMouseDragPointX( final float x ) {
-        _last_drag_point_x = x;
-    }
-
-    final void setLastMouseDragPointY( final float y ) {
-        _last_drag_point_y = y;
-    }
-
-    final void setMediumFonts() {
-        getTreeFontSet().mediumFonts();
-    }
-
-    final void setNodeInPreorderToNull() {
-        _nodes_in_preorder = null;
-    }
-
-    final void setOvOn( final boolean ov_on ) {
-        _ov_on = ov_on;
-    }
-
-    final void setPhylogenyGraphicsType( final PHYLOGENY_GRAPHICS_TYPE graphics_type ) {
-        _graphics_type = graphics_type;
-        setTextAntialias();
-    }
-
-    final void setSmallFonts() {
-        getTreeFontSet().smallFonts();
-    }
-
-    final void setStartingAngle( final double starting_angle ) {
-        _urt_starting_angle = starting_angle;
-    }
-
-    void setStatisticsForExpressionValues( final DescriptiveStatistics statistics_for_expression_values ) {
-        _statistics_for_vector_data = statistics_for_expression_values;
-    }
-
-    final void setSuperTinyFonts() {
-        getTreeFontSet().superTinyFonts();
-    }
-
-    final void setTextAntialias() {
-        if ( ( _phylogeny != null ) && !_phylogeny.isEmpty() ) {
-            if ( _phylogeny.getNumberOfExternalNodes() <= LIMIT_FOR_HQ_RENDERING ) {
-                _rendering_hints.put( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY );
+    final private void openSeqWeb( final PhylogenyNode node ) {
+        if ( ForesterUtil.isEmpty( isCanOpenSeqWeb( node ) ) ) {
+            cannotOpenBrowserWarningMessage( "sequence" );
+            return;
+        }
+        final String uri_str = TreePanelUtil.createUriForSeqWeb( node, getConfiguration(), this );
+        if ( !ForesterUtil.isEmpty( uri_str ) ) {
+            try {
+                AptxUtil.launchWebBrowser( new URI( uri_str ),
+                                           isApplet(),
+                                           isApplet() ? obtainApplet() : null,
+                                           "_aptx_seq" );
             }
-            else {
-                _rendering_hints.put( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED );
+            catch ( final IOException e ) {
+                AptxUtil.showErrorMessage( this, e.toString() );
+                e.printStackTrace();
+            }
+            catch ( final URISyntaxException e ) {
+                AptxUtil.showErrorMessage( this, e.toString() );
+                e.printStackTrace();
             }
-        }
-        if ( getMainPanel().getOptions().isAntialiasScreen() ) {
-            _rendering_hints.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
-            // try {
-            _rendering_hints.put( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB );
-            // }
-            // catch ( final Throwable e ) {
-            //    _rendering_hints.put( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON );
-            //}
         }
         else {
-            _rendering_hints.put( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF );
-            _rendering_hints.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
+            cannotOpenBrowserWarningMessage( "sequence" );
         }
     }
 
-    final void setTinyFonts() {
-        getTreeFontSet().tinyFonts();
-    }
-
-    final void setTreeFile( final File treefile ) {
-        _treefile = treefile;
-    }
-
-    final void setXcorrectionFactor( final float f ) {
-        _x_correction_factor = f;
-    }
-
-    final void setXdistance( final float x ) {
-        _x_distance = x;
-    }
-
-    final void setYdistance( final float y ) {
-        _y_distance = y;
-    }
-
-    final void sortDescendants( final PhylogenyNode node ) {
-        if ( !node.isExternal() ) {
-            DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
-            if ( getControlPanel().isShowTaxonomyScientificNames() || getControlPanel().isShowTaxonomyCode() ) {
-                pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
+    final private void openTaxWeb( final PhylogenyNode node ) {
+        if ( !isCanOpenTaxWeb( node ) ) {
+            cannotOpenBrowserWarningMessage( "taxonomic" );
+            return;
+        }
+        String uri_str = null;
+        final Taxonomy tax = node.getNodeData().getTaxonomy();
+        if ( ( tax.getIdentifier() != null ) && !ForesterUtil.isEmpty( tax.getIdentifier().getValue() )
+                && tax.getIdentifier().getValue().startsWith( "http://" ) ) {
+            try {
+                uri_str = new URI( tax.getIdentifier().getValue() ).toString();
             }
-            else if ( getControlPanel().isShowSeqNames() || getControlPanel().isShowSeqSymbols()
-                    || getControlPanel().isShowGeneNames() ) {
-                pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
+            catch ( final URISyntaxException e ) {
+                AptxUtil.showErrorMessage( this, e.toString() );
+                uri_str = null;
+                e.printStackTrace();
             }
-            PhylogenyMethods.sortNodeDescendents( node, pri );
-            setNodeInPreorderToNull();
-            _phylogeny.externalNodesHaveChanged();
-            _phylogeny.clearHashIdToNodeMap();
-            _phylogeny.recalculateNumberOfExternalDescendants( true );
-            resetNodeIdToDistToLeafMap();
-            setEdited( true );
         }
-        repaint();
-    }
-
-    final void subTree( final PhylogenyNode node ) {
-        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
-            JOptionPane.showMessageDialog( this,
-                                           "Cannot get a sub/super tree in unrooted display",
-                                           "Attempt to get sub/super tree in unrooted display",
-                                           JOptionPane.WARNING_MESSAGE );
-            return;
+        else if ( ( tax.getIdentifier() != null )
+                && !ForesterUtil.isEmpty( tax.getIdentifier().getValue() )
+                && !ForesterUtil.isEmpty( tax.getIdentifier().getProvider() )
+                && ( tax.getIdentifier().getProvider().equalsIgnoreCase( "ncbi" ) || tax.getIdentifier().getProvider()
+                        .equalsIgnoreCase( "uniprot" ) ) ) {
+            try {
+                uri_str = "http://www.uniprot.org/taxonomy/"
+                        + URLEncoder.encode( tax.getIdentifier().getValue(), ForesterConstants.UTF8 );
+            }
+            catch ( final UnsupportedEncodingException e ) {
+                AptxUtil.showErrorMessage( this, e.toString() );
+                e.printStackTrace();
+            }
         }
-        if ( node.isExternal() ) {
-            JOptionPane.showMessageDialog( this,
-                                           "Cannot get a subtree of a external node",
-                                           "Attempt to get subtree of external node",
-                                           JOptionPane.WARNING_MESSAGE );
-            return;
+        else if ( !ForesterUtil.isEmpty( tax.getScientificName() ) ) {
+            try {
+                uri_str = "http://www.uniprot.org/taxonomy/?query="
+                        + URLEncoder.encode( tax.getScientificName(), ForesterConstants.UTF8 );
+            }
+            catch ( final UnsupportedEncodingException e ) {
+                AptxUtil.showErrorMessage( this, e.toString() );
+                e.printStackTrace();
+            }
         }
-        if ( node.isRoot() && !isCurrentTreeIsSubtree() ) {
-            JOptionPane.showMessageDialog( this,
-                                           "Cannot get a subtree of the root node",
-                                           "Attempt to get subtree of root node",
-                                           JOptionPane.WARNING_MESSAGE );
-            return;
-        }
-        setNodeInPreorderToNull();
-        if ( !node.isExternal() && !node.isRoot() && ( _subtree_index <= ( TreePanel.MAX_SUBTREES - 1 ) ) ) {
-            _sub_phylogenies[ _subtree_index ] = _phylogeny;
-            _sub_phylogenies_temp_roots[ _subtree_index ] = node;
-            ++_subtree_index;
-            _phylogeny = TreePanelUtil.subTree( node, _phylogeny );
-            updateSubSuperTreeButton();
-        }
-        else if ( node.isRoot() && isCurrentTreeIsSubtree() ) {
-            superTree();
-        }
-        _main_panel.getControlPanel().showWhole();
-        repaint();
-    }
-
-    final void superTree() {
-        setNodeInPreorderToNull();
-        final PhylogenyNode temp_root = _sub_phylogenies_temp_roots[ _subtree_index - 1 ];
-        for( final PhylogenyNode n : temp_root.getDescendants() ) {
-            n.setParent( temp_root );
+        else if ( !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) {
+            try {
+                uri_str = "http://www.uniprot.org/taxonomy/?query="
+                        + URLEncoder.encode( tax.getTaxonomyCode(), ForesterConstants.UTF8 );
+            }
+            catch ( final UnsupportedEncodingException e ) {
+                AptxUtil.showErrorMessage( this, e.toString() );
+                e.printStackTrace();
+            }
         }
-        _sub_phylogenies[ _subtree_index ] = null;
-        _sub_phylogenies_temp_roots[ _subtree_index ] = null;
-        _phylogeny = _sub_phylogenies[ --_subtree_index ];
-        updateSubSuperTreeButton();
-    }
-
-    final void swap( final PhylogenyNode node ) {
-        if ( node.isExternal() || ( node.getNumberOfDescendants() < 2 ) ) {
-            return;
+        else if ( !ForesterUtil.isEmpty( tax.getCommonName() ) ) {
+            try {
+                uri_str = "http://www.uniprot.org/taxonomy/?query="
+                        + URLEncoder.encode( tax.getCommonName(), ForesterConstants.UTF8 );
+            }
+            catch ( final UnsupportedEncodingException e ) {
+                AptxUtil.showErrorMessage( this, e.toString() );
+                e.printStackTrace();
+            }
         }
-        if ( node.getNumberOfDescendants() > 2 ) {
-            JOptionPane.showMessageDialog( this,
-                                           "Cannot swap descendants of nodes with more than 2 descendants",
-                                           "Cannot swap descendants",
-                                           JOptionPane.ERROR_MESSAGE );
-            return;
+        if ( !ForesterUtil.isEmpty( uri_str ) ) {
+            try {
+                AptxUtil.launchWebBrowser( new URI( uri_str ),
+                                           isApplet(),
+                                           isApplet() ? obtainApplet() : null,
+                                           "_aptx_tax" );
+            }
+            catch ( final IOException e ) {
+                AptxUtil.showErrorMessage( this, e.toString() );
+                e.printStackTrace();
+            }
+            catch ( final URISyntaxException e ) {
+                AptxUtil.showErrorMessage( this, e.toString() );
+                e.printStackTrace();
+            }
         }
-        if ( !node.isExternal() ) {
-            node.swapChildren();
-            setNodeInPreorderToNull();
-            _phylogeny.externalNodesHaveChanged();
-            _phylogeny.clearHashIdToNodeMap();
-            _phylogeny.recalculateNumberOfExternalDescendants( true );
-            resetNodeIdToDistToLeafMap();
-            setEdited( true );
+        else {
+            cannotOpenBrowserWarningMessage( "taxonomic" );
         }
-        repaint();
     }
 
-    final void taxColor() {
-        if ( ( _phylogeny == null ) || ( _phylogeny.getNumberOfExternalNodes() < 2 ) ) {
-            return;
-        }
-        setWaitCursor();
-        TreePanelUtil.colorPhylogenyAccordingToExternalTaxonomy( _phylogeny, this );
-        _control_panel.setColorBranches( true );
-        if ( _control_panel.getUseVisualStylesCb() != null ) {
-            _control_panel.getUseVisualStylesCb().setSelected( true );
+    final private void paintBranchLength( final Graphics2D g,
+                                          final PhylogenyNode node,
+                                          final boolean to_pdf,
+                                          final boolean to_graphics_file ) {
+        g.setFont( getTreeFontSet().getSmallFont() );
+        if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
+            g.setColor( Color.BLACK );
         }
-        setEdited( true );
-        setArrowCursor();
-        repaint();
-    }
-
-    final void updateOvSettings() {
-        switch ( getOptions().getOvPlacement() ) {
-            case LOWER_LEFT:
-                setOvXPosition( OV_BORDER );
-                setOvYPosition( ForesterUtil.roundToInt( getVisibleRect().height - OV_BORDER - getOvMaxHeight() ) );
-                setOvYStart( ForesterUtil.roundToInt( getOvYPosition() + ( getOvMaxHeight() / 2 ) ) );
-                break;
-            case LOWER_RIGHT:
-                setOvXPosition( ForesterUtil.roundToInt( getVisibleRect().width - OV_BORDER - getOvMaxWidth() ) );
-                setOvYPosition( ForesterUtil.roundToInt( getVisibleRect().height - OV_BORDER - getOvMaxHeight() ) );
-                setOvYStart( ForesterUtil.roundToInt( getOvYPosition() + ( getOvMaxHeight() / 2 ) ) );
-                break;
-            case UPPER_RIGHT:
-                setOvXPosition( ForesterUtil.roundToInt( getVisibleRect().width - OV_BORDER - getOvMaxWidth() ) );
-                setOvYPosition( OV_BORDER );
-                setOvYStart( ForesterUtil.roundToInt( OV_BORDER + ( getOvMaxHeight() / 2 ) ) );
-                break;
-            default:
-                setOvXPosition( OV_BORDER );
-                setOvYPosition( OV_BORDER );
-                setOvYStart( ForesterUtil.roundToInt( OV_BORDER + ( getOvMaxHeight() / 2 ) ) );
-                break;
+        else {
+            g.setColor( getTreeColorSet().getBranchLengthColor() );
         }
-    }
-
-    final void updateOvSizes() {
-        if ( ( getWidth() > ( 1.05 * getVisibleRect().width ) ) || ( getHeight() > ( 1.05 * getVisibleRect().height ) ) ) {
-            setOvOn( true );
-            float l = getLongestExtNodeInfo();
-            final float w_ratio = getOvMaxWidth() / getWidth();
-            l *= w_ratio;
-            final int ext_nodes = _phylogeny.getRoot().getNumberOfExternalNodes();
-            setOvYDistance( getOvMaxHeight() / ( 2 * ext_nodes ) );
-            float ov_xdist = 0;
-            if ( !isNonLinedUpCladogram() && !isUniformBranchLengthsForCladogram() ) {
-                ov_xdist = ( ( getOvMaxWidth() - l ) / ( ext_nodes ) );
-            }
-            else {
-                ov_xdist = ( ( getOvMaxWidth() - l ) / ( PhylogenyMethods.calculateMaxDepth( _phylogeny ) ) );
-            }
-            float ydist = ( float ) ( ( getOvMaxWidth() / ( ext_nodes * 2.0 ) ) );
-            if ( ov_xdist < 0.0 ) {
-                ov_xdist = 0.0f;
-            }
-            if ( ydist < 0.0 ) {
-                ydist = 0.0f;
+        if ( !node.isRoot() ) {
+            if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) {
+                TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ), node.getParent()
+                        .getXcoord() + EURO_D, node.getYcoord() - getTreeFontSet().getSmallMaxDescent(), g );
             }
-            setOvXDistance( ov_xdist );
-            final double height = _phylogeny.getHeight();
-            if ( height > 0 ) {
-                final float ov_corr = ( float ) ( ( ( getOvMaxWidth() - l ) - getOvXDistance() ) / height );
-                setOvXcorrectionFactor( ov_corr > 0 ? ov_corr : 0 );
+            else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) {
+                TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ), node.getParent()
+                        .getXcoord() + ROUNDED_D, node.getYcoord() - getTreeFontSet().getSmallMaxDescent(), g );
             }
             else {
-                setOvXcorrectionFactor( 0 );
+                TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ), node.getParent()
+                        .getXcoord() + 3, node.getYcoord() - getTreeFontSet().getSmallMaxDescent(), g );
             }
         }
         else {
-            setOvOn( false );
+            TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ), 3, node.getYcoord()
+                    - getTreeFontSet().getSmallMaxDescent(), g );
         }
     }
 
-    void updateSetOfCollapsedExternalNodes() {
-        final Phylogeny phy = getPhylogeny();
-        _collapsed_external_nodeid_set.clear();
-        if ( phy != null ) {
-            E: for( final PhylogenyNodeIterator it = phy.iteratorExternalForward(); it.hasNext(); ) {
-                final PhylogenyNode ext_node = it.next();
-                PhylogenyNode n = ext_node;
-                while ( !n.isRoot() ) {
-                    if ( n.isCollapse() ) {
-                        _collapsed_external_nodeid_set.add( ext_node.getId() );
-                        ext_node.setCollapse( true );
-                        continue E;
-                    }
-                    n = n.getParent();
-                }
-            }
+    final private void paintBranchLite( final Graphics2D g,
+                                        final float x1,
+                                        final float x2,
+                                        final float y1,
+                                        final float y2,
+                                        final PhylogenyNode node ) {
+        g.setColor( getTreeColorSet().getOvColor() );
+        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR ) {
+            drawLine( x1, y1, x2, y2, g );
         }
-    }
-
-    final void updateSubSuperTreeButton() {
-        if ( _subtree_index < 1 ) {
-            getControlPanel().deactivateButtonToReturnToSuperTree();
+        else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CONVEX ) {
+            _quad_curve.setCurve( x1, y1, x1, y2, x2, y2 );
+            ( g ).draw( _quad_curve );
+        }
+        else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CURVED ) {
+            final float dx = x2 - x1;
+            final float dy = y2 - y1;
+            _cubic_curve.setCurve( x1, y1, x1 + ( dx * 0.4f ), y1 + ( dy * 0.2f ), x1 + ( dx * 0.6f ), y1
+                    + ( dy * 0.8f ), x2, y2 );
+            ( g ).draw( _cubic_curve );
         }
         else {
-            getControlPanel().activateButtonToReturnToSuperTree( _subtree_index );
+            final float x2a = x2;
+            final float x1a = x1;
+            // draw the vertical line
+            if ( node.isFirstChildNode() || node.isLastChildNode() ) {
+                drawLine( x1, y1, x1, y2, g );
+            }
+            // draw the horizontal line
+            drawLine( x1a, y2, x2a, y2, g );
         }
     }
 
-    final void zoomInDomainStructure() {
-        if ( _domain_structure_width < 2000 ) {
-            _domain_structure_width *= 1.2;
+    /**
+     * Paint a branch which consists of a vertical and a horizontal bar
+     * @param is_ind_found_nodes
+     */
+    final private void paintBranchRectangular( final Graphics2D g,
+                                               final float x1,
+                                               final float x2,
+                                               final float y1,
+                                               final float y2,
+                                               final PhylogenyNode node,
+                                               final boolean to_pdf,
+                                               final boolean to_graphics_file ) {
+        assignGraphicsForBranchWithColorForParentBranch( node, false, g, to_pdf, to_graphics_file );
+        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR ) {
+            drawLine( x1, y1, x2, y2, g );
         }
-    }
-
-    final void zoomOutDomainStructure() {
-        if ( _domain_structure_width > 20 ) {
-            _domain_structure_width *= 0.8;
+        else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CONVEX ) {
+            _quad_curve.setCurve( x1, y1, x1, y2, x2, y2 );
+            g.draw( _quad_curve );
         }
-    }
-
-    private void abbreviateScientificName( final String sn, final StringBuilder sb ) {
-        final String[] a = sn.split( "\\s+" );
-        sb.append( a[ 0 ].substring( 0, 1 ) );
-        sb.append( a[ 1 ].substring( 0, 2 ) );
-        if ( a.length > 2 ) {
-            for( int i = 2; i < a.length; i++ ) {
-                sb.append( " " );
-                sb.append( a[ i ] );
-            }
-        }
-    }
-
-    final private void addEmptyNode( final PhylogenyNode node ) {
-        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
-            errorMessageNoCutCopyPasteInUnrootedDisplay();
-            return;
-        }
-        final String label = createASimpleTextRepresentationOfANode( node );
-        String msg = "";
-        if ( ForesterUtil.isEmpty( label ) ) {
-            msg = "How to add the new, empty node?";
-        }
-        else {
-            msg = "How to add the new, empty node to node" + label + "?";
-        }
-        final Object[] options = { "As sibling", "As descendant", "Cancel" };
-        final int r = JOptionPane.showOptionDialog( this,
-                                                    msg,
-                                                    "Addition of Empty New Node",
-                                                    JOptionPane.CLOSED_OPTION,
-                                                    JOptionPane.QUESTION_MESSAGE,
-                                                    null,
-                                                    options,
-                                                    options[ 2 ] );
-        boolean add_as_sibling = true;
-        if ( r == 1 ) {
-            add_as_sibling = false;
-        }
-        else if ( r != 0 ) {
-            return;
-        }
-        final Phylogeny phy = new Phylogeny();
-        phy.setRoot( new PhylogenyNode() );
-        phy.setRooted( true );
-        if ( add_as_sibling ) {
-            if ( node.isRoot() ) {
-                JOptionPane.showMessageDialog( this,
-                                               "Cannot add sibling to root",
-                                               "Attempt to add sibling to root",
-                                               JOptionPane.ERROR_MESSAGE );
-                return;
-            }
-            phy.addAsSibling( node );
-        }
-        else {
-            phy.addAsChild( node );
-        }
-        setNodeInPreorderToNull();
-        _phylogeny.externalNodesHaveChanged();
-        _phylogeny.clearHashIdToNodeMap();
-        _phylogeny.recalculateNumberOfExternalDescendants( true );
-        resetNodeIdToDistToLeafMap();
-        setEdited( true );
-        repaint();
-    }
-
-    final private void addToCurrentExternalNodes( final long i ) {
-        if ( _current_external_nodes == null ) {
-            _current_external_nodes = new HashSet<Long>();
-        }
-        _current_external_nodes.add( i );
-    }
-
-    final private void assignGraphicsForBranchWithColorForParentBranch( final PhylogenyNode node,
-                                                                        final boolean is_vertical,
-                                                                        final Graphics g,
-                                                                        final boolean to_pdf,
-                                                                        final boolean to_graphics_file ) {
-        final NodeClickAction action = _control_panel.getActionWhenNodeClicked();
-        if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
-            g.setColor( Color.BLACK );
-        }
-        else if ( ( ( action == NodeClickAction.COPY_SUBTREE ) || ( action == NodeClickAction.CUT_SUBTREE )
-                || ( action == NodeClickAction.DELETE_NODE_OR_SUBTREE ) || ( action == NodeClickAction.PASTE_SUBTREE ) || ( action == NodeClickAction.ADD_NEW_NODE ) )
-                && ( getCutOrCopiedTree() != null )
-                && ( getCopiedAndPastedNodes() != null )
-                && !to_pdf
-                && !to_graphics_file && getCopiedAndPastedNodes().contains( node.getId() ) ) {
-            g.setColor( getTreeColorSet().getFoundColor0() );
-        }
-        else if ( getControlPanel().isUseVisualStyles() && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) {
-            g.setColor( PhylogenyMethods.getBranchColorValue( node ) );
-        }
-        else if ( to_pdf ) {
-            g.setColor( getTreeColorSet().getBranchColorForPdf() );
-        }
-        else {
-            g.setColor( getTreeColorSet().getBranchColor() );
-        }
-    }
-
-    final private void blast( final PhylogenyNode node ) {
-        if ( !isCanBlast( node ) ) {
-            JOptionPane.showMessageDialog( this,
-                                           "Insufficient information present",
-                                           "Cannot Blast",
-                                           JOptionPane.INFORMATION_MESSAGE );
-            return;
+        else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CURVED ) {
+            final float dx = x2 - x1;
+            final float dy = y2 - y1;
+            _cubic_curve.setCurve( x1, y1, x1 + ( dx * 0.4f ), y1 + ( dy * 0.2f ), x1 + ( dx * 0.6f ), y1
+                    + ( dy * 0.8f ), x2, y2 );
+            g.draw( _cubic_curve );
         }
         else {
-            final String query = Blast.obtainQueryForBlast( node );
-            System.out.println( "query for BLAST is: " + query );
-            char type = '?';
-            if ( !ForesterUtil.isEmpty( query ) ) {
-                if ( node.getNodeData().isHasSequence() ) {
-                    if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getType() ) ) {
-                        if ( node.getNodeData().getSequence().getType().toLowerCase()
-                                .equals( PhyloXmlUtil.SEQ_TYPE_PROTEIN ) ) {
-                            type = 'p';
-                        }
-                        else {
-                            type = 'n';
+            final float x2a = x2;
+            final float x1a = x1;
+            float y2_r = 0;
+            if ( node.isFirstChildNode() || node.isLastChildNode()
+                    || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE )
+                    || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) ) {
+                if ( !to_graphics_file
+                        && !to_pdf
+                        && ( ( ( y2 < ( getVisibleRect().getMinY() - 20 ) ) && ( y1 < ( getVisibleRect().getMinY() - 20 ) ) ) || ( ( y2 > ( getVisibleRect()
+                                .getMaxY() + 20 ) ) && ( y1 > ( getVisibleRect().getMaxY() + 20 ) ) ) ) ) {
+                    // Do nothing.
+                }
+                else {
+                    if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) {
+                        float x2c = x1 + EURO_D;
+                        if ( x2c > x2a ) {
+                            x2c = x2a;
                         }
+                        drawLine( x1, y1, x2c, y2, g );
                     }
-                    else if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) {
-                        if ( ForesterUtil.seqIsLikelyToBeAa( node.getNodeData().getSequence().getMolecularSequence() ) ) {
-                            type = 'p';
+                    else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) {
+                        if ( y2 > y1 ) {
+                            y2_r = y2 - ROUNDED_D;
+                            if ( y2_r < y1 ) {
+                                y2_r = y1;
+                            }
+                            drawLine( x1, y1, x1, y2_r, g );
                         }
                         else {
-                            type = 'n';
+                            y2_r = y2 + ROUNDED_D;
+                            if ( y2_r > y1 ) {
+                                y2_r = y1;
+                            }
+                            drawLine( x1, y1, x1, y2_r, g );
                         }
                     }
-                }
-                if ( type == '?' ) {
-                    if ( SequenceAccessionTools.isProteinDbQuery( query ) ) {
-                        type = 'p';
-                    }
                     else {
-                        type = 'n';
+                        drawLine( x1, y1, x1, y2, g );
                     }
                 }
-                JApplet applet = null;
-                if ( isApplet() ) {
-                    applet = obtainApplet();
+            }
+            // draw the horizontal line
+            if ( !to_graphics_file && !to_pdf
+                    && ( ( y2 < ( getVisibleRect().getMinY() - 20 ) ) || ( y2 > ( getVisibleRect().getMaxY() + 20 ) ) ) ) {
+                return;
+            }
+            float x1_r = 0;
+            if ( !getControlPanel().isWidthBranches() || ( PhylogenyMethods.getBranchWidthValue( node ) == 1 ) ) {
+                if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) {
+                    x1_r = x1a + ROUNDED_D;
+                    if ( x1_r < x2a ) {
+                        drawLine( x1_r, y2, x2a, y2, g );
+                    }
                 }
-                try {
-                    Blast.openNcbiBlastWeb( query, type == 'n', applet, this );
+                else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) {
+                    final float x1c = x1a + EURO_D;
+                    if ( x1c < x2a ) {
+                        drawLine( x1c, y2, x2a, y2, g );
+                    }
                 }
-                catch ( final Exception e ) {
-                    e.printStackTrace();
+                else {
+                    drawLine( x1a, y2, x2a, y2, g );
                 }
-                if ( Constants.ALLOW_DDBJ_BLAST ) {
-                    try {
-                        System.out.println( "trying: " + query );
-                        final Blast s = new Blast();
-                        s.ddbjBlast( query );
+            }
+            else {
+                final double w = PhylogenyMethods.getBranchWidthValue( node );
+                if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) {
+                    x1_r = x1a + ROUNDED_D;
+                    if ( x1_r < x2a ) {
+                        drawRectFilled( x1_r, y2 - ( w / 2 ), x2a - x1_r, w, g );
                     }
-                    catch ( final Exception e ) {
-                        e.printStackTrace();
+                }
+                else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) {
+                    final float x1c = x1a + EURO_D;
+                    if ( x1c < x2a ) {
+                        drawRectFilled( x1c, y2 - ( w / 2 ), x2a - x1c, w, g );
                     }
                 }
+                else {
+                    drawRectFilled( x1a, y2 - ( w / 2 ), x2a - x1a, w, g );
+                }
+            }
+            if ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) ) {
+                if ( x1_r > x2a ) {
+                    x1_r = x2a;
+                }
+                if ( y2 > y2_r ) {
+                    final double diff = y2 - y2_r;
+                    _arc.setArc( x1, y2_r - diff, 2 * ( x1_r - x1 ), 2 * diff, 180, 90, Arc2D.OPEN );
+                }
+                else {
+                    _arc.setArc( x1, y2, 2 * ( x1_r - x1 ), 2 * ( y2_r - y2 ), 90, 90, Arc2D.OPEN );
+                }
+                g.draw( _arc );
             }
         }
+        if ( node.isExternal() ) {
+            paintNodeBox( x2, y2, node, g, to_pdf, to_graphics_file );
+        }
     }
 
-    private final int calcDynamicHidingFactor() {
-        return ( int ) ( 0.5 + ( getFontMetricsForLargeDefaultFont().getHeight() / ( 1.5 * getYdistance() ) ) );
-    }
-
-    /**
-     * Calculate the length of the distance between the given node and its
-     * parent.
-     *
-     * @param node
-     * @param ext_node_x
-     * @factor
-     * @return the distance value
-     */
-    final private float calculateBranchLengthToParent( final PhylogenyNode node, final float factor ) {
-        if ( getControlPanel().isDrawPhylogram() ) {
-            if ( node.getDistanceToParent() < 0.0 ) {
-                return 0.0f;
+    final private double paintCirculars( final PhylogenyNode n,
+                                         final Phylogeny phy,
+                                         final float center_x,
+                                         final float center_y,
+                                         final double radius,
+                                         final boolean radial_labels,
+                                         final Graphics2D g,
+                                         final boolean to_pdf,
+                                         final boolean to_graphics_file ) {
+        if ( n.isExternal() || n.isCollapse() ) { //~~circ collapse
+            if ( !_urt_nodeid_angle_map.containsKey( n.getId() ) ) {
+                System.out.println( "no " + n + " =====>>>>>>> ERROR!" );//TODO
             }
-            return ( float ) ( getXcorrectionFactor() * node.getDistanceToParent() );
+            return _urt_nodeid_angle_map.get( n.getId() );
         }
         else {
-            if ( ( factor == 0 ) || isNonLinedUpCladogram() ) {
-                return getXdistance();
-            }
-            return getXdistance() * factor;
-        }
-    }
-
-    final private Color calculateColorForAnnotation( final SortedSet<Annotation> ann ) {
-        Color c = getTreeColorSet().getAnnotationColor();
-        if ( getControlPanel().isColorAccordingToAnnotation() && ( getControlPanel().getAnnotationColors() != null ) ) {
-            final StringBuilder sb = new StringBuilder();
-            for( final Annotation a : ann ) {
-                sb.append( !ForesterUtil.isEmpty( a.getRefValue() ) ? a.getRefValue() : a.getDesc() );
+            final List<PhylogenyNode> descs = n.getDescendants();
+            double sum = 0;
+            for( final PhylogenyNode desc : descs ) {
+                sum += paintCirculars( desc,
+                                       phy,
+                                       center_x,
+                                       center_y,
+                                       radius,
+                                       radial_labels,
+                                       g,
+                                       to_pdf,
+                                       to_graphics_file );
             }
-            final String ann_str = sb.toString();
-            if ( !ForesterUtil.isEmpty( ann_str ) ) {
-                c = getControlPanel().getAnnotationColors().get( ann_str );
-                if ( c == null ) {
-                    c = AptxUtil.calculateColorFromString( ann_str, false );
-                    getControlPanel().getAnnotationColors().put( ann_str, c );
-                }
-                if ( c == null ) {
-                    c = getTreeColorSet().getAnnotationColor();
-                }
+            double r = 0;
+            if ( !n.isRoot() ) {
+                r = 1 - ( ( ( double ) _circ_max_depth - n.calculateDepth() ) / _circ_max_depth );
+            }
+            final double theta = sum / descs.size();
+            n.setXcoord( ( float ) ( center_x + ( r * radius * Math.cos( theta ) ) ) );
+            n.setYcoord( ( float ) ( center_y + ( r * radius * Math.sin( theta ) ) ) );
+            _urt_nodeid_angle_map.put( n.getId(), theta );
+            for( final PhylogenyNode desc : descs ) {
+                paintBranchCircular( n, desc, g, radial_labels, to_pdf, to_graphics_file );
             }
+            return theta;
         }
-        return c;
     }
 
-    final private float calculateOvBranchLengthToParent( final PhylogenyNode node, final int factor ) {
-        if ( getControlPanel().isDrawPhylogram() ) {
-            if ( node.getDistanceToParent() < 0.0 ) {
-                return 0.0f;
-            }
-            return ( float ) ( getOvXcorrectionFactor() * node.getDistanceToParent() );
+    final private void paintCircularsLite( final PhylogenyNode n,
+                                           final Phylogeny phy,
+                                           final int center_x,
+                                           final int center_y,
+                                           final int radius,
+                                           final Graphics2D g ) {
+        if ( n.isExternal() ) {
+            return;
         }
         else {
-            if ( ( factor == 0 ) || isNonLinedUpCladogram() ) {
-                return getOvXDistance();
+            final List<PhylogenyNode> descs = n.getDescendants();
+            for( final PhylogenyNode desc : descs ) {
+                paintCircularsLite( desc, phy, center_x, center_y, radius, g );
+            }
+            float r = 0;
+            if ( !n.isRoot() ) {
+                r = 1 - ( ( ( float ) _circ_max_depth - n.calculateDepth() ) / _circ_max_depth );
+            }
+            final double theta = _urt_nodeid_angle_map.get( n.getId() );
+            n.setXSecondary( ( float ) ( center_x + ( radius * r * Math.cos( theta ) ) ) );
+            n.setYSecondary( ( float ) ( center_y + ( radius * r * Math.sin( theta ) ) ) );
+            for( final PhylogenyNode desc : descs ) {
+                paintBranchCircularLite( n, desc, g );
             }
-            return getOvXDistance() * factor;
         }
     }
 
-    final private void cannotOpenBrowserWarningMessage( final String type_type ) {
-        JOptionPane.showMessageDialog( this,
-                                       "Cannot launch web browser for " + type_type + " data of this node",
-                                       "Cannot launch web browser",
-                                       JOptionPane.WARNING_MESSAGE );
-    }
-
-    private void changeNodeFont( final PhylogenyNode node ) {
-        final FontChooser fc = new FontChooser();
-        Font f = null;
-        if ( ( node.getNodeData().getNodeVisualData() != null ) && !node.getNodeData().getNodeVisualData().isEmpty() ) {
-            f = node.getNodeData().getNodeVisualData().getFont();
-        }
-        if ( f != null ) {
-            fc.setFont( f );
+    final private void paintCollapsedNode( final Graphics2D g,
+                                           final PhylogenyNode node,
+                                           final boolean to_graphics_file,
+                                           final boolean to_pdf,
+                                           final boolean is_in_found_nodes ) {
+        Color c = null;
+        if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
+            c = Color.BLACK;
         }
-        else {
-            fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
+        else if ( is_in_found_nodes ) {
+            c = getColorForFoundNode( node );
         }
-        List<PhylogenyNode> nodes = new ArrayList<PhylogenyNode>();
-        if ( ( getFoundNodes0() != null ) || ( getFoundNodes1() != null ) ) {
-            nodes = getFoundNodesAsListOfPhylogenyNodes();
+        else if ( getControlPanel().isColorAccordingToSequence() ) {
+            c = getSequenceBasedColor( node );
         }
-        if ( !nodes.contains( node ) ) {
-            nodes.add( node );
+        else if ( getControlPanel().isColorAccordingToTaxonomy() ) {
+            c = getTaxonomyBasedColor( node );
         }
-        final int count = nodes.size();
-        String title = "Change the font for ";
-        if ( count == 1 ) {
-            title += "one node";
+        else if ( getOptions().isColorLabelsSameAsParentBranch() && getControlPanel().isUseVisualStyles()
+                && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) {
+            c = PhylogenyMethods.getBranchColorValue( node );
         }
         else {
-            title += ( count + " nodes" );
-        }
-        fc.showDialog( this, title );
-        if ( ( fc.getFont() != null ) && !ForesterUtil.isEmpty( fc.getFont().getFamily().trim() ) ) {
-            for( final PhylogenyNode n : nodes ) {
-                if ( n.getNodeData().getNodeVisualData() == null ) {
-                    n.getNodeData().setNodeVisualData( new NodeVisualData() );
-                }
-                final NodeVisualData vd = n.getNodeData().getNodeVisualData();
-                final Font ff = fc.getFont();
-                vd.setFontName( ff.getFamily().trim() );
-                int s = ff.getSize();
-                if ( s < 0 ) {
-                    s = 0;
-                }
-                if ( s > Byte.MAX_VALUE ) {
-                    s = Byte.MAX_VALUE;
-                }
-                vd.setFontSize( s );
-                vd.setFontStyle( ff.getStyle() );
-            }
-            if ( _control_panel.getUseVisualStylesCb() != null ) {
-                getControlPanel().getUseVisualStylesCb().setSelected( true );
-            }
+            c = getTreeColorSet().getCollapseFillColor();
         }
-        setEdited( true );
-        repaint();
-    }
-
-    private void colorNodeFont( final PhylogenyNode node ) {
-        _color_chooser.setPreviewPanel( new JPanel() );
-        NodeColorizationActionListener al;
-        int count = 1;
-        if ( ( getFoundNodes0() != null ) || ( getFoundNodes1() != null ) ) {
-            final List<PhylogenyNode> additional_nodes = getFoundNodesAsListOfPhylogenyNodes();
-            al = new NodeColorizationActionListener( _color_chooser, node, additional_nodes );
-            count = additional_nodes.size();
-            if ( !additional_nodes.contains( node ) ) {
-                count++;
-            }
+        double d = node.getAllExternalDescendants().size();
+        if ( d > 1000 ) {
+            d = ( 3 * _y_distance ) / 3;
         }
         else {
-            al = new NodeColorizationActionListener( _color_chooser, node );
-        }
-        String title = "Change the (node and font) color for ";
-        if ( count == 1 ) {
-            title += "one node";
+            d = ( Math.log10( d ) * _y_distance ) / 2.5;
         }
-        else {
-            title += ( count + " nodes" );
+        final int box_size = getOptions().getDefaultNodeShapeSize() + 1;
+        if ( d < box_size ) {
+            d = box_size;
         }
-        final JDialog dialog = JColorChooser.createDialog( this, title, true, _color_chooser, al, null );
-        setEdited( true );
-        dialog.setVisible( true );
-    }
-
-    final private void colorizeNodes( final Color c,
-                                      final PhylogenyNode node,
-                                      final List<PhylogenyNode> additional_nodes ) {
-        _control_panel.setColorBranches( true );
-        if ( _control_panel.getUseVisualStylesCb() != null ) {
-            _control_panel.getUseVisualStylesCb().setSelected( true );
+        final float xx = node.getXcoord() - ( 2 * box_size );
+        final float xxx = xx > ( node.getParent().getXcoord() + 1 ) ? xx : node.getParent().getXcoord() + 1;
+        _polygon.reset();
+        _polygon.moveTo( xxx, node.getYcoord() );
+        _polygon.lineTo( node.getXcoord() + 1, node.getYcoord() - d );
+        _polygon.lineTo( node.getXcoord() + 1, node.getYcoord() + d );
+        _polygon.closePath();
+        if ( getOptions().getDefaultNodeFill() == NodeVisualData.NodeFill.SOLID ) {
+            g.setColor( c );
+            g.fill( _polygon );
         }
-        if ( node != null ) {
-            colorizeNodesHelper( c, node );
+        else if ( getOptions().getDefaultNodeFill() == NodeVisualData.NodeFill.NONE ) {
+            g.setColor( getBackground() );
+            g.fill( _polygon );
+            g.setColor( c );
+            g.draw( _polygon );
         }
-        if ( additional_nodes != null ) {
-            for( final PhylogenyNode n : additional_nodes ) {
-                colorizeNodesHelper( c, n );
-            }
+        else if ( getOptions().getDefaultNodeFill() == NodeFill.GRADIENT ) {
+            g.setPaint( new GradientPaint( xxx, node.getYcoord(), getBackground(), node.getXcoord(), ( float ) ( node
+                    .getYcoord() - d ), c, false ) );
+            g.fill( _polygon );
+            g.setPaint( c );
+            g.draw( _polygon );
         }
-        repaint();
+        paintNodeData( g, node, to_graphics_file, to_pdf, is_in_found_nodes );
     }
 
-    final private void colorizeSubtree( final Color c,
-                                        final PhylogenyNode node,
-                                        final List<PhylogenyNode> additional_nodes ) {
-        _control_panel.setColorBranches( true );
-        if ( _control_panel.getUseVisualStylesCb() != null ) {
-            _control_panel.getUseVisualStylesCb().setSelected( true );
-        }
-        if ( node != null ) {
-            for( final PreorderTreeIterator it = new PreorderTreeIterator( node ); it.hasNext(); ) {
-                it.next().getBranchData().setBranchColor( new BranchColor( c ) );
-            }
-        }
-        if ( additional_nodes != null ) {
-            for( final PhylogenyNode an : additional_nodes ) {
-                for( final PreorderTreeIterator it = new PreorderTreeIterator( an ); it.hasNext(); ) {
-                    it.next().getBranchData().setBranchColor( new BranchColor( c ) );
+    final private void paintConfidenceValues( final Graphics2D g,
+                                              final PhylogenyNode node,
+                                              final boolean to_pdf,
+                                              final boolean to_graphics_file ) {
+        final List<Confidence> confidences = node.getBranchData().getConfidences();
+        boolean not_first = false;
+        Collections.sort( confidences );
+        final StringBuilder sb = new StringBuilder();
+        for( final Confidence confidence : confidences ) {
+            if ( ForesterUtil.isEmpty( SHOW_ONLY_THIS_CONF_TYPE )
+                    || ( !ForesterUtil.isEmpty( confidence.getType() ) && confidence.getType()
+                            .equalsIgnoreCase( SHOW_ONLY_THIS_CONF_TYPE ) ) ) {
+                final double value = confidence.getValue();
+                if ( value != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
+                    if ( value < getOptions().getMinConfidenceValue() ) {
+                        return;
+                    }
+                    if ( not_first ) {
+                        sb.append( "/" );
+                    }
+                    else {
+                        not_first = true;
+                    }
+                    sb.append( FORMATTER_CONFIDENCE.format( ForesterUtil.round( value, getOptions()
+                            .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
+                    if ( getOptions().isShowConfidenceStddev() ) {
+                        if ( confidence.getStandardDeviation() != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
+                            sb.append( "(" );
+                            sb.append( FORMATTER_CONFIDENCE.format( ForesterUtil.round( confidence
+                                    .getStandardDeviation(), getOptions()
+                                    .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
+                            sb.append( ")" );
+                        }
+                    }
                 }
             }
         }
-        repaint();
-    }
-
-    final private void colorSubtree( final PhylogenyNode node ) {
-        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
-            JOptionPane.showMessageDialog( this,
-                                           "Cannot colorize subtree in unrooted display type",
-                                           "Attempt to colorize subtree in unrooted display",
-                                           JOptionPane.WARNING_MESSAGE );
-            return;
-        }
-        _color_chooser.setPreviewPanel( new JPanel() );
-        SubtreeColorizationActionListener al;
-        if ( ( getFoundNodes0() != null ) || ( getFoundNodes1() != null ) ) {
-            final List<PhylogenyNode> additional_nodes = getFoundNodesAsListOfPhylogenyNodes();
-            al = new SubtreeColorizationActionListener( _color_chooser, node, additional_nodes );
-        }
-        else {
-            al = new SubtreeColorizationActionListener( _color_chooser, node );
-        }
-        final JDialog dialog = JColorChooser
-                .createDialog( this, "Subtree colorization", true, _color_chooser, al, null );
-        setEdited( true );
-        dialog.setVisible( true );
-    }
-
-    final private void copySubtree( final PhylogenyNode node ) {
-        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
-            errorMessageNoCutCopyPasteInUnrootedDisplay();
-            return;
-        }
-        setNodeInPreorderToNull();
-        setCutOrCopiedTree( _phylogeny.copy( node ) );
-        final List<PhylogenyNode> nodes = PhylogenyMethods.getAllDescendants( node );
-        final Set<Long> node_ids = new HashSet<Long>( nodes.size() );
-        for( final PhylogenyNode n : nodes ) {
-            node_ids.add( n.getId() );
-        }
-        node_ids.add( node.getId() );
-        setCopiedAndPastedNodes( node_ids );
-        repaint();
-    }
-
-    final private String createASimpleTextRepresentationOfANode( final PhylogenyNode node ) {
-        final String tax = PhylogenyMethods.getSpecies( node );
-        String label = node.getName();
-        if ( !ForesterUtil.isEmpty( label ) && !ForesterUtil.isEmpty( tax ) ) {
-            label = label + " " + tax;
-        }
-        else if ( !ForesterUtil.isEmpty( tax ) ) {
-            label = tax;
-        }
-        else {
-            label = "";
-        }
-        if ( !ForesterUtil.isEmpty( label ) ) {
-            label = " [" + label + "]";
-        }
-        return label;
-    }
-
-    final private void cutSubtree( final PhylogenyNode node ) {
-        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
-            errorMessageNoCutCopyPasteInUnrootedDisplay();
-            return;
-        }
-        if ( node.isRoot() ) {
-            JOptionPane.showMessageDialog( this,
-                                           "Cannot cut entire tree as subtree",
-                                           "Attempt to cut entire tree",
-                                           JOptionPane.ERROR_MESSAGE );
-            return;
-        }
-        final String label = createASimpleTextRepresentationOfANode( node );
-        final int r = JOptionPane.showConfirmDialog( null,
-                                                     "Cut subtree" + label + "?",
-                                                     "Confirm Cutting of Subtree",
-                                                     JOptionPane.YES_NO_OPTION );
-        if ( r != JOptionPane.OK_OPTION ) {
-            return;
+        if ( sb.length() > 0 ) {
+            final float parent_x = node.getParent().getXcoord();
+            float x = node.getXcoord();
+            g.setFont( getTreeFontSet().getSmallFont() );
+            if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) {
+                x += EURO_D;
+            }
+            else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) {
+                x += ROUNDED_D;
+            }
+            if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
+                g.setColor( Color.BLACK );
+            }
+            else {
+                g.setColor( getTreeColorSet().getConfidenceColor() );
+            }
+            final String conf_str = sb.toString();
+            TreePanel.drawString( conf_str,
+                                  parent_x
+                                          + ( ( x - parent_x - getTreeFontSet().getFontMetricsSmall()
+                                                  .stringWidth( conf_str ) ) / 2 ),
+                                  ( node.getYcoord() + getTreeFontSet().getSmallMaxAscent() ) - 1,
+                                  g );
         }
-        setNodeInPreorderToNull();
-        setCopiedAndPastedNodes( null );
-        setCutOrCopiedTree( _phylogeny.copy( node ) );
-        _phylogeny.deleteSubtree( node, true );
-        _phylogeny.clearHashIdToNodeMap();
-        _phylogeny.recalculateNumberOfExternalDescendants( true );
-        resetNodeIdToDistToLeafMap();
-        setEdited( true );
-        repaint();
     }
 
-    final private void cycleColors() {
-        getMainPanel().getTreeColorSet().cycleColorScheme();
-        for( final TreePanel tree_panel : getMainPanel().getTreePanels() ) {
-            tree_panel.setBackground( getMainPanel().getTreeColorSet().getBackgroundColor() );
+    final private void paintGainedAndLostCharacters( final Graphics2D g,
+                                                     final PhylogenyNode node,
+                                                     final String gained,
+                                                     final String lost ) {
+        if ( node.getParent() != null ) {
+            final float parent_x = node.getParent().getXcoord();
+            final float x = node.getXcoord();
+            g.setFont( getTreeFontSet().getLargeFont() );
+            g.setColor( getTreeColorSet().getGainedCharactersColor() );
+            if ( Constants.SPECIAL_CUSTOM ) {
+                g.setColor( Color.BLUE );
+            }
+            TreePanel
+                    .drawString( gained,
+                                 parent_x
+                                         + ( ( x - parent_x - getFontMetricsForLargeDefaultFont().stringWidth( gained ) ) / 2 ),
+                                 ( node.getYcoord() - getFontMetricsForLargeDefaultFont().getMaxDescent() ),
+                                 g );
+            g.setColor( getTreeColorSet().getLostCharactersColor() );
+            TreePanel
+                    .drawString( lost,
+                                 parent_x
+                                         + ( ( x - parent_x - getFontMetricsForLargeDefaultFont().stringWidth( lost ) ) / 2 ),
+                                 ( node.getYcoord() + getFontMetricsForLargeDefaultFont().getMaxAscent() ),
+                                 g );
         }
     }
 
-    final private void decreaseOvSize() {
-        if ( ( getOvMaxWidth() > 20 ) && ( getOvMaxHeight() > 20 ) ) {
-            setOvMaxWidth( getOvMaxWidth() - 5 );
-            setOvMaxHeight( getOvMaxHeight() - 5 );
-            updateOvSettings();
-            getControlPanel().displayedPhylogenyMightHaveChanged( false );
+    private void paintMolecularSequences( final Graphics2D g, final PhylogenyNode node, final boolean to_pdf ) {
+        final RenderableMsaSequence rs = RenderableMsaSequence.createInstance( node.getNodeData().getSequence()
+                .getMolecularSequence(), node.getNodeData().getSequence().getType(), getConfiguration() );
+        if ( rs != null ) {
+            final int default_height = 8;
+            final float y = getYdistance();
+            final int h = ( y / 2 ) < default_height ? ForesterUtil.roundToInt( y * 2 ) : default_height;
+            rs.setRenderingHeight( h > 1 ? h : 1 );
+            if ( getControlPanel().isDrawPhylogram() ) {
+                rs.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() ) + _length_of_longest_text ),
+                           node.getYcoord() - ( h / 2.0f ),
+                           g,
+                           this,
+                           to_pdf );
+            }
+            else {
+                rs.render( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text,
+                           node.getYcoord() - ( h / 2.0f ),
+                           g,
+                           this,
+                           to_pdf );
+            }
         }
     }
 
-    final private void deleteNodeOrSubtree( final PhylogenyNode node ) {
-        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
-            errorMessageNoCutCopyPasteInUnrootedDisplay();
-            return;
-        }
-        if ( node.isRoot() && ( node.getNumberOfDescendants() != 1 ) ) {
-            JOptionPane.showMessageDialog( this,
-                                           "Cannot delete entire tree",
-                                           "Attempt to delete entire tree",
-                                           JOptionPane.ERROR_MESSAGE );
-            return;
-        }
-        final String label = createASimpleTextRepresentationOfANode( node );
-        final Object[] options = { "Node only", "Entire subtree", "Cancel" };
-        final int r = JOptionPane.showOptionDialog( this,
-                                                    "Delete" + label + "?",
-                                                    "Delete Node/Subtree",
-                                                    JOptionPane.CLOSED_OPTION,
-                                                    JOptionPane.QUESTION_MESSAGE,
-                                                    null,
-                                                    options,
-                                                    options[ 2 ] );
-        setNodeInPreorderToNull();
-        boolean node_only = true;
-        if ( r == 1 ) {
-            node_only = false;
-        }
-        else if ( r != 0 ) {
+    /**
+     * Draw a box at the indicated node.
+     *
+     * @param x
+     * @param y
+     * @param node
+     * @param g
+     */
+    final private void paintNodeBox( final float x,
+                                     final float y,
+                                     final PhylogenyNode node,
+                                     final Graphics2D g,
+                                     final boolean to_pdf,
+                                     final boolean to_graphics_file ) {
+        if ( node.isCollapse() ) {
             return;
         }
-        if ( node_only ) {
-            PhylogenyMethods.removeNode( node, _phylogeny );
-        }
-        else {
-            _phylogeny.deleteSubtree( node, true );
-        }
-        _phylogeny.externalNodesHaveChanged();
-        _phylogeny.clearHashIdToNodeMap();
-        _phylogeny.recalculateNumberOfExternalDescendants( true );
-        resetNodeIdToDistToLeafMap();
-        setEdited( true );
-        repaint();
-    }
-
-    final private void displayNodePopupMenu( final PhylogenyNode node, final int x, final int y ) {
-        makePopupMenus( node );
-        _node_popup_menu.putClientProperty( NODE_POPMENU_NODE_CLIENT_PROPERTY, node );
-        _node_popup_menu.show( this, x, y );
-    }
-
-    final private void drawArc( final double x,
-                                final double y,
-                                final double width,
-                                final double heigth,
-                                final double start_angle,
-                                final double arc_angle,
-                                final Graphics2D g ) {
-        _arc.setArc( x, y, width, heigth, _180_OVER_PI * start_angle, _180_OVER_PI * arc_angle, Arc2D.OPEN );
-        g.draw( _arc );
-    }
-
-    final private void drawLine( final double x1, final double y1, final double x2, final double y2, final Graphics2D g ) {
-        if ( ( x1 == x2 ) && ( y1 == y2 ) ) {
-            return;
+        // if this node should be highlighted, do so
+        if ( ( _highlight_node == node ) && !to_pdf && !to_graphics_file ) {
+            g.setColor( getTreeColorSet().getFoundColor0() );
+            drawOval( x - 8, y - 8, 16, 16, g );
+            drawOval( x - 9, y - 8, 17, 17, g );
+            drawOval( x - 9, y - 9, 18, 18, g );
         }
-        _line.setLine( x1, y1, x2, y2 );
-        g.draw( _line );
-    }
-
-    final private void drawOval( final double x,
-                                 final double y,
-                                 final double width,
-                                 final double heigth,
-                                 final Graphics2D g ) {
-        _ellipse.setFrame( x, y, width, heigth );
-        g.draw( _ellipse );
-    }
-
-    final private void drawOvalFilled( final double x,
-                                       final double y,
-                                       final double width,
-                                       final double heigth,
-                                       final Graphics2D g ) {
-        _ellipse.setFrame( x, y, width, heigth );
-        g.fill( _ellipse );
-    }
-
-    final private void drawOvalGradient( final float x,
-                                         final float y,
-                                         final float width,
-                                         final float heigth,
-                                         final Graphics2D g,
-                                         final Color color_1,
-                                         final Color color_2,
-                                         final Color color_border ) {
-        _ellipse.setFrame( x, y, width, heigth );
-        g.setPaint( new GradientPaint( x, y, color_1, ( x + width ), ( y + heigth ), color_2, false ) );
-        g.fill( _ellipse );
-        if ( color_border != null ) {
-            g.setPaint( color_border );
-            g.draw( _ellipse );
-        }
-    }
-
-    final private void drawRect( final float x, final float y, final float width, final float heigth, final Graphics2D g ) {
-        _rectangle.setFrame( x, y, width, heigth );
-        g.draw( _rectangle );
-    }
-
-    final private void drawRectFilled( final double x,
-                                       final double y,
-                                       final double width,
-                                       final double heigth,
-                                       final Graphics2D g ) {
-        _rectangle.setFrame( x, y, width, heigth );
-        g.fill( _rectangle );
-    }
-
-    final private void drawRectGradient( final float x,
-                                         final float y,
-                                         final float width,
-                                         final float heigth,
-                                         final Graphics2D g,
-                                         final Color color_1,
-                                         final Color color_2,
-                                         final Color color_border ) {
-        _rectangle.setFrame( x, y, width, heigth );
-        g.setPaint( new GradientPaint( x, y, color_1, ( x + width ), ( y + heigth ), color_2, false ) );
-        g.fill( _rectangle );
-        if ( color_border != null ) {
-            g.setPaint( color_border );
-            g.draw( _rectangle );
-        }
-    }
-
-    private double drawTaxonomyImage( final double x, final double y, final PhylogenyNode node, final Graphics2D g ) {
-        final List<Uri> us = new ArrayList<Uri>();
-        for( final Taxonomy t : node.getNodeData().getTaxonomies() ) {
-            for( final Uri uri : t.getUris() ) {
-                us.add( uri );
+        if ( ( isInFoundNodes( node ) || isInCurrentExternalNodes( node ) )
+                || ( getOptions().isShowDefaultNodeShapesExternal() && node.isExternal() )
+                || ( getOptions().isShowDefaultNodeShapesInternal() && node.isInternal() )
+                || ( getOptions().isShowDefaultNodeShapesForMarkedNodes()
+                        && ( node.getNodeData().getNodeVisualData() != null ) && ( !node.getNodeData()
+                        .getNodeVisualData().isEmpty() ) )
+                || ( getControlPanel().isUseVisualStyles() && ( ( node.getNodeData().getNodeVisualData() != null ) && ( ( node
+                        .getNodeData().getNodeVisualData().getNodeColor() != null )
+                        || ( node.getNodeData().getNodeVisualData().getSize() != NodeVisualData.DEFAULT_SIZE )
+                        || ( node.getNodeData().getNodeVisualData().getFillType() != NodeFill.DEFAULT ) || ( node
+                        .getNodeData().getNodeVisualData().getShape() != NodeShape.DEFAULT ) ) ) )
+                || ( getControlPanel().isEvents() && node.isHasAssignedEvent() && ( node.getNodeData().getEvent()
+                        .isDuplication()
+                        || node.getNodeData().getEvent().isSpeciation() || node.getNodeData().getEvent()
+                        .isSpeciationOrDuplication() ) ) ) {
+            NodeVisualData vis = null;
+            if ( getControlPanel().isUseVisualStyles() && ( node.getNodeData().getNodeVisualData() != null )
+                    && ( !node.getNodeData().getNodeVisualData().isEmpty() ) ) {
+                vis = node.getNodeData().getNodeVisualData();
             }
-        }
-        double offset = 0;
-        for( final Uri uri : us ) {
-            if ( uri != null ) {
-                final String uri_str = uri.getValue().toString().toLowerCase();
-                if ( getImageMap().containsKey( uri_str ) ) {
-                    final BufferedImage bi = getImageMap().get( uri_str );
-                    if ( ( bi != null ) && ( bi.getHeight() > 5 ) && ( bi.getWidth() > 5 ) ) {
-                        double scaling_factor = 1;
-                        if ( getOptions().isAllowMagnificationOfTaxonomyImages()
-                                || ( bi.getHeight() > ( 1.8 * getYdistance() ) ) ) {
-                            scaling_factor = ( 1.8 * getYdistance() ) / bi.getHeight();
-                        }
-                        // y = y - ( 0.9 * getYdistance() );
-                        final double hs = bi.getHeight() * scaling_factor;
-                        double ws = ( bi.getWidth() * scaling_factor ) + offset;
-                        final double my_y = y - ( 0.5 * hs );
-                        final int x_w = ( int ) ( x + ws + 0.5 );
-                        final int y_h = ( int ) ( my_y + hs + 0.5 );
-                        if ( ( ( x_w - x ) > 7 ) && ( ( y_h - my_y ) > 7 ) ) {
-                            g.drawImage( bi,
-                                         ( int ) ( x + 0.5 + offset ),
-                                         ( int ) ( my_y + 0.5 ),
-                                         x_w,
-                                         y_h,
-                                         0,
-                                         0,
-                                         bi.getWidth(),
-                                         bi.getHeight(),
-                                         null );
-                            ws += 8;
-                        }
-                        else {
-                            ws = 0.0;
-                        }
-                        offset = ws;
+            float box_size = getOptions().getDefaultNodeShapeSize();
+            if ( ( vis != null ) && ( vis.getSize() != NodeVisualData.DEFAULT_SIZE ) ) {
+                box_size = vis.getSize();
+            }
+            final float half_box_size = box_size / 2.0f;
+            Color outline_color = null;
+            if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
+                outline_color = Color.BLACK;
+            }
+            else if ( isInFoundNodes( node ) || isInCurrentExternalNodes( node ) ) {
+                outline_color = getColorForFoundNode( node );
+            }
+            else if ( vis != null ) {
+                if ( vis.getNodeColor() != null ) {
+                    outline_color = vis.getNodeColor();
+                }
+                else if ( vis.getFontColor() != null ) {
+                    outline_color = vis.getFontColor();
+                }
+            }
+            else if ( getControlPanel().isEvents() && TreePanelUtil.isHasAssignedEvent( node ) ) {
+                final Event event = node.getNodeData().getEvent();
+                if ( event.isDuplication() ) {
+                    outline_color = getTreeColorSet().getDuplicationBoxColor();
+                }
+                else if ( event.isSpeciation() ) {
+                    outline_color = getTreeColorSet().getSpecBoxColor();
+                }
+                else if ( event.isSpeciationOrDuplication() ) {
+                    outline_color = getTreeColorSet().getDuplicationOrSpeciationColor();
+                }
+            }
+            if ( outline_color == null ) {
+                outline_color = getGraphicsForNodeBoxWithColorForParentBranch( node );
+                if ( to_pdf && ( outline_color == getTreeColorSet().getBranchColor() ) ) {
+                    outline_color = getTreeColorSet().getBranchColorForPdf();
+                }
+            }
+            NodeShape shape = null;
+            if ( vis != null ) {
+                if ( vis.getShape() == NodeShape.CIRCLE ) {
+                    shape = NodeShape.CIRCLE;
+                }
+                else if ( vis.getShape() == NodeShape.RECTANGLE ) {
+                    shape = NodeShape.RECTANGLE;
+                }
+            }
+            if ( shape == null ) {
+                if ( getOptions().getDefaultNodeShape() == NodeShape.CIRCLE ) {
+                    shape = NodeShape.CIRCLE;
+                }
+                else if ( getOptions().getDefaultNodeShape() == NodeShape.RECTANGLE ) {
+                    shape = NodeShape.RECTANGLE;
+                }
+            }
+            NodeFill fill = null;
+            if ( vis != null ) {
+                if ( vis.getFillType() == NodeFill.SOLID ) {
+                    fill = NodeFill.SOLID;
+                }
+                else if ( vis.getFillType() == NodeFill.NONE ) {
+                    fill = NodeFill.NONE;
+                }
+                else if ( vis.getFillType() == NodeFill.GRADIENT ) {
+                    fill = NodeFill.GRADIENT;
+                }
+            }
+            if ( fill == null ) {
+                if ( getOptions().getDefaultNodeFill() == NodeFill.SOLID ) {
+                    fill = NodeFill.SOLID;
+                }
+                else if ( getOptions().getDefaultNodeFill() == NodeFill.NONE ) {
+                    fill = NodeFill.NONE;
+                }
+                else if ( getOptions().getDefaultNodeFill() == NodeFill.GRADIENT ) {
+                    fill = NodeFill.GRADIENT;
+                }
+            }
+            Color vis_fill_color = null;
+            if ( ( vis != null ) && ( vis.getNodeColor() != null ) ) {
+                vis_fill_color = vis.getNodeColor();
+            }
+            if ( shape == NodeShape.CIRCLE ) {
+                if ( fill == NodeFill.GRADIENT ) {
+                    drawOvalGradient( x - half_box_size, y - half_box_size, box_size, box_size, g, to_pdf ? Color.WHITE
+                            : outline_color, to_pdf ? outline_color : getBackground(), outline_color );
+                }
+                else if ( fill == NodeFill.NONE ) {
+                    Color background = getBackground();
+                    if ( to_pdf ) {
+                        background = Color.WHITE;
+                    }
+                    drawOvalGradient( x - half_box_size,
+                                      y - half_box_size,
+                                      box_size,
+                                      box_size,
+                                      g,
+                                      background,
+                                      background,
+                                      outline_color );
+                }
+                else if ( fill == NodeVisualData.NodeFill.SOLID ) {
+                    if ( vis_fill_color != null ) {
+                        g.setColor( vis_fill_color );
+                    }
+                    else {
+                        g.setColor( outline_color );
+                    }
+                    drawOvalFilled( x - half_box_size, y - half_box_size, box_size, box_size, g );
+                }
+            }
+            else if ( shape == NodeVisualData.NodeShape.RECTANGLE ) {
+                if ( fill == NodeVisualData.NodeFill.GRADIENT ) {
+                    drawRectGradient( x - half_box_size, y - half_box_size, box_size, box_size, g, to_pdf ? Color.WHITE
+                            : outline_color, to_pdf ? outline_color : getBackground(), outline_color );
+                }
+                else if ( fill == NodeVisualData.NodeFill.NONE ) {
+                    Color background = getBackground();
+                    if ( to_pdf ) {
+                        background = Color.WHITE;
+                    }
+                    drawRectGradient( x - half_box_size,
+                                      y - half_box_size,
+                                      box_size,
+                                      box_size,
+                                      g,
+                                      background,
+                                      background,
+                                      outline_color );
+                }
+                else if ( fill == NodeVisualData.NodeFill.SOLID ) {
+                    if ( vis_fill_color != null ) {
+                        g.setColor( vis_fill_color );
+                    }
+                    else {
+                        g.setColor( outline_color );
                     }
+                    drawRectFilled( x - half_box_size, y - half_box_size, box_size, box_size, g );
                 }
             }
         }
-        return offset;
-    }
-
-    final private void errorMessageNoCutCopyPasteInUnrootedDisplay() {
-        JOptionPane.showMessageDialog( this,
-                                       "Cannot cut, copy, paste, add, or delete subtrees/nodes in unrooted display",
-                                       "Attempt to cut/copy/paste/add/delete in unrooted display",
-                                       JOptionPane.ERROR_MESSAGE );
     }
 
-    private final Color getColorForFoundNode( final PhylogenyNode n ) {
-        if ( isInCurrentExternalNodes( n ) ) {
-            return getTreeColorSet().getFoundColor0();
-        }
-        else if ( isInFoundNodes0( n ) && !isInFoundNodes1( n ) ) {
-            return getTreeColorSet().getFoundColor0();
+    final private int paintNodeData( final Graphics2D g,
+                                     final PhylogenyNode node,
+                                     final boolean to_graphics_file,
+                                     final boolean to_pdf,
+                                     final boolean is_in_found_nodes ) {
+        if ( isNodeDataInvisible( node ) && !to_graphics_file && !to_pdf ) {
+            return 0;
         }
-        else if ( !isInFoundNodes0( n ) && isInFoundNodes1( n ) ) {
-            return getTreeColorSet().getFoundColor1();
+        if ( getControlPanel().isWriteBranchLengthValues()
+                && ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR )
+                        || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) )
+                && ( !node.isRoot() ) && ( node.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) ) {
+            paintBranchLength( g, node, to_pdf, to_graphics_file );
+        }
+        if ( !getControlPanel().isShowInternalData() && !node.isExternal() && !node.isCollapse() ) {
+            return 0;
+        }
+        _sb.setLength( 0 );
+        int x = 0;
+        final int half_box_size = getOptions().getDefaultNodeShapeSize() / 2;
+        if ( getControlPanel().isShowTaxonomyImages()
+                && ( getImageMap() != null )
+                && !getImageMap().isEmpty()
+                && node.getNodeData().isHasTaxonomy()
+                && ( ( node.getNodeData().getTaxonomy().getUris() != null ) && !node.getNodeData().getTaxonomy()
+                        .getUris().isEmpty() ) ) {
+            x += drawTaxonomyImage( node.getXcoord() + 2 + half_box_size, node.getYcoord(), node, g );
+        }
+        if ( ( getControlPanel().isShowTaxonomyCode() || getControlPanel().isShowTaxonomyScientificNames() || getControlPanel()
+                .isShowTaxonomyCommonNames() ) && node.getNodeData().isHasTaxonomy() ) {
+            x += paintTaxonomy( g, node, is_in_found_nodes, to_pdf, to_graphics_file, x );
+        }
+        setColor( g, node, to_graphics_file, to_pdf, is_in_found_nodes, getTreeColorSet().getSequenceColor() );
+        if ( node.isCollapse() && ( ( !node.isRoot() && !node.getParent().isCollapse() ) || node.isRoot() ) ) {
+            if ( _sb.length() > 0 ) {
+                _sb.setLength( 0 );
+                _sb.append( " (" );
+                _sb.append( node.getAllExternalDescendants().size() );
+                _sb.append( ")" );
+            }
         }
         else {
-            return getTreeColorSet().getFoundColor0and1();
+            _sb.setLength( 0 );
         }
-    }
-
-    final private Set<Long> getCopiedAndPastedNodes() {
-        return getMainPanel().getCopiedAndPastedNodes();
-    }
-
-    final private Set<Long> getCurrentExternalNodes() {
-        return _current_external_nodes;
-    }
-
-    final private Phylogeny getCutOrCopiedTree() {
-        return getMainPanel().getCutOrCopiedTree();
-    }
-
-    private FontMetrics getFontMetricsForLargeDefaultFont() {
-        return getTreeFontSet().getFontMetricsLarge();
-    }
-
-    List<PhylogenyNode> getFoundNodesAsListOfPhylogenyNodes() {
-        final List<PhylogenyNode> additional_nodes = new ArrayList<PhylogenyNode>();
-        if ( getFoundNodes0() != null ) {
-            for( final Long id : getFoundNodes0() ) {
-                final PhylogenyNode n = _phylogeny.getNode( id );
-                if ( n != null ) {
-                    additional_nodes.add( n );
+        nodeDataAsSB( node, _sb );
+        final boolean using_visual_font = setFont( g, node, is_in_found_nodes );
+        float down_shift_factor = 3.0f;
+        if ( !node.isExternal() && ( node.getNumberOfDescendants() == 1 ) ) {
+            down_shift_factor = 1;
+        }
+        final float pos_x = node.getXcoord() + x + 2 + half_box_size;
+        float pos_y;
+        if ( !using_visual_font ) {
+            pos_y = ( node.getYcoord() + ( getFontMetricsForLargeDefaultFont().getAscent() / down_shift_factor ) );
+        }
+        else {
+            pos_y = ( node.getYcoord() + ( getFontMetrics( g.getFont() ).getAscent() / down_shift_factor ) );
+        }
+        final String sb_str = _sb.toString();
+        // GUILHEM_BEG ______________
+        if ( _control_panel.isShowSequenceRelations() && node.getNodeData().isHasSequence()
+                && ( _query_sequence != null ) ) {
+            int nodeTextBoundsWidth = 0;
+            if ( sb_str.length() > 0 ) {
+                final Rectangle2D node_text_bounds = new TextLayout( sb_str, g.getFont(), _frc ).getBounds(); //would like to remove this 'new', but how...
+                nodeTextBoundsWidth = ( int ) node_text_bounds.getWidth();
+            }
+            if ( node.getNodeData().getSequence().equals( _query_sequence ) ) {
+                if ( nodeTextBoundsWidth > 0 ) { // invert font color and background color to show that this is the query sequence
+                    g.fillRect( ( int ) pos_x - 1, ( int ) pos_y - 8, nodeTextBoundsWidth + 5, 11 );
+                    g.setColor( getTreeColorSet().getBackgroundColor() );
                 }
             }
-        }
-        if ( getFoundNodes1() != null ) {
-            for( final Long id : getFoundNodes1() ) {
-                if ( ( getFoundNodes0() == null ) || !getFoundNodes0().contains( id ) ) {
-                    final PhylogenyNode n = _phylogeny.getNode( id );
-                    if ( n != null ) {
-                        additional_nodes.add( n );
+            else {
+                final List<SequenceRelation> seqRelations = node.getNodeData().getSequence().getSequenceRelations();
+                for( final SequenceRelation seqRelation : seqRelations ) {
+                    final boolean fGotRelationWithQuery = ( seqRelation.getRef0().isEqual( _query_sequence ) || seqRelation
+                            .getRef1().isEqual( _query_sequence ) )
+                            && seqRelation.getType().equals( getControlPanel().getSequenceRelationTypeBox()
+                                    .getSelectedItem() );
+                    if ( fGotRelationWithQuery ) { // we will underline the text to show that this sequence is ortholog to the query
+                        final double linePosX = node.getXcoord() + 2 + half_box_size;
+                        final String sConfidence = ( !getControlPanel().isShowSequenceRelationConfidence() || ( seqRelation
+                                .getConfidence() == null ) ) ? null : " (" + seqRelation.getConfidence().getValue()
+                                + ")";
+                        if ( sConfidence != null ) {
+                            float confidenceX = pos_x;
+                            if ( sb_str.length() > 0 ) {
+                                confidenceX += new TextLayout( sb_str, g.getFont(), _frc ).getBounds().getWidth()
+                                        + CONFIDENCE_LEFT_MARGIN;
+                            }
+                            if ( confidenceX > linePosX ) { // let's only display confidence value if we are already displaying at least one of Prot/Gene Name and Taxonomy Code
+                                final int confidenceWidth = ( int ) new TextLayout( sConfidence, g.getFont(), _frc )
+                                        .getBounds().getWidth();
+                                TreePanel.drawString( sConfidence, confidenceX, pos_y, g );
+                                x += CONFIDENCE_LEFT_MARGIN + confidenceWidth;
+                            }
+                        }
+                        if ( ( x + nodeTextBoundsWidth ) > 0 ) /* we only underline if there is something displayed */
+                        {
+                            if ( nodeTextBoundsWidth == 0 ) {
+                                nodeTextBoundsWidth -= 3; /* the gap between taxonomy code and node name should not be underlined if nothing comes after it */
+                            }
+                            else {
+                                nodeTextBoundsWidth += 2;
+                            }
+                            g.drawLine( ( int ) linePosX + 1, 3 + ( int ) pos_y, ( int ) linePosX + x
+                                    + nodeTextBoundsWidth, 3 + ( int ) pos_y );
+                            break;
+                        }
                     }
                 }
             }
         }
-        return additional_nodes;
-    }
-
-    final private float getLastDragPointX() {
-        return _last_drag_point_x;
-    }
-
-    final private float getLastDragPointY() {
-        return _last_drag_point_y;
-    }
-
-    final private short getMaxBranchesToLeaf( final PhylogenyNode node ) {
-        if ( !_nodeid_dist_to_leaf.containsKey( node.getId() ) ) {
-            final short m = PhylogenyMethods.calculateMaxBranchesToLeaf( node );
-            _nodeid_dist_to_leaf.put( node.getId(), m );
-            return m;
+        if ( sb_str.length() > 0 ) {
+            TreePanel.drawString( sb_str, pos_x, pos_y, g );
         }
-        else {
-            return _nodeid_dist_to_leaf.get( node.getId() );
+        // GUILHEM_END _____________
+        if ( _sb.length() > 0 ) {
+            if ( !using_visual_font && !is_in_found_nodes ) {
+                x += getFontMetricsForLargeDefaultFont().stringWidth( _sb.toString() ) + 5;
+            }
+            else {
+                x += getFontMetrics( g.getFont() ).stringWidth( _sb.toString() ) + 5;
+            }
         }
-    }
-
-    final private double getMaxDistanceToRoot() {
-        if ( _max_distance_to_root < 0 ) {
-            recalculateMaxDistanceToRoot();
+        if ( getControlPanel().isShowAnnotation() && node.getNodeData().isHasSequence()
+                && ( node.getNodeData().getSequence().getAnnotations() != null )
+                && ( !node.getNodeData().getSequence().getAnnotations().isEmpty() ) ) {
+            final SortedSet<Annotation> ann = node.getNodeData().getSequence().getAnnotations();
+            if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
+                g.setColor( Color.BLACK );
+            }
+            else if ( getControlPanel().isColorAccordingToAnnotation() ) {
+                g.setColor( calculateColorForAnnotation( ann ) );
+            }
+            final String ann_str = TreePanelUtil.createAnnotationString( ann, getOptions().isShowAnnotationRefSource() );
+            TreePanel.drawString( ann_str, node.getXcoord() + x + 3 + half_box_size, node.getYcoord()
+                    + ( getFontMetricsForLargeDefaultFont().getAscent() / down_shift_factor ), g );
+            _sb.setLength( 0 );
+            _sb.append( ann_str );
+            if ( _sb.length() > 0 ) {
+                if ( !using_visual_font && !is_in_found_nodes ) {
+                    x += getFontMetricsForLargeDefaultFont().stringWidth( _sb.toString() ) + 5;
+                }
+                else {
+                    x += getFontMetrics( g.getFont() ).stringWidth( _sb.toString() ) + 5;
+                }
+            }
         }
-        return _max_distance_to_root;
-    }
-
-    final private float getOvMaxHeight() {
-        return _ov_max_height;
-    }
-
-    final private float getOvMaxWidth() {
-        return _ov_max_width;
-    }
-
-    final private float getOvXcorrectionFactor() {
-        return _ov_x_correction_factor;
-    }
-
-    final private float getOvXDistance() {
-        return _ov_x_distance;
-    }
-
-    final private int getOvXPosition() {
-        return _ov_x_position;
-    }
-
-    final private float getOvYDistance() {
-        return _ov_y_distance;
-    }
-
-    final private int getOvYPosition() {
-        return _ov_y_position;
-    }
-
-    final private int getOvYStart() {
-        return _ov_y_start;
-    }
-
-    final private List<Accession> getPdbAccs( final PhylogenyNode node ) {
-        final List<Accession> pdb_ids = new ArrayList<Accession>();
-        if ( node.getNodeData().isHasSequence() ) {
-            final Sequence seq = node.getNodeData().getSequence();
-            if ( !ForesterUtil.isEmpty( seq.getCrossReferences() ) ) {
-                final SortedSet<Accession> cross_refs = seq.getCrossReferences();
-                for( final Accession acc : cross_refs ) {
-                    if ( acc.getSource().equalsIgnoreCase( "pdb" ) ) {
-                        pdb_ids.add( acc );
-                    }
+        if ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR )
+                || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE )
+                || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) ) {
+            if ( ( getControlPanel().isShowBinaryCharacters() || getControlPanel().isShowBinaryCharacterCounts() )
+                    && node.getNodeData().isHasBinaryCharacters() ) {
+                if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
+                    g.setColor( Color.BLACK );
+                }
+                else {
+                    g.setColor( getTreeColorSet().getBinaryDomainCombinationsColor() );
+                }
+                if ( getControlPanel().isShowBinaryCharacters() ) {
+                    TreePanel.drawString( node.getNodeData().getBinaryCharacters().getPresentCharactersAsStringBuffer()
+                            .toString(), node.getXcoord() + x + 1 + half_box_size, node.getYcoord()
+                            + ( getFontMetricsForLargeDefaultFont().getAscent() / down_shift_factor ), g );
+                    paintGainedAndLostCharacters( g, node, node.getNodeData().getBinaryCharacters()
+                            .getGainedCharactersAsStringBuffer().toString(), node.getNodeData().getBinaryCharacters()
+                            .getLostCharactersAsStringBuffer().toString() );
+                }
+                else {
+                    TreePanel
+                            .drawString( " " + node.getNodeData().getBinaryCharacters().getPresentCount(),
+                                         node.getXcoord() + x + 4 + half_box_size,
+                                         node.getYcoord()
+                                                 + ( getFontMetricsForLargeDefaultFont().getAscent() / down_shift_factor ),
+                                         g );
+                    paintGainedAndLostCharacters( g, node, "+"
+                            + node.getNodeData().getBinaryCharacters().getGainedCount(), "-"
+                            + node.getNodeData().getBinaryCharacters().getLostCount() );
                 }
             }
         }
-        return pdb_ids;
-    }
-
-    final private double getScaleDistance() {
-        return _scale_distance;
-    }
-
-    final private String getScaleLabel() {
-        return _scale_label;
+        return x;
     }
 
-    final private TreeFontSet getTreeFontSet() {
-        return getMainPanel().getTreeFontSet();
-    }
-
-    final private float getUrtFactor() {
-        return _urt_factor;
-    }
-
-    final private float getUrtFactorOv() {
-        return _urt_factor_ov;
-    }
-
-    final private void handleClickToAction( final NodeClickAction action, final PhylogenyNode node ) {
-        switch ( action ) {
-            case SHOW_DATA:
-                showNodeFrame( node );
-                break;
-            case COLLAPSE:
-                collapse( node );
-                break;
-            case REROOT:
-                reRoot( node );
-                break;
-            case SUBTREE:
-                subTree( node );
-                break;
-            case SWAP:
-                swap( node );
-                break;
-            case COLOR_SUBTREE:
-                colorSubtree( node );
-                break;
-            case COLOR_NODE_FONT:
-                colorNodeFont( node );
-                break;
-            case CHANGE_NODE_FONT:
-                changeNodeFont( node );
-                break;
-            case OPEN_SEQ_WEB:
-                openSeqWeb( node );
-                break;
-            case BLAST:
-                blast( node );
-                break;
-            case OPEN_TAX_WEB:
-                openTaxWeb( node );
-                break;
-            case OPEN_PDB_WEB:
-                openPdbWeb( node );
-                break;
-            case CUT_SUBTREE:
-                cutSubtree( node );
-                break;
-            case COPY_SUBTREE:
-                copySubtree( node );
-                break;
-            case PASTE_SUBTREE:
-                pasteSubtree( node );
-                break;
-            case DELETE_NODE_OR_SUBTREE:
-                deleteNodeOrSubtree( node );
-                break;
-            case ADD_NEW_NODE:
-                addEmptyNode( node );
-                break;
-            case EDIT_NODE_DATA:
-                showNodeEditFrame( node );
-                break;
-            case SELECT_NODES:
-                selectNode( node );
-                break;
-            case SORT_DESCENDENTS:
-                sortDescendants( node );
-                break;
-            case GET_EXT_DESC_DATA:
-                showExtDescNodeData( node );
-                break;
-            default:
-                throw new IllegalArgumentException( "unknown action: " + action );
-        }
-    }
-
-    final private void increaseCurrentExternalNodesDataBufferChangeCounter() {
-        _current_external_nodes_data_buffer_change_counter++;
-    }
-
-    final private void increaseOvSize() {
-        if ( ( getOvMaxWidth() < ( getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect().getWidth() / 2 ) )
-                && ( getOvMaxHeight() < ( getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect()
-                        .getHeight() / 2 ) ) ) {
-            setOvMaxWidth( getOvMaxWidth() + 5 );
-            setOvMaxHeight( getOvMaxHeight() + 5 );
-            updateOvSettings();
-            getControlPanel().displayedPhylogenyMightHaveChanged( false );
-        }
-    }
-
-    final private void init() {
-        _color_chooser = new JColorChooser();
-        _rollover_popup = new JTextArea();
-        _rollover_popup.setFont( POPUP_FONT );
-        resetNodeIdToDistToLeafMap();
-        setTextAntialias();
-        setTreeFile( null );
-        setEdited( false );
-        initializeOvSettings();
-        setStartingAngle( ( TWO_PI * 3 ) / 4 );
-        final ImageLoader il = new ImageLoader( this );
-        new Thread( il ).start();
-    }
-
-    final private void initializeOvSettings() {
-        setOvMaxHeight( getConfiguration().getOvMaxHeight() );
-        setOvMaxWidth( getConfiguration().getOvMaxWidth() );
-    }
-
-    final private boolean inOvVirtualRectangle( final int x, final int y ) {
-        return ( ( x >= ( getOvVirtualRectangle().x - 1 ) )
-                && ( x <= ( getOvVirtualRectangle().x + getOvVirtualRectangle().width + 1 ) )
-                && ( y >= ( getOvVirtualRectangle().y - 1 ) ) && ( y <= ( getOvVirtualRectangle().y
-                        + getOvVirtualRectangle().height + 1 ) ) );
-    }
-
-    final private boolean inOvVirtualRectangle( final MouseEvent e ) {
-        return ( inOvVirtualRectangle( e.getX(), e.getY() ) );
-    }
-
-    final private boolean isCanBlast( final PhylogenyNode node ) {
-        if ( !node.getNodeData().isHasSequence() && ForesterUtil.isEmpty( node.getName() ) ) {
-            return false;
-        }
-        return Blast.isContainsQueryForBlast( node );
-    }
-
-    final private String isCanOpenSeqWeb( final PhylogenyNode node ) {
-        final Accession a = SequenceAccessionTools.obtainAccessorFromDataFields( node );
-        if ( a != null ) {
-            return a.getValue();
+    final private void paintNodeDataUnrootedCirc( final Graphics2D g,
+                                                  final PhylogenyNode node,
+                                                  final boolean to_pdf,
+                                                  final boolean to_graphics_file,
+                                                  final boolean radial_labels,
+                                                  final double ur_angle,
+                                                  final boolean is_in_found_nodes ) {
+        if ( isNodeDataInvisibleUnrootedCirc( node ) && !to_graphics_file && !to_pdf ) {
+            return;
         }
-        return null;
-    }
-
-    final private boolean isCanOpenTaxWeb( final PhylogenyNode node ) {
+        _sb.setLength( 0 );
+        _sb.append( " " );
         if ( node.getNodeData().isHasTaxonomy()
-                && ( ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getScientificName() ) )
-                        || ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getTaxonomyCode() ) )
-                        || ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getCommonName() ) ) || ( ( node
-                                .getNodeData().getTaxonomy().getIdentifier() != null ) && !ForesterUtil.isEmpty( node
-                                                                                                                 .getNodeData().getTaxonomy().getIdentifier().getValue() ) ) ) ) {
-            return true;
-        }
-        else {
-            return false;
-        }
-    }
-
-    final private boolean isInCurrentExternalNodes( final PhylogenyNode node ) {
-        return ( ( getCurrentExternalNodes() != null ) && getCurrentExternalNodes().contains( node.getId() ) );
-    }
-
-    private boolean isInFoundNodes( final PhylogenyNode n ) {
-        return isInFoundNodes0( n ) || isInFoundNodes1( n );
-    }
-
-    final private boolean isInFoundNodes0( final PhylogenyNode node ) {
-        return ( ( getFoundNodes0() != null ) && getFoundNodes0().contains( node.getId() ) );
-    }
-
-    final private boolean isInFoundNodes1( final PhylogenyNode node ) {
-        return ( ( getFoundNodes1() != null ) && getFoundNodes1().contains( node.getId() ) );
-    }
-
-    final private boolean isInOv() {
-        return _in_ov;
-    }
-
-    final private boolean isNodeDataInvisible( final PhylogenyNode node ) {
-        int y_dist = 40;
-        if ( getControlPanel().isShowTaxonomyImages() ) {
-            y_dist = 40 + ( int ) getYdistance();
-        }
-        return ( ( node.getYcoord() < ( getVisibleRect().getMinY() - y_dist ) )
-                || ( node.getYcoord() > ( getVisibleRect().getMaxY() + y_dist ) ) || ( ( node.getParent() != null ) && ( node
-                        .getParent().getXcoord() > getVisibleRect().getMaxX() ) ) );
-    }
-
-    final private boolean isNodeDataInvisibleUnrootedCirc( final PhylogenyNode node ) {
-        return ( ( node.getYcoord() < ( getVisibleRect().getMinY() - 20 ) )
-                || ( node.getYcoord() > ( getVisibleRect().getMaxY() + 20 ) )
-                || ( node.getXcoord() < ( getVisibleRect().getMinX() - 20 ) ) || ( node.getXcoord() > ( getVisibleRect()
-                        .getMaxX() + 20 ) ) );
-    }
-
-    final private boolean isNonLinedUpCladogram() {
-        return getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP;
-    }
-
-    final private boolean isUniformBranchLengthsForCladogram() {
-        return getOptions().getCladogramType() == CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP;
-    }
-
-    final private void keyPressedCalls( final KeyEvent e ) {
-        if ( isOvOn() && ( getMousePosition() != null ) && ( getMousePosition().getLocation() != null ) ) {
-            if ( inOvVirtualRectangle( getMousePosition().x, getMousePosition().y ) ) {
-                if ( !isInOvRect() ) {
-                    setInOvRect( true );
-                }
+                && ( getControlPanel().isShowTaxonomyCode() || getControlPanel().isShowTaxonomyScientificNames() || getControlPanel()
+                        .isShowTaxonomyCommonNames() ) ) {
+            final Taxonomy taxonomy = node.getNodeData().getTaxonomy();
+            if ( _control_panel.isShowTaxonomyCode() && !ForesterUtil.isEmpty( taxonomy.getTaxonomyCode() ) ) {
+                _sb.append( taxonomy.getTaxonomyCode() );
+                _sb.append( " " );
             }
-            else if ( isInOvRect() ) {
-                setInOvRect( false );
+            if ( _control_panel.isShowTaxonomyScientificNames() && _control_panel.isShowTaxonomyCommonNames() ) {
+                if ( !ForesterUtil.isEmpty( taxonomy.getScientificName() )
+                        && !ForesterUtil.isEmpty( taxonomy.getCommonName() ) ) {
+                    _sb.append( taxonomy.getScientificName() );
+                    _sb.append( " (" );
+                    _sb.append( taxonomy.getCommonName() );
+                    _sb.append( ") " );
+                }
+                else if ( !ForesterUtil.isEmpty( taxonomy.getScientificName() ) ) {
+                    _sb.append( taxonomy.getScientificName() );
+                    _sb.append( " " );
+                }
+                else if ( !ForesterUtil.isEmpty( taxonomy.getCommonName() ) ) {
+                    _sb.append( taxonomy.getCommonName() );
+                    _sb.append( " " );
+                }
             }
-        }
-        if ( e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK ) {
-            if ( ( e.getKeyCode() == KeyEvent.VK_DELETE ) || ( e.getKeyCode() == KeyEvent.VK_HOME )
-                    || ( e.getKeyCode() == KeyEvent.VK_F ) ) {
-                getMainPanel().getTreeFontSet().mediumFonts();
-                getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( true );
+            else if ( _control_panel.isShowTaxonomyScientificNames() ) {
+                if ( !ForesterUtil.isEmpty( taxonomy.getScientificName() ) ) {
+                    _sb.append( taxonomy.getScientificName() );
+                    _sb.append( " " );
+                }
             }
-            else if ( ( e.getKeyCode() == KeyEvent.VK_SUBTRACT ) || ( e.getKeyCode() == KeyEvent.VK_MINUS ) ) {
-                getMainPanel().getTreeFontSet().decreaseFontSize( 1, false );
-                getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( true );
+            else if ( _control_panel.isShowTaxonomyCommonNames() ) {
+                if ( !ForesterUtil.isEmpty( taxonomy.getCommonName() ) ) {
+                    _sb.append( taxonomy.getCommonName() );
+                    _sb.append( " " );
+                }
             }
-            else if ( plusPressed( e.getKeyCode() ) ) {
-                getMainPanel().getTreeFontSet().increaseFontSize();
-                getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( true );
+        }
+        if ( node.isCollapse() && ( ( !node.isRoot() && !node.getParent().isCollapse() ) || node.isRoot() ) ) {
+            _sb.append( " [" );
+            _sb.append( node.getAllExternalDescendants().size() );
+            _sb.append( "]" );
+        }
+        if ( getControlPanel().isShowNodeNames() && ( node.getName().length() > 0 ) ) {
+            if ( _sb.length() > 0 ) {
+                _sb.append( " " );
             }
+            _sb.append( node.getName() );
         }
-        else {
-            if ( ( e.getKeyCode() == KeyEvent.VK_DELETE ) || ( e.getKeyCode() == KeyEvent.VK_HOME )
-                    || ( e.getKeyCode() == KeyEvent.VK_F ) ) {
-                getControlPanel().showWhole();
+        if ( node.getNodeData().isHasSequence() ) {
+            if ( getControlPanel().isShowSequenceAcc() && ( node.getNodeData().getSequence().getAccession() != null ) ) {
+                if ( _sb.length() > 0 ) {
+                    _sb.append( " " );
+                }
+                if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getSource() ) ) {
+                    _sb.append( node.getNodeData().getSequence().getAccession().getSource() );
+                    _sb.append( ":" );
+                }
+                _sb.append( node.getNodeData().getSequence().getAccession().getValue() );
             }
-            else if ( ( e.getKeyCode() == KeyEvent.VK_UP ) || ( e.getKeyCode() == KeyEvent.VK_DOWN )
-                    || ( e.getKeyCode() == KeyEvent.VK_LEFT ) || ( e.getKeyCode() == KeyEvent.VK_RIGHT ) ) {
-                if ( e.getModifiersEx() == InputEvent.SHIFT_DOWN_MASK ) {
-                    if ( e.getKeyCode() == KeyEvent.VK_UP ) {
-                        getMainPanel().getControlPanel().zoomInY( Constants.WHEEL_ZOOM_IN_FACTOR );
-                        getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
-                    }
-                    else if ( e.getKeyCode() == KeyEvent.VK_DOWN ) {
-                        getMainPanel().getControlPanel().zoomOutY( Constants.WHEEL_ZOOM_OUT_FACTOR );
-                        getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
-                    }
-                    else if ( e.getKeyCode() == KeyEvent.VK_LEFT ) {
-                        getMainPanel().getControlPanel().zoomOutX( Constants.WHEEL_ZOOM_OUT_FACTOR,
-                                                                   Constants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR );
-                        getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
-                    }
-                    else if ( e.getKeyCode() == KeyEvent.VK_RIGHT ) {
-                        getMainPanel().getControlPanel().zoomInX( Constants.WHEEL_ZOOM_IN_FACTOR,
-                                                                  Constants.WHEEL_ZOOM_IN_FACTOR );
-                        getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
-                    }
+            if ( getControlPanel().isShowSeqNames() && ( node.getNodeData().getSequence().getName().length() > 0 ) ) {
+                if ( _sb.length() > 0 ) {
+                    _sb.append( " " );
                 }
-                else {
-                    final int d = 80;
-                    int dx = 0;
-                    int dy = -d;
-                    if ( e.getKeyCode() == KeyEvent.VK_DOWN ) {
-                        dy = d;
-                    }
-                    else if ( e.getKeyCode() == KeyEvent.VK_LEFT ) {
-                        dx = -d;
-                        dy = 0;
-                    }
-                    else if ( e.getKeyCode() == KeyEvent.VK_RIGHT ) {
-                        dx = d;
-                        dy = 0;
-                    }
-                    final Point scroll_position = getMainPanel().getCurrentScrollPane().getViewport().getViewPosition();
-                    scroll_position.x = scroll_position.x + dx;
-                    scroll_position.y = scroll_position.y + dy;
-                    if ( scroll_position.x <= 0 ) {
-                        scroll_position.x = 0;
+                _sb.append( node.getNodeData().getSequence().getName() );
+            }
+        }
+        //g.setFont( getTreeFontSet().getLargeFont() );
+        //if ( is_in_found_nodes ) {
+        //    g.setFont( getTreeFontSet().getLargeFont().deriveFont( Font.BOLD ) );
+        // }
+        if ( _sb.length() > 1 ) {
+            setColor( g, node, to_graphics_file, to_pdf, is_in_found_nodes, getTreeColorSet().getSequenceColor() );
+            final boolean using_visual_font = setFont( g, node, is_in_found_nodes );
+            final String sb_str = _sb.toString();
+            double m = 0;
+            if ( _graphics_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
+                m = _urt_nodeid_angle_map.get( node.getId() ) % TWO_PI;
+            }
+            else {
+                m = ( float ) ( ur_angle % TWO_PI );
+            }
+            _at = g.getTransform();
+            boolean need_to_reset = false;
+            final float x_coord = node.getXcoord();
+            float y_coord;
+            if ( !using_visual_font ) {
+                y_coord = node.getYcoord() + ( getFontMetricsForLargeDefaultFont().getAscent() / 3.0f );
+            }
+            else {
+                y_coord = node.getYcoord() + ( getFontMetrics( g.getFont() ).getAscent() / 3.0f );
+            }
+            if ( radial_labels ) {
+                need_to_reset = true;
+                boolean left = false;
+                if ( ( m > HALF_PI ) && ( m < ONEHALF_PI ) ) {
+                    m -= PI;
+                    left = true;
+                }
+                g.rotate( m, x_coord, node.getYcoord() );
+                if ( left ) {
+                    if ( !using_visual_font ) {
+                        g.translate( -( getFontMetricsForLargeDefaultFont().getStringBounds( sb_str, g ).getWidth() ),
+                                     0 );
                     }
                     else {
-                        final int max_x = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getMaximum()
-                                - getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getVisibleAmount();
-                        if ( scroll_position.x >= max_x ) {
-                            scroll_position.x = max_x;
-                        }
+                        g.translate( -( getFontMetrics( g.getFont() ).getStringBounds( sb_str, g ).getWidth() ), 0 );
                     }
-                    if ( scroll_position.y <= 0 ) {
-                        scroll_position.y = 0;
+                }
+            }
+            else {
+                if ( ( m > HALF_PI ) && ( m < ONEHALF_PI ) ) {
+                    need_to_reset = true;
+                    if ( !using_visual_font ) {
+                        g.translate( -getFontMetricsForLargeDefaultFont().getStringBounds( sb_str, g ).getWidth(), 0 );
                     }
                     else {
-                        final int max_y = getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getMaximum()
-                                - getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getVisibleAmount();
-                        if ( scroll_position.y >= max_y ) {
-                            scroll_position.y = max_y;
-                        }
+                        g.translate( -getFontMetrics( g.getFont() ).getStringBounds( sb_str, g ).getWidth(), 0 );
                     }
-                    repaint();
-                    getMainPanel().getCurrentScrollPane().getViewport().setViewPosition( scroll_position );
                 }
             }
-            else if ( ( e.getKeyCode() == KeyEvent.VK_SUBTRACT ) || ( e.getKeyCode() == KeyEvent.VK_MINUS ) ) {
-                getMainPanel().getControlPanel().zoomOutY( Constants.WHEEL_ZOOM_OUT_FACTOR );
-                getMainPanel().getControlPanel().zoomOutX( Constants.WHEEL_ZOOM_OUT_FACTOR,
-                                                           Constants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR );
-                getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
-            }
-            else if ( plusPressed( e.getKeyCode() ) ) {
-                getMainPanel().getControlPanel().zoomInX( Constants.WHEEL_ZOOM_IN_FACTOR,
-                                                          Constants.WHEEL_ZOOM_IN_FACTOR );
-                getMainPanel().getControlPanel().zoomInY( Constants.WHEEL_ZOOM_IN_FACTOR );
-                getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
-            }
-            else if ( e.getKeyCode() == KeyEvent.VK_S ) {
-                if ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
-                        || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
-                    setStartingAngle( ( getStartingAngle() % TWO_PI ) + ANGLE_ROTATION_UNIT );
-                    getControlPanel().displayedPhylogenyMightHaveChanged( false );
-                }
+            TreePanel.drawString( sb_str, x_coord, y_coord, g );
+            if ( need_to_reset ) {
+                g.setTransform( _at );
             }
-            else if ( e.getKeyCode() == KeyEvent.VK_A ) {
-                if ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
-                        || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
-                    setStartingAngle( ( getStartingAngle() % TWO_PI ) - ANGLE_ROTATION_UNIT );
-                    if ( getStartingAngle() < 0 ) {
-                        setStartingAngle( TWO_PI + getStartingAngle() );
-                    }
-                    getControlPanel().displayedPhylogenyMightHaveChanged( false );
-                }
+        }
+    }
+
+    final private void paintNodeLite( final Graphics2D g, final PhylogenyNode node ) {
+        if ( node.isCollapse() ) {
+            if ( !node.isRoot() && !node.getParent().isCollapse() ) {
+                paintCollapsedNode( g, node, false, false, false );
             }
-            else if ( e.getKeyCode() == KeyEvent.VK_D ) {
-                boolean selected = false;
-                if ( getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.HORIZONTAL ) {
-                    getOptions().setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
-                    selected = true;
+            return;
+        }
+        if ( isInFoundNodes( node ) || isInCurrentExternalNodes( node ) ) {
+            g.setColor( getColorForFoundNode( node ) );
+            drawRectFilled( node.getXSecondary() - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF, node.getYSecondary()
+                    - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF, OVERVIEW_FOUND_NODE_BOX_SIZE, OVERVIEW_FOUND_NODE_BOX_SIZE, g );
+        }
+        float new_x = 0;
+        if ( !node.isExternal() && !node.isCollapse() ) {
+            boolean first_child = true;
+            float y2 = 0.0f;
+            final int parent_max_branch_to_leaf = getMaxBranchesToLeaf( node );
+            for( int i = 0; i < node.getNumberOfDescendants(); ++i ) {
+                final PhylogenyNode child_node = node.getChildNode( i );
+                int factor_x;
+                if ( !isUniformBranchLengthsForCladogram() ) {
+                    factor_x = node.getNumberOfExternalNodes() - child_node.getNumberOfExternalNodes();
                 }
                 else {
-                    getOptions().setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
+                    factor_x = parent_max_branch_to_leaf - getMaxBranchesToLeaf( child_node );
                 }
-                if ( getMainPanel().getMainFrame() == null ) {
-                    // Must be "E" applet version.
-                    final ArchaeopteryxE ae = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
-                    if ( ae.getlabelDirectionCbmi() != null ) {
-                        ae.getlabelDirectionCbmi().setSelected( selected );
-                    }
+                if ( first_child ) {
+                    first_child = false;
+                    y2 = node.getYSecondary()
+                            - ( getOvYDistance() * ( node.getNumberOfExternalNodes() - child_node
+                                    .getNumberOfExternalNodes() ) );
                 }
                 else {
-                    getMainPanel().getMainFrame().getlabelDirectionCbmi().setSelected( selected );
+                    y2 += getOvYDistance() * child_node.getNumberOfExternalNodes();
                 }
-                repaint();
-            }
-            else if ( e.getKeyCode() == KeyEvent.VK_X ) {
-                switchDisplaygetPhylogenyGraphicsType();
-                repaint();
-            }
-            else if ( e.getKeyCode() == KeyEvent.VK_C ) {
-                cycleColors();
-                repaint();
-            }
-            else if ( getOptions().isShowOverview() && isOvOn() && ( e.getKeyCode() == KeyEvent.VK_O ) ) {
-                MainFrame.cycleOverview( getOptions(), this );
-                repaint();
-            }
-            else if ( getOptions().isShowOverview() && isOvOn() && ( e.getKeyCode() == KeyEvent.VK_I ) ) {
-                increaseOvSize();
-            }
-            else if ( getOptions().isShowOverview() && isOvOn() && ( e.getKeyCode() == KeyEvent.VK_U ) ) {
-                decreaseOvSize();
+                final float x2 = calculateOvBranchLengthToParent( child_node, factor_x );
+                new_x = x2 + node.getXSecondary();
+                final float diff_y = node.getYSecondary() - y2;
+                final float diff_x = node.getXSecondary() - new_x;
+                if ( ( diff_y > 2 ) || ( diff_y < -2 ) || ( diff_x > 2 ) || ( diff_x < -2 ) ) {
+                    paintBranchLite( g, node.getXSecondary(), new_x, node.getYSecondary(), y2, child_node );
+                }
+                child_node.setXSecondary( new_x );
+                child_node.setYSecondary( y2 );
+                y2 += getOvYDistance() * child_node.getNumberOfExternalNodes();
             }
-            e.consume();
         }
     }
 
-    final private void makePopupMenus( final PhylogenyNode node ) {
-        _node_popup_menu = new JPopupMenu();
-        final List<String> clickto_names = _main_panel.getControlPanel().getSingleClickToNames();
-        _node_popup_menu_items = new JMenuItem[ clickto_names.size() ];
-        for( int i = 0; i < clickto_names.size(); i++ ) {
-            final String title = clickto_names.get( i );
-            _node_popup_menu_items[ i ] = new JMenuItem( title );
-            if ( title.equals( Configuration.clickto_options[ Configuration.open_seq_web ][ 0 ] ) ) {
-                final String id = isCanOpenSeqWeb( node );
-                if ( !ForesterUtil.isEmpty( id ) ) {
-                    _node_popup_menu_items[ i ].setText( _node_popup_menu_items[ i ].getText() + " [" + id + "]" );
-                    _node_popup_menu_items[ i ].setEnabled( true );
-                }
-                else {
-                    _node_popup_menu_items[ i ].setEnabled( false );
-                }
-            }
-            else if ( title.equals( Configuration.clickto_options[ Configuration.open_pdb_web ][ 0 ] ) ) {
-                final List<Accession> accs = getPdbAccs( node );
-                _node_popup_menu_items[ i ] = new JMenuItem( title );
-                if ( !ForesterUtil.isEmpty( accs ) ) {
-                    if ( accs.size() == 1 ) {
-                        _node_popup_menu_items[ i ].setText( _node_popup_menu_items[ i ].getText() + " ["
-                                + TreePanelUtil.pdbAccToString( accs, 0 ) + "]" );
-                        _node_popup_menu_items[ i ].setEnabled( true );
-                    }
-                    else if ( accs.size() == 2 ) {
-                        _node_popup_menu_items[ i ].setText( _node_popup_menu_items[ i ].getText() + " ["
-                                + TreePanelUtil.pdbAccToString( accs, 0 ) + ", "
-                                + TreePanelUtil.pdbAccToString( accs, 1 ) + "]" );
-                        _node_popup_menu_items[ i ].setEnabled( true );
-                    }
-                    else if ( accs.size() == 3 ) {
-                        _node_popup_menu_items[ i ].setText( _node_popup_menu_items[ i ].getText() + " ["
-                                + TreePanelUtil.pdbAccToString( accs, 0 ) + ", "
-                                + TreePanelUtil.pdbAccToString( accs, 1 ) + ", "
-                                + TreePanelUtil.pdbAccToString( accs, 2 ) + "]" );
-                        _node_popup_menu_items[ i ].setEnabled( true );
-                    }
-                    else {
-                        _node_popup_menu_items[ i ].setText( _node_popup_menu_items[ i ].getText() + " ["
-                                + TreePanelUtil.pdbAccToString( accs, 0 ) + ", "
-                                + TreePanelUtil.pdbAccToString( accs, 1 ) + ", "
-                                + TreePanelUtil.pdbAccToString( accs, 2 ) + ", + " + ( accs.size() - 3 ) + " more]" );
-                        _node_popup_menu_items[ i ].setEnabled( true );
-                    }
-                }
-                else {
-                    _node_popup_menu_items[ i ].setEnabled( false );
-                }
+    final private void paintNodeRectangular( final Graphics2D g,
+                                             final PhylogenyNode node,
+                                             final boolean to_pdf,
+                                             final boolean dynamically_hide,
+                                             final int dynamic_hiding_factor,
+                                             final boolean to_graphics_file,
+                                             final boolean disallow_shortcutting ) {
+        final boolean is_in_found_nodes = isInFoundNodes( node ) || isInCurrentExternalNodes( node );
+        if ( node.isCollapse() ) {
+            if ( ( !node.isRoot() && !node.getParent().isCollapse() ) ) {
+                paintCollapsedNode( g, node, to_graphics_file, to_pdf, is_in_found_nodes );
             }
-            else if ( title.startsWith( Configuration.clickto_options[ Configuration.get_ext_desc_data ][ 0 ] ) ) {
-                _node_popup_menu_items[ i ]
-                        .setText( Configuration.clickto_options[ Configuration.get_ext_desc_data ][ 0 ] + ": "
-                                + getOptions().getExtDescNodeDataToReturn().toString() );
+            return;
+        }
+        if ( node.isExternal() ) {
+            ++_external_node_index;
+        }
+        // Confidence values
+        if ( getControlPanel().isShowConfidenceValues()
+                && !node.isExternal()
+                && !node.isRoot()
+                && ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED )
+                        || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) )
+                && node.getBranchData().isHasConfidences() ) {
+            paintConfidenceValues( g, node, to_pdf, to_graphics_file );
+        }
+        // Draw a line to root:
+        if ( node.isRoot() && _phylogeny.isRooted() ) {
+            paintRootBranch( g, node.getXcoord(), node.getYcoord(), node, to_pdf, to_graphics_file );
+        }
+        float new_x = 0;
+        float new_x_min = Float.MAX_VALUE;
+        float min_dist = 1.5f;
+        if ( !disallow_shortcutting ) {
+            if ( dynamic_hiding_factor > 4000 ) {
+                min_dist = 4;
             }
-            else if ( title.equals( Configuration.clickto_options[ Configuration.open_tax_web ][ 0 ] ) ) {
-                _node_popup_menu_items[ i ].setEnabled( isCanOpenTaxWeb( node ) );
+            else if ( dynamic_hiding_factor > 1000 ) {
+                min_dist = 3;
             }
-            else if ( title.equals( Configuration.clickto_options[ Configuration.blast ][ 0 ] ) ) {
-                _node_popup_menu_items[ i ].setEnabled( isCanBlast( node ) );
+            else if ( dynamic_hiding_factor > 100 ) {
+                min_dist = 2;
             }
-            else if ( title.equals( Configuration.clickto_options[ Configuration.delete_subtree_or_node ][ 0 ] ) ) {
-                if ( !getOptions().isEditable() ) {
-                    continue;
+        }
+        if ( !node.isExternal() && !node.isCollapse() ) {
+            boolean first_child = true;
+            float y2 = 0.0f;
+            final int parent_max_branch_to_leaf = getMaxBranchesToLeaf( node );
+            for( int i = 0; i < node.getNumberOfDescendants(); ++i ) {
+                final PhylogenyNode child_node = node.getChildNode( i );
+                int factor_x;
+                if ( !isUniformBranchLengthsForCladogram() ) {
+                    factor_x = node.getNumberOfExternalNodes() - child_node.getNumberOfExternalNodes();
                 }
-                _node_popup_menu_items[ i ].setEnabled( isCanDelete() );
-            }
-            else if ( title.equals( Configuration.clickto_options[ Configuration.cut_subtree ][ 0 ] ) ) {
-                if ( !getOptions().isEditable() ) {
-                    continue;
+                else {
+                    factor_x = parent_max_branch_to_leaf - getMaxBranchesToLeaf( child_node );
                 }
-                _node_popup_menu_items[ i ].setEnabled( isCanCut( node ) );
-            }
-            else if ( title.equals( Configuration.clickto_options[ Configuration.copy_subtree ][ 0 ] ) ) {
-                if ( !getOptions().isEditable() ) {
-                    continue;
+                if ( first_child ) {
+                    first_child = false;
+                    y2 = node.getYcoord()
+                            - ( _y_distance * ( node.getNumberOfExternalNodes() - child_node.getNumberOfExternalNodes() ) );
                 }
-                _node_popup_menu_items[ i ].setEnabled( isCanCopy() );
-            }
-            else if ( title.equals( Configuration.clickto_options[ Configuration.paste_subtree ][ 0 ] ) ) {
-                if ( !getOptions().isEditable() ) {
-                    continue;
+                else {
+                    y2 += _y_distance * child_node.getNumberOfExternalNodes();
                 }
-                _node_popup_menu_items[ i ].setEnabled( isCanPaste() );
-            }
-            else if ( title.equals( Configuration.clickto_options[ Configuration.edit_node_data ][ 0 ] ) ) {
-                if ( !getOptions().isEditable() ) {
-                    continue;
+                final float x2 = calculateBranchLengthToParent( child_node, factor_x );
+                new_x = x2 + node.getXcoord();
+                if ( dynamically_hide && ( x2 < new_x_min ) ) {
+                    new_x_min = x2;
                 }
-            }
-            else if ( title.equals( Configuration.clickto_options[ Configuration.add_new_node ][ 0 ] ) ) {
-                if ( !getOptions().isEditable() ) {
-                    continue;
+                final float diff_y = node.getYcoord() - y2;
+                final float diff_x = node.getXcoord() - new_x;
+                if ( disallow_shortcutting || ( diff_y > min_dist ) || ( diff_y < -min_dist ) || ( diff_x > min_dist )
+                        || ( diff_x < -min_dist ) ) {
+                    paintBranchRectangular( g,
+                                            node.getXcoord(),
+                                            new_x,
+                                            node.getYcoord(),
+                                            y2,
+                                            child_node,
+                                            to_pdf,
+                                            to_graphics_file );
                 }
+                child_node.setXcoord( new_x );
+                child_node.setYcoord( y2 );
+                y2 += _y_distance * child_node.getNumberOfExternalNodes();
             }
-            else if ( title.equals( Configuration.clickto_options[ Configuration.reroot ][ 0 ] ) ) {
-                _node_popup_menu_items[ i ].setEnabled( isCanReroot() );
-            }
-            else if ( title.equals( Configuration.clickto_options[ Configuration.collapse_uncollapse ][ 0 ] ) ) {
-                _node_popup_menu_items[ i ].setEnabled( ( isCanCollapse() && !node.isExternal() ) );
-            }
-            else if ( title.equals( Configuration.clickto_options[ Configuration.color_subtree ][ 0 ] ) ) {
-                _node_popup_menu_items[ i ].setEnabled( isCanColorSubtree() );
-            }
-            else if ( title.equals( Configuration.clickto_options[ Configuration.subtree ][ 0 ] ) ) {
-                _node_popup_menu_items[ i ].setEnabled( isCanSubtree( node ) );
-            }
-            else if ( title.equals( Configuration.clickto_options[ Configuration.swap ][ 0 ] ) ) {
-                _node_popup_menu_items[ i ].setEnabled( node.getNumberOfDescendants() == 2 );
-            }
-            else if ( title.equals( Configuration.clickto_options[ Configuration.sort_descendents ][ 0 ] ) ) {
-                _node_popup_menu_items[ i ].setEnabled( node.getNumberOfDescendants() > 1 );
-            }
-            _node_popup_menu_items[ i ].addActionListener( this );
-            _node_popup_menu.add( _node_popup_menu_items[ i ] );
+            paintNodeBox( node.getXcoord(), node.getYcoord(), node, g, to_pdf, to_graphics_file );
+        }
+        if ( getControlPanel().isShowMolSequences() && ( node.getNodeData().isHasSequence() )
+                && ( node.getNodeData().getSequence().isMolecularSequenceAligned() )
+                && ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) ) {
+            paintMolecularSequences( g, node, to_pdf );
+        }
+        if ( dynamically_hide
+                && !is_in_found_nodes
+                && ( ( node.isExternal() && ( ( _external_node_index % dynamic_hiding_factor ) != 1 ) ) || ( !node
+                        .isExternal() && ( ( new_x_min < 20 ) || ( ( _y_distance * node.getNumberOfExternalNodes() ) < getFontMetricsForLargeDefaultFont()
+                        .getHeight() ) ) ) ) ) {
+            return;
         }
+        final int x = paintNodeData( g, node, to_graphics_file, to_pdf, is_in_found_nodes );
+        paintNodeWithRenderableData( x, g, node, to_graphics_file, to_pdf );
     }
 
-    private final void nodeDataAsSB( final PhylogenyNode node, final StringBuilder sb ) {
-        if ( node != null ) {
-            if ( getControlPanel().isShowNodeNames() && ( !ForesterUtil.isEmpty( node.getName() ) ) ) {
-                if ( sb.length() > 0 ) {
-                    sb.append( " " );
-                }
-                sb.append( node.getName() );
+    final private void paintNodeWithRenderableData( final int x,
+                                                    final Graphics2D g,
+                                                    final PhylogenyNode node,
+                                                    final boolean to_graphics_file,
+                                                    final boolean to_pdf ) {
+        if ( isNodeDataInvisible( node ) && !( to_graphics_file || to_pdf ) ) {
+            return;
+        }
+        if ( ( !getControlPanel().isShowInternalData() && !node.isExternal() ) ) {
+            return;
+        }
+        if ( getControlPanel().isShowDomainArchitectures() && node.getNodeData().isHasSequence()
+                && ( node.getNodeData().getSequence().getDomainArchitecture() != null )
+                && ( node.getNodeData().getSequence().getDomainArchitecture() instanceof RenderableDomainArchitecture ) ) {
+            RenderableDomainArchitecture rds = null;
+            try {
+                rds = ( RenderableDomainArchitecture ) node.getNodeData().getSequence().getDomainArchitecture();
             }
-            if ( node.getNodeData().isHasSequence() ) {
-                if ( getControlPanel().isShowSeqSymbols()
-                        && ( node.getNodeData().getSequence().getSymbol().length() > 0 ) ) {
-                    if ( sb.length() > 0 ) {
-                        sb.append( " " );
-                    }
-                    sb.append( node.getNodeData().getSequence().getSymbol() );
+            catch ( final ClassCastException cce ) {
+                cce.printStackTrace();
+            }
+            if ( rds != null ) {
+                final int default_height = 7;
+                float y = getYdistance();
+                if ( getControlPanel().isDynamicallyHideData() ) {
+                    y = getTreeFontSet().getFontMetricsLarge().getHeight();
                 }
-                if ( getControlPanel().isShowGeneNames()
-                        && ( node.getNodeData().getSequence().getGeneName().length() > 0 ) ) {
-                    if ( sb.length() > 0 ) {
-                        sb.append( " " );
+                final int h = y < default_height ? ForesterUtil.roundToInt( y ) : default_height;
+                rds.setRenderingHeight( h > 1 ? h : 2 );
+                if ( getControlPanel().isDrawPhylogram() ) {
+                    if ( getOptions().isLineUpRendarableNodeData() ) {
+                        if ( getOptions().isRightLineUpDomains() ) {
+                            rds.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() )
+                                    + _length_of_longest_text + ( ( _longest_domain - rds.getTotalLength() ) * rds
+                                    .getRenderingFactorWidth() ) ), node.getYcoord() - ( h / 2.0f ), g, this, to_pdf );
+                        }
+                        else {
+                            rds.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() ) + _length_of_longest_text ),
+                                        node.getYcoord() - ( h / 2.0f ),
+                                        g,
+                                        this,
+                                        to_pdf );
+                        }
                     }
-                    sb.append( node.getNodeData().getSequence().getGeneName() );
-                }
-                if ( getControlPanel().isShowSeqNames() && ( node.getNodeData().getSequence().getName().length() > 0 ) ) {
-                    if ( sb.length() > 0 ) {
-                        sb.append( " " );
+                    else {
+                        rds.render( node.getXcoord() + x, node.getYcoord() - ( h / 2.0f ), g, this, to_pdf );
                     }
-                    sb.append( node.getNodeData().getSequence().getName() );
                 }
-                if ( getControlPanel().isShowSequenceAcc()
-                        && ( node.getNodeData().getSequence().getAccession() != null ) ) {
-                    if ( sb.length() > 0 ) {
-                        sb.append( " " );
-                    }
-                    if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getSource() ) ) {
-                        sb.append( node.getNodeData().getSequence().getAccession().getSource() );
-                        sb.append( ":" );
+                else {
+                    if ( getOptions().isRightLineUpDomains() ) {
+                        rds.render( ( ( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text ) - 20 )
+                                            + ( ( _longest_domain - rds.getTotalLength() ) * rds
+                                                    .getRenderingFactorWidth() ),
+                                    node.getYcoord() - ( h / 2.0f ),
+                                    g,
+                                    this,
+                                    to_pdf );
+                    }
+                    else {
+                        rds.render( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text,
+                                    node.getYcoord() - ( h / 2.0f ),
+                                    g,
+                                    this,
+                                    to_pdf );
                     }
-                    sb.append( node.getNodeData().getSequence().getAccession().getValue() );
-                }
-            }
-            if ( getControlPanel().isShowProperties() && node.getNodeData().isHasProperties() ) {
-                if ( sb.length() > 0 ) {
-                    sb.append( " " );
                 }
-                sb.append( propertiesToString( node ) );
             }
         }
-    }
-
-    private final void nodeTaxonomyDataAsSB( final Taxonomy taxonomy, final StringBuilder sb ) {
-        if ( _control_panel.isShowTaxonomyCode() && !ForesterUtil.isEmpty( taxonomy.getTaxonomyCode() ) ) {
-            sb.append( taxonomy.getTaxonomyCode() );
-            sb.append( " " );
-        }
-        if ( _control_panel.isShowTaxonomyScientificNames() && _control_panel.isShowTaxonomyCommonNames() ) {
-            if ( !ForesterUtil.isEmpty( taxonomy.getScientificName() )
-                    && !ForesterUtil.isEmpty( taxonomy.getCommonName() ) ) {
-                if ( getOptions().isAbbreviateScientificTaxonNames()
-                        && ( taxonomy.getScientificName().indexOf( ' ' ) > 0 ) ) {
-                    abbreviateScientificName( taxonomy.getScientificName(), sb );
-                }
-                else {
-                    sb.append( taxonomy.getScientificName() );
+        if ( getControlPanel().isShowVectorData() && ( node.getNodeData().getVector() != null )
+                && ( node.getNodeData().getVector().size() > 0 ) && ( getStatisticsForExpressionValues() != null ) ) {
+            final RenderableVector rv = RenderableVector.createInstance( node.getNodeData().getVector(),
+                                                                         getStatisticsForExpressionValues(),
+                                                                         getConfiguration() );
+            if ( rv != null ) {
+                double domain_add = 0;
+                if ( getControlPanel().isShowDomainArchitectures() && node.getNodeData().isHasSequence()
+                        && ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) {
+                    domain_add = _domain_structure_width + 10;
                 }
-                sb.append( " (" );
-                sb.append( taxonomy.getCommonName() );
-                sb.append( ") " );
-            }
-            else if ( !ForesterUtil.isEmpty( taxonomy.getScientificName() ) ) {
-                if ( getOptions().isAbbreviateScientificTaxonNames()
-                        && ( taxonomy.getScientificName().indexOf( ' ' ) > 0 ) ) {
-                    abbreviateScientificName( taxonomy.getScientificName(), sb );
+                if ( getControlPanel().isDrawPhylogram() ) {
+                    rv.render( ( float ) ( node.getXcoord() + x + domain_add ), node.getYcoord() - 3, g, this, to_pdf );
                 }
                 else {
-                    sb.append( taxonomy.getScientificName() );
+                    rv.render( ( float ) ( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text + domain_add ),
+                               node.getYcoord() - 3,
+                               g,
+                               this,
+                               to_pdf );
                 }
-                sb.append( " " );
-            }
-            else if ( !ForesterUtil.isEmpty( taxonomy.getCommonName() ) ) {
-                sb.append( taxonomy.getCommonName() );
-                sb.append( " " );
             }
         }
-        else if ( _control_panel.isShowTaxonomyScientificNames() ) {
-            if ( !ForesterUtil.isEmpty( taxonomy.getScientificName() ) ) {
-                if ( getOptions().isAbbreviateScientificTaxonNames()
-                        && ( taxonomy.getScientificName().indexOf( ' ' ) > 0 ) ) {
-                    abbreviateScientificName( taxonomy.getScientificName(), sb );
-                }
-                else {
-                    sb.append( taxonomy.getScientificName() );
-                }
-                sb.append( " " );
-            }
+        //if ( getControlPanel().isShowMolSequences() && ( node.getNodeData().isHasSequence() )
+        //        && ( node.getNodeData().getSequence().isMolecularSequenceAligned() )
+        //        && ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) ) {
+        //    paintMolecularSequences( g, node, to_pdf );
+        //}
+    }
+
+    final private void paintOvRectangle( final Graphics2D g ) {
+        final float w_ratio = ( ( float ) getWidth() ) / getVisibleRect().width;
+        final float h_ratio = ( ( float ) getHeight() ) / getVisibleRect().height;
+        final float x_ratio = ( ( float ) getWidth() ) / getVisibleRect().x;
+        final float y_ratio = ( ( float ) getHeight() ) / getVisibleRect().y;
+        final float width = getOvMaxWidth() / w_ratio;
+        final float height = getOvMaxHeight() / h_ratio;
+        final float x = getVisibleRect().x + getOvXPosition() + ( getOvMaxWidth() / x_ratio );
+        final float y = getVisibleRect().y + getOvYPosition() + ( getOvMaxHeight() / y_ratio );
+        g.setColor( getTreeColorSet().getFoundColor0() );
+        getOvRectangle().setRect( x, y, width, height );
+        final Stroke s = g.getStroke();
+        g.setStroke( STROKE_1 );
+        if ( ( width < 6 ) && ( height < 6 ) ) {
+            drawRectFilled( x, y, 6, 6, g );
+            getOvVirtualRectangle().setRect( x, y, 6, 6 );
         }
-        else if ( _control_panel.isShowTaxonomyCommonNames() ) {
-            if ( !ForesterUtil.isEmpty( taxonomy.getCommonName() ) ) {
-                sb.append( taxonomy.getCommonName() );
-                sb.append( " " );
+        else if ( width < 6 ) {
+            drawRectFilled( x, y, 6, height, g );
+            getOvVirtualRectangle().setRect( x, y, 6, height );
+        }
+        else if ( height < 6 ) {
+            drawRectFilled( x, y, width, 6, g );
+            getOvVirtualRectangle().setRect( x, y, width, 6 );
+        }
+        else {
+            drawRect( x, y, width, height, g );
+            if ( isInOvRect() ) {
+                drawRect( x + 1, y + 1, width - 2, height - 2, g );
             }
+            getOvVirtualRectangle().setRect( x, y, width, height );
         }
+        g.setStroke( s );
     }
 
-    private final String obtainTitleForExtDescNodeData() {
-        return getOptions().getExtDescNodeDataToReturn().toString();
+    final private void paintPhylogenyLite( final Graphics2D g ) {
+        _phylogeny
+                .getRoot()
+                .setXSecondary( ( float ) ( getVisibleRect().x + getOvXPosition() + ( MOVE / ( getVisibleRect().width / getOvRectangle()
+                        .getWidth() ) ) ) );
+        _phylogeny.getRoot().setYSecondary( ( getVisibleRect().y + getOvYStart() ) );
+        final Stroke s = g.getStroke();
+        g.setStroke( STROKE_05 );
+        for( final PhylogenyNode element : _nodes_in_preorder ) {
+            paintNodeLite( g, element );
+        }
+        g.setStroke( s );
+        paintOvRectangle( g );
     }
 
-    final private void openPdbWeb( final PhylogenyNode node ) {
-        final List<Accession> pdb_ids = getPdbAccs( node );
-        if ( ForesterUtil.isEmpty( pdb_ids ) ) {
-            cannotOpenBrowserWarningMessage( "PDB" );
-            return;
+    /**
+     * Paint the root branch. (Differs from others because it will always be a
+     * single horizontal line).
+     * @param to_graphics_file
+     *
+     * @return new x1 value
+     */
+    final private void paintRootBranch( final Graphics2D g,
+                                        final float x1,
+                                        final float y1,
+                                        final PhylogenyNode root,
+                                        final boolean to_pdf,
+                                        final boolean to_graphics_file ) {
+        assignGraphicsForBranchWithColorForParentBranch( root, false, g, to_pdf, to_graphics_file );
+        float d = getXdistance();
+        if ( getControlPanel().isDrawPhylogram() && ( root.getDistanceToParent() > 0.0 ) ) {
+            d = ( float ) ( getXcorrectionFactor() * root.getDistanceToParent() );
         }
-        final List<String> uri_strs = TreePanelUtil.createUrisForPdbWeb( node, pdb_ids, getConfiguration(), this );
-        if ( !ForesterUtil.isEmpty( uri_strs ) ) {
-            for( final String uri_str : uri_strs ) {
-                try {
-                    AptxUtil.launchWebBrowser( new URI( uri_str ),
-                                               isApplet(),
-                                               isApplet() ? obtainApplet() : null,
-                            "_aptx_seq" );
-                }
-                catch ( final IOException e ) {
-                    AptxUtil.showErrorMessage( this, e.toString() );
-                    e.printStackTrace();
-                }
-                catch ( final URISyntaxException e ) {
-                    AptxUtil.showErrorMessage( this, e.toString() );
-                    e.printStackTrace();
-                }
-            }
+        if ( d < MIN_ROOT_LENGTH ) {
+            d = MIN_ROOT_LENGTH;
+        }
+        if ( !getControlPanel().isWidthBranches() || ( PhylogenyMethods.getBranchWidthValue( root ) == 1 ) ) {
+            drawLine( x1 - d, root.getYcoord(), x1, root.getYcoord(), g );
         }
         else {
-            cannotOpenBrowserWarningMessage( "PDB" );
+            final double w = PhylogenyMethods.getBranchWidthValue( root );
+            drawRectFilled( x1 - d, root.getYcoord() - ( w / 2 ), d, w, g );
         }
+        paintNodeBox( x1, root.getYcoord(), root, g, to_pdf, to_graphics_file );
     }
 
-    final private void openSeqWeb( final PhylogenyNode node ) {
-        if ( ForesterUtil.isEmpty( isCanOpenSeqWeb( node ) ) ) {
-            cannotOpenBrowserWarningMessage( "sequence" );
-            return;
-        }
-        final String uri_str = TreePanelUtil.createUriForSeqWeb( node, getConfiguration(), this );
-        if ( !ForesterUtil.isEmpty( uri_str ) ) {
-            try {
-                AptxUtil.launchWebBrowser( new URI( uri_str ),
-                                           isApplet(),
-                                           isApplet() ? obtainApplet() : null,
-                        "_aptx_seq" );
-            }
-            catch ( final IOException e ) {
-                AptxUtil.showErrorMessage( this, e.toString() );
-                e.printStackTrace();
-            }
-            catch ( final URISyntaxException e ) {
-                AptxUtil.showErrorMessage( this, e.toString() );
-                e.printStackTrace();
-            }
+    final private void paintScale( final Graphics2D g,
+                                   int x1,
+                                   int y1,
+                                   final boolean to_pdf,
+                                   final boolean to_graphics_file ) {
+        x1 += MOVE;
+        final double x2 = x1 + ( getScaleDistance() * getXcorrectionFactor() );
+        y1 -= 12;
+        final int y2 = y1 - 8;
+        final int y3 = y1 - 4;
+        g.setFont( getTreeFontSet().getSmallFont() );
+        if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
+            g.setColor( Color.BLACK );
         }
         else {
-            cannotOpenBrowserWarningMessage( "sequence" );
+            g.setColor( getTreeColorSet().getBranchLengthColor() );
+        }
+        final Stroke s = g.getStroke();
+        g.setStroke( STROKE_1 );
+        drawLine( x1, y1, x1, y2, g );
+        drawLine( x2, y1, x2, y2, g );
+        drawLine( x1, y3, x2, y3, g );
+        if ( getScaleLabel() != null ) {
+            g.drawString( getScaleLabel(), ( x1 + 2 ), y3 - 2 );
         }
+        g.setStroke( s );
     }
 
-    final private void openTaxWeb( final PhylogenyNode node ) {
-        if ( !isCanOpenTaxWeb( node ) ) {
-            cannotOpenBrowserWarningMessage( "taxonomic" );
-            return;
+    final private int paintTaxonomy( final Graphics2D g,
+                                     final PhylogenyNode node,
+                                     final boolean is_in_found_nodes,
+                                     final boolean to_pdf,
+                                     final boolean to_graphics_file,
+                                     final float x_shift ) {
+        final Taxonomy taxonomy = node.getNodeData().getTaxonomy();
+        final boolean using_visual_font = setFont( g, node, is_in_found_nodes );
+        setColor( g, node, to_graphics_file, to_pdf, is_in_found_nodes, getTreeColorSet().getTaxonomyColor() );
+        final float start_x = node.getXcoord() + 3 + ( getOptions().getDefaultNodeShapeSize() / 2 ) + x_shift;
+        float start_y;
+        if ( !using_visual_font ) {
+            start_y = node.getYcoord()
+                    + ( getFontMetricsForLargeDefaultFont().getAscent() / ( node.getNumberOfDescendants() == 1 ? 1
+                            : 3.0f ) );
         }
-        String uri_str = null;
-        final Taxonomy tax = node.getNodeData().getTaxonomy();
-        if ( ( tax.getIdentifier() != null ) && !ForesterUtil.isEmpty( tax.getIdentifier().getValue() )
-                && tax.getIdentifier().getValue().startsWith( "http://" ) ) {
-            try {
-                uri_str = new URI( tax.getIdentifier().getValue() ).toString();
-            }
-            catch ( final URISyntaxException e ) {
-                AptxUtil.showErrorMessage( this, e.toString() );
-                uri_str = null;
-                e.printStackTrace();
-            }
+        else {
+            start_y = node.getYcoord()
+                    + ( getFontMetrics( g.getFont() ).getAscent() / ( node.getNumberOfDescendants() == 1 ? 1 : 3.0f ) );
         }
-        else if ( ( tax.getIdentifier() != null )
-                && !ForesterUtil.isEmpty( tax.getIdentifier().getValue() )
-                && !ForesterUtil.isEmpty( tax.getIdentifier().getProvider() )
-                && ( tax.getIdentifier().getProvider().equalsIgnoreCase( "ncbi" ) || tax.getIdentifier().getProvider()
-                        .equalsIgnoreCase( "uniprot" ) ) ) {
-            try {
-                uri_str = "http://www.uniprot.org/taxonomy/"
-                        + URLEncoder.encode( tax.getIdentifier().getValue(), ForesterConstants.UTF8 );
-            }
-            catch ( final UnsupportedEncodingException e ) {
-                AptxUtil.showErrorMessage( this, e.toString() );
-                e.printStackTrace();
-            }
+        _sb.setLength( 0 );
+        nodeTaxonomyDataAsSB( taxonomy, _sb );
+        final String label = _sb.toString();
+        /* GUILHEM_BEG */
+        if ( _control_panel.isShowSequenceRelations() && ( label.length() > 0 )
+                && ( node.getNodeData().isHasSequence() ) && node.getNodeData().getSequence().equals( _query_sequence ) ) {
+            // invert font color and background color to show that this is the query sequence
+            final Rectangle2D nodeTextBounds = new TextLayout( label, g.getFont(), new FontRenderContext( null,
+                                                                                                          false,
+                                                                                                          false ) )
+                    .getBounds();
+            g.fillRect( ( int ) start_x - 1, ( int ) start_y - 8, ( int ) nodeTextBounds.getWidth() + 4, 11 );
+            g.setColor( getTreeColorSet().getBackgroundColor() );
         }
-        else if ( !ForesterUtil.isEmpty( tax.getScientificName() ) ) {
-            try {
-                uri_str = "http://www.uniprot.org/taxonomy/?query="
-                        + URLEncoder.encode( tax.getScientificName(), ForesterConstants.UTF8 );
-            }
-            catch ( final UnsupportedEncodingException e ) {
-                AptxUtil.showErrorMessage( this, e.toString() );
-                e.printStackTrace();
-            }
+        /* GUILHEM_END */
+        TreePanel.drawString( label, start_x, start_y, g );
+        if ( !using_visual_font && !is_in_found_nodes ) {
+            return getFontMetricsForLargeDefaultFont().stringWidth( label );
         }
-        else if ( !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) {
-            try {
-                uri_str = "http://www.uniprot.org/taxonomy/?query="
-                        + URLEncoder.encode( tax.getTaxonomyCode(), ForesterConstants.UTF8 );
-            }
-            catch ( final UnsupportedEncodingException e ) {
-                AptxUtil.showErrorMessage( this, e.toString() );
-                e.printStackTrace();
-            }
+        return getFontMetrics( g.getFont() ).stringWidth( label );
+    }
+
+    final private void paintUnrooted( final PhylogenyNode n,
+                                      final double low_angle,
+                                      final double high_angle,
+                                      final boolean radial_labels,
+                                      final Graphics2D g,
+                                      final boolean to_pdf,
+                                      final boolean to_graphics_file ) {
+        if ( n.isRoot() ) {
+            n.setXcoord( getWidth() / 2 );
+            n.setYcoord( getHeight() / 2 );
         }
-        else if ( !ForesterUtil.isEmpty( tax.getCommonName() ) ) {
-            try {
-                uri_str = "http://www.uniprot.org/taxonomy/?query="
-                        + URLEncoder.encode( tax.getCommonName(), ForesterConstants.UTF8 );
-            }
-            catch ( final UnsupportedEncodingException e ) {
-                AptxUtil.showErrorMessage( this, e.toString() );
-                e.printStackTrace();
-            }
+        if ( n.isExternal() ) {
+            paintNodeDataUnrootedCirc( g,
+                                       n,
+                                       to_pdf,
+                                       to_graphics_file,
+                                       radial_labels,
+                                       ( high_angle + low_angle ) / 2,
+                                       isInFoundNodes( n ) || isInCurrentExternalNodes( n ) );
+            return;
         }
-        if ( !ForesterUtil.isEmpty( uri_str ) ) {
-            try {
-                AptxUtil.launchWebBrowser( new URI( uri_str ),
-                                           isApplet(),
-                                           isApplet() ? obtainApplet() : null,
-                        "_aptx_tax" );
-            }
-            catch ( final IOException e ) {
-                AptxUtil.showErrorMessage( this, e.toString() );
-                e.printStackTrace();
+        final float num_enclosed = n.getNumberOfExternalNodes();
+        final float x = n.getXcoord();
+        final float y = n.getYcoord();
+        double current_angle = low_angle;
+        // final boolean n_below = n.getYcoord() < getVisibleRect().getMinY() - 20;
+        // final boolean n_above = n.getYcoord() > getVisibleRect().getMaxY() + 20;
+        // final boolean n_left = n.getXcoord() < getVisibleRect().getMinX() - 20;
+        // final boolean n_right = n.getXcoord() > getVisibleRect().getMaxX() + 20;
+        for( int i = 0; i < n.getNumberOfDescendants(); ++i ) {
+            final PhylogenyNode desc = n.getChildNode( i );
+            ///  if ( ( ( n_below ) & ( desc.getYcoord() < getVisibleRect().getMinY() - 20 ) )
+            //          || ( ( n_above ) & ( desc.getYcoord() > getVisibleRect().getMaxY() + 20 ) )
+            //         || ( ( n_left ) & ( desc.getXcoord() < getVisibleRect().getMinX() - 20 ) )
+            //          || ( ( n_right ) & ( desc.getXcoord() > getVisibleRect().getMaxX() + 20 ) ) ) {
+            //     continue;
+            // }
+            //if ( ( desc.getYcoord() > n.getYcoord() ) && ( n.getYcoord() > getVisibleRect().getMaxY() - 20 ) ) {
+            //    continue;
+            //}
+            //if ( ( desc.getYcoord() < n.getYcoord() ) && ( n.getYcoord() < getVisibleRect().getMinY() + 20 ) ) {
+            //    continue;
+            // }
+            final int desc_num_enclosed = desc.getNumberOfExternalNodes();
+            final double arc_size = ( desc_num_enclosed / num_enclosed ) * ( high_angle - low_angle );
+            float length;
+            if ( isPhyHasBranchLengths() && getControlPanel().isDrawPhylogram() ) {
+                if ( desc.getDistanceToParent() < 0 ) {
+                    length = 0;
+                }
+                else {
+                    length = ( float ) ( desc.getDistanceToParent() * getUrtFactor() );
+                }
             }
-            catch ( final URISyntaxException e ) {
-                AptxUtil.showErrorMessage( this, e.toString() );
-                e.printStackTrace();
+            else {
+                length = getUrtFactor();
             }
+            final double mid_angle = current_angle + ( arc_size / 2 );
+            final float new_x = ( float ) ( x + ( Math.cos( mid_angle ) * length ) );
+            final float new_y = ( float ) ( y + ( Math.sin( mid_angle ) * length ) );
+            desc.setXcoord( new_x );
+            desc.setYcoord( new_y );
+            paintUnrooted( desc, current_angle, current_angle + arc_size, radial_labels, g, to_pdf, to_graphics_file );
+            current_angle += arc_size;
+            assignGraphicsForBranchWithColorForParentBranch( desc, false, g, to_pdf, to_graphics_file );
+            drawLine( x, y, new_x, new_y, g );
+            paintNodeBox( new_x, new_y, desc, g, to_pdf, to_graphics_file );
         }
-        else {
-            cannotOpenBrowserWarningMessage( "taxonomic" );
+        if ( n.isRoot() ) {
+            paintNodeBox( n.getXcoord(), n.getYcoord(), n, g, to_pdf, to_graphics_file );
         }
     }
 
-    final private void paintBranchLength( final Graphics2D g,
-                                          final PhylogenyNode node,
-                                          final boolean to_pdf,
-                                          final boolean to_graphics_file ) {
-        g.setFont( getTreeFontSet().getSmallFont() );
-        if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
-            g.setColor( Color.BLACK );
+    final private void paintUnrootedLite( final PhylogenyNode n,
+                                          final double low_angle,
+                                          final double high_angle,
+                                          final Graphics2D g,
+                                          final float urt_ov_factor ) {
+        if ( n.isRoot() ) {
+            final int x_pos = ( int ) ( getVisibleRect().x + getOvXPosition() + ( getOvMaxWidth() / 2 ) );
+            final int y_pos = ( int ) ( getVisibleRect().y + getOvYPosition() + ( getOvMaxHeight() / 2 ) );
+            n.setXSecondary( x_pos );
+            n.setYSecondary( y_pos );
         }
-        else {
-            g.setColor( getTreeColorSet().getBranchLengthColor() );
+        if ( n.isExternal() ) {
+            return;
         }
-        if ( !node.isRoot() ) {
-            if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) {
-                TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ), node.getParent()
-                                      .getXcoord() + EURO_D, node.getYcoord() - getTreeFontSet().getSmallMaxDescent(), g );
-            }
-            else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) {
-                TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ), node.getParent()
-                                      .getXcoord() + ROUNDED_D, node.getYcoord() - getTreeFontSet().getSmallMaxDescent(), g );
+        final float num_enclosed = n.getNumberOfExternalNodes();
+        final float x = n.getXSecondary();
+        final float y = n.getYSecondary();
+        double current_angle = low_angle;
+        for( int i = 0; i < n.getNumberOfDescendants(); ++i ) {
+            final PhylogenyNode desc = n.getChildNode( i );
+            final int desc_num_enclosed = desc.getNumberOfExternalNodes();
+            final double arc_size = ( desc_num_enclosed / num_enclosed ) * ( high_angle - low_angle );
+            float length;
+            if ( isPhyHasBranchLengths() && getControlPanel().isDrawPhylogram() ) {
+                if ( desc.getDistanceToParent() < 0 ) {
+                    length = 0;
+                }
+                else {
+                    length = ( float ) ( desc.getDistanceToParent() * urt_ov_factor );
+                }
             }
             else {
-                TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ), node.getParent()
-                                      .getXcoord() + 3, node.getYcoord() - getTreeFontSet().getSmallMaxDescent(), g );
+                length = urt_ov_factor;
             }
-        }
-        else {
-            TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ), 3, node.getYcoord()
-                                  - getTreeFontSet().getSmallMaxDescent(), g );
+            final double mid_angle = current_angle + ( arc_size / 2 );
+            final float new_x = ( float ) ( x + ( Math.cos( mid_angle ) * length ) );
+            final float new_y = ( float ) ( y + ( Math.sin( mid_angle ) * length ) );
+            desc.setXSecondary( new_x );
+            desc.setYSecondary( new_y );
+            if ( isInFoundNodes( desc ) || isInCurrentExternalNodes( desc ) ) {
+                g.setColor( getColorForFoundNode( desc ) );
+                drawRectFilled( desc.getXSecondary() - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF,
+                                desc.getYSecondary() - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF,
+                                OVERVIEW_FOUND_NODE_BOX_SIZE,
+                                OVERVIEW_FOUND_NODE_BOX_SIZE,
+                                g );
+                g.setColor( getTreeColorSet().getOvColor() );
+            }
+            paintUnrootedLite( desc, current_angle, current_angle + arc_size, g, urt_ov_factor );
+            current_angle += arc_size;
+            drawLine( x, y, new_x, new_y, g );
         }
     }
 
-    final private void paintBranchLite( final Graphics2D g,
-                                        final float x1,
-                                        final float x2,
-                                        final float y1,
-                                        final float y2,
-                                        final PhylogenyNode node ) {
-        g.setColor( getTreeColorSet().getOvColor() );
-        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR ) {
-            drawLine( x1, y1, x2, y2, g );
+    final private void pasteSubtree( final PhylogenyNode node ) {
+        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
+            errorMessageNoCutCopyPasteInUnrootedDisplay();
+            return;
         }
-        else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CONVEX ) {
-            _quad_curve.setCurve( x1, y1, x1, y2, x2, y2 );
-            ( g ).draw( _quad_curve );
+        if ( ( getCutOrCopiedTree() == null ) || getCutOrCopiedTree().isEmpty() ) {
+            JOptionPane.showMessageDialog( this,
+                                           "No tree in buffer (need to copy or cut a subtree first)",
+                                           "Attempt to paste with empty buffer",
+                                           JOptionPane.ERROR_MESSAGE );
+            return;
         }
-        else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CURVED ) {
-            final float dx = x2 - x1;
-            final float dy = y2 - y1;
-            _cubic_curve.setCurve( x1, y1, x1 + ( dx * 0.4f ), y1 + ( dy * 0.2f ), x1 + ( dx * 0.6f ), y1
-                                   + ( dy * 0.8f ), x2, y2 );
-            ( g ).draw( _cubic_curve );
+        final String label = createASimpleTextRepresentationOfANode( getCutOrCopiedTree().getRoot() );
+        final Object[] options = { "As sibling", "As descendant", "Cancel" };
+        final int r = JOptionPane.showOptionDialog( this,
+                                                    "How to paste subtree" + label + "?",
+                                                    "Paste Subtree",
+                                                    JOptionPane.CLOSED_OPTION,
+                                                    JOptionPane.QUESTION_MESSAGE,
+                                                    null,
+                                                    options,
+                                                    options[ 2 ] );
+        boolean paste_as_sibling = true;
+        if ( r == 1 ) {
+            paste_as_sibling = false;
         }
-        else {
-            final float x2a = x2;
-            final float x1a = x1;
-            // draw the vertical line
-            if ( node.isFirstChildNode() || node.isLastChildNode() ) {
-                drawLine( x1, y1, x1, y2, g );
-            }
-            // draw the horizontal line
-            drawLine( x1a, y2, x2a, y2, g );
+        else if ( r != 0 ) {
+            return;
         }
-    }
-
-    /**
-     * Paint a branch which consists of a vertical and a horizontal bar
-     * @param is_ind_found_nodes
-     */
-    final private void paintBranchRectangular( final Graphics2D g,
-                                               final float x1,
-                                               final float x2,
-                                               final float y1,
-                                               final float y2,
-                                               final PhylogenyNode node,
-                                               final boolean to_pdf,
-                                               final boolean to_graphics_file ) {
-        assignGraphicsForBranchWithColorForParentBranch( node, false, g, to_pdf, to_graphics_file );
-        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR ) {
-            drawLine( x1, y1, x2, y2, g );
-        }
-        else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CONVEX ) {
-            _quad_curve.setCurve( x1, y1, x1, y2, x2, y2 );
-            g.draw( _quad_curve );
-        }
-        else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CURVED ) {
-            final float dx = x2 - x1;
-            final float dy = y2 - y1;
-            _cubic_curve.setCurve( x1, y1, x1 + ( dx * 0.4f ), y1 + ( dy * 0.2f ), x1 + ( dx * 0.6f ), y1
-                                   + ( dy * 0.8f ), x2, y2 );
-            g.draw( _cubic_curve );
-        }
-        else {
-            final float x2a = x2;
-            final float x1a = x1;
-            float y2_r = 0;
-            if ( node.isFirstChildNode() || node.isLastChildNode()
-                    || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE )
-                    || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) ) {
-                if ( !to_graphics_file
-                        && !to_pdf
-                        && ( ( ( y2 < ( getVisibleRect().getMinY() - 20 ) ) && ( y1 < ( getVisibleRect().getMinY() - 20 ) ) ) || ( ( y2 > ( getVisibleRect()
-                                .getMaxY() + 20 ) ) && ( y1 > ( getVisibleRect().getMaxY() + 20 ) ) ) ) ) {
-                    // Do nothing.
-                }
-                else {
-                    if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) {
-                        float x2c = x1 + EURO_D;
-                        if ( x2c > x2a ) {
-                            x2c = x2a;
-                        }
-                        drawLine( x1, y1, x2c, y2, g );
-                    }
-                    else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) {
-                        if ( y2 > y1 ) {
-                            y2_r = y2 - ROUNDED_D;
-                            if ( y2_r < y1 ) {
-                                y2_r = y1;
-                            }
-                            drawLine( x1, y1, x1, y2_r, g );
-                        }
-                        else {
-                            y2_r = y2 + ROUNDED_D;
-                            if ( y2_r > y1 ) {
-                                y2_r = y1;
-                            }
-                            drawLine( x1, y1, x1, y2_r, g );
-                        }
-                    }
-                    else {
-                        drawLine( x1, y1, x1, y2, g );
-                    }
-                }
-            }
-            // draw the horizontal line
-            if ( !to_graphics_file && !to_pdf
-                    && ( ( y2 < ( getVisibleRect().getMinY() - 20 ) ) || ( y2 > ( getVisibleRect().getMaxY() + 20 ) ) ) ) {
+        final Phylogeny buffer_phy = getCutOrCopiedTree().copy();
+        buffer_phy.setAllNodesToNotCollapse();
+        PhylogenyMethods.preOrderReId( buffer_phy );
+        buffer_phy.setRooted( true );
+        boolean need_to_show_whole = false;
+        if ( paste_as_sibling ) {
+            if ( node.isRoot() ) {
+                JOptionPane.showMessageDialog( this,
+                                               "Cannot paste sibling to root",
+                                               "Attempt to paste sibling to root",
+                                               JOptionPane.ERROR_MESSAGE );
                 return;
             }
-            float x1_r = 0;
-            if ( !getControlPanel().isWidthBranches() || ( PhylogenyMethods.getBranchWidthValue( node ) == 1 ) ) {
-                if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) {
-                    x1_r = x1a + ROUNDED_D;
-                    if ( x1_r < x2a ) {
-                        drawLine( x1_r, y2, x2a, y2, g );
-                    }
-                }
-                else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) {
-                    final float x1c = x1a + EURO_D;
-                    if ( x1c < x2a ) {
-                        drawLine( x1c, y2, x2a, y2, g );
-                    }
-                }
-                else {
-                    drawLine( x1a, y2, x2a, y2, g );
-                }
+            buffer_phy.addAsSibling( node );
+        }
+        else {
+            if ( ( node.getNumberOfExternalNodes() == 1 ) && node.isRoot() ) {
+                need_to_show_whole = true;
+                _phylogeny = buffer_phy;
             }
             else {
-                final double w = PhylogenyMethods.getBranchWidthValue( node );
-                if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) {
-                    x1_r = x1a + ROUNDED_D;
-                    if ( x1_r < x2a ) {
-                        drawRectFilled( x1_r, y2 - ( w / 2 ), x2a - x1_r, w, g );
-                    }
-                }
-                else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) {
-                    final float x1c = x1a + EURO_D;
-                    if ( x1c < x2a ) {
-                        drawRectFilled( x1c, y2 - ( w / 2 ), x2a - x1c, w, g );
-                    }
-                }
-                else {
-                    drawRectFilled( x1a, y2 - ( w / 2 ), x2a - x1a, w, g );
-                }
-            }
-            if ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) ) {
-                if ( x1_r > x2a ) {
-                    x1_r = x2a;
-                }
-                if ( y2 > y2_r ) {
-                    final double diff = y2 - y2_r;
-                    _arc.setArc( x1, y2_r - diff, 2 * ( x1_r - x1 ), 2 * diff, 180, 90, Arc2D.OPEN );
-                }
-                else {
-                    _arc.setArc( x1, y2, 2 * ( x1_r - x1 ), 2 * ( y2_r - y2 ), 90, 90, Arc2D.OPEN );
-                }
-                g.draw( _arc );
+                buffer_phy.addAsChild( node );
             }
         }
-        if ( node.isExternal() ) {
-            paintNodeBox( x2, y2, node, g, to_pdf, to_graphics_file );
+        if ( getCopiedAndPastedNodes() == null ) {
+            setCopiedAndPastedNodes( new HashSet<Long>() );
         }
-    }
-
-    final private double paintCirculars( final PhylogenyNode n,
-                                         final Phylogeny phy,
-                                         final float center_x,
-                                         final float center_y,
-                                         final double radius,
-                                         final boolean radial_labels,
-                                         final Graphics2D g,
-                                         final boolean to_pdf,
-                                         final boolean to_graphics_file ) {
-        if ( n.isExternal() || n.isCollapse() ) { //~~circ collapse
-            if ( !_urt_nodeid_angle_map.containsKey( n.getId() ) ) {
-                System.out.println( "no " + n + " =====>>>>>>> ERROR!" );//TODO
-            }
-            return _urt_nodeid_angle_map.get( n.getId() );
+        final List<PhylogenyNode> nodes = PhylogenyMethods.obtainAllNodesAsList( buffer_phy );
+        final Set<Long> node_ids = new HashSet<Long>( nodes.size() );
+        for( final PhylogenyNode n : nodes ) {
+            node_ids.add( n.getId() );
         }
-        else {
-            final List<PhylogenyNode> descs = n.getDescendants();
-            double sum = 0;
-            for( final PhylogenyNode desc : descs ) {
-                sum += paintCirculars( desc,
-                                       phy,
-                                       center_x,
-                                       center_y,
-                                       radius,
-                                       radial_labels,
-                                       g,
-                                       to_pdf,
-                                       to_graphics_file );
-            }
-            double r = 0;
-            if ( !n.isRoot() ) {
-                r = 1 - ( ( ( double ) _circ_max_depth - n.calculateDepth() ) / _circ_max_depth );
-            }
-            final double theta = sum / descs.size();
-            n.setXcoord( ( float ) ( center_x + ( r * radius * Math.cos( theta ) ) ) );
-            n.setYcoord( ( float ) ( center_y + ( r * radius * Math.sin( theta ) ) ) );
-            _urt_nodeid_angle_map.put( n.getId(), theta );
-            for( final PhylogenyNode desc : descs ) {
-                paintBranchCircular( n, desc, g, radial_labels, to_pdf, to_graphics_file );
-            }
-            return theta;
+        node_ids.add( node.getId() );
+        getCopiedAndPastedNodes().addAll( node_ids );
+        setNodeInPreorderToNull();
+        _phylogeny.externalNodesHaveChanged();
+        _phylogeny.clearHashIdToNodeMap();
+        _phylogeny.recalculateNumberOfExternalDescendants( true );
+        resetNodeIdToDistToLeafMap();
+        setEdited( true );
+        if ( need_to_show_whole ) {
+            getControlPanel().showWhole();
         }
+        repaint();
     }
 
-    final private void paintCircularsLite( final PhylogenyNode n,
-                                           final Phylogeny phy,
-                                           final int center_x,
-                                           final int center_y,
-                                           final int radius,
-                                           final Graphics2D g ) {
-        if ( n.isExternal() ) {
-            return;
-        }
-        else {
-            final List<PhylogenyNode> descs = n.getDescendants();
-            for( final PhylogenyNode desc : descs ) {
-                paintCircularsLite( desc, phy, center_x, center_y, radius, g );
+    private final StringBuffer propertiesToString( final PhylogenyNode node ) {
+        final PropertiesMap properties = node.getNodeData().getProperties();
+        final StringBuffer sb = new StringBuffer();
+        boolean first = true;
+        for( final String ref : properties.getPropertyRefs() ) {
+            if ( first ) {
+                first = false;
             }
-            float r = 0;
-            if ( !n.isRoot() ) {
-                r = 1 - ( ( ( float ) _circ_max_depth - n.calculateDepth() ) / _circ_max_depth );
+            else {
+                sb.append( " " );
             }
-            final double theta = _urt_nodeid_angle_map.get( n.getId() );
-            n.setXSecondary( ( float ) ( center_x + ( radius * r * Math.cos( theta ) ) ) );
-            n.setYSecondary( ( float ) ( center_y + ( radius * r * Math.sin( theta ) ) ) );
-            for( final PhylogenyNode desc : descs ) {
-                paintBranchCircularLite( n, desc, g );
+            final Property p = properties.getProperty( ref );
+            sb.append( TreePanelUtil.getPartAfterColon( p.getRef() ) );
+            sb.append( "=" );
+            sb.append( p.getValue() );
+            if ( !ForesterUtil.isEmpty( p.getUnit() ) ) {
+                sb.append( TreePanelUtil.getPartAfterColon( p.getUnit() ) );
             }
         }
+        return sb;
     }
 
-    final private void paintCollapsedNode( final Graphics2D g,
-                                           final PhylogenyNode node,
-                                           final boolean to_graphics_file,
-                                           final boolean to_pdf,
-                                           final boolean is_in_found_nodes ) {
-        Color c = null;
+    private void setColor( final Graphics2D g,
+                           final PhylogenyNode node,
+                           final boolean to_graphics_file,
+                           final boolean to_pdf,
+                           final boolean is_in_found_nodes,
+                           final Color default_color ) {
         if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
-            c = Color.BLACK;
+            g.setColor( Color.BLACK );
         }
         else if ( is_in_found_nodes ) {
-            c = getColorForFoundNode( node );
+            g.setColor( getColorForFoundNode( node ) );
+        }
+        else if ( getControlPanel().isUseVisualStyles() && ( node.getNodeData().getNodeVisualData() != null )
+                && ( node.getNodeData().getNodeVisualData().getFontColor() != null ) ) {
+            g.setColor( node.getNodeData().getNodeVisualData().getFontColor() );
         }
         else if ( getControlPanel().isColorAccordingToSequence() ) {
-            c = getSequenceBasedColor( node );
+            g.setColor( getSequenceBasedColor( node ) );
         }
         else if ( getControlPanel().isColorAccordingToTaxonomy() ) {
-            c = getTaxonomyBasedColor( node );
+            g.setColor( getTaxonomyBasedColor( node ) );
+        }
+        else if ( getControlPanel().isColorAccordingToAnnotation()
+                && ( node.getNodeData().isHasSequence() && ( node.getNodeData().getSequence().getAnnotations() != null ) && ( !node
+                        .getNodeData().getSequence().getAnnotations().isEmpty() ) ) ) {
+            g.setColor( calculateColorForAnnotation( node.getNodeData().getSequence().getAnnotations() ) );
         }
         else if ( getOptions().isColorLabelsSameAsParentBranch() && getControlPanel().isUseVisualStyles()
                 && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) {
-            c = PhylogenyMethods.getBranchColorValue( node );
+            g.setColor( PhylogenyMethods.getBranchColorValue( node ) );
+        }
+        else if ( to_pdf ) {
+            g.setColor( Color.BLACK );
         }
         else {
-            c = getTreeColorSet().getCollapseFillColor();
+            g.setColor( default_color );
         }
-        double d = node.getAllExternalDescendants().size();
-        if ( d > 1000 ) {
-            d = ( 3 * _y_distance ) / 3;
+    }
+
+    final private void setCopiedAndPastedNodes( final Set<Long> nodeIds ) {
+        getMainPanel().setCopiedAndPastedNodes( nodeIds );
+    }
+
+    final private void setCutOrCopiedTree( final Phylogeny cut_or_copied_tree ) {
+        getMainPanel().setCutOrCopiedTree( cut_or_copied_tree );
+    }
+
+    private boolean setFont( final Graphics2D g, final PhylogenyNode node, final boolean is_in_found_nodes ) {
+        Font visual_font = null;
+        if ( getControlPanel().isUseVisualStyles() && ( node.getNodeData().getNodeVisualData() != null ) ) {
+            visual_font = node.getNodeData().getNodeVisualData().getFont();
+            g.setFont( visual_font != null ? visual_font : getTreeFontSet().getLargeFont() );
         }
         else {
-            d = ( Math.log10( d ) * _y_distance ) / 2.5;
+            g.setFont( getTreeFontSet().getLargeFont() );
         }
-        final int box_size = getOptions().getDefaultNodeShapeSize() + 1;
-        if ( d < box_size ) {
-            d = box_size;
+        if ( is_in_found_nodes ) {
+            g.setFont( g.getFont().deriveFont( Font.BOLD ) );
         }
-        final float xx = node.getXcoord() - ( 2 * box_size );
-        final float xxx = xx > ( node.getParent().getXcoord() + 1 ) ? xx : node.getParent().getXcoord() + 1;
-        _polygon.reset();
-        _polygon.moveTo( xxx, node.getYcoord() );
-        _polygon.lineTo( node.getXcoord() + 1, node.getYcoord() - d );
-        _polygon.lineTo( node.getXcoord() + 1, node.getYcoord() + d );
-        _polygon.closePath();
-        if ( getOptions().getDefaultNodeFill() == NodeVisualData.NodeFill.SOLID ) {
-            g.setColor( c );
-            g.fill( _polygon );
+        return visual_font != null;
+    }
+
+    final private void setInOv( final boolean in_ov ) {
+        _in_ov = in_ov;
+    }
+
+    final private void setOvMaxHeight( final float ov_max_height ) {
+        _ov_max_height = ov_max_height;
+    }
+
+    final private void setOvMaxWidth( final float ov_max_width ) {
+        _ov_max_width = ov_max_width;
+    }
+
+    final private void setOvXcorrectionFactor( final float f ) {
+        _ov_x_correction_factor = f;
+    }
+
+    final private void setOvXDistance( final float ov_x_distance ) {
+        _ov_x_distance = ov_x_distance;
+    }
+
+    final private void setOvXPosition( final int ov_x_position ) {
+        _ov_x_position = ov_x_position;
+    }
+
+    final private void setOvYDistance( final float ov_y_distance ) {
+        _ov_y_distance = ov_y_distance;
+    }
+
+    final private void setOvYPosition( final int ov_y_position ) {
+        _ov_y_position = ov_y_position;
+    }
+
+    final private void setOvYStart( final int ov_y_start ) {
+        _ov_y_start = ov_y_start;
+    }
+
+    final private void setScaleDistance( final double scale_distance ) {
+        _scale_distance = scale_distance;
+    }
+
+    final private void setScaleLabel( final String scale_label ) {
+        _scale_label = scale_label;
+    }
+
+    private final void setupStroke( final Graphics2D g ) {
+        if ( getYdistance() < 0.0001 ) {
+            g.setStroke( STROKE_0025 );
         }
-        else if ( getOptions().getDefaultNodeFill() == NodeVisualData.NodeFill.NONE ) {
-            g.setColor( getBackground() );
-            g.fill( _polygon );
-            g.setColor( c );
-            g.draw( _polygon );
+        if ( getYdistance() < 0.001 ) {
+            g.setStroke( STROKE_005 );
         }
-        else if ( getOptions().getDefaultNodeFill() == NodeFill.GRADIENT ) {
-            g.setPaint( new GradientPaint( xxx, node.getYcoord(), getBackground(), node.getXcoord(), ( float ) ( node
-                    .getYcoord() - d ), c, false ) );
-            g.fill( _polygon );
-            g.setPaint( c );
-            g.draw( _polygon );
+        else if ( getYdistance() < 0.01 ) {
+            g.setStroke( STROKE_01 );
+        }
+        else if ( getYdistance() < 0.5 ) {
+            g.setStroke( STROKE_025 );
+        }
+        else if ( getYdistance() < 1 ) {
+            g.setStroke( STROKE_05 );
+        }
+        else if ( getYdistance() < 2 ) {
+            g.setStroke( STROKE_075 );
+        }
+        else if ( ( getYdistance() < 20 ) || !getConfiguration().isAllowThickStrokes() ) {
+            g.setStroke( STROKE_1 );
+        }
+        else {
+            g.setStroke( STROKE_2 );
         }
-        paintNodeData( g, node, to_graphics_file, to_pdf, is_in_found_nodes );
     }
 
-    final private void paintConfidenceValues( final Graphics2D g,
-                                              final PhylogenyNode node,
-                                              final boolean to_pdf,
-                                              final boolean to_graphics_file ) {
-        final List<Confidence> confidences = node.getBranchData().getConfidences();
-        boolean not_first = false;
-        Collections.sort( confidences );
-        final StringBuilder sb = new StringBuilder();
-        for( final Confidence confidence : confidences ) {
-            if ( ForesterUtil.isEmpty( SHOW_ONLY_THIS_CONF_TYPE )
-                    || ( !ForesterUtil.isEmpty( confidence.getType() ) && confidence.getType()
-                            .equalsIgnoreCase( SHOW_ONLY_THIS_CONF_TYPE ) ) ) {
-                final double value = confidence.getValue();
-                if ( value != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
-                    if ( value < getOptions().getMinConfidenceValue() ) {
-                        return;
-                    }
-                    if ( not_first ) {
-                        sb.append( "/" );
-                    }
-                    else {
-                        not_first = true;
-                    }
-                    sb.append( FORMATTER_CONFIDENCE.format( ForesterUtil.round( value, getOptions()
-                                                                                .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
-                    if ( getOptions().isShowConfidenceStddev() ) {
-                        if ( confidence.getStandardDeviation() != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
-                            sb.append( "(" );
-                            sb.append( FORMATTER_CONFIDENCE.format( ForesterUtil.round( confidence
-                                                                                        .getStandardDeviation(), getOptions()
-                                                                                        .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
-                            sb.append( ")" );
-                        }
-                    }
-                }
-            }
+    final private void setUpUrtFactor() {
+        final int d = getVisibleRect().width < getVisibleRect().height ? getVisibleRect().width
+                : getVisibleRect().height;
+        if ( isPhyHasBranchLengths() && getControlPanel().isDrawPhylogram() ) {
+            setUrtFactor( ( float ) ( d / ( 2 * getMaxDistanceToRoot() ) ) );
         }
-        if ( sb.length() > 0 ) {
-            final float parent_x = node.getParent().getXcoord();
-            float x = node.getXcoord();
-            g.setFont( getTreeFontSet().getSmallFont() );
-            if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) {
-                x += EURO_D;
-            }
-            else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) {
-                x += ROUNDED_D;
-            }
-            if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
-                g.setColor( Color.BLACK );
+        else {
+            final int max_depth = _circ_max_depth;
+            if ( max_depth > 0 ) {
+                setUrtFactor( d / ( 2 * max_depth ) );
             }
             else {
-                g.setColor( getTreeColorSet().getConfidenceColor() );
+                setUrtFactor( d / 2 );
             }
-            final String conf_str = sb.toString();
-            TreePanel.drawString( conf_str,
-                                  parent_x
-                                  + ( ( x - parent_x - getTreeFontSet().getFontMetricsSmall()
-                                          .stringWidth( conf_str ) ) / 2 ),
-                                          ( node.getYcoord() + getTreeFontSet().getSmallMaxAscent() ) - 1,
-                                          g );
         }
+        setUrtFactorOv( getUrtFactor() );
     }
 
-    final private void paintGainedAndLostCharacters( final Graphics2D g,
-                                                     final PhylogenyNode node,
-                                                     final String gained,
-                                                     final String lost ) {
-        if ( node.getParent() != null ) {
-            final float parent_x = node.getParent().getXcoord();
-            final float x = node.getXcoord();
-            g.setFont( getTreeFontSet().getLargeFont() );
-            g.setColor( getTreeColorSet().getGainedCharactersColor() );
-            if ( Constants.SPECIAL_CUSTOM ) {
-                g.setColor( Color.BLUE );
-            }
-            TreePanel
-            .drawString( gained,
-                         parent_x
-                         + ( ( x - parent_x - getFontMetricsForLargeDefaultFont().stringWidth( gained ) ) / 2 ),
-                         ( node.getYcoord() - getFontMetricsForLargeDefaultFont().getMaxDescent() ),
-                         g );
-            g.setColor( getTreeColorSet().getLostCharactersColor() );
-            TreePanel
-            .drawString( lost,
-                         parent_x
-                         + ( ( x - parent_x - getFontMetricsForLargeDefaultFont().stringWidth( lost ) ) / 2 ),
-                         ( node.getYcoord() + getFontMetricsForLargeDefaultFont().getMaxAscent() ),
-                         g );
-        }
+    final private void setUrtFactor( final float urt_factor ) {
+        _urt_factor = urt_factor;
     }
 
-    /**
-     * Draw a box at the indicated node.
-     *
-     * @param x
-     * @param y
-     * @param node
-     * @param g
-     */
-    final private void paintNodeBox( final float x,
-                                     final float y,
-                                     final PhylogenyNode node,
-                                     final Graphics2D g,
-                                     final boolean to_pdf,
-                                     final boolean to_graphics_file ) {
-        if ( node.isCollapse() ) {
-            return;
-        }
-        // if this node should be highlighted, do so
-        if ( ( _highlight_node == node ) && !to_pdf && !to_graphics_file ) {
-            g.setColor( getTreeColorSet().getFoundColor0() );
-            drawOval( x - 8, y - 8, 16, 16, g );
-            drawOval( x - 9, y - 8, 17, 17, g );
-            drawOval( x - 9, y - 9, 18, 18, g );
-        }
-        if ( ( isInFoundNodes( node ) || isInCurrentExternalNodes( node ) )
-                || ( getOptions().isShowDefaultNodeShapesExternal() && node.isExternal() )
-                || ( getOptions().isShowDefaultNodeShapesInternal() && node.isInternal() )
-                || ( getOptions().isShowDefaultNodeShapesForMarkedNodes()
-                        && ( node.getNodeData().getNodeVisualData() != null ) && ( !node.getNodeData()
-                                .getNodeVisualData().isEmpty() ) )
-                                || ( getControlPanel().isUseVisualStyles() && ( ( node.getNodeData().getNodeVisualData() != null ) && ( ( node
-                                        .getNodeData().getNodeVisualData().getNodeColor() != null )
-                                        || ( node.getNodeData().getNodeVisualData().getSize() != NodeVisualData.DEFAULT_SIZE )
-                                        || ( node.getNodeData().getNodeVisualData().getFillType() != NodeFill.DEFAULT ) || ( node
-                                                .getNodeData().getNodeVisualData().getShape() != NodeShape.DEFAULT ) ) ) )
-                                                || ( getControlPanel().isEvents() && node.isHasAssignedEvent() && ( node.getNodeData().getEvent()
-                                                        .isDuplication()
-                                                        || node.getNodeData().getEvent().isSpeciation() || node.getNodeData().getEvent()
-                                                        .isSpeciationOrDuplication() ) ) ) {
-            NodeVisualData vis = null;
-            if ( getControlPanel().isUseVisualStyles() && ( node.getNodeData().getNodeVisualData() != null )
-                    && ( !node.getNodeData().getNodeVisualData().isEmpty() ) ) {
-                vis = node.getNodeData().getNodeVisualData();
-            }
-            float box_size = getOptions().getDefaultNodeShapeSize();
-            if ( ( vis != null ) && ( vis.getSize() != NodeVisualData.DEFAULT_SIZE ) ) {
-                box_size = vis.getSize();
-            }
-            final float half_box_size = box_size / 2.0f;
-            Color outline_color = null;
-            if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
-                outline_color = Color.BLACK;
-            }
-            else if ( isInFoundNodes( node ) || isInCurrentExternalNodes( node ) ) {
-                outline_color = getColorForFoundNode( node );
+    final private void setUrtFactorOv( final float urt_factor_ov ) {
+        _urt_factor_ov = urt_factor_ov;
+    }
+
+    private void showExtDescNodeData( final PhylogenyNode node ) {
+        final List<String> data = new ArrayList<String>();
+        final List<PhylogenyNode> nodes = node.getAllExternalDescendants();
+        if ( ( getFoundNodes0() != null ) || ( getFoundNodes1() != null ) ) {
+            for( final PhylogenyNode n : getFoundNodesAsListOfPhylogenyNodes() ) {
+                if ( !nodes.contains( n ) ) {
+                    nodes.add( n );
+                }
             }
-            else if ( vis != null ) {
-                if ( vis.getNodeColor() != null ) {
-                    outline_color = vis.getNodeColor();
-                }
-                else if ( vis.getFontColor() != null ) {
-                    outline_color = vis.getFontColor();
-                }
+        }
+        for( final PhylogenyNode n : nodes ) {
+            switch ( getOptions().getExtDescNodeDataToReturn() ) {
+                case NODE_NAME:
+                    if ( !ForesterUtil.isEmpty( n.getName() ) ) {
+                        data.add( n.getName() );
+                    }
+                    break;
+                case SEQUENCE_NAME:
+                    if ( n.getNodeData().isHasSequence()
+                            && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getName() ) ) {
+                        data.add( n.getNodeData().getSequence().getName() );
+                    }
+                    break;
+                case GENE_NAME:
+                    if ( n.getNodeData().isHasSequence()
+                            && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getGeneName() ) ) {
+                        data.add( n.getNodeData().getSequence().getGeneName() );
+                    }
+                    break;
+                case SEQUENCE_SYMBOL:
+                    if ( n.getNodeData().isHasSequence()
+                            && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getSymbol() ) ) {
+                        data.add( n.getNodeData().getSequence().getSymbol() );
+                    }
+                    break;
+                case SEQUENCE_MOL_SEQ_FASTA:
+                    final StringBuilder sb = new StringBuilder();
+                    if ( n.getNodeData().isHasSequence()
+                            && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getMolecularSequence() ) ) {
+                        final StringBuilder ann = new StringBuilder();
+                        if ( !ForesterUtil.isEmpty( n.getName() ) ) {
+                            ann.append( n.getName() );
+                            ann.append( "|" );
+                        }
+                        if ( !ForesterUtil.isEmpty( n.getNodeData().getSequence().getSymbol() ) ) {
+                            ann.append( "SYM=" );
+                            ann.append( n.getNodeData().getSequence().getSymbol() );
+                            ann.append( "|" );
+                        }
+                        if ( !ForesterUtil.isEmpty( n.getNodeData().getSequence().getName() ) ) {
+                            ann.append( "NAME=" );
+                            ann.append( n.getNodeData().getSequence().getName() );
+                            ann.append( "|" );
+                        }
+                        if ( !ForesterUtil.isEmpty( n.getNodeData().getSequence().getGeneName() ) ) {
+                            ann.append( "GN=" );
+                            ann.append( n.getNodeData().getSequence().getGeneName() );
+                            ann.append( "|" );
+                        }
+                        if ( n.getNodeData().getSequence().getAccession() != null ) {
+                            ann.append( "ACC=" );
+                            ann.append( n.getNodeData().getSequence().getAccession().asText() );
+                            ann.append( "|" );
+                        }
+                        if ( n.getNodeData().isHasTaxonomy() ) {
+                            if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
+                                ann.append( "TAXID=" );
+                                ann.append( n.getNodeData().getTaxonomy().getTaxonomyCode() );
+                                ann.append( "|" );
+                            }
+                            if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) {
+                                ann.append( "SN=" );
+                                ann.append( n.getNodeData().getTaxonomy().getScientificName() );
+                                ann.append( "|" );
+                            }
+                        }
+                        String ann_str;
+                        if ( ann.charAt( ann.length() - 1 ) == '|' ) {
+                            ann_str = ann.substring( 0, ann.length() - 1 );
+                        }
+                        else {
+                            ann_str = ann.toString();
+                        }
+                        sb.append( SequenceWriter.toFasta( ann_str, n.getNodeData().getSequence()
+                                .getMolecularSequence(), 60 ) );
+                        data.add( sb.toString() );
+                    }
+                    break;
+                case SEQUENCE_ACC:
+                    if ( n.getNodeData().isHasSequence() && ( n.getNodeData().getSequence().getAccession() != null )
+                            && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getAccession().toString() ) ) {
+                        data.add( n.getNodeData().getSequence().getAccession().toString() );
+                    }
+                    break;
+                case TAXONOMY_SCIENTIFIC_NAME:
+                    if ( n.getNodeData().isHasTaxonomy()
+                            && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) {
+                        data.add( n.getNodeData().getTaxonomy().getScientificName() );
+                    }
+                    break;
+                case TAXONOMY_CODE:
+                    if ( n.getNodeData().isHasTaxonomy()
+                            && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
+                        data.add( n.getNodeData().getTaxonomy().getTaxonomyCode() );
+                    }
+                    break;
+                case DOMAINS_ALL:
+                case DOMAINS_COLLAPSED_PER_PROTEIN:
+                    if ( n.getNodeData().isHasSequence()
+                            && ( n.getNodeData().getSequence().getDomainArchitecture() != null ) ) {
+                        final DomainArchitecture da = n.getNodeData().getSequence().getDomainArchitecture();
+                        final Set<String> s = new HashSet<String>();
+                        for( int i = 0; i < da.getDomains().size(); ++i ) {
+                            final ProteinDomain d = da.getDomain( i );
+                            if ( d.getConfidence() <= Math.pow( 10, getDomainStructureEvalueThresholdExp() ) ) {
+                                final String name = d.getName();
+                                if ( !( s.contains( name ) ) ) {
+                                    data.add( name );
+                                    if ( getOptions().getExtDescNodeDataToReturn() == NodeDataField.DOMAINS_COLLAPSED_PER_PROTEIN ) {
+                                        s.add( name );
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    break;
+                case SEQ_ANNOTATIONS:
+                    if ( n.getNodeData().isHasSequence() ) {
+                        if ( n.getNodeData().isHasSequence()
+                                && ( n.getNodeData().getSequence().getAnnotations() != null ) ) {
+                            final SortedSet<Annotation> a = n.getNodeData().getSequence().getAnnotations();
+                            for( int i = 0; i < a.size(); ++i ) {
+                                data.add( n.getNodeData().getSequence().getAnnotation( i ).toString() );
+                            }
+                        }
+                    }
+                    break;
+                case GO_TERM_IDS:
+                    if ( n.getNodeData().isHasSequence() ) {
+                        if ( n.getNodeData().isHasSequence()
+                                && ( n.getNodeData().getSequence().getAnnotations() != null ) ) {
+                            final SortedSet<Annotation> a = n.getNodeData().getSequence().getAnnotations();
+                            for( int i = 0; i < a.size(); ++i ) {
+                                final Annotation ann = n.getNodeData().getSequence().getAnnotation( i );
+                                final String ref = ann.getRef();
+                                if ( ref.toUpperCase().startsWith( "GO:" ) ) {
+                                    data.add( ref );
+                                }
+                            }
+                        }
+                    }
+                    break;
+                case UNKNOWN:
+                    TreePanelUtil.showExtDescNodeDataUserSelectedHelper( getControlPanel(), n, data );
+                    break;
+                default:
+                    throw new IllegalArgumentException( "unknown data element: "
+                            + getOptions().getExtDescNodeDataToReturn() );
             }
-            else if ( getControlPanel().isEvents() && TreePanelUtil.isHasAssignedEvent( node ) ) {
-                final Event event = node.getNodeData().getEvent();
-                if ( event.isDuplication() ) {
-                    outline_color = getTreeColorSet().getDuplicationBoxColor();
-                }
-                else if ( event.isSpeciation() ) {
-                    outline_color = getTreeColorSet().getSpecBoxColor();
-                }
-                else if ( event.isSpeciationOrDuplication() ) {
-                    outline_color = getTreeColorSet().getDuplicationOrSpeciationColor();
-                }
+        } // for loop
+        final StringBuilder sb = new StringBuilder();
+        final int size = TreePanelUtil.nodeDataIntoStringBuffer( data, getOptions(), sb );
+        if ( ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.CONSOLE )
+                || ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.BUFFER_ONLY ) ) {
+            if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.CONSOLE ) {
+                System.out.println( sb );
             }
-            if ( outline_color == null ) {
-                outline_color = getGraphicsForNodeBoxWithColorForParentBranch( node );
-                if ( to_pdf && ( outline_color == getTreeColorSet().getBranchColor() ) ) {
-                    outline_color = getTreeColorSet().getBranchColorForPdf();
-                }
+            if ( sb.length() < 1 ) {
+                clearCurrentExternalNodesDataBuffer();
             }
-            NodeShape shape = null;
-            if ( vis != null ) {
-                if ( vis.getShape() == NodeShape.CIRCLE ) {
-                    shape = NodeShape.CIRCLE;
-                }
-                else if ( vis.getShape() == NodeShape.RECTANGLE ) {
-                    shape = NodeShape.RECTANGLE;
-                }
+            else {
+                setCurrentExternalNodesDataBuffer( sb );
             }
-            if ( shape == null ) {
-                if ( getOptions().getDefaultNodeShape() == NodeShape.CIRCLE ) {
-                    shape = NodeShape.CIRCLE;
-                }
-                else if ( getOptions().getDefaultNodeShape() == NodeShape.RECTANGLE ) {
-                    shape = NodeShape.RECTANGLE;
-                }
+        }
+        else if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.WINODW ) {
+            if ( sb.length() < 1 ) {
+                TreePanelUtil.showInformationMessage( this, "No Appropriate Data (" + obtainTitleForExtDescNodeData()
+                        + ")", "Descendants of selected node do not contain selected data" );
+                clearCurrentExternalNodesDataBuffer();
             }
-            NodeFill fill = null;
-            if ( vis != null ) {
-                if ( vis.getFillType() == NodeFill.SOLID ) {
-                    fill = NodeFill.SOLID;
-                }
-                else if ( vis.getFillType() == NodeFill.NONE ) {
-                    fill = NodeFill.NONE;
-                }
-                else if ( vis.getFillType() == NodeFill.GRADIENT ) {
-                    fill = NodeFill.GRADIENT;
+            else {
+                setCurrentExternalNodesDataBuffer( sb );
+                String title;
+                if ( ( getFoundNodes0() != null ) && !getFoundNodes0().isEmpty() ) {
+                    title = ( getOptions().getExtDescNodeDataToReturn() == NodeDataField.UNKNOWN ? "Data"
+                            : obtainTitleForExtDescNodeData() )
+                            + " for "
+                            + data.size()
+                            + " nodes, unique entries: "
+                            + size;
                 }
-            }
-            if ( fill == null ) {
-                if ( getOptions().getDefaultNodeFill() == NodeFill.SOLID ) {
-                    fill = NodeFill.SOLID;
+                else {
+                    title = ( getOptions().getExtDescNodeDataToReturn() == NodeDataField.UNKNOWN ? "Data"
+                            : obtainTitleForExtDescNodeData() )
+                            + " for "
+                            + data.size()
+                            + "/"
+                            + node.getNumberOfExternalNodes()
+                            + " external descendats of node "
+                            + node
+                            + ", unique entries: " + size;
                 }
-                else if ( getOptions().getDefaultNodeFill() == NodeFill.NONE ) {
-                    fill = NodeFill.NONE;
+                final String s = sb.toString().trim();
+                if ( getMainPanel().getMainFrame() == null ) {
+                    // Must be "E" applet version.
+                    final ArchaeopteryxE ae = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
+                    ae.showTextFrame( s, title );
                 }
-                else if ( getOptions().getDefaultNodeFill() == NodeFill.GRADIENT ) {
-                    fill = NodeFill.GRADIENT;
+                else {
+                    getMainPanel().getMainFrame().showTextFrame( s, title );
                 }
             }
-            Color vis_fill_color = null;
-            if ( ( vis != null ) && ( vis.getNodeColor() != null ) ) {
-                vis_fill_color = vis.getNodeColor();
-            }
-            if ( shape == NodeShape.CIRCLE ) {
-                if ( fill == NodeFill.GRADIENT ) {
-                    drawOvalGradient( x - half_box_size, y - half_box_size, box_size, box_size, g, to_pdf ? Color.WHITE
-                            : outline_color, to_pdf ? outline_color : getBackground(), outline_color );
-                }
-                else if ( fill == NodeFill.NONE ) {
-                    Color background = getBackground();
-                    if ( to_pdf ) {
-                        background = Color.WHITE;
+        }
+    }
+
+    final private void showNodeDataPopup( final MouseEvent e, final PhylogenyNode node ) {
+        try {
+            if ( ( node.getName().length() > 0 )
+                    || ( node.getNodeData().isHasTaxonomy() && !TreePanelUtil.isTaxonomyEmpty( node.getNodeData()
+                            .getTaxonomy() ) )
+                    || ( node.getNodeData().isHasSequence() && !TreePanelUtil.isSequenceEmpty( node.getNodeData()
+                            .getSequence() ) ) || ( node.getNodeData().isHasDate() )
+                    || ( node.getNodeData().isHasDistribution() ) || node.getBranchData().isHasConfidences() ) {
+                _popup_buffer.setLength( 0 );
+                short lines = 0;
+                if ( node.getName().length() > 0 ) {
+                    lines++;
+                    _popup_buffer.append( node.getName() );
+                }
+                if ( node.getNodeData().isHasTaxonomy()
+                        && !TreePanelUtil.isTaxonomyEmpty( node.getNodeData().getTaxonomy() ) ) {
+                    lines++;
+                    boolean enc_data = false;
+                    final Taxonomy tax = node.getNodeData().getTaxonomy();
+                    if ( _popup_buffer.length() > 0 ) {
+                        _popup_buffer.append( "\n" );
+                    }
+                    if ( !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) {
+                        _popup_buffer.append( "[" );
+                        _popup_buffer.append( tax.getTaxonomyCode() );
+                        _popup_buffer.append( "]" );
+                        enc_data = true;
+                    }
+                    if ( !ForesterUtil.isEmpty( tax.getScientificName() ) ) {
+                        if ( enc_data ) {
+                            _popup_buffer.append( " " );
+                        }
+                        _popup_buffer.append( tax.getScientificName() );
+                        enc_data = true;
+                    }
+                    if ( !ForesterUtil.isEmpty( tax.getCommonName() ) ) {
+                        if ( enc_data ) {
+                            _popup_buffer.append( " (" );
+                        }
+                        else {
+                            _popup_buffer.append( "(" );
+                        }
+                        _popup_buffer.append( tax.getCommonName() );
+                        _popup_buffer.append( ")" );
+                        enc_data = true;
+                    }
+                    if ( !ForesterUtil.isEmpty( tax.getAuthority() ) ) {
+                        if ( enc_data ) {
+                            _popup_buffer.append( " (" );
+                        }
+                        else {
+                            _popup_buffer.append( "(" );
+                        }
+                        _popup_buffer.append( tax.getAuthority() );
+                        _popup_buffer.append( ")" );
+                        enc_data = true;
+                    }
+                    if ( !ForesterUtil.isEmpty( tax.getRank() ) ) {
+                        if ( enc_data ) {
+                            _popup_buffer.append( " [" );
+                        }
+                        else {
+                            _popup_buffer.append( "[" );
+                        }
+                        _popup_buffer.append( tax.getRank() );
+                        _popup_buffer.append( "]" );
+                        enc_data = true;
+                    }
+                    if ( tax.getSynonyms().size() > 0 ) {
+                        if ( enc_data ) {
+                            _popup_buffer.append( " " );
+                        }
+                        _popup_buffer.append( "[" );
+                        int counter = 1;
+                        for( final String syn : tax.getSynonyms() ) {
+                            if ( !ForesterUtil.isEmpty( syn ) ) {
+                                enc_data = true;
+                                _popup_buffer.append( syn );
+                                if ( counter < tax.getSynonyms().size() ) {
+                                    _popup_buffer.append( ", " );
+                                }
+                            }
+                            counter++;
+                        }
+                        _popup_buffer.append( "]" );
+                    }
+                    if ( !enc_data ) {
+                        if ( ( tax.getIdentifier() != null ) && !ForesterUtil.isEmpty( tax.getIdentifier().getValue() ) ) {
+                            if ( !ForesterUtil.isEmpty( tax.getIdentifier().getProvider() ) ) {
+                                _popup_buffer.append( "[" );
+                                _popup_buffer.append( tax.getIdentifier().getProvider() );
+                                _popup_buffer.append( "] " );
+                            }
+                            _popup_buffer.append( tax.getIdentifier().getValue() );
+                        }
                     }
-                    drawOvalGradient( x - half_box_size,
-                                      y - half_box_size,
-                                      box_size,
-                                      box_size,
-                                      g,
-                                      background,
-                                      background,
-                                      outline_color );
                 }
-                else if ( fill == NodeVisualData.NodeFill.SOLID ) {
-                    if ( vis_fill_color != null ) {
-                        g.setColor( vis_fill_color );
+                if ( node.getNodeData().isHasSequence()
+                        && !TreePanelUtil.isSequenceEmpty( node.getNodeData().getSequence() ) ) {
+                    lines++;
+                    boolean enc_data = false;
+                    if ( _popup_buffer.length() > 0 ) {
+                        _popup_buffer.append( "\n" );
                     }
-                    else {
-                        g.setColor( outline_color );
+                    final Sequence seq = node.getNodeData().getSequence();
+                    if ( seq.getAccession() != null ) {
+                        _popup_buffer.append( "[" );
+                        if ( !ForesterUtil.isEmpty( seq.getAccession().getSource() ) ) {
+                            _popup_buffer.append( seq.getAccession().getSource() );
+                            _popup_buffer.append( ":" );
+                        }
+                        _popup_buffer.append( seq.getAccession().getValue() );
+                        _popup_buffer.append( "]" );
+                        enc_data = true;
+                    }
+                    if ( !ForesterUtil.isEmpty( seq.getSymbol() ) ) {
+                        if ( enc_data ) {
+                            _popup_buffer.append( " [" );
+                        }
+                        else {
+                            _popup_buffer.append( "[" );
+                        }
+                        _popup_buffer.append( seq.getSymbol() );
+                        _popup_buffer.append( "]" );
+                        enc_data = true;
+                    }
+                    if ( !ForesterUtil.isEmpty( seq.getGeneName() ) ) {
+                        if ( enc_data ) {
+                            _popup_buffer.append( " [" );
+                        }
+                        else {
+                            _popup_buffer.append( "[" );
+                        }
+                        _popup_buffer.append( seq.getGeneName() );
+                        _popup_buffer.append( "]" );
+                        enc_data = true;
+                    }
+                    if ( !ForesterUtil.isEmpty( seq.getName() ) ) {
+                        if ( enc_data ) {
+                            _popup_buffer.append( " " );
+                        }
+                        _popup_buffer.append( seq.getName() );
                     }
-                    drawOvalFilled( x - half_box_size, y - half_box_size, box_size, box_size, g );
                 }
-            }
-            else if ( shape == NodeVisualData.NodeShape.RECTANGLE ) {
-                if ( fill == NodeVisualData.NodeFill.GRADIENT ) {
-                    drawRectGradient( x - half_box_size, y - half_box_size, box_size, box_size, g, to_pdf ? Color.WHITE
-                            : outline_color, to_pdf ? outline_color : getBackground(), outline_color );
+                if ( node.getNodeData().isHasDate() ) {
+                    lines++;
+                    if ( _popup_buffer.length() > 0 ) {
+                        _popup_buffer.append( "\n" );
+                    }
+                    _popup_buffer.append( node.getNodeData().getDate().asSimpleText() );
                 }
-                else if ( fill == NodeVisualData.NodeFill.NONE ) {
-                    Color background = getBackground();
-                    if ( to_pdf ) {
-                        background = Color.WHITE;
+                if ( node.getNodeData().isHasDistribution() ) {
+                    lines++;
+                    if ( _popup_buffer.length() > 0 ) {
+                        _popup_buffer.append( "\n" );
                     }
-                    drawRectGradient( x - half_box_size,
-                                      y - half_box_size,
-                                      box_size,
-                                      box_size,
-                                      g,
-                                      background,
-                                      background,
-                                      outline_color );
+                    _popup_buffer.append( node.getNodeData().getDistribution().asSimpleText() );
                 }
-                else if ( fill == NodeVisualData.NodeFill.SOLID ) {
-                    if ( vis_fill_color != null ) {
-                        g.setColor( vis_fill_color );
+                if ( node.getBranchData().isHasConfidences() ) {
+                    final List<Confidence> confs = node.getBranchData().getConfidences();
+                    for( final Confidence confidence : confs ) {
+                        lines++;
+                        if ( _popup_buffer.length() > 0 ) {
+                            _popup_buffer.append( "\n" );
+                        }
+                        if ( !ForesterUtil.isEmpty( confidence.getType() ) ) {
+                            _popup_buffer.append( "[" );
+                            _popup_buffer.append( confidence.getType() );
+                            _popup_buffer.append( "] " );
+                        }
+                        _popup_buffer
+                                .append( FORMATTER_CONFIDENCE.format( ForesterUtil.round( confidence.getValue(),
+                                                                                          getOptions()
+                                                                                                  .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
+                        if ( confidence.getStandardDeviation() != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
+                            _popup_buffer.append( " (sd=" );
+                            _popup_buffer.append( FORMATTER_CONFIDENCE.format( ForesterUtil.round( confidence
+                                    .getStandardDeviation(), getOptions()
+                                    .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
+                            _popup_buffer.append( ")" );
+                        }
+                    }
+                }
+                if ( node.getNodeData().isHasProperties() ) {
+                    final PropertiesMap properties = node.getNodeData().getProperties();
+                    for( final String ref : properties.getPropertyRefs() ) {
+                        _popup_buffer.append( "\n" );
+                        final Property p = properties.getProperty( ref );
+                        _popup_buffer.append( TreePanelUtil.getPartAfterColon( p.getRef() ) );
+                        _popup_buffer.append( "=" );
+                        _popup_buffer.append( p.getValue() );
+                        if ( !ForesterUtil.isEmpty( p.getUnit() ) ) {
+                            _popup_buffer.append( TreePanelUtil.getPartAfterColon( p.getUnit() ) );
+                        }
+                    }
+                }
+                if ( _popup_buffer.length() > 0 ) {
+                    if ( !getConfiguration().isUseNativeUI() ) {
+                        _rollover_popup
+                                .setBorder( BorderFactory.createLineBorder( getTreeColorSet().getBranchColor() ) );
+                        _rollover_popup.setBackground( getTreeColorSet().getBackgroundColor() );
+                        if ( isInFoundNodes0( node ) && !isInFoundNodes1( node ) ) {
+                            _rollover_popup.setForeground( getTreeColorSet().getFoundColor0() );
+                        }
+                        else if ( !isInFoundNodes0( node ) && isInFoundNodes1( node ) ) {
+                            _rollover_popup.setForeground( getTreeColorSet().getFoundColor1() );
+                        }
+                        else if ( isInFoundNodes0( node ) && isInFoundNodes1( node ) ) {
+                            _rollover_popup.setForeground( getTreeColorSet().getFoundColor0and1() );
+                        }
+                        else {
+                            _rollover_popup.setForeground( getTreeColorSet().getSequenceColor() );
+                        }
                     }
                     else {
-                        g.setColor( outline_color );
+                        _rollover_popup.setBorder( BorderFactory.createLineBorder( Color.BLACK ) );
                     }
-                    drawRectFilled( x - half_box_size, y - half_box_size, box_size, box_size, g );
+                    _rollover_popup.setText( _popup_buffer.toString() );
+                    _node_desc_popup = PopupFactory.getSharedInstance().getPopup( null,
+                                                                                  _rollover_popup,
+                                                                                  e.getLocationOnScreen().x + 10,
+                                                                                  e.getLocationOnScreen().y
+                                                                                          - ( lines * 20 ) );
+                    _node_desc_popup.show();
                 }
             }
         }
+        catch ( final Exception ex ) {
+            // Do nothing.
+        }
     }
 
-    final private int paintNodeData( final Graphics2D g,
-                                     final PhylogenyNode node,
-                                     final boolean to_graphics_file,
-                                     final boolean to_pdf,
-                                     final boolean is_in_found_nodes ) {
-        if ( isNodeDataInvisible( node ) && !to_graphics_file && !to_pdf ) {
-            return 0;
-        }
-        if ( getControlPanel().isWriteBranchLengthValues()
-                && ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR )
-                        || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) )
-                        && ( !node.isRoot() ) && ( node.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) ) {
-            paintBranchLength( g, node, to_pdf, to_graphics_file );
+    final private void showNodeEditFrame( final PhylogenyNode n ) {
+        if ( _node_frame_index < TreePanel.MAX_NODE_FRAMES ) {
+            // pop up edit box for single node
+            _node_frames[ _node_frame_index ] = new NodeFrame( n, _phylogeny, this, _node_frame_index, "" );
+            _node_frame_index++;
         }
-        if ( !getControlPanel().isShowInternalData() && !node.isExternal() && !node.isCollapse() ) {
-            return 0;
+        else {
+            JOptionPane.showMessageDialog( this, "too many node windows are open" );
         }
-        _sb.setLength( 0 );
-        int x = 0;
-        final int half_box_size = getOptions().getDefaultNodeShapeSize() / 2;
-        if ( getControlPanel().isShowTaxonomyImages()
-                && ( getImageMap() != null )
-                && !getImageMap().isEmpty()
-                && node.getNodeData().isHasTaxonomy()
-                && ( ( node.getNodeData().getTaxonomy().getUris() != null ) && !node.getNodeData().getTaxonomy()
-                        .getUris().isEmpty() ) ) {
-            x += drawTaxonomyImage( node.getXcoord() + 2 + half_box_size, node.getYcoord(), node, g );
+    }
+
+    final private void showNodeFrame( final PhylogenyNode n ) {
+        if ( _node_frame_index < TreePanel.MAX_NODE_FRAMES ) {
+            // pop up edit box for single node
+            _node_frames[ _node_frame_index ] = new NodeFrame( n, _phylogeny, this, _node_frame_index );
+            _node_frame_index++;
         }
-        if ( ( getControlPanel().isShowTaxonomyCode() || getControlPanel().isShowTaxonomyScientificNames() || getControlPanel()
-                .isShowTaxonomyCommonNames() ) && node.getNodeData().isHasTaxonomy() ) {
-            x += paintTaxonomy( g, node, is_in_found_nodes, to_pdf, to_graphics_file, x );
+        else {
+            JOptionPane.showMessageDialog( this, "too many node windows are open" );
         }
-        setColor( g, node, to_graphics_file, to_pdf, is_in_found_nodes, getTreeColorSet().getSequenceColor() );
-        if ( node.isCollapse() && ( ( !node.isRoot() && !node.getParent().isCollapse() ) || node.isRoot() ) ) {
-            if ( _sb.length() > 0 ) {
-                _sb.setLength( 0 );
-                _sb.append( " (" );
-                _sb.append( node.getAllExternalDescendants().size() );
-                _sb.append( ")" );
+    }
+
+    final private void switchDisplaygetPhylogenyGraphicsType() {
+        switch ( getPhylogenyGraphicsType() ) {
+            case RECTANGULAR:
+                setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
+                getOptions().setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
+                break;
+            case EURO_STYLE:
+                setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
+                getOptions().setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
+                break;
+            case ROUNDED:
+                setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
+                getOptions().setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
+                break;
+            case CURVED:
+                setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
+                getOptions().setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
+                break;
+            case TRIANGULAR:
+                setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
+                getOptions().setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
+                break;
+            case CONVEX:
+                setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
+                getOptions().setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
+                break;
+            case UNROOTED:
+                setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
+                getOptions().setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
+                break;
+            case CIRCULAR:
+                setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
+                getOptions().setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
+                break;
+            default:
+                throw new RuntimeException( "unkwnown display type: " + getPhylogenyGraphicsType() );
+        }
+        if ( getControlPanel().getDynamicallyHideData() != null ) {
+            if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
+                getControlPanel().getDynamicallyHideData().setEnabled( false );
+            }
+            else {
+                getControlPanel().getDynamicallyHideData().setEnabled( true );
             }
         }
-        else {
-            _sb.setLength( 0 );
+        if ( isPhyHasBranchLengths() && ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
+            getControlPanel().setDrawPhylogramEnabled( true );
         }
-        nodeDataAsSB( node, _sb );
-        final boolean using_visual_font = setFont( g, node, is_in_found_nodes );
-        float down_shift_factor = 3.0f;
-        if ( !node.isExternal() && ( node.getNumberOfDescendants() == 1 ) ) {
-            down_shift_factor = 1;
+        else {
+            getControlPanel().setDrawPhylogramEnabled( false );
         }
-        final float pos_x = node.getXcoord() + x + 2 + half_box_size;
-        float pos_y;
-        if ( !using_visual_font ) {
-            pos_y = ( node.getYcoord() + ( getFontMetricsForLargeDefaultFont().getAscent() / down_shift_factor ) );
+        if ( getMainPanel().getMainFrame() == null ) {
+            // Must be "E" applet version.
+            ( ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet() )
+                    .setSelectedTypeInTypeMenu( getPhylogenyGraphicsType() );
         }
         else {
-            pos_y = ( node.getYcoord() + ( getFontMetrics( g.getFont() ).getAscent() / down_shift_factor ) );
+            getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getPhylogenyGraphicsType() );
         }
-        final String sb_str = _sb.toString();
-        // GUILHEM_BEG ______________
-        if ( _control_panel.isShowSequenceRelations() && node.getNodeData().isHasSequence()
-                && ( _query_sequence != null ) ) {
-            int nodeTextBoundsWidth = 0;
-            if ( sb_str.length() > 0 ) {
-                final Rectangle2D node_text_bounds = new TextLayout( sb_str, g.getFont(), _frc ).getBounds(); //would like to remove this 'new', but how...
-                nodeTextBoundsWidth = ( int ) node_text_bounds.getWidth();
-            }
-            if ( node.getNodeData().getSequence().equals( _query_sequence ) ) {
-                if ( nodeTextBoundsWidth > 0 ) { // invert font color and background color to show that this is the query sequence
-                    g.fillRect( ( int ) pos_x - 1, ( int ) pos_y - 8, nodeTextBoundsWidth + 5, 11 );
-                    g.setColor( getTreeColorSet().getBackgroundColor() );
+    }
+
+    final void calcMaxDepth() {
+        if ( _phylogeny != null ) {
+            _circ_max_depth = PhylogenyMethods.calculateMaxDepth( _phylogeny );
+        }
+    }
+
+    /**
+     * Set parameters for printing the displayed tree
+     *
+     */
+    final void calcParametersForPainting( final int x, final int y ) {
+        // updateStyle(); not needed?
+        if ( ( _phylogeny != null ) && !_phylogeny.isEmpty() ) {
+            initNodeData();
+            calculateLongestExtNodeInfo();
+            if ( ( getLongestExtNodeInfo() > ( x * 0.6 ) )
+                    && ( getTreeFontSet().getLargeFont().getSize() > ( 2 + TreeFontSet.FONT_SIZE_CHANGE_STEP ) ) ) {
+                while ( ( getLongestExtNodeInfo() > ( x * 0.7 ) ) && ( getTreeFontSet().getLargeFont().getSize() > 2 ) ) {
+                    getMainPanel().getTreeFontSet().decreaseFontSize( getConfiguration().getMinBaseFontSize(), true );
+                    calculateLongestExtNodeInfo();
                 }
             }
             else {
-                final List<SequenceRelation> seqRelations = node.getNodeData().getSequence().getSequenceRelations();
-                for( final SequenceRelation seqRelation : seqRelations ) {
-                    final boolean fGotRelationWithQuery = ( seqRelation.getRef0().isEqual( _query_sequence ) || seqRelation
-                            .getRef1().isEqual( _query_sequence ) )
-                            && seqRelation.getType().equals( getControlPanel().getSequenceRelationTypeBox()
-                                                             .getSelectedItem() );
-                    if ( fGotRelationWithQuery ) { // we will underline the text to show that this sequence is ortholog to the query
-                        final double linePosX = node.getXcoord() + 2 + half_box_size;
-                        final String sConfidence = ( !getControlPanel().isShowSequenceRelationConfidence() || ( seqRelation
-                                .getConfidence() == null ) ) ? null : " (" + seqRelation.getConfidence().getValue()
-                                        + ")";
-                        if ( sConfidence != null ) {
-                            float confidenceX = pos_x;
-                            if ( sb_str.length() > 0 ) {
-                                confidenceX += new TextLayout( sb_str, g.getFont(), _frc ).getBounds().getWidth()
-                                        + CONFIDENCE_LEFT_MARGIN;
-                            }
-                            if ( confidenceX > linePosX ) { // let's only display confidence value if we are already displaying at least one of Prot/Gene Name and Taxonomy Code
-                                final int confidenceWidth = ( int ) new TextLayout( sConfidence, g.getFont(), _frc )
-                                .getBounds().getWidth();
-                                TreePanel.drawString( sConfidence, confidenceX, pos_y, g );
-                                x += CONFIDENCE_LEFT_MARGIN + confidenceWidth;
-                            }
-                        }
-                        if ( ( x + nodeTextBoundsWidth ) > 0 ) /* we only underline if there is something displayed */
-                        {
-                            if ( nodeTextBoundsWidth == 0 ) {
-                                nodeTextBoundsWidth -= 3; /* the gap between taxonomy code and node name should not be underlined if nothing comes after it */
-                            }
-                            else {
-                                nodeTextBoundsWidth += 2;
-                            }
-                            g.drawLine( ( int ) linePosX + 1, 3 + ( int ) pos_y, ( int ) linePosX + x
-                                        + nodeTextBoundsWidth, 3 + ( int ) pos_y );
-                            break;
-                        }
-                    }
+                while ( ( getLongestExtNodeInfo() < ( x * 0.6 ) )
+                        && ( getTreeFontSet().getLargeFont().getSize() <= ( getTreeFontSet().getLargeFontMemory()
+                                .getSize() - TreeFontSet.FONT_SIZE_CHANGE_STEP ) ) ) {
+                    getMainPanel().getTreeFontSet().increaseFontSize();
+                    calculateLongestExtNodeInfo();
                 }
             }
-        }
-        if ( sb_str.length() > 0 ) {
-            TreePanel.drawString( sb_str, pos_x, pos_y, g );
-        }
-        // GUILHEM_END _____________
-        if ( _sb.length() > 0 ) {
-            if ( !using_visual_font && !is_in_found_nodes ) {
-                x += getFontMetricsForLargeDefaultFont().stringWidth( _sb.toString() ) + 5;
+            //_length_of_longest_text = calcLengthOfLongestText();
+            int ext_nodes = _phylogeny.getRoot().getNumberOfExternalNodes();
+            final int max_depth = PhylogenyMethods.calculateMaxDepth( _phylogeny );
+            if ( ext_nodes == 1 ) {
+                ext_nodes = max_depth;
+                if ( ext_nodes < 1 ) {
+                    ext_nodes = 1;
+                }
             }
-            else {
-                x += getFontMetrics( g.getFont() ).stringWidth( _sb.toString() ) + 5;
+            updateOvSizes();
+            float xdist = 0;
+            float ov_xdist = 0;
+            if ( !isNonLinedUpCladogram() && !isUniformBranchLengthsForCladogram() ) {
+                xdist = ( float ) ( ( x - getLongestExtNodeInfo() - TreePanel.MOVE ) / ( ext_nodes + 3.0 ) );
+                ov_xdist = ( float ) ( getOvMaxWidth() / ( ext_nodes + 3.0 ) );
             }
-        }
-        if ( getControlPanel().isShowAnnotation() && node.getNodeData().isHasSequence()
-                && ( node.getNodeData().getSequence().getAnnotations() != null )
-                && ( !node.getNodeData().getSequence().getAnnotations().isEmpty() ) ) {
-            final SortedSet<Annotation> ann = node.getNodeData().getSequence().getAnnotations();
-            if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
-                g.setColor( Color.BLACK );
+            else {
+                xdist = ( ( x - getLongestExtNodeInfo() - TreePanel.MOVE ) / ( max_depth + 1 ) );
+                ov_xdist = ( getOvMaxWidth() / ( max_depth + 1 ) );
             }
-            else if ( getControlPanel().isColorAccordingToAnnotation() ) {
-                g.setColor( calculateColorForAnnotation( ann ) );
+            float ydist = ( float ) ( ( y - TreePanel.MOVE ) / ( ext_nodes * 2.0 ) );
+            if ( xdist < 0.0 ) {
+                xdist = 0.0f;
             }
-            final String ann_str = TreePanelUtil.createAnnotationString( ann, getOptions().isShowAnnotationRefSource() );
-            TreePanel.drawString( ann_str, node.getXcoord() + x + 3 + half_box_size, node.getYcoord()
-                                  + ( getFontMetricsForLargeDefaultFont().getAscent() / down_shift_factor ), g );
-            _sb.setLength( 0 );
-            _sb.append( ann_str );
-            if ( _sb.length() > 0 ) {
-                if ( !using_visual_font && !is_in_found_nodes ) {
-                    x += getFontMetricsForLargeDefaultFont().stringWidth( _sb.toString() ) + 5;
-                }
-                else {
-                    x += getFontMetrics( g.getFont() ).stringWidth( _sb.toString() ) + 5;
-                }
+            if ( ov_xdist < 0.0 ) {
+                ov_xdist = 0.0f;
             }
-        }
-        if ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR )
-                || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE )
-                || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) ) {
-            if ( ( getControlPanel().isShowBinaryCharacters() || getControlPanel().isShowBinaryCharacterCounts() )
-                    && node.getNodeData().isHasBinaryCharacters() ) {
-                if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
-                    g.setColor( Color.BLACK );
-                }
-                else {
-                    g.setColor( getTreeColorSet().getBinaryDomainCombinationsColor() );
-                }
-                if ( getControlPanel().isShowBinaryCharacters() ) {
-                    TreePanel.drawString( node.getNodeData().getBinaryCharacters().getPresentCharactersAsStringBuffer()
-                                          .toString(), node.getXcoord() + x + 1 + half_box_size, node.getYcoord()
-                                          + ( getFontMetricsForLargeDefaultFont().getAscent() / down_shift_factor ), g );
-                    paintGainedAndLostCharacters( g, node, node.getNodeData().getBinaryCharacters()
-                                                  .getGainedCharactersAsStringBuffer().toString(), node.getNodeData().getBinaryCharacters()
-                                                  .getLostCharactersAsStringBuffer().toString() );
-                }
-                else {
-                    TreePanel
-                    .drawString( " " + node.getNodeData().getBinaryCharacters().getPresentCount(),
-                                 node.getXcoord() + x + 4 + half_box_size,
-                                 node.getYcoord()
-                                 + ( getFontMetricsForLargeDefaultFont().getAscent() / down_shift_factor ),
-                                 g );
-                    paintGainedAndLostCharacters( g, node, "+"
-                            + node.getNodeData().getBinaryCharacters().getGainedCount(), "-"
-                                    + node.getNodeData().getBinaryCharacters().getLostCount() );
-                }
+            if ( ydist < 0.0 ) {
+                ydist = 0.0f;
             }
-        }
-        return x;
-    }
-
-    final private void paintNodeDataUnrootedCirc( final Graphics2D g,
-                                                  final PhylogenyNode node,
-                                                  final boolean to_pdf,
-                                                  final boolean to_graphics_file,
-                                                  final boolean radial_labels,
-                                                  final double ur_angle,
-                                                  final boolean is_in_found_nodes ) {
-        if ( isNodeDataInvisibleUnrootedCirc( node ) && !to_graphics_file && !to_pdf ) {
-            return;
-        }
-        _sb.setLength( 0 );
-        _sb.append( " " );
-        if ( node.getNodeData().isHasTaxonomy()
-                && ( getControlPanel().isShowTaxonomyCode() || getControlPanel().isShowTaxonomyScientificNames() || getControlPanel()
-                        .isShowTaxonomyCommonNames() ) ) {
-            final Taxonomy taxonomy = node.getNodeData().getTaxonomy();
-            if ( _control_panel.isShowTaxonomyCode() && !ForesterUtil.isEmpty( taxonomy.getTaxonomyCode() ) ) {
-                _sb.append( taxonomy.getTaxonomyCode() );
-                _sb.append( " " );
-            }
-            if ( _control_panel.isShowTaxonomyScientificNames() && _control_panel.isShowTaxonomyCommonNames() ) {
-                if ( !ForesterUtil.isEmpty( taxonomy.getScientificName() )
-                        && !ForesterUtil.isEmpty( taxonomy.getCommonName() ) ) {
-                    _sb.append( taxonomy.getScientificName() );
-                    _sb.append( " (" );
-                    _sb.append( taxonomy.getCommonName() );
-                    _sb.append( ") " );
-                }
-                else if ( !ForesterUtil.isEmpty( taxonomy.getScientificName() ) ) {
-                    _sb.append( taxonomy.getScientificName() );
-                    _sb.append( " " );
-                }
-                else if ( !ForesterUtil.isEmpty( taxonomy.getCommonName() ) ) {
-                    _sb.append( taxonomy.getCommonName() );
-                    _sb.append( " " );
-                }
+            setXdistance( xdist );
+            setYdistance( ydist );
+            setOvXDistance( ov_xdist );
+            final double height = _phylogeny.getHeight();
+            if ( height > 0 ) {
+                final float corr = ( float ) ( ( x - TreePanel.MOVE - getLongestExtNodeInfo() - getXdistance() ) / height );
+                setXcorrectionFactor( corr > 0 ? corr : 0 );
+                final float ov_corr = ( float ) ( ( getOvMaxWidth() - getOvXDistance() ) / height );
+                setOvXcorrectionFactor( ov_corr > 0 ? ov_corr : 0 );
             }
-            else if ( _control_panel.isShowTaxonomyScientificNames() ) {
-                if ( !ForesterUtil.isEmpty( taxonomy.getScientificName() ) ) {
-                    _sb.append( taxonomy.getScientificName() );
-                    _sb.append( " " );
-                }
+            else {
+                setXcorrectionFactor( 0 );
+                setOvXcorrectionFactor( 0 );
             }
-            else if ( _control_panel.isShowTaxonomyCommonNames() ) {
-                if ( !ForesterUtil.isEmpty( taxonomy.getCommonName() ) ) {
-                    _sb.append( taxonomy.getCommonName() );
-                    _sb.append( " " );
-                }
+            _circ_max_depth = max_depth;
+            setUpUrtFactor();
+            //
+            if ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
+                    && ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
+                //                int dynamic_hiding_factor = calcDynamicHidingFactor();
+                //                if ( dynamic_hiding_factor > 1 ) {
+                //                    while ( dynamic_hiding_factor > 1
+                //                            && getTreeFontSet()._fm_large.getHeight() > TreeFontSet.SMALL_FONTS_BASE ) {
+                //                        getTreeFontSet().decreaseFontSize( 1, true );
+                //                        dynamic_hiding_factor = calcDynamicHidingFactor();
+                //                    }
+                //                }
+                //                else if ( getTreeFontSet().isDecreasedSizeBySystem() ) {
+                //                    while ( dynamic_hiding_factor < 1 && getTreeFontSet()._fm_large.getHeight() < 12 ) {
+                //                        getTreeFontSet().increaseFontSize();
+                //                        dynamic_hiding_factor = calcDynamicHidingFactor();
+                //                    }
+                //                }
             }
+            //
         }
-        if ( node.isCollapse() && ( ( !node.isRoot() && !node.getParent().isCollapse() ) || node.isRoot() ) ) {
-            _sb.append( " [" );
-            _sb.append( node.getAllExternalDescendants().size() );
-            _sb.append( "]" );
+    }
+
+    final void calculateLongestExtNodeInfo() {
+        if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
+            return;
         }
-        if ( getControlPanel().isShowNodeNames() && ( node.getName().length() > 0 ) ) {
-            if ( _sb.length() > 0 ) {
-                _sb.append( " " );
-            }
-            _sb.append( node.getName() );
+        int max_length = ForesterUtil.roundToInt( ( getSize().getWidth() - MOVE )
+                * Constants.EXT_NODE_INFO_LENGTH_MAX_RATIO );
+        if ( max_length < 40 ) {
+            max_length = 40;
         }
-        if ( node.getNodeData().isHasSequence() ) {
-            if ( getControlPanel().isShowSequenceAcc() && ( node.getNodeData().getSequence().getAccession() != null ) ) {
-                if ( _sb.length() > 0 ) {
-                    _sb.append( " " );
-                }
-                if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getSource() ) ) {
-                    _sb.append( node.getNodeData().getSequence().getAccession().getSource() );
-                    _sb.append( ":" );
-                }
-                _sb.append( node.getNodeData().getSequence().getAccession().getValue() );
+        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;
+            if ( node.isCollapse() ) {
+                continue;
             }
-            if ( getControlPanel().isShowSeqNames() && ( node.getNodeData().getSequence().getName().length() > 0 ) ) {
-                if ( _sb.length() > 0 ) {
-                    _sb.append( " " );
-                }
-                _sb.append( node.getNodeData().getSequence().getName() );
+            final StringBuilder sb = new StringBuilder();
+            nodeDataAsSB( node, sb );
+            if ( node.getNodeData().isHasTaxonomy() ) {
+                nodeTaxonomyDataAsSB( node.getNodeData().getTaxonomy(), sb );
             }
-        }
-        //g.setFont( getTreeFontSet().getLargeFont() );
-        //if ( is_in_found_nodes ) {
-        //    g.setFont( getTreeFontSet().getLargeFont().deriveFont( Font.BOLD ) );
-        // }
-        if ( _sb.length() > 1 ) {
-            setColor( g, node, to_graphics_file, to_pdf, is_in_found_nodes, getTreeColorSet().getSequenceColor() );
-            final boolean using_visual_font = setFont( g, node, is_in_found_nodes );
-            final String sb_str = _sb.toString();
-            double m = 0;
-            if ( _graphics_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
-                m = _urt_nodeid_angle_map.get( node.getId() ) % TWO_PI;
+            final int txt = sb.length();
+            if ( txt > longest_txt ) {
+                longest_txt = txt;
+                longest_txt_node = node;
             }
-            else {
-                m = ( float ) ( ur_angle % TWO_PI );
+            boolean use_vis = false;
+            final Graphics2D g = ( Graphics2D ) getGraphics();
+            if ( getControlPanel().isUseVisualStyles() ) {
+                use_vis = setFont( g, node, false );
             }
-            _at = g.getTransform();
-            boolean need_to_reset = false;
-            final float x_coord = node.getXcoord();
-            float y_coord;
-            if ( !using_visual_font ) {
-                y_coord = node.getYcoord() + ( getFontMetricsForLargeDefaultFont().getAscent() / 3.0f );
+            if ( !use_vis ) {
+                sum = getFontMetricsForLargeDefaultFont().stringWidth( sb.toString() );
             }
             else {
-                y_coord = node.getYcoord() + ( getFontMetrics( g.getFont() ).getAscent() / 3.0f );
+                sum = getFontMetrics( g.getFont() ).stringWidth( sb.toString() );
             }
-            if ( radial_labels ) {
-                need_to_reset = true;
-                boolean left = false;
-                if ( ( m > HALF_PI ) && ( m < ONEHALF_PI ) ) {
-                    m -= PI;
-                    left = true;
+            if ( getControlPanel().isShowBinaryCharacters() && node.getNodeData().isHasBinaryCharacters() ) {
+                sum += getFontMetricsForLargeDefaultFont().stringWidth( node.getNodeData().getBinaryCharacters()
+                        .getGainedCharactersAsStringBuffer().toString() );
+            }
+            if ( getControlPanel().isShowVectorData() && ( node.getNodeData().getVector() != null )
+                    && ( node.getNodeData().getVector().size() > 0 ) ) {
+                if ( getConfiguration() != null ) {
+                    sum += getConfiguration().getVectorDataWidth() + 10;
                 }
-                g.rotate( m, x_coord, node.getYcoord() );
-                if ( left ) {
-                    if ( !using_visual_font ) {
-                        g.translate( -( getFontMetricsForLargeDefaultFont().getStringBounds( sb_str, g ).getWidth() ),
-                                     0 );
-                    }
-                    else {
-                        g.translate( -( getFontMetrics( g.getFont() ).getStringBounds( sb_str, g ).getWidth() ), 0 );
-                    }
+                else {
+                    sum += RenderableVector.VECTOR_DEFAULT_WIDTH + 10;
                 }
             }
-            else {
-                if ( ( m > HALF_PI ) && ( m < ONEHALF_PI ) ) {
-                    need_to_reset = true;
-                    if ( !using_visual_font ) {
-                        g.translate( -getFontMetricsForLargeDefaultFont().getStringBounds( sb_str, g ).getWidth(), 0 );
-                    }
-                    else {
-                        g.translate( -getFontMetrics( g.getFont() ).getStringBounds( sb_str, g ).getWidth(), 0 );
-                    }
+            if ( getControlPanel().isShowDomainArchitectures() && node.getNodeData().isHasSequence()
+                    && ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) {
+                // FIXME
+                // TODO this might need some clean up
+                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();
                 }
             }
-            TreePanel.drawString( sb_str, x_coord, y_coord, g );
-            if ( need_to_reset ) {
-                g.setTransform( _at );
+            if ( getControlPanel().isShowMolSequences() && ( node.getNodeData().isHasSequence() )
+                    && ( node.getNodeData().getSequence().isMolecularSequenceAligned() )
+                    && ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) ) {
+                // FIXME
+                sum += RenderableMsaSequence.DEFAULT_WIDTH + 30;
             }
+            if ( sum >= max_length ) {
+                _longest_ext_node_info = max_length;
+                // return; //FIXME why?
+            }
+            if ( sum > longest ) {
+                longest = sum;
+            }
+        }
+        _ext_node_with_longest_txt_info = longest_txt_node;
+        if ( longest >= max_length ) {
+            _longest_ext_node_info = max_length;
+        }
+        else {
+            _longest_ext_node_info = longest;
         }
+        _length_of_longest_text = calcLengthOfLongestText();
     }
 
-    final private void paintNodeLite( final Graphics2D g, final PhylogenyNode node ) {
-        if ( node.isCollapse() ) {
-            if ( !node.isRoot() && !node.getParent().isCollapse() ) {
-                paintCollapsedNode( g, node, false, false, false );
-            }
+    final void calculateScaleDistance() {
+        if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
             return;
         }
-        if ( isInFoundNodes( node ) || isInCurrentExternalNodes( node ) ) {
-            g.setColor( getColorForFoundNode( node ) );
-            drawRectFilled( node.getXSecondary() - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF, node.getYSecondary()
-                            - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF, OVERVIEW_FOUND_NODE_BOX_SIZE, OVERVIEW_FOUND_NODE_BOX_SIZE, g );
+        final double height = getMaxDistanceToRoot();
+        if ( height > 0 ) {
+            if ( ( height <= 0.5 ) ) {
+                setScaleDistance( 0.01 );
+            }
+            else if ( height <= 5.0 ) {
+                setScaleDistance( 0.1 );
+            }
+            else if ( height <= 50.0 ) {
+                setScaleDistance( 1 );
+            }
+            else if ( height <= 500.0 ) {
+                setScaleDistance( 10 );
+            }
+            else {
+                setScaleDistance( 100 );
+            }
         }
-        float new_x = 0;
-        if ( !node.isExternal() && !node.isCollapse() ) {
-            boolean first_child = true;
-            float y2 = 0.0f;
-            final int parent_max_branch_to_leaf = getMaxBranchesToLeaf( node );
-            for( int i = 0; i < node.getNumberOfDescendants(); ++i ) {
-                final PhylogenyNode child_node = node.getChildNode( i );
-                int factor_x;
-                if ( !isUniformBranchLengthsForCladogram() ) {
-                    factor_x = node.getNumberOfExternalNodes() - child_node.getNumberOfExternalNodes();
-                }
-                else {
-                    factor_x = parent_max_branch_to_leaf - getMaxBranchesToLeaf( child_node );
-                }
-                if ( first_child ) {
-                    first_child = false;
-                    y2 = node.getYSecondary()
-                            - ( getOvYDistance() * ( node.getNumberOfExternalNodes() - child_node
-                                    .getNumberOfExternalNodes() ) );
-                }
-                else {
-                    y2 += getOvYDistance() * child_node.getNumberOfExternalNodes();
-                }
-                final float x2 = calculateOvBranchLengthToParent( child_node, factor_x );
-                new_x = x2 + node.getXSecondary();
-                final float diff_y = node.getYSecondary() - y2;
-                final float diff_x = node.getXSecondary() - new_x;
-                if ( ( diff_y > 2 ) || ( diff_y < -2 ) || ( diff_x > 2 ) || ( diff_x < -2 ) ) {
-                    paintBranchLite( g, node.getXSecondary(), new_x, node.getYSecondary(), y2, child_node );
-                }
-                child_node.setXSecondary( new_x );
-                child_node.setYSecondary( y2 );
-                y2 += getOvYDistance() * child_node.getNumberOfExternalNodes();
-            }
+        else {
+            setScaleDistance( 0.0 );
+        }
+        String scale_label = String.valueOf( getScaleDistance() );
+        if ( !ForesterUtil.isEmpty( _phylogeny.getDistanceUnit() ) ) {
+            scale_label += " [" + _phylogeny.getDistanceUnit() + "]";
         }
+        setScaleLabel( scale_label );
     }
 
-    final private void paintNodeRectangular( final Graphics2D g,
-                                             final PhylogenyNode node,
-                                             final boolean to_pdf,
-                                             final boolean dynamically_hide,
-                                             final int dynamic_hiding_factor,
-                                             final boolean to_graphics_file,
-                                             final boolean disallow_shortcutting ) {
-        final boolean is_in_found_nodes = isInFoundNodes( node ) || isInCurrentExternalNodes( node );
-        if ( node.isCollapse() ) {
-            if ( ( !node.isRoot() && !node.getParent().isCollapse() ) ) {
-                paintCollapsedNode( g, node, to_graphics_file, to_pdf, is_in_found_nodes );
-            }
-            return;
-        }
-        if ( node.isExternal() ) {
-            ++_external_node_index;
+    final Color calculateSequenceBasedColor( final Sequence seq ) {
+        if ( ForesterUtil.isEmpty( seq.getName() ) ) {
+            return getTreeColorSet().getSequenceColor();
         }
-        // Confidence values
-        if ( getControlPanel().isShowConfidenceValues()
-                && !node.isExternal()
-                && !node.isRoot()
-                && ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED )
-                        || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) )
-                        && node.getBranchData().isHasConfidences() ) {
-            paintConfidenceValues( g, node, to_pdf, to_graphics_file );
+        Color c = null;
+        final String seq_name = seq.getName();
+        c = getControlPanel().getSequenceColors().get( seq_name );
+        if ( c == null ) {
+            c = AptxUtil.calculateColorFromString( seq_name, false );
+            getControlPanel().getSequenceColors().put( seq_name, c );
         }
-        // Draw a line to root:
-        if ( node.isRoot() && _phylogeny.isRooted() ) {
-            paintRootBranch( g, node.getXcoord(), node.getYcoord(), node, to_pdf, to_graphics_file );
+        return c;
+    }
+
+    final Color calculateTaxonomyBasedColor( final Taxonomy tax ) {
+        if ( getOptions().isColorByTaxonomicGroup() ) {
+            if ( !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) {
+                boolean ex = false;
+                String group = null;
+                try {
+                    group = TaxonomyUtil.getTaxGroupByTaxCode( tax.getTaxonomyCode() );
+                }
+                catch ( final Exception e ) {
+                    ex = true;
+                }
+                if ( !ex && !ForesterUtil.isEmpty( group ) ) {
+                    final Color c = ForesterUtil.obtainColorDependingOnTaxonomyGroup( group );
+                    if ( c != null ) {
+                        return c;
+                    }
+                }
+            }
+            return getTreeColorSet().getTaxonomyColor();
         }
-        float new_x = 0;
-        float new_x_min = Float.MAX_VALUE;
-        float min_dist = 1.5f;
-        if ( !disallow_shortcutting ) {
-            if ( dynamic_hiding_factor > 4000 ) {
-                min_dist = 4;
+        else {
+            if ( ForesterUtil.isEmpty( tax.getTaxonomyCode() ) && ForesterUtil.isEmpty( tax.getScientificName() ) ) {
+                return getTreeColorSet().getTaxonomyColor();
             }
-            else if ( dynamic_hiding_factor > 1000 ) {
-                min_dist = 3;
+            Color c = null;
+            if ( !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) {
+                c = getControlPanel().getSpeciesColors().get( tax.getTaxonomyCode() );
             }
-            else if ( dynamic_hiding_factor > 100 ) {
-                min_dist = 2;
+            if ( ( c == null ) && !ForesterUtil.isEmpty( tax.getScientificName() ) ) {
+                c = getControlPanel().getSpeciesColors().get( tax.getScientificName() );
             }
-        }
-        if ( !node.isExternal() && !node.isCollapse() ) {
-            boolean first_child = true;
-            float y2 = 0.0f;
-            final int parent_max_branch_to_leaf = getMaxBranchesToLeaf( node );
-            for( int i = 0; i < node.getNumberOfDescendants(); ++i ) {
-                final PhylogenyNode child_node = node.getChildNode( i );
-                int factor_x;
-                if ( !isUniformBranchLengthsForCladogram() ) {
-                    factor_x = node.getNumberOfExternalNodes() - child_node.getNumberOfExternalNodes();
-                }
-                else {
-                    factor_x = parent_max_branch_to_leaf - getMaxBranchesToLeaf( child_node );
-                }
-                if ( first_child ) {
-                    first_child = false;
-                    y2 = node.getYcoord()
-                            - ( _y_distance * ( node.getNumberOfExternalNodes() - child_node.getNumberOfExternalNodes() ) );
+            if ( c == null ) {
+                if ( !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) {
+                    c = AptxUtil.calculateColorFromString( tax.getTaxonomyCode(), true );
+                    getControlPanel().getSpeciesColors().put( tax.getTaxonomyCode(), c );
                 }
                 else {
-                    y2 += _y_distance * child_node.getNumberOfExternalNodes();
+                    c = AptxUtil.calculateColorFromString( tax.getScientificName(), true );
+                    getControlPanel().getSpeciesColors().put( tax.getScientificName(), c );
                 }
-                final float x2 = calculateBranchLengthToParent( child_node, factor_x );
-                new_x = x2 + node.getXcoord();
-                if ( dynamically_hide && ( x2 < new_x_min ) ) {
-                    new_x_min = x2;
+            }
+            return c;
+        }
+    }
+
+    void checkForVectorProperties( final Phylogeny phy ) {
+        final DescriptiveStatistics stats = new BasicDescriptiveStatistics();
+        for( final PhylogenyNodeIterator iter = phy.iteratorPreorder(); iter.hasNext(); ) {
+            final PhylogenyNode node = iter.next();
+            if ( node.getNodeData().getProperties() != null ) {
+                final PropertiesMap pm = node.getNodeData().getProperties();
+                final double[] vector = new double[ pm.getProperties().size() ];
+                int counter = 0;
+                for( final String ref : pm.getProperties().keySet() ) {
+                    if ( ref.startsWith( PhyloXmlUtil.VECTOR_PROPERTY_REF ) ) {
+                        final Property p = pm.getProperty( ref );
+                        final String value_str = p.getValue();
+                        final String index_str = ref
+                                .substring( PhyloXmlUtil.VECTOR_PROPERTY_REF.length(), ref.length() );
+                        double d = -100;
+                        try {
+                            d = Double.parseDouble( value_str );
+                        }
+                        catch ( final NumberFormatException e ) {
+                            JOptionPane.showMessageDialog( this, "Could not parse \"" + value_str
+                                    + "\" into a decimal value", "Problem with Vector Data", JOptionPane.ERROR_MESSAGE );
+                            return;
+                        }
+                        int i = -1;
+                        try {
+                            i = Integer.parseInt( index_str );
+                        }
+                        catch ( final NumberFormatException e ) {
+                            JOptionPane.showMessageDialog( this,
+                                                           "Could not parse \"" + index_str
+                                                                   + "\" into index for vector data",
+                                                           "Problem with Vector Data",
+                                                           JOptionPane.ERROR_MESSAGE );
+                            return;
+                        }
+                        if ( i < 0 ) {
+                            JOptionPane.showMessageDialog( this,
+                                                           "Attempt to use negative index for vector data",
+                                                           "Problem with Vector Data",
+                                                           JOptionPane.ERROR_MESSAGE );
+                            return;
+                        }
+                        vector[ i ] = d;
+                        ++counter;
+                        stats.addValue( d );
+                    }
                 }
-                final float diff_y = node.getYcoord() - y2;
-                final float diff_x = node.getXcoord() - new_x;
-                if ( disallow_shortcutting || ( diff_y > min_dist ) || ( diff_y < -min_dist ) || ( diff_x > min_dist )
-                        || ( diff_x < -min_dist ) ) {
-                    paintBranchRectangular( g,
-                                            node.getXcoord(),
-                                            new_x,
-                                            node.getYcoord(),
-                                            y2,
-                                            child_node,
-                                            to_pdf,
-                                            to_graphics_file );
+                final List<Double> vector_l = new ArrayList<Double>( counter );
+                for( int i = 0; i < counter; ++i ) {
+                    vector_l.add( vector[ i ] );
                 }
-                child_node.setXcoord( new_x );
-                child_node.setYcoord( y2 );
-                y2 += _y_distance * child_node.getNumberOfExternalNodes();
+                node.getNodeData().setVector( vector_l );
             }
-            paintNodeBox( node.getXcoord(), node.getYcoord(), node, g, to_pdf, to_graphics_file );
         }
-        if ( getControlPanel().isShowMolSequences() && ( node.getNodeData().isHasSequence() )
-                && ( node.getNodeData().getSequence().isMolecularSequenceAligned() )
-                && ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) ) {
-            paintMolecularSequences( g, node, to_pdf );
-        }
-        if ( dynamically_hide
-                && !is_in_found_nodes
-                && ( ( node.isExternal() && ( ( _external_node_index % dynamic_hiding_factor ) != 1 ) ) || ( !node
-                        .isExternal() && ( ( new_x_min < 20 ) || ( ( _y_distance * node.getNumberOfExternalNodes() ) < getFontMetricsForLargeDefaultFont()
-                                .getHeight() ) ) ) ) ) {
-            return;
+        if ( stats.getN() > 0 ) {
+            _statistics_for_vector_data = stats;
         }
-        final int x = paintNodeData( g, node, to_graphics_file, to_pdf, is_in_found_nodes );
-        paintNodeWithRenderableData( x, g, node, to_graphics_file, to_pdf );
     }
 
-    final private void paintNodeWithRenderableData( final int x,
-                                                    final Graphics2D g,
-                                                    final PhylogenyNode node,
-                                                    final boolean to_graphics_file,
-                                                    final boolean to_pdf ) {
-        if ( isNodeDataInvisible( node ) && !( to_graphics_file || to_pdf ) ) {
-            return;
-        }
-        if ( ( !getControlPanel().isShowInternalData() && !node.isExternal() ) ) {
+    void clearCurrentExternalNodesDataBuffer() {
+        setCurrentExternalNodesDataBuffer( new StringBuilder() );
+    }
+
+    /**
+     * Collapse the tree from the given node
+     *
+     * @param node
+     *            a PhylogenyNode
+     */
+    final void collapse( final PhylogenyNode node ) {
+        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
+            JOptionPane.showMessageDialog( this,
+                                           "Cannot collapse in unrooted display type",
+                                           "Attempt to collapse in unrooted display",
+                                           JOptionPane.WARNING_MESSAGE );
             return;
         }
-        if ( getControlPanel().isShowDomainArchitectures() && node.getNodeData().isHasSequence()
-                && ( node.getNodeData().getSequence().getDomainArchitecture() != null )
-                && ( node.getNodeData().getSequence().getDomainArchitecture() instanceof RenderableDomainArchitecture ) ) {
-            RenderableDomainArchitecture rds = null;
-            try {
-                rds = ( RenderableDomainArchitecture ) node.getNodeData().getSequence().getDomainArchitecture();
-            }
-            catch ( final ClassCastException cce ) {
-                cce.printStackTrace();
-            }
-            if ( rds != null ) {
-                final int default_height = 7;
-                float y = getYdistance();
-                if ( getControlPanel().isDynamicallyHideData() ) {
-                    y = getTreeFontSet().getFontMetricsLarge().getHeight();
-                }
-                final int h = y < default_height ? ForesterUtil.roundToInt( y ) : default_height;
-                rds.setRenderingHeight( h > 1 ? h : 2 );
-                if ( getControlPanel().isDrawPhylogram() ) {
-                    if ( getOptions().isLineUpRendarableNodeData() ) {
-                        if ( getOptions().isRightLineUpDomains() ) {
-                            rds.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() )
-                                    + _length_of_longest_text + ( ( _longest_domain - rds.getTotalLength() ) * rds
-                                            .getRenderingFactorWidth() ) ), node.getYcoord() - ( h / 2.0f ), g, this, to_pdf );
-                        }
-                        else {
-                            rds.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() ) + _length_of_longest_text ),
-                                        node.getYcoord() - ( h / 2.0f ),
-                                        g,
-                                        this,
-                                        to_pdf );
-                        }
-                    }
-                    else {
-                        rds.render( node.getXcoord() + x, node.getYcoord() - ( h / 2.0f ), g, this, to_pdf );
-                    }
-                }
-                else {
-                    if ( getOptions().isRightLineUpDomains() ) {
-                        rds.render( ( ( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text ) - 20 )
-                                    + ( ( _longest_domain - rds.getTotalLength() ) * rds
-                                            .getRenderingFactorWidth() ),
-                                            node.getYcoord() - ( h / 2.0f ),
-                                            g,
-                                            this,
-                                            to_pdf );
-                    }
-                    else {
-                        rds.render( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text,
-                                    node.getYcoord() - ( h / 2.0f ),
-                                    g,
-                                    this,
-                                    to_pdf );
-                    }
-                }
-            }
+        if ( !node.isExternal() && !node.isRoot() ) {
+            final boolean collapse = !node.isCollapse();
+            TreePanelUtil.collapseSubtree( node, collapse );
+            updateSetOfCollapsedExternalNodes();
+            _phylogeny.recalculateNumberOfExternalDescendants( true );
+            resetNodeIdToDistToLeafMap();
+            calculateLongestExtNodeInfo();
+            setNodeInPreorderToNull();
+            _control_panel.displayedPhylogenyMightHaveChanged( true );
+            resetPreferredSize();
+            updateOvSizes();
+            _main_panel.adjustJScrollPane();
+            repaint();
         }
-        if ( getControlPanel().isShowVectorData() && ( node.getNodeData().getVector() != null )
-                && ( node.getNodeData().getVector().size() > 0 ) && ( getStatisticsForExpressionValues() != null ) ) {
-            final RenderableVector rv = RenderableVector.createInstance( node.getNodeData().getVector(),
-                                                                         getStatisticsForExpressionValues(),
-                                                                         getConfiguration() );
-            if ( rv != null ) {
-                double domain_add = 0;
-                if ( getControlPanel().isShowDomainArchitectures() && node.getNodeData().isHasSequence()
-                        && ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) {
-                    domain_add = _domain_structure_width + 10;
-                }
-                if ( getControlPanel().isDrawPhylogram() ) {
-                    rv.render( ( float ) ( node.getXcoord() + x + domain_add ), node.getYcoord() - 3, g, this, to_pdf );
-                }
-                else {
-                    rv.render( ( float ) ( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text + domain_add ),
-                               node.getYcoord() - 3,
-                               g,
-                               this,
-                               to_pdf );
-                }
-            }
+    }
+
+    final void collapseSpeciesSpecificSubtrees() {
+        if ( ( _phylogeny == null ) || ( _phylogeny.getNumberOfExternalNodes() < 2 ) ) {
+            return;
         }
-       
-        //if ( getControlPanel().isShowMolSequences() && ( node.getNodeData().isHasSequence() )
-        //        && ( node.getNodeData().getSequence().isMolecularSequenceAligned() )
-        //        && ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) ) {
-        //    paintMolecularSequences( g, node, to_pdf );
-        //}
+        setWaitCursor();
+        TreePanelUtil.collapseSpeciesSpecificSubtrees( _phylogeny );
+        updateSetOfCollapsedExternalNodes();
+        _phylogeny.recalculateNumberOfExternalDescendants( true );
+        resetNodeIdToDistToLeafMap();
+        calculateLongestExtNodeInfo();
+        setNodeInPreorderToNull();
+        resetPreferredSize();
+        _main_panel.adjustJScrollPane();
+        setArrowCursor();
+        repaint();
     }
 
-    private void paintMolecularSequences( final Graphics2D g, final PhylogenyNode node, final boolean to_pdf ) {
-        final RenderableMsaSequence rs = RenderableMsaSequence.createInstance( node.getNodeData().getSequence()
-                                                                               .getMolecularSequence(), node.getNodeData().getSequence().getType(), getConfiguration() );
-        if ( rs != null ) {
-            final int default_height = 8;
-            float y = getYdistance();
-           
-            final int h = ( y / 2) < default_height ? ForesterUtil.roundToInt( y * 2 ) : default_height;
-            rs.setRenderingHeight( h > 1 ? h : 1 );
-           
-            if ( getControlPanel().isDrawPhylogram() ) {
-                rs.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() ) + _length_of_longest_text ),
-                           node.getYcoord() - ( h / 2.0f ),
-                           g,
-                           this,
-                           to_pdf );
+    final void colorRank( final String rank ) {
+        if ( ( _phylogeny == null ) || ( _phylogeny.getNumberOfExternalNodes() < 2 ) ) {
+            return;
+        }
+        setWaitCursor();
+        AptxUtil.removeBranchColors( _phylogeny );
+        final int colorizations = TreePanelUtil.colorPhylogenyAccordingToRanks( _phylogeny, rank, this );
+        if ( colorizations > 0 ) {
+            _control_panel.setColorBranches( true );
+            if ( _control_panel.getUseVisualStylesCb() != null ) {
+                _control_panel.getUseVisualStylesCb().setSelected( true );
             }
-            else {
-                rs.render( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text,
-                           node.getYcoord() - ( h / 2.0f ),
-                           g,
-                           this,
-                           to_pdf );
+            if ( _control_panel.getColorAccSpeciesCb() != null ) {
+                _control_panel.getColorAccSpeciesCb().setSelected( false );
+            }
+            _options.setColorLabelsSameAsParentBranch( true );
+            if ( getMainPanel().getMainFrame()._color_labels_same_as_parent_branch != null ) {
+                getMainPanel().getMainFrame()._color_labels_same_as_parent_branch.setSelected( true );
             }
+            _control_panel.repaint();
         }
-    }
-
-    final private int calcLengthOfLongestText() {
-        final StringBuilder sb = new StringBuilder();
-        if ( _ext_node_with_longest_txt_info != null ) {
-            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 );
+        setArrowCursor();
+        repaint();
+        if ( colorizations > 0 ) {
+            String msg = "Taxonomy colorization via " + rank + " completed:\n";
+            if ( colorizations > 1 ) {
+                msg += "colorized " + colorizations + " subtrees";
+            }
+            else {
+                msg += "colorized one subtree";
             }
+            setEdited( true );
+            JOptionPane.showMessageDialog( this,
+                                           msg,
+                                           "Taxonomy Colorization Completed (" + rank + ")",
+                                           JOptionPane.INFORMATION_MESSAGE );
+        }
+        else {
+            String msg = "Could not taxonomy colorize any subtree via " + rank + ".\n";
+            msg += "Possible solutions (given that suitable taxonomic information is present):\n";
+            msg += "select a different rank (e.g. phylum, genus, ...)\n";
+            msg += "  and/or\n";
+            msg += "execute:\n";
+            msg += "1. \"" + MainFrameApplication.OBTAIN_DETAILED_TAXONOMIC_INFORMATION + "\" (Tools)\n";
+            msg += "2. \"" + MainFrameApplication.INFER_ANCESTOR_TAXONOMIES + "\" (Analysis)";
+            JOptionPane.showMessageDialog( this, msg, "Taxonomy Colorization Failed", JOptionPane.WARNING_MESSAGE );
         }
-        return getFontMetricsForLargeDefaultFont().stringWidth( sb.toString() );
     }
 
-    final private void paintOvRectangle( final Graphics2D g ) {
-        final float w_ratio = ( ( float ) getWidth() ) / getVisibleRect().width;
-        final float h_ratio = ( ( float ) getHeight() ) / getVisibleRect().height;
-        final float x_ratio = ( ( float ) getWidth() ) / getVisibleRect().x;
-        final float y_ratio = ( ( float ) getHeight() ) / getVisibleRect().y;
-        final float width = getOvMaxWidth() / w_ratio;
-        final float height = getOvMaxHeight() / h_ratio;
-        final float x = getVisibleRect().x + getOvXPosition() + ( getOvMaxWidth() / x_ratio );
-        final float y = getVisibleRect().y + getOvYPosition() + ( getOvMaxHeight() / y_ratio );
-        g.setColor( getTreeColorSet().getFoundColor0() );
-        getOvRectangle().setRect( x, y, width, height );
-        final Stroke s = g.getStroke();
-        g.setStroke( STROKE_1 );
-        if ( ( width < 6 ) && ( height < 6 ) ) {
-            drawRectFilled( x, y, 6, 6, g );
-            getOvVirtualRectangle().setRect( x, y, 6, 6 );
-        }
-        else if ( width < 6 ) {
-            drawRectFilled( x, y, 6, height, g );
-            getOvVirtualRectangle().setRect( x, y, 6, height );
-        }
-        else if ( height < 6 ) {
-            drawRectFilled( x, y, width, 6, g );
-            getOvVirtualRectangle().setRect( x, y, width, 6 );
+    final void confColor() {
+        if ( ( _phylogeny == null ) || ( _phylogeny.getNumberOfExternalNodes() < 2 ) ) {
+            return;
         }
-        else {
-            drawRect( x, y, width, height, g );
-            if ( isInOvRect() ) {
-                drawRect( x + 1, y + 1, width - 2, height - 2, g );
-            }
-            getOvVirtualRectangle().setRect( x, y, width, height );
+        setWaitCursor();
+        AptxUtil.removeBranchColors( _phylogeny );
+        TreePanelUtil.colorPhylogenyAccordingToConfidenceValues( _phylogeny, this );
+        _control_panel.setColorBranches( true );
+        if ( _control_panel.getUseVisualStylesCb() != null ) {
+            _control_panel.getUseVisualStylesCb().setSelected( true );
         }
-        g.setStroke( s );
+        setArrowCursor();
+        repaint();
     }
 
-    final private void paintPhylogenyLite( final Graphics2D g ) {
-        _phylogeny
-        .getRoot()
-        .setXSecondary( ( float ) ( getVisibleRect().x + getOvXPosition() + ( MOVE / ( getVisibleRect().width / getOvRectangle()
-                .getWidth() ) ) ) );
-        _phylogeny.getRoot().setYSecondary( ( getVisibleRect().y + getOvYStart() ) );
-        final Stroke s = g.getStroke();
-        g.setStroke( STROKE_05 );
-        for( final PhylogenyNode element : _nodes_in_preorder ) {
-            paintNodeLite( g, element );
+    final void decreaseDomainStructureEvalueThresholdExp() {
+        if ( _domain_structure_e_value_thr_exp > -20 ) {
+            _domain_structure_e_value_thr_exp -= 1;
         }
-        g.setStroke( s );
-        paintOvRectangle( g );
     }
 
     /**
-     * Paint the root branch. (Differs from others because it will always be a
-     * single horizontal line).
-     * @param to_graphics_file
+     * Find the node, if any, at the given location
      *
-     * @return new x1 value
+     * @param x
+     * @param y
+     * @return pointer to the node at x,y, null if not found
      */
-    final private void paintRootBranch( final Graphics2D g,
-                                        final float x1,
-                                        final float y1,
-                                        final PhylogenyNode root,
-                                        final boolean to_pdf,
-                                        final boolean to_graphics_file ) {
-        assignGraphicsForBranchWithColorForParentBranch( root, false, g, to_pdf, to_graphics_file );
-        float d = getXdistance();
-        if ( getControlPanel().isDrawPhylogram() && ( root.getDistanceToParent() > 0.0 ) ) {
-            d = ( float ) ( getXcorrectionFactor() * root.getDistanceToParent() );
-        }
-        if ( d < MIN_ROOT_LENGTH ) {
-            d = MIN_ROOT_LENGTH;
+    final PhylogenyNode findNode( final int x, final int y ) {
+        if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
+            return null;
         }
-        if ( !getControlPanel().isWidthBranches() || ( PhylogenyMethods.getBranchWidthValue( root ) == 1 ) ) {
-            drawLine( x1 - d, root.getYcoord(), x1, root.getYcoord(), g );
+        final int half_box_size_plus_wiggle = ( getOptions().getDefaultNodeShapeSize() / 2 ) + WIGGLE;
+        for( final PhylogenyNodeIterator iter = _phylogeny.iteratorPostorder(); iter.hasNext(); ) {
+            final PhylogenyNode node = iter.next();
+            if ( ( _phylogeny.isRooted() || !node.isRoot() || ( node.getNumberOfDescendants() > 2 ) )
+                    && ( ( node.getXcoord() - half_box_size_plus_wiggle ) <= x )
+                    && ( ( node.getXcoord() + half_box_size_plus_wiggle ) >= x )
+                    && ( ( node.getYcoord() - half_box_size_plus_wiggle ) <= y )
+                    && ( ( node.getYcoord() + half_box_size_plus_wiggle ) >= y ) ) {
+                return node;
+            }
         }
-        else {
-            final double w = PhylogenyMethods.getBranchWidthValue( root );
-            drawRectFilled( x1 - d, root.getYcoord() - ( w / 2 ), d, w, g );
-        }
-        paintNodeBox( x1, root.getYcoord(), root, g, to_pdf, to_graphics_file );
+        return null;
     }
 
-    final private void paintScale( final Graphics2D g,
-                                   int x1,
-                                   int y1,
-                                   final boolean to_pdf,
-                                   final boolean to_graphics_file ) {
-        x1 += MOVE;
-        final double x2 = x1 + ( getScaleDistance() * getXcorrectionFactor() );
-        y1 -= 12;
-        final int y2 = y1 - 8;
-        final int y3 = y1 - 4;
-        g.setFont( getTreeFontSet().getSmallFont() );
-        if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
-            g.setColor( Color.BLACK );
-        }
-        else {
-            g.setColor( getTreeColorSet().getBranchLengthColor() );
+    final Configuration getConfiguration() {
+        return _configuration;
+    }
+
+    final ControlPanel getControlPanel() {
+        return _control_panel;
+    }
+
+    String getCurrentExternalNodesDataBufferAsString() {
+        return _current_external_nodes_data_buffer.toString();
+    }
+
+    int getCurrentExternalNodesDataBufferChangeCounter() {
+        return _current_external_nodes_data_buffer_change_counter;
+    }
+
+    final int getDomainStructureEvalueThresholdExp() {
+        return _domain_structure_e_value_thr_exp;
+    }
+
+    final Set<Long> getFoundNodes0() {
+        return _found_nodes_0;
+    }
+
+    final Set<Long> getFoundNodes1() {
+        return _found_nodes_1;
+    }
+
+    List<PhylogenyNode> getFoundNodesAsListOfPhylogenyNodes() {
+        final List<PhylogenyNode> additional_nodes = new ArrayList<PhylogenyNode>();
+        if ( getFoundNodes0() != null ) {
+            for( final Long id : getFoundNodes0() ) {
+                final PhylogenyNode n = _phylogeny.getNode( id );
+                if ( n != null ) {
+                    additional_nodes.add( n );
+                }
+            }
         }
-        final Stroke s = g.getStroke();
-        g.setStroke( STROKE_1 );
-        drawLine( x1, y1, x1, y2, g );
-        drawLine( x2, y1, x2, y2, g );
-        drawLine( x1, y3, x2, y3, g );
-        if ( getScaleLabel() != null ) {
-            g.drawString( getScaleLabel(), ( x1 + 2 ), y3 - 2 );
+        if ( getFoundNodes1() != null ) {
+            for( final Long id : getFoundNodes1() ) {
+                if ( ( getFoundNodes0() == null ) || !getFoundNodes0().contains( id ) ) {
+                    final PhylogenyNode n = _phylogeny.getNode( id );
+                    if ( n != null ) {
+                        additional_nodes.add( n );
+                    }
+                }
+            }
         }
-        g.setStroke( s );
+        return additional_nodes;
     }
 
-    final private int paintTaxonomy( final Graphics2D g,
-                                     final PhylogenyNode node,
-                                     final boolean is_in_found_nodes,
-                                     final boolean to_pdf,
-                                     final boolean to_graphics_file,
-                                     final float x_shift ) {
-        final Taxonomy taxonomy = node.getNodeData().getTaxonomy();
-        final boolean using_visual_font = setFont( g, node, is_in_found_nodes );
-        setColor( g, node, to_graphics_file, to_pdf, is_in_found_nodes, getTreeColorSet().getTaxonomyColor() );
-        final float start_x = node.getXcoord() + 3 + ( getOptions().getDefaultNodeShapeSize() / 2 ) + x_shift;
-        float start_y;
-        if ( !using_visual_font ) {
-            start_y = node.getYcoord()
-                    + ( getFontMetricsForLargeDefaultFont().getAscent() / ( node.getNumberOfDescendants() == 1 ? 1
-                            : 3.0f ) );
+    final Color getGraphicsForNodeBoxWithColorForParentBranch( final PhylogenyNode node ) {
+        if ( getControlPanel().isUseVisualStyles() && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) {
+            return ( PhylogenyMethods.getBranchColorValue( node ) );
         }
         else {
-            start_y = node.getYcoord()
-                    + ( getFontMetrics( g.getFont() ).getAscent() / ( node.getNumberOfDescendants() == 1 ? 1 : 3.0f ) );
+            return ( getTreeColorSet().getBranchColor() );
         }
-        _sb.setLength( 0 );
-        nodeTaxonomyDataAsSB( taxonomy, _sb );
-        final String label = _sb.toString();
-        /* GUILHEM_BEG */
-        if ( _control_panel.isShowSequenceRelations() && ( label.length() > 0 )
-                && ( node.getNodeData().isHasSequence() ) && node.getNodeData().getSequence().equals( _query_sequence ) ) {
-            // invert font color and background color to show that this is the query sequence
-            final Rectangle2D nodeTextBounds = new TextLayout( label, g.getFont(), new FontRenderContext( null,
-                                                                                                          false,
-                                                                                                          false ) )
-            .getBounds();
-            g.fillRect( ( int ) start_x - 1, ( int ) start_y - 8, ( int ) nodeTextBounds.getWidth() + 4, 11 );
-            g.setColor( getTreeColorSet().getBackgroundColor() );
+    }
+
+    final int getLongestExtNodeInfo() {
+        return _longest_ext_node_info;
+    }
+
+    final Options getOptions() {
+        if ( _options == null ) {
+            _options = getControlPanel().getOptions();
         }
-        /* GUILHEM_END */
-        TreePanel.drawString( label, start_x, start_y, g );
-        if ( !using_visual_font && !is_in_found_nodes ) {
-            return getFontMetricsForLargeDefaultFont().stringWidth( label );
+        return _options;
+    }
+
+    final Rectangle2D getOvRectangle() {
+        return _ov_rectangle;
+    }
+
+    final Rectangle getOvVirtualRectangle() {
+        return _ov_virtual_rectangle;
+    }
+
+    final PHYLOGENY_GRAPHICS_TYPE getPhylogenyGraphicsType() {
+        return _graphics_type;
+    }
+
+    final Color getSequenceBasedColor( final PhylogenyNode node ) {
+        if ( node.getNodeData().isHasSequence() ) {
+            return calculateSequenceBasedColor( node.getNodeData().getSequence() );
         }
-        return getFontMetrics( g.getFont() ).stringWidth( label );
+        // return non-colorized color
+        return getTreeColorSet().getSequenceColor();
     }
 
-    final private void paintUnrooted( final PhylogenyNode n,
-                                      final double low_angle,
-                                      final double high_angle,
-                                      final boolean radial_labels,
-                                      final Graphics2D g,
-                                      final boolean to_pdf,
-                                      final boolean to_graphics_file ) {
-        if ( n.isRoot() ) {
-            n.setXcoord( getWidth() / 2 );
-            n.setYcoord( getHeight() / 2 );
+    final double getStartingAngle() {
+        return _urt_starting_angle;
+    }
+
+    DescriptiveStatistics getStatisticsForExpressionValues() {
+        return _statistics_for_vector_data;
+    }
+
+    final Color getTaxonomyBasedColor( final PhylogenyNode node ) {
+        if ( node.isExternal() && node.getNodeData().isHasTaxonomy() ) {
+            return calculateTaxonomyBasedColor( node.getNodeData().getTaxonomy() );
         }
-        if ( n.isExternal() ) {
-            paintNodeDataUnrootedCirc( g,
-                                       n,
-                                       to_pdf,
-                                       to_graphics_file,
-                                       radial_labels,
-                                       ( high_angle + low_angle ) / 2,
-                                       isInFoundNodes( n ) || isInCurrentExternalNodes( n ) );
+        // return non-colorized color
+        return getTreeColorSet().getTaxonomyColor();
+    }
+
+    final File getTreeFile() {
+        return _treefile;
+    }
+
+    final float getXcorrectionFactor() {
+        return _x_correction_factor;
+    }
+
+    final float getXdistance() {
+        return _x_distance;
+    }
+
+    final float getYdistance() {
+        return _y_distance;
+    }
+
+    final void increaseDomainStructureEvalueThresholdExp() {
+        if ( _domain_structure_e_value_thr_exp < 3 ) {
+            _domain_structure_e_value_thr_exp += 1;
+        }
+    }
+
+    final void initNodeData() {
+        if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
             return;
         }
-        final float num_enclosed = n.getNumberOfExternalNodes();
-        final float x = n.getXcoord();
-        final float y = n.getYcoord();
-        double current_angle = low_angle;
-        // final boolean n_below = n.getYcoord() < getVisibleRect().getMinY() - 20;
-        // final boolean n_above = n.getYcoord() > getVisibleRect().getMaxY() + 20;
-        // final boolean n_left = n.getXcoord() < getVisibleRect().getMinX() - 20;
-        // final boolean n_right = n.getXcoord() > getVisibleRect().getMaxX() + 20;
-        for( int i = 0; i < n.getNumberOfDescendants(); ++i ) {
-            final PhylogenyNode desc = n.getChildNode( i );
-            ///  if ( ( ( n_below ) & ( desc.getYcoord() < getVisibleRect().getMinY() - 20 ) )
-            //          || ( ( n_above ) & ( desc.getYcoord() > getVisibleRect().getMaxY() + 20 ) )
-            //         || ( ( n_left ) & ( desc.getXcoord() < getVisibleRect().getMinX() - 20 ) )
-            //          || ( ( n_right ) & ( desc.getXcoord() > getVisibleRect().getMaxX() + 20 ) ) ) {
-            //     continue;
-            // }
-            //if ( ( desc.getYcoord() > n.getYcoord() ) && ( n.getYcoord() > getVisibleRect().getMaxY() - 20 ) ) {
-            //    continue;
-            //}
-            //if ( ( desc.getYcoord() < n.getYcoord() ) && ( n.getYcoord() < getVisibleRect().getMinY() + 20 ) ) {
-            //    continue;
-            // }
-            final int desc_num_enclosed = desc.getNumberOfExternalNodes();
-            final double arc_size = ( desc_num_enclosed / num_enclosed ) * ( high_angle - low_angle );
-            float length;
-            if ( isPhyHasBranchLengths() && getControlPanel().isDrawPhylogram() ) {
-                if ( desc.getDistanceToParent() < 0 ) {
-                    length = 0;
+        double _max_original_domain_structure_width = 0.0;
+        for( final PhylogenyNode node : _phylogeny.getExternalNodes() ) {
+            if ( node.getNodeData().isHasSequence()
+                    && ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) {
+                RenderableDomainArchitecture rds = null;
+                if ( !( node.getNodeData().getSequence().getDomainArchitecture() instanceof RenderableDomainArchitecture ) ) {
+                    if ( SPECIAL_DOMAIN_COLORING ) {
+                        rds = new RenderableDomainArchitecture( node.getNodeData().getSequence()
+                                .getDomainArchitecture(), node.getName() );
+                    }
+                    else {
+                        rds = new RenderableDomainArchitecture( node.getNodeData().getSequence()
+                                .getDomainArchitecture() );
+                    }
+                    node.getNodeData().getSequence().setDomainArchitecture( rds );
                 }
                 else {
-                    length = ( float ) ( desc.getDistanceToParent() * getUrtFactor() );
+                    rds = ( RenderableDomainArchitecture ) node.getNodeData().getSequence().getDomainArchitecture();
+                }
+                if ( getControlPanel().isShowDomainArchitectures() ) {
+                    final double dsw = rds.getOriginalSize().getWidth();
+                    if ( dsw > _max_original_domain_structure_width ) {
+                        _max_original_domain_structure_width = dsw;
+                    }
                 }
             }
-            else {
-                length = getUrtFactor();
-            }
-            final double mid_angle = current_angle + ( arc_size / 2 );
-            final float new_x = ( float ) ( x + ( Math.cos( mid_angle ) * length ) );
-            final float new_y = ( float ) ( y + ( Math.sin( mid_angle ) * length ) );
-            desc.setXcoord( new_x );
-            desc.setYcoord( new_y );
-            paintUnrooted( desc, current_angle, current_angle + arc_size, radial_labels, g, to_pdf, to_graphics_file );
-            current_angle += arc_size;
-            assignGraphicsForBranchWithColorForParentBranch( desc, false, g, to_pdf, to_graphics_file );
-            drawLine( x, y, new_x, new_y, g );
-            paintNodeBox( new_x, new_y, desc, g, to_pdf, to_graphics_file );
-        }
-        if ( n.isRoot() ) {
-            paintNodeBox( n.getXcoord(), n.getYcoord(), n, g, to_pdf, to_graphics_file );
-        }
-    }
-
-    final private void paintUnrootedLite( final PhylogenyNode n,
-                                          final double low_angle,
-                                          final double high_angle,
-                                          final Graphics2D g,
-                                          final float urt_ov_factor ) {
-        if ( n.isRoot() ) {
-            final int x_pos = ( int ) ( getVisibleRect().x + getOvXPosition() + ( getOvMaxWidth() / 2 ) );
-            final int y_pos = ( int ) ( getVisibleRect().y + getOvYPosition() + ( getOvMaxHeight() / 2 ) );
-            n.setXSecondary( x_pos );
-            n.setYSecondary( y_pos );
-        }
-        if ( n.isExternal() ) {
-            return;
         }
-        final float num_enclosed = n.getNumberOfExternalNodes();
-        final float x = n.getXSecondary();
-        final float y = n.getYSecondary();
-        double current_angle = low_angle;
-        for( int i = 0; i < n.getNumberOfDescendants(); ++i ) {
-            final PhylogenyNode desc = n.getChildNode( i );
-            final int desc_num_enclosed = desc.getNumberOfExternalNodes();
-            final double arc_size = ( desc_num_enclosed / num_enclosed ) * ( high_angle - low_angle );
-            float length;
-            if ( isPhyHasBranchLengths() && getControlPanel().isDrawPhylogram() ) {
-                if ( desc.getDistanceToParent() < 0 ) {
-                    length = 0;
-                }
-                else {
-                    length = ( float ) ( desc.getDistanceToParent() * urt_ov_factor );
+        if ( getControlPanel().isShowDomainArchitectures() ) {
+            final float ds_factor_width = ( float ) ( _domain_structure_width / _max_original_domain_structure_width );
+            for( final PhylogenyNode node : _phylogeny.getExternalNodes() ) {
+                if ( node.getNodeData().isHasSequence()
+                        && ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) {
+                    final RenderableDomainArchitecture rds = ( RenderableDomainArchitecture ) node.getNodeData()
+                            .getSequence().getDomainArchitecture();
+                    rds.setRenderingFactorWidth( ds_factor_width );
+                    rds.setParameter( _domain_structure_e_value_thr_exp );
                 }
             }
-            else {
-                length = urt_ov_factor;
-            }
-            final double mid_angle = current_angle + ( arc_size / 2 );
-            final float new_x = ( float ) ( x + ( Math.cos( mid_angle ) * length ) );
-            final float new_y = ( float ) ( y + ( Math.sin( mid_angle ) * length ) );
-            desc.setXSecondary( new_x );
-            desc.setYSecondary( new_y );
-            if ( isInFoundNodes( desc ) || isInCurrentExternalNodes( desc ) ) {
-                g.setColor( getColorForFoundNode( desc ) );
-                drawRectFilled( desc.getXSecondary() - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF,
-                                desc.getYSecondary() - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF,
-                                OVERVIEW_FOUND_NODE_BOX_SIZE,
-                                OVERVIEW_FOUND_NODE_BOX_SIZE,
-                                g );
-                g.setColor( getTreeColorSet().getOvColor() );
-            }
-            paintUnrootedLite( desc, current_angle, current_angle + arc_size, g, urt_ov_factor );
-            current_angle += arc_size;
-            drawLine( x, y, new_x, new_y, g );
         }
     }
 
-    final private void pasteSubtree( final PhylogenyNode node ) {
-        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
-            errorMessageNoCutCopyPasteInUnrootedDisplay();
-            return;
-        }
-        if ( ( getCutOrCopiedTree() == null ) || getCutOrCopiedTree().isEmpty() ) {
-            JOptionPane.showMessageDialog( this,
-                                           "No tree in buffer (need to copy or cut a subtree first)",
-                                           "Attempt to paste with empty buffer",
-                                           JOptionPane.ERROR_MESSAGE );
-            return;
-        }
-        final String label = createASimpleTextRepresentationOfANode( getCutOrCopiedTree().getRoot() );
-        final Object[] options = { "As sibling", "As descendant", "Cancel" };
-        final int r = JOptionPane.showOptionDialog( this,
-                                                    "How to paste subtree" + label + "?",
-                                                    "Paste Subtree",
-                                                    JOptionPane.CLOSED_OPTION,
-                                                    JOptionPane.QUESTION_MESSAGE,
-                                                    null,
-                                                    options,
-                                                    options[ 2 ] );
-        boolean paste_as_sibling = true;
-        if ( r == 1 ) {
-            paste_as_sibling = false;
-        }
-        else if ( r != 0 ) {
-            return;
-        }
-        final Phylogeny buffer_phy = getCutOrCopiedTree().copy();
-        buffer_phy.setAllNodesToNotCollapse();
-        PhylogenyMethods.preOrderReId( buffer_phy );
-        buffer_phy.setRooted( true );
-        boolean need_to_show_whole = false;
-        if ( paste_as_sibling ) {
-            if ( node.isRoot() ) {
-                JOptionPane.showMessageDialog( this,
-                                               "Cannot paste sibling to root",
-                                               "Attempt to paste sibling to root",
-                                               JOptionPane.ERROR_MESSAGE );
-                return;
-            }
-            buffer_phy.addAsSibling( node );
-        }
-        else {
-            if ( ( node.getNumberOfExternalNodes() == 1 ) && node.isRoot() ) {
-                need_to_show_whole = true;
-                _phylogeny = buffer_phy;
-            }
-            else {
-                buffer_phy.addAsChild( node );
-            }
-        }
-        if ( getCopiedAndPastedNodes() == null ) {
-            setCopiedAndPastedNodes( new HashSet<Long>() );
-        }
-        final List<PhylogenyNode> nodes = PhylogenyMethods.obtainAllNodesAsList( buffer_phy );
-        final Set<Long> node_ids = new HashSet<Long>( nodes.size() );
-        for( final PhylogenyNode n : nodes ) {
-            node_ids.add( n.getId() );
-        }
-        node_ids.add( node.getId() );
-        getCopiedAndPastedNodes().addAll( node_ids );
-        setNodeInPreorderToNull();
-        _phylogeny.externalNodesHaveChanged();
-        _phylogeny.clearHashIdToNodeMap();
-        _phylogeny.recalculateNumberOfExternalDescendants( true );
-        resetNodeIdToDistToLeafMap();
-        setEdited( true );
-        if ( need_to_show_whole ) {
-            getControlPanel().showWhole();
-        }
-        repaint();
+    final boolean inOv( final MouseEvent e ) {
+        return ( ( e.getX() > ( getVisibleRect().x + getOvXPosition() + 1 ) )
+                && ( e.getX() < ( ( getVisibleRect().x + getOvXPosition() + getOvMaxWidth() ) - 1 ) )
+                && ( e.getY() > ( getVisibleRect().y + getOvYPosition() + 1 ) ) && ( e.getY() < ( ( getVisibleRect().y
+                + getOvYPosition() + getOvMaxHeight() ) - 1 ) ) );
     }
 
-    private final StringBuffer propertiesToString( final PhylogenyNode node ) {
-        final PropertiesMap properties = node.getNodeData().getProperties();
-        final StringBuffer sb = new StringBuffer();
-        boolean first = true;
-        for( final String ref : properties.getPropertyRefs() ) {
-            if ( first ) {
-                first = false;
-            }
-            else {
-                sb.append( " " );
-            }
-            final Property p = properties.getProperty( ref );
-            sb.append( TreePanelUtil.getPartAfterColon( p.getRef() ) );
-            sb.append( "=" );
-            sb.append( p.getValue() );
-            if ( !ForesterUtil.isEmpty( p.getUnit() ) ) {
-                sb.append( TreePanelUtil.getPartAfterColon( p.getUnit() ) );
-            }
-        }
-        return sb;
+    final boolean inOvRectangle( final MouseEvent e ) {
+        return ( ( e.getX() >= ( getOvRectangle().getX() - 1 ) )
+                && ( e.getX() <= ( getOvRectangle().getX() + getOvRectangle().getWidth() + 1 ) )
+                && ( e.getY() >= ( getOvRectangle().getY() - 1 ) ) && ( e.getY() <= ( getOvRectangle().getY()
+                + getOvRectangle().getHeight() + 1 ) ) );
     }
 
-    private void setColor( final Graphics2D g,
-                           final PhylogenyNode node,
-                           final boolean to_graphics_file,
-                           final boolean to_pdf,
-                           final boolean is_in_found_nodes,
-                           final Color default_color ) {
-        if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
-            g.setColor( Color.BLACK );
-        }
-        else if ( is_in_found_nodes ) {
-            g.setColor( getColorForFoundNode( node ) );
-        }
-        else if ( getControlPanel().isUseVisualStyles() && ( node.getNodeData().getNodeVisualData() != null )
-                && ( node.getNodeData().getNodeVisualData().getFontColor() != null ) ) {
-            g.setColor( node.getNodeData().getNodeVisualData().getFontColor() );
-        }
-        else if ( getControlPanel().isColorAccordingToSequence() ) {
-            g.setColor( getSequenceBasedColor( node ) );
-        }
-        else if ( getControlPanel().isColorAccordingToTaxonomy() ) {
-            g.setColor( getTaxonomyBasedColor( node ) );
-        }
-        else if ( getControlPanel().isColorAccordingToAnnotation()
-                && ( node.getNodeData().isHasSequence() && ( node.getNodeData().getSequence().getAnnotations() != null ) && ( !node
-                        .getNodeData().getSequence().getAnnotations().isEmpty() ) ) ) {
-            g.setColor( calculateColorForAnnotation( node.getNodeData().getSequence().getAnnotations() ) );
-        }
-        else if ( getOptions().isColorLabelsSameAsParentBranch() && getControlPanel().isUseVisualStyles()
-                && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) {
-            g.setColor( PhylogenyMethods.getBranchColorValue( node ) );
-        }
-        else if ( to_pdf ) {
-            g.setColor( Color.BLACK );
-        }
-        else {
-            g.setColor( default_color );
-        }
+    final boolean isApplet() {
+        return getMainPanel() instanceof MainPanelApplets;
     }
 
-    final private void setCopiedAndPastedNodes( final Set<Long> nodeIds ) {
-        getMainPanel().setCopiedAndPastedNodes( nodeIds );
+    final boolean isCanCollapse() {
+        return ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
     }
 
-    final private void setCutOrCopiedTree( final Phylogeny cut_or_copied_tree ) {
-        getMainPanel().setCutOrCopiedTree( cut_or_copied_tree );
+    final boolean isCanColorSubtree() {
+        return ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
     }
 
-    private boolean setFont( final Graphics2D g, final PhylogenyNode node, final boolean is_in_found_nodes ) {
-        Font visual_font = null;
-        if ( getControlPanel().isUseVisualStyles() && ( node.getNodeData().getNodeVisualData() != null ) ) {
-            visual_font = node.getNodeData().getNodeVisualData().getFont();
-            g.setFont( visual_font != null ? visual_font : getTreeFontSet().getLargeFont() );
-        }
-        else {
-            g.setFont( getTreeFontSet().getLargeFont() );
-        }
-        if ( is_in_found_nodes ) {
-            g.setFont( g.getFont().deriveFont( Font.BOLD ) );
-        }
-        return visual_font != null;
+    final boolean isCanCopy() {
+        return ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && getOptions().isEditable() );
     }
 
-    final private void setInOv( final boolean in_ov ) {
-        _in_ov = in_ov;
+    final boolean isCanCut( final PhylogenyNode node ) {
+        return ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && getOptions().isEditable() && !node
+                .isRoot() );
     }
 
-    final private void setOvMaxHeight( final float ov_max_height ) {
-        _ov_max_height = ov_max_height;
+    final boolean isCanDelete() {
+        return ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && getOptions().isEditable() );
     }
 
-    final private void setOvMaxWidth( final float ov_max_width ) {
-        _ov_max_width = ov_max_width;
+    final boolean isCanPaste() {
+        return ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && getOptions().isEditable()
+                && ( getCutOrCopiedTree() != null ) && !getCutOrCopiedTree().isEmpty() );
     }
 
-    final private void setOvXcorrectionFactor( final float f ) {
-        _ov_x_correction_factor = f;
+    final boolean isCanReroot() {
+        return ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( _subtree_index < 1 ) );
     }
 
-    final private void setOvXDistance( final float ov_x_distance ) {
-        _ov_x_distance = ov_x_distance;
+    final boolean isCanSubtree( final PhylogenyNode node ) {
+        return ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && !node.isExternal() && ( !node
+                .isRoot() || ( _subtree_index > 0 ) ) );
     }
 
-    final private void setOvXPosition( final int ov_x_position ) {
-        _ov_x_position = ov_x_position;
+    final boolean isCurrentTreeIsSubtree() {
+        return ( _subtree_index > 0 );
     }
 
-    final private void setOvYDistance( final float ov_y_distance ) {
-        _ov_y_distance = ov_y_distance;
+    final boolean isEdited() {
+        return _edited;
     }
 
-    final private void setOvYPosition( final int ov_y_position ) {
-        _ov_y_position = ov_y_position;
+    final boolean isInOvRect() {
+        return _in_ov_rect;
     }
 
-    final private void setOvYStart( final int ov_y_start ) {
-        _ov_y_start = ov_y_start;
+    final boolean isOvOn() {
+        return _ov_on;
     }
 
-    final private void setScaleDistance( final double scale_distance ) {
-        _scale_distance = scale_distance;
+    final boolean isPhyHasBranchLengths() {
+        return _phy_has_branch_lengths;
     }
 
-    final private void setScaleLabel( final String scale_label ) {
-        _scale_label = scale_label;
+    final void midpointRoot() {
+        if ( ( _phylogeny == null ) || ( _phylogeny.getNumberOfExternalNodes() < 2 ) ) {
+            return;
+        }
+        if ( !_phylogeny.isRerootable() ) {
+            JOptionPane.showMessageDialog( this,
+                                           "This is not rerootable",
+                                           "Not rerootable",
+                                           JOptionPane.WARNING_MESSAGE );
+            return;
+        }
+        setNodeInPreorderToNull();
+        setWaitCursor();
+        PhylogenyMethods.midpointRoot( _phylogeny );
+        resetNodeIdToDistToLeafMap();
+        setArrowCursor();
+        setEdited( true );
+        repaint();
     }
 
-    private final void setupStroke( final Graphics2D g ) {
-        if ( getYdistance() < 0.0001 ) {
-            g.setStroke( STROKE_0025 );
+    final void mouseClicked( final MouseEvent e ) {
+        if ( getOptions().isShowOverview() && isOvOn() && isInOv() ) {
+            final double w_ratio = getVisibleRect().width / getOvRectangle().getWidth();
+            final double h_ratio = getVisibleRect().height / getOvRectangle().getHeight();
+            double x = ( e.getX() - getVisibleRect().x - getOvXPosition() - ( getOvRectangle().getWidth() / 2.0 ) )
+                    * w_ratio;
+            double y = ( e.getY() - getVisibleRect().y - getOvYPosition() - ( getOvRectangle().getHeight() / 2.0 ) )
+                    * h_ratio;
+            if ( x < 0 ) {
+                x = 0;
+            }
+            if ( y < 0 ) {
+                y = 0;
+            }
+            final double max_x = getWidth() - getVisibleRect().width;
+            final double max_y = getHeight() - getVisibleRect().height;
+            if ( x > max_x ) {
+                x = max_x;
+            }
+            if ( y > max_y ) {
+                y = max_y;
+            }
+            getMainPanel().getCurrentScrollPane().getViewport()
+                    .setViewPosition( new Point( ForesterUtil.roundToInt( x ), ForesterUtil.roundToInt( y ) ) );
+            setInOvRect( true );
+            repaint();
         }
-        if ( getYdistance() < 0.001 ) {
-            g.setStroke( STROKE_005 );
+        else {
+            final PhylogenyNode node = findNode( e.getX(), e.getY() );
+            if ( node != null ) {
+                if ( !node.isRoot() && node.getParent().isCollapse() ) {
+                    return;
+                }
+                _highlight_node = node;
+                // Check if shift key is down
+                if ( ( e.getModifiers() & InputEvent.SHIFT_MASK ) != 0 ) {
+                    // Yes, so add to _found_nodes
+                    if ( getFoundNodes0() == null ) {
+                        setFoundNodes0( new HashSet<Long>() );
+                    }
+                    getFoundNodes0().add( node.getId() );
+                    // Check if control key is down
+                }
+                else if ( ( e.getModifiers() & InputEvent.CTRL_MASK ) != 0 ) {
+                    // Yes, so pop-up menu
+                    displayNodePopupMenu( node, e.getX(), e.getY() );
+                    // Handle unadorned click
+                }
+                else {
+                    // Check for right mouse button
+                    if ( e.getModifiers() == 4 ) {
+                        displayNodePopupMenu( node, e.getX(), e.getY() );
+                    }
+                    else {
+                        // if not in _found_nodes, clear _found_nodes
+                        handleClickToAction( _control_panel.getActionWhenNodeClicked(), node );
+                    }
+                }
+            }
+            else {
+                // no node was clicked
+                _highlight_node = null;
+            }
         }
-        else if ( getYdistance() < 0.01 ) {
-            g.setStroke( STROKE_01 );
+        repaint();
+    }
+
+    final void mouseDragInBrowserPanel( final MouseEvent e ) {
+        setCursor( MOVE_CURSOR );
+        final Point scroll_position = getMainPanel().getCurrentScrollPane().getViewport().getViewPosition();
+        scroll_position.x -= ( e.getX() - getLastDragPointX() );
+        scroll_position.y -= ( e.getY() - getLastDragPointY() );
+        if ( scroll_position.x < 0 ) {
+            scroll_position.x = 0;
         }
-        else if ( getYdistance() < 0.5 ) {
-            g.setStroke( STROKE_025 );
+        else {
+            final int max_x = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getMaximum()
+                    - getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getVisibleAmount();
+            if ( scroll_position.x > max_x ) {
+                scroll_position.x = max_x;
+            }
         }
-        else if ( getYdistance() < 1 ) {
-            g.setStroke( STROKE_05 );
+        if ( scroll_position.y < 0 ) {
+            scroll_position.y = 0;
         }
-        else if ( getYdistance() < 2 ) {
-            g.setStroke( STROKE_075 );
+        else {
+            final int max_y = getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getMaximum()
+                    - getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getVisibleAmount();
+            if ( scroll_position.y > max_y ) {
+                scroll_position.y = max_y;
+            }
         }
-        else if ( ( getYdistance() < 20 ) || !getConfiguration().isAllowThickStrokes() ) {
-            g.setStroke( STROKE_1 );
+        if ( isOvOn() || getOptions().isShowScale() ) {
+            repaint();
+        }
+        getMainPanel().getCurrentScrollPane().getViewport().setViewPosition( scroll_position );
+    }
+
+    final void mouseDragInOvRectangle( final MouseEvent e ) {
+        setCursor( HAND_CURSOR );
+        final double w_ratio = getVisibleRect().width / getOvRectangle().getWidth();
+        final double h_ratio = getVisibleRect().height / getOvRectangle().getHeight();
+        final Point scroll_position = getMainPanel().getCurrentScrollPane().getViewport().getViewPosition();
+        double dx = ( ( w_ratio * e.getX() ) - ( w_ratio * getLastDragPointX() ) );
+        double dy = ( ( h_ratio * e.getY() ) - ( h_ratio * getLastDragPointY() ) );
+        scroll_position.x = ForesterUtil.roundToInt( scroll_position.x + dx );
+        scroll_position.y = ForesterUtil.roundToInt( scroll_position.y + dy );
+        if ( scroll_position.x <= 0 ) {
+            scroll_position.x = 0;
+            dx = 0;
         }
         else {
-            g.setStroke( STROKE_2 );
+            final int max_x = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getMaximum()
+                    - getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getVisibleAmount();
+            if ( scroll_position.x >= max_x ) {
+                dx = 0;
+                scroll_position.x = max_x;
+            }
+        }
+        if ( scroll_position.y <= 0 ) {
+            dy = 0;
+            scroll_position.y = 0;
+        }
+        else {
+            final int max_y = getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getMaximum()
+                    - getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getVisibleAmount();
+            if ( scroll_position.y >= max_y ) {
+                dy = 0;
+                scroll_position.y = max_y;
+            }
         }
+        repaint();
+        getMainPanel().getCurrentScrollPane().getViewport().setViewPosition( scroll_position );
+        setLastMouseDragPointX( ( float ) ( e.getX() + dx ) );
+        setLastMouseDragPointY( ( float ) ( e.getY() + dy ) );
     }
 
-    final private void setUpUrtFactor() {
-        final int d = getVisibleRect().width < getVisibleRect().height ? getVisibleRect().width
-                : getVisibleRect().height;
-        if ( isPhyHasBranchLengths() && getControlPanel().isDrawPhylogram() ) {
-            setUrtFactor( ( float ) ( d / ( 2 * getMaxDistanceToRoot() ) ) );
+    final void mouseMoved( final MouseEvent e ) {
+        requestFocusInWindow();
+        if ( _current_external_nodes != null ) {
+            _current_external_nodes = null;
+            repaint();
+        }
+        if ( getControlPanel().isNodeDescPopup() ) {
+            if ( _node_desc_popup != null ) {
+                _node_desc_popup.hide();
+                _node_desc_popup = null;
+            }
+        }
+        if ( getOptions().isShowOverview() && isOvOn() ) {
+            if ( inOvVirtualRectangle( e ) ) {
+                if ( !isInOvRect() ) {
+                    setInOvRect( true );
+                    repaint();
+                }
+            }
+            else {
+                if ( isInOvRect() ) {
+                    setInOvRect( false );
+                    repaint();
+                }
+            }
+        }
+        if ( inOv( e ) && getOptions().isShowOverview() && isOvOn() ) {
+            if ( !isInOv() ) {
+                setInOv( true );
+            }
         }
         else {
-            final int max_depth = _circ_max_depth;
-            if ( max_depth > 0 ) {
-                setUrtFactor( d / ( 2 * max_depth ) );
+            if ( isInOv() ) {
+                setInOv( false );
+            }
+            final PhylogenyNode node = findNode( e.getX(), e.getY() );
+            if ( ( node != null ) && ( node.isRoot() || !node.getParent().isCollapse() ) ) {
+                if ( ( getControlPanel().getActionWhenNodeClicked() == NodeClickAction.GET_EXT_DESC_DATA ) ) {
+                    for( final PhylogenyNode n : node.getAllExternalDescendants() ) {
+                        addToCurrentExternalNodes( n.getId() );
+                    }
+                    setCursor( HAND_CURSOR );
+                    repaint();
+                }
+                else if ( ( getControlPanel().getActionWhenNodeClicked() == NodeClickAction.CUT_SUBTREE )
+                        || ( getControlPanel().getActionWhenNodeClicked() == NodeClickAction.COPY_SUBTREE )
+                        || ( getControlPanel().getActionWhenNodeClicked() == NodeClickAction.PASTE_SUBTREE )
+                        || ( getControlPanel().getActionWhenNodeClicked() == NodeClickAction.DELETE_NODE_OR_SUBTREE )
+                        || ( getControlPanel().getActionWhenNodeClicked() == NodeClickAction.REROOT )
+                        || ( getControlPanel().getActionWhenNodeClicked() == NodeClickAction.ADD_NEW_NODE ) ) {
+                    setCursor( CUT_CURSOR );
+                }
+                else {
+                    setCursor( HAND_CURSOR );
+                    if ( getControlPanel().isNodeDescPopup() ) {
+                        showNodeDataPopup( e, node );
+                    }
+                }
             }
             else {
-                setUrtFactor( d / 2 );
+                setCursor( ARROW_CURSOR );
             }
         }
-        setUrtFactorOv( getUrtFactor() );
     }
 
-    final private void setUrtFactor( final float urt_factor ) {
-        _urt_factor = urt_factor;
+    final void mouseReleasedInBrowserPanel( final MouseEvent e ) {
+        setCursor( ARROW_CURSOR );
     }
 
-    final private void setUrtFactorOv( final float urt_factor_ov ) {
-        _urt_factor_ov = urt_factor_ov;
+    final void multiplyUrtFactor( final float f ) {
+        _urt_factor *= f;
     }
 
-    private void showExtDescNodeData( final PhylogenyNode node ) {
-        final List<String> data = new ArrayList<String>();
-        final List<PhylogenyNode> nodes = node.getAllExternalDescendants();
-        if ( ( getFoundNodes0() != null ) || ( getFoundNodes1() != null ) ) {
-            for( final PhylogenyNode n : getFoundNodesAsListOfPhylogenyNodes() ) {
-                if ( !nodes.contains( n ) ) {
-                    nodes.add( n );
-                }
-            }
+    final JApplet obtainApplet() {
+        return ( ( MainPanelApplets ) getMainPanel() ).getApplet();
+    }
+
+    final void paintBranchCircular( final PhylogenyNode p,
+                                    final PhylogenyNode c,
+                                    final Graphics2D g,
+                                    final boolean radial_labels,
+                                    final boolean to_pdf,
+                                    final boolean to_graphics_file ) {
+        final double angle = _urt_nodeid_angle_map.get( c.getId() );
+        final double root_x = _root.getXcoord();
+        final double root_y = _root.getYcoord();
+        final double dx = root_x - p.getXcoord();
+        final double dy = root_y - p.getYcoord();
+        final double parent_radius = Math.sqrt( ( dx * dx ) + ( dy * dy ) );
+        final double arc = ( _urt_nodeid_angle_map.get( p.getId() ) ) - angle;
+        assignGraphicsForBranchWithColorForParentBranch( c, false, g, to_pdf, to_graphics_file );
+        if ( ( c.isFirstChildNode() || c.isLastChildNode() )
+                && ( ( Math.abs( parent_radius * arc ) > 1.5 ) || to_pdf || to_graphics_file ) ) {
+            final double r2 = 2.0 * parent_radius;
+            drawArc( root_x - parent_radius, root_y - parent_radius, r2, r2, ( -angle - arc ), arc, g );
         }
-        for( final PhylogenyNode n : nodes ) {
-            switch ( getOptions().getExtDescNodeDataToReturn() ) {
-                case NODE_NAME:
-                    if ( !ForesterUtil.isEmpty( n.getName() ) ) {
-                        data.add( n.getName() );
-                    }
-                    break;
-                case SEQUENCE_NAME:
-                    if ( n.getNodeData().isHasSequence()
-                            && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getName() ) ) {
-                        data.add( n.getNodeData().getSequence().getName() );
-                    }
-                    break;
-                case GENE_NAME:
-                    if ( n.getNodeData().isHasSequence()
-                            && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getGeneName() ) ) {
-                        data.add( n.getNodeData().getSequence().getGeneName() );
-                    }
-                    break;
-                case SEQUENCE_SYMBOL:
-                    if ( n.getNodeData().isHasSequence()
-                            && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getSymbol() ) ) {
-                        data.add( n.getNodeData().getSequence().getSymbol() );
-                    }
-                    break;
-                case SEQUENCE_MOL_SEQ_FASTA:
-                    final StringBuilder sb = new StringBuilder();
-                    if ( n.getNodeData().isHasSequence()
-                            && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getMolecularSequence() ) ) {
-                        final StringBuilder ann = new StringBuilder();
-                        if ( !ForesterUtil.isEmpty( n.getName() ) ) {
-                            ann.append( n.getName() );
-                            ann.append( "|" );
-                        }
-                        if ( !ForesterUtil.isEmpty( n.getNodeData().getSequence().getSymbol() ) ) {
-                            ann.append( "SYM=" );
-                            ann.append( n.getNodeData().getSequence().getSymbol() );
-                            ann.append( "|" );
-                        }
-                        if ( !ForesterUtil.isEmpty( n.getNodeData().getSequence().getName() ) ) {
-                            ann.append( "NAME=" );
-                            ann.append( n.getNodeData().getSequence().getName() );
-                            ann.append( "|" );
-                        }
-                        if ( !ForesterUtil.isEmpty( n.getNodeData().getSequence().getGeneName() ) ) {
-                            ann.append( "GN=" );
-                            ann.append( n.getNodeData().getSequence().getGeneName() );
-                            ann.append( "|" );
-                        }
-                        if ( n.getNodeData().getSequence().getAccession() != null ) {
-                            ann.append( "ACC=" );
-                            ann.append( n.getNodeData().getSequence().getAccession().asText() );
-                            ann.append( "|" );
-                        }
-                        if ( n.getNodeData().isHasTaxonomy() ) {
-                            if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
-                                ann.append( "TAXID=" );
-                                ann.append( n.getNodeData().getTaxonomy().getTaxonomyCode() );
-                                ann.append( "|" );
-                            }
-                            if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) {
-                                ann.append( "SN=" );
-                                ann.append( n.getNodeData().getTaxonomy().getScientificName() );
-                                ann.append( "|" );
-                            }
-                        }
-                        String ann_str;
-                        if ( ann.charAt( ann.length() - 1 ) == '|' ) {
-                            ann_str = ann.substring( 0, ann.length() - 1 );
-                        }
-                        else {
-                            ann_str = ann.toString();
-                        }
-                        sb.append( SequenceWriter.toFasta( ann_str, n.getNodeData().getSequence()
-                                                           .getMolecularSequence(), 60 ) );
-                        data.add( sb.toString() );
-                    }
-                    break;
-                case SEQUENCE_ACC:
-                    if ( n.getNodeData().isHasSequence() && ( n.getNodeData().getSequence().getAccession() != null )
-                            && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getAccession().toString() ) ) {
-                        data.add( n.getNodeData().getSequence().getAccession().toString() );
-                    }
-                    break;
-                case TAXONOMY_SCIENTIFIC_NAME:
-                    if ( n.getNodeData().isHasTaxonomy()
-                            && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) {
-                        data.add( n.getNodeData().getTaxonomy().getScientificName() );
-                    }
-                    break;
-                case TAXONOMY_CODE:
-                    if ( n.getNodeData().isHasTaxonomy()
-                            && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
-                        data.add( n.getNodeData().getTaxonomy().getTaxonomyCode() );
-                    }
-                    break;
-                case DOMAINS_ALL:
-                case DOMAINS_COLLAPSED_PER_PROTEIN:
-                    if ( n.getNodeData().isHasSequence()
-                            && ( n.getNodeData().getSequence().getDomainArchitecture() != null ) ) {
-                        final DomainArchitecture da = n.getNodeData().getSequence().getDomainArchitecture();
-                        final Set<String> s = new HashSet<String>();
-                        for( int i = 0; i < da.getDomains().size(); ++i ) {
-                            final ProteinDomain d = da.getDomain( i );
-                            if ( d.getConfidence() <= Math.pow( 10, getDomainStructureEvalueThresholdExp() ) ) {
-                                final String name = d.getName();
-                                if ( !( s.contains( name ) ) ) {
-                                    data.add( name );
-                                    if ( getOptions().getExtDescNodeDataToReturn() == NodeDataField.DOMAINS_COLLAPSED_PER_PROTEIN ) {
-                                        s.add( name );
-                                    }
-                                }
-                            }
-                        }
-                    }
-                    break;
-                case SEQ_ANNOTATIONS:
-                    if ( n.getNodeData().isHasSequence() ) {
-                        if ( n.getNodeData().isHasSequence()
-                                && ( n.getNodeData().getSequence().getAnnotations() != null ) ) {
-                            final SortedSet<Annotation> a = n.getNodeData().getSequence().getAnnotations();
-                            for( int i = 0; i < a.size(); ++i ) {
-                                data.add( n.getNodeData().getSequence().getAnnotation( i ).toString() );
-                            }
-                        }
-                    }
-                    break;
-                case GO_TERM_IDS:
-                    if ( n.getNodeData().isHasSequence() ) {
-                        if ( n.getNodeData().isHasSequence()
-                                && ( n.getNodeData().getSequence().getAnnotations() != null ) ) {
-                            final SortedSet<Annotation> a = n.getNodeData().getSequence().getAnnotations();
-                            for( int i = 0; i < a.size(); ++i ) {
-                                final Annotation ann = n.getNodeData().getSequence().getAnnotation( i );
-                                final String ref = ann.getRef();
-                                if ( ref.toUpperCase().startsWith( "GO:" ) ) {
-                                    data.add( ref );
-                                }
-                            }
-                        }
-                    }
-                    break;
-                case UNKNOWN:
-                    TreePanelUtil.showExtDescNodeDataUserSelectedHelper( getControlPanel(), n, data );
-                    break;
-                default:
-                    throw new IllegalArgumentException( "unknown data element: "
-                            + getOptions().getExtDescNodeDataToReturn() );
-            }
-        } // for loop
-        final StringBuilder sb = new StringBuilder();
-        final int size = TreePanelUtil.nodeDataIntoStringBuffer( data, getOptions(), sb );
-        if ( ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.CONSOLE )
-                || ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.BUFFER_ONLY ) ) {
-            if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.CONSOLE ) {
-                System.out.println( sb );
+        drawLine( c.getXcoord(),
+                  c.getYcoord(),
+                  root_x + ( Math.cos( angle ) * parent_radius ),
+                  root_y + ( Math.sin( angle ) * parent_radius ),
+                  g );
+        paintNodeBox( c.getXcoord(), c.getYcoord(), c, g, to_pdf, to_graphics_file );
+        if ( c.isExternal() ) {
+            final boolean is_in_found_nodes = isInFoundNodes0( c ) || isInFoundNodes1( c )
+                    || isInCurrentExternalNodes( c );
+            if ( ( _dynamic_hiding_factor > 1 ) && !is_in_found_nodes
+                    && ( ( _urt_nodeid_index_map.get( c.getId() ) % _dynamic_hiding_factor ) != 1 ) ) {
+                return;
             }
-            if ( sb.length() < 1 ) {
-                clearCurrentExternalNodesDataBuffer();
+            paintNodeDataUnrootedCirc( g, c, to_pdf, to_graphics_file, radial_labels, 0, is_in_found_nodes );
+        }
+    }
+
+    final void paintBranchCircularLite( final PhylogenyNode p, final PhylogenyNode c, final Graphics2D g ) {
+        final double angle = _urt_nodeid_angle_map.get( c.getId() );
+        final double root_x = _root.getXSecondary();
+        final double root_y = _root.getYSecondary();
+        final double dx = root_x - p.getXSecondary();
+        final double dy = root_y - p.getYSecondary();
+        final double arc = ( _urt_nodeid_angle_map.get( p.getId() ) ) - angle;
+        final double parent_radius = Math.sqrt( ( dx * dx ) + ( dy * dy ) );
+        g.setColor( getTreeColorSet().getOvColor() );
+        if ( ( c.isFirstChildNode() || c.isLastChildNode() ) && ( Math.abs( arc ) > 0.02 ) ) {
+            final double r2 = 2.0 * parent_radius;
+            drawArc( root_x - parent_radius, root_y - parent_radius, r2, r2, ( -angle - arc ), arc, g );
+        }
+        drawLine( c.getXSecondary(),
+                  c.getYSecondary(),
+                  root_x + ( Math.cos( angle ) * parent_radius ),
+                  root_y + ( Math.sin( angle ) * parent_radius ),
+                  g );
+        if ( isInFoundNodes( c ) || isInCurrentExternalNodes( c ) ) {
+            g.setColor( getColorForFoundNode( c ) );
+            drawRectFilled( c.getXSecondary() - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF, c.getYSecondary()
+                    - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF, OVERVIEW_FOUND_NODE_BOX_SIZE, OVERVIEW_FOUND_NODE_BOX_SIZE, g );
+        }
+    }
+
+    final void paintCircular( final Phylogeny phy,
+                              final double starting_angle,
+                              final int center_x,
+                              final int center_y,
+                              final int radius,
+                              final Graphics2D g,
+                              final boolean to_pdf,
+                              final boolean to_graphics_file ) {
+        final int circ_num_ext_nodes = phy.getNumberOfExternalNodes() - _collapsed_external_nodeid_set.size();
+        System.out.println( "# collapsed external = " + _collapsed_external_nodeid_set.size() );
+        _root = phy.getRoot();
+        _root.setXcoord( center_x );
+        _root.setYcoord( center_y );
+        final boolean radial_labels = getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL;
+        double current_angle = starting_angle;
+        int i = 0;
+        for( final PhylogenyNodeIterator it = phy.iteratorExternalForward(); it.hasNext(); ) {
+            final PhylogenyNode n = it.next();
+            if ( !n.isCollapse() ) {
+                n.setXcoord( ( float ) ( center_x + ( radius * Math.cos( current_angle ) ) ) );
+                n.setYcoord( ( float ) ( center_y + ( radius * Math.sin( current_angle ) ) ) );
+                _urt_nodeid_angle_map.put( n.getId(), current_angle );
+                _urt_nodeid_index_map.put( n.getId(), i++ );
+                current_angle += ( TWO_PI / circ_num_ext_nodes );
             }
             else {
-                setCurrentExternalNodesDataBuffer( sb );
+                //TODO remove me
+                System.out.println( "is collapse" + n.getName() );
             }
         }
-        else if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.WINODW ) {
-            if ( sb.length() < 1 ) {
-                TreePanelUtil.showInformationMessage( this, "No Appropriate Data (" + obtainTitleForExtDescNodeData()
-                                                      + ")", "Descendants of selected node do not contain selected data" );
-                clearCurrentExternalNodesDataBuffer();
+        paintCirculars( phy.getRoot(), phy, center_x, center_y, radius, radial_labels, g, to_pdf, to_graphics_file );
+        paintNodeBox( _root.getXcoord(), _root.getYcoord(), _root, g, to_pdf, to_graphics_file );
+    }
+
+    final void paintCircularLite( final Phylogeny phy,
+                                  final double starting_angle,
+                                  final int center_x,
+                                  final int center_y,
+                                  final int radius,
+                                  final Graphics2D g ) {
+        final int circ_num_ext_nodes = phy.getNumberOfExternalNodes();
+        _root = phy.getRoot();
+        _root.setXSecondary( center_x );
+        _root.setYSecondary( center_y );
+        double current_angle = starting_angle;
+        for( final PhylogenyNodeIterator it = phy.iteratorExternalForward(); it.hasNext(); ) {
+            final PhylogenyNode n = it.next();
+            n.setXSecondary( ( float ) ( center_x + ( radius * Math.cos( current_angle ) ) ) );
+            n.setYSecondary( ( float ) ( center_y + ( radius * Math.sin( current_angle ) ) ) );
+            _urt_nodeid_angle_map.put( n.getId(), current_angle );
+            current_angle += ( TWO_PI / circ_num_ext_nodes );
+        }
+        paintCircularsLite( phy.getRoot(), phy, center_x, center_y, radius, g );
+    }
+
+    final void paintPhylogeny( final Graphics2D g,
+                               final boolean to_pdf,
+                               final boolean to_graphics_file,
+                               final int graphics_file_width,
+                               final int graphics_file_height,
+                               final int graphics_file_x,
+                               final int graphics_file_y ) {
+        if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
+            return;
+        }
+        if ( _control_panel.isShowSequenceRelations() ) {
+            _query_sequence = _control_panel.getSelectedQuerySequence();
+        }
+        // Color the background
+        if ( !to_pdf ) {
+            final Rectangle r = getVisibleRect();
+            if ( !getOptions().isBackgroundColorGradient() || getOptions().isPrintBlackAndWhite() ) {
+                g.setColor( getTreeColorSet().getBackgroundColor() );
+                if ( !to_graphics_file ) {
+                    g.fill( r );
+                }
+                else {
+                    if ( getOptions().isPrintBlackAndWhite() ) {
+                        g.setColor( Color.WHITE );
+                    }
+                    g.fillRect( graphics_file_x, graphics_file_y, graphics_file_width, graphics_file_height );
+                }
             }
             else {
-                setCurrentExternalNodesDataBuffer( sb );
-                String title;
-                if ( ( getFoundNodes0() != null ) && !getFoundNodes0().isEmpty() ) {
-                    title = ( getOptions().getExtDescNodeDataToReturn() == NodeDataField.UNKNOWN ? "Data"
-                            : obtainTitleForExtDescNodeData() )
-                            + " for "
-                            + data.size()
-                            + " nodes, unique entries: "
-                            + size;
+                if ( !to_graphics_file ) {
+                    g.setPaint( new GradientPaint( r.x, r.y, getTreeColorSet().getBackgroundColor(), r.x, r.y
+                            + r.height, getTreeColorSet().getBackgroundColorGradientBottom() ) );
+                    g.fill( r );
                 }
                 else {
-                    title = ( getOptions().getExtDescNodeDataToReturn() == NodeDataField.UNKNOWN ? "Data"
-                            : obtainTitleForExtDescNodeData() )
-                            + " for "
-                            + data.size()
-                            + "/"
-                            + node.getNumberOfExternalNodes()
-                            + " external descendats of node "
-                            + node
-                            + ", unique entries: " + size;
+                    g.setPaint( new GradientPaint( graphics_file_x,
+                                                   graphics_file_y,
+                                                   getTreeColorSet().getBackgroundColor(),
+                                                   graphics_file_x,
+                                                   graphics_file_y + graphics_file_height,
+                                                   getTreeColorSet().getBackgroundColorGradientBottom() ) );
+                    g.fillRect( graphics_file_x, graphics_file_y, graphics_file_width, graphics_file_height );
                 }
-                final String s = sb.toString().trim();
-                if ( getMainPanel().getMainFrame() == null ) {
-                    // Must be "E" applet version.
-                    final ArchaeopteryxE ae = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
-                    ae.showTextFrame( s, title );
+            }
+            setupStroke( g );
+        }
+        else {
+            g.setStroke( new BasicStroke( getOptions().getPrintLineWidth() ) );
+        }
+        if ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
+                && ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
+            _external_node_index = 0;
+            // Position starting X of tree
+            if ( !_phylogeny.isRooted() /*|| ( _subtree_index > 0 )*/) {
+                _phylogeny.getRoot().setXcoord( TreePanel.MOVE );
+            }
+            else if ( ( _phylogeny.getRoot().getDistanceToParent() > 0.0 ) && getControlPanel().isDrawPhylogram() ) {
+                _phylogeny.getRoot().setXcoord( ( float ) ( TreePanel.MOVE + ( _phylogeny.getRoot()
+                        .getDistanceToParent() * getXcorrectionFactor() ) ) );
+            }
+            else {
+                _phylogeny.getRoot().setXcoord( TreePanel.MOVE + getXdistance() );
+            }
+            // Position starting Y of tree
+            _phylogeny.getRoot().setYcoord( ( getYdistance() * _phylogeny.getRoot().getNumberOfExternalNodes() )
+                    + ( TreePanel.MOVE / 2.0f ) );
+            final int dynamic_hiding_factor = calcDynamicHidingFactor();
+            if ( getControlPanel().isDynamicallyHideData() ) {
+                if ( dynamic_hiding_factor > 1 ) {
+                    getControlPanel().setDynamicHidingIsOn( true );
                 }
                 else {
-                    getMainPanel().getMainFrame().showTextFrame( s, title );
+                    getControlPanel().setDynamicHidingIsOn( false );
+                }
+            }
+            if ( _nodes_in_preorder == null ) {
+                _nodes_in_preorder = new PhylogenyNode[ _phylogeny.getNodeCount() ];
+                int i = 0;
+                for( final PhylogenyNodeIterator it = _phylogeny.iteratorPreorder(); it.hasNext(); ) {
+                    _nodes_in_preorder[ i++ ] = it.next();
+                }
+            }
+            final boolean disallow_shortcutting = ( dynamic_hiding_factor < 40 )
+                    || getControlPanel().isUseVisualStyles() || getOptions().isShowDefaultNodeShapesForMarkedNodes()
+                    || ( ( getFoundNodes0() != null ) && !getFoundNodes0().isEmpty() )
+                    || ( ( getFoundNodes1() != null ) && !getFoundNodes1().isEmpty() )
+                    || ( ( getCurrentExternalNodes() != null ) && !getCurrentExternalNodes().isEmpty() )
+                    || to_graphics_file || to_pdf;
+            for( final PhylogenyNode element : _nodes_in_preorder ) {
+                paintNodeRectangular( g,
+                                      element,
+                                      to_pdf,
+                                      getControlPanel().isDynamicallyHideData() && ( dynamic_hiding_factor > 1 ),
+                                      dynamic_hiding_factor,
+                                      to_graphics_file,
+                                      disallow_shortcutting );
+            }
+            if ( getOptions().isShowScale() && getControlPanel().isDrawPhylogram() && ( getScaleDistance() > 0.0 ) ) {
+                if ( !( to_graphics_file || to_pdf ) ) {
+                    paintScale( g,
+                                getVisibleRect().x,
+                                getVisibleRect().y + getVisibleRect().height,
+                                to_pdf,
+                                to_graphics_file );
+                }
+                else {
+                    paintScale( g, graphics_file_x, graphics_file_y + graphics_file_height, to_pdf, to_graphics_file );
+                }
+            }
+            if ( getOptions().isShowOverview() && isOvOn() && !to_graphics_file && !to_pdf ) {
+                paintPhylogenyLite( g );
+            }
+        }
+        else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
+            if ( getControlPanel().getDynamicallyHideData() != null ) {
+                getControlPanel().setDynamicHidingIsOn( false );
+            }
+            final double angle = getStartingAngle();
+            final boolean radial_labels = getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL;
+            _dynamic_hiding_factor = 0;
+            if ( getControlPanel().isDynamicallyHideData() ) {
+                _dynamic_hiding_factor = ( int ) ( ( getFontMetricsForLargeDefaultFont().getHeight() * 1.5 * getPhylogeny()
+                        .getNumberOfExternalNodes() ) / ( TWO_PI * 10 ) );
+            }
+            if ( getControlPanel().getDynamicallyHideData() != null ) {
+                if ( _dynamic_hiding_factor > 1 ) {
+                    getControlPanel().setDynamicHidingIsOn( true );
+                }
+                else {
+                    getControlPanel().setDynamicHidingIsOn( false );
+                }
+            }
+            paintUnrooted( _phylogeny.getRoot(),
+                           angle,
+                           ( float ) ( angle + ( 2 * Math.PI ) ),
+                           radial_labels,
+                           g,
+                           to_pdf,
+                           to_graphics_file );
+            if ( getOptions().isShowScale() ) {
+                if ( !( to_graphics_file || to_pdf ) ) {
+                    paintScale( g,
+                                getVisibleRect().x,
+                                getVisibleRect().y + getVisibleRect().height,
+                                to_pdf,
+                                to_graphics_file );
+                }
+                else {
+                    paintScale( g, graphics_file_x, graphics_file_y + graphics_file_height, to_pdf, to_graphics_file );
+                }
+            }
+            if ( getOptions().isShowOverview() && isOvOn() && !to_graphics_file && !to_pdf ) {
+                g.setColor( getTreeColorSet().getOvColor() );
+                paintUnrootedLite( _phylogeny.getRoot(),
+                                   angle,
+                                   angle + ( 2 * Math.PI ),
+                                   g,
+                                   ( getUrtFactorOv() / ( getVisibleRect().width / getOvMaxWidth() ) ) );
+                paintOvRectangle( g );
+            }
+        }
+        else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
+            final int radius = ( int ) ( ( Math.min( getPreferredSize().getWidth(), getPreferredSize().getHeight() ) / 2 ) - ( MOVE + getLongestExtNodeInfo() ) );
+            final int d = radius + MOVE + getLongestExtNodeInfo();
+            _dynamic_hiding_factor = 0;
+            if ( getControlPanel().isDynamicallyHideData() && ( radius > 0 ) ) {
+                _dynamic_hiding_factor = ( int ) ( ( getFontMetricsForLargeDefaultFont().getHeight() * 1.5 * getPhylogeny()
+                        .getNumberOfExternalNodes() ) / ( TWO_PI * radius ) );
+            }
+            if ( getControlPanel().getDynamicallyHideData() != null ) {
+                if ( _dynamic_hiding_factor > 1 ) {
+                    getControlPanel().setDynamicHidingIsOn( true );
+                }
+                else {
+                    getControlPanel().setDynamicHidingIsOn( false );
+                }
+            }
+            paintCircular( _phylogeny, getStartingAngle(), d, d, radius > 0 ? radius : 0, g, to_pdf, to_graphics_file );
+            if ( getOptions().isShowOverview() && isOvOn() && !to_graphics_file && !to_pdf ) {
+                final int radius_ov = ( int ) ( getOvMaxHeight() < getOvMaxWidth() ? getOvMaxHeight() / 2
+                        : getOvMaxWidth() / 2 );
+                double x_scale = 1.0;
+                double y_scale = 1.0;
+                int x_pos = getVisibleRect().x + getOvXPosition();
+                int y_pos = getVisibleRect().y + getOvYPosition();
+                if ( getWidth() > getHeight() ) {
+                    x_scale = ( double ) getHeight() / getWidth();
+                    x_pos = ForesterUtil.roundToInt( x_pos / x_scale );
+                }
+                else {
+                    y_scale = ( double ) getWidth() / getHeight();
+                    y_pos = ForesterUtil.roundToInt( y_pos / y_scale );
                 }
+                _at = g.getTransform();
+                g.scale( x_scale, y_scale );
+                paintCircularLite( _phylogeny,
+                                   getStartingAngle(),
+                                   x_pos + radius_ov,
+                                   y_pos + radius_ov,
+                                   ( int ) ( radius_ov - ( getLongestExtNodeInfo() / ( getVisibleRect().width / getOvRectangle()
+                                           .getWidth() ) ) ),
+                                   g );
+                g.setTransform( _at );
+                paintOvRectangle( g );
             }
         }
     }
 
-    final private void showNodeDataPopup( final MouseEvent e, final PhylogenyNode node ) {
-        try {
-            if ( ( node.getName().length() > 0 )
-                    || ( node.getNodeData().isHasTaxonomy() && !TreePanelUtil.isTaxonomyEmpty( node.getNodeData()
-                                                                                               .getTaxonomy() ) )
-                                                                                               || ( node.getNodeData().isHasSequence() && !TreePanelUtil.isSequenceEmpty( node.getNodeData()
-                                                                                                                                                                          .getSequence() ) ) || ( node.getNodeData().isHasDate() )
-                                                                                                                                                                          || ( node.getNodeData().isHasDistribution() ) || node.getBranchData().isHasConfidences() ) {
-                _popup_buffer.setLength( 0 );
-                short lines = 0;
-                if ( node.getName().length() > 0 ) {
-                    lines++;
-                    _popup_buffer.append( node.getName() );
-                }
-                if ( node.getNodeData().isHasTaxonomy()
-                        && !TreePanelUtil.isTaxonomyEmpty( node.getNodeData().getTaxonomy() ) ) {
-                    lines++;
-                    boolean enc_data = false;
-                    final Taxonomy tax = node.getNodeData().getTaxonomy();
-                    if ( _popup_buffer.length() > 0 ) {
-                        _popup_buffer.append( "\n" );
-                    }
-                    if ( !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) {
-                        _popup_buffer.append( "[" );
-                        _popup_buffer.append( tax.getTaxonomyCode() );
-                        _popup_buffer.append( "]" );
-                        enc_data = true;
-                    }
-                    if ( !ForesterUtil.isEmpty( tax.getScientificName() ) ) {
-                        if ( enc_data ) {
-                            _popup_buffer.append( " " );
-                        }
-                        _popup_buffer.append( tax.getScientificName() );
-                        enc_data = true;
-                    }
-                    if ( !ForesterUtil.isEmpty( tax.getCommonName() ) ) {
-                        if ( enc_data ) {
-                            _popup_buffer.append( " (" );
-                        }
-                        else {
-                            _popup_buffer.append( "(" );
-                        }
-                        _popup_buffer.append( tax.getCommonName() );
-                        _popup_buffer.append( ")" );
-                        enc_data = true;
-                    }
-                    if ( !ForesterUtil.isEmpty( tax.getAuthority() ) ) {
-                        if ( enc_data ) {
-                            _popup_buffer.append( " (" );
-                        }
-                        else {
-                            _popup_buffer.append( "(" );
-                        }
-                        _popup_buffer.append( tax.getAuthority() );
-                        _popup_buffer.append( ")" );
-                        enc_data = true;
-                    }
-                    if ( !ForesterUtil.isEmpty( tax.getRank() ) ) {
-                        if ( enc_data ) {
-                            _popup_buffer.append( " [" );
-                        }
-                        else {
-                            _popup_buffer.append( "[" );
-                        }
-                        _popup_buffer.append( tax.getRank() );
-                        _popup_buffer.append( "]" );
-                        enc_data = true;
-                    }
-                    if ( tax.getSynonyms().size() > 0 ) {
-                        if ( enc_data ) {
-                            _popup_buffer.append( " " );
-                        }
-                        _popup_buffer.append( "[" );
-                        int counter = 1;
-                        for( final String syn : tax.getSynonyms() ) {
-                            if ( !ForesterUtil.isEmpty( syn ) ) {
-                                enc_data = true;
-                                _popup_buffer.append( syn );
-                                if ( counter < tax.getSynonyms().size() ) {
-                                    _popup_buffer.append( ", " );
-                                }
-                            }
-                            counter++;
-                        }
-                        _popup_buffer.append( "]" );
-                    }
-                    if ( !enc_data ) {
-                        if ( ( tax.getIdentifier() != null ) && !ForesterUtil.isEmpty( tax.getIdentifier().getValue() ) ) {
-                            if ( !ForesterUtil.isEmpty( tax.getIdentifier().getProvider() ) ) {
-                                _popup_buffer.append( "[" );
-                                _popup_buffer.append( tax.getIdentifier().getProvider() );
-                                _popup_buffer.append( "] " );
-                            }
-                            _popup_buffer.append( tax.getIdentifier().getValue() );
-                        }
-                    }
-                }
-                if ( node.getNodeData().isHasSequence()
-                        && !TreePanelUtil.isSequenceEmpty( node.getNodeData().getSequence() ) ) {
-                    lines++;
-                    boolean enc_data = false;
-                    if ( _popup_buffer.length() > 0 ) {
-                        _popup_buffer.append( "\n" );
-                    }
-                    final Sequence seq = node.getNodeData().getSequence();
-                    if ( seq.getAccession() != null ) {
-                        _popup_buffer.append( "[" );
-                        if ( !ForesterUtil.isEmpty( seq.getAccession().getSource() ) ) {
-                            _popup_buffer.append( seq.getAccession().getSource() );
-                            _popup_buffer.append( ":" );
-                        }
-                        _popup_buffer.append( seq.getAccession().getValue() );
-                        _popup_buffer.append( "]" );
-                        enc_data = true;
-                    }
-                    if ( !ForesterUtil.isEmpty( seq.getSymbol() ) ) {
-                        if ( enc_data ) {
-                            _popup_buffer.append( " [" );
-                        }
-                        else {
-                            _popup_buffer.append( "[" );
-                        }
-                        _popup_buffer.append( seq.getSymbol() );
-                        _popup_buffer.append( "]" );
-                        enc_data = true;
-                    }
-                    if ( !ForesterUtil.isEmpty( seq.getGeneName() ) ) {
-                        if ( enc_data ) {
-                            _popup_buffer.append( " [" );
-                        }
-                        else {
-                            _popup_buffer.append( "[" );
-                        }
-                        _popup_buffer.append( seq.getGeneName() );
-                        _popup_buffer.append( "]" );
-                        enc_data = true;
-                    }
-                    if ( !ForesterUtil.isEmpty( seq.getName() ) ) {
-                        if ( enc_data ) {
-                            _popup_buffer.append( " " );
-                        }
-                        _popup_buffer.append( seq.getName() );
-                    }
-                }
-                if ( node.getNodeData().isHasDate() ) {
-                    lines++;
-                    if ( _popup_buffer.length() > 0 ) {
-                        _popup_buffer.append( "\n" );
-                    }
-                    _popup_buffer.append( node.getNodeData().getDate().asSimpleText() );
-                }
-                if ( node.getNodeData().isHasDistribution() ) {
-                    lines++;
-                    if ( _popup_buffer.length() > 0 ) {
-                        _popup_buffer.append( "\n" );
-                    }
-                    _popup_buffer.append( node.getNodeData().getDistribution().asSimpleText() );
-                }
-                if ( node.getBranchData().isHasConfidences() ) {
-                    final List<Confidence> confs = node.getBranchData().getConfidences();
-                    for( final Confidence confidence : confs ) {
-                        lines++;
-                        if ( _popup_buffer.length() > 0 ) {
-                            _popup_buffer.append( "\n" );
-                        }
-                        if ( !ForesterUtil.isEmpty( confidence.getType() ) ) {
-                            _popup_buffer.append( "[" );
-                            _popup_buffer.append( confidence.getType() );
-                            _popup_buffer.append( "] " );
-                        }
-                        _popup_buffer
-                        .append( FORMATTER_CONFIDENCE.format( ForesterUtil.round( confidence.getValue(),
-                                                                                  getOptions()
-                                                                                  .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
-                        if ( confidence.getStandardDeviation() != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
-                            _popup_buffer.append( " (sd=" );
-                            _popup_buffer.append( FORMATTER_CONFIDENCE.format( ForesterUtil.round( confidence
-                                                                                                   .getStandardDeviation(), getOptions()
-                                                                                                   .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
-                            _popup_buffer.append( ")" );
-                        }
-                    }
-                }
-                if ( node.getNodeData().isHasProperties() ) {
-                    final PropertiesMap properties = node.getNodeData().getProperties();
-                    for( final String ref : properties.getPropertyRefs() ) {
-                        _popup_buffer.append( "\n" );
-                        final Property p = properties.getProperty( ref );
-                        _popup_buffer.append( TreePanelUtil.getPartAfterColon( p.getRef() ) );
-                        _popup_buffer.append( "=" );
-                        _popup_buffer.append( p.getValue() );
-                        if ( !ForesterUtil.isEmpty( p.getUnit() ) ) {
-                            _popup_buffer.append( TreePanelUtil.getPartAfterColon( p.getUnit() ) );
-                        }
-                    }
-                }
-                if ( _popup_buffer.length() > 0 ) {
-                    if ( !getConfiguration().isUseNativeUI() ) {
-                        _rollover_popup
-                        .setBorder( BorderFactory.createLineBorder( getTreeColorSet().getBranchColor() ) );
-                        _rollover_popup.setBackground( getTreeColorSet().getBackgroundColor() );
-                        if ( isInFoundNodes0( node ) && !isInFoundNodes1( node ) ) {
-                            _rollover_popup.setForeground( getTreeColorSet().getFoundColor0() );
-                        }
-                        else if ( !isInFoundNodes0( node ) && isInFoundNodes1( node ) ) {
-                            _rollover_popup.setForeground( getTreeColorSet().getFoundColor1() );
-                        }
-                        else if ( isInFoundNodes0( node ) && isInFoundNodes1( node ) ) {
-                            _rollover_popup.setForeground( getTreeColorSet().getFoundColor0and1() );
-                        }
-                        else {
-                            _rollover_popup.setForeground( getTreeColorSet().getSequenceColor() );
-                        }
-                    }
-                    else {
-                        _rollover_popup.setBorder( BorderFactory.createLineBorder( Color.BLACK ) );
-                    }
-                    _rollover_popup.setText( _popup_buffer.toString() );
-                    _node_desc_popup = PopupFactory.getSharedInstance().getPopup( null,
-                                                                                  _rollover_popup,
-                                                                                  e.getLocationOnScreen().x + 10,
-                                                                                  e.getLocationOnScreen().y
-                                                                                  - ( lines * 20 ) );
-                    _node_desc_popup.show();
-                }
+    final void recalculateMaxDistanceToRoot() {
+        _max_distance_to_root = PhylogenyMethods.calculateMaxDistanceToRoot( getPhylogeny() );
+    }
+
+    /**
+     * Remove all edit-node frames
+     */
+    final void removeAllEditNodeJFrames() {
+        for( int i = 0; i <= ( TreePanel.MAX_NODE_FRAMES - 1 ); i++ ) {
+            if ( _node_frames[ i ] != null ) {
+                _node_frames[ i ].dispose();
+                _node_frames[ i ] = null;
+            }
+        }
+        _node_frame_index = 0;
+    }
+
+    /**
+     * Remove a node-edit frame.
+     */
+    final void removeEditNodeFrame( final int i ) {
+        _node_frame_index--;
+        _node_frames[ i ] = null;
+        if ( i < _node_frame_index ) {
+            for( int j = 0; j < ( _node_frame_index - 1 ); j++ ) {
+                _node_frames[ j ] = _node_frames[ j + 1 ];
+            }
+            _node_frames[ _node_frame_index ] = null;
+        }
+    }
+
+    final void reRoot( final PhylogenyNode node ) {
+        if ( !getPhylogeny().isRerootable() ) {
+            JOptionPane.showMessageDialog( this,
+                                           "This is not rerootable",
+                                           "Not rerootable",
+                                           JOptionPane.WARNING_MESSAGE );
+            return;
+        }
+        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
+            JOptionPane.showMessageDialog( this,
+                                           "Cannot reroot in unrooted display type",
+                                           "Attempt to reroot tree in unrooted display",
+                                           JOptionPane.WARNING_MESSAGE );
+            return;
+        }
+        getPhylogeny().reRoot( node );
+        getPhylogeny().recalculateNumberOfExternalDescendants( true );
+        resetNodeIdToDistToLeafMap();
+        setNodeInPreorderToNull();
+        resetPreferredSize();
+        getMainPanel().adjustJScrollPane();
+        setEdited( true );
+        repaint();
+        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
+            getControlPanel().showWhole();
+        }
+    }
+
+    final void resetNodeIdToDistToLeafMap() {
+        _nodeid_dist_to_leaf = new HashMap<Long, Short>();
+    }
+
+    final void resetPreferredSize() {
+        if ( ( getPhylogeny() == null ) || getPhylogeny().isEmpty() ) {
+            return;
+        }
+        int x = 0;
+        int y = 0;
+        y = TreePanel.MOVE
+                + ForesterUtil.roundToInt( getYdistance() * getPhylogeny().getRoot().getNumberOfExternalNodes() * 2 );
+        if ( getControlPanel().isDrawPhylogram() ) {
+            x = TreePanel.MOVE
+                    + getLongestExtNodeInfo()
+                    + ForesterUtil
+                            .roundToInt( ( getXcorrectionFactor() * getPhylogeny().getHeight() ) + getXdistance() );
+        }
+        else {
+            if ( !isNonLinedUpCladogram() && !isUniformBranchLengthsForCladogram() ) {
+                x = TreePanel.MOVE
+                        + getLongestExtNodeInfo()
+                        + ForesterUtil.roundToInt( getXdistance()
+                                * ( getPhylogeny().getRoot().getNumberOfExternalNodes() + 2 ) );
+            }
+            else {
+                x = TreePanel.MOVE
+                        + getLongestExtNodeInfo()
+                        + ForesterUtil.roundToInt( getXdistance()
+                                * ( PhylogenyMethods.calculateMaxDepth( getPhylogeny() ) + 1 ) );
+            }
+        }
+        setPreferredSize( new Dimension( x, y ) );
+    }
+
+    final void selectNode( final PhylogenyNode node ) {
+        if ( ( getFoundNodes0() != null ) && getFoundNodes0().contains( node.getId() ) ) {
+            getFoundNodes0().remove( node.getId() );
+            getControlPanel().setSearchFoundCountsOnLabel0( getFoundNodes0().size() );
+            if ( getFoundNodes0().size() < 1 ) {
+                getControlPanel().searchReset0();
+            }
+        }
+        else {
+            getControlPanel().getSearchFoundCountsLabel0().setVisible( true );
+            getControlPanel().getSearchResetButton0().setEnabled( true );
+            getControlPanel().getSearchResetButton0().setVisible( true );
+            if ( getFoundNodes0() == null ) {
+                setFoundNodes0( new HashSet<Long>() );
+            }
+            getFoundNodes0().add( node.getId() );
+            getControlPanel().setSearchFoundCountsOnLabel0( getFoundNodes0().size() );
+        }
+    }
+
+    final void setArrowCursor() {
+        setCursor( ARROW_CURSOR );
+        repaint();
+    }
+
+    final void setControlPanel( final ControlPanel atv_control ) {
+        _control_panel = atv_control;
+    }
+
+    void setCurrentExternalNodesDataBuffer( final StringBuilder sb ) {
+        increaseCurrentExternalNodesDataBufferChangeCounter();
+        _current_external_nodes_data_buffer = sb;
+    }
+
+    final void setFoundNodes0( final Set<Long> found_nodes ) {
+        _found_nodes_0 = found_nodes;
+    }
+
+    final void setFoundNodes1( final Set<Long> found_nodes ) {
+        _found_nodes_1 = found_nodes;
+    }
+
+    final void setInOvRect( final boolean in_ov_rect ) {
+        _in_ov_rect = in_ov_rect;
+    }
+
+    final void setLargeFonts() {
+        getTreeFontSet().largeFonts();
+    }
+
+    final void setLastMouseDragPointX( final float x ) {
+        _last_drag_point_x = x;
+    }
+
+    final void setLastMouseDragPointY( final float y ) {
+        _last_drag_point_y = y;
+    }
+
+    final void setMediumFonts() {
+        getTreeFontSet().mediumFonts();
+    }
+
+    final void setNodeInPreorderToNull() {
+        _nodes_in_preorder = null;
+    }
+
+    final void setOvOn( final boolean ov_on ) {
+        _ov_on = ov_on;
+    }
+
+    final void setPhylogenyGraphicsType( final PHYLOGENY_GRAPHICS_TYPE graphics_type ) {
+        _graphics_type = graphics_type;
+        setTextAntialias();
+    }
+
+    final void setSmallFonts() {
+        getTreeFontSet().smallFonts();
+    }
+
+    final void setStartingAngle( final double starting_angle ) {
+        _urt_starting_angle = starting_angle;
+    }
+
+    void setStatisticsForExpressionValues( final DescriptiveStatistics statistics_for_expression_values ) {
+        _statistics_for_vector_data = statistics_for_expression_values;
+    }
+
+    final void setSuperTinyFonts() {
+        getTreeFontSet().superTinyFonts();
+    }
+
+    final void setTextAntialias() {
+        if ( ( _phylogeny != null ) && !_phylogeny.isEmpty() ) {
+            if ( _phylogeny.getNumberOfExternalNodes() <= LIMIT_FOR_HQ_RENDERING ) {
+                _rendering_hints.put( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY );
             }
+            else {
+                _rendering_hints.put( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED );
+            }
+        }
+        if ( getMainPanel().getOptions().isAntialiasScreen() ) {
+            _rendering_hints.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
+            // try {
+            _rendering_hints.put( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB );
+            // }
+            // catch ( final Throwable e ) {
+            //    _rendering_hints.put( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON );
+            //}
+        }
+        else {
+            _rendering_hints.put( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF );
+            _rendering_hints.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
+        }
+    }
+
+    final void setTinyFonts() {
+        getTreeFontSet().tinyFonts();
+    }
+
+    final void setTreeFile( final File treefile ) {
+        _treefile = treefile;
+    }
+
+    final void setXcorrectionFactor( final float f ) {
+        _x_correction_factor = f;
+    }
+
+    final void setXdistance( final float x ) {
+        _x_distance = x;
+    }
+
+    final void setYdistance( final float y ) {
+        _y_distance = y;
+    }
+
+    final void sortDescendants( final PhylogenyNode node ) {
+        if ( !node.isExternal() ) {
+            DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
+            if ( getControlPanel().isShowTaxonomyScientificNames() || getControlPanel().isShowTaxonomyCode() ) {
+                pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
+            }
+            else if ( getControlPanel().isShowSeqNames() || getControlPanel().isShowSeqSymbols()
+                    || getControlPanel().isShowGeneNames() ) {
+                pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
+            }
+            PhylogenyMethods.sortNodeDescendents( node, pri );
+            setNodeInPreorderToNull();
+            _phylogeny.externalNodesHaveChanged();
+            _phylogeny.clearHashIdToNodeMap();
+            _phylogeny.recalculateNumberOfExternalDescendants( true );
+            resetNodeIdToDistToLeafMap();
+            setEdited( true );
+        }
+        repaint();
+    }
+
+    final void subTree( final PhylogenyNode node ) {
+        if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
+            JOptionPane.showMessageDialog( this,
+                                           "Cannot get a sub/super tree in unrooted display",
+                                           "Attempt to get sub/super tree in unrooted display",
+                                           JOptionPane.WARNING_MESSAGE );
+            return;
+        }
+        if ( node.isExternal() ) {
+            JOptionPane.showMessageDialog( this,
+                                           "Cannot get a subtree of a external node",
+                                           "Attempt to get subtree of external node",
+                                           JOptionPane.WARNING_MESSAGE );
+            return;
+        }
+        if ( node.isRoot() && !isCurrentTreeIsSubtree() ) {
+            JOptionPane.showMessageDialog( this,
+                                           "Cannot get a subtree of the root node",
+                                           "Attempt to get subtree of root node",
+                                           JOptionPane.WARNING_MESSAGE );
+            return;
         }
-        catch ( final Exception ex ) {
-            // Do nothing.
+        setNodeInPreorderToNull();
+        if ( !node.isExternal() && !node.isRoot() && ( _subtree_index <= ( TreePanel.MAX_SUBTREES - 1 ) ) ) {
+            _sub_phylogenies[ _subtree_index ] = _phylogeny;
+            _sub_phylogenies_temp_roots[ _subtree_index ] = node;
+            ++_subtree_index;
+            _phylogeny = TreePanelUtil.subTree( node, _phylogeny );
+            updateSubSuperTreeButton();
+        }
+        else if ( node.isRoot() && isCurrentTreeIsSubtree() ) {
+            superTree();
         }
+        _main_panel.getControlPanel().showWhole();
+        repaint();
     }
 
-    final private void showNodeEditFrame( final PhylogenyNode n ) {
-        if ( _node_frame_index < TreePanel.MAX_NODE_FRAMES ) {
-            // pop up edit box for single node
-            _node_frames[ _node_frame_index ] = new NodeFrame( n, _phylogeny, this, _node_frame_index, "" );
-            _node_frame_index++;
+    final void superTree() {
+        setNodeInPreorderToNull();
+        final PhylogenyNode temp_root = _sub_phylogenies_temp_roots[ _subtree_index - 1 ];
+        for( final PhylogenyNode n : temp_root.getDescendants() ) {
+            n.setParent( temp_root );
         }
-        else {
-            JOptionPane.showMessageDialog( this, "too many node windows are open" );
+        _sub_phylogenies[ _subtree_index ] = null;
+        _sub_phylogenies_temp_roots[ _subtree_index ] = null;
+        _phylogeny = _sub_phylogenies[ --_subtree_index ];
+        updateSubSuperTreeButton();
+    }
+
+    final void swap( final PhylogenyNode node ) {
+        if ( node.isExternal() || ( node.getNumberOfDescendants() < 2 ) ) {
+            return;
+        }
+        if ( node.getNumberOfDescendants() > 2 ) {
+            JOptionPane.showMessageDialog( this,
+                                           "Cannot swap descendants of nodes with more than 2 descendants",
+                                           "Cannot swap descendants",
+                                           JOptionPane.ERROR_MESSAGE );
+            return;
+        }
+        if ( !node.isExternal() ) {
+            node.swapChildren();
+            setNodeInPreorderToNull();
+            _phylogeny.externalNodesHaveChanged();
+            _phylogeny.clearHashIdToNodeMap();
+            _phylogeny.recalculateNumberOfExternalDescendants( true );
+            resetNodeIdToDistToLeafMap();
+            setEdited( true );
         }
+        repaint();
     }
 
-    final private void showNodeFrame( final PhylogenyNode n ) {
-        if ( _node_frame_index < TreePanel.MAX_NODE_FRAMES ) {
-            // pop up edit box for single node
-            _node_frames[ _node_frame_index ] = new NodeFrame( n, _phylogeny, this, _node_frame_index );
-            _node_frame_index++;
+    final void taxColor() {
+        if ( ( _phylogeny == null ) || ( _phylogeny.getNumberOfExternalNodes() < 2 ) ) {
+            return;
         }
-        else {
-            JOptionPane.showMessageDialog( this, "too many node windows are open" );
+        setWaitCursor();
+        TreePanelUtil.colorPhylogenyAccordingToExternalTaxonomy( _phylogeny, this );
+        _control_panel.setColorBranches( true );
+        if ( _control_panel.getUseVisualStylesCb() != null ) {
+            _control_panel.getUseVisualStylesCb().setSelected( true );
         }
+        setEdited( true );
+        setArrowCursor();
+        repaint();
     }
 
-    final private void switchDisplaygetPhylogenyGraphicsType() {
-        switch ( getPhylogenyGraphicsType() ) {
-            case RECTANGULAR:
-                setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
-                getOptions().setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
-                break;
-            case EURO_STYLE:
-                setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
-                getOptions().setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
-                break;
-            case ROUNDED:
-                setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
-                getOptions().setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
-                break;
-            case CURVED:
-                setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
-                getOptions().setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
-                break;
-            case TRIANGULAR:
-                setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
-                getOptions().setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
-                break;
-            case CONVEX:
-                setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
-                getOptions().setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
+    final void updateOvSettings() {
+        switch ( getOptions().getOvPlacement() ) {
+            case LOWER_LEFT:
+                setOvXPosition( OV_BORDER );
+                setOvYPosition( ForesterUtil.roundToInt( getVisibleRect().height - OV_BORDER - getOvMaxHeight() ) );
+                setOvYStart( ForesterUtil.roundToInt( getOvYPosition() + ( getOvMaxHeight() / 2 ) ) );
                 break;
-            case UNROOTED:
-                setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
-                getOptions().setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
+            case LOWER_RIGHT:
+                setOvXPosition( ForesterUtil.roundToInt( getVisibleRect().width - OV_BORDER - getOvMaxWidth() ) );
+                setOvYPosition( ForesterUtil.roundToInt( getVisibleRect().height - OV_BORDER - getOvMaxHeight() ) );
+                setOvYStart( ForesterUtil.roundToInt( getOvYPosition() + ( getOvMaxHeight() / 2 ) ) );
                 break;
-            case CIRCULAR:
-                setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
-                getOptions().setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
+            case UPPER_RIGHT:
+                setOvXPosition( ForesterUtil.roundToInt( getVisibleRect().width - OV_BORDER - getOvMaxWidth() ) );
+                setOvYPosition( OV_BORDER );
+                setOvYStart( ForesterUtil.roundToInt( OV_BORDER + ( getOvMaxHeight() / 2 ) ) );
                 break;
             default:
-                throw new RuntimeException( "unkwnown display type: " + getPhylogenyGraphicsType() );
+                setOvXPosition( OV_BORDER );
+                setOvYPosition( OV_BORDER );
+                setOvYStart( ForesterUtil.roundToInt( OV_BORDER + ( getOvMaxHeight() / 2 ) ) );
+                break;
         }
-        if ( getControlPanel().getDynamicallyHideData() != null ) {
-            if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
-                getControlPanel().getDynamicallyHideData().setEnabled( false );
+    }
+
+    final void updateOvSizes() {
+        if ( ( getWidth() > ( 1.05 * getVisibleRect().width ) ) || ( getHeight() > ( 1.05 * getVisibleRect().height ) ) ) {
+            setOvOn( true );
+            float l = getLongestExtNodeInfo();
+            final float w_ratio = getOvMaxWidth() / getWidth();
+            l *= w_ratio;
+            final int ext_nodes = _phylogeny.getRoot().getNumberOfExternalNodes();
+            setOvYDistance( getOvMaxHeight() / ( 2 * ext_nodes ) );
+            float ov_xdist = 0;
+            if ( !isNonLinedUpCladogram() && !isUniformBranchLengthsForCladogram() ) {
+                ov_xdist = ( ( getOvMaxWidth() - l ) / ( ext_nodes ) );
             }
             else {
-                getControlPanel().getDynamicallyHideData().setEnabled( true );
+                ov_xdist = ( ( getOvMaxWidth() - l ) / ( PhylogenyMethods.calculateMaxDepth( _phylogeny ) ) );
+            }
+            float ydist = ( float ) ( ( getOvMaxWidth() / ( ext_nodes * 2.0 ) ) );
+            if ( ov_xdist < 0.0 ) {
+                ov_xdist = 0.0f;
+            }
+            if ( ydist < 0.0 ) {
+                ydist = 0.0f;
+            }
+            setOvXDistance( ov_xdist );
+            final double height = _phylogeny.getHeight();
+            if ( height > 0 ) {
+                final float ov_corr = ( float ) ( ( ( getOvMaxWidth() - l ) - getOvXDistance() ) / height );
+                setOvXcorrectionFactor( ov_corr > 0 ? ov_corr : 0 );
+            }
+            else {
+                setOvXcorrectionFactor( 0 );
             }
-        }
-        if ( isPhyHasBranchLengths() && ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
-            getControlPanel().setDrawPhylogramEnabled( true );
         }
         else {
-            getControlPanel().setDrawPhylogramEnabled( false );
+            setOvOn( false );
         }
-        if ( getMainPanel().getMainFrame() == null ) {
-            // Must be "E" applet version.
-            ( ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet() )
-            .setSelectedTypeInTypeMenu( getPhylogenyGraphicsType() );
+    }
+
+    void updateSetOfCollapsedExternalNodes() {
+        final Phylogeny phy = getPhylogeny();
+        _collapsed_external_nodeid_set.clear();
+        if ( phy != null ) {
+            E: for( final PhylogenyNodeIterator it = phy.iteratorExternalForward(); it.hasNext(); ) {
+                final PhylogenyNode ext_node = it.next();
+                PhylogenyNode n = ext_node;
+                while ( !n.isRoot() ) {
+                    if ( n.isCollapse() ) {
+                        _collapsed_external_nodeid_set.add( ext_node.getId() );
+                        ext_node.setCollapse( true );
+                        continue E;
+                    }
+                    n = n.getParent();
+                }
+            }
+        }
+    }
+
+    final void updateSubSuperTreeButton() {
+        if ( _subtree_index < 1 ) {
+            getControlPanel().deactivateButtonToReturnToSuperTree();
         }
         else {
-            getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getPhylogenyGraphicsType() );
+            getControlPanel().activateButtonToReturnToSuperTree( _subtree_index );
+        }
+    }
+
+    final void zoomInDomainStructure() {
+        if ( _domain_structure_width < 2000 ) {
+            _domain_structure_width *= 1.2;
+        }
+    }
+
+    final void zoomOutDomainStructure() {
+        if ( _domain_structure_width > 20 ) {
+            _domain_structure_width *= 0.8;
         }
     }
 
@@ -6022,60 +6074,4 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         return ( ( key_code == KeyEvent.VK_ADD ) || ( key_code == KeyEvent.VK_PLUS )
                 || ( key_code == KeyEvent.VK_EQUALS ) || ( key_code == KeyEvent.VK_SEMICOLON ) || ( key_code == KeyEvent.VK_1 ) );
     }
-
-    final private class NodeColorizationActionListener implements ActionListener {
-
-        List<PhylogenyNode> _additional_nodes = null;
-        JColorChooser       _chooser          = null;
-        PhylogenyNode       _node             = null;
-
-        NodeColorizationActionListener( final JColorChooser chooser, final PhylogenyNode node ) {
-            _chooser = chooser;
-            _node = node;
-        }
-
-        NodeColorizationActionListener( final JColorChooser chooser,
-                                        final PhylogenyNode node,
-                                        final List<PhylogenyNode> additional_nodes ) {
-            _chooser = chooser;
-            _node = node;
-            _additional_nodes = additional_nodes;
-        }
-
-        @Override
-        public void actionPerformed( final ActionEvent e ) {
-            final Color c = _chooser.getColor();
-            if ( c != null ) {
-                colorizeNodes( c, _node, _additional_nodes );
-            }
-        }
-    }
-
-    final private class SubtreeColorizationActionListener implements ActionListener {
-
-        List<PhylogenyNode> _additional_nodes = null;
-        JColorChooser       _chooser          = null;
-        PhylogenyNode       _node             = null;
-
-        SubtreeColorizationActionListener( final JColorChooser chooser, final PhylogenyNode node ) {
-            _chooser = chooser;
-            _node = node;
-        }
-
-        SubtreeColorizationActionListener( final JColorChooser chooser,
-                                           final PhylogenyNode node,
-                                           final List<PhylogenyNode> additional_nodes ) {
-            _chooser = chooser;
-            _node = node;
-            _additional_nodes = additional_nodes;
-        }
-
-        @Override
-        public void actionPerformed( final ActionEvent e ) {
-            final Color c = _chooser.getColor();
-            if ( c != null ) {
-                colorizeSubtree( c, _node, _additional_nodes );
-            }
-        }
-    }
 }
index eb9a3b1..b58894d 100644 (file)
@@ -150,7 +150,7 @@ public class TreePanelUtil {
         if ( cp.isShowSeqSymbols() && node.getNodeData().isHasSequence()
                 && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getSymbol() ) ) {
             TreePanelUtil
-                    .showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence().getSymbol(), sb );
+            .showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence().getSymbol(), sb );
         }
         if ( cp.isShowGeneNames() && node.getNodeData().isHasSequence()
                 && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getGeneName() ) ) {
@@ -161,29 +161,29 @@ public class TreePanelUtil {
                 && ( node.getNodeData().getSequence().getAccession() != null )
                 && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().toString() ) ) {
             TreePanelUtil.showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence().getAccession()
-                    .toString(), sb );
+                                                                       .toString(), sb );
         }
         if ( cp.isShowTaxonomyCode() && node.getNodeData().isHasTaxonomy()
                 && !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
             TreePanelUtil.showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getTaxonomy()
-                    .getTaxonomyCode(), sb );
+                                                                       .getTaxonomyCode(), sb );
         }
         if ( cp.isShowTaxonomyScientificNames() && node.getNodeData().isHasTaxonomy()
                 && !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getScientificName() ) ) {
             TreePanelUtil.showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getTaxonomy()
-                    .getScientificName(), sb );
+                                                                       .getScientificName(), sb );
         }
         if ( cp.isShowTaxonomyCommonNames() && node.getNodeData().isHasTaxonomy()
                 && !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getCommonName() ) ) {
             TreePanelUtil
-                    .showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getTaxonomy().getCommonName(), sb );
-        }
-//        if ( ( cp.isShowSeqNames() || cp.isShowSeqSymbols() || cp.isShowSequenceAcc() )
-//                && node.getNodeData().isHasSequence()
-//                && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) {
-//            TreePanelUtil.showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence()
-//                    .getMolecularSequence(), sb );
-//        }
+            .showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getTaxonomy().getCommonName(), sb );
+        }
+        //        if ( ( cp.isShowSeqNames() || cp.isShowSeqSymbols() || cp.isShowSequenceAcc() )
+        //                && node.getNodeData().isHasSequence()
+        //                && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) {
+        //            TreePanelUtil.showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence()
+        //                    .getMolecularSequence(), sb );
+        //        }
         final String s = sb.toString().trim();
         if ( !ForesterUtil.isEmpty( s ) ) {
             data.add( s );
@@ -211,7 +211,7 @@ public class TreePanelUtil {
                     TreePanelUtil.collapseSubtree( n, true );
                     if ( !n.getNodeData().isHasTaxonomy() ) {
                         n.getNodeData().setTaxonomy( ( Taxonomy ) n.getAllExternalDescendants().get( 0 ).getNodeData()
-                                .getTaxonomy().copy() );
+                                                     .getTaxonomy().copy() );
                     }
                     inferred = true;
                 }
@@ -283,7 +283,7 @@ public class TreePanelUtil {
                     final List<PhylogenyNode> descs = PhylogenyMethods.getAllDescendants( n );
                     for( final PhylogenyNode desc : descs ) {
                         desc.getBranchData()
-                                .setBranchColor( new BranchColor( tree_panel.calculateTaxonomyBasedColor( tax ) ) );
+                        .setBranchColor( new BranchColor( tree_panel.calculateTaxonomyBasedColor( tax ) ) );
                     }
                 }
             }
@@ -298,11 +298,11 @@ public class TreePanelUtil {
             if ( n.getNodeData().isHasTaxonomy()
                     && ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() )
                             || !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getCommonName() ) || !ForesterUtil
-                                .isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) ) {
+                            .isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) ) {
                 if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getRank() )
                         && n.getNodeData().getTaxonomy().getRank().equalsIgnoreCase( rank ) ) {
                     final BranchColor c = new BranchColor( tree_panel.calculateTaxonomyBasedColor( n.getNodeData()
-                            .getTaxonomy() ) );
+                                                                                                   .getTaxonomy() ) );
                     TreePanelUtil.colorizeSubtree( n, c );
                     ++colorizations;
                     if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) {
@@ -320,7 +320,7 @@ public class TreePanelUtil {
                     for( final String lin : node.getNodeData().getTaxonomy().getLineage() ) {
                         if ( true_lineage_to_color_map.containsKey( lin ) ) {
                             TreePanelUtil
-                                    .colorizeSubtree( node, new BranchColor( true_lineage_to_color_map.get( lin ) ) );
+                            .colorizeSubtree( node, new BranchColor( true_lineage_to_color_map.get( lin ) ) );
                             ++colorizations;
                             success = true;
                             break;
index 1779119..36c6265 100644 (file)
@@ -132,7 +132,7 @@ public class UrlTreeReader implements Runnable {
                     case PFAM:
                         parser = new NHXParser();
                         ( ( NHXParser ) parser )
-                                .setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
+                        .setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
                         ( ( NHXParser ) parser ).setReplaceUnderscores( false );
                         ( ( NHXParser ) parser ).setGuessRootedness( true );
                         break;
@@ -245,23 +245,23 @@ public class UrlTreeReader implements Runnable {
                         }
                         _main_frame.getMainPanel().getCurrentTreePanel().setTreeFile( new File( my_name_for_file ) );
                         AptxUtil.lookAtSomeTreePropertiesForAptxControlSettings( phylogeny, _main_frame.getMainPanel()
-                                .getControlPanel(), _main_frame.getConfiguration() );
+                                                                                 .getControlPanel(), _main_frame.getConfiguration() );
                         _main_frame.getMainPanel().getControlPanel().showWhole();
                     }
                 }
             }
             else if ( !exception ) {
                 JOptionPane.showMessageDialog( null, ForesterUtil.wordWrap( "Failed to read in tree(s) from [" + url
-                        + "]", 80 ), "Error", JOptionPane.ERROR_MESSAGE );
+                                                                            + "]", 80 ), "Error", JOptionPane.ERROR_MESSAGE );
             }
             _main_frame.getContentPane().repaint();
             if ( ( trees != null ) && ( trees.length > 0 ) ) {
                 try {
                     JOptionPane.showMessageDialog( null,
                                                    ForesterUtil.wordWrap( "Successfully read in " + trees.length
-                                                           + " tree(s) from [" + url + "]", 80 ),
-                                                   "Success",
-                                                   JOptionPane.INFORMATION_MESSAGE );
+                                                                          + " tree(s) from [" + url + "]", 80 ),
+                                                                          "Success",
+                                                                          JOptionPane.INFORMATION_MESSAGE );
                 }
                 catch ( final Exception e ) {
                     // Not important if this fails, do nothing.