X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FControlPanel.java;h=26d5c6b5c75c9d43f38089b369507943d6d4fbef;hb=10297bd8b8a4b4ab198a17a42fc6ff24ae2ed49b;hp=b58411ba6bf03d5ab88188fb252f8be71494940d;hpb=f6de7e66f71bf840d3d68ed70dda9946ad2e0faa;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java index b58411b..26d5c6b 100644 --- a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java +++ b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java @@ -20,7 +20,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA // // Contact: phylosoft @ gmail . com -// WWW: www.phylosoft.org/forester +// WWW: https://sites.google.com/site/cmzmasek/home/software/forester package org.forester.archaeopteryx; @@ -65,100 +65,115 @@ 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.data.SequenceRelation.SEQUENCE_RELATION_TYPE; import org.forester.phylogeny.iterators.PhylogenyNodeIterator; import org.forester.util.ForesterUtil; final class ControlPanel extends JPanel implements ActionListener { - private static final String RETURN_TO_SUPER_TREE_TEXT = "Back to Super Tree"; - final static Font jcb_font = new Font( Configuration.getDefaultFontFamilyName(), - Font.PLAIN, - 9 ); - final static Font js_font = new Font( Configuration.getDefaultFontFamilyName(), - Font.PLAIN, - 9 ); - final static Font jcb_bold_font = new Font( Configuration.getDefaultFontFamilyName(), - Font.BOLD, - 9 ); - private static final long serialVersionUID = -8463483932821545633L; - private final MainPanel _mainpanel; + 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; // The settings from the conf file - private final Configuration _configuration; + 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; // Tree checkboxes - private JCheckBox _display_internal_data; - private JCheckBox _show_node_names; - private JCheckBox _show_taxo_code; - private JCheckBox _write_confidence; - private JCheckBox _show_events; - private JCheckBox _color_acc_species; - private JCheckBox _color_branches_cb; - private JCheckBox _width_branches; - private JCheckBox _show_domain_architectures; - private JCheckBox _show_annotation; - private JCheckBox _show_binary_characters; - private JCheckBox _show_binary_character_counts; - private JCheckBox _show_gene_names; - private JCheckBox _show_gene_symbols; - private JCheckBox _show_sequence_acc; - private JCheckBox _node_desc_popup_cb; - private JCheckBox _dynamically_hide_data; - private JCheckBox _show_taxo_scientific_names; - private JCheckBox _show_taxo_common_names; - private JCheckBox _show_taxo_images_cb; - private JCheckBox _color_according_to_annotation; - private JCheckBox _display_as_phylogram_cb; - private JCheckBox _seq_relation_confidence_switch; - private JComboBox _show_sequence_relations; - private JComboBox _sequence_relation_type_box; - private JCheckBox _show_vector_data_cb; - private JCheckBox _show_properties_cb; - private JLabel _click_to_label; - private JLabel _zoom_label; - private JLabel _domain_display_label; - private JComboBox _click_to_combobox; - private Map _all_click_to_names; - private List _click_to_names; + 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; + // 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; // Indices for the click-to options in the combo box - private int _show_data_item; - private int _collapse_cb_item; - private int _reroot_cb_item; - private int _swap_cb_item; - 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; - private int _delete_node_or_subtree_item; - private int _paste_subtree_item; - private int _add_new_node_item; - private int _edit_node_data_item; - private int _blast_item; - // zooming and quick tree manipulation buttons: - private JButton _zoom_in_x; - private JButton _zoom_in_y; - private JButton _zoom_out_x; - private JButton _zoom_out_y; - private JButton _show_whole; - private JButton _order; - private JButton _uncollapse_all; - private JButton _zoom_in_domain_structure; - private JButton _zoom_out_domain_structure; - private JButton _decr_domain_structure_evalue_thr; - private JButton _incr_domain_structure_evalue_thr; - private JButton _return_to_super_tree; - private JTextField _domain_structure_evalue_thr_tf; - private JTextField _search_tf; - private boolean _order_of_appearance; - private boolean _color_branches; - private NodeClickAction _action_when_node_clicked; - private List _draw_phylogram; - private Map _annotation_colors; - private Map _species_colors; - private JButton _search_reset_button; - private JLabel _search_found_label; - private Sequence _selected_query_seq; + 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; ControlPanel( final MainPanel ap, final Configuration configuration ) { init(); @@ -179,6 +194,16 @@ final class ControlPanel extends JPanel implements ActionListener { @Override public void actionPerformed( final ActionEvent e ) { try { + if ( e.getSource() == _color_acc_sequence ) { + if ( _color_acc_species != null ) { + _color_acc_species.setSelected( false ); + } + } + else if ( e.getSource() == _color_acc_species ) { + if ( _color_acc_sequence != null ) { + _color_acc_sequence.setSelected( false ); + } + } final TreePanel tp = getMainPanel().getCurrentTreePanel(); if ( tp == null ) { return; @@ -199,17 +224,10 @@ final class ControlPanel extends JPanel implements ActionListener { } displayedPhylogenyMightHaveChanged( true ); } - else if ( e.getSource() == _color_according_to_annotation ) { - if ( ( _show_annotation != null ) && _color_according_to_annotation.isSelected() ) { - _show_annotation.setSelected( true ); - } - displayedPhylogenyMightHaveChanged( false ); - } - else if ( e.getSource() == _show_annotation ) { - if ( ( _color_according_to_annotation != null ) && !_show_annotation.isSelected() ) { - _color_according_to_annotation.setSelected( false ); - } - displayedPhylogenyMightHaveChanged( false ); + else if ( e.getSource() == _show_domain_architectures ) { + search0(); + search1(); + displayedPhylogenyMightHaveChanged( true ); } else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) { if ( e.getSource() == getDisplayAsPhylogramCb() ) { @@ -234,6 +252,7 @@ final class ControlPanel extends JPanel implements ActionListener { displayedPhylogenyMightHaveChanged( false ); } else if ( e.getSource() == _show_whole ) { + displayedPhylogenyMightHaveChanged( true ); showWhole(); } else if ( e.getSource() == _return_to_super_tree ) { @@ -241,24 +260,22 @@ final class ControlPanel extends JPanel implements ActionListener { showWhole(); } else if ( e.getSource() == _order ) { - 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; - } + 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().hashIDs(); + tp.getPhylogeny().clearHashIdToNodeMap(); tp.getPhylogeny().recalculateNumberOfExternalDescendants( true ); tp.resetNodeIdToDistToLeafMap(); tp.setEdited( true ); - displayedPhylogenyMightHaveChanged( false ); + displayedPhylogenyMightHaveChanged( true ); } else if ( e.getSource() == _uncollapse_all ) { uncollapseAll( tp ); @@ -280,8 +297,17 @@ final class ControlPanel extends JPanel implements ActionListener { _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThreshold(); displayedPhylogenyMightHaveChanged( true ); } - else if ( e.getSource() == _search_tf ) { - search(); + else if ( e.getSource() == _search_tf_0 ) { + search0(); + displayedPhylogenyMightHaveChanged( true ); + } + else if ( e.getSource() == _search_tf_1 ) { + search1(); + displayedPhylogenyMightHaveChanged( true ); + } + else if ( ( _dynamically_hide_data != null ) && ( e.getSource() == _dynamically_hide_data ) + && !_dynamically_hide_data.isSelected() ) { + setDynamicHidingIsOn( false ); displayedPhylogenyMightHaveChanged( true ); } else { @@ -300,6 +326,136 @@ final class ControlPanel extends JPanel implements ActionListener { } } + public JCheckBox getColorAccSpeciesCb() { + return _color_acc_species; + } + + public JCheckBox getColorAccSequenceCb() { + return _color_acc_sequence; + } + + public JCheckBox getUseVisualStylesCb() { + return _use_visual_styles_cb; + } + + public JCheckBox getDisplayAsPhylogramCb() { + return _display_as_phylogram_cb; + } + + public JCheckBox getDynamicallyHideData() { + return _dynamically_hide_data; + } + + public JCheckBox getNodeDescPopupCb() { + return _node_desc_popup_cb; + } + + public Sequence getSelectedQuerySequence() { + return _selected_query_seq; + } + + public JComboBox getSequenceRelationBox() { + if ( _show_sequence_relations == null ) { + _show_sequence_relations = new JComboBox(); + _show_sequence_relations.setFocusable( false ); + _show_sequence_relations.setMaximumRowCount( 20 ); + _show_sequence_relations.setFont( ControlPanel.js_font ); + if ( !_configuration.isUseNativeUI() ) { + _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() ); + _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() ); + } + _show_sequence_relations.addItem( "-----" ); + _show_sequence_relations.setToolTipText( "To display orthology information for selected query" ); + } + return _show_sequence_relations; + } + + /* GUILHEM_BEG */ + public JComboBox getSequenceRelationTypeBox() { + if ( _sequence_relation_type_box == null ) { + _sequence_relation_type_box = new JComboBox(); + for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) { + _sequence_relation_type_box.addItem( type ); + } + _sequence_relation_type_box.addActionListener( new ActionListener() { + + @Override + public void actionPerformed( final ActionEvent e ) { + if ( _mainpanel.getCurrentPhylogeny() != null ) { + setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() ); + } + } + } ); + } + return _sequence_relation_type_box; + } + + public JCheckBox getShowEventsCb() { + return _show_events; + } + + public JCheckBox getWriteConfidenceCb() { + return _write_confidence; + } + + public boolean isShowProperties() { + return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() ); + } + + public boolean isShowTaxonomyImages() { + return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() ); + } + + public boolean isShowVectorData() { + return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() ); + } + + public void setSequenceRelationQueries( final Collection sequenceRelationQueries ) { + final JComboBox box = getSequenceRelationBox(); + while ( box.getItemCount() > 1 ) { + box.removeItemAt( 1 ); + } + final HashMap sequencesByName = new HashMap(); + final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box + .getSelectedItem(); + if ( relationType == null ) { + return; + } + final ArrayList sequenceNamesToAdd = new ArrayList(); + for( final Sequence seq : sequenceRelationQueries ) { + if ( seq.hasSequenceRelations() ) { + boolean fFoundForCurrentType = false; + for( final SequenceRelation sq : seq.getSequenceRelations() ) { + if ( sq.getType().equals( relationType ) ) { + fFoundForCurrentType = true; + break; + } + } + if ( fFoundForCurrentType ) { + sequenceNamesToAdd.add( seq.getName() ); + sequencesByName.put( seq.getName(), seq ); + } + } + } + // sort sequences by name before adding them to the combo + final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] ); + Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER ); + for( final String seqName : sequenceNameArray ) { + box.addItem( seqName ); + } + for( final ItemListener oldItemListener : box.getItemListeners() ) { + box.removeItemListener( oldItemListener ); + } + box.addItemListener( new ItemListener() { + + @Override + public void itemStateChanged( final ItemEvent e ) { + _selected_query_seq = sequencesByName.get( e.getItem() ); + _mainpanel.getCurrentTreePanel().repaint(); + } + } ); + } + void activateButtonToReturnToSuperTree( int index ) { --index; if ( index > 0 ) { @@ -343,12 +499,12 @@ final class ControlPanel extends JPanel implements ActionListener { _zoom_in_y = new JButton( "Y+" ); _zoom_out_y = new JButton( "Y-" ); _show_whole = new JButton( "F" ); - _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [Backspace]" ); - _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+Right]" ); - _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+Up]" ); - _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+Left]" ); - _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+Down]" ); - if ( getConfiguration().isUseNativeUI() && AptxUtil.isMac() ) { + _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]" ); + if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) { _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) ); _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) ); } @@ -398,11 +554,16 @@ final class ControlPanel extends JPanel implements ActionListener { break; case Configuration.color_according_to_species: _color_acc_species = new JCheckBox( title ); - _color_acc_species - .setToolTipText( "To colorize taxonomy and sequence labels as a function of taxonomy" ); + _color_acc_species.setToolTipText( "To colorize node labels as a function of taxonomy" ); addJCheckBox( _color_acc_species, ch_panel ); add( ch_panel ); break; + case Configuration.color_according_to_sequence: + _color_acc_sequence = new JCheckBox( title ); + _color_acc_sequence.setToolTipText( "To colorize node labels as a function of sequence name" ); + addJCheckBox( _color_acc_sequence, ch_panel ); + add( ch_panel ); + break; case Configuration.color_according_to_annotation: _color_according_to_annotation = new JCheckBox( title ); _color_according_to_annotation @@ -460,10 +621,11 @@ final class ControlPanel extends JPanel implements ActionListener { addJCheckBox( getShowEventsCb(), ch_panel ); add( ch_panel ); break; - case Configuration.color_branches: - _color_branches_cb = new JCheckBox( title ); - getColorBranchesCb().setToolTipText( "To use branch color values, if present" ); - addJCheckBox( getColorBranchesCb(), ch_panel ); + case Configuration.use_style: + _use_visual_styles_cb = new JCheckBox( title ); + getUseVisualStylesCb() + .setToolTipText( "To use visual styles (node colors, fonts) and branch colors, if present" ); + addJCheckBox( getUseVisualStylesCb(), ch_panel ); add( ch_panel ); break; case Configuration.width_branches: @@ -472,19 +634,34 @@ final class ControlPanel extends JPanel implements ActionListener { addJCheckBox( _width_branches, ch_panel ); add( ch_panel ); break; + case Configuration.write_branch_length_values: + _write_branch_length_values = new JCheckBox( title ); + addJCheckBox( _write_branch_length_values, ch_panel ); + add( ch_panel ); + break; case Configuration.show_domain_architectures: _show_domain_architectures = new JCheckBox( title ); addJCheckBox( _show_domain_architectures, ch_panel ); add( ch_panel ); break; + case Configuration.show_mol_seqs: + _show_mol_seqs = new JCheckBox( title ); + addJCheckBox( _show_mol_seqs, ch_panel ); + add( ch_panel ); + break; + case Configuration.show_seq_names: + _show_seq_names = new JCheckBox( title ); + addJCheckBox( _show_seq_names, ch_panel ); + add( ch_panel ); + break; case Configuration.show_gene_names: _show_gene_names = new JCheckBox( title ); addJCheckBox( _show_gene_names, ch_panel ); add( ch_panel ); break; - case Configuration.show_gene_symbols: - _show_gene_symbols = new JCheckBox( title ); - addJCheckBox( _show_gene_symbols, ch_panel ); + case Configuration.show_seq_symbols: + _show_seq_symbols = new JCheckBox( title ); + addJCheckBox( _show_seq_symbols, ch_panel ); add( ch_panel ); break; case Configuration.show_sequence_acc: @@ -494,7 +671,7 @@ final class ControlPanel extends JPanel implements ActionListener { break; case Configuration.dynamically_hide_data: _dynamically_hide_data = new JCheckBox( title ); - getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" ); + getDynamicallyHideData().setToolTipText( "To hide labels depending on expected visibility" ); addJCheckBox( getDynamicallyHideData(), ch_panel ); add( ch_panel ); break; @@ -524,16 +701,6 @@ final class ControlPanel extends JPanel implements ActionListener { } }// addCheckbox - private void addClickToOption( final int which, final String title ) { - _click_to_combobox.addItem( title ); - _click_to_names.add( title ); - _all_click_to_names.put( new Integer( which ), title ); - if ( !_configuration.isUseNativeUI() ) { - _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() ); - _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() ); - } - } - void addJButton( final JButton jb, final JPanel p ) { jb.setFocusPainted( false ); jb.setFont( ControlPanel.jcb_font ); @@ -566,58 +733,6 @@ final class ControlPanel extends JPanel implements ActionListener { tf.addActionListener( this ); } - /* GUILHEM_BEG */ - private void addSequenceRelationBlock() { - final JLabel spacer = new JLabel( "" ); - spacer.setSize( 1, 1 ); - add( spacer ); - final JLabel mainLabel = new JLabel( "Sequence relations to display" ); - final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() ); - typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) ); - getSequenceRelationTypeBox().setFocusable( false ); - _sequence_relation_type_box.setFont( ControlPanel.js_font ); - if ( !_configuration.isUseNativeUI() ) { - _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() ); - _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() ); - } - _sequence_relation_type_box.setRenderer( new ListCellRenderer() { - - @Override - public Component getListCellRendererComponent( final JList list, - final Object value, - final int index, - final boolean isSelected, - final boolean cellHasFocus ) { - final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list, - value, - index, - isSelected, - cellHasFocus ); - if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) { - ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation - .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) ); - } - return component; - } - } ); - final GridBagLayout gbl = new GridBagLayout(); - _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) ); - _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) ); - final JPanel horizGrid = new JPanel( gbl ); - horizGrid.setBackground( getBackground() ); - horizGrid.add( typeLabel ); - horizGrid.add( _sequence_relation_type_box ); - add( customizeLabel( mainLabel, getConfiguration() ) ); - add( horizGrid ); - add( getSequenceRelationBox() ); - if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) { - addCheckbox( Configuration.show_relation_confidence, - _configuration.getDisplayTitle( Configuration.show_relation_confidence ) ); - setCheckbox( Configuration.show_relation_confidence, - _configuration.doCheckOption( Configuration.show_relation_confidence ) ); - } - }// addSequenceRelationBlock - void deactivateButtonToReturnToSuperTree() { _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT ); _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() ); @@ -625,7 +740,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(); } @@ -650,7 +766,7 @@ final class ControlPanel extends JPanel implements ActionListener { /** * Indicates what action should be execute when a node is clicked - * + * * @return the click-on action */ NodeClickAction getActionWhenNodeClicked() { @@ -665,14 +781,6 @@ final class ControlPanel extends JPanel implements ActionListener { return _annotation_colors; } - public JCheckBox getColorBranchesCb() { - return _color_branches_cb; - } - - public JCheckBox getColorAccSpeciesCb() { - return _color_acc_species; - } - Configuration getConfiguration() { return _configuration; } @@ -681,108 +789,53 @@ final class ControlPanel extends JPanel implements ActionListener { return getMainPanel().getCurrentTreePanel(); } - public JCheckBox getDisplayAsPhylogramCb() { - return _display_as_phylogram_cb; + MainPanel getMainPanel() { + return _mainpanel; } - public JCheckBox getDynamicallyHideData() { - return _dynamically_hide_data; + Options getOptions() { + return getMainPanel().getOptions(); } - /* GUILHEM_END */ - private List getIsDrawPhylogramList() { - return _draw_phylogram; + JLabel getSearchFoundCountsLabel0() { + return _search_found_label_0; } - MainPanel getMainPanel() { - return _mainpanel; + JLabel getSearchFoundCountsLabel1() { + return _search_found_label_1; } - public JCheckBox getNodeDescPopupCb() { - return _node_desc_popup_cb; + JButton getSearchResetButton0() { + return _search_reset_button_0; } - Options getOptions() { - return getMainPanel().getOptions(); + JButton getSearchResetButton1() { + return _search_reset_button_1; } - private JLabel getSearchFoundCountsLabel() { - return _search_found_label; + JTextField getSearchTextField0() { + return _search_tf_0; } - private JButton getSearchResetButton() { - return _search_reset_button; + JTextField getSearchTextField1() { + return _search_tf_1; } - JTextField getSearchTextField() { - return _search_tf; + List getSingleClickToNames() { + return _click_to_names; } - public Sequence getSelectedQuerySequence() { - return _selected_query_seq; + Map getSpeciesColors() { + return _species_colors; } - public JComboBox getSequenceRelationBox() { - if ( _show_sequence_relations == null ) { - _show_sequence_relations = new JComboBox(); - _show_sequence_relations.setFocusable( false ); - _show_sequence_relations.setMaximumRowCount( 20 ); - _show_sequence_relations.setFont( ControlPanel.js_font ); - if ( !_configuration.isUseNativeUI() ) { - _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() ); - _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() ); - } - _show_sequence_relations.addItem( "-----" ); - _show_sequence_relations.setToolTipText( "To display orthology information for selected query" ); - } - return _show_sequence_relations; + Map getSequenceColors() { + return _sequence_colors; } - /* GUILHEM_BEG */ - public JComboBox getSequenceRelationTypeBox() { - if ( _sequence_relation_type_box == null ) { - _sequence_relation_type_box = new JComboBox(); - for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) { - _sequence_relation_type_box.addItem( type ); - } - _sequence_relation_type_box.addActionListener( new ActionListener() { - - @Override - public void actionPerformed( final ActionEvent e ) { - if ( _mainpanel.getCurrentPhylogeny() != null ) { - setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() ); - } - } - } ); - } - return _sequence_relation_type_box; - } - - public JCheckBox getShowEventsCb() { - return _show_events; - } - - List getSingleClickToNames() { - return _click_to_names; - } - - Map getSpeciesColors() { - return _species_colors; - } - - public JCheckBox getWriteConfidenceCb() { - return _write_confidence; - } - - private void init() { - _draw_phylogram = new ArrayList(); - setSpeciesColors( new HashMap() ); - setAnnotationColors( new HashMap() ); - } - - boolean isAntialiasScreenText() { - return true; - } + boolean isAntialiasScreenText() { + return true; + } boolean isColorAccordingToAnnotation() { return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() ); @@ -792,16 +845,16 @@ final class ControlPanel extends JPanel implements ActionListener { return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() ); } - boolean isColorBranches() { - return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) ); + boolean isColorAccordingToSequence() { + return ( ( _color_acc_sequence != null ) && _color_acc_sequence.isSelected() ); } - boolean isDrawPhylogram() { - return isDrawPhylogram( getMainPanel().getCurrentTabIndex() ); + boolean isUseVisualStyles() { + return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() ) || ( ( getUseVisualStylesCb() == null ) && _color_branches ) ); } - private boolean isDrawPhylogram( final int index ) { - return getIsDrawPhylogramList().get( index ); + boolean isDrawPhylogram() { + return isDrawPhylogram( getMainPanel().getCurrentTabIndex() ); } boolean isDynamicallyHideData() { @@ -832,24 +885,20 @@ final class ControlPanel extends JPanel implements ActionListener { return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() ); } - boolean isShowDomainArchitectures() { - return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() ); - } - - boolean isShowGeneNames() { - return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() ); + boolean isWriteBranchLengthValues() { + return ( ( _write_branch_length_values != null ) && _write_branch_length_values.isSelected() ); } - public boolean isShowVectorData() { - return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() ); + boolean isShowDomainArchitectures() { + return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() ); } - public boolean isShowProperties() { - return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() ); + public boolean isShowMolSequences() { + return ( ( _show_mol_seqs != null ) && _show_mol_seqs.isSelected() ); } - boolean isShowGeneSymbols() { - return ( ( _show_gene_symbols != null ) && _show_gene_symbols.isSelected() ); + boolean isShowGeneNames() { + return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() ); } boolean isShowInternalData() { @@ -860,6 +909,14 @@ final class ControlPanel extends JPanel implements ActionListener { return ( ( _show_node_names != null ) && _show_node_names.isSelected() ); } + boolean isShowSeqNames() { + return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() ); + } + + boolean isShowSeqSymbols() { + return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() ); + } + boolean isShowSequenceAcc() { return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() ); } @@ -876,10 +933,6 @@ final class ControlPanel extends JPanel implements ActionListener { return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() ); } - public boolean isShowTaxonomyImages() { - return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() ); - } - boolean isShowTaxonomyCommonNames() { return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() ); } @@ -900,86 +953,57 @@ final class ControlPanel extends JPanel implements ActionListener { getIsDrawPhylogramList().remove( index ); } - void search() { + void search0() { final MainPanel main_panel = getMainPanel(); final Phylogeny tree = main_panel.getCurrentPhylogeny(); if ( ( tree == null ) || tree.isEmpty() ) { return; } - String query = getSearchTextField().getText(); + String query = getSearchTextField0().getText(); if ( query != null ) { query = query.trim(); } - else { - getSearchFoundCountsLabel().setVisible( false ); - getSearchResetButton().setEnabled( false ); - getSearchResetButton().setVisible( false ); - searchReset(); - } if ( !ForesterUtil.isEmpty( query ) ) { - search( main_panel, tree, query ); + search0( main_panel, tree, query ); } else { - getSearchFoundCountsLabel().setVisible( false ); - getSearchResetButton().setEnabled( false ); - getSearchResetButton().setVisible( false ); - searchReset(); + getSearchFoundCountsLabel0().setVisible( false ); + getSearchResetButton0().setEnabled( false ); + getSearchResetButton0().setVisible( false ); + searchReset0(); } } - private void search( final MainPanel main_panel, final Phylogeny tree, final String query_str ) { - getSearchFoundCountsLabel().setVisible( true ); - getSearchResetButton().setEnabled( true ); - getSearchResetButton().setVisible( true ); - String[] queries = null; - List nodes = null; - if ( query_str.indexOf( ',' ) >= 0 ) { - queries = query_str.split( ",+" ); - } - else { - queries = new String[ 1 ]; - queries[ 0 ] = query_str.trim(); + void search1() { + final MainPanel main_panel = getMainPanel(); + final Phylogeny tree = main_panel.getCurrentPhylogeny(); + if ( ( tree == null ) || tree.isEmpty() ) { + return; } - if ( ( queries != null ) && ( queries.length > 0 ) ) { - nodes = new ArrayList(); - for( String query : queries ) { - if ( ForesterUtil.isEmpty( query ) ) { - continue; - } - query = query.trim(); - if ( query.indexOf( '+' ) >= 0 ) { - nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ), tree, getOptions() - .isSearchCaseSensitive(), !getOptions().isMatchWholeTermsOnly() ) ); - } - else { - nodes.addAll( PhylogenyMethods.searchData( query, - tree, - getOptions().isSearchCaseSensitive(), - !getOptions().isMatchWholeTermsOnly() ) ); - } - } - if ( getOptions().isInverseSearchResult() ) { - final List all = PhylogenyMethods.obtainAllNodesAsList( tree ); - all.removeAll( nodes ); - nodes = all; - } + String query = getSearchTextField1().getText(); + if ( query != null ) { + query = query.trim(); } - if ( ( nodes != null ) && ( nodes.size() > 0 ) ) { - main_panel.getCurrentTreePanel().setFoundNodes( new HashSet() ); - for( final PhylogenyNode node : nodes ) { - main_panel.getCurrentTreePanel().getFoundNodes().add( node.getId() ); - } - setSearchFoundCountsOnLabel( nodes.size() ); + if ( !ForesterUtil.isEmpty( query ) ) { + search1( main_panel, tree, query ); } else { - setSearchFoundCountsOnLabel( 0 ); - searchReset(); + getSearchFoundCountsLabel1().setVisible( false ); + getSearchResetButton1().setEnabled( false ); + getSearchResetButton1().setVisible( false ); + searchReset1(); + } + } + + void searchReset0() { + if ( getMainPanel().getCurrentTreePanel() != null ) { + getMainPanel().getCurrentTreePanel().setFoundNodes0( null ); } } - private void searchReset() { + void searchReset1() { if ( getMainPanel().getCurrentTreePanel() != null ) { - getMainPanel().getCurrentTreePanel().setFoundNodes( null ); + getMainPanel().getCurrentTreePanel().setFoundNodes1( null ); } } @@ -1008,6 +1032,11 @@ final class ControlPanel extends JPanel implements ActionListener { _color_acc_species.setSelected( state ); } break; + case Configuration.color_according_to_sequence: + if ( _color_acc_sequence != null ) { + _color_acc_sequence.setSelected( state ); + } + break; case Configuration.color_according_to_annotation: if ( _color_according_to_annotation != null ) { _color_according_to_annotation.setSelected( state ); @@ -1063,9 +1092,9 @@ final class ControlPanel extends JPanel implements ActionListener { getShowEventsCb().setSelected( state ); } break; - case Configuration.color_branches: - if ( getColorBranchesCb() != null ) { - getColorBranchesCb().setSelected( state ); + case Configuration.use_style: + if ( getUseVisualStylesCb() != null ) { + getUseVisualStylesCb().setSelected( state ); } break; case Configuration.width_branches: @@ -1078,14 +1107,29 @@ final class ControlPanel extends JPanel implements ActionListener { _show_domain_architectures.setSelected( state ); } break; + case Configuration.write_branch_length_values: + if ( _write_branch_length_values != null ) { + _write_branch_length_values.setSelected( state ); + } + break; + case Configuration.show_mol_seqs: + if ( _show_mol_seqs != null ) { + _show_mol_seqs.setSelected( state ); + } + break; + case Configuration.show_seq_names: + if ( _show_seq_names != null ) { + _show_seq_names.setSelected( state ); + } + break; case Configuration.show_gene_names: if ( _show_gene_names != null ) { _show_gene_names.setSelected( state ); } break; - case Configuration.show_gene_symbols: - if ( _show_gene_symbols != null ) { - _show_gene_symbols.setSelected( state ); + case Configuration.show_seq_symbols: + if ( _show_seq_symbols != null ) { + _show_seq_symbols.setSelected( state ); } break; case Configuration.show_vector_data: @@ -1185,6 +1229,21 @@ final class ControlPanel extends JPanel implements ActionListener { else if ( action == _edit_node_data_item ) { setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA ); } + else if ( action == _select_nodes_item ) { + setActionWhenNodeClicked( NodeClickAction.SELECT_NODES ); + } + else if ( action == _get_ext_desc_data ) { + setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA ); + } + else if ( action == _open_pdb_item ) { + setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB ); + } + else if ( action == _color_node_font_item ) { + setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT ); + } + else if ( action == _change_node_font_item ) { + setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT ); + } else { throw new RuntimeException( "unknown action: " + action ); } @@ -1202,16 +1261,11 @@ final class ControlPanel extends JPanel implements ActionListener { setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b ); } - private void setDrawPhylogram( final int index, final boolean b ) { - getIsDrawPhylogramList().set( index, b ); - } - void setDrawPhylogramEnabled( final boolean b ) { getDisplayAsPhylogramCb().setEnabled( b ); } void setDynamicHidingIsOn( final boolean is_on ) { - // if ( !_configuration.isUseNativeUI() ) { if ( is_on ) { getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() ); } @@ -1223,57 +1277,14 @@ final class ControlPanel extends JPanel implements ActionListener { getDynamicallyHideData().setForeground( Color.BLACK ); } } - // } } - private void setSearchFoundCountsOnLabel( final int counts ) { - getSearchFoundCountsLabel().setText( "Found: " + counts ); + void setSearchFoundCountsOnLabel0( final int counts ) { + getSearchFoundCountsLabel0().setText( "Found: " + counts ); } - public void setSequenceRelationQueries( final Collection sequenceRelationQueries ) { - final JComboBox box = getSequenceRelationBox(); - while ( box.getItemCount() > 1 ) { - box.removeItemAt( 1 ); - } - final HashMap sequencesByName = new HashMap(); - final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box - .getSelectedItem(); - if ( relationType == null ) { - return; - } - final ArrayList sequenceNamesToAdd = new ArrayList(); - for( final Sequence seq : sequenceRelationQueries ) { - if ( seq.hasSequenceRelations() ) { - boolean fFoundForCurrentType = false; - for( final SequenceRelation sq : seq.getSequenceRelations() ) { - if ( sq.getType().equals( relationType ) ) { - fFoundForCurrentType = true; - break; - } - } - if ( fFoundForCurrentType ) { - sequenceNamesToAdd.add( seq.getName() ); - sequencesByName.put( seq.getName(), seq ); - } - } - } - // sort sequences by name before adding them to the combo - final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] ); - Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER ); - for( final String seqName : sequenceNameArray ) { - box.addItem( seqName ); - } - for( final ItemListener oldItemListener : box.getItemListeners() ) { - box.removeItemListener( oldItemListener ); - } - box.addItemListener( new ItemListener() { - - @Override - public void itemStateChanged( final ItemEvent e ) { - _selected_query_seq = sequencesByName.get( e.getItem() ); - _mainpanel.getCurrentTreePanel().repaint(); - } - } ); + void setSearchFoundCountsOnLabel1( final int counts ) { + getSearchFoundCountsLabel1().setText( "Found: " + counts ); } void setShowEvents( final boolean show_events ) { @@ -1287,51 +1298,665 @@ final class ControlPanel extends JPanel implements ActionListener { _species_colors = species_colors; } - private void setupClickToOptions() { - final int default_option = _configuration.getDefaultDisplayClicktoOption(); - int selected_index = 0; - int cb_index = 0; - if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) { - _show_data_item = cb_index; - addClickToOption( Configuration.display_node_data, - _configuration.getClickToTitle( Configuration.display_node_data ) ); - if ( default_option == Configuration.display_node_data ) { - selected_index = cb_index; - } - cb_index++; - } - if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) { - _collapse_cb_item = cb_index; - addClickToOption( Configuration.collapse_uncollapse, - _configuration.getClickToTitle( Configuration.collapse_uncollapse ) ); - if ( default_option == Configuration.collapse_uncollapse ) { - selected_index = cb_index; - } - cb_index++; - } - if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) { - _reroot_cb_item = cb_index; - addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) ); - if ( default_option == Configuration.reroot ) { - selected_index = cb_index; - } - cb_index++; + void setSequenceColors( final Map sequence_colors ) { + _sequence_colors = sequence_colors; + } + + /* GUILHEM_END */ + /* + * Set up the controls from the config settings. 11/26/05 + */ + void setupControls() { + // The tree display options: + setupDisplayCheckboxes(); + /* GUILHEM_BEG */ + // The sequence relation query selection combo-box + if ( _configuration.displaySequenceRelations() ) { + addSequenceRelationBlock(); } - if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) { - _subtree_cb_item = cb_index; - addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) ); - if ( default_option == Configuration.subtree ) { - selected_index = cb_index; - } - cb_index++; + /* GUILHEM_END */ + // Click-to options + startClickToOptions(); + setupClickToOptions(); + endClickToOptions(); + // Zoom and quick edit buttons + addButtons(); + setupSearchTools0(); + setupSearchTools1(); + } + + 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-" ); + _decr_domain_structure_evalue_thr = new JButton( "-" ); + _incr_domain_structure_evalue_thr = new JButton( "+" ); + _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) ); + _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) ); + _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) ); + _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) ); + _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" ); + _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" ); + _domain_structure_evalue_thr_tf = new JTextField( 3 ); + _domain_structure_evalue_thr_tf.setEditable( false ); + if ( !getConfiguration().isUseNativeUI() ) { + _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() ); + _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() ); + _domain_structure_evalue_thr_tf.setBorder( null ); } - if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) { - _swap_cb_item = cb_index; - addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) ); - if ( default_option == Configuration.swap ) { - selected_index = cb_index; - } - cb_index++; + final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) ); + final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) ); + if ( !_configuration.isUseNativeUI() ) { + d1_panel.setBackground( getBackground() ); + d2_panel.setBackground( getBackground() ); + } + add( d1_panel ); + add( d2_panel ); + addJButton( _zoom_out_domain_structure, d1_panel ); + addJButton( _zoom_in_domain_structure, d1_panel ); + addJButton( _decr_domain_structure_evalue_thr, d2_panel ); + addJTextField( _domain_structure_evalue_thr_tf, d2_panel ); + addJButton( _incr_domain_structure_evalue_thr, d2_panel ); + } + + void setupSearchTools0() { + final JLabel search_label = new JLabel( "Search (A):" ); + search_label.setFont( ControlPanel.jcb_bold_font ); + if ( !getConfiguration().isUseNativeUI() ) { + search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() ); + } + add( search_label ); + search_label.setToolTipText( SEARCH_TIP_TEXT ); + _search_found_label_0 = new JLabel(); + getSearchFoundCountsLabel0().setVisible( false ); + _search_found_label_0.setFont( ControlPanel.jcb_bold_font ); + if ( !getConfiguration().isUseNativeUI() ) { + _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() ); + } + _search_tf_0 = new JTextField( 3 ); + _search_tf_0.setToolTipText( SEARCH_TIP_TEXT ); + _search_tf_0.setEditable( true ); + if ( !getConfiguration().isUseNativeUI() ) { + _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() ); + _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() ); + _search_tf_0.setBorder( null ); + } + _search_reset_button_0 = new JButton(); + getSearchResetButton0().setText( "Reset" ); + getSearchResetButton0().setEnabled( false ); + getSearchResetButton0().setVisible( false ); + final JPanel s_panel_1 = new JPanel( new BorderLayout() ); + final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) ); + s_panel_1.setBackground( getBackground() ); + add( s_panel_1 ); + s_panel_2.setBackground( getBackground() ); + add( s_panel_2 ); + final KeyAdapter key_adapter = new KeyAdapter() { + + @Override + public void keyReleased( final KeyEvent key_event ) { + search0(); + displayedPhylogenyMightHaveChanged( true ); + } + }; + final ActionListener action_listener = new ActionListener() { + + @Override + public void actionPerformed( final ActionEvent e ) { + searchReset0(); + setSearchFoundCountsOnLabel0( 0 ); + getSearchFoundCountsLabel0().setVisible( false ); + getSearchTextField0().setText( "" ); + getSearchResetButton0().setEnabled( false ); + getSearchResetButton0().setVisible( false ); + displayedPhylogenyMightHaveChanged( true ); + } + }; + _search_reset_button_0.addActionListener( action_listener ); + _search_tf_0.addKeyListener( key_adapter ); + addJTextField( _search_tf_0, s_panel_1 ); + s_panel_2.add( _search_found_label_0 ); + addJButton( _search_reset_button_0, s_panel_2 ); + } + + void setupSearchTools1() { + final JLabel search_label = new JLabel( "Search (B):" ); + search_label.setFont( ControlPanel.jcb_bold_font ); + if ( !getConfiguration().isUseNativeUI() ) { + search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() ); + } + add( search_label ); + search_label.setToolTipText( SEARCH_TIP_TEXT ); + _search_found_label_1 = new JLabel(); + getSearchFoundCountsLabel1().setVisible( false ); + _search_found_label_1.setFont( ControlPanel.jcb_bold_font ); + if ( !getConfiguration().isUseNativeUI() ) { + _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() ); + } + _search_tf_1 = new JTextField( 3 ); + _search_tf_1.setToolTipText( SEARCH_TIP_TEXT ); + _search_tf_1.setEditable( true ); + if ( !getConfiguration().isUseNativeUI() ) { + _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() ); + _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() ); + _search_tf_1.setBorder( null ); + } + _search_reset_button_1 = new JButton(); + getSearchResetButton1().setText( "Reset" ); + getSearchResetButton1().setEnabled( false ); + getSearchResetButton1().setVisible( false ); + final JPanel s_panel_1 = new JPanel( new BorderLayout() ); + final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) ); + s_panel_1.setBackground( getBackground() ); + add( s_panel_1 ); + s_panel_2.setBackground( getBackground() ); + add( s_panel_2 ); + final KeyAdapter key_adapter = new KeyAdapter() { + + @Override + public void keyReleased( final KeyEvent key_event ) { + search1(); + displayedPhylogenyMightHaveChanged( true ); + } + }; + final ActionListener action_listener = new ActionListener() { + + @Override + public void actionPerformed( final ActionEvent e ) { + searchReset1(); + setSearchFoundCountsOnLabel1( 0 ); + getSearchFoundCountsLabel1().setVisible( false ); + getSearchTextField1().setText( "" ); + getSearchResetButton1().setEnabled( false ); + getSearchResetButton1().setVisible( false ); + displayedPhylogenyMightHaveChanged( true ); + } + }; + _search_reset_button_1.addActionListener( action_listener ); + _search_tf_1.addKeyListener( key_adapter ); + addJTextField( _search_tf_1, s_panel_1 ); + s_panel_2.add( _search_found_label_1 ); + addJButton( _search_reset_button_1, s_panel_2 ); + } + + void showAnnotations() { + if ( _show_annotation != null ) { + _show_annotation.setSelected( true ); + } + if ( _color_according_to_annotation != null ) { + _color_according_to_annotation.setSelected( true ); + } + if ( _color_acc_species != null ) { + _color_acc_species.setSelected( false ); + } + if ( _color_acc_sequence != null ) { + _color_acc_sequence.setSelected( false ); + } + _mainpanel.getCurrentTreePanel().repaint(); + } + + /** + * Fit entire tree into window. + */ + void showWhole() { + if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) { + return; + } + getCurrentTreePanel().updateSetOfCollapsedExternalNodes(); + displayedPhylogenyMightHaveChanged( true ); + _mainpanel.getCurrentTreePanel().updateOvSettings(); + _mainpanel.getCurrentTreePanel().validate(); + _mainpanel.validate(); + _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width, + _mainpanel.getSizeOfViewport().height ); + _mainpanel.getCurrentTreePanel().resetPreferredSize(); + _mainpanel.adjustJScrollPane(); + _mainpanel.getCurrentTreePanel().repaint(); + _mainpanel.getCurrentTreePanel().validate(); + _mainpanel.validate(); + _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width, + _mainpanel.getSizeOfViewport().height ); + _mainpanel.getCurrentTreePanel().resetPreferredSize(); + _mainpanel.adjustJScrollPane(); + _mainpanel.getCurrentTreePanel().repaint(); + _mainpanel.getCurrentTreePanel().updateOvSizes(); + } + + void showWholeAll() { + for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) { + if ( tree_panel != null ) { + tree_panel.validate(); + tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width, + _mainpanel.getSizeOfViewport().height ); + tree_panel.resetPreferredSize(); + tree_panel.repaint(); + } + } + } + + // Create header for click-to combo box. + void startClickToOptions() { + final JLabel spacer = new JLabel( "" ); + spacer.setFont( ControlPanel.jcb_font ); + add( spacer ); + _click_to_label = new JLabel( "Click on Node to:" ); + add( customizeLabel( _click_to_label, getConfiguration() ) ); + _click_to_combobox = new JComboBox(); + _click_to_combobox.setFocusable( false ); + _click_to_combobox.setMaximumRowCount( 14 ); + _click_to_combobox.setFont( ControlPanel.js_font ); + if ( !_configuration.isUseNativeUI() ) { + _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() ); + } + // don't add listener until all items are set (or each one will trigger + // an event) + // click_to_list.addActionListener(this); + add( _click_to_combobox ); + // Correlates option names to titles + _all_click_to_names = new HashMap(); + _click_to_names = new ArrayList(); + } + + void tabChanged() { + if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) { + if ( getCurrentTreePanel().isPhyHasBranchLengths() + && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) { + setDrawPhylogramEnabled( true ); + setDrawPhylogram( isDrawPhylogram() ); + } + else { + setDrawPhylogramEnabled( false ); + setDrawPhylogram( false ); + } + if ( getMainPanel().getMainFrame() == null ) { + // Must be "E" applet version. + final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet(); + e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() ); + } + else { + getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel() + .getPhylogenyGraphicsType() ); + } + getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton(); + getMainPanel().getControlPanel().search0(); + getMainPanel().getControlPanel().search1(); + getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay(); + getSequenceRelationTypeBox().removeAllItems(); + for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny() + .getRelevantSequenceRelationTypes() ) { + _sequence_relation_type_box.addItem( type ); + } + getMainPanel().getCurrentTreePanel().repaint(); + //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() ); + // according to GUILHEM the line above can be removed. + } + } + + /** + * Uncollapse all nodes. + */ + void uncollapseAll( final TreePanel tp ) { + final Phylogeny t = tp.getPhylogeny(); + if ( ( t != null ) && !t.isEmpty() ) { + for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) { + final PhylogenyNode node = iter.next(); + node.setCollapse( false ); + } + tp.resetNodeIdToDistToLeafMap(); + tp.updateSetOfCollapsedExternalNodes(); + t.recalculateNumberOfExternalDescendants( false ); + tp.setNodeInPreorderToNull(); + t.clearHashIdToNodeMap(); + showWhole(); + } + } + + void updateDomainStructureEvaluethresholdDisplay() { + if ( _domain_structure_evalue_thr_tf != null ) { + _domain_structure_evalue_thr_tf.setText( "10^" + + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() ); + } + } + + void zoomInX( final float factor, final float x_correction_factor ) { + final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar(); + final TreePanel treepanel = getMainPanel().getCurrentTreePanel(); + treepanel.multiplyUrtFactor( 1f ); + if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) + || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) + || isDrawPhylogram( getMainPanel().getCurrentTabIndex() ) + || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) { + final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) ); + treepanel.setXdistance( ( treepanel.getXdistance() * factor ) ); + treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) ); + getMainPanel().adjustJScrollPane(); + treepanel.resetPreferredSize(); + getMainPanel().getCurrentScrollPane().getViewport().validate(); + sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) + - ( sb.getVisibleAmount() / 2.0 ) ) ); + } + else { + final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue(); + treepanel.setXdistance( ( treepanel.getXdistance() * factor ) ); + treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) ); + getMainPanel().adjustJScrollPane(); + treepanel.resetPreferredSize(); + getMainPanel().getCurrentScrollPane().getViewport().validate(); + sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() ); + } + treepanel.resetPreferredSize(); + treepanel.updateOvSizes(); + } + + void zoomInY( final float factor ) { + final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar(); + final TreePanel treepanel = getMainPanel().getCurrentTreePanel(); + treepanel.multiplyUrtFactor( 1.1f ); + final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) ); + treepanel.setYdistance( ( treepanel.getYdistance() * factor ) ); + getMainPanel().adjustJScrollPane(); + treepanel.resetPreferredSize(); + getMainPanel().getCurrentScrollPane().getViewport().validate(); + sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) + - ( sb.getVisibleAmount() / 2.0 ) ) ); + treepanel.resetPreferredSize(); + treepanel.updateOvSizes(); + } + + void zoomOutX( final float factor, final float x_correction_factor ) { + final TreePanel treepanel = getMainPanel().getCurrentTreePanel(); + treepanel.multiplyUrtFactor( 1f ); + if ( ( treepanel.getXdistance() * factor ) > 0.0 ) { + final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar(); + if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) + || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) + || isDrawPhylogram( getMainPanel().getCurrentTabIndex() ) + || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) { + getMainPanel().adjustJScrollPane(); + treepanel.resetPreferredSize(); + getMainPanel().getCurrentScrollPane().getViewport().validate(); + final double x = ( sb.getMaximum() - sb.getMinimum() ) + / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) ); + treepanel.setXdistance( ( treepanel.getXdistance() * factor ) ); + treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) ); + getMainPanel().adjustJScrollPane(); + treepanel.resetPreferredSize(); + getMainPanel().getCurrentScrollPane().getViewport().validate(); + sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) + - ( sb.getVisibleAmount() / 2.0 ) ) ); + } + else { + final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue(); + treepanel.setXdistance( treepanel.getXdistance() * factor ); + treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor ); + if ( x > 0 ) { + getMainPanel().adjustJScrollPane(); + treepanel.resetPreferredSize(); + getMainPanel().getCurrentScrollPane().getViewport().validate(); + sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() ); + } + } + treepanel.resetPreferredSize(); + treepanel.updateOvSizes(); + } + } + + void zoomOutY( final float factor ) { + final TreePanel treepanel = getMainPanel().getCurrentTreePanel(); + treepanel.multiplyUrtFactor( 0.9f ); + if ( ( treepanel.getYdistance() * factor ) > 0.0 ) { + final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar(); + final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) ); + treepanel.setYdistance( ( treepanel.getYdistance() * factor ) ); + getMainPanel().adjustJScrollPane(); + treepanel.resetPreferredSize(); + getMainPanel().getCurrentScrollPane().getViewport().validate(); + sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) + - ( sb.getVisibleAmount() / 2.0 ) ) ); + treepanel.resetPreferredSize(); + treepanel.updateOvSizes(); + } + } + + private void addClickToOption( final int which, final String title ) { + _click_to_combobox.addItem( title ); + _click_to_names.add( title ); + _all_click_to_names.put( new Integer( which ), title ); + if ( !_configuration.isUseNativeUI() ) { + _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() ); + _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() ); + } + } + + /* GUILHEM_BEG */ + private void addSequenceRelationBlock() { + final JLabel spacer = new JLabel( "" ); + spacer.setSize( 1, 1 ); + add( spacer ); + final JLabel mainLabel = new JLabel( "Sequence relations to display" ); + final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() ); + typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) ); + getSequenceRelationTypeBox().setFocusable( false ); + _sequence_relation_type_box.setFont( ControlPanel.js_font ); + if ( !_configuration.isUseNativeUI() ) { + _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() ); + _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() ); + } + _sequence_relation_type_box.setRenderer( new ListCellRenderer() { + + @Override + public Component getListCellRendererComponent( final JList list, + final Object value, + final int index, + final boolean isSelected, + final boolean cellHasFocus ) { + final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list, + value, + index, + isSelected, + cellHasFocus ); + if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) { + ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation + .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) ); + } + return component; + } + } ); + final GridBagLayout gbl = new GridBagLayout(); + _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) ); + _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) ); + final JPanel horizGrid = new JPanel( gbl ); + horizGrid.setBackground( getBackground() ); + horizGrid.add( typeLabel ); + horizGrid.add( _sequence_relation_type_box ); + add( customizeLabel( mainLabel, getConfiguration() ) ); + add( horizGrid ); + add( getSequenceRelationBox() ); + if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) { + addCheckbox( Configuration.show_relation_confidence, + _configuration.getDisplayTitle( Configuration.show_relation_confidence ) ); + setCheckbox( Configuration.show_relation_confidence, + _configuration.doCheckOption( Configuration.show_relation_confidence ) ); + } + }// addSequenceRelationBlock + + /* GUILHEM_END */ + private List getIsDrawPhylogramList() { + return _draw_phylogram; + } + + private void init() { + _draw_phylogram = new ArrayList(); + setSpeciesColors( new HashMap() ); + setSequenceColors( new HashMap() ); + setAnnotationColors( new HashMap() ); + } + + private boolean isDrawPhylogram( final int index ) { + return getIsDrawPhylogramList().get( index ); + } + + private void search0( final MainPanel main_panel, final Phylogeny tree, final String query_str ) { + getSearchFoundCountsLabel0().setVisible( true ); + getSearchResetButton0().setEnabled( true ); + getSearchResetButton0().setVisible( true ); + String[] queries = null; + List nodes = null; + if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) { + queries = query_str.split( ",+" ); + } + else { + queries = new String[ 1 ]; + queries[ 0 ] = query_str.trim(); + } + if ( ( queries != null ) && ( queries.length > 0 ) ) { + nodes = new ArrayList(); + for( String query : queries ) { + if ( ForesterUtil.isEmpty( query ) ) { + continue; + } + query = query.trim(); + if ( ( query.indexOf( '+' ) >= 0 ) && !getOptions().isSearchWithRegex() ) { + nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ), + tree, + getOptions().isSearchCaseSensitive(), + !getOptions().isMatchWholeTermsOnly(), + isShowDomainArchitectures() ) ); + } + else { + nodes.addAll( PhylogenyMethods.searchData( query, + tree, + getOptions().isSearchCaseSensitive(), + !getOptions().isMatchWholeTermsOnly(), + getOptions().isSearchWithRegex(), + isShowDomainArchitectures() ) ); + } + } + if ( getOptions().isInverseSearchResult() ) { + final List all = PhylogenyMethods.obtainAllNodesAsList( tree ); + all.removeAll( nodes ); + nodes = all; + } + } + if ( ( nodes != null ) && ( nodes.size() > 0 ) ) { + main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet() ); + for( final PhylogenyNode node : nodes ) { + main_panel.getCurrentTreePanel().getFoundNodes0().add( node.getId() ); + } + setSearchFoundCountsOnLabel0( nodes.size() ); + } + else { + setSearchFoundCountsOnLabel0( 0 ); + searchReset0(); + } + } + + private void search1( final MainPanel main_panel, final Phylogeny tree, final String query_str ) { + getSearchFoundCountsLabel1().setVisible( true ); + getSearchResetButton1().setEnabled( true ); + getSearchResetButton1().setVisible( true ); + String[] queries = null; + List nodes = null; + if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) { + queries = query_str.split( ",+" ); + } + else { + queries = new String[ 1 ]; + queries[ 0 ] = query_str.trim(); + } + if ( ( queries != null ) && ( queries.length > 0 ) ) { + nodes = new ArrayList(); + for( String query : queries ) { + if ( ForesterUtil.isEmpty( query ) ) { + continue; + } + query = query.trim(); + if ( ( query.indexOf( '+' ) >= 0 ) && !getOptions().isSearchWithRegex() ) { + nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ), + tree, + getOptions().isSearchCaseSensitive(), + !getOptions().isMatchWholeTermsOnly(), + isShowDomainArchitectures() ) ); + } + else { + nodes.addAll( PhylogenyMethods.searchData( query, + tree, + getOptions().isSearchCaseSensitive(), + !getOptions().isMatchWholeTermsOnly(), + getOptions().isSearchWithRegex(), + isShowDomainArchitectures() ) ); + } + } + if ( getOptions().isInverseSearchResult() ) { + final List all = PhylogenyMethods.obtainAllNodesAsList( tree ); + all.removeAll( nodes ); + nodes = all; + } + } + if ( ( nodes != null ) && ( nodes.size() > 0 ) ) { + main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet() ); + for( final PhylogenyNode node : nodes ) { + main_panel.getCurrentTreePanel().getFoundNodes1().add( node.getId() ); + } + setSearchFoundCountsOnLabel1( nodes.size() ); + } + else { + setSearchFoundCountsOnLabel1( 0 ); + searchReset1(); + } + } + + private void setDrawPhylogram( final int index, final boolean b ) { + getIsDrawPhylogramList().set( index, b ); + } + + private void setupClickToOptions() { + final int default_option = _configuration.getDefaultDisplayClicktoOption(); + int selected_index = 0; + int cb_index = 0; + if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) { + _show_data_item = cb_index; + addClickToOption( Configuration.display_node_data, + _configuration.getClickToTitle( Configuration.display_node_data ) ); + if ( default_option == Configuration.display_node_data ) { + selected_index = cb_index; + } + cb_index++; + } + if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) { + _collapse_cb_item = cb_index; + addClickToOption( Configuration.collapse_uncollapse, + _configuration.getClickToTitle( Configuration.collapse_uncollapse ) ); + if ( default_option == Configuration.collapse_uncollapse ) { + selected_index = cb_index; + } + cb_index++; + } + if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) { + _reroot_cb_item = cb_index; + addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) ); + if ( default_option == Configuration.reroot ) { + selected_index = cb_index; + } + cb_index++; + } + if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) { + _subtree_cb_item = cb_index; + addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) ); + if ( default_option == Configuration.subtree ) { + selected_index = cb_index; + } + cb_index++; + } + if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) { + _swap_cb_item = cb_index; + addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) ); + if ( default_option == Configuration.swap ) { + selected_index = cb_index; + } + cb_index++; } if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) { _sort_descendents_item = cb_index; @@ -1342,6 +1967,24 @@ final class ControlPanel extends JPanel implements ActionListener { } cb_index++; } + if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) { + _color_node_font_item = cb_index; + addClickToOption( Configuration.color_node_font, + _configuration.getClickToTitle( Configuration.color_node_font ) ); + if ( default_option == Configuration.color_node_font ) { + selected_index = cb_index; + } + cb_index++; + } + if ( _configuration.doDisplayClickToOption( Configuration.change_node_font ) ) { + _change_node_font_item = cb_index; + addClickToOption( Configuration.change_node_font, + _configuration.getClickToTitle( Configuration.change_node_font ) ); + if ( default_option == Configuration.change_node_font ) { + 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 ) ); @@ -1358,6 +2001,14 @@ final class ControlPanel extends JPanel implements ActionListener { } cb_index++; } + if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) { + _open_pdb_item = cb_index; + addClickToOption( Configuration.open_pdb_web, _configuration.getClickToTitle( Configuration.open_pdb_web ) ); + if ( default_option == Configuration.open_pdb_web ) { + selected_index = cb_index; + } + cb_index++; + } if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) { _open_tax_web_item = cb_index; addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) ); @@ -1374,6 +2025,68 @@ final class ControlPanel extends JPanel implements ActionListener { } cb_index++; } + if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) { + _select_nodes_item = cb_index; + addClickToOption( Configuration.select_nodes, _configuration.getClickToTitle( Configuration.select_nodes ) ); + if ( default_option == Configuration.select_nodes ) { + selected_index = cb_index; + } + cb_index++; + } + 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() ); + } + else { + String s = ";"; + switch ( getConfiguration().getExtDescNodeDataToReturn() ) { + case NODE_NAME: + s = "Node Names"; + break; + case SEQUENCE_ACC: + s = "Sequence Accessors"; + break; + case SEQUENCE_MOL_SEQ: + s = "Molecular Sequence"; + break; + case SEQUENCE_MOL_SEQ_FASTA: + s = "Molecular Sequence (Fasta)"; + break; + case SEQUENCE_NAME: + s = "Sequence Names"; + break; + case GENE_NAME: + s = "Gene Names"; + break; + case SEQUENCE_SYMBOL: + s = "Sequence Symbols"; + break; + case TAXONOMY_CODE: + s = "Taxonomy Codes"; + break; + case TAXONOMY_COMM0N_NAME: + s = "Taxonomy Common Names"; + break; + case TAXONOMY_SCIENTIFIC_NAME: + s = "Scientific Names"; + break; + case UNKNOWN: + s = "User Selected Data"; + break; + default: + throw new IllegalStateException( "dont know how to deal with " + + getConfiguration().getExtDescNodeDataToReturn() ); + } + final String label = _configuration.getClickToTitle( Configuration.get_ext_desc_data ) + " " + s; + addClickToOption( Configuration.get_ext_desc_data, label ); + } + if ( default_option == Configuration.get_ext_desc_data ) { + selected_index = cb_index; + } + cb_index++; + } if ( getOptions().isEditable() ) { if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) { _cut_subtree_item = cb_index; @@ -1434,64 +2147,6 @@ final class ControlPanel extends JPanel implements ActionListener { setClickToAction( selected_index ); } - /* GUILHEM_END */ - /* - * Set up the controls from the config settings. 11/26/05 - */ - void setupControls() { - // The tree display options: - setupDisplayCheckboxes(); - /* GUILHEM_BEG */ - // The sequence relation query selection combo-box - if ( _configuration.displaySequenceRelations() ) { - addSequenceRelationBlock(); - } - /* GUILHEM_END */ - // Click-to options - startClickToOptions(); - setupClickToOptions(); - endClickToOptions(); - // Zoom and quick edit buttons - addButtons(); - setupSearchTools(); - } - - void setUpControlsForDomainStrucures() { - _domain_display_label = new JLabel( "Domain Display:" ); - add( customizeLabel( _domain_display_label, getConfiguration() ) ); - add( _domain_display_label ); - _zoom_in_domain_structure = new JButton( "d+" ); - _zoom_out_domain_structure = new JButton( "d-" ); - _decr_domain_structure_evalue_thr = new JButton( "-" ); - _incr_domain_structure_evalue_thr = new JButton( "+" ); - _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) ); - _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) ); - _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) ); - _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) ); - _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" ); - _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" ); - _domain_structure_evalue_thr_tf = new JTextField( 3 ); - _domain_structure_evalue_thr_tf.setEditable( false ); - if ( !getConfiguration().isUseNativeUI() ) { - _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() ); - _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() ); - _domain_structure_evalue_thr_tf.setBorder( null ); - } - final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) ); - final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) ); - if ( !_configuration.isUseNativeUI() ) { - d1_panel.setBackground( getBackground() ); - d2_panel.setBackground( getBackground() ); - } - add( d1_panel ); - add( d2_panel ); - addJButton( _zoom_out_domain_structure, d1_panel ); - addJButton( _zoom_in_domain_structure, d1_panel ); - addJButton( _decr_domain_structure_evalue_thr, d2_panel ); - addJTextField( _domain_structure_evalue_thr_tf, d2_panel ); - addJButton( _incr_domain_structure_evalue_thr, d2_panel ); - } - private void setupDisplayCheckboxes() { if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) { addCheckbox( Configuration.display_as_phylogram, @@ -1515,6 +2170,12 @@ final class ControlPanel extends JPanel implements ActionListener { setCheckbox( Configuration.display_internal_data, _configuration.doCheckOption( Configuration.display_internal_data ) ); } + if ( _configuration.doDisplayOption( Configuration.color_according_to_sequence ) ) { + addCheckbox( Configuration.color_according_to_sequence, + _configuration.getDisplayTitle( Configuration.color_according_to_sequence ) ); + setCheckbox( Configuration.color_according_to_sequence, + _configuration.doCheckOption( Configuration.color_according_to_sequence ) ); + } if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) { addCheckbox( Configuration.color_according_to_species, _configuration.getDisplayTitle( Configuration.color_according_to_species ) ); @@ -1527,9 +2188,9 @@ final class ControlPanel extends JPanel implements ActionListener { setCheckbox( Configuration.color_according_to_annotation, _configuration.doCheckOption( Configuration.color_according_to_annotation ) ); } - if ( _configuration.doDisplayOption( Configuration.color_branches ) ) { - addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) ); - setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) ); + if ( _configuration.doDisplayOption( Configuration.use_style ) ) { + addCheckbox( Configuration.use_style, _configuration.getDisplayTitle( Configuration.use_style ) ); + setCheckbox( Configuration.use_style, _configuration.doCheckOption( Configuration.use_style ) ); } if ( _configuration.doDisplayOption( Configuration.width_branches ) ) { addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) ); @@ -1561,22 +2222,19 @@ 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_taxonomy_images ) ) { - addCheckbox( Configuration.show_taxonomy_images, - _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) ); - setCheckbox( Configuration.show_taxonomy_images, - _configuration.doCheckOption( Configuration.show_taxonomy_images ) ); - } - if ( _configuration.doDisplayOption( Configuration.show_gene_symbols ) ) { - addCheckbox( Configuration.show_gene_symbols, - _configuration.getDisplayTitle( Configuration.show_gene_symbols ) ); - setCheckbox( Configuration.show_gene_symbols, - _configuration.doCheckOption( Configuration.show_gene_symbols ) ); + 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 ) ); 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 ) ); + } if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) { addCheckbox( Configuration.show_sequence_acc, _configuration.getDisplayTitle( Configuration.show_sequence_acc ) ); @@ -1587,6 +2245,18 @@ final class ControlPanel extends JPanel implements ActionListener { 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 ) ) { + addCheckbox( Configuration.write_confidence_values, + _configuration.getDisplayTitle( Configuration.write_confidence_values ) ); + setCheckbox( Configuration.write_confidence_values, + _configuration.doCheckOption( Configuration.write_confidence_values ) ); + } + if ( _configuration.doDisplayOption( Configuration.write_branch_length_values ) ) { + addCheckbox( Configuration.write_branch_length_values, + _configuration.getDisplayTitle( Configuration.write_branch_length_values ) ); + setCheckbox( Configuration.write_branch_length_values, + _configuration.doCheckOption( Configuration.write_branch_length_values ) ); + } if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) { addCheckbox( Configuration.show_binary_characters, _configuration.getDisplayTitle( Configuration.show_binary_characters ) ); @@ -1605,11 +2275,9 @@ final class ControlPanel extends JPanel implements ActionListener { setCheckbox( Configuration.show_domain_architectures, _configuration.doCheckOption( Configuration.show_domain_architectures ) ); } - if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) { - addCheckbox( Configuration.write_confidence_values, - _configuration.getDisplayTitle( Configuration.write_confidence_values ) ); - setCheckbox( Configuration.write_confidence_values, - _configuration.doCheckOption( Configuration.write_confidence_values ) ); + if ( _configuration.doDisplayOption( Configuration.show_mol_seqs ) ) { + addCheckbox( Configuration.show_mol_seqs, _configuration.getDisplayTitle( Configuration.show_mol_seqs ) ); + setCheckbox( Configuration.show_mol_seqs, _configuration.doCheckOption( Configuration.show_mol_seqs ) ); } if ( _configuration.doDisplayOption( Configuration.write_events ) ) { addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) ); @@ -1623,311 +2291,182 @@ final class ControlPanel extends JPanel implements ActionListener { if ( _configuration.doDisplayOption( Configuration.show_properties ) ) { addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) ); setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) ); - } - } - - void setupSearchTools() { - final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND."; - final JLabel search_label = new JLabel( "Search:" ); - search_label.setFont( ControlPanel.jcb_bold_font ); - if ( !getConfiguration().isUseNativeUI() ) { - search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() ); - } - add( search_label ); - search_label.setToolTipText( tip ); - _search_found_label = new JLabel(); - getSearchFoundCountsLabel().setVisible( false ); - _search_found_label.setFont( ControlPanel.jcb_bold_font ); - if ( !getConfiguration().isUseNativeUI() ) { - _search_found_label.setForeground( getConfiguration().getGuiCheckboxTextColor() ); - } - _search_tf = new JTextField( 3 ); - _search_tf.setToolTipText( tip ); - _search_tf.setEditable( true ); - if ( !getConfiguration().isUseNativeUI() ) { - _search_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() ); - _search_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() ); - _search_tf.setBorder( null ); - } - _search_reset_button = new JButton(); - getSearchResetButton().setText( "Reset" ); - getSearchResetButton().setEnabled( false ); - getSearchResetButton().setVisible( false ); - final JPanel s_panel_1 = new JPanel( new BorderLayout() ); - final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) ); - s_panel_1.setBackground( getBackground() ); - add( s_panel_1 ); - s_panel_2.setBackground( getBackground() ); - add( s_panel_2 ); - final KeyAdapter key_adapter = new KeyAdapter() { - - @Override - public void keyReleased( final KeyEvent key_event ) { - search(); - displayedPhylogenyMightHaveChanged( true ); - } - }; - final ActionListener action_listener = new ActionListener() { - - @Override - public void actionPerformed( final ActionEvent e ) { - searchReset(); - setSearchFoundCountsOnLabel( 0 ); - getSearchFoundCountsLabel().setVisible( false ); - getSearchTextField().setText( "" ); - getSearchResetButton().setEnabled( false ); - getSearchResetButton().setVisible( false ); - displayedPhylogenyMightHaveChanged( true ); - } - }; - _search_reset_button.addActionListener( action_listener ); - _search_tf.addKeyListener( key_adapter ); - addJTextField( _search_tf, s_panel_1 ); - s_panel_2.add( _search_found_label ); - addJButton( _search_reset_button, s_panel_2 ); + } + if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) { + addCheckbox( Configuration.show_taxonomy_images, + _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) ); + setCheckbox( Configuration.show_taxonomy_images, + _configuration.doCheckOption( Configuration.show_taxonomy_images ) ); + } } private void setVisibilityOfDomainStrucureControls() { if ( _zoom_in_domain_structure != null ) { - if ( isShowDomainArchitectures() ) { - _domain_display_label.setVisible( true ); - _zoom_in_domain_structure.setVisible( true ); - _zoom_out_domain_structure.setVisible( true ); - _decr_domain_structure_evalue_thr.setVisible( true ); - _incr_domain_structure_evalue_thr.setVisible( true ); - _domain_structure_evalue_thr_tf.setVisible( true ); - } - else { - _domain_display_label.setVisible( false ); - _zoom_in_domain_structure.setVisible( false ); - _zoom_out_domain_structure.setVisible( false ); - _decr_domain_structure_evalue_thr.setVisible( false ); - _incr_domain_structure_evalue_thr.setVisible( false ); - _domain_structure_evalue_thr_tf.setVisible( false ); + final MainFrame mf = getMainFrame(); + if ( mf != null ) { + if ( isShowDomainArchitectures() ) { + _domain_display_label.setVisible( true ); + _zoom_in_domain_structure.setVisible( true ); + _zoom_out_domain_structure.setVisible( true ); + _decr_domain_structure_evalue_thr.setVisible( true ); + _incr_domain_structure_evalue_thr.setVisible( true ); + _domain_structure_evalue_thr_tf.setVisible( true ); + if ( mf._right_line_up_domains_cbmi != null ) { + mf._right_line_up_domains_cbmi.setVisible( true ); + } + if ( mf._show_domain_labels != null ) { + mf._show_domain_labels.setVisible( true ); + } + } + else { + _domain_display_label.setVisible( false ); + _zoom_in_domain_structure.setVisible( false ); + _zoom_out_domain_structure.setVisible( false ); + _decr_domain_structure_evalue_thr.setVisible( false ); + _incr_domain_structure_evalue_thr.setVisible( false ); + _domain_structure_evalue_thr_tf.setVisible( false ); + if ( mf._right_line_up_domains_cbmi != null ) { + mf._right_line_up_domains_cbmi.setVisible( false ); + } + if ( mf._show_domain_labels != null ) { + mf._show_domain_labels.setVisible( false ); + } + } } } } - /** - * Fit entire tree into window. - */ - void showWhole() { - if ( _mainpanel.getCurrentScrollPane() == null ) { - return; - } - getCurrentTreePanel().updateSetOfCollapsedExternalNodes(); - displayedPhylogenyMightHaveChanged( true ); - _mainpanel.getCurrentTreePanel().updateOvSettings(); - _mainpanel.getCurrentTreePanel().validate(); - _mainpanel.validate(); - _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width, - _mainpanel.getSizeOfViewport().height, - true ); - _mainpanel.getCurrentTreePanel().resetPreferredSize(); - _mainpanel.adjustJScrollPane(); - _mainpanel.getCurrentTreePanel().repaint(); - _mainpanel.getCurrentTreePanel().validate(); - _mainpanel.validate(); - _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width, - _mainpanel.getSizeOfViewport().height, - true ); - _mainpanel.getCurrentTreePanel().resetPreferredSize(); - _mainpanel.adjustJScrollPane(); - _mainpanel.getCurrentTreePanel().repaint(); - _mainpanel.getCurrentTreePanel().updateOvSizes(); - } - - void showWholeAll() { - for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) { - if ( tree_panel != null ) { - tree_panel.validate(); - tree_panel.setParametersForPainting( _mainpanel.getSizeOfViewport().width, - _mainpanel.getSizeOfViewport().height, - true ); - tree_panel.resetPreferredSize(); - tree_panel.repaint(); + // 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; } - // Create header for click-to combo box. - void startClickToOptions() { - final JLabel spacer = new JLabel( "" ); - spacer.setFont( ControlPanel.jcb_font ); - add( spacer ); - _click_to_label = new JLabel( "Click on Node to:" ); - add( customizeLabel( _click_to_label, getConfiguration() ) ); - _click_to_combobox = new JComboBox(); - _click_to_combobox.setFocusable( false ); - _click_to_combobox.setMaximumRowCount( 14 ); - _click_to_combobox.setFont( ControlPanel.js_font ); - if ( !_configuration.isUseNativeUI() ) { - _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() ); - } - // don't add listener until all items are set (or each one will trigger - // an event) - // click_to_list.addActionListener(this); - add( _click_to_combobox ); - // Correlates option names to titles - _all_click_to_names = new HashMap(); - _click_to_names = new ArrayList(); - } - - void tabChanged() { - if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) { - if ( getCurrentTreePanel().isPhyHasBranchLengths() - && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) { - setDrawPhylogramEnabled( true ); - setDrawPhylogram( isDrawPhylogram() ); + void setVisibilityOfX() { + final MainFrame mf = getMainFrame(); + if ( mf != null ) { + if ( ( getCurrentTreePanel() != null ) && ( getCurrentTreePanel().getPhylogeny() != null ) ) { + if ( AptxUtil.isHasAtLeastOneBranchWithSupportSD( getCurrentTreePanel().getPhylogeny() ) ) { + if ( mf._show_confidence_stddev_cbmi != null ) { + mf._show_confidence_stddev_cbmi.setVisible( true ); + } + } + else { + if ( mf._show_confidence_stddev_cbmi != null ) { + mf._show_confidence_stddev_cbmi.setVisible( false ); + } + } + if ( AptxUtil.isHasAtLeastOneNodeWithScientificName( getCurrentTreePanel().getPhylogeny() ) ) { + if ( mf._abbreviate_scientific_names != null ) { + mf._abbreviate_scientific_names.setVisible( true ); + } + } + else { + if ( mf._abbreviate_scientific_names != null ) { + mf._abbreviate_scientific_names.setVisible( false ); + } + } + if ( AptxUtil.isHasAtLeastOneNodeWithSequenceAnnotation( getCurrentTreePanel().getPhylogeny() ) ) { + if ( mf._show_annotation_ref_source != null ) { + mf._show_annotation_ref_source.setVisible( true ); + } + } + else { + if ( mf._show_annotation_ref_source != null ) { + mf._show_annotation_ref_source.setVisible( false ); + } + } + } + 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 ); + } } else { - setDrawPhylogramEnabled( false ); - setDrawPhylogram( false ); + 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 ); + } } - if ( getMainPanel().getMainFrame() == null ) { - // Must be "E" applet version. - final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet(); - e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() ); + if ( isDrawPhylogram() ) { + if ( mf._show_scale_cbmi != null ) { + mf._show_scale_cbmi.setVisible( true ); + } } else { - getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel() - .getPhylogenyGraphicsType() ); + if ( mf._show_scale_cbmi != null ) { + mf._show_scale_cbmi.setVisible( false ); + } } - getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton(); - getMainPanel().getControlPanel().search(); - getSequenceRelationTypeBox().removeAllItems(); - for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny() - .getRelevantSequenceRelationTypes() ) { - _sequence_relation_type_box.addItem( type ); + if ( getCurrentTreePanel() != null ) { + if ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) + || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) { + if ( mf._label_direction_cbmi != null ) { + mf._label_direction_cbmi.setVisible( true ); + } + } + else { + if ( mf._label_direction_cbmi != null ) { + mf._label_direction_cbmi.setVisible( false ); + } + } } - //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() ); - // according to GUILHEM the line above can be removed. } } - /** - * Uncollapse all nodes. - */ - void uncollapseAll( final TreePanel tp ) { - final Phylogeny t = tp.getPhylogeny(); - if ( ( t != null ) && !t.isEmpty() ) { - for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) { - final PhylogenyNode node = iter.next(); - node.setCollapse( false ); + void setVisibilityOfDomainStrucureCB() { + try { + 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 ); + } + if ( getMainPanel().getMainFrame()._show_domain_labels != null ) { + getMainPanel().getMainFrame()._show_domain_labels.setVisible( false ); + } } - tp.resetNodeIdToDistToLeafMap(); - tp.updateSetOfCollapsedExternalNodes(); - t.recalculateNumberOfExternalDescendants( false ); - tp.setNodeInPreorderToNull(); - t.hashIDs(); - showWhole(); - } - } - - void updateDomainStructureEvaluethresholdDisplay() { - if ( _domain_structure_evalue_thr_tf != null ) { - _domain_structure_evalue_thr_tf.setText( "10^" - + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() ); - } - } - - void zoomInX( final float factor, final float x_correction_factor ) { - final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar(); - final TreePanel treepanel = getMainPanel().getCurrentTreePanel(); - treepanel.multiplyUrtFactor( 1f ); - if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) - || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) - || isDrawPhylogram( getMainPanel().getCurrentTabIndex() ) - || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) { - final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) ); - treepanel.setXdistance( ( treepanel.getXdistance() * factor ) ); - treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) ); - getMainPanel().adjustJScrollPane(); - treepanel.resetPreferredSize(); - getMainPanel().getCurrentScrollPane().getViewport().validate(); - sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - - ( sb.getVisibleAmount() / 2.0 ) ) ); - } - else { - final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue(); - treepanel.setXdistance( ( treepanel.getXdistance() * factor ) ); - treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) ); - getMainPanel().adjustJScrollPane(); - treepanel.resetPreferredSize(); - getMainPanel().getCurrentScrollPane().getViewport().validate(); - sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() ); - } - treepanel.resetPreferredSize(); - treepanel.updateOvSizes(); - } - - void zoomInY( final float factor ) { - final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar(); - final TreePanel treepanel = getMainPanel().getCurrentTreePanel(); - treepanel.multiplyUrtFactor( 1.1f ); - final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) ); - treepanel.setYdistance( ( treepanel.getYdistance() * factor ) ); - getMainPanel().adjustJScrollPane(); - treepanel.resetPreferredSize(); - getMainPanel().getCurrentScrollPane().getViewport().validate(); - sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - - ( sb.getVisibleAmount() / 2.0 ) ) ); - treepanel.resetPreferredSize(); - treepanel.updateOvSizes(); - } - - void zoomOutX( final float factor, final float x_correction_factor ) { - final TreePanel treepanel = getMainPanel().getCurrentTreePanel(); - treepanel.multiplyUrtFactor( 1f ); - if ( ( treepanel.getXdistance() * factor ) > 0.0 ) { - final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar(); - if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) - || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) - || isDrawPhylogram( getMainPanel().getCurrentTabIndex() ) - || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) { - getMainPanel().adjustJScrollPane(); - treepanel.resetPreferredSize(); - getMainPanel().getCurrentScrollPane().getViewport().validate(); - final double x = ( sb.getMaximum() - sb.getMinimum() ) - / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) ); - treepanel.setXdistance( ( treepanel.getXdistance() * factor ) ); - treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) ); - getMainPanel().adjustJScrollPane(); - treepanel.resetPreferredSize(); - getMainPanel().getCurrentScrollPane().getViewport().validate(); - sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - - ( sb.getVisibleAmount() / 2.0 ) ) ); + else if ( isShowDomainArchitectures() ) { + if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) { + getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( true ); + } + if ( getMainPanel().getMainFrame()._show_domain_labels != null ) { + getMainPanel().getMainFrame()._show_domain_labels.setVisible( true ); + } } else { - final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue(); - treepanel.setXdistance( treepanel.getXdistance() * factor ); - treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor ); - if ( x > 0 ) { - getMainPanel().adjustJScrollPane(); - treepanel.resetPreferredSize(); - getMainPanel().getCurrentScrollPane().getViewport().validate(); - sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() ); + if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) { + getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false ); + } + if ( getMainPanel().getMainFrame()._show_domain_labels != null ) { + getMainPanel().getMainFrame()._show_domain_labels.setVisible( false ); } } - treepanel.resetPreferredSize(); - treepanel.updateOvSizes(); } - } - - void zoomOutY( final float factor ) { - final TreePanel treepanel = getMainPanel().getCurrentTreePanel(); - treepanel.multiplyUrtFactor( 0.9f ); - if ( ( treepanel.getYdistance() * factor ) > 0.0 ) { - final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar(); - final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) ); - treepanel.setYdistance( ( treepanel.getYdistance() * factor ) ); - getMainPanel().adjustJScrollPane(); - treepanel.resetPreferredSize(); - getMainPanel().getCurrentScrollPane().getViewport().validate(); - sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - - ( sb.getVisibleAmount() / 2.0 ) ) ); - treepanel.resetPreferredSize(); - treepanel.updateOvSizes(); + catch ( final Exception ignore ) { + //not important... } } @@ -1941,21 +2480,26 @@ final class ControlPanel extends JPanel implements ActionListener { } enum NodeClickAction { - SHOW_DATA, + ADD_NEW_NODE, + BLAST, COLLAPSE, - REROOT, - SUBTREE, - SWAP, COLOR_SUBTREE, - OPEN_TAX_WEB, - OPEN_SEQ_WEB, - CUT_SUBTREE, COPY_SUBTREE, + CUT_SUBTREE, DELETE_NODE_OR_SUBTREE, - PASTE_SUBTREE, - ADD_NEW_NODE, 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, - BLAST; + SUBTREE, + SWAP, + CHANGE_NODE_FONT, + COLOR_NODE_FONT; } }