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