X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FControlPanel.java;h=ade84083507c729d006f35812d6b69a500e35e60;hb=aff0b302cc19e0ee3e73bc4a87884b4591ac5f08;hp=4cc496032a25eed274c39298d4b21264fe0d5aef;hpb=236967e4df09b7a3fd6659a8131aa97ef9906a28;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java index 4cc4960..ade8408 100644 --- a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java +++ b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java @@ -47,6 +47,7 @@ import java.util.Map; import java.util.Set; import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; import javax.swing.DefaultListCellRenderer; import javax.swing.JButton; import javax.swing.JCheckBox; @@ -54,12 +55,14 @@ import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; +import javax.swing.JRadioButton; import javax.swing.JScrollBar; import javax.swing.JTextField; import javax.swing.ListCellRenderer; import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE; import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE; +import org.forester.archaeopteryx.util.TypomaticJButton; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyMethods; import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY; @@ -70,134 +73,147 @@ import org.forester.phylogeny.data.SequenceRelation.SEQUENCE_RELATION_TYPE; import org.forester.phylogeny.iterators.PhylogenyNodeIterator; import org.forester.util.ForesterUtil; -final class ControlPanel extends JPanel implements ActionListener { +public final class ControlPanel extends JPanel implements ActionListener { enum NodeClickAction { - ADD_NEW_NODE, - BLAST, - COLLAPSE, - COLOR_SUBTREE, - COPY_SUBTREE, - CUT_SUBTREE, - DELETE_NODE_OR_SUBTREE, - EDIT_NODE_DATA, - GET_EXT_DESC_DATA, - OPEN_PDB_WEB, - OPEN_SEQ_WEB, - OPEN_TAX_WEB, - PASTE_SUBTREE, - REROOT, - SELECT_NODES, - SHOW_DATA, - SORT_DESCENDENTS, - SUBTREE, - SWAP, - CHANGE_NODE_FONT, - COLOR_NODE_FONT; - } - final static Font jcb_bold_font = new Font( Configuration.getDefaultFontFamilyName(), - Font.BOLD, - 9 ); - final static Font jcb_font = new Font( Configuration.getDefaultFontFamilyName(), - Font.PLAIN, - 9 ); - final static Font js_font = new Font( Configuration.getDefaultFontFamilyName(), - Font.PLAIN, - 9 ); - private static final String RETURN_TO_SUPER_TREE_TEXT = "Back to Super Tree"; - private static final String SEARCH_TIP_TEXT = "Enter text to search for. Use ',' for logical OR and '+' for logical AND (not used in this manner for regular expression searches)."; - private static final long serialVersionUID = -8463483932821545633L; - private NodeClickAction _action_when_node_clicked; - private int _add_new_node_item; - private Map _all_click_to_names; - private Map _annotation_colors; - private int _blast_item; - private JComboBox _click_to_combobox; - private JLabel _click_to_label; - private List _click_to_names; - private int _collapse_cb_item; - private JCheckBox _color_acc_species; - private JCheckBox _color_acc_sequence; - private JCheckBox _color_according_to_annotation; - private boolean _color_branches; - private JCheckBox _use_visual_styles_cb; - private int _color_subtree_cb_item; - private int _change_node_font_item; + ADD_NEW_NODE, + BLAST, + COLLAPSE, + COLOR_SUBTREE, + COPY_SUBTREE, + CUT_SUBTREE, + DELETE_NODE_OR_SUBTREE, + EDIT_NODE_DATA, + GET_EXT_DESC_DATA, + OPEN_PDB_WEB, + OPEN_SEQ_WEB, + OPEN_TAX_WEB, + PASTE_SUBTREE, + REROOT, + SELECT_NODES, + SHOW_DATA, + SORT_DESCENDENTS, + SUBTREE, + SWAP, + CHANGE_NODE_FONT, + COLOR_NODE_FONT, + UNCOLLAPSE_ALL, + ORDER_SUBTREE; + } + final static Font jcb_bold_font = new Font( Configuration + .getDefaultFontFamilyName(), Font.BOLD, Configuration.getGuiFontSize() ); + final static Font jcb_font = new Font( Configuration + .getDefaultFontFamilyName(), Font.PLAIN, Configuration.getGuiFontSize() ); + final static Font js_font = new Font( Configuration + .getDefaultFontFamilyName(), Font.PLAIN, Configuration.getGuiFontSize() ); + private static final String RETURN_TO_SUPER_TREE_TEXT = "R"; + private static final String SEARCH_TIP_TEXT = "Enter text to search for. Use ',' for logical OR and '+' for logical AND (not used in this manner for regular expression searches)."; + private static final long serialVersionUID = -8463483932821545633L; + private NodeClickAction _action_when_node_clicked; + private int _add_new_node_item; + private Map _all_click_to_names; + private Map _annotation_colors; + private int _blast_item; + private JComboBox _click_to_combobox; + private JLabel _click_to_label; + private List _click_to_names; + private int _collapse_cb_item; + private int _uncollapse_all_cb_item; + private int _order_subtree_cb_item; + private JCheckBox _color_acc_species; + private JCheckBox _color_acc_sequence; + private JCheckBox _color_according_to_annotation; + private boolean _color_branches; + private JCheckBox _use_visual_styles_cb; + private int _color_subtree_cb_item; + private int _change_node_font_item; // The settings from the conf file - private final Configuration _configuration; - private int _copy_subtree_item; - private int _cut_subtree_item; - private JButton _decr_domain_structure_evalue_thr; - private int _delete_node_or_subtree_item; - private JCheckBox _display_as_phylogram_cb; + private final Configuration _configuration; + private int _copy_subtree_item; + private int _cut_subtree_item; + private JButton _decr_domain_structure_evalue_thr; + private int _delete_node_or_subtree_item; + private JRadioButton _display_as_unaligned_phylogram_rb; + private JRadioButton _display_as_aligned_phylogram_rb; + private JRadioButton _display_as_cladogram_rb; + private ButtonGroup _display_as_buttongroup; // Tree checkboxes - private JCheckBox _display_internal_data; - private JLabel _domain_display_label; - private JTextField _domain_structure_evalue_thr_tf; - private List _draw_phylogram; - private JCheckBox _dynamically_hide_data; - private int _edit_node_data_item; - private int _get_ext_desc_data; - private JButton _incr_domain_structure_evalue_thr; - private final MainPanel _mainpanel; - private JCheckBox _node_desc_popup_cb; - private int _open_pdb_item; - private int _open_seq_web_item; - private int _open_tax_web_item; - private int _color_node_font_item; - private JButton _order; - private boolean _order_of_appearance; - private int _paste_subtree_item; - private int _reroot_cb_item; - private JButton _return_to_super_tree; + private JCheckBox _display_internal_data; + private JCheckBox _display_external_data; + private JLabel _domain_display_label; + private JTextField _domain_structure_evalue_thr_tf; + private JTextField _depth_collapse_depth_tf; + private JTextField _rank_collapse_depth_tf; + private List _tree_display_types; + private JCheckBox _dynamically_hide_data; + private int _edit_node_data_item; + private int _get_ext_desc_data; + private JButton _incr_domain_structure_evalue_thr; + private final MainPanel _mainpanel; + private JCheckBox _node_desc_popup_cb; + private int _open_pdb_item; + private int _open_seq_web_item; + private int _open_tax_web_item; + private int _color_node_font_item; + private JButton _order; + private int _paste_subtree_item; + private int _reroot_cb_item; + private JButton _return_to_super_tree; // Search - private JLabel _search_found_label_0; - private JLabel _search_found_label_1; - private JButton _search_reset_button_0; - private JButton _search_reset_button_1; - private JTextField _search_tf_0; - private JTextField _search_tf_1; - private int _select_nodes_item; - private Sequence _selected_query_seq; - private JCheckBox _seq_relation_confidence_switch; - private JComboBox _sequence_relation_type_box; - private JCheckBox _show_annotation; - private JCheckBox _show_binary_character_counts; - private JCheckBox _show_binary_characters; + private JLabel _search_found_label_0; + private JLabel _search_found_label_1; + private JButton _search_reset_button_0; + private JButton _search_reset_button_1; + private JTextField _search_tf_0; + private JTextField _search_tf_1; + private int _select_nodes_item; + private Sequence _selected_query_seq; + private JCheckBox _seq_relation_confidence_switch; + private JComboBox _sequence_relation_type_box; + private JCheckBox _show_annotation; + private JCheckBox _show_binary_character_counts; + private JCheckBox _show_binary_characters; // Indices for the click-to options in the combo box - private int _show_data_item; - private JCheckBox _show_domain_architectures; - private JCheckBox _show_mol_seqs; - private JCheckBox _write_branch_length_values; - private JCheckBox _show_events; - private JCheckBox _show_gene_names; - private JCheckBox _show_node_names; - private JCheckBox _show_properties_cb; - private JCheckBox _show_seq_names; - private JCheckBox _show_seq_symbols; - private JCheckBox _show_sequence_acc; - private JComboBox _show_sequence_relations; - private JCheckBox _show_taxo_code; - private JCheckBox _show_taxo_common_names; - private JCheckBox _show_taxo_images_cb; - private JCheckBox _show_taxo_scientific_names; - private JCheckBox _show_vector_data_cb; - private JButton _show_whole; - private int _sort_descendents_item; - private Map _species_colors; - private Map _sequence_colors; - private int _subtree_cb_item; - private int _swap_cb_item; - private JButton _uncollapse_all; - private JCheckBox _width_branches; - private JCheckBox _write_confidence; - private JButton _zoom_in_domain_structure; - private JButton _zoom_in_x; - private JButton _zoom_in_y; - private JLabel _zoom_label; - private JButton _zoom_out_domain_structure; - private JButton _zoom_out_x; - private JButton _zoom_out_y; + private int _show_data_item; + private JCheckBox _show_domain_architectures; + private JCheckBox _show_mol_seqs; + private JCheckBox _write_branch_length_values; + private JCheckBox _show_events; + private JCheckBox _show_gene_names; + private JCheckBox _show_node_names; + private JCheckBox _show_properties_cb; + private JCheckBox _show_seq_names; + private JCheckBox _show_seq_symbols; + private JCheckBox _show_sequence_acc; + private JComboBox _show_sequence_relations; + private JCheckBox _show_taxo_code; + private JCheckBox _show_taxo_rank; + private JCheckBox _show_taxo_common_names; + private JCheckBox _show_taxo_images_cb; + private JCheckBox _show_taxo_scientific_names; + private JCheckBox _show_vector_data_cb; + private JButton _show_whole; + private int _sort_descendents_item; + private Map _species_colors; + private Map _sequence_colors; + private int _subtree_cb_item; + private int _swap_cb_item; + private JButton _uncollapse_all; + private JCheckBox _width_branches; + private JCheckBox _write_confidence; + private JButton _zoom_in_domain_structure; + private JButton _zoom_in_x; + private JButton _zoom_in_y; + private JLabel _zoom_label; + private JButton _zoom_out_domain_structure; + private JButton _zoom_out_x; + private JButton _zoom_out_y; + private JButton _decr_depth_collapse_level; + private JButton _incr_depth_collapse_level; + private JLabel _depth_collapse_label; + private JButton _decr_rank_collapse_level; + private JButton _incr_rank_collapse_level; + private JLabel _rank_collapse_label; ControlPanel( final MainPanel ap, final Configuration configuration ) { init(); @@ -208,7 +224,6 @@ final class ControlPanel extends JPanel implements ActionListener { setBorder( BorderFactory.createRaisedBevelBorder() ); } setLayout( new GridLayout( 0, 1, 2, 2 ) ); - _order_of_appearance = true; setupControls(); } @@ -254,25 +269,33 @@ final class ControlPanel extends JPanel implements ActionListener { displayedPhylogenyMightHaveChanged( true ); } else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) { - if ( e.getSource() == getDisplayAsPhylogramCb() ) { - setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() ); + if ( e.getSource() == getDisplayAsUnalignedPhylogramRb() ) { + setTreeDisplayType( Options.PHYLOGENY_DISPLAY_TYPE.UNALIGNED_PHYLOGRAM ); + showWhole(); + } + if ( e.getSource() == getDisplayAsAlignedPhylogramRb() ) { + setTreeDisplayType( Options.PHYLOGENY_DISPLAY_TYPE.ALIGNED_PHYLOGRAM ); + showWhole(); + } + if ( e.getSource() == getDisplayAsCladogramRb() ) { + setTreeDisplayType( Options.PHYLOGENY_DISPLAY_TYPE.CLADOGRAM ); showWhole(); } // Zoom buttons else if ( e.getSource() == _zoom_in_x ) { - zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR ); + zoomInX( AptxConstants.BUTTON_ZOOM_IN_FACTOR, AptxConstants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR ); displayedPhylogenyMightHaveChanged( false ); } else if ( e.getSource() == _zoom_in_y ) { - zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR ); + zoomInY( AptxConstants.BUTTON_ZOOM_IN_FACTOR ); displayedPhylogenyMightHaveChanged( false ); } else if ( e.getSource() == _zoom_out_x ) { - zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR ); + zoomOutX( AptxConstants.BUTTON_ZOOM_OUT_FACTOR, AptxConstants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR ); displayedPhylogenyMightHaveChanged( false ); } else if ( e.getSource() == _zoom_out_y ) { - zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR ); + zoomOutY( AptxConstants.BUTTON_ZOOM_OUT_FACTOR ); displayedPhylogenyMightHaveChanged( false ); } else if ( e.getSource() == _show_whole ) { @@ -280,26 +303,10 @@ final class ControlPanel extends JPanel implements ActionListener { showWhole(); } else if ( e.getSource() == _return_to_super_tree ) { - _mainpanel.getCurrentTreePanel().superTree(); - showWhole(); + returnedToSuperTreePressed(); } else if ( e.getSource() == _order ) { - DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.NODE_NAME; - if ( isShowTaxonomyScientificNames() || isShowTaxonomyCode() ) { - pri = DESCENDANT_SORT_PRIORITY.TAXONOMY; - } - else if ( isShowSeqNames() || isShowSeqSymbols() || isShowGeneNames() ) { - pri = DESCENDANT_SORT_PRIORITY.SEQUENCE; - } - PhylogenyMethods.orderAppearance( tp.getPhylogeny().getRoot(), _order_of_appearance, true, pri ); - _order_of_appearance = !_order_of_appearance; - tp.setNodeInPreorderToNull(); - tp.getPhylogeny().externalNodesHaveChanged(); - tp.getPhylogeny().clearHashIdToNodeMap(); - tp.getPhylogeny().recalculateNumberOfExternalDescendants( true ); - tp.resetNodeIdToDistToLeafMap(); - tp.setEdited( true ); - displayedPhylogenyMightHaveChanged( true ); + orderPressed( tp ); } else if ( e.getSource() == _uncollapse_all ) { uncollapseAll( tp ); @@ -338,6 +345,50 @@ final class ControlPanel extends JPanel implements ActionListener { setDynamicHidingIsOn( false ); displayedPhylogenyMightHaveChanged( true ); } + else if ( ( e.getSource() == _decr_depth_collapse_level ) + || ( e.getSource() == _incr_depth_collapse_level ) ) { + if ( e.getSource() == _decr_depth_collapse_level ) { + _mainpanel.getCurrentTreePanel().decreaseDepthCollapseLevel(); + } + else { + _mainpanel.getCurrentTreePanel().increaseDepthCollapseLevel(); + } + search0(); + search1(); + _mainpanel.getCurrentTreePanel().updateSetOfCollapsedExternalNodes(); + _mainpanel.getCurrentTreePanel().getPhylogeny().recalculateNumberOfExternalDescendants( true ); + _mainpanel.getCurrentTreePanel().resetNodeIdToDistToLeafMap(); + _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo(); + _mainpanel.getCurrentTreePanel().setNodeInPreorderToNull(); + displayedPhylogenyMightHaveChanged( true ); + _mainpanel.getCurrentTreePanel().resetPreferredSize(); + _mainpanel.getCurrentTreePanel().updateOvSizes(); + _mainpanel.adjustJScrollPane(); + showWhole(); + repaint(); + } + else if ( ( e.getSource() == _decr_rank_collapse_level ) + || ( e.getSource() == _incr_rank_collapse_level ) ) { + if ( e.getSource() == _decr_rank_collapse_level ) { + _mainpanel.getCurrentTreePanel().decreaseRankCollapseLevel(); + } + else { + _mainpanel.getCurrentTreePanel().increaseRankCollapseLevel(); + } + search0(); + search1(); + _mainpanel.getCurrentTreePanel().updateSetOfCollapsedExternalNodes(); + _mainpanel.getCurrentTreePanel().getPhylogeny().recalculateNumberOfExternalDescendants( true ); + _mainpanel.getCurrentTreePanel().resetNodeIdToDistToLeafMap(); + _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo(); + _mainpanel.getCurrentTreePanel().setNodeInPreorderToNull(); + displayedPhylogenyMightHaveChanged( true ); + _mainpanel.getCurrentTreePanel().resetPreferredSize(); + _mainpanel.getCurrentTreePanel().updateOvSizes(); + _mainpanel.adjustJScrollPane(); + showWhole(); + repaint(); + } else { displayedPhylogenyMightHaveChanged( true ); } @@ -354,6 +405,31 @@ final class ControlPanel extends JPanel implements ActionListener { } } + void orderPressed( final TreePanel tp ) { + DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.NODE_NAME; + if ( isShowTaxonomyScientificNames() || isShowTaxonomyCode() ) { + pri = DESCENDANT_SORT_PRIORITY.TAXONOMY; + } + else if ( isShowSeqNames() || isShowSeqSymbols() || isShowGeneNames() ) { + pri = DESCENDANT_SORT_PRIORITY.SEQUENCE; + } + PhylogenyMethods.orderAppearanceX( tp.getPhylogeny().getRoot(), true, pri ); + tp.setNodeInPreorderToNull(); + tp.getPhylogeny().externalNodesHaveChanged(); + tp.getPhylogeny().clearHashIdToNodeMap(); + tp.getPhylogeny().recalculateNumberOfExternalDescendants( true ); + tp.resetNodeIdToDistToLeafMap(); + tp.setEdited( true ); + displayedPhylogenyMightHaveChanged( true ); + } + + void returnedToSuperTreePressed() { + if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) { + _mainpanel.getCurrentTreePanel().superTree(); + showWhole(); + } + } + public JCheckBox getColorAccSequenceCb() { return _color_acc_sequence; } @@ -362,8 +438,16 @@ final class ControlPanel extends JPanel implements ActionListener { return _color_acc_species; } - public JCheckBox getDisplayAsPhylogramCb() { - return _display_as_phylogram_cb; + public JRadioButton getDisplayAsCladogramRb() { + return _display_as_cladogram_rb; + } + + public JRadioButton getDisplayAsAlignedPhylogramRb() { + return _display_as_aligned_phylogram_rb; + } + + public JRadioButton getDisplayAsUnalignedPhylogramRb() { + return _display_as_unaligned_phylogram_rb; } public JCheckBox getDynamicallyHideData() { @@ -398,7 +482,8 @@ final class ControlPanel extends JPanel implements ActionListener { public JComboBox getSequenceRelationTypeBox() { if ( _sequence_relation_type_box == null ) { _sequence_relation_type_box = new JComboBox(); - for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) { + for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE + .values() ) { _sequence_relation_type_box.addItem( type ); } _sequence_relation_type_box.addActionListener( new ActionListener() { @@ -455,7 +540,7 @@ final class ControlPanel extends JPanel implements ActionListener { } final ArrayList sequenceNamesToAdd = new ArrayList(); for( final Sequence seq : sequenceRelationQueries ) { - if ( seq.hasSequenceRelations() ) { + if ( seq.isHasSequenceRelations() ) { boolean fFoundForCurrentType = false; for( final SequenceRelation sq : seq.getSequenceRelations() ) { if ( sq.getType().equals( relationType ) ) { @@ -520,11 +605,8 @@ final class ControlPanel extends JPanel implements ActionListener { final int index, final boolean isSelected, final boolean cellHasFocus ) { - final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list, - value, - index, - isSelected, - cellHasFocus ); + final Component component = new DefaultListCellRenderer() + .getListCellRendererComponent( list, value, index, isSelected, cellHasFocus ); if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) { ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) ); @@ -551,42 +633,32 @@ final class ControlPanel extends JPanel implements ActionListener { }// addSequenceRelationBlock /* GUILHEM_END */ - private List getIsDrawPhylogramList() { - return _draw_phylogram; + private List getTreeDisplayTypes() { + return _tree_display_types; } - // This takes care of ArchaeopteryxE-issue. - // Can, and will, return null prior to ArchaeopteryxE initialization completion. final private MainFrame getMainFrame() { - MainFrame mf = getMainPanel().getMainFrame(); - if ( mf == null ) { - // Must be "E" applet version. - final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet(); - if ( e.getMainPanel() == null ) { - return null; - } - mf = e.getMainPanel().getMainFrame(); - } - return mf; + return getMainPanel().getMainFrame(); } private void init() { - _draw_phylogram = new ArrayList(); + _tree_display_types = new ArrayList(); setSpeciesColors( new HashMap() ); setSequenceColors( new HashMap() ); setAnnotationColors( new HashMap() ); } - private boolean isDrawPhylogram( final int index ) { - return getIsDrawPhylogramList().get( index ); + private Options.PHYLOGENY_DISPLAY_TYPE getTreeDisplayType( final int index ) { + return getTreeDisplayTypes().get( index ); } - private void search0( final MainPanel main_panel, final Phylogeny tree, final String query_str ) { + private void search0( final MainPanel main_panel, final Phylogeny tree, String query_str ) { getSearchFoundCountsLabel0().setVisible( true ); getSearchResetButton0().setEnabled( true ); getSearchResetButton0().setVisible( true ); String[] queries = null; - Set nodes = null; + Set nodes = null; + query_str = query_str.replaceAll( "\\s+", " " ); if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) { queries = query_str.split( ",+" ); } @@ -595,7 +667,7 @@ final class ControlPanel extends JPanel implements ActionListener { queries[ 0 ] = query_str.trim(); } if ( ( queries != null ) && ( queries.length > 0 ) ) { - nodes = new HashSet(); + nodes = new HashSet(); for( String query : queries ) { if ( ForesterUtil.isEmpty( query ) ) { continue; @@ -608,32 +680,37 @@ final class ControlPanel extends JPanel implements ActionListener { getOptions().isSearchCaseSensitive(), !getOptions().isMatchWholeTermsOnly(), isShowDomainArchitectures(), - tp != null ? Math.pow( 10, - tp.getDomainStructureEvalueThresholdExp() ) - : 0 ) ); + tp != null + ? Math.pow( 10, + tp.getDomainStructureEvalueThresholdExp() ) + : 0 ) ); } else { - nodes.addAll( PhylogenyMethods.searchData( query, - tree, - getOptions().isSearchCaseSensitive(), - !getOptions().isMatchWholeTermsOnly(), - getOptions().isSearchWithRegex(), - isShowDomainArchitectures(), - tp != null ? Math.pow( 10, tp - .getDomainStructureEvalueThresholdExp() ) : 0 ) ); + nodes.addAll( PhylogenyMethods + .searchData( query, + tree, + getOptions().isSearchCaseSensitive(), + !getOptions().isMatchWholeTermsOnly(), + getOptions().isSearchWithRegex(), + isShowDomainArchitectures(), + tp != null ? Math.pow( 10, tp.getDomainStructureEvalueThresholdExp() ) : 0 ) ); } } if ( getOptions().isInverseSearchResult() ) { final List all = PhylogenyMethods.obtainAllNodesAsList( tree ); - all.removeAll( nodes ); - nodes = new HashSet(); - nodes.addAll( all ); + final Set temp_nodes = nodes; + nodes = new HashSet(); + for( final PhylogenyNode n : all ) { + if ( ( !temp_nodes.contains( n.getId() ) ) && n.isHasNodeData() ) { + nodes.add( n.getId() ); + } + } } } if ( ( nodes != null ) && ( nodes.size() > 0 ) ) { main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet() ); - for( final PhylogenyNode node : nodes ) { - main_panel.getCurrentTreePanel().getFoundNodes0().add( node.getId() ); + for( final Long node : nodes ) { + main_panel.getCurrentTreePanel().getFoundNodes0().add( node ); } setSearchFoundCountsOnLabel0( nodes.size() ); } @@ -643,12 +720,13 @@ final class ControlPanel extends JPanel implements ActionListener { } } - private void search1( final MainPanel main_panel, final Phylogeny tree, final String query_str ) { + private void search1( final MainPanel main_panel, final Phylogeny tree, String query_str ) { getSearchFoundCountsLabel1().setVisible( true ); getSearchResetButton1().setEnabled( true ); getSearchResetButton1().setVisible( true ); String[] queries = null; - Set nodes = null; + Set nodes = null; + query_str = query_str.replaceAll( "\\s+", " " ); if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) { queries = query_str.split( ",+" ); } @@ -657,7 +735,7 @@ final class ControlPanel extends JPanel implements ActionListener { queries[ 0 ] = query_str.trim(); } if ( ( queries != null ) && ( queries.length > 0 ) ) { - nodes = new HashSet(); + nodes = new HashSet(); for( String query : queries ) { if ( ForesterUtil.isEmpty( query ) ) { continue; @@ -670,32 +748,37 @@ final class ControlPanel extends JPanel implements ActionListener { getOptions().isSearchCaseSensitive(), !getOptions().isMatchWholeTermsOnly(), isShowDomainArchitectures(), - tp != null ? Math.pow( 10, - tp.getDomainStructureEvalueThresholdExp() ) - : 0 ) ); + tp != null + ? Math.pow( 10, + tp.getDomainStructureEvalueThresholdExp() ) + : 0 ) ); } else { - nodes.addAll( PhylogenyMethods.searchData( query, - tree, - getOptions().isSearchCaseSensitive(), - !getOptions().isMatchWholeTermsOnly(), - getOptions().isSearchWithRegex(), - isShowDomainArchitectures(), - tp != null ? Math.pow( 10, tp - .getDomainStructureEvalueThresholdExp() ) : 0 ) ); + nodes.addAll( PhylogenyMethods + .searchData( query, + tree, + getOptions().isSearchCaseSensitive(), + !getOptions().isMatchWholeTermsOnly(), + getOptions().isSearchWithRegex(), + isShowDomainArchitectures(), + tp != null ? Math.pow( 10, tp.getDomainStructureEvalueThresholdExp() ) : 0 ) ); } } if ( getOptions().isInverseSearchResult() ) { final List all = PhylogenyMethods.obtainAllNodesAsList( tree ); - all.removeAll( nodes ); - nodes = new HashSet(); - nodes.addAll( all ); + final Set temp_nodes = nodes; + nodes = new HashSet(); + for( final PhylogenyNode n : all ) { + if ( ( !temp_nodes.contains( n.getId() ) ) && n.isHasNodeData() ) { + nodes.add( n.getId() ); + } + } } } if ( ( nodes != null ) && ( nodes.size() > 0 ) ) { main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet() ); - for( final PhylogenyNode node : nodes ) { - main_panel.getCurrentTreePanel().getFoundNodes1().add( node.getId() ); + for( final Long node : nodes ) { + main_panel.getCurrentTreePanel().getFoundNodes1().add( node ); } setSearchFoundCountsOnLabel1( nodes.size() ); } @@ -705,8 +788,8 @@ final class ControlPanel extends JPanel implements ActionListener { } } - private void setDrawPhylogram( final int index, final boolean b ) { - getIsDrawPhylogramList().set( index, b ); + private void setTreeDisplayType( final int index, final Options.PHYLOGENY_DISPLAY_TYPE t ) { + getTreeDisplayTypes().set( index, t ); } private void setupClickToOptions() { @@ -731,6 +814,15 @@ final class ControlPanel extends JPanel implements ActionListener { } cb_index++; } + if ( _configuration.doDisplayClickToOption( Configuration.uncollapse_all ) ) { + _uncollapse_all_cb_item = cb_index; + addClickToOption( Configuration.uncollapse_all, + _configuration.getClickToTitle( Configuration.uncollapse_all ) ); + if ( default_option == Configuration.uncollapse_all ) { + selected_index = cb_index; + } + cb_index++; + } if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) { _reroot_cb_item = cb_index; addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) ); @@ -755,6 +847,15 @@ final class ControlPanel extends JPanel implements ActionListener { } cb_index++; } + if ( _configuration.doDisplayClickToOption( Configuration.order_subtree ) ) { + _order_subtree_cb_item = cb_index; + addClickToOption( Configuration.order_subtree, + _configuration.getClickToTitle( Configuration.order_subtree ) ); + if ( default_option == Configuration.order_subtree ) { + selected_index = cb_index; + } + cb_index++; + } if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) { _sort_descendents_item = cb_index; addClickToOption( Configuration.sort_descendents, @@ -784,7 +885,8 @@ final class ControlPanel extends JPanel implements ActionListener { } if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) { _color_subtree_cb_item = cb_index; - addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) ); + addClickToOption( Configuration.color_subtree, + _configuration.getClickToTitle( Configuration.color_subtree ) ); if ( default_option == Configuration.color_subtree ) { selected_index = cb_index; } @@ -792,7 +894,8 @@ final class ControlPanel extends JPanel implements ActionListener { } if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) { _open_seq_web_item = cb_index; - addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) ); + addClickToOption( Configuration.open_seq_web, + _configuration.getClickToTitle( Configuration.open_seq_web ) ); if ( default_option == Configuration.open_seq_web ) { selected_index = cb_index; } @@ -800,7 +903,8 @@ final class ControlPanel extends JPanel implements ActionListener { } if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) { _open_pdb_item = cb_index; - addClickToOption( Configuration.open_pdb_web, _configuration.getClickToTitle( Configuration.open_pdb_web ) ); + addClickToOption( Configuration.open_pdb_web, + _configuration.getClickToTitle( Configuration.open_pdb_web ) ); if ( default_option == Configuration.open_pdb_web ) { selected_index = cb_index; } @@ -808,7 +912,8 @@ final class ControlPanel extends JPanel implements ActionListener { } if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) { _open_tax_web_item = cb_index; - addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) ); + addClickToOption( Configuration.open_tax_web, + _configuration.getClickToTitle( Configuration.open_tax_web ) ); if ( default_option == Configuration.open_tax_web ) { selected_index = cb_index; } @@ -824,7 +929,8 @@ final class ControlPanel extends JPanel implements ActionListener { } if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) { _select_nodes_item = cb_index; - addClickToOption( Configuration.select_nodes, _configuration.getClickToTitle( Configuration.select_nodes ) ); + addClickToOption( Configuration.select_nodes, + _configuration.getClickToTitle( Configuration.select_nodes ) ); if ( default_option == Configuration.select_nodes ) { selected_index = cb_index; } @@ -833,8 +939,8 @@ final class ControlPanel extends JPanel implements ActionListener { if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) { _get_ext_desc_data = cb_index; if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) { - addClickToOption( Configuration.get_ext_desc_data, getConfiguration() - .getLabelForGetExtDescendentsData() ); + addClickToOption( Configuration.get_ext_desc_data, + getConfiguration().getLabelForGetExtDescendentsData() ); } else { addClickToOption( Configuration.get_ext_desc_data, @@ -848,7 +954,8 @@ final class ControlPanel extends JPanel implements ActionListener { if ( getOptions().isEditable() ) { if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) { _cut_subtree_item = cb_index; - addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) ); + addClickToOption( Configuration.cut_subtree, + _configuration.getClickToTitle( Configuration.cut_subtree ) ); if ( default_option == Configuration.cut_subtree ) { selected_index = cb_index; } @@ -906,12 +1013,6 @@ final class ControlPanel extends JPanel implements ActionListener { } private void setupDisplayCheckboxes() { - if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) { - addCheckbox( Configuration.display_as_phylogram, - _configuration.getDisplayTitle( Configuration.display_as_phylogram ) ); - setCheckbox( Configuration.display_as_phylogram, - _configuration.doCheckOption( Configuration.display_as_phylogram ) ); - } if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) { addCheckbox( Configuration.dynamically_hide_data, _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) ); @@ -919,7 +1020,8 @@ final class ControlPanel extends JPanel implements ActionListener { _configuration.doCheckOption( Configuration.dynamically_hide_data ) ); } if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) { - addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) ); + addCheckbox( Configuration.node_data_popup, + _configuration.getDisplayTitle( Configuration.node_data_popup ) ); setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) ); } if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) { @@ -928,6 +1030,12 @@ final class ControlPanel extends JPanel implements ActionListener { setCheckbox( Configuration.display_internal_data, _configuration.doCheckOption( Configuration.display_internal_data ) ); } + if ( _configuration.doDisplayOption( Configuration.display_external_data ) ) { + addCheckbox( Configuration.display_external_data, + _configuration.getDisplayTitle( Configuration.display_external_data ) ); + setCheckbox( Configuration.display_external_data, + _configuration.doCheckOption( Configuration.display_external_data ) ); + } if ( _configuration.doDisplayOption( Configuration.color_according_to_sequence ) ) { addCheckbox( Configuration.color_according_to_sequence, _configuration.getDisplayTitle( Configuration.color_according_to_sequence ) ); @@ -961,7 +1069,8 @@ final class ControlPanel extends JPanel implements ActionListener { } add( label ); if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) { - addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) ); + addCheckbox( Configuration.show_node_names, + _configuration.getDisplayTitle( Configuration.show_node_names ) ); setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) ); } if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) { @@ -980,18 +1089,24 @@ final class ControlPanel extends JPanel implements ActionListener { setCheckbox( Configuration.show_taxonomy_common_names, _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) ); } + if ( _configuration.doDisplayOption( Configuration.show_tax_rank ) ) { + addCheckbox( Configuration.show_tax_rank, _configuration.getDisplayTitle( Configuration.show_tax_rank ) ); + setCheckbox( Configuration.show_tax_rank, _configuration.doCheckOption( Configuration.show_tax_rank ) ); + } if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) { addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) ); setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) ); } if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) { - addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) ); + addCheckbox( Configuration.show_gene_names, + _configuration.getDisplayTitle( Configuration.show_gene_names ) ); setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) ); } if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) { addCheckbox( Configuration.show_seq_symbols, _configuration.getDisplayTitle( Configuration.show_seq_symbols ) ); - setCheckbox( Configuration.show_seq_symbols, _configuration.doCheckOption( Configuration.show_seq_symbols ) ); + setCheckbox( Configuration.show_seq_symbols, + _configuration.doCheckOption( Configuration.show_seq_symbols ) ); } if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) { addCheckbox( Configuration.show_sequence_acc, @@ -1000,7 +1115,8 @@ final class ControlPanel extends JPanel implements ActionListener { _configuration.doCheckOption( Configuration.show_sequence_acc ) ); } if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) { - addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) ); + addCheckbox( Configuration.show_annotation, + _configuration.getDisplayTitle( Configuration.show_annotation ) ); setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) ); } if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) { @@ -1044,10 +1160,12 @@ final class ControlPanel extends JPanel implements ActionListener { if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) { addCheckbox( Configuration.show_vector_data, _configuration.getDisplayTitle( Configuration.show_vector_data ) ); - setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) ); + setCheckbox( Configuration.show_vector_data, + _configuration.doCheckOption( Configuration.show_vector_data ) ); } if ( _configuration.doDisplayOption( Configuration.show_properties ) ) { - addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) ); + addCheckbox( Configuration.show_properties, + _configuration.getDisplayTitle( Configuration.show_properties ) ); setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) ); } if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) { @@ -1106,6 +1224,11 @@ final class ControlPanel extends JPanel implements ActionListener { _return_to_super_tree.setEnabled( true ); } + void activateButtonToUncollapseAll() { + _uncollapse_all.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() ); + _uncollapse_all.setEnabled( true ); + } + /** * Add zoom and quick edit buttons. (Last modified 8/9/04) */ @@ -1116,10 +1239,12 @@ final class ControlPanel extends JPanel implements ActionListener { final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) ); final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) ); final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) ); + final JPanel o_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) ); if ( !getConfiguration().isUseNativeUI() ) { x_panel.setBackground( getBackground() ); y_panel.setBackground( getBackground() ); z_panel.setBackground( getBackground() ); + o_panel.setBackground( getBackground() ); } add( _zoom_label = new JLabel( "Zoom:" ) ); customizeLabel( _zoom_label, getConfiguration() ); @@ -1127,21 +1252,21 @@ final class ControlPanel extends JPanel implements ActionListener { add( y_panel ); add( z_panel ); if ( getConfiguration().isUseNativeUI() ) { - _zoom_in_x = new JButton( "+" ); - _zoom_out_x = new JButton( "-" ); + _zoom_in_x = new TypomaticJButton( "+" ); + _zoom_out_x = new TypomaticJButton( "-" ); } else { - _zoom_in_x = new JButton( "X+" ); - _zoom_out_x = new JButton( "X-" ); + _zoom_in_x = new TypomaticJButton( "X+" ); + _zoom_out_x = new TypomaticJButton( "X-" ); } - _zoom_in_y = new JButton( "Y+" ); - _zoom_out_y = new JButton( "Y-" ); + _zoom_in_y = new TypomaticJButton( "Y+" ); + _zoom_out_y = new TypomaticJButton( "Y-" ); _show_whole = new JButton( "F" ); - _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [F or Home]" ); - _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+cursor-right]" ); - _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+cursor-up]" ); - _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+cursor-left]" ); - _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+cursor-down]" ); + _show_whole.setToolTipText( "fit and center tree display [Alt+C, Home, or Esc]" ); + _zoom_in_x.setToolTipText( "zoom in horizontally [Alt+Right or Shift+Alt+mousewheel]" ); + _zoom_in_y.setToolTipText( "zoom in vertically [Alt+Up or Shift+mousewheel]" ); + _zoom_out_x.setToolTipText( "zoom out horizontally [Alt+Left or Shift+Alt+mousewheel]" ); + _zoom_out_y.setToolTipText( "zoom out vertically [Alt+Down or Shift+mousewheel]" ); if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) { _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) ); _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) ); @@ -1154,22 +1279,32 @@ final class ControlPanel extends JPanel implements ActionListener { _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) ); _show_whole.setPreferredSize( new Dimension( 10, 10 ) ); _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT ); + _return_to_super_tree.setToolTipText( "return to the super-tree (if in sub-tree) [Alt+R]" ); _return_to_super_tree.setEnabled( false ); - _order = new JButton( "Order Subtrees" ); - _uncollapse_all = new JButton( "Uncollapse All" ); + _order = new JButton( "O" ); + _order.setToolTipText( "order all [Alt+O]" ); + _uncollapse_all = new JButton( "U" ); + _uncollapse_all.setToolTipText( "uncollapse all [Alt+U]" ); addJButton( _zoom_in_y, x_panel ); addJButton( _zoom_out_x, y_panel ); addJButton( _show_whole, y_panel ); addJButton( _zoom_in_x, y_panel ); addJButton( _zoom_out_y, z_panel ); + final JLabel spacer2 = new JLabel( "" ); + add( spacer2 ); + add( o_panel ); + addJButton( _order, o_panel ); + addJButton( _return_to_super_tree, o_panel ); + addJButton( _uncollapse_all, o_panel ); if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) { setUpControlsForDomainStrucures(); } - final JLabel spacer2 = new JLabel( "" ); - add( spacer2 ); - addJButton( _return_to_super_tree, this ); - addJButton( _order, this ); - addJButton( _uncollapse_all, this ); + if ( true ) { + setUpControlsForDepthCollapse(); + } + if ( true ) { + setUpControlsForRankCollapse(); + } final JLabel spacer3 = new JLabel( "" ); add( spacer3 ); setVisibilityOfDomainStrucureControls(); @@ -1178,18 +1313,18 @@ final class ControlPanel extends JPanel implements ActionListener { void addCheckbox( final int which, final String title ) { final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) ); switch ( which ) { - case Configuration.display_as_phylogram: - _display_as_phylogram_cb = new JCheckBox( title ); - getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" ); - addJCheckBox( getDisplayAsPhylogramCb(), ch_panel ); - add( ch_panel ); - break; case Configuration.display_internal_data: _display_internal_data = new JCheckBox( title ); _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" ); addJCheckBox( _display_internal_data, ch_panel ); add( ch_panel ); break; + case Configuration.display_external_data: + _display_external_data = new JCheckBox( title ); + _display_external_data.setToolTipText( "To allow or disallow display of external labels" ); + addJCheckBox( _display_external_data, ch_panel ); + add( ch_panel ); + break; case Configuration.color_according_to_species: _color_acc_species = new JCheckBox( title ); _color_acc_species.setToolTipText( "To colorize node labels as a function of taxonomy" ); @@ -1229,6 +1364,11 @@ final class ControlPanel extends JPanel implements ActionListener { addJCheckBox( _show_taxo_code, ch_panel ); add( ch_panel ); break; + case Configuration.show_tax_rank: + _show_taxo_rank = new JCheckBox( title ); + addJCheckBox( _show_taxo_rank, ch_panel ); + add( ch_panel ); + break; case Configuration.show_taxonomy_images: _show_taxo_images_cb = new JCheckBox( title ); addJCheckBox( _show_taxo_images_cb, ch_panel ); @@ -1362,6 +1502,16 @@ final class ControlPanel extends JPanel implements ActionListener { jcb.addActionListener( this ); } + private final void setupJRadioButton( final JRadioButton rb ) { + rb.setFocusPainted( false ); + rb.setFont( ControlPanel.jcb_font ); + if ( !_configuration.isUseNativeUI() ) { + rb.setBackground( getConfiguration().getGuiBackgroundColor() ); + rb.setForeground( getConfiguration().getGuiCheckboxTextColor() ); + } + rb.addActionListener( this ); + } + void addJTextField( final JTextField tf, final JPanel p ) { if ( !_configuration.isUseNativeUI() ) { tf.setForeground( getConfiguration().getGuiBackgroundColor() ); @@ -1377,24 +1527,33 @@ final class ControlPanel extends JPanel implements ActionListener { _return_to_super_tree.setEnabled( false ); } + void deactivateButtonToUncollapseAll() { + _uncollapse_all.setForeground( getConfiguration().getGuiButtonTextColor() ); + _uncollapse_all.setEnabled( false ); + } + void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) { if ( ( _mainpanel != null ) && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) { + if ( recalc_longest_ext_node_info ) { + _mainpanel.getCurrentTreePanel().initNodeData(); + _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo(); + } if ( getOptions().isShowOverview() ) { _mainpanel.getCurrentTreePanel().updateOvSizes(); } _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot(); setVisibilityOfDomainStrucureControls(); updateDomainStructureEvaluethresholdDisplay(); + updateDepthCollapseDepthDisplay(); + updateRankCollapseRankDisplay(); + getMainPanel().getControlPanel(); + _mainpanel.getCurrentTreePanel().updateButtonToUncollapseAll(); _mainpanel.getCurrentTreePanel().calculateScaleDistance(); _mainpanel.getCurrentTreePanel().calcMaxDepth(); _mainpanel.adjustJScrollPane(); - if ( recalc_longest_ext_node_info ) { - _mainpanel.getCurrentTreePanel().initNodeData(); - _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo(); - } _mainpanel.getCurrentTreePanel().repaint(); - // _mainpanel.getCurrentTreePanel().setUpUrtFactors(); + // _mainpanel.getCurrentTreePanel().setUpUrtFactor(); } } @@ -1488,7 +1647,9 @@ final class ControlPanel extends JPanel implements ActionListener { } boolean isDrawPhylogram() { - return isDrawPhylogram( getMainPanel().getCurrentTabIndex() ); + final Options.PHYLOGENY_DISPLAY_TYPE t = getTreeDisplayType( getMainPanel().getCurrentTabIndex() ); + return ( ( t == Options.PHYLOGENY_DISPLAY_TYPE.ALIGNED_PHYLOGRAM ) + || ( t == Options.PHYLOGENY_DISPLAY_TYPE.UNALIGNED_PHYLOGRAM ) ); } boolean isDynamicallyHideData() { @@ -1531,6 +1692,10 @@ final class ControlPanel extends JPanel implements ActionListener { return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() ); } + boolean isShowExternalData() { + return ( ( _display_external_data == null ) || _display_external_data.isSelected() ); + } + boolean isShowNodeNames() { return ( ( _show_node_names != null ) && _show_node_names.isSelected() ); } @@ -1559,6 +1724,10 @@ final class ControlPanel extends JPanel implements ActionListener { return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() ); } + boolean isShowTaxonomyRank() { + return ( ( _show_taxo_rank != null ) && _show_taxo_rank.isSelected() ); + } + boolean isShowTaxonomyCommonNames() { return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() ); } @@ -1568,7 +1737,8 @@ final class ControlPanel extends JPanel implements ActionListener { } boolean isUseVisualStyles() { - return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() ) || ( ( getUseVisualStylesCb() == null ) && _color_branches ) ); + return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() ) + || ( ( getUseVisualStylesCb() == null ) && _color_branches ) ); } boolean isWidthBranches() { @@ -1580,11 +1750,16 @@ final class ControlPanel extends JPanel implements ActionListener { } void phylogenyAdded( final Configuration configuration ) { - getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() ); + if ( configuration.isDrawAsPhylogram() ) { + getTreeDisplayTypes().add( Options.PHYLOGENY_DISPLAY_TYPE.UNALIGNED_PHYLOGRAM ); + } + else { + getTreeDisplayTypes().add( Options.PHYLOGENY_DISPLAY_TYPE.CLADOGRAM ); + } } void phylogenyRemoved( final int index ) { - getIsDrawPhylogramList().remove( index ); + getTreeDisplayTypes().remove( index ); } void search0() { @@ -1652,8 +1827,10 @@ final class ControlPanel extends JPanel implements ActionListener { void setCheckbox( final int which, final boolean state ) { switch ( which ) { case Configuration.display_as_phylogram: - if ( getDisplayAsPhylogramCb() != null ) { - getDisplayAsPhylogramCb().setSelected( state ); + if ( getDisplayAsUnalignedPhylogramRb() != null ) { + getDisplayAsUnalignedPhylogramRb().setSelected( state ); + getDisplayAsAlignedPhylogramRb().setSelected( !state ); + getDisplayAsCladogramRb().setSelected( !state ); } break; case Configuration.display_internal_data: @@ -1661,6 +1838,11 @@ final class ControlPanel extends JPanel implements ActionListener { _display_internal_data.setSelected( state ); } break; + case Configuration.display_external_data: + if ( _display_external_data != null ) { + _display_external_data.setSelected( state ); + } + break; case Configuration.color_according_to_species: if ( _color_acc_species != null ) { _color_acc_species.setSelected( state ); @@ -1696,6 +1878,11 @@ final class ControlPanel extends JPanel implements ActionListener { _show_taxo_code.setSelected( state ); } break; + case Configuration.show_tax_rank: + if ( _show_taxo_rank != null ) { + _show_taxo_rank.setSelected( state ); + } + break; case Configuration.show_taxonomy_images: if ( _show_taxo_images_cb != null ) { _show_taxo_images_cb.setSelected( state ); @@ -1878,6 +2065,12 @@ final class ControlPanel extends JPanel implements ActionListener { else if ( action == _change_node_font_item ) { setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT ); } + else if ( action == _uncollapse_all_cb_item ) { + setActionWhenNodeClicked( NodeClickAction.UNCOLLAPSE_ALL ); + } + else if ( action == _order_subtree_cb_item ) { + setActionWhenNodeClicked( NodeClickAction.ORDER_SUBTREE ); + } else { throw new RuntimeException( "unknown action: " + action ); } @@ -1886,17 +2079,32 @@ final class ControlPanel extends JPanel implements ActionListener { _click_to_combobox.setSelectedIndex( action ); } - void setColorBranches( final boolean color_branches ) { + public void setColorBranches( final boolean color_branches ) { _color_branches = color_branches; } - void setDrawPhylogram( final boolean b ) { - getDisplayAsPhylogramCb().setSelected( b ); - setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b ); + void setTreeDisplayType( final Options.PHYLOGENY_DISPLAY_TYPE t ) { + switch ( t ) { + case UNALIGNED_PHYLOGRAM: + getDisplayAsUnalignedPhylogramRb().setSelected( true ); + break; + case ALIGNED_PHYLOGRAM: + getDisplayAsAlignedPhylogramRb().setSelected( true ); + break; + case CLADOGRAM: + getDisplayAsCladogramRb().setSelected( true ); + break; + } + setTreeDisplayType( getMainPanel().getCurrentTabIndex(), t ); } void setDrawPhylogramEnabled( final boolean b ) { - getDisplayAsPhylogramCb().setEnabled( b ); + if ( getDisplayAsAlignedPhylogramRb() != null && getDisplayAsUnalignedPhylogramRb() != null + && getDisplayAsCladogramRb() != null ) { + getDisplayAsAlignedPhylogramRb().setEnabled( b ); + getDisplayAsUnalignedPhylogramRb().setEnabled( b ); + getDisplayAsCladogramRb().setEnabled( b ); + } } void setDynamicHidingIsOn( final boolean is_on ) { @@ -1937,7 +2145,7 @@ final class ControlPanel extends JPanel implements ActionListener { } void setupControls() { - // The tree display options: + setupTreeDisplayTypeOptions(); setupDisplayCheckboxes(); /* GUILHEM_BEG */ // The sequence relation query selection combo-box @@ -1955,12 +2163,38 @@ final class ControlPanel extends JPanel implements ActionListener { setupSearchTools1(); } + void setupTreeDisplayTypeOptions() { + _display_as_unaligned_phylogram_rb = new JRadioButton( "P" ); + _display_as_aligned_phylogram_rb = new JRadioButton( "A" ); + _display_as_cladogram_rb = new JRadioButton( "C" ); + _display_as_buttongroup = new ButtonGroup(); + _display_as_buttongroup.add( _display_as_unaligned_phylogram_rb ); + _display_as_buttongroup.add( _display_as_aligned_phylogram_rb ); + _display_as_buttongroup.add( _display_as_cladogram_rb ); + getDisplayAsUnalignedPhylogramRb().setToolTipText( "(unaligned) phylogram" ); + getDisplayAsAlignedPhylogramRb().setToolTipText( "aligned phylogram" ); + getDisplayAsCladogramRb().setToolTipText( "cladogram" ); + setupJRadioButton( getDisplayAsUnalignedPhylogramRb() ); + setupJRadioButton( getDisplayAsAlignedPhylogramRb() ); + setupJRadioButton( getDisplayAsCladogramRb() ); + final JPanel p = new JPanel( new GridLayout( 1, 3, 0, 0 ) ); + p.setFont( ControlPanel.jcb_font ); + if ( !_configuration.isUseNativeUI() ) { + p.setBackground( getConfiguration().getGuiBackgroundColor() ); + p.setForeground( getConfiguration().getGuiCheckboxTextColor() ); + } + p.add( _display_as_unaligned_phylogram_rb ); + p.add( _display_as_aligned_phylogram_rb ); + p.add( _display_as_cladogram_rb ); + add( p ); + } + void setUpControlsForDomainStrucures() { _domain_display_label = new JLabel( "Domain Architectures:" ); add( customizeLabel( _domain_display_label, getConfiguration() ) ); add( _domain_display_label ); - _zoom_in_domain_structure = new JButton( "d+" ); - _zoom_out_domain_structure = new JButton( "d-" ); + _zoom_in_domain_structure = new TypomaticJButton( "d+" ); + _zoom_out_domain_structure = new TypomaticJButton( "d-" ); _decr_domain_structure_evalue_thr = new JButton( "-" ); _incr_domain_structure_evalue_thr = new JButton( "+" ); _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) ); @@ -1991,6 +2225,66 @@ final class ControlPanel extends JPanel implements ActionListener { addJButton( _incr_domain_structure_evalue_thr, d2_panel ); } + void setUpControlsForDepthCollapse() { + _depth_collapse_label = new JLabel( "Collapse by Node Depth:" ); + _depth_collapse_label + .setToolTipText( "to automaticall collapse nodes with a depth equal or larger than a threshold" ); + add( customizeLabel( _depth_collapse_label, getConfiguration() ) ); + add( _depth_collapse_label ); + _decr_depth_collapse_level = new TypomaticJButton( "-" ); + _incr_depth_collapse_level = new TypomaticJButton( "+" ); + _decr_depth_collapse_level.setPreferredSize( new Dimension( 10, 10 ) ); + _incr_depth_collapse_level.setPreferredSize( new Dimension( 10, 10 ) ); + _decr_depth_collapse_level.setToolTipText( "to decrease the depth threshold (wraps around)" ); + _incr_depth_collapse_level.setToolTipText( "to increase the depth threshold (wraps around)" ); + _depth_collapse_depth_tf = new JTextField( 3 ); + _depth_collapse_depth_tf.setToolTipText( "the current depth threshold" ); + _depth_collapse_depth_tf.setEditable( false ); + if ( !getConfiguration().isUseNativeUI() ) { + _depth_collapse_depth_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() ); + _depth_collapse_depth_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() ); + _depth_collapse_depth_tf.setBorder( null ); + } + final JPanel panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) ); + if ( !_configuration.isUseNativeUI() ) { + panel.setBackground( getBackground() ); + } + add( panel ); + addJButton( _decr_depth_collapse_level, panel ); + addJTextField( _depth_collapse_depth_tf, panel ); + addJButton( _incr_depth_collapse_level, panel ); + } + + void setUpControlsForRankCollapse() { + _rank_collapse_label = new JLabel( "Collapse by Node Rank:" ); + _rank_collapse_label + .setToolTipText( "to automatically collapse nodes with a taxonomic rank equal or lower than a threshold" ); + add( customizeLabel( _rank_collapse_label, getConfiguration() ) ); + add( _rank_collapse_label ); + _decr_rank_collapse_level = new TypomaticJButton( "-" ); + _incr_rank_collapse_level = new TypomaticJButton( "+" ); + _decr_rank_collapse_level.setPreferredSize( new Dimension( 10, 10 ) ); + _incr_rank_collapse_level.setPreferredSize( new Dimension( 10, 10 ) ); + _decr_rank_collapse_level.setToolTipText( "to decrease the taxonomic rank threshold (wraps around)" ); + _incr_rank_collapse_level.setToolTipText( "to increase the taxonomic rank threshold (wraps around)" ); + _rank_collapse_depth_tf = new JTextField( 3 ); + _rank_collapse_depth_tf.setToolTipText( "the current taxonomic rank threshold" ); + _rank_collapse_depth_tf.setEditable( false ); + if ( !getConfiguration().isUseNativeUI() ) { + _rank_collapse_depth_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() ); + _rank_collapse_depth_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() ); + _rank_collapse_depth_tf.setBorder( null ); + } + final JPanel panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) ); + if ( !_configuration.isUseNativeUI() ) { + panel.setBackground( getBackground() ); + } + add( panel ); + addJButton( _decr_rank_collapse_level, panel ); + addJTextField( _rank_collapse_depth_tf, panel ); + addJButton( _incr_rank_collapse_level, panel ); + } + void setupSearchTools0() { final JLabel search_label = new JLabel( "Search (A):" ); search_label.setFont( ControlPanel.jcb_bold_font ); @@ -2113,9 +2407,9 @@ final class ControlPanel extends JPanel implements ActionListener { void setVisibilityOfDomainStrucureCB() { try { - if ( ( getCurrentTreePanel() != null ) - && ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( getCurrentTreePanel() - .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) { + if ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel() + .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) + || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) { if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) { getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false ); } @@ -2180,15 +2474,12 @@ final class ControlPanel extends JPanel implements ActionListener { } } } - if ( isDrawPhylogram() - || ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( getCurrentTreePanel() - .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) ) { + if ( isDrawPhylogram() || ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel() + .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) + || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) ) { if ( mf._non_lined_up_cladograms_rbmi != null ) { mf._non_lined_up_cladograms_rbmi.setVisible( false ); } - if ( mf._uniform_cladograms_rbmi != null ) { - mf._uniform_cladograms_rbmi.setVisible( false ); - } if ( mf._ext_node_dependent_cladogram_rbmi != null ) { mf._ext_node_dependent_cladogram_rbmi.setVisible( false ); } @@ -2197,9 +2488,6 @@ final class ControlPanel extends JPanel implements ActionListener { if ( mf._non_lined_up_cladograms_rbmi != null ) { mf._non_lined_up_cladograms_rbmi.setVisible( true ); } - if ( mf._uniform_cladograms_rbmi != null ) { - mf._uniform_cladograms_rbmi.setVisible( true ); - } if ( mf._ext_node_dependent_cladogram_rbmi != null ) { mf._ext_node_dependent_cladogram_rbmi.setVisible( true ); } @@ -2250,7 +2538,8 @@ final class ControlPanel extends JPanel implements ActionListener { * Fit entire tree into window. */ void showWhole() { - if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) { + if ( ( _mainpanel.getCurrentScrollPane() == null ) + || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) { return; } getCurrentTreePanel().updateSetOfCollapsedExternalNodes(); @@ -2313,25 +2602,21 @@ final class ControlPanel extends JPanel implements ActionListener { if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) { setDrawPhylogramEnabled( true ); - setDrawPhylogram( isDrawPhylogram() ); + setTreeDisplayType( getTreeDisplayType( getMainPanel().getCurrentTabIndex() ) ); } else { setDrawPhylogramEnabled( false ); - setDrawPhylogram( false ); - } - if ( getMainPanel().getMainFrame() == null ) { - // Must be "E" applet version. - final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet(); - e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() ); - } - else { - getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel() - .getPhylogenyGraphicsType() ); + setTreeDisplayType( Options.PHYLOGENY_DISPLAY_TYPE.CLADOGRAM ); } + getMainPanel().getMainFrame() + .setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel().getPhylogenyGraphicsType() ); getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton(); + getMainPanel().getCurrentTreePanel().updateButtonToUncollapseAll(); getMainPanel().getControlPanel().search0(); getMainPanel().getControlPanel().search1(); getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay(); + getMainPanel().getControlPanel().updateDepthCollapseDepthDisplay(); + getMainPanel().getControlPanel().updateRankCollapseRankDisplay(); getSequenceRelationTypeBox().removeAllItems(); for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny() .getRelevantSequenceRelationTypes() ) { @@ -2346,7 +2631,7 @@ final class ControlPanel extends JPanel implements ActionListener { /** * Uncollapse all nodes. */ - void uncollapseAll( final TreePanel tp ) { + final void uncollapseAll( final TreePanel tp ) { final Phylogeny t = tp.getPhylogeny(); if ( ( t != null ) && !t.isEmpty() ) { for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) { @@ -2358,18 +2643,88 @@ final class ControlPanel extends JPanel implements ActionListener { t.recalculateNumberOfExternalDescendants( false ); tp.setNodeInPreorderToNull(); t.clearHashIdToNodeMap(); + tp.resetDepthCollapseDepthValue(); + tp.resetRankCollapseRankValue(); showWhole(); } } - void updateDomainStructureEvaluethresholdDisplay() { + final void updateDomainStructureEvaluethresholdDisplay() { if ( _domain_structure_evalue_thr_tf != null ) { - _domain_structure_evalue_thr_tf.setText( "10^" - + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThresholdExp() ); + _domain_structure_evalue_thr_tf + .setText( "10^" + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThresholdExp() ); } } - void zoomInX( final float factor, final float x_correction_factor ) { + private final String obtainDepthCollapseDepthValue() { + if ( getMainPanel().getCurrentTreePanel() == null ) { + return ""; + } + final TreePanel tp = getMainPanel().getCurrentTreePanel(); + final Phylogeny p = tp.getPhylogeny(); + if ( ( p == null ) || ( p.getNumberOfExternalNodes() < 3 ) ) { + return "off"; + } + else if ( tp.getDepthCollapseDepthValue() < 0 ) { + tp.setDepthCollapseDepthValue( PhylogenyMethods.calculateMaxDepth( p ) ); + return "off"; + } + else if ( tp.getDepthCollapseDepthValue() == PhylogenyMethods.calculateMaxDepth( p ) ) { + return "off"; + } + return String.valueOf( tp.getDepthCollapseDepthValue() ); + } + + private final String obtainRankCollapseDepthValue() { + if ( getMainPanel().getCurrentTreePanel() == null ) { + return ""; + } + final TreePanel tp = getMainPanel().getCurrentTreePanel(); + final Phylogeny p = tp.getPhylogeny(); + if ( ( p == null ) || ( p.getNumberOfExternalNodes() < 3 ) ) { + return "off"; + } + else { + final String ranks[] = PhylogenyMethods.obtainPresentRanksSorted( p ); + if ( ranks.length < 1 ) { + return "off"; + } + else if ( tp.getRankCollapseRankValue() < 0 ) { + tp.setRankCollapseRankValue( ranks.length - 1 ); + return "off"; + } + else if ( tp.getRankCollapseRankValue() == ( ranks.length - 1 ) ) { + return "off"; + } + } + return String.valueOf( tp.getRankCollapseRankValue() ); + } + + final void updateDepthCollapseDepthDisplay() { + if ( _depth_collapse_depth_tf != null ) { + _depth_collapse_depth_tf.setText( " " + obtainDepthCollapseDepthValue() ); + } + } + + final void updateRankCollapseRankDisplay() { + if ( _rank_collapse_depth_tf != null ) { + final String r = obtainRankCollapseDepthValue(); + if ( r.equals( "off" ) ) { + _rank_collapse_depth_tf.setText( " off" ); + _rank_collapse_depth_tf.setToolTipText( "the current taxonomic rank threshold" ); + } + else { + final String ranks[] = PhylogenyMethods + .obtainPresentRanksSorted( getMainPanel().getCurrentTreePanel().getPhylogeny() ); + final int rr = Integer.parseInt( r ); + _rank_collapse_depth_tf.setText( ranks[ rr ] ); + _rank_collapse_depth_tf.setToolTipText( ( rr + 1 ) + "/" + ( ranks.length - 1 ) + ": " + + ranks[ Integer.parseInt( r ) ] ); + } + } + } + + final void zoomInX( final float factor, final float x_correction_factor ) { final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar(); final TreePanel treepanel = getMainPanel().getCurrentTreePanel(); treepanel.multiplyUrtFactor( 1f ); @@ -2377,14 +2732,15 @@ final class ControlPanel extends JPanel implements ActionListener { || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) || isDrawPhylogram( getMainPanel().getCurrentTabIndex() ) || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) { - final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) ); + final double x = ( sb.getMaximum() - sb.getMinimum() ) + / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) ); treepanel.setXdistance( ( treepanel.getXdistance() * factor ) ); treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) ); getMainPanel().adjustJScrollPane(); treepanel.resetPreferredSize(); getMainPanel().getCurrentScrollPane().getViewport().validate(); - sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - - ( sb.getVisibleAmount() / 2.0 ) ) ); + sb.setValue( ForesterUtil + .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) ); } else { final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue(); @@ -2399,7 +2755,7 @@ final class ControlPanel extends JPanel implements ActionListener { treepanel.updateOvSizes(); } - void zoomInY( final float factor ) { + final void zoomInY( final float factor ) { final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar(); final TreePanel treepanel = getMainPanel().getCurrentTreePanel(); treepanel.multiplyUrtFactor( 1.1f ); @@ -2408,13 +2764,13 @@ final class ControlPanel extends JPanel implements ActionListener { getMainPanel().adjustJScrollPane(); treepanel.resetPreferredSize(); getMainPanel().getCurrentScrollPane().getViewport().validate(); - sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - - ( sb.getVisibleAmount() / 2.0 ) ) ); + sb.setValue( ForesterUtil + .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) ); treepanel.resetPreferredSize(); treepanel.updateOvSizes(); } - void zoomOutX( final float factor, final float x_correction_factor ) { + final void zoomOutX( final float factor, final float x_correction_factor ) { final TreePanel treepanel = getMainPanel().getCurrentTreePanel(); treepanel.multiplyUrtFactor( 1f ); if ( ( treepanel.getXdistance() * factor ) > 0.0 ) { @@ -2452,24 +2808,31 @@ final class ControlPanel extends JPanel implements ActionListener { } } - void zoomOutY( final float factor ) { + private final boolean isDrawPhylogram( int currentTabIndex ) { + Options.PHYLOGENY_DISPLAY_TYPE t = getTreeDisplayType( currentTabIndex ); + return ( ( t == Options.PHYLOGENY_DISPLAY_TYPE.ALIGNED_PHYLOGRAM ) + | ( t == Options.PHYLOGENY_DISPLAY_TYPE.UNALIGNED_PHYLOGRAM ) ); + } + + final void zoomOutY( final float factor ) { final TreePanel treepanel = getMainPanel().getCurrentTreePanel(); treepanel.multiplyUrtFactor( 0.9f ); if ( ( treepanel.getYdistance() * factor ) > 0.0 ) { final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar(); - final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) ); + final double x = ( sb.getMaximum() - sb.getMinimum() ) + / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) ); treepanel.setYdistance( ( treepanel.getYdistance() * factor ) ); getMainPanel().adjustJScrollPane(); treepanel.resetPreferredSize(); getMainPanel().getCurrentScrollPane().getViewport().validate(); - sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - - ( sb.getVisibleAmount() / 2.0 ) ) ); + sb.setValue( ForesterUtil + .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) ); treepanel.resetPreferredSize(); treepanel.updateOvSizes(); } } - static JLabel customizeLabel( final JLabel label, final Configuration configuration ) { + final static JLabel customizeLabel( final JLabel label, final Configuration configuration ) { label.setFont( ControlPanel.jcb_bold_font ); if ( !configuration.isUseNativeUI() ) { label.setForeground( configuration.getGuiCheckboxTextColor() ); @@ -2477,4 +2840,18 @@ final class ControlPanel extends JPanel implements ActionListener { } return label; } + + final public JCheckBox getUseBranchWidthsCb() { + return _width_branches; + } + + public Options.PHYLOGENY_DISPLAY_TYPE getTreeDisplayType() { + if ( _display_as_unaligned_phylogram_rb.isSelected() ) { + return Options.PHYLOGENY_DISPLAY_TYPE.UNALIGNED_PHYLOGRAM; + } + else if ( _display_as_aligned_phylogram_rb.isSelected() ) { + return Options.PHYLOGENY_DISPLAY_TYPE.ALIGNED_PHYLOGRAM; + } + return Options.PHYLOGENY_DISPLAY_TYPE.CLADOGRAM; + } }