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 int _select_nodes_item;
126 private Sequence _selected_query_seq;
127 private JCheckBox _seq_relation_confidence_switch;
128 private JComboBox _sequence_relation_type_box;
129 private JCheckBox _show_annotation;
130 private JCheckBox _show_binary_character_counts;
131 private JCheckBox _show_binary_characters;
133 private JLabel _search_found_label_0;
134 private JButton _search_reset_button_0;
135 private JTextField _search_tf_0;
136 private JLabel _search_found_label_1;
137 private JButton _search_reset_button_1;
138 private JTextField _search_tf_1;
140 // Indices for the click-to options in the combo box
141 private int _show_data_item;
142 private JCheckBox _show_domain_architectures;
143 private JCheckBox _show_events;
144 private JCheckBox _show_gene_names;
145 private JCheckBox _show_node_names;
146 private JCheckBox _show_properties_cb;
147 private JCheckBox _show_seq_names;
148 private JCheckBox _show_seq_symbols;
149 private JCheckBox _show_sequence_acc;
150 private JComboBox _show_sequence_relations;
151 private JCheckBox _show_taxo_code;
152 private JCheckBox _show_taxo_common_names;
153 private JCheckBox _show_taxo_images_cb;
154 private JCheckBox _show_taxo_scientific_names;
155 private JCheckBox _show_vector_data_cb;
156 private JButton _show_whole;
157 private int _sort_descendents_item;
158 private Map<String, Color> _species_colors;
159 private int _subtree_cb_item;
160 private int _swap_cb_item;
161 private JButton _uncollapse_all;
162 private JCheckBox _width_branches;
163 private JCheckBox _write_confidence;
164 private JButton _zoom_in_domain_structure;
165 // zooming and quick tree manipulation buttons:
166 private JButton _zoom_in_x;
167 private JButton _zoom_in_y;
168 private JLabel _zoom_label;
169 private JButton _zoom_out_domain_structure;
170 private JButton _zoom_out_x;
171 private JButton _zoom_out_y;
173 ControlPanel( final MainPanel ap, final Configuration configuration ) {
176 _configuration = configuration;
177 if ( !_configuration.isUseNativeUI() ) {
178 setBackground( getConfiguration().getGuiBackgroundColor() );
179 setBorder( BorderFactory.createRaisedBevelBorder() );
181 setLayout( new GridLayout( 0, 1, 2, 2 ) );
182 _order_of_appearance = true;
190 public void actionPerformed( final ActionEvent e ) {
192 final TreePanel tp = getMainPanel().getCurrentTreePanel();
196 if ( e.getSource() == _click_to_combobox ) {
197 setClickToAction( _click_to_combobox.getSelectedIndex() );
198 getCurrentTreePanel().repaint();
200 else if ( e.getSource() == _show_binary_characters ) {
201 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
202 _show_binary_character_counts.setSelected( false );
204 displayedPhylogenyMightHaveChanged( true );
206 else if ( e.getSource() == _show_binary_character_counts ) {
207 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
208 _show_binary_characters.setSelected( false );
210 displayedPhylogenyMightHaveChanged( true );
212 else if ( e.getSource() == _show_domain_architectures ) {
215 displayedPhylogenyMightHaveChanged( true );
217 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
218 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
219 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
223 else if ( e.getSource() == _zoom_in_x ) {
224 zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
225 displayedPhylogenyMightHaveChanged( false );
227 else if ( e.getSource() == _zoom_in_y ) {
228 zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR );
229 displayedPhylogenyMightHaveChanged( false );
231 else if ( e.getSource() == _zoom_out_x ) {
232 zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
233 displayedPhylogenyMightHaveChanged( false );
235 else if ( e.getSource() == _zoom_out_y ) {
236 zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR );
237 displayedPhylogenyMightHaveChanged( false );
239 else if ( e.getSource() == _show_whole ) {
242 else if ( e.getSource() == _return_to_super_tree ) {
243 _mainpanel.getCurrentTreePanel().superTree();
246 else if ( e.getSource() == _order ) {
247 DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
248 if ( ( !isShowTaxonomyScientificNames() && !isShowTaxonomyCode() && !isShowTaxonomyCommonNames() ) ) {
249 if ( ( isShowSequenceAcc() || isShowSeqNames() || isShowSeqSymbols() ) ) {
250 pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
252 else if ( isShowNodeNames() ) {
253 pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
256 PhylogenyMethods.orderAppearance( tp.getPhylogeny().getRoot(), _order_of_appearance, true, pri );
257 _order_of_appearance = !_order_of_appearance;
258 tp.setNodeInPreorderToNull();
259 tp.getPhylogeny().externalNodesHaveChanged();
260 tp.getPhylogeny().clearHashIdToNodeMap();
261 tp.getPhylogeny().recalculateNumberOfExternalDescendants( true );
262 tp.resetNodeIdToDistToLeafMap();
263 tp.setEdited( true );
264 displayedPhylogenyMightHaveChanged( false );
266 else if ( e.getSource() == _uncollapse_all ) {
268 displayedPhylogenyMightHaveChanged( false );
270 else if ( e.getSource() == _zoom_in_domain_structure ) {
271 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
272 displayedPhylogenyMightHaveChanged( true );
274 else if ( e.getSource() == _zoom_out_domain_structure ) {
275 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
276 displayedPhylogenyMightHaveChanged( true );
278 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
279 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThreshold();
280 displayedPhylogenyMightHaveChanged( true );
282 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
283 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThreshold();
284 displayedPhylogenyMightHaveChanged( true );
286 else if ( e.getSource() == _search_tf_0 ) {
288 displayedPhylogenyMightHaveChanged( true );
290 else if ( e.getSource() == _search_tf_1 ) {
292 displayedPhylogenyMightHaveChanged( true );
295 displayedPhylogenyMightHaveChanged( true );
299 tp.requestFocusInWindow();
302 catch ( final Exception ex ) {
303 AptxUtil.unexpectedException( ex );
305 catch ( final Error err ) {
306 AptxUtil.unexpectedError( err );
310 public JCheckBox getColorAccSpeciesCb() {
311 return _color_acc_species;
314 public JCheckBox getColorBranchesCb() {
315 return _color_branches_cb;
318 public JCheckBox getDisplayAsPhylogramCb() {
319 return _display_as_phylogram_cb;
322 public JCheckBox getDynamicallyHideData() {
323 return _dynamically_hide_data;
326 public JCheckBox getNodeDescPopupCb() {
327 return _node_desc_popup_cb;
330 public Sequence getSelectedQuerySequence() {
331 return _selected_query_seq;
334 public JComboBox getSequenceRelationBox() {
335 if ( _show_sequence_relations == null ) {
336 _show_sequence_relations = new JComboBox();
337 _show_sequence_relations.setFocusable( false );
338 _show_sequence_relations.setMaximumRowCount( 20 );
339 _show_sequence_relations.setFont( ControlPanel.js_font );
340 if ( !_configuration.isUseNativeUI() ) {
341 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
342 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
344 _show_sequence_relations.addItem( "-----" );
345 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
347 return _show_sequence_relations;
351 public JComboBox getSequenceRelationTypeBox() {
352 if ( _sequence_relation_type_box == null ) {
353 _sequence_relation_type_box = new JComboBox();
354 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
355 _sequence_relation_type_box.addItem( type );
357 _sequence_relation_type_box.addActionListener( new ActionListener() {
360 public void actionPerformed( final ActionEvent e ) {
361 if ( _mainpanel.getCurrentPhylogeny() != null ) {
362 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
367 return _sequence_relation_type_box;
370 public JCheckBox getShowEventsCb() {
374 public JCheckBox getWriteConfidenceCb() {
375 return _write_confidence;
378 public boolean isShowProperties() {
379 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
382 public boolean isShowTaxonomyImages() {
383 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
386 public boolean isShowVectorData() {
387 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
390 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
391 final JComboBox box = getSequenceRelationBox();
392 while ( box.getItemCount() > 1 ) {
393 box.removeItemAt( 1 );
395 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
396 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
398 if ( relationType == null ) {
401 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
402 for( final Sequence seq : sequenceRelationQueries ) {
403 if ( seq.hasSequenceRelations() ) {
404 boolean fFoundForCurrentType = false;
405 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
406 if ( sq.getType().equals( relationType ) ) {
407 fFoundForCurrentType = true;
411 if ( fFoundForCurrentType ) {
412 sequenceNamesToAdd.add( seq.getName() );
413 sequencesByName.put( seq.getName(), seq );
417 // sort sequences by name before adding them to the combo
418 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
419 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
420 for( final String seqName : sequenceNameArray ) {
421 box.addItem( seqName );
423 for( final ItemListener oldItemListener : box.getItemListeners() ) {
424 box.removeItemListener( oldItemListener );
426 box.addItemListener( new ItemListener() {
429 public void itemStateChanged( final ItemEvent e ) {
430 _selected_query_seq = sequencesByName.get( e.getItem() );
431 _mainpanel.getCurrentTreePanel().repaint();
436 void activateButtonToReturnToSuperTree( int index ) {
439 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
442 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
444 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
445 _return_to_super_tree.setEnabled( true );
449 * Add zoom and quick edit buttons. (Last modified 8/9/04)
452 final JLabel spacer = new JLabel( "" );
453 spacer.setOpaque( false );
455 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
456 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
457 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
458 if ( !getConfiguration().isUseNativeUI() ) {
459 x_panel.setBackground( getBackground() );
460 y_panel.setBackground( getBackground() );
461 z_panel.setBackground( getBackground() );
463 add( _zoom_label = new JLabel( "Zoom:" ) );
464 customizeLabel( _zoom_label, getConfiguration() );
468 if ( getConfiguration().isUseNativeUI() ) {
469 _zoom_in_x = new JButton( "+" );
470 _zoom_out_x = new JButton( "-" );
473 _zoom_in_x = new JButton( "X+" );
474 _zoom_out_x = new JButton( "X-" );
476 _zoom_in_y = new JButton( "Y+" );
477 _zoom_out_y = new JButton( "Y-" );
478 _show_whole = new JButton( "F" );
479 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [F or Home]" );
480 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+cursor-right]" );
481 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+cursor-up]" );
482 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+cursor-left]" );
483 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+cursor-down]" );
484 if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) {
485 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
486 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
489 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
490 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
492 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
493 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
494 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
495 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
496 _return_to_super_tree.setEnabled( false );
497 _order = new JButton( "Order Subtrees" );
498 _uncollapse_all = new JButton( "Uncollapse All" );
499 addJButton( _zoom_in_y, x_panel );
500 addJButton( _zoom_out_x, y_panel );
501 addJButton( _show_whole, y_panel );
502 addJButton( _zoom_in_x, y_panel );
503 addJButton( _zoom_out_y, z_panel );
504 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
505 setUpControlsForDomainStrucures();
507 final JLabel spacer2 = new JLabel( "" );
509 addJButton( _return_to_super_tree, this );
510 addJButton( _order, this );
511 addJButton( _uncollapse_all, this );
512 final JLabel spacer3 = new JLabel( "" );
514 setVisibilityOfDomainStrucureControls();
517 void addCheckbox( final int which, final String title ) {
518 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
520 case Configuration.display_as_phylogram:
521 _display_as_phylogram_cb = new JCheckBox( title );
522 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
523 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
526 case Configuration.display_internal_data:
527 _display_internal_data = new JCheckBox( title );
528 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
529 addJCheckBox( _display_internal_data, ch_panel );
532 case Configuration.color_according_to_species:
533 _color_acc_species = new JCheckBox( title );
535 .setToolTipText( "To colorize taxonomy and sequence labels as a function of taxonomy" );
536 addJCheckBox( _color_acc_species, ch_panel );
539 case Configuration.color_according_to_annotation:
540 _color_according_to_annotation = new JCheckBox( title );
541 _color_according_to_annotation
542 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
543 addJCheckBox( _color_according_to_annotation, ch_panel );
546 case Configuration.show_node_names:
547 _show_node_names = new JCheckBox( title );
548 addJCheckBox( _show_node_names, ch_panel );
551 case Configuration.show_taxonomy_scientific_names:
552 _show_taxo_scientific_names = new JCheckBox( title );
553 addJCheckBox( _show_taxo_scientific_names, ch_panel );
556 case Configuration.show_taxonomy_common_names:
557 _show_taxo_common_names = new JCheckBox( title );
558 addJCheckBox( _show_taxo_common_names, ch_panel );
561 case Configuration.show_tax_code:
562 _show_taxo_code = new JCheckBox( title );
563 addJCheckBox( _show_taxo_code, ch_panel );
566 case Configuration.show_taxonomy_images:
567 _show_taxo_images_cb = new JCheckBox( title );
568 addJCheckBox( _show_taxo_images_cb, ch_panel );
571 case Configuration.show_binary_characters:
572 _show_binary_characters = new JCheckBox( title );
573 addJCheckBox( _show_binary_characters, ch_panel );
576 case Configuration.show_annotation:
577 _show_annotation = new JCheckBox( title );
578 addJCheckBox( _show_annotation, ch_panel );
581 case Configuration.show_binary_character_counts:
582 _show_binary_character_counts = new JCheckBox( title );
583 addJCheckBox( _show_binary_character_counts, ch_panel );
586 case Configuration.write_confidence_values:
587 _write_confidence = new JCheckBox( title );
588 addJCheckBox( getWriteConfidenceCb(), ch_panel );
591 case Configuration.write_events:
592 _show_events = new JCheckBox( title );
593 addJCheckBox( getShowEventsCb(), ch_panel );
596 case Configuration.color_branches:
597 _color_branches_cb = new JCheckBox( title );
598 getColorBranchesCb().setToolTipText( "To use branch color values, if present" );
599 addJCheckBox( getColorBranchesCb(), ch_panel );
602 case Configuration.width_branches:
603 _width_branches = new JCheckBox( title );
604 _width_branches.setToolTipText( "To use branch width values, if present" );
605 addJCheckBox( _width_branches, ch_panel );
608 case Configuration.show_domain_architectures:
609 _show_domain_architectures = new JCheckBox( title );
610 addJCheckBox( _show_domain_architectures, ch_panel );
613 case Configuration.show_seq_names:
614 _show_seq_names = new JCheckBox( title );
615 addJCheckBox( _show_seq_names, ch_panel );
618 case Configuration.show_gene_names:
619 _show_gene_names = new JCheckBox( title );
620 addJCheckBox( _show_gene_names, ch_panel );
623 case Configuration.show_seq_symbols:
624 _show_seq_symbols = new JCheckBox( title );
625 addJCheckBox( _show_seq_symbols, ch_panel );
628 case Configuration.show_sequence_acc:
629 _show_sequence_acc = new JCheckBox( title );
630 addJCheckBox( _show_sequence_acc, ch_panel );
633 case Configuration.dynamically_hide_data:
634 _dynamically_hide_data = new JCheckBox( title );
635 getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" );
636 addJCheckBox( getDynamicallyHideData(), ch_panel );
639 case Configuration.node_data_popup:
640 _node_desc_popup_cb = new JCheckBox( title );
641 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
642 addJCheckBox( getNodeDescPopupCb(), ch_panel );
645 case Configuration.show_relation_confidence:
646 _seq_relation_confidence_switch = new JCheckBox( title );
647 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
650 case Configuration.show_vector_data:
651 _show_vector_data_cb = new JCheckBox( title );
652 addJCheckBox( _show_vector_data_cb, ch_panel );
655 case Configuration.show_properties:
656 _show_properties_cb = new JCheckBox( title );
657 addJCheckBox( _show_properties_cb, ch_panel );
661 throw new RuntimeException( "unknown checkbox: " + which );
665 void addJButton( final JButton jb, final JPanel p ) {
666 jb.setFocusPainted( false );
667 jb.setFont( ControlPanel.jcb_font );
668 if ( !_configuration.isUseNativeUI() ) {
669 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
670 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
671 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
674 jb.addActionListener( this );
677 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
678 jcb.setFocusPainted( false );
679 jcb.setFont( ControlPanel.jcb_font );
680 if ( !_configuration.isUseNativeUI() ) {
681 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
682 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
684 p.add( jcb, "Center" );
685 jcb.addActionListener( this );
688 void addJTextField( final JTextField tf, final JPanel p ) {
689 if ( !_configuration.isUseNativeUI() ) {
690 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
691 tf.setFont( ControlPanel.jcb_font );
694 tf.addActionListener( this );
697 void deactivateButtonToReturnToSuperTree() {
698 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
699 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
700 _return_to_super_tree.setEnabled( false );
703 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
704 if ( ( _mainpanel != null )
705 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
706 if ( getOptions().isShowOverview() ) {
707 _mainpanel.getCurrentTreePanel().updateOvSizes();
709 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
710 setVisibilityOfDomainStrucureControls();
711 updateDomainStructureEvaluethresholdDisplay();
712 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
713 _mainpanel.getCurrentTreePanel().calcMaxDepth();
714 _mainpanel.adjustJScrollPane();
715 if ( recalc_longest_ext_node_info ) {
716 _mainpanel.getCurrentTreePanel().initNodeData();
717 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
719 _mainpanel.getCurrentTreePanel().repaint();
720 // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
724 void endClickToOptions() {
725 _click_to_combobox.addActionListener( this );
729 * Indicates what action should be execute when a node is clicked
731 * @return the click-on action
733 NodeClickAction getActionWhenNodeClicked() {
734 return _action_when_node_clicked;
737 Map<Integer, String> getAllClickToItems() {
738 return _all_click_to_names;
741 Map<String, Color> getAnnotationColors() {
742 return _annotation_colors;
745 Configuration getConfiguration() {
746 return _configuration;
749 TreePanel getCurrentTreePanel() {
750 return getMainPanel().getCurrentTreePanel();
753 MainPanel getMainPanel() {
757 Options getOptions() {
758 return getMainPanel().getOptions();
761 JLabel getSearchFoundCountsLabel0() {
762 return _search_found_label_0;
765 JLabel getSearchFoundCountsLabel1() {
766 return _search_found_label_1;
769 JButton getSearchResetButton0() {
770 return _search_reset_button_0;
773 JButton getSearchResetButton1() {
774 return _search_reset_button_1;
777 JTextField getSearchTextField0() {
781 JTextField getSearchTextField1() {
785 List<String> getSingleClickToNames() {
786 return _click_to_names;
789 Map<String, Color> getSpeciesColors() {
790 return _species_colors;
793 boolean isAntialiasScreenText() {
797 boolean isColorAccordingToAnnotation() {
798 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
801 boolean isColorAccordingToTaxonomy() {
802 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
805 boolean isColorBranches() {
806 return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) );
809 boolean isDrawPhylogram() {
810 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
813 boolean isDynamicallyHideData() {
814 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
818 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
821 boolean isNodeDescPopup() {
822 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
825 boolean isShowAnnotation() {
826 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
829 boolean isShowBinaryCharacterCounts() {
830 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
833 boolean isShowBinaryCharacters() {
834 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
837 boolean isShowConfidenceValues() {
838 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
841 boolean isShowDomainArchitectures() {
842 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
845 boolean isShowGeneNames() {
846 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
849 boolean isShowInternalData() {
850 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
853 boolean isShowNodeNames() {
854 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
857 boolean isShowSeqNames() {
858 return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
861 boolean isShowSeqSymbols() {
862 return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
865 boolean isShowSequenceAcc() {
866 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
869 boolean isShowSequenceRelationConfidence() {
870 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
873 boolean isShowSequenceRelations() {
874 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
877 boolean isShowTaxonomyCode() {
878 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
881 boolean isShowTaxonomyCommonNames() {
882 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
885 boolean isShowTaxonomyScientificNames() {
886 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
889 boolean isWidthBranches() {
890 return ( ( _width_branches != null ) && _width_branches.isSelected() );
893 void phylogenyAdded( final Configuration configuration ) {
894 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
897 void phylogenyRemoved( final int index ) {
898 getIsDrawPhylogramList().remove( index );
902 final MainPanel main_panel = getMainPanel();
903 final Phylogeny tree = main_panel.getCurrentPhylogeny();
904 if ( ( tree == null ) || tree.isEmpty() ) {
907 String query = getSearchTextField0().getText();
908 if ( query != null ) {
909 query = query.trim();
913 if ( !ForesterUtil.isEmpty( query ) ) {
914 search0( main_panel, tree, query );
917 getSearchFoundCountsLabel0().setVisible( false );
918 getSearchResetButton0().setEnabled( false );
919 getSearchResetButton0().setVisible( false );
925 final MainPanel main_panel = getMainPanel();
926 final Phylogeny tree = main_panel.getCurrentPhylogeny();
927 if ( ( tree == null ) || tree.isEmpty() ) {
930 String query = getSearchTextField1().getText();
931 if ( query != null ) {
932 query = query.trim();
935 if ( !ForesterUtil.isEmpty( query ) ) {
936 search1( main_panel, tree, query );
939 getSearchFoundCountsLabel1().setVisible( false );
940 getSearchResetButton1().setEnabled( false );
941 getSearchResetButton1().setVisible( false );
948 void searchReset0() {
949 if ( getMainPanel().getCurrentTreePanel() != null ) {
950 getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
954 void searchReset1() {
955 if ( getMainPanel().getCurrentTreePanel() != null ) {
956 getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
960 void setActionWhenNodeClicked( final NodeClickAction action ) {
961 _action_when_node_clicked = action;
964 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
965 _annotation_colors = annotation_colors;
968 void setCheckbox( final int which, final boolean state ) {
970 case Configuration.display_as_phylogram:
971 if ( getDisplayAsPhylogramCb() != null ) {
972 getDisplayAsPhylogramCb().setSelected( state );
975 case Configuration.display_internal_data:
976 if ( _display_internal_data != null ) {
977 _display_internal_data.setSelected( state );
980 case Configuration.color_according_to_species:
981 if ( _color_acc_species != null ) {
982 _color_acc_species.setSelected( state );
985 case Configuration.color_according_to_annotation:
986 if ( _color_according_to_annotation != null ) {
987 _color_according_to_annotation.setSelected( state );
990 case Configuration.show_node_names:
991 if ( _show_node_names != null ) {
992 _show_node_names.setSelected( state );
995 case Configuration.show_taxonomy_scientific_names:
996 if ( _show_taxo_scientific_names != null ) {
997 _show_taxo_scientific_names.setSelected( state );
1000 case Configuration.show_taxonomy_common_names:
1001 if ( _show_taxo_common_names != null ) {
1002 _show_taxo_common_names.setSelected( state );
1005 case Configuration.show_tax_code:
1006 if ( _show_taxo_code != null ) {
1007 _show_taxo_code.setSelected( state );
1010 case Configuration.show_taxonomy_images:
1011 if ( _show_taxo_images_cb != null ) {
1012 _show_taxo_images_cb.setSelected( state );
1015 case Configuration.show_annotation:
1016 if ( _show_annotation != null ) {
1017 _show_annotation.setSelected( state );
1020 case Configuration.show_binary_characters:
1021 if ( _show_binary_characters != null ) {
1022 _show_binary_characters.setSelected( state );
1025 case Configuration.show_binary_character_counts:
1026 if ( _show_binary_character_counts != null ) {
1027 _show_binary_character_counts.setSelected( state );
1030 case Configuration.write_confidence_values:
1031 if ( getWriteConfidenceCb() != null ) {
1032 getWriteConfidenceCb().setSelected( state );
1035 case Configuration.write_events:
1036 if ( getShowEventsCb() != null ) {
1037 getShowEventsCb().setSelected( state );
1040 case Configuration.color_branches:
1041 if ( getColorBranchesCb() != null ) {
1042 getColorBranchesCb().setSelected( state );
1045 case Configuration.width_branches:
1046 if ( _width_branches != null ) {
1047 _width_branches.setSelected( state );
1050 case Configuration.show_domain_architectures:
1051 if ( _show_domain_architectures != null ) {
1052 _show_domain_architectures.setSelected( state );
1055 case Configuration.show_seq_names:
1056 if ( _show_seq_names != null ) {
1057 _show_seq_names.setSelected( state );
1060 case Configuration.show_gene_names:
1061 if ( _show_gene_names != null ) {
1062 _show_gene_names.setSelected( state );
1065 case Configuration.show_seq_symbols:
1066 if ( _show_seq_symbols != null ) {
1067 _show_seq_symbols.setSelected( state );
1070 case Configuration.show_vector_data:
1071 if ( _show_vector_data_cb != null ) {
1072 _show_vector_data_cb.setSelected( state );
1075 case Configuration.show_properties:
1076 if ( _show_properties_cb != null ) {
1077 _show_properties_cb.setSelected( state );
1080 case Configuration.show_sequence_acc:
1081 if ( _show_sequence_acc != null ) {
1082 _show_sequence_acc.setSelected( state );
1085 case Configuration.dynamically_hide_data:
1086 if ( getDynamicallyHideData() != null ) {
1087 getDynamicallyHideData().setSelected( state );
1090 case Configuration.node_data_popup:
1091 if ( getNodeDescPopupCb() != null ) {
1092 getNodeDescPopupCb().setSelected( state );
1096 case Configuration.show_relation_confidence:
1097 if ( _seq_relation_confidence_switch != null ) {
1098 _seq_relation_confidence_switch.setSelected( state );
1103 throw new AssertionError( "unknown checkbox: " + which );
1108 * Set this checkbox state. Not all checkboxes have been instantiated
1109 * depending on the config.
1111 void setCheckbox( final JCheckBox cb, final boolean state ) {
1113 cb.setSelected( state );
1117 void setClickToAction( final int action ) {
1118 // Set click-to action
1119 if ( action == _show_data_item ) {
1120 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1122 else if ( action == _collapse_cb_item ) {
1123 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1125 else if ( action == _reroot_cb_item ) {
1126 setActionWhenNodeClicked( NodeClickAction.REROOT );
1128 else if ( action == _subtree_cb_item ) {
1129 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1131 else if ( action == _swap_cb_item ) {
1132 setActionWhenNodeClicked( NodeClickAction.SWAP );
1134 else if ( action == _color_subtree_cb_item ) {
1135 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1137 else if ( action == _open_seq_web_item ) {
1138 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1140 else if ( action == _sort_descendents_item ) {
1141 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1143 else if ( action == _blast_item ) {
1144 setActionWhenNodeClicked( NodeClickAction.BLAST );
1146 else if ( action == _open_tax_web_item ) {
1147 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1149 else if ( action == _cut_subtree_item ) {
1150 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1152 else if ( action == _copy_subtree_item ) {
1153 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1155 else if ( action == _delete_node_or_subtree_item ) {
1156 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1158 else if ( action == _paste_subtree_item ) {
1159 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1161 else if ( action == _add_new_node_item ) {
1162 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1164 else if ( action == _edit_node_data_item ) {
1165 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1167 else if ( action == _select_nodes_item ) {
1168 setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
1170 else if ( action == _get_ext_desc_data ) {
1171 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
1173 else if ( action == _open_pdb_item ) {
1174 setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
1177 throw new RuntimeException( "unknown action: " + action );
1179 // make sure drop down is displaying the correct action
1180 // in case this was called from outside the class
1181 _click_to_combobox.setSelectedIndex( action );
1184 void setColorBranches( final boolean color_branches ) {
1185 _color_branches = color_branches;
1188 void setDrawPhylogram( final boolean b ) {
1189 getDisplayAsPhylogramCb().setSelected( b );
1190 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1193 void setDrawPhylogramEnabled( final boolean b ) {
1194 getDisplayAsPhylogramCb().setEnabled( b );
1197 void setDynamicHidingIsOn( final boolean is_on ) {
1198 // if ( !_configuration.isUseNativeUI() ) {
1200 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1203 if ( !_configuration.isUseNativeUI() ) {
1204 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1207 getDynamicallyHideData().setForeground( Color.BLACK );
1213 void setSearchFoundCountsOnLabel0( final int counts ) {
1214 getSearchFoundCountsLabel0().setText( "Found: " + counts );
1217 void setSearchFoundCountsOnLabel1( final int counts ) {
1218 getSearchFoundCountsLabel1().setText( "Found: " + counts );
1221 void setShowEvents( final boolean show_events ) {
1222 if ( getShowEventsCb() == null ) {
1223 _show_events = new JCheckBox( "" );
1225 getShowEventsCb().setSelected( show_events );
1228 void setSpeciesColors( final Map<String, Color> species_colors ) {
1229 _species_colors = species_colors;
1234 * Set up the controls from the config settings. 11/26/05
1236 void setupControls() {
1237 // The tree display options:
1238 setupDisplayCheckboxes();
1240 // The sequence relation query selection combo-box
1241 if ( _configuration.displaySequenceRelations() ) {
1242 addSequenceRelationBlock();
1246 startClickToOptions();
1247 setupClickToOptions();
1248 endClickToOptions();
1249 // Zoom and quick edit buttons
1251 setupSearchTools0();
1252 setupSearchTools1();
1255 void setUpControlsForDomainStrucures() {
1256 _domain_display_label = new JLabel( "Domain Display:" );
1257 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1258 add( _domain_display_label );
1259 _zoom_in_domain_structure = new JButton( "d+" );
1260 _zoom_out_domain_structure = new JButton( "d-" );
1261 _decr_domain_structure_evalue_thr = new JButton( "-" );
1262 _incr_domain_structure_evalue_thr = new JButton( "+" );
1263 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1264 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1265 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1266 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1267 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1268 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1269 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1270 _domain_structure_evalue_thr_tf.setEditable( false );
1271 if ( !getConfiguration().isUseNativeUI() ) {
1272 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1273 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1274 _domain_structure_evalue_thr_tf.setBorder( null );
1276 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1277 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1278 if ( !_configuration.isUseNativeUI() ) {
1279 d1_panel.setBackground( getBackground() );
1280 d2_panel.setBackground( getBackground() );
1284 addJButton( _zoom_out_domain_structure, d1_panel );
1285 addJButton( _zoom_in_domain_structure, d1_panel );
1286 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1287 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1288 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1291 void setupSearchTools0() {
1292 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1293 final JLabel search_label = new JLabel( "Search (A):" );
1294 search_label.setFont( ControlPanel.jcb_bold_font );
1295 if ( !getConfiguration().isUseNativeUI() ) {
1296 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1298 add( search_label );
1299 search_label.setToolTipText( tip );
1300 _search_found_label_0 = new JLabel();
1301 getSearchFoundCountsLabel0().setVisible( false );
1302 _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
1303 if ( !getConfiguration().isUseNativeUI() ) {
1304 _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1306 _search_tf_0 = new JTextField( 3 );
1307 _search_tf_0.setToolTipText( tip );
1308 _search_tf_0.setEditable( true );
1309 if ( !getConfiguration().isUseNativeUI() ) {
1310 _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1311 _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1312 _search_tf_0.setBorder( null );
1314 _search_reset_button_0 = new JButton();
1315 getSearchResetButton0().setText( "Reset" );
1316 getSearchResetButton0().setEnabled( false );
1317 getSearchResetButton0().setVisible( false );
1318 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1319 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1320 s_panel_1.setBackground( getBackground() );
1322 s_panel_2.setBackground( getBackground() );
1324 final KeyAdapter key_adapter = new KeyAdapter() {
1327 public void keyReleased( final KeyEvent key_event ) {
1329 displayedPhylogenyMightHaveChanged( true );
1332 final ActionListener action_listener = new ActionListener() {
1335 public void actionPerformed( final ActionEvent e ) {
1337 setSearchFoundCountsOnLabel0( 0 );
1338 getSearchFoundCountsLabel0().setVisible( false );
1339 getSearchTextField0().setText( "" );
1340 getSearchResetButton0().setEnabled( false );
1341 getSearchResetButton0().setVisible( false );
1342 displayedPhylogenyMightHaveChanged( true );
1345 _search_reset_button_0.addActionListener( action_listener );
1346 _search_tf_0.addKeyListener( key_adapter );
1347 addJTextField( _search_tf_0, s_panel_1 );
1348 s_panel_2.add( _search_found_label_0 );
1349 addJButton( _search_reset_button_0, s_panel_2 );
1352 void setupSearchTools1() {
1353 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1354 final JLabel search_label = new JLabel( "Search (B):" );
1355 search_label.setFont( ControlPanel.jcb_bold_font );
1356 if ( !getConfiguration().isUseNativeUI() ) {
1357 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1359 add( search_label );
1360 search_label.setToolTipText( tip );
1361 _search_found_label_1 = new JLabel();
1362 getSearchFoundCountsLabel1().setVisible( false );
1363 _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
1364 if ( !getConfiguration().isUseNativeUI() ) {
1365 _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1367 _search_tf_1 = new JTextField( 3 );
1368 _search_tf_1.setToolTipText( tip );
1369 _search_tf_1.setEditable( true );
1370 if ( !getConfiguration().isUseNativeUI() ) {
1371 _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1372 _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1373 _search_tf_1.setBorder( null );
1375 _search_reset_button_1 = new JButton();
1376 getSearchResetButton1().setText( "Reset" );
1377 getSearchResetButton1().setEnabled( false );
1378 getSearchResetButton1().setVisible( false );
1379 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1380 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1381 s_panel_1.setBackground( getBackground() );
1383 s_panel_2.setBackground( getBackground() );
1385 final KeyAdapter key_adapter = new KeyAdapter() {
1388 public void keyReleased( final KeyEvent key_event ) {
1390 displayedPhylogenyMightHaveChanged( true );
1393 final ActionListener action_listener = new ActionListener() {
1396 public void actionPerformed( final ActionEvent e ) {
1398 setSearchFoundCountsOnLabel1( 0 );
1399 getSearchFoundCountsLabel1().setVisible( false );
1400 getSearchTextField1().setText( "" );
1401 getSearchResetButton1().setEnabled( false );
1402 getSearchResetButton1().setVisible( false );
1403 displayedPhylogenyMightHaveChanged( true );
1406 _search_reset_button_1.addActionListener( action_listener );
1407 _search_tf_1.addKeyListener( key_adapter );
1408 addJTextField( _search_tf_1, s_panel_1 );
1409 s_panel_2.add( _search_found_label_1 );
1410 addJButton( _search_reset_button_1, s_panel_2 );
1414 void showAnnotations() {
1415 if ( _show_annotation != null ) {
1416 _show_annotation.setSelected( true );
1418 if ( _color_according_to_annotation != null ) {
1419 _color_according_to_annotation.setSelected( true );
1421 if ( _color_acc_species != null ) {
1422 _color_acc_species.setSelected( false );
1424 _mainpanel.getCurrentTreePanel().repaint();
1428 * Fit entire tree into window.
1431 if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
1434 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
1435 displayedPhylogenyMightHaveChanged( true );
1436 _mainpanel.getCurrentTreePanel().updateOvSettings();
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().validate();
1446 _mainpanel.validate();
1447 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1448 _mainpanel.getSizeOfViewport().height,
1450 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1451 _mainpanel.adjustJScrollPane();
1452 _mainpanel.getCurrentTreePanel().repaint();
1453 _mainpanel.getCurrentTreePanel().updateOvSizes();
1456 void showWholeAll() {
1457 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1458 if ( tree_panel != null ) {
1459 tree_panel.validate();
1460 tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1461 _mainpanel.getSizeOfViewport().height,
1463 tree_panel.resetPreferredSize();
1464 tree_panel.repaint();
1469 // Create header for click-to combo box.
1470 void startClickToOptions() {
1471 final JLabel spacer = new JLabel( "" );
1472 spacer.setFont( ControlPanel.jcb_font );
1474 _click_to_label = new JLabel( "Click on Node to:" );
1475 add( customizeLabel( _click_to_label, getConfiguration() ) );
1476 _click_to_combobox = new JComboBox();
1477 _click_to_combobox.setFocusable( false );
1478 _click_to_combobox.setMaximumRowCount( 14 );
1479 _click_to_combobox.setFont( ControlPanel.js_font );
1480 if ( !_configuration.isUseNativeUI() ) {
1481 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1483 // don't add listener until all items are set (or each one will trigger
1485 // click_to_list.addActionListener(this);
1486 add( _click_to_combobox );
1487 // Correlates option names to titles
1488 _all_click_to_names = new HashMap<Integer, String>();
1489 _click_to_names = new ArrayList<String>();
1493 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1494 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1495 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1496 setDrawPhylogramEnabled( true );
1497 setDrawPhylogram( isDrawPhylogram() );
1500 setDrawPhylogramEnabled( false );
1501 setDrawPhylogram( false );
1503 if ( getMainPanel().getMainFrame() == null ) {
1504 // Must be "E" applet version.
1505 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1506 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1509 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1510 .getPhylogenyGraphicsType() );
1512 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1513 getMainPanel().getControlPanel().search0();
1514 getMainPanel().getControlPanel().search1();
1515 getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
1516 getSequenceRelationTypeBox().removeAllItems();
1517 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1518 .getRelevantSequenceRelationTypes() ) {
1519 _sequence_relation_type_box.addItem( type );
1521 getMainPanel().getCurrentTreePanel().repaint();
1522 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1523 // according to GUILHEM the line above can be removed.
1528 * Uncollapse all nodes.
1530 void uncollapseAll( final TreePanel tp ) {
1531 final Phylogeny t = tp.getPhylogeny();
1532 if ( ( t != null ) && !t.isEmpty() ) {
1533 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
1534 final PhylogenyNode node = iter.next();
1535 node.setCollapse( false );
1537 tp.resetNodeIdToDistToLeafMap();
1538 tp.updateSetOfCollapsedExternalNodes();
1539 t.recalculateNumberOfExternalDescendants( false );
1540 tp.setNodeInPreorderToNull();
1541 t.clearHashIdToNodeMap();
1546 void updateDomainStructureEvaluethresholdDisplay() {
1547 if ( _domain_structure_evalue_thr_tf != null ) {
1548 _domain_structure_evalue_thr_tf.setText( "10^"
1549 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1553 void zoomInX( final float factor, final float x_correction_factor ) {
1554 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1555 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1556 treepanel.multiplyUrtFactor( 1f );
1557 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1558 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1559 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1560 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1561 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1562 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1563 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1564 getMainPanel().adjustJScrollPane();
1565 treepanel.resetPreferredSize();
1566 getMainPanel().getCurrentScrollPane().getViewport().validate();
1567 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1568 - ( sb.getVisibleAmount() / 2.0 ) ) );
1571 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1572 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1573 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1574 getMainPanel().adjustJScrollPane();
1575 treepanel.resetPreferredSize();
1576 getMainPanel().getCurrentScrollPane().getViewport().validate();
1577 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1579 treepanel.resetPreferredSize();
1580 treepanel.updateOvSizes();
1583 void zoomInY( final float factor ) {
1584 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1585 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1586 treepanel.multiplyUrtFactor( 1.1f );
1587 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1588 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1589 getMainPanel().adjustJScrollPane();
1590 treepanel.resetPreferredSize();
1591 getMainPanel().getCurrentScrollPane().getViewport().validate();
1592 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1593 - ( sb.getVisibleAmount() / 2.0 ) ) );
1594 treepanel.resetPreferredSize();
1595 treepanel.updateOvSizes();
1598 void zoomOutX( final float factor, final float x_correction_factor ) {
1599 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1600 treepanel.multiplyUrtFactor( 1f );
1601 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1602 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1603 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1604 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1605 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1606 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1607 getMainPanel().adjustJScrollPane();
1608 treepanel.resetPreferredSize();
1609 getMainPanel().getCurrentScrollPane().getViewport().validate();
1610 final double x = ( sb.getMaximum() - sb.getMinimum() )
1611 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1612 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1613 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1614 getMainPanel().adjustJScrollPane();
1615 treepanel.resetPreferredSize();
1616 getMainPanel().getCurrentScrollPane().getViewport().validate();
1617 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1618 - ( sb.getVisibleAmount() / 2.0 ) ) );
1621 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1622 treepanel.setXdistance( treepanel.getXdistance() * factor );
1623 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() );
1631 treepanel.resetPreferredSize();
1632 treepanel.updateOvSizes();
1636 void zoomOutY( final float factor ) {
1637 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1638 treepanel.multiplyUrtFactor( 0.9f );
1639 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1640 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1641 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1642 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1643 getMainPanel().adjustJScrollPane();
1644 treepanel.resetPreferredSize();
1645 getMainPanel().getCurrentScrollPane().getViewport().validate();
1646 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1647 - ( sb.getVisibleAmount() / 2.0 ) ) );
1648 treepanel.resetPreferredSize();
1649 treepanel.updateOvSizes();
1653 private void addClickToOption( final int which, final String title ) {
1654 _click_to_combobox.addItem( title );
1655 _click_to_names.add( title );
1656 _all_click_to_names.put( new Integer( which ), title );
1657 if ( !_configuration.isUseNativeUI() ) {
1658 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1659 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
1664 private void addSequenceRelationBlock() {
1665 final JLabel spacer = new JLabel( "" );
1666 spacer.setSize( 1, 1 );
1668 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
1669 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
1670 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
1671 getSequenceRelationTypeBox().setFocusable( false );
1672 _sequence_relation_type_box.setFont( ControlPanel.js_font );
1673 if ( !_configuration.isUseNativeUI() ) {
1674 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1675 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
1677 _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
1680 public Component getListCellRendererComponent( final JList list,
1683 final boolean isSelected,
1684 final boolean cellHasFocus ) {
1685 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
1690 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
1691 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
1692 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
1697 final GridBagLayout gbl = new GridBagLayout();
1698 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
1699 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
1700 final JPanel horizGrid = new JPanel( gbl );
1701 horizGrid.setBackground( getBackground() );
1702 horizGrid.add( typeLabel );
1703 horizGrid.add( _sequence_relation_type_box );
1704 add( customizeLabel( mainLabel, getConfiguration() ) );
1706 add( getSequenceRelationBox() );
1707 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
1708 addCheckbox( Configuration.show_relation_confidence,
1709 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
1710 setCheckbox( Configuration.show_relation_confidence,
1711 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
1713 }// addSequenceRelationBlock
1716 private List<Boolean> getIsDrawPhylogramList() {
1717 return _draw_phylogram;
1720 private void init() {
1721 _draw_phylogram = new ArrayList<Boolean>();
1722 setSpeciesColors( new HashMap<String, Color>() );
1723 setAnnotationColors( new HashMap<String, Color>() );
1726 private boolean isDrawPhylogram( final int index ) {
1727 return getIsDrawPhylogramList().get( index );
1730 private void search0( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
1731 getSearchFoundCountsLabel0().setVisible( true );
1732 getSearchResetButton0().setEnabled( true );
1733 getSearchResetButton0().setVisible( true );
1734 String[] queries = null;
1735 List<PhylogenyNode> nodes = null;
1736 if ( query_str.indexOf( ',' ) >= 0 ) {
1737 queries = query_str.split( ",+" );
1740 queries = new String[ 1 ];
1741 queries[ 0 ] = query_str.trim();
1743 if ( ( queries != null ) && ( queries.length > 0 ) ) {
1744 nodes = new ArrayList<PhylogenyNode>();
1745 for( String query : queries ) {
1746 if ( ForesterUtil.isEmpty( query ) ) {
1749 query = query.trim();
1750 if ( query.indexOf( '+' ) >= 0 ) {
1751 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
1753 getOptions().isSearchCaseSensitive(),
1754 !getOptions().isMatchWholeTermsOnly(),
1755 isShowDomainArchitectures() ) );
1758 nodes.addAll( PhylogenyMethods.searchData( query,
1760 getOptions().isSearchCaseSensitive(),
1761 !getOptions().isMatchWholeTermsOnly(),
1762 isShowDomainArchitectures() ) );
1765 if ( getOptions().isInverseSearchResult() ) {
1766 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
1767 all.removeAll( nodes );
1771 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
1772 main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet<Long>() );
1773 for( final PhylogenyNode node : nodes ) {
1774 main_panel.getCurrentTreePanel().getFoundNodes0().add( node.getId() );
1776 setSearchFoundCountsOnLabel0( nodes.size() );
1779 setSearchFoundCountsOnLabel0( 0 );
1784 private void search1( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
1785 getSearchFoundCountsLabel1().setVisible( true );
1786 getSearchResetButton1().setEnabled( true );
1787 getSearchResetButton1().setVisible( true );
1788 String[] queries = null;
1789 List<PhylogenyNode> nodes = null;
1790 if ( query_str.indexOf( ',' ) >= 0 ) {
1791 queries = query_str.split( ",+" );
1794 queries = new String[ 1 ];
1795 queries[ 0 ] = query_str.trim();
1797 if ( ( queries != null ) && ( queries.length > 0 ) ) {
1798 nodes = new ArrayList<PhylogenyNode>();
1799 for( String query : queries ) {
1800 if ( ForesterUtil.isEmpty( query ) ) {
1803 query = query.trim();
1804 if ( query.indexOf( '+' ) >= 0 ) {
1805 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
1807 getOptions().isSearchCaseSensitive(),
1808 !getOptions().isMatchWholeTermsOnly(),
1809 isShowDomainArchitectures() ) );
1812 nodes.addAll( PhylogenyMethods.searchData( query,
1814 getOptions().isSearchCaseSensitive(),
1815 !getOptions().isMatchWholeTermsOnly(),
1816 isShowDomainArchitectures() ) );
1819 if ( getOptions().isInverseSearchResult() ) {
1820 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
1821 all.removeAll( nodes );
1825 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
1826 main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet<Long>() );
1827 for( final PhylogenyNode node : nodes ) {
1828 main_panel.getCurrentTreePanel().getFoundNodes1().add( node.getId() );
1830 setSearchFoundCountsOnLabel1( nodes.size() );
1833 setSearchFoundCountsOnLabel1( 0 );
1838 private void setDrawPhylogram( final int index, final boolean b ) {
1839 getIsDrawPhylogramList().set( index, b );
1842 private void setupClickToOptions() {
1843 final int default_option = _configuration.getDefaultDisplayClicktoOption();
1844 int selected_index = 0;
1846 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1847 _show_data_item = cb_index;
1848 addClickToOption( Configuration.display_node_data,
1849 _configuration.getClickToTitle( Configuration.display_node_data ) );
1850 if ( default_option == Configuration.display_node_data ) {
1851 selected_index = cb_index;
1855 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1856 _collapse_cb_item = cb_index;
1857 addClickToOption( Configuration.collapse_uncollapse,
1858 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
1859 if ( default_option == Configuration.collapse_uncollapse ) {
1860 selected_index = cb_index;
1864 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1865 _reroot_cb_item = cb_index;
1866 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1867 if ( default_option == Configuration.reroot ) {
1868 selected_index = cb_index;
1872 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1873 _subtree_cb_item = cb_index;
1874 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1875 if ( default_option == Configuration.subtree ) {
1876 selected_index = cb_index;
1880 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1881 _swap_cb_item = cb_index;
1882 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1883 if ( default_option == Configuration.swap ) {
1884 selected_index = cb_index;
1888 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
1889 _sort_descendents_item = cb_index;
1890 addClickToOption( Configuration.sort_descendents,
1891 _configuration.getClickToTitle( Configuration.sort_descendents ) );
1892 if ( default_option == Configuration.sort_descendents ) {
1893 selected_index = cb_index;
1897 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1898 _color_subtree_cb_item = cb_index;
1899 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1900 if ( default_option == Configuration.color_subtree ) {
1901 selected_index = cb_index;
1905 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1906 _open_seq_web_item = cb_index;
1907 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1908 if ( default_option == Configuration.open_seq_web ) {
1909 selected_index = cb_index;
1913 if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
1914 _open_pdb_item = cb_index;
1915 addClickToOption( Configuration.open_pdb_web, _configuration.getClickToTitle( Configuration.open_pdb_web ) );
1916 if ( default_option == Configuration.open_pdb_web ) {
1917 selected_index = cb_index;
1921 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1922 _open_tax_web_item = cb_index;
1923 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1924 if ( default_option == Configuration.open_tax_web ) {
1925 selected_index = cb_index;
1929 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1930 _blast_item = cb_index;
1931 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
1932 if ( default_option == Configuration.blast ) {
1933 selected_index = cb_index;
1937 if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
1938 _select_nodes_item = cb_index;
1939 addClickToOption( Configuration.select_nodes, _configuration.getClickToTitle( Configuration.select_nodes ) );
1940 if ( default_option == Configuration.select_nodes ) {
1941 selected_index = cb_index;
1945 if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
1946 _get_ext_desc_data = cb_index;
1947 if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
1948 addClickToOption( Configuration.get_ext_desc_data, getConfiguration()
1949 .getLabelForGetExtDescendentsData() );
1953 switch ( getConfiguration().getExtDescNodeDataToReturn() ) {
1958 s = "Sequence Accessors";
1960 case SEQUENCE_MOL_SEQ:
1961 s = "Molecular Sequence";
1963 case SEQUENCE_MOL_SEQ_FASTA:
1964 s = "Molecular Sequence (Fasta)";
1967 s = "Sequence Names";
1972 case SEQUENCE_SYMBOL:
1973 s = "Sequence Symbols";
1976 s = "Taxonomy Codes";
1978 case TAXONOMY_COMM0N_NAME:
1979 s = "Taxonomy Common Names";
1981 case TAXONOMY_SCIENTIFIC_NAME:
1982 s = "Scientific Names";
1985 s = "User Selected Data";
1988 final String label = _configuration.getClickToTitle( Configuration.get_ext_desc_data ) + " " + s;
1989 addClickToOption( Configuration.get_ext_desc_data, label );
1991 if ( default_option == Configuration.get_ext_desc_data ) {
1992 selected_index = cb_index;
1996 if ( getOptions().isEditable() ) {
1997 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
1998 _cut_subtree_item = cb_index;
1999 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
2000 if ( default_option == Configuration.cut_subtree ) {
2001 selected_index = cb_index;
2005 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
2006 _copy_subtree_item = cb_index;
2007 addClickToOption( Configuration.copy_subtree,
2008 _configuration.getClickToTitle( Configuration.copy_subtree ) );
2009 if ( default_option == Configuration.copy_subtree ) {
2010 selected_index = cb_index;
2014 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
2015 _paste_subtree_item = cb_index;
2016 addClickToOption( Configuration.paste_subtree,
2017 _configuration.getClickToTitle( Configuration.paste_subtree ) );
2018 if ( default_option == Configuration.paste_subtree ) {
2019 selected_index = cb_index;
2023 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
2024 _delete_node_or_subtree_item = cb_index;
2025 addClickToOption( Configuration.delete_subtree_or_node,
2026 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
2027 if ( default_option == Configuration.delete_subtree_or_node ) {
2028 selected_index = cb_index;
2032 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
2033 _add_new_node_item = cb_index;
2034 addClickToOption( Configuration.add_new_node,
2035 _configuration.getClickToTitle( Configuration.add_new_node ) );
2036 if ( default_option == Configuration.add_new_node ) {
2037 selected_index = cb_index;
2041 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
2042 _edit_node_data_item = cb_index;
2043 addClickToOption( Configuration.edit_node_data,
2044 _configuration.getClickToTitle( Configuration.edit_node_data ) );
2045 if ( default_option == Configuration.edit_node_data ) {
2046 selected_index = cb_index;
2051 // Set default selection and its action
2052 _click_to_combobox.setSelectedIndex( selected_index );
2053 setClickToAction( selected_index );
2056 private void setupDisplayCheckboxes() {
2057 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
2058 addCheckbox( Configuration.display_as_phylogram,
2059 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
2060 setCheckbox( Configuration.display_as_phylogram,
2061 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
2063 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
2064 addCheckbox( Configuration.dynamically_hide_data,
2065 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
2066 setCheckbox( Configuration.dynamically_hide_data,
2067 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
2069 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
2070 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
2071 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
2073 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
2074 addCheckbox( Configuration.display_internal_data,
2075 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
2076 setCheckbox( Configuration.display_internal_data,
2077 _configuration.doCheckOption( Configuration.display_internal_data ) );
2079 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
2080 addCheckbox( Configuration.color_according_to_species,
2081 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
2082 setCheckbox( Configuration.color_according_to_species,
2083 _configuration.doCheckOption( Configuration.color_according_to_species ) );
2085 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
2086 addCheckbox( Configuration.color_according_to_annotation,
2087 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
2088 setCheckbox( Configuration.color_according_to_annotation,
2089 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
2091 if ( _configuration.doDisplayOption( Configuration.color_branches ) ) {
2092 addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) );
2093 setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) );
2095 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
2096 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
2097 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
2099 final JLabel label = new JLabel( "Display Data:" );
2100 label.setFont( ControlPanel.jcb_bold_font );
2101 if ( !getConfiguration().isUseNativeUI() ) {
2102 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2105 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
2106 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
2107 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
2109 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
2110 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
2111 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
2113 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
2114 addCheckbox( Configuration.show_taxonomy_scientific_names,
2115 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
2116 setCheckbox( Configuration.show_taxonomy_scientific_names,
2117 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
2119 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
2120 addCheckbox( Configuration.show_taxonomy_common_names,
2121 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
2122 setCheckbox( Configuration.show_taxonomy_common_names,
2123 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
2125 if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
2126 addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
2127 setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
2129 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
2130 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
2131 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
2133 if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
2134 addCheckbox( Configuration.show_seq_symbols,
2135 _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
2136 setCheckbox( Configuration.show_seq_symbols, _configuration.doCheckOption( Configuration.show_seq_symbols ) );
2138 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
2139 addCheckbox( Configuration.show_sequence_acc,
2140 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
2141 setCheckbox( Configuration.show_sequence_acc,
2142 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
2144 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
2145 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
2146 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
2148 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
2149 addCheckbox( Configuration.show_binary_characters,
2150 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
2151 setCheckbox( Configuration.show_binary_characters,
2152 _configuration.doCheckOption( Configuration.show_binary_characters ) );
2154 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
2155 addCheckbox( Configuration.show_binary_character_counts,
2156 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
2157 setCheckbox( Configuration.show_binary_character_counts,
2158 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
2160 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
2161 addCheckbox( Configuration.show_domain_architectures,
2162 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
2163 setCheckbox( Configuration.show_domain_architectures,
2164 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
2166 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
2167 addCheckbox( Configuration.write_confidence_values,
2168 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
2169 setCheckbox( Configuration.write_confidence_values,
2170 _configuration.doCheckOption( Configuration.write_confidence_values ) );
2172 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
2173 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
2174 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
2176 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
2177 addCheckbox( Configuration.show_vector_data,
2178 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
2179 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
2181 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
2182 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
2183 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
2185 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
2186 addCheckbox( Configuration.show_taxonomy_images,
2187 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
2188 setCheckbox( Configuration.show_taxonomy_images,
2189 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
2193 private void setVisibilityOfDomainStrucureControls() {
2194 if ( _zoom_in_domain_structure != null ) {
2195 if ( isShowDomainArchitectures() ) {
2196 _domain_display_label.setVisible( true );
2197 _zoom_in_domain_structure.setVisible( true );
2198 _zoom_out_domain_structure.setVisible( true );
2199 _decr_domain_structure_evalue_thr.setVisible( true );
2200 _incr_domain_structure_evalue_thr.setVisible( true );
2201 _domain_structure_evalue_thr_tf.setVisible( true );
2204 _domain_display_label.setVisible( false );
2205 _zoom_in_domain_structure.setVisible( false );
2206 _zoom_out_domain_structure.setVisible( false );
2207 _decr_domain_structure_evalue_thr.setVisible( false );
2208 _incr_domain_structure_evalue_thr.setVisible( false );
2209 _domain_structure_evalue_thr_tf.setVisible( false );
2214 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2215 label.setFont( ControlPanel.jcb_bold_font );
2216 if ( !configuration.isUseNativeUI() ) {
2217 label.setForeground( configuration.getGuiCheckboxTextColor() );
2218 label.setBackground( configuration.getGuiBackgroundColor() );
2223 enum NodeClickAction {
2230 DELETE_NODE_OR_SUBTREE,