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 _use_visual_styles_cb;
97 private int _color_subtree_cb_item;
98 private int _change_node_font_item;
99 // The settings from the conf file
100 private final Configuration _configuration;
101 private int _copy_subtree_item;
102 private int _cut_subtree_item;
103 private JButton _decr_domain_structure_evalue_thr;
104 private int _delete_node_or_subtree_item;
105 private JCheckBox _display_as_phylogram_cb;
107 private JCheckBox _display_internal_data;
108 private JLabel _domain_display_label;
109 private JTextField _domain_structure_evalue_thr_tf;
110 private List<Boolean> _draw_phylogram;
111 private JCheckBox _dynamically_hide_data;
112 private int _edit_node_data_item;
113 private int _get_ext_desc_data;
114 private JButton _incr_domain_structure_evalue_thr;
115 private final MainPanel _mainpanel;
116 private JCheckBox _node_desc_popup_cb;
117 private int _open_pdb_item;
118 private int _open_seq_web_item;
119 private int _open_tax_web_item;
120 private int _color_node_font_item;
121 private JButton _order;
122 private boolean _order_of_appearance;
123 private int _paste_subtree_item;
124 private int _reroot_cb_item;
125 private JButton _return_to_super_tree;
127 private JLabel _search_found_label_0;
128 private JLabel _search_found_label_1;
129 private JButton _search_reset_button_0;
130 private JButton _search_reset_button_1;
131 private JTextField _search_tf_0;
132 private JTextField _search_tf_1;
133 private int _select_nodes_item;
134 private Sequence _selected_query_seq;
135 private JCheckBox _seq_relation_confidence_switch;
136 private JComboBox _sequence_relation_type_box;
137 private JCheckBox _show_annotation;
138 private JCheckBox _show_binary_character_counts;
139 private JCheckBox _show_binary_characters;
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 getUseVisualStylesCb() {
315 return _use_visual_styles_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.use_style:
597 _use_visual_styles_cb = new JCheckBox( title );
598 getUseVisualStylesCb()
599 .setToolTipText( "To use visual styles (node colors, fonts) and branch colors, if present" );
600 addJCheckBox( getUseVisualStylesCb(), ch_panel );
603 case Configuration.width_branches:
604 _width_branches = new JCheckBox( title );
605 _width_branches.setToolTipText( "To use branch width values, if present" );
606 addJCheckBox( _width_branches, ch_panel );
609 case Configuration.show_domain_architectures:
610 _show_domain_architectures = new JCheckBox( title );
611 addJCheckBox( _show_domain_architectures, ch_panel );
614 case Configuration.show_seq_names:
615 _show_seq_names = new JCheckBox( title );
616 addJCheckBox( _show_seq_names, ch_panel );
619 case Configuration.show_gene_names:
620 _show_gene_names = new JCheckBox( title );
621 addJCheckBox( _show_gene_names, ch_panel );
624 case Configuration.show_seq_symbols:
625 _show_seq_symbols = new JCheckBox( title );
626 addJCheckBox( _show_seq_symbols, ch_panel );
629 case Configuration.show_sequence_acc:
630 _show_sequence_acc = new JCheckBox( title );
631 addJCheckBox( _show_sequence_acc, ch_panel );
634 case Configuration.dynamically_hide_data:
635 _dynamically_hide_data = new JCheckBox( title );
636 getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" );
637 addJCheckBox( getDynamicallyHideData(), ch_panel );
640 case Configuration.node_data_popup:
641 _node_desc_popup_cb = new JCheckBox( title );
642 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
643 addJCheckBox( getNodeDescPopupCb(), ch_panel );
646 case Configuration.show_relation_confidence:
647 _seq_relation_confidence_switch = new JCheckBox( title );
648 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
651 case Configuration.show_vector_data:
652 _show_vector_data_cb = new JCheckBox( title );
653 addJCheckBox( _show_vector_data_cb, ch_panel );
656 case Configuration.show_properties:
657 _show_properties_cb = new JCheckBox( title );
658 addJCheckBox( _show_properties_cb, ch_panel );
662 throw new RuntimeException( "unknown checkbox: " + which );
666 void addJButton( final JButton jb, final JPanel p ) {
667 jb.setFocusPainted( false );
668 jb.setFont( ControlPanel.jcb_font );
669 if ( !_configuration.isUseNativeUI() ) {
670 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
671 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
672 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
675 jb.addActionListener( this );
678 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
679 jcb.setFocusPainted( false );
680 jcb.setFont( ControlPanel.jcb_font );
681 if ( !_configuration.isUseNativeUI() ) {
682 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
683 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
685 p.add( jcb, "Center" );
686 jcb.addActionListener( this );
689 void addJTextField( final JTextField tf, final JPanel p ) {
690 if ( !_configuration.isUseNativeUI() ) {
691 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
692 tf.setFont( ControlPanel.jcb_font );
695 tf.addActionListener( this );
698 void deactivateButtonToReturnToSuperTree() {
699 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
700 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
701 _return_to_super_tree.setEnabled( false );
704 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
705 if ( ( _mainpanel != null )
706 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
707 if ( getOptions().isShowOverview() ) {
708 _mainpanel.getCurrentTreePanel().updateOvSizes();
710 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
711 setVisibilityOfDomainStrucureControls();
712 updateDomainStructureEvaluethresholdDisplay();
713 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
714 _mainpanel.getCurrentTreePanel().calcMaxDepth();
715 _mainpanel.adjustJScrollPane();
716 if ( recalc_longest_ext_node_info ) {
717 _mainpanel.getCurrentTreePanel().initNodeData();
718 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
720 _mainpanel.getCurrentTreePanel().repaint();
721 // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
725 void endClickToOptions() {
726 _click_to_combobox.addActionListener( this );
730 * Indicates what action should be execute when a node is clicked
732 * @return the click-on action
734 NodeClickAction getActionWhenNodeClicked() {
735 return _action_when_node_clicked;
738 Map<Integer, String> getAllClickToItems() {
739 return _all_click_to_names;
742 Map<String, Color> getAnnotationColors() {
743 return _annotation_colors;
746 Configuration getConfiguration() {
747 return _configuration;
750 TreePanel getCurrentTreePanel() {
751 return getMainPanel().getCurrentTreePanel();
754 MainPanel getMainPanel() {
758 Options getOptions() {
759 return getMainPanel().getOptions();
762 JLabel getSearchFoundCountsLabel0() {
763 return _search_found_label_0;
766 JLabel getSearchFoundCountsLabel1() {
767 return _search_found_label_1;
770 JButton getSearchResetButton0() {
771 return _search_reset_button_0;
774 JButton getSearchResetButton1() {
775 return _search_reset_button_1;
778 JTextField getSearchTextField0() {
782 JTextField getSearchTextField1() {
786 List<String> getSingleClickToNames() {
787 return _click_to_names;
790 Map<String, Color> getSpeciesColors() {
791 return _species_colors;
794 boolean isAntialiasScreenText() {
798 boolean isColorAccordingToAnnotation() {
799 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
802 boolean isColorAccordingToTaxonomy() {
803 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
806 boolean isUseVisualStyles() {
807 return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() ) || ( ( getUseVisualStylesCb() == null ) && _color_branches ) );
810 boolean isDrawPhylogram() {
811 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
814 boolean isDynamicallyHideData() {
815 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
819 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
822 boolean isNodeDescPopup() {
823 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
826 boolean isShowAnnotation() {
827 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
830 boolean isShowBinaryCharacterCounts() {
831 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
834 boolean isShowBinaryCharacters() {
835 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
838 boolean isShowConfidenceValues() {
839 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
842 boolean isShowDomainArchitectures() {
843 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
846 boolean isShowGeneNames() {
847 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
850 boolean isShowInternalData() {
851 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
854 boolean isShowNodeNames() {
855 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
858 boolean isShowSeqNames() {
859 return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
862 boolean isShowSeqSymbols() {
863 return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
866 boolean isShowSequenceAcc() {
867 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
870 boolean isShowSequenceRelationConfidence() {
871 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
874 boolean isShowSequenceRelations() {
875 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
878 boolean isShowTaxonomyCode() {
879 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
882 boolean isShowTaxonomyCommonNames() {
883 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
886 boolean isShowTaxonomyScientificNames() {
887 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
890 boolean isWidthBranches() {
891 return ( ( _width_branches != null ) && _width_branches.isSelected() );
894 void phylogenyAdded( final Configuration configuration ) {
895 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
898 void phylogenyRemoved( final int index ) {
899 getIsDrawPhylogramList().remove( index );
903 final MainPanel main_panel = getMainPanel();
904 final Phylogeny tree = main_panel.getCurrentPhylogeny();
905 if ( ( tree == null ) || tree.isEmpty() ) {
908 String query = getSearchTextField0().getText();
909 if ( query != null ) {
910 query = query.trim();
912 if ( !ForesterUtil.isEmpty( query ) ) {
913 search0( main_panel, tree, query );
916 getSearchFoundCountsLabel0().setVisible( false );
917 getSearchResetButton0().setEnabled( false );
918 getSearchResetButton0().setVisible( false );
924 final MainPanel main_panel = getMainPanel();
925 final Phylogeny tree = main_panel.getCurrentPhylogeny();
926 if ( ( tree == null ) || tree.isEmpty() ) {
929 String query = getSearchTextField1().getText();
930 if ( query != null ) {
931 query = query.trim();
933 if ( !ForesterUtil.isEmpty( query ) ) {
934 search1( main_panel, tree, query );
937 getSearchFoundCountsLabel1().setVisible( false );
938 getSearchResetButton1().setEnabled( false );
939 getSearchResetButton1().setVisible( false );
944 void searchReset0() {
945 if ( getMainPanel().getCurrentTreePanel() != null ) {
946 getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
950 void searchReset1() {
951 if ( getMainPanel().getCurrentTreePanel() != null ) {
952 getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
956 void setActionWhenNodeClicked( final NodeClickAction action ) {
957 _action_when_node_clicked = action;
960 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
961 _annotation_colors = annotation_colors;
964 void setCheckbox( final int which, final boolean state ) {
966 case Configuration.display_as_phylogram:
967 if ( getDisplayAsPhylogramCb() != null ) {
968 getDisplayAsPhylogramCb().setSelected( state );
971 case Configuration.display_internal_data:
972 if ( _display_internal_data != null ) {
973 _display_internal_data.setSelected( state );
976 case Configuration.color_according_to_species:
977 if ( _color_acc_species != null ) {
978 _color_acc_species.setSelected( state );
981 case Configuration.color_according_to_annotation:
982 if ( _color_according_to_annotation != null ) {
983 _color_according_to_annotation.setSelected( state );
986 case Configuration.show_node_names:
987 if ( _show_node_names != null ) {
988 _show_node_names.setSelected( state );
991 case Configuration.show_taxonomy_scientific_names:
992 if ( _show_taxo_scientific_names != null ) {
993 _show_taxo_scientific_names.setSelected( state );
996 case Configuration.show_taxonomy_common_names:
997 if ( _show_taxo_common_names != null ) {
998 _show_taxo_common_names.setSelected( state );
1001 case Configuration.show_tax_code:
1002 if ( _show_taxo_code != null ) {
1003 _show_taxo_code.setSelected( state );
1006 case Configuration.show_taxonomy_images:
1007 if ( _show_taxo_images_cb != null ) {
1008 _show_taxo_images_cb.setSelected( state );
1011 case Configuration.show_annotation:
1012 if ( _show_annotation != null ) {
1013 _show_annotation.setSelected( state );
1016 case Configuration.show_binary_characters:
1017 if ( _show_binary_characters != null ) {
1018 _show_binary_characters.setSelected( state );
1021 case Configuration.show_binary_character_counts:
1022 if ( _show_binary_character_counts != null ) {
1023 _show_binary_character_counts.setSelected( state );
1026 case Configuration.write_confidence_values:
1027 if ( getWriteConfidenceCb() != null ) {
1028 getWriteConfidenceCb().setSelected( state );
1031 case Configuration.write_events:
1032 if ( getShowEventsCb() != null ) {
1033 getShowEventsCb().setSelected( state );
1036 case Configuration.use_style:
1037 if ( getUseVisualStylesCb() != null ) {
1038 getUseVisualStylesCb().setSelected( state );
1041 case Configuration.width_branches:
1042 if ( _width_branches != null ) {
1043 _width_branches.setSelected( state );
1046 case Configuration.show_domain_architectures:
1047 if ( _show_domain_architectures != null ) {
1048 _show_domain_architectures.setSelected( state );
1051 case Configuration.show_seq_names:
1052 if ( _show_seq_names != null ) {
1053 _show_seq_names.setSelected( state );
1056 case Configuration.show_gene_names:
1057 if ( _show_gene_names != null ) {
1058 _show_gene_names.setSelected( state );
1061 case Configuration.show_seq_symbols:
1062 if ( _show_seq_symbols != null ) {
1063 _show_seq_symbols.setSelected( state );
1066 case Configuration.show_vector_data:
1067 if ( _show_vector_data_cb != null ) {
1068 _show_vector_data_cb.setSelected( state );
1071 case Configuration.show_properties:
1072 if ( _show_properties_cb != null ) {
1073 _show_properties_cb.setSelected( state );
1076 case Configuration.show_sequence_acc:
1077 if ( _show_sequence_acc != null ) {
1078 _show_sequence_acc.setSelected( state );
1081 case Configuration.dynamically_hide_data:
1082 if ( getDynamicallyHideData() != null ) {
1083 getDynamicallyHideData().setSelected( state );
1086 case Configuration.node_data_popup:
1087 if ( getNodeDescPopupCb() != null ) {
1088 getNodeDescPopupCb().setSelected( state );
1092 case Configuration.show_relation_confidence:
1093 if ( _seq_relation_confidence_switch != null ) {
1094 _seq_relation_confidence_switch.setSelected( state );
1099 throw new AssertionError( "unknown checkbox: " + which );
1104 * Set this checkbox state. Not all checkboxes have been instantiated
1105 * depending on the config.
1107 void setCheckbox( final JCheckBox cb, final boolean state ) {
1109 cb.setSelected( state );
1113 void setClickToAction( final int action ) {
1114 // Set click-to action
1115 if ( action == _show_data_item ) {
1116 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1118 else if ( action == _collapse_cb_item ) {
1119 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1121 else if ( action == _reroot_cb_item ) {
1122 setActionWhenNodeClicked( NodeClickAction.REROOT );
1124 else if ( action == _subtree_cb_item ) {
1125 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1127 else if ( action == _swap_cb_item ) {
1128 setActionWhenNodeClicked( NodeClickAction.SWAP );
1130 else if ( action == _color_subtree_cb_item ) {
1131 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1133 else if ( action == _open_seq_web_item ) {
1134 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1136 else if ( action == _sort_descendents_item ) {
1137 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1139 else if ( action == _blast_item ) {
1140 setActionWhenNodeClicked( NodeClickAction.BLAST );
1142 else if ( action == _open_tax_web_item ) {
1143 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1145 else if ( action == _cut_subtree_item ) {
1146 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1148 else if ( action == _copy_subtree_item ) {
1149 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1151 else if ( action == _delete_node_or_subtree_item ) {
1152 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1154 else if ( action == _paste_subtree_item ) {
1155 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1157 else if ( action == _add_new_node_item ) {
1158 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1160 else if ( action == _edit_node_data_item ) {
1161 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1163 else if ( action == _select_nodes_item ) {
1164 setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
1166 else if ( action == _get_ext_desc_data ) {
1167 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
1169 else if ( action == _open_pdb_item ) {
1170 setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
1172 else if ( action == _color_node_font_item ) {
1173 setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
1175 else if ( action == _change_node_font_item ) {
1176 setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT );
1179 throw new RuntimeException( "unknown action: " + action );
1181 // make sure drop down is displaying the correct action
1182 // in case this was called from outside the class
1183 _click_to_combobox.setSelectedIndex( action );
1186 void setColorBranches( final boolean color_branches ) {
1187 _color_branches = color_branches;
1190 void setDrawPhylogram( final boolean b ) {
1191 getDisplayAsPhylogramCb().setSelected( b );
1192 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1195 void setDrawPhylogramEnabled( final boolean b ) {
1196 getDisplayAsPhylogramCb().setEnabled( b );
1199 void setDynamicHidingIsOn( final boolean is_on ) {
1200 // if ( !_configuration.isUseNativeUI() ) {
1202 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1205 if ( !_configuration.isUseNativeUI() ) {
1206 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1209 getDynamicallyHideData().setForeground( Color.BLACK );
1215 void setSearchFoundCountsOnLabel0( final int counts ) {
1216 getSearchFoundCountsLabel0().setText( "Found: " + counts );
1219 void setSearchFoundCountsOnLabel1( final int counts ) {
1220 getSearchFoundCountsLabel1().setText( "Found: " + counts );
1223 void setShowEvents( final boolean show_events ) {
1224 if ( getShowEventsCb() == null ) {
1225 _show_events = new JCheckBox( "" );
1227 getShowEventsCb().setSelected( show_events );
1230 void setSpeciesColors( final Map<String, Color> species_colors ) {
1231 _species_colors = species_colors;
1236 * Set up the controls from the config settings. 11/26/05
1238 void setupControls() {
1239 // The tree display options:
1240 setupDisplayCheckboxes();
1242 // The sequence relation query selection combo-box
1243 if ( _configuration.displaySequenceRelations() ) {
1244 addSequenceRelationBlock();
1248 startClickToOptions();
1249 setupClickToOptions();
1250 endClickToOptions();
1251 // Zoom and quick edit buttons
1253 setupSearchTools0();
1254 setupSearchTools1();
1257 void setUpControlsForDomainStrucures() {
1258 _domain_display_label = new JLabel( "Domain Display:" );
1259 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1260 add( _domain_display_label );
1261 _zoom_in_domain_structure = new JButton( "d+" );
1262 _zoom_out_domain_structure = new JButton( "d-" );
1263 _decr_domain_structure_evalue_thr = new JButton( "-" );
1264 _incr_domain_structure_evalue_thr = new JButton( "+" );
1265 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1266 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1267 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1268 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1269 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1270 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1271 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1272 _domain_structure_evalue_thr_tf.setEditable( false );
1273 if ( !getConfiguration().isUseNativeUI() ) {
1274 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1275 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1276 _domain_structure_evalue_thr_tf.setBorder( null );
1278 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1279 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1280 if ( !_configuration.isUseNativeUI() ) {
1281 d1_panel.setBackground( getBackground() );
1282 d2_panel.setBackground( getBackground() );
1286 addJButton( _zoom_out_domain_structure, d1_panel );
1287 addJButton( _zoom_in_domain_structure, d1_panel );
1288 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1289 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1290 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1293 void setupSearchTools0() {
1294 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1295 final JLabel search_label = new JLabel( "Search (A):" );
1296 search_label.setFont( ControlPanel.jcb_bold_font );
1297 if ( !getConfiguration().isUseNativeUI() ) {
1298 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1300 add( search_label );
1301 search_label.setToolTipText( tip );
1302 _search_found_label_0 = new JLabel();
1303 getSearchFoundCountsLabel0().setVisible( false );
1304 _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
1305 if ( !getConfiguration().isUseNativeUI() ) {
1306 _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1308 _search_tf_0 = new JTextField( 3 );
1309 _search_tf_0.setToolTipText( tip );
1310 _search_tf_0.setEditable( true );
1311 if ( !getConfiguration().isUseNativeUI() ) {
1312 _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1313 _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1314 _search_tf_0.setBorder( null );
1316 _search_reset_button_0 = new JButton();
1317 getSearchResetButton0().setText( "Reset" );
1318 getSearchResetButton0().setEnabled( false );
1319 getSearchResetButton0().setVisible( false );
1320 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1321 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1322 s_panel_1.setBackground( getBackground() );
1324 s_panel_2.setBackground( getBackground() );
1326 final KeyAdapter key_adapter = new KeyAdapter() {
1329 public void keyReleased( final KeyEvent key_event ) {
1331 displayedPhylogenyMightHaveChanged( true );
1334 final ActionListener action_listener = new ActionListener() {
1337 public void actionPerformed( final ActionEvent e ) {
1339 setSearchFoundCountsOnLabel0( 0 );
1340 getSearchFoundCountsLabel0().setVisible( false );
1341 getSearchTextField0().setText( "" );
1342 getSearchResetButton0().setEnabled( false );
1343 getSearchResetButton0().setVisible( false );
1344 displayedPhylogenyMightHaveChanged( true );
1347 _search_reset_button_0.addActionListener( action_listener );
1348 _search_tf_0.addKeyListener( key_adapter );
1349 addJTextField( _search_tf_0, s_panel_1 );
1350 s_panel_2.add( _search_found_label_0 );
1351 addJButton( _search_reset_button_0, s_panel_2 );
1354 void setupSearchTools1() {
1355 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1356 final JLabel search_label = new JLabel( "Search (B):" );
1357 search_label.setFont( ControlPanel.jcb_bold_font );
1358 if ( !getConfiguration().isUseNativeUI() ) {
1359 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1361 add( search_label );
1362 search_label.setToolTipText( tip );
1363 _search_found_label_1 = new JLabel();
1364 getSearchFoundCountsLabel1().setVisible( false );
1365 _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
1366 if ( !getConfiguration().isUseNativeUI() ) {
1367 _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1369 _search_tf_1 = new JTextField( 3 );
1370 _search_tf_1.setToolTipText( tip );
1371 _search_tf_1.setEditable( true );
1372 if ( !getConfiguration().isUseNativeUI() ) {
1373 _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1374 _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1375 _search_tf_1.setBorder( null );
1377 _search_reset_button_1 = new JButton();
1378 getSearchResetButton1().setText( "Reset" );
1379 getSearchResetButton1().setEnabled( false );
1380 getSearchResetButton1().setVisible( false );
1381 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1382 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1383 s_panel_1.setBackground( getBackground() );
1385 s_panel_2.setBackground( getBackground() );
1387 final KeyAdapter key_adapter = new KeyAdapter() {
1390 public void keyReleased( final KeyEvent key_event ) {
1392 displayedPhylogenyMightHaveChanged( true );
1395 final ActionListener action_listener = new ActionListener() {
1398 public void actionPerformed( final ActionEvent e ) {
1400 setSearchFoundCountsOnLabel1( 0 );
1401 getSearchFoundCountsLabel1().setVisible( false );
1402 getSearchTextField1().setText( "" );
1403 getSearchResetButton1().setEnabled( false );
1404 getSearchResetButton1().setVisible( false );
1405 displayedPhylogenyMightHaveChanged( true );
1408 _search_reset_button_1.addActionListener( action_listener );
1409 _search_tf_1.addKeyListener( key_adapter );
1410 addJTextField( _search_tf_1, s_panel_1 );
1411 s_panel_2.add( _search_found_label_1 );
1412 addJButton( _search_reset_button_1, s_panel_2 );
1415 void showAnnotations() {
1416 if ( _show_annotation != null ) {
1417 _show_annotation.setSelected( true );
1419 if ( _color_according_to_annotation != null ) {
1420 _color_according_to_annotation.setSelected( true );
1422 if ( _color_acc_species != null ) {
1423 _color_acc_species.setSelected( false );
1425 _mainpanel.getCurrentTreePanel().repaint();
1429 * Fit entire tree into window.
1432 if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
1435 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
1436 displayedPhylogenyMightHaveChanged( true );
1437 _mainpanel.getCurrentTreePanel().updateOvSettings();
1438 _mainpanel.getCurrentTreePanel().validate();
1439 _mainpanel.validate();
1440 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1441 _mainpanel.getSizeOfViewport().height,
1443 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1444 _mainpanel.adjustJScrollPane();
1445 _mainpanel.getCurrentTreePanel().repaint();
1446 _mainpanel.getCurrentTreePanel().validate();
1447 _mainpanel.validate();
1448 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1449 _mainpanel.getSizeOfViewport().height,
1451 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1452 _mainpanel.adjustJScrollPane();
1453 _mainpanel.getCurrentTreePanel().repaint();
1454 _mainpanel.getCurrentTreePanel().updateOvSizes();
1457 void showWholeAll() {
1458 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1459 if ( tree_panel != null ) {
1460 tree_panel.validate();
1461 tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1462 _mainpanel.getSizeOfViewport().height,
1464 tree_panel.resetPreferredSize();
1465 tree_panel.repaint();
1470 // Create header for click-to combo box.
1471 void startClickToOptions() {
1472 final JLabel spacer = new JLabel( "" );
1473 spacer.setFont( ControlPanel.jcb_font );
1475 _click_to_label = new JLabel( "Click on Node to:" );
1476 add( customizeLabel( _click_to_label, getConfiguration() ) );
1477 _click_to_combobox = new JComboBox();
1478 _click_to_combobox.setFocusable( false );
1479 _click_to_combobox.setMaximumRowCount( 14 );
1480 _click_to_combobox.setFont( ControlPanel.js_font );
1481 if ( !_configuration.isUseNativeUI() ) {
1482 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1484 // don't add listener until all items are set (or each one will trigger
1486 // click_to_list.addActionListener(this);
1487 add( _click_to_combobox );
1488 // Correlates option names to titles
1489 _all_click_to_names = new HashMap<Integer, String>();
1490 _click_to_names = new ArrayList<String>();
1494 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1495 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1496 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1497 setDrawPhylogramEnabled( true );
1498 setDrawPhylogram( isDrawPhylogram() );
1501 setDrawPhylogramEnabled( false );
1502 setDrawPhylogram( false );
1504 if ( getMainPanel().getMainFrame() == null ) {
1505 // Must be "E" applet version.
1506 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1507 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1510 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1511 .getPhylogenyGraphicsType() );
1513 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1514 getMainPanel().getControlPanel().search0();
1515 getMainPanel().getControlPanel().search1();
1516 getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
1517 getSequenceRelationTypeBox().removeAllItems();
1518 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1519 .getRelevantSequenceRelationTypes() ) {
1520 _sequence_relation_type_box.addItem( type );
1522 getMainPanel().getCurrentTreePanel().repaint();
1523 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1524 // according to GUILHEM the line above can be removed.
1529 * Uncollapse all nodes.
1531 void uncollapseAll( final TreePanel tp ) {
1532 final Phylogeny t = tp.getPhylogeny();
1533 if ( ( t != null ) && !t.isEmpty() ) {
1534 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
1535 final PhylogenyNode node = iter.next();
1536 node.setCollapse( false );
1538 tp.resetNodeIdToDistToLeafMap();
1539 tp.updateSetOfCollapsedExternalNodes();
1540 t.recalculateNumberOfExternalDescendants( false );
1541 tp.setNodeInPreorderToNull();
1542 t.clearHashIdToNodeMap();
1547 void updateDomainStructureEvaluethresholdDisplay() {
1548 if ( _domain_structure_evalue_thr_tf != null ) {
1549 _domain_structure_evalue_thr_tf.setText( "10^"
1550 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1554 void zoomInX( final float factor, final float x_correction_factor ) {
1555 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1556 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1557 treepanel.multiplyUrtFactor( 1f );
1558 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1559 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1560 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1561 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1562 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1563 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1564 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1565 getMainPanel().adjustJScrollPane();
1566 treepanel.resetPreferredSize();
1567 getMainPanel().getCurrentScrollPane().getViewport().validate();
1568 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1569 - ( sb.getVisibleAmount() / 2.0 ) ) );
1572 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1573 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1574 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1575 getMainPanel().adjustJScrollPane();
1576 treepanel.resetPreferredSize();
1577 getMainPanel().getCurrentScrollPane().getViewport().validate();
1578 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1580 treepanel.resetPreferredSize();
1581 treepanel.updateOvSizes();
1584 void zoomInY( final float factor ) {
1585 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1586 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1587 treepanel.multiplyUrtFactor( 1.1f );
1588 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1589 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1590 getMainPanel().adjustJScrollPane();
1591 treepanel.resetPreferredSize();
1592 getMainPanel().getCurrentScrollPane().getViewport().validate();
1593 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1594 - ( sb.getVisibleAmount() / 2.0 ) ) );
1595 treepanel.resetPreferredSize();
1596 treepanel.updateOvSizes();
1599 void zoomOutX( final float factor, final float x_correction_factor ) {
1600 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1601 treepanel.multiplyUrtFactor( 1f );
1602 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1603 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1604 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1605 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1606 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1607 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1608 getMainPanel().adjustJScrollPane();
1609 treepanel.resetPreferredSize();
1610 getMainPanel().getCurrentScrollPane().getViewport().validate();
1611 final double x = ( sb.getMaximum() - sb.getMinimum() )
1612 / ( 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 );
1626 getMainPanel().adjustJScrollPane();
1627 treepanel.resetPreferredSize();
1628 getMainPanel().getCurrentScrollPane().getViewport().validate();
1629 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1632 treepanel.resetPreferredSize();
1633 treepanel.updateOvSizes();
1637 void zoomOutY( final float factor ) {
1638 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1639 treepanel.multiplyUrtFactor( 0.9f );
1640 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1641 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1642 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1643 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1644 getMainPanel().adjustJScrollPane();
1645 treepanel.resetPreferredSize();
1646 getMainPanel().getCurrentScrollPane().getViewport().validate();
1647 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1648 - ( sb.getVisibleAmount() / 2.0 ) ) );
1649 treepanel.resetPreferredSize();
1650 treepanel.updateOvSizes();
1654 private void addClickToOption( final int which, final String title ) {
1655 _click_to_combobox.addItem( title );
1656 _click_to_names.add( title );
1657 _all_click_to_names.put( new Integer( which ), title );
1658 if ( !_configuration.isUseNativeUI() ) {
1659 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1660 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
1665 private void addSequenceRelationBlock() {
1666 final JLabel spacer = new JLabel( "" );
1667 spacer.setSize( 1, 1 );
1669 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
1670 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
1671 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
1672 getSequenceRelationTypeBox().setFocusable( false );
1673 _sequence_relation_type_box.setFont( ControlPanel.js_font );
1674 if ( !_configuration.isUseNativeUI() ) {
1675 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1676 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
1678 _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
1681 public Component getListCellRendererComponent( final JList list,
1684 final boolean isSelected,
1685 final boolean cellHasFocus ) {
1686 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
1691 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
1692 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
1693 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
1698 final GridBagLayout gbl = new GridBagLayout();
1699 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
1700 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
1701 final JPanel horizGrid = new JPanel( gbl );
1702 horizGrid.setBackground( getBackground() );
1703 horizGrid.add( typeLabel );
1704 horizGrid.add( _sequence_relation_type_box );
1705 add( customizeLabel( mainLabel, getConfiguration() ) );
1707 add( getSequenceRelationBox() );
1708 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
1709 addCheckbox( Configuration.show_relation_confidence,
1710 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
1711 setCheckbox( Configuration.show_relation_confidence,
1712 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
1714 }// addSequenceRelationBlock
1717 private List<Boolean> getIsDrawPhylogramList() {
1718 return _draw_phylogram;
1721 private void init() {
1722 _draw_phylogram = new ArrayList<Boolean>();
1723 setSpeciesColors( new HashMap<String, Color>() );
1724 setAnnotationColors( new HashMap<String, Color>() );
1727 private boolean isDrawPhylogram( final int index ) {
1728 return getIsDrawPhylogramList().get( index );
1731 private void search0( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
1732 getSearchFoundCountsLabel0().setVisible( true );
1733 getSearchResetButton0().setEnabled( true );
1734 getSearchResetButton0().setVisible( true );
1735 String[] queries = null;
1736 List<PhylogenyNode> nodes = null;
1737 if ( query_str.indexOf( ',' ) >= 0 ) {
1738 queries = query_str.split( ",+" );
1741 queries = new String[ 1 ];
1742 queries[ 0 ] = query_str.trim();
1744 if ( ( queries != null ) && ( queries.length > 0 ) ) {
1745 nodes = new ArrayList<PhylogenyNode>();
1746 for( String query : queries ) {
1747 if ( ForesterUtil.isEmpty( query ) ) {
1750 query = query.trim();
1751 if ( query.indexOf( '+' ) >= 0 ) {
1752 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
1754 getOptions().isSearchCaseSensitive(),
1755 !getOptions().isMatchWholeTermsOnly(),
1756 isShowDomainArchitectures() ) );
1759 nodes.addAll( PhylogenyMethods.searchData( query,
1761 getOptions().isSearchCaseSensitive(),
1762 !getOptions().isMatchWholeTermsOnly(),
1763 isShowDomainArchitectures() ) );
1766 if ( getOptions().isInverseSearchResult() ) {
1767 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
1768 all.removeAll( nodes );
1772 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
1773 main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet<Long>() );
1774 for( final PhylogenyNode node : nodes ) {
1775 main_panel.getCurrentTreePanel().getFoundNodes0().add( node.getId() );
1777 setSearchFoundCountsOnLabel0( nodes.size() );
1780 setSearchFoundCountsOnLabel0( 0 );
1785 private void search1( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
1786 getSearchFoundCountsLabel1().setVisible( true );
1787 getSearchResetButton1().setEnabled( true );
1788 getSearchResetButton1().setVisible( true );
1789 String[] queries = null;
1790 List<PhylogenyNode> nodes = null;
1791 if ( query_str.indexOf( ',' ) >= 0 ) {
1792 queries = query_str.split( ",+" );
1795 queries = new String[ 1 ];
1796 queries[ 0 ] = query_str.trim();
1798 if ( ( queries != null ) && ( queries.length > 0 ) ) {
1799 nodes = new ArrayList<PhylogenyNode>();
1800 for( String query : queries ) {
1801 if ( ForesterUtil.isEmpty( query ) ) {
1804 query = query.trim();
1805 if ( query.indexOf( '+' ) >= 0 ) {
1806 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
1808 getOptions().isSearchCaseSensitive(),
1809 !getOptions().isMatchWholeTermsOnly(),
1810 isShowDomainArchitectures() ) );
1813 nodes.addAll( PhylogenyMethods.searchData( query,
1815 getOptions().isSearchCaseSensitive(),
1816 !getOptions().isMatchWholeTermsOnly(),
1817 isShowDomainArchitectures() ) );
1820 if ( getOptions().isInverseSearchResult() ) {
1821 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
1822 all.removeAll( nodes );
1826 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
1827 main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet<Long>() );
1828 for( final PhylogenyNode node : nodes ) {
1829 main_panel.getCurrentTreePanel().getFoundNodes1().add( node.getId() );
1831 setSearchFoundCountsOnLabel1( nodes.size() );
1834 setSearchFoundCountsOnLabel1( 0 );
1839 private void setDrawPhylogram( final int index, final boolean b ) {
1840 getIsDrawPhylogramList().set( index, b );
1843 private void setupClickToOptions() {
1844 final int default_option = _configuration.getDefaultDisplayClicktoOption();
1845 int selected_index = 0;
1847 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1848 _show_data_item = cb_index;
1849 addClickToOption( Configuration.display_node_data,
1850 _configuration.getClickToTitle( Configuration.display_node_data ) );
1851 if ( default_option == Configuration.display_node_data ) {
1852 selected_index = cb_index;
1856 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1857 _collapse_cb_item = cb_index;
1858 addClickToOption( Configuration.collapse_uncollapse,
1859 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
1860 if ( default_option == Configuration.collapse_uncollapse ) {
1861 selected_index = cb_index;
1865 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1866 _reroot_cb_item = cb_index;
1867 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1868 if ( default_option == Configuration.reroot ) {
1869 selected_index = cb_index;
1873 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1874 _subtree_cb_item = cb_index;
1875 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1876 if ( default_option == Configuration.subtree ) {
1877 selected_index = cb_index;
1881 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1882 _swap_cb_item = cb_index;
1883 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1884 if ( default_option == Configuration.swap ) {
1885 selected_index = cb_index;
1889 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
1890 _sort_descendents_item = cb_index;
1891 addClickToOption( Configuration.sort_descendents,
1892 _configuration.getClickToTitle( Configuration.sort_descendents ) );
1893 if ( default_option == Configuration.sort_descendents ) {
1894 selected_index = cb_index;
1898 if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) {
1899 _color_node_font_item = cb_index;
1900 addClickToOption( Configuration.color_node_font,
1901 _configuration.getClickToTitle( Configuration.color_node_font ) );
1902 if ( default_option == Configuration.color_node_font ) {
1903 selected_index = cb_index;
1907 if ( _configuration.doDisplayClickToOption( Configuration.change_node_font ) ) {
1908 _change_node_font_item = cb_index;
1909 addClickToOption( Configuration.change_node_font,
1910 _configuration.getClickToTitle( Configuration.change_node_font ) );
1911 if ( default_option == Configuration.change_node_font ) {
1912 selected_index = cb_index;
1916 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1917 _color_subtree_cb_item = cb_index;
1918 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1919 if ( default_option == Configuration.color_subtree ) {
1920 selected_index = cb_index;
1924 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1925 _open_seq_web_item = cb_index;
1926 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1927 if ( default_option == Configuration.open_seq_web ) {
1928 selected_index = cb_index;
1932 if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
1933 _open_pdb_item = cb_index;
1934 addClickToOption( Configuration.open_pdb_web, _configuration.getClickToTitle( Configuration.open_pdb_web ) );
1935 if ( default_option == Configuration.open_pdb_web ) {
1936 selected_index = cb_index;
1940 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1941 _open_tax_web_item = cb_index;
1942 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1943 if ( default_option == Configuration.open_tax_web ) {
1944 selected_index = cb_index;
1948 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1949 _blast_item = cb_index;
1950 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
1951 if ( default_option == Configuration.blast ) {
1952 selected_index = cb_index;
1956 if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
1957 _select_nodes_item = cb_index;
1958 addClickToOption( Configuration.select_nodes, _configuration.getClickToTitle( Configuration.select_nodes ) );
1959 if ( default_option == Configuration.select_nodes ) {
1960 selected_index = cb_index;
1964 if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
1965 _get_ext_desc_data = cb_index;
1966 if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
1967 addClickToOption( Configuration.get_ext_desc_data, getConfiguration()
1968 .getLabelForGetExtDescendentsData() );
1972 switch ( getConfiguration().getExtDescNodeDataToReturn() ) {
1977 s = "Sequence Accessors";
1979 case SEQUENCE_MOL_SEQ:
1980 s = "Molecular Sequence";
1982 case SEQUENCE_MOL_SEQ_FASTA:
1983 s = "Molecular Sequence (Fasta)";
1986 s = "Sequence Names";
1991 case SEQUENCE_SYMBOL:
1992 s = "Sequence Symbols";
1995 s = "Taxonomy Codes";
1997 case TAXONOMY_COMM0N_NAME:
1998 s = "Taxonomy Common Names";
2000 case TAXONOMY_SCIENTIFIC_NAME:
2001 s = "Scientific Names";
2004 s = "User Selected Data";
2007 final String label = _configuration.getClickToTitle( Configuration.get_ext_desc_data ) + " " + s;
2008 addClickToOption( Configuration.get_ext_desc_data, label );
2010 if ( default_option == Configuration.get_ext_desc_data ) {
2011 selected_index = cb_index;
2015 if ( getOptions().isEditable() ) {
2016 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
2017 _cut_subtree_item = cb_index;
2018 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
2019 if ( default_option == Configuration.cut_subtree ) {
2020 selected_index = cb_index;
2024 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
2025 _copy_subtree_item = cb_index;
2026 addClickToOption( Configuration.copy_subtree,
2027 _configuration.getClickToTitle( Configuration.copy_subtree ) );
2028 if ( default_option == Configuration.copy_subtree ) {
2029 selected_index = cb_index;
2033 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
2034 _paste_subtree_item = cb_index;
2035 addClickToOption( Configuration.paste_subtree,
2036 _configuration.getClickToTitle( Configuration.paste_subtree ) );
2037 if ( default_option == Configuration.paste_subtree ) {
2038 selected_index = cb_index;
2042 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
2043 _delete_node_or_subtree_item = cb_index;
2044 addClickToOption( Configuration.delete_subtree_or_node,
2045 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
2046 if ( default_option == Configuration.delete_subtree_or_node ) {
2047 selected_index = cb_index;
2051 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
2052 _add_new_node_item = cb_index;
2053 addClickToOption( Configuration.add_new_node,
2054 _configuration.getClickToTitle( Configuration.add_new_node ) );
2055 if ( default_option == Configuration.add_new_node ) {
2056 selected_index = cb_index;
2060 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
2061 _edit_node_data_item = cb_index;
2062 addClickToOption( Configuration.edit_node_data,
2063 _configuration.getClickToTitle( Configuration.edit_node_data ) );
2064 if ( default_option == Configuration.edit_node_data ) {
2065 selected_index = cb_index;
2070 // Set default selection and its action
2071 _click_to_combobox.setSelectedIndex( selected_index );
2072 setClickToAction( selected_index );
2075 private void setupDisplayCheckboxes() {
2076 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
2077 addCheckbox( Configuration.display_as_phylogram,
2078 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
2079 setCheckbox( Configuration.display_as_phylogram,
2080 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
2082 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
2083 addCheckbox( Configuration.dynamically_hide_data,
2084 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
2085 setCheckbox( Configuration.dynamically_hide_data,
2086 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
2088 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
2089 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
2090 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
2092 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
2093 addCheckbox( Configuration.display_internal_data,
2094 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
2095 setCheckbox( Configuration.display_internal_data,
2096 _configuration.doCheckOption( Configuration.display_internal_data ) );
2098 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
2099 addCheckbox( Configuration.color_according_to_species,
2100 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
2101 setCheckbox( Configuration.color_according_to_species,
2102 _configuration.doCheckOption( Configuration.color_according_to_species ) );
2104 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
2105 addCheckbox( Configuration.color_according_to_annotation,
2106 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
2107 setCheckbox( Configuration.color_according_to_annotation,
2108 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
2110 if ( _configuration.doDisplayOption( Configuration.use_style ) ) {
2111 addCheckbox( Configuration.use_style, _configuration.getDisplayTitle( Configuration.use_style ) );
2112 setCheckbox( Configuration.use_style, _configuration.doCheckOption( Configuration.use_style ) );
2114 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
2115 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
2116 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
2118 final JLabel label = new JLabel( "Display Data:" );
2119 label.setFont( ControlPanel.jcb_bold_font );
2120 if ( !getConfiguration().isUseNativeUI() ) {
2121 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2124 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
2125 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
2126 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
2128 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
2129 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
2130 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
2132 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
2133 addCheckbox( Configuration.show_taxonomy_scientific_names,
2134 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
2135 setCheckbox( Configuration.show_taxonomy_scientific_names,
2136 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
2138 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
2139 addCheckbox( Configuration.show_taxonomy_common_names,
2140 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
2141 setCheckbox( Configuration.show_taxonomy_common_names,
2142 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
2144 if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
2145 addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
2146 setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
2148 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
2149 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
2150 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
2152 if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
2153 addCheckbox( Configuration.show_seq_symbols,
2154 _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
2155 setCheckbox( Configuration.show_seq_symbols, _configuration.doCheckOption( Configuration.show_seq_symbols ) );
2157 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
2158 addCheckbox( Configuration.show_sequence_acc,
2159 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
2160 setCheckbox( Configuration.show_sequence_acc,
2161 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
2163 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
2164 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
2165 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
2167 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
2168 addCheckbox( Configuration.show_binary_characters,
2169 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
2170 setCheckbox( Configuration.show_binary_characters,
2171 _configuration.doCheckOption( Configuration.show_binary_characters ) );
2173 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
2174 addCheckbox( Configuration.show_binary_character_counts,
2175 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
2176 setCheckbox( Configuration.show_binary_character_counts,
2177 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
2179 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
2180 addCheckbox( Configuration.show_domain_architectures,
2181 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
2182 setCheckbox( Configuration.show_domain_architectures,
2183 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
2185 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
2186 addCheckbox( Configuration.write_confidence_values,
2187 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
2188 setCheckbox( Configuration.write_confidence_values,
2189 _configuration.doCheckOption( Configuration.write_confidence_values ) );
2191 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
2192 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
2193 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
2195 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
2196 addCheckbox( Configuration.show_vector_data,
2197 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
2198 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
2200 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
2201 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
2202 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
2204 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
2205 addCheckbox( Configuration.show_taxonomy_images,
2206 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
2207 setCheckbox( Configuration.show_taxonomy_images,
2208 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
2212 private void setVisibilityOfDomainStrucureControls() {
2213 if ( _zoom_in_domain_structure != null ) {
2214 if ( isShowDomainArchitectures() ) {
2215 _domain_display_label.setVisible( true );
2216 _zoom_in_domain_structure.setVisible( true );
2217 _zoom_out_domain_structure.setVisible( true );
2218 _decr_domain_structure_evalue_thr.setVisible( true );
2219 _incr_domain_structure_evalue_thr.setVisible( true );
2220 _domain_structure_evalue_thr_tf.setVisible( true );
2223 _domain_display_label.setVisible( false );
2224 _zoom_in_domain_structure.setVisible( false );
2225 _zoom_out_domain_structure.setVisible( false );
2226 _decr_domain_structure_evalue_thr.setVisible( false );
2227 _incr_domain_structure_evalue_thr.setVisible( false );
2228 _domain_structure_evalue_thr_tf.setVisible( false );
2233 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2234 label.setFont( ControlPanel.jcb_bold_font );
2235 if ( !configuration.isUseNativeUI() ) {
2236 label.setForeground( configuration.getGuiCheckboxTextColor() );
2237 label.setBackground( configuration.getGuiBackgroundColor() );
2242 enum NodeClickAction {
2249 DELETE_NODE_OR_SUBTREE,