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