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