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