2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 // Contact: phylosoft @ gmail . com
23 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
25 package org.forester.archaeopteryx;
27 import java.awt.BorderLayout;
28 import java.awt.Color;
29 import java.awt.Component;
30 import java.awt.Dimension;
32 import java.awt.GridBagLayout;
33 import java.awt.GridLayout;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.ActionListener;
36 import java.awt.event.ItemEvent;
37 import java.awt.event.ItemListener;
38 import java.awt.event.KeyAdapter;
39 import java.awt.event.KeyEvent;
40 import java.util.ArrayList;
41 import java.util.Arrays;
42 import java.util.Collection;
43 import java.util.HashMap;
44 import java.util.HashSet;
45 import java.util.List;
48 import javax.swing.BorderFactory;
49 import javax.swing.DefaultListCellRenderer;
50 import javax.swing.JButton;
51 import javax.swing.JCheckBox;
52 import javax.swing.JComboBox;
53 import javax.swing.JLabel;
54 import javax.swing.JList;
55 import javax.swing.JPanel;
56 import javax.swing.JScrollBar;
57 import javax.swing.JTextField;
58 import javax.swing.ListCellRenderer;
60 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
61 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
62 import org.forester.phylogeny.Phylogeny;
63 import org.forester.phylogeny.PhylogenyMethods;
64 import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
65 import org.forester.phylogeny.PhylogenyNode;
66 import org.forester.phylogeny.data.Sequence;
67 import org.forester.phylogeny.data.SequenceRelation;
68 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
69 import org.forester.util.ForesterUtil;
71 final class ControlPanel extends JPanel implements ActionListener {
73 final static Font jcb_bold_font = new Font( Configuration.getDefaultFontFamilyName(),
76 final static Font jcb_font = new Font( Configuration.getDefaultFontFamilyName(),
79 final static Font js_font = new Font( Configuration.getDefaultFontFamilyName(),
82 private static final String RETURN_TO_SUPER_TREE_TEXT = "Back to Super Tree";
83 private static final long serialVersionUID = -8463483932821545633L;
84 private NodeClickAction _action_when_node_clicked;
85 private int _add_new_node_item;
86 private Map<Integer, String> _all_click_to_names;
87 private Map<String, Color> _annotation_colors;
88 private int _blast_item;
89 private JComboBox _click_to_combobox;
90 private JLabel _click_to_label;
91 private List<String> _click_to_names;
92 private int _collapse_cb_item;
93 private JCheckBox _color_acc_species;
94 private JCheckBox _color_according_to_annotation;
95 private boolean _color_branches;
96 private JCheckBox _color_branches_cb;
97 private int _color_subtree_cb_item;
98 // The settings from the conf file
99 private final Configuration _configuration;
100 private int _copy_subtree_item;
101 private int _cut_subtree_item;
102 private JButton _decr_domain_structure_evalue_thr;
103 private int _delete_node_or_subtree_item;
104 private JCheckBox _display_as_phylogram_cb;
106 private JCheckBox _display_internal_data;
107 private JLabel _domain_display_label;
108 private JTextField _domain_structure_evalue_thr_tf;
109 private List<Boolean> _draw_phylogram;
110 private JCheckBox _dynamically_hide_data;
111 private int _edit_node_data_item;
112 private int _get_ext_desc_data;
113 private JButton _incr_domain_structure_evalue_thr;
114 private final MainPanel _mainpanel;
115 private JCheckBox _node_desc_popup_cb;
116 private int _open_pdb_item;
117 private int _open_seq_web_item;
118 private int _open_tax_web_item;
119 private int _color_node_font_item;
120 private JButton _order;
121 private boolean _order_of_appearance;
122 private int _paste_subtree_item;
123 private int _reroot_cb_item;
124 private JButton _return_to_super_tree;
126 private JLabel _search_found_label_0;
127 private JLabel _search_found_label_1;
128 private JButton _search_reset_button_0;
129 private JButton _search_reset_button_1;
130 private JTextField _search_tf_0;
131 private JTextField _search_tf_1;
132 private int _select_nodes_item;
133 private Sequence _selected_query_seq;
134 private JCheckBox _seq_relation_confidence_switch;
135 private JComboBox _sequence_relation_type_box;
136 private JCheckBox _show_annotation;
137 private JCheckBox _show_binary_character_counts;
138 private JCheckBox _show_binary_characters;
139 // Indices for the click-to options in the combo box
140 private int _show_data_item;
141 private JCheckBox _show_domain_architectures;
142 private JCheckBox _show_events;
143 private JCheckBox _show_gene_names;
144 private JCheckBox _show_node_names;
145 private JCheckBox _show_properties_cb;
146 private JCheckBox _show_seq_names;
147 private JCheckBox _show_seq_symbols;
148 private JCheckBox _show_sequence_acc;
149 private JComboBox _show_sequence_relations;
150 private JCheckBox _show_taxo_code;
151 private JCheckBox _show_taxo_common_names;
152 private JCheckBox _show_taxo_images_cb;
153 private JCheckBox _show_taxo_scientific_names;
154 private JCheckBox _show_vector_data_cb;
155 private JButton _show_whole;
156 private int _sort_descendents_item;
157 private Map<String, Color> _species_colors;
158 private int _subtree_cb_item;
159 private int _swap_cb_item;
160 private JButton _uncollapse_all;
161 private JCheckBox _width_branches;
162 private JCheckBox _write_confidence;
163 private JButton _zoom_in_domain_structure;
164 // zooming and quick tree manipulation buttons:
165 private JButton _zoom_in_x;
166 private JButton _zoom_in_y;
167 private JLabel _zoom_label;
168 private JButton _zoom_out_domain_structure;
169 private JButton _zoom_out_x;
170 private JButton _zoom_out_y;
172 ControlPanel( final MainPanel ap, final Configuration configuration ) {
175 _configuration = configuration;
176 if ( !_configuration.isUseNativeUI() ) {
177 setBackground( getConfiguration().getGuiBackgroundColor() );
178 setBorder( BorderFactory.createRaisedBevelBorder() );
180 setLayout( new GridLayout( 0, 1, 2, 2 ) );
181 _order_of_appearance = true;
189 public void actionPerformed( final ActionEvent e ) {
191 final TreePanel tp = getMainPanel().getCurrentTreePanel();
195 if ( e.getSource() == _click_to_combobox ) {
196 setClickToAction( _click_to_combobox.getSelectedIndex() );
197 getCurrentTreePanel().repaint();
199 else if ( e.getSource() == _show_binary_characters ) {
200 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
201 _show_binary_character_counts.setSelected( false );
203 displayedPhylogenyMightHaveChanged( true );
205 else if ( e.getSource() == _show_binary_character_counts ) {
206 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
207 _show_binary_characters.setSelected( false );
209 displayedPhylogenyMightHaveChanged( true );
211 else if ( e.getSource() == _show_domain_architectures ) {
214 displayedPhylogenyMightHaveChanged( true );
216 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
217 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
218 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
222 else if ( e.getSource() == _zoom_in_x ) {
223 zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
224 displayedPhylogenyMightHaveChanged( false );
226 else if ( e.getSource() == _zoom_in_y ) {
227 zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR );
228 displayedPhylogenyMightHaveChanged( false );
230 else if ( e.getSource() == _zoom_out_x ) {
231 zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
232 displayedPhylogenyMightHaveChanged( false );
234 else if ( e.getSource() == _zoom_out_y ) {
235 zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR );
236 displayedPhylogenyMightHaveChanged( false );
238 else if ( e.getSource() == _show_whole ) {
241 else if ( e.getSource() == _return_to_super_tree ) {
242 _mainpanel.getCurrentTreePanel().superTree();
245 else if ( e.getSource() == _order ) {
246 DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
247 if ( ( !isShowTaxonomyScientificNames() && !isShowTaxonomyCode() && !isShowTaxonomyCommonNames() ) ) {
248 if ( ( isShowSequenceAcc() || isShowSeqNames() || isShowSeqSymbols() ) ) {
249 pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
251 else if ( isShowNodeNames() ) {
252 pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
255 PhylogenyMethods.orderAppearance( tp.getPhylogeny().getRoot(), _order_of_appearance, true, pri );
256 _order_of_appearance = !_order_of_appearance;
257 tp.setNodeInPreorderToNull();
258 tp.getPhylogeny().externalNodesHaveChanged();
259 tp.getPhylogeny().clearHashIdToNodeMap();
260 tp.getPhylogeny().recalculateNumberOfExternalDescendants( true );
261 tp.resetNodeIdToDistToLeafMap();
262 tp.setEdited( true );
263 displayedPhylogenyMightHaveChanged( false );
265 else if ( e.getSource() == _uncollapse_all ) {
267 displayedPhylogenyMightHaveChanged( false );
269 else if ( e.getSource() == _zoom_in_domain_structure ) {
270 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
271 displayedPhylogenyMightHaveChanged( true );
273 else if ( e.getSource() == _zoom_out_domain_structure ) {
274 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
275 displayedPhylogenyMightHaveChanged( true );
277 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
278 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThreshold();
279 displayedPhylogenyMightHaveChanged( true );
281 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
282 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThreshold();
283 displayedPhylogenyMightHaveChanged( true );
285 else if ( e.getSource() == _search_tf_0 ) {
287 displayedPhylogenyMightHaveChanged( true );
289 else if ( e.getSource() == _search_tf_1 ) {
291 displayedPhylogenyMightHaveChanged( true );
294 displayedPhylogenyMightHaveChanged( true );
298 tp.requestFocusInWindow();
301 catch ( final Exception ex ) {
302 AptxUtil.unexpectedException( ex );
304 catch ( final Error err ) {
305 AptxUtil.unexpectedError( err );
309 public JCheckBox getColorAccSpeciesCb() {
310 return _color_acc_species;
313 public JCheckBox getColorBranchesCb() {
314 return _color_branches_cb;
317 public JCheckBox getDisplayAsPhylogramCb() {
318 return _display_as_phylogram_cb;
321 public JCheckBox getDynamicallyHideData() {
322 return _dynamically_hide_data;
325 public JCheckBox getNodeDescPopupCb() {
326 return _node_desc_popup_cb;
329 public Sequence getSelectedQuerySequence() {
330 return _selected_query_seq;
333 public JComboBox getSequenceRelationBox() {
334 if ( _show_sequence_relations == null ) {
335 _show_sequence_relations = new JComboBox();
336 _show_sequence_relations.setFocusable( false );
337 _show_sequence_relations.setMaximumRowCount( 20 );
338 _show_sequence_relations.setFont( ControlPanel.js_font );
339 if ( !_configuration.isUseNativeUI() ) {
340 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
341 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
343 _show_sequence_relations.addItem( "-----" );
344 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
346 return _show_sequence_relations;
350 public JComboBox getSequenceRelationTypeBox() {
351 if ( _sequence_relation_type_box == null ) {
352 _sequence_relation_type_box = new JComboBox();
353 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
354 _sequence_relation_type_box.addItem( type );
356 _sequence_relation_type_box.addActionListener( new ActionListener() {
359 public void actionPerformed( final ActionEvent e ) {
360 if ( _mainpanel.getCurrentPhylogeny() != null ) {
361 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
366 return _sequence_relation_type_box;
369 public JCheckBox getShowEventsCb() {
373 public JCheckBox getWriteConfidenceCb() {
374 return _write_confidence;
377 public boolean isShowProperties() {
378 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
381 public boolean isShowTaxonomyImages() {
382 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
385 public boolean isShowVectorData() {
386 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
389 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
390 final JComboBox box = getSequenceRelationBox();
391 while ( box.getItemCount() > 1 ) {
392 box.removeItemAt( 1 );
394 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
395 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
397 if ( relationType == null ) {
400 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
401 for( final Sequence seq : sequenceRelationQueries ) {
402 if ( seq.hasSequenceRelations() ) {
403 boolean fFoundForCurrentType = false;
404 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
405 if ( sq.getType().equals( relationType ) ) {
406 fFoundForCurrentType = true;
410 if ( fFoundForCurrentType ) {
411 sequenceNamesToAdd.add( seq.getName() );
412 sequencesByName.put( seq.getName(), seq );
416 // sort sequences by name before adding them to the combo
417 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
418 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
419 for( final String seqName : sequenceNameArray ) {
420 box.addItem( seqName );
422 for( final ItemListener oldItemListener : box.getItemListeners() ) {
423 box.removeItemListener( oldItemListener );
425 box.addItemListener( new ItemListener() {
428 public void itemStateChanged( final ItemEvent e ) {
429 _selected_query_seq = sequencesByName.get( e.getItem() );
430 _mainpanel.getCurrentTreePanel().repaint();
435 void activateButtonToReturnToSuperTree( int index ) {
438 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
441 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
443 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
444 _return_to_super_tree.setEnabled( true );
448 * Add zoom and quick edit buttons. (Last modified 8/9/04)
451 final JLabel spacer = new JLabel( "" );
452 spacer.setOpaque( false );
454 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
455 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
456 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
457 if ( !getConfiguration().isUseNativeUI() ) {
458 x_panel.setBackground( getBackground() );
459 y_panel.setBackground( getBackground() );
460 z_panel.setBackground( getBackground() );
462 add( _zoom_label = new JLabel( "Zoom:" ) );
463 customizeLabel( _zoom_label, getConfiguration() );
467 if ( getConfiguration().isUseNativeUI() ) {
468 _zoom_in_x = new JButton( "+" );
469 _zoom_out_x = new JButton( "-" );
472 _zoom_in_x = new JButton( "X+" );
473 _zoom_out_x = new JButton( "X-" );
475 _zoom_in_y = new JButton( "Y+" );
476 _zoom_out_y = new JButton( "Y-" );
477 _show_whole = new JButton( "F" );
478 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [F or Home]" );
479 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+cursor-right]" );
480 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+cursor-up]" );
481 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+cursor-left]" );
482 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+cursor-down]" );
483 if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) {
484 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
485 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
488 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
489 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
491 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
492 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
493 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
494 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
495 _return_to_super_tree.setEnabled( false );
496 _order = new JButton( "Order Subtrees" );
497 _uncollapse_all = new JButton( "Uncollapse All" );
498 addJButton( _zoom_in_y, x_panel );
499 addJButton( _zoom_out_x, y_panel );
500 addJButton( _show_whole, y_panel );
501 addJButton( _zoom_in_x, y_panel );
502 addJButton( _zoom_out_y, z_panel );
503 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
504 setUpControlsForDomainStrucures();
506 final JLabel spacer2 = new JLabel( "" );
508 addJButton( _return_to_super_tree, this );
509 addJButton( _order, this );
510 addJButton( _uncollapse_all, this );
511 final JLabel spacer3 = new JLabel( "" );
513 setVisibilityOfDomainStrucureControls();
516 void addCheckbox( final int which, final String title ) {
517 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
519 case Configuration.display_as_phylogram:
520 _display_as_phylogram_cb = new JCheckBox( title );
521 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
522 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
525 case Configuration.display_internal_data:
526 _display_internal_data = new JCheckBox( title );
527 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
528 addJCheckBox( _display_internal_data, ch_panel );
531 case Configuration.color_according_to_species:
532 _color_acc_species = new JCheckBox( title );
534 .setToolTipText( "To colorize taxonomy and sequence labels as a function of taxonomy" );
535 addJCheckBox( _color_acc_species, ch_panel );
538 case Configuration.color_according_to_annotation:
539 _color_according_to_annotation = new JCheckBox( title );
540 _color_according_to_annotation
541 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
542 addJCheckBox( _color_according_to_annotation, ch_panel );
545 case Configuration.show_node_names:
546 _show_node_names = new JCheckBox( title );
547 addJCheckBox( _show_node_names, ch_panel );
550 case Configuration.show_taxonomy_scientific_names:
551 _show_taxo_scientific_names = new JCheckBox( title );
552 addJCheckBox( _show_taxo_scientific_names, ch_panel );
555 case Configuration.show_taxonomy_common_names:
556 _show_taxo_common_names = new JCheckBox( title );
557 addJCheckBox( _show_taxo_common_names, ch_panel );
560 case Configuration.show_tax_code:
561 _show_taxo_code = new JCheckBox( title );
562 addJCheckBox( _show_taxo_code, ch_panel );
565 case Configuration.show_taxonomy_images:
566 _show_taxo_images_cb = new JCheckBox( title );
567 addJCheckBox( _show_taxo_images_cb, ch_panel );
570 case Configuration.show_binary_characters:
571 _show_binary_characters = new JCheckBox( title );
572 addJCheckBox( _show_binary_characters, ch_panel );
575 case Configuration.show_annotation:
576 _show_annotation = new JCheckBox( title );
577 addJCheckBox( _show_annotation, ch_panel );
580 case Configuration.show_binary_character_counts:
581 _show_binary_character_counts = new JCheckBox( title );
582 addJCheckBox( _show_binary_character_counts, ch_panel );
585 case Configuration.write_confidence_values:
586 _write_confidence = new JCheckBox( title );
587 addJCheckBox( getWriteConfidenceCb(), ch_panel );
590 case Configuration.write_events:
591 _show_events = new JCheckBox( title );
592 addJCheckBox( getShowEventsCb(), ch_panel );
595 case Configuration.color_branches:
596 _color_branches_cb = new JCheckBox( title );
597 getColorBranchesCb().setToolTipText( "To use branch color values, if present" );
598 addJCheckBox( getColorBranchesCb(), ch_panel );
601 case Configuration.width_branches:
602 _width_branches = new JCheckBox( title );
603 _width_branches.setToolTipText( "To use branch width values, if present" );
604 addJCheckBox( _width_branches, ch_panel );
607 case Configuration.show_domain_architectures:
608 _show_domain_architectures = new JCheckBox( title );
609 addJCheckBox( _show_domain_architectures, ch_panel );
612 case Configuration.show_seq_names:
613 _show_seq_names = new JCheckBox( title );
614 addJCheckBox( _show_seq_names, ch_panel );
617 case Configuration.show_gene_names:
618 _show_gene_names = new JCheckBox( title );
619 addJCheckBox( _show_gene_names, ch_panel );
622 case Configuration.show_seq_symbols:
623 _show_seq_symbols = new JCheckBox( title );
624 addJCheckBox( _show_seq_symbols, ch_panel );
627 case Configuration.show_sequence_acc:
628 _show_sequence_acc = new JCheckBox( title );
629 addJCheckBox( _show_sequence_acc, ch_panel );
632 case Configuration.dynamically_hide_data:
633 _dynamically_hide_data = new JCheckBox( title );
634 getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" );
635 addJCheckBox( getDynamicallyHideData(), ch_panel );
638 case Configuration.node_data_popup:
639 _node_desc_popup_cb = new JCheckBox( title );
640 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
641 addJCheckBox( getNodeDescPopupCb(), ch_panel );
644 case Configuration.show_relation_confidence:
645 _seq_relation_confidence_switch = new JCheckBox( title );
646 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
649 case Configuration.show_vector_data:
650 _show_vector_data_cb = new JCheckBox( title );
651 addJCheckBox( _show_vector_data_cb, ch_panel );
654 case Configuration.show_properties:
655 _show_properties_cb = new JCheckBox( title );
656 addJCheckBox( _show_properties_cb, ch_panel );
660 throw new RuntimeException( "unknown checkbox: " + which );
664 void addJButton( final JButton jb, final JPanel p ) {
665 jb.setFocusPainted( false );
666 jb.setFont( ControlPanel.jcb_font );
667 if ( !_configuration.isUseNativeUI() ) {
668 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
669 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
670 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
673 jb.addActionListener( this );
676 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
677 jcb.setFocusPainted( false );
678 jcb.setFont( ControlPanel.jcb_font );
679 if ( !_configuration.isUseNativeUI() ) {
680 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
681 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
683 p.add( jcb, "Center" );
684 jcb.addActionListener( this );
687 void addJTextField( final JTextField tf, final JPanel p ) {
688 if ( !_configuration.isUseNativeUI() ) {
689 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
690 tf.setFont( ControlPanel.jcb_font );
693 tf.addActionListener( this );
696 void deactivateButtonToReturnToSuperTree() {
697 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
698 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
699 _return_to_super_tree.setEnabled( false );
702 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
703 if ( ( _mainpanel != null )
704 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
705 if ( getOptions().isShowOverview() ) {
706 _mainpanel.getCurrentTreePanel().updateOvSizes();
708 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
709 setVisibilityOfDomainStrucureControls();
710 updateDomainStructureEvaluethresholdDisplay();
711 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
712 _mainpanel.getCurrentTreePanel().calcMaxDepth();
713 _mainpanel.adjustJScrollPane();
714 if ( recalc_longest_ext_node_info ) {
715 _mainpanel.getCurrentTreePanel().initNodeData();
716 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
718 _mainpanel.getCurrentTreePanel().repaint();
719 // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
723 void endClickToOptions() {
724 _click_to_combobox.addActionListener( this );
728 * Indicates what action should be execute when a node is clicked
730 * @return the click-on action
732 NodeClickAction getActionWhenNodeClicked() {
733 return _action_when_node_clicked;
736 Map<Integer, String> getAllClickToItems() {
737 return _all_click_to_names;
740 Map<String, Color> getAnnotationColors() {
741 return _annotation_colors;
744 Configuration getConfiguration() {
745 return _configuration;
748 TreePanel getCurrentTreePanel() {
749 return getMainPanel().getCurrentTreePanel();
752 MainPanel getMainPanel() {
756 Options getOptions() {
757 return getMainPanel().getOptions();
760 JLabel getSearchFoundCountsLabel0() {
761 return _search_found_label_0;
764 JLabel getSearchFoundCountsLabel1() {
765 return _search_found_label_1;
768 JButton getSearchResetButton0() {
769 return _search_reset_button_0;
772 JButton getSearchResetButton1() {
773 return _search_reset_button_1;
776 JTextField getSearchTextField0() {
780 JTextField getSearchTextField1() {
784 List<String> getSingleClickToNames() {
785 return _click_to_names;
788 Map<String, Color> getSpeciesColors() {
789 return _species_colors;
792 boolean isAntialiasScreenText() {
796 boolean isColorAccordingToAnnotation() {
797 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
800 boolean isColorAccordingToTaxonomy() {
801 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
804 boolean isColorBranches() {
805 return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) );
808 boolean isDrawPhylogram() {
809 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
812 boolean isDynamicallyHideData() {
813 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
817 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
820 boolean isNodeDescPopup() {
821 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
824 boolean isShowAnnotation() {
825 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
828 boolean isShowBinaryCharacterCounts() {
829 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
832 boolean isShowBinaryCharacters() {
833 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
836 boolean isShowConfidenceValues() {
837 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
840 boolean isShowDomainArchitectures() {
841 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
844 boolean isShowGeneNames() {
845 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
848 boolean isShowInternalData() {
849 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
852 boolean isShowNodeNames() {
853 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
856 boolean isShowSeqNames() {
857 return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
860 boolean isShowSeqSymbols() {
861 return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
864 boolean isShowSequenceAcc() {
865 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
868 boolean isShowSequenceRelationConfidence() {
869 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
872 boolean isShowSequenceRelations() {
873 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
876 boolean isShowTaxonomyCode() {
877 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
880 boolean isShowTaxonomyCommonNames() {
881 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
884 boolean isShowTaxonomyScientificNames() {
885 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
888 boolean isWidthBranches() {
889 return ( ( _width_branches != null ) && _width_branches.isSelected() );
892 void phylogenyAdded( final Configuration configuration ) {
893 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
896 void phylogenyRemoved( final int index ) {
897 getIsDrawPhylogramList().remove( index );
901 final MainPanel main_panel = getMainPanel();
902 final Phylogeny tree = main_panel.getCurrentPhylogeny();
903 if ( ( tree == null ) || tree.isEmpty() ) {
906 String query = getSearchTextField0().getText();
907 if ( query != null ) {
908 query = query.trim();
910 if ( !ForesterUtil.isEmpty( query ) ) {
911 search0( main_panel, tree, query );
914 getSearchFoundCountsLabel0().setVisible( false );
915 getSearchResetButton0().setEnabled( false );
916 getSearchResetButton0().setVisible( false );
922 final MainPanel main_panel = getMainPanel();
923 final Phylogeny tree = main_panel.getCurrentPhylogeny();
924 if ( ( tree == null ) || tree.isEmpty() ) {
927 String query = getSearchTextField1().getText();
928 if ( query != null ) {
929 query = query.trim();
931 if ( !ForesterUtil.isEmpty( query ) ) {
932 search1( main_panel, tree, query );
935 getSearchFoundCountsLabel1().setVisible( false );
936 getSearchResetButton1().setEnabled( false );
937 getSearchResetButton1().setVisible( false );
942 void searchReset0() {
943 if ( getMainPanel().getCurrentTreePanel() != null ) {
944 getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
948 void searchReset1() {
949 if ( getMainPanel().getCurrentTreePanel() != null ) {
950 getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
954 void setActionWhenNodeClicked( final NodeClickAction action ) {
955 _action_when_node_clicked = action;
958 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
959 _annotation_colors = annotation_colors;
962 void setCheckbox( final int which, final boolean state ) {
964 case Configuration.display_as_phylogram:
965 if ( getDisplayAsPhylogramCb() != null ) {
966 getDisplayAsPhylogramCb().setSelected( state );
969 case Configuration.display_internal_data:
970 if ( _display_internal_data != null ) {
971 _display_internal_data.setSelected( state );
974 case Configuration.color_according_to_species:
975 if ( _color_acc_species != null ) {
976 _color_acc_species.setSelected( state );
979 case Configuration.color_according_to_annotation:
980 if ( _color_according_to_annotation != null ) {
981 _color_according_to_annotation.setSelected( state );
984 case Configuration.show_node_names:
985 if ( _show_node_names != null ) {
986 _show_node_names.setSelected( state );
989 case Configuration.show_taxonomy_scientific_names:
990 if ( _show_taxo_scientific_names != null ) {
991 _show_taxo_scientific_names.setSelected( state );
994 case Configuration.show_taxonomy_common_names:
995 if ( _show_taxo_common_names != null ) {
996 _show_taxo_common_names.setSelected( state );
999 case Configuration.show_tax_code:
1000 if ( _show_taxo_code != null ) {
1001 _show_taxo_code.setSelected( state );
1004 case Configuration.show_taxonomy_images:
1005 if ( _show_taxo_images_cb != null ) {
1006 _show_taxo_images_cb.setSelected( state );
1009 case Configuration.show_annotation:
1010 if ( _show_annotation != null ) {
1011 _show_annotation.setSelected( state );
1014 case Configuration.show_binary_characters:
1015 if ( _show_binary_characters != null ) {
1016 _show_binary_characters.setSelected( state );
1019 case Configuration.show_binary_character_counts:
1020 if ( _show_binary_character_counts != null ) {
1021 _show_binary_character_counts.setSelected( state );
1024 case Configuration.write_confidence_values:
1025 if ( getWriteConfidenceCb() != null ) {
1026 getWriteConfidenceCb().setSelected( state );
1029 case Configuration.write_events:
1030 if ( getShowEventsCb() != null ) {
1031 getShowEventsCb().setSelected( state );
1034 case Configuration.color_branches:
1035 if ( getColorBranchesCb() != null ) {
1036 getColorBranchesCb().setSelected( state );
1039 case Configuration.width_branches:
1040 if ( _width_branches != null ) {
1041 _width_branches.setSelected( state );
1044 case Configuration.show_domain_architectures:
1045 if ( _show_domain_architectures != null ) {
1046 _show_domain_architectures.setSelected( state );
1049 case Configuration.show_seq_names:
1050 if ( _show_seq_names != null ) {
1051 _show_seq_names.setSelected( state );
1054 case Configuration.show_gene_names:
1055 if ( _show_gene_names != null ) {
1056 _show_gene_names.setSelected( state );
1059 case Configuration.show_seq_symbols:
1060 if ( _show_seq_symbols != null ) {
1061 _show_seq_symbols.setSelected( state );
1064 case Configuration.show_vector_data:
1065 if ( _show_vector_data_cb != null ) {
1066 _show_vector_data_cb.setSelected( state );
1069 case Configuration.show_properties:
1070 if ( _show_properties_cb != null ) {
1071 _show_properties_cb.setSelected( state );
1074 case Configuration.show_sequence_acc:
1075 if ( _show_sequence_acc != null ) {
1076 _show_sequence_acc.setSelected( state );
1079 case Configuration.dynamically_hide_data:
1080 if ( getDynamicallyHideData() != null ) {
1081 getDynamicallyHideData().setSelected( state );
1084 case Configuration.node_data_popup:
1085 if ( getNodeDescPopupCb() != null ) {
1086 getNodeDescPopupCb().setSelected( state );
1090 case Configuration.show_relation_confidence:
1091 if ( _seq_relation_confidence_switch != null ) {
1092 _seq_relation_confidence_switch.setSelected( state );
1097 throw new AssertionError( "unknown checkbox: " + which );
1102 * Set this checkbox state. Not all checkboxes have been instantiated
1103 * depending on the config.
1105 void setCheckbox( final JCheckBox cb, final boolean state ) {
1107 cb.setSelected( state );
1111 void setClickToAction( final int action ) {
1112 // Set click-to action
1113 if ( action == _show_data_item ) {
1114 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1116 else if ( action == _collapse_cb_item ) {
1117 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1119 else if ( action == _reroot_cb_item ) {
1120 setActionWhenNodeClicked( NodeClickAction.REROOT );
1122 else if ( action == _subtree_cb_item ) {
1123 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1125 else if ( action == _swap_cb_item ) {
1126 setActionWhenNodeClicked( NodeClickAction.SWAP );
1128 else if ( action == _color_subtree_cb_item ) {
1129 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1131 else if ( action == _open_seq_web_item ) {
1132 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1134 else if ( action == _sort_descendents_item ) {
1135 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1137 else if ( action == _blast_item ) {
1138 setActionWhenNodeClicked( NodeClickAction.BLAST );
1140 else if ( action == _open_tax_web_item ) {
1141 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1143 else if ( action == _cut_subtree_item ) {
1144 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1146 else if ( action == _copy_subtree_item ) {
1147 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1149 else if ( action == _delete_node_or_subtree_item ) {
1150 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1152 else if ( action == _paste_subtree_item ) {
1153 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1155 else if ( action == _add_new_node_item ) {
1156 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1158 else if ( action == _edit_node_data_item ) {
1159 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1161 else if ( action == _select_nodes_item ) {
1162 setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
1164 else if ( action == _get_ext_desc_data ) {
1165 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
1167 else if ( action == _open_pdb_item ) {
1168 setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
1170 else if ( action == _color_node_font_item ) {
1171 setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
1174 throw new RuntimeException( "unknown action: " + action );
1176 // make sure drop down is displaying the correct action
1177 // in case this was called from outside the class
1178 _click_to_combobox.setSelectedIndex( action );
1181 void setColorBranches( final boolean color_branches ) {
1182 _color_branches = color_branches;
1185 void setDrawPhylogram( final boolean b ) {
1186 getDisplayAsPhylogramCb().setSelected( b );
1187 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1190 void setDrawPhylogramEnabled( final boolean b ) {
1191 getDisplayAsPhylogramCb().setEnabled( b );
1194 void setDynamicHidingIsOn( final boolean is_on ) {
1195 // if ( !_configuration.isUseNativeUI() ) {
1197 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1200 if ( !_configuration.isUseNativeUI() ) {
1201 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1204 getDynamicallyHideData().setForeground( Color.BLACK );
1210 void setSearchFoundCountsOnLabel0( final int counts ) {
1211 getSearchFoundCountsLabel0().setText( "Found: " + counts );
1214 void setSearchFoundCountsOnLabel1( final int counts ) {
1215 getSearchFoundCountsLabel1().setText( "Found: " + counts );
1218 void setShowEvents( final boolean show_events ) {
1219 if ( getShowEventsCb() == null ) {
1220 _show_events = new JCheckBox( "" );
1222 getShowEventsCb().setSelected( show_events );
1225 void setSpeciesColors( final Map<String, Color> species_colors ) {
1226 _species_colors = species_colors;
1231 * Set up the controls from the config settings. 11/26/05
1233 void setupControls() {
1234 // The tree display options:
1235 setupDisplayCheckboxes();
1237 // The sequence relation query selection combo-box
1238 if ( _configuration.displaySequenceRelations() ) {
1239 addSequenceRelationBlock();
1243 startClickToOptions();
1244 setupClickToOptions();
1245 endClickToOptions();
1246 // Zoom and quick edit buttons
1248 setupSearchTools0();
1249 setupSearchTools1();
1252 void setUpControlsForDomainStrucures() {
1253 _domain_display_label = new JLabel( "Domain Display:" );
1254 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1255 add( _domain_display_label );
1256 _zoom_in_domain_structure = new JButton( "d+" );
1257 _zoom_out_domain_structure = new JButton( "d-" );
1258 _decr_domain_structure_evalue_thr = new JButton( "-" );
1259 _incr_domain_structure_evalue_thr = new JButton( "+" );
1260 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1261 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1262 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1263 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1264 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1265 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1266 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1267 _domain_structure_evalue_thr_tf.setEditable( false );
1268 if ( !getConfiguration().isUseNativeUI() ) {
1269 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1270 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1271 _domain_structure_evalue_thr_tf.setBorder( null );
1273 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1274 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1275 if ( !_configuration.isUseNativeUI() ) {
1276 d1_panel.setBackground( getBackground() );
1277 d2_panel.setBackground( getBackground() );
1281 addJButton( _zoom_out_domain_structure, d1_panel );
1282 addJButton( _zoom_in_domain_structure, d1_panel );
1283 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1284 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1285 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1288 void setupSearchTools0() {
1289 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1290 final JLabel search_label = new JLabel( "Search (A):" );
1291 search_label.setFont( ControlPanel.jcb_bold_font );
1292 if ( !getConfiguration().isUseNativeUI() ) {
1293 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1295 add( search_label );
1296 search_label.setToolTipText( tip );
1297 _search_found_label_0 = new JLabel();
1298 getSearchFoundCountsLabel0().setVisible( false );
1299 _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
1300 if ( !getConfiguration().isUseNativeUI() ) {
1301 _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1303 _search_tf_0 = new JTextField( 3 );
1304 _search_tf_0.setToolTipText( tip );
1305 _search_tf_0.setEditable( true );
1306 if ( !getConfiguration().isUseNativeUI() ) {
1307 _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1308 _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1309 _search_tf_0.setBorder( null );
1311 _search_reset_button_0 = new JButton();
1312 getSearchResetButton0().setText( "Reset" );
1313 getSearchResetButton0().setEnabled( false );
1314 getSearchResetButton0().setVisible( false );
1315 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1316 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1317 s_panel_1.setBackground( getBackground() );
1319 s_panel_2.setBackground( getBackground() );
1321 final KeyAdapter key_adapter = new KeyAdapter() {
1324 public void keyReleased( final KeyEvent key_event ) {
1326 displayedPhylogenyMightHaveChanged( true );
1329 final ActionListener action_listener = new ActionListener() {
1332 public void actionPerformed( final ActionEvent e ) {
1334 setSearchFoundCountsOnLabel0( 0 );
1335 getSearchFoundCountsLabel0().setVisible( false );
1336 getSearchTextField0().setText( "" );
1337 getSearchResetButton0().setEnabled( false );
1338 getSearchResetButton0().setVisible( false );
1339 displayedPhylogenyMightHaveChanged( true );
1342 _search_reset_button_0.addActionListener( action_listener );
1343 _search_tf_0.addKeyListener( key_adapter );
1344 addJTextField( _search_tf_0, s_panel_1 );
1345 s_panel_2.add( _search_found_label_0 );
1346 addJButton( _search_reset_button_0, s_panel_2 );
1349 void setupSearchTools1() {
1350 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1351 final JLabel search_label = new JLabel( "Search (B):" );
1352 search_label.setFont( ControlPanel.jcb_bold_font );
1353 if ( !getConfiguration().isUseNativeUI() ) {
1354 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1356 add( search_label );
1357 search_label.setToolTipText( tip );
1358 _search_found_label_1 = new JLabel();
1359 getSearchFoundCountsLabel1().setVisible( false );
1360 _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
1361 if ( !getConfiguration().isUseNativeUI() ) {
1362 _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1364 _search_tf_1 = new JTextField( 3 );
1365 _search_tf_1.setToolTipText( tip );
1366 _search_tf_1.setEditable( true );
1367 if ( !getConfiguration().isUseNativeUI() ) {
1368 _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1369 _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1370 _search_tf_1.setBorder( null );
1372 _search_reset_button_1 = new JButton();
1373 getSearchResetButton1().setText( "Reset" );
1374 getSearchResetButton1().setEnabled( false );
1375 getSearchResetButton1().setVisible( false );
1376 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1377 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1378 s_panel_1.setBackground( getBackground() );
1380 s_panel_2.setBackground( getBackground() );
1382 final KeyAdapter key_adapter = new KeyAdapter() {
1385 public void keyReleased( final KeyEvent key_event ) {
1387 displayedPhylogenyMightHaveChanged( true );
1390 final ActionListener action_listener = new ActionListener() {
1393 public void actionPerformed( final ActionEvent e ) {
1395 setSearchFoundCountsOnLabel1( 0 );
1396 getSearchFoundCountsLabel1().setVisible( false );
1397 getSearchTextField1().setText( "" );
1398 getSearchResetButton1().setEnabled( false );
1399 getSearchResetButton1().setVisible( false );
1400 displayedPhylogenyMightHaveChanged( true );
1403 _search_reset_button_1.addActionListener( action_listener );
1404 _search_tf_1.addKeyListener( key_adapter );
1405 addJTextField( _search_tf_1, s_panel_1 );
1406 s_panel_2.add( _search_found_label_1 );
1407 addJButton( _search_reset_button_1, s_panel_2 );
1410 void showAnnotations() {
1411 if ( _show_annotation != null ) {
1412 _show_annotation.setSelected( true );
1414 if ( _color_according_to_annotation != null ) {
1415 _color_according_to_annotation.setSelected( true );
1417 if ( _color_acc_species != null ) {
1418 _color_acc_species.setSelected( false );
1420 _mainpanel.getCurrentTreePanel().repaint();
1424 * Fit entire tree into window.
1427 if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
1430 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
1431 displayedPhylogenyMightHaveChanged( true );
1432 _mainpanel.getCurrentTreePanel().updateOvSettings();
1433 _mainpanel.getCurrentTreePanel().validate();
1434 _mainpanel.validate();
1435 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1436 _mainpanel.getSizeOfViewport().height,
1438 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1439 _mainpanel.adjustJScrollPane();
1440 _mainpanel.getCurrentTreePanel().repaint();
1441 _mainpanel.getCurrentTreePanel().validate();
1442 _mainpanel.validate();
1443 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1444 _mainpanel.getSizeOfViewport().height,
1446 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1447 _mainpanel.adjustJScrollPane();
1448 _mainpanel.getCurrentTreePanel().repaint();
1449 _mainpanel.getCurrentTreePanel().updateOvSizes();
1452 void showWholeAll() {
1453 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1454 if ( tree_panel != null ) {
1455 tree_panel.validate();
1456 tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1457 _mainpanel.getSizeOfViewport().height,
1459 tree_panel.resetPreferredSize();
1460 tree_panel.repaint();
1465 // Create header for click-to combo box.
1466 void startClickToOptions() {
1467 final JLabel spacer = new JLabel( "" );
1468 spacer.setFont( ControlPanel.jcb_font );
1470 _click_to_label = new JLabel( "Click on Node to:" );
1471 add( customizeLabel( _click_to_label, getConfiguration() ) );
1472 _click_to_combobox = new JComboBox();
1473 _click_to_combobox.setFocusable( false );
1474 _click_to_combobox.setMaximumRowCount( 14 );
1475 _click_to_combobox.setFont( ControlPanel.js_font );
1476 if ( !_configuration.isUseNativeUI() ) {
1477 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1479 // don't add listener until all items are set (or each one will trigger
1481 // click_to_list.addActionListener(this);
1482 add( _click_to_combobox );
1483 // Correlates option names to titles
1484 _all_click_to_names = new HashMap<Integer, String>();
1485 _click_to_names = new ArrayList<String>();
1489 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1490 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1491 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1492 setDrawPhylogramEnabled( true );
1493 setDrawPhylogram( isDrawPhylogram() );
1496 setDrawPhylogramEnabled( false );
1497 setDrawPhylogram( false );
1499 if ( getMainPanel().getMainFrame() == null ) {
1500 // Must be "E" applet version.
1501 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1502 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1505 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1506 .getPhylogenyGraphicsType() );
1508 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1509 getMainPanel().getControlPanel().search0();
1510 getMainPanel().getControlPanel().search1();
1511 getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
1512 getSequenceRelationTypeBox().removeAllItems();
1513 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1514 .getRelevantSequenceRelationTypes() ) {
1515 _sequence_relation_type_box.addItem( type );
1517 getMainPanel().getCurrentTreePanel().repaint();
1518 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1519 // according to GUILHEM the line above can be removed.
1524 * Uncollapse all nodes.
1526 void uncollapseAll( final TreePanel tp ) {
1527 final Phylogeny t = tp.getPhylogeny();
1528 if ( ( t != null ) && !t.isEmpty() ) {
1529 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
1530 final PhylogenyNode node = iter.next();
1531 node.setCollapse( false );
1533 tp.resetNodeIdToDistToLeafMap();
1534 tp.updateSetOfCollapsedExternalNodes();
1535 t.recalculateNumberOfExternalDescendants( false );
1536 tp.setNodeInPreorderToNull();
1537 t.clearHashIdToNodeMap();
1542 void updateDomainStructureEvaluethresholdDisplay() {
1543 if ( _domain_structure_evalue_thr_tf != null ) {
1544 _domain_structure_evalue_thr_tf.setText( "10^"
1545 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1549 void zoomInX( final float factor, final float x_correction_factor ) {
1550 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1551 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1552 treepanel.multiplyUrtFactor( 1f );
1553 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1554 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1555 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1556 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1557 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1558 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1559 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1560 getMainPanel().adjustJScrollPane();
1561 treepanel.resetPreferredSize();
1562 getMainPanel().getCurrentScrollPane().getViewport().validate();
1563 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1564 - ( sb.getVisibleAmount() / 2.0 ) ) );
1567 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1568 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1569 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1570 getMainPanel().adjustJScrollPane();
1571 treepanel.resetPreferredSize();
1572 getMainPanel().getCurrentScrollPane().getViewport().validate();
1573 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1575 treepanel.resetPreferredSize();
1576 treepanel.updateOvSizes();
1579 void zoomInY( final float factor ) {
1580 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1581 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1582 treepanel.multiplyUrtFactor( 1.1f );
1583 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1584 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1585 getMainPanel().adjustJScrollPane();
1586 treepanel.resetPreferredSize();
1587 getMainPanel().getCurrentScrollPane().getViewport().validate();
1588 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1589 - ( sb.getVisibleAmount() / 2.0 ) ) );
1590 treepanel.resetPreferredSize();
1591 treepanel.updateOvSizes();
1594 void zoomOutX( final float factor, final float x_correction_factor ) {
1595 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1596 treepanel.multiplyUrtFactor( 1f );
1597 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1598 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1599 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1600 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1601 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1602 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1603 getMainPanel().adjustJScrollPane();
1604 treepanel.resetPreferredSize();
1605 getMainPanel().getCurrentScrollPane().getViewport().validate();
1606 final double x = ( sb.getMaximum() - sb.getMinimum() )
1607 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1608 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1609 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1610 getMainPanel().adjustJScrollPane();
1611 treepanel.resetPreferredSize();
1612 getMainPanel().getCurrentScrollPane().getViewport().validate();
1613 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1614 - ( sb.getVisibleAmount() / 2.0 ) ) );
1617 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1618 treepanel.setXdistance( treepanel.getXdistance() * factor );
1619 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
1621 getMainPanel().adjustJScrollPane();
1622 treepanel.resetPreferredSize();
1623 getMainPanel().getCurrentScrollPane().getViewport().validate();
1624 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1627 treepanel.resetPreferredSize();
1628 treepanel.updateOvSizes();
1632 void zoomOutY( final float factor ) {
1633 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1634 treepanel.multiplyUrtFactor( 0.9f );
1635 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1636 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
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();
1649 private void addClickToOption( final int which, final String title ) {
1650 _click_to_combobox.addItem( title );
1651 _click_to_names.add( title );
1652 _all_click_to_names.put( new Integer( which ), title );
1653 if ( !_configuration.isUseNativeUI() ) {
1654 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1655 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
1660 private void addSequenceRelationBlock() {
1661 final JLabel spacer = new JLabel( "" );
1662 spacer.setSize( 1, 1 );
1664 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
1665 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
1666 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
1667 getSequenceRelationTypeBox().setFocusable( false );
1668 _sequence_relation_type_box.setFont( ControlPanel.js_font );
1669 if ( !_configuration.isUseNativeUI() ) {
1670 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1671 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
1673 _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
1676 public Component getListCellRendererComponent( final JList list,
1679 final boolean isSelected,
1680 final boolean cellHasFocus ) {
1681 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
1686 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
1687 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
1688 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
1693 final GridBagLayout gbl = new GridBagLayout();
1694 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
1695 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
1696 final JPanel horizGrid = new JPanel( gbl );
1697 horizGrid.setBackground( getBackground() );
1698 horizGrid.add( typeLabel );
1699 horizGrid.add( _sequence_relation_type_box );
1700 add( customizeLabel( mainLabel, getConfiguration() ) );
1702 add( getSequenceRelationBox() );
1703 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
1704 addCheckbox( Configuration.show_relation_confidence,
1705 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
1706 setCheckbox( Configuration.show_relation_confidence,
1707 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
1709 }// addSequenceRelationBlock
1712 private List<Boolean> getIsDrawPhylogramList() {
1713 return _draw_phylogram;
1716 private void init() {
1717 _draw_phylogram = new ArrayList<Boolean>();
1718 setSpeciesColors( new HashMap<String, Color>() );
1719 setAnnotationColors( new HashMap<String, Color>() );
1722 private boolean isDrawPhylogram( final int index ) {
1723 return getIsDrawPhylogramList().get( index );
1726 private void search0( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
1727 getSearchFoundCountsLabel0().setVisible( true );
1728 getSearchResetButton0().setEnabled( true );
1729 getSearchResetButton0().setVisible( true );
1730 String[] queries = null;
1731 List<PhylogenyNode> nodes = null;
1732 if ( query_str.indexOf( ',' ) >= 0 ) {
1733 queries = query_str.split( ",+" );
1736 queries = new String[ 1 ];
1737 queries[ 0 ] = query_str.trim();
1739 if ( ( queries != null ) && ( queries.length > 0 ) ) {
1740 nodes = new ArrayList<PhylogenyNode>();
1741 for( String query : queries ) {
1742 if ( ForesterUtil.isEmpty( query ) ) {
1745 query = query.trim();
1746 if ( query.indexOf( '+' ) >= 0 ) {
1747 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
1749 getOptions().isSearchCaseSensitive(),
1750 !getOptions().isMatchWholeTermsOnly(),
1751 isShowDomainArchitectures() ) );
1754 nodes.addAll( PhylogenyMethods.searchData( query,
1756 getOptions().isSearchCaseSensitive(),
1757 !getOptions().isMatchWholeTermsOnly(),
1758 isShowDomainArchitectures() ) );
1761 if ( getOptions().isInverseSearchResult() ) {
1762 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
1763 all.removeAll( nodes );
1767 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
1768 main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet<Long>() );
1769 for( final PhylogenyNode node : nodes ) {
1770 main_panel.getCurrentTreePanel().getFoundNodes0().add( node.getId() );
1772 setSearchFoundCountsOnLabel0( nodes.size() );
1775 setSearchFoundCountsOnLabel0( 0 );
1780 private void search1( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
1781 getSearchFoundCountsLabel1().setVisible( true );
1782 getSearchResetButton1().setEnabled( true );
1783 getSearchResetButton1().setVisible( true );
1784 String[] queries = null;
1785 List<PhylogenyNode> nodes = null;
1786 if ( query_str.indexOf( ',' ) >= 0 ) {
1787 queries = query_str.split( ",+" );
1790 queries = new String[ 1 ];
1791 queries[ 0 ] = query_str.trim();
1793 if ( ( queries != null ) && ( queries.length > 0 ) ) {
1794 nodes = new ArrayList<PhylogenyNode>();
1795 for( String query : queries ) {
1796 if ( ForesterUtil.isEmpty( query ) ) {
1799 query = query.trim();
1800 if ( query.indexOf( '+' ) >= 0 ) {
1801 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
1803 getOptions().isSearchCaseSensitive(),
1804 !getOptions().isMatchWholeTermsOnly(),
1805 isShowDomainArchitectures() ) );
1808 nodes.addAll( PhylogenyMethods.searchData( query,
1810 getOptions().isSearchCaseSensitive(),
1811 !getOptions().isMatchWholeTermsOnly(),
1812 isShowDomainArchitectures() ) );
1815 if ( getOptions().isInverseSearchResult() ) {
1816 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
1817 all.removeAll( nodes );
1821 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
1822 main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet<Long>() );
1823 for( final PhylogenyNode node : nodes ) {
1824 main_panel.getCurrentTreePanel().getFoundNodes1().add( node.getId() );
1826 setSearchFoundCountsOnLabel1( nodes.size() );
1829 setSearchFoundCountsOnLabel1( 0 );
1834 private void setDrawPhylogram( final int index, final boolean b ) {
1835 getIsDrawPhylogramList().set( index, b );
1838 private void setupClickToOptions() {
1839 final int default_option = _configuration.getDefaultDisplayClicktoOption();
1840 int selected_index = 0;
1842 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1843 _show_data_item = cb_index;
1844 addClickToOption( Configuration.display_node_data,
1845 _configuration.getClickToTitle( Configuration.display_node_data ) );
1846 if ( default_option == Configuration.display_node_data ) {
1847 selected_index = cb_index;
1851 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1852 _collapse_cb_item = cb_index;
1853 addClickToOption( Configuration.collapse_uncollapse,
1854 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
1855 if ( default_option == Configuration.collapse_uncollapse ) {
1856 selected_index = cb_index;
1860 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1861 _reroot_cb_item = cb_index;
1862 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1863 if ( default_option == Configuration.reroot ) {
1864 selected_index = cb_index;
1868 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1869 _subtree_cb_item = cb_index;
1870 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1871 if ( default_option == Configuration.subtree ) {
1872 selected_index = cb_index;
1876 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1877 _swap_cb_item = cb_index;
1878 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1879 if ( default_option == Configuration.swap ) {
1880 selected_index = cb_index;
1884 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
1885 _sort_descendents_item = cb_index;
1886 addClickToOption( Configuration.sort_descendents,
1887 _configuration.getClickToTitle( Configuration.sort_descendents ) );
1888 if ( default_option == Configuration.sort_descendents ) {
1889 selected_index = cb_index;
1893 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1894 _color_subtree_cb_item = cb_index;
1895 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1896 if ( default_option == Configuration.color_subtree ) {
1897 selected_index = cb_index;
1901 if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) {
1902 _color_node_font_item = cb_index;
1903 addClickToOption( Configuration.color_node_font,
1904 _configuration.getClickToTitle( Configuration.color_node_font ) );
1905 if ( default_option == Configuration.color_node_font ) {
1906 selected_index = cb_index;
1910 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1911 _open_seq_web_item = cb_index;
1912 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1913 if ( default_option == Configuration.open_seq_web ) {
1914 selected_index = cb_index;
1918 if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
1919 _open_pdb_item = cb_index;
1920 addClickToOption( Configuration.open_pdb_web, _configuration.getClickToTitle( Configuration.open_pdb_web ) );
1921 if ( default_option == Configuration.open_pdb_web ) {
1922 selected_index = cb_index;
1926 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1927 _open_tax_web_item = cb_index;
1928 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1929 if ( default_option == Configuration.open_tax_web ) {
1930 selected_index = cb_index;
1934 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1935 _blast_item = cb_index;
1936 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
1937 if ( default_option == Configuration.blast ) {
1938 selected_index = cb_index;
1942 if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
1943 _select_nodes_item = cb_index;
1944 addClickToOption( Configuration.select_nodes, _configuration.getClickToTitle( Configuration.select_nodes ) );
1945 if ( default_option == Configuration.select_nodes ) {
1946 selected_index = cb_index;
1950 if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
1951 _get_ext_desc_data = cb_index;
1952 if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
1953 addClickToOption( Configuration.get_ext_desc_data, getConfiguration()
1954 .getLabelForGetExtDescendentsData() );
1958 switch ( getConfiguration().getExtDescNodeDataToReturn() ) {
1963 s = "Sequence Accessors";
1965 case SEQUENCE_MOL_SEQ:
1966 s = "Molecular Sequence";
1968 case SEQUENCE_MOL_SEQ_FASTA:
1969 s = "Molecular Sequence (Fasta)";
1972 s = "Sequence Names";
1977 case SEQUENCE_SYMBOL:
1978 s = "Sequence Symbols";
1981 s = "Taxonomy Codes";
1983 case TAXONOMY_COMM0N_NAME:
1984 s = "Taxonomy Common Names";
1986 case TAXONOMY_SCIENTIFIC_NAME:
1987 s = "Scientific Names";
1990 s = "User Selected Data";
1993 final String label = _configuration.getClickToTitle( Configuration.get_ext_desc_data ) + " " + s;
1994 addClickToOption( Configuration.get_ext_desc_data, label );
1996 if ( default_option == Configuration.get_ext_desc_data ) {
1997 selected_index = cb_index;
2001 if ( getOptions().isEditable() ) {
2002 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
2003 _cut_subtree_item = cb_index;
2004 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
2005 if ( default_option == Configuration.cut_subtree ) {
2006 selected_index = cb_index;
2010 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
2011 _copy_subtree_item = cb_index;
2012 addClickToOption( Configuration.copy_subtree,
2013 _configuration.getClickToTitle( Configuration.copy_subtree ) );
2014 if ( default_option == Configuration.copy_subtree ) {
2015 selected_index = cb_index;
2019 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
2020 _paste_subtree_item = cb_index;
2021 addClickToOption( Configuration.paste_subtree,
2022 _configuration.getClickToTitle( Configuration.paste_subtree ) );
2023 if ( default_option == Configuration.paste_subtree ) {
2024 selected_index = cb_index;
2028 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
2029 _delete_node_or_subtree_item = cb_index;
2030 addClickToOption( Configuration.delete_subtree_or_node,
2031 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
2032 if ( default_option == Configuration.delete_subtree_or_node ) {
2033 selected_index = cb_index;
2037 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
2038 _add_new_node_item = cb_index;
2039 addClickToOption( Configuration.add_new_node,
2040 _configuration.getClickToTitle( Configuration.add_new_node ) );
2041 if ( default_option == Configuration.add_new_node ) {
2042 selected_index = cb_index;
2046 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
2047 _edit_node_data_item = cb_index;
2048 addClickToOption( Configuration.edit_node_data,
2049 _configuration.getClickToTitle( Configuration.edit_node_data ) );
2050 if ( default_option == Configuration.edit_node_data ) {
2051 selected_index = cb_index;
2056 // Set default selection and its action
2057 _click_to_combobox.setSelectedIndex( selected_index );
2058 setClickToAction( selected_index );
2061 private void setupDisplayCheckboxes() {
2062 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
2063 addCheckbox( Configuration.display_as_phylogram,
2064 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
2065 setCheckbox( Configuration.display_as_phylogram,
2066 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
2068 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
2069 addCheckbox( Configuration.dynamically_hide_data,
2070 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
2071 setCheckbox( Configuration.dynamically_hide_data,
2072 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
2074 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
2075 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
2076 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
2078 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
2079 addCheckbox( Configuration.display_internal_data,
2080 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
2081 setCheckbox( Configuration.display_internal_data,
2082 _configuration.doCheckOption( Configuration.display_internal_data ) );
2084 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
2085 addCheckbox( Configuration.color_according_to_species,
2086 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
2087 setCheckbox( Configuration.color_according_to_species,
2088 _configuration.doCheckOption( Configuration.color_according_to_species ) );
2090 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
2091 addCheckbox( Configuration.color_according_to_annotation,
2092 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
2093 setCheckbox( Configuration.color_according_to_annotation,
2094 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
2096 if ( _configuration.doDisplayOption( Configuration.color_branches ) ) {
2097 addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) );
2098 setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) );
2100 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
2101 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
2102 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
2104 final JLabel label = new JLabel( "Display Data:" );
2105 label.setFont( ControlPanel.jcb_bold_font );
2106 if ( !getConfiguration().isUseNativeUI() ) {
2107 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2110 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
2111 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
2112 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
2114 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
2115 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
2116 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
2118 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
2119 addCheckbox( Configuration.show_taxonomy_scientific_names,
2120 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
2121 setCheckbox( Configuration.show_taxonomy_scientific_names,
2122 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
2124 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
2125 addCheckbox( Configuration.show_taxonomy_common_names,
2126 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
2127 setCheckbox( Configuration.show_taxonomy_common_names,
2128 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
2130 if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
2131 addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
2132 setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
2134 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
2135 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
2136 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
2138 if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
2139 addCheckbox( Configuration.show_seq_symbols,
2140 _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
2141 setCheckbox( Configuration.show_seq_symbols, _configuration.doCheckOption( Configuration.show_seq_symbols ) );
2143 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
2144 addCheckbox( Configuration.show_sequence_acc,
2145 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
2146 setCheckbox( Configuration.show_sequence_acc,
2147 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
2149 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
2150 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
2151 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
2153 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
2154 addCheckbox( Configuration.show_binary_characters,
2155 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
2156 setCheckbox( Configuration.show_binary_characters,
2157 _configuration.doCheckOption( Configuration.show_binary_characters ) );
2159 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
2160 addCheckbox( Configuration.show_binary_character_counts,
2161 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
2162 setCheckbox( Configuration.show_binary_character_counts,
2163 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
2165 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
2166 addCheckbox( Configuration.show_domain_architectures,
2167 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
2168 setCheckbox( Configuration.show_domain_architectures,
2169 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
2171 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
2172 addCheckbox( Configuration.write_confidence_values,
2173 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
2174 setCheckbox( Configuration.write_confidence_values,
2175 _configuration.doCheckOption( Configuration.write_confidence_values ) );
2177 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
2178 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
2179 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
2181 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
2182 addCheckbox( Configuration.show_vector_data,
2183 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
2184 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
2186 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
2187 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
2188 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
2190 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
2191 addCheckbox( Configuration.show_taxonomy_images,
2192 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
2193 setCheckbox( Configuration.show_taxonomy_images,
2194 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
2198 private void setVisibilityOfDomainStrucureControls() {
2199 if ( _zoom_in_domain_structure != null ) {
2200 if ( isShowDomainArchitectures() ) {
2201 _domain_display_label.setVisible( true );
2202 _zoom_in_domain_structure.setVisible( true );
2203 _zoom_out_domain_structure.setVisible( true );
2204 _decr_domain_structure_evalue_thr.setVisible( true );
2205 _incr_domain_structure_evalue_thr.setVisible( true );
2206 _domain_structure_evalue_thr_tf.setVisible( true );
2209 _domain_display_label.setVisible( false );
2210 _zoom_in_domain_structure.setVisible( false );
2211 _zoom_out_domain_structure.setVisible( false );
2212 _decr_domain_structure_evalue_thr.setVisible( false );
2213 _incr_domain_structure_evalue_thr.setVisible( false );
2214 _domain_structure_evalue_thr_tf.setVisible( false );
2219 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2220 label.setFont( ControlPanel.jcb_bold_font );
2221 if ( !configuration.isUseNativeUI() ) {
2222 label.setForeground( configuration.getGuiCheckboxTextColor() );
2223 label.setBackground( configuration.getGuiBackgroundColor() );
2228 enum NodeClickAction {
2235 DELETE_NODE_OR_SUBTREE,