annotation things
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Thu, 29 Nov 2012 06:49:57 +0000 (06:49 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Thu, 29 Nov 2012 06:49:57 +0000 (06:49 +0000)
forester/java/src/org/forester/archaeopteryx/AptxUtil.java
forester/java/src/org/forester/archaeopteryx/ControlPanel.java
forester/java/src/org/forester/archaeopteryx/MainFrame.java
forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java
forester/java/src/org/forester/archaeopteryx/NodeEditPanel.java
forester/java/src/org/forester/archaeopteryx/TreePanel.java
forester/java/src/org/forester/archaeopteryx/tools/PhylogeneticInferrer.java
forester/java/src/org/forester/phylogeny/data/Annotation.java
forester/java/src/org/forester/tools/PhylogenyDecorator.java
forester/java/src/org/forester/util/ForesterUtil.java

index ab8bcf6..1078656 100644 (file)
@@ -72,8 +72,6 @@ import org.forester.phylogeny.PhylogenyMethods;
 import org.forester.phylogeny.PhylogenyNode;
 import org.forester.phylogeny.data.Accession;
 import org.forester.phylogeny.data.BranchColor;
-import org.forester.phylogeny.data.Distribution;
-import org.forester.phylogeny.data.Sequence;
 import org.forester.phylogeny.data.Taxonomy;
 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
 import org.forester.phylogeny.factories.PhylogenyFactory;
@@ -96,6 +94,243 @@ public final class AptxUtil {
         Arrays.sort( AVAILABLE_FONT_FAMILIES_SORTED );
     }
 
+    public static MaskFormatter createMaskFormatter( final String s ) {
+        MaskFormatter formatter = null;
+        try {
+            formatter = new MaskFormatter( s );
+        }
+        catch ( final ParseException e ) {
+            throw new IllegalArgumentException( e );
+        }
+        return formatter;
+    }
+
+    final static public boolean isHasAtLeastNodeWithEvent( final Phylogeny phy ) {
+        final PhylogenyNodeIterator it = phy.iteratorPostorder();
+        while ( it.hasNext() ) {
+            if ( it.next().getNodeData().isHasEvent() ) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Returns true if at least one branch has a length larger than zero.
+     * 
+     * 
+     * @param phy
+     */
+    final static public boolean isHasAtLeastOneBranchLengthLargerThanZero( final Phylogeny phy ) {
+        final PhylogenyNodeIterator it = phy.iteratorPostorder();
+        while ( it.hasNext() ) {
+            if ( it.next().getDistanceToParent() > 0.0 ) {
+                return true;
+            }
+        }
+        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 public static void launchWebBrowser( final URI uri,
+                                               final boolean is_applet,
+                                               final JApplet applet,
+                                               final String frame_name ) throws IOException {
+        if ( is_applet ) {
+            applet.getAppletContext().showDocument( uri.toURL(), frame_name );
+        }
+        else {
+            // This requires Java 1.6:
+            // =======================
+            // boolean no_desktop = false;
+            // try {
+            // if ( Desktop.isDesktopSupported() ) {
+            // System.out.println( "desktop supported" );
+            // final Desktop dt = Desktop.getDesktop();
+            // dt.browse( uri );
+            // }
+            // else {
+            // no_desktop = true;
+            // }
+            // }
+            // catch ( final Exception ex ) {
+            // ex.printStackTrace();
+            // no_desktop = true;
+            // }
+            // catch ( final Error er ) {
+            // er.printStackTrace();
+            // no_desktop = true;
+            // }
+            // if ( no_desktop ) {
+            // System.out.println( "desktop not supported" );
+            try {
+                openUrlInWebBrowser( uri.toString() );
+            }
+            catch ( final Exception e ) {
+                throw new IOException( e );
+            }
+            // }
+        }
+    }
+
+    public final static Accession obtainSequenceAccessionFromName( final String sequence_name ) {
+        final String n = sequence_name.trim();
+        final Matcher matcher1 = seq_identifier_pattern_1.matcher( n );
+        String group1 = "";
+        String group2 = "";
+        if ( matcher1.matches() ) {
+            group1 = matcher1.group( 1 );
+            group2 = matcher1.group( 2 );
+        }
+        else {
+            final Matcher matcher2 = seq_identifier_pattern_2.matcher( n );
+            if ( matcher2.matches() ) {
+                group1 = matcher2.group( 1 );
+                group2 = matcher2.group( 2 );
+            }
+        }
+        if ( ForesterUtil.isEmpty( group1 ) || ForesterUtil.isEmpty( group2 ) ) {
+            return null;
+        }
+        return new Accession( group2, group1 );
+    }
+
+    public final static void printWarningMessage( final String name, final String message ) {
+        System.out.println( "[" + name + "] > " + message );
+    }
+
+    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 );
+    }
+
+    public final static void showExtDescNodeDataUserSelectedHelper( final ControlPanel cp,
+                                                                    final PhylogenyNode node,
+                                                                    final List<String> data ) {
+        final StringBuilder sb = new StringBuilder();
+        if ( cp.isShowNodeNames() && !ForesterUtil.isEmpty( node.getName() ) ) {
+            showExtDescNodeDataUserSelectedHelperHelper( node.getName(), sb );
+        }
+        if ( cp.isShowGeneNames() && node.getNodeData().isHasSequence()
+                && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getName() ) ) {
+            showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence().getName(), sb );
+        }
+        if ( cp.isShowGeneSymbols() && node.getNodeData().isHasSequence()
+                && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getSymbol() ) ) {
+            showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence().getSymbol(), sb );
+        }
+        if ( cp.isShowSequenceAcc() && node.getNodeData().isHasSequence()
+                && ( node.getNodeData().getSequence().getAccession() != null )
+                && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().toString() ) ) {
+            showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence().getAccession().toString(), sb );
+        }
+        if ( cp.isShowTaxonomyCode() && node.getNodeData().isHasTaxonomy()
+                && !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
+            showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getTaxonomy().getTaxonomyCode(), sb );
+        }
+        if ( cp.isShowTaxonomyScientificNames() && node.getNodeData().isHasTaxonomy()
+                && !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getScientificName() ) ) {
+            showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getTaxonomy().getScientificName(), sb );
+        }
+        if ( ( cp.isShowGeneNames() || cp.isShowGeneSymbols() || cp.isShowSequenceAcc() )
+                && node.getNodeData().isHasSequence()
+                && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) {
+            showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence().getMolecularSequence(), sb );
+        }
+        final String s = sb.toString().trim();
+        if ( !ForesterUtil.isEmpty( s ) ) {
+            data.add( s );
+        }
+    }
+
+    public final static void showExtDescNodeDataUserSelectedHelperHelper( final String s, final StringBuilder sb ) {
+        if ( sb.length() > 0 ) {
+            sb.append( "\t" );
+        }
+        sb.append( s );
+    }
+
+    final public static void showInformationMessage( final Component parent, final String title, final String msg ) {
+        JOptionPane.showMessageDialog( parent, msg, title, JOptionPane.INFORMATION_MESSAGE );
+    }
+
+    public static void writePhylogenyToGraphicsFile( final File intree,
+                                                     final File outfile,
+                                                     final int width,
+                                                     final int height,
+                                                     final GraphicsExportType type,
+                                                     final Configuration config ) throws IOException {
+        final PhylogenyParser parser = ParserUtils.createParserDependingOnFileType( intree, true );
+        Phylogeny[] phys = null;
+        phys = PhylogenyMethods.readPhylogenies( parser, intree );
+        writePhylogenyToGraphicsFile( phys[ 0 ], outfile, width, height, type, config );
+    }
+
+    public static void writePhylogenyToGraphicsFile( final Phylogeny phy,
+                                                     final File outfile,
+                                                     final int width,
+                                                     final int height,
+                                                     final GraphicsExportType type,
+                                                     final Configuration config ) throws IOException {
+        final Phylogeny[] phys = new Phylogeny[ 1 ];
+        phys[ 0 ] = phy;
+        final MainFrameApplication mf = MainFrameApplication.createInstance( phys, config );
+        AptxUtil.writePhylogenyToGraphicsFileNonInteractive( outfile, width, height, mf.getMainPanel()
+                .getCurrentTreePanel(), mf.getMainPanel().getControlPanel(), type, mf.getOptions() );
+        mf.end();
+    }
+
+    public final static void writePhylogenyToGraphicsFileNonInteractive( final File outfile,
+                                                                         final int width,
+                                                                         final int height,
+                                                                         final TreePanel tree_panel,
+                                                                         final ControlPanel ac,
+                                                                         final GraphicsExportType type,
+                                                                         final Options options ) throws IOException {
+        tree_panel.setParametersForPainting( width, height, true );
+        tree_panel.resetPreferredSize();
+        tree_panel.repaint();
+        final RenderingHints rendering_hints = new RenderingHints( RenderingHints.KEY_RENDERING,
+                                                                   RenderingHints.VALUE_RENDER_QUALITY );
+        rendering_hints.put( RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY );
+        if ( options.isAntialiasPrint() ) {
+            rendering_hints.put( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON );
+            rendering_hints.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_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 Phylogeny phylogeny = tree_panel.getPhylogeny();
+        if ( ( phylogeny == null ) || phylogeny.isEmpty() ) {
+            return;
+        }
+        if ( outfile.isDirectory() ) {
+            throw new IOException( "\"" + outfile + "\" is a directory" );
+        }
+        final BufferedImage buffered_img = new BufferedImage( width, height, BufferedImage.TYPE_INT_RGB );
+        final Graphics2D g2d = buffered_img.createGraphics();
+        g2d.setRenderingHints( rendering_hints );
+        tree_panel.paintPhylogeny( g2d, false, true, width, height, 0, 0 );
+        if ( type == GraphicsExportType.TIFF ) {
+            writeToTiff( outfile, buffered_img );
+        }
+        else {
+            ImageIO.write( buffered_img, type.toString(), outfile );
+        }
+        g2d.dispose();
+    }
+
     final static void addPhylogeniesToTabs( final Phylogeny[] phys,
                                             final String default_name,
                                             final String full_path,
@@ -231,7 +466,7 @@ public final class AptxUtil {
         return iter.hasNext();
     }
 
-    final public static void collapseSpeciesSpecificSubtrees( final Phylogeny phy ) {
+    final static void collapseSpeciesSpecificSubtrees( final Phylogeny phy ) {
         boolean inferred = false;
         for( final PhylogenyNodeIterator it = phy.iteratorPreorder(); it.hasNext(); ) {
             final PhylogenyNode n = it.next();
@@ -266,14 +501,6 @@ public final class AptxUtil {
         }
     }
 
-    private static void colorizeSubtree( final PhylogenyNode node, final BranchColor c ) {
-        node.getBranchData().setBranchColor( c );
-        final List<PhylogenyNode> descs = PhylogenyMethods.getAllDescendants( node );
-        for( final PhylogenyNode desc : descs ) {
-            desc.getBranchData().setBranchColor( c );
-        }
-    }
-
     final static void colorPhylogenyAccordingToConfidenceValues( final Phylogeny tree, final TreePanel tree_panel ) {
         double max_conf = 0.0;
         for( final PhylogenyNodeIterator it = tree.iteratorPreorder(); it.hasNext(); ) {
@@ -522,17 +749,6 @@ public final class AptxUtil {
         return desc.toString();
     }
 
-    public static MaskFormatter createMaskFormatter( final String s ) {
-        MaskFormatter formatter = null;
-        try {
-            formatter = new MaskFormatter( s );
-        }
-        catch ( final ParseException e ) {
-            throw new IllegalArgumentException( e );
-        }
-        return formatter;
-    }
-
     /**
      * Exits with -1.
      * 
@@ -549,31 +765,7 @@ public final class AptxUtil {
         System.exit( -1 );
     }
 
-    final public static void ensurePresenceOfDate( final PhylogenyNode node ) {
-        if ( !node.getNodeData().isHasDate() ) {
-            node.getNodeData().setDate( new org.forester.phylogeny.data.Date() );
-        }
-    }
-
-    final public static void ensurePresenceOfDistribution( final PhylogenyNode node ) {
-        if ( !node.getNodeData().isHasDistribution() ) {
-            node.getNodeData().setDistribution( new Distribution( "" ) );
-        }
-    }
-
-    public static void ensurePresenceOfSequence( final PhylogenyNode node ) {
-        if ( !node.getNodeData().isHasSequence() ) {
-            node.getNodeData().setSequence( new Sequence() );
-        }
-    }
-
-    public static void ensurePresenceOfTaxonomy( final PhylogenyNode node ) {
-        if ( !node.getNodeData().isHasTaxonomy() ) {
-            node.getNodeData().setTaxonomy( new Taxonomy() );
-        }
-    }
-
-    public static String[] getAllPossibleRanks() {
+    final static String[] getAllPossibleRanks() {
         final String[] str_array = new String[ PhyloXmlUtil.TAXONOMY_RANKS_LIST.size() - 2 ];
         int i = 0;
         for( final String e : PhyloXmlUtil.TAXONOMY_RANKS_LIST ) {
@@ -627,42 +819,6 @@ public final class AptxUtil {
         return true;
     }
 
-    final static public boolean isHasAtLeastNodeWithEvent( final Phylogeny phy ) {
-        final PhylogenyNodeIterator it = phy.iteratorPostorder();
-        while ( it.hasNext() ) {
-            if ( it.next().getNodeData().isHasEvent() ) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Returns true if at least one branch has a length larger than zero.
-     * 
-     * 
-     * @param phy
-     */
-    final static public boolean isHasAtLeastOneBranchLengthLargerThanZero( final Phylogeny phy ) {
-        final PhylogenyNodeIterator it = phy.iteratorPostorder();
-        while ( it.hasNext() ) {
-            if ( it.next().getDistanceToParent() > 0.0 ) {
-                return true;
-            }
-        }
-        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 boolean isJava15() {
         try {
             final String s = ForesterUtil.JAVA_VERSION;
@@ -708,47 +864,6 @@ public final class AptxUtil {
         }
     }
 
-    final public static void launchWebBrowser( final URI uri,
-                                               final boolean is_applet,
-                                               final JApplet applet,
-                                               final String frame_name ) throws IOException {
-        if ( is_applet ) {
-            applet.getAppletContext().showDocument( uri.toURL(), frame_name );
-        }
-        else {
-            // This requires Java 1.6:
-            // =======================
-            // boolean no_desktop = false;
-            // try {
-            // if ( Desktop.isDesktopSupported() ) {
-            // System.out.println( "desktop supported" );
-            // final Desktop dt = Desktop.getDesktop();
-            // dt.browse( uri );
-            // }
-            // else {
-            // no_desktop = true;
-            // }
-            // }
-            // catch ( final Exception ex ) {
-            // ex.printStackTrace();
-            // no_desktop = true;
-            // }
-            // catch ( final Error er ) {
-            // er.printStackTrace();
-            // no_desktop = true;
-            // }
-            // if ( no_desktop ) {
-            // System.out.println( "desktop not supported" );
-            try {
-                openUrlInWebBrowser( uri.toString() );
-            }
-            catch ( final Exception e ) {
-                throw new IOException( e );
-            }
-            // }
-        }
-    }
-
     final static void lookAtSomeTreePropertiesForAptxControlSettings( final Phylogeny t,
                                                                       final ControlPanel atv_control,
                                                                       final Configuration configuration ) {
@@ -791,66 +906,6 @@ public final class AptxUtil {
         }
     }
 
-    final private static char normalizeCharForRGB( char c ) {
-        c -= 65;
-        c *= 10.2;
-        c = c > 255 ? 255 : c;
-        c = c < 0 ? 0 : c;
-        return c;
-    }
-
-    public final static Accession obtainSequenceAccessionFromName( final String sequence_name ) {
-        final String n = sequence_name.trim();
-        final Matcher matcher1 = seq_identifier_pattern_1.matcher( n );
-        String group1 = "";
-        String group2 = "";
-        if ( matcher1.matches() ) {
-            group1 = matcher1.group( 1 );
-            group2 = matcher1.group( 2 );
-        }
-        else {
-            final Matcher matcher2 = seq_identifier_pattern_2.matcher( n );
-            if ( matcher2.matches() ) {
-                group1 = matcher2.group( 1 );
-                group2 = matcher2.group( 2 );
-            }
-        }
-        if ( ForesterUtil.isEmpty( group1 ) || ForesterUtil.isEmpty( group2 ) ) {
-            return null;
-        }
-        return new Accession( group2, group1 );
-    }
-
-    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 ( 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 openWebsite( final String url, final boolean is_applet, final JApplet applet ) throws IOException {
         try {
             AptxUtil.launchWebBrowser( new URI( url ), is_applet, applet, Constants.PRG_NAME );
@@ -864,10 +919,6 @@ public final class AptxUtil {
         System.out.println( "[" + applet_name + "] > " + message );
     }
 
-    public final static void printWarningMessage( final String name, final String message ) {
-        System.out.println( "[" + name + "] > " + message );
-    }
-
     final static Phylogeny[] readPhylogeniesFromUrl( final URL url, final boolean phyloxml_validate_against_xsd )
             throws FileNotFoundException, IOException {
         final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
@@ -887,62 +938,6 @@ public final class AptxUtil {
         }
     }
 
-    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 );
-    }
-
-    public final static void showExtDescNodeDataUserSelectedHelper( final ControlPanel cp,
-                                                                    final PhylogenyNode node,
-                                                                    final List<String> data ) {
-        final StringBuilder sb = new StringBuilder();
-        if ( cp.isShowNodeNames() && !ForesterUtil.isEmpty( node.getName() ) ) {
-            showExtDescNodeDataUserSelectedHelperHelper( node.getName(), sb );
-        }
-        if ( cp.isShowGeneNames() && node.getNodeData().isHasSequence()
-                && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getName() ) ) {
-            showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence().getName(), sb );
-        }
-        if ( cp.isShowGeneSymbols() && node.getNodeData().isHasSequence()
-                && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getSymbol() ) ) {
-            showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence().getSymbol(), sb );
-        }
-        if ( cp.isShowSequenceAcc() && node.getNodeData().isHasSequence()
-                && ( node.getNodeData().getSequence().getAccession() != null )
-                && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().toString() ) ) {
-            showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence().getAccession().toString(), sb );
-        }
-        if ( cp.isShowTaxonomyCode() && node.getNodeData().isHasTaxonomy()
-                && !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
-            showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getTaxonomy().getTaxonomyCode(), sb );
-        }
-        if ( cp.isShowTaxonomyScientificNames() && node.getNodeData().isHasTaxonomy()
-                && !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getScientificName() ) ) {
-            showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getTaxonomy().getScientificName(), sb );
-        }
-        if ( ( cp.isShowGeneNames() || cp.isShowGeneSymbols() || cp.isShowSequenceAcc() )
-                && node.getNodeData().isHasSequence()
-                && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) {
-            showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence().getMolecularSequence(), sb );
-        }
-        final String s = sb.toString().trim();
-        if ( !ForesterUtil.isEmpty( s ) ) {
-            data.add( s );
-        }
-    }
-
-    public final static void showExtDescNodeDataUserSelectedHelperHelper( final String s, final StringBuilder sb ) {
-        if ( sb.length() > 0 ) {
-            sb.append( "\t" );
-        }
-        sb.append( s );
-    }
-
-    final public static void showInformationMessage( final Component parent, final String title, final String msg ) {
-        JOptionPane.showMessageDialog( parent, msg, title, JOptionPane.INFORMATION_MESSAGE );
-    }
-
     final static void unexpectedError( final Error err ) {
         err.printStackTrace();
         final StringBuffer sb = new StringBuffer();
@@ -1034,32 +1029,6 @@ public final class AptxUtil {
         return msg;
     }
 
-    public static void writePhylogenyToGraphicsFile( final File intree,
-                                                     final File outfile,
-                                                     final int width,
-                                                     final int height,
-                                                     final GraphicsExportType type,
-                                                     final Configuration config ) throws IOException {
-        final PhylogenyParser parser = ParserUtils.createParserDependingOnFileType( intree, true );
-        Phylogeny[] phys = null;
-        phys = PhylogenyMethods.readPhylogenies( parser, intree );
-        writePhylogenyToGraphicsFile( phys[ 0 ], outfile, width, height, type, config );
-    }
-
-    public static void writePhylogenyToGraphicsFile( final Phylogeny phy,
-                                                     final File outfile,
-                                                     final int width,
-                                                     final int height,
-                                                     final GraphicsExportType type,
-                                                     final Configuration config ) throws IOException {
-        final Phylogeny[] phys = new Phylogeny[ 1 ];
-        phys[ 0 ] = phy;
-        final MainFrameApplication mf = MainFrameApplication.createInstance( phys, config );
-        AptxUtil.writePhylogenyToGraphicsFileNonInteractive( outfile, width, height, mf.getMainPanel()
-                .getCurrentTreePanel(), mf.getMainPanel().getControlPanel(), type, mf.getOptions() );
-        mf.end();
-    }
-
     final static String writePhylogenyToGraphicsFile( final String file_name,
                                                       int width,
                                                       int height,
@@ -1134,47 +1103,6 @@ public final class AptxUtil {
         return msg;
     }
 
-    public final static void writePhylogenyToGraphicsFileNonInteractive( final File outfile,
-                                                                         final int width,
-                                                                         final int height,
-                                                                         final TreePanel tree_panel,
-                                                                         final ControlPanel ac,
-                                                                         final GraphicsExportType type,
-                                                                         final Options options ) throws IOException {
-        tree_panel.setParametersForPainting( width, height, true );
-        tree_panel.resetPreferredSize();
-        tree_panel.repaint();
-        final RenderingHints rendering_hints = new RenderingHints( RenderingHints.KEY_RENDERING,
-                                                                   RenderingHints.VALUE_RENDER_QUALITY );
-        rendering_hints.put( RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY );
-        if ( options.isAntialiasPrint() ) {
-            rendering_hints.put( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON );
-            rendering_hints.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_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 Phylogeny phylogeny = tree_panel.getPhylogeny();
-        if ( ( phylogeny == null ) || phylogeny.isEmpty() ) {
-            return;
-        }
-        if ( outfile.isDirectory() ) {
-            throw new IOException( "\"" + outfile + "\" is a directory" );
-        }
-        final BufferedImage buffered_img = new BufferedImage( width, height, BufferedImage.TYPE_INT_RGB );
-        final Graphics2D g2d = buffered_img.createGraphics();
-        g2d.setRenderingHints( rendering_hints );
-        tree_panel.paintPhylogeny( g2d, false, true, width, height, 0, 0 );
-        if ( type == GraphicsExportType.TIFF ) {
-            writeToTiff( outfile, buffered_img );
-        }
-        else {
-            ImageIO.write( buffered_img, type.toString(), outfile );
-        }
-        g2d.dispose();
-    }
-
     final static void writeToTiff( final File file, final BufferedImage image ) throws IOException {
         // See: http://log.robmeek.com/2005/08/write-tiff-in-java.html
         ImageWriter writer = null;
@@ -1204,6 +1132,52 @@ public final class AptxUtil {
         writer.write( null, iio_image, image_write_param );
     }
 
+    private static void colorizeSubtree( final PhylogenyNode node, final BranchColor c ) {
+        node.getBranchData().setBranchColor( c );
+        final List<PhylogenyNode> descs = PhylogenyMethods.getAllDescendants( node );
+        for( final PhylogenyNode desc : descs ) {
+            desc.getBranchData().setBranchColor( c );
+        }
+    }
+
+    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 ( 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 } );
+            }
+        }
+    }
+
     // See: http://www.xml.nig.ac.jp/tutorial/rest/index.html#2.2
     // static void openDDBJRest() throws IOException {
     // //set URL
index 1dee33f..f7e6dba 100644 (file)
@@ -201,18 +201,6 @@ final class ControlPanel extends JPanel implements ActionListener {
                 }
                 displayedPhylogenyMightHaveChanged( true );
             }
-            else if ( e.getSource() == _color_according_to_annotation ) {
-                if ( ( _show_annotation != null ) && _color_according_to_annotation.isSelected() ) {
-                    _show_annotation.setSelected( true );
-                }
-                displayedPhylogenyMightHaveChanged( false );
-            }
-            else if ( e.getSource() == _show_annotation ) {
-                if ( ( _color_according_to_annotation != null ) && !_show_annotation.isSelected() ) {
-                    _color_according_to_annotation.setSelected( false );
-                }
-                displayedPhylogenyMightHaveChanged( false );
-            }
             else if ( e.getSource() == _show_domain_architectures ) {
                 search();
                 displayedPhylogenyMightHaveChanged( false );
@@ -306,6 +294,132 @@ final class ControlPanel extends JPanel implements ActionListener {
         }
     }
 
+    public JCheckBox getColorAccSpeciesCb() {
+        return _color_acc_species;
+    }
+
+    public JCheckBox getColorBranchesCb() {
+        return _color_branches_cb;
+    }
+
+    public JCheckBox getDisplayAsPhylogramCb() {
+        return _display_as_phylogram_cb;
+    }
+
+    public JCheckBox getDynamicallyHideData() {
+        return _dynamically_hide_data;
+    }
+
+    public JCheckBox getNodeDescPopupCb() {
+        return _node_desc_popup_cb;
+    }
+
+    public Sequence getSelectedQuerySequence() {
+        return _selected_query_seq;
+    }
+
+    public JComboBox getSequenceRelationBox() {
+        if ( _show_sequence_relations == null ) {
+            _show_sequence_relations = new JComboBox();
+            _show_sequence_relations.setFocusable( false );
+            _show_sequence_relations.setMaximumRowCount( 20 );
+            _show_sequence_relations.setFont( ControlPanel.js_font );
+            if ( !_configuration.isUseNativeUI() ) {
+                _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
+                _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
+            }
+            _show_sequence_relations.addItem( "-----" );
+            _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
+        }
+        return _show_sequence_relations;
+    }
+
+    /* GUILHEM_BEG */
+    public JComboBox getSequenceRelationTypeBox() {
+        if ( _sequence_relation_type_box == null ) {
+            _sequence_relation_type_box = new JComboBox();
+            for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
+                _sequence_relation_type_box.addItem( type );
+            }
+            _sequence_relation_type_box.addActionListener( new ActionListener() {
+
+                @Override
+                public void actionPerformed( final ActionEvent e ) {
+                    if ( _mainpanel.getCurrentPhylogeny() != null ) {
+                        setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
+                    }
+                }
+            } );
+        }
+        return _sequence_relation_type_box;
+    }
+
+    public JCheckBox getShowEventsCb() {
+        return _show_events;
+    }
+
+    public JCheckBox getWriteConfidenceCb() {
+        return _write_confidence;
+    }
+
+    public boolean isShowProperties() {
+        return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
+    }
+
+    public boolean isShowTaxonomyImages() {
+        return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
+    }
+
+    public boolean isShowVectorData() {
+        return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
+    }
+
+    public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
+        final JComboBox box = getSequenceRelationBox();
+        while ( box.getItemCount() > 1 ) {
+            box.removeItemAt( 1 );
+        }
+        final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
+        final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
+                .getSelectedItem();
+        if ( relationType == null ) {
+            return;
+        }
+        final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
+        for( final Sequence seq : sequenceRelationQueries ) {
+            if ( seq.hasSequenceRelations() ) {
+                boolean fFoundForCurrentType = false;
+                for( final SequenceRelation sq : seq.getSequenceRelations() ) {
+                    if ( sq.getType().equals( relationType ) ) {
+                        fFoundForCurrentType = true;
+                        break;
+                    }
+                }
+                if ( fFoundForCurrentType ) {
+                    sequenceNamesToAdd.add( seq.getName() );
+                    sequencesByName.put( seq.getName(), seq );
+                }
+            }
+        }
+        // sort sequences by name before adding them to the combo
+        final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
+        Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
+        for( final String seqName : sequenceNameArray ) {
+            box.addItem( seqName );
+        }
+        for( final ItemListener oldItemListener : box.getItemListeners() ) {
+            box.removeItemListener( oldItemListener );
+        }
+        box.addItemListener( new ItemListener() {
+
+            @Override
+            public void itemStateChanged( final ItemEvent e ) {
+                _selected_query_seq = sequencesByName.get( e.getItem() );
+                _mainpanel.getCurrentTreePanel().repaint();
+            }
+        } );
+    }
+
     void activateButtonToReturnToSuperTree( int index ) {
         --index;
         if ( index > 0 ) {
@@ -530,16 +644,6 @@ final class ControlPanel extends JPanel implements ActionListener {
         }
     }// addCheckbox
 
-    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() );
-        }
-    }
-
     void addJButton( final JButton jb, final JPanel p ) {
         jb.setFocusPainted( false );
         jb.setFont( ControlPanel.jcb_font );
@@ -572,58 +676,6 @@ final class ControlPanel extends JPanel implements ActionListener {
         tf.addActionListener( this );
     }
 
-    /* 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() {
-
-            @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
-
     void deactivateButtonToReturnToSuperTree() {
         _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
         _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
@@ -672,14 +724,6 @@ final class ControlPanel extends JPanel implements ActionListener {
         return _annotation_colors;
     }
 
-    public JCheckBox getColorBranchesCb() {
-        return _color_branches_cb;
-    }
-
-    public JCheckBox getColorAccSpeciesCb() {
-        return _color_acc_species;
-    }
-
     Configuration getConfiguration() {
         return _configuration;
     }
@@ -688,127 +732,44 @@ final class ControlPanel extends JPanel implements ActionListener {
         return getMainPanel().getCurrentTreePanel();
     }
 
-    public JCheckBox getDisplayAsPhylogramCb() {
-        return _display_as_phylogram_cb;
+    MainPanel getMainPanel() {
+        return _mainpanel;
     }
 
-    public JCheckBox getDynamicallyHideData() {
-        return _dynamically_hide_data;
+    Options getOptions() {
+        return getMainPanel().getOptions();
     }
 
-    /* GUILHEM_END */
-    private List<Boolean> getIsDrawPhylogramList() {
-        return _draw_phylogram;
+    JTextField getSearchTextField() {
+        return _search_tf;
     }
 
-    MainPanel getMainPanel() {
-        return _mainpanel;
+    List<String> getSingleClickToNames() {
+        return _click_to_names;
     }
 
-    public JCheckBox getNodeDescPopupCb() {
-        return _node_desc_popup_cb;
+    Map<String, Color> getSpeciesColors() {
+        return _species_colors;
     }
 
-    Options getOptions() {
-        return getMainPanel().getOptions();
+    boolean isAntialiasScreenText() {
+        return true;
     }
 
-    private JLabel getSearchFoundCountsLabel() {
-        return _search_found_label;
+    boolean isColorAccordingToAnnotation() {
+        return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
     }
 
-    private JButton getSearchResetButton() {
-        return _search_reset_button;
+    boolean isColorAccordingToTaxonomy() {
+        return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
     }
 
-    JTextField getSearchTextField() {
-        return _search_tf;
+    boolean isColorBranches() {
+        return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) );
     }
 
-    public Sequence getSelectedQuerySequence() {
-        return _selected_query_seq;
-    }
-
-    public JComboBox getSequenceRelationBox() {
-        if ( _show_sequence_relations == null ) {
-            _show_sequence_relations = new JComboBox();
-            _show_sequence_relations.setFocusable( false );
-            _show_sequence_relations.setMaximumRowCount( 20 );
-            _show_sequence_relations.setFont( ControlPanel.js_font );
-            if ( !_configuration.isUseNativeUI() ) {
-                _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
-                _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
-            }
-            _show_sequence_relations.addItem( "-----" );
-            _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
-        }
-        return _show_sequence_relations;
-    }
-
-    /* GUILHEM_BEG */
-    public JComboBox getSequenceRelationTypeBox() {
-        if ( _sequence_relation_type_box == null ) {
-            _sequence_relation_type_box = new JComboBox();
-            for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
-                _sequence_relation_type_box.addItem( type );
-            }
-            _sequence_relation_type_box.addActionListener( new ActionListener() {
-
-                @Override
-                public void actionPerformed( final ActionEvent e ) {
-                    if ( _mainpanel.getCurrentPhylogeny() != null ) {
-                        setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
-                    }
-                }
-            } );
-        }
-        return _sequence_relation_type_box;
-    }
-
-    public JCheckBox getShowEventsCb() {
-        return _show_events;
-    }
-
-    List<String> getSingleClickToNames() {
-        return _click_to_names;
-    }
-
-    Map<String, Color> getSpeciesColors() {
-        return _species_colors;
-    }
-
-    public JCheckBox getWriteConfidenceCb() {
-        return _write_confidence;
-    }
-
-    private void init() {
-        _draw_phylogram = new ArrayList<Boolean>();
-        setSpeciesColors( new HashMap<String, Color>() );
-        setAnnotationColors( new HashMap<String, Color>() );
-    }
-
-    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 isColorBranches() {
-        return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) );
-    }
-
-    boolean isDrawPhylogram() {
-        return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
-    }
-
-    private boolean isDrawPhylogram( final int index ) {
-        return getIsDrawPhylogramList().get( index );
+    boolean isDrawPhylogram() {
+        return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
     }
 
     boolean isDynamicallyHideData() {
@@ -847,14 +808,6 @@ final class ControlPanel extends JPanel implements ActionListener {
         return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
     }
 
-    public boolean isShowVectorData() {
-        return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
-    }
-
-    public boolean isShowProperties() {
-        return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
-    }
-
     boolean isShowGeneSymbols() {
         return ( ( _show_gene_symbols != null ) && _show_gene_symbols.isSelected() );
     }
@@ -883,10 +836,6 @@ final class ControlPanel extends JPanel implements ActionListener {
         return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
     }
 
-    public boolean isShowTaxonomyImages() {
-        return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
-    }
-
     boolean isShowTaxonomyCommonNames() {
         return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
     }
@@ -934,66 +883,6 @@ final class ControlPanel extends JPanel implements ActionListener {
         }
     }
 
-    private void search( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
-        getSearchFoundCountsLabel().setVisible( true );
-        getSearchResetButton().setEnabled( true );
-        getSearchResetButton().setVisible( true );
-        String[] queries = null;
-        List<PhylogenyNode> nodes = null;
-        if ( query_str.indexOf( ',' ) >= 0 ) {
-            queries = query_str.split( ",+" );
-        }
-        else {
-            queries = new String[ 1 ];
-            queries[ 0 ] = query_str.trim();
-        }
-        if ( ( queries != null ) && ( queries.length > 0 ) ) {
-            nodes = new ArrayList<PhylogenyNode>();
-            for( String query : queries ) {
-                if ( ForesterUtil.isEmpty( query ) ) {
-                    continue;
-                }
-                query = query.trim();
-                if ( query.indexOf( '+' ) >= 0 ) {
-                    nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
-                                                                         tree,
-                                                                         getOptions().isSearchCaseSensitive(),
-                                                                         !getOptions().isMatchWholeTermsOnly(),
-                                                                         isShowDomainArchitectures() ) );
-                }
-                else {
-                    nodes.addAll( PhylogenyMethods.searchData( query,
-                                                               tree,
-                                                               getOptions().isSearchCaseSensitive(),
-                                                               !getOptions().isMatchWholeTermsOnly(),
-                                                               isShowDomainArchitectures() ) );
-                }
-            }
-            if ( getOptions().isInverseSearchResult() ) {
-                final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
-                all.removeAll( nodes );
-                nodes = all;
-            }
-        }
-        if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
-            main_panel.getCurrentTreePanel().setFoundNodes( new HashSet<Integer>() );
-            for( final PhylogenyNode node : nodes ) {
-                main_panel.getCurrentTreePanel().getFoundNodes().add( node.getId() );
-            }
-            setSearchFoundCountsOnLabel( nodes.size() );
-        }
-        else {
-            setSearchFoundCountsOnLabel( 0 );
-            searchReset();
-        }
-    }
-
-    private void searchReset() {
-        if ( getMainPanel().getCurrentTreePanel() != null ) {
-            getMainPanel().getCurrentTreePanel().setFoundNodes( null );
-        }
-    }
-
     void setActionWhenNodeClicked( final NodeClickAction action ) {
         _action_when_node_clicked = action;
     }
@@ -1219,10 +1108,6 @@ final class ControlPanel extends JPanel implements ActionListener {
         setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
     }
 
-    private void setDrawPhylogram( final int index, final boolean b ) {
-        getIsDrawPhylogramList().set( index, b );
-    }
-
     void setDrawPhylogramEnabled( final boolean b ) {
         getDisplayAsPhylogramCb().setEnabled( b );
     }
@@ -1243,56 +1128,6 @@ final class ControlPanel extends JPanel implements ActionListener {
         // }
     }
 
-    private void setSearchFoundCountsOnLabel( final int counts ) {
-        getSearchFoundCountsLabel().setText( "Found: " + counts );
-    }
-
-    public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
-        final JComboBox box = getSequenceRelationBox();
-        while ( box.getItemCount() > 1 ) {
-            box.removeItemAt( 1 );
-        }
-        final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
-        final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
-                .getSelectedItem();
-        if ( relationType == null ) {
-            return;
-        }
-        final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
-        for( final Sequence seq : sequenceRelationQueries ) {
-            if ( seq.hasSequenceRelations() ) {
-                boolean fFoundForCurrentType = false;
-                for( final SequenceRelation sq : seq.getSequenceRelations() ) {
-                    if ( sq.getType().equals( relationType ) ) {
-                        fFoundForCurrentType = true;
-                        break;
-                    }
-                }
-                if ( fFoundForCurrentType ) {
-                    sequenceNamesToAdd.add( seq.getName() );
-                    sequencesByName.put( seq.getName(), seq );
-                }
-            }
-        }
-        // sort sequences by name before adding them to the combo
-        final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
-        Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
-        for( final String seqName : sequenceNameArray ) {
-            box.addItem( seqName );
-        }
-        for( final ItemListener oldItemListener : box.getItemListeners() ) {
-            box.removeItemListener( oldItemListener );
-        }
-        box.addItemListener( new ItemListener() {
-
-            @Override
-            public void itemStateChanged( final ItemEvent e ) {
-                _selected_query_seq = sequencesByName.get( e.getItem() );
-                _mainpanel.getCurrentTreePanel().repaint();
-            }
-        } );
-    }
-
     void setShowEvents( final boolean show_events ) {
         if ( getShowEventsCb() == null ) {
             _show_events = new JCheckBox( "" );
@@ -1304,32 +1139,527 @@ final class ControlPanel extends JPanel implements ActionListener {
         _species_colors = species_colors;
     }
 
-    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++;
+    /* GUILHEM_END */
+    /*
+     * Set up the controls from the config settings. 11/26/05
+     */
+    void setupControls() {
+        // The tree display options:
+        setupDisplayCheckboxes();
+        /* GUILHEM_BEG */
+        // The sequence relation query selection combo-box
+        if ( _configuration.displaySequenceRelations() ) {
+            addSequenceRelationBlock();
         }
-        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++;
+        /* GUILHEM_END */
+        // Click-to options
+        startClickToOptions();
+        setupClickToOptions();
+        endClickToOptions();
+        // Zoom and quick edit buttons
+        addButtons();
+        setupSearchTools();
+    }
+
+    void setUpControlsForDomainStrucures() {
+        _domain_display_label = new JLabel( "Domain Display:" );
+        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.doDisplayClickToOption( Configuration.reroot ) ) {
-            _reroot_cb_item = cb_index;
-            addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
-            if ( default_option == Configuration.reroot ) {
+        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 );
+    }
+
+    void setupSearchTools() {
+        final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
+        final JLabel search_label = new JLabel( "Search:" );
+        search_label.setFont( ControlPanel.jcb_bold_font );
+        if ( !getConfiguration().isUseNativeUI() ) {
+            search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
+        }
+        add( search_label );
+        search_label.setToolTipText( tip );
+        _search_found_label = new JLabel();
+        getSearchFoundCountsLabel().setVisible( false );
+        _search_found_label.setFont( ControlPanel.jcb_bold_font );
+        if ( !getConfiguration().isUseNativeUI() ) {
+            _search_found_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
+        }
+        _search_tf = new JTextField( 3 );
+        _search_tf.setToolTipText( tip );
+        _search_tf.setEditable( true );
+        if ( !getConfiguration().isUseNativeUI() ) {
+            _search_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
+            _search_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
+            _search_tf.setBorder( null );
+        }
+        _search_reset_button = new JButton();
+        getSearchResetButton().setText( "Reset" );
+        getSearchResetButton().setEnabled( false );
+        getSearchResetButton().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 ) {
+                search();
+                displayedPhylogenyMightHaveChanged( true );
+            }
+        };
+        final ActionListener action_listener = new ActionListener() {
+
+            @Override
+            public void actionPerformed( final ActionEvent e ) {
+                searchReset();
+                setSearchFoundCountsOnLabel( 0 );
+                getSearchFoundCountsLabel().setVisible( false );
+                getSearchTextField().setText( "" );
+                getSearchResetButton().setEnabled( false );
+                getSearchResetButton().setVisible( false );
+                displayedPhylogenyMightHaveChanged( true );
+            }
+        };
+        _search_reset_button.addActionListener( action_listener );
+        _search_tf.addKeyListener( key_adapter );
+        addJTextField( _search_tf, s_panel_1 );
+        s_panel_2.add( _search_found_label );
+        addJButton( _search_reset_button, s_panel_2 );
+    }
+
+    /**
+     * 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().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
+                                                                   _mainpanel.getSizeOfViewport().height,
+                                                                   true );
+        _mainpanel.getCurrentTreePanel().resetPreferredSize();
+        _mainpanel.adjustJScrollPane();
+        _mainpanel.getCurrentTreePanel().repaint();
+        _mainpanel.getCurrentTreePanel().validate();
+        _mainpanel.validate();
+        _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
+                                                                   _mainpanel.getSizeOfViewport().height,
+                                                                   true );
+        _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.setParametersForPainting( _mainpanel.getSizeOfViewport().width,
+                                                     _mainpanel.getSizeOfViewport().height,
+                                                     true );
+                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();
+        _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 {
+                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().search();
+            getSequenceRelationTypeBox().removeAllItems();
+            for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
+                    .getRelevantSequenceRelationTypes() ) {
+                _sequence_relation_type_box.addItem( type );
+            }
+            //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
+            // according to GUILHEM the line above can be removed.
+        }
+    }
+
+    /**
+     * 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();
+        }
+    }
+
+    void updateDomainStructureEvaluethresholdDisplay() {
+        if ( _domain_structure_evalue_thr_tf != null ) {
+            _domain_structure_evalue_thr_tf.setText( "10^"
+                    + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
+        }
+    }
+
+    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 {
+                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();
+        }
+    }
+
+    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();
+        }
+    }
+
+    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() );
+        }
+    }
+
+    /* 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() {
+
+            @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
+
+    /* GUILHEM_END */
+    private List<Boolean> getIsDrawPhylogramList() {
+        return _draw_phylogram;
+    }
+
+    JLabel getSearchFoundCountsLabel() {
+        return _search_found_label;
+    }
+
+    JButton getSearchResetButton() {
+        return _search_reset_button;
+    }
+
+    private void init() {
+        _draw_phylogram = new ArrayList<Boolean>();
+        setSpeciesColors( new HashMap<String, Color>() );
+        setAnnotationColors( new HashMap<String, Color>() );
+    }
+
+    private boolean isDrawPhylogram( final int index ) {
+        return getIsDrawPhylogramList().get( index );
+    }
+
+    private void search( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
+        getSearchFoundCountsLabel().setVisible( true );
+        getSearchResetButton().setEnabled( true );
+        getSearchResetButton().setVisible( true );
+        String[] queries = null;
+        List<PhylogenyNode> nodes = null;
+        if ( query_str.indexOf( ',' ) >= 0 ) {
+            queries = query_str.split( ",+" );
+        }
+        else {
+            queries = new String[ 1 ];
+            queries[ 0 ] = query_str.trim();
+        }
+        if ( ( queries != null ) && ( queries.length > 0 ) ) {
+            nodes = new ArrayList<PhylogenyNode>();
+            for( String query : queries ) {
+                if ( ForesterUtil.isEmpty( query ) ) {
+                    continue;
+                }
+                query = query.trim();
+                if ( query.indexOf( '+' ) >= 0 ) {
+                    nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
+                                                                         tree,
+                                                                         getOptions().isSearchCaseSensitive(),
+                                                                         !getOptions().isMatchWholeTermsOnly(),
+                                                                         isShowDomainArchitectures() ) );
+                }
+                else {
+                    nodes.addAll( PhylogenyMethods.searchData( query,
+                                                               tree,
+                                                               getOptions().isSearchCaseSensitive(),
+                                                               !getOptions().isMatchWholeTermsOnly(),
+                                                               isShowDomainArchitectures() ) );
+                }
+            }
+            if ( getOptions().isInverseSearchResult() ) {
+                final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
+                all.removeAll( nodes );
+                nodes = all;
+            }
+        }
+        if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
+            main_panel.getCurrentTreePanel().setFoundNodes( new HashSet<Integer>() );
+            for( final PhylogenyNode node : nodes ) {
+                main_panel.getCurrentTreePanel().getFoundNodes().add( node.getId() );
+            }
+            setSearchFoundCountsOnLabel( nodes.size() );
+        }
+        else {
+            setSearchFoundCountsOnLabel( 0 );
+            searchReset();
+        }
+    }
+
+    void searchReset() {
+        if ( getMainPanel().getCurrentTreePanel() != null ) {
+            getMainPanel().getCurrentTreePanel().setFoundNodes( null );
+        }
+    }
+
+    private void setDrawPhylogram( final int index, final boolean b ) {
+        getIsDrawPhylogramList().set( index, b );
+    }
+
+    void setSearchFoundCountsOnLabel( final int counts ) {
+        getSearchFoundCountsLabel().setText( "Found: " + counts );
+    }
+
+    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++;
@@ -1502,64 +1832,6 @@ final class ControlPanel extends JPanel implements ActionListener {
         setClickToAction( selected_index );
     }
 
-    /* GUILHEM_END */
-    /*
-     * Set up the controls from the config settings. 11/26/05
-     */
-    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();
-        setupSearchTools();
-    }
-
-    void setUpControlsForDomainStrucures() {
-        _domain_display_label = new JLabel( "Domain Display:" );
-        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 );
-    }
-
     private void setupDisplayCheckboxes() {
         if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
             addCheckbox( Configuration.display_as_phylogram,
@@ -1659,100 +1931,39 @@ final class ControlPanel extends JPanel implements ActionListener {
             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.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_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 ) );
-        }
-    }
-
-    void setupSearchTools() {
-        final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
-        final JLabel search_label = new JLabel( "Search:" );
-        search_label.setFont( ControlPanel.jcb_bold_font );
-        if ( !getConfiguration().isUseNativeUI() ) {
-            search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
-        }
-        add( search_label );
-        search_label.setToolTipText( tip );
-        _search_found_label = new JLabel();
-        getSearchFoundCountsLabel().setVisible( false );
-        _search_found_label.setFont( ControlPanel.jcb_bold_font );
-        if ( !getConfiguration().isUseNativeUI() ) {
-            _search_found_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
-        }
-        _search_tf = new JTextField( 3 );
-        _search_tf.setToolTipText( tip );
-        _search_tf.setEditable( true );
-        if ( !getConfiguration().isUseNativeUI() ) {
-            _search_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
-            _search_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
-            _search_tf.setBorder( null );
-        }
-        _search_reset_button = new JButton();
-        getSearchResetButton().setText( "Reset" );
-        getSearchResetButton().setEnabled( false );
-        getSearchResetButton().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 ) {
-                search();
-                displayedPhylogenyMightHaveChanged( true );
-            }
-        };
-        final ActionListener action_listener = new ActionListener() {
-
-            @Override
-            public void actionPerformed( final ActionEvent e ) {
-                searchReset();
-                setSearchFoundCountsOnLabel( 0 );
-                getSearchFoundCountsLabel().setVisible( false );
-                getSearchTextField().setText( "" );
-                getSearchResetButton().setEnabled( false );
-                getSearchResetButton().setVisible( false );
-                displayedPhylogenyMightHaveChanged( true );
-            }
-        };
-        _search_reset_button.addActionListener( action_listener );
-        _search_tf.addKeyListener( key_adapter );
-        addJTextField( _search_tf, s_panel_1 );
-        s_panel_2.add( _search_found_label );
-        addJButton( _search_reset_button, s_panel_2 );
+                         _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.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_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 ) );
+        }
     }
 
     private void setVisibilityOfDomainStrucureControls() {
@@ -1776,229 +1987,6 @@ final class ControlPanel extends JPanel implements ActionListener {
         }
     }
 
-    /**
-     * 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().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
-                                                                   _mainpanel.getSizeOfViewport().height,
-                                                                   true );
-        _mainpanel.getCurrentTreePanel().resetPreferredSize();
-        _mainpanel.adjustJScrollPane();
-        _mainpanel.getCurrentTreePanel().repaint();
-        _mainpanel.getCurrentTreePanel().validate();
-        _mainpanel.validate();
-        _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
-                                                                   _mainpanel.getSizeOfViewport().height,
-                                                                   true );
-        _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.setParametersForPainting( _mainpanel.getSizeOfViewport().width,
-                                                     _mainpanel.getSizeOfViewport().height,
-                                                     true );
-                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();
-        _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 {
-                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().search();
-            getSequenceRelationTypeBox().removeAllItems();
-            for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
-                    .getRelevantSequenceRelationTypes() ) {
-                _sequence_relation_type_box.addItem( type );
-            }
-            //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
-            // according to GUILHEM the line above can be removed.
-        }
-    }
-
-    /**
-     * 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();
-        }
-    }
-
-    void updateDomainStructureEvaluethresholdDisplay() {
-        if ( _domain_structure_evalue_thr_tf != null ) {
-            _domain_structure_evalue_thr_tf.setText( "10^"
-                    + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
-        }
-    }
-
-    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 {
-                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();
-        }
-    }
-
-    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();
-        }
-    }
-
     static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
         label.setFont( ControlPanel.jcb_bold_font );
         if ( !configuration.isUseNativeUI() ) {
index bd7f19f..ae4f8b4 100644 (file)
@@ -36,15 +36,20 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.NoSuchElementException;
+import java.util.Set;
 
+import javax.swing.Box;
 import javax.swing.JApplet;
 import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JFrame;
+import javax.swing.JLabel;
 import javax.swing.JMenu;
 import javax.swing.JMenuBar;
 import javax.swing.JMenuItem;
 import javax.swing.JOptionPane;
+import javax.swing.JPanel;
 import javax.swing.JRadioButtonMenuItem;
+import javax.swing.JTextField;
 import javax.swing.SwingUtilities;
 
 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
@@ -54,7 +59,9 @@ import org.forester.archaeopteryx.tools.InferenceManager;
 import org.forester.archaeopteryx.tools.ProcessPool;
 import org.forester.archaeopteryx.tools.ProcessRunning;
 import org.forester.phylogeny.Phylogeny;
+import org.forester.phylogeny.PhylogenyNode;
 import org.forester.phylogeny.PhylogenyNodeI.NH_CONVERSION_SUPPORT_VALUE_STYLE;
+import org.forester.phylogeny.data.Annotation;
 import org.forester.phylogeny.data.NodeVisualization.NodeFill;
 import org.forester.phylogeny.data.NodeVisualization.NodeShape;
 import org.forester.util.ForesterConstants;
@@ -137,6 +144,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     JMenuItem                   _move_node_names_to_tax_sn_jmi;
     JMenuItem                   _move_node_names_to_seq_names_jmi;
     JMenuItem                   _extract_tax_code_from_node_names_jmi;
+    JMenuItem                   _annotate_item;
     // font size menu:
     JMenuItem                   _super_tiny_fonts_item;
     JMenuItem                   _tiny_fonts_item;
@@ -220,15 +228,12 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     Options                     _options;
     InferenceManager            _inference_manager;
     final ProcessPool           _process_pool;
+    private String              _previous_node_annotation_ref;
 
     MainFrame() {
         _process_pool = ProcessPool.createInstance();
     }
 
-    public ProcessPool getProcessPool() {
-        return _process_pool;
-    }
-
     /**
      * Action performed.
      */
@@ -286,6 +291,9 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             }
             midpointRoot();
         }
+        else if ( o == _annotate_item ) {
+            annotateSequences();
+        }
         else if ( o == _switch_colors_mi ) {
             switchColors();
         }
@@ -483,18 +491,45 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         _contentpane.repaint();
     }
 
-    boolean isSubtreeDisplayed() {
-        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 );
-                return true;
+    public Configuration getConfiguration() {
+        return _configuration;
+    }
+
+    public InferenceManager getInferenceManager() {
+        return _inference_manager;
+    }
+
+    public MainPanel getMainPanel() {
+        return _mainpanel;
+    }
+
+    public Options getOptions() {
+        return _options;
+    }
+
+    public ProcessPool getProcessPool() {
+        return _process_pool;
+    }
+
+    public void showTextFrame( final String s, final String title ) {
+        checkTextFrames();
+        _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
+    }
+
+    public void showWhole() {
+        _mainpanel.getControlPanel().showWhole();
+    }
+
+    public void updateProcessMenu() {
+        // In general Swing is not thread safe.
+        // See "Swing's Threading Policy".
+        SwingUtilities.invokeLater( new Runnable() {
+
+            @Override
+            public void run() {
+                doUpdateProcessMenu();
             }
-        }
-        return false;
+        } );
     }
 
     void activateSaveAllIfNeeded() {
@@ -551,44 +586,6 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         _jmenubar.add( _help_jmenu );
     }
 
-    public void updateProcessMenu() {
-        // In general Swing is not thread safe.
-        // See "Swing's Threading Policy".
-        SwingUtilities.invokeLater( new Runnable() {
-
-            @Override
-            public void run() {
-                doUpdateProcessMenu();
-            }
-        } );
-    }
-
-    private void doUpdateProcessMenu() {
-        if ( _process_pool.size() > 0 ) {
-            if ( _process_menu == null ) {
-                _process_menu = createMenu( "", getConfiguration() );
-                _process_menu.setForeground( Color.RED );
-            }
-            _process_menu.removeAll();
-            final String text = "processes running: " + _process_pool.size();
-            _process_menu.setText( text );
-            _jmenubar.add( _process_menu );
-            for( int i = 0; i < _process_pool.size(); ++i ) {
-                final ProcessRunning p = _process_pool.getProcessByIndex( i );
-                _process_menu.add( customizeJMenuItem( new JMenuItem( p.getName() + " [" + p.getStart() + "]" ) ) );
-            }
-        }
-        else {
-            if ( _process_menu != null ) {
-                _process_menu.removeAll();
-                _jmenubar.remove( _process_menu );
-            }
-        }
-        _jmenubar.validate();
-        _jmenubar.repaint();
-        repaint();
-    }
-
     void buildTypeMenu() {
         _type_menu = createMenu( TYPE_MENU_HEADER, getConfiguration() );
         _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
@@ -629,74 +626,18 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         _jmenubar.add( _view_jmenu );
     }
 
-    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 enter 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 );
-            }
-        }
-    }
-
-    static void chooseNodeSize( final Options options, final Component parent ) {
-        final String s = ( String ) JOptionPane.showInputDialog( parent,
-                                                                 "Please enter the default size for node shapes.\n"
-                                                                         + "[current value: "
-                                                                         + options.getDefaultNodeShapeSize() + "]\n",
-                                                                 "Node Shape Size",
-                                                                 JOptionPane.QUESTION_MESSAGE,
-                                                                 null,
-                                                                 null,
-                                                                 options.getDefaultNodeShapeSize() );
-        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 );
+    void checkTextFrames() {
+        if ( _textframes.size() > 5 ) {
+            try {
+                if ( _textframes.getFirst() != null ) {
+                    _textframes.getFirst().removeMe();
                 }
-                catch ( final Exception ex ) {
-                    success = false;
+                else {
+                    _textframes.removeFirst();
                 }
             }
-            else {
-                success = false;
-            }
-            if ( success && ( m >= 0.0 ) ) {
-                final short size = ForesterUtil.roundToShort( m );
-                if ( size >= 0.0 ) {
-                    options.setDefaultNodeShapeSize( size );
-                }
+            catch ( final NoSuchElementException e ) {
+                // Ignore.
             }
         }
     }
@@ -713,12 +654,6 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         dispose();
     }
 
-    void confColor() {
-        if ( _mainpanel.getCurrentTreePanel() != null ) {
-            _mainpanel.getCurrentTreePanel().confColor();
-        }
-    }
-
     void colorRank() {
         if ( _mainpanel.getCurrentTreePanel() != null ) {
             final String[] ranks = AptxUtil.getAllPossibleRanks();
@@ -736,6 +671,12 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }
     }
 
+    void confColor() {
+        if ( _mainpanel.getCurrentTreePanel() != null ) {
+            _mainpanel.getCurrentTreePanel().confColor();
+        }
+    }
+
     void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
         if ( item != null ) {
             item.setFont( MainFrame.menu_font );
@@ -772,6 +713,16 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }
     }
 
+    void displayBasicInformation() {
+        if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
+            String title = "Basic Information";
+            if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
+                title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
+            }
+            showTextFrame( AptxUtil.createBasicInformation( _mainpanel.getCurrentPhylogeny() ), title );
+        }
+    }
+
     void exceptionOccuredDuringOpenFile( final Exception e ) {
         try {
             _mainpanel.getCurrentTreePanel().setArrowCursor();
@@ -815,10 +766,6 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }
     }
 
-    public Configuration getConfiguration() {
-        return _configuration;
-    }
-
     TreePanel getCurrentTreePanel() {
         return getMainPanel().getCurrentTreePanel();
     }
@@ -831,81 +778,163 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         return _label_direction_cbmi;
     }
 
-    public MainPanel getMainPanel() {
-        return _mainpanel;
-    }
-
     JMenuBar getMenuBarOfMainFrame() {
         return _jmenubar;
     }
 
-    public Options getOptions() {
-        return _options;
-    }
-
-    void initializeTypeMenu( final Options options ) {
-        setTypeMenuToAllUnselected();
-        switch ( options.getPhylogenyGraphicsType() ) {
-            case CONVEX:
-                _convex_type_cbmi.setSelected( true );
-                break;
-            case CURVED:
-                _curved_type_cbmi.setSelected( true );
-                break;
-            case EURO_STYLE:
-                _euro_type_cbmi.setSelected( true );
-                break;
-            case ROUNDED:
-                _rounded_type_cbmi.setSelected( true );
-                break;
-            case TRIANGULAR:
-                _triangular_type_cbmi.setSelected( true );
-                break;
-            case UNROOTED:
-                _unrooted_type_cbmi.setSelected( true );
-                break;
-            case CIRCULAR:
-                _circular_type_cbmi.setSelected( true );
-                break;
-            default:
-                _rectangular_type_cbmi.setSelected( true );
-                break;
-        }
-    }
-
-    void midpointRoot() {
-        if ( _mainpanel.getCurrentTreePanel() != null ) {
-            _mainpanel.getCurrentTreePanel().midpointRoot();
-        }
-    }
-
-    abstract void readPhylogeniesFromURL();
-
-    void readPhylogeniesFromWebservice( final int i ) {
-        final UrlTreeReader reader = new UrlTreeReader( this, i );
-        new Thread( reader ).start();
-    }
-
-    private void removeBranchColors() {
-        if ( getMainPanel().getCurrentPhylogeny() != null ) {
-            AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
-        }
-    }
-
-    void checkTextFrames() {
-        if ( _textframes.size() > 5 ) {
-            try {
-                if ( _textframes.getFirst() != null ) {
-                    _textframes.getFirst().removeMe();
-                }
-                else {
-                    _textframes.removeFirst();
-                }
+    void help( final Map<String, WebLink> weblinks ) {
+        final StringBuilder sb = new StringBuilder();
+        sb.append( "Display options\n" );
+        sb.append( "-------------------\n" );
+        sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
+        sb.append( "Clickable tree nodes\n" );
+        sb.append( "--------------------\n" );
+        sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
+        sb.append( "or by right clicking:\n" );
+        sb.append( "o  Display Node Data -- display information for a node\n" );
+        sb.append( "o  Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
+        sb.append( "o  Root/Reroot -- change tree root to clicked node\n" );
+        sb.append( "o  Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
+        sb.append( "o  Swap Descendants -- switch descendant on either side of clicked node\n" );
+        sb.append( "o  Colorize Subtree -- color a subtree\n" );
+        sb.append( "o  Open Sequence Web -- launch a web browser to display sequence information\n" );
+        sb.append( "o  Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
+        sb.append( "-  there may be additional choices depending on this particular setup\n\n" );
+        sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
+        sb.append( "Zooming\n" );
+        sb.append( "---------\n" );
+        sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
+        sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
+        sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
+        sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
+        sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
+        sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
+        sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
+        sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
+        sb.append( "Quick tree manipulation:\n" );
+        sb.append( "------------------------\n" );
+        sb.append( "Order Subtrees -- order the tree by branch length\n" );
+        sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
+        sb.append( "Memory problems (Java heap space error)\n" );
+        sb.append( "---------------------------------------\n" );
+        sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
+        sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
+        sb.append( "the '-Xmx' Java command line option. For example:\n" );
+        sb.append( "java -Xms32m -Xmx256m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
+        if ( ( weblinks != null ) && ( weblinks.size() > 0 ) ) {
+            sb.append( "Active web links\n" );
+            sb.append( "--------------------\n" );
+            for( final String key : weblinks.keySet() ) {
+                sb.append( " " + weblinks.get( key ).toString() + "\n" );
             }
-            catch ( final NoSuchElementException e ) {
-                // Ignore.
+        }
+        // + "General remarks\n"
+        // + "---------------\n"
+        // +
+        // "o  The application version permits copying to the clipboard \n"
+        // +
+        // "    in the \"View\"|\"View as ...\" frame (either by control-c or button press).\n"
+        // +
+        // "o  Changes made to a subtree affect this subtree and its subtrees,\n"
+        // + "    but not any of its parent tree(s).\n"
+        // +
+        // "o  Archaeopteryx tries to detect whether the numerical values in a NH tree\n"
+        // +
+        // "    are likely to be bootstrap values instead of branch length values.\n\n"
+        // +
+        // " Remarks regarding SDI (Speciation Duplication Inference):\n"
+        // +
+        // "o  Each external node of the gene tree (in display) needs to be associated with\n"
+        // +
+        // "    a species: either directly through the \"Species\" field, or the species\n"
+        // +
+        // "    is part of the sequence name in the form \"XXXX_SPECIES\"\n"
+        // +
+        // "    (e.g. \"ACON_DROME\" or \"ACON_DROME/123-4489\" which is also acceptable).\n"
+        // +
+        // "o  A species tree for each species of the gene tree needs to be loaded with\n"
+        // +
+        // "   \"SDI\"|\"Load species tree\" prior the SDI execution.\n"
+        // +
+        // "o  !External nodes of the gene tree associated with species not present in\n"
+        // +
+        // "    the species tree are REMOVED prior to SDI execution!\n"
+        // +
+        // "o  Both the gene tree and the species tree must be completely binary.\n"
+        // +
+        // "o  Duplications and speciations are a function of the position of the root.\n"
+        // +
+        // "    Hence, after each manual \"Root/Reroot\"ing some duplications will be\n"
+        // + "    incorrect and need to be inferred again\n"
+        // +
+        // "    with: \"SDI\"|\"SDI (Speciation Duplication Inference)\n\n"
+        sb.append( "\n" );
+        sb.append( "phyloXML\n" );
+        sb.append( "-------------------\n" );
+        sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
+        sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
+        sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
+        sb.append( "\n" );
+        sb.append( "For more information: http://www.phylosoft.org/archaeopteryx/\n" );
+        sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
+        TextFrame.instantiate( sb.toString(), "Help", _textframes );
+    }
+
+    void initializeTypeMenu( final Options options ) {
+        setTypeMenuToAllUnselected();
+        switch ( options.getPhylogenyGraphicsType() ) {
+            case CONVEX:
+                _convex_type_cbmi.setSelected( true );
+                break;
+            case CURVED:
+                _curved_type_cbmi.setSelected( true );
+                break;
+            case EURO_STYLE:
+                _euro_type_cbmi.setSelected( true );
+                break;
+            case ROUNDED:
+                _rounded_type_cbmi.setSelected( true );
+                break;
+            case TRIANGULAR:
+                _triangular_type_cbmi.setSelected( true );
+                break;
+            case UNROOTED:
+                _unrooted_type_cbmi.setSelected( true );
+                break;
+            case CIRCULAR:
+                _circular_type_cbmi.setSelected( true );
+                break;
+            default:
+                _rectangular_type_cbmi.setSelected( true );
+                break;
+        }
+    }
+
+    boolean isSubtreeDisplayed() {
+        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 );
+                return true;
             }
         }
+        return false;
+    }
+
+    void midpointRoot() {
+        if ( _mainpanel.getCurrentTreePanel() != null ) {
+            _mainpanel.getCurrentTreePanel().midpointRoot();
+        }
+    }
+
+    abstract void readPhylogeniesFromURL();
+
+    void readPhylogeniesFromWebservice( final int i ) {
+        final UrlTreeReader reader = new UrlTreeReader( this, i );
+        new Thread( reader ).start();
     }
 
     void removeAllTextFrames() {
@@ -921,16 +950,12 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         _configuration = configuration;
     }
 
-    void setOptions( final Options options ) {
-        _options = options;
-    }
-
     void setInferenceManager( final InferenceManager i ) {
         _inference_manager = i;
     }
 
-    public InferenceManager getInferenceManager() {
-        return _inference_manager;
+    void setOptions( final Options options ) {
+        _options = options;
     }
 
     void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
@@ -976,10 +1001,6 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         _circular_type_cbmi.setSelected( false );
     }
 
-    public void showWhole() {
-        _mainpanel.getControlPanel().showWhole();
-    }
-
     void switchColors() {
         final TreeColorSet colorset = _mainpanel.getTreeColorSet();
         final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
@@ -1133,16 +1154,6 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         ( ( JCheckBoxMenuItem ) o ).setSelected( true );
     }
 
-    void displayBasicInformation() {
-        if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
-            String title = "Basic Information";
-            if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
-                title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
-            }
-            showTextFrame( AptxUtil.createBasicInformation( _mainpanel.getCurrentPhylogeny() ), title );
-        }
-    }
-
     void viewAsNexus() {
         if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
             String title = "Nexus";
@@ -1186,9 +1197,141 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }
     }
 
-    public void showTextFrame( final String s, final String title ) {
-        checkTextFrames();
-        _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
+    private void annotateSequences() {
+        if ( getCurrentTreePanel() != null ) {
+            final Set<Integer> nodes = getCurrentTreePanel().getFoundNodes();
+            if ( ( nodes == null ) || nodes.isEmpty() ) {
+                JOptionPane
+                        .showMessageDialog( this,
+                                            "Need to select nodes, either via direct selection or via the \"Search\" function",
+                                            "No nodes selected for annotation",
+                                            JOptionPane.ERROR_MESSAGE );
+                return;
+            }
+            final Phylogeny phy = getMainPanel().getCurrentPhylogeny();
+            if ( ( phy != null ) && !phy.isEmpty() ) {
+                final JTextField xField = new JTextField( 10 );
+                final JTextField yField = new JTextField( 20 );
+                xField.setText( ForesterUtil.isEmpty( getPreviousNodeAnnotationReference() ) ? ""
+                        : getPreviousNodeAnnotationReference() );
+                final JPanel myPanel = new JPanel();
+                myPanel.add( new JLabel( "Reference " ) );
+                myPanel.add( xField );
+                myPanel.add( Box.createHorizontalStrut( 15 ) );
+                myPanel.add( new JLabel( "Description " ) );
+                myPanel.add( yField );
+                final int result = JOptionPane.showConfirmDialog( null,
+                                                                  myPanel,
+                                                                  "Enter the sequence annotation(s) for the "
+                                                                          + nodes.size() + " selected nodes",
+                                                                  JOptionPane.OK_CANCEL_OPTION );
+                if ( result == JOptionPane.OK_OPTION ) {
+                    String ref = xField.getText();
+                    String desc = yField.getText();
+                    if ( ref != null ) {
+                        ref = ref.trim();
+                        ref = ref.replaceAll( "\\s+", " " );
+                    }
+                    if ( desc != null ) {
+                        desc = desc.trim();
+                        desc = desc.replaceAll( "\\s+", " " );
+                    }
+                    if ( ref != null ) {
+                        setPreviousNodeAnnotationReference( ref );
+                    }
+                    if ( !ForesterUtil.isEmpty( ref ) || !ForesterUtil.isEmpty( desc ) ) {
+                        for( final Integer id : nodes ) {
+                            final PhylogenyNode n = phy.getNode( id );
+                            ForesterUtil.ensurePresenceOfSequence( n );
+                            final Annotation ann = ForesterUtil.isEmpty( ref ) ? new Annotation()
+                                    : new Annotation( ref );
+                            if ( !ForesterUtil.isEmpty( desc ) ) {
+                                ann.setDesc( desc );
+                            }
+                            n.getNodeData().getSequence().addAnnotation( ann );
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    private String getPreviousNodeAnnotationReference() {
+        return _previous_node_annotation_ref;
+    }
+
+    private void setPreviousNodeAnnotationReference( final String previous_node_annotation_ref ) {
+        _previous_node_annotation_ref = previous_node_annotation_ref;
+    }
+
+    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 enter 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 doUpdateProcessMenu() {
+        if ( _process_pool.size() > 0 ) {
+            if ( _process_menu == null ) {
+                _process_menu = createMenu( "", getConfiguration() );
+                _process_menu.setForeground( Color.RED );
+            }
+            _process_menu.removeAll();
+            final String text = "processes running: " + _process_pool.size();
+            _process_menu.setText( text );
+            _jmenubar.add( _process_menu );
+            for( int i = 0; i < _process_pool.size(); ++i ) {
+                final ProcessRunning p = _process_pool.getProcessByIndex( i );
+                _process_menu.add( customizeJMenuItem( new JMenuItem( p.getName() + " [" + p.getStart() + "]" ) ) );
+            }
+        }
+        else {
+            if ( _process_menu != null ) {
+                _process_menu.removeAll();
+                _jmenubar.remove( _process_menu );
+            }
+        }
+        _jmenubar.validate();
+        _jmenubar.repaint();
+        repaint();
+    }
+
+    private void removeBranchColors() {
+        if ( getMainPanel().getCurrentPhylogeny() != null ) {
+            AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
+        }
     }
 
     /**
@@ -1224,6 +1367,40 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         JOptionPane.showMessageDialog( null, about, Constants.PRG_NAME, JOptionPane.PLAIN_MESSAGE );
     }
 
+    static void chooseNodeSize( final Options options, final Component parent ) {
+        final String s = ( String ) JOptionPane.showInputDialog( parent,
+                                                                 "Please enter the default size for node shapes.\n"
+                                                                         + "[current value: "
+                                                                         + options.getDefaultNodeShapeSize() + "]\n",
+                                                                 "Node Shape Size",
+                                                                 JOptionPane.QUESTION_MESSAGE,
+                                                                 null,
+                                                                 null,
+                                                                 options.getDefaultNodeShapeSize() );
+        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 ) ) {
+                final short size = ForesterUtil.roundToShort( m );
+                if ( size >= 0.0 ) {
+                    options.setDefaultNodeShapeSize( size );
+                }
+            }
+        }
+    }
+
     static String createCurrentFontDesc( final TreeFontSet tree_font_set ) {
         return tree_font_set.getLargeFont().getFamily() + " " + tree_font_set.getLargeFont().getSize();
     }
@@ -1250,28 +1427,6 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         return label;
     }
 
-    static void cycleOverview( final Options op, final TreePanel tree_panel ) {
-        switch ( op.getOvPlacement() ) {
-            case LOWER_LEFT:
-                op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
-                break;
-            case LOWER_RIGHT:
-                op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
-                break;
-            case UPPER_LEFT:
-                op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
-                break;
-            case UPPER_RIGHT:
-                op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
-                break;
-            default:
-                throw new RuntimeException( "unknown placement: " + op.getOvPlacement() );
-        }
-        if ( tree_panel != null ) {
-            tree_panel.updateOvSettings();
-        }
-    }
-
     static void cycleNodeFill( final Options op, final TreePanel tree_panel ) {
         switch ( op.getDefaultNodeFill() ) {
             case GRADIENT:
@@ -1301,110 +1456,25 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }
     }
 
-    void help( final Map<String, WebLink> weblinks ) {
-        final StringBuilder sb = new StringBuilder();
-        sb.append( "Display options\n" );
-        sb.append( "-------------------\n" );
-        sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
-        sb.append( "Clickable tree nodes\n" );
-        sb.append( "--------------------\n" );
-        sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
-        sb.append( "or by right clicking:\n" );
-        sb.append( "o  Display Node Data -- display information for a node\n" );
-        sb.append( "o  Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
-        sb.append( "o  Root/Reroot -- change tree root to clicked node\n" );
-        sb.append( "o  Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
-        sb.append( "o  Swap Descendants -- switch descendant on either side of clicked node\n" );
-        sb.append( "o  Colorize Subtree -- color a subtree\n" );
-        sb.append( "o  Open Sequence Web -- launch a web browser to display sequence information\n" );
-        sb.append( "o  Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
-        sb.append( "-  there may be additional choices depending on this particular setup\n\n" );
-        sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
-        sb.append( "Zooming\n" );
-        sb.append( "---------\n" );
-        sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
-        sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
-        sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
-        sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
-        sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
-        sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
-        sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
-        sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
-        sb.append( "Quick tree manipulation:\n" );
-        sb.append( "------------------------\n" );
-        sb.append( "Order Subtrees -- order the tree by branch length\n" );
-        sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
-        sb.append( "Memory problems (Java heap space error)\n" );
-        sb.append( "---------------------------------------\n" );
-        sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
-        sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
-        sb.append( "the '-Xmx' Java command line option. For example:\n" );
-        sb.append( "java -Xms32m -Xmx256m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
-        if ( ( weblinks != null ) && ( weblinks.size() > 0 ) ) {
-            sb.append( "Active web links\n" );
-            sb.append( "--------------------\n" );
-            for( final String key : weblinks.keySet() ) {
-                sb.append( " " + weblinks.get( key ).toString() + "\n" );
-            }
-        }
-        // + "General remarks\n"
-        // + "---------------\n"
-        // +
-        // "o  The application version permits copying to the clipboard \n"
-        // +
-        // "    in the \"View\"|\"View as ...\" frame (either by control-c or button press).\n"
-        // +
-        // "o  Changes made to a subtree affect this subtree and its subtrees,\n"
-        // + "    but not any of its parent tree(s).\n"
-        // +
-        // "o  Archaeopteryx tries to detect whether the numerical values in a NH tree\n"
-        // +
-        // "    are likely to be bootstrap values instead of branch length values.\n\n"
-        // +
-        // " Remarks regarding SDI (Speciation Duplication Inference):\n"
-        // +
-        // "o  Each external node of the gene tree (in display) needs to be associated with\n"
-        // +
-        // "    a species: either directly through the \"Species\" field, or the species\n"
-        // +
-        // "    is part of the sequence name in the form \"XXXX_SPECIES\"\n"
-        // +
-        // "    (e.g. \"ACON_DROME\" or \"ACON_DROME/123-4489\" which is also acceptable).\n"
-        // +
-        // "o  A species tree for each species of the gene tree needs to be loaded with\n"
-        // +
-        // "   \"SDI\"|\"Load species tree\" prior the SDI execution.\n"
-        // +
-        // "o  !External nodes of the gene tree associated with species not present in\n"
-        // +
-        // "    the species tree are REMOVED prior to SDI execution!\n"
-        // +
-        // "o  Both the gene tree and the species tree must be completely binary.\n"
-        // +
-        // "o  Duplications and speciations are a function of the position of the root.\n"
-        // +
-        // "    Hence, after each manual \"Root/Reroot\"ing some duplications will be\n"
-        // + "    incorrect and need to be inferred again\n"
-        // +
-        // "    with: \"SDI\"|\"SDI (Speciation Duplication Inference)\n\n"
-        sb.append( "\n" );
-        sb.append( "phyloXML\n" );
-        sb.append( "-------------------\n" );
-        sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
-        sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
-        sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
-        sb.append( "\n" );
-        sb.append( "For more information: http://www.phylosoft.org/archaeopteryx/\n" );
-        sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
-        TextFrame.instantiate( sb.toString(), "Help", _textframes );
-    }
-
-    static void setOvPlacementColorChooseMenuItem( final JMenuItem mi, final Options options ) {
-        if ( ( options != null ) && ( options.getOvPlacement() != null ) ) {
-            mi.setText( "Cycle Overview Placement... (current: " + options.getOvPlacement() + ")" );
+    static void cycleOverview( final Options op, final TreePanel tree_panel ) {
+        switch ( op.getOvPlacement() ) {
+            case LOWER_LEFT:
+                op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
+                break;
+            case LOWER_RIGHT:
+                op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
+                break;
+            case UPPER_LEFT:
+                op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
+                break;
+            case UPPER_RIGHT:
+                op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
+                break;
+            default:
+                throw new RuntimeException( "unknown placement: " + op.getOvPlacement() );
         }
-        else {
-            mi.setText( "Cycle Overview Placement..." );
+        if ( tree_panel != null ) {
+            tree_panel.updateOvSettings();
         }
     }
 
@@ -1428,6 +1498,15 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }
     }
 
+    static void setOvPlacementColorChooseMenuItem( final JMenuItem mi, final Options options ) {
+        if ( ( options != null ) && ( options.getOvPlacement() != null ) ) {
+            mi.setText( "Cycle Overview Placement... (current: " + options.getOvPlacement() + ")" );
+        }
+        else {
+            mi.setText( "Cycle Overview Placement..." );
+        }
+    }
+
     static void setTextColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {
         if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {
             mi.setText( "Select Colors... (current: " + tree_panel.getTreeColorSet().getCurrentColorSchemeName() + ")" );
index 2c674fe..6194d47 100644 (file)
@@ -914,6 +914,9 @@ public final class MainFrameApplication extends MainFrame {
         _remove_branch_color_item.setToolTipText( "To delete branch color values from the current phylogeny" );
         customizeJMenuItem( _remove_branch_color_item );
         _tools_menu.addSeparator();
+        _tools_menu.add( _annotate_item = new JMenuItem( "Annotate Sequences of Selected Nodes" ) );
+        customizeJMenuItem( _annotate_item );
+        _tools_menu.addSeparator();
         _tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) );
         customizeJMenuItem( _midpoint_root_item );
         _tools_menu.addSeparator();
index 2a6fdd3..2392620 100644 (file)
@@ -566,7 +566,7 @@ class NodeEditPanel extends JPanel {
     }
 
     private List<Point> obtainPoints() {
-        AptxUtil.ensurePresenceOfDistribution( getMyNode() );
+        ForesterUtil.ensurePresenceOfDistribution( getMyNode() );
         Distribution d = getMyNode().getNodeData().getDistribution();
         if ( d.getPoints() == null ) {
             d = new Distribution( d.getDesc(), new ArrayList<Point>(), d.getPolygons() );
@@ -734,7 +734,7 @@ class NodeEditPanel extends JPanel {
                 }
                 break;
             case TAXONOMY_CODE:
-                AptxUtil.ensurePresenceOfTaxonomy( getMyNode() );
+                ForesterUtil.ensurePresenceOfTaxonomy( getMyNode() );
                 try {
                     getMyNode().getNodeData().getTaxonomy().setTaxonomyCode( value );
                 }
@@ -744,15 +744,15 @@ class NodeEditPanel extends JPanel {
                 }
                 break;
             case TAXONOMY_SCIENTIFIC_NAME:
-                AptxUtil.ensurePresenceOfTaxonomy( getMyNode() );
+                ForesterUtil.ensurePresenceOfTaxonomy( getMyNode() );
                 getMyNode().getNodeData().getTaxonomy().setScientificName( value );
                 break;
             case TAXONOMY_COMMON_NAME:
-                AptxUtil.ensurePresenceOfTaxonomy( getMyNode() );
+                ForesterUtil.ensurePresenceOfTaxonomy( getMyNode() );
                 getMyNode().getNodeData().getTaxonomy().setCommonName( value );
                 break;
             case TAXONOMY_RANK:
-                AptxUtil.ensurePresenceOfTaxonomy( getMyNode() );
+                ForesterUtil.ensurePresenceOfTaxonomy( getMyNode() );
                 try {
                     getMyNode().getNodeData().getTaxonomy().setRank( value.toLowerCase() );
                 }
@@ -762,7 +762,7 @@ class NodeEditPanel extends JPanel {
                 }
                 break;
             case TAXONOMY_AUTHORITY:
-                AptxUtil.ensurePresenceOfTaxonomy( getMyNode() );
+                ForesterUtil.ensurePresenceOfTaxonomy( getMyNode() );
                 getMyNode().getNodeData().getTaxonomy().setAuthority( value );
                 break;
             case TAXONOMY_URI: {
@@ -780,7 +780,7 @@ class NodeEditPanel extends JPanel {
                     }
                 }
                 if ( uri != null ) {
-                    AptxUtil.ensurePresenceOfTaxonomy( getMyNode() );
+                    ForesterUtil.ensurePresenceOfTaxonomy( getMyNode() );
                 }
                 addUri( mtn, uri, number, getMyNode().getNodeData().getTaxonomy() );
                 break;
@@ -791,7 +791,7 @@ class NodeEditPanel extends JPanel {
                 }
                 else if ( getMyNode().getNodeData().getTaxonomy().getSynonyms().size() == number ) {
                     if ( !ForesterUtil.isEmpty( value ) ) {
-                        AptxUtil.ensurePresenceOfTaxonomy( getMyNode() );
+                        ForesterUtil.ensurePresenceOfTaxonomy( getMyNode() );
                         getMyNode().getNodeData().getTaxonomy().getSynonyms().add( value );
                     }
                 }
@@ -800,7 +800,7 @@ class NodeEditPanel extends JPanel {
                 }
                 break;
             case TAXONOMY_ID_VALUE:
-                AptxUtil.ensurePresenceOfTaxonomy( getMyNode() );
+                ForesterUtil.ensurePresenceOfTaxonomy( getMyNode() );
                 if ( getMyNode().getNodeData().getTaxonomy().getIdentifier() == null ) {
                     getMyNode().getNodeData().getTaxonomy().setIdentifier( new Identifier( value ) );
                 }
@@ -810,7 +810,7 @@ class NodeEditPanel extends JPanel {
                 }
                 break;
             case TAXONOMY_ID_PROVIDER:
-                AptxUtil.ensurePresenceOfTaxonomy( getMyNode() );
+                ForesterUtil.ensurePresenceOfTaxonomy( getMyNode() );
                 if ( getMyNode().getNodeData().getTaxonomy().getIdentifier() == null ) {
                     getMyNode().getNodeData().getTaxonomy().setIdentifier( new Identifier( "", value ) );
                 }
@@ -820,19 +820,19 @@ class NodeEditPanel extends JPanel {
                 }
                 break;
             case SEQ_LOCATION:
-                AptxUtil.ensurePresenceOfSequence( getMyNode() );
+                ForesterUtil.ensurePresenceOfSequence( getMyNode() );
                 getMyNode().getNodeData().getSequence().setLocation( value );
                 break;
             case SEQ_MOL_SEQ:
-                AptxUtil.ensurePresenceOfSequence( getMyNode() );
+                ForesterUtil.ensurePresenceOfSequence( getMyNode() );
                 getMyNode().getNodeData().getSequence().setMolecularSequence( value.replaceAll( "[^a-zA-Z-]", "" ) );
                 break;
             case SEQ_NAME:
-                AptxUtil.ensurePresenceOfSequence( getMyNode() );
+                ForesterUtil.ensurePresenceOfSequence( getMyNode() );
                 getMyNode().getNodeData().getSequence().setName( value );
                 break;
             case SEQ_SYMBOL:
-                AptxUtil.ensurePresenceOfSequence( getMyNode() );
+                ForesterUtil.ensurePresenceOfSequence( getMyNode() );
                 try {
                     getMyNode().getNodeData().getSequence().setSymbol( value );
                 }
@@ -842,7 +842,7 @@ class NodeEditPanel extends JPanel {
                 }
                 break;
             case SEQ_TYPE:
-                AptxUtil.ensurePresenceOfSequence( getMyNode() );
+                ForesterUtil.ensurePresenceOfSequence( getMyNode() );
                 try {
                     getMyNode().getNodeData().getSequence().setType( value.toLowerCase() );
                 }
@@ -852,7 +852,7 @@ class NodeEditPanel extends JPanel {
                 }
                 break;
             case SEQ_ACC_SOURCE:
-                AptxUtil.ensurePresenceOfSequence( getMyNode() );
+                ForesterUtil.ensurePresenceOfSequence( getMyNode() );
                 if ( getMyNode().getNodeData().getSequence().getAccession() == null ) {
                     getMyNode().getNodeData().getSequence().setAccession( new Accession( "", value ) );
                 }
@@ -862,7 +862,7 @@ class NodeEditPanel extends JPanel {
                 }
                 break;
             case SEQ_ACC_VALUE:
-                AptxUtil.ensurePresenceOfSequence( getMyNode() );
+                ForesterUtil.ensurePresenceOfSequence( getMyNode() );
                 if ( getMyNode().getNodeData().getSequence().getAccession() == null ) {
                     getMyNode().getNodeData().getSequence().setAccession( new Accession( value, "" ) );
                 }
@@ -886,7 +886,7 @@ class NodeEditPanel extends JPanel {
                     }
                 }
                 if ( uri != null ) {
-                    AptxUtil.ensurePresenceOfSequence( getMyNode() );
+                    ForesterUtil.ensurePresenceOfSequence( getMyNode() );
                 }
                 addUri( mtn, uri, number, getMyNode().getNodeData().getSequence() );
                 break;
@@ -928,23 +928,23 @@ class NodeEditPanel extends JPanel {
                 getMyNode().getNodeData().getEvent().setGeneLosses( parsePositiveInt( mtn, value ) );
                 break;
             case DATE_DESCRIPTION:
-                AptxUtil.ensurePresenceOfDate( getMyNode() );
+                ForesterUtil.ensurePresenceOfDate( getMyNode() );
                 getMyNode().getNodeData().getDate().setDesc( value );
                 break;
             case DATE_MAX:
-                AptxUtil.ensurePresenceOfDate( getMyNode() );
+                ForesterUtil.ensurePresenceOfDate( getMyNode() );
                 getMyNode().getNodeData().getDate().setMax( parseBigDecimal( mtn, value ) );
                 break;
             case DATE_MIN:
-                AptxUtil.ensurePresenceOfDate( getMyNode() );
+                ForesterUtil.ensurePresenceOfDate( getMyNode() );
                 getMyNode().getNodeData().getDate().setMin( parseBigDecimal( mtn, value ) );
                 break;
             case DATE_UNIT:
-                AptxUtil.ensurePresenceOfDate( getMyNode() );
+                ForesterUtil.ensurePresenceOfDate( getMyNode() );
                 getMyNode().getNodeData().getDate().setUnit( value );
                 break;
             case DATE_VALUE:
-                AptxUtil.ensurePresenceOfDate( getMyNode() );
+                ForesterUtil.ensurePresenceOfDate( getMyNode() );
                 getMyNode().getNodeData().getDate().setValue( parseBigDecimal( mtn, value ) );
                 break;
             case DIST_ALT: {
@@ -963,7 +963,7 @@ class NodeEditPanel extends JPanel {
                 break;
             }
             case DIST_DESC: {
-                AptxUtil.ensurePresenceOfDistribution( getMyNode() );
+                ForesterUtil.ensurePresenceOfDistribution( getMyNode() );
                 final Distribution d = getMyNode().getNodeData().getDistribution();
                 getMyNode().getNodeData().setDistribution( new Distribution( value, d.getPoints(), d.getPolygons() ) );
                 break;
index fb1316b..7adf066 100644 (file)
@@ -111,7 +111,6 @@ import org.forester.phylogeny.data.NodeData.NODE_DATA;
 import org.forester.phylogeny.data.NodeVisualization;
 import org.forester.phylogeny.data.NodeVisualization.NodeFill;
 import org.forester.phylogeny.data.NodeVisualization.NodeShape;
-import org.forester.phylogeny.data.PhylogenyData;
 import org.forester.phylogeny.data.PhylogenyDataUtil;
 import org.forester.phylogeny.data.PropertiesMap;
 import org.forester.phylogeny.data.Property;
@@ -223,9 +222,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
     private boolean                         _edited                           = false;
     private Popup                           _node_desc_popup;
     private JTextArea                       _rollover_popup;
-    // private final int                       _box_size;
-    // private final int                       _half_box_size;
-    //private final short                     _skip_counter                     = 0;
     private final StringBuffer              _popup_buffer                     = new StringBuffer();
     final private static Font               POPUP_FONT                        = new Font( Configuration.getDefaultFontFamilyName(),
                                                                                           Font.PLAIN,
@@ -1728,12 +1724,20 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
     final void selectNode( final PhylogenyNode node ) {
         if ( ( getFoundNodes() != null ) && getFoundNodes().contains( node.getId() ) ) {
             getFoundNodes().remove( node.getId() );
+            getControlPanel().setSearchFoundCountsOnLabel( getFoundNodes().size() );
+            if ( getFoundNodes().size() < 1 ) {
+                getControlPanel().searchReset();
+            }
         }
         else {
+            getControlPanel().getSearchFoundCountsLabel().setVisible( true );
+            getControlPanel().getSearchResetButton().setEnabled( true );
+            getControlPanel().getSearchResetButton().setVisible( true );
             if ( getFoundNodes() == null ) {
                 setFoundNodes( new HashSet<Integer>() );
             }
             getFoundNodes().add( node.getId() );
+            getControlPanel().setSearchFoundCountsOnLabel( getFoundNodes().size() );
         }
     }
 
@@ -2244,12 +2248,19 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         }
     }
 
-    final private Color calculateColorForAnnotation( final PhylogenyData ann ) {
+    final private Color calculateColorForAnnotation( final Annotation ann ) {
         Color c = getTreeColorSet().getAnnotationColor();
         if ( getControlPanel().isColorAccordingToAnnotation() && ( getControlPanel().getAnnotationColors() != null ) ) {
-            c = getControlPanel().getAnnotationColors().get( ann.asSimpleText().toString() );
-            if ( c == null ) {
-                c = getTreeColorSet().getAnnotationColor();
+            final String ann_str = !ForesterUtil.isEmpty( ann.getRef() ) ? ann.getRef() : ann.getDesc();
+            if ( !ForesterUtil.isEmpty( ann_str ) ) {
+                c = getControlPanel().getAnnotationColors().get( ann_str );
+                if ( c == null ) {
+                    c = AptxUtil.calculateColorFromString( ann_str );
+                    getControlPanel().getAnnotationColors().put( ann_str, c );
+                }
+                if ( c == null ) {
+                    c = getTreeColorSet().getAnnotationColor();
+                }
             }
         }
         return c;
@@ -3840,6 +3851,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         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().getAnnotation( 0 ) ) );
+        }
         else if ( getOptions().isColorLabelsSameAsParentBranch() && getControlPanel().isColorBranches()
                 && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) {
             g.setColor( PhylogenyMethods.getBranchColorValue( node ) );
@@ -3979,7 +3995,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
                 g.setColor( Color.BLACK );
             }
-            else {
+            else if ( getControlPanel().isColorAccordingToAnnotation() ) {
                 g.setColor( calculateColorForAnnotation( ann ) );
             }
             final String ann_str = ann.asSimpleText().toString();
index 9e651fb..f0ed725 100644 (file)
@@ -34,7 +34,6 @@ import java.util.regex.Matcher;
 
 import javax.swing.JOptionPane;
 
-import org.forester.archaeopteryx.AptxUtil;
 import org.forester.archaeopteryx.MainFrameApplication;
 import org.forester.evoinference.distance.NeighborJoining;
 import org.forester.evoinference.distance.PairwiseDistanceCalculator;
@@ -328,15 +327,15 @@ public class PhylogeneticInferrer extends RunnableProcess {
                     final String seq_name = name_m.group( 3 );
                     final String tax_sn = name_m.group( 4 );
                     if ( !ForesterUtil.isEmpty( acc_source ) && !ForesterUtil.isEmpty( acc ) ) {
-                        AptxUtil.ensurePresenceOfSequence( node );
+                        ForesterUtil.ensurePresenceOfSequence( node );
                         node.getNodeData().getSequence( 0 ).setAccession( new Accession( acc, acc_source ) );
                     }
                     if ( !ForesterUtil.isEmpty( seq_name ) ) {
-                        AptxUtil.ensurePresenceOfSequence( node );
+                        ForesterUtil.ensurePresenceOfSequence( node );
                         node.getNodeData().getSequence( 0 ).setName( seq_name );
                     }
                     if ( !ForesterUtil.isEmpty( tax_sn ) ) {
-                        AptxUtil.ensurePresenceOfTaxonomy( node );
+                        ForesterUtil.ensurePresenceOfTaxonomy( node );
                         node.getNodeData().getTaxonomy( 0 ).setScientificName( tax_sn );
                     }
                 }
index a1d6b22..4e9eb08 100644 (file)
@@ -47,23 +47,28 @@ public class Annotation implements PhylogenyData, MultipleUris, Comparable<Annot
 
     public Annotation( final String ref ) {
         if ( ForesterUtil.isEmpty( ref ) ) {
-            throw new IllegalArgumentException( "illegal attempt to create Annotation with null or empty reference" );
+            throw new IllegalArgumentException( "annotation reference is empty or null" );
         }
         if ( ( ref.indexOf( ':' ) < 1 ) || ( ref.length() < 3 ) ) {
-            throw new IllegalArgumentException( "illegal format for Annotation reference: [" + ref + "]" );
+            throw new IllegalArgumentException( "illegal format for annotation reference: [" + ref + "]" );
         }
         _ref = ref;
         init();
     }
 
+    public Annotation() {
+        _ref = "";
+        init();
+    }
+
     @Override
     public StringBuffer asSimpleText() {
-        return new StringBuffer( getDesc() );
+        return new StringBuffer( !ForesterUtil.isEmpty( getRef() ) ? getRef() : getDesc() );
     }
 
     @Override
     public StringBuffer asText() {
-        return new StringBuffer( getDesc() );
+        return asSimpleText();
     }
 
     @Override
index 2bf5ad2..7e70444 100644 (file)
@@ -31,7 +31,6 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.regex.Pattern;
 
-import org.forester.archaeopteryx.AptxUtil;
 import org.forester.io.parsers.nhx.NHXFormatException;
 import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException;
 import org.forester.phylogeny.Phylogeny;
@@ -92,63 +91,63 @@ public final class PhylogenyDecorator {
                     }
                     if ( new_values != null ) {
                         if ( new_values.containsKey( TP_TAXONOMY_CODE ) ) {
-                            AptxUtil.ensurePresenceOfTaxonomy( node );
+                            ForesterUtil.ensurePresenceOfTaxonomy( node );
                             node.getNodeData().getTaxonomy().setTaxonomyCode( new_values.get( TP_TAXONOMY_CODE ) );
                         }
                         if ( new_values.containsKey( TP_TAXONOMY_ID )
                                 && new_values.containsKey( TP_TAXONOMY_ID_PROVIDER ) ) {
-                            AptxUtil.ensurePresenceOfTaxonomy( node );
+                            ForesterUtil.ensurePresenceOfTaxonomy( node );
                             node.getNodeData()
                                     .getTaxonomy()
                                     .setIdentifier( new Identifier( new_values.get( TP_TAXONOMY_ID ),
                                                                     new_values.get( TP_TAXONOMY_ID_PROVIDER ) ) );
                         }
                         else if ( new_values.containsKey( TP_TAXONOMY_ID ) ) {
-                            AptxUtil.ensurePresenceOfTaxonomy( node );
+                            ForesterUtil.ensurePresenceOfTaxonomy( node );
                             node.getNodeData().getTaxonomy()
                                     .setIdentifier( new Identifier( new_values.get( TP_TAXONOMY_ID ) ) );
                         }
                         if ( new_values.containsKey( TP_TAXONOMY_SN ) ) {
-                            AptxUtil.ensurePresenceOfTaxonomy( node );
+                            ForesterUtil.ensurePresenceOfTaxonomy( node );
                             node.getNodeData().getTaxonomy().setScientificName( new_values.get( TP_TAXONOMY_SN ) );
                         }
                         if ( new_values.containsKey( TP_TAXONOMY_CN ) ) {
-                            AptxUtil.ensurePresenceOfTaxonomy( node );
+                            ForesterUtil.ensurePresenceOfTaxonomy( node );
                             node.getNodeData().getTaxonomy().setCommonName( new_values.get( TP_TAXONOMY_CN ) );
                         }
                         if ( new_values.containsKey( TP_TAXONOMY_SYN ) ) {
-                            AptxUtil.ensurePresenceOfTaxonomy( node );
+                            ForesterUtil.ensurePresenceOfTaxonomy( node );
                             node.getNodeData().getTaxonomy().getSynonyms().add( new_values.get( TP_TAXONOMY_SYN ) );
                         }
                         if ( new_values.containsKey( TP_SEQ_ACCESSION )
                                 && new_values.containsKey( TP_SEQ_ACCESSION_SOURCE ) ) {
-                            AptxUtil.ensurePresenceOfSequence( node );
+                            ForesterUtil.ensurePresenceOfSequence( node );
                             node.getNodeData()
                                     .getSequence()
                                     .setAccession( new Accession( new_values.get( TP_SEQ_ACCESSION ),
                                                                   new_values.get( TP_SEQ_ACCESSION_SOURCE ) ) );
                         }
                         if ( new_values.containsKey( TP_SEQ_ANNOTATION_DESC ) ) {
-                            AptxUtil.ensurePresenceOfSequence( node );
-                            final Annotation ann = new Annotation( "?" );
+                            ForesterUtil.ensurePresenceOfSequence( node );
+                            final Annotation ann = new Annotation();
                             ann.setDesc( new_values.get( TP_SEQ_ANNOTATION_DESC ) );
                             node.getNodeData().getSequence().addAnnotation( ann );
                         }
                         if ( new_values.containsKey( TP_SEQ_ANNOTATION_REF ) ) {
-                            AptxUtil.ensurePresenceOfSequence( node );
+                            ForesterUtil.ensurePresenceOfSequence( node );
                             final Annotation ann = new Annotation( new_values.get( TP_SEQ_ANNOTATION_REF ) );
                             node.getNodeData().getSequence().addAnnotation( ann );
                         }
                         if ( new_values.containsKey( TP_SEQ_SYMBOL ) ) {
-                            AptxUtil.ensurePresenceOfSequence( node );
+                            ForesterUtil.ensurePresenceOfSequence( node );
                             node.getNodeData().getSequence().setSymbol( new_values.get( TP_SEQ_SYMBOL ) );
                         }
                         if ( new_values.containsKey( TP_SEQ_NAME ) ) {
-                            AptxUtil.ensurePresenceOfSequence( node );
+                            ForesterUtil.ensurePresenceOfSequence( node );
                             node.getNodeData().getSequence().setName( new_values.get( TP_SEQ_NAME ) );
                         }
                         if ( new_values.containsKey( TP_SEQ_MOL_SEQ ) ) {
-                            AptxUtil.ensurePresenceOfSequence( node );
+                            ForesterUtil.ensurePresenceOfSequence( node );
                             node.getNodeData().getSequence().setMolecularSequence( new_values.get( TP_SEQ_MOL_SEQ ) );
                         }
                         if ( new_values.containsKey( TP_NODE_NAME ) ) {
@@ -306,14 +305,14 @@ public final class PhylogenyDecorator {
                                 if ( PhylogenyDecorator.VERBOSE ) {
                                     System.out.println( name + ": " + new_value );
                                 }
-                                AptxUtil.ensurePresenceOfTaxonomy( node );
+                                ForesterUtil.ensurePresenceOfTaxonomy( node );
                                 node.getNodeData().getTaxonomy().setTaxonomyCode( new_value );
                                 break;
                             case TAXONOMY_SCIENTIFIC_NAME:
                                 if ( PhylogenyDecorator.VERBOSE ) {
                                     System.out.println( name + ": " + new_value );
                                 }
-                                AptxUtil.ensurePresenceOfTaxonomy( node );
+                                ForesterUtil.ensurePresenceOfTaxonomy( node );
                                 node.getNodeData().getTaxonomy().setScientificName( new_value );
                                 break;
                             case SEQUENCE_NAME:
@@ -445,7 +444,7 @@ public final class PhylogenyDecorator {
     private static String extractBracketedScientificNames( final PhylogenyNode node, final String new_value ) {
         final int i = new_value.lastIndexOf( "[" );
         final String scientific_name = new_value.substring( i + 1, new_value.length() - 1 );
-        AptxUtil.ensurePresenceOfTaxonomy( node );
+        ForesterUtil.ensurePresenceOfTaxonomy( node );
         node.getNodeData().getTaxonomy().setScientificName( scientific_name );
         return new_value.substring( 0, i - 1 ).trim();
     }
@@ -453,7 +452,7 @@ public final class PhylogenyDecorator {
     private static String extractBracketedTaxCodes( final PhylogenyNode node, final String new_value ) {
         final int i = new_value.lastIndexOf( "[" );
         final String tc = new_value.substring( i + 1, new_value.length() - 1 );
-        AptxUtil.ensurePresenceOfTaxonomy( node );
+        ForesterUtil.ensurePresenceOfTaxonomy( node );
         try {
             node.getNodeData().getTaxonomy().setTaxonomyCode( tc );
         }
index 9d9570d..043df39 100644 (file)
@@ -61,6 +61,11 @@ import java.util.TreeMap;
 import java.util.TreeSet;
 import java.util.regex.Pattern;
 
+import org.forester.phylogeny.PhylogenyNode;
+import org.forester.phylogeny.data.Distribution;
+import org.forester.phylogeny.data.Sequence;
+import org.forester.phylogeny.data.Taxonomy;
+
 public final class ForesterUtil {
 
     public final static String       FILE_SEPARATOR                   = System.getProperty( "file.separator" );
@@ -90,6 +95,30 @@ public final class ForesterUtil {
     private ForesterUtil() {
     }
 
+    public static void ensurePresenceOfTaxonomy( final PhylogenyNode node ) {
+        if ( !node.getNodeData().isHasTaxonomy() ) {
+            node.getNodeData().setTaxonomy( new Taxonomy() );
+        }
+    }
+
+    public static void ensurePresenceOfSequence( final PhylogenyNode node ) {
+        if ( !node.getNodeData().isHasSequence() ) {
+            node.getNodeData().setSequence( new Sequence() );
+        }
+    }
+
+    final public static void ensurePresenceOfDistribution( final PhylogenyNode node ) {
+        if ( !node.getNodeData().isHasDistribution() ) {
+            node.getNodeData().setDistribution( new Distribution( "" ) );
+        }
+    }
+
+    final public static void ensurePresenceOfDate( final PhylogenyNode node ) {
+        if ( !node.getNodeData().isHasDate() ) {
+            node.getNodeData().setDate( new org.forester.phylogeny.data.Date() );
+        }
+    }
+
     final public static void appendSeparatorIfNotEmpty( final StringBuffer sb, final char separator ) {
         if ( sb.length() > 0 ) {
             sb.append( separator );