1st fix of embedded applet null pointer "issue"... ^^
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Tue, 9 Oct 2012 07:04:13 +0000 (07:04 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Tue, 9 Oct 2012 07:04:13 +0000 (07:04 +0000)
forester/java/src/org/forester/archaeopteryx/AptxUtil.java
forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java
forester/java/src/org/forester/archaeopteryx/MainFrame.java
forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java
forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java
forester/java/src/org/forester/archaeopteryx/TextFrame.java
forester/java/src/org/forester/archaeopteryx/TreePanel.java
forester/java/src/org/forester/phylogeny/PhylogenyNode.java

index e355967..1942bbe 100644 (file)
@@ -581,7 +581,7 @@ public final class AptxUtil {
             }
             desc.append( "\n" );
             final DescriptiveStatistics bs = PhylogenyMethods.calculatBranchLengthStatistics( phy );
-            if ( bs.getN() > 2 ) {
+            if ( bs.getN() > 3 ) {
                 desc.append( "\n" );
                 desc.append( "Branch-length statistics: " );
                 desc.append( "\n" );
@@ -597,9 +597,11 @@ public final class AptxUtil {
                 desc.append( "\n" );
                 desc.append( "    Maximum: " + ForesterUtil.round( bs.getMax(), 6 ) );
                 desc.append( "\n" );
-                desc.append( "\n" );
-                final AsciiHistogram histo = new AsciiHistogram( bs );
-                desc.append( histo.toStringBuffer( 12, '#', 40, 7, "    " ) );
+                if ( Math.abs( bs.getMax() - bs.getMin() ) > 0.0001 ) {
+                    desc.append( "\n" );
+                    final AsciiHistogram histo = new AsciiHistogram( bs );
+                    desc.append( histo.toStringBuffer( 12, '#', 40, 7, "    " ) );
+                }
             }
             final DescriptiveStatistics ds = PhylogenyMethods.calculatNumberOfDescendantsPerNodeStatistics( phy );
             if ( ds.getN() > 2 ) {
index 6b3f74f..b72d1b5 100644 (file)
@@ -11,7 +11,10 @@ import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.net.URL;
+import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
 
 import javax.swing.ButtonGroup;
 import javax.swing.JApplet;
@@ -62,7 +65,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
     private JMenuItem            _small_fonts_mi;
     private JMenuItem            _medium_fonts_mi;
     private JMenuItem            _large_fonts_mi;
-    private TextFrame            _textframe;
     private JMenu                _tools_menu;
     private JMenuItem            _taxcolor_item;
     private JMenuItem            _confcolor_item;
@@ -119,6 +121,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
     private JMenuItem            _choose_node_size_mi;
     private JCheckBoxMenuItem    _taxonomy_colorize_node_shapes_cbmi;
     private JCheckBoxMenuItem    _show_confidence_stddev_cbmi;
+    final LinkedList<TextFrame>  _textframes      = new LinkedList<TextFrame>(); ;
 
     @Override
     public void actionPerformed( final ActionEvent e ) {
@@ -281,7 +284,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
             MainFrame.about();
         }
         else if ( o == _help_item ) {
-            MainFrame.help( getConfiguration().getWebLinks() );
+            help( getConfiguration().getWebLinks() );
         }
         else if ( o == _website_item ) {
             try {
@@ -318,6 +321,64 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         repaint();
     }
 
+    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" );
+            }
+        }
+        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 );
+    }
+
     /**
      * This method returns the current phylogeny as a string in the chosen format
      * 
@@ -326,7 +387,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
      * @author Herve Menager
      */
     public String getCurrentPhylogeny( final String format ) {
-        removeTextFrame();
+        removeAllTextFrames();
         if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty()
                 || ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
             return new String();
@@ -652,7 +713,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
     @Override
     public void destroy() {
         AptxUtil.printAppletMessage( NAME, "going to be destroyed " );
-        removeTextFrame();
+        removeAllTextFrames();
         if ( getMainPanel() != null ) {
             getMainPanel().terminate();
         }
@@ -843,13 +904,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         }
     }
 
-    void removeTextFrame() {
-        if ( _textframe != null ) {
-            _textframe.close();
-            _textframe = null;
-        }
-    }
-
     void setConfiguration( final Configuration configuration ) {
         _configuration = configuration;
     }
@@ -1069,40 +1123,88 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         ( ( JCheckBoxMenuItem ) o ).setSelected( true );
     }
 
+    void displayBasicInformation() {
+        if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
+            String title = "Basic Information";
+            if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
+                title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
+            }
+            showTextFrame( AptxUtil.createBasicInformation( getMainPanel().getCurrentPhylogeny() ), title );
+        }
+    }
+
     void viewAsNexus() {
         if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
+            String title = "Nexus";
+            if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
+                title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
+            }
             showTextFrame( getMainPanel().getCurrentPhylogeny().toNexus( getOptions()
-                    .getNhConversionSupportValueStyle() ) );
+                                   .getNhConversionSupportValueStyle() ),
+                           title );
         }
     }
 
     void viewAsNH() {
         if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
-            showTextFrame( getMainPanel().getCurrentPhylogeny().toNewHampshire() );
+            String title = "New Hampshire";
+            if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
+                title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
+            }
+            showTextFrame( getMainPanel().getCurrentPhylogeny()
+                                   .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ),
+                           title );
         }
     }
 
     void viewAsNHX() {
         if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
-            showTextFrame( getMainPanel().getCurrentPhylogeny().toNewHampshireX() );
+            String title = "NHX";
+            if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
+                title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
+            }
+            showTextFrame( getMainPanel().getCurrentPhylogeny().toNewHampshireX(), title );
         }
     }
 
     void viewAsXML() {
         if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
-            showTextFrame( getMainPanel().getCurrentPhylogeny().toPhyloXML( 0 ) );
+            String title = "phyloXML";
+            if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
+                title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
+            }
+            showTextFrame( getMainPanel().getCurrentPhylogeny().toPhyloXML( 0 ), title );
         }
     }
 
-    void displayBasicInformation() {
-        if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
-            showTextFrame( AptxUtil.createBasicInformation( getMainPanel().getCurrentPhylogeny() ) );
+    public void showTextFrame( final String s, final String title ) {
+        checkTextFrames();
+        _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
+    }
+
+    void checkTextFrames() {
+        if ( _textframes.size() > 5 ) {
+            try {
+                if ( _textframes.getFirst() != null ) {
+                    _textframes.getFirst().removeMe();
+                }
+                else {
+                    _textframes.removeFirst();
+                }
+            }
+            catch ( final NoSuchElementException e ) {
+                // Ignore.
+            }
         }
     }
 
-    public void showTextFrame( final String s ) {
-        removeTextFrame();
-        _textframe = TextFrame.instantiate( s );
+    void removeAllTextFrames() {
+        for( final TextFrame tf : _textframes ) {
+            if ( tf != null ) {
+                tf.close();
+            }
+        }
+        _textframes.clear();
     }
 
     static void setupScreenTextAntialias( final List<TreePanel> treepanels, final boolean antialias ) {
index 3cffdf0..8d5a4e7 100644 (file)
@@ -31,9 +31,11 @@ import java.awt.Font;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.io.IOException;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.NoSuchElementException;
 
 import javax.swing.JApplet;
 import javax.swing.JCheckBoxMenuItem;
@@ -60,164 +62,164 @@ import org.forester.util.ForesterUtil;
 
 public abstract class MainFrame extends JFrame implements ActionListener {
 
-    static final String       USE_MOUSEWHEEL_SHIFT_TO_ROTATE          = "In this display type, use mousewheel + Shift to rotate [or A and S]";
-    static final String       PHYLOXML_REF_TOOL_TIP                   = Constants.PHYLOXML_REFERENCE;                                                                                                                                       //TODO //FIXME
-    static final String       APTX_REF_TOOL_TIP                       = Constants.APTX_REFERENCE;
-    private static final long serialVersionUID                        = 3655000897845508358L;
-    final static Font         menu_font                               = new Font( Configuration.getDefaultFontFamilyName(),
-                                                                                  Font.PLAIN,
-                                                                                  10 );
-    static final String       TYPE_MENU_HEADER                        = "Type";
-    static final String       RECTANGULAR_TYPE_CBMI_LABEL             = "Rectangular";
-    static final String       EURO_TYPE_CBMI_LABEL                    = "Euro Type";
-    static final String       CURVED_TYPE_CBMI_LABEL                  = "Curved";
-    static final String       TRIANGULAR_TYPE_CBMI_LABEL              = "Triangular";
-    static final String       CONVEX_TYPE_CBMI_LABEL                  = "Convex";
-    static final String       ROUNDED_TYPE_CBMI_LABEL                 = "Rounded";
-    static final String       UNROOTED_TYPE_CBMI_LABEL                = "Unrooted (alpha)";                                                                                                                                                 //TODO
-    static final String       CIRCULAR_TYPE_CBMI_LABEL                = "Circular (alpha)";                                                                                                                                                 //TODO
-    static final String       OPTIONS_HEADER                          = "Options";
-    static final String       SEARCH_SUBHEADER                        = "Search:";
-    static final String       DISPLAY_SUBHEADER                       = "Display:";
-    static final String       SEARCH_TERMS_ONLY_LABEL                 = "Match Complete Terms Only";
-    static final String       SEARCH_CASE_SENSITIVE_LABEL             = "Case Sensitive";
-    static final String       INVERSE_SEARCH_RESULT_LABEL             = "Negate Result";
-    static final String       DISPLAY_BRANCH_LENGTH_VALUES_LABEL      = "Display Branch Length Values";
-    static final String       DISPLAY_SCALE_LABEL                     = "Display Scale";
-    static final String       NON_LINED_UP_CLADOGRAMS_LABEL           = "Non-Lined Up Cladograms";
-    static final String       UNIFORM_CLADOGRAMS_LABEL                = "Total Node Sum Dependent Cladograms";
-    static final String       LABEL_DIRECTION_LABEL                   = "Radial Labels";
-    static final String       LABEL_DIRECTION_TIP                     = "To use radial node labels in radial and unrooted display types";
-    static final String       SCREEN_ANTIALIAS_LABEL                  = "Antialias";
-    static final String       COLOR_LABELS_LABEL                      = "Colorize Labels Same as Parent Branch";
-    static final String       BG_GRAD_LABEL                           = "Background Color Gradient";
-    static final String       DISPLAY_NODE_BOXES_LABEL                = "Show Node Shapes";
-    static final String       SHOW_OVERVIEW_LABEL                     = "Show Overview";
-    static final String       FONT_SIZE_MENU_LABEL                    = "Font Size";
-    static final String       NONUNIFORM_CLADOGRAMS_LABEL             = "External Node Sum Dependent Cladograms";
-    static final String       SHOW_DOMAIN_LABELS_LABEL                = "Show Domain Labels";
-    static final String       COLOR_LABELS_TIP                        = "To use parent branch colors for node labels as well, need to turn off taxonomy dependent colorization and turn on branch colorization for this to become apparent";
-    static final String       ABBREV_SN_LABEL                         = "Abbreviate Scientific Taxonomic Names";
-    static final String       TAXONOMY_COLORIZE_NODE_SHAPES_LABEL     = "Colorize Node Shapes According to Taxonomy";
-    static final String       CYCLE_NODE_SHAPE_LABEL                  = "Cycle Node Shapes";
-    static final String       CYCLE_NODE_FILL_LABEL                   = "Cycle Node Fill Type";
-    static final String       CHOOSE_NODE_SIZE_LABEL                  = "Choose Node Shape Size";
-    static final String       SHOW_CONF_STDDEV_LABEL                  = "Show Confidence Standard Deviations";
-    static final String       USE_BRACKETS_FOR_CONF_IN_NH_LABEL       = "Use Brackets for Confidence Values";
-    static final String       USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL = "Use Internal Node Names for Confidence Values";
-    JMenuBar                  _jmenubar;
-    JMenu                     _file_jmenu;
-    JMenu                     _tools_menu;
-    JMenu                     _view_jmenu;
-    JMenu                     _options_jmenu;
-    JMenu                     _font_size_menu;
-    JMenu                     _help_jmenu;
-    JMenuItem[]               _load_phylogeny_from_webservice_menu_items;
+    static final String         USE_MOUSEWHEEL_SHIFT_TO_ROTATE          = "In this display type, use mousewheel + Shift to rotate [or A and S]";
+    static final String         PHYLOXML_REF_TOOL_TIP                   = Constants.PHYLOXML_REFERENCE;                                                                                                                                       //TODO //FIXME
+    static final String         APTX_REF_TOOL_TIP                       = Constants.APTX_REFERENCE;
+    private static final long   serialVersionUID                        = 3655000897845508358L;
+    final static Font           menu_font                               = new Font( Configuration.getDefaultFontFamilyName(),
+                                                                                    Font.PLAIN,
+                                                                                    10 );
+    static final String         TYPE_MENU_HEADER                        = "Type";
+    static final String         RECTANGULAR_TYPE_CBMI_LABEL             = "Rectangular";
+    static final String         EURO_TYPE_CBMI_LABEL                    = "Euro Type";
+    static final String         CURVED_TYPE_CBMI_LABEL                  = "Curved";
+    static final String         TRIANGULAR_TYPE_CBMI_LABEL              = "Triangular";
+    static final String         CONVEX_TYPE_CBMI_LABEL                  = "Convex";
+    static final String         ROUNDED_TYPE_CBMI_LABEL                 = "Rounded";
+    static final String         UNROOTED_TYPE_CBMI_LABEL                = "Unrooted (alpha)";                                                                                                                                                 //TODO
+    static final String         CIRCULAR_TYPE_CBMI_LABEL                = "Circular (alpha)";                                                                                                                                                 //TODO
+    static final String         OPTIONS_HEADER                          = "Options";
+    static final String         SEARCH_SUBHEADER                        = "Search:";
+    static final String         DISPLAY_SUBHEADER                       = "Display:";
+    static final String         SEARCH_TERMS_ONLY_LABEL                 = "Match Complete Terms Only";
+    static final String         SEARCH_CASE_SENSITIVE_LABEL             = "Case Sensitive";
+    static final String         INVERSE_SEARCH_RESULT_LABEL             = "Negate Result";
+    static final String         DISPLAY_BRANCH_LENGTH_VALUES_LABEL      = "Display Branch Length Values";
+    static final String         DISPLAY_SCALE_LABEL                     = "Display Scale";
+    static final String         NON_LINED_UP_CLADOGRAMS_LABEL           = "Non-Lined Up Cladograms";
+    static final String         UNIFORM_CLADOGRAMS_LABEL                = "Total Node Sum Dependent Cladograms";
+    static final String         LABEL_DIRECTION_LABEL                   = "Radial Labels";
+    static final String         LABEL_DIRECTION_TIP                     = "To use radial node labels in radial and unrooted display types";
+    static final String         SCREEN_ANTIALIAS_LABEL                  = "Antialias";
+    static final String         COLOR_LABELS_LABEL                      = "Colorize Labels Same as Parent Branch";
+    static final String         BG_GRAD_LABEL                           = "Background Color Gradient";
+    static final String         DISPLAY_NODE_BOXES_LABEL                = "Show Node Shapes";
+    static final String         SHOW_OVERVIEW_LABEL                     = "Show Overview";
+    static final String         FONT_SIZE_MENU_LABEL                    = "Font Size";
+    static final String         NONUNIFORM_CLADOGRAMS_LABEL             = "External Node Sum Dependent Cladograms";
+    static final String         SHOW_DOMAIN_LABELS_LABEL                = "Show Domain Labels";
+    static final String         COLOR_LABELS_TIP                        = "To use parent branch colors for node labels as well, need to turn off taxonomy dependent colorization and turn on branch colorization for this to become apparent";
+    static final String         ABBREV_SN_LABEL                         = "Abbreviate Scientific Taxonomic Names";
+    static final String         TAXONOMY_COLORIZE_NODE_SHAPES_LABEL     = "Colorize Node Shapes According to Taxonomy";
+    static final String         CYCLE_NODE_SHAPE_LABEL                  = "Cycle Node Shapes";
+    static final String         CYCLE_NODE_FILL_LABEL                   = "Cycle Node Fill Type";
+    static final String         CHOOSE_NODE_SIZE_LABEL                  = "Choose Node Shape Size";
+    static final String         SHOW_CONF_STDDEV_LABEL                  = "Show Confidence Standard Deviations";
+    static final String         USE_BRACKETS_FOR_CONF_IN_NH_LABEL       = "Use Brackets for Confidence Values";
+    static final String         USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL = "Use Internal Node Names for Confidence Values";
+    JMenuBar                    _jmenubar;
+    JMenu                       _file_jmenu;
+    JMenu                       _tools_menu;
+    JMenu                       _view_jmenu;
+    JMenu                       _options_jmenu;
+    JMenu                       _font_size_menu;
+    JMenu                       _help_jmenu;
+    JMenuItem[]                 _load_phylogeny_from_webservice_menu_items;
     // file menu:
-    JMenuItem                 _open_item;
-    JMenuItem                 _open_url_item;
-    JMenuItem                 _save_item;
-    JMenuItem                 _save_all_item;
-    JMenuItem                 _close_item;
-    JMenuItem                 _exit_item;
-    JMenuItem                 _new_item;
+    JMenuItem                   _open_item;
+    JMenuItem                   _open_url_item;
+    JMenuItem                   _save_item;
+    JMenuItem                   _save_all_item;
+    JMenuItem                   _close_item;
+    JMenuItem                   _exit_item;
+    JMenuItem                   _new_item;
     // tools menu:
-    JMenuItem                 _midpoint_root_item;
-    JMenuItem                 _taxcolor_item;
-    JMenuItem                 _confcolor_item;
-    JMenuItem                 _color_rank_jmi;
-    JMenuItem                 _infer_common_sn_names_item;
-    JMenuItem                 _collapse_species_specific_subtrees;
-    JMenuItem                 _collapse_below_threshold;                                                                                                                                                                                    //TODO implememt me
-    JMenuItem                 _obtain_detailed_taxonomic_information_jmi;
-    JMenuItem                 _obtain_detailed_taxonomic_information_deleting_jmi;
-    JMenuItem                 _obtain_uniprot_seq_information_jmi;
-    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                   _midpoint_root_item;
+    JMenuItem                   _taxcolor_item;
+    JMenuItem                   _confcolor_item;
+    JMenuItem                   _color_rank_jmi;
+    JMenuItem                   _infer_common_sn_names_item;
+    JMenuItem                   _collapse_species_specific_subtrees;
+    JMenuItem                   _collapse_below_threshold;                                                                                                                                                                                    //TODO implememt me
+    JMenuItem                   _obtain_detailed_taxonomic_information_jmi;
+    JMenuItem                   _obtain_detailed_taxonomic_information_deleting_jmi;
+    JMenuItem                   _obtain_uniprot_seq_information_jmi;
+    JMenuItem                   _move_node_names_to_tax_sn_jmi;
+    JMenuItem                   _move_node_names_to_seq_names_jmi;
+    JMenuItem                   _extract_tax_code_from_node_names_jmi;
     // font size menu:
-    JMenuItem                 _super_tiny_fonts_item;
-    JMenuItem                 _tiny_fonts_item;
-    JMenuItem                 _small_fonts_item;
-    JMenuItem                 _medium_fonts_item;
-    JMenuItem                 _large_fonts_item;
+    JMenuItem                   _super_tiny_fonts_item;
+    JMenuItem                   _tiny_fonts_item;
+    JMenuItem                   _small_fonts_item;
+    JMenuItem                   _medium_fonts_item;
+    JMenuItem                   _large_fonts_item;
     // options menu:
     // _  screen and print
-    JMenuItem                 _choose_font_mi;
-    JMenuItem                 _switch_colors_mi;
-    JCheckBoxMenuItem         _label_direction_cbmi;
+    JMenuItem                   _choose_font_mi;
+    JMenuItem                   _switch_colors_mi;
+    JCheckBoxMenuItem           _label_direction_cbmi;
     // _  screen display
-    JCheckBoxMenuItem         _screen_antialias_cbmi;
-    JCheckBoxMenuItem         _background_gradient_cbmi;
-    JRadioButtonMenuItem      _non_lined_up_cladograms_rbmi;
-    JRadioButtonMenuItem      _uniform_cladograms_rbmi;
-    JRadioButtonMenuItem      _ext_node_dependent_cladogram_rbmi;
-    JCheckBoxMenuItem         _show_branch_length_values_cbmi;
-    JCheckBoxMenuItem         _show_scale_cbmi;                                                                                                                                                                                             //TODO fix me
-    JCheckBoxMenuItem         _show_overview_cbmi;
-    JCheckBoxMenuItem         _show_domain_labels;
-    JCheckBoxMenuItem         _abbreviate_scientific_names;
-    JCheckBoxMenuItem         _color_labels_same_as_parent_branch;
-    JMenuItem                 _overview_placment_mi;
-    JMenuItem                 _choose_minimal_confidence_mi;
-    JCheckBoxMenuItem         _show_default_node_shapes_cbmi;
-    JMenuItem                 _cycle_node_shape_mi;
-    JMenuItem                 _cycle_node_fill_mi;
-    JMenuItem                 _choose_node_size_mi;
-    JCheckBoxMenuItem         _taxonomy_colorize_node_shapes_cbmi;
-    JCheckBoxMenuItem         _show_confidence_stddev_cbmi;
+    JCheckBoxMenuItem           _screen_antialias_cbmi;
+    JCheckBoxMenuItem           _background_gradient_cbmi;
+    JRadioButtonMenuItem        _non_lined_up_cladograms_rbmi;
+    JRadioButtonMenuItem        _uniform_cladograms_rbmi;
+    JRadioButtonMenuItem        _ext_node_dependent_cladogram_rbmi;
+    JCheckBoxMenuItem           _show_branch_length_values_cbmi;
+    JCheckBoxMenuItem           _show_scale_cbmi;                                                                                                                                                                                             //TODO fix me
+    JCheckBoxMenuItem           _show_overview_cbmi;
+    JCheckBoxMenuItem           _show_domain_labels;
+    JCheckBoxMenuItem           _abbreviate_scientific_names;
+    JCheckBoxMenuItem           _color_labels_same_as_parent_branch;
+    JMenuItem                   _overview_placment_mi;
+    JMenuItem                   _choose_minimal_confidence_mi;
+    JCheckBoxMenuItem           _show_default_node_shapes_cbmi;
+    JMenuItem                   _cycle_node_shape_mi;
+    JMenuItem                   _cycle_node_fill_mi;
+    JMenuItem                   _choose_node_size_mi;
+    JCheckBoxMenuItem           _taxonomy_colorize_node_shapes_cbmi;
+    JCheckBoxMenuItem           _show_confidence_stddev_cbmi;
     // _  print
-    JCheckBoxMenuItem         _graphics_export_visible_only_cbmi;
-    JCheckBoxMenuItem         _antialias_print_cbmi;
-    JCheckBoxMenuItem         _print_black_and_white_cbmi;
-    JCheckBoxMenuItem         _print_using_actual_size_cbmi;
-    JCheckBoxMenuItem         _graphics_export_using_actual_size_cbmi;
-    JMenuItem                 _print_size_mi;
-    JMenuItem                 _choose_pdf_width_mi;
+    JCheckBoxMenuItem           _graphics_export_visible_only_cbmi;
+    JCheckBoxMenuItem           _antialias_print_cbmi;
+    JCheckBoxMenuItem           _print_black_and_white_cbmi;
+    JCheckBoxMenuItem           _print_using_actual_size_cbmi;
+    JCheckBoxMenuItem           _graphics_export_using_actual_size_cbmi;
+    JMenuItem                   _print_size_mi;
+    JMenuItem                   _choose_pdf_width_mi;
     // _  parsing
-    JCheckBoxMenuItem         _internal_number_are_confidence_for_nh_parsing_cbmi;
-    JCheckBoxMenuItem         _extract_pfam_style_tax_codes_cbmi;
-    JCheckBoxMenuItem         _replace_underscores_cbmi;
-    JCheckBoxMenuItem         _use_brackets_for_conf_in_nh_export_cbmi;
-    JCheckBoxMenuItem         _use_internal_names_for_conf_in_nh_export_cbmi;
+    JCheckBoxMenuItem           _internal_number_are_confidence_for_nh_parsing_cbmi;
+    JCheckBoxMenuItem           _extract_pfam_style_tax_codes_cbmi;
+    JCheckBoxMenuItem           _replace_underscores_cbmi;
+    JCheckBoxMenuItem           _use_brackets_for_conf_in_nh_export_cbmi;
+    JCheckBoxMenuItem           _use_internal_names_for_conf_in_nh_export_cbmi;
     // _  search
-    JCheckBoxMenuItem         _search_case_senstive_cbmi;
-    JCheckBoxMenuItem         _search_whole_words_only_cbmi;
-    JCheckBoxMenuItem         _inverse_search_result_cbmi;
+    JCheckBoxMenuItem           _search_case_senstive_cbmi;
+    JCheckBoxMenuItem           _search_whole_words_only_cbmi;
+    JCheckBoxMenuItem           _inverse_search_result_cbmi;
     // type menu:
-    JMenu                     _type_menu;
-    JCheckBoxMenuItem         _rectangular_type_cbmi;
-    JCheckBoxMenuItem         _triangular_type_cbmi;
-    JCheckBoxMenuItem         _curved_type_cbmi;
-    JCheckBoxMenuItem         _convex_type_cbmi;
-    JCheckBoxMenuItem         _euro_type_cbmi;
-    JCheckBoxMenuItem         _rounded_type_cbmi;
-    JCheckBoxMenuItem         _unrooted_type_cbmi;
-    JCheckBoxMenuItem         _circular_type_cbmi;
+    JMenu                       _type_menu;
+    JCheckBoxMenuItem           _rectangular_type_cbmi;
+    JCheckBoxMenuItem           _triangular_type_cbmi;
+    JCheckBoxMenuItem           _curved_type_cbmi;
+    JCheckBoxMenuItem           _convex_type_cbmi;
+    JCheckBoxMenuItem           _euro_type_cbmi;
+    JCheckBoxMenuItem           _rounded_type_cbmi;
+    JCheckBoxMenuItem           _unrooted_type_cbmi;
+    JCheckBoxMenuItem           _circular_type_cbmi;
     // view as text menu:
-    JMenuItem                 _view_as_NH_item;
-    JMenuItem                 _view_as_NHX_item;
-    JMenuItem                 _view_as_XML_item;
-    JMenuItem                 _view_as_nexus_item;
-    JMenuItem                 _display_basic_information_item;
+    JMenuItem                   _view_as_NH_item;
+    JMenuItem                   _view_as_NHX_item;
+    JMenuItem                   _view_as_XML_item;
+    JMenuItem                   _view_as_nexus_item;
+    JMenuItem                   _display_basic_information_item;
     // help menu:
-    JMenuItem                 _about_item;
-    JMenuItem                 _help_item;
-    JMenuItem                 _website_item;
-    JMenuItem                 _phyloxml_website_item;
-    JMenuItem                 _phyloxml_ref_item;
-    JMenuItem                 _aptx_ref_item;
+    JMenuItem                   _about_item;
+    JMenuItem                   _help_item;
+    JMenuItem                   _website_item;
+    JMenuItem                   _phyloxml_website_item;
+    JMenuItem                   _phyloxml_ref_item;
+    JMenuItem                   _aptx_ref_item;
     // process menu:
-    JMenu                     _process_menu;
+    JMenu                       _process_menu;
     // Handy pointers to child components:
-    MainPanel                 _mainpanel;
-    Container                 _contentpane;
-    TextFrame                 _textframe;
-    Configuration             _configuration;
-    JMenuItem                 _remove_branch_color_item;
-    Options                   _options;
-    InferenceManager          _inference_manager;
-    final ProcessPool         _process_pool;
+    MainPanel                   _mainpanel;
+    Container                   _contentpane;
+    final LinkedList<TextFrame> _textframes                             = new LinkedList<TextFrame>();                                                                                                                                         ;
+    Configuration               _configuration;
+    JMenuItem                   _remove_branch_color_item;
+    Options                     _options;
+    InferenceManager            _inference_manager;
+    final ProcessPool           _process_pool;
 
     MainFrame() {
         _process_pool = ProcessPool.createInstance();
@@ -698,7 +700,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     }
 
     void close() {
-        removeTextFrame();
+        removeAllTextFrames();
         if ( _mainpanel != null ) {
             _mainpanel.terminate();
         }
@@ -888,13 +890,31 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }
     }
 
-    void removeTextFrame() {
-        if ( _textframe != null ) {
-            _textframe.close();
-            _textframe = null;
+    void checkTextFrames() {
+        if ( _textframes.size() > 5 ) {
+            try {
+                if ( _textframes.getFirst() != null ) {
+                    _textframes.getFirst().removeMe();
+                }
+                else {
+                    _textframes.removeFirst();
+                }
+            }
+            catch ( final NoSuchElementException e ) {
+                // Ignore.
+            }
         }
     }
 
+    void removeAllTextFrames() {
+        for( final TextFrame tf : _textframes ) {
+            if ( tf != null ) {
+                tf.close();
+            }
+        }
+        _textframes.clear();
+    }
+
     void setConfiguration( final Configuration configuration ) {
         _configuration = configuration;
     }
@@ -1113,38 +1133,60 @@ public abstract class MainFrame extends JFrame implements ActionListener {
 
     void displayBasicInformation() {
         if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
-            showTextFrame( AptxUtil.createBasicInformation( _mainpanel.getCurrentPhylogeny() ) );
+            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() ) {
-            showTextFrame( _mainpanel.getCurrentPhylogeny().toNexus( getOptions().getNhConversionSupportValueStyle() ) );
+            String title = "Nexus";
+            if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
+                title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
+            }
+            showTextFrame( _mainpanel.getCurrentPhylogeny().toNexus( getOptions().getNhConversionSupportValueStyle() ),
+                           title );
         }
     }
 
     void viewAsNH() {
         if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
+            String title = "New Hampshire";
+            if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
+                title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
+            }
             showTextFrame( _mainpanel.getCurrentPhylogeny()
-                    .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ) );
+                                   .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ),
+                           title );
         }
     }
 
     void viewAsNHX() {
         if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
-            showTextFrame( _mainpanel.getCurrentPhylogeny().toNewHampshireX() );
+            String title = "NHX";
+            if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
+                title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
+            }
+            showTextFrame( _mainpanel.getCurrentPhylogeny().toNewHampshireX(), title );
         }
     }
 
     void viewAsXML() {
         if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
-            showTextFrame( _mainpanel.getCurrentPhylogeny().toPhyloXML( 0 ) );
+            String title = "phyloXML";
+            if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
+                title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
+            }
+            showTextFrame( _mainpanel.getCurrentPhylogeny().toPhyloXML( 0 ), title );
         }
     }
 
-    public void showTextFrame( final String s ) {
-        removeTextFrame();
-        _textframe = TextFrame.instantiate( s );
+    public void showTextFrame( final String s, final String title ) {
+        checkTextFrames();
+        _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
     }
 
     /**
@@ -1257,7 +1299,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         }
     }
 
-    static void help( final Map<String, WebLink> weblinks ) {
+    void help( final Map<String, WebLink> weblinks ) {
         final StringBuilder sb = new StringBuilder();
         sb.append( "Display options\n" );
         sb.append( "-------------------\n" );
@@ -1352,7 +1394,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         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() );
+        TextFrame.instantiate( sb.toString(), "Help", _textframes );
     }
 
     static void setOvPlacementColorChooseMenuItem( final JMenuItem mi, final Options options ) {
index 74b747c..62cca3a 100644 (file)
@@ -62,7 +62,7 @@ public final class MainFrameApplet extends MainFrame {
         _applet = parent_applet;
         setConfiguration( configuration );
         setOptions( Options.createInstance( configuration ) );
-        _textframe = null;
+        //_textframes = null; //~~~~
         URL url = null;
         Phylogeny[] phys = null;
         // Get URL to tree file
index d772d3e..2c674fe 100644 (file)
@@ -295,7 +295,7 @@ public final class MainFrameApplication extends MainFrame {
         setOptions( Options.createInstance( _configuration ) );
         setInferenceManager( InferenceManager.createInstance( _configuration ) );
         setPhylogeneticInferenceOptions( PhylogeneticInferenceOptions.createInstance( _configuration ) );
-        _textframe = null;
+        //     _textframe = null; #~~~~
         _species_tree = null;
         // set title
         setTitle( Constants.PRG_NAME + " " + Constants.VERSION + " (" + Constants.PRG_DATE + ")" );
@@ -1330,7 +1330,7 @@ public final class MainFrameApplication extends MainFrame {
     }
 
     void exit() {
-        removeTextFrame();
+        removeAllTextFrames();
         _mainpanel.terminate();
         _contentpane.removeAll();
         setVisible( false );
index c7edaa2..55c12d4 100644 (file)
@@ -41,6 +41,7 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
+import java.util.LinkedList;
 
 import javax.swing.JButton;
 import javax.swing.JFrame;
@@ -53,24 +54,26 @@ final class TextFrame extends JFrame implements ActionListener, ClipboardOwner {
     /**
      * 
      */
-    private static final long serialVersionUID = -5012834229705518363L;
-    private static Color      ta_text_color    = new Color( 0, 0, 0 ),
+    private static final long           serialVersionUID = -5012834229705518363L;
+    private static Color                ta_text_color    = new Color( 0, 0, 0 ),
             ta_background_color = new Color( 240, 240, 240 ), background_color = new Color( 215, 215, 215 ),
             button_background_color = new Color( 215, 215, 215 ), button_text_color = new Color( 0, 0, 0 );
-    private final static Font button_font      = new Font( "Helvetica", Font.PLAIN, 10 ),
+    private final static Font           button_font      = new Font( "Helvetica", Font.PLAIN, 10 ),
             ta_font = new Font( "Helvetica", Font.PLAIN, 10 );
-    private boolean           can_use_clipboard;
-    private final String      text;
-    private final JTextArea   jtextarea;
-    private final JButton     close_button;
-    private JButton           copy_button;
-    private final JPanel      buttonjpanel;
-    private final Container   contentpane;
+    private boolean                     can_use_clipboard;
+    private final String                text;
+    private final JTextArea             jtextarea;
+    private final JButton               close_button;
+    private JButton                     copy_button;
+    private final JPanel                buttonjpanel;
+    private final Container             contentpane;
+    private final LinkedList<TextFrame> _tframes;
 
-    private TextFrame( final String s ) {
+    private TextFrame( final String s, final String title, final LinkedList<TextFrame> tframes ) {
         // first things first
-        setTitle( Constants.PRG_NAME );
+        setTitle( title );
         text = s;
+        _tframes = tframes;
         // check to see if we have permission to use the clipboard:
         can_use_clipboard = true;
         final SecurityManager sm = System.getSecurityManager();
@@ -118,7 +121,7 @@ final class TextFrame extends JFrame implements ActionListener, ClipboardOwner {
 
             @Override
             public void windowClosing( final WindowEvent e ) {
-                close();
+                removeMe();
             }
         } );
         setVisible( true );
@@ -128,7 +131,7 @@ final class TextFrame extends JFrame implements ActionListener, ClipboardOwner {
     public void actionPerformed( final ActionEvent e ) {
         final Object o = e.getSource();
         if ( o == close_button ) {
-            close();
+            removeMe();
         }
         else if ( o == copy_button ) {
             copy();
@@ -140,6 +143,14 @@ final class TextFrame extends JFrame implements ActionListener, ClipboardOwner {
         dispose();
     }
 
+    void removeMe() {
+        final int i = _tframes.indexOf( this );
+        if ( i >= 0 ) {
+            _tframes.remove( i );
+        }
+        close();
+    }
+
     private void copy() {
         if ( !can_use_clipboard ) {
             // can't do this!
@@ -154,7 +165,7 @@ final class TextFrame extends JFrame implements ActionListener, ClipboardOwner {
     public void lostOwnership( final Clipboard clipboard, final Transferable contents ) {
     }
 
-    static TextFrame instantiate( final String s ) {
-        return new TextFrame( s );
+    static TextFrame instantiate( final String s, final String title, final LinkedList<TextFrame> tframes ) {
+        return new TextFrame( s, title, tframes );
     }
 }
index 1f237f7..17cd7f6 100644 (file)
@@ -369,7 +369,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             errorMessageNoCutCopyPasteInUnrootedDisplay();
             return;
         }
-        final String label = getASimpleTextRepresentationOfANode( node );
+        final String label = createASimpleTextRepresentationOfANode( node );
         String msg = "";
         if ( ForesterUtil.isEmpty( label ) ) {
             msg = "How to add the new, empty node?";
@@ -875,7 +875,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                                            JOptionPane.ERROR_MESSAGE );
             return;
         }
-        final String label = getASimpleTextRepresentationOfANode( node );
+        final String label = createASimpleTextRepresentationOfANode( node );
         final int r = JOptionPane.showConfirmDialog( null,
                                                      "Cut subtree" + label + "?",
                                                      "Confirm Cutting of Subtree",
@@ -928,7 +928,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                                            JOptionPane.ERROR_MESSAGE );
             return;
         }
-        final String label = getASimpleTextRepresentationOfANode( node );
+        final String label = createASimpleTextRepresentationOfANode( node );
         final Object[] options = { "Node only", "Entire subtree", "Cancel" };
         final int r = JOptionPane.showOptionDialog( this,
                                                     "Delete" + label + "?",
@@ -1095,7 +1095,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         return null;
     }
 
-    final private String getASimpleTextRepresentationOfANode( final PhylogenyNode node ) {
+    final private String createASimpleTextRepresentationOfANode( final PhylogenyNode node ) {
         final String tax = PhylogenyMethods.getSpecies( node );
         String label = node.getName();
         if ( !ForesterUtil.isEmpty( label ) && !ForesterUtil.isEmpty( tax ) ) {
@@ -1398,26 +1398,49 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                     throw new IllegalArgumentException( "unknown data element: "
                             + getOptions().getExtDescNodeDataToReturn() );
             }
-            if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.CONSOLE ) {
-                for( final String d : data ) {
-                    System.out.println( d );
-                }
+        } // for loop
+        if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.CONSOLE ) {
+            for( final String d : data ) {
+                System.out.println( d );
             }
-            else if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.WINODW ) {
-                final StringBuilder sb = new StringBuilder();
-                for( final String d : data ) {
-                    sb.append( d );
-                    sb.append( "\n" );
-                }
-                if ( getMainPanel().getMainFrame() == null ) {
-                    // Must be "E" applet version.
-                    ( ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet() ).showTextFrame( sb
-                            .toString() );
-                }
-                else {
-                    getMainPanel().getMainFrame().showTextFrame( sb.toString() );
-                }
+        }
+        else if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.WINODW ) {
+            final StringBuilder sb = new StringBuilder();
+            for( final String d : data ) {
+                sb.append( d );
+                sb.append( "\n" );
+            }
+            if ( getMainPanel().getMainFrame() == null ) {
+                // Must be "E" applet version.
+                ( ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet() )
+                        .showTextFrame( sb.toString(), node + " " + obtainTitleForExtDescNodeData() );
             }
+            else {
+                getMainPanel().getMainFrame().showTextFrame( sb.toString(),
+                                                             node + " " + obtainTitleForExtDescNodeData() );
+            }
+        }
+    }
+
+    private final String obtainTitleForExtDescNodeData() {
+        switch ( getOptions().getExtDescNodeDataToReturn() ) {
+            case NODE_NAME:
+                return "Node Names";
+            case SEQUENCE_NAME:
+                return "Sequence Names";
+            case SEQUENCE_SYMBOL:
+                return "Sequence Symbols";
+            case SEQUENCE_MOL_SEQ:
+                return "Molecular Sequences";
+            case SEQUENCE_ACC:
+                return "Sequence Accessors";
+            case TAXONOMY_SCIENTIFIC_NAME:
+                return "Scientific Names";
+            case TAXONOMY_CODE:
+                return "Taxonomy Codes";
+            default:
+                throw new IllegalArgumentException( "unknown data element: "
+                        + getOptions().getExtDescNodeDataToReturn() );
         }
     }
 
@@ -4270,7 +4293,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                                            JOptionPane.ERROR_MESSAGE );
             return;
         }
-        final String label = getASimpleTextRepresentationOfANode( getCutOrCopiedTree().getRoot() );
+        final String label = createASimpleTextRepresentationOfANode( getCutOrCopiedTree().getRoot() );
         final Object[] options = { "As sibling", "As descendant", "Cancel" };
         final int r = JOptionPane.showOptionDialog( this,
                                                     "How to paste subtree" + label + "?",
index 651bbbc..318a83c 100644 (file)
@@ -492,9 +492,6 @@ public final class PhylogenyNode implements PhylogenyNodeI, Comparable<Phylogeny
         return _id;
     }
 
-    /**
-     * Returns the name of this node.
-     */
     @Override
     final public String getName() {
         return getNodeData().getNodeName();