2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
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.
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.
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
22 // Contact: phylosoft @ gmail . com
23 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
25 package org.forester.archaeopteryx;
27 import java.awt.BorderLayout;
28 import java.awt.Color;
29 import java.awt.Component;
30 import java.awt.Dimension;
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;
48 import javax.swing.BorderFactory;
49 import javax.swing.DefaultListCellRenderer;
50 import javax.swing.JButton;
51 import javax.swing.JCheckBox;
52 import javax.swing.JComboBox;
53 import javax.swing.JLabel;
54 import javax.swing.JList;
55 import javax.swing.JPanel;
56 import javax.swing.JScrollBar;
57 import javax.swing.JTextField;
58 import javax.swing.ListCellRenderer;
60 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
61 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
62 import org.forester.phylogeny.Phylogeny;
63 import org.forester.phylogeny.PhylogenyMethods;
64 import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
65 import org.forester.phylogeny.PhylogenyNode;
66 import org.forester.phylogeny.data.Sequence;
67 import org.forester.phylogeny.data.SequenceRelation;
68 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
69 import org.forester.util.ForesterUtil;
71 final class ControlPanel extends JPanel implements ActionListener {
73 final static Font jcb_bold_font = new Font( Configuration.getDefaultFontFamilyName(),
76 final static Font jcb_font = new Font( Configuration.getDefaultFontFamilyName(),
79 final static Font js_font = new Font( Configuration.getDefaultFontFamilyName(),
82 private static final String RETURN_TO_SUPER_TREE_TEXT = "Back to Super Tree";
83 private static final long serialVersionUID = -8463483932821545633L;
84 private NodeClickAction _action_when_node_clicked;
85 private int _add_new_node_item;
86 private Map<Integer, String> _all_click_to_names;
87 private Map<String, Color> _annotation_colors;
88 private int _blast_item;
89 private JComboBox _click_to_combobox;
90 private JLabel _click_to_label;
91 private List<String> _click_to_names;
92 private int _collapse_cb_item;
93 private JCheckBox _color_acc_species;
94 private JCheckBox _color_according_to_annotation;
95 private boolean _color_branches;
96 private JCheckBox _color_branches_cb;
97 private int _color_subtree_cb_item;
98 // The settings from the conf file
99 private final Configuration _configuration;
100 private int _copy_subtree_item;
101 private int _cut_subtree_item;
102 private JButton _decr_domain_structure_evalue_thr;
103 private int _delete_node_or_subtree_item;
104 private JCheckBox _display_as_phylogram_cb;
106 private JCheckBox _display_internal_data;
107 private JLabel _domain_display_label;
108 private JTextField _domain_structure_evalue_thr_tf;
109 private List<Boolean> _draw_phylogram;
110 private JCheckBox _dynamically_hide_data;
111 private int _edit_node_data_item;
112 private int _get_ext_desc_data;
113 private JButton _incr_domain_structure_evalue_thr;
114 private final MainPanel _mainpanel;
115 private JCheckBox _node_desc_popup_cb;
116 private int _open_pdb_item;
117 private int _open_seq_web_item;
118 private int _open_tax_web_item;
119 private JButton _order;
120 private boolean _order_of_appearance;
121 private int _paste_subtree_item;
122 private int _reroot_cb_item;
123 private JButton _return_to_super_tree;
125 private JLabel _search_found_label_0;
126 private JLabel _search_found_label_1;
127 private JButton _search_reset_button_0;
128 private JButton _search_reset_button_1;
129 private JTextField _search_tf_0;
130 private JTextField _search_tf_1;
131 private int _select_nodes_item;
132 private Sequence _selected_query_seq;
133 private JCheckBox _seq_relation_confidence_switch;
134 private JComboBox _sequence_relation_type_box;
135 private JCheckBox _show_annotation;
136 private JCheckBox _show_binary_character_counts;
137 private JCheckBox _show_binary_characters;
138 // Indices for the click-to options in the combo box
139 private int _show_data_item;
140 private JCheckBox _show_domain_architectures;
141 private JCheckBox _show_events;
142 private JCheckBox _show_gene_names;
143 private JCheckBox _show_node_names;
144 private JCheckBox _show_properties_cb;
145 private JCheckBox _show_seq_names;
146 private JCheckBox _show_seq_symbols;
147 private JCheckBox _show_sequence_acc;
148 private JComboBox _show_sequence_relations;
149 private JCheckBox _show_taxo_code;
150 private JCheckBox _show_taxo_common_names;
151 private JCheckBox _show_taxo_images_cb;
152 private JCheckBox _show_taxo_scientific_names;
153 private JCheckBox _show_vector_data_cb;
154 private JButton _show_whole;
155 private int _sort_descendents_item;
156 private Map<String, Color> _species_colors;
157 private int _subtree_cb_item;
158 private int _swap_cb_item;
159 private JButton _uncollapse_all;
160 private JCheckBox _width_branches;
161 private JCheckBox _write_confidence;
162 private JButton _zoom_in_domain_structure;
163 // zooming and quick tree manipulation buttons:
164 private JButton _zoom_in_x;
165 private JButton _zoom_in_y;
166 private JLabel _zoom_label;
167 private JButton _zoom_out_domain_structure;
168 private JButton _zoom_out_x;
169 private JButton _zoom_out_y;
171 ControlPanel( final MainPanel ap, final Configuration configuration ) {
174 _configuration = configuration;
175 if ( !_configuration.isUseNativeUI() ) {
176 setBackground( getConfiguration().getGuiBackgroundColor() );
177 setBorder( BorderFactory.createRaisedBevelBorder() );
179 setLayout( new GridLayout( 0, 1, 2, 2 ) );
180 _order_of_appearance = true;
188 public void actionPerformed( final ActionEvent e ) {
190 final TreePanel tp = getMainPanel().getCurrentTreePanel();
194 if ( e.getSource() == _click_to_combobox ) {
195 setClickToAction( _click_to_combobox.getSelectedIndex() );
196 getCurrentTreePanel().repaint();
198 else if ( e.getSource() == _show_binary_characters ) {
199 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
200 _show_binary_character_counts.setSelected( false );
202 displayedPhylogenyMightHaveChanged( true );
204 else if ( e.getSource() == _show_binary_character_counts ) {
205 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
206 _show_binary_characters.setSelected( false );
208 displayedPhylogenyMightHaveChanged( true );
210 else if ( e.getSource() == _show_domain_architectures ) {
213 displayedPhylogenyMightHaveChanged( true );
215 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
216 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
217 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
221 else if ( e.getSource() == _zoom_in_x ) {
222 zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
223 displayedPhylogenyMightHaveChanged( false );
225 else if ( e.getSource() == _zoom_in_y ) {
226 zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR );
227 displayedPhylogenyMightHaveChanged( false );
229 else if ( e.getSource() == _zoom_out_x ) {
230 zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
231 displayedPhylogenyMightHaveChanged( false );
233 else if ( e.getSource() == _zoom_out_y ) {
234 zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR );
235 displayedPhylogenyMightHaveChanged( false );
237 else if ( e.getSource() == _show_whole ) {
240 else if ( e.getSource() == _return_to_super_tree ) {
241 _mainpanel.getCurrentTreePanel().superTree();
244 else if ( e.getSource() == _order ) {
245 DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
246 if ( ( !isShowTaxonomyScientificNames() && !isShowTaxonomyCode() && !isShowTaxonomyCommonNames() ) ) {
247 if ( ( isShowSequenceAcc() || isShowSeqNames() || isShowSeqSymbols() ) ) {
248 pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
250 else if ( isShowNodeNames() ) {
251 pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
254 PhylogenyMethods.orderAppearance( tp.getPhylogeny().getRoot(), _order_of_appearance, true, pri );
255 _order_of_appearance = !_order_of_appearance;
256 tp.setNodeInPreorderToNull();
257 tp.getPhylogeny().externalNodesHaveChanged();
258 tp.getPhylogeny().clearHashIdToNodeMap();
259 tp.getPhylogeny().recalculateNumberOfExternalDescendants( true );
260 tp.resetNodeIdToDistToLeafMap();
261 tp.setEdited( true );
262 displayedPhylogenyMightHaveChanged( false );
264 else if ( e.getSource() == _uncollapse_all ) {
266 displayedPhylogenyMightHaveChanged( false );
268 else if ( e.getSource() == _zoom_in_domain_structure ) {
269 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
270 displayedPhylogenyMightHaveChanged( true );
272 else if ( e.getSource() == _zoom_out_domain_structure ) {
273 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
274 displayedPhylogenyMightHaveChanged( true );
276 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
277 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThreshold();
278 displayedPhylogenyMightHaveChanged( true );
280 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
281 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThreshold();
282 displayedPhylogenyMightHaveChanged( true );
284 else if ( e.getSource() == _search_tf_0 ) {
286 displayedPhylogenyMightHaveChanged( true );
288 else if ( e.getSource() == _search_tf_1 ) {
290 displayedPhylogenyMightHaveChanged( true );
293 displayedPhylogenyMightHaveChanged( true );
297 tp.requestFocusInWindow();
300 catch ( final Exception ex ) {
301 AptxUtil.unexpectedException( ex );
303 catch ( final Error err ) {
304 AptxUtil.unexpectedError( err );
308 public JCheckBox getColorAccSpeciesCb() {
309 return _color_acc_species;
312 public JCheckBox getColorBranchesCb() {
313 return _color_branches_cb;
316 public JCheckBox getDisplayAsPhylogramCb() {
317 return _display_as_phylogram_cb;
320 public JCheckBox getDynamicallyHideData() {
321 return _dynamically_hide_data;
324 public JCheckBox getNodeDescPopupCb() {
325 return _node_desc_popup_cb;
328 public Sequence getSelectedQuerySequence() {
329 return _selected_query_seq;
332 public JComboBox getSequenceRelationBox() {
333 if ( _show_sequence_relations == null ) {
334 _show_sequence_relations = new JComboBox();
335 _show_sequence_relations.setFocusable( false );
336 _show_sequence_relations.setMaximumRowCount( 20 );
337 _show_sequence_relations.setFont( ControlPanel.js_font );
338 if ( !_configuration.isUseNativeUI() ) {
339 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
340 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
342 _show_sequence_relations.addItem( "-----" );
343 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
345 return _show_sequence_relations;
349 public JComboBox getSequenceRelationTypeBox() {
350 if ( _sequence_relation_type_box == null ) {
351 _sequence_relation_type_box = new JComboBox();
352 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
353 _sequence_relation_type_box.addItem( type );
355 _sequence_relation_type_box.addActionListener( new ActionListener() {
358 public void actionPerformed( final ActionEvent e ) {
359 if ( _mainpanel.getCurrentPhylogeny() != null ) {
360 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
365 return _sequence_relation_type_box;
368 public JCheckBox getShowEventsCb() {
372 public JCheckBox getWriteConfidenceCb() {
373 return _write_confidence;
376 public boolean isShowProperties() {
377 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
380 public boolean isShowTaxonomyImages() {
381 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
384 public boolean isShowVectorData() {
385 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
388 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
389 final JComboBox box = getSequenceRelationBox();
390 while ( box.getItemCount() > 1 ) {
391 box.removeItemAt( 1 );
393 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
394 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
396 if ( relationType == null ) {
399 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
400 for( final Sequence seq : sequenceRelationQueries ) {
401 if ( seq.hasSequenceRelations() ) {
402 boolean fFoundForCurrentType = false;
403 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
404 if ( sq.getType().equals( relationType ) ) {
405 fFoundForCurrentType = true;
409 if ( fFoundForCurrentType ) {
410 sequenceNamesToAdd.add( seq.getName() );
411 sequencesByName.put( seq.getName(), seq );
415 // sort sequences by name before adding them to the combo
416 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
417 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
418 for( final String seqName : sequenceNameArray ) {
419 box.addItem( seqName );
421 for( final ItemListener oldItemListener : box.getItemListeners() ) {
422 box.removeItemListener( oldItemListener );
424 box.addItemListener( new ItemListener() {
427 public void itemStateChanged( final ItemEvent e ) {
428 _selected_query_seq = sequencesByName.get( e.getItem() );
429 _mainpanel.getCurrentTreePanel().repaint();
434 void activateButtonToReturnToSuperTree( int index ) {
437 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
440 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
442 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
443 _return_to_super_tree.setEnabled( true );
447 * Add zoom and quick edit buttons. (Last modified 8/9/04)
450 final JLabel spacer = new JLabel( "" );
451 spacer.setOpaque( false );
453 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
454 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
455 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
456 if ( !getConfiguration().isUseNativeUI() ) {
457 x_panel.setBackground( getBackground() );
458 y_panel.setBackground( getBackground() );
459 z_panel.setBackground( getBackground() );
461 add( _zoom_label = new JLabel( "Zoom:" ) );
462 customizeLabel( _zoom_label, getConfiguration() );
466 if ( getConfiguration().isUseNativeUI() ) {
467 _zoom_in_x = new JButton( "+" );
468 _zoom_out_x = new JButton( "-" );
471 _zoom_in_x = new JButton( "X+" );
472 _zoom_out_x = new JButton( "X-" );
474 _zoom_in_y = new JButton( "Y+" );
475 _zoom_out_y = new JButton( "Y-" );
476 _show_whole = new JButton( "F" );
477 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [F or Home]" );
478 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+cursor-right]" );
479 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+cursor-up]" );
480 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+cursor-left]" );
481 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+cursor-down]" );
482 if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) {
483 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
484 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
487 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
488 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
490 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
491 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
492 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
493 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
494 _return_to_super_tree.setEnabled( false );
495 _order = new JButton( "Order Subtrees" );
496 _uncollapse_all = new JButton( "Uncollapse All" );
497 addJButton( _zoom_in_y, x_panel );
498 addJButton( _zoom_out_x, y_panel );
499 addJButton( _show_whole, y_panel );
500 addJButton( _zoom_in_x, y_panel );
501 addJButton( _zoom_out_y, z_panel );
502 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
503 setUpControlsForDomainStrucures();
505 final JLabel spacer2 = new JLabel( "" );
507 addJButton( _return_to_super_tree, this );
508 addJButton( _order, this );
509 addJButton( _uncollapse_all, this );
510 final JLabel spacer3 = new JLabel( "" );
512 setVisibilityOfDomainStrucureControls();
515 void addCheckbox( final int which, final String title ) {
516 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
518 case Configuration.display_as_phylogram:
519 _display_as_phylogram_cb = new JCheckBox( title );
520 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
521 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
524 case Configuration.display_internal_data:
525 _display_internal_data = new JCheckBox( title );
526 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
527 addJCheckBox( _display_internal_data, ch_panel );
530 case Configuration.color_according_to_species:
531 _color_acc_species = new JCheckBox( title );
533 .setToolTipText( "To colorize taxonomy and sequence labels as a function of taxonomy" );
534 addJCheckBox( _color_acc_species, ch_panel );
537 case Configuration.color_according_to_annotation:
538 _color_according_to_annotation = new JCheckBox( title );
539 _color_according_to_annotation
540 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
541 addJCheckBox( _color_according_to_annotation, ch_panel );
544 case Configuration.show_node_names:
545 _show_node_names = new JCheckBox( title );
546 addJCheckBox( _show_node_names, ch_panel );
549 case Configuration.show_taxonomy_scientific_names:
550 _show_taxo_scientific_names = new JCheckBox( title );
551 addJCheckBox( _show_taxo_scientific_names, ch_panel );
554 case Configuration.show_taxonomy_common_names:
555 _show_taxo_common_names = new JCheckBox( title );
556 addJCheckBox( _show_taxo_common_names, ch_panel );
559 case Configuration.show_tax_code:
560 _show_taxo_code = new JCheckBox( title );
561 addJCheckBox( _show_taxo_code, ch_panel );
564 case Configuration.show_taxonomy_images:
565 _show_taxo_images_cb = new JCheckBox( title );
566 addJCheckBox( _show_taxo_images_cb, ch_panel );
569 case Configuration.show_binary_characters:
570 _show_binary_characters = new JCheckBox( title );
571 addJCheckBox( _show_binary_characters, ch_panel );
574 case Configuration.show_annotation:
575 _show_annotation = new JCheckBox( title );
576 addJCheckBox( _show_annotation, ch_panel );
579 case Configuration.show_binary_character_counts:
580 _show_binary_character_counts = new JCheckBox( title );
581 addJCheckBox( _show_binary_character_counts, ch_panel );
584 case Configuration.write_confidence_values:
585 _write_confidence = new JCheckBox( title );
586 addJCheckBox( getWriteConfidenceCb(), ch_panel );
589 case Configuration.write_events:
590 _show_events = new JCheckBox( title );
591 addJCheckBox( getShowEventsCb(), ch_panel );
594 case Configuration.color_branches:
595 _color_branches_cb = new JCheckBox( title );
596 getColorBranchesCb().setToolTipText( "To use branch color values, if present" );
597 addJCheckBox( getColorBranchesCb(), ch_panel );
600 case Configuration.width_branches:
601 _width_branches = new JCheckBox( title );
602 _width_branches.setToolTipText( "To use branch width values, if present" );
603 addJCheckBox( _width_branches, ch_panel );
606 case Configuration.show_domain_architectures:
607 _show_domain_architectures = new JCheckBox( title );
608 addJCheckBox( _show_domain_architectures, ch_panel );
611 case Configuration.show_seq_names:
612 _show_seq_names = new JCheckBox( title );
613 addJCheckBox( _show_seq_names, ch_panel );
616 case Configuration.show_gene_names:
617 _show_gene_names = new JCheckBox( title );
618 addJCheckBox( _show_gene_names, ch_panel );
621 case Configuration.show_seq_symbols:
622 _show_seq_symbols = new JCheckBox( title );
623 addJCheckBox( _show_seq_symbols, ch_panel );
626 case Configuration.show_sequence_acc:
627 _show_sequence_acc = new JCheckBox( title );
628 addJCheckBox( _show_sequence_acc, ch_panel );
631 case Configuration.dynamically_hide_data:
632 _dynamically_hide_data = new JCheckBox( title );
633 getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" );
634 addJCheckBox( getDynamicallyHideData(), ch_panel );
637 case Configuration.node_data_popup:
638 _node_desc_popup_cb = new JCheckBox( title );
639 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
640 addJCheckBox( getNodeDescPopupCb(), ch_panel );
643 case Configuration.show_relation_confidence:
644 _seq_relation_confidence_switch = new JCheckBox( title );
645 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
648 case Configuration.show_vector_data:
649 _show_vector_data_cb = new JCheckBox( title );
650 addJCheckBox( _show_vector_data_cb, ch_panel );
653 case Configuration.show_properties:
654 _show_properties_cb = new JCheckBox( title );
655 addJCheckBox( _show_properties_cb, ch_panel );
659 throw new RuntimeException( "unknown checkbox: " + which );
663 void addJButton( final JButton jb, final JPanel p ) {
664 jb.setFocusPainted( false );
665 jb.setFont( ControlPanel.jcb_font );
666 if ( !_configuration.isUseNativeUI() ) {
667 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
668 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
669 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
672 jb.addActionListener( this );
675 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
676 jcb.setFocusPainted( false );
677 jcb.setFont( ControlPanel.jcb_font );
678 if ( !_configuration.isUseNativeUI() ) {
679 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
680 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
682 p.add( jcb, "Center" );
683 jcb.addActionListener( this );
686 void addJTextField( final JTextField tf, final JPanel p ) {
687 if ( !_configuration.isUseNativeUI() ) {
688 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
689 tf.setFont( ControlPanel.jcb_font );
692 tf.addActionListener( this );
695 void deactivateButtonToReturnToSuperTree() {
696 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
697 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
698 _return_to_super_tree.setEnabled( false );
701 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
702 if ( ( _mainpanel != null )
703 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
704 if ( getOptions().isShowOverview() ) {
705 _mainpanel.getCurrentTreePanel().updateOvSizes();
707 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
708 setVisibilityOfDomainStrucureControls();
709 updateDomainStructureEvaluethresholdDisplay();
710 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
711 _mainpanel.getCurrentTreePanel().calcMaxDepth();
712 _mainpanel.adjustJScrollPane();
713 if ( recalc_longest_ext_node_info ) {
714 _mainpanel.getCurrentTreePanel().initNodeData();
715 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
717 _mainpanel.getCurrentTreePanel().repaint();
718 // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
722 void endClickToOptions() {
723 _click_to_combobox.addActionListener( this );
727 * Indicates what action should be execute when a node is clicked
729 * @return the click-on action
731 NodeClickAction getActionWhenNodeClicked() {
732 return _action_when_node_clicked;
735 Map<Integer, String> getAllClickToItems() {
736 return _all_click_to_names;
739 Map<String, Color> getAnnotationColors() {
740 return _annotation_colors;
743 Configuration getConfiguration() {
744 return _configuration;
747 TreePanel getCurrentTreePanel() {
748 return getMainPanel().getCurrentTreePanel();
751 MainPanel getMainPanel() {
755 Options getOptions() {
756 return getMainPanel().getOptions();
759 JLabel getSearchFoundCountsLabel0() {
760 return _search_found_label_0;
763 JLabel getSearchFoundCountsLabel1() {
764 return _search_found_label_1;
767 JButton getSearchResetButton0() {
768 return _search_reset_button_0;
771 JButton getSearchResetButton1() {
772 return _search_reset_button_1;
775 JTextField getSearchTextField0() {
779 JTextField getSearchTextField1() {
783 List<String> getSingleClickToNames() {
784 return _click_to_names;
787 Map<String, Color> getSpeciesColors() {
788 return _species_colors;
791 boolean isAntialiasScreenText() {
795 boolean isColorAccordingToAnnotation() {
796 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
799 boolean isColorAccordingToTaxonomy() {
800 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
803 boolean isColorBranches() {
804 return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) );
807 boolean isDrawPhylogram() {
808 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
811 boolean isDynamicallyHideData() {
812 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
816 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
819 boolean isNodeDescPopup() {
820 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
823 boolean isShowAnnotation() {
824 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
827 boolean isShowBinaryCharacterCounts() {
828 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
831 boolean isShowBinaryCharacters() {
832 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
835 boolean isShowConfidenceValues() {
836 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
839 boolean isShowDomainArchitectures() {
840 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
843 boolean isShowGeneNames() {
844 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
847 boolean isShowInternalData() {
848 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
851 boolean isShowNodeNames() {
852 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
855 boolean isShowSeqNames() {
856 return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
859 boolean isShowSeqSymbols() {
860 return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
863 boolean isShowSequenceAcc() {
864 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
867 boolean isShowSequenceRelationConfidence() {
868 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
871 boolean isShowSequenceRelations() {
872 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
875 boolean isShowTaxonomyCode() {
876 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
879 boolean isShowTaxonomyCommonNames() {
880 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
883 boolean isShowTaxonomyScientificNames() {
884 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
887 boolean isWidthBranches() {
888 return ( ( _width_branches != null ) && _width_branches.isSelected() );
891 void phylogenyAdded( final Configuration configuration ) {
892 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
895 void phylogenyRemoved( final int index ) {
896 getIsDrawPhylogramList().remove( index );
900 final MainPanel main_panel = getMainPanel();
901 final Phylogeny tree = main_panel.getCurrentPhylogeny();
902 if ( ( tree == null ) || tree.isEmpty() ) {
905 String query = getSearchTextField0().getText();
906 if ( query != null ) {
907 query = query.trim();
909 if ( !ForesterUtil.isEmpty( query ) ) {
910 search0( main_panel, tree, query );
913 getSearchFoundCountsLabel0().setVisible( false );
914 getSearchResetButton0().setEnabled( false );
915 getSearchResetButton0().setVisible( false );
921 final MainPanel main_panel = getMainPanel();
922 final Phylogeny tree = main_panel.getCurrentPhylogeny();
923 if ( ( tree == null ) || tree.isEmpty() ) {
926 String query = getSearchTextField1().getText();
927 if ( query != null ) {
928 query = query.trim();
930 if ( !ForesterUtil.isEmpty( query ) ) {
931 search1( main_panel, tree, query );
934 getSearchFoundCountsLabel1().setVisible( false );
935 getSearchResetButton1().setEnabled( false );
936 getSearchResetButton1().setVisible( false );
941 void searchReset0() {
942 if ( getMainPanel().getCurrentTreePanel() != null ) {
943 getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
947 void searchReset1() {
948 if ( getMainPanel().getCurrentTreePanel() != null ) {
949 getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
953 void setActionWhenNodeClicked( final NodeClickAction action ) {
954 _action_when_node_clicked = action;
957 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
958 _annotation_colors = annotation_colors;
961 void setCheckbox( final int which, final boolean state ) {
963 case Configuration.display_as_phylogram:
964 if ( getDisplayAsPhylogramCb() != null ) {
965 getDisplayAsPhylogramCb().setSelected( state );
968 case Configuration.display_internal_data:
969 if ( _display_internal_data != null ) {
970 _display_internal_data.setSelected( state );
973 case Configuration.color_according_to_species:
974 if ( _color_acc_species != null ) {
975 _color_acc_species.setSelected( state );
978 case Configuration.color_according_to_annotation:
979 if ( _color_according_to_annotation != null ) {
980 _color_according_to_annotation.setSelected( state );
983 case Configuration.show_node_names:
984 if ( _show_node_names != null ) {
985 _show_node_names.setSelected( state );
988 case Configuration.show_taxonomy_scientific_names:
989 if ( _show_taxo_scientific_names != null ) {
990 _show_taxo_scientific_names.setSelected( state );
993 case Configuration.show_taxonomy_common_names:
994 if ( _show_taxo_common_names != null ) {
995 _show_taxo_common_names.setSelected( state );
998 case Configuration.show_tax_code:
999 if ( _show_taxo_code != null ) {
1000 _show_taxo_code.setSelected( state );
1003 case Configuration.show_taxonomy_images:
1004 if ( _show_taxo_images_cb != null ) {
1005 _show_taxo_images_cb.setSelected( state );
1008 case Configuration.show_annotation:
1009 if ( _show_annotation != null ) {
1010 _show_annotation.setSelected( state );
1013 case Configuration.show_binary_characters:
1014 if ( _show_binary_characters != null ) {
1015 _show_binary_characters.setSelected( state );
1018 case Configuration.show_binary_character_counts:
1019 if ( _show_binary_character_counts != null ) {
1020 _show_binary_character_counts.setSelected( state );
1023 case Configuration.write_confidence_values:
1024 if ( getWriteConfidenceCb() != null ) {
1025 getWriteConfidenceCb().setSelected( state );
1028 case Configuration.write_events:
1029 if ( getShowEventsCb() != null ) {
1030 getShowEventsCb().setSelected( state );
1033 case Configuration.color_branches:
1034 if ( getColorBranchesCb() != null ) {
1035 getColorBranchesCb().setSelected( state );
1038 case Configuration.width_branches:
1039 if ( _width_branches != null ) {
1040 _width_branches.setSelected( state );
1043 case Configuration.show_domain_architectures:
1044 if ( _show_domain_architectures != null ) {
1045 _show_domain_architectures.setSelected( state );
1048 case Configuration.show_seq_names:
1049 if ( _show_seq_names != null ) {
1050 _show_seq_names.setSelected( state );
1053 case Configuration.show_gene_names:
1054 if ( _show_gene_names != null ) {
1055 _show_gene_names.setSelected( state );
1058 case Configuration.show_seq_symbols:
1059 if ( _show_seq_symbols != null ) {
1060 _show_seq_symbols.setSelected( state );
1063 case Configuration.show_vector_data:
1064 if ( _show_vector_data_cb != null ) {
1065 _show_vector_data_cb.setSelected( state );
1068 case Configuration.show_properties:
1069 if ( _show_properties_cb != null ) {
1070 _show_properties_cb.setSelected( state );
1073 case Configuration.show_sequence_acc:
1074 if ( _show_sequence_acc != null ) {
1075 _show_sequence_acc.setSelected( state );
1078 case Configuration.dynamically_hide_data:
1079 if ( getDynamicallyHideData() != null ) {
1080 getDynamicallyHideData().setSelected( state );
1083 case Configuration.node_data_popup:
1084 if ( getNodeDescPopupCb() != null ) {
1085 getNodeDescPopupCb().setSelected( state );
1089 case Configuration.show_relation_confidence:
1090 if ( _seq_relation_confidence_switch != null ) {
1091 _seq_relation_confidence_switch.setSelected( state );
1096 throw new AssertionError( "unknown checkbox: " + which );
1101 * Set this checkbox state. Not all checkboxes have been instantiated
1102 * depending on the config.
1104 void setCheckbox( final JCheckBox cb, final boolean state ) {
1106 cb.setSelected( state );
1110 void setClickToAction( final int action ) {
1111 // Set click-to action
1112 if ( action == _show_data_item ) {
1113 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1115 else if ( action == _collapse_cb_item ) {
1116 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1118 else if ( action == _reroot_cb_item ) {
1119 setActionWhenNodeClicked( NodeClickAction.REROOT );
1121 else if ( action == _subtree_cb_item ) {
1122 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1124 else if ( action == _swap_cb_item ) {
1125 setActionWhenNodeClicked( NodeClickAction.SWAP );
1127 else if ( action == _color_subtree_cb_item ) {
1128 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1130 else if ( action == _open_seq_web_item ) {
1131 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1133 else if ( action == _sort_descendents_item ) {
1134 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1136 else if ( action == _blast_item ) {
1137 setActionWhenNodeClicked( NodeClickAction.BLAST );
1139 else if ( action == _open_tax_web_item ) {
1140 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1142 else if ( action == _cut_subtree_item ) {
1143 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1145 else if ( action == _copy_subtree_item ) {
1146 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1148 else if ( action == _delete_node_or_subtree_item ) {
1149 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1151 else if ( action == _paste_subtree_item ) {
1152 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1154 else if ( action == _add_new_node_item ) {
1155 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1157 else if ( action == _edit_node_data_item ) {
1158 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1160 else if ( action == _select_nodes_item ) {
1161 setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
1163 else if ( action == _get_ext_desc_data ) {
1164 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
1166 else if ( action == _open_pdb_item ) {
1167 setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
1170 throw new RuntimeException( "unknown action: " + action );
1172 // make sure drop down is displaying the correct action
1173 // in case this was called from outside the class
1174 _click_to_combobox.setSelectedIndex( action );
1177 void setColorBranches( final boolean color_branches ) {
1178 _color_branches = color_branches;
1181 void setDrawPhylogram( final boolean b ) {
1182 getDisplayAsPhylogramCb().setSelected( b );
1183 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1186 void setDrawPhylogramEnabled( final boolean b ) {
1187 getDisplayAsPhylogramCb().setEnabled( b );
1190 void setDynamicHidingIsOn( final boolean is_on ) {
1191 // if ( !_configuration.isUseNativeUI() ) {
1193 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1196 if ( !_configuration.isUseNativeUI() ) {
1197 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1200 getDynamicallyHideData().setForeground( Color.BLACK );
1206 void setSearchFoundCountsOnLabel0( final int counts ) {
1207 getSearchFoundCountsLabel0().setText( "Found: " + counts );
1210 void setSearchFoundCountsOnLabel1( final int counts ) {
1211 getSearchFoundCountsLabel1().setText( "Found: " + counts );
1214 void setShowEvents( final boolean show_events ) {
1215 if ( getShowEventsCb() == null ) {
1216 _show_events = new JCheckBox( "" );
1218 getShowEventsCb().setSelected( show_events );
1221 void setSpeciesColors( final Map<String, Color> species_colors ) {
1222 _species_colors = species_colors;
1227 * Set up the controls from the config settings. 11/26/05
1229 void setupControls() {
1230 // The tree display options:
1231 setupDisplayCheckboxes();
1233 // The sequence relation query selection combo-box
1234 if ( _configuration.displaySequenceRelations() ) {
1235 addSequenceRelationBlock();
1239 startClickToOptions();
1240 setupClickToOptions();
1241 endClickToOptions();
1242 // Zoom and quick edit buttons
1244 setupSearchTools0();
1245 setupSearchTools1();
1248 void setUpControlsForDomainStrucures() {
1249 _domain_display_label = new JLabel( "Domain Display:" );
1250 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1251 add( _domain_display_label );
1252 _zoom_in_domain_structure = new JButton( "d+" );
1253 _zoom_out_domain_structure = new JButton( "d-" );
1254 _decr_domain_structure_evalue_thr = new JButton( "-" );
1255 _incr_domain_structure_evalue_thr = new JButton( "+" );
1256 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1257 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1258 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1259 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1260 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1261 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1262 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1263 _domain_structure_evalue_thr_tf.setEditable( false );
1264 if ( !getConfiguration().isUseNativeUI() ) {
1265 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1266 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1267 _domain_structure_evalue_thr_tf.setBorder( null );
1269 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1270 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1271 if ( !_configuration.isUseNativeUI() ) {
1272 d1_panel.setBackground( getBackground() );
1273 d2_panel.setBackground( getBackground() );
1277 addJButton( _zoom_out_domain_structure, d1_panel );
1278 addJButton( _zoom_in_domain_structure, d1_panel );
1279 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1280 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1281 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1284 void setupSearchTools0() {
1285 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1286 final JLabel search_label = new JLabel( "Search (A):" );
1287 search_label.setFont( ControlPanel.jcb_bold_font );
1288 if ( !getConfiguration().isUseNativeUI() ) {
1289 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1291 add( search_label );
1292 search_label.setToolTipText( tip );
1293 _search_found_label_0 = new JLabel();
1294 getSearchFoundCountsLabel0().setVisible( false );
1295 _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
1296 if ( !getConfiguration().isUseNativeUI() ) {
1297 _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1299 _search_tf_0 = new JTextField( 3 );
1300 _search_tf_0.setToolTipText( tip );
1301 _search_tf_0.setEditable( true );
1302 if ( !getConfiguration().isUseNativeUI() ) {
1303 _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1304 _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1305 _search_tf_0.setBorder( null );
1307 _search_reset_button_0 = new JButton();
1308 getSearchResetButton0().setText( "Reset" );
1309 getSearchResetButton0().setEnabled( false );
1310 getSearchResetButton0().setVisible( false );
1311 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1312 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1313 s_panel_1.setBackground( getBackground() );
1315 s_panel_2.setBackground( getBackground() );
1317 final KeyAdapter key_adapter = new KeyAdapter() {
1320 public void keyReleased( final KeyEvent key_event ) {
1322 displayedPhylogenyMightHaveChanged( true );
1325 final ActionListener action_listener = new ActionListener() {
1328 public void actionPerformed( final ActionEvent e ) {
1330 setSearchFoundCountsOnLabel0( 0 );
1331 getSearchFoundCountsLabel0().setVisible( false );
1332 getSearchTextField0().setText( "" );
1333 getSearchResetButton0().setEnabled( false );
1334 getSearchResetButton0().setVisible( false );
1335 displayedPhylogenyMightHaveChanged( true );
1338 _search_reset_button_0.addActionListener( action_listener );
1339 _search_tf_0.addKeyListener( key_adapter );
1340 addJTextField( _search_tf_0, s_panel_1 );
1341 s_panel_2.add( _search_found_label_0 );
1342 addJButton( _search_reset_button_0, s_panel_2 );
1345 void setupSearchTools1() {
1346 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1347 final JLabel search_label = new JLabel( "Search (B):" );
1348 search_label.setFont( ControlPanel.jcb_bold_font );
1349 if ( !getConfiguration().isUseNativeUI() ) {
1350 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1352 add( search_label );
1353 search_label.setToolTipText( tip );
1354 _search_found_label_1 = new JLabel();
1355 getSearchFoundCountsLabel1().setVisible( false );
1356 _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
1357 if ( !getConfiguration().isUseNativeUI() ) {
1358 _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1360 _search_tf_1 = new JTextField( 3 );
1361 _search_tf_1.setToolTipText( tip );
1362 _search_tf_1.setEditable( true );
1363 if ( !getConfiguration().isUseNativeUI() ) {
1364 _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1365 _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1366 _search_tf_1.setBorder( null );
1368 _search_reset_button_1 = new JButton();
1369 getSearchResetButton1().setText( "Reset" );
1370 getSearchResetButton1().setEnabled( false );
1371 getSearchResetButton1().setVisible( false );
1372 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1373 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1374 s_panel_1.setBackground( getBackground() );
1376 s_panel_2.setBackground( getBackground() );
1378 final KeyAdapter key_adapter = new KeyAdapter() {
1381 public void keyReleased( final KeyEvent key_event ) {
1383 displayedPhylogenyMightHaveChanged( true );
1386 final ActionListener action_listener = new ActionListener() {
1389 public void actionPerformed( final ActionEvent e ) {
1391 setSearchFoundCountsOnLabel1( 0 );
1392 getSearchFoundCountsLabel1().setVisible( false );
1393 getSearchTextField1().setText( "" );
1394 getSearchResetButton1().setEnabled( false );
1395 getSearchResetButton1().setVisible( false );
1396 displayedPhylogenyMightHaveChanged( true );
1399 _search_reset_button_1.addActionListener( action_listener );
1400 _search_tf_1.addKeyListener( key_adapter );
1401 addJTextField( _search_tf_1, s_panel_1 );
1402 s_panel_2.add( _search_found_label_1 );
1403 addJButton( _search_reset_button_1, s_panel_2 );
1406 void showAnnotations() {
1407 if ( _show_annotation != null ) {
1408 _show_annotation.setSelected( true );
1410 if ( _color_according_to_annotation != null ) {
1411 _color_according_to_annotation.setSelected( true );
1413 if ( _color_acc_species != null ) {
1414 _color_acc_species.setSelected( false );
1416 _mainpanel.getCurrentTreePanel().repaint();
1420 * Fit entire tree into window.
1423 if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
1426 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
1427 displayedPhylogenyMightHaveChanged( true );
1428 _mainpanel.getCurrentTreePanel().updateOvSettings();
1429 _mainpanel.getCurrentTreePanel().validate();
1430 _mainpanel.validate();
1431 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1432 _mainpanel.getSizeOfViewport().height,
1434 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1435 _mainpanel.adjustJScrollPane();
1436 _mainpanel.getCurrentTreePanel().repaint();
1437 _mainpanel.getCurrentTreePanel().validate();
1438 _mainpanel.validate();
1439 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1440 _mainpanel.getSizeOfViewport().height,
1442 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1443 _mainpanel.adjustJScrollPane();
1444 _mainpanel.getCurrentTreePanel().repaint();
1445 _mainpanel.getCurrentTreePanel().updateOvSizes();
1448 void showWholeAll() {
1449 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1450 if ( tree_panel != null ) {
1451 tree_panel.validate();
1452 tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1453 _mainpanel.getSizeOfViewport().height,
1455 tree_panel.resetPreferredSize();
1456 tree_panel.repaint();
1461 // Create header for click-to combo box.
1462 void startClickToOptions() {
1463 final JLabel spacer = new JLabel( "" );
1464 spacer.setFont( ControlPanel.jcb_font );
1466 _click_to_label = new JLabel( "Click on Node to:" );
1467 add( customizeLabel( _click_to_label, getConfiguration() ) );
1468 _click_to_combobox = new JComboBox();
1469 _click_to_combobox.setFocusable( false );
1470 _click_to_combobox.setMaximumRowCount( 14 );
1471 _click_to_combobox.setFont( ControlPanel.js_font );
1472 if ( !_configuration.isUseNativeUI() ) {
1473 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1475 // don't add listener until all items are set (or each one will trigger
1477 // click_to_list.addActionListener(this);
1478 add( _click_to_combobox );
1479 // Correlates option names to titles
1480 _all_click_to_names = new HashMap<Integer, String>();
1481 _click_to_names = new ArrayList<String>();
1485 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1486 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1487 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1488 setDrawPhylogramEnabled( true );
1489 setDrawPhylogram( isDrawPhylogram() );
1492 setDrawPhylogramEnabled( false );
1493 setDrawPhylogram( false );
1495 if ( getMainPanel().getMainFrame() == null ) {
1496 // Must be "E" applet version.
1497 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1498 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1501 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1502 .getPhylogenyGraphicsType() );
1504 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1505 getMainPanel().getControlPanel().search0();
1506 getMainPanel().getControlPanel().search1();
1507 getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
1508 getSequenceRelationTypeBox().removeAllItems();
1509 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1510 .getRelevantSequenceRelationTypes() ) {
1511 _sequence_relation_type_box.addItem( type );
1513 getMainPanel().getCurrentTreePanel().repaint();
1514 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1515 // according to GUILHEM the line above can be removed.
1520 * Uncollapse all nodes.
1522 void uncollapseAll( final TreePanel tp ) {
1523 final Phylogeny t = tp.getPhylogeny();
1524 if ( ( t != null ) && !t.isEmpty() ) {
1525 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
1526 final PhylogenyNode node = iter.next();
1527 node.setCollapse( false );
1529 tp.resetNodeIdToDistToLeafMap();
1530 tp.updateSetOfCollapsedExternalNodes();
1531 t.recalculateNumberOfExternalDescendants( false );
1532 tp.setNodeInPreorderToNull();
1533 t.clearHashIdToNodeMap();
1538 void updateDomainStructureEvaluethresholdDisplay() {
1539 if ( _domain_structure_evalue_thr_tf != null ) {
1540 _domain_structure_evalue_thr_tf.setText( "10^"
1541 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1545 void zoomInX( final float factor, final float x_correction_factor ) {
1546 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1547 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1548 treepanel.multiplyUrtFactor( 1f );
1549 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1550 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1551 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1552 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1553 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1554 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1555 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1556 getMainPanel().adjustJScrollPane();
1557 treepanel.resetPreferredSize();
1558 getMainPanel().getCurrentScrollPane().getViewport().validate();
1559 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1560 - ( sb.getVisibleAmount() / 2.0 ) ) );
1563 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1564 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1565 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1566 getMainPanel().adjustJScrollPane();
1567 treepanel.resetPreferredSize();
1568 getMainPanel().getCurrentScrollPane().getViewport().validate();
1569 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1571 treepanel.resetPreferredSize();
1572 treepanel.updateOvSizes();
1575 void zoomInY( final float factor ) {
1576 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1577 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1578 treepanel.multiplyUrtFactor( 1.1f );
1579 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1580 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1581 getMainPanel().adjustJScrollPane();
1582 treepanel.resetPreferredSize();
1583 getMainPanel().getCurrentScrollPane().getViewport().validate();
1584 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1585 - ( sb.getVisibleAmount() / 2.0 ) ) );
1586 treepanel.resetPreferredSize();
1587 treepanel.updateOvSizes();
1590 void zoomOutX( final float factor, final float x_correction_factor ) {
1591 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1592 treepanel.multiplyUrtFactor( 1f );
1593 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1594 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1595 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1596 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1597 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1598 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1599 getMainPanel().adjustJScrollPane();
1600 treepanel.resetPreferredSize();
1601 getMainPanel().getCurrentScrollPane().getViewport().validate();
1602 final double x = ( sb.getMaximum() - sb.getMinimum() )
1603 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1604 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1605 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1606 getMainPanel().adjustJScrollPane();
1607 treepanel.resetPreferredSize();
1608 getMainPanel().getCurrentScrollPane().getViewport().validate();
1609 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1610 - ( sb.getVisibleAmount() / 2.0 ) ) );
1613 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1614 treepanel.setXdistance( treepanel.getXdistance() * factor );
1615 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
1617 getMainPanel().adjustJScrollPane();
1618 treepanel.resetPreferredSize();
1619 getMainPanel().getCurrentScrollPane().getViewport().validate();
1620 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1623 treepanel.resetPreferredSize();
1624 treepanel.updateOvSizes();
1628 void zoomOutY( final float factor ) {
1629 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1630 treepanel.multiplyUrtFactor( 0.9f );
1631 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1632 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1633 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1634 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1635 getMainPanel().adjustJScrollPane();
1636 treepanel.resetPreferredSize();
1637 getMainPanel().getCurrentScrollPane().getViewport().validate();
1638 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1639 - ( sb.getVisibleAmount() / 2.0 ) ) );
1640 treepanel.resetPreferredSize();
1641 treepanel.updateOvSizes();
1645 private void addClickToOption( final int which, final String title ) {
1646 _click_to_combobox.addItem( title );
1647 _click_to_names.add( title );
1648 _all_click_to_names.put( new Integer( which ), title );
1649 if ( !_configuration.isUseNativeUI() ) {
1650 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1651 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
1656 private void addSequenceRelationBlock() {
1657 final JLabel spacer = new JLabel( "" );
1658 spacer.setSize( 1, 1 );
1660 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
1661 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
1662 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
1663 getSequenceRelationTypeBox().setFocusable( false );
1664 _sequence_relation_type_box.setFont( ControlPanel.js_font );
1665 if ( !_configuration.isUseNativeUI() ) {
1666 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1667 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
1669 _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
1672 public Component getListCellRendererComponent( final JList list,
1675 final boolean isSelected,
1676 final boolean cellHasFocus ) {
1677 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
1682 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
1683 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
1684 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
1689 final GridBagLayout gbl = new GridBagLayout();
1690 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
1691 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
1692 final JPanel horizGrid = new JPanel( gbl );
1693 horizGrid.setBackground( getBackground() );
1694 horizGrid.add( typeLabel );
1695 horizGrid.add( _sequence_relation_type_box );
1696 add( customizeLabel( mainLabel, getConfiguration() ) );
1698 add( getSequenceRelationBox() );
1699 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
1700 addCheckbox( Configuration.show_relation_confidence,
1701 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
1702 setCheckbox( Configuration.show_relation_confidence,
1703 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
1705 }// addSequenceRelationBlock
1708 private List<Boolean> getIsDrawPhylogramList() {
1709 return _draw_phylogram;
1712 private void init() {
1713 _draw_phylogram = new ArrayList<Boolean>();
1714 setSpeciesColors( new HashMap<String, Color>() );
1715 setAnnotationColors( new HashMap<String, Color>() );
1718 private boolean isDrawPhylogram( final int index ) {
1719 return getIsDrawPhylogramList().get( index );
1722 private void search0( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
1723 getSearchFoundCountsLabel0().setVisible( true );
1724 getSearchResetButton0().setEnabled( true );
1725 getSearchResetButton0().setVisible( true );
1726 String[] queries = null;
1727 List<PhylogenyNode> nodes = null;
1728 if ( query_str.indexOf( ',' ) >= 0 ) {
1729 queries = query_str.split( ",+" );
1732 queries = new String[ 1 ];
1733 queries[ 0 ] = query_str.trim();
1735 if ( ( queries != null ) && ( queries.length > 0 ) ) {
1736 nodes = new ArrayList<PhylogenyNode>();
1737 for( String query : queries ) {
1738 if ( ForesterUtil.isEmpty( query ) ) {
1741 query = query.trim();
1742 if ( query.indexOf( '+' ) >= 0 ) {
1743 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
1745 getOptions().isSearchCaseSensitive(),
1746 !getOptions().isMatchWholeTermsOnly(),
1747 isShowDomainArchitectures() ) );
1750 nodes.addAll( PhylogenyMethods.searchData( query,
1752 getOptions().isSearchCaseSensitive(),
1753 !getOptions().isMatchWholeTermsOnly(),
1754 isShowDomainArchitectures() ) );
1757 if ( getOptions().isInverseSearchResult() ) {
1758 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
1759 all.removeAll( nodes );
1763 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
1764 main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet<Long>() );
1765 for( final PhylogenyNode node : nodes ) {
1766 main_panel.getCurrentTreePanel().getFoundNodes0().add( node.getId() );
1768 setSearchFoundCountsOnLabel0( nodes.size() );
1771 setSearchFoundCountsOnLabel0( 0 );
1776 private void search1( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
1777 getSearchFoundCountsLabel1().setVisible( true );
1778 getSearchResetButton1().setEnabled( true );
1779 getSearchResetButton1().setVisible( true );
1780 String[] queries = null;
1781 List<PhylogenyNode> nodes = null;
1782 if ( query_str.indexOf( ',' ) >= 0 ) {
1783 queries = query_str.split( ",+" );
1786 queries = new String[ 1 ];
1787 queries[ 0 ] = query_str.trim();
1789 if ( ( queries != null ) && ( queries.length > 0 ) ) {
1790 nodes = new ArrayList<PhylogenyNode>();
1791 for( String query : queries ) {
1792 if ( ForesterUtil.isEmpty( query ) ) {
1795 query = query.trim();
1796 if ( query.indexOf( '+' ) >= 0 ) {
1797 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
1799 getOptions().isSearchCaseSensitive(),
1800 !getOptions().isMatchWholeTermsOnly(),
1801 isShowDomainArchitectures() ) );
1804 nodes.addAll( PhylogenyMethods.searchData( query,
1806 getOptions().isSearchCaseSensitive(),
1807 !getOptions().isMatchWholeTermsOnly(),
1808 isShowDomainArchitectures() ) );
1811 if ( getOptions().isInverseSearchResult() ) {
1812 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
1813 all.removeAll( nodes );
1817 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
1818 main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet<Long>() );
1819 for( final PhylogenyNode node : nodes ) {
1820 main_panel.getCurrentTreePanel().getFoundNodes1().add( node.getId() );
1822 setSearchFoundCountsOnLabel1( nodes.size() );
1825 setSearchFoundCountsOnLabel1( 0 );
1830 private void setDrawPhylogram( final int index, final boolean b ) {
1831 getIsDrawPhylogramList().set( index, b );
1834 private void setupClickToOptions() {
1835 final int default_option = _configuration.getDefaultDisplayClicktoOption();
1836 int selected_index = 0;
1838 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1839 _show_data_item = cb_index;
1840 addClickToOption( Configuration.display_node_data,
1841 _configuration.getClickToTitle( Configuration.display_node_data ) );
1842 if ( default_option == Configuration.display_node_data ) {
1843 selected_index = cb_index;
1847 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1848 _collapse_cb_item = cb_index;
1849 addClickToOption( Configuration.collapse_uncollapse,
1850 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
1851 if ( default_option == Configuration.collapse_uncollapse ) {
1852 selected_index = cb_index;
1856 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1857 _reroot_cb_item = cb_index;
1858 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1859 if ( default_option == Configuration.reroot ) {
1860 selected_index = cb_index;
1864 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1865 _subtree_cb_item = cb_index;
1866 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1867 if ( default_option == Configuration.subtree ) {
1868 selected_index = cb_index;
1872 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1873 _swap_cb_item = cb_index;
1874 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1875 if ( default_option == Configuration.swap ) {
1876 selected_index = cb_index;
1880 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
1881 _sort_descendents_item = cb_index;
1882 addClickToOption( Configuration.sort_descendents,
1883 _configuration.getClickToTitle( Configuration.sort_descendents ) );
1884 if ( default_option == Configuration.sort_descendents ) {
1885 selected_index = cb_index;
1889 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1890 _color_subtree_cb_item = cb_index;
1891 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1892 if ( default_option == Configuration.color_subtree ) {
1893 selected_index = cb_index;
1897 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1898 _open_seq_web_item = cb_index;
1899 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1900 if ( default_option == Configuration.open_seq_web ) {
1901 selected_index = cb_index;
1905 if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
1906 _open_pdb_item = cb_index;
1907 addClickToOption( Configuration.open_pdb_web, _configuration.getClickToTitle( Configuration.open_pdb_web ) );
1908 if ( default_option == Configuration.open_pdb_web ) {
1909 selected_index = cb_index;
1913 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1914 _open_tax_web_item = cb_index;
1915 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1916 if ( default_option == Configuration.open_tax_web ) {
1917 selected_index = cb_index;
1921 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1922 _blast_item = cb_index;
1923 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
1924 if ( default_option == Configuration.blast ) {
1925 selected_index = cb_index;
1929 if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
1930 _select_nodes_item = cb_index;
1931 addClickToOption( Configuration.select_nodes, _configuration.getClickToTitle( Configuration.select_nodes ) );
1932 if ( default_option == Configuration.select_nodes ) {
1933 selected_index = cb_index;
1937 if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
1938 _get_ext_desc_data = cb_index;
1939 if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
1940 addClickToOption( Configuration.get_ext_desc_data, getConfiguration()
1941 .getLabelForGetExtDescendentsData() );
1945 switch ( getConfiguration().getExtDescNodeDataToReturn() ) {
1950 s = "Sequence Accessors";
1952 case SEQUENCE_MOL_SEQ:
1953 s = "Molecular Sequence";
1955 case SEQUENCE_MOL_SEQ_FASTA:
1956 s = "Molecular Sequence (Fasta)";
1959 s = "Sequence Names";
1964 case SEQUENCE_SYMBOL:
1965 s = "Sequence Symbols";
1968 s = "Taxonomy Codes";
1970 case TAXONOMY_COMM0N_NAME:
1971 s = "Taxonomy Common Names";
1973 case TAXONOMY_SCIENTIFIC_NAME:
1974 s = "Scientific Names";
1977 s = "User Selected Data";
1980 final String label = _configuration.getClickToTitle( Configuration.get_ext_desc_data ) + " " + s;
1981 addClickToOption( Configuration.get_ext_desc_data, label );
1983 if ( default_option == Configuration.get_ext_desc_data ) {
1984 selected_index = cb_index;
1988 if ( getOptions().isEditable() ) {
1989 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
1990 _cut_subtree_item = cb_index;
1991 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
1992 if ( default_option == Configuration.cut_subtree ) {
1993 selected_index = cb_index;
1997 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
1998 _copy_subtree_item = cb_index;
1999 addClickToOption( Configuration.copy_subtree,
2000 _configuration.getClickToTitle( Configuration.copy_subtree ) );
2001 if ( default_option == Configuration.copy_subtree ) {
2002 selected_index = cb_index;
2006 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
2007 _paste_subtree_item = cb_index;
2008 addClickToOption( Configuration.paste_subtree,
2009 _configuration.getClickToTitle( Configuration.paste_subtree ) );
2010 if ( default_option == Configuration.paste_subtree ) {
2011 selected_index = cb_index;
2015 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
2016 _delete_node_or_subtree_item = cb_index;
2017 addClickToOption( Configuration.delete_subtree_or_node,
2018 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
2019 if ( default_option == Configuration.delete_subtree_or_node ) {
2020 selected_index = cb_index;
2024 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
2025 _add_new_node_item = cb_index;
2026 addClickToOption( Configuration.add_new_node,
2027 _configuration.getClickToTitle( Configuration.add_new_node ) );
2028 if ( default_option == Configuration.add_new_node ) {
2029 selected_index = cb_index;
2033 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
2034 _edit_node_data_item = cb_index;
2035 addClickToOption( Configuration.edit_node_data,
2036 _configuration.getClickToTitle( Configuration.edit_node_data ) );
2037 if ( default_option == Configuration.edit_node_data ) {
2038 selected_index = cb_index;
2043 // Set default selection and its action
2044 _click_to_combobox.setSelectedIndex( selected_index );
2045 setClickToAction( selected_index );
2048 private void setupDisplayCheckboxes() {
2049 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
2050 addCheckbox( Configuration.display_as_phylogram,
2051 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
2052 setCheckbox( Configuration.display_as_phylogram,
2053 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
2055 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
2056 addCheckbox( Configuration.dynamically_hide_data,
2057 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
2058 setCheckbox( Configuration.dynamically_hide_data,
2059 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
2061 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
2062 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
2063 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
2065 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
2066 addCheckbox( Configuration.display_internal_data,
2067 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
2068 setCheckbox( Configuration.display_internal_data,
2069 _configuration.doCheckOption( Configuration.display_internal_data ) );
2071 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
2072 addCheckbox( Configuration.color_according_to_species,
2073 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
2074 setCheckbox( Configuration.color_according_to_species,
2075 _configuration.doCheckOption( Configuration.color_according_to_species ) );
2077 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
2078 addCheckbox( Configuration.color_according_to_annotation,
2079 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
2080 setCheckbox( Configuration.color_according_to_annotation,
2081 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
2083 if ( _configuration.doDisplayOption( Configuration.color_branches ) ) {
2084 addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) );
2085 setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) );
2087 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
2088 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
2089 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
2091 final JLabel label = new JLabel( "Display Data:" );
2092 label.setFont( ControlPanel.jcb_bold_font );
2093 if ( !getConfiguration().isUseNativeUI() ) {
2094 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2097 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
2098 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
2099 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
2101 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
2102 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
2103 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
2105 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
2106 addCheckbox( Configuration.show_taxonomy_scientific_names,
2107 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
2108 setCheckbox( Configuration.show_taxonomy_scientific_names,
2109 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
2111 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
2112 addCheckbox( Configuration.show_taxonomy_common_names,
2113 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
2114 setCheckbox( Configuration.show_taxonomy_common_names,
2115 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
2117 if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
2118 addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
2119 setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
2121 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
2122 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
2123 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
2125 if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
2126 addCheckbox( Configuration.show_seq_symbols,
2127 _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
2128 setCheckbox( Configuration.show_seq_symbols, _configuration.doCheckOption( Configuration.show_seq_symbols ) );
2130 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
2131 addCheckbox( Configuration.show_sequence_acc,
2132 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
2133 setCheckbox( Configuration.show_sequence_acc,
2134 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
2136 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
2137 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
2138 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
2140 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
2141 addCheckbox( Configuration.show_binary_characters,
2142 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
2143 setCheckbox( Configuration.show_binary_characters,
2144 _configuration.doCheckOption( Configuration.show_binary_characters ) );
2146 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
2147 addCheckbox( Configuration.show_binary_character_counts,
2148 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
2149 setCheckbox( Configuration.show_binary_character_counts,
2150 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
2152 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
2153 addCheckbox( Configuration.show_domain_architectures,
2154 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
2155 setCheckbox( Configuration.show_domain_architectures,
2156 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
2158 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
2159 addCheckbox( Configuration.write_confidence_values,
2160 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
2161 setCheckbox( Configuration.write_confidence_values,
2162 _configuration.doCheckOption( Configuration.write_confidence_values ) );
2164 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
2165 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
2166 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
2168 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
2169 addCheckbox( Configuration.show_vector_data,
2170 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
2171 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
2173 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
2174 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
2175 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
2177 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
2178 addCheckbox( Configuration.show_taxonomy_images,
2179 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
2180 setCheckbox( Configuration.show_taxonomy_images,
2181 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
2185 private void setVisibilityOfDomainStrucureControls() {
2186 if ( _zoom_in_domain_structure != null ) {
2187 if ( isShowDomainArchitectures() ) {
2188 _domain_display_label.setVisible( true );
2189 _zoom_in_domain_structure.setVisible( true );
2190 _zoom_out_domain_structure.setVisible( true );
2191 _decr_domain_structure_evalue_thr.setVisible( true );
2192 _incr_domain_structure_evalue_thr.setVisible( true );
2193 _domain_structure_evalue_thr_tf.setVisible( true );
2196 _domain_display_label.setVisible( false );
2197 _zoom_in_domain_structure.setVisible( false );
2198 _zoom_out_domain_structure.setVisible( false );
2199 _decr_domain_structure_evalue_thr.setVisible( false );
2200 _incr_domain_structure_evalue_thr.setVisible( false );
2201 _domain_structure_evalue_thr_tf.setVisible( false );
2206 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2207 label.setFont( ControlPanel.jcb_bold_font );
2208 if ( !configuration.isUseNativeUI() ) {
2209 label.setForeground( configuration.getGuiCheckboxTextColor() );
2210 label.setBackground( configuration.getGuiBackgroundColor() );
2215 enum NodeClickAction {
2222 DELETE_NODE_OR_SUBTREE,