X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FControlPanel.java;h=5bca3986a86714b305e9a42f4b29cd3f3bf148d1;hb=f95ddfc23b184985166c2838f452c20b1a2c8307;hp=471ca78fb9693db0d21889ddb6b93b97f95eaeef;hpb=89d7b6ec1ddc3a3c1e953cf389c24ba7aae7fbfe;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java index 471ca78..5bca398 100644 --- a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java +++ b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java @@ -61,9 +61,11 @@ import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE; import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyMethods; +import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY; import org.forester.phylogeny.PhylogenyNode; import org.forester.phylogeny.data.Sequence; import org.forester.phylogeny.data.SequenceRelation; +import org.forester.phylogeny.iterators.PhylogenyNodeIterator; import org.forester.util.ForesterUtil; final class ControlPanel extends JPanel implements ActionListener { @@ -124,6 +126,7 @@ final class ControlPanel extends JPanel implements ActionListener { private int _subtree_cb_item; private int _color_subtree_cb_item; private int _open_seq_web_item; + private int _sort_descendents_item; private int _open_tax_web_item; private int _cut_subtree_item; private int _copy_subtree_item; @@ -238,8 +241,23 @@ final class ControlPanel extends JPanel implements ActionListener { showWhole(); } else if ( e.getSource() == _order ) { - tp.getPhylogeny().orderAppearance( _order_of_appearance ); + DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.TAXONOMY; + if ( ( !isShowTaxonomyScientificNames() && !isShowTaxonomyCode() && !isShowTaxonomyCommonNames() ) ) { + if ( ( isShowSequenceAcc() || isShowGeneNames() || isShowGeneSymbols() ) ) { + pri = DESCENDANT_SORT_PRIORITY.SEQUENCE; + } + else if ( isShowNodeNames() ) { + pri = DESCENDANT_SORT_PRIORITY.NODE_NAME; + } + } + PhylogenyMethods.orderAppearance( tp.getPhylogeny().getRoot(), _order_of_appearance, true, pri ); _order_of_appearance = !_order_of_appearance; + tp.setNodeInPreorderToNull(); + tp.getPhylogeny().externalNodesHaveChanged(); + tp.getPhylogeny().hashIDs(); + tp.getPhylogeny().recalculateNumberOfExternalDescendants( true ); + tp.resetNodeIdToDistToLeafMap(); + tp.setEdited( true ); displayedPhylogenyMightHaveChanged( false ); } else if ( e.getSource() == _uncollapse_all ) { @@ -607,7 +625,8 @@ final class ControlPanel extends JPanel implements ActionListener { } void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) { - if ( ( _mainpanel != null ) && ( _mainpanel.getCurrentPhylogeny() != null ) ) { + if ( ( _mainpanel != null ) + && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) { if ( getOptions().isShowOverview() ) { _mainpanel.getCurrentTreePanel().updateOvSizes(); } @@ -1140,10 +1159,11 @@ final class ControlPanel extends JPanel implements ActionListener { else if ( action == _open_seq_web_item ) { setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB ); } + else if ( action == _sort_descendents_item ) { + setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS ); + } else if ( action == _blast_item ) { - if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) { - setActionWhenNodeClicked( NodeClickAction.BLAST ); - } + setActionWhenNodeClicked( NodeClickAction.BLAST ); } else if ( action == _open_tax_web_item ) { setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB ); @@ -1314,6 +1334,15 @@ final class ControlPanel extends JPanel implements ActionListener { } cb_index++; } + if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) { + _sort_descendents_item = cb_index; + addClickToOption( Configuration.sort_descendents, + _configuration.getClickToTitle( Configuration.sort_descendents ) ); + if ( default_option == Configuration.sort_descendents ) { + selected_index = cb_index; + } + cb_index++; + } if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) { _color_subtree_cb_item = cb_index; addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) ); @@ -1338,6 +1367,14 @@ final class ControlPanel extends JPanel implements ActionListener { } cb_index++; } + if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) { + _blast_item = cb_index; + addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) ); + if ( default_option == Configuration.blast ) { + selected_index = cb_index; + } + cb_index++; + } if ( getOptions().isEditable() ) { if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) { _cut_subtree_item = cb_index; @@ -1392,16 +1429,6 @@ final class ControlPanel extends JPanel implements ActionListener { } cb_index++; } - if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) { - if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) { - _blast_item = cb_index; - addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) ); - if ( default_option == Configuration.blast ) { - selected_index = cb_index; - } - cb_index++; - } - } } // Set default selection and its action _click_to_combobox.setSelectedIndex( selected_index ); @@ -1686,10 +1713,11 @@ final class ControlPanel extends JPanel implements ActionListener { * Fit entire tree into window. */ void showWhole() { - if ( _mainpanel.getCurrentScrollPane() == null ) { + if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) { return; } - displayedPhylogenyMightHaveChanged( false ); + getCurrentTreePanel().updateSetOfCollapsedExternalNodes(); + displayedPhylogenyMightHaveChanged( true ); _mainpanel.getCurrentTreePanel().updateOvSettings(); _mainpanel.getCurrentTreePanel().validate(); _mainpanel.validate(); @@ -1784,8 +1812,15 @@ final class ControlPanel extends JPanel implements ActionListener { void uncollapseAll( final TreePanel tp ) { final Phylogeny t = tp.getPhylogeny(); if ( ( t != null ) && !t.isEmpty() ) { - t.setAllNodesToNotCollapse(); + 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.hashIDs(); showWhole(); } } @@ -1921,6 +1956,7 @@ final class ControlPanel extends JPanel implements ActionListener { PASTE_SUBTREE, ADD_NEW_NODE, EDIT_NODE_DATA, + SORT_DESCENDENTS, BLAST; } }