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 );
205 final TreePanel tp = getMainPanel().getCurrentTreePanel();
209 if ( e.getSource() == _click_to_combobox ) {
210 setClickToAction( _click_to_combobox.getSelectedIndex() );
211 getCurrentTreePanel().repaint();
213 else if ( e.getSource() == _show_binary_characters ) {
214 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
215 _show_binary_character_counts.setSelected( false );
217 displayedPhylogenyMightHaveChanged( true );
219 else if ( e.getSource() == _show_binary_character_counts ) {
220 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
221 _show_binary_characters.setSelected( false );
223 displayedPhylogenyMightHaveChanged( true );
225 else if ( e.getSource() == _show_domain_architectures ) {
228 displayedPhylogenyMightHaveChanged( true );
230 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
231 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
232 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
236 else if ( e.getSource() == _zoom_in_x ) {
237 zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
238 displayedPhylogenyMightHaveChanged( false );
240 else if ( e.getSource() == _zoom_in_y ) {
241 zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR );
242 displayedPhylogenyMightHaveChanged( false );
244 else if ( e.getSource() == _zoom_out_x ) {
245 zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
246 displayedPhylogenyMightHaveChanged( false );
248 else if ( e.getSource() == _zoom_out_y ) {
249 zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR );
250 displayedPhylogenyMightHaveChanged( false );
252 else if ( e.getSource() == _show_whole ) {
255 else if ( e.getSource() == _return_to_super_tree ) {
256 _mainpanel.getCurrentTreePanel().superTree();
259 else if ( e.getSource() == _order ) {
260 DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
261 if ( ( !isShowTaxonomyScientificNames() && !isShowTaxonomyCode() && !isShowTaxonomyCommonNames() ) ) {
262 if ( ( isShowSequenceAcc() || isShowSeqNames() || isShowSeqSymbols() ) ) {
263 pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
265 else if ( isShowNodeNames() ) {
266 pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
269 PhylogenyMethods.orderAppearance( tp.getPhylogeny().getRoot(), _order_of_appearance, true, pri );
270 _order_of_appearance = !_order_of_appearance;
271 tp.setNodeInPreorderToNull();
272 tp.getPhylogeny().externalNodesHaveChanged();
273 tp.getPhylogeny().clearHashIdToNodeMap();
274 tp.getPhylogeny().recalculateNumberOfExternalDescendants( true );
275 tp.resetNodeIdToDistToLeafMap();
276 tp.setEdited( true );
277 displayedPhylogenyMightHaveChanged( false );
279 else if ( e.getSource() == _uncollapse_all ) {
281 displayedPhylogenyMightHaveChanged( false );
283 else if ( e.getSource() == _zoom_in_domain_structure ) {
284 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
285 displayedPhylogenyMightHaveChanged( true );
287 else if ( e.getSource() == _zoom_out_domain_structure ) {
288 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
289 displayedPhylogenyMightHaveChanged( true );
291 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
292 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThreshold();
293 displayedPhylogenyMightHaveChanged( true );
295 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
296 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThreshold();
297 displayedPhylogenyMightHaveChanged( true );
299 else if ( e.getSource() == _search_tf_0 ) {
301 displayedPhylogenyMightHaveChanged( true );
303 else if ( e.getSource() == _search_tf_1 ) {
305 displayedPhylogenyMightHaveChanged( true );
307 else if ( ( _dynamically_hide_data != null ) && ( e.getSource() == _dynamically_hide_data )
308 && !_dynamically_hide_data.isSelected() ) {
309 setDynamicHidingIsOn( false );
310 displayedPhylogenyMightHaveChanged( true );
313 displayedPhylogenyMightHaveChanged( true );
317 tp.requestFocusInWindow();
320 catch ( final Exception ex ) {
321 AptxUtil.unexpectedException( ex );
323 catch ( final Error err ) {
324 AptxUtil.unexpectedError( err );
328 public JCheckBox getColorAccSpeciesCb() {
329 return _color_acc_species;
332 public JCheckBox getColorAccSequenceCb() {
333 return _color_acc_sequence;
336 public JCheckBox getUseVisualStylesCb() {
337 return _use_visual_styles_cb;
340 public JCheckBox getDisplayAsPhylogramCb() {
341 return _display_as_phylogram_cb;
344 public JCheckBox getDynamicallyHideData() {
345 return _dynamically_hide_data;
348 public JCheckBox getNodeDescPopupCb() {
349 return _node_desc_popup_cb;
352 public Sequence getSelectedQuerySequence() {
353 return _selected_query_seq;
356 public JComboBox<String> getSequenceRelationBox() {
357 if ( _show_sequence_relations == null ) {
358 _show_sequence_relations = new JComboBox<String>();
359 _show_sequence_relations.setFocusable( false );
360 _show_sequence_relations.setMaximumRowCount( 20 );
361 _show_sequence_relations.setFont( ControlPanel.js_font );
362 if ( !_configuration.isUseNativeUI() ) {
363 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
364 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
366 _show_sequence_relations.addItem( "-----" );
367 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
369 return _show_sequence_relations;
373 public JComboBox<SEQUENCE_RELATION_TYPE> getSequenceRelationTypeBox() {
374 if ( _sequence_relation_type_box == null ) {
375 _sequence_relation_type_box = new JComboBox<SEQUENCE_RELATION_TYPE>();
376 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
377 _sequence_relation_type_box.addItem( type );
379 _sequence_relation_type_box.addActionListener( new ActionListener() {
382 public void actionPerformed( final ActionEvent e ) {
383 if ( _mainpanel.getCurrentPhylogeny() != null ) {
384 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
389 return _sequence_relation_type_box;
392 public JCheckBox getShowEventsCb() {
396 public JCheckBox getWriteConfidenceCb() {
397 return _write_confidence;
400 public boolean isShowProperties() {
401 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
404 public boolean isShowTaxonomyImages() {
405 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
408 public boolean isShowVectorData() {
409 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
412 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
413 final JComboBox<String> box = getSequenceRelationBox();
414 while ( box.getItemCount() > 1 ) {
415 box.removeItemAt( 1 );
417 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
418 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
420 if ( relationType == null ) {
423 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
424 for( final Sequence seq : sequenceRelationQueries ) {
425 if ( seq.hasSequenceRelations() ) {
426 boolean fFoundForCurrentType = false;
427 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
428 if ( sq.getType().equals( relationType ) ) {
429 fFoundForCurrentType = true;
433 if ( fFoundForCurrentType ) {
434 sequenceNamesToAdd.add( seq.getName() );
435 sequencesByName.put( seq.getName(), seq );
439 // sort sequences by name before adding them to the combo
440 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
441 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
442 for( final String seqName : sequenceNameArray ) {
443 box.addItem( seqName );
445 for( final ItemListener oldItemListener : box.getItemListeners() ) {
446 box.removeItemListener( oldItemListener );
448 box.addItemListener( new ItemListener() {
451 public void itemStateChanged( final ItemEvent e ) {
452 _selected_query_seq = sequencesByName.get( e.getItem() );
453 _mainpanel.getCurrentTreePanel().repaint();
458 void activateButtonToReturnToSuperTree( int index ) {
461 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
464 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
466 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
467 _return_to_super_tree.setEnabled( true );
471 * Add zoom and quick edit buttons. (Last modified 8/9/04)
474 final JLabel spacer = new JLabel( "" );
475 spacer.setOpaque( false );
477 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
478 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
479 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
480 if ( !getConfiguration().isUseNativeUI() ) {
481 x_panel.setBackground( getBackground() );
482 y_panel.setBackground( getBackground() );
483 z_panel.setBackground( getBackground() );
485 add( _zoom_label = new JLabel( "Zoom:" ) );
486 customizeLabel( _zoom_label, getConfiguration() );
490 if ( getConfiguration().isUseNativeUI() ) {
491 _zoom_in_x = new JButton( "+" );
492 _zoom_out_x = new JButton( "-" );
495 _zoom_in_x = new JButton( "X+" );
496 _zoom_out_x = new JButton( "X-" );
498 _zoom_in_y = new JButton( "Y+" );
499 _zoom_out_y = new JButton( "Y-" );
500 _show_whole = new JButton( "F" );
501 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [F or Home]" );
502 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+cursor-right]" );
503 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+cursor-up]" );
504 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+cursor-left]" );
505 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+cursor-down]" );
506 if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) {
507 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
508 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
511 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
512 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
514 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
515 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
516 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
517 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
518 _return_to_super_tree.setEnabled( false );
519 _order = new JButton( "Order Subtrees" );
520 _uncollapse_all = new JButton( "Uncollapse All" );
521 addJButton( _zoom_in_y, x_panel );
522 addJButton( _zoom_out_x, y_panel );
523 addJButton( _show_whole, y_panel );
524 addJButton( _zoom_in_x, y_panel );
525 addJButton( _zoom_out_y, z_panel );
526 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
527 setUpControlsForDomainStrucures();
529 final JLabel spacer2 = new JLabel( "" );
531 addJButton( _return_to_super_tree, this );
532 addJButton( _order, this );
533 addJButton( _uncollapse_all, this );
534 final JLabel spacer3 = new JLabel( "" );
536 setVisibilityOfDomainStrucureControls();
539 void addCheckbox( final int which, final String title ) {
540 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
542 case Configuration.display_as_phylogram:
543 _display_as_phylogram_cb = new JCheckBox( title );
544 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
545 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
548 case Configuration.display_internal_data:
549 _display_internal_data = new JCheckBox( title );
550 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
551 addJCheckBox( _display_internal_data, ch_panel );
554 case Configuration.color_according_to_species:
555 _color_acc_species = new JCheckBox( title );
556 _color_acc_species.setToolTipText( "To colorize node labels as a function of taxonomy" );
557 addJCheckBox( _color_acc_species, ch_panel );
560 case Configuration.color_according_to_sequence:
561 _color_acc_sequence = new JCheckBox( title );
562 _color_acc_sequence.setToolTipText( "To colorize node labels as a function of sequence name" );
563 addJCheckBox( _color_acc_sequence, ch_panel );
566 case Configuration.color_according_to_annotation:
567 _color_according_to_annotation = new JCheckBox( title );
568 _color_according_to_annotation
569 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
570 addJCheckBox( _color_according_to_annotation, ch_panel );
573 case Configuration.show_node_names:
574 _show_node_names = new JCheckBox( title );
575 addJCheckBox( _show_node_names, ch_panel );
578 case Configuration.show_taxonomy_scientific_names:
579 _show_taxo_scientific_names = new JCheckBox( title );
580 addJCheckBox( _show_taxo_scientific_names, ch_panel );
583 case Configuration.show_taxonomy_common_names:
584 _show_taxo_common_names = new JCheckBox( title );
585 addJCheckBox( _show_taxo_common_names, ch_panel );
588 case Configuration.show_tax_code:
589 _show_taxo_code = new JCheckBox( title );
590 addJCheckBox( _show_taxo_code, ch_panel );
593 case Configuration.show_taxonomy_images:
594 _show_taxo_images_cb = new JCheckBox( title );
595 addJCheckBox( _show_taxo_images_cb, ch_panel );
598 case Configuration.show_binary_characters:
599 _show_binary_characters = new JCheckBox( title );
600 addJCheckBox( _show_binary_characters, ch_panel );
603 case Configuration.show_annotation:
604 _show_annotation = new JCheckBox( title );
605 addJCheckBox( _show_annotation, ch_panel );
608 case Configuration.show_binary_character_counts:
609 _show_binary_character_counts = new JCheckBox( title );
610 addJCheckBox( _show_binary_character_counts, ch_panel );
613 case Configuration.write_confidence_values:
614 _write_confidence = new JCheckBox( title );
615 addJCheckBox( getWriteConfidenceCb(), ch_panel );
618 case Configuration.write_events:
619 _show_events = new JCheckBox( title );
620 addJCheckBox( getShowEventsCb(), ch_panel );
623 case Configuration.use_style:
624 _use_visual_styles_cb = new JCheckBox( title );
625 getUseVisualStylesCb()
626 .setToolTipText( "To use visual styles (node colors, fonts) and branch colors, if present" );
627 addJCheckBox( getUseVisualStylesCb(), ch_panel );
630 case Configuration.width_branches:
631 _width_branches = new JCheckBox( title );
632 _width_branches.setToolTipText( "To use branch width values, if present" );
633 addJCheckBox( _width_branches, ch_panel );
636 case Configuration.show_domain_architectures:
637 _show_domain_architectures = new JCheckBox( title );
638 addJCheckBox( _show_domain_architectures, ch_panel );
641 case Configuration.show_seq_names:
642 _show_seq_names = new JCheckBox( title );
643 addJCheckBox( _show_seq_names, ch_panel );
646 case Configuration.show_gene_names:
647 _show_gene_names = new JCheckBox( title );
648 addJCheckBox( _show_gene_names, ch_panel );
651 case Configuration.show_seq_symbols:
652 _show_seq_symbols = new JCheckBox( title );
653 addJCheckBox( _show_seq_symbols, ch_panel );
656 case Configuration.show_sequence_acc:
657 _show_sequence_acc = new JCheckBox( title );
658 addJCheckBox( _show_sequence_acc, ch_panel );
661 case Configuration.dynamically_hide_data:
662 _dynamically_hide_data = new JCheckBox( title );
663 getDynamicallyHideData().setToolTipText( "To hide labels depending on expected visibility" );
664 addJCheckBox( getDynamicallyHideData(), ch_panel );
667 case Configuration.node_data_popup:
668 _node_desc_popup_cb = new JCheckBox( title );
669 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
670 addJCheckBox( getNodeDescPopupCb(), ch_panel );
673 case Configuration.show_relation_confidence:
674 _seq_relation_confidence_switch = new JCheckBox( title );
675 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
678 case Configuration.show_vector_data:
679 _show_vector_data_cb = new JCheckBox( title );
680 addJCheckBox( _show_vector_data_cb, ch_panel );
683 case Configuration.show_properties:
684 _show_properties_cb = new JCheckBox( title );
685 addJCheckBox( _show_properties_cb, ch_panel );
689 throw new RuntimeException( "unknown checkbox: " + which );
693 void addJButton( final JButton jb, final JPanel p ) {
694 jb.setFocusPainted( false );
695 jb.setFont( ControlPanel.jcb_font );
696 if ( !_configuration.isUseNativeUI() ) {
697 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
698 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
699 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
702 jb.addActionListener( this );
705 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
706 jcb.setFocusPainted( false );
707 jcb.setFont( ControlPanel.jcb_font );
708 if ( !_configuration.isUseNativeUI() ) {
709 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
710 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
712 p.add( jcb, "Center" );
713 jcb.addActionListener( this );
716 void addJTextField( final JTextField tf, final JPanel p ) {
717 if ( !_configuration.isUseNativeUI() ) {
718 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
719 tf.setFont( ControlPanel.jcb_font );
722 tf.addActionListener( this );
725 void deactivateButtonToReturnToSuperTree() {
726 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
727 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
728 _return_to_super_tree.setEnabled( false );
731 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
732 if ( ( _mainpanel != null )
733 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
734 if ( getOptions().isShowOverview() ) {
735 _mainpanel.getCurrentTreePanel().updateOvSizes();
737 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
738 setVisibilityOfDomainStrucureControls();
739 updateDomainStructureEvaluethresholdDisplay();
740 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
741 _mainpanel.getCurrentTreePanel().calcMaxDepth();
742 _mainpanel.adjustJScrollPane();
743 if ( recalc_longest_ext_node_info ) {
744 _mainpanel.getCurrentTreePanel().initNodeData();
745 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
747 _mainpanel.getCurrentTreePanel().repaint();
748 // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
752 void endClickToOptions() {
753 _click_to_combobox.addActionListener( this );
757 * Indicates what action should be execute when a node is clicked
759 * @return the click-on action
761 NodeClickAction getActionWhenNodeClicked() {
762 return _action_when_node_clicked;
765 Map<Integer, String> getAllClickToItems() {
766 return _all_click_to_names;
769 Map<String, Color> getAnnotationColors() {
770 return _annotation_colors;
773 Configuration getConfiguration() {
774 return _configuration;
777 TreePanel getCurrentTreePanel() {
778 return getMainPanel().getCurrentTreePanel();
781 MainPanel getMainPanel() {
785 Options getOptions() {
786 return getMainPanel().getOptions();
789 JLabel getSearchFoundCountsLabel0() {
790 return _search_found_label_0;
793 JLabel getSearchFoundCountsLabel1() {
794 return _search_found_label_1;
797 JButton getSearchResetButton0() {
798 return _search_reset_button_0;
801 JButton getSearchResetButton1() {
802 return _search_reset_button_1;
805 JTextField getSearchTextField0() {
809 JTextField getSearchTextField1() {
813 List<String> getSingleClickToNames() {
814 return _click_to_names;
817 Map<String, Color> getSpeciesColors() {
818 return _species_colors;
821 Map<String, Color> getSequenceColors() {
822 return _sequence_colors;
825 boolean isAntialiasScreenText() {
829 boolean isColorAccordingToAnnotation() {
830 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
833 boolean isColorAccordingToTaxonomy() {
834 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
837 boolean isColorAccordingToSequence() {
838 return ( ( _color_acc_sequence != null ) && _color_acc_sequence.isSelected() );
841 boolean isUseVisualStyles() {
842 return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() ) || ( ( getUseVisualStylesCb() == null ) && _color_branches ) );
845 boolean isDrawPhylogram() {
846 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
849 boolean isDynamicallyHideData() {
850 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
854 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
857 boolean isNodeDescPopup() {
858 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
861 boolean isShowAnnotation() {
862 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
865 boolean isShowBinaryCharacterCounts() {
866 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
869 boolean isShowBinaryCharacters() {
870 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
873 boolean isShowConfidenceValues() {
874 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
877 boolean isShowDomainArchitectures() {
878 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
881 boolean isShowGeneNames() {
882 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
885 boolean isShowInternalData() {
886 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
889 boolean isShowNodeNames() {
890 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
893 boolean isShowSeqNames() {
894 return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
897 boolean isShowSeqSymbols() {
898 return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
901 boolean isShowSequenceAcc() {
902 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
905 boolean isShowSequenceRelationConfidence() {
906 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
909 boolean isShowSequenceRelations() {
910 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
913 boolean isShowTaxonomyCode() {
914 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
917 boolean isShowTaxonomyCommonNames() {
918 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
921 boolean isShowTaxonomyScientificNames() {
922 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
925 boolean isWidthBranches() {
926 return ( ( _width_branches != null ) && _width_branches.isSelected() );
929 void phylogenyAdded( final Configuration configuration ) {
930 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
933 void phylogenyRemoved( final int index ) {
934 getIsDrawPhylogramList().remove( index );
938 final MainPanel main_panel = getMainPanel();
939 final Phylogeny tree = main_panel.getCurrentPhylogeny();
940 if ( ( tree == null ) || tree.isEmpty() ) {
943 String query = getSearchTextField0().getText();
944 if ( query != null ) {
945 query = query.trim();
947 if ( !ForesterUtil.isEmpty( query ) ) {
948 search0( main_panel, tree, query );
951 getSearchFoundCountsLabel0().setVisible( false );
952 getSearchResetButton0().setEnabled( false );
953 getSearchResetButton0().setVisible( false );
959 final MainPanel main_panel = getMainPanel();
960 final Phylogeny tree = main_panel.getCurrentPhylogeny();
961 if ( ( tree == null ) || tree.isEmpty() ) {
964 String query = getSearchTextField1().getText();
965 if ( query != null ) {
966 query = query.trim();
968 if ( !ForesterUtil.isEmpty( query ) ) {
969 search1( main_panel, tree, query );
972 getSearchFoundCountsLabel1().setVisible( false );
973 getSearchResetButton1().setEnabled( false );
974 getSearchResetButton1().setVisible( false );
979 void searchReset0() {
980 if ( getMainPanel().getCurrentTreePanel() != null ) {
981 getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
985 void searchReset1() {
986 if ( getMainPanel().getCurrentTreePanel() != null ) {
987 getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
991 void setActionWhenNodeClicked( final NodeClickAction action ) {
992 _action_when_node_clicked = action;
995 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
996 _annotation_colors = annotation_colors;
999 void setCheckbox( final int which, final boolean state ) {
1001 case Configuration.display_as_phylogram:
1002 if ( getDisplayAsPhylogramCb() != null ) {
1003 getDisplayAsPhylogramCb().setSelected( state );
1006 case Configuration.display_internal_data:
1007 if ( _display_internal_data != null ) {
1008 _display_internal_data.setSelected( state );
1011 case Configuration.color_according_to_species:
1012 if ( _color_acc_species != null ) {
1013 _color_acc_species.setSelected( state );
1016 case Configuration.color_according_to_sequence:
1017 if ( _color_acc_sequence != null ) {
1018 _color_acc_sequence.setSelected( state );
1021 case Configuration.color_according_to_annotation:
1022 if ( _color_according_to_annotation != null ) {
1023 _color_according_to_annotation.setSelected( state );
1026 case Configuration.show_node_names:
1027 if ( _show_node_names != null ) {
1028 _show_node_names.setSelected( state );
1031 case Configuration.show_taxonomy_scientific_names:
1032 if ( _show_taxo_scientific_names != null ) {
1033 _show_taxo_scientific_names.setSelected( state );
1036 case Configuration.show_taxonomy_common_names:
1037 if ( _show_taxo_common_names != null ) {
1038 _show_taxo_common_names.setSelected( state );
1041 case Configuration.show_tax_code:
1042 if ( _show_taxo_code != null ) {
1043 _show_taxo_code.setSelected( state );
1046 case Configuration.show_taxonomy_images:
1047 if ( _show_taxo_images_cb != null ) {
1048 _show_taxo_images_cb.setSelected( state );
1051 case Configuration.show_annotation:
1052 if ( _show_annotation != null ) {
1053 _show_annotation.setSelected( state );
1056 case Configuration.show_binary_characters:
1057 if ( _show_binary_characters != null ) {
1058 _show_binary_characters.setSelected( state );
1061 case Configuration.show_binary_character_counts:
1062 if ( _show_binary_character_counts != null ) {
1063 _show_binary_character_counts.setSelected( state );
1066 case Configuration.write_confidence_values:
1067 if ( getWriteConfidenceCb() != null ) {
1068 getWriteConfidenceCb().setSelected( state );
1071 case Configuration.write_events:
1072 if ( getShowEventsCb() != null ) {
1073 getShowEventsCb().setSelected( state );
1076 case Configuration.use_style:
1077 if ( getUseVisualStylesCb() != null ) {
1078 getUseVisualStylesCb().setSelected( state );
1081 case Configuration.width_branches:
1082 if ( _width_branches != null ) {
1083 _width_branches.setSelected( state );
1086 case Configuration.show_domain_architectures:
1087 if ( _show_domain_architectures != null ) {
1088 _show_domain_architectures.setSelected( state );
1091 case Configuration.show_seq_names:
1092 if ( _show_seq_names != null ) {
1093 _show_seq_names.setSelected( state );
1096 case Configuration.show_gene_names:
1097 if ( _show_gene_names != null ) {
1098 _show_gene_names.setSelected( state );
1101 case Configuration.show_seq_symbols:
1102 if ( _show_seq_symbols != null ) {
1103 _show_seq_symbols.setSelected( state );
1106 case Configuration.show_vector_data:
1107 if ( _show_vector_data_cb != null ) {
1108 _show_vector_data_cb.setSelected( state );
1111 case Configuration.show_properties:
1112 if ( _show_properties_cb != null ) {
1113 _show_properties_cb.setSelected( state );
1116 case Configuration.show_sequence_acc:
1117 if ( _show_sequence_acc != null ) {
1118 _show_sequence_acc.setSelected( state );
1121 case Configuration.dynamically_hide_data:
1122 if ( getDynamicallyHideData() != null ) {
1123 getDynamicallyHideData().setSelected( state );
1126 case Configuration.node_data_popup:
1127 if ( getNodeDescPopupCb() != null ) {
1128 getNodeDescPopupCb().setSelected( state );
1132 case Configuration.show_relation_confidence:
1133 if ( _seq_relation_confidence_switch != null ) {
1134 _seq_relation_confidence_switch.setSelected( state );
1139 throw new AssertionError( "unknown checkbox: " + which );
1144 * Set this checkbox state. Not all checkboxes have been instantiated
1145 * depending on the config.
1147 void setCheckbox( final JCheckBox cb, final boolean state ) {
1149 cb.setSelected( state );
1153 void setClickToAction( final int action ) {
1154 // Set click-to action
1155 if ( action == _show_data_item ) {
1156 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1158 else if ( action == _collapse_cb_item ) {
1159 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1161 else if ( action == _reroot_cb_item ) {
1162 setActionWhenNodeClicked( NodeClickAction.REROOT );
1164 else if ( action == _subtree_cb_item ) {
1165 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1167 else if ( action == _swap_cb_item ) {
1168 setActionWhenNodeClicked( NodeClickAction.SWAP );
1170 else if ( action == _color_subtree_cb_item ) {
1171 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1173 else if ( action == _open_seq_web_item ) {
1174 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1176 else if ( action == _sort_descendents_item ) {
1177 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1179 else if ( action == _blast_item ) {
1180 setActionWhenNodeClicked( NodeClickAction.BLAST );
1182 else if ( action == _open_tax_web_item ) {
1183 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1185 else if ( action == _cut_subtree_item ) {
1186 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1188 else if ( action == _copy_subtree_item ) {
1189 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1191 else if ( action == _delete_node_or_subtree_item ) {
1192 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1194 else if ( action == _paste_subtree_item ) {
1195 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1197 else if ( action == _add_new_node_item ) {
1198 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1200 else if ( action == _edit_node_data_item ) {
1201 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1203 else if ( action == _select_nodes_item ) {
1204 setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
1206 else if ( action == _get_ext_desc_data ) {
1207 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
1209 else if ( action == _open_pdb_item ) {
1210 setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
1212 else if ( action == _color_node_font_item ) {
1213 setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
1215 else if ( action == _change_node_font_item ) {
1216 setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT );
1219 throw new RuntimeException( "unknown action: " + action );
1221 // make sure drop down is displaying the correct action
1222 // in case this was called from outside the class
1223 _click_to_combobox.setSelectedIndex( action );
1226 void setColorBranches( final boolean color_branches ) {
1227 _color_branches = color_branches;
1230 void setDrawPhylogram( final boolean b ) {
1231 getDisplayAsPhylogramCb().setSelected( b );
1232 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1235 void setDrawPhylogramEnabled( final boolean b ) {
1236 getDisplayAsPhylogramCb().setEnabled( b );
1239 void setDynamicHidingIsOn( final boolean is_on ) {
1241 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1244 if ( !_configuration.isUseNativeUI() ) {
1245 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1248 getDynamicallyHideData().setForeground( Color.BLACK );
1253 void setSearchFoundCountsOnLabel0( final int counts ) {
1254 getSearchFoundCountsLabel0().setText( "Found: " + counts );
1257 void setSearchFoundCountsOnLabel1( final int counts ) {
1258 getSearchFoundCountsLabel1().setText( "Found: " + counts );
1261 void setShowEvents( final boolean show_events ) {
1262 if ( getShowEventsCb() == null ) {
1263 _show_events = new JCheckBox( "" );
1265 getShowEventsCb().setSelected( show_events );
1268 void setSpeciesColors( final Map<String, Color> species_colors ) {
1269 _species_colors = species_colors;
1272 void setSequenceColors( final Map<String, Color> sequence_colors ) {
1273 _sequence_colors = sequence_colors;
1278 * Set up the controls from the config settings. 11/26/05
1280 void setupControls() {
1281 // The tree display options:
1282 setupDisplayCheckboxes();
1284 // The sequence relation query selection combo-box
1285 if ( _configuration.displaySequenceRelations() ) {
1286 addSequenceRelationBlock();
1290 startClickToOptions();
1291 setupClickToOptions();
1292 endClickToOptions();
1293 // Zoom and quick edit buttons
1295 setupSearchTools0();
1296 setupSearchTools1();
1299 void setUpControlsForDomainStrucures() {
1300 _domain_display_label = new JLabel( "Domain Display:" );
1301 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1302 add( _domain_display_label );
1303 _zoom_in_domain_structure = new JButton( "d+" );
1304 _zoom_out_domain_structure = new JButton( "d-" );
1305 _decr_domain_structure_evalue_thr = new JButton( "-" );
1306 _incr_domain_structure_evalue_thr = new JButton( "+" );
1307 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1308 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1309 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1310 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1311 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1312 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1313 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1314 _domain_structure_evalue_thr_tf.setEditable( false );
1315 if ( !getConfiguration().isUseNativeUI() ) {
1316 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1317 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1318 _domain_structure_evalue_thr_tf.setBorder( null );
1320 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1321 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1322 if ( !_configuration.isUseNativeUI() ) {
1323 d1_panel.setBackground( getBackground() );
1324 d2_panel.setBackground( getBackground() );
1328 addJButton( _zoom_out_domain_structure, d1_panel );
1329 addJButton( _zoom_in_domain_structure, d1_panel );
1330 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1331 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1332 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1335 void setupSearchTools0() {
1336 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1337 final JLabel search_label = new JLabel( "Search (A):" );
1338 search_label.setFont( ControlPanel.jcb_bold_font );
1339 if ( !getConfiguration().isUseNativeUI() ) {
1340 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1342 add( search_label );
1343 search_label.setToolTipText( tip );
1344 _search_found_label_0 = new JLabel();
1345 getSearchFoundCountsLabel0().setVisible( false );
1346 _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
1347 if ( !getConfiguration().isUseNativeUI() ) {
1348 _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1350 _search_tf_0 = new JTextField( 3 );
1351 _search_tf_0.setToolTipText( tip );
1352 _search_tf_0.setEditable( true );
1353 if ( !getConfiguration().isUseNativeUI() ) {
1354 _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1355 _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1356 _search_tf_0.setBorder( null );
1358 _search_reset_button_0 = new JButton();
1359 getSearchResetButton0().setText( "Reset" );
1360 getSearchResetButton0().setEnabled( false );
1361 getSearchResetButton0().setVisible( false );
1362 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1363 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1364 s_panel_1.setBackground( getBackground() );
1366 s_panel_2.setBackground( getBackground() );
1368 final KeyAdapter key_adapter = new KeyAdapter() {
1371 public void keyReleased( final KeyEvent key_event ) {
1373 displayedPhylogenyMightHaveChanged( true );
1376 final ActionListener action_listener = new ActionListener() {
1379 public void actionPerformed( final ActionEvent e ) {
1381 setSearchFoundCountsOnLabel0( 0 );
1382 getSearchFoundCountsLabel0().setVisible( false );
1383 getSearchTextField0().setText( "" );
1384 getSearchResetButton0().setEnabled( false );
1385 getSearchResetButton0().setVisible( false );
1386 displayedPhylogenyMightHaveChanged( true );
1389 _search_reset_button_0.addActionListener( action_listener );
1390 _search_tf_0.addKeyListener( key_adapter );
1391 addJTextField( _search_tf_0, s_panel_1 );
1392 s_panel_2.add( _search_found_label_0 );
1393 addJButton( _search_reset_button_0, s_panel_2 );
1396 void setupSearchTools1() {
1397 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1398 final JLabel search_label = new JLabel( "Search (B):" );
1399 search_label.setFont( ControlPanel.jcb_bold_font );
1400 if ( !getConfiguration().isUseNativeUI() ) {
1401 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1403 add( search_label );
1404 search_label.setToolTipText( tip );
1405 _search_found_label_1 = new JLabel();
1406 getSearchFoundCountsLabel1().setVisible( false );
1407 _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
1408 if ( !getConfiguration().isUseNativeUI() ) {
1409 _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1411 _search_tf_1 = new JTextField( 3 );
1412 _search_tf_1.setToolTipText( tip );
1413 _search_tf_1.setEditable( true );
1414 if ( !getConfiguration().isUseNativeUI() ) {
1415 _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1416 _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1417 _search_tf_1.setBorder( null );
1419 _search_reset_button_1 = new JButton();
1420 getSearchResetButton1().setText( "Reset" );
1421 getSearchResetButton1().setEnabled( false );
1422 getSearchResetButton1().setVisible( false );
1423 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1424 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1425 s_panel_1.setBackground( getBackground() );
1427 s_panel_2.setBackground( getBackground() );
1429 final KeyAdapter key_adapter = new KeyAdapter() {
1432 public void keyReleased( final KeyEvent key_event ) {
1434 displayedPhylogenyMightHaveChanged( true );
1437 final ActionListener action_listener = new ActionListener() {
1440 public void actionPerformed( final ActionEvent e ) {
1442 setSearchFoundCountsOnLabel1( 0 );
1443 getSearchFoundCountsLabel1().setVisible( false );
1444 getSearchTextField1().setText( "" );
1445 getSearchResetButton1().setEnabled( false );
1446 getSearchResetButton1().setVisible( false );
1447 displayedPhylogenyMightHaveChanged( true );
1450 _search_reset_button_1.addActionListener( action_listener );
1451 _search_tf_1.addKeyListener( key_adapter );
1452 addJTextField( _search_tf_1, s_panel_1 );
1453 s_panel_2.add( _search_found_label_1 );
1454 addJButton( _search_reset_button_1, s_panel_2 );
1457 void showAnnotations() {
1458 if ( _show_annotation != null ) {
1459 _show_annotation.setSelected( true );
1461 if ( _color_according_to_annotation != null ) {
1462 _color_according_to_annotation.setSelected( true );
1464 if ( _color_acc_species != null ) {
1465 _color_acc_species.setSelected( false );
1467 if ( _color_acc_sequence != null ) {
1468 _color_acc_sequence.setSelected( false );
1470 _mainpanel.getCurrentTreePanel().repaint();
1474 * Fit entire tree into window.
1477 if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
1480 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
1481 displayedPhylogenyMightHaveChanged( true );
1482 _mainpanel.getCurrentTreePanel().updateOvSettings();
1483 _mainpanel.getCurrentTreePanel().validate();
1484 _mainpanel.validate();
1485 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1486 _mainpanel.getSizeOfViewport().height,
1488 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1489 _mainpanel.adjustJScrollPane();
1490 _mainpanel.getCurrentTreePanel().repaint();
1491 _mainpanel.getCurrentTreePanel().validate();
1492 _mainpanel.validate();
1493 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1494 _mainpanel.getSizeOfViewport().height,
1496 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1497 _mainpanel.adjustJScrollPane();
1498 _mainpanel.getCurrentTreePanel().repaint();
1499 _mainpanel.getCurrentTreePanel().updateOvSizes();
1502 void showWholeAll() {
1503 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1504 if ( tree_panel != null ) {
1505 tree_panel.validate();
1506 tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
1507 _mainpanel.getSizeOfViewport().height,
1509 tree_panel.resetPreferredSize();
1510 tree_panel.repaint();
1515 // Create header for click-to combo box.
1516 void startClickToOptions() {
1517 final JLabel spacer = new JLabel( "" );
1518 spacer.setFont( ControlPanel.jcb_font );
1520 _click_to_label = new JLabel( "Click on Node to:" );
1521 add( customizeLabel( _click_to_label, getConfiguration() ) );
1522 _click_to_combobox = new JComboBox<String>();
1523 _click_to_combobox.setFocusable( false );
1524 _click_to_combobox.setMaximumRowCount( 14 );
1525 _click_to_combobox.setFont( ControlPanel.js_font );
1526 if ( !_configuration.isUseNativeUI() ) {
1527 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1529 // don't add listener until all items are set (or each one will trigger
1531 // click_to_list.addActionListener(this);
1532 add( _click_to_combobox );
1533 // Correlates option names to titles
1534 _all_click_to_names = new HashMap<Integer, String>();
1535 _click_to_names = new ArrayList<String>();
1539 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1540 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1541 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1542 setDrawPhylogramEnabled( true );
1543 setDrawPhylogram( isDrawPhylogram() );
1546 setDrawPhylogramEnabled( false );
1547 setDrawPhylogram( false );
1549 if ( getMainPanel().getMainFrame() == null ) {
1550 // Must be "E" applet version.
1551 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1552 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1555 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1556 .getPhylogenyGraphicsType() );
1558 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1559 getMainPanel().getControlPanel().search0();
1560 getMainPanel().getControlPanel().search1();
1561 getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
1562 getSequenceRelationTypeBox().removeAllItems();
1563 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1564 .getRelevantSequenceRelationTypes() ) {
1565 _sequence_relation_type_box.addItem( type );
1567 getMainPanel().getCurrentTreePanel().repaint();
1568 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1569 // according to GUILHEM the line above can be removed.
1574 * Uncollapse all nodes.
1576 void uncollapseAll( final TreePanel tp ) {
1577 final Phylogeny t = tp.getPhylogeny();
1578 if ( ( t != null ) && !t.isEmpty() ) {
1579 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
1580 final PhylogenyNode node = iter.next();
1581 node.setCollapse( false );
1583 tp.resetNodeIdToDistToLeafMap();
1584 tp.updateSetOfCollapsedExternalNodes();
1585 t.recalculateNumberOfExternalDescendants( false );
1586 tp.setNodeInPreorderToNull();
1587 t.clearHashIdToNodeMap();
1592 void updateDomainStructureEvaluethresholdDisplay() {
1593 if ( _domain_structure_evalue_thr_tf != null ) {
1594 _domain_structure_evalue_thr_tf.setText( "10^"
1595 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1599 void zoomInX( final float factor, final float x_correction_factor ) {
1600 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1601 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1602 treepanel.multiplyUrtFactor( 1f );
1603 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1604 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1605 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1606 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1607 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( 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 ) );
1620 getMainPanel().adjustJScrollPane();
1621 treepanel.resetPreferredSize();
1622 getMainPanel().getCurrentScrollPane().getViewport().validate();
1623 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1625 treepanel.resetPreferredSize();
1626 treepanel.updateOvSizes();
1629 void zoomInY( final float factor ) {
1630 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1631 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1632 treepanel.multiplyUrtFactor( 1.1f );
1633 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1634 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1635 getMainPanel().adjustJScrollPane();
1636 treepanel.resetPreferredSize();
1637 getMainPanel().getCurrentScrollPane().getViewport().validate();
1638 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1639 - ( sb.getVisibleAmount() / 2.0 ) ) );
1640 treepanel.resetPreferredSize();
1641 treepanel.updateOvSizes();
1644 void zoomOutX( final float factor, final float x_correction_factor ) {
1645 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1646 treepanel.multiplyUrtFactor( 1f );
1647 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1648 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1649 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1650 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1651 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1652 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1653 getMainPanel().adjustJScrollPane();
1654 treepanel.resetPreferredSize();
1655 getMainPanel().getCurrentScrollPane().getViewport().validate();
1656 final double x = ( sb.getMaximum() - sb.getMinimum() )
1657 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1658 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1659 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1660 getMainPanel().adjustJScrollPane();
1661 treepanel.resetPreferredSize();
1662 getMainPanel().getCurrentScrollPane().getViewport().validate();
1663 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1664 - ( sb.getVisibleAmount() / 2.0 ) ) );
1667 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1668 treepanel.setXdistance( treepanel.getXdistance() * factor );
1669 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
1671 getMainPanel().adjustJScrollPane();
1672 treepanel.resetPreferredSize();
1673 getMainPanel().getCurrentScrollPane().getViewport().validate();
1674 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1677 treepanel.resetPreferredSize();
1678 treepanel.updateOvSizes();
1682 void zoomOutY( final float factor ) {
1683 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1684 treepanel.multiplyUrtFactor( 0.9f );
1685 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1686 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1687 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1688 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1689 getMainPanel().adjustJScrollPane();
1690 treepanel.resetPreferredSize();
1691 getMainPanel().getCurrentScrollPane().getViewport().validate();
1692 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1693 - ( sb.getVisibleAmount() / 2.0 ) ) );
1694 treepanel.resetPreferredSize();
1695 treepanel.updateOvSizes();
1699 private void addClickToOption( final int which, final String title ) {
1700 _click_to_combobox.addItem( title );
1701 _click_to_names.add( title );
1702 _all_click_to_names.put( new Integer( which ), title );
1703 if ( !_configuration.isUseNativeUI() ) {
1704 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1705 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
1710 private void addSequenceRelationBlock() {
1711 final JLabel spacer = new JLabel( "" );
1712 spacer.setSize( 1, 1 );
1714 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
1715 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
1716 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
1717 getSequenceRelationTypeBox().setFocusable( false );
1718 _sequence_relation_type_box.setFont( ControlPanel.js_font );
1719 if ( !_configuration.isUseNativeUI() ) {
1720 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1721 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
1723 _sequence_relation_type_box.setRenderer( new ListCellRenderer<Object>() {
1726 public Component getListCellRendererComponent( final JList<?> list,
1729 final boolean isSelected,
1730 final boolean cellHasFocus ) {
1731 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
1736 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
1737 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
1738 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
1743 final GridBagLayout gbl = new GridBagLayout();
1744 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
1745 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
1746 final JPanel horizGrid = new JPanel( gbl );
1747 horizGrid.setBackground( getBackground() );
1748 horizGrid.add( typeLabel );
1749 horizGrid.add( _sequence_relation_type_box );
1750 add( customizeLabel( mainLabel, getConfiguration() ) );
1752 add( getSequenceRelationBox() );
1753 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
1754 addCheckbox( Configuration.show_relation_confidence,
1755 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
1756 setCheckbox( Configuration.show_relation_confidence,
1757 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
1759 }// addSequenceRelationBlock
1762 private List<Boolean> getIsDrawPhylogramList() {
1763 return _draw_phylogram;
1766 private void init() {
1767 _draw_phylogram = new ArrayList<Boolean>();
1768 setSpeciesColors( new HashMap<String, Color>() );
1769 setSequenceColors( new HashMap<String, Color>() );
1770 setAnnotationColors( new HashMap<String, Color>() );
1773 private boolean isDrawPhylogram( final int index ) {
1774 return getIsDrawPhylogramList().get( index );
1777 private void search0( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
1778 getSearchFoundCountsLabel0().setVisible( true );
1779 getSearchResetButton0().setEnabled( true );
1780 getSearchResetButton0().setVisible( true );
1781 String[] queries = null;
1782 List<PhylogenyNode> nodes = null;
1783 if ( query_str.indexOf( ',' ) >= 0 ) {
1784 queries = query_str.split( ",+" );
1787 queries = new String[ 1 ];
1788 queries[ 0 ] = query_str.trim();
1790 if ( ( queries != null ) && ( queries.length > 0 ) ) {
1791 nodes = new ArrayList<PhylogenyNode>();
1792 for( String query : queries ) {
1793 if ( ForesterUtil.isEmpty( query ) ) {
1796 query = query.trim();
1797 if ( query.indexOf( '+' ) >= 0 ) {
1798 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
1800 getOptions().isSearchCaseSensitive(),
1801 !getOptions().isMatchWholeTermsOnly(),
1802 isShowDomainArchitectures() ) );
1805 nodes.addAll( PhylogenyMethods.searchData( query,
1807 getOptions().isSearchCaseSensitive(),
1808 !getOptions().isMatchWholeTermsOnly(),
1809 isShowDomainArchitectures() ) );
1812 if ( getOptions().isInverseSearchResult() ) {
1813 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
1814 all.removeAll( nodes );
1818 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
1819 main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet<Long>() );
1820 for( final PhylogenyNode node : nodes ) {
1821 main_panel.getCurrentTreePanel().getFoundNodes0().add( node.getId() );
1823 setSearchFoundCountsOnLabel0( nodes.size() );
1826 setSearchFoundCountsOnLabel0( 0 );
1831 private void search1( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
1832 getSearchFoundCountsLabel1().setVisible( true );
1833 getSearchResetButton1().setEnabled( true );
1834 getSearchResetButton1().setVisible( true );
1835 String[] queries = null;
1836 List<PhylogenyNode> nodes = null;
1837 if ( query_str.indexOf( ',' ) >= 0 ) {
1838 queries = query_str.split( ",+" );
1841 queries = new String[ 1 ];
1842 queries[ 0 ] = query_str.trim();
1844 if ( ( queries != null ) && ( queries.length > 0 ) ) {
1845 nodes = new ArrayList<PhylogenyNode>();
1846 for( String query : queries ) {
1847 if ( ForesterUtil.isEmpty( query ) ) {
1850 query = query.trim();
1851 if ( query.indexOf( '+' ) >= 0 ) {
1852 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
1854 getOptions().isSearchCaseSensitive(),
1855 !getOptions().isMatchWholeTermsOnly(),
1856 isShowDomainArchitectures() ) );
1859 nodes.addAll( PhylogenyMethods.searchData( query,
1861 getOptions().isSearchCaseSensitive(),
1862 !getOptions().isMatchWholeTermsOnly(),
1863 isShowDomainArchitectures() ) );
1866 if ( getOptions().isInverseSearchResult() ) {
1867 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
1868 all.removeAll( nodes );
1872 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
1873 main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet<Long>() );
1874 for( final PhylogenyNode node : nodes ) {
1875 main_panel.getCurrentTreePanel().getFoundNodes1().add( node.getId() );
1877 setSearchFoundCountsOnLabel1( nodes.size() );
1880 setSearchFoundCountsOnLabel1( 0 );
1885 private void setDrawPhylogram( final int index, final boolean b ) {
1886 getIsDrawPhylogramList().set( index, b );
1889 private void setupClickToOptions() {
1890 final int default_option = _configuration.getDefaultDisplayClicktoOption();
1891 int selected_index = 0;
1893 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1894 _show_data_item = cb_index;
1895 addClickToOption( Configuration.display_node_data,
1896 _configuration.getClickToTitle( Configuration.display_node_data ) );
1897 if ( default_option == Configuration.display_node_data ) {
1898 selected_index = cb_index;
1902 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1903 _collapse_cb_item = cb_index;
1904 addClickToOption( Configuration.collapse_uncollapse,
1905 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
1906 if ( default_option == Configuration.collapse_uncollapse ) {
1907 selected_index = cb_index;
1911 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1912 _reroot_cb_item = cb_index;
1913 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1914 if ( default_option == Configuration.reroot ) {
1915 selected_index = cb_index;
1919 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1920 _subtree_cb_item = cb_index;
1921 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1922 if ( default_option == Configuration.subtree ) {
1923 selected_index = cb_index;
1927 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1928 _swap_cb_item = cb_index;
1929 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1930 if ( default_option == Configuration.swap ) {
1931 selected_index = cb_index;
1935 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
1936 _sort_descendents_item = cb_index;
1937 addClickToOption( Configuration.sort_descendents,
1938 _configuration.getClickToTitle( Configuration.sort_descendents ) );
1939 if ( default_option == Configuration.sort_descendents ) {
1940 selected_index = cb_index;
1944 if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) {
1945 _color_node_font_item = cb_index;
1946 addClickToOption( Configuration.color_node_font,
1947 _configuration.getClickToTitle( Configuration.color_node_font ) );
1948 if ( default_option == Configuration.color_node_font ) {
1949 selected_index = cb_index;
1953 if ( _configuration.doDisplayClickToOption( Configuration.change_node_font ) ) {
1954 _change_node_font_item = cb_index;
1955 addClickToOption( Configuration.change_node_font,
1956 _configuration.getClickToTitle( Configuration.change_node_font ) );
1957 if ( default_option == Configuration.change_node_font ) {
1958 selected_index = cb_index;
1962 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1963 _color_subtree_cb_item = cb_index;
1964 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1965 if ( default_option == Configuration.color_subtree ) {
1966 selected_index = cb_index;
1970 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1971 _open_seq_web_item = cb_index;
1972 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1973 if ( default_option == Configuration.open_seq_web ) {
1974 selected_index = cb_index;
1978 if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
1979 _open_pdb_item = cb_index;
1980 addClickToOption( Configuration.open_pdb_web, _configuration.getClickToTitle( Configuration.open_pdb_web ) );
1981 if ( default_option == Configuration.open_pdb_web ) {
1982 selected_index = cb_index;
1986 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1987 _open_tax_web_item = cb_index;
1988 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1989 if ( default_option == Configuration.open_tax_web ) {
1990 selected_index = cb_index;
1994 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1995 _blast_item = cb_index;
1996 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
1997 if ( default_option == Configuration.blast ) {
1998 selected_index = cb_index;
2002 if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
2003 _select_nodes_item = cb_index;
2004 addClickToOption( Configuration.select_nodes, _configuration.getClickToTitle( Configuration.select_nodes ) );
2005 if ( default_option == Configuration.select_nodes ) {
2006 selected_index = cb_index;
2010 if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
2011 _get_ext_desc_data = cb_index;
2012 if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
2013 addClickToOption( Configuration.get_ext_desc_data, getConfiguration()
2014 .getLabelForGetExtDescendentsData() );
2018 switch ( getConfiguration().getExtDescNodeDataToReturn() ) {
2023 s = "Sequence Accessors";
2025 case SEQUENCE_MOL_SEQ:
2026 s = "Molecular Sequence";
2028 case SEQUENCE_MOL_SEQ_FASTA:
2029 s = "Molecular Sequence (Fasta)";
2032 s = "Sequence Names";
2037 case SEQUENCE_SYMBOL:
2038 s = "Sequence Symbols";
2041 s = "Taxonomy Codes";
2043 case TAXONOMY_COMM0N_NAME:
2044 s = "Taxonomy Common Names";
2046 case TAXONOMY_SCIENTIFIC_NAME:
2047 s = "Scientific Names";
2050 s = "User Selected Data";
2053 throw new IllegalStateException( "dont know how to deal with "
2054 + getConfiguration().getExtDescNodeDataToReturn() );
2056 final String label = _configuration.getClickToTitle( Configuration.get_ext_desc_data ) + " " + s;
2057 addClickToOption( Configuration.get_ext_desc_data, label );
2059 if ( default_option == Configuration.get_ext_desc_data ) {
2060 selected_index = cb_index;
2064 if ( getOptions().isEditable() ) {
2065 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
2066 _cut_subtree_item = cb_index;
2067 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
2068 if ( default_option == Configuration.cut_subtree ) {
2069 selected_index = cb_index;
2073 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
2074 _copy_subtree_item = cb_index;
2075 addClickToOption( Configuration.copy_subtree,
2076 _configuration.getClickToTitle( Configuration.copy_subtree ) );
2077 if ( default_option == Configuration.copy_subtree ) {
2078 selected_index = cb_index;
2082 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
2083 _paste_subtree_item = cb_index;
2084 addClickToOption( Configuration.paste_subtree,
2085 _configuration.getClickToTitle( Configuration.paste_subtree ) );
2086 if ( default_option == Configuration.paste_subtree ) {
2087 selected_index = cb_index;
2091 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
2092 _delete_node_or_subtree_item = cb_index;
2093 addClickToOption( Configuration.delete_subtree_or_node,
2094 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
2095 if ( default_option == Configuration.delete_subtree_or_node ) {
2096 selected_index = cb_index;
2100 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
2101 _add_new_node_item = cb_index;
2102 addClickToOption( Configuration.add_new_node,
2103 _configuration.getClickToTitle( Configuration.add_new_node ) );
2104 if ( default_option == Configuration.add_new_node ) {
2105 selected_index = cb_index;
2109 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
2110 _edit_node_data_item = cb_index;
2111 addClickToOption( Configuration.edit_node_data,
2112 _configuration.getClickToTitle( Configuration.edit_node_data ) );
2113 if ( default_option == Configuration.edit_node_data ) {
2114 selected_index = cb_index;
2119 // Set default selection and its action
2120 _click_to_combobox.setSelectedIndex( selected_index );
2121 setClickToAction( selected_index );
2124 private void setupDisplayCheckboxes() {
2125 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
2126 addCheckbox( Configuration.display_as_phylogram,
2127 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
2128 setCheckbox( Configuration.display_as_phylogram,
2129 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
2131 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
2132 addCheckbox( Configuration.dynamically_hide_data,
2133 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
2134 setCheckbox( Configuration.dynamically_hide_data,
2135 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
2137 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
2138 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
2139 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
2141 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
2142 addCheckbox( Configuration.display_internal_data,
2143 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
2144 setCheckbox( Configuration.display_internal_data,
2145 _configuration.doCheckOption( Configuration.display_internal_data ) );
2147 if ( _configuration.doDisplayOption( Configuration.color_according_to_sequence ) ) {
2148 addCheckbox( Configuration.color_according_to_sequence,
2149 _configuration.getDisplayTitle( Configuration.color_according_to_sequence ) );
2150 setCheckbox( Configuration.color_according_to_sequence,
2151 _configuration.doCheckOption( Configuration.color_according_to_sequence ) );
2153 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
2154 addCheckbox( Configuration.color_according_to_species,
2155 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
2156 setCheckbox( Configuration.color_according_to_species,
2157 _configuration.doCheckOption( Configuration.color_according_to_species ) );
2159 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
2160 addCheckbox( Configuration.color_according_to_annotation,
2161 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
2162 setCheckbox( Configuration.color_according_to_annotation,
2163 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
2165 if ( _configuration.doDisplayOption( Configuration.use_style ) ) {
2166 addCheckbox( Configuration.use_style, _configuration.getDisplayTitle( Configuration.use_style ) );
2167 setCheckbox( Configuration.use_style, _configuration.doCheckOption( Configuration.use_style ) );
2169 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
2170 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
2171 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
2173 final JLabel label = new JLabel( "Display Data:" );
2174 label.setFont( ControlPanel.jcb_bold_font );
2175 if ( !getConfiguration().isUseNativeUI() ) {
2176 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2179 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
2180 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
2181 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
2183 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
2184 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
2185 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
2187 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
2188 addCheckbox( Configuration.show_taxonomy_scientific_names,
2189 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
2190 setCheckbox( Configuration.show_taxonomy_scientific_names,
2191 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
2193 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
2194 addCheckbox( Configuration.show_taxonomy_common_names,
2195 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
2196 setCheckbox( Configuration.show_taxonomy_common_names,
2197 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
2199 if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
2200 addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
2201 setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
2203 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
2204 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
2205 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
2207 if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
2208 addCheckbox( Configuration.show_seq_symbols,
2209 _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
2210 setCheckbox( Configuration.show_seq_symbols, _configuration.doCheckOption( Configuration.show_seq_symbols ) );
2212 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
2213 addCheckbox( Configuration.show_sequence_acc,
2214 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
2215 setCheckbox( Configuration.show_sequence_acc,
2216 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
2218 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
2219 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
2220 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
2222 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
2223 addCheckbox( Configuration.show_binary_characters,
2224 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
2225 setCheckbox( Configuration.show_binary_characters,
2226 _configuration.doCheckOption( Configuration.show_binary_characters ) );
2228 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
2229 addCheckbox( Configuration.show_binary_character_counts,
2230 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
2231 setCheckbox( Configuration.show_binary_character_counts,
2232 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
2234 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
2235 addCheckbox( Configuration.show_domain_architectures,
2236 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
2237 setCheckbox( Configuration.show_domain_architectures,
2238 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
2240 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
2241 addCheckbox( Configuration.write_confidence_values,
2242 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
2243 setCheckbox( Configuration.write_confidence_values,
2244 _configuration.doCheckOption( Configuration.write_confidence_values ) );
2246 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
2247 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
2248 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
2250 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
2251 addCheckbox( Configuration.show_vector_data,
2252 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
2253 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
2255 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
2256 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
2257 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
2259 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
2260 addCheckbox( Configuration.show_taxonomy_images,
2261 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
2262 setCheckbox( Configuration.show_taxonomy_images,
2263 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
2267 private void setVisibilityOfDomainStrucureControls() {
2268 if ( _zoom_in_domain_structure != null ) {
2269 if ( isShowDomainArchitectures() ) {
2270 _domain_display_label.setVisible( true );
2271 _zoom_in_domain_structure.setVisible( true );
2272 _zoom_out_domain_structure.setVisible( true );
2273 _decr_domain_structure_evalue_thr.setVisible( true );
2274 _incr_domain_structure_evalue_thr.setVisible( true );
2275 _domain_structure_evalue_thr_tf.setVisible( true );
2278 _domain_display_label.setVisible( false );
2279 _zoom_in_domain_structure.setVisible( false );
2280 _zoom_out_domain_structure.setVisible( false );
2281 _decr_domain_structure_evalue_thr.setVisible( false );
2282 _incr_domain_structure_evalue_thr.setVisible( false );
2283 _domain_structure_evalue_thr_tf.setVisible( false );
2288 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2289 label.setFont( ControlPanel.jcb_bold_font );
2290 if ( !configuration.isUseNativeUI() ) {
2291 label.setForeground( configuration.getGuiCheckboxTextColor() );
2292 label.setBackground( configuration.getGuiBackgroundColor() );
2297 enum NodeClickAction {
2304 DELETE_NODE_OR_SUBTREE,