0.9916 beta
authorcmzmasek <cmzmasek@yahoo.com>
Thu, 18 Aug 2016 18:27:59 +0000 (11:27 -0700)
committercmzmasek <cmzmasek@yahoo.com>
Thu, 18 Aug 2016 18:27:59 +0000 (11:27 -0700)
12 files changed:
forester/java/src/org/forester/archaeopteryx/AptxConstants.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/Options.java
forester/java/src/org/forester/archaeopteryx/TreePanel.java
forester/java/src/org/forester/archaeopteryx/TreePanelUtil.java
forester/java/src/org/forester/archaeopteryx/util/TypomaticJButton.java [new file with mode: 0644]
forester/java/src/org/forester/phylogeny/Phylogeny.java
forester/java/src/org/forester/phylogeny/PhylogenyMethods.java
forester/java/src/org/forester/util/ForesterConstants.java
forester/java/src/org/forester/util/TaxonomyUtil.java

index c322ccf..cb03d46 100644 (file)
@@ -38,8 +38,8 @@ public final class AptxConstants {
 
     final static boolean        __ALLOW_PHYLOGENETIC_INFERENCE                                = true;
     public final static String  PRG_NAME                                                      = "Archaeopteryx";
-    final static String         VERSION                                                       = "0.9915 test";
-    final static String         PRG_DATE                                                      = "160727";
+    final static String         VERSION                                                       = "0.9916 beta";
+    final static String         PRG_DATE                                                      = "160817";
     final static String         DEFAULT_CONFIGURATION_FILE_NAME                               = "_aptx_configuration_file";
     final static String[]       DEFAULT_FONT_CHOICES                                          = { 
             "Arial Unicode MS", "Dialog", "SansSerif", "Sans", "Arial", "Helvetica" };
@@ -106,4 +106,5 @@ public final class AptxConstants {
                                                                                                            150,
                                                                                                            150 );
     final static short          DEFAULT_NODE_SHAPE_SIZE_DEFAULT                               = 4;
+    static final int            MAX_LENGTH_FOR_COLLAPSED_NAME = 8;
 }
index 6a45310..32121a0 100644 (file)
@@ -2604,6 +2604,8 @@ final class ControlPanel extends JPanel implements ActionListener {
     }
 
     final void updateRankCollapseRankDisplay() {
+      
+        
         if ( _rank_collapse_depth_tf != null ) {
             final String r = obtainRankCollapseDepthValue();
             if ( r.equals( "off" ) ) {
index 758f053..a06adaf 100644 (file)
@@ -231,6 +231,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     JCheckBoxMenuItem                _right_line_up_domains_cbmi;
     JCheckBoxMenuItem                _line_up_renderable_data_cbmi;
     JCheckBoxMenuItem                _collapsed_with_average_height_cbmi;
+    JCheckBoxMenuItem                _show_abbreviated_labels_for_collapsed_nodes_cbmi;
     // _  print
     JCheckBoxMenuItem                _graphics_export_visible_only_cbmi;
     JCheckBoxMenuItem                _antialias_print_cbmi;
@@ -581,6 +582,12 @@ public abstract class MainFrame extends JFrame implements ActionListener {
             }
             updateOptions( getOptions() );
         }
+        else if ( o == _show_abbreviated_labels_for_collapsed_nodes_cbmi ) {
+            if ( _show_abbreviated_labels_for_collapsed_nodes_cbmi.isSelected() ) {
+                _show_abbreviated_labels_for_collapsed_nodes_cbmi.setSelected( true );
+            }
+            updateOptions( getOptions() );
+        }
         else if ( o == _right_line_up_domains_cbmi ) {
             if ( _right_line_up_domains_cbmi.isSelected() ) {
                 _line_up_renderable_data_cbmi.setSelected( true );
@@ -1943,6 +1950,9 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         if ( ( _collapsed_with_average_height_cbmi != null ) && _collapsed_with_average_height_cbmi.isEnabled() ) {
             options.setCollapsedWithAverageHeigh(_collapsed_with_average_height_cbmi.isSelected() );
         }
+        if ( ( _show_abbreviated_labels_for_collapsed_nodes_cbmi != null ) && _show_abbreviated_labels_for_collapsed_nodes_cbmi.isEnabled() ) {
+            options.setShowAbbreviatedLabelsForCollapsedNodes(_show_abbreviated_labels_for_collapsed_nodes_cbmi.isSelected() );
+        }
         
     }
 
index 3baabd1..f5b88fb 100644 (file)
@@ -1834,6 +1834,11 @@ public final class MainFrameApplication extends MainFrame {
 
         
         _options_jmenu
+        .add( _show_abbreviated_labels_for_collapsed_nodes_cbmi = new JCheckBoxMenuItem( "Add Abbreviated Labels to Collapsed Subtrees" ) );
+
+     
+        
+        _options_jmenu
                 .add( _line_up_renderable_data_cbmi = new JCheckBoxMenuItem( MainFrame.LINE_UP_RENDERABLE_DATA ) );
         
        
@@ -1941,6 +1946,8 @@ public final class MainFrameApplication extends MainFrame {
         customizeCheckBoxMenuItem( _search_case_senstive_cbmi, getOptions().isSearchCaseSensitive() );
         customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );
         customizeCheckBoxMenuItem( _collapsed_with_average_height_cbmi, getOptions().isCollapsedWithAverageHeigh() );
+        customizeCheckBoxMenuItem( _show_abbreviated_labels_for_collapsed_nodes_cbmi, getOptions().isShowAbbreviatedLabelsForCollapsedNodes() );
+        
         customizeRadioButtonMenuItem( _non_lined_up_cladograms_rbmi,
                                       getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP );
         customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi,
index 4241797..5a083b4 100644 (file)
@@ -121,6 +121,7 @@ final public class Options {
     private boolean                           _color_all_found_nodes_when_coloring_subtree;
     private boolean                           _parse_beast_style_extended_nexus_tags;
     private boolean                           _collapsed_with_average_height;
+    private boolean                           _show_abbreviated_labels_for_collapsed_nodes;
     
     private Options() {
         init();
@@ -225,7 +226,8 @@ final public class Options {
         _ext_desc_data_to_return = NodeDataField.UNKNOWN;
         _line_up_renderable_node_data = true;
         _right_align_domains = false;
-        _collapsed_with_average_height= true;
+        _collapsed_with_average_height = true;
+        _show_abbreviated_labels_for_collapsed_nodes = true;
     }
 
     final private void setNumberOfDigitsAfterCommaForBranchLength( final short number_of_digits_after_comma_for_branch_length_values ) {
@@ -611,6 +613,14 @@ final public class Options {
     final void setCollapsedWithAverageHeigh( final boolean collapsed_with_average_height ) {
         _collapsed_with_average_height = collapsed_with_average_height;
     }
+
+    final boolean isShowAbbreviatedLabelsForCollapsedNodes() {
+        return _show_abbreviated_labels_for_collapsed_nodes;
+    }
+    
+    final void setShowAbbreviatedLabelsForCollapsedNodes(final boolean show_abbreviated_labels_for_collapsed_nodes) {
+        _show_abbreviated_labels_for_collapsed_nodes =  show_abbreviated_labels_for_collapsed_nodes;
+    }
     
     
 }
index ef650bc..53b1620 100644 (file)
@@ -2399,6 +2399,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) {
             c = PhylogenyMethods.getBranchColorValue( node );
         }
+        else if ( to_pdf ) {
+            g.setColor( getTreeColorSet().getBranchColorForPdf() );
+        }
         else {
             c = getTreeColorSet().getCollapseFillColor();
         }
@@ -2825,7 +2828,45 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         }
         setColor( g, node, to_graphics_file, to_pdf, is_in_found_nodes, getTreeColorSet().getSequenceColor() );
         if ( node.isCollapse() && ( ( !node.isRoot() && !node.getParent().isCollapse() ) || node.isRoot() ) ) {
-            if ( _sb.length() > 0 ) {
+            if ( _sb.length() == 0 ) {
+                if ( getOptions().isShowAbbreviatedLabelsForCollapsedNodes()
+                        && ( getControlPanel().isShowTaxonomyCode() || getControlPanel().isShowTaxonomyScientificNames()
+                                || getControlPanel().isShowSeqNames() || getControlPanel().isShowNodeNames() ) ) {
+                    final PhylogenyNode first = PhylogenyMethods.getFirstExternalNode( node );
+                    final PhylogenyNode last = PhylogenyMethods.getLastExternalNode( node );
+                    if ( getControlPanel().isShowTaxonomyCode() && first.getNodeData().isHasTaxonomy()
+                            && last.getNodeData().isHasTaxonomy()
+                            && !ForesterUtil.isEmpty( first.getNodeData().getTaxonomy().getTaxonomyCode() )
+                            && !ForesterUtil.isEmpty( last.getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
+                        addLabelForCollapsed( first.getNodeData().getTaxonomy().getTaxonomyCode(),
+                                              last.getNodeData().getTaxonomy().getTaxonomyCode(),
+                                              node.getAllExternalDescendants().size() );
+                    }
+                    else if ( getControlPanel().isShowTaxonomyScientificNames() && first.getNodeData().isHasTaxonomy()
+                            && last.getNodeData().isHasTaxonomy()
+                            && !ForesterUtil.isEmpty( first.getNodeData().getTaxonomy().getScientificName() )
+                            && !ForesterUtil.isEmpty( last.getNodeData().getTaxonomy().getScientificName() ) ) {
+                        addLabelForCollapsed( first.getNodeData().getTaxonomy().getScientificName(),
+                                              last.getNodeData().getTaxonomy().getScientificName(),
+                                              node.getAllExternalDescendants().size() );
+                    }
+                    else if ( getControlPanel().isShowSeqNames() && first.getNodeData().isHasSequence()
+                            && last.getNodeData().isHasSequence()
+                            && !ForesterUtil.isEmpty( first.getNodeData().getSequence().getName() )
+                            && !ForesterUtil.isEmpty( last.getNodeData().getSequence().getName() ) ) {
+                        addLabelForCollapsed( first.getNodeData().getSequence().getName(),
+                                              last.getNodeData().getSequence().getName(),
+                                              node.getAllExternalDescendants().size() );
+                    }
+                    else if ( getControlPanel().isShowNodeNames() && !ForesterUtil.isEmpty( first.getName() )
+                            && !ForesterUtil.isEmpty( last.getName() ) ) {
+                        addLabelForCollapsed( first.getName(),
+                                              last.getName(),
+                                              node.getAllExternalDescendants().size() );
+                    }
+                }
+            }
+            else if ( _sb.length() > 0 ) {
                 _sb.setLength( 0 );
                 _sb.append( " (" );
                 _sb.append( node.getAllExternalDescendants().size() );
@@ -2993,6 +3034,15 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         return x;
     }
 
+    private final void addLabelForCollapsed( final String first, final String last, final int size ) {
+        _sb.append( first.length() < AptxConstants.MAX_LENGTH_FOR_COLLAPSED_NAME ? first
+                : first.substring( 0, AptxConstants.MAX_LENGTH_FOR_COLLAPSED_NAME - 1 ) );
+        _sb.append( " ... " );
+        _sb.append( last.length() < AptxConstants.MAX_LENGTH_FOR_COLLAPSED_NAME ? last
+                : last.substring( 0, AptxConstants.MAX_LENGTH_FOR_COLLAPSED_NAME - 1 ) );
+        _sb.append( " (" + size + ")" );
+    }
+
     private final boolean isAllowAttributedStrings() {
         return false;
     }
@@ -4847,8 +4897,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         setArrowCursor();
     }
 
-  
-
     final void colorRank( final String rank ) {
         if ( ( _phylogeny == null ) || ( _phylogeny.getNumberOfExternalNodes() < 2 ) ) {
             return;
@@ -6051,7 +6099,20 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             _sub_phylogenies_temp_roots[ _subtree_index ] = node;
             ++_subtree_index;
             _phylogeny = TreePanelUtil.subTree( node, _phylogeny );
+            if ( _phylogeny.getRoot().isCollapse() ) {
+                _phylogeny.getRoot().setCollapse( false );
+            }
+            _phylogeny.externalNodesHaveChanged();
+            _phylogeny.clearHashIdToNodeMap();
+            _phylogeny.recalculateNumberOfExternalDescendants( true );
             updateSubSuperTreeButton();
+            getMainPanel().getControlPanel().search0();
+            getMainPanel().getControlPanel().search1();
+            resetRankCollapseRankValue();
+            resetDepthCollapseDepthValue();
+            getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
+            getMainPanel().getControlPanel().updateDepthCollapseDepthDisplay();
+            getMainPanel().getControlPanel().updateRankCollapseRankDisplay();
         }
         else if ( node.isRoot() && isCurrentTreeIsSubtree() ) {
             superTree();
@@ -6069,6 +6130,16 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         _sub_phylogenies[ _subtree_index ] = null;
         _sub_phylogenies_temp_roots[ _subtree_index ] = null;
         _phylogeny = _sub_phylogenies[ --_subtree_index ];
+        _phylogeny.externalNodesHaveChanged();
+        _phylogeny.clearHashIdToNodeMap();
+        _phylogeny.recalculateNumberOfExternalDescendants( true );
+        getMainPanel().getControlPanel().search0();
+        getMainPanel().getControlPanel().search1();
+        resetRankCollapseRankValue();
+        resetDepthCollapseDepthValue();
+        getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
+        getMainPanel().getControlPanel().updateDepthCollapseDepthDisplay();
+        getMainPanel().getControlPanel().updateRankCollapseRankDisplay();
         updateSubSuperTreeButton();
     }
 
@@ -6290,7 +6361,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 --_depth_collapse_level;
                 PhylogenyMethods.collapseToDepth( _phylogeny, _depth_collapse_level );
             }
-            
         }
     }
 
@@ -6317,34 +6387,35 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 }
                 else {
                     --_rank_collapse_level;
-                    PhylogenyMethods.collapseToRank( _phylogeny, mapToAbsoluteRankLevel( ranks, _rank_collapse_level ) );
+                    PhylogenyMethods.collapseToRank( _phylogeny,
+                                                     mapToAbsoluteRankLevel( ranks, _rank_collapse_level ) );
                 }
             }
         }
     }
 
-    
     public void increaseRankCollapseLevel() {
         if ( ( _phylogeny != null ) && ( _phylogeny.getNumberOfExternalNodes() > 2 ) ) {
             final String ranks[] = PhylogenyMethods.obtainPresentRanksSorted( _phylogeny );
             if ( ranks.length > 1 ) {
-                if ( _rank_collapse_level >= (ranks.length - 1 ) ) {
+                if ( _rank_collapse_level >= ( ranks.length - 1 ) ) {
                     _rank_collapse_level = 0;
-                    PhylogenyMethods.collapseToRank( _phylogeny,mapToAbsoluteRankLevel( ranks, _rank_collapse_level ) );
+                    PhylogenyMethods.collapseToRank( _phylogeny,
+                                                     mapToAbsoluteRankLevel( ranks, _rank_collapse_level ) );
                 }
-                else if ( _rank_collapse_level == (ranks.length - 2 ) ) {
+                else if ( _rank_collapse_level == ( ranks.length - 2 ) ) {
                     ++_rank_collapse_level;
                     uncollapseAll();
                 }
                 else {
                     ++_rank_collapse_level;
-                    PhylogenyMethods.collapseToRank( _phylogeny,mapToAbsoluteRankLevel( ranks, _rank_collapse_level ) );
+                    PhylogenyMethods.collapseToRank( _phylogeny,
+                                                     mapToAbsoluteRankLevel( ranks, _rank_collapse_level ) );
                 }
             }
         }
     }
 
-   
     private final static int mapToAbsoluteRankLevel( final String present_ranks_sorted[],
                                                      final int rank_collapse_level ) {
         final String rank_str = present_ranks_sorted[ rank_collapse_level ];
@@ -6353,14 +6424,14 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         }
         return TaxonomyUtil.RANK_TO_INT.get( rank_str );
     }
-    
+
     private final void uncollapseAll() {
-        final PhylogenyNodeIterator it = new PreorderTreeIterator(_phylogeny  );
+        final PhylogenyNodeIterator it = new PreorderTreeIterator( _phylogeny );
         while ( it.hasNext() ) {
             it.next().setCollapse( false );
         }
     }
-    
+
     final int resetDepthCollapseDepthValue() {
         return _depth_collapse_level = -1;
     }
@@ -6372,7 +6443,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
     final void setDepthCollapseDepthValue( final int depth_collapse_level ) {
         _depth_collapse_level = depth_collapse_level;
     }
-    
+
     final int resetRankCollapseRankValue() {
         return _rank_collapse_level = -1;
     }
index 9aeec3b..c764eae 100644 (file)
@@ -307,76 +307,76 @@ public class TreePanelUtil {
         }
     }
 
-    final static int collapseByTaxonomicRank( final Phylogeny tree, final String rank, final TreePanel tree_panel ) {
-        final Set<String> true_lineage_set = new HashSet<String>();
-        for( final PhylogenyNodeIterator iter = tree.iteratorPreorder(); iter.hasNext(); ) {
-            iter.next().setCollapse( false );
-        }
-        int collapsed = 0;
-        for( final PhylogenyNodeIterator it = tree.iteratorPostorder(); it.hasNext(); ) {
-            final PhylogenyNode n = it.next();
-            if ( !n.isExternal() && n.getNodeData().isHasTaxonomy() && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getRank() )
-                    && n.getNodeData().getTaxonomy().getRank().equalsIgnoreCase( rank ) /*&& !n.isRoot()*/ ) {
-                TreePanelUtil.collapseSubtree( n, true );
-                ++collapsed;
-                if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) {
-                    true_lineage_set.add( n.getNodeData().getTaxonomy().getScientificName() );
-                }
-            }
-        }
-        for( final PhylogenyNodeIterator it = tree.iteratorPostorder(); it.hasNext(); ) {
-            final PhylogenyNode node = it.next();
-            if ( ( !node.isExternal() && !node.isCollapse() ) && node.getNodeData().isHasTaxonomy()
-                    && !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getLineage() ) /* && !node.isRoot()*/ ) {
-                boolean success = false;
-                if ( !true_lineage_set.isEmpty() ) {
-                    for( final String lin : node.getNodeData().getTaxonomy().getLineage() ) {
-                        if ( true_lineage_set.contains( lin ) ) {
-                            TreePanelUtil.collapseSubtree( node, true );
-                            ++collapsed;
-                            success = true;
-                            break;
-                        }
-                    }
-                }
-                if ( !success ) {
-                    final Map<String, String> lineage_to_rank_map = MainPanel.getLineageToRankMap();
-                    for( final String lin : node.getNodeData().getTaxonomy().getLineage() ) {
-                        final Taxonomy temp_tax = new Taxonomy();
-                        temp_tax.setScientificName( lin );
-                        if ( lineage_to_rank_map.containsKey( lin )
-                                && !ForesterUtil.isEmpty( lineage_to_rank_map.get( lin ) )
-                                && lineage_to_rank_map.get( lin ).equalsIgnoreCase( rank ) ) {
-                             TreePanelUtil.collapseSubtree( node, true );
-                            ++collapsed;
-                            true_lineage_set.add( lin );
-                            break;
-                        }
-                        else {
-                            UniProtTaxonomy up = null;
-                            try {
-                                up = TaxonomyDataManager.obtainUniProtTaxonomy( temp_tax, null, null );
-                            }
-                            catch ( final Exception e ) {
-                                e.printStackTrace();
-                            }
-                            if ( ( up != null ) && !ForesterUtil.isEmpty( up.getRank() ) ) {
-                                lineage_to_rank_map.put( lin, up.getRank() );
-                                System.out.println( lin + "->" + up.getRank() );
-                                if ( up.getRank().equalsIgnoreCase( rank ) ) {
-                                    TreePanelUtil.collapseSubtree( node, true );
-                                    ++collapsed;
-                                    true_lineage_set.add( lin );
-                                    break;
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        return collapsed;
-    }
+//    final static int collapseByTaxonomicRank( final Phylogeny tree, final String rank, final TreePanel tree_panel ) {
+//        final Set<String> true_lineage_set = new HashSet<String>();
+//        for( final PhylogenyNodeIterator iter = tree.iteratorPreorder(); iter.hasNext(); ) {
+//            iter.next().setCollapse( false );
+//        }
+//        int collapsed = 0;
+//        for( final PhylogenyNodeIterator it = tree.iteratorPostorder(); it.hasNext(); ) {
+//            final PhylogenyNode n = it.next();
+//            if ( !n.isExternal() && n.getNodeData().isHasTaxonomy() && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getRank() )
+//                    && n.getNodeData().getTaxonomy().getRank().equalsIgnoreCase( rank ) /*&& !n.isRoot()*/ ) {
+//                TreePanelUtil.collapseSubtree( n, true );
+//                ++collapsed;
+//                if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) {
+//                    true_lineage_set.add( n.getNodeData().getTaxonomy().getScientificName() );
+//                }
+//            }
+//        }
+//        for( final PhylogenyNodeIterator it = tree.iteratorPostorder(); it.hasNext(); ) {
+//            final PhylogenyNode node = it.next();
+//            if ( ( !node.isExternal() && !node.isCollapse() ) && node.getNodeData().isHasTaxonomy()
+//                    && !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getLineage() ) /* && !node.isRoot()*/ ) {
+//                boolean success = false;
+//                if ( !true_lineage_set.isEmpty() ) {
+//                    for( final String lin : node.getNodeData().getTaxonomy().getLineage() ) {
+//                        if ( true_lineage_set.contains( lin ) ) {
+//                            TreePanelUtil.collapseSubtree( node, true );
+//                            ++collapsed;
+//                            success = true;
+//                            break;
+//                        }
+//                    }
+//                }
+//                if ( !success ) {
+//                    final Map<String, String> lineage_to_rank_map = MainPanel.getLineageToRankMap();
+//                    for( final String lin : node.getNodeData().getTaxonomy().getLineage() ) {
+//                        final Taxonomy temp_tax = new Taxonomy();
+//                        temp_tax.setScientificName( lin );
+//                        if ( lineage_to_rank_map.containsKey( lin )
+//                                && !ForesterUtil.isEmpty( lineage_to_rank_map.get( lin ) )
+//                                && lineage_to_rank_map.get( lin ).equalsIgnoreCase( rank ) ) {
+//                             TreePanelUtil.collapseSubtree( node, true );
+//                            ++collapsed;
+//                            true_lineage_set.add( lin );
+//                            break;
+//                        }
+//                        else {
+//                            UniProtTaxonomy up = null;
+//                            try {
+//                                up = TaxonomyDataManager.obtainUniProtTaxonomy( temp_tax, null, null );
+//                            }
+//                            catch ( final Exception e ) {
+//                                e.printStackTrace();
+//                            }
+//                            if ( ( up != null ) && !ForesterUtil.isEmpty( up.getRank() ) ) {
+//                                lineage_to_rank_map.put( lin, up.getRank() );
+//                                System.out.println( lin + "->" + up.getRank() );
+//                                if ( up.getRank().equalsIgnoreCase( rank ) ) {
+//                                    TreePanelUtil.collapseSubtree( node, true );
+//                                    ++collapsed;
+//                                    true_lineage_set.add( lin );
+//                                    break;
+//                                }
+//                            }
+//                        }
+//                    }
+//                }
+//            }
+//        }
+//        return collapsed;
+//    }
 
     final static int colorPhylogenyAccordingToRanks( final Phylogeny tree,
                                                      final String rank,
diff --git a/forester/java/src/org/forester/archaeopteryx/util/TypomaticJButton.java b/forester/java/src/org/forester/archaeopteryx/util/TypomaticJButton.java
new file mode 100644 (file)
index 0000000..6421ce2
--- /dev/null
@@ -0,0 +1,158 @@
+
+package org.forester.archaeopteryx.util;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+
+import javax.swing.Action;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.Timer;
+
+public final class TypomaticJButton extends JButton implements ActionListener, MouseListener {
+
+    private static final long serialVersionUID = 7435606927739361980L;
+    private boolean           pressed          = false;
+    private boolean           repeat_enabled   = true;
+    private Timer             timer            = null;
+    private int               initial_delay    = 600;
+    private int               delay            = 200;
+    private int               modifiers        = 0;
+
+    public TypomaticJButton() {
+        super();
+        init();
+    }
+
+    public TypomaticJButton( final Action a ) {
+        super( a );
+        init();
+    }
+
+    public TypomaticJButton( final Icon icon ) {
+        super( icon );
+        init();
+    }
+
+    public TypomaticJButton( final String text ) {
+        super( text );
+        init();
+    }
+
+    public TypomaticJButton( final String text, final Icon icon ) {
+        super( text, icon );
+        init();
+    }
+
+    @Override
+    final public void actionPerformed( final ActionEvent ae ) {
+        if ( ae.getSource() == timer ) {
+            final ActionEvent event = new ActionEvent( this,
+                                                       ActionEvent.ACTION_PERFORMED,
+                                                       super.getActionCommand(),
+                                                       modifiers );
+            super.fireActionPerformed( event );
+        }
+    }
+
+    final public int getDelay() {
+        return delay;
+    }
+
+    final public int getInitialDelay() {
+        return initial_delay;
+    }
+
+    final private void init() {
+        addMouseListener( this );
+        timer = new Timer( delay, this );
+        timer.setRepeats( true );
+    }
+
+    final public boolean isRepeatEnabled() {
+        return repeat_enabled;
+    }
+
+    @Override
+    final public void mouseClicked( final MouseEvent me ) {
+        if ( me.getSource() == this ) {
+            pressed = false;
+            if ( timer.isRunning() ) {
+                timer.stop();
+            }
+        }
+    }
+
+    @Override
+    final public void mouseEntered( final MouseEvent e ) {
+        if ( ( e.getSource() == this ) && isEnabled() && isRepeatEnabled() ) {
+            if ( pressed && !timer.isRunning() ) {
+                modifiers = e.getModifiers();
+                timer.setInitialDelay( delay );
+                timer.start();
+            }
+        }
+    }
+
+    @Override
+    final public void mouseExited( final MouseEvent e ) {
+        if ( e.getSource() == this ) {
+            if ( timer.isRunning() ) {
+                timer.stop();
+            }
+        }
+    }
+
+    @Override
+    final public void mousePressed( final MouseEvent e ) {
+        if ( ( e.getSource() == this ) && isEnabled() && isRepeatEnabled() ) {
+            pressed = true;
+            if ( !timer.isRunning() ) {
+                modifiers = e.getModifiers();
+                timer.setInitialDelay( initial_delay );
+                timer.start();
+            }
+        }
+    }
+
+    @Override
+    final public void mouseReleased( final MouseEvent e ) {
+        if ( e.getSource() == this ) {
+            pressed = false;
+            if ( timer.isRunning() ) {
+                timer.stop();
+            }
+        }
+    }
+
+    final public void setDelay( final int d ) {
+        delay = d;
+    }
+
+    @Override
+    final public void setEnabled( final boolean e ) {
+        if ( e != super.isEnabled() ) {
+            pressed = false;
+            if ( timer.isRunning() ) {
+                timer.stop();
+            }
+        }
+        super.setEnabled( e );
+    }
+
+    final public void setInitialDelay( final int d ) {
+        initial_delay = d;
+    }
+
+    final public void setRepeatEnabled( final boolean e ) {
+        if ( !e ) {
+            pressed = false;
+            if ( timer.isRunning() ) {
+                timer.stop();
+            }
+        }
+        repeat_enabled = e;
+    }
+}
\ No newline at end of file
index 0990171..34eb487 100644 (file)
@@ -332,28 +332,7 @@ public class Phylogeny {
         return _external_nodes_set;
     }
 
-    /**
-     * Returns the number of duplications of this Phylogeny (int). A return
-     * value of -1 indicates that the number of duplications is unknown.
-     */
-    // public int getNumberOfDuplications() {
-    // return _number_of_duplications;
-    // } // getNumberOfDuplications()
-    /**
-     * Sets the number of duplications of this Phylogeny (int). A value of -1
-     * indicates that the number of duplications is unknown.
-     *
-     * @param clean_nh
-     *            set to true for clean NH format
-     */
-    // public void setNumberOfDuplications( int i ) {
-    // if ( i < 0 ) {
-    // _number_of_duplications = -1;
-    // }
-    // else {
-    // _number_of_duplications = i;
-    // }
-    // } // setNumberOfDuplications( int )
     /**
      * Returns the first external PhylogenyNode.
      */
index dfe3341..97eba29 100644 (file)
@@ -66,6 +66,7 @@ import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
 import org.forester.phylogeny.iterators.PreorderTreeIterator;
 import org.forester.util.BasicDescriptiveStatistics;
 import org.forester.util.DescriptiveStatistics;
+import org.forester.util.FailedConditionCheckException;
 import org.forester.util.ForesterUtil;
 import org.forester.util.TaxonomyUtil;
 
@@ -2126,6 +2127,20 @@ public class PhylogenyMethods {
         }
     }
     
-   
+    public final static PhylogenyNode getFirstExternalNode( final PhylogenyNode node ) {
+        PhylogenyNode n = node;
+        while ( n.isInternal() ) {
+            n = n.getFirstChildNode();
+        }
+        return n;
+    }
+    
+    public final static PhylogenyNode getLastExternalNode( final PhylogenyNode node ) {
+        PhylogenyNode n = node;
+        while ( n.isInternal() ) {
+            n = n.getLastChildNode();
+        }
+        return n;
+    }
     
 }
index 441b0f7..af05ca0 100644 (file)
@@ -27,8 +27,8 @@ package org.forester.util;
 
 public final class ForesterConstants {
 
-    public final static String  FORESTER_VERSION            = "1.042";
-    public final static String  FORESTER_DATE               = "160712";
+    public final static String  FORESTER_VERSION            = "1.043";
+    public final static String  FORESTER_DATE               = "160817";
     public final static String  PHYLO_XML_VERSION           = "1.20";
     public final static String  PHYLO_XML_LOCATION          = "http://www.phyloxml.org";
     public final static String  PHYLO_XML_XSD               = "phyloxml.xsd";
index a5beeac..6fc79de 100644 (file)
@@ -674,12 +674,10 @@ public final class TaxonomyUtil {
     static {
         // same thing as set:
         for( final String rank : TAXONOMY_RANKS_LIST ) {
-            System.out.println( "=" + rank );
             TAXONOMY_RANKS_SET.add( rank );
         }
         final int l = RANKS.length;
         for( int i = 0; i < l; ++i ) {
-            System.out.println( "i=" + i );
             RANKS[ i ] = TAXONOMY_RANKS_LIST.get( i );
             RANK_TO_INT.put( RANKS[ i ], i );
         }