inprogress
[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     private int                  _change_node_font_item;
99     // The settings from the conf file
100     private final Configuration  _configuration;
101     private int                  _copy_subtree_item;
102     private int                  _cut_subtree_item;
103     private JButton              _decr_domain_structure_evalue_thr;
104     private int                  _delete_node_or_subtree_item;
105     private JCheckBox            _display_as_phylogram_cb;
106     // Tree checkboxes
107     private JCheckBox            _display_internal_data;
108     private JLabel               _domain_display_label;
109     private JTextField           _domain_structure_evalue_thr_tf;
110     private List<Boolean>        _draw_phylogram;
111     private JCheckBox            _dynamically_hide_data;
112     private int                  _edit_node_data_item;
113     private int                  _get_ext_desc_data;
114     private JButton              _incr_domain_structure_evalue_thr;
115     private final MainPanel      _mainpanel;
116     private JCheckBox            _node_desc_popup_cb;
117     private int                  _open_pdb_item;
118     private int                  _open_seq_web_item;
119     private int                  _open_tax_web_item;
120     private int                  _color_node_font_item;
121     private JButton              _order;
122     private boolean              _order_of_appearance;
123     private int                  _paste_subtree_item;
124     private int                  _reroot_cb_item;
125     private JButton              _return_to_super_tree;
126     // Search 
127     private JLabel               _search_found_label_0;
128     private JLabel               _search_found_label_1;
129     private JButton              _search_reset_button_0;
130     private JButton              _search_reset_button_1;
131     private JTextField           _search_tf_0;
132     private JTextField           _search_tf_1;
133     private int                  _select_nodes_item;
134     private Sequence             _selected_query_seq;
135     private JCheckBox            _seq_relation_confidence_switch;
136     private JComboBox            _sequence_relation_type_box;
137     private JCheckBox            _show_annotation;
138     private JCheckBox            _show_binary_character_counts;
139     private JCheckBox            _show_binary_characters;
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         if ( !ForesterUtil.isEmpty( query ) ) {
912             search0( main_panel, tree, query );
913         }
914         else {
915             getSearchFoundCountsLabel0().setVisible( false );
916             getSearchResetButton0().setEnabled( false );
917             getSearchResetButton0().setVisible( false );
918             searchReset0();
919         }
920     }
921
922     void search1() {
923         final MainPanel main_panel = getMainPanel();
924         final Phylogeny tree = main_panel.getCurrentPhylogeny();
925         if ( ( tree == null ) || tree.isEmpty() ) {
926             return;
927         }
928         String query = getSearchTextField1().getText();
929         if ( query != null ) {
930             query = query.trim();
931         }
932         if ( !ForesterUtil.isEmpty( query ) ) {
933             search1( main_panel, tree, query );
934         }
935         else {
936             getSearchFoundCountsLabel1().setVisible( false );
937             getSearchResetButton1().setEnabled( false );
938             getSearchResetButton1().setVisible( false );
939             searchReset1();
940         }
941     }
942
943     void searchReset0() {
944         if ( getMainPanel().getCurrentTreePanel() != null ) {
945             getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
946         }
947     }
948
949     void searchReset1() {
950         if ( getMainPanel().getCurrentTreePanel() != null ) {
951             getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
952         }
953     }
954
955     void setActionWhenNodeClicked( final NodeClickAction action ) {
956         _action_when_node_clicked = action;
957     }
958
959     void setAnnotationColors( final Map<String, Color> annotation_colors ) {
960         _annotation_colors = annotation_colors;
961     }
962
963     void setCheckbox( final int which, final boolean state ) {
964         switch ( which ) {
965             case Configuration.display_as_phylogram:
966                 if ( getDisplayAsPhylogramCb() != null ) {
967                     getDisplayAsPhylogramCb().setSelected( state );
968                 }
969                 break;
970             case Configuration.display_internal_data:
971                 if ( _display_internal_data != null ) {
972                     _display_internal_data.setSelected( state );
973                 }
974                 break;
975             case Configuration.color_according_to_species:
976                 if ( _color_acc_species != null ) {
977                     _color_acc_species.setSelected( state );
978                 }
979                 break;
980             case Configuration.color_according_to_annotation:
981                 if ( _color_according_to_annotation != null ) {
982                     _color_according_to_annotation.setSelected( state );
983                 }
984                 break;
985             case Configuration.show_node_names:
986                 if ( _show_node_names != null ) {
987                     _show_node_names.setSelected( state );
988                 }
989                 break;
990             case Configuration.show_taxonomy_scientific_names:
991                 if ( _show_taxo_scientific_names != null ) {
992                     _show_taxo_scientific_names.setSelected( state );
993                 }
994                 break;
995             case Configuration.show_taxonomy_common_names:
996                 if ( _show_taxo_common_names != null ) {
997                     _show_taxo_common_names.setSelected( state );
998                 }
999                 break;
1000             case Configuration.show_tax_code:
1001                 if ( _show_taxo_code != null ) {
1002                     _show_taxo_code.setSelected( state );
1003                 }
1004                 break;
1005             case Configuration.show_taxonomy_images:
1006                 if ( _show_taxo_images_cb != null ) {
1007                     _show_taxo_images_cb.setSelected( state );
1008                 }
1009                 break;
1010             case Configuration.show_annotation:
1011                 if ( _show_annotation != null ) {
1012                     _show_annotation.setSelected( state );
1013                 }
1014                 break;
1015             case Configuration.show_binary_characters:
1016                 if ( _show_binary_characters != null ) {
1017                     _show_binary_characters.setSelected( state );
1018                 }
1019                 break;
1020             case Configuration.show_binary_character_counts:
1021                 if ( _show_binary_character_counts != null ) {
1022                     _show_binary_character_counts.setSelected( state );
1023                 }
1024                 break;
1025             case Configuration.write_confidence_values:
1026                 if ( getWriteConfidenceCb() != null ) {
1027                     getWriteConfidenceCb().setSelected( state );
1028                 }
1029                 break;
1030             case Configuration.write_events:
1031                 if ( getShowEventsCb() != null ) {
1032                     getShowEventsCb().setSelected( state );
1033                 }
1034                 break;
1035             case Configuration.color_branches:
1036                 if ( getColorBranchesCb() != null ) {
1037                     getColorBranchesCb().setSelected( state );
1038                 }
1039                 break;
1040             case Configuration.width_branches:
1041                 if ( _width_branches != null ) {
1042                     _width_branches.setSelected( state );
1043                 }
1044                 break;
1045             case Configuration.show_domain_architectures:
1046                 if ( _show_domain_architectures != null ) {
1047                     _show_domain_architectures.setSelected( state );
1048                 }
1049                 break;
1050             case Configuration.show_seq_names:
1051                 if ( _show_seq_names != null ) {
1052                     _show_seq_names.setSelected( state );
1053                 }
1054                 break;
1055             case Configuration.show_gene_names:
1056                 if ( _show_gene_names != null ) {
1057                     _show_gene_names.setSelected( state );
1058                 }
1059                 break;
1060             case Configuration.show_seq_symbols:
1061                 if ( _show_seq_symbols != null ) {
1062                     _show_seq_symbols.setSelected( state );
1063                 }
1064                 break;
1065             case Configuration.show_vector_data:
1066                 if ( _show_vector_data_cb != null ) {
1067                     _show_vector_data_cb.setSelected( state );
1068                 }
1069                 break;
1070             case Configuration.show_properties:
1071                 if ( _show_properties_cb != null ) {
1072                     _show_properties_cb.setSelected( state );
1073                 }
1074                 break;
1075             case Configuration.show_sequence_acc:
1076                 if ( _show_sequence_acc != null ) {
1077                     _show_sequence_acc.setSelected( state );
1078                 }
1079                 break;
1080             case Configuration.dynamically_hide_data:
1081                 if ( getDynamicallyHideData() != null ) {
1082                     getDynamicallyHideData().setSelected( state );
1083                 }
1084                 break;
1085             case Configuration.node_data_popup:
1086                 if ( getNodeDescPopupCb() != null ) {
1087                     getNodeDescPopupCb().setSelected( state );
1088                 }
1089                 break;
1090             /* GUILHEM_BEG */
1091             case Configuration.show_relation_confidence:
1092                 if ( _seq_relation_confidence_switch != null ) {
1093                     _seq_relation_confidence_switch.setSelected( state );
1094                 }
1095                 break;
1096             /* GUILHEM_END */
1097             default:
1098                 throw new AssertionError( "unknown checkbox: " + which );
1099         }
1100     }
1101
1102     /**
1103      * Set this checkbox state. Not all checkboxes have been instantiated
1104      * depending on the config.
1105      */
1106     void setCheckbox( final JCheckBox cb, final boolean state ) {
1107         if ( cb != null ) {
1108             cb.setSelected( state );
1109         }
1110     }
1111
1112     void setClickToAction( final int action ) {
1113         // Set click-to action
1114         if ( action == _show_data_item ) {
1115             setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1116         }
1117         else if ( action == _collapse_cb_item ) {
1118             setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1119         }
1120         else if ( action == _reroot_cb_item ) {
1121             setActionWhenNodeClicked( NodeClickAction.REROOT );
1122         }
1123         else if ( action == _subtree_cb_item ) {
1124             setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1125         }
1126         else if ( action == _swap_cb_item ) {
1127             setActionWhenNodeClicked( NodeClickAction.SWAP );
1128         }
1129         else if ( action == _color_subtree_cb_item ) {
1130             setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1131         }
1132         else if ( action == _open_seq_web_item ) {
1133             setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1134         }
1135         else if ( action == _sort_descendents_item ) {
1136             setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1137         }
1138         else if ( action == _blast_item ) {
1139             setActionWhenNodeClicked( NodeClickAction.BLAST );
1140         }
1141         else if ( action == _open_tax_web_item ) {
1142             setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1143         }
1144         else if ( action == _cut_subtree_item ) {
1145             setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1146         }
1147         else if ( action == _copy_subtree_item ) {
1148             setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1149         }
1150         else if ( action == _delete_node_or_subtree_item ) {
1151             setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1152         }
1153         else if ( action == _paste_subtree_item ) {
1154             setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1155         }
1156         else if ( action == _add_new_node_item ) {
1157             setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1158         }
1159         else if ( action == _edit_node_data_item ) {
1160             setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1161         }
1162         else if ( action == _select_nodes_item ) {
1163             setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
1164         }
1165         else if ( action == _get_ext_desc_data ) {
1166             setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
1167         }
1168         else if ( action == _open_pdb_item ) {
1169             setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
1170         }
1171         else if ( action == _color_node_font_item ) {
1172             setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
1173         }
1174         else if ( action == _change_node_font_item ) {
1175             setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT );
1176         }
1177         else {
1178             throw new RuntimeException( "unknown action: " + action );
1179         }
1180         // make sure drop down is displaying the correct action
1181         // in case this was called from outside the class
1182         _click_to_combobox.setSelectedIndex( action );
1183     }
1184
1185     void setColorBranches( final boolean color_branches ) {
1186         _color_branches = color_branches;
1187     }
1188
1189     void setDrawPhylogram( final boolean b ) {
1190         getDisplayAsPhylogramCb().setSelected( b );
1191         setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1192     }
1193
1194     void setDrawPhylogramEnabled( final boolean b ) {
1195         getDisplayAsPhylogramCb().setEnabled( b );
1196     }
1197
1198     void setDynamicHidingIsOn( final boolean is_on ) {
1199         //  if ( !_configuration.isUseNativeUI() ) {
1200         if ( is_on ) {
1201             getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1202         }
1203         else {
1204             if ( !_configuration.isUseNativeUI() ) {
1205                 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1206             }
1207             else {
1208                 getDynamicallyHideData().setForeground( Color.BLACK );
1209             }
1210         }
1211         // }
1212     }
1213
1214     void setSearchFoundCountsOnLabel0( final int counts ) {
1215         getSearchFoundCountsLabel0().setText( "Found: " + counts );
1216     }
1217
1218     void setSearchFoundCountsOnLabel1( final int counts ) {
1219         getSearchFoundCountsLabel1().setText( "Found: " + counts );
1220     }
1221
1222     void setShowEvents( final boolean show_events ) {
1223         if ( getShowEventsCb() == null ) {
1224             _show_events = new JCheckBox( "" );
1225         }
1226         getShowEventsCb().setSelected( show_events );
1227     }
1228
1229     void setSpeciesColors( final Map<String, Color> species_colors ) {
1230         _species_colors = species_colors;
1231     }
1232
1233     /* GUILHEM_END */
1234     /*
1235      * Set up the controls from the config settings. 11/26/05
1236      */
1237     void setupControls() {
1238         // The tree display options:
1239         setupDisplayCheckboxes();
1240         /* GUILHEM_BEG */
1241         // The sequence relation query selection combo-box
1242         if ( _configuration.displaySequenceRelations() ) {
1243             addSequenceRelationBlock();
1244         }
1245         /* GUILHEM_END */
1246         // Click-to options
1247         startClickToOptions();
1248         setupClickToOptions();
1249         endClickToOptions();
1250         // Zoom and quick edit buttons
1251         addButtons();
1252         setupSearchTools0();
1253         setupSearchTools1();
1254     }
1255
1256     void setUpControlsForDomainStrucures() {
1257         _domain_display_label = new JLabel( "Domain Display:" );
1258         add( customizeLabel( _domain_display_label, getConfiguration() ) );
1259         add( _domain_display_label );
1260         _zoom_in_domain_structure = new JButton( "d+" );
1261         _zoom_out_domain_structure = new JButton( "d-" );
1262         _decr_domain_structure_evalue_thr = new JButton( "-" );
1263         _incr_domain_structure_evalue_thr = new JButton( "+" );
1264         _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1265         _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1266         _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1267         _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1268         _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1269         _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1270         _domain_structure_evalue_thr_tf = new JTextField( 3 );
1271         _domain_structure_evalue_thr_tf.setEditable( false );
1272         if ( !getConfiguration().isUseNativeUI() ) {
1273             _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1274             _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1275             _domain_structure_evalue_thr_tf.setBorder( null );
1276         }
1277         final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1278         final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1279         if ( !_configuration.isUseNativeUI() ) {
1280             d1_panel.setBackground( getBackground() );
1281             d2_panel.setBackground( getBackground() );
1282         }
1283         add( d1_panel );
1284         add( d2_panel );
1285         addJButton( _zoom_out_domain_structure, d1_panel );
1286         addJButton( _zoom_in_domain_structure, d1_panel );
1287         addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1288         addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1289         addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1290     }
1291
1292     void setupSearchTools0() {
1293         final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1294         final JLabel search_label = new JLabel( "Search (A):" );
1295         search_label.setFont( ControlPanel.jcb_bold_font );
1296         if ( !getConfiguration().isUseNativeUI() ) {
1297             search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1298         }
1299         add( search_label );
1300         search_label.setToolTipText( tip );
1301         _search_found_label_0 = new JLabel();
1302         getSearchFoundCountsLabel0().setVisible( false );
1303         _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
1304         if ( !getConfiguration().isUseNativeUI() ) {
1305             _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1306         }
1307         _search_tf_0 = new JTextField( 3 );
1308         _search_tf_0.setToolTipText( tip );
1309         _search_tf_0.setEditable( true );
1310         if ( !getConfiguration().isUseNativeUI() ) {
1311             _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1312             _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1313             _search_tf_0.setBorder( null );
1314         }
1315         _search_reset_button_0 = new JButton();
1316         getSearchResetButton0().setText( "Reset" );
1317         getSearchResetButton0().setEnabled( false );
1318         getSearchResetButton0().setVisible( false );
1319         final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1320         final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1321         s_panel_1.setBackground( getBackground() );
1322         add( s_panel_1 );
1323         s_panel_2.setBackground( getBackground() );
1324         add( s_panel_2 );
1325         final KeyAdapter key_adapter = new KeyAdapter() {
1326
1327             @Override
1328             public void keyReleased( final KeyEvent key_event ) {
1329                 search0();
1330                 displayedPhylogenyMightHaveChanged( true );
1331             }
1332         };
1333         final ActionListener action_listener = new ActionListener() {
1334
1335             @Override
1336             public void actionPerformed( final ActionEvent e ) {
1337                 searchReset0();
1338                 setSearchFoundCountsOnLabel0( 0 );
1339                 getSearchFoundCountsLabel0().setVisible( false );
1340                 getSearchTextField0().setText( "" );
1341                 getSearchResetButton0().setEnabled( false );
1342                 getSearchResetButton0().setVisible( false );
1343                 displayedPhylogenyMightHaveChanged( true );
1344             }
1345         };
1346         _search_reset_button_0.addActionListener( action_listener );
1347         _search_tf_0.addKeyListener( key_adapter );
1348         addJTextField( _search_tf_0, s_panel_1 );
1349         s_panel_2.add( _search_found_label_0 );
1350         addJButton( _search_reset_button_0, s_panel_2 );
1351     }
1352
1353     void setupSearchTools1() {
1354         final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1355         final JLabel search_label = new JLabel( "Search (B):" );
1356         search_label.setFont( ControlPanel.jcb_bold_font );
1357         if ( !getConfiguration().isUseNativeUI() ) {
1358             search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1359         }
1360         add( search_label );
1361         search_label.setToolTipText( tip );
1362         _search_found_label_1 = new JLabel();
1363         getSearchFoundCountsLabel1().setVisible( false );
1364         _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
1365         if ( !getConfiguration().isUseNativeUI() ) {
1366             _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1367         }
1368         _search_tf_1 = new JTextField( 3 );
1369         _search_tf_1.setToolTipText( tip );
1370         _search_tf_1.setEditable( true );
1371         if ( !getConfiguration().isUseNativeUI() ) {
1372             _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1373             _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1374             _search_tf_1.setBorder( null );
1375         }
1376         _search_reset_button_1 = new JButton();
1377         getSearchResetButton1().setText( "Reset" );
1378         getSearchResetButton1().setEnabled( false );
1379         getSearchResetButton1().setVisible( false );
1380         final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1381         final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1382         s_panel_1.setBackground( getBackground() );
1383         add( s_panel_1 );
1384         s_panel_2.setBackground( getBackground() );
1385         add( s_panel_2 );
1386         final KeyAdapter key_adapter = new KeyAdapter() {
1387
1388             @Override
1389             public void keyReleased( final KeyEvent key_event ) {
1390                 search1();
1391                 displayedPhylogenyMightHaveChanged( true );
1392             }
1393         };
1394         final ActionListener action_listener = new ActionListener() {
1395
1396             @Override
1397             public void actionPerformed( final ActionEvent e ) {
1398                 searchReset1();
1399                 setSearchFoundCountsOnLabel1( 0 );
1400                 getSearchFoundCountsLabel1().setVisible( false );
1401                 getSearchTextField1().setText( "" );
1402                 getSearchResetButton1().setEnabled( false );
1403                 getSearchResetButton1().setVisible( false );
1404                 displayedPhylogenyMightHaveChanged( true );
1405             }
1406         };
1407         _search_reset_button_1.addActionListener( action_listener );
1408         _search_tf_1.addKeyListener( key_adapter );
1409         addJTextField( _search_tf_1, s_panel_1 );
1410         s_panel_2.add( _search_found_label_1 );
1411         addJButton( _search_reset_button_1, s_panel_2 );
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.color_node_font ) ) {
1906             _color_node_font_item = cb_index;
1907             addClickToOption( Configuration.color_node_font,
1908                               _configuration.getClickToTitle( Configuration.color_node_font ) );
1909             if ( default_option == Configuration.color_node_font ) {
1910                 selected_index = cb_index;
1911             }
1912             cb_index++;
1913         }
1914         if ( _configuration.doDisplayClickToOption( Configuration.change_node_font ) ) {
1915             _change_node_font_item = cb_index;
1916             addClickToOption( Configuration.change_node_font,
1917                               _configuration.getClickToTitle( Configuration.change_node_font ) );
1918             if ( default_option == Configuration.change_node_font ) {
1919                 selected_index = cb_index;
1920             }
1921             cb_index++;
1922         }
1923         if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1924             _open_seq_web_item = cb_index;
1925             addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1926             if ( default_option == Configuration.open_seq_web ) {
1927                 selected_index = cb_index;
1928             }
1929             cb_index++;
1930         }
1931         if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
1932             _open_pdb_item = cb_index;
1933             addClickToOption( Configuration.open_pdb_web, _configuration.getClickToTitle( Configuration.open_pdb_web ) );
1934             if ( default_option == Configuration.open_pdb_web ) {
1935                 selected_index = cb_index;
1936             }
1937             cb_index++;
1938         }
1939         if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1940             _open_tax_web_item = cb_index;
1941             addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1942             if ( default_option == Configuration.open_tax_web ) {
1943                 selected_index = cb_index;
1944             }
1945             cb_index++;
1946         }
1947         if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1948             _blast_item = cb_index;
1949             addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
1950             if ( default_option == Configuration.blast ) {
1951                 selected_index = cb_index;
1952             }
1953             cb_index++;
1954         }
1955         if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
1956             _select_nodes_item = cb_index;
1957             addClickToOption( Configuration.select_nodes, _configuration.getClickToTitle( Configuration.select_nodes ) );
1958             if ( default_option == Configuration.select_nodes ) {
1959                 selected_index = cb_index;
1960             }
1961             cb_index++;
1962         }
1963         if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
1964             _get_ext_desc_data = cb_index;
1965             if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
1966                 addClickToOption( Configuration.get_ext_desc_data, getConfiguration()
1967                         .getLabelForGetExtDescendentsData() );
1968             }
1969             else {
1970                 String s = ";";
1971                 switch ( getConfiguration().getExtDescNodeDataToReturn() ) {
1972                     case NODE_NAME:
1973                         s = "Node Names";
1974                         break;
1975                     case SEQUENCE_ACC:
1976                         s = "Sequence Accessors";
1977                         break;
1978                     case SEQUENCE_MOL_SEQ:
1979                         s = "Molecular Sequence";
1980                         break;
1981                     case SEQUENCE_MOL_SEQ_FASTA:
1982                         s = "Molecular Sequence (Fasta)";
1983                         break;
1984                     case SEQUENCE_NAME:
1985                         s = "Sequence Names";
1986                         break;
1987                     case GENE_NAME:
1988                         s = "Gene Names";
1989                         break;
1990                     case SEQUENCE_SYMBOL:
1991                         s = "Sequence Symbols";
1992                         break;
1993                     case TAXONOMY_CODE:
1994                         s = "Taxonomy Codes";
1995                         break;
1996                     case TAXONOMY_COMM0N_NAME:
1997                         s = "Taxonomy Common Names";
1998                         break;
1999                     case TAXONOMY_SCIENTIFIC_NAME:
2000                         s = "Scientific Names";
2001                         break;
2002                     case UNKNOWN:
2003                         s = "User Selected Data";
2004                         break;
2005                 }
2006                 final String label = _configuration.getClickToTitle( Configuration.get_ext_desc_data ) + " " + s;
2007                 addClickToOption( Configuration.get_ext_desc_data, label );
2008             }
2009             if ( default_option == Configuration.get_ext_desc_data ) {
2010                 selected_index = cb_index;
2011             }
2012             cb_index++;
2013         }
2014         if ( getOptions().isEditable() ) {
2015             if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
2016                 _cut_subtree_item = cb_index;
2017                 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
2018                 if ( default_option == Configuration.cut_subtree ) {
2019                     selected_index = cb_index;
2020                 }
2021                 cb_index++;
2022             }
2023             if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
2024                 _copy_subtree_item = cb_index;
2025                 addClickToOption( Configuration.copy_subtree,
2026                                   _configuration.getClickToTitle( Configuration.copy_subtree ) );
2027                 if ( default_option == Configuration.copy_subtree ) {
2028                     selected_index = cb_index;
2029                 }
2030                 cb_index++;
2031             }
2032             if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
2033                 _paste_subtree_item = cb_index;
2034                 addClickToOption( Configuration.paste_subtree,
2035                                   _configuration.getClickToTitle( Configuration.paste_subtree ) );
2036                 if ( default_option == Configuration.paste_subtree ) {
2037                     selected_index = cb_index;
2038                 }
2039                 cb_index++;
2040             }
2041             if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
2042                 _delete_node_or_subtree_item = cb_index;
2043                 addClickToOption( Configuration.delete_subtree_or_node,
2044                                   _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
2045                 if ( default_option == Configuration.delete_subtree_or_node ) {
2046                     selected_index = cb_index;
2047                 }
2048                 cb_index++;
2049             }
2050             if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
2051                 _add_new_node_item = cb_index;
2052                 addClickToOption( Configuration.add_new_node,
2053                                   _configuration.getClickToTitle( Configuration.add_new_node ) );
2054                 if ( default_option == Configuration.add_new_node ) {
2055                     selected_index = cb_index;
2056                 }
2057                 cb_index++;
2058             }
2059             if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
2060                 _edit_node_data_item = cb_index;
2061                 addClickToOption( Configuration.edit_node_data,
2062                                   _configuration.getClickToTitle( Configuration.edit_node_data ) );
2063                 if ( default_option == Configuration.edit_node_data ) {
2064                     selected_index = cb_index;
2065                 }
2066                 cb_index++;
2067             }
2068         }
2069         // Set default selection and its action
2070         _click_to_combobox.setSelectedIndex( selected_index );
2071         setClickToAction( selected_index );
2072     }
2073
2074     private void setupDisplayCheckboxes() {
2075         if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
2076             addCheckbox( Configuration.display_as_phylogram,
2077                          _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
2078             setCheckbox( Configuration.display_as_phylogram,
2079                          _configuration.doCheckOption( Configuration.display_as_phylogram ) );
2080         }
2081         if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
2082             addCheckbox( Configuration.dynamically_hide_data,
2083                          _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
2084             setCheckbox( Configuration.dynamically_hide_data,
2085                          _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
2086         }
2087         if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
2088             addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
2089             setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
2090         }
2091         if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
2092             addCheckbox( Configuration.display_internal_data,
2093                          _configuration.getDisplayTitle( Configuration.display_internal_data ) );
2094             setCheckbox( Configuration.display_internal_data,
2095                          _configuration.doCheckOption( Configuration.display_internal_data ) );
2096         }
2097         if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
2098             addCheckbox( Configuration.color_according_to_species,
2099                          _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
2100             setCheckbox( Configuration.color_according_to_species,
2101                          _configuration.doCheckOption( Configuration.color_according_to_species ) );
2102         }
2103         if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
2104             addCheckbox( Configuration.color_according_to_annotation,
2105                          _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
2106             setCheckbox( Configuration.color_according_to_annotation,
2107                          _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
2108         }
2109         if ( _configuration.doDisplayOption( Configuration.color_branches ) ) {
2110             addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) );
2111             setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) );
2112         }
2113         if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
2114             addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
2115             setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
2116         }
2117         final JLabel label = new JLabel( "Display Data:" );
2118         label.setFont( ControlPanel.jcb_bold_font );
2119         if ( !getConfiguration().isUseNativeUI() ) {
2120             label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2121         }
2122         add( label );
2123         if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
2124             addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
2125             setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
2126         }
2127         if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
2128             addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
2129             setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
2130         }
2131         if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
2132             addCheckbox( Configuration.show_taxonomy_scientific_names,
2133                          _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
2134             setCheckbox( Configuration.show_taxonomy_scientific_names,
2135                          _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
2136         }
2137         if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
2138             addCheckbox( Configuration.show_taxonomy_common_names,
2139                          _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
2140             setCheckbox( Configuration.show_taxonomy_common_names,
2141                          _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
2142         }
2143         if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
2144             addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
2145             setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
2146         }
2147         if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
2148             addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
2149             setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
2150         }
2151         if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
2152             addCheckbox( Configuration.show_seq_symbols,
2153                          _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
2154             setCheckbox( Configuration.show_seq_symbols, _configuration.doCheckOption( Configuration.show_seq_symbols ) );
2155         }
2156         if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
2157             addCheckbox( Configuration.show_sequence_acc,
2158                          _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
2159             setCheckbox( Configuration.show_sequence_acc,
2160                          _configuration.doCheckOption( Configuration.show_sequence_acc ) );
2161         }
2162         if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
2163             addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
2164             setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
2165         }
2166         if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
2167             addCheckbox( Configuration.show_binary_characters,
2168                          _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
2169             setCheckbox( Configuration.show_binary_characters,
2170                          _configuration.doCheckOption( Configuration.show_binary_characters ) );
2171         }
2172         if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
2173             addCheckbox( Configuration.show_binary_character_counts,
2174                          _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
2175             setCheckbox( Configuration.show_binary_character_counts,
2176                          _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
2177         }
2178         if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
2179             addCheckbox( Configuration.show_domain_architectures,
2180                          _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
2181             setCheckbox( Configuration.show_domain_architectures,
2182                          _configuration.doCheckOption( Configuration.show_domain_architectures ) );
2183         }
2184         if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
2185             addCheckbox( Configuration.write_confidence_values,
2186                          _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
2187             setCheckbox( Configuration.write_confidence_values,
2188                          _configuration.doCheckOption( Configuration.write_confidence_values ) );
2189         }
2190         if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
2191             addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
2192             setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
2193         }
2194         if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
2195             addCheckbox( Configuration.show_vector_data,
2196                          _configuration.getDisplayTitle( Configuration.show_vector_data ) );
2197             setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
2198         }
2199         if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
2200             addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
2201             setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
2202         }
2203         if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
2204             addCheckbox( Configuration.show_taxonomy_images,
2205                          _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
2206             setCheckbox( Configuration.show_taxonomy_images,
2207                          _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
2208         }
2209     }
2210
2211     private void setVisibilityOfDomainStrucureControls() {
2212         if ( _zoom_in_domain_structure != null ) {
2213             if ( isShowDomainArchitectures() ) {
2214                 _domain_display_label.setVisible( true );
2215                 _zoom_in_domain_structure.setVisible( true );
2216                 _zoom_out_domain_structure.setVisible( true );
2217                 _decr_domain_structure_evalue_thr.setVisible( true );
2218                 _incr_domain_structure_evalue_thr.setVisible( true );
2219                 _domain_structure_evalue_thr_tf.setVisible( true );
2220             }
2221             else {
2222                 _domain_display_label.setVisible( false );
2223                 _zoom_in_domain_structure.setVisible( false );
2224                 _zoom_out_domain_structure.setVisible( false );
2225                 _decr_domain_structure_evalue_thr.setVisible( false );
2226                 _incr_domain_structure_evalue_thr.setVisible( false );
2227                 _domain_structure_evalue_thr_tf.setVisible( false );
2228             }
2229         }
2230     }
2231
2232     static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2233         label.setFont( ControlPanel.jcb_bold_font );
2234         if ( !configuration.isUseNativeUI() ) {
2235             label.setForeground( configuration.getGuiCheckboxTextColor() );
2236             label.setBackground( configuration.getGuiBackgroundColor() );
2237         }
2238         return label;
2239     }
2240
2241     enum NodeClickAction {
2242         ADD_NEW_NODE,
2243         BLAST,
2244         COLLAPSE,
2245         COLOR_SUBTREE,
2246         COPY_SUBTREE,
2247         CUT_SUBTREE,
2248         DELETE_NODE_OR_SUBTREE,
2249         EDIT_NODE_DATA,
2250         GET_EXT_DESC_DATA,
2251         OPEN_PDB_WEB,
2252         OPEN_SEQ_WEB,
2253         OPEN_TAX_WEB,
2254         PASTE_SUBTREE,
2255         REROOT,
2256         SELECT_NODES,
2257         SHOW_DATA,
2258         SORT_DESCENDENTS,
2259         SUBTREE,
2260         SWAP,
2261         CHANGE_NODE_FONT,
2262         COLOR_NODE_FONT;
2263     }
2264 }