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