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.data.SequenceRelation.SEQUENCE_RELATION_TYPE;
69 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
70 import org.forester.util.ForesterUtil;
72 final class ControlPanel extends JPanel implements ActionListener {
74 final static Font jcb_bold_font = new Font( Configuration.getDefaultFontFamilyName(),
77 final static Font jcb_font = new Font( Configuration.getDefaultFontFamilyName(),
80 final static Font js_font = new Font( Configuration.getDefaultFontFamilyName(),
83 private static final String RETURN_TO_SUPER_TREE_TEXT = "Back to Super Tree";
84 private static final long serialVersionUID = -8463483932821545633L;
85 private NodeClickAction _action_when_node_clicked;
86 private int _add_new_node_item;
87 private Map<Integer, String> _all_click_to_names;
88 private Map<String, Color> _annotation_colors;
89 private int _blast_item;
90 private JComboBox<String> _click_to_combobox;
91 private JLabel _click_to_label;
92 private List<String> _click_to_names;
93 private int _collapse_cb_item;
94 private JCheckBox _color_acc_species;
95 private JCheckBox _color_acc_sequence;
96 private JCheckBox _color_according_to_annotation;
97 private boolean _color_branches;
98 private JCheckBox _use_visual_styles_cb;
99 private int _color_subtree_cb_item;
100 private int _change_node_font_item;
101 // The settings from the conf file
102 private final Configuration _configuration;
103 private int _copy_subtree_item;
104 private int _cut_subtree_item;
105 private JButton _decr_domain_structure_evalue_thr;
106 private int _delete_node_or_subtree_item;
107 private JCheckBox _display_as_phylogram_cb;
109 private JCheckBox _display_internal_data;
110 private JLabel _domain_display_label;
111 private JTextField _domain_structure_evalue_thr_tf;
112 private List<Boolean> _draw_phylogram;
113 private JCheckBox _dynamically_hide_data;
114 private int _edit_node_data_item;
115 private int _get_ext_desc_data;
116 private JButton _incr_domain_structure_evalue_thr;
117 private final MainPanel _mainpanel;
118 private JCheckBox _node_desc_popup_cb;
119 private int _open_pdb_item;
120 private int _open_seq_web_item;
121 private int _open_tax_web_item;
122 private int _color_node_font_item;
123 private JButton _order;
124 private boolean _order_of_appearance;
125 private int _paste_subtree_item;
126 private int _reroot_cb_item;
127 private JButton _return_to_super_tree;
129 private JLabel _search_found_label_0;
130 private JLabel _search_found_label_1;
131 private JButton _search_reset_button_0;
132 private JButton _search_reset_button_1;
133 private JTextField _search_tf_0;
134 private JTextField _search_tf_1;
135 private int _select_nodes_item;
136 private Sequence _selected_query_seq;
137 private JCheckBox _seq_relation_confidence_switch;
138 private JComboBox<SEQUENCE_RELATION_TYPE> _sequence_relation_type_box;
139 private JCheckBox _show_annotation;
140 private JCheckBox _show_binary_character_counts;
141 private JCheckBox _show_binary_characters;
142 // Indices for the click-to options in the combo box
143 private int _show_data_item;
144 private JCheckBox _show_domain_architectures;
145 private JCheckBox _show_events;
146 private JCheckBox _show_gene_names;
147 private JCheckBox _show_node_names;
148 private JCheckBox _show_properties_cb;
149 private JCheckBox _show_seq_names;
150 private JCheckBox _show_seq_symbols;
151 private JCheckBox _show_sequence_acc;
152 private JComboBox<String> _show_sequence_relations;
153 private JCheckBox _show_taxo_code;
154 private JCheckBox _show_taxo_common_names;
155 private JCheckBox _show_taxo_images_cb;
156 private JCheckBox _show_taxo_scientific_names;
157 private JCheckBox _show_vector_data_cb;
158 private JButton _show_whole;
159 private int _sort_descendents_item;
160 private Map<String, Color> _species_colors;
161 private Map<String, Color> _sequence_colors;
162 private int _subtree_cb_item;
163 private int _swap_cb_item;
164 private JButton _uncollapse_all;
165 private JCheckBox _width_branches;
166 private JCheckBox _write_confidence;
167 private JButton _zoom_in_domain_structure;
168 // zooming and quick tree manipulation buttons:
169 private JButton _zoom_in_x;
170 private JButton _zoom_in_y;
171 private JLabel _zoom_label;
172 private JButton _zoom_out_domain_structure;
173 private JButton _zoom_out_x;
174 private JButton _zoom_out_y;
176 ControlPanel( final MainPanel ap, final Configuration configuration ) {
179 _configuration = configuration;
180 if ( !_configuration.isUseNativeUI() ) {
181 setBackground( getConfiguration().getGuiBackgroundColor() );
182 setBorder( BorderFactory.createRaisedBevelBorder() );
184 setLayout( new GridLayout( 0, 1, 2, 2 ) );
185 _order_of_appearance = true;
193 public void actionPerformed( final ActionEvent e ) {
195 if ( e.getSource() == _color_acc_sequence ) {
196 if ( _color_acc_species != null ) {
197 _color_acc_species.setSelected( false );
200 else if ( e.getSource() == _color_acc_species ) {
201 if ( _color_acc_sequence != null ) {
202 _color_acc_sequence.setSelected( false );
208 final TreePanel tp = getMainPanel().getCurrentTreePanel();
212 if ( e.getSource() == _click_to_combobox ) {
213 setClickToAction( _click_to_combobox.getSelectedIndex() );
214 getCurrentTreePanel().repaint();
216 else if ( e.getSource() == _show_binary_characters ) {
217 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
218 _show_binary_character_counts.setSelected( false );
220 displayedPhylogenyMightHaveChanged( true );
222 else if ( e.getSource() == _show_binary_character_counts ) {
223 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
224 _show_binary_characters.setSelected( false );
226 displayedPhylogenyMightHaveChanged( true );
228 else if ( e.getSource() == _show_domain_architectures ) {
231 displayedPhylogenyMightHaveChanged( true );
233 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
234 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
235 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
239 else if ( e.getSource() == _zoom_in_x ) {
240 zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
241 displayedPhylogenyMightHaveChanged( false );
243 else if ( e.getSource() == _zoom_in_y ) {
244 zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR );
245 displayedPhylogenyMightHaveChanged( false );
247 else if ( e.getSource() == _zoom_out_x ) {
248 zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
249 displayedPhylogenyMightHaveChanged( false );
251 else if ( e.getSource() == _zoom_out_y ) {
252 zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR );
253 displayedPhylogenyMightHaveChanged( false );
255 else if ( e.getSource() == _show_whole ) {
258 else if ( e.getSource() == _return_to_super_tree ) {
259 _mainpanel.getCurrentTreePanel().superTree();
262 else if ( e.getSource() == _order ) {
263 DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
264 if ( ( !isShowTaxonomyScientificNames() && !isShowTaxonomyCode() && !isShowTaxonomyCommonNames() ) ) {
265 if ( ( isShowSequenceAcc() || isShowSeqNames() || isShowSeqSymbols() ) ) {
266 pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
268 else if ( isShowNodeNames() ) {
269 pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
272 PhylogenyMethods.orderAppearance( tp.getPhylogeny().getRoot(), _order_of_appearance, true, pri );
273 _order_of_appearance = !_order_of_appearance;
274 tp.setNodeInPreorderToNull();
275 tp.getPhylogeny().externalNodesHaveChanged();
276 tp.getPhylogeny().clearHashIdToNodeMap();
277 tp.getPhylogeny().recalculateNumberOfExternalDescendants( true );
278 tp.resetNodeIdToDistToLeafMap();
279 tp.setEdited( true );
280 displayedPhylogenyMightHaveChanged( false );
282 else if ( e.getSource() == _uncollapse_all ) {
284 displayedPhylogenyMightHaveChanged( false );
286 else if ( e.getSource() == _zoom_in_domain_structure ) {
287 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
288 displayedPhylogenyMightHaveChanged( true );
290 else if ( e.getSource() == _zoom_out_domain_structure ) {
291 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
292 displayedPhylogenyMightHaveChanged( true );
294 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
295 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThreshold();
296 displayedPhylogenyMightHaveChanged( true );
298 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
299 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThreshold();
300 displayedPhylogenyMightHaveChanged( true );
302 else if ( e.getSource() == _search_tf_0 ) {
304 displayedPhylogenyMightHaveChanged( true );
306 else if ( e.getSource() == _search_tf_1 ) {
308 displayedPhylogenyMightHaveChanged( true );
310 else if ( _dynamically_hide_data != null && e.getSource() == _dynamically_hide_data && !_dynamically_hide_data.isSelected() ) {
311 setDynamicHidingIsOn( false );
312 displayedPhylogenyMightHaveChanged( true );
315 displayedPhylogenyMightHaveChanged( true );
319 tp.requestFocusInWindow();
322 catch ( final Exception ex ) {
323 AptxUtil.unexpectedException( ex );
325 catch ( final Error err ) {
326 AptxUtil.unexpectedError( err );
330 public JCheckBox getColorAccSpeciesCb() {
331 return _color_acc_species;
334 public JCheckBox getColorAccSequenceCb() {
335 return _color_acc_sequence;
338 public JCheckBox getUseVisualStylesCb() {
339 return _use_visual_styles_cb;
342 public JCheckBox getDisplayAsPhylogramCb() {
343 return _display_as_phylogram_cb;
346 public JCheckBox getDynamicallyHideData() {
347 return _dynamically_hide_data;
350 public JCheckBox getNodeDescPopupCb() {
351 return _node_desc_popup_cb;
354 public Sequence getSelectedQuerySequence() {
355 return _selected_query_seq;
358 public JComboBox<String> getSequenceRelationBox() {
359 if ( _show_sequence_relations == null ) {
360 _show_sequence_relations = new JComboBox<String>();
361 _show_sequence_relations.setFocusable( false );
362 _show_sequence_relations.setMaximumRowCount( 20 );
363 _show_sequence_relations.setFont( ControlPanel.js_font );
364 if ( !_configuration.isUseNativeUI() ) {
365 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
366 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
368 _show_sequence_relations.addItem( "-----" );
369 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
371 return _show_sequence_relations;
375 public JComboBox<SEQUENCE_RELATION_TYPE> getSequenceRelationTypeBox() {
376 if ( _sequence_relation_type_box == null ) {
377 _sequence_relation_type_box = new JComboBox<SEQUENCE_RELATION_TYPE>();
378 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
379 _sequence_relation_type_box.addItem( type );
381 _sequence_relation_type_box.addActionListener( new ActionListener() {
384 public void actionPerformed( final ActionEvent e ) {
385 if ( _mainpanel.getCurrentPhylogeny() != null ) {
386 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
391 return _sequence_relation_type_box;
394 public JCheckBox getShowEventsCb() {
398 public JCheckBox getWriteConfidenceCb() {
399 return _write_confidence;
402 public boolean isShowProperties() {
403 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
406 public boolean isShowTaxonomyImages() {
407 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
410 public boolean isShowVectorData() {
411 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
414 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
415 final JComboBox<String> box = getSequenceRelationBox();
416 while ( box.getItemCount() > 1 ) {
417 box.removeItemAt( 1 );
419 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
420 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
422 if ( relationType == null ) {
425 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
426 for( final Sequence seq : sequenceRelationQueries ) {
427 if ( seq.hasSequenceRelations() ) {
428 boolean fFoundForCurrentType = false;
429 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
430 if ( sq.getType().equals( relationType ) ) {
431 fFoundForCurrentType = true;
435 if ( fFoundForCurrentType ) {
436 sequenceNamesToAdd.add( seq.getName() );
437 sequencesByName.put( seq.getName(), seq );
441 // sort sequences by name before adding them to the combo
442 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
443 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
444 for( final String seqName : sequenceNameArray ) {
445 box.addItem( seqName );
447 for( final ItemListener oldItemListener : box.getItemListeners() ) {
448 box.removeItemListener( oldItemListener );
450 box.addItemListener( new ItemListener() {
453 public void itemStateChanged( final ItemEvent e ) {
454 _selected_query_seq = sequencesByName.get( e.getItem() );
455 _mainpanel.getCurrentTreePanel().repaint();
460 void activateButtonToReturnToSuperTree( int index ) {
463 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
466 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
468 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
469 _return_to_super_tree.setEnabled( true );
473 * Add zoom and quick edit buttons. (Last modified 8/9/04)
476 final JLabel spacer = new JLabel( "" );
477 spacer.setOpaque( false );
479 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
480 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
481 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
482 if ( !getConfiguration().isUseNativeUI() ) {
483 x_panel.setBackground( getBackground() );
484 y_panel.setBackground( getBackground() );
485 z_panel.setBackground( getBackground() );
487 add( _zoom_label = new JLabel( "Zoom:" ) );
488 customizeLabel( _zoom_label, getConfiguration() );
492 if ( getConfiguration().isUseNativeUI() ) {
493 _zoom_in_x = new JButton( "+" );
494 _zoom_out_x = new JButton( "-" );
497 _zoom_in_x = new JButton( "X+" );
498 _zoom_out_x = new JButton( "X-" );
500 _zoom_in_y = new JButton( "Y+" );
501 _zoom_out_y = new JButton( "Y-" );
502 _show_whole = new JButton( "F" );
503 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [F or Home]" );
504 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+cursor-right]" );
505 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+cursor-up]" );
506 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+cursor-left]" );
507 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+cursor-down]" );
508 if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) {
509 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
510 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
513 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
514 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
516 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
517 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
518 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
519 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
520 _return_to_super_tree.setEnabled( false );
521 _order = new JButton( "Order Subtrees" );
522 _uncollapse_all = new JButton( "Uncollapse All" );
523 addJButton( _zoom_in_y, x_panel );
524 addJButton( _zoom_out_x, y_panel );
525 addJButton( _show_whole, y_panel );
526 addJButton( _zoom_in_x, y_panel );
527 addJButton( _zoom_out_y, z_panel );
528 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
529 setUpControlsForDomainStrucures();
531 final JLabel spacer2 = new JLabel( "" );
533 addJButton( _return_to_super_tree, this );
534 addJButton( _order, this );
535 addJButton( _uncollapse_all, this );
536 final JLabel spacer3 = new JLabel( "" );
538 setVisibilityOfDomainStrucureControls();
541 void addCheckbox( final int which, final String title ) {
542 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
544 case Configuration.display_as_phylogram:
545 _display_as_phylogram_cb = new JCheckBox( title );
546 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
547 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
550 case Configuration.display_internal_data:
551 _display_internal_data = new JCheckBox( title );
552 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
553 addJCheckBox( _display_internal_data, ch_panel );
556 case Configuration.color_according_to_species:
557 _color_acc_species = new JCheckBox( title );
559 .setToolTipText( "To colorize node labels as a function of taxonomy" );
560 addJCheckBox( _color_acc_species, ch_panel );
563 case Configuration.color_according_to_sequence:
564 _color_acc_sequence = new JCheckBox( title );
566 .setToolTipText( "To colorize node labels as a function of sequence name" );
567 addJCheckBox( _color_acc_sequence, ch_panel );
570 case Configuration.color_according_to_annotation:
571 _color_according_to_annotation = new JCheckBox( title );
572 _color_according_to_annotation
573 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
574 addJCheckBox( _color_according_to_annotation, ch_panel );
577 case Configuration.show_node_names:
578 _show_node_names = new JCheckBox( title );
579 addJCheckBox( _show_node_names, ch_panel );
582 case Configuration.show_taxonomy_scientific_names:
583 _show_taxo_scientific_names = new JCheckBox( title );
584 addJCheckBox( _show_taxo_scientific_names, ch_panel );
587 case Configuration.show_taxonomy_common_names:
588 _show_taxo_common_names = new JCheckBox( title );
589 addJCheckBox( _show_taxo_common_names, ch_panel );
592 case Configuration.show_tax_code:
593 _show_taxo_code = new JCheckBox( title );
594 addJCheckBox( _show_taxo_code, ch_panel );
597 case Configuration.show_taxonomy_images:
598 _show_taxo_images_cb = new JCheckBox( title );
599 addJCheckBox( _show_taxo_images_cb, ch_panel );
602 case Configuration.show_binary_characters:
603 _show_binary_characters = new JCheckBox( title );
604 addJCheckBox( _show_binary_characters, ch_panel );
607 case Configuration.show_annotation:
608 _show_annotation = new JCheckBox( title );
609 addJCheckBox( _show_annotation, ch_panel );
612 case Configuration.show_binary_character_counts:
613 _show_binary_character_counts = new JCheckBox( title );
614 addJCheckBox( _show_binary_character_counts, ch_panel );
617 case Configuration.write_confidence_values:
618 _write_confidence = new JCheckBox( title );
619 addJCheckBox( getWriteConfidenceCb(), ch_panel );
622 case Configuration.write_events:
623 _show_events = new JCheckBox( title );
624 addJCheckBox( getShowEventsCb(), ch_panel );
627 case Configuration.use_style:
628 _use_visual_styles_cb = new JCheckBox( title );
629 getUseVisualStylesCb()
630 .setToolTipText( "To use visual styles (node colors, fonts) and branch colors, if present" );
631 addJCheckBox( getUseVisualStylesCb(), ch_panel );
634 case Configuration.width_branches:
635 _width_branches = new JCheckBox( title );
636 _width_branches.setToolTipText( "To use branch width values, if present" );
637 addJCheckBox( _width_branches, ch_panel );
640 case Configuration.show_domain_architectures:
641 _show_domain_architectures = new JCheckBox( title );
642 addJCheckBox( _show_domain_architectures, ch_panel );
645 case Configuration.show_seq_names:
646 _show_seq_names = new JCheckBox( title );
647 addJCheckBox( _show_seq_names, ch_panel );
650 case Configuration.show_gene_names:
651 _show_gene_names = new JCheckBox( title );
652 addJCheckBox( _show_gene_names, ch_panel );
655 case Configuration.show_seq_symbols:
656 _show_seq_symbols = new JCheckBox( title );
657 addJCheckBox( _show_seq_symbols, ch_panel );
660 case Configuration.show_sequence_acc:
661 _show_sequence_acc = new JCheckBox( title );
662 addJCheckBox( _show_sequence_acc, ch_panel );
665 case Configuration.dynamically_hide_data:
666 _dynamically_hide_data = new JCheckBox( title );
667 getDynamicallyHideData().setToolTipText( "To hide labels depending on expected visibility" );
668 addJCheckBox( getDynamicallyHideData(), ch_panel );
671 case Configuration.node_data_popup:
672 _node_desc_popup_cb = new JCheckBox( title );
673 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
674 addJCheckBox( getNodeDescPopupCb(), ch_panel );
677 case Configuration.show_relation_confidence:
678 _seq_relation_confidence_switch = new JCheckBox( title );
679 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
682 case Configuration.show_vector_data:
683 _show_vector_data_cb = new JCheckBox( title );
684 addJCheckBox( _show_vector_data_cb, ch_panel );
687 case Configuration.show_properties:
688 _show_properties_cb = new JCheckBox( title );
689 addJCheckBox( _show_properties_cb, ch_panel );
693 throw new RuntimeException( "unknown checkbox: " + which );
697 void addJButton( final JButton jb, final JPanel p ) {
698 jb.setFocusPainted( false );
699 jb.setFont( ControlPanel.jcb_font );
700 if ( !_configuration.isUseNativeUI() ) {
701 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
702 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
703 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
706 jb.addActionListener( this );
709 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
710 jcb.setFocusPainted( false );
711 jcb.setFont( ControlPanel.jcb_font );
712 if ( !_configuration.isUseNativeUI() ) {
713 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
714 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
716 p.add( jcb, "Center" );
717 jcb.addActionListener( this );
720 void addJTextField( final JTextField tf, final JPanel p ) {
721 if ( !_configuration.isUseNativeUI() ) {
722 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
723 tf.setFont( ControlPanel.jcb_font );
726 tf.addActionListener( this );
729 void deactivateButtonToReturnToSuperTree() {
730 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
731 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
732 _return_to_super_tree.setEnabled( false );
735 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
736 if ( ( _mainpanel != null )
737 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
738 if ( getOptions().isShowOverview() ) {
739 _mainpanel.getCurrentTreePanel().updateOvSizes();
741 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
742 setVisibilityOfDomainStrucureControls();
743 updateDomainStructureEvaluethresholdDisplay();
744 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
745 _mainpanel.getCurrentTreePanel().calcMaxDepth();
746 _mainpanel.adjustJScrollPane();
747 if ( recalc_longest_ext_node_info ) {
748 _mainpanel.getCurrentTreePanel().initNodeData();
749 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
751 _mainpanel.getCurrentTreePanel().repaint();
752 // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
756 void endClickToOptions() {
757 _click_to_combobox.addActionListener( this );
761 * Indicates what action should be execute when a node is clicked
763 * @return the click-on action
765 NodeClickAction getActionWhenNodeClicked() {
766 return _action_when_node_clicked;
769 Map<Integer, String> getAllClickToItems() {
770 return _all_click_to_names;
773 Map<String, Color> getAnnotationColors() {
774 return _annotation_colors;
777 Configuration getConfiguration() {
778 return _configuration;
781 TreePanel getCurrentTreePanel() {
782 return getMainPanel().getCurrentTreePanel();
785 MainPanel getMainPanel() {
789 Options getOptions() {
790 return getMainPanel().getOptions();
793 JLabel getSearchFoundCountsLabel0() {
794 return _search_found_label_0;
797 JLabel getSearchFoundCountsLabel1() {
798 return _search_found_label_1;
801 JButton getSearchResetButton0() {
802 return _search_reset_button_0;
805 JButton getSearchResetButton1() {
806 return _search_reset_button_1;
809 JTextField getSearchTextField0() {
813 JTextField getSearchTextField1() {
817 List<String> getSingleClickToNames() {
818 return _click_to_names;
821 Map<String, Color> getSpeciesColors() {
822 return _species_colors;
825 Map<String, Color> getSequenceColors() {
826 return _sequence_colors;
829 boolean isAntialiasScreenText() {
833 boolean isColorAccordingToAnnotation() {
834 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
837 boolean isColorAccordingToTaxonomy() {
838 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
841 boolean isColorAccordingToSequence() {
842 return ( ( _color_acc_sequence != null ) && _color_acc_sequence.isSelected() );
845 boolean isUseVisualStyles() {
846 return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() ) || ( ( getUseVisualStylesCb() == null ) && _color_branches ) );
849 boolean isDrawPhylogram() {
850 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
853 boolean isDynamicallyHideData() {
854 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
858 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
861 boolean isNodeDescPopup() {
862 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
865 boolean isShowAnnotation() {
866 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
869 boolean isShowBinaryCharacterCounts() {
870 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
873 boolean isShowBinaryCharacters() {
874 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
877 boolean isShowConfidenceValues() {
878 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
881 boolean isShowDomainArchitectures() {
882 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
885 boolean isShowGeneNames() {
886 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
889 boolean isShowInternalData() {
890 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
893 boolean isShowNodeNames() {
894 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
897 boolean isShowSeqNames() {
898 return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
901 boolean isShowSeqSymbols() {
902 return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
905 boolean isShowSequenceAcc() {
906 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
909 boolean isShowSequenceRelationConfidence() {
910 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
913 boolean isShowSequenceRelations() {
914 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
917 boolean isShowTaxonomyCode() {
918 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
921 boolean isShowTaxonomyCommonNames() {
922 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
925 boolean isShowTaxonomyScientificNames() {
926 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
929 boolean isWidthBranches() {
930 return ( ( _width_branches != null ) && _width_branches.isSelected() );
933 void phylogenyAdded( final Configuration configuration ) {
934 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
937 void phylogenyRemoved( final int index ) {
938 getIsDrawPhylogramList().remove( index );
942 final MainPanel main_panel = getMainPanel();
943 final Phylogeny tree = main_panel.getCurrentPhylogeny();
944 if ( ( tree == null ) || tree.isEmpty() ) {
947 String query = getSearchTextField0().getText();
948 if ( query != null ) {
949 query = query.trim();
951 if ( !ForesterUtil.isEmpty( query ) ) {
952 search0( main_panel, tree, query );
955 getSearchFoundCountsLabel0().setVisible( false );
956 getSearchResetButton0().setEnabled( false );
957 getSearchResetButton0().setVisible( false );
963 final MainPanel main_panel = getMainPanel();
964 final Phylogeny tree = main_panel.getCurrentPhylogeny();
965 if ( ( tree == null ) || tree.isEmpty() ) {
968 String query = getSearchTextField1().getText();
969 if ( query != null ) {
970 query = query.trim();
972 if ( !ForesterUtil.isEmpty( query ) ) {
973 search1( main_panel, tree, query );
976 getSearchFoundCountsLabel1().setVisible( false );
977 getSearchResetButton1().setEnabled( false );
978 getSearchResetButton1().setVisible( false );
983 void searchReset0() {
984 if ( getMainPanel().getCurrentTreePanel() != null ) {
985 getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
989 void searchReset1() {
990 if ( getMainPanel().getCurrentTreePanel() != null ) {
991 getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
995 void setActionWhenNodeClicked( final NodeClickAction action ) {
996 _action_when_node_clicked = action;
999 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
1000 _annotation_colors = annotation_colors;
1003 void setCheckbox( final int which, final boolean state ) {
1005 case Configuration.display_as_phylogram:
1006 if ( getDisplayAsPhylogramCb() != null ) {
1007 getDisplayAsPhylogramCb().setSelected( state );
1010 case Configuration.display_internal_data:
1011 if ( _display_internal_data != null ) {
1012 _display_internal_data.setSelected( state );
1015 case Configuration.color_according_to_species:
1016 if ( _color_acc_species != null ) {
1017 _color_acc_species.setSelected( state );
1020 case Configuration.color_according_to_sequence:
1021 if ( _color_acc_sequence != null ) {
1022 _color_acc_sequence.setSelected( state );
1025 case Configuration.color_according_to_annotation:
1026 if ( _color_according_to_annotation != null ) {
1027 _color_according_to_annotation.setSelected( state );
1030 case Configuration.show_node_names:
1031 if ( _show_node_names != null ) {
1032 _show_node_names.setSelected( state );
1035 case Configuration.show_taxonomy_scientific_names:
1036 if ( _show_taxo_scientific_names != null ) {
1037 _show_taxo_scientific_names.setSelected( state );
1040 case Configuration.show_taxonomy_common_names:
1041 if ( _show_taxo_common_names != null ) {
1042 _show_taxo_common_names.setSelected( state );
1045 case Configuration.show_tax_code:
1046 if ( _show_taxo_code != null ) {
1047 _show_taxo_code.setSelected( state );
1050 case Configuration.show_taxonomy_images:
1051 if ( _show_taxo_images_cb != null ) {
1052 _show_taxo_images_cb.setSelected( state );
1055 case Configuration.show_annotation:
1056 if ( _show_annotation != null ) {
1057 _show_annotation.setSelected( state );
1060 case Configuration.show_binary_characters:
1061 if ( _show_binary_characters != null ) {
1062 _show_binary_characters.setSelected( state );
1065 case Configuration.show_binary_character_counts:
1066 if ( _show_binary_character_counts != null ) {
1067 _show_binary_character_counts.setSelected( state );
1070 case Configuration.write_confidence_values:
1071 if ( getWriteConfidenceCb() != null ) {
1072 getWriteConfidenceCb().setSelected( state );
1075 case Configuration.write_events:
1076 if ( getShowEventsCb() != null ) {
1077 getShowEventsCb().setSelected( state );
1080 case Configuration.use_style:
1081 if ( getUseVisualStylesCb() != null ) {
1082 getUseVisualStylesCb().setSelected( state );
1085 case Configuration.width_branches:
1086 if ( _width_branches != null ) {
1087 _width_branches.setSelected( state );
1090 case Configuration.show_domain_architectures:
1091 if ( _show_domain_architectures != null ) {
1092 _show_domain_architectures.setSelected( state );
1095 case Configuration.show_seq_names:
1096 if ( _show_seq_names != null ) {
1097 _show_seq_names.setSelected( state );
1100 case Configuration.show_gene_names:
1101 if ( _show_gene_names != null ) {
1102 _show_gene_names.setSelected( state );
1105 case Configuration.show_seq_symbols:
1106 if ( _show_seq_symbols != null ) {
1107 _show_seq_symbols.setSelected( state );
1110 case Configuration.show_vector_data:
1111 if ( _show_vector_data_cb != null ) {
1112 _show_vector_data_cb.setSelected( state );
1115 case Configuration.show_properties:
1116 if ( _show_properties_cb != null ) {
1117 _show_properties_cb.setSelected( state );
1120 case Configuration.show_sequence_acc:
1121 if ( _show_sequence_acc != null ) {
1122 _show_sequence_acc.setSelected( state );
1125 case Configuration.dynamically_hide_data:
1126 if ( getDynamicallyHideData() != null ) {
1127 getDynamicallyHideData().setSelected( state );
1130 case Configuration.node_data_popup:
1131 if ( getNodeDescPopupCb() != null ) {
1132 getNodeDescPopupCb().setSelected( state );
1136 case Configuration.show_relation_confidence:
1137 if ( _seq_relation_confidence_switch != null ) {
1138 _seq_relation_confidence_switch.setSelected( state );
1143 throw new AssertionError( "unknown checkbox: " + which );
1148 * Set this checkbox state. Not all checkboxes have been instantiated
1149 * depending on the config.
1151 void setCheckbox( final JCheckBox cb, final boolean state ) {
1153 cb.setSelected( state );
1157 void setClickToAction( final int action ) {
1158 // Set click-to action
1159 if ( action == _show_data_item ) {
1160 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1162 else if ( action == _collapse_cb_item ) {
1163 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1165 else if ( action == _reroot_cb_item ) {
1166 setActionWhenNodeClicked( NodeClickAction.REROOT );
1168 else if ( action == _subtree_cb_item ) {
1169 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1171 else if ( action == _swap_cb_item ) {
1172 setActionWhenNodeClicked( NodeClickAction.SWAP );
1174 else if ( action == _color_subtree_cb_item ) {
1175 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1177 else if ( action == _open_seq_web_item ) {
1178 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1180 else if ( action == _sort_descendents_item ) {
1181 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1183 else if ( action == _blast_item ) {
1184 setActionWhenNodeClicked( NodeClickAction.BLAST );
1186 else if ( action == _open_tax_web_item ) {
1187 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1189 else if ( action == _cut_subtree_item ) {
1190 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1192 else if ( action == _copy_subtree_item ) {
1193 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1195 else if ( action == _delete_node_or_subtree_item ) {
1196 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1198 else if ( action == _paste_subtree_item ) {
1199 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1201 else if ( action == _add_new_node_item ) {
1202 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1204 else if ( action == _edit_node_data_item ) {
1205 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1207 else if ( action == _select_nodes_item ) {
1208 setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
1210 else if ( action == _get_ext_desc_data ) {
1211 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
1213 else if ( action == _open_pdb_item ) {
1214 setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
1216 else if ( action == _color_node_font_item ) {
1217 setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
1219 else if ( action == _change_node_font_item ) {
1220 setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT );
1223 throw new RuntimeException( "unknown action: " + action );
1225 // make sure drop down is displaying the correct action
1226 // in case this was called from outside the class
1227 _click_to_combobox.setSelectedIndex( action );
1230 void setColorBranches( final boolean color_branches ) {
1231 _color_branches = color_branches;
1234 void setDrawPhylogram( final boolean b ) {
1235 getDisplayAsPhylogramCb().setSelected( b );
1236 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1239 void setDrawPhylogramEnabled( final boolean b ) {
1240 getDisplayAsPhylogramCb().setEnabled( b );
1243 void setDynamicHidingIsOn( final boolean is_on ) {
1245 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1248 if ( !_configuration.isUseNativeUI() ) {
1249 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1252 getDynamicallyHideData().setForeground( Color.BLACK );
1257 void setSearchFoundCountsOnLabel0( final int counts ) {
1258 getSearchFoundCountsLabel0().setText( "Found: " + counts );
1261 void setSearchFoundCountsOnLabel1( final int counts ) {
1262 getSearchFoundCountsLabel1().setText( "Found: " + counts );
1265 void setShowEvents( final boolean show_events ) {
1266 if ( getShowEventsCb() == null ) {
1267 _show_events = new JCheckBox( "" );
1269 getShowEventsCb().setSelected( show_events );
1272 void setSpeciesColors( final Map<String, Color> species_colors ) {
1273 _species_colors = species_colors;
1276 void setSequenceColors( final Map<String, Color> sequence_colors ) {
1277 _sequence_colors = sequence_colors;
1282 * Set up the controls from the config settings. 11/26/05
1284 void setupControls() {
1285 // The tree display options:
1286 setupDisplayCheckboxes();
1288 // The sequence relation query selection combo-box
1289 if ( _configuration.displaySequenceRelations() ) {
1290 addSequenceRelationBlock();
1294 startClickToOptions();
1295 setupClickToOptions();
1296 endClickToOptions();
1297 // Zoom and quick edit buttons
1299 setupSearchTools0();
1300 setupSearchTools1();
1303 void setUpControlsForDomainStrucures() {
1304 _domain_display_label = new JLabel( "Domain Display:" );
1305 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1306 add( _domain_display_label );
1307 _zoom_in_domain_structure = new JButton( "d+" );
1308 _zoom_out_domain_structure = new JButton( "d-" );
1309 _decr_domain_structure_evalue_thr = new JButton( "-" );
1310 _incr_domain_structure_evalue_thr = new JButton( "+" );
1311 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1312 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1313 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1314 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1315 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1316 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1317 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1318 _domain_structure_evalue_thr_tf.setEditable( false );
1319 if ( !getConfiguration().isUseNativeUI() ) {
1320 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1321 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1322 _domain_structure_evalue_thr_tf.setBorder( null );
1324 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1325 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1326 if ( !_configuration.isUseNativeUI() ) {
1327 d1_panel.setBackground( getBackground() );
1328 d2_panel.setBackground( getBackground() );
1332 addJButton( _zoom_out_domain_structure, d1_panel );
1333 addJButton( _zoom_in_domain_structure, d1_panel );
1334 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1335 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1336 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1339 void setupSearchTools0() {
1340 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1341 final JLabel search_label = new JLabel( "Search (A):" );
1342 search_label.setFont( ControlPanel.jcb_bold_font );
1343 if ( !getConfiguration().isUseNativeUI() ) {
1344 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1346 add( search_label );
1347 search_label.setToolTipText( tip );
1348 _search_found_label_0 = new JLabel();
1349 getSearchFoundCountsLabel0().setVisible( false );
1350 _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
1351 if ( !getConfiguration().isUseNativeUI() ) {
1352 _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1354 _search_tf_0 = new JTextField( 3 );
1355 _search_tf_0.setToolTipText( tip );
1356 _search_tf_0.setEditable( true );
1357 if ( !getConfiguration().isUseNativeUI() ) {
1358 _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1359 _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1360 _search_tf_0.setBorder( null );
1362 _search_reset_button_0 = new JButton();
1363 getSearchResetButton0().setText( "Reset" );
1364 getSearchResetButton0().setEnabled( false );
1365 getSearchResetButton0().setVisible( false );
1366 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1367 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1368 s_panel_1.setBackground( getBackground() );
1370 s_panel_2.setBackground( getBackground() );
1372 final KeyAdapter key_adapter = new KeyAdapter() {
1375 public void keyReleased( final KeyEvent key_event ) {
1377 displayedPhylogenyMightHaveChanged( true );
1380 final ActionListener action_listener = new ActionListener() {
1383 public void actionPerformed( final ActionEvent e ) {
1385 setSearchFoundCountsOnLabel0( 0 );
1386 getSearchFoundCountsLabel0().setVisible( false );
1387 getSearchTextField0().setText( "" );
1388 getSearchResetButton0().setEnabled( false );
1389 getSearchResetButton0().setVisible( false );
1390 displayedPhylogenyMightHaveChanged( true );
1393 _search_reset_button_0.addActionListener( action_listener );
1394 _search_tf_0.addKeyListener( key_adapter );
1395 addJTextField( _search_tf_0, s_panel_1 );
1396 s_panel_2.add( _search_found_label_0 );
1397 addJButton( _search_reset_button_0, s_panel_2 );
1400 void setupSearchTools1() {
1401 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1402 final JLabel search_label = new JLabel( "Search (B):" );
1403 search_label.setFont( ControlPanel.jcb_bold_font );
1404 if ( !getConfiguration().isUseNativeUI() ) {
1405 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1407 add( search_label );
1408 search_label.setToolTipText( tip );
1409 _search_found_label_1 = new JLabel();
1410 getSearchFoundCountsLabel1().setVisible( false );
1411 _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
1412 if ( !getConfiguration().isUseNativeUI() ) {
1413 _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1415 _search_tf_1 = new JTextField( 3 );
1416 _search_tf_1.setToolTipText( tip );
1417 _search_tf_1.setEditable( true );
1418 if ( !getConfiguration().isUseNativeUI() ) {
1419 _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1420 _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1421 _search_tf_1.setBorder( null );
1423 _search_reset_button_1 = new JButton();
1424 getSearchResetButton1().setText( "Reset" );
1425 getSearchResetButton1().setEnabled( false );
1426 getSearchResetButton1().setVisible( false );
1427 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1428 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1429 s_panel_1.setBackground( getBackground() );
1431 s_panel_2.setBackground( getBackground() );
1433 final KeyAdapter key_adapter = new KeyAdapter() {
1436 public void keyReleased( final KeyEvent key_event ) {
1438 displayedPhylogenyMightHaveChanged( true );
1441 final ActionListener action_listener = new ActionListener() {
1444 public void actionPerformed( final ActionEvent e ) {
1446 setSearchFoundCountsOnLabel1( 0 );
1447 getSearchFoundCountsLabel1().setVisible( false );
1448 getSearchTextField1().setText( "" );
1449 getSearchResetButton1().setEnabled( false );
1450 getSearchResetButton1().setVisible( false );
1451 displayedPhylogenyMightHaveChanged( true );
1454 _search_reset_button_1.addActionListener( action_listener );
1455 _search_tf_1.addKeyListener( key_adapter );
1456 addJTextField( _search_tf_1, s_panel_1 );
1457 s_panel_2.add( _search_found_label_1 );
1458 addJButton( _search_reset_button_1, s_panel_2 );
1461 void showAnnotations() {
1462 if ( _show_annotation != null ) {
1463 _show_annotation.setSelected( true );
1465 if ( _color_according_to_annotation != null ) {
1466 _color_according_to_annotation.setSelected( true );
1468 if ( _color_acc_species != null ) {
1469 _color_acc_species.setSelected( false );
1471 if ( _color_acc_sequence != null ) {
1472 _color_acc_sequence.setSelected( false );
1474 _mainpanel.getCurrentTreePanel().repaint();
1478 * Fit entire tree into window.
1481 if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
1484 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
1485 displayedPhylogenyMightHaveChanged( true );
1486 _mainpanel.getCurrentTreePanel().updateOvSettings();
1487 _mainpanel.getCurrentTreePanel().validate();
1488 _mainpanel.validate();
1489 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1490 _mainpanel.getSizeOfViewport().height,
1492 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1493 _mainpanel.adjustJScrollPane();
1494 _mainpanel.getCurrentTreePanel().repaint();
1495 _mainpanel.getCurrentTreePanel().validate();
1496 _mainpanel.validate();
1497 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1498 _mainpanel.getSizeOfViewport().height,
1500 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1501 _mainpanel.adjustJScrollPane();
1502 _mainpanel.getCurrentTreePanel().repaint();
1503 _mainpanel.getCurrentTreePanel().updateOvSizes();
1506 void showWholeAll() {
1507 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1508 if ( tree_panel != null ) {
1509 tree_panel.validate();
1510 tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1511 _mainpanel.getSizeOfViewport().height,
1513 tree_panel.resetPreferredSize();
1514 tree_panel.repaint();
1519 // Create header for click-to combo box.
1520 void startClickToOptions() {
1521 final JLabel spacer = new JLabel( "" );
1522 spacer.setFont( ControlPanel.jcb_font );
1524 _click_to_label = new JLabel( "Click on Node to:" );
1525 add( customizeLabel( _click_to_label, getConfiguration() ) );
1526 _click_to_combobox = new JComboBox<String>();
1527 _click_to_combobox.setFocusable( false );
1528 _click_to_combobox.setMaximumRowCount( 14 );
1529 _click_to_combobox.setFont( ControlPanel.js_font );
1530 if ( !_configuration.isUseNativeUI() ) {
1531 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1533 // don't add listener until all items are set (or each one will trigger
1535 // click_to_list.addActionListener(this);
1536 add( _click_to_combobox );
1537 // Correlates option names to titles
1538 _all_click_to_names = new HashMap<Integer, String>();
1539 _click_to_names = new ArrayList<String>();
1543 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1544 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1545 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1546 setDrawPhylogramEnabled( true );
1547 setDrawPhylogram( isDrawPhylogram() );
1550 setDrawPhylogramEnabled( false );
1551 setDrawPhylogram( false );
1553 if ( getMainPanel().getMainFrame() == null ) {
1554 // Must be "E" applet version.
1555 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1556 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1559 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1560 .getPhylogenyGraphicsType() );
1562 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1563 getMainPanel().getControlPanel().search0();
1564 getMainPanel().getControlPanel().search1();
1565 getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
1566 getSequenceRelationTypeBox().removeAllItems();
1567 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1568 .getRelevantSequenceRelationTypes() ) {
1569 _sequence_relation_type_box.addItem( type );
1571 getMainPanel().getCurrentTreePanel().repaint();
1572 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1573 // according to GUILHEM the line above can be removed.
1578 * Uncollapse all nodes.
1580 void uncollapseAll( final TreePanel tp ) {
1581 final Phylogeny t = tp.getPhylogeny();
1582 if ( ( t != null ) && !t.isEmpty() ) {
1583 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
1584 final PhylogenyNode node = iter.next();
1585 node.setCollapse( false );
1587 tp.resetNodeIdToDistToLeafMap();
1588 tp.updateSetOfCollapsedExternalNodes();
1589 t.recalculateNumberOfExternalDescendants( false );
1590 tp.setNodeInPreorderToNull();
1591 t.clearHashIdToNodeMap();
1596 void updateDomainStructureEvaluethresholdDisplay() {
1597 if ( _domain_structure_evalue_thr_tf != null ) {
1598 _domain_structure_evalue_thr_tf.setText( "10^"
1599 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1603 void zoomInX( final float factor, final float x_correction_factor ) {
1604 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1605 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1606 treepanel.multiplyUrtFactor( 1f );
1607 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1608 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1609 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1610 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1611 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( 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 ) );
1624 getMainPanel().adjustJScrollPane();
1625 treepanel.resetPreferredSize();
1626 getMainPanel().getCurrentScrollPane().getViewport().validate();
1627 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1629 treepanel.resetPreferredSize();
1630 treepanel.updateOvSizes();
1633 void zoomInY( final float factor ) {
1634 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1635 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1636 treepanel.multiplyUrtFactor( 1.1f );
1637 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1638 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1639 getMainPanel().adjustJScrollPane();
1640 treepanel.resetPreferredSize();
1641 getMainPanel().getCurrentScrollPane().getViewport().validate();
1642 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1643 - ( sb.getVisibleAmount() / 2.0 ) ) );
1644 treepanel.resetPreferredSize();
1645 treepanel.updateOvSizes();
1648 void zoomOutX( final float factor, final float x_correction_factor ) {
1649 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1650 treepanel.multiplyUrtFactor( 1f );
1651 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1652 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1653 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1654 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1655 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1656 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1657 getMainPanel().adjustJScrollPane();
1658 treepanel.resetPreferredSize();
1659 getMainPanel().getCurrentScrollPane().getViewport().validate();
1660 final double x = ( sb.getMaximum() - sb.getMinimum() )
1661 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1662 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1663 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1664 getMainPanel().adjustJScrollPane();
1665 treepanel.resetPreferredSize();
1666 getMainPanel().getCurrentScrollPane().getViewport().validate();
1667 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1668 - ( sb.getVisibleAmount() / 2.0 ) ) );
1671 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1672 treepanel.setXdistance( treepanel.getXdistance() * factor );
1673 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
1675 getMainPanel().adjustJScrollPane();
1676 treepanel.resetPreferredSize();
1677 getMainPanel().getCurrentScrollPane().getViewport().validate();
1678 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1681 treepanel.resetPreferredSize();
1682 treepanel.updateOvSizes();
1686 void zoomOutY( final float factor ) {
1687 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1688 treepanel.multiplyUrtFactor( 0.9f );
1689 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1690 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1691 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1692 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1693 getMainPanel().adjustJScrollPane();
1694 treepanel.resetPreferredSize();
1695 getMainPanel().getCurrentScrollPane().getViewport().validate();
1696 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1697 - ( sb.getVisibleAmount() / 2.0 ) ) );
1698 treepanel.resetPreferredSize();
1699 treepanel.updateOvSizes();
1703 private void addClickToOption( final int which, final String title ) {
1704 _click_to_combobox.addItem( title );
1705 _click_to_names.add( title );
1706 _all_click_to_names.put( new Integer( which ), title );
1707 if ( !_configuration.isUseNativeUI() ) {
1708 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1709 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
1714 private void addSequenceRelationBlock() {
1715 final JLabel spacer = new JLabel( "" );
1716 spacer.setSize( 1, 1 );
1718 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
1719 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
1720 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
1721 getSequenceRelationTypeBox().setFocusable( false );
1722 _sequence_relation_type_box.setFont( ControlPanel.js_font );
1723 if ( !_configuration.isUseNativeUI() ) {
1724 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1725 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
1727 _sequence_relation_type_box.setRenderer( new ListCellRenderer<Object>() {
1730 public Component getListCellRendererComponent( final JList<?> list,
1733 final boolean isSelected,
1734 final boolean cellHasFocus ) {
1735 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
1740 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
1741 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
1742 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
1747 final GridBagLayout gbl = new GridBagLayout();
1748 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
1749 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
1750 final JPanel horizGrid = new JPanel( gbl );
1751 horizGrid.setBackground( getBackground() );
1752 horizGrid.add( typeLabel );
1753 horizGrid.add( _sequence_relation_type_box );
1754 add( customizeLabel( mainLabel, getConfiguration() ) );
1756 add( getSequenceRelationBox() );
1757 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
1758 addCheckbox( Configuration.show_relation_confidence,
1759 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
1760 setCheckbox( Configuration.show_relation_confidence,
1761 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
1763 }// addSequenceRelationBlock
1766 private List<Boolean> getIsDrawPhylogramList() {
1767 return _draw_phylogram;
1770 private void init() {
1771 _draw_phylogram = new ArrayList<Boolean>();
1772 setSpeciesColors( new HashMap<String, Color>() );
1773 setSequenceColors( new HashMap<String, Color>() );
1774 setAnnotationColors( new HashMap<String, Color>() );
1777 private boolean isDrawPhylogram( final int index ) {
1778 return getIsDrawPhylogramList().get( index );
1781 private void search0( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
1782 getSearchFoundCountsLabel0().setVisible( true );
1783 getSearchResetButton0().setEnabled( true );
1784 getSearchResetButton0().setVisible( true );
1785 String[] queries = null;
1786 List<PhylogenyNode> nodes = null;
1787 if ( query_str.indexOf( ',' ) >= 0 ) {
1788 queries = query_str.split( ",+" );
1791 queries = new String[ 1 ];
1792 queries[ 0 ] = query_str.trim();
1794 if ( ( queries != null ) && ( queries.length > 0 ) ) {
1795 nodes = new ArrayList<PhylogenyNode>();
1796 for( String query : queries ) {
1797 if ( ForesterUtil.isEmpty( query ) ) {
1800 query = query.trim();
1801 if ( query.indexOf( '+' ) >= 0 ) {
1802 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
1804 getOptions().isSearchCaseSensitive(),
1805 !getOptions().isMatchWholeTermsOnly(),
1806 isShowDomainArchitectures() ) );
1809 nodes.addAll( PhylogenyMethods.searchData( query,
1811 getOptions().isSearchCaseSensitive(),
1812 !getOptions().isMatchWholeTermsOnly(),
1813 isShowDomainArchitectures() ) );
1816 if ( getOptions().isInverseSearchResult() ) {
1817 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
1818 all.removeAll( nodes );
1822 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
1823 main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet<Long>() );
1824 for( final PhylogenyNode node : nodes ) {
1825 main_panel.getCurrentTreePanel().getFoundNodes0().add( node.getId() );
1827 setSearchFoundCountsOnLabel0( nodes.size() );
1830 setSearchFoundCountsOnLabel0( 0 );
1835 private void search1( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
1836 getSearchFoundCountsLabel1().setVisible( true );
1837 getSearchResetButton1().setEnabled( true );
1838 getSearchResetButton1().setVisible( true );
1839 String[] queries = null;
1840 List<PhylogenyNode> nodes = null;
1841 if ( query_str.indexOf( ',' ) >= 0 ) {
1842 queries = query_str.split( ",+" );
1845 queries = new String[ 1 ];
1846 queries[ 0 ] = query_str.trim();
1848 if ( ( queries != null ) && ( queries.length > 0 ) ) {
1849 nodes = new ArrayList<PhylogenyNode>();
1850 for( String query : queries ) {
1851 if ( ForesterUtil.isEmpty( query ) ) {
1854 query = query.trim();
1855 if ( query.indexOf( '+' ) >= 0 ) {
1856 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
1858 getOptions().isSearchCaseSensitive(),
1859 !getOptions().isMatchWholeTermsOnly(),
1860 isShowDomainArchitectures() ) );
1863 nodes.addAll( PhylogenyMethods.searchData( query,
1865 getOptions().isSearchCaseSensitive(),
1866 !getOptions().isMatchWholeTermsOnly(),
1867 isShowDomainArchitectures() ) );
1870 if ( getOptions().isInverseSearchResult() ) {
1871 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
1872 all.removeAll( nodes );
1876 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
1877 main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet<Long>() );
1878 for( final PhylogenyNode node : nodes ) {
1879 main_panel.getCurrentTreePanel().getFoundNodes1().add( node.getId() );
1881 setSearchFoundCountsOnLabel1( nodes.size() );
1884 setSearchFoundCountsOnLabel1( 0 );
1889 private void setDrawPhylogram( final int index, final boolean b ) {
1890 getIsDrawPhylogramList().set( index, b );
1893 private void setupClickToOptions() {
1894 final int default_option = _configuration.getDefaultDisplayClicktoOption();
1895 int selected_index = 0;
1897 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1898 _show_data_item = cb_index;
1899 addClickToOption( Configuration.display_node_data,
1900 _configuration.getClickToTitle( Configuration.display_node_data ) );
1901 if ( default_option == Configuration.display_node_data ) {
1902 selected_index = cb_index;
1906 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1907 _collapse_cb_item = cb_index;
1908 addClickToOption( Configuration.collapse_uncollapse,
1909 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
1910 if ( default_option == Configuration.collapse_uncollapse ) {
1911 selected_index = cb_index;
1915 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1916 _reroot_cb_item = cb_index;
1917 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1918 if ( default_option == Configuration.reroot ) {
1919 selected_index = cb_index;
1923 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1924 _subtree_cb_item = cb_index;
1925 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1926 if ( default_option == Configuration.subtree ) {
1927 selected_index = cb_index;
1931 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1932 _swap_cb_item = cb_index;
1933 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1934 if ( default_option == Configuration.swap ) {
1935 selected_index = cb_index;
1939 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
1940 _sort_descendents_item = cb_index;
1941 addClickToOption( Configuration.sort_descendents,
1942 _configuration.getClickToTitle( Configuration.sort_descendents ) );
1943 if ( default_option == Configuration.sort_descendents ) {
1944 selected_index = cb_index;
1948 if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) {
1949 _color_node_font_item = cb_index;
1950 addClickToOption( Configuration.color_node_font,
1951 _configuration.getClickToTitle( Configuration.color_node_font ) );
1952 if ( default_option == Configuration.color_node_font ) {
1953 selected_index = cb_index;
1957 if ( _configuration.doDisplayClickToOption( Configuration.change_node_font ) ) {
1958 _change_node_font_item = cb_index;
1959 addClickToOption( Configuration.change_node_font,
1960 _configuration.getClickToTitle( Configuration.change_node_font ) );
1961 if ( default_option == Configuration.change_node_font ) {
1962 selected_index = cb_index;
1966 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1967 _color_subtree_cb_item = cb_index;
1968 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1969 if ( default_option == Configuration.color_subtree ) {
1970 selected_index = cb_index;
1974 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1975 _open_seq_web_item = cb_index;
1976 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1977 if ( default_option == Configuration.open_seq_web ) {
1978 selected_index = cb_index;
1982 if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
1983 _open_pdb_item = cb_index;
1984 addClickToOption( Configuration.open_pdb_web, _configuration.getClickToTitle( Configuration.open_pdb_web ) );
1985 if ( default_option == Configuration.open_pdb_web ) {
1986 selected_index = cb_index;
1990 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1991 _open_tax_web_item = cb_index;
1992 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1993 if ( default_option == Configuration.open_tax_web ) {
1994 selected_index = cb_index;
1998 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1999 _blast_item = cb_index;
2000 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
2001 if ( default_option == Configuration.blast ) {
2002 selected_index = cb_index;
2006 if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
2007 _select_nodes_item = cb_index;
2008 addClickToOption( Configuration.select_nodes, _configuration.getClickToTitle( Configuration.select_nodes ) );
2009 if ( default_option == Configuration.select_nodes ) {
2010 selected_index = cb_index;
2014 if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
2015 _get_ext_desc_data = cb_index;
2016 if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
2017 addClickToOption( Configuration.get_ext_desc_data, getConfiguration()
2018 .getLabelForGetExtDescendentsData() );
2022 switch ( getConfiguration().getExtDescNodeDataToReturn() ) {
2027 s = "Sequence Accessors";
2029 case SEQUENCE_MOL_SEQ:
2030 s = "Molecular Sequence";
2032 case SEQUENCE_MOL_SEQ_FASTA:
2033 s = "Molecular Sequence (Fasta)";
2036 s = "Sequence Names";
2041 case SEQUENCE_SYMBOL:
2042 s = "Sequence Symbols";
2045 s = "Taxonomy Codes";
2047 case TAXONOMY_COMM0N_NAME:
2048 s = "Taxonomy Common Names";
2050 case TAXONOMY_SCIENTIFIC_NAME:
2051 s = "Scientific Names";
2054 s = "User Selected Data";
2057 throw new IllegalStateException( "dont know how to deal with " + getConfiguration().getExtDescNodeDataToReturn() );
2060 final String label = _configuration.getClickToTitle( Configuration.get_ext_desc_data ) + " " + s;
2061 addClickToOption( Configuration.get_ext_desc_data, label );
2063 if ( default_option == Configuration.get_ext_desc_data ) {
2064 selected_index = cb_index;
2068 if ( getOptions().isEditable() ) {
2069 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
2070 _cut_subtree_item = cb_index;
2071 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
2072 if ( default_option == Configuration.cut_subtree ) {
2073 selected_index = cb_index;
2077 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
2078 _copy_subtree_item = cb_index;
2079 addClickToOption( Configuration.copy_subtree,
2080 _configuration.getClickToTitle( Configuration.copy_subtree ) );
2081 if ( default_option == Configuration.copy_subtree ) {
2082 selected_index = cb_index;
2086 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
2087 _paste_subtree_item = cb_index;
2088 addClickToOption( Configuration.paste_subtree,
2089 _configuration.getClickToTitle( Configuration.paste_subtree ) );
2090 if ( default_option == Configuration.paste_subtree ) {
2091 selected_index = cb_index;
2095 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
2096 _delete_node_or_subtree_item = cb_index;
2097 addClickToOption( Configuration.delete_subtree_or_node,
2098 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
2099 if ( default_option == Configuration.delete_subtree_or_node ) {
2100 selected_index = cb_index;
2104 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
2105 _add_new_node_item = cb_index;
2106 addClickToOption( Configuration.add_new_node,
2107 _configuration.getClickToTitle( Configuration.add_new_node ) );
2108 if ( default_option == Configuration.add_new_node ) {
2109 selected_index = cb_index;
2113 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
2114 _edit_node_data_item = cb_index;
2115 addClickToOption( Configuration.edit_node_data,
2116 _configuration.getClickToTitle( Configuration.edit_node_data ) );
2117 if ( default_option == Configuration.edit_node_data ) {
2118 selected_index = cb_index;
2123 // Set default selection and its action
2124 _click_to_combobox.setSelectedIndex( selected_index );
2125 setClickToAction( selected_index );
2128 private void setupDisplayCheckboxes() {
2129 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
2130 addCheckbox( Configuration.display_as_phylogram,
2131 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
2132 setCheckbox( Configuration.display_as_phylogram,
2133 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
2135 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
2136 addCheckbox( Configuration.dynamically_hide_data,
2137 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
2138 setCheckbox( Configuration.dynamically_hide_data,
2139 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
2141 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
2142 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
2143 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
2145 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
2146 addCheckbox( Configuration.display_internal_data,
2147 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
2148 setCheckbox( Configuration.display_internal_data,
2149 _configuration.doCheckOption( Configuration.display_internal_data ) );
2153 if ( _configuration.doDisplayOption( Configuration.color_according_to_sequence ) ) {
2154 addCheckbox( Configuration.color_according_to_sequence,
2155 _configuration.getDisplayTitle( Configuration.color_according_to_sequence ) );
2156 setCheckbox( Configuration.color_according_to_sequence,
2157 _configuration.doCheckOption( Configuration.color_according_to_sequence ) );
2163 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
2164 addCheckbox( Configuration.color_according_to_species,
2165 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
2166 setCheckbox( Configuration.color_according_to_species,
2167 _configuration.doCheckOption( Configuration.color_according_to_species ) );
2169 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
2170 addCheckbox( Configuration.color_according_to_annotation,
2171 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
2172 setCheckbox( Configuration.color_according_to_annotation,
2173 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
2175 if ( _configuration.doDisplayOption( Configuration.use_style ) ) {
2176 addCheckbox( Configuration.use_style, _configuration.getDisplayTitle( Configuration.use_style ) );
2177 setCheckbox( Configuration.use_style, _configuration.doCheckOption( Configuration.use_style ) );
2179 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
2180 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
2181 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
2183 final JLabel label = new JLabel( "Display Data:" );
2184 label.setFont( ControlPanel.jcb_bold_font );
2185 if ( !getConfiguration().isUseNativeUI() ) {
2186 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2189 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
2190 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
2191 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
2193 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
2194 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
2195 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
2197 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
2198 addCheckbox( Configuration.show_taxonomy_scientific_names,
2199 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
2200 setCheckbox( Configuration.show_taxonomy_scientific_names,
2201 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
2203 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
2204 addCheckbox( Configuration.show_taxonomy_common_names,
2205 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
2206 setCheckbox( Configuration.show_taxonomy_common_names,
2207 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
2209 if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
2210 addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
2211 setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
2213 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
2214 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
2215 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
2217 if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
2218 addCheckbox( Configuration.show_seq_symbols,
2219 _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
2220 setCheckbox( Configuration.show_seq_symbols, _configuration.doCheckOption( Configuration.show_seq_symbols ) );
2222 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
2223 addCheckbox( Configuration.show_sequence_acc,
2224 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
2225 setCheckbox( Configuration.show_sequence_acc,
2226 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
2228 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
2229 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
2230 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
2232 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
2233 addCheckbox( Configuration.show_binary_characters,
2234 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
2235 setCheckbox( Configuration.show_binary_characters,
2236 _configuration.doCheckOption( Configuration.show_binary_characters ) );
2238 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
2239 addCheckbox( Configuration.show_binary_character_counts,
2240 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
2241 setCheckbox( Configuration.show_binary_character_counts,
2242 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
2244 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
2245 addCheckbox( Configuration.show_domain_architectures,
2246 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
2247 setCheckbox( Configuration.show_domain_architectures,
2248 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
2250 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
2251 addCheckbox( Configuration.write_confidence_values,
2252 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
2253 setCheckbox( Configuration.write_confidence_values,
2254 _configuration.doCheckOption( Configuration.write_confidence_values ) );
2256 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
2257 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
2258 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
2260 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
2261 addCheckbox( Configuration.show_vector_data,
2262 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
2263 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
2265 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
2266 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
2267 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
2269 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
2270 addCheckbox( Configuration.show_taxonomy_images,
2271 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
2272 setCheckbox( Configuration.show_taxonomy_images,
2273 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
2277 private void setVisibilityOfDomainStrucureControls() {
2278 if ( _zoom_in_domain_structure != null ) {
2279 if ( isShowDomainArchitectures() ) {
2280 _domain_display_label.setVisible( true );
2281 _zoom_in_domain_structure.setVisible( true );
2282 _zoom_out_domain_structure.setVisible( true );
2283 _decr_domain_structure_evalue_thr.setVisible( true );
2284 _incr_domain_structure_evalue_thr.setVisible( true );
2285 _domain_structure_evalue_thr_tf.setVisible( true );
2288 _domain_display_label.setVisible( false );
2289 _zoom_in_domain_structure.setVisible( false );
2290 _zoom_out_domain_structure.setVisible( false );
2291 _decr_domain_structure_evalue_thr.setVisible( false );
2292 _incr_domain_structure_evalue_thr.setVisible( false );
2293 _domain_structure_evalue_thr_tf.setVisible( false );
2298 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2299 label.setFont( ControlPanel.jcb_bold_font );
2300 if ( !configuration.isUseNativeUI() ) {
2301 label.setForeground( configuration.getGuiCheckboxTextColor() );
2302 label.setBackground( configuration.getGuiBackgroundColor() );
2307 enum NodeClickAction {
2314 DELETE_NODE_OR_SUBTREE,