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: www.phylosoft.org/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 private static final String RETURN_TO_SUPER_TREE_TEXT = "Back to Super Tree";
74 final static Font jcb_font = new Font( Configuration.getDefaultFontFamilyName(),
77 final static Font js_font = new Font( Configuration.getDefaultFontFamilyName(),
80 final static Font jcb_bold_font = new Font( Configuration.getDefaultFontFamilyName(),
83 private static final long serialVersionUID = -8463483932821545633L;
84 private final MainPanel _mainpanel;
85 // The settings from the conf file
86 private final Configuration _configuration;
88 private JCheckBox _display_internal_data;
89 private JCheckBox _show_node_names;
90 private JCheckBox _show_taxo_code;
91 private JCheckBox _write_confidence;
92 private JCheckBox _show_events;
93 private JCheckBox _color_acc_species;
94 private JCheckBox _color_branches_cb;
95 private JCheckBox _width_branches;
96 private JCheckBox _show_domain_architectures;
97 private JCheckBox _show_annotation;
98 private JCheckBox _show_binary_characters;
99 private JCheckBox _show_binary_character_counts;
100 private JCheckBox _show_gene_names;
101 private JCheckBox _show_gene_symbols;
102 private JCheckBox _show_sequence_acc;
103 private JCheckBox _node_desc_popup_cb;
104 private JCheckBox _dynamically_hide_data;
105 private JCheckBox _show_taxo_scientific_names;
106 private JCheckBox _show_taxo_common_names;
107 private JCheckBox _show_taxo_images_cb;
108 private JCheckBox _color_according_to_annotation;
109 private JCheckBox _display_as_phylogram_cb;
110 private JCheckBox _seq_relation_confidence_switch;
111 private JComboBox _show_sequence_relations;
112 private JComboBox _sequence_relation_type_box;
113 private JCheckBox _show_vector_data_cb;
114 private JCheckBox _show_properties_cb;
115 private JLabel _click_to_label;
116 private JLabel _zoom_label;
117 private JLabel _domain_display_label;
118 private JComboBox _click_to_combobox;
119 private Map<Integer, String> _all_click_to_names;
120 private List<String> _click_to_names;
121 // Indices for the click-to options in the combo box
122 private int _show_data_item;
123 private int _collapse_cb_item;
124 private int _reroot_cb_item;
125 private int _swap_cb_item;
126 private int _subtree_cb_item;
127 private int _color_subtree_cb_item;
128 private int _open_seq_web_item;
129 private int _sort_descendents_item;
130 private int _open_tax_web_item;
131 private int _cut_subtree_item;
132 private int _copy_subtree_item;
133 private int _delete_node_or_subtree_item;
134 private int _paste_subtree_item;
135 private int _add_new_node_item;
136 private int _edit_node_data_item;
137 private int _select_nodes_item;
138 private int _get_ext_desc_data;
139 private int _blast_item;
140 // zooming and quick tree manipulation buttons:
141 private JButton _zoom_in_x;
142 private JButton _zoom_in_y;
143 private JButton _zoom_out_x;
144 private JButton _zoom_out_y;
145 private JButton _show_whole;
146 private JButton _order;
147 private JButton _uncollapse_all;
148 private JButton _zoom_in_domain_structure;
149 private JButton _zoom_out_domain_structure;
150 private JButton _decr_domain_structure_evalue_thr;
151 private JButton _incr_domain_structure_evalue_thr;
152 private JButton _return_to_super_tree;
153 private JTextField _domain_structure_evalue_thr_tf;
154 private JTextField _search_tf;
155 private boolean _order_of_appearance;
156 private boolean _color_branches;
157 private NodeClickAction _action_when_node_clicked;
158 private List<Boolean> _draw_phylogram;
159 private Map<String, Color> _annotation_colors;
160 private Map<String, Color> _species_colors;
161 private JButton _search_reset_button;
162 private JLabel _search_found_label;
163 private Sequence _selected_query_seq;
165 ControlPanel( final MainPanel ap, final Configuration configuration ) {
168 _configuration = configuration;
169 if ( !_configuration.isUseNativeUI() ) {
170 setBackground( getConfiguration().getGuiBackgroundColor() );
171 setBorder( BorderFactory.createRaisedBevelBorder() );
173 setLayout( new GridLayout( 0, 1, 2, 2 ) );
174 _order_of_appearance = true;
182 public void actionPerformed( final ActionEvent e ) {
184 final TreePanel tp = getMainPanel().getCurrentTreePanel();
188 if ( e.getSource() == _click_to_combobox ) {
189 setClickToAction( _click_to_combobox.getSelectedIndex() );
190 getCurrentTreePanel().repaint();
192 else if ( e.getSource() == _show_binary_characters ) {
193 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
194 _show_binary_character_counts.setSelected( false );
196 displayedPhylogenyMightHaveChanged( true );
198 else if ( e.getSource() == _show_binary_character_counts ) {
199 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
200 _show_binary_characters.setSelected( false );
202 displayedPhylogenyMightHaveChanged( true );
204 else if ( e.getSource() == _color_according_to_annotation ) {
205 if ( ( _show_annotation != null ) && _color_according_to_annotation.isSelected() ) {
206 _show_annotation.setSelected( true );
208 displayedPhylogenyMightHaveChanged( false );
210 else if ( e.getSource() == _show_annotation ) {
211 if ( ( _color_according_to_annotation != null ) && !_show_annotation.isSelected() ) {
212 _color_according_to_annotation.setSelected( false );
214 displayedPhylogenyMightHaveChanged( false );
216 else if ( e.getSource() == _show_domain_architectures ) {
218 displayedPhylogenyMightHaveChanged( false );
220 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
221 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
222 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
226 else if ( e.getSource() == _zoom_in_x ) {
227 zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
228 displayedPhylogenyMightHaveChanged( false );
230 else if ( e.getSource() == _zoom_in_y ) {
231 zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR );
232 displayedPhylogenyMightHaveChanged( false );
234 else if ( e.getSource() == _zoom_out_x ) {
235 zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
236 displayedPhylogenyMightHaveChanged( false );
238 else if ( e.getSource() == _zoom_out_y ) {
239 zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR );
240 displayedPhylogenyMightHaveChanged( false );
242 else if ( e.getSource() == _show_whole ) {
245 else if ( e.getSource() == _return_to_super_tree ) {
246 _mainpanel.getCurrentTreePanel().superTree();
249 else if ( e.getSource() == _order ) {
250 DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
251 if ( ( !isShowTaxonomyScientificNames() && !isShowTaxonomyCode() && !isShowTaxonomyCommonNames() ) ) {
252 if ( ( isShowSequenceAcc() || isShowGeneNames() || isShowGeneSymbols() ) ) {
253 pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
255 else if ( isShowNodeNames() ) {
256 pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
259 PhylogenyMethods.orderAppearance( tp.getPhylogeny().getRoot(), _order_of_appearance, true, pri );
260 _order_of_appearance = !_order_of_appearance;
261 tp.setNodeInPreorderToNull();
262 tp.getPhylogeny().externalNodesHaveChanged();
263 tp.getPhylogeny().clearHashIdToNodeMap();
264 tp.getPhylogeny().recalculateNumberOfExternalDescendants( true );
265 tp.resetNodeIdToDistToLeafMap();
266 tp.setEdited( true );
267 displayedPhylogenyMightHaveChanged( false );
269 else if ( e.getSource() == _uncollapse_all ) {
271 displayedPhylogenyMightHaveChanged( false );
273 else if ( e.getSource() == _zoom_in_domain_structure ) {
274 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
275 displayedPhylogenyMightHaveChanged( true );
277 else if ( e.getSource() == _zoom_out_domain_structure ) {
278 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
279 displayedPhylogenyMightHaveChanged( true );
281 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
282 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThreshold();
283 displayedPhylogenyMightHaveChanged( true );
285 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
286 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThreshold();
287 displayedPhylogenyMightHaveChanged( true );
289 else if ( e.getSource() == _search_tf ) {
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 void activateButtonToReturnToSuperTree( int index ) {
312 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
315 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
317 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
318 _return_to_super_tree.setEnabled( true );
322 * Add zoom and quick edit buttons. (Last modified 8/9/04)
325 final JLabel spacer = new JLabel( "" );
326 spacer.setOpaque( false );
328 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
329 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
330 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
331 if ( !getConfiguration().isUseNativeUI() ) {
332 x_panel.setBackground( getBackground() );
333 y_panel.setBackground( getBackground() );
334 z_panel.setBackground( getBackground() );
336 add( _zoom_label = new JLabel( "Zoom:" ) );
337 customizeLabel( _zoom_label, getConfiguration() );
341 if ( getConfiguration().isUseNativeUI() ) {
342 _zoom_in_x = new JButton( "+" );
343 _zoom_out_x = new JButton( "-" );
346 _zoom_in_x = new JButton( "X+" );
347 _zoom_out_x = new JButton( "X-" );
349 _zoom_in_y = new JButton( "Y+" );
350 _zoom_out_y = new JButton( "Y-" );
351 _show_whole = new JButton( "F" );
352 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [Backspace]" );
353 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+Right]" );
354 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+Up]" );
355 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+Left]" );
356 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+Down]" );
357 if ( getConfiguration().isUseNativeUI() && AptxUtil.isMac() ) {
358 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
359 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
362 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
363 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
365 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
366 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
367 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
368 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
369 _return_to_super_tree.setEnabled( false );
370 _order = new JButton( "Order Subtrees" );
371 _uncollapse_all = new JButton( "Uncollapse All" );
372 addJButton( _zoom_in_y, x_panel );
373 addJButton( _zoom_out_x, y_panel );
374 addJButton( _show_whole, y_panel );
375 addJButton( _zoom_in_x, y_panel );
376 addJButton( _zoom_out_y, z_panel );
377 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
378 setUpControlsForDomainStrucures();
380 final JLabel spacer2 = new JLabel( "" );
382 addJButton( _return_to_super_tree, this );
383 addJButton( _order, this );
384 addJButton( _uncollapse_all, this );
385 final JLabel spacer3 = new JLabel( "" );
387 setVisibilityOfDomainStrucureControls();
390 void addCheckbox( final int which, final String title ) {
391 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
393 case Configuration.display_as_phylogram:
394 _display_as_phylogram_cb = new JCheckBox( title );
395 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
396 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
399 case Configuration.display_internal_data:
400 _display_internal_data = new JCheckBox( title );
401 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
402 addJCheckBox( _display_internal_data, ch_panel );
405 case Configuration.color_according_to_species:
406 _color_acc_species = new JCheckBox( title );
408 .setToolTipText( "To colorize taxonomy and sequence labels as a function of taxonomy" );
409 addJCheckBox( _color_acc_species, ch_panel );
412 case Configuration.color_according_to_annotation:
413 _color_according_to_annotation = new JCheckBox( title );
414 _color_according_to_annotation
415 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
416 addJCheckBox( _color_according_to_annotation, ch_panel );
419 case Configuration.show_node_names:
420 _show_node_names = new JCheckBox( title );
421 addJCheckBox( _show_node_names, ch_panel );
424 case Configuration.show_taxonomy_scientific_names:
425 _show_taxo_scientific_names = new JCheckBox( title );
426 addJCheckBox( _show_taxo_scientific_names, ch_panel );
429 case Configuration.show_taxonomy_common_names:
430 _show_taxo_common_names = new JCheckBox( title );
431 addJCheckBox( _show_taxo_common_names, ch_panel );
434 case Configuration.show_tax_code:
435 _show_taxo_code = new JCheckBox( title );
436 addJCheckBox( _show_taxo_code, ch_panel );
439 case Configuration.show_taxonomy_images:
440 _show_taxo_images_cb = new JCheckBox( title );
441 addJCheckBox( _show_taxo_images_cb, ch_panel );
444 case Configuration.show_binary_characters:
445 _show_binary_characters = new JCheckBox( title );
446 addJCheckBox( _show_binary_characters, ch_panel );
449 case Configuration.show_annotation:
450 _show_annotation = new JCheckBox( title );
451 addJCheckBox( _show_annotation, ch_panel );
454 case Configuration.show_binary_character_counts:
455 _show_binary_character_counts = new JCheckBox( title );
456 addJCheckBox( _show_binary_character_counts, ch_panel );
459 case Configuration.write_confidence_values:
460 _write_confidence = new JCheckBox( title );
461 addJCheckBox( getWriteConfidenceCb(), ch_panel );
464 case Configuration.write_events:
465 _show_events = new JCheckBox( title );
466 addJCheckBox( getShowEventsCb(), ch_panel );
469 case Configuration.color_branches:
470 _color_branches_cb = new JCheckBox( title );
471 getColorBranchesCb().setToolTipText( "To use branch color values, if present" );
472 addJCheckBox( getColorBranchesCb(), ch_panel );
475 case Configuration.width_branches:
476 _width_branches = new JCheckBox( title );
477 _width_branches.setToolTipText( "To use branch width values, if present" );
478 addJCheckBox( _width_branches, ch_panel );
481 case Configuration.show_domain_architectures:
482 _show_domain_architectures = new JCheckBox( title );
483 addJCheckBox( _show_domain_architectures, ch_panel );
486 case Configuration.show_gene_names:
487 _show_gene_names = new JCheckBox( title );
488 addJCheckBox( _show_gene_names, ch_panel );
491 case Configuration.show_gene_symbols:
492 _show_gene_symbols = new JCheckBox( title );
493 addJCheckBox( _show_gene_symbols, ch_panel );
496 case Configuration.show_sequence_acc:
497 _show_sequence_acc = new JCheckBox( title );
498 addJCheckBox( _show_sequence_acc, ch_panel );
501 case Configuration.dynamically_hide_data:
502 _dynamically_hide_data = new JCheckBox( title );
503 getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" );
504 addJCheckBox( getDynamicallyHideData(), ch_panel );
507 case Configuration.node_data_popup:
508 _node_desc_popup_cb = new JCheckBox( title );
509 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
510 addJCheckBox( getNodeDescPopupCb(), ch_panel );
513 case Configuration.show_relation_confidence:
514 _seq_relation_confidence_switch = new JCheckBox( title );
515 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
518 case Configuration.show_vector_data:
519 _show_vector_data_cb = new JCheckBox( title );
520 addJCheckBox( _show_vector_data_cb, ch_panel );
523 case Configuration.show_properties:
524 _show_properties_cb = new JCheckBox( title );
525 addJCheckBox( _show_properties_cb, ch_panel );
529 throw new RuntimeException( "unknown checkbox: " + which );
533 private void addClickToOption( final int which, final String title ) {
534 _click_to_combobox.addItem( title );
535 _click_to_names.add( title );
536 _all_click_to_names.put( new Integer( which ), title );
537 if ( !_configuration.isUseNativeUI() ) {
538 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
539 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
543 void addJButton( final JButton jb, final JPanel p ) {
544 jb.setFocusPainted( false );
545 jb.setFont( ControlPanel.jcb_font );
546 if ( !_configuration.isUseNativeUI() ) {
547 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
548 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
549 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
552 jb.addActionListener( this );
555 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
556 jcb.setFocusPainted( false );
557 jcb.setFont( ControlPanel.jcb_font );
558 if ( !_configuration.isUseNativeUI() ) {
559 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
560 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
562 p.add( jcb, "Center" );
563 jcb.addActionListener( this );
566 void addJTextField( final JTextField tf, final JPanel p ) {
567 if ( !_configuration.isUseNativeUI() ) {
568 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
569 tf.setFont( ControlPanel.jcb_font );
572 tf.addActionListener( this );
576 private void addSequenceRelationBlock() {
577 final JLabel spacer = new JLabel( "" );
578 spacer.setSize( 1, 1 );
580 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
581 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
582 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
583 getSequenceRelationTypeBox().setFocusable( false );
584 _sequence_relation_type_box.setFont( ControlPanel.js_font );
585 if ( !_configuration.isUseNativeUI() ) {
586 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
587 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
589 _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
592 public Component getListCellRendererComponent( final JList list,
595 final boolean isSelected,
596 final boolean cellHasFocus ) {
597 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
602 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
603 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
604 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
609 final GridBagLayout gbl = new GridBagLayout();
610 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
611 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
612 final JPanel horizGrid = new JPanel( gbl );
613 horizGrid.setBackground( getBackground() );
614 horizGrid.add( typeLabel );
615 horizGrid.add( _sequence_relation_type_box );
616 add( customizeLabel( mainLabel, getConfiguration() ) );
618 add( getSequenceRelationBox() );
619 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
620 addCheckbox( Configuration.show_relation_confidence,
621 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
622 setCheckbox( Configuration.show_relation_confidence,
623 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
625 }// addSequenceRelationBlock
627 void deactivateButtonToReturnToSuperTree() {
628 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
629 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
630 _return_to_super_tree.setEnabled( false );
633 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
634 if ( ( _mainpanel != null )
635 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
636 if ( getOptions().isShowOverview() ) {
637 _mainpanel.getCurrentTreePanel().updateOvSizes();
639 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
640 setVisibilityOfDomainStrucureControls();
641 updateDomainStructureEvaluethresholdDisplay();
642 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
643 _mainpanel.getCurrentTreePanel().calcMaxDepth();
644 _mainpanel.adjustJScrollPane();
645 if ( recalc_longest_ext_node_info ) {
646 _mainpanel.getCurrentTreePanel().initNodeData();
647 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
649 _mainpanel.getCurrentTreePanel().repaint();
650 // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
654 void endClickToOptions() {
655 _click_to_combobox.addActionListener( this );
659 * Indicates what action should be execute when a node is clicked
661 * @return the click-on action
663 NodeClickAction getActionWhenNodeClicked() {
664 return _action_when_node_clicked;
667 Map<Integer, String> getAllClickToItems() {
668 return _all_click_to_names;
671 Map<String, Color> getAnnotationColors() {
672 return _annotation_colors;
675 public JCheckBox getColorBranchesCb() {
676 return _color_branches_cb;
679 public JCheckBox getColorAccSpeciesCb() {
680 return _color_acc_species;
683 Configuration getConfiguration() {
684 return _configuration;
687 TreePanel getCurrentTreePanel() {
688 return getMainPanel().getCurrentTreePanel();
691 public JCheckBox getDisplayAsPhylogramCb() {
692 return _display_as_phylogram_cb;
695 public JCheckBox getDynamicallyHideData() {
696 return _dynamically_hide_data;
700 private List<Boolean> getIsDrawPhylogramList() {
701 return _draw_phylogram;
704 MainPanel getMainPanel() {
708 public JCheckBox getNodeDescPopupCb() {
709 return _node_desc_popup_cb;
712 Options getOptions() {
713 return getMainPanel().getOptions();
716 private JLabel getSearchFoundCountsLabel() {
717 return _search_found_label;
720 private JButton getSearchResetButton() {
721 return _search_reset_button;
724 JTextField getSearchTextField() {
728 public Sequence getSelectedQuerySequence() {
729 return _selected_query_seq;
732 public JComboBox getSequenceRelationBox() {
733 if ( _show_sequence_relations == null ) {
734 _show_sequence_relations = new JComboBox();
735 _show_sequence_relations.setFocusable( false );
736 _show_sequence_relations.setMaximumRowCount( 20 );
737 _show_sequence_relations.setFont( ControlPanel.js_font );
738 if ( !_configuration.isUseNativeUI() ) {
739 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
740 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
742 _show_sequence_relations.addItem( "-----" );
743 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
745 return _show_sequence_relations;
749 public JComboBox getSequenceRelationTypeBox() {
750 if ( _sequence_relation_type_box == null ) {
751 _sequence_relation_type_box = new JComboBox();
752 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
753 _sequence_relation_type_box.addItem( type );
755 _sequence_relation_type_box.addActionListener( new ActionListener() {
758 public void actionPerformed( final ActionEvent e ) {
759 if ( _mainpanel.getCurrentPhylogeny() != null ) {
760 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
765 return _sequence_relation_type_box;
768 public JCheckBox getShowEventsCb() {
772 List<String> getSingleClickToNames() {
773 return _click_to_names;
776 Map<String, Color> getSpeciesColors() {
777 return _species_colors;
780 public JCheckBox getWriteConfidenceCb() {
781 return _write_confidence;
784 private void init() {
785 _draw_phylogram = new ArrayList<Boolean>();
786 setSpeciesColors( new HashMap<String, Color>() );
787 setAnnotationColors( new HashMap<String, Color>() );
790 boolean isAntialiasScreenText() {
794 boolean isColorAccordingToAnnotation() {
795 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
798 boolean isColorAccordingToTaxonomy() {
799 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
802 boolean isColorBranches() {
803 return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) );
806 boolean isDrawPhylogram() {
807 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
810 private boolean isDrawPhylogram( final int index ) {
811 return getIsDrawPhylogramList().get( index );
814 boolean isDynamicallyHideData() {
815 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
819 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
822 boolean isNodeDescPopup() {
823 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
826 boolean isShowAnnotation() {
827 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
830 boolean isShowBinaryCharacterCounts() {
831 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
834 boolean isShowBinaryCharacters() {
835 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
838 boolean isShowConfidenceValues() {
839 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
842 boolean isShowDomainArchitectures() {
843 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
846 boolean isShowGeneNames() {
847 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
850 public boolean isShowVectorData() {
851 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
854 public boolean isShowProperties() {
855 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
858 boolean isShowGeneSymbols() {
859 return ( ( _show_gene_symbols != null ) && _show_gene_symbols.isSelected() );
862 boolean isShowInternalData() {
863 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
866 boolean isShowNodeNames() {
867 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
870 boolean isShowSequenceAcc() {
871 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
874 boolean isShowSequenceRelationConfidence() {
875 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
878 boolean isShowSequenceRelations() {
879 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
882 boolean isShowTaxonomyCode() {
883 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
886 public boolean isShowTaxonomyImages() {
887 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
890 boolean isShowTaxonomyCommonNames() {
891 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
894 boolean isShowTaxonomyScientificNames() {
895 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
898 boolean isWidthBranches() {
899 return ( ( _width_branches != null ) && _width_branches.isSelected() );
902 void phylogenyAdded( final Configuration configuration ) {
903 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
906 void phylogenyRemoved( final int index ) {
907 getIsDrawPhylogramList().remove( index );
911 final MainPanel main_panel = getMainPanel();
912 final Phylogeny tree = main_panel.getCurrentPhylogeny();
913 if ( ( tree == null ) || tree.isEmpty() ) {
916 String query = getSearchTextField().getText();
917 if ( query != null ) {
918 query = query.trim();
921 getSearchFoundCountsLabel().setVisible( false );
922 getSearchResetButton().setEnabled( false );
923 getSearchResetButton().setVisible( false );
926 if ( !ForesterUtil.isEmpty( query ) ) {
927 search( main_panel, tree, query );
930 getSearchFoundCountsLabel().setVisible( false );
931 getSearchResetButton().setEnabled( false );
932 getSearchResetButton().setVisible( false );
937 private void search( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
938 getSearchFoundCountsLabel().setVisible( true );
939 getSearchResetButton().setEnabled( true );
940 getSearchResetButton().setVisible( true );
941 String[] queries = null;
942 List<PhylogenyNode> nodes = null;
943 if ( query_str.indexOf( ',' ) >= 0 ) {
944 queries = query_str.split( ",+" );
947 queries = new String[ 1 ];
948 queries[ 0 ] = query_str.trim();
950 if ( ( queries != null ) && ( queries.length > 0 ) ) {
951 nodes = new ArrayList<PhylogenyNode>();
952 for( String query : queries ) {
953 if ( ForesterUtil.isEmpty( query ) ) {
956 query = query.trim();
957 if ( query.indexOf( '+' ) >= 0 ) {
958 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
960 getOptions().isSearchCaseSensitive(),
961 !getOptions().isMatchWholeTermsOnly(),
962 isShowDomainArchitectures() ) );
965 nodes.addAll( PhylogenyMethods.searchData( query,
967 getOptions().isSearchCaseSensitive(),
968 !getOptions().isMatchWholeTermsOnly(),
969 isShowDomainArchitectures() ) );
972 if ( getOptions().isInverseSearchResult() ) {
973 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
974 all.removeAll( nodes );
978 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
979 main_panel.getCurrentTreePanel().setFoundNodes( new HashSet<Integer>() );
980 for( final PhylogenyNode node : nodes ) {
981 main_panel.getCurrentTreePanel().getFoundNodes().add( node.getId() );
983 setSearchFoundCountsOnLabel( nodes.size() );
986 setSearchFoundCountsOnLabel( 0 );
991 private void searchReset() {
992 if ( getMainPanel().getCurrentTreePanel() != null ) {
993 getMainPanel().getCurrentTreePanel().setFoundNodes( null );
997 void setActionWhenNodeClicked( final NodeClickAction action ) {
998 _action_when_node_clicked = action;
1001 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
1002 _annotation_colors = annotation_colors;
1005 void setCheckbox( final int which, final boolean state ) {
1007 case Configuration.display_as_phylogram:
1008 if ( getDisplayAsPhylogramCb() != null ) {
1009 getDisplayAsPhylogramCb().setSelected( state );
1012 case Configuration.display_internal_data:
1013 if ( _display_internal_data != null ) {
1014 _display_internal_data.setSelected( state );
1017 case Configuration.color_according_to_species:
1018 if ( _color_acc_species != null ) {
1019 _color_acc_species.setSelected( state );
1022 case Configuration.color_according_to_annotation:
1023 if ( _color_according_to_annotation != null ) {
1024 _color_according_to_annotation.setSelected( state );
1027 case Configuration.show_node_names:
1028 if ( _show_node_names != null ) {
1029 _show_node_names.setSelected( state );
1032 case Configuration.show_taxonomy_scientific_names:
1033 if ( _show_taxo_scientific_names != null ) {
1034 _show_taxo_scientific_names.setSelected( state );
1037 case Configuration.show_taxonomy_common_names:
1038 if ( _show_taxo_common_names != null ) {
1039 _show_taxo_common_names.setSelected( state );
1042 case Configuration.show_tax_code:
1043 if ( _show_taxo_code != null ) {
1044 _show_taxo_code.setSelected( state );
1047 case Configuration.show_taxonomy_images:
1048 if ( _show_taxo_images_cb != null ) {
1049 _show_taxo_images_cb.setSelected( state );
1052 case Configuration.show_annotation:
1053 if ( _show_annotation != null ) {
1054 _show_annotation.setSelected( state );
1057 case Configuration.show_binary_characters:
1058 if ( _show_binary_characters != null ) {
1059 _show_binary_characters.setSelected( state );
1062 case Configuration.show_binary_character_counts:
1063 if ( _show_binary_character_counts != null ) {
1064 _show_binary_character_counts.setSelected( state );
1067 case Configuration.write_confidence_values:
1068 if ( getWriteConfidenceCb() != null ) {
1069 getWriteConfidenceCb().setSelected( state );
1072 case Configuration.write_events:
1073 if ( getShowEventsCb() != null ) {
1074 getShowEventsCb().setSelected( state );
1077 case Configuration.color_branches:
1078 if ( getColorBranchesCb() != null ) {
1079 getColorBranchesCb().setSelected( state );
1082 case Configuration.width_branches:
1083 if ( _width_branches != null ) {
1084 _width_branches.setSelected( state );
1087 case Configuration.show_domain_architectures:
1088 if ( _show_domain_architectures != null ) {
1089 _show_domain_architectures.setSelected( state );
1092 case Configuration.show_gene_names:
1093 if ( _show_gene_names != null ) {
1094 _show_gene_names.setSelected( state );
1097 case Configuration.show_gene_symbols:
1098 if ( _show_gene_symbols != null ) {
1099 _show_gene_symbols.setSelected( state );
1102 case Configuration.show_vector_data:
1103 if ( _show_vector_data_cb != null ) {
1104 _show_vector_data_cb.setSelected( state );
1107 case Configuration.show_properties:
1108 if ( _show_properties_cb != null ) {
1109 _show_properties_cb.setSelected( state );
1112 case Configuration.show_sequence_acc:
1113 if ( _show_sequence_acc != null ) {
1114 _show_sequence_acc.setSelected( state );
1117 case Configuration.dynamically_hide_data:
1118 if ( getDynamicallyHideData() != null ) {
1119 getDynamicallyHideData().setSelected( state );
1122 case Configuration.node_data_popup:
1123 if ( getNodeDescPopupCb() != null ) {
1124 getNodeDescPopupCb().setSelected( state );
1128 case Configuration.show_relation_confidence:
1129 if ( _seq_relation_confidence_switch != null ) {
1130 _seq_relation_confidence_switch.setSelected( state );
1135 throw new AssertionError( "unknown checkbox: " + which );
1140 * Set this checkbox state. Not all checkboxes have been instantiated
1141 * depending on the config.
1143 void setCheckbox( final JCheckBox cb, final boolean state ) {
1145 cb.setSelected( state );
1149 void setClickToAction( final int action ) {
1150 // Set click-to action
1151 if ( action == _show_data_item ) {
1152 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1154 else if ( action == _collapse_cb_item ) {
1155 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1157 else if ( action == _reroot_cb_item ) {
1158 setActionWhenNodeClicked( NodeClickAction.REROOT );
1160 else if ( action == _subtree_cb_item ) {
1161 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1163 else if ( action == _swap_cb_item ) {
1164 setActionWhenNodeClicked( NodeClickAction.SWAP );
1166 else if ( action == _color_subtree_cb_item ) {
1167 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1169 else if ( action == _open_seq_web_item ) {
1170 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1172 else if ( action == _sort_descendents_item ) {
1173 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1175 else if ( action == _blast_item ) {
1176 setActionWhenNodeClicked( NodeClickAction.BLAST );
1178 else if ( action == _open_tax_web_item ) {
1179 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1181 else if ( action == _cut_subtree_item ) {
1182 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1184 else if ( action == _copy_subtree_item ) {
1185 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1187 else if ( action == _delete_node_or_subtree_item ) {
1188 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1190 else if ( action == _paste_subtree_item ) {
1191 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1193 else if ( action == _add_new_node_item ) {
1194 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1196 else if ( action == _edit_node_data_item ) {
1197 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1199 else if ( action == _select_nodes_item ) {
1200 setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
1202 else if ( action == _get_ext_desc_data ) {
1203 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
1206 throw new RuntimeException( "unknown action: " + action );
1208 // make sure drop down is displaying the correct action
1209 // in case this was called from outside the class
1210 _click_to_combobox.setSelectedIndex( action );
1213 void setColorBranches( final boolean color_branches ) {
1214 _color_branches = color_branches;
1217 void setDrawPhylogram( final boolean b ) {
1218 getDisplayAsPhylogramCb().setSelected( b );
1219 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1222 private void setDrawPhylogram( final int index, final boolean b ) {
1223 getIsDrawPhylogramList().set( index, b );
1226 void setDrawPhylogramEnabled( final boolean b ) {
1227 getDisplayAsPhylogramCb().setEnabled( b );
1230 void setDynamicHidingIsOn( final boolean is_on ) {
1231 // if ( !_configuration.isUseNativeUI() ) {
1233 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1236 if ( !_configuration.isUseNativeUI() ) {
1237 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1240 getDynamicallyHideData().setForeground( Color.BLACK );
1246 private void setSearchFoundCountsOnLabel( final int counts ) {
1247 getSearchFoundCountsLabel().setText( "Found: " + counts );
1250 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
1251 final JComboBox box = getSequenceRelationBox();
1252 while ( box.getItemCount() > 1 ) {
1253 box.removeItemAt( 1 );
1255 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
1256 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
1258 if ( relationType == null ) {
1261 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
1262 for( final Sequence seq : sequenceRelationQueries ) {
1263 if ( seq.hasSequenceRelations() ) {
1264 boolean fFoundForCurrentType = false;
1265 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
1266 if ( sq.getType().equals( relationType ) ) {
1267 fFoundForCurrentType = true;
1271 if ( fFoundForCurrentType ) {
1272 sequenceNamesToAdd.add( seq.getName() );
1273 sequencesByName.put( seq.getName(), seq );
1277 // sort sequences by name before adding them to the combo
1278 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
1279 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
1280 for( final String seqName : sequenceNameArray ) {
1281 box.addItem( seqName );
1283 for( final ItemListener oldItemListener : box.getItemListeners() ) {
1284 box.removeItemListener( oldItemListener );
1286 box.addItemListener( new ItemListener() {
1289 public void itemStateChanged( final ItemEvent e ) {
1290 _selected_query_seq = sequencesByName.get( e.getItem() );
1291 _mainpanel.getCurrentTreePanel().repaint();
1296 void setShowEvents( final boolean show_events ) {
1297 if ( getShowEventsCb() == null ) {
1298 _show_events = new JCheckBox( "" );
1300 getShowEventsCb().setSelected( show_events );
1303 void setSpeciesColors( final Map<String, Color> species_colors ) {
1304 _species_colors = species_colors;
1307 private void setupClickToOptions() {
1308 final int default_option = _configuration.getDefaultDisplayClicktoOption();
1309 int selected_index = 0;
1311 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1312 _show_data_item = cb_index;
1313 addClickToOption( Configuration.display_node_data,
1314 _configuration.getClickToTitle( Configuration.display_node_data ) );
1315 if ( default_option == Configuration.display_node_data ) {
1316 selected_index = cb_index;
1320 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1321 _collapse_cb_item = cb_index;
1322 addClickToOption( Configuration.collapse_uncollapse,
1323 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
1324 if ( default_option == Configuration.collapse_uncollapse ) {
1325 selected_index = cb_index;
1329 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1330 _reroot_cb_item = cb_index;
1331 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1332 if ( default_option == Configuration.reroot ) {
1333 selected_index = cb_index;
1337 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1338 _subtree_cb_item = cb_index;
1339 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1340 if ( default_option == Configuration.subtree ) {
1341 selected_index = cb_index;
1345 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1346 _swap_cb_item = cb_index;
1347 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1348 if ( default_option == Configuration.swap ) {
1349 selected_index = cb_index;
1353 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
1354 _sort_descendents_item = cb_index;
1355 addClickToOption( Configuration.sort_descendents,
1356 _configuration.getClickToTitle( Configuration.sort_descendents ) );
1357 if ( default_option == Configuration.sort_descendents ) {
1358 selected_index = cb_index;
1362 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1363 _color_subtree_cb_item = cb_index;
1364 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1365 if ( default_option == Configuration.color_subtree ) {
1366 selected_index = cb_index;
1370 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1371 _open_seq_web_item = cb_index;
1372 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1373 if ( default_option == Configuration.open_seq_web ) {
1374 selected_index = cb_index;
1378 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1379 _open_tax_web_item = cb_index;
1380 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1381 if ( default_option == Configuration.open_tax_web ) {
1382 selected_index = cb_index;
1386 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1387 _blast_item = cb_index;
1388 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
1389 if ( default_option == Configuration.blast ) {
1390 selected_index = cb_index;
1394 if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
1395 _get_ext_desc_data = cb_index;
1396 if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
1397 addClickToOption( Configuration.get_ext_desc_data, getConfiguration()
1398 .getLabelForGetExtDescendentsData() );
1402 switch ( getConfiguration().getExtDescNodeDataToReturn() ) {
1407 s = "Sequence Accessors";
1409 case SEQUENCE_MOL_SEQ:
1410 s = "Molecular Sequence";
1413 s = "Sequence Names";
1415 case SEQUENCE_SYMBOL:
1416 s = "Sequence Symbols";
1419 s = "Taxonomy Codes";
1421 case TAXONOMY_SCIENTIFIC_NAME:
1422 s = "Scientific Names";
1425 s = "User Selected Data";
1428 final String label = _configuration.getClickToTitle( Configuration.get_ext_desc_data ) + " " + s;
1429 addClickToOption( Configuration.get_ext_desc_data, label );
1431 if ( default_option == Configuration.get_ext_desc_data ) {
1432 selected_index = cb_index;
1436 if ( getOptions().isEditable() ) {
1437 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
1438 _cut_subtree_item = cb_index;
1439 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
1440 if ( default_option == Configuration.cut_subtree ) {
1441 selected_index = cb_index;
1445 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
1446 _copy_subtree_item = cb_index;
1447 addClickToOption( Configuration.copy_subtree,
1448 _configuration.getClickToTitle( Configuration.copy_subtree ) );
1449 if ( default_option == Configuration.copy_subtree ) {
1450 selected_index = cb_index;
1454 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
1455 _paste_subtree_item = cb_index;
1456 addClickToOption( Configuration.paste_subtree,
1457 _configuration.getClickToTitle( Configuration.paste_subtree ) );
1458 if ( default_option == Configuration.paste_subtree ) {
1459 selected_index = cb_index;
1463 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
1464 _delete_node_or_subtree_item = cb_index;
1465 addClickToOption( Configuration.delete_subtree_or_node,
1466 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
1467 if ( default_option == Configuration.delete_subtree_or_node ) {
1468 selected_index = cb_index;
1472 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
1473 _add_new_node_item = cb_index;
1474 addClickToOption( Configuration.add_new_node,
1475 _configuration.getClickToTitle( Configuration.add_new_node ) );
1476 if ( default_option == Configuration.add_new_node ) {
1477 selected_index = cb_index;
1481 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
1482 _edit_node_data_item = cb_index;
1483 addClickToOption( Configuration.edit_node_data,
1484 _configuration.getClickToTitle( Configuration.edit_node_data ) );
1485 if ( default_option == Configuration.edit_node_data ) {
1486 selected_index = cb_index;
1490 if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
1491 _select_nodes_item = cb_index;
1492 addClickToOption( Configuration.select_nodes,
1493 _configuration.getClickToTitle( Configuration.select_nodes ) );
1494 if ( default_option == Configuration.select_nodes ) {
1495 selected_index = cb_index;
1500 // Set default selection and its action
1501 _click_to_combobox.setSelectedIndex( selected_index );
1502 setClickToAction( selected_index );
1507 * Set up the controls from the config settings. 11/26/05
1509 void setupControls() {
1510 // The tree display options:
1511 setupDisplayCheckboxes();
1513 // The sequence relation query selection combo-box
1514 if ( _configuration.displaySequenceRelations() ) {
1515 addSequenceRelationBlock();
1519 startClickToOptions();
1520 setupClickToOptions();
1521 endClickToOptions();
1522 // Zoom and quick edit buttons
1527 void setUpControlsForDomainStrucures() {
1528 _domain_display_label = new JLabel( "Domain Display:" );
1529 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1530 add( _domain_display_label );
1531 _zoom_in_domain_structure = new JButton( "d+" );
1532 _zoom_out_domain_structure = new JButton( "d-" );
1533 _decr_domain_structure_evalue_thr = new JButton( "-" );
1534 _incr_domain_structure_evalue_thr = new JButton( "+" );
1535 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1536 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1537 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1538 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1539 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1540 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1541 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1542 _domain_structure_evalue_thr_tf.setEditable( false );
1543 if ( !getConfiguration().isUseNativeUI() ) {
1544 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1545 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1546 _domain_structure_evalue_thr_tf.setBorder( null );
1548 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1549 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1550 if ( !_configuration.isUseNativeUI() ) {
1551 d1_panel.setBackground( getBackground() );
1552 d2_panel.setBackground( getBackground() );
1556 addJButton( _zoom_out_domain_structure, d1_panel );
1557 addJButton( _zoom_in_domain_structure, d1_panel );
1558 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1559 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1560 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1563 private void setupDisplayCheckboxes() {
1564 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
1565 addCheckbox( Configuration.display_as_phylogram,
1566 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
1567 setCheckbox( Configuration.display_as_phylogram,
1568 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
1570 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1571 addCheckbox( Configuration.dynamically_hide_data,
1572 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
1573 setCheckbox( Configuration.dynamically_hide_data,
1574 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
1576 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1577 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1578 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1580 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1581 addCheckbox( Configuration.display_internal_data,
1582 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
1583 setCheckbox( Configuration.display_internal_data,
1584 _configuration.doCheckOption( Configuration.display_internal_data ) );
1586 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1587 addCheckbox( Configuration.color_according_to_species,
1588 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
1589 setCheckbox( Configuration.color_according_to_species,
1590 _configuration.doCheckOption( Configuration.color_according_to_species ) );
1592 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1593 addCheckbox( Configuration.color_according_to_annotation,
1594 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
1595 setCheckbox( Configuration.color_according_to_annotation,
1596 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
1598 if ( _configuration.doDisplayOption( Configuration.color_branches ) ) {
1599 addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) );
1600 setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) );
1602 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1603 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1604 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1606 final JLabel label = new JLabel( "Display Data:" );
1607 label.setFont( ControlPanel.jcb_bold_font );
1608 if ( !getConfiguration().isUseNativeUI() ) {
1609 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1612 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1613 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
1614 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1616 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1617 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1618 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1620 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1621 addCheckbox( Configuration.show_taxonomy_scientific_names,
1622 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1623 setCheckbox( Configuration.show_taxonomy_scientific_names,
1624 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1626 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1627 addCheckbox( Configuration.show_taxonomy_common_names,
1628 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1629 setCheckbox( Configuration.show_taxonomy_common_names,
1630 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1632 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1633 addCheckbox( Configuration.show_taxonomy_images,
1634 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1635 setCheckbox( Configuration.show_taxonomy_images,
1636 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1638 if ( _configuration.doDisplayOption( Configuration.show_gene_symbols ) ) {
1639 addCheckbox( Configuration.show_gene_symbols,
1640 _configuration.getDisplayTitle( Configuration.show_gene_symbols ) );
1641 setCheckbox( Configuration.show_gene_symbols,
1642 _configuration.doCheckOption( Configuration.show_gene_symbols ) );
1644 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1645 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1646 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1648 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1649 addCheckbox( Configuration.show_sequence_acc,
1650 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1651 setCheckbox( Configuration.show_sequence_acc,
1652 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1654 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1655 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
1656 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1658 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1659 addCheckbox( Configuration.show_binary_characters,
1660 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1661 setCheckbox( Configuration.show_binary_characters,
1662 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1664 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1665 addCheckbox( Configuration.show_binary_character_counts,
1666 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1667 setCheckbox( Configuration.show_binary_character_counts,
1668 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1670 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1671 addCheckbox( Configuration.show_domain_architectures,
1672 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1673 setCheckbox( Configuration.show_domain_architectures,
1674 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1676 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1677 addCheckbox( Configuration.write_confidence_values,
1678 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1679 setCheckbox( Configuration.write_confidence_values,
1680 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1682 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1683 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1684 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1686 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1687 addCheckbox( Configuration.show_vector_data,
1688 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1689 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
1691 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1692 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
1693 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1697 void setupSearchTools() {
1698 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1699 final JLabel search_label = new JLabel( "Search:" );
1700 search_label.setFont( ControlPanel.jcb_bold_font );
1701 if ( !getConfiguration().isUseNativeUI() ) {
1702 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1704 add( search_label );
1705 search_label.setToolTipText( tip );
1706 _search_found_label = new JLabel();
1707 getSearchFoundCountsLabel().setVisible( false );
1708 _search_found_label.setFont( ControlPanel.jcb_bold_font );
1709 if ( !getConfiguration().isUseNativeUI() ) {
1710 _search_found_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1712 _search_tf = new JTextField( 3 );
1713 _search_tf.setToolTipText( tip );
1714 _search_tf.setEditable( true );
1715 if ( !getConfiguration().isUseNativeUI() ) {
1716 _search_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1717 _search_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1718 _search_tf.setBorder( null );
1720 _search_reset_button = new JButton();
1721 getSearchResetButton().setText( "Reset" );
1722 getSearchResetButton().setEnabled( false );
1723 getSearchResetButton().setVisible( false );
1724 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1725 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1726 s_panel_1.setBackground( getBackground() );
1728 s_panel_2.setBackground( getBackground() );
1730 final KeyAdapter key_adapter = new KeyAdapter() {
1733 public void keyReleased( final KeyEvent key_event ) {
1735 displayedPhylogenyMightHaveChanged( true );
1738 final ActionListener action_listener = new ActionListener() {
1741 public void actionPerformed( final ActionEvent e ) {
1743 setSearchFoundCountsOnLabel( 0 );
1744 getSearchFoundCountsLabel().setVisible( false );
1745 getSearchTextField().setText( "" );
1746 getSearchResetButton().setEnabled( false );
1747 getSearchResetButton().setVisible( false );
1748 displayedPhylogenyMightHaveChanged( true );
1751 _search_reset_button.addActionListener( action_listener );
1752 _search_tf.addKeyListener( key_adapter );
1753 addJTextField( _search_tf, s_panel_1 );
1754 s_panel_2.add( _search_found_label );
1755 addJButton( _search_reset_button, s_panel_2 );
1758 private void setVisibilityOfDomainStrucureControls() {
1759 if ( _zoom_in_domain_structure != null ) {
1760 if ( isShowDomainArchitectures() ) {
1761 _domain_display_label.setVisible( true );
1762 _zoom_in_domain_structure.setVisible( true );
1763 _zoom_out_domain_structure.setVisible( true );
1764 _decr_domain_structure_evalue_thr.setVisible( true );
1765 _incr_domain_structure_evalue_thr.setVisible( true );
1766 _domain_structure_evalue_thr_tf.setVisible( true );
1769 _domain_display_label.setVisible( false );
1770 _zoom_in_domain_structure.setVisible( false );
1771 _zoom_out_domain_structure.setVisible( false );
1772 _decr_domain_structure_evalue_thr.setVisible( false );
1773 _incr_domain_structure_evalue_thr.setVisible( false );
1774 _domain_structure_evalue_thr_tf.setVisible( false );
1780 * Fit entire tree into window.
1783 if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
1786 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
1787 displayedPhylogenyMightHaveChanged( true );
1788 _mainpanel.getCurrentTreePanel().updateOvSettings();
1789 _mainpanel.getCurrentTreePanel().validate();
1790 _mainpanel.validate();
1791 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1792 _mainpanel.getSizeOfViewport().height,
1794 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1795 _mainpanel.adjustJScrollPane();
1796 _mainpanel.getCurrentTreePanel().repaint();
1797 _mainpanel.getCurrentTreePanel().validate();
1798 _mainpanel.validate();
1799 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1800 _mainpanel.getSizeOfViewport().height,
1802 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1803 _mainpanel.adjustJScrollPane();
1804 _mainpanel.getCurrentTreePanel().repaint();
1805 _mainpanel.getCurrentTreePanel().updateOvSizes();
1808 void showWholeAll() {
1809 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1810 if ( tree_panel != null ) {
1811 tree_panel.validate();
1812 tree_panel.setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1813 _mainpanel.getSizeOfViewport().height,
1815 tree_panel.resetPreferredSize();
1816 tree_panel.repaint();
1821 // Create header for click-to combo box.
1822 void startClickToOptions() {
1823 final JLabel spacer = new JLabel( "" );
1824 spacer.setFont( ControlPanel.jcb_font );
1826 _click_to_label = new JLabel( "Click on Node to:" );
1827 add( customizeLabel( _click_to_label, getConfiguration() ) );
1828 _click_to_combobox = new JComboBox();
1829 _click_to_combobox.setFocusable( false );
1830 _click_to_combobox.setMaximumRowCount( 14 );
1831 _click_to_combobox.setFont( ControlPanel.js_font );
1832 if ( !_configuration.isUseNativeUI() ) {
1833 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1835 // don't add listener until all items are set (or each one will trigger
1837 // click_to_list.addActionListener(this);
1838 add( _click_to_combobox );
1839 // Correlates option names to titles
1840 _all_click_to_names = new HashMap<Integer, String>();
1841 _click_to_names = new ArrayList<String>();
1845 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1846 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1847 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1848 setDrawPhylogramEnabled( true );
1849 setDrawPhylogram( isDrawPhylogram() );
1852 setDrawPhylogramEnabled( false );
1853 setDrawPhylogram( false );
1855 if ( getMainPanel().getMainFrame() == null ) {
1856 // Must be "E" applet version.
1857 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1858 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1861 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1862 .getPhylogenyGraphicsType() );
1864 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1865 getMainPanel().getControlPanel().search();
1866 getSequenceRelationTypeBox().removeAllItems();
1867 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1868 .getRelevantSequenceRelationTypes() ) {
1869 _sequence_relation_type_box.addItem( type );
1871 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1872 // according to GUILHEM the line above can be removed.
1877 * Uncollapse all nodes.
1879 void uncollapseAll( final TreePanel tp ) {
1880 final Phylogeny t = tp.getPhylogeny();
1881 if ( ( t != null ) && !t.isEmpty() ) {
1882 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
1883 final PhylogenyNode node = iter.next();
1884 node.setCollapse( false );
1886 tp.resetNodeIdToDistToLeafMap();
1887 tp.updateSetOfCollapsedExternalNodes();
1888 t.recalculateNumberOfExternalDescendants( false );
1889 tp.setNodeInPreorderToNull();
1890 t.clearHashIdToNodeMap();
1895 void updateDomainStructureEvaluethresholdDisplay() {
1896 if ( _domain_structure_evalue_thr_tf != null ) {
1897 _domain_structure_evalue_thr_tf.setText( "10^"
1898 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1902 void zoomInX( final float factor, final float x_correction_factor ) {
1903 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1904 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1905 treepanel.multiplyUrtFactor( 1f );
1906 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1907 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1908 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1909 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1910 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1911 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1912 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1913 getMainPanel().adjustJScrollPane();
1914 treepanel.resetPreferredSize();
1915 getMainPanel().getCurrentScrollPane().getViewport().validate();
1916 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1917 - ( sb.getVisibleAmount() / 2.0 ) ) );
1920 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1921 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1922 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1923 getMainPanel().adjustJScrollPane();
1924 treepanel.resetPreferredSize();
1925 getMainPanel().getCurrentScrollPane().getViewport().validate();
1926 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1928 treepanel.resetPreferredSize();
1929 treepanel.updateOvSizes();
1932 void zoomInY( final float factor ) {
1933 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1934 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1935 treepanel.multiplyUrtFactor( 1.1f );
1936 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1937 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1938 getMainPanel().adjustJScrollPane();
1939 treepanel.resetPreferredSize();
1940 getMainPanel().getCurrentScrollPane().getViewport().validate();
1941 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1942 - ( sb.getVisibleAmount() / 2.0 ) ) );
1943 treepanel.resetPreferredSize();
1944 treepanel.updateOvSizes();
1947 void zoomOutX( final float factor, final float x_correction_factor ) {
1948 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1949 treepanel.multiplyUrtFactor( 1f );
1950 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1951 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1952 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1953 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1954 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1955 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1956 getMainPanel().adjustJScrollPane();
1957 treepanel.resetPreferredSize();
1958 getMainPanel().getCurrentScrollPane().getViewport().validate();
1959 final double x = ( sb.getMaximum() - sb.getMinimum() )
1960 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1961 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1962 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1963 getMainPanel().adjustJScrollPane();
1964 treepanel.resetPreferredSize();
1965 getMainPanel().getCurrentScrollPane().getViewport().validate();
1966 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1967 - ( sb.getVisibleAmount() / 2.0 ) ) );
1970 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1971 treepanel.setXdistance( treepanel.getXdistance() * factor );
1972 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
1974 getMainPanel().adjustJScrollPane();
1975 treepanel.resetPreferredSize();
1976 getMainPanel().getCurrentScrollPane().getViewport().validate();
1977 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1980 treepanel.resetPreferredSize();
1981 treepanel.updateOvSizes();
1985 void zoomOutY( final float factor ) {
1986 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1987 treepanel.multiplyUrtFactor( 0.9f );
1988 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1989 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1990 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1991 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1992 getMainPanel().adjustJScrollPane();
1993 treepanel.resetPreferredSize();
1994 getMainPanel().getCurrentScrollPane().getViewport().validate();
1995 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1996 - ( sb.getVisibleAmount() / 2.0 ) ) );
1997 treepanel.resetPreferredSize();
1998 treepanel.updateOvSizes();
2002 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2003 label.setFont( ControlPanel.jcb_bold_font );
2004 if ( !configuration.isUseNativeUI() ) {
2005 label.setForeground( configuration.getGuiCheckboxTextColor() );
2006 label.setBackground( configuration.getGuiBackgroundColor() );
2011 enum NodeClickAction {
2022 DELETE_NODE_OR_SUBTREE,