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_acc_sequence;
95 private JCheckBox _color_according_to_annotation;
96 private boolean _color_branches;
97 private JCheckBox _use_visual_styles_cb;
98 private int _color_subtree_cb_item;
99 private int _change_node_font_item;
100 // The settings from the conf file
101 private final Configuration _configuration;
102 private int _copy_subtree_item;
103 private int _cut_subtree_item;
104 private JButton _decr_domain_structure_evalue_thr;
105 private int _delete_node_or_subtree_item;
106 private JCheckBox _display_as_phylogram_cb;
108 private JCheckBox _display_internal_data;
109 private JLabel _domain_display_label;
110 private JTextField _domain_structure_evalue_thr_tf;
111 private List<Boolean> _draw_phylogram;
112 private JCheckBox _dynamically_hide_data;
113 private int _edit_node_data_item;
114 private int _get_ext_desc_data;
115 private JButton _incr_domain_structure_evalue_thr;
116 private final MainPanel _mainpanel;
117 private JCheckBox _node_desc_popup_cb;
118 private int _open_pdb_item;
119 private int _open_seq_web_item;
120 private int _open_tax_web_item;
121 private int _color_node_font_item;
122 private JButton _order;
123 private boolean _order_of_appearance;
124 private int _paste_subtree_item;
125 private int _reroot_cb_item;
126 private JButton _return_to_super_tree;
128 private JLabel _search_found_label_0;
129 private JLabel _search_found_label_1;
130 private JButton _search_reset_button_0;
131 private JButton _search_reset_button_1;
132 private JTextField _search_tf_0;
133 private JTextField _search_tf_1;
134 private int _select_nodes_item;
135 private Sequence _selected_query_seq;
136 private JCheckBox _seq_relation_confidence_switch;
137 private JComboBox _sequence_relation_type_box;
138 private JCheckBox _show_annotation;
139 private JCheckBox _show_binary_character_counts;
140 private JCheckBox _show_binary_characters;
141 // Indices for the click-to options in the combo box
142 private int _show_data_item;
143 private JCheckBox _show_domain_architectures;
144 private JCheckBox _show_events;
145 private JCheckBox _show_gene_names;
146 private JCheckBox _show_node_names;
147 private JCheckBox _show_properties_cb;
148 private JCheckBox _show_seq_names;
149 private JCheckBox _show_seq_symbols;
150 private JCheckBox _show_sequence_acc;
151 private JComboBox _show_sequence_relations;
152 private JCheckBox _show_taxo_code;
153 private JCheckBox _show_taxo_common_names;
154 private JCheckBox _show_taxo_images_cb;
155 private JCheckBox _show_taxo_scientific_names;
156 private JCheckBox _show_vector_data_cb;
157 private JButton _show_whole;
158 private int _sort_descendents_item;
159 private Map<String, Color> _species_colors;
160 private Map<String, Color> _sequence_colors;
161 private int _subtree_cb_item;
162 private int _swap_cb_item;
163 private JButton _uncollapse_all;
164 private JCheckBox _width_branches;
165 private JCheckBox _write_confidence;
166 private JButton _zoom_in_domain_structure;
167 // zooming and quick tree manipulation buttons:
168 private JButton _zoom_in_x;
169 private JButton _zoom_in_y;
170 private JLabel _zoom_label;
171 private JButton _zoom_out_domain_structure;
172 private JButton _zoom_out_x;
173 private JButton _zoom_out_y;
175 ControlPanel( final MainPanel ap, final Configuration configuration ) {
178 _configuration = configuration;
179 if ( !_configuration.isUseNativeUI() ) {
180 setBackground( getConfiguration().getGuiBackgroundColor() );
181 setBorder( BorderFactory.createRaisedBevelBorder() );
183 setLayout( new GridLayout( 0, 1, 2, 2 ) );
184 _order_of_appearance = true;
192 public void actionPerformed( final ActionEvent e ) {
194 if ( e.getSource() == _color_acc_sequence ) {
195 if ( _color_acc_species != null ) {
196 _color_acc_species.setSelected( false );
199 else if ( e.getSource() == _color_acc_species ) {
200 if ( _color_acc_sequence != null ) {
201 _color_acc_sequence.setSelected( false );
207 final TreePanel tp = getMainPanel().getCurrentTreePanel();
211 if ( e.getSource() == _click_to_combobox ) {
212 setClickToAction( _click_to_combobox.getSelectedIndex() );
213 getCurrentTreePanel().repaint();
215 else if ( e.getSource() == _show_binary_characters ) {
216 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
217 _show_binary_character_counts.setSelected( false );
219 displayedPhylogenyMightHaveChanged( true );
221 else if ( e.getSource() == _show_binary_character_counts ) {
222 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
223 _show_binary_characters.setSelected( false );
225 displayedPhylogenyMightHaveChanged( true );
227 else if ( e.getSource() == _show_domain_architectures ) {
230 displayedPhylogenyMightHaveChanged( true );
232 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
233 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
234 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
238 else if ( e.getSource() == _zoom_in_x ) {
239 zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
240 displayedPhylogenyMightHaveChanged( false );
242 else if ( e.getSource() == _zoom_in_y ) {
243 zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR );
244 displayedPhylogenyMightHaveChanged( false );
246 else if ( e.getSource() == _zoom_out_x ) {
247 zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
248 displayedPhylogenyMightHaveChanged( false );
250 else if ( e.getSource() == _zoom_out_y ) {
251 zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR );
252 displayedPhylogenyMightHaveChanged( false );
254 else if ( e.getSource() == _show_whole ) {
257 else if ( e.getSource() == _return_to_super_tree ) {
258 _mainpanel.getCurrentTreePanel().superTree();
261 else if ( e.getSource() == _order ) {
262 DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
263 if ( ( !isShowTaxonomyScientificNames() && !isShowTaxonomyCode() && !isShowTaxonomyCommonNames() ) ) {
264 if ( ( isShowSequenceAcc() || isShowSeqNames() || isShowSeqSymbols() ) ) {
265 pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
267 else if ( isShowNodeNames() ) {
268 pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
271 PhylogenyMethods.orderAppearance( tp.getPhylogeny().getRoot(), _order_of_appearance, true, pri );
272 _order_of_appearance = !_order_of_appearance;
273 tp.setNodeInPreorderToNull();
274 tp.getPhylogeny().externalNodesHaveChanged();
275 tp.getPhylogeny().clearHashIdToNodeMap();
276 tp.getPhylogeny().recalculateNumberOfExternalDescendants( true );
277 tp.resetNodeIdToDistToLeafMap();
278 tp.setEdited( true );
279 displayedPhylogenyMightHaveChanged( false );
281 else if ( e.getSource() == _uncollapse_all ) {
283 displayedPhylogenyMightHaveChanged( false );
285 else if ( e.getSource() == _zoom_in_domain_structure ) {
286 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
287 displayedPhylogenyMightHaveChanged( true );
289 else if ( e.getSource() == _zoom_out_domain_structure ) {
290 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
291 displayedPhylogenyMightHaveChanged( true );
293 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
294 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThreshold();
295 displayedPhylogenyMightHaveChanged( true );
297 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
298 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThreshold();
299 displayedPhylogenyMightHaveChanged( true );
301 else if ( e.getSource() == _search_tf_0 ) {
303 displayedPhylogenyMightHaveChanged( true );
305 else if ( e.getSource() == _search_tf_1 ) {
307 displayedPhylogenyMightHaveChanged( true );
314 displayedPhylogenyMightHaveChanged( true );
318 tp.requestFocusInWindow();
321 catch ( final Exception ex ) {
322 AptxUtil.unexpectedException( ex );
324 catch ( final Error err ) {
325 AptxUtil.unexpectedError( err );
329 public JCheckBox getColorAccSpeciesCb() {
330 return _color_acc_species;
333 public JCheckBox getColorAccSequenceCb() {
334 return _color_acc_sequence;
337 public JCheckBox getUseVisualStylesCb() {
338 return _use_visual_styles_cb;
341 public JCheckBox getDisplayAsPhylogramCb() {
342 return _display_as_phylogram_cb;
345 public JCheckBox getDynamicallyHideData() {
346 return _dynamically_hide_data;
349 public JCheckBox getNodeDescPopupCb() {
350 return _node_desc_popup_cb;
353 public Sequence getSelectedQuerySequence() {
354 return _selected_query_seq;
357 public JComboBox getSequenceRelationBox() {
358 if ( _show_sequence_relations == null ) {
359 _show_sequence_relations = new JComboBox();
360 _show_sequence_relations.setFocusable( false );
361 _show_sequence_relations.setMaximumRowCount( 20 );
362 _show_sequence_relations.setFont( ControlPanel.js_font );
363 if ( !_configuration.isUseNativeUI() ) {
364 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
365 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
367 _show_sequence_relations.addItem( "-----" );
368 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
370 return _show_sequence_relations;
374 public JComboBox getSequenceRelationTypeBox() {
375 if ( _sequence_relation_type_box == null ) {
376 _sequence_relation_type_box = new JComboBox();
377 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
378 _sequence_relation_type_box.addItem( type );
380 _sequence_relation_type_box.addActionListener( new ActionListener() {
383 public void actionPerformed( final ActionEvent e ) {
384 if ( _mainpanel.getCurrentPhylogeny() != null ) {
385 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
390 return _sequence_relation_type_box;
393 public JCheckBox getShowEventsCb() {
397 public JCheckBox getWriteConfidenceCb() {
398 return _write_confidence;
401 public boolean isShowProperties() {
402 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
405 public boolean isShowTaxonomyImages() {
406 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
409 public boolean isShowVectorData() {
410 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
413 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
414 final JComboBox box = getSequenceRelationBox();
415 while ( box.getItemCount() > 1 ) {
416 box.removeItemAt( 1 );
418 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
419 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
421 if ( relationType == null ) {
424 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
425 for( final Sequence seq : sequenceRelationQueries ) {
426 if ( seq.hasSequenceRelations() ) {
427 boolean fFoundForCurrentType = false;
428 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
429 if ( sq.getType().equals( relationType ) ) {
430 fFoundForCurrentType = true;
434 if ( fFoundForCurrentType ) {
435 sequenceNamesToAdd.add( seq.getName() );
436 sequencesByName.put( seq.getName(), seq );
440 // sort sequences by name before adding them to the combo
441 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
442 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
443 for( final String seqName : sequenceNameArray ) {
444 box.addItem( seqName );
446 for( final ItemListener oldItemListener : box.getItemListeners() ) {
447 box.removeItemListener( oldItemListener );
449 box.addItemListener( new ItemListener() {
452 public void itemStateChanged( final ItemEvent e ) {
453 _selected_query_seq = sequencesByName.get( e.getItem() );
454 _mainpanel.getCurrentTreePanel().repaint();
459 void activateButtonToReturnToSuperTree( int index ) {
462 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
465 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
467 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
468 _return_to_super_tree.setEnabled( true );
472 * Add zoom and quick edit buttons. (Last modified 8/9/04)
475 final JLabel spacer = new JLabel( "" );
476 spacer.setOpaque( false );
478 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
479 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
480 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
481 if ( !getConfiguration().isUseNativeUI() ) {
482 x_panel.setBackground( getBackground() );
483 y_panel.setBackground( getBackground() );
484 z_panel.setBackground( getBackground() );
486 add( _zoom_label = new JLabel( "Zoom:" ) );
487 customizeLabel( _zoom_label, getConfiguration() );
491 if ( getConfiguration().isUseNativeUI() ) {
492 _zoom_in_x = new JButton( "+" );
493 _zoom_out_x = new JButton( "-" );
496 _zoom_in_x = new JButton( "X+" );
497 _zoom_out_x = new JButton( "X-" );
499 _zoom_in_y = new JButton( "Y+" );
500 _zoom_out_y = new JButton( "Y-" );
501 _show_whole = new JButton( "F" );
502 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [F or Home]" );
503 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+cursor-right]" );
504 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+cursor-up]" );
505 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+cursor-left]" );
506 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+cursor-down]" );
507 if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) {
508 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
509 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
512 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
513 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
515 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
516 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
517 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
518 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
519 _return_to_super_tree.setEnabled( false );
520 _order = new JButton( "Order Subtrees" );
521 _uncollapse_all = new JButton( "Uncollapse All" );
522 addJButton( _zoom_in_y, x_panel );
523 addJButton( _zoom_out_x, y_panel );
524 addJButton( _show_whole, y_panel );
525 addJButton( _zoom_in_x, y_panel );
526 addJButton( _zoom_out_y, z_panel );
527 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
528 setUpControlsForDomainStrucures();
530 final JLabel spacer2 = new JLabel( "" );
532 addJButton( _return_to_super_tree, this );
533 addJButton( _order, this );
534 addJButton( _uncollapse_all, this );
535 final JLabel spacer3 = new JLabel( "" );
537 setVisibilityOfDomainStrucureControls();
540 void addCheckbox( final int which, final String title ) {
541 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
543 case Configuration.display_as_phylogram:
544 _display_as_phylogram_cb = new JCheckBox( title );
545 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
546 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
549 case Configuration.display_internal_data:
550 _display_internal_data = new JCheckBox( title );
551 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
552 addJCheckBox( _display_internal_data, ch_panel );
555 case Configuration.color_according_to_species:
556 _color_acc_species = new JCheckBox( title );
558 .setToolTipText( "To colorize node labels as a function of taxonomy" );
559 addJCheckBox( _color_acc_species, ch_panel );
562 case Configuration.color_according_to_sequence:
563 _color_acc_sequence = new JCheckBox( title );
565 .setToolTipText( "To colorize node labels as a function of sequence name" );
566 addJCheckBox( _color_acc_sequence, ch_panel );
569 case Configuration.color_according_to_annotation:
570 _color_according_to_annotation = new JCheckBox( title );
571 _color_according_to_annotation
572 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
573 addJCheckBox( _color_according_to_annotation, ch_panel );
576 case Configuration.show_node_names:
577 _show_node_names = new JCheckBox( title );
578 addJCheckBox( _show_node_names, ch_panel );
581 case Configuration.show_taxonomy_scientific_names:
582 _show_taxo_scientific_names = new JCheckBox( title );
583 addJCheckBox( _show_taxo_scientific_names, ch_panel );
586 case Configuration.show_taxonomy_common_names:
587 _show_taxo_common_names = new JCheckBox( title );
588 addJCheckBox( _show_taxo_common_names, ch_panel );
591 case Configuration.show_tax_code:
592 _show_taxo_code = new JCheckBox( title );
593 addJCheckBox( _show_taxo_code, ch_panel );
596 case Configuration.show_taxonomy_images:
597 _show_taxo_images_cb = new JCheckBox( title );
598 addJCheckBox( _show_taxo_images_cb, ch_panel );
601 case Configuration.show_binary_characters:
602 _show_binary_characters = new JCheckBox( title );
603 addJCheckBox( _show_binary_characters, ch_panel );
606 case Configuration.show_annotation:
607 _show_annotation = new JCheckBox( title );
608 addJCheckBox( _show_annotation, ch_panel );
611 case Configuration.show_binary_character_counts:
612 _show_binary_character_counts = new JCheckBox( title );
613 addJCheckBox( _show_binary_character_counts, ch_panel );
616 case Configuration.write_confidence_values:
617 _write_confidence = new JCheckBox( title );
618 addJCheckBox( getWriteConfidenceCb(), ch_panel );
621 case Configuration.write_events:
622 _show_events = new JCheckBox( title );
623 addJCheckBox( getShowEventsCb(), ch_panel );
626 case Configuration.use_style:
627 _use_visual_styles_cb = new JCheckBox( title );
628 getUseVisualStylesCb()
629 .setToolTipText( "To use visual styles (node colors, fonts) and branch colors, if present" );
630 addJCheckBox( getUseVisualStylesCb(), ch_panel );
633 case Configuration.width_branches:
634 _width_branches = new JCheckBox( title );
635 _width_branches.setToolTipText( "To use branch width values, if present" );
636 addJCheckBox( _width_branches, ch_panel );
639 case Configuration.show_domain_architectures:
640 _show_domain_architectures = new JCheckBox( title );
641 addJCheckBox( _show_domain_architectures, ch_panel );
644 case Configuration.show_seq_names:
645 _show_seq_names = new JCheckBox( title );
646 addJCheckBox( _show_seq_names, ch_panel );
649 case Configuration.show_gene_names:
650 _show_gene_names = new JCheckBox( title );
651 addJCheckBox( _show_gene_names, ch_panel );
654 case Configuration.show_seq_symbols:
655 _show_seq_symbols = new JCheckBox( title );
656 addJCheckBox( _show_seq_symbols, ch_panel );
659 case Configuration.show_sequence_acc:
660 _show_sequence_acc = new JCheckBox( title );
661 addJCheckBox( _show_sequence_acc, ch_panel );
664 case Configuration.dynamically_hide_data:
665 _dynamically_hide_data = new JCheckBox( title );
666 getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" );
667 addJCheckBox( getDynamicallyHideData(), ch_panel );
670 case Configuration.node_data_popup:
671 _node_desc_popup_cb = new JCheckBox( title );
672 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
673 addJCheckBox( getNodeDescPopupCb(), ch_panel );
676 case Configuration.show_relation_confidence:
677 _seq_relation_confidence_switch = new JCheckBox( title );
678 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
681 case Configuration.show_vector_data:
682 _show_vector_data_cb = new JCheckBox( title );
683 addJCheckBox( _show_vector_data_cb, ch_panel );
686 case Configuration.show_properties:
687 _show_properties_cb = new JCheckBox( title );
688 addJCheckBox( _show_properties_cb, ch_panel );
692 throw new RuntimeException( "unknown checkbox: " + which );
696 void addJButton( final JButton jb, final JPanel p ) {
697 jb.setFocusPainted( false );
698 jb.setFont( ControlPanel.jcb_font );
699 if ( !_configuration.isUseNativeUI() ) {
700 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
701 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
702 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
705 jb.addActionListener( this );
708 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
709 jcb.setFocusPainted( false );
710 jcb.setFont( ControlPanel.jcb_font );
711 if ( !_configuration.isUseNativeUI() ) {
712 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
713 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
715 p.add( jcb, "Center" );
716 jcb.addActionListener( this );
719 void addJTextField( final JTextField tf, final JPanel p ) {
720 if ( !_configuration.isUseNativeUI() ) {
721 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
722 tf.setFont( ControlPanel.jcb_font );
725 tf.addActionListener( this );
728 void deactivateButtonToReturnToSuperTree() {
729 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
730 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
731 _return_to_super_tree.setEnabled( false );
734 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
735 if ( ( _mainpanel != null )
736 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
737 if ( getOptions().isShowOverview() ) {
738 _mainpanel.getCurrentTreePanel().updateOvSizes();
740 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
741 setVisibilityOfDomainStrucureControls();
742 updateDomainStructureEvaluethresholdDisplay();
743 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
744 _mainpanel.getCurrentTreePanel().calcMaxDepth();
745 _mainpanel.adjustJScrollPane();
746 if ( recalc_longest_ext_node_info ) {
747 _mainpanel.getCurrentTreePanel().initNodeData();
748 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
750 _mainpanel.getCurrentTreePanel().repaint();
751 // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
755 void endClickToOptions() {
756 _click_to_combobox.addActionListener( this );
760 * Indicates what action should be execute when a node is clicked
762 * @return the click-on action
764 NodeClickAction getActionWhenNodeClicked() {
765 return _action_when_node_clicked;
768 Map<Integer, String> getAllClickToItems() {
769 return _all_click_to_names;
772 Map<String, Color> getAnnotationColors() {
773 return _annotation_colors;
776 Configuration getConfiguration() {
777 return _configuration;
780 TreePanel getCurrentTreePanel() {
781 return getMainPanel().getCurrentTreePanel();
784 MainPanel getMainPanel() {
788 Options getOptions() {
789 return getMainPanel().getOptions();
792 JLabel getSearchFoundCountsLabel0() {
793 return _search_found_label_0;
796 JLabel getSearchFoundCountsLabel1() {
797 return _search_found_label_1;
800 JButton getSearchResetButton0() {
801 return _search_reset_button_0;
804 JButton getSearchResetButton1() {
805 return _search_reset_button_1;
808 JTextField getSearchTextField0() {
812 JTextField getSearchTextField1() {
816 List<String> getSingleClickToNames() {
817 return _click_to_names;
820 Map<String, Color> getSpeciesColors() {
821 return _species_colors;
824 Map<String, Color> getSequenceColors() {
825 return _sequence_colors;
828 boolean isAntialiasScreenText() {
832 boolean isColorAccordingToAnnotation() {
833 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
836 boolean isColorAccordingToTaxonomy() {
837 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
840 boolean isColorAccordingToSequence() {
841 return ( ( _color_acc_sequence != null ) && _color_acc_sequence.isSelected() );
844 boolean isUseVisualStyles() {
845 return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() ) || ( ( getUseVisualStylesCb() == null ) && _color_branches ) );
848 boolean isDrawPhylogram() {
849 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
852 boolean isDynamicallyHideData() {
853 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
857 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
860 boolean isNodeDescPopup() {
861 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
864 boolean isShowAnnotation() {
865 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
868 boolean isShowBinaryCharacterCounts() {
869 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
872 boolean isShowBinaryCharacters() {
873 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
876 boolean isShowConfidenceValues() {
877 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
880 boolean isShowDomainArchitectures() {
881 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
884 boolean isShowGeneNames() {
885 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
888 boolean isShowInternalData() {
889 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
892 boolean isShowNodeNames() {
893 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
896 boolean isShowSeqNames() {
897 return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
900 boolean isShowSeqSymbols() {
901 return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
904 boolean isShowSequenceAcc() {
905 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
908 boolean isShowSequenceRelationConfidence() {
909 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
912 boolean isShowSequenceRelations() {
913 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
916 boolean isShowTaxonomyCode() {
917 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
920 boolean isShowTaxonomyCommonNames() {
921 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
924 boolean isShowTaxonomyScientificNames() {
925 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
928 boolean isWidthBranches() {
929 return ( ( _width_branches != null ) && _width_branches.isSelected() );
932 void phylogenyAdded( final Configuration configuration ) {
933 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
936 void phylogenyRemoved( final int index ) {
937 getIsDrawPhylogramList().remove( index );
941 final MainPanel main_panel = getMainPanel();
942 final Phylogeny tree = main_panel.getCurrentPhylogeny();
943 if ( ( tree == null ) || tree.isEmpty() ) {
946 String query = getSearchTextField0().getText();
947 if ( query != null ) {
948 query = query.trim();
950 if ( !ForesterUtil.isEmpty( query ) ) {
951 search0( main_panel, tree, query );
954 getSearchFoundCountsLabel0().setVisible( false );
955 getSearchResetButton0().setEnabled( false );
956 getSearchResetButton0().setVisible( false );
962 final MainPanel main_panel = getMainPanel();
963 final Phylogeny tree = main_panel.getCurrentPhylogeny();
964 if ( ( tree == null ) || tree.isEmpty() ) {
967 String query = getSearchTextField1().getText();
968 if ( query != null ) {
969 query = query.trim();
971 if ( !ForesterUtil.isEmpty( query ) ) {
972 search1( main_panel, tree, query );
975 getSearchFoundCountsLabel1().setVisible( false );
976 getSearchResetButton1().setEnabled( false );
977 getSearchResetButton1().setVisible( false );
982 void searchReset0() {
983 if ( getMainPanel().getCurrentTreePanel() != null ) {
984 getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
988 void searchReset1() {
989 if ( getMainPanel().getCurrentTreePanel() != null ) {
990 getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
994 void setActionWhenNodeClicked( final NodeClickAction action ) {
995 _action_when_node_clicked = action;
998 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
999 _annotation_colors = annotation_colors;
1002 void setCheckbox( final int which, final boolean state ) {
1004 case Configuration.display_as_phylogram:
1005 if ( getDisplayAsPhylogramCb() != null ) {
1006 getDisplayAsPhylogramCb().setSelected( state );
1009 case Configuration.display_internal_data:
1010 if ( _display_internal_data != null ) {
1011 _display_internal_data.setSelected( state );
1014 case Configuration.color_according_to_species:
1015 if ( _color_acc_species != null ) {
1016 _color_acc_species.setSelected( state );
1019 case Configuration.color_according_to_sequence:
1020 if ( _color_acc_sequence != null ) {
1021 _color_acc_sequence.setSelected( state );
1024 case Configuration.color_according_to_annotation:
1025 if ( _color_according_to_annotation != null ) {
1026 _color_according_to_annotation.setSelected( state );
1029 case Configuration.show_node_names:
1030 if ( _show_node_names != null ) {
1031 _show_node_names.setSelected( state );
1034 case Configuration.show_taxonomy_scientific_names:
1035 if ( _show_taxo_scientific_names != null ) {
1036 _show_taxo_scientific_names.setSelected( state );
1039 case Configuration.show_taxonomy_common_names:
1040 if ( _show_taxo_common_names != null ) {
1041 _show_taxo_common_names.setSelected( state );
1044 case Configuration.show_tax_code:
1045 if ( _show_taxo_code != null ) {
1046 _show_taxo_code.setSelected( state );
1049 case Configuration.show_taxonomy_images:
1050 if ( _show_taxo_images_cb != null ) {
1051 _show_taxo_images_cb.setSelected( state );
1054 case Configuration.show_annotation:
1055 if ( _show_annotation != null ) {
1056 _show_annotation.setSelected( state );
1059 case Configuration.show_binary_characters:
1060 if ( _show_binary_characters != null ) {
1061 _show_binary_characters.setSelected( state );
1064 case Configuration.show_binary_character_counts:
1065 if ( _show_binary_character_counts != null ) {
1066 _show_binary_character_counts.setSelected( state );
1069 case Configuration.write_confidence_values:
1070 if ( getWriteConfidenceCb() != null ) {
1071 getWriteConfidenceCb().setSelected( state );
1074 case Configuration.write_events:
1075 if ( getShowEventsCb() != null ) {
1076 getShowEventsCb().setSelected( state );
1079 case Configuration.use_style:
1080 if ( getUseVisualStylesCb() != null ) {
1081 getUseVisualStylesCb().setSelected( state );
1084 case Configuration.width_branches:
1085 if ( _width_branches != null ) {
1086 _width_branches.setSelected( state );
1089 case Configuration.show_domain_architectures:
1090 if ( _show_domain_architectures != null ) {
1091 _show_domain_architectures.setSelected( state );
1094 case Configuration.show_seq_names:
1095 if ( _show_seq_names != null ) {
1096 _show_seq_names.setSelected( state );
1099 case Configuration.show_gene_names:
1100 if ( _show_gene_names != null ) {
1101 _show_gene_names.setSelected( state );
1104 case Configuration.show_seq_symbols:
1105 if ( _show_seq_symbols != null ) {
1106 _show_seq_symbols.setSelected( state );
1109 case Configuration.show_vector_data:
1110 if ( _show_vector_data_cb != null ) {
1111 _show_vector_data_cb.setSelected( state );
1114 case Configuration.show_properties:
1115 if ( _show_properties_cb != null ) {
1116 _show_properties_cb.setSelected( state );
1119 case Configuration.show_sequence_acc:
1120 if ( _show_sequence_acc != null ) {
1121 _show_sequence_acc.setSelected( state );
1124 case Configuration.dynamically_hide_data:
1125 if ( getDynamicallyHideData() != null ) {
1126 getDynamicallyHideData().setSelected( state );
1129 case Configuration.node_data_popup:
1130 if ( getNodeDescPopupCb() != null ) {
1131 getNodeDescPopupCb().setSelected( state );
1135 case Configuration.show_relation_confidence:
1136 if ( _seq_relation_confidence_switch != null ) {
1137 _seq_relation_confidence_switch.setSelected( state );
1142 throw new AssertionError( "unknown checkbox: " + which );
1147 * Set this checkbox state. Not all checkboxes have been instantiated
1148 * depending on the config.
1150 void setCheckbox( final JCheckBox cb, final boolean state ) {
1152 cb.setSelected( state );
1156 void setClickToAction( final int action ) {
1157 // Set click-to action
1158 if ( action == _show_data_item ) {
1159 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1161 else if ( action == _collapse_cb_item ) {
1162 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1164 else if ( action == _reroot_cb_item ) {
1165 setActionWhenNodeClicked( NodeClickAction.REROOT );
1167 else if ( action == _subtree_cb_item ) {
1168 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1170 else if ( action == _swap_cb_item ) {
1171 setActionWhenNodeClicked( NodeClickAction.SWAP );
1173 else if ( action == _color_subtree_cb_item ) {
1174 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1176 else if ( action == _open_seq_web_item ) {
1177 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1179 else if ( action == _sort_descendents_item ) {
1180 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1182 else if ( action == _blast_item ) {
1183 setActionWhenNodeClicked( NodeClickAction.BLAST );
1185 else if ( action == _open_tax_web_item ) {
1186 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1188 else if ( action == _cut_subtree_item ) {
1189 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1191 else if ( action == _copy_subtree_item ) {
1192 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1194 else if ( action == _delete_node_or_subtree_item ) {
1195 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1197 else if ( action == _paste_subtree_item ) {
1198 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1200 else if ( action == _add_new_node_item ) {
1201 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1203 else if ( action == _edit_node_data_item ) {
1204 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1206 else if ( action == _select_nodes_item ) {
1207 setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
1209 else if ( action == _get_ext_desc_data ) {
1210 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
1212 else if ( action == _open_pdb_item ) {
1213 setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
1215 else if ( action == _color_node_font_item ) {
1216 setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
1218 else if ( action == _change_node_font_item ) {
1219 setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT );
1222 throw new RuntimeException( "unknown action: " + action );
1224 // make sure drop down is displaying the correct action
1225 // in case this was called from outside the class
1226 _click_to_combobox.setSelectedIndex( action );
1229 void setColorBranches( final boolean color_branches ) {
1230 _color_branches = color_branches;
1233 void setDrawPhylogram( final boolean b ) {
1234 getDisplayAsPhylogramCb().setSelected( b );
1235 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1238 void setDrawPhylogramEnabled( final boolean b ) {
1239 getDisplayAsPhylogramCb().setEnabled( b );
1242 void setDynamicHidingIsOn( final boolean is_on ) {
1243 // if ( !_configuration.isUseNativeUI() ) {
1245 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1248 if ( !_configuration.isUseNativeUI() ) {
1249 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1252 getDynamicallyHideData().setForeground( Color.BLACK );
1258 void setSearchFoundCountsOnLabel0( final int counts ) {
1259 getSearchFoundCountsLabel0().setText( "Found: " + counts );
1262 void setSearchFoundCountsOnLabel1( final int counts ) {
1263 getSearchFoundCountsLabel1().setText( "Found: " + counts );
1266 void setShowEvents( final boolean show_events ) {
1267 if ( getShowEventsCb() == null ) {
1268 _show_events = new JCheckBox( "" );
1270 getShowEventsCb().setSelected( show_events );
1273 void setSpeciesColors( final Map<String, Color> species_colors ) {
1274 _species_colors = species_colors;
1277 void setSequenceColors( final Map<String, Color> sequence_colors ) {
1278 _sequence_colors = sequence_colors;
1283 * Set up the controls from the config settings. 11/26/05
1285 void setupControls() {
1286 // The tree display options:
1287 setupDisplayCheckboxes();
1289 // The sequence relation query selection combo-box
1290 if ( _configuration.displaySequenceRelations() ) {
1291 addSequenceRelationBlock();
1295 startClickToOptions();
1296 setupClickToOptions();
1297 endClickToOptions();
1298 // Zoom and quick edit buttons
1300 setupSearchTools0();
1301 setupSearchTools1();
1304 void setUpControlsForDomainStrucures() {
1305 _domain_display_label = new JLabel( "Domain Display:" );
1306 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1307 add( _domain_display_label );
1308 _zoom_in_domain_structure = new JButton( "d+" );
1309 _zoom_out_domain_structure = new JButton( "d-" );
1310 _decr_domain_structure_evalue_thr = new JButton( "-" );
1311 _incr_domain_structure_evalue_thr = new JButton( "+" );
1312 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1313 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1314 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1315 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1316 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1317 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1318 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1319 _domain_structure_evalue_thr_tf.setEditable( false );
1320 if ( !getConfiguration().isUseNativeUI() ) {
1321 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1322 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1323 _domain_structure_evalue_thr_tf.setBorder( null );
1325 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1326 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1327 if ( !_configuration.isUseNativeUI() ) {
1328 d1_panel.setBackground( getBackground() );
1329 d2_panel.setBackground( getBackground() );
1333 addJButton( _zoom_out_domain_structure, d1_panel );
1334 addJButton( _zoom_in_domain_structure, d1_panel );
1335 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1336 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1337 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1340 void setupSearchTools0() {
1341 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1342 final JLabel search_label = new JLabel( "Search (A):" );
1343 search_label.setFont( ControlPanel.jcb_bold_font );
1344 if ( !getConfiguration().isUseNativeUI() ) {
1345 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1347 add( search_label );
1348 search_label.setToolTipText( tip );
1349 _search_found_label_0 = new JLabel();
1350 getSearchFoundCountsLabel0().setVisible( false );
1351 _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
1352 if ( !getConfiguration().isUseNativeUI() ) {
1353 _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1355 _search_tf_0 = new JTextField( 3 );
1356 _search_tf_0.setToolTipText( tip );
1357 _search_tf_0.setEditable( true );
1358 if ( !getConfiguration().isUseNativeUI() ) {
1359 _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1360 _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1361 _search_tf_0.setBorder( null );
1363 _search_reset_button_0 = new JButton();
1364 getSearchResetButton0().setText( "Reset" );
1365 getSearchResetButton0().setEnabled( false );
1366 getSearchResetButton0().setVisible( false );
1367 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1368 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1369 s_panel_1.setBackground( getBackground() );
1371 s_panel_2.setBackground( getBackground() );
1373 final KeyAdapter key_adapter = new KeyAdapter() {
1376 public void keyReleased( final KeyEvent key_event ) {
1378 displayedPhylogenyMightHaveChanged( true );
1381 final ActionListener action_listener = new ActionListener() {
1384 public void actionPerformed( final ActionEvent e ) {
1386 setSearchFoundCountsOnLabel0( 0 );
1387 getSearchFoundCountsLabel0().setVisible( false );
1388 getSearchTextField0().setText( "" );
1389 getSearchResetButton0().setEnabled( false );
1390 getSearchResetButton0().setVisible( false );
1391 displayedPhylogenyMightHaveChanged( true );
1394 _search_reset_button_0.addActionListener( action_listener );
1395 _search_tf_0.addKeyListener( key_adapter );
1396 addJTextField( _search_tf_0, s_panel_1 );
1397 s_panel_2.add( _search_found_label_0 );
1398 addJButton( _search_reset_button_0, s_panel_2 );
1401 void setupSearchTools1() {
1402 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1403 final JLabel search_label = new JLabel( "Search (B):" );
1404 search_label.setFont( ControlPanel.jcb_bold_font );
1405 if ( !getConfiguration().isUseNativeUI() ) {
1406 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1408 add( search_label );
1409 search_label.setToolTipText( tip );
1410 _search_found_label_1 = new JLabel();
1411 getSearchFoundCountsLabel1().setVisible( false );
1412 _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
1413 if ( !getConfiguration().isUseNativeUI() ) {
1414 _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1416 _search_tf_1 = new JTextField( 3 );
1417 _search_tf_1.setToolTipText( tip );
1418 _search_tf_1.setEditable( true );
1419 if ( !getConfiguration().isUseNativeUI() ) {
1420 _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1421 _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1422 _search_tf_1.setBorder( null );
1424 _search_reset_button_1 = new JButton();
1425 getSearchResetButton1().setText( "Reset" );
1426 getSearchResetButton1().setEnabled( false );
1427 getSearchResetButton1().setVisible( false );
1428 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1429 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1430 s_panel_1.setBackground( getBackground() );
1432 s_panel_2.setBackground( getBackground() );
1434 final KeyAdapter key_adapter = new KeyAdapter() {
1437 public void keyReleased( final KeyEvent key_event ) {
1439 displayedPhylogenyMightHaveChanged( true );
1442 final ActionListener action_listener = new ActionListener() {
1445 public void actionPerformed( final ActionEvent e ) {
1447 setSearchFoundCountsOnLabel1( 0 );
1448 getSearchFoundCountsLabel1().setVisible( false );
1449 getSearchTextField1().setText( "" );
1450 getSearchResetButton1().setEnabled( false );
1451 getSearchResetButton1().setVisible( false );
1452 displayedPhylogenyMightHaveChanged( true );
1455 _search_reset_button_1.addActionListener( action_listener );
1456 _search_tf_1.addKeyListener( key_adapter );
1457 addJTextField( _search_tf_1, s_panel_1 );
1458 s_panel_2.add( _search_found_label_1 );
1459 addJButton( _search_reset_button_1, s_panel_2 );
1462 void showAnnotations() {
1463 if ( _show_annotation != null ) {
1464 _show_annotation.setSelected( true );
1466 if ( _color_according_to_annotation != null ) {
1467 _color_according_to_annotation.setSelected( true );
1469 if ( _color_acc_species != null ) {
1470 _color_acc_species.setSelected( false );
1472 if ( _color_acc_sequence != null ) {
1473 _color_acc_sequence.setSelected( false );
1475 _mainpanel.getCurrentTreePanel().repaint();
1479 * Fit entire tree into window.
1482 if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
1485 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
1486 displayedPhylogenyMightHaveChanged( true );
1487 _mainpanel.getCurrentTreePanel().updateOvSettings();
1488 _mainpanel.getCurrentTreePanel().validate();
1489 _mainpanel.validate();
1490 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1491 _mainpanel.getSizeOfViewport().height,
1493 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1494 _mainpanel.adjustJScrollPane();
1495 _mainpanel.getCurrentTreePanel().repaint();
1496 _mainpanel.getCurrentTreePanel().validate();
1497 _mainpanel.validate();
1498 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1499 _mainpanel.getSizeOfViewport().height,
1501 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1502 _mainpanel.adjustJScrollPane();
1503 _mainpanel.getCurrentTreePanel().repaint();
1504 _mainpanel.getCurrentTreePanel().updateOvSizes();
1507 void showWholeAll() {
1508 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1509 if ( tree_panel != null ) {
1510 tree_panel.validate();
1511 tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1512 _mainpanel.getSizeOfViewport().height,
1514 tree_panel.resetPreferredSize();
1515 tree_panel.repaint();
1520 // Create header for click-to combo box.
1521 void startClickToOptions() {
1522 final JLabel spacer = new JLabel( "" );
1523 spacer.setFont( ControlPanel.jcb_font );
1525 _click_to_label = new JLabel( "Click on Node to:" );
1526 add( customizeLabel( _click_to_label, getConfiguration() ) );
1527 _click_to_combobox = new JComboBox();
1528 _click_to_combobox.setFocusable( false );
1529 _click_to_combobox.setMaximumRowCount( 14 );
1530 _click_to_combobox.setFont( ControlPanel.js_font );
1531 if ( !_configuration.isUseNativeUI() ) {
1532 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1534 // don't add listener until all items are set (or each one will trigger
1536 // click_to_list.addActionListener(this);
1537 add( _click_to_combobox );
1538 // Correlates option names to titles
1539 _all_click_to_names = new HashMap<Integer, String>();
1540 _click_to_names = new ArrayList<String>();
1544 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1545 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1546 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1547 setDrawPhylogramEnabled( true );
1548 setDrawPhylogram( isDrawPhylogram() );
1551 setDrawPhylogramEnabled( false );
1552 setDrawPhylogram( false );
1554 if ( getMainPanel().getMainFrame() == null ) {
1555 // Must be "E" applet version.
1556 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1557 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1560 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1561 .getPhylogenyGraphicsType() );
1563 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1564 getMainPanel().getControlPanel().search0();
1565 getMainPanel().getControlPanel().search1();
1566 getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
1567 getSequenceRelationTypeBox().removeAllItems();
1568 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1569 .getRelevantSequenceRelationTypes() ) {
1570 _sequence_relation_type_box.addItem( type );
1572 getMainPanel().getCurrentTreePanel().repaint();
1573 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1574 // according to GUILHEM the line above can be removed.
1579 * Uncollapse all nodes.
1581 void uncollapseAll( final TreePanel tp ) {
1582 final Phylogeny t = tp.getPhylogeny();
1583 if ( ( t != null ) && !t.isEmpty() ) {
1584 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
1585 final PhylogenyNode node = iter.next();
1586 node.setCollapse( false );
1588 tp.resetNodeIdToDistToLeafMap();
1589 tp.updateSetOfCollapsedExternalNodes();
1590 t.recalculateNumberOfExternalDescendants( false );
1591 tp.setNodeInPreorderToNull();
1592 t.clearHashIdToNodeMap();
1597 void updateDomainStructureEvaluethresholdDisplay() {
1598 if ( _domain_structure_evalue_thr_tf != null ) {
1599 _domain_structure_evalue_thr_tf.setText( "10^"
1600 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1604 void zoomInX( final float factor, final float x_correction_factor ) {
1605 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1606 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1607 treepanel.multiplyUrtFactor( 1f );
1608 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1609 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1610 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1611 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1612 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1613 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1614 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1615 getMainPanel().adjustJScrollPane();
1616 treepanel.resetPreferredSize();
1617 getMainPanel().getCurrentScrollPane().getViewport().validate();
1618 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1619 - ( sb.getVisibleAmount() / 2.0 ) ) );
1622 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1623 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1624 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1625 getMainPanel().adjustJScrollPane();
1626 treepanel.resetPreferredSize();
1627 getMainPanel().getCurrentScrollPane().getViewport().validate();
1628 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1630 treepanel.resetPreferredSize();
1631 treepanel.updateOvSizes();
1634 void zoomInY( final float factor ) {
1635 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1636 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1637 treepanel.multiplyUrtFactor( 1.1f );
1638 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1639 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1640 getMainPanel().adjustJScrollPane();
1641 treepanel.resetPreferredSize();
1642 getMainPanel().getCurrentScrollPane().getViewport().validate();
1643 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1644 - ( sb.getVisibleAmount() / 2.0 ) ) );
1645 treepanel.resetPreferredSize();
1646 treepanel.updateOvSizes();
1649 void zoomOutX( final float factor, final float x_correction_factor ) {
1650 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1651 treepanel.multiplyUrtFactor( 1f );
1652 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1653 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1654 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1655 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1656 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1657 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1658 getMainPanel().adjustJScrollPane();
1659 treepanel.resetPreferredSize();
1660 getMainPanel().getCurrentScrollPane().getViewport().validate();
1661 final double x = ( sb.getMaximum() - sb.getMinimum() )
1662 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1663 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1664 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1665 getMainPanel().adjustJScrollPane();
1666 treepanel.resetPreferredSize();
1667 getMainPanel().getCurrentScrollPane().getViewport().validate();
1668 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1669 - ( sb.getVisibleAmount() / 2.0 ) ) );
1672 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1673 treepanel.setXdistance( treepanel.getXdistance() * factor );
1674 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
1676 getMainPanel().adjustJScrollPane();
1677 treepanel.resetPreferredSize();
1678 getMainPanel().getCurrentScrollPane().getViewport().validate();
1679 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1682 treepanel.resetPreferredSize();
1683 treepanel.updateOvSizes();
1687 void zoomOutY( final float factor ) {
1688 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1689 treepanel.multiplyUrtFactor( 0.9f );
1690 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1691 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1692 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1693 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1694 getMainPanel().adjustJScrollPane();
1695 treepanel.resetPreferredSize();
1696 getMainPanel().getCurrentScrollPane().getViewport().validate();
1697 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1698 - ( sb.getVisibleAmount() / 2.0 ) ) );
1699 treepanel.resetPreferredSize();
1700 treepanel.updateOvSizes();
1704 private void addClickToOption( final int which, final String title ) {
1705 _click_to_combobox.addItem( title );
1706 _click_to_names.add( title );
1707 _all_click_to_names.put( new Integer( which ), title );
1708 if ( !_configuration.isUseNativeUI() ) {
1709 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1710 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
1715 private void addSequenceRelationBlock() {
1716 final JLabel spacer = new JLabel( "" );
1717 spacer.setSize( 1, 1 );
1719 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
1720 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
1721 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
1722 getSequenceRelationTypeBox().setFocusable( false );
1723 _sequence_relation_type_box.setFont( ControlPanel.js_font );
1724 if ( !_configuration.isUseNativeUI() ) {
1725 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1726 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
1728 _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
1731 public Component getListCellRendererComponent( final JList list,
1734 final boolean isSelected,
1735 final boolean cellHasFocus ) {
1736 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
1741 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
1742 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
1743 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
1748 final GridBagLayout gbl = new GridBagLayout();
1749 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
1750 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
1751 final JPanel horizGrid = new JPanel( gbl );
1752 horizGrid.setBackground( getBackground() );
1753 horizGrid.add( typeLabel );
1754 horizGrid.add( _sequence_relation_type_box );
1755 add( customizeLabel( mainLabel, getConfiguration() ) );
1757 add( getSequenceRelationBox() );
1758 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
1759 addCheckbox( Configuration.show_relation_confidence,
1760 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
1761 setCheckbox( Configuration.show_relation_confidence,
1762 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
1764 }// addSequenceRelationBlock
1767 private List<Boolean> getIsDrawPhylogramList() {
1768 return _draw_phylogram;
1771 private void init() {
1772 _draw_phylogram = new ArrayList<Boolean>();
1773 setSpeciesColors( new HashMap<String, Color>() );
1774 setSequenceColors( new HashMap<String, Color>() );
1775 setAnnotationColors( new HashMap<String, Color>() );
1778 private boolean isDrawPhylogram( final int index ) {
1779 return getIsDrawPhylogramList().get( index );
1782 private void search0( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
1783 getSearchFoundCountsLabel0().setVisible( true );
1784 getSearchResetButton0().setEnabled( true );
1785 getSearchResetButton0().setVisible( true );
1786 String[] queries = null;
1787 List<PhylogenyNode> nodes = null;
1788 if ( query_str.indexOf( ',' ) >= 0 ) {
1789 queries = query_str.split( ",+" );
1792 queries = new String[ 1 ];
1793 queries[ 0 ] = query_str.trim();
1795 if ( ( queries != null ) && ( queries.length > 0 ) ) {
1796 nodes = new ArrayList<PhylogenyNode>();
1797 for( String query : queries ) {
1798 if ( ForesterUtil.isEmpty( query ) ) {
1801 query = query.trim();
1802 if ( query.indexOf( '+' ) >= 0 ) {
1803 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
1805 getOptions().isSearchCaseSensitive(),
1806 !getOptions().isMatchWholeTermsOnly(),
1807 isShowDomainArchitectures() ) );
1810 nodes.addAll( PhylogenyMethods.searchData( query,
1812 getOptions().isSearchCaseSensitive(),
1813 !getOptions().isMatchWholeTermsOnly(),
1814 isShowDomainArchitectures() ) );
1817 if ( getOptions().isInverseSearchResult() ) {
1818 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
1819 all.removeAll( nodes );
1823 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
1824 main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet<Long>() );
1825 for( final PhylogenyNode node : nodes ) {
1826 main_panel.getCurrentTreePanel().getFoundNodes0().add( node.getId() );
1828 setSearchFoundCountsOnLabel0( nodes.size() );
1831 setSearchFoundCountsOnLabel0( 0 );
1836 private void search1( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
1837 getSearchFoundCountsLabel1().setVisible( true );
1838 getSearchResetButton1().setEnabled( true );
1839 getSearchResetButton1().setVisible( true );
1840 String[] queries = null;
1841 List<PhylogenyNode> nodes = null;
1842 if ( query_str.indexOf( ',' ) >= 0 ) {
1843 queries = query_str.split( ",+" );
1846 queries = new String[ 1 ];
1847 queries[ 0 ] = query_str.trim();
1849 if ( ( queries != null ) && ( queries.length > 0 ) ) {
1850 nodes = new ArrayList<PhylogenyNode>();
1851 for( String query : queries ) {
1852 if ( ForesterUtil.isEmpty( query ) ) {
1855 query = query.trim();
1856 if ( query.indexOf( '+' ) >= 0 ) {
1857 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
1859 getOptions().isSearchCaseSensitive(),
1860 !getOptions().isMatchWholeTermsOnly(),
1861 isShowDomainArchitectures() ) );
1864 nodes.addAll( PhylogenyMethods.searchData( query,
1866 getOptions().isSearchCaseSensitive(),
1867 !getOptions().isMatchWholeTermsOnly(),
1868 isShowDomainArchitectures() ) );
1871 if ( getOptions().isInverseSearchResult() ) {
1872 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
1873 all.removeAll( nodes );
1877 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
1878 main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet<Long>() );
1879 for( final PhylogenyNode node : nodes ) {
1880 main_panel.getCurrentTreePanel().getFoundNodes1().add( node.getId() );
1882 setSearchFoundCountsOnLabel1( nodes.size() );
1885 setSearchFoundCountsOnLabel1( 0 );
1890 private void setDrawPhylogram( final int index, final boolean b ) {
1891 getIsDrawPhylogramList().set( index, b );
1894 private void setupClickToOptions() {
1895 final int default_option = _configuration.getDefaultDisplayClicktoOption();
1896 int selected_index = 0;
1898 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1899 _show_data_item = cb_index;
1900 addClickToOption( Configuration.display_node_data,
1901 _configuration.getClickToTitle( Configuration.display_node_data ) );
1902 if ( default_option == Configuration.display_node_data ) {
1903 selected_index = cb_index;
1907 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1908 _collapse_cb_item = cb_index;
1909 addClickToOption( Configuration.collapse_uncollapse,
1910 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
1911 if ( default_option == Configuration.collapse_uncollapse ) {
1912 selected_index = cb_index;
1916 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1917 _reroot_cb_item = cb_index;
1918 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1919 if ( default_option == Configuration.reroot ) {
1920 selected_index = cb_index;
1924 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1925 _subtree_cb_item = cb_index;
1926 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1927 if ( default_option == Configuration.subtree ) {
1928 selected_index = cb_index;
1932 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1933 _swap_cb_item = cb_index;
1934 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1935 if ( default_option == Configuration.swap ) {
1936 selected_index = cb_index;
1940 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
1941 _sort_descendents_item = cb_index;
1942 addClickToOption( Configuration.sort_descendents,
1943 _configuration.getClickToTitle( Configuration.sort_descendents ) );
1944 if ( default_option == Configuration.sort_descendents ) {
1945 selected_index = cb_index;
1949 if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) {
1950 _color_node_font_item = cb_index;
1951 addClickToOption( Configuration.color_node_font,
1952 _configuration.getClickToTitle( Configuration.color_node_font ) );
1953 if ( default_option == Configuration.color_node_font ) {
1954 selected_index = cb_index;
1958 if ( _configuration.doDisplayClickToOption( Configuration.change_node_font ) ) {
1959 _change_node_font_item = cb_index;
1960 addClickToOption( Configuration.change_node_font,
1961 _configuration.getClickToTitle( Configuration.change_node_font ) );
1962 if ( default_option == Configuration.change_node_font ) {
1963 selected_index = cb_index;
1967 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1968 _color_subtree_cb_item = cb_index;
1969 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1970 if ( default_option == Configuration.color_subtree ) {
1971 selected_index = cb_index;
1975 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1976 _open_seq_web_item = cb_index;
1977 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1978 if ( default_option == Configuration.open_seq_web ) {
1979 selected_index = cb_index;
1983 if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
1984 _open_pdb_item = cb_index;
1985 addClickToOption( Configuration.open_pdb_web, _configuration.getClickToTitle( Configuration.open_pdb_web ) );
1986 if ( default_option == Configuration.open_pdb_web ) {
1987 selected_index = cb_index;
1991 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1992 _open_tax_web_item = cb_index;
1993 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1994 if ( default_option == Configuration.open_tax_web ) {
1995 selected_index = cb_index;
1999 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
2000 _blast_item = cb_index;
2001 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
2002 if ( default_option == Configuration.blast ) {
2003 selected_index = cb_index;
2007 if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
2008 _select_nodes_item = cb_index;
2009 addClickToOption( Configuration.select_nodes, _configuration.getClickToTitle( Configuration.select_nodes ) );
2010 if ( default_option == Configuration.select_nodes ) {
2011 selected_index = cb_index;
2015 if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
2016 _get_ext_desc_data = cb_index;
2017 if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
2018 addClickToOption( Configuration.get_ext_desc_data, getConfiguration()
2019 .getLabelForGetExtDescendentsData() );
2023 switch ( getConfiguration().getExtDescNodeDataToReturn() ) {
2028 s = "Sequence Accessors";
2030 case SEQUENCE_MOL_SEQ:
2031 s = "Molecular Sequence";
2033 case SEQUENCE_MOL_SEQ_FASTA:
2034 s = "Molecular Sequence (Fasta)";
2037 s = "Sequence Names";
2042 case SEQUENCE_SYMBOL:
2043 s = "Sequence Symbols";
2046 s = "Taxonomy Codes";
2048 case TAXONOMY_COMM0N_NAME:
2049 s = "Taxonomy Common Names";
2051 case TAXONOMY_SCIENTIFIC_NAME:
2052 s = "Scientific Names";
2055 s = "User Selected Data";
2058 final String label = _configuration.getClickToTitle( Configuration.get_ext_desc_data ) + " " + s;
2059 addClickToOption( Configuration.get_ext_desc_data, label );
2061 if ( default_option == Configuration.get_ext_desc_data ) {
2062 selected_index = cb_index;
2066 if ( getOptions().isEditable() ) {
2067 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
2068 _cut_subtree_item = cb_index;
2069 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
2070 if ( default_option == Configuration.cut_subtree ) {
2071 selected_index = cb_index;
2075 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
2076 _copy_subtree_item = cb_index;
2077 addClickToOption( Configuration.copy_subtree,
2078 _configuration.getClickToTitle( Configuration.copy_subtree ) );
2079 if ( default_option == Configuration.copy_subtree ) {
2080 selected_index = cb_index;
2084 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
2085 _paste_subtree_item = cb_index;
2086 addClickToOption( Configuration.paste_subtree,
2087 _configuration.getClickToTitle( Configuration.paste_subtree ) );
2088 if ( default_option == Configuration.paste_subtree ) {
2089 selected_index = cb_index;
2093 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
2094 _delete_node_or_subtree_item = cb_index;
2095 addClickToOption( Configuration.delete_subtree_or_node,
2096 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
2097 if ( default_option == Configuration.delete_subtree_or_node ) {
2098 selected_index = cb_index;
2102 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
2103 _add_new_node_item = cb_index;
2104 addClickToOption( Configuration.add_new_node,
2105 _configuration.getClickToTitle( Configuration.add_new_node ) );
2106 if ( default_option == Configuration.add_new_node ) {
2107 selected_index = cb_index;
2111 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
2112 _edit_node_data_item = cb_index;
2113 addClickToOption( Configuration.edit_node_data,
2114 _configuration.getClickToTitle( Configuration.edit_node_data ) );
2115 if ( default_option == Configuration.edit_node_data ) {
2116 selected_index = cb_index;
2121 // Set default selection and its action
2122 _click_to_combobox.setSelectedIndex( selected_index );
2123 setClickToAction( selected_index );
2126 private void setupDisplayCheckboxes() {
2127 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
2128 addCheckbox( Configuration.display_as_phylogram,
2129 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
2130 setCheckbox( Configuration.display_as_phylogram,
2131 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
2133 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
2134 addCheckbox( Configuration.dynamically_hide_data,
2135 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
2136 setCheckbox( Configuration.dynamically_hide_data,
2137 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
2139 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
2140 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
2141 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
2143 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
2144 addCheckbox( Configuration.display_internal_data,
2145 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
2146 setCheckbox( Configuration.display_internal_data,
2147 _configuration.doCheckOption( Configuration.display_internal_data ) );
2151 if ( _configuration.doDisplayOption( Configuration.color_according_to_sequence ) ) {
2152 addCheckbox( Configuration.color_according_to_sequence,
2153 _configuration.getDisplayTitle( Configuration.color_according_to_sequence ) );
2154 setCheckbox( Configuration.color_according_to_sequence,
2155 _configuration.doCheckOption( Configuration.color_according_to_sequence ) );
2161 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
2162 addCheckbox( Configuration.color_according_to_species,
2163 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
2164 setCheckbox( Configuration.color_according_to_species,
2165 _configuration.doCheckOption( Configuration.color_according_to_species ) );
2167 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
2168 addCheckbox( Configuration.color_according_to_annotation,
2169 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
2170 setCheckbox( Configuration.color_according_to_annotation,
2171 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
2173 if ( _configuration.doDisplayOption( Configuration.use_style ) ) {
2174 addCheckbox( Configuration.use_style, _configuration.getDisplayTitle( Configuration.use_style ) );
2175 setCheckbox( Configuration.use_style, _configuration.doCheckOption( Configuration.use_style ) );
2177 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
2178 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
2179 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
2181 final JLabel label = new JLabel( "Display Data:" );
2182 label.setFont( ControlPanel.jcb_bold_font );
2183 if ( !getConfiguration().isUseNativeUI() ) {
2184 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2187 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
2188 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
2189 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
2191 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
2192 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
2193 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
2195 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
2196 addCheckbox( Configuration.show_taxonomy_scientific_names,
2197 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
2198 setCheckbox( Configuration.show_taxonomy_scientific_names,
2199 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
2201 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
2202 addCheckbox( Configuration.show_taxonomy_common_names,
2203 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
2204 setCheckbox( Configuration.show_taxonomy_common_names,
2205 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
2207 if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
2208 addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
2209 setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
2211 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
2212 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
2213 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
2215 if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
2216 addCheckbox( Configuration.show_seq_symbols,
2217 _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
2218 setCheckbox( Configuration.show_seq_symbols, _configuration.doCheckOption( Configuration.show_seq_symbols ) );
2220 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
2221 addCheckbox( Configuration.show_sequence_acc,
2222 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
2223 setCheckbox( Configuration.show_sequence_acc,
2224 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
2226 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
2227 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
2228 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
2230 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
2231 addCheckbox( Configuration.show_binary_characters,
2232 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
2233 setCheckbox( Configuration.show_binary_characters,
2234 _configuration.doCheckOption( Configuration.show_binary_characters ) );
2236 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
2237 addCheckbox( Configuration.show_binary_character_counts,
2238 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
2239 setCheckbox( Configuration.show_binary_character_counts,
2240 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
2242 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
2243 addCheckbox( Configuration.show_domain_architectures,
2244 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
2245 setCheckbox( Configuration.show_domain_architectures,
2246 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
2248 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
2249 addCheckbox( Configuration.write_confidence_values,
2250 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
2251 setCheckbox( Configuration.write_confidence_values,
2252 _configuration.doCheckOption( Configuration.write_confidence_values ) );
2254 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
2255 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
2256 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
2258 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
2259 addCheckbox( Configuration.show_vector_data,
2260 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
2261 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
2263 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
2264 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
2265 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
2267 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
2268 addCheckbox( Configuration.show_taxonomy_images,
2269 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
2270 setCheckbox( Configuration.show_taxonomy_images,
2271 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
2275 private void setVisibilityOfDomainStrucureControls() {
2276 if ( _zoom_in_domain_structure != null ) {
2277 if ( isShowDomainArchitectures() ) {
2278 _domain_display_label.setVisible( true );
2279 _zoom_in_domain_structure.setVisible( true );
2280 _zoom_out_domain_structure.setVisible( true );
2281 _decr_domain_structure_evalue_thr.setVisible( true );
2282 _incr_domain_structure_evalue_thr.setVisible( true );
2283 _domain_structure_evalue_thr_tf.setVisible( true );
2286 _domain_display_label.setVisible( false );
2287 _zoom_in_domain_structure.setVisible( false );
2288 _zoom_out_domain_structure.setVisible( false );
2289 _decr_domain_structure_evalue_thr.setVisible( false );
2290 _incr_domain_structure_evalue_thr.setVisible( false );
2291 _domain_structure_evalue_thr_tf.setVisible( false );
2296 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2297 label.setFont( ControlPanel.jcb_bold_font );
2298 if ( !configuration.isUseNativeUI() ) {
2299 label.setForeground( configuration.getGuiCheckboxTextColor() );
2300 label.setBackground( configuration.getGuiBackgroundColor() );
2305 enum NodeClickAction {
2312 DELETE_NODE_OR_SUBTREE,