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