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