X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FControlPanel.java;h=8c80f0c01b9d7acabda5a43467bbfdf01343c9c4;hb=7aa2563168935732ea6d59a3f1c6cd8bf9a4ad61;hp=233952e67e17f45dee797dd309b93de90c5f430b;hpb=d772adf9d23c4cdbf84b2af9d23e2e7ebedfcf3a;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java index 233952e..8c80f0c 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; @@ -134,6 +134,8 @@ final class ControlPanel extends JPanel implements ActionListener { private int _paste_subtree_item; private int _add_new_node_item; private int _edit_node_data_item; + private int _select_nodes_item; + private int _get_ext_desc_data; private int _blast_item; // zooming and quick tree manipulation buttons: private JButton _zoom_in_x; @@ -199,16 +201,8 @@ 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 ); - } + else if ( e.getSource() == _show_domain_architectures ) { + search(); displayedPhylogenyMightHaveChanged( false ); } else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) { @@ -254,7 +248,7 @@ final class ControlPanel extends JPanel implements ActionListener { _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 ); @@ -300,6 +294,132 @@ final class ControlPanel extends JPanel implements ActionListener { } } + public JCheckBox getColorAccSpeciesCb() { + return _color_acc_species; + } + + public JCheckBox getColorBranchesCb() { + return _color_branches_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 ) { @@ -312,6 +432,13 @@ final class ControlPanel extends JPanel implements ActionListener { _return_to_super_tree.setEnabled( true ); } + void showAnnotations() { + _show_annotation.setSelected( true ); + _color_according_to_annotation.setSelected( true ); + _color_acc_species.setSelected( false ); + _mainpanel.getCurrentTreePanel().repaint(); + } + /** * Add zoom and quick edit buttons. (Last modified 8/9/04) */ @@ -524,16 +651,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 +683,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() ); @@ -626,7 +691,7 @@ final class ControlPanel extends JPanel implements ActionListener { void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) { if ( ( _mainpanel != null ) - && ( _mainpanel.getCurrentPhylogeny() != null && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) { + && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) { if ( getOptions().isShowOverview() ) { _mainpanel.getCurrentTreePanel().updateOvSizes(); } @@ -666,14 +731,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; } @@ -682,127 +739,44 @@ 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; + JTextField getSearchTextField() { + return _search_tf; } - MainPanel getMainPanel() { - return _mainpanel; + List getSingleClickToNames() { + return _click_to_names; } - public JCheckBox getNodeDescPopupCb() { - return _node_desc_popup_cb; + Map getSpeciesColors() { + return _species_colors; } - Options getOptions() { - return getMainPanel().getOptions(); + boolean isAntialiasScreenText() { + return true; } - private JLabel getSearchFoundCountsLabel() { - return _search_found_label; + boolean isColorAccordingToAnnotation() { + return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() ); } - private JButton getSearchResetButton() { - return _search_reset_button; + boolean isColorAccordingToTaxonomy() { + return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() ); } - JTextField getSearchTextField() { - return _search_tf; + boolean isColorBranches() { + return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) ); } - 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; - } - - 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 isColorAccordingToAnnotation() { - return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() ); - } - - boolean isColorAccordingToTaxonomy() { - return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() ); - } - - boolean isColorBranches() { - return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) ); - } - - boolean isDrawPhylogram() { - return isDrawPhylogram( getMainPanel().getCurrentTabIndex() ); - } - - private boolean isDrawPhylogram( final int index ) { - return getIsDrawPhylogramList().get( index ); + boolean isDrawPhylogram() { + return isDrawPhylogram( getMainPanel().getCurrentTabIndex() ); } boolean isDynamicallyHideData() { @@ -841,14 +815,6 @@ final class ControlPanel extends JPanel implements ActionListener { return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() ); } - public boolean isShowVectorData() { - return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() ); - } - - public boolean isShowProperties() { - return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() ); - } - boolean isShowGeneSymbols() { return ( ( _show_gene_symbols != null ) && _show_gene_symbols.isSelected() ); } @@ -877,10 +843,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() ); } @@ -928,62 +890,6 @@ final class ControlPanel extends JPanel implements ActionListener { } } - 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(); - } - 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; - } - } - 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() ); - } - else { - setSearchFoundCountsOnLabel( 0 ); - searchReset(); - } - } - - private void searchReset() { - if ( getMainPanel().getCurrentTreePanel() != null ) { - getMainPanel().getCurrentTreePanel().setFoundNodes( null ); - } - } - void setActionWhenNodeClicked( final NodeClickAction action ) { _action_when_node_clicked = action; } @@ -1186,6 +1092,12 @@ 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 { throw new RuntimeException( "unknown action: " + action ); } @@ -1203,10 +1115,6 @@ 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 ); } @@ -1227,56 +1135,6 @@ final class ControlPanel extends JPanel implements ActionListener { // } } - private void setSearchFoundCountsOnLabel( final int counts ) { - getSearchFoundCountsLabel().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 setShowEvents( final boolean show_events ) { if ( getShowEventsCb() == null ) { _show_events = new JCheckBox( "" ); @@ -1288,35 +1146,530 @@ 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++; + /* 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.reroot ) ) { - _reroot_cb_item = cb_index; - addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) ); - if ( default_option == Configuration.reroot ) { - selected_index = cb_index; - } - cb_index++; + /* 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 ); + } + + 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 ); + } + + /** + * 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, + true ); + _mainpanel.getCurrentTreePanel().resetPreferredSize(); + _mainpanel.adjustJScrollPane(); + _mainpanel.getCurrentTreePanel().repaint(); + _mainpanel.getCurrentTreePanel().validate(); + _mainpanel.validate(); + _mainpanel.getCurrentTreePanel().calcParametersForPainting( _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.calcParametersForPainting( _mainpanel.getSizeOfViewport().width, + _mainpanel.getSizeOfViewport().height, + true ); + 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().search(); + getSequenceRelationTypeBox().removeAllItems(); + for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny() + .getRelevantSequenceRelationTypes() ) { + _sequence_relation_type_box.addItem( type ); + } + //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; + } + + JLabel getSearchFoundCountsLabel() { + return _search_found_label; + } + + JButton getSearchResetButton() { + return _search_reset_button; + } + + private void init() { + _draw_phylogram = new ArrayList(); + setSpeciesColors( new HashMap() ); + setAnnotationColors( new HashMap() ); + } + + private boolean isDrawPhylogram( final int index ) { + return getIsDrawPhylogramList().get( index ); + } + + 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(); + } + 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(), + isShowDomainArchitectures() ) ); + } + else { + nodes.addAll( PhylogenyMethods.searchData( query, + tree, + getOptions().isSearchCaseSensitive(), + !getOptions().isMatchWholeTermsOnly(), + isShowDomainArchitectures() ) ); + } + } + if ( getOptions().isInverseSearchResult() ) { + final List all = PhylogenyMethods.obtainAllNodesAsList( tree ); + all.removeAll( nodes ); + nodes = all; + } + } + 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() ); + } + else { + setSearchFoundCountsOnLabel( 0 ); + searchReset(); + } + } + + void searchReset() { + if ( getMainPanel().getCurrentTreePanel() != null ) { + getMainPanel().getCurrentTreePanel().setFoundNodes( null ); + } + } + + private void setDrawPhylogram( final int index, final boolean b ) { + getIsDrawPhylogramList().set( index, b ); + } + + void setSearchFoundCountsOnLabel( final int counts ) { + getSearchFoundCountsLabel().setText( "Found: " + counts ); + } + + 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; @@ -1375,6 +1728,51 @@ final class ControlPanel extends JPanel implements ActionListener { } 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 SEQUENCE_SYMBOL: + s = "Sequence Symbols"; + break; + case TAXONOMY_CODE: + s = "Taxonomy Codes"; + break; + case TAXONOMY_SCIENTIFIC_NAME: + s = "Scientific Names"; + break; + case UNKNOWN: + s = "User Selected Data"; + break; + } + 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; @@ -1429,70 +1827,21 @@ 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++; + } } // Set default selection and its action _click_to_combobox.setSelectedIndex( selected_index ); 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, @@ -1616,76 +1965,15 @@ final class ControlPanel extends JPanel implements ActionListener { addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) ); setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) ); } - if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) { - addCheckbox( Configuration.show_vector_data, - _configuration.getDisplayTitle( Configuration.show_vector_data ) ); - setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) ); - } - 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 ); + if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) { + addCheckbox( Configuration.show_vector_data, + _configuration.getDisplayTitle( Configuration.show_vector_data ) ); + setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) ); + } + if ( _configuration.doDisplayOption( Configuration.show_properties ) ) { + addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) ); + setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) ); } - _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 ); } private void setVisibilityOfDomainStrucureControls() { @@ -1709,229 +1997,6 @@ final class ControlPanel extends JPanel implements ActionListener { } } - /** - * 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().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(); - } - } - } - - // 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().search(); - getSequenceRelationTypeBox().removeAllItems(); - for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny() - .getRelevantSequenceRelationTypes() ) { - _sequence_relation_type_box.addItem( type ); - } - //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.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 { - 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(); - } - } - static JLabel customizeLabel( final JLabel label, final Configuration configuration ) { label.setFont( ControlPanel.jcb_bold_font ); if ( !configuration.isUseNativeUI() ) { @@ -1956,7 +2021,9 @@ final class ControlPanel extends JPanel implements ActionListener { PASTE_SUBTREE, ADD_NEW_NODE, EDIT_NODE_DATA, + SELECT_NODES, SORT_DESCENDENTS, + GET_EXT_DESC_DATA, BLAST; } }