cleanup
[jalview.git] / forester / java / src / org / forester / archaeopteryx / ControlPanel.java
1 // $Id:
2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
4 //
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 //
22 // Contact: phylosoft @ gmail . com
23 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
24
25 package org.forester.archaeopteryx;
26
27 import java.awt.BorderLayout;
28 import java.awt.Color;
29 import java.awt.Component;
30 import java.awt.Dimension;
31 import java.awt.Font;
32 import java.awt.GridBagLayout;
33 import java.awt.GridLayout;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.ActionListener;
36 import java.awt.event.ItemEvent;
37 import java.awt.event.ItemListener;
38 import java.awt.event.KeyAdapter;
39 import java.awt.event.KeyEvent;
40 import java.util.ArrayList;
41 import java.util.Arrays;
42 import java.util.Collection;
43 import java.util.HashMap;
44 import java.util.HashSet;
45 import java.util.List;
46 import java.util.Map;
47
48 import javax.swing.BorderFactory;
49 import javax.swing.DefaultListCellRenderer;
50 import javax.swing.JButton;
51 import javax.swing.JCheckBox;
52 import javax.swing.JComboBox;
53 import javax.swing.JLabel;
54 import javax.swing.JList;
55 import javax.swing.JPanel;
56 import javax.swing.JScrollBar;
57 import javax.swing.JTextField;
58 import javax.swing.ListCellRenderer;
59
60 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
61 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
62 import org.forester.phylogeny.Phylogeny;
63 import org.forester.phylogeny.PhylogenyMethods;
64 import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
65 import org.forester.phylogeny.PhylogenyNode;
66 import org.forester.phylogeny.data.Sequence;
67 import org.forester.phylogeny.data.SequenceRelation;
68 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
69 import org.forester.util.ForesterUtil;
70
71 final class ControlPanel extends JPanel implements ActionListener {
72
73     final static Font            jcb_bold_font             = new Font( Configuration.getDefaultFontFamilyName(),
74                                                                        Font.BOLD,
75                                                                        9 );
76     final static Font            jcb_font                  = new Font( Configuration.getDefaultFontFamilyName(),
77                                                                        Font.PLAIN,
78                                                                        9 );
79     final static Font            js_font                   = new Font( Configuration.getDefaultFontFamilyName(),
80                                                                        Font.PLAIN,
81                                                                        9 );
82     private static final String  RETURN_TO_SUPER_TREE_TEXT = "Back to Super Tree";
83     private static final long    serialVersionUID          = -8463483932821545633L;
84     private NodeClickAction      _action_when_node_clicked;
85     private int                  _add_new_node_item;
86     private Map<Integer, String> _all_click_to_names;
87     private Map<String, Color>   _annotation_colors;
88     private int                  _blast_item;
89     private JComboBox            _click_to_combobox;
90     private JLabel               _click_to_label;
91     private List<String>         _click_to_names;
92     private int                  _collapse_cb_item;
93     private JCheckBox            _color_acc_species;
94     private JCheckBox            _color_according_to_annotation;
95     private boolean              _color_branches;
96     private JCheckBox            _color_branches_cb;
97     private int                  _color_subtree_cb_item;
98     // The settings from the conf file
99     private final Configuration  _configuration;
100     private int                  _copy_subtree_item;
101     private int                  _cut_subtree_item;
102     private JButton              _decr_domain_structure_evalue_thr;
103     private int                  _delete_node_or_subtree_item;
104     private JCheckBox            _display_as_phylogram_cb;
105     // Tree checkboxes
106     private JCheckBox            _display_internal_data;
107     private JLabel               _domain_display_label;
108     private JTextField           _domain_structure_evalue_thr_tf;
109     private List<Boolean>        _draw_phylogram;
110     private JCheckBox            _dynamically_hide_data;
111     private int                  _edit_node_data_item;
112     private int                  _get_ext_desc_data;
113     private JButton              _incr_domain_structure_evalue_thr;
114     private final MainPanel      _mainpanel;
115     private JCheckBox            _node_desc_popup_cb;
116     private int                  _open_pdb_item;
117     private int                  _open_seq_web_item;
118     private int                  _open_tax_web_item;
119     private int                  _color_node_font_item;
120     private JButton              _order;
121     private boolean              _order_of_appearance;
122     private int                  _paste_subtree_item;
123     private int                  _reroot_cb_item;
124     private JButton              _return_to_super_tree;
125     // Search 
126     private JLabel               _search_found_label_0;
127     private JLabel               _search_found_label_1;
128     private JButton              _search_reset_button_0;
129     private JButton              _search_reset_button_1;
130     private JTextField           _search_tf_0;
131     private JTextField           _search_tf_1;
132     private int                  _select_nodes_item;
133     private Sequence             _selected_query_seq;
134     private JCheckBox            _seq_relation_confidence_switch;
135     private JComboBox            _sequence_relation_type_box;
136     private JCheckBox            _show_annotation;
137     private JCheckBox            _show_binary_character_counts;
138     private JCheckBox            _show_binary_characters;
139     // Indices for the click-to options in the combo box
140     private int                  _show_data_item;
141     private JCheckBox            _show_domain_architectures;
142     private JCheckBox            _show_events;
143     private JCheckBox            _show_gene_names;
144     private JCheckBox            _show_node_names;
145     private JCheckBox            _show_properties_cb;
146     private JCheckBox            _show_seq_names;
147     private JCheckBox            _show_seq_symbols;
148     private JCheckBox            _show_sequence_acc;
149     private JComboBox            _show_sequence_relations;
150     private JCheckBox            _show_taxo_code;
151     private JCheckBox            _show_taxo_common_names;
152     private JCheckBox            _show_taxo_images_cb;
153     private JCheckBox            _show_taxo_scientific_names;
154     private JCheckBox            _show_vector_data_cb;
155     private JButton              _show_whole;
156     private int                  _sort_descendents_item;
157     private Map<String, Color>   _species_colors;
158     private int                  _subtree_cb_item;
159     private int                  _swap_cb_item;
160     private JButton              _uncollapse_all;
161     private JCheckBox            _width_branches;
162     private JCheckBox            _write_confidence;
163     private JButton              _zoom_in_domain_structure;
164     // zooming and quick tree manipulation buttons:
165     private JButton              _zoom_in_x;
166     private JButton              _zoom_in_y;
167     private JLabel               _zoom_label;
168     private JButton              _zoom_out_domain_structure;
169     private JButton              _zoom_out_x;
170     private JButton              _zoom_out_y;
171
172     ControlPanel( final MainPanel ap, final Configuration configuration ) {
173         init();
174         _mainpanel = ap;
175         _configuration = configuration;
176         if ( !_configuration.isUseNativeUI() ) {
177             setBackground( getConfiguration().getGuiBackgroundColor() );
178             setBorder( BorderFactory.createRaisedBevelBorder() );
179         }
180         setLayout( new GridLayout( 0, 1, 2, 2 ) );
181         _order_of_appearance = true;
182         setupControls();
183     }
184
185     /**
186      * Handle an action.
187      */
188     @Override
189     public void actionPerformed( final ActionEvent e ) {
190         try {
191             final TreePanel tp = getMainPanel().getCurrentTreePanel();
192             if ( tp == null ) {
193                 return;
194             }
195             if ( e.getSource() == _click_to_combobox ) {
196                 setClickToAction( _click_to_combobox.getSelectedIndex() );
197                 getCurrentTreePanel().repaint();
198             }
199             else if ( e.getSource() == _show_binary_characters ) {
200                 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
201                     _show_binary_character_counts.setSelected( false );
202                 }
203                 displayedPhylogenyMightHaveChanged( true );
204             }
205             else if ( e.getSource() == _show_binary_character_counts ) {
206                 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
207                     _show_binary_characters.setSelected( false );
208                 }
209                 displayedPhylogenyMightHaveChanged( true );
210             }
211             else if ( e.getSource() == _show_domain_architectures ) {
212                 search0();
213                 search1();
214                 displayedPhylogenyMightHaveChanged( true );
215             }
216             else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
217                 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
218                     setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
219                     showWhole();
220                 }
221                 // Zoom buttons
222                 else if ( e.getSource() == _zoom_in_x ) {
223                     zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
224                     displayedPhylogenyMightHaveChanged( false );
225                 }
226                 else if ( e.getSource() == _zoom_in_y ) {
227                     zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR );
228                     displayedPhylogenyMightHaveChanged( false );
229                 }
230                 else if ( e.getSource() == _zoom_out_x ) {
231                     zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
232                     displayedPhylogenyMightHaveChanged( false );
233                 }
234                 else if ( e.getSource() == _zoom_out_y ) {
235                     zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR );
236                     displayedPhylogenyMightHaveChanged( false );
237                 }
238                 else if ( e.getSource() == _show_whole ) {
239                     showWhole();
240                 }
241                 else if ( e.getSource() == _return_to_super_tree ) {
242                     _mainpanel.getCurrentTreePanel().superTree();
243                     showWhole();
244                 }
245                 else if ( e.getSource() == _order ) {
246                     DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
247                     if ( ( !isShowTaxonomyScientificNames() && !isShowTaxonomyCode() && !isShowTaxonomyCommonNames() ) ) {
248                         if ( ( isShowSequenceAcc() || isShowSeqNames() || isShowSeqSymbols() ) ) {
249                             pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
250                         }
251                         else if ( isShowNodeNames() ) {
252                             pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
253                         }
254                     }
255                     PhylogenyMethods.orderAppearance( tp.getPhylogeny().getRoot(), _order_of_appearance, true, pri );
256                     _order_of_appearance = !_order_of_appearance;
257                     tp.setNodeInPreorderToNull();
258                     tp.getPhylogeny().externalNodesHaveChanged();
259                     tp.getPhylogeny().clearHashIdToNodeMap();
260                     tp.getPhylogeny().recalculateNumberOfExternalDescendants( true );
261                     tp.resetNodeIdToDistToLeafMap();
262                     tp.setEdited( true );
263                     displayedPhylogenyMightHaveChanged( false );
264                 }
265                 else if ( e.getSource() == _uncollapse_all ) {
266                     uncollapseAll( tp );
267                     displayedPhylogenyMightHaveChanged( false );
268                 }
269                 else if ( e.getSource() == _zoom_in_domain_structure ) {
270                     _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
271                     displayedPhylogenyMightHaveChanged( true );
272                 }
273                 else if ( e.getSource() == _zoom_out_domain_structure ) {
274                     _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
275                     displayedPhylogenyMightHaveChanged( true );
276                 }
277                 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
278                     _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThreshold();
279                     displayedPhylogenyMightHaveChanged( true );
280                 }
281                 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
282                     _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThreshold();
283                     displayedPhylogenyMightHaveChanged( true );
284                 }
285                 else if ( e.getSource() == _search_tf_0 ) {
286                     search0();
287                     displayedPhylogenyMightHaveChanged( true );
288                 }
289                 else if ( e.getSource() == _search_tf_1 ) {
290                     search1();
291                     displayedPhylogenyMightHaveChanged( true );
292                 }
293                 else {
294                     displayedPhylogenyMightHaveChanged( true );
295                 }
296             }
297             tp.requestFocus();
298             tp.requestFocusInWindow();
299             tp.requestFocus();
300         }
301         catch ( final Exception ex ) {
302             AptxUtil.unexpectedException( ex );
303         }
304         catch ( final Error err ) {
305             AptxUtil.unexpectedError( err );
306         }
307     }
308
309     public JCheckBox getColorAccSpeciesCb() {
310         return _color_acc_species;
311     }
312
313     public JCheckBox getColorBranchesCb() {
314         return _color_branches_cb;
315     }
316
317     public JCheckBox getDisplayAsPhylogramCb() {
318         return _display_as_phylogram_cb;
319     }
320
321     public JCheckBox getDynamicallyHideData() {
322         return _dynamically_hide_data;
323     }
324
325     public JCheckBox getNodeDescPopupCb() {
326         return _node_desc_popup_cb;
327     }
328
329     public Sequence getSelectedQuerySequence() {
330         return _selected_query_seq;
331     }
332
333     public JComboBox getSequenceRelationBox() {
334         if ( _show_sequence_relations == null ) {
335             _show_sequence_relations = new JComboBox();
336             _show_sequence_relations.setFocusable( false );
337             _show_sequence_relations.setMaximumRowCount( 20 );
338             _show_sequence_relations.setFont( ControlPanel.js_font );
339             if ( !_configuration.isUseNativeUI() ) {
340                 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
341                 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
342             }
343             _show_sequence_relations.addItem( "-----" );
344             _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
345         }
346         return _show_sequence_relations;
347     }
348
349     /* GUILHEM_BEG */
350     public JComboBox getSequenceRelationTypeBox() {
351         if ( _sequence_relation_type_box == null ) {
352             _sequence_relation_type_box = new JComboBox();
353             for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
354                 _sequence_relation_type_box.addItem( type );
355             }
356             _sequence_relation_type_box.addActionListener( new ActionListener() {
357
358                 @Override
359                 public void actionPerformed( final ActionEvent e ) {
360                     if ( _mainpanel.getCurrentPhylogeny() != null ) {
361                         setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
362                     }
363                 }
364             } );
365         }
366         return _sequence_relation_type_box;
367     }
368
369     public JCheckBox getShowEventsCb() {
370         return _show_events;
371     }
372
373     public JCheckBox getWriteConfidenceCb() {
374         return _write_confidence;
375     }
376
377     public boolean isShowProperties() {
378         return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
379     }
380
381     public boolean isShowTaxonomyImages() {
382         return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
383     }
384
385     public boolean isShowVectorData() {
386         return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
387     }
388
389     public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
390         final JComboBox box = getSequenceRelationBox();
391         while ( box.getItemCount() > 1 ) {
392             box.removeItemAt( 1 );
393         }
394         final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
395         final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
396                 .getSelectedItem();
397         if ( relationType == null ) {
398             return;
399         }
400         final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
401         for( final Sequence seq : sequenceRelationQueries ) {
402             if ( seq.hasSequenceRelations() ) {
403                 boolean fFoundForCurrentType = false;
404                 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
405                     if ( sq.getType().equals( relationType ) ) {
406                         fFoundForCurrentType = true;
407                         break;
408                     }
409                 }
410                 if ( fFoundForCurrentType ) {
411                     sequenceNamesToAdd.add( seq.getName() );
412                     sequencesByName.put( seq.getName(), seq );
413                 }
414             }
415         }
416         // sort sequences by name before adding them to the combo
417         final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
418         Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
419         for( final String seqName : sequenceNameArray ) {
420             box.addItem( seqName );
421         }
422         for( final ItemListener oldItemListener : box.getItemListeners() ) {
423             box.removeItemListener( oldItemListener );
424         }
425         box.addItemListener( new ItemListener() {
426
427             @Override
428             public void itemStateChanged( final ItemEvent e ) {
429                 _selected_query_seq = sequencesByName.get( e.getItem() );
430                 _mainpanel.getCurrentTreePanel().repaint();
431             }
432         } );
433     }
434
435     void activateButtonToReturnToSuperTree( int index ) {
436         --index;
437         if ( index > 0 ) {
438             _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
439         }
440         else {
441             _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
442         }
443         _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
444         _return_to_super_tree.setEnabled( true );
445     }
446
447     /**
448      * Add zoom and quick edit buttons. (Last modified 8/9/04)
449      */
450     void addButtons() {
451         final JLabel spacer = new JLabel( "" );
452         spacer.setOpaque( false );
453         add( spacer );
454         final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
455         final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
456         final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
457         if ( !getConfiguration().isUseNativeUI() ) {
458             x_panel.setBackground( getBackground() );
459             y_panel.setBackground( getBackground() );
460             z_panel.setBackground( getBackground() );
461         }
462         add( _zoom_label = new JLabel( "Zoom:" ) );
463         customizeLabel( _zoom_label, getConfiguration() );
464         add( x_panel );
465         add( y_panel );
466         add( z_panel );
467         if ( getConfiguration().isUseNativeUI() ) {
468             _zoom_in_x = new JButton( "+" );
469             _zoom_out_x = new JButton( "-" );
470         }
471         else {
472             _zoom_in_x = new JButton( "X+" );
473             _zoom_out_x = new JButton( "X-" );
474         }
475         _zoom_in_y = new JButton( "Y+" );
476         _zoom_out_y = new JButton( "Y-" );
477         _show_whole = new JButton( "F" );
478         _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [F or Home]" );
479         _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+cursor-right]" );
480         _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+cursor-up]" );
481         _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+cursor-left]" );
482         _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+cursor-down]" );
483         if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) {
484             _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
485             _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
486         }
487         else {
488             _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
489             _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
490         }
491         _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
492         _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
493         _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
494         _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
495         _return_to_super_tree.setEnabled( false );
496         _order = new JButton( "Order Subtrees" );
497         _uncollapse_all = new JButton( "Uncollapse All" );
498         addJButton( _zoom_in_y, x_panel );
499         addJButton( _zoom_out_x, y_panel );
500         addJButton( _show_whole, y_panel );
501         addJButton( _zoom_in_x, y_panel );
502         addJButton( _zoom_out_y, z_panel );
503         if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
504             setUpControlsForDomainStrucures();
505         }
506         final JLabel spacer2 = new JLabel( "" );
507         add( spacer2 );
508         addJButton( _return_to_super_tree, this );
509         addJButton( _order, this );
510         addJButton( _uncollapse_all, this );
511         final JLabel spacer3 = new JLabel( "" );
512         add( spacer3 );
513         setVisibilityOfDomainStrucureControls();
514     }
515
516     void addCheckbox( final int which, final String title ) {
517         final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
518         switch ( which ) {
519             case Configuration.display_as_phylogram:
520                 _display_as_phylogram_cb = new JCheckBox( title );
521                 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
522                 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
523                 add( ch_panel );
524                 break;
525             case Configuration.display_internal_data:
526                 _display_internal_data = new JCheckBox( title );
527                 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
528                 addJCheckBox( _display_internal_data, ch_panel );
529                 add( ch_panel );
530                 break;
531             case Configuration.color_according_to_species:
532                 _color_acc_species = new JCheckBox( title );
533                 _color_acc_species
534                         .setToolTipText( "To colorize taxonomy and sequence labels as a function of taxonomy" );
535                 addJCheckBox( _color_acc_species, ch_panel );
536                 add( ch_panel );
537                 break;
538             case Configuration.color_according_to_annotation:
539                 _color_according_to_annotation = new JCheckBox( title );
540                 _color_according_to_annotation
541                         .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
542                 addJCheckBox( _color_according_to_annotation, ch_panel );
543                 add( ch_panel );
544                 break;
545             case Configuration.show_node_names:
546                 _show_node_names = new JCheckBox( title );
547                 addJCheckBox( _show_node_names, ch_panel );
548                 add( ch_panel );
549                 break;
550             case Configuration.show_taxonomy_scientific_names:
551                 _show_taxo_scientific_names = new JCheckBox( title );
552                 addJCheckBox( _show_taxo_scientific_names, ch_panel );
553                 add( ch_panel );
554                 break;
555             case Configuration.show_taxonomy_common_names:
556                 _show_taxo_common_names = new JCheckBox( title );
557                 addJCheckBox( _show_taxo_common_names, ch_panel );
558                 add( ch_panel );
559                 break;
560             case Configuration.show_tax_code:
561                 _show_taxo_code = new JCheckBox( title );
562                 addJCheckBox( _show_taxo_code, ch_panel );
563                 add( ch_panel );
564                 break;
565             case Configuration.show_taxonomy_images:
566                 _show_taxo_images_cb = new JCheckBox( title );
567                 addJCheckBox( _show_taxo_images_cb, ch_panel );
568                 add( ch_panel );
569                 break;
570             case Configuration.show_binary_characters:
571                 _show_binary_characters = new JCheckBox( title );
572                 addJCheckBox( _show_binary_characters, ch_panel );
573                 add( ch_panel );
574                 break;
575             case Configuration.show_annotation:
576                 _show_annotation = new JCheckBox( title );
577                 addJCheckBox( _show_annotation, ch_panel );
578                 add( ch_panel );
579                 break;
580             case Configuration.show_binary_character_counts:
581                 _show_binary_character_counts = new JCheckBox( title );
582                 addJCheckBox( _show_binary_character_counts, ch_panel );
583                 add( ch_panel );
584                 break;
585             case Configuration.write_confidence_values:
586                 _write_confidence = new JCheckBox( title );
587                 addJCheckBox( getWriteConfidenceCb(), ch_panel );
588                 add( ch_panel );
589                 break;
590             case Configuration.write_events:
591                 _show_events = new JCheckBox( title );
592                 addJCheckBox( getShowEventsCb(), ch_panel );
593                 add( ch_panel );
594                 break;
595             case Configuration.color_branches:
596                 _color_branches_cb = new JCheckBox( title );
597                 getColorBranchesCb().setToolTipText( "To use branch color values, if present" );
598                 addJCheckBox( getColorBranchesCb(), ch_panel );
599                 add( ch_panel );
600                 break;
601             case Configuration.width_branches:
602                 _width_branches = new JCheckBox( title );
603                 _width_branches.setToolTipText( "To use branch width values, if present" );
604                 addJCheckBox( _width_branches, ch_panel );
605                 add( ch_panel );
606                 break;
607             case Configuration.show_domain_architectures:
608                 _show_domain_architectures = new JCheckBox( title );
609                 addJCheckBox( _show_domain_architectures, ch_panel );
610                 add( ch_panel );
611                 break;
612             case Configuration.show_seq_names:
613                 _show_seq_names = new JCheckBox( title );
614                 addJCheckBox( _show_seq_names, ch_panel );
615                 add( ch_panel );
616                 break;
617             case Configuration.show_gene_names:
618                 _show_gene_names = new JCheckBox( title );
619                 addJCheckBox( _show_gene_names, ch_panel );
620                 add( ch_panel );
621                 break;
622             case Configuration.show_seq_symbols:
623                 _show_seq_symbols = new JCheckBox( title );
624                 addJCheckBox( _show_seq_symbols, ch_panel );
625                 add( ch_panel );
626                 break;
627             case Configuration.show_sequence_acc:
628                 _show_sequence_acc = new JCheckBox( title );
629                 addJCheckBox( _show_sequence_acc, ch_panel );
630                 add( ch_panel );
631                 break;
632             case Configuration.dynamically_hide_data:
633                 _dynamically_hide_data = new JCheckBox( title );
634                 getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" );
635                 addJCheckBox( getDynamicallyHideData(), ch_panel );
636                 add( ch_panel );
637                 break;
638             case Configuration.node_data_popup:
639                 _node_desc_popup_cb = new JCheckBox( title );
640                 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
641                 addJCheckBox( getNodeDescPopupCb(), ch_panel );
642                 add( ch_panel );
643                 break;
644             case Configuration.show_relation_confidence:
645                 _seq_relation_confidence_switch = new JCheckBox( title );
646                 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
647                 add( ch_panel );
648                 break;
649             case Configuration.show_vector_data:
650                 _show_vector_data_cb = new JCheckBox( title );
651                 addJCheckBox( _show_vector_data_cb, ch_panel );
652                 add( ch_panel );
653                 break;
654             case Configuration.show_properties:
655                 _show_properties_cb = new JCheckBox( title );
656                 addJCheckBox( _show_properties_cb, ch_panel );
657                 add( ch_panel );
658                 break;
659             default:
660                 throw new RuntimeException( "unknown checkbox: " + which );
661         }
662     }// addCheckbox
663
664     void addJButton( final JButton jb, final JPanel p ) {
665         jb.setFocusPainted( false );
666         jb.setFont( ControlPanel.jcb_font );
667         if ( !_configuration.isUseNativeUI() ) {
668             jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
669             jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
670             jb.setForeground( getConfiguration().getGuiButtonTextColor() );
671         }
672         p.add( jb );
673         jb.addActionListener( this );
674     }
675
676     void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
677         jcb.setFocusPainted( false );
678         jcb.setFont( ControlPanel.jcb_font );
679         if ( !_configuration.isUseNativeUI() ) {
680             jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
681             jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
682         }
683         p.add( jcb, "Center" );
684         jcb.addActionListener( this );
685     }
686
687     void addJTextField( final JTextField tf, final JPanel p ) {
688         if ( !_configuration.isUseNativeUI() ) {
689             tf.setForeground( getConfiguration().getGuiBackgroundColor() );
690             tf.setFont( ControlPanel.jcb_font );
691         }
692         p.add( tf );
693         tf.addActionListener( this );
694     }
695
696     void deactivateButtonToReturnToSuperTree() {
697         _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
698         _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
699         _return_to_super_tree.setEnabled( false );
700     }
701
702     void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
703         if ( ( _mainpanel != null )
704                 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
705             if ( getOptions().isShowOverview() ) {
706                 _mainpanel.getCurrentTreePanel().updateOvSizes();
707             }
708             _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
709             setVisibilityOfDomainStrucureControls();
710             updateDomainStructureEvaluethresholdDisplay();
711             _mainpanel.getCurrentTreePanel().calculateScaleDistance();
712             _mainpanel.getCurrentTreePanel().calcMaxDepth();
713             _mainpanel.adjustJScrollPane();
714             if ( recalc_longest_ext_node_info ) {
715                 _mainpanel.getCurrentTreePanel().initNodeData();
716                 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
717             }
718             _mainpanel.getCurrentTreePanel().repaint();
719             // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
720         }
721     }
722
723     void endClickToOptions() {
724         _click_to_combobox.addActionListener( this );
725     }
726
727     /**
728      * Indicates what action should be execute when a node is clicked
729      * 
730      * @return the click-on action
731      */
732     NodeClickAction getActionWhenNodeClicked() {
733         return _action_when_node_clicked;
734     }
735
736     Map<Integer, String> getAllClickToItems() {
737         return _all_click_to_names;
738     }
739
740     Map<String, Color> getAnnotationColors() {
741         return _annotation_colors;
742     }
743
744     Configuration getConfiguration() {
745         return _configuration;
746     }
747
748     TreePanel getCurrentTreePanel() {
749         return getMainPanel().getCurrentTreePanel();
750     }
751
752     MainPanel getMainPanel() {
753         return _mainpanel;
754     }
755
756     Options getOptions() {
757         return getMainPanel().getOptions();
758     }
759
760     JLabel getSearchFoundCountsLabel0() {
761         return _search_found_label_0;
762     }
763
764     JLabel getSearchFoundCountsLabel1() {
765         return _search_found_label_1;
766     }
767
768     JButton getSearchResetButton0() {
769         return _search_reset_button_0;
770     }
771
772     JButton getSearchResetButton1() {
773         return _search_reset_button_1;
774     }
775
776     JTextField getSearchTextField0() {
777         return _search_tf_0;
778     }
779
780     JTextField getSearchTextField1() {
781         return _search_tf_1;
782     }
783
784     List<String> getSingleClickToNames() {
785         return _click_to_names;
786     }
787
788     Map<String, Color> getSpeciesColors() {
789         return _species_colors;
790     }
791
792     boolean isAntialiasScreenText() {
793         return true;
794     }
795
796     boolean isColorAccordingToAnnotation() {
797         return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
798     }
799
800     boolean isColorAccordingToTaxonomy() {
801         return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
802     }
803
804     boolean isColorBranches() {
805         return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) );
806     }
807
808     boolean isDrawPhylogram() {
809         return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
810     }
811
812     boolean isDynamicallyHideData() {
813         return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
814     }
815
816     boolean isEvents() {
817         return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
818     }
819
820     boolean isNodeDescPopup() {
821         return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
822     }
823
824     boolean isShowAnnotation() {
825         return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
826     }
827
828     boolean isShowBinaryCharacterCounts() {
829         return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
830     }
831
832     boolean isShowBinaryCharacters() {
833         return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
834     }
835
836     boolean isShowConfidenceValues() {
837         return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
838     }
839
840     boolean isShowDomainArchitectures() {
841         return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
842     }
843
844     boolean isShowGeneNames() {
845         return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
846     }
847
848     boolean isShowInternalData() {
849         return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
850     }
851
852     boolean isShowNodeNames() {
853         return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
854     }
855
856     boolean isShowSeqNames() {
857         return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
858     }
859
860     boolean isShowSeqSymbols() {
861         return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
862     }
863
864     boolean isShowSequenceAcc() {
865         return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
866     }
867
868     boolean isShowSequenceRelationConfidence() {
869         return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
870     }
871
872     boolean isShowSequenceRelations() {
873         return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
874     }
875
876     boolean isShowTaxonomyCode() {
877         return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
878     }
879
880     boolean isShowTaxonomyCommonNames() {
881         return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
882     }
883
884     boolean isShowTaxonomyScientificNames() {
885         return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
886     }
887
888     boolean isWidthBranches() {
889         return ( ( _width_branches != null ) && _width_branches.isSelected() );
890     }
891
892     void phylogenyAdded( final Configuration configuration ) {
893         getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
894     }
895
896     void phylogenyRemoved( final int index ) {
897         getIsDrawPhylogramList().remove( index );
898     }
899
900     void search0() {
901         final MainPanel main_panel = getMainPanel();
902         final Phylogeny tree = main_panel.getCurrentPhylogeny();
903         if ( ( tree == null ) || tree.isEmpty() ) {
904             return;
905         }
906         String query = getSearchTextField0().getText();
907         if ( query != null ) {
908             query = query.trim();
909         }
910         if ( !ForesterUtil.isEmpty( query ) ) {
911             search0( main_panel, tree, query );
912         }
913         else {
914             getSearchFoundCountsLabel0().setVisible( false );
915             getSearchResetButton0().setEnabled( false );
916             getSearchResetButton0().setVisible( false );
917             searchReset0();
918         }
919     }
920
921     void search1() {
922         final MainPanel main_panel = getMainPanel();
923         final Phylogeny tree = main_panel.getCurrentPhylogeny();
924         if ( ( tree == null ) || tree.isEmpty() ) {
925             return;
926         }
927         String query = getSearchTextField1().getText();
928         if ( query != null ) {
929             query = query.trim();
930         }
931         if ( !ForesterUtil.isEmpty( query ) ) {
932             search1( main_panel, tree, query );
933         }
934         else {
935             getSearchFoundCountsLabel1().setVisible( false );
936             getSearchResetButton1().setEnabled( false );
937             getSearchResetButton1().setVisible( false );
938             searchReset1();
939         }
940     }
941
942     void searchReset0() {
943         if ( getMainPanel().getCurrentTreePanel() != null ) {
944             getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
945         }
946     }
947
948     void searchReset1() {
949         if ( getMainPanel().getCurrentTreePanel() != null ) {
950             getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
951         }
952     }
953
954     void setActionWhenNodeClicked( final NodeClickAction action ) {
955         _action_when_node_clicked = action;
956     }
957
958     void setAnnotationColors( final Map<String, Color> annotation_colors ) {
959         _annotation_colors = annotation_colors;
960     }
961
962     void setCheckbox( final int which, final boolean state ) {
963         switch ( which ) {
964             case Configuration.display_as_phylogram:
965                 if ( getDisplayAsPhylogramCb() != null ) {
966                     getDisplayAsPhylogramCb().setSelected( state );
967                 }
968                 break;
969             case Configuration.display_internal_data:
970                 if ( _display_internal_data != null ) {
971                     _display_internal_data.setSelected( state );
972                 }
973                 break;
974             case Configuration.color_according_to_species:
975                 if ( _color_acc_species != null ) {
976                     _color_acc_species.setSelected( state );
977                 }
978                 break;
979             case Configuration.color_according_to_annotation:
980                 if ( _color_according_to_annotation != null ) {
981                     _color_according_to_annotation.setSelected( state );
982                 }
983                 break;
984             case Configuration.show_node_names:
985                 if ( _show_node_names != null ) {
986                     _show_node_names.setSelected( state );
987                 }
988                 break;
989             case Configuration.show_taxonomy_scientific_names:
990                 if ( _show_taxo_scientific_names != null ) {
991                     _show_taxo_scientific_names.setSelected( state );
992                 }
993                 break;
994             case Configuration.show_taxonomy_common_names:
995                 if ( _show_taxo_common_names != null ) {
996                     _show_taxo_common_names.setSelected( state );
997                 }
998                 break;
999             case Configuration.show_tax_code:
1000                 if ( _show_taxo_code != null ) {
1001                     _show_taxo_code.setSelected( state );
1002                 }
1003                 break;
1004             case Configuration.show_taxonomy_images:
1005                 if ( _show_taxo_images_cb != null ) {
1006                     _show_taxo_images_cb.setSelected( state );
1007                 }
1008                 break;
1009             case Configuration.show_annotation:
1010                 if ( _show_annotation != null ) {
1011                     _show_annotation.setSelected( state );
1012                 }
1013                 break;
1014             case Configuration.show_binary_characters:
1015                 if ( _show_binary_characters != null ) {
1016                     _show_binary_characters.setSelected( state );
1017                 }
1018                 break;
1019             case Configuration.show_binary_character_counts:
1020                 if ( _show_binary_character_counts != null ) {
1021                     _show_binary_character_counts.setSelected( state );
1022                 }
1023                 break;
1024             case Configuration.write_confidence_values:
1025                 if ( getWriteConfidenceCb() != null ) {
1026                     getWriteConfidenceCb().setSelected( state );
1027                 }
1028                 break;
1029             case Configuration.write_events:
1030                 if ( getShowEventsCb() != null ) {
1031                     getShowEventsCb().setSelected( state );
1032                 }
1033                 break;
1034             case Configuration.color_branches:
1035                 if ( getColorBranchesCb() != null ) {
1036                     getColorBranchesCb().setSelected( state );
1037                 }
1038                 break;
1039             case Configuration.width_branches:
1040                 if ( _width_branches != null ) {
1041                     _width_branches.setSelected( state );
1042                 }
1043                 break;
1044             case Configuration.show_domain_architectures:
1045                 if ( _show_domain_architectures != null ) {
1046                     _show_domain_architectures.setSelected( state );
1047                 }
1048                 break;
1049             case Configuration.show_seq_names:
1050                 if ( _show_seq_names != null ) {
1051                     _show_seq_names.setSelected( state );
1052                 }
1053                 break;
1054             case Configuration.show_gene_names:
1055                 if ( _show_gene_names != null ) {
1056                     _show_gene_names.setSelected( state );
1057                 }
1058                 break;
1059             case Configuration.show_seq_symbols:
1060                 if ( _show_seq_symbols != null ) {
1061                     _show_seq_symbols.setSelected( state );
1062                 }
1063                 break;
1064             case Configuration.show_vector_data:
1065                 if ( _show_vector_data_cb != null ) {
1066                     _show_vector_data_cb.setSelected( state );
1067                 }
1068                 break;
1069             case Configuration.show_properties:
1070                 if ( _show_properties_cb != null ) {
1071                     _show_properties_cb.setSelected( state );
1072                 }
1073                 break;
1074             case Configuration.show_sequence_acc:
1075                 if ( _show_sequence_acc != null ) {
1076                     _show_sequence_acc.setSelected( state );
1077                 }
1078                 break;
1079             case Configuration.dynamically_hide_data:
1080                 if ( getDynamicallyHideData() != null ) {
1081                     getDynamicallyHideData().setSelected( state );
1082                 }
1083                 break;
1084             case Configuration.node_data_popup:
1085                 if ( getNodeDescPopupCb() != null ) {
1086                     getNodeDescPopupCb().setSelected( state );
1087                 }
1088                 break;
1089             /* GUILHEM_BEG */
1090             case Configuration.show_relation_confidence:
1091                 if ( _seq_relation_confidence_switch != null ) {
1092                     _seq_relation_confidence_switch.setSelected( state );
1093                 }
1094                 break;
1095             /* GUILHEM_END */
1096             default:
1097                 throw new AssertionError( "unknown checkbox: " + which );
1098         }
1099     }
1100
1101     /**
1102      * Set this checkbox state. Not all checkboxes have been instantiated
1103      * depending on the config.
1104      */
1105     void setCheckbox( final JCheckBox cb, final boolean state ) {
1106         if ( cb != null ) {
1107             cb.setSelected( state );
1108         }
1109     }
1110
1111     void setClickToAction( final int action ) {
1112         // Set click-to action
1113         if ( action == _show_data_item ) {
1114             setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1115         }
1116         else if ( action == _collapse_cb_item ) {
1117             setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1118         }
1119         else if ( action == _reroot_cb_item ) {
1120             setActionWhenNodeClicked( NodeClickAction.REROOT );
1121         }
1122         else if ( action == _subtree_cb_item ) {
1123             setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1124         }
1125         else if ( action == _swap_cb_item ) {
1126             setActionWhenNodeClicked( NodeClickAction.SWAP );
1127         }
1128         else if ( action == _color_subtree_cb_item ) {
1129             setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1130         }
1131         else if ( action == _open_seq_web_item ) {
1132             setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1133         }
1134         else if ( action == _sort_descendents_item ) {
1135             setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1136         }
1137         else if ( action == _blast_item ) {
1138             setActionWhenNodeClicked( NodeClickAction.BLAST );
1139         }
1140         else if ( action == _open_tax_web_item ) {
1141             setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1142         }
1143         else if ( action == _cut_subtree_item ) {
1144             setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1145         }
1146         else if ( action == _copy_subtree_item ) {
1147             setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1148         }
1149         else if ( action == _delete_node_or_subtree_item ) {
1150             setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1151         }
1152         else if ( action == _paste_subtree_item ) {
1153             setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1154         }
1155         else if ( action == _add_new_node_item ) {
1156             setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1157         }
1158         else if ( action == _edit_node_data_item ) {
1159             setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1160         }
1161         else if ( action == _select_nodes_item ) {
1162             setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
1163         }
1164         else if ( action == _get_ext_desc_data ) {
1165             setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
1166         }
1167         else if ( action == _open_pdb_item ) {
1168             setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
1169         }
1170         else if ( action == _color_node_font_item ) {
1171             setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
1172         }
1173         else {
1174             throw new RuntimeException( "unknown action: " + action );
1175         }
1176         // make sure drop down is displaying the correct action
1177         // in case this was called from outside the class
1178         _click_to_combobox.setSelectedIndex( action );
1179     }
1180
1181     void setColorBranches( final boolean color_branches ) {
1182         _color_branches = color_branches;
1183     }
1184
1185     void setDrawPhylogram( final boolean b ) {
1186         getDisplayAsPhylogramCb().setSelected( b );
1187         setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1188     }
1189
1190     void setDrawPhylogramEnabled( final boolean b ) {
1191         getDisplayAsPhylogramCb().setEnabled( b );
1192     }
1193
1194     void setDynamicHidingIsOn( final boolean is_on ) {
1195         //  if ( !_configuration.isUseNativeUI() ) {
1196         if ( is_on ) {
1197             getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1198         }
1199         else {
1200             if ( !_configuration.isUseNativeUI() ) {
1201                 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1202             }
1203             else {
1204                 getDynamicallyHideData().setForeground( Color.BLACK );
1205             }
1206         }
1207         // }
1208     }
1209
1210     void setSearchFoundCountsOnLabel0( final int counts ) {
1211         getSearchFoundCountsLabel0().setText( "Found: " + counts );
1212     }
1213
1214     void setSearchFoundCountsOnLabel1( final int counts ) {
1215         getSearchFoundCountsLabel1().setText( "Found: " + counts );
1216     }
1217
1218     void setShowEvents( final boolean show_events ) {
1219         if ( getShowEventsCb() == null ) {
1220             _show_events = new JCheckBox( "" );
1221         }
1222         getShowEventsCb().setSelected( show_events );
1223     }
1224
1225     void setSpeciesColors( final Map<String, Color> species_colors ) {
1226         _species_colors = species_colors;
1227     }
1228
1229     /* GUILHEM_END */
1230     /*
1231      * Set up the controls from the config settings. 11/26/05
1232      */
1233     void setupControls() {
1234         // The tree display options:
1235         setupDisplayCheckboxes();
1236         /* GUILHEM_BEG */
1237         // The sequence relation query selection combo-box
1238         if ( _configuration.displaySequenceRelations() ) {
1239             addSequenceRelationBlock();
1240         }
1241         /* GUILHEM_END */
1242         // Click-to options
1243         startClickToOptions();
1244         setupClickToOptions();
1245         endClickToOptions();
1246         // Zoom and quick edit buttons
1247         addButtons();
1248         setupSearchTools0();
1249         setupSearchTools1();
1250     }
1251
1252     void setUpControlsForDomainStrucures() {
1253         _domain_display_label = new JLabel( "Domain Display:" );
1254         add( customizeLabel( _domain_display_label, getConfiguration() ) );
1255         add( _domain_display_label );
1256         _zoom_in_domain_structure = new JButton( "d+" );
1257         _zoom_out_domain_structure = new JButton( "d-" );
1258         _decr_domain_structure_evalue_thr = new JButton( "-" );
1259         _incr_domain_structure_evalue_thr = new JButton( "+" );
1260         _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1261         _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1262         _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1263         _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1264         _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1265         _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1266         _domain_structure_evalue_thr_tf = new JTextField( 3 );
1267         _domain_structure_evalue_thr_tf.setEditable( false );
1268         if ( !getConfiguration().isUseNativeUI() ) {
1269             _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1270             _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1271             _domain_structure_evalue_thr_tf.setBorder( null );
1272         }
1273         final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1274         final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1275         if ( !_configuration.isUseNativeUI() ) {
1276             d1_panel.setBackground( getBackground() );
1277             d2_panel.setBackground( getBackground() );
1278         }
1279         add( d1_panel );
1280         add( d2_panel );
1281         addJButton( _zoom_out_domain_structure, d1_panel );
1282         addJButton( _zoom_in_domain_structure, d1_panel );
1283         addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1284         addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1285         addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1286     }
1287
1288     void setupSearchTools0() {
1289         final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1290         final JLabel search_label = new JLabel( "Search (A):" );
1291         search_label.setFont( ControlPanel.jcb_bold_font );
1292         if ( !getConfiguration().isUseNativeUI() ) {
1293             search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1294         }
1295         add( search_label );
1296         search_label.setToolTipText( tip );
1297         _search_found_label_0 = new JLabel();
1298         getSearchFoundCountsLabel0().setVisible( false );
1299         _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
1300         if ( !getConfiguration().isUseNativeUI() ) {
1301             _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1302         }
1303         _search_tf_0 = new JTextField( 3 );
1304         _search_tf_0.setToolTipText( tip );
1305         _search_tf_0.setEditable( true );
1306         if ( !getConfiguration().isUseNativeUI() ) {
1307             _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1308             _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1309             _search_tf_0.setBorder( null );
1310         }
1311         _search_reset_button_0 = new JButton();
1312         getSearchResetButton0().setText( "Reset" );
1313         getSearchResetButton0().setEnabled( false );
1314         getSearchResetButton0().setVisible( false );
1315         final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1316         final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1317         s_panel_1.setBackground( getBackground() );
1318         add( s_panel_1 );
1319         s_panel_2.setBackground( getBackground() );
1320         add( s_panel_2 );
1321         final KeyAdapter key_adapter = new KeyAdapter() {
1322
1323             @Override
1324             public void keyReleased( final KeyEvent key_event ) {
1325                 search0();
1326                 displayedPhylogenyMightHaveChanged( true );
1327             }
1328         };
1329         final ActionListener action_listener = new ActionListener() {
1330
1331             @Override
1332             public void actionPerformed( final ActionEvent e ) {
1333                 searchReset0();
1334                 setSearchFoundCountsOnLabel0( 0 );
1335                 getSearchFoundCountsLabel0().setVisible( false );
1336                 getSearchTextField0().setText( "" );
1337                 getSearchResetButton0().setEnabled( false );
1338                 getSearchResetButton0().setVisible( false );
1339                 displayedPhylogenyMightHaveChanged( true );
1340             }
1341         };
1342         _search_reset_button_0.addActionListener( action_listener );
1343         _search_tf_0.addKeyListener( key_adapter );
1344         addJTextField( _search_tf_0, s_panel_1 );
1345         s_panel_2.add( _search_found_label_0 );
1346         addJButton( _search_reset_button_0, s_panel_2 );
1347     }
1348
1349     void setupSearchTools1() {
1350         final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1351         final JLabel search_label = new JLabel( "Search (B):" );
1352         search_label.setFont( ControlPanel.jcb_bold_font );
1353         if ( !getConfiguration().isUseNativeUI() ) {
1354             search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1355         }
1356         add( search_label );
1357         search_label.setToolTipText( tip );
1358         _search_found_label_1 = new JLabel();
1359         getSearchFoundCountsLabel1().setVisible( false );
1360         _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
1361         if ( !getConfiguration().isUseNativeUI() ) {
1362             _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1363         }
1364         _search_tf_1 = new JTextField( 3 );
1365         _search_tf_1.setToolTipText( tip );
1366         _search_tf_1.setEditable( true );
1367         if ( !getConfiguration().isUseNativeUI() ) {
1368             _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1369             _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1370             _search_tf_1.setBorder( null );
1371         }
1372         _search_reset_button_1 = new JButton();
1373         getSearchResetButton1().setText( "Reset" );
1374         getSearchResetButton1().setEnabled( false );
1375         getSearchResetButton1().setVisible( false );
1376         final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1377         final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1378         s_panel_1.setBackground( getBackground() );
1379         add( s_panel_1 );
1380         s_panel_2.setBackground( getBackground() );
1381         add( s_panel_2 );
1382         final KeyAdapter key_adapter = new KeyAdapter() {
1383
1384             @Override
1385             public void keyReleased( final KeyEvent key_event ) {
1386                 search1();
1387                 displayedPhylogenyMightHaveChanged( true );
1388             }
1389         };
1390         final ActionListener action_listener = new ActionListener() {
1391
1392             @Override
1393             public void actionPerformed( final ActionEvent e ) {
1394                 searchReset1();
1395                 setSearchFoundCountsOnLabel1( 0 );
1396                 getSearchFoundCountsLabel1().setVisible( false );
1397                 getSearchTextField1().setText( "" );
1398                 getSearchResetButton1().setEnabled( false );
1399                 getSearchResetButton1().setVisible( false );
1400                 displayedPhylogenyMightHaveChanged( true );
1401             }
1402         };
1403         _search_reset_button_1.addActionListener( action_listener );
1404         _search_tf_1.addKeyListener( key_adapter );
1405         addJTextField( _search_tf_1, s_panel_1 );
1406         s_panel_2.add( _search_found_label_1 );
1407         addJButton( _search_reset_button_1, s_panel_2 );
1408     }
1409
1410     void showAnnotations() {
1411         if ( _show_annotation != null ) {
1412             _show_annotation.setSelected( true );
1413         }
1414         if ( _color_according_to_annotation != null ) {
1415             _color_according_to_annotation.setSelected( true );
1416         }
1417         if ( _color_acc_species != null ) {
1418             _color_acc_species.setSelected( false );
1419         }
1420         _mainpanel.getCurrentTreePanel().repaint();
1421     }
1422
1423     /**
1424      * Fit entire tree into window.
1425      */
1426     void showWhole() {
1427         if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
1428             return;
1429         }
1430         getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
1431         displayedPhylogenyMightHaveChanged( true );
1432         _mainpanel.getCurrentTreePanel().updateOvSettings();
1433         _mainpanel.getCurrentTreePanel().validate();
1434         _mainpanel.validate();
1435         _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1436                                                                     _mainpanel.getSizeOfViewport().height,
1437                                                                     true );
1438         _mainpanel.getCurrentTreePanel().resetPreferredSize();
1439         _mainpanel.adjustJScrollPane();
1440         _mainpanel.getCurrentTreePanel().repaint();
1441         _mainpanel.getCurrentTreePanel().validate();
1442         _mainpanel.validate();
1443         _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1444                                                                     _mainpanel.getSizeOfViewport().height,
1445                                                                     true );
1446         _mainpanel.getCurrentTreePanel().resetPreferredSize();
1447         _mainpanel.adjustJScrollPane();
1448         _mainpanel.getCurrentTreePanel().repaint();
1449         _mainpanel.getCurrentTreePanel().updateOvSizes();
1450     }
1451
1452     void showWholeAll() {
1453         for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1454             if ( tree_panel != null ) {
1455                 tree_panel.validate();
1456                 tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1457                                                       _mainpanel.getSizeOfViewport().height,
1458                                                       true );
1459                 tree_panel.resetPreferredSize();
1460                 tree_panel.repaint();
1461             }
1462         }
1463     }
1464
1465     // Create header for click-to combo box.
1466     void startClickToOptions() {
1467         final JLabel spacer = new JLabel( "" );
1468         spacer.setFont( ControlPanel.jcb_font );
1469         add( spacer );
1470         _click_to_label = new JLabel( "Click on Node to:" );
1471         add( customizeLabel( _click_to_label, getConfiguration() ) );
1472         _click_to_combobox = new JComboBox();
1473         _click_to_combobox.setFocusable( false );
1474         _click_to_combobox.setMaximumRowCount( 14 );
1475         _click_to_combobox.setFont( ControlPanel.js_font );
1476         if ( !_configuration.isUseNativeUI() ) {
1477             _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1478         }
1479         // don't add listener until all items are set (or each one will trigger
1480         // an event)
1481         // click_to_list.addActionListener(this);
1482         add( _click_to_combobox );
1483         // Correlates option names to titles
1484         _all_click_to_names = new HashMap<Integer, String>();
1485         _click_to_names = new ArrayList<String>();
1486     }
1487
1488     void tabChanged() {
1489         if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1490             if ( getCurrentTreePanel().isPhyHasBranchLengths()
1491                     && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1492                 setDrawPhylogramEnabled( true );
1493                 setDrawPhylogram( isDrawPhylogram() );
1494             }
1495             else {
1496                 setDrawPhylogramEnabled( false );
1497                 setDrawPhylogram( false );
1498             }
1499             if ( getMainPanel().getMainFrame() == null ) {
1500                 // Must be "E" applet version.
1501                 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1502                 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1503             }
1504             else {
1505                 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1506                         .getPhylogenyGraphicsType() );
1507             }
1508             getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1509             getMainPanel().getControlPanel().search0();
1510             getMainPanel().getControlPanel().search1();
1511             getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
1512             getSequenceRelationTypeBox().removeAllItems();
1513             for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1514                     .getRelevantSequenceRelationTypes() ) {
1515                 _sequence_relation_type_box.addItem( type );
1516             }
1517             getMainPanel().getCurrentTreePanel().repaint();
1518             //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1519             // according to GUILHEM the line above can be removed.
1520         }
1521     }
1522
1523     /**
1524      * Uncollapse all nodes.
1525      */
1526     void uncollapseAll( final TreePanel tp ) {
1527         final Phylogeny t = tp.getPhylogeny();
1528         if ( ( t != null ) && !t.isEmpty() ) {
1529             for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
1530                 final PhylogenyNode node = iter.next();
1531                 node.setCollapse( false );
1532             }
1533             tp.resetNodeIdToDistToLeafMap();
1534             tp.updateSetOfCollapsedExternalNodes();
1535             t.recalculateNumberOfExternalDescendants( false );
1536             tp.setNodeInPreorderToNull();
1537             t.clearHashIdToNodeMap();
1538             showWhole();
1539         }
1540     }
1541
1542     void updateDomainStructureEvaluethresholdDisplay() {
1543         if ( _domain_structure_evalue_thr_tf != null ) {
1544             _domain_structure_evalue_thr_tf.setText( "10^"
1545                     + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1546         }
1547     }
1548
1549     void zoomInX( final float factor, final float x_correction_factor ) {
1550         final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1551         final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1552         treepanel.multiplyUrtFactor( 1f );
1553         if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1554                 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1555                 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1556                 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1557             final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1558             treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1559             treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1560             getMainPanel().adjustJScrollPane();
1561             treepanel.resetPreferredSize();
1562             getMainPanel().getCurrentScrollPane().getViewport().validate();
1563             sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1564                     - ( sb.getVisibleAmount() / 2.0 ) ) );
1565         }
1566         else {
1567             final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1568             treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1569             treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1570             getMainPanel().adjustJScrollPane();
1571             treepanel.resetPreferredSize();
1572             getMainPanel().getCurrentScrollPane().getViewport().validate();
1573             sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1574         }
1575         treepanel.resetPreferredSize();
1576         treepanel.updateOvSizes();
1577     }
1578
1579     void zoomInY( final float factor ) {
1580         final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1581         final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1582         treepanel.multiplyUrtFactor( 1.1f );
1583         final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1584         treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1585         getMainPanel().adjustJScrollPane();
1586         treepanel.resetPreferredSize();
1587         getMainPanel().getCurrentScrollPane().getViewport().validate();
1588         sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1589                 - ( sb.getVisibleAmount() / 2.0 ) ) );
1590         treepanel.resetPreferredSize();
1591         treepanel.updateOvSizes();
1592     }
1593
1594     void zoomOutX( final float factor, final float x_correction_factor ) {
1595         final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1596         treepanel.multiplyUrtFactor( 1f );
1597         if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1598             final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1599             if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1600                     || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1601                     || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1602                     || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1603                 getMainPanel().adjustJScrollPane();
1604                 treepanel.resetPreferredSize();
1605                 getMainPanel().getCurrentScrollPane().getViewport().validate();
1606                 final double x = ( sb.getMaximum() - sb.getMinimum() )
1607                         / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1608                 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1609                 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1610                 getMainPanel().adjustJScrollPane();
1611                 treepanel.resetPreferredSize();
1612                 getMainPanel().getCurrentScrollPane().getViewport().validate();
1613                 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1614                         - ( sb.getVisibleAmount() / 2.0 ) ) );
1615             }
1616             else {
1617                 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1618                 treepanel.setXdistance( treepanel.getXdistance() * factor );
1619                 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
1620                 if ( x > 0 ) {
1621                     getMainPanel().adjustJScrollPane();
1622                     treepanel.resetPreferredSize();
1623                     getMainPanel().getCurrentScrollPane().getViewport().validate();
1624                     sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1625                 }
1626             }
1627             treepanel.resetPreferredSize();
1628             treepanel.updateOvSizes();
1629         }
1630     }
1631
1632     void zoomOutY( final float factor ) {
1633         final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1634         treepanel.multiplyUrtFactor( 0.9f );
1635         if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1636             final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1637             final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1638             treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1639             getMainPanel().adjustJScrollPane();
1640             treepanel.resetPreferredSize();
1641             getMainPanel().getCurrentScrollPane().getViewport().validate();
1642             sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1643                     - ( sb.getVisibleAmount() / 2.0 ) ) );
1644             treepanel.resetPreferredSize();
1645             treepanel.updateOvSizes();
1646         }
1647     }
1648
1649     private void addClickToOption( final int which, final String title ) {
1650         _click_to_combobox.addItem( title );
1651         _click_to_names.add( title );
1652         _all_click_to_names.put( new Integer( which ), title );
1653         if ( !_configuration.isUseNativeUI() ) {
1654             _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1655             _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
1656         }
1657     }
1658
1659     /* GUILHEM_BEG */
1660     private void addSequenceRelationBlock() {
1661         final JLabel spacer = new JLabel( "" );
1662         spacer.setSize( 1, 1 );
1663         add( spacer );
1664         final JLabel mainLabel = new JLabel( "Sequence relations to display" );
1665         final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
1666         typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
1667         getSequenceRelationTypeBox().setFocusable( false );
1668         _sequence_relation_type_box.setFont( ControlPanel.js_font );
1669         if ( !_configuration.isUseNativeUI() ) {
1670             _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1671             _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
1672         }
1673         _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
1674
1675             @Override
1676             public Component getListCellRendererComponent( final JList list,
1677                                                            final Object value,
1678                                                            final int index,
1679                                                            final boolean isSelected,
1680                                                            final boolean cellHasFocus ) {
1681                 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
1682                                                                                                         value,
1683                                                                                                         index,
1684                                                                                                         isSelected,
1685                                                                                                         cellHasFocus );
1686                 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
1687                     ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
1688                             .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
1689                 }
1690                 return component;
1691             }
1692         } );
1693         final GridBagLayout gbl = new GridBagLayout();
1694         _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
1695         _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
1696         final JPanel horizGrid = new JPanel( gbl );
1697         horizGrid.setBackground( getBackground() );
1698         horizGrid.add( typeLabel );
1699         horizGrid.add( _sequence_relation_type_box );
1700         add( customizeLabel( mainLabel, getConfiguration() ) );
1701         add( horizGrid );
1702         add( getSequenceRelationBox() );
1703         if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
1704             addCheckbox( Configuration.show_relation_confidence,
1705                          _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
1706             setCheckbox( Configuration.show_relation_confidence,
1707                          _configuration.doCheckOption( Configuration.show_relation_confidence ) );
1708         }
1709     }// addSequenceRelationBlock
1710
1711     /* GUILHEM_END */
1712     private List<Boolean> getIsDrawPhylogramList() {
1713         return _draw_phylogram;
1714     }
1715
1716     private void init() {
1717         _draw_phylogram = new ArrayList<Boolean>();
1718         setSpeciesColors( new HashMap<String, Color>() );
1719         setAnnotationColors( new HashMap<String, Color>() );
1720     }
1721
1722     private boolean isDrawPhylogram( final int index ) {
1723         return getIsDrawPhylogramList().get( index );
1724     }
1725
1726     private void search0( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
1727         getSearchFoundCountsLabel0().setVisible( true );
1728         getSearchResetButton0().setEnabled( true );
1729         getSearchResetButton0().setVisible( true );
1730         String[] queries = null;
1731         List<PhylogenyNode> nodes = null;
1732         if ( query_str.indexOf( ',' ) >= 0 ) {
1733             queries = query_str.split( ",+" );
1734         }
1735         else {
1736             queries = new String[ 1 ];
1737             queries[ 0 ] = query_str.trim();
1738         }
1739         if ( ( queries != null ) && ( queries.length > 0 ) ) {
1740             nodes = new ArrayList<PhylogenyNode>();
1741             for( String query : queries ) {
1742                 if ( ForesterUtil.isEmpty( query ) ) {
1743                     continue;
1744                 }
1745                 query = query.trim();
1746                 if ( query.indexOf( '+' ) >= 0 ) {
1747                     nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
1748                                                                          tree,
1749                                                                          getOptions().isSearchCaseSensitive(),
1750                                                                          !getOptions().isMatchWholeTermsOnly(),
1751                                                                          isShowDomainArchitectures() ) );
1752                 }
1753                 else {
1754                     nodes.addAll( PhylogenyMethods.searchData( query,
1755                                                                tree,
1756                                                                getOptions().isSearchCaseSensitive(),
1757                                                                !getOptions().isMatchWholeTermsOnly(),
1758                                                                isShowDomainArchitectures() ) );
1759                 }
1760             }
1761             if ( getOptions().isInverseSearchResult() ) {
1762                 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
1763                 all.removeAll( nodes );
1764                 nodes = all;
1765             }
1766         }
1767         if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
1768             main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet<Long>() );
1769             for( final PhylogenyNode node : nodes ) {
1770                 main_panel.getCurrentTreePanel().getFoundNodes0().add( node.getId() );
1771             }
1772             setSearchFoundCountsOnLabel0( nodes.size() );
1773         }
1774         else {
1775             setSearchFoundCountsOnLabel0( 0 );
1776             searchReset0();
1777         }
1778     }
1779
1780     private void search1( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
1781         getSearchFoundCountsLabel1().setVisible( true );
1782         getSearchResetButton1().setEnabled( true );
1783         getSearchResetButton1().setVisible( true );
1784         String[] queries = null;
1785         List<PhylogenyNode> nodes = null;
1786         if ( query_str.indexOf( ',' ) >= 0 ) {
1787             queries = query_str.split( ",+" );
1788         }
1789         else {
1790             queries = new String[ 1 ];
1791             queries[ 0 ] = query_str.trim();
1792         }
1793         if ( ( queries != null ) && ( queries.length > 0 ) ) {
1794             nodes = new ArrayList<PhylogenyNode>();
1795             for( String query : queries ) {
1796                 if ( ForesterUtil.isEmpty( query ) ) {
1797                     continue;
1798                 }
1799                 query = query.trim();
1800                 if ( query.indexOf( '+' ) >= 0 ) {
1801                     nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
1802                                                                          tree,
1803                                                                          getOptions().isSearchCaseSensitive(),
1804                                                                          !getOptions().isMatchWholeTermsOnly(),
1805                                                                          isShowDomainArchitectures() ) );
1806                 }
1807                 else {
1808                     nodes.addAll( PhylogenyMethods.searchData( query,
1809                                                                tree,
1810                                                                getOptions().isSearchCaseSensitive(),
1811                                                                !getOptions().isMatchWholeTermsOnly(),
1812                                                                isShowDomainArchitectures() ) );
1813                 }
1814             }
1815             if ( getOptions().isInverseSearchResult() ) {
1816                 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
1817                 all.removeAll( nodes );
1818                 nodes = all;
1819             }
1820         }
1821         if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
1822             main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet<Long>() );
1823             for( final PhylogenyNode node : nodes ) {
1824                 main_panel.getCurrentTreePanel().getFoundNodes1().add( node.getId() );
1825             }
1826             setSearchFoundCountsOnLabel1( nodes.size() );
1827         }
1828         else {
1829             setSearchFoundCountsOnLabel1( 0 );
1830             searchReset1();
1831         }
1832     }
1833
1834     private void setDrawPhylogram( final int index, final boolean b ) {
1835         getIsDrawPhylogramList().set( index, b );
1836     }
1837
1838     private void setupClickToOptions() {
1839         final int default_option = _configuration.getDefaultDisplayClicktoOption();
1840         int selected_index = 0;
1841         int cb_index = 0;
1842         if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1843             _show_data_item = cb_index;
1844             addClickToOption( Configuration.display_node_data,
1845                               _configuration.getClickToTitle( Configuration.display_node_data ) );
1846             if ( default_option == Configuration.display_node_data ) {
1847                 selected_index = cb_index;
1848             }
1849             cb_index++;
1850         }
1851         if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1852             _collapse_cb_item = cb_index;
1853             addClickToOption( Configuration.collapse_uncollapse,
1854                               _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
1855             if ( default_option == Configuration.collapse_uncollapse ) {
1856                 selected_index = cb_index;
1857             }
1858             cb_index++;
1859         }
1860         if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1861             _reroot_cb_item = cb_index;
1862             addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1863             if ( default_option == Configuration.reroot ) {
1864                 selected_index = cb_index;
1865             }
1866             cb_index++;
1867         }
1868         if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1869             _subtree_cb_item = cb_index;
1870             addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1871             if ( default_option == Configuration.subtree ) {
1872                 selected_index = cb_index;
1873             }
1874             cb_index++;
1875         }
1876         if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1877             _swap_cb_item = cb_index;
1878             addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1879             if ( default_option == Configuration.swap ) {
1880                 selected_index = cb_index;
1881             }
1882             cb_index++;
1883         }
1884         if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
1885             _sort_descendents_item = cb_index;
1886             addClickToOption( Configuration.sort_descendents,
1887                               _configuration.getClickToTitle( Configuration.sort_descendents ) );
1888             if ( default_option == Configuration.sort_descendents ) {
1889                 selected_index = cb_index;
1890             }
1891             cb_index++;
1892         }
1893         if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1894             _color_subtree_cb_item = cb_index;
1895             addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1896             if ( default_option == Configuration.color_subtree ) {
1897                 selected_index = cb_index;
1898             }
1899             cb_index++;
1900         }
1901         if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) {
1902             _color_node_font_item = cb_index;
1903             addClickToOption( Configuration.color_node_font,
1904                               _configuration.getClickToTitle( Configuration.color_node_font ) );
1905             if ( default_option == Configuration.color_node_font ) {
1906                 selected_index = cb_index;
1907             }
1908             cb_index++;
1909         }
1910         if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1911             _open_seq_web_item = cb_index;
1912             addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1913             if ( default_option == Configuration.open_seq_web ) {
1914                 selected_index = cb_index;
1915             }
1916             cb_index++;
1917         }
1918         if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
1919             _open_pdb_item = cb_index;
1920             addClickToOption( Configuration.open_pdb_web, _configuration.getClickToTitle( Configuration.open_pdb_web ) );
1921             if ( default_option == Configuration.open_pdb_web ) {
1922                 selected_index = cb_index;
1923             }
1924             cb_index++;
1925         }
1926         if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1927             _open_tax_web_item = cb_index;
1928             addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1929             if ( default_option == Configuration.open_tax_web ) {
1930                 selected_index = cb_index;
1931             }
1932             cb_index++;
1933         }
1934         if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1935             _blast_item = cb_index;
1936             addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
1937             if ( default_option == Configuration.blast ) {
1938                 selected_index = cb_index;
1939             }
1940             cb_index++;
1941         }
1942         if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
1943             _select_nodes_item = cb_index;
1944             addClickToOption( Configuration.select_nodes, _configuration.getClickToTitle( Configuration.select_nodes ) );
1945             if ( default_option == Configuration.select_nodes ) {
1946                 selected_index = cb_index;
1947             }
1948             cb_index++;
1949         }
1950         if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
1951             _get_ext_desc_data = cb_index;
1952             if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
1953                 addClickToOption( Configuration.get_ext_desc_data, getConfiguration()
1954                         .getLabelForGetExtDescendentsData() );
1955             }
1956             else {
1957                 String s = ";";
1958                 switch ( getConfiguration().getExtDescNodeDataToReturn() ) {
1959                     case NODE_NAME:
1960                         s = "Node Names";
1961                         break;
1962                     case SEQUENCE_ACC:
1963                         s = "Sequence Accessors";
1964                         break;
1965                     case SEQUENCE_MOL_SEQ:
1966                         s = "Molecular Sequence";
1967                         break;
1968                     case SEQUENCE_MOL_SEQ_FASTA:
1969                         s = "Molecular Sequence (Fasta)";
1970                         break;
1971                     case SEQUENCE_NAME:
1972                         s = "Sequence Names";
1973                         break;
1974                     case GENE_NAME:
1975                         s = "Gene Names";
1976                         break;
1977                     case SEQUENCE_SYMBOL:
1978                         s = "Sequence Symbols";
1979                         break;
1980                     case TAXONOMY_CODE:
1981                         s = "Taxonomy Codes";
1982                         break;
1983                     case TAXONOMY_COMM0N_NAME:
1984                         s = "Taxonomy Common Names";
1985                         break;
1986                     case TAXONOMY_SCIENTIFIC_NAME:
1987                         s = "Scientific Names";
1988                         break;
1989                     case UNKNOWN:
1990                         s = "User Selected Data";
1991                         break;
1992                 }
1993                 final String label = _configuration.getClickToTitle( Configuration.get_ext_desc_data ) + " " + s;
1994                 addClickToOption( Configuration.get_ext_desc_data, label );
1995             }
1996             if ( default_option == Configuration.get_ext_desc_data ) {
1997                 selected_index = cb_index;
1998             }
1999             cb_index++;
2000         }
2001         if ( getOptions().isEditable() ) {
2002             if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
2003                 _cut_subtree_item = cb_index;
2004                 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
2005                 if ( default_option == Configuration.cut_subtree ) {
2006                     selected_index = cb_index;
2007                 }
2008                 cb_index++;
2009             }
2010             if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
2011                 _copy_subtree_item = cb_index;
2012                 addClickToOption( Configuration.copy_subtree,
2013                                   _configuration.getClickToTitle( Configuration.copy_subtree ) );
2014                 if ( default_option == Configuration.copy_subtree ) {
2015                     selected_index = cb_index;
2016                 }
2017                 cb_index++;
2018             }
2019             if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
2020                 _paste_subtree_item = cb_index;
2021                 addClickToOption( Configuration.paste_subtree,
2022                                   _configuration.getClickToTitle( Configuration.paste_subtree ) );
2023                 if ( default_option == Configuration.paste_subtree ) {
2024                     selected_index = cb_index;
2025                 }
2026                 cb_index++;
2027             }
2028             if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
2029                 _delete_node_or_subtree_item = cb_index;
2030                 addClickToOption( Configuration.delete_subtree_or_node,
2031                                   _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
2032                 if ( default_option == Configuration.delete_subtree_or_node ) {
2033                     selected_index = cb_index;
2034                 }
2035                 cb_index++;
2036             }
2037             if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
2038                 _add_new_node_item = cb_index;
2039                 addClickToOption( Configuration.add_new_node,
2040                                   _configuration.getClickToTitle( Configuration.add_new_node ) );
2041                 if ( default_option == Configuration.add_new_node ) {
2042                     selected_index = cb_index;
2043                 }
2044                 cb_index++;
2045             }
2046             if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
2047                 _edit_node_data_item = cb_index;
2048                 addClickToOption( Configuration.edit_node_data,
2049                                   _configuration.getClickToTitle( Configuration.edit_node_data ) );
2050                 if ( default_option == Configuration.edit_node_data ) {
2051                     selected_index = cb_index;
2052                 }
2053                 cb_index++;
2054             }
2055         }
2056         // Set default selection and its action
2057         _click_to_combobox.setSelectedIndex( selected_index );
2058         setClickToAction( selected_index );
2059     }
2060
2061     private void setupDisplayCheckboxes() {
2062         if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
2063             addCheckbox( Configuration.display_as_phylogram,
2064                          _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
2065             setCheckbox( Configuration.display_as_phylogram,
2066                          _configuration.doCheckOption( Configuration.display_as_phylogram ) );
2067         }
2068         if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
2069             addCheckbox( Configuration.dynamically_hide_data,
2070                          _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
2071             setCheckbox( Configuration.dynamically_hide_data,
2072                          _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
2073         }
2074         if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
2075             addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
2076             setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
2077         }
2078         if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
2079             addCheckbox( Configuration.display_internal_data,
2080                          _configuration.getDisplayTitle( Configuration.display_internal_data ) );
2081             setCheckbox( Configuration.display_internal_data,
2082                          _configuration.doCheckOption( Configuration.display_internal_data ) );
2083         }
2084         if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
2085             addCheckbox( Configuration.color_according_to_species,
2086                          _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
2087             setCheckbox( Configuration.color_according_to_species,
2088                          _configuration.doCheckOption( Configuration.color_according_to_species ) );
2089         }
2090         if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
2091             addCheckbox( Configuration.color_according_to_annotation,
2092                          _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
2093             setCheckbox( Configuration.color_according_to_annotation,
2094                          _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
2095         }
2096         if ( _configuration.doDisplayOption( Configuration.color_branches ) ) {
2097             addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) );
2098             setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) );
2099         }
2100         if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
2101             addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
2102             setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
2103         }
2104         final JLabel label = new JLabel( "Display Data:" );
2105         label.setFont( ControlPanel.jcb_bold_font );
2106         if ( !getConfiguration().isUseNativeUI() ) {
2107             label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2108         }
2109         add( label );
2110         if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
2111             addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
2112             setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
2113         }
2114         if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
2115             addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
2116             setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
2117         }
2118         if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
2119             addCheckbox( Configuration.show_taxonomy_scientific_names,
2120                          _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
2121             setCheckbox( Configuration.show_taxonomy_scientific_names,
2122                          _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
2123         }
2124         if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
2125             addCheckbox( Configuration.show_taxonomy_common_names,
2126                          _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
2127             setCheckbox( Configuration.show_taxonomy_common_names,
2128                          _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
2129         }
2130         if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
2131             addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
2132             setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
2133         }
2134         if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
2135             addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
2136             setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
2137         }
2138         if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
2139             addCheckbox( Configuration.show_seq_symbols,
2140                          _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
2141             setCheckbox( Configuration.show_seq_symbols, _configuration.doCheckOption( Configuration.show_seq_symbols ) );
2142         }
2143         if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
2144             addCheckbox( Configuration.show_sequence_acc,
2145                          _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
2146             setCheckbox( Configuration.show_sequence_acc,
2147                          _configuration.doCheckOption( Configuration.show_sequence_acc ) );
2148         }
2149         if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
2150             addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
2151             setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
2152         }
2153         if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
2154             addCheckbox( Configuration.show_binary_characters,
2155                          _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
2156             setCheckbox( Configuration.show_binary_characters,
2157                          _configuration.doCheckOption( Configuration.show_binary_characters ) );
2158         }
2159         if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
2160             addCheckbox( Configuration.show_binary_character_counts,
2161                          _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
2162             setCheckbox( Configuration.show_binary_character_counts,
2163                          _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
2164         }
2165         if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
2166             addCheckbox( Configuration.show_domain_architectures,
2167                          _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
2168             setCheckbox( Configuration.show_domain_architectures,
2169                          _configuration.doCheckOption( Configuration.show_domain_architectures ) );
2170         }
2171         if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
2172             addCheckbox( Configuration.write_confidence_values,
2173                          _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
2174             setCheckbox( Configuration.write_confidence_values,
2175                          _configuration.doCheckOption( Configuration.write_confidence_values ) );
2176         }
2177         if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
2178             addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
2179             setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
2180         }
2181         if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
2182             addCheckbox( Configuration.show_vector_data,
2183                          _configuration.getDisplayTitle( Configuration.show_vector_data ) );
2184             setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
2185         }
2186         if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
2187             addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
2188             setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
2189         }
2190         if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
2191             addCheckbox( Configuration.show_taxonomy_images,
2192                          _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
2193             setCheckbox( Configuration.show_taxonomy_images,
2194                          _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
2195         }
2196     }
2197
2198     private void setVisibilityOfDomainStrucureControls() {
2199         if ( _zoom_in_domain_structure != null ) {
2200             if ( isShowDomainArchitectures() ) {
2201                 _domain_display_label.setVisible( true );
2202                 _zoom_in_domain_structure.setVisible( true );
2203                 _zoom_out_domain_structure.setVisible( true );
2204                 _decr_domain_structure_evalue_thr.setVisible( true );
2205                 _incr_domain_structure_evalue_thr.setVisible( true );
2206                 _domain_structure_evalue_thr_tf.setVisible( true );
2207             }
2208             else {
2209                 _domain_display_label.setVisible( false );
2210                 _zoom_in_domain_structure.setVisible( false );
2211                 _zoom_out_domain_structure.setVisible( false );
2212                 _decr_domain_structure_evalue_thr.setVisible( false );
2213                 _incr_domain_structure_evalue_thr.setVisible( false );
2214                 _domain_structure_evalue_thr_tf.setVisible( false );
2215             }
2216         }
2217     }
2218
2219     static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2220         label.setFont( ControlPanel.jcb_bold_font );
2221         if ( !configuration.isUseNativeUI() ) {
2222             label.setForeground( configuration.getGuiCheckboxTextColor() );
2223             label.setBackground( configuration.getGuiBackgroundColor() );
2224         }
2225         return label;
2226     }
2227
2228     enum NodeClickAction {
2229         ADD_NEW_NODE,
2230         BLAST,
2231         COLLAPSE,
2232         COLOR_SUBTREE,
2233         COPY_SUBTREE,
2234         CUT_SUBTREE,
2235         DELETE_NODE_OR_SUBTREE,
2236         EDIT_NODE_DATA,
2237         GET_EXT_DESC_DATA,
2238         OPEN_PDB_WEB,
2239         OPEN_SEQ_WEB,
2240         OPEN_TAX_WEB,
2241         PASTE_SUBTREE,
2242         REROOT,
2243         SELECT_NODES,
2244         SHOW_DATA,
2245         SORT_DESCENDENTS,
2246         SUBTREE,
2247         SWAP,
2248         CHANGE_NODE_FONT,
2249         COLOR_NODE_FONT;
2250     }
2251 }