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