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