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.PhylogenyNode;
65 import org.forester.phylogeny.data.Sequence;
66 import org.forester.phylogeny.data.SequenceRelation;
67 import org.forester.util.ForesterUtil;
69 final class ControlPanel extends JPanel implements ActionListener {
71 private static final String RETURN_TO_SUPER_TREE_TEXT = "Back to Super Tree";
72 final static Font jcb_font = new Font( Configuration.getDefaultFontFamilyName(),
75 final static Font js_font = new Font( Configuration.getDefaultFontFamilyName(),
78 final static Font jcb_bold_font = new Font( Configuration.getDefaultFontFamilyName(),
81 private static final long serialVersionUID = -8463483932821545633L;
82 private final MainPanel _mainpanel;
83 // The settings from the conf file
84 private final Configuration _configuration;
86 private JCheckBox _display_internal_data;
87 private JCheckBox _show_node_names;
88 private JCheckBox _show_taxo_code;
89 private JCheckBox _write_confidence;
90 private JCheckBox _write_confidence_sd;
91 private JCheckBox _show_events;
92 private JCheckBox _color_acc_species;
93 private JCheckBox _color_branches_cb;
94 private JCheckBox _width_branches;
95 private JCheckBox _show_domain_architectures;
96 private JCheckBox _show_annotation;
97 private JCheckBox _show_binary_characters;
98 private JCheckBox _show_binary_character_counts;
99 private JCheckBox _show_gene_names;
100 private JCheckBox _show_gene_symbols;
101 private JCheckBox _show_sequence_acc;
102 private JCheckBox _node_desc_popup_cb;
103 private JCheckBox _dynamically_hide_data;
104 private JCheckBox _show_taxo_scientific_names;
105 private JCheckBox _show_taxo_common_names;
106 private JCheckBox _show_taxo_images_cb;
107 private JCheckBox _color_according_to_annotation;
108 private JCheckBox _display_as_phylogram_cb;
109 private JCheckBox _seq_relation_confidence_switch;
110 private JComboBox _show_sequence_relations;
111 private JComboBox _sequence_relation_type_box;
112 private JCheckBox _show_vector_data_cb;
113 private JCheckBox _show_properties_cb;
114 private JLabel _click_to_label;
115 private JLabel _zoom_label;
116 private JLabel _domain_display_label;
117 private JComboBox _click_to_combobox;
118 private Map<Integer, String> _all_click_to_names;
119 private List<String> _click_to_names;
120 // Indices for the click-to options in the combo box
121 private int _show_data_item;
122 private int _collapse_cb_item;
123 private int _reroot_cb_item;
124 private int _swap_cb_item;
125 private int _subtree_cb_item;
126 private int _color_subtree_cb_item;
127 private int _open_seq_web_item;
128 private int _open_tax_web_item;
129 private int _cut_subtree_item;
130 private int _copy_subtree_item;
131 private int _delete_node_or_subtree_item;
132 private int _paste_subtree_item;
133 private int _add_new_node_item;
134 private int _edit_node_data_item;
135 private int _blast_item;
136 // zooming and quick tree manipulation buttons:
137 private JButton _zoom_in_x;
138 private JButton _zoom_in_y;
139 private JButton _zoom_out_x;
140 private JButton _zoom_out_y;
141 private JButton _show_whole;
142 private JButton _order;
143 private JButton _uncollapse_all;
144 private JButton _zoom_in_domain_structure;
145 private JButton _zoom_out_domain_structure;
146 private JButton _decr_domain_structure_evalue_thr;
147 private JButton _incr_domain_structure_evalue_thr;
148 private JButton _return_to_super_tree;
149 private JTextField _domain_structure_evalue_thr_tf;
150 private JTextField _search_tf;
151 private boolean _order_of_appearance;
152 private boolean _color_branches;
153 private NodeClickAction _action_when_node_clicked;
154 private List<Boolean> _draw_phylogram;
155 private Map<String, Color> _annotation_colors;
156 private Map<String, Color> _species_colors;
157 private JButton _search_reset_button;
158 private JLabel _search_found_label;
159 private Sequence _selected_query_seq;
161 ControlPanel( final MainPanel ap, final Configuration configuration ) {
164 _configuration = configuration;
165 if ( !_configuration.isUseNativeUI() ) {
166 setBackground( getConfiguration().getGuiBackgroundColor() );
167 setBorder( BorderFactory.createRaisedBevelBorder() );
169 setLayout( new GridLayout( 0, 1, 2, 2 ) );
170 _order_of_appearance = true;
178 public void actionPerformed( final ActionEvent e ) {
180 final TreePanel tp = getMainPanel().getCurrentTreePanel();
184 if ( e.getSource() == _click_to_combobox ) {
185 setClickToAction( _click_to_combobox.getSelectedIndex() );
186 getCurrentTreePanel().repaint();
188 else if ( e.getSource() == _show_binary_characters ) {
189 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
190 _show_binary_character_counts.setSelected( false );
192 displayedPhylogenyMightHaveChanged( true );
194 else if ( e.getSource() == _show_binary_character_counts ) {
195 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
196 _show_binary_characters.setSelected( false );
198 displayedPhylogenyMightHaveChanged( true );
200 else if ( e.getSource() == _color_according_to_annotation ) {
201 if ( ( _show_annotation != null ) && _color_according_to_annotation.isSelected() ) {
202 _show_annotation.setSelected( true );
204 displayedPhylogenyMightHaveChanged( false );
206 else if ( e.getSource() == _show_annotation ) {
207 if ( ( _color_according_to_annotation != null ) && !_show_annotation.isSelected() ) {
208 _color_according_to_annotation.setSelected( false );
210 displayedPhylogenyMightHaveChanged( false );
212 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
213 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
214 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
218 else if ( e.getSource() == _zoom_in_x ) {
219 zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
220 displayedPhylogenyMightHaveChanged( false );
222 else if ( e.getSource() == _zoom_in_y ) {
223 zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR );
224 displayedPhylogenyMightHaveChanged( false );
226 else if ( e.getSource() == _zoom_out_x ) {
227 zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
228 displayedPhylogenyMightHaveChanged( false );
230 else if ( e.getSource() == _zoom_out_y ) {
231 zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR );
232 displayedPhylogenyMightHaveChanged( false );
234 else if ( e.getSource() == _show_whole ) {
237 else if ( e.getSource() == _return_to_super_tree ) {
238 _mainpanel.getCurrentTreePanel().superTree();
241 else if ( e.getSource() == _order ) {
242 tp.getPhylogeny().orderAppearance( _order_of_appearance );
243 _order_of_appearance = !_order_of_appearance;
244 displayedPhylogenyMightHaveChanged( false );
246 else if ( e.getSource() == _uncollapse_all ) {
248 displayedPhylogenyMightHaveChanged( false );
250 else if ( e.getSource() == _zoom_in_domain_structure ) {
251 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
252 displayedPhylogenyMightHaveChanged( true );
254 else if ( e.getSource() == _zoom_out_domain_structure ) {
255 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
256 displayedPhylogenyMightHaveChanged( true );
258 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
259 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThreshold();
260 displayedPhylogenyMightHaveChanged( true );
262 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
263 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThreshold();
264 displayedPhylogenyMightHaveChanged( true );
266 else if ( e.getSource() == _search_tf ) {
268 displayedPhylogenyMightHaveChanged( true );
271 displayedPhylogenyMightHaveChanged( true );
275 tp.requestFocusInWindow();
278 catch ( final Exception ex ) {
279 AptxUtil.unexpectedException( ex );
281 catch ( final Error err ) {
282 AptxUtil.unexpectedError( err );
286 void activateButtonToReturnToSuperTree( int index ) {
289 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
292 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
294 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
295 _return_to_super_tree.setEnabled( true );
299 * Add zoom and quick edit buttons. (Last modified 8/9/04)
302 final JLabel spacer = new JLabel( "" );
303 spacer.setOpaque( false );
305 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
306 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
307 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
308 if ( !getConfiguration().isUseNativeUI() ) {
309 x_panel.setBackground( getBackground() );
310 y_panel.setBackground( getBackground() );
311 z_panel.setBackground( getBackground() );
313 add( _zoom_label = new JLabel( "Zoom:" ) );
314 customizeLabel( _zoom_label, getConfiguration() );
318 if ( getConfiguration().isUseNativeUI() ) {
319 _zoom_in_x = new JButton( "+" );
320 _zoom_out_x = new JButton( "-" );
323 _zoom_in_x = new JButton( "X+" );
324 _zoom_out_x = new JButton( "X-" );
326 _zoom_in_y = new JButton( "Y+" );
327 _zoom_out_y = new JButton( "Y-" );
328 _show_whole = new JButton( "F" );
329 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [Backspace]" );
330 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+Right]" );
331 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+Up]" );
332 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+Left]" );
333 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+Down]" );
334 if ( getConfiguration().isUseNativeUI() && AptxUtil.isMac() ) {
335 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
336 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
339 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
340 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
342 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
343 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
344 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
345 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
346 _return_to_super_tree.setEnabled( false );
347 _order = new JButton( "Order Subtrees" );
348 _uncollapse_all = new JButton( "Uncollapse All" );
349 addJButton( _zoom_in_y, x_panel );
350 addJButton( _zoom_out_x, y_panel );
351 addJButton( _show_whole, y_panel );
352 addJButton( _zoom_in_x, y_panel );
353 addJButton( _zoom_out_y, z_panel );
354 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
355 setUpControlsForDomainStrucures();
357 final JLabel spacer2 = new JLabel( "" );
359 addJButton( _return_to_super_tree, this );
360 addJButton( _order, this );
361 addJButton( _uncollapse_all, this );
362 final JLabel spacer3 = new JLabel( "" );
364 setVisibilityOfDomainStrucureControls();
367 void addCheckbox( final int which, final String title ) {
368 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
370 case Configuration.display_as_phylogram:
371 _display_as_phylogram_cb = new JCheckBox( title );
372 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
373 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
376 case Configuration.display_internal_data:
377 _display_internal_data = new JCheckBox( title );
378 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
379 addJCheckBox( _display_internal_data, ch_panel );
382 case Configuration.color_according_to_species:
383 _color_acc_species = new JCheckBox( title );
385 .setToolTipText( "To colorize taxonomy and sequence labels as a function of taxonomy" );
386 addJCheckBox( _color_acc_species, ch_panel );
389 case Configuration.color_according_to_annotation:
390 _color_according_to_annotation = new JCheckBox( title );
391 _color_according_to_annotation
392 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
393 addJCheckBox( _color_according_to_annotation, ch_panel );
396 case Configuration.show_node_names:
397 _show_node_names = new JCheckBox( title );
398 addJCheckBox( _show_node_names, ch_panel );
401 case Configuration.show_taxonomy_scientific_names:
402 _show_taxo_scientific_names = new JCheckBox( title );
403 addJCheckBox( _show_taxo_scientific_names, ch_panel );
406 case Configuration.show_taxonomy_common_names:
407 _show_taxo_common_names = new JCheckBox( title );
408 addJCheckBox( _show_taxo_common_names, ch_panel );
411 case Configuration.show_tax_code:
412 _show_taxo_code = new JCheckBox( title );
413 addJCheckBox( _show_taxo_code, ch_panel );
416 case Configuration.show_taxonomy_images:
417 _show_taxo_images_cb = new JCheckBox( title );
418 addJCheckBox( _show_taxo_images_cb, ch_panel );
421 case Configuration.show_binary_characters:
422 _show_binary_characters = new JCheckBox( title );
423 addJCheckBox( _show_binary_characters, ch_panel );
426 case Configuration.show_annotation:
427 _show_annotation = new JCheckBox( title );
428 addJCheckBox( _show_annotation, ch_panel );
431 case Configuration.show_binary_character_counts:
432 _show_binary_character_counts = new JCheckBox( title );
433 addJCheckBox( _show_binary_character_counts, ch_panel );
436 case Configuration.write_confidence_values:
437 _write_confidence = new JCheckBox( title );
438 addJCheckBox( getWriteConfidenceCb(), ch_panel );
441 case Configuration.write_confidence_values_sd:
442 _write_confidence_sd = new JCheckBox( title );
443 addJCheckBox( getWriteConfidenceSDCb(), ch_panel );
446 case Configuration.write_events:
447 _show_events = new JCheckBox( title );
448 addJCheckBox( getShowEventsCb(), ch_panel );
451 case Configuration.color_branches:
452 _color_branches_cb = new JCheckBox( title );
453 getColorBranchesCb().setToolTipText( "To use branch color values, if present" );
454 addJCheckBox( getColorBranchesCb(), ch_panel );
457 case Configuration.width_branches:
458 _width_branches = new JCheckBox( title );
459 _width_branches.setToolTipText( "To use branch width values, if present" );
460 addJCheckBox( _width_branches, ch_panel );
463 case Configuration.show_domain_architectures:
464 _show_domain_architectures = new JCheckBox( title );
465 addJCheckBox( _show_domain_architectures, ch_panel );
468 case Configuration.show_gene_names:
469 _show_gene_names = new JCheckBox( title );
470 addJCheckBox( _show_gene_names, ch_panel );
473 case Configuration.show_gene_symbols:
474 _show_gene_symbols = new JCheckBox( title );
475 addJCheckBox( _show_gene_symbols, ch_panel );
478 case Configuration.show_sequence_acc:
479 _show_sequence_acc = new JCheckBox( title );
480 addJCheckBox( _show_sequence_acc, ch_panel );
483 case Configuration.dynamically_hide_data:
484 _dynamically_hide_data = new JCheckBox( title );
485 getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" );
486 addJCheckBox( getDynamicallyHideData(), ch_panel );
489 case Configuration.node_data_popup:
490 _node_desc_popup_cb = new JCheckBox( title );
491 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
492 addJCheckBox( getNodeDescPopupCb(), ch_panel );
495 case Configuration.show_relation_confidence:
496 _seq_relation_confidence_switch = new JCheckBox( title );
497 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
500 case Configuration.show_vector_data:
501 _show_vector_data_cb = new JCheckBox( title );
502 addJCheckBox( _show_vector_data_cb, ch_panel );
505 case Configuration.show_properties:
506 _show_properties_cb = new JCheckBox( title );
507 addJCheckBox( _show_properties_cb, ch_panel );
511 throw new RuntimeException( "unknown checkbox: " + which );
515 private void addClickToOption( final int which, final String title ) {
516 _click_to_combobox.addItem( title );
517 _click_to_names.add( title );
518 _all_click_to_names.put( new Integer( which ), title );
519 if ( !_configuration.isUseNativeUI() ) {
520 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
521 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
525 void addJButton( final JButton jb, final JPanel p ) {
526 jb.setFocusPainted( false );
527 jb.setFont( ControlPanel.jcb_font );
528 if ( !_configuration.isUseNativeUI() ) {
529 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
530 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
531 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
534 jb.addActionListener( this );
537 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
538 jcb.setFocusPainted( false );
539 jcb.setFont( ControlPanel.jcb_font );
540 if ( !_configuration.isUseNativeUI() ) {
541 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
542 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
544 p.add( jcb, "Center" );
545 jcb.addActionListener( this );
548 void addJTextField( final JTextField tf, final JPanel p ) {
549 if ( !_configuration.isUseNativeUI() ) {
550 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
551 tf.setFont( ControlPanel.jcb_font );
554 tf.addActionListener( this );
558 private void addSequenceRelationBlock() {
559 final JLabel spacer = new JLabel( "" );
560 spacer.setSize( 1, 1 );
562 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
563 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
564 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
565 getSequenceRelationTypeBox().setFocusable( false );
566 _sequence_relation_type_box.setFont( ControlPanel.js_font );
567 if ( !_configuration.isUseNativeUI() ) {
568 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
569 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
571 _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
574 public Component getListCellRendererComponent( final JList list,
577 final boolean isSelected,
578 final boolean cellHasFocus ) {
579 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
584 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
585 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
586 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
591 final GridBagLayout gbl = new GridBagLayout();
592 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
593 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
594 final JPanel horizGrid = new JPanel( gbl );
595 horizGrid.setBackground( getBackground() );
596 horizGrid.add( typeLabel );
597 horizGrid.add( _sequence_relation_type_box );
598 add( customizeLabel( mainLabel, getConfiguration() ) );
600 add( getSequenceRelationBox() );
601 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
602 addCheckbox( Configuration.show_relation_confidence,
603 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
604 setCheckbox( Configuration.show_relation_confidence,
605 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
607 }// addSequenceRelationBlock
609 void deactivateButtonToReturnToSuperTree() {
610 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
611 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
612 _return_to_super_tree.setEnabled( false );
615 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
616 if ( ( _mainpanel != null ) && ( _mainpanel.getCurrentPhylogeny() != null ) ) {
617 if ( getOptions().isShowOverview() ) {
618 _mainpanel.getCurrentTreePanel().updateOvSizes();
620 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
621 setVisibilityOfDomainStrucureControls();
622 updateDomainStructureEvaluethresholdDisplay();
623 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
624 _mainpanel.getCurrentTreePanel().calcMaxDepth();
625 _mainpanel.adjustJScrollPane();
626 if ( recalc_longest_ext_node_info ) {
627 _mainpanel.getCurrentTreePanel().initNodeData();
628 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
630 _mainpanel.getCurrentTreePanel().repaint();
631 // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
635 void endClickToOptions() {
636 _click_to_combobox.addActionListener( this );
640 * Indicates what action should be execute when a node is clicked
642 * @return the click-on action
644 NodeClickAction getActionWhenNodeClicked() {
645 return _action_when_node_clicked;
648 Map<Integer, String> getAllClickToItems() {
649 return _all_click_to_names;
652 Map<String, Color> getAnnotationColors() {
653 return _annotation_colors;
656 public JCheckBox getColorBranchesCb() {
657 return _color_branches_cb;
660 public JCheckBox getColorAccSpeciesCb() {
661 return _color_acc_species;
664 Configuration getConfiguration() {
665 return _configuration;
668 TreePanel getCurrentTreePanel() {
669 return getMainPanel().getCurrentTreePanel();
672 public JCheckBox getDisplayAsPhylogramCb() {
673 return _display_as_phylogram_cb;
676 public JCheckBox getDynamicallyHideData() {
677 return _dynamically_hide_data;
681 private List<Boolean> getIsDrawPhylogramList() {
682 return _draw_phylogram;
685 MainPanel getMainPanel() {
689 public JCheckBox getNodeDescPopupCb() {
690 return _node_desc_popup_cb;
693 Options getOptions() {
694 return getMainPanel().getOptions();
697 private JLabel getSearchFoundCountsLabel() {
698 return _search_found_label;
701 private JButton getSearchResetButton() {
702 return _search_reset_button;
705 JTextField getSearchTextField() {
709 public Sequence getSelectedQuerySequence() {
710 return _selected_query_seq;
713 public JComboBox getSequenceRelationBox() {
714 if ( _show_sequence_relations == null ) {
715 _show_sequence_relations = new JComboBox();
716 _show_sequence_relations.setFocusable( false );
717 _show_sequence_relations.setMaximumRowCount( 20 );
718 _show_sequence_relations.setFont( ControlPanel.js_font );
719 if ( !_configuration.isUseNativeUI() ) {
720 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
721 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
723 _show_sequence_relations.addItem( "-----" );
724 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
726 return _show_sequence_relations;
730 public JComboBox getSequenceRelationTypeBox() {
731 if ( _sequence_relation_type_box == null ) {
732 _sequence_relation_type_box = new JComboBox();
733 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
734 _sequence_relation_type_box.addItem( type );
736 _sequence_relation_type_box.addActionListener( new ActionListener() {
739 public void actionPerformed( final ActionEvent e ) {
740 if ( _mainpanel.getCurrentPhylogeny() != null ) {
741 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
746 return _sequence_relation_type_box;
749 public JCheckBox getShowEventsCb() {
753 List<String> getSingleClickToNames() {
754 return _click_to_names;
757 Map<String, Color> getSpeciesColors() {
758 return _species_colors;
761 public JCheckBox getWriteConfidenceCb() {
762 return _write_confidence;
765 public JCheckBox getWriteConfidenceSDCb() {
766 return _write_confidence_sd;
769 private void init() {
770 _draw_phylogram = new ArrayList<Boolean>();
771 setSpeciesColors( new HashMap<String, Color>() );
772 setAnnotationColors( new HashMap<String, Color>() );
775 boolean isAntialiasScreenText() {
779 boolean isColorAccordingToAnnotation() {
780 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
783 boolean isColorAccordingToTaxonomy() {
784 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
787 boolean isColorBranches() {
788 return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) );
791 boolean isDrawPhylogram() {
792 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
795 private boolean isDrawPhylogram( final int index ) {
796 return getIsDrawPhylogramList().get( index );
799 boolean isDynamicallyHideData() {
800 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
804 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
807 boolean isNodeDescPopup() {
808 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
811 boolean isShowAnnotation() {
812 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
815 boolean isShowBinaryCharacterCounts() {
816 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
819 boolean isShowBinaryCharacters() {
820 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
823 boolean isShowConfidenceValues() {
824 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
827 boolean isShowConfidenceSDValues() {
828 return ( ( getWriteConfidenceSDCb() != null ) && getWriteConfidenceSDCb().isSelected() );
831 boolean isShowDomainArchitectures() {
832 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
835 boolean isShowGeneNames() {
836 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
839 public boolean isShowVectorData() {
840 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
843 public boolean isShowProperties() {
844 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
847 boolean isShowGeneSymbols() {
848 return ( ( _show_gene_symbols != null ) && _show_gene_symbols.isSelected() );
851 boolean isShowInternalData() {
852 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
855 boolean isShowNodeNames() {
856 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
859 boolean isShowSequenceAcc() {
860 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
863 boolean isShowSequenceRelationConfidence() {
864 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
867 boolean isShowSequenceRelations() {
868 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
871 boolean isShowTaxonomyCode() {
872 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
875 public boolean isShowTaxonomyImages() {
876 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
879 boolean isShowTaxonomyCommonNames() {
880 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
883 boolean isShowTaxonomyScientificNames() {
884 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
887 boolean isWidthBranches() {
888 return ( ( _width_branches != null ) && _width_branches.isSelected() );
891 void phylogenyAdded( final Configuration configuration ) {
892 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
895 void phylogenyRemoved( final int index ) {
896 getIsDrawPhylogramList().remove( index );
900 final MainPanel main_panel = getMainPanel();
901 final Phylogeny tree = main_panel.getCurrentPhylogeny();
902 if ( ( tree == null ) || tree.isEmpty() ) {
905 String query = getSearchTextField().getText();
906 if ( query != null ) {
907 query = query.trim();
910 getSearchFoundCountsLabel().setVisible( false );
911 getSearchResetButton().setEnabled( false );
912 getSearchResetButton().setVisible( false );
915 if ( !ForesterUtil.isEmpty( query ) ) {
916 search( main_panel, tree, query );
919 getSearchFoundCountsLabel().setVisible( false );
920 getSearchResetButton().setEnabled( false );
921 getSearchResetButton().setVisible( false );
926 private void search( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
927 getSearchFoundCountsLabel().setVisible( true );
928 getSearchResetButton().setEnabled( true );
929 getSearchResetButton().setVisible( true );
930 String[] queries = null;
931 List<PhylogenyNode> nodes = null;
932 if ( query_str.indexOf( ',' ) >= 0 ) {
933 queries = query_str.split( ",+" );
936 queries = new String[ 1 ];
937 queries[ 0 ] = query_str.trim();
939 if ( ( queries != null ) && ( queries.length > 0 ) ) {
940 nodes = new ArrayList<PhylogenyNode>();
941 for( String query : queries ) {
942 if ( ForesterUtil.isEmpty( query ) ) {
945 query = query.trim();
946 if ( query.indexOf( '+' ) >= 0 ) {
947 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ), tree, getOptions()
948 .isSearchCaseSensitive(), !getOptions().isMatchWholeTermsOnly() ) );
951 nodes.addAll( PhylogenyMethods.searchData( query,
953 getOptions().isSearchCaseSensitive(),
954 !getOptions().isMatchWholeTermsOnly() ) );
957 if ( getOptions().isInverseSearchResult() ) {
958 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
959 all.removeAll( nodes );
963 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
964 main_panel.getCurrentTreePanel().setFoundNodes( new HashSet<Integer>() );
965 for( final PhylogenyNode node : nodes ) {
966 main_panel.getCurrentTreePanel().getFoundNodes().add( node.getId() );
968 setSearchFoundCountsOnLabel( nodes.size() );
971 setSearchFoundCountsOnLabel( 0 );
976 private void searchReset() {
977 if ( getMainPanel().getCurrentTreePanel() != null ) {
978 getMainPanel().getCurrentTreePanel().setFoundNodes( null );
982 void setActionWhenNodeClicked( final NodeClickAction action ) {
983 _action_when_node_clicked = action;
986 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
987 _annotation_colors = annotation_colors;
990 void setCheckbox( final int which, final boolean state ) {
992 case Configuration.display_as_phylogram:
993 if ( getDisplayAsPhylogramCb() != null ) {
994 getDisplayAsPhylogramCb().setSelected( state );
997 case Configuration.display_internal_data:
998 if ( _display_internal_data != null ) {
999 _display_internal_data.setSelected( state );
1002 case Configuration.color_according_to_species:
1003 if ( _color_acc_species != null ) {
1004 _color_acc_species.setSelected( state );
1007 case Configuration.color_according_to_annotation:
1008 if ( _color_according_to_annotation != null ) {
1009 _color_according_to_annotation.setSelected( state );
1012 case Configuration.show_node_names:
1013 if ( _show_node_names != null ) {
1014 _show_node_names.setSelected( state );
1017 case Configuration.show_taxonomy_scientific_names:
1018 if ( _show_taxo_scientific_names != null ) {
1019 _show_taxo_scientific_names.setSelected( state );
1022 case Configuration.show_taxonomy_common_names:
1023 if ( _show_taxo_common_names != null ) {
1024 _show_taxo_common_names.setSelected( state );
1027 case Configuration.show_tax_code:
1028 if ( _show_taxo_code != null ) {
1029 _show_taxo_code.setSelected( state );
1032 case Configuration.show_taxonomy_images:
1033 if ( _show_taxo_images_cb != null ) {
1034 _show_taxo_images_cb.setSelected( state );
1037 case Configuration.show_annotation:
1038 if ( _show_annotation != null ) {
1039 _show_annotation.setSelected( state );
1042 case Configuration.show_binary_characters:
1043 if ( _show_binary_characters != null ) {
1044 _show_binary_characters.setSelected( state );
1047 case Configuration.show_binary_character_counts:
1048 if ( _show_binary_character_counts != null ) {
1049 _show_binary_character_counts.setSelected( state );
1052 case Configuration.write_confidence_values:
1053 if ( getWriteConfidenceCb() != null ) {
1054 getWriteConfidenceCb().setSelected( state );
1057 case Configuration.write_confidence_values_sd:
1058 if ( getWriteConfidenceSDCb() != null ) {
1059 getWriteConfidenceSDCb().setSelected( state );
1062 case Configuration.write_events:
1063 if ( getShowEventsCb() != null ) {
1064 getShowEventsCb().setSelected( state );
1067 case Configuration.color_branches:
1068 if ( getColorBranchesCb() != null ) {
1069 getColorBranchesCb().setSelected( state );
1072 case Configuration.width_branches:
1073 if ( _width_branches != null ) {
1074 _width_branches.setSelected( state );
1077 case Configuration.show_domain_architectures:
1078 if ( _show_domain_architectures != null ) {
1079 _show_domain_architectures.setSelected( state );
1082 case Configuration.show_gene_names:
1083 if ( _show_gene_names != null ) {
1084 _show_gene_names.setSelected( state );
1087 case Configuration.show_gene_symbols:
1088 if ( _show_gene_symbols != null ) {
1089 _show_gene_symbols.setSelected( state );
1092 case Configuration.show_vector_data:
1093 if ( _show_vector_data_cb != null ) {
1094 _show_vector_data_cb.setSelected( state );
1097 case Configuration.show_properties:
1098 if ( _show_properties_cb != null ) {
1099 _show_properties_cb.setSelected( state );
1102 case Configuration.show_sequence_acc:
1103 if ( _show_sequence_acc != null ) {
1104 _show_sequence_acc.setSelected( state );
1107 case Configuration.dynamically_hide_data:
1108 if ( getDynamicallyHideData() != null ) {
1109 getDynamicallyHideData().setSelected( state );
1112 case Configuration.node_data_popup:
1113 if ( getNodeDescPopupCb() != null ) {
1114 getNodeDescPopupCb().setSelected( state );
1118 case Configuration.show_relation_confidence:
1119 if ( _seq_relation_confidence_switch != null ) {
1120 _seq_relation_confidence_switch.setSelected( state );
1125 throw new AssertionError( "unknown checkbox: " + which );
1130 * Set this checkbox state. Not all checkboxes have been instantiated
1131 * depending on the config.
1133 void setCheckbox( final JCheckBox cb, final boolean state ) {
1135 cb.setSelected( state );
1139 void setClickToAction( final int action ) {
1140 // Set click-to action
1141 if ( action == _show_data_item ) {
1142 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1144 else if ( action == _collapse_cb_item ) {
1145 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1147 else if ( action == _reroot_cb_item ) {
1148 setActionWhenNodeClicked( NodeClickAction.REROOT );
1150 else if ( action == _subtree_cb_item ) {
1151 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1153 else if ( action == _swap_cb_item ) {
1154 setActionWhenNodeClicked( NodeClickAction.SWAP );
1156 else if ( action == _color_subtree_cb_item ) {
1157 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1159 else if ( action == _open_seq_web_item ) {
1160 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1162 else if ( action == _blast_item ) {
1163 if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
1164 setActionWhenNodeClicked( NodeClickAction.BLAST );
1167 else if ( action == _open_tax_web_item ) {
1168 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1170 else if ( action == _cut_subtree_item ) {
1171 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1173 else if ( action == _copy_subtree_item ) {
1174 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1176 else if ( action == _delete_node_or_subtree_item ) {
1177 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1179 else if ( action == _paste_subtree_item ) {
1180 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1182 else if ( action == _add_new_node_item ) {
1183 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1185 else if ( action == _edit_node_data_item ) {
1186 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1189 throw new RuntimeException( "unknown action: " + action );
1191 // make sure drop down is displaying the correct action
1192 // in case this was called from outside the class
1193 _click_to_combobox.setSelectedIndex( action );
1196 void setColorBranches( final boolean color_branches ) {
1197 _color_branches = color_branches;
1200 void setDrawPhylogram( final boolean b ) {
1201 getDisplayAsPhylogramCb().setSelected( b );
1202 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1205 private void setDrawPhylogram( final int index, final boolean b ) {
1206 getIsDrawPhylogramList().set( index, b );
1209 void setDrawPhylogramEnabled( final boolean b ) {
1210 getDisplayAsPhylogramCb().setEnabled( b );
1213 void setDynamicHidingIsOn( final boolean is_on ) {
1214 // if ( !_configuration.isUseNativeUI() ) {
1216 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1219 if ( !_configuration.isUseNativeUI() ) {
1220 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1223 getDynamicallyHideData().setForeground( Color.BLACK );
1229 private void setSearchFoundCountsOnLabel( final int counts ) {
1230 getSearchFoundCountsLabel().setText( "Found: " + counts );
1233 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
1234 final JComboBox box = getSequenceRelationBox();
1235 while ( box.getItemCount() > 1 ) {
1236 box.removeItemAt( 1 );
1238 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
1239 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
1241 if ( relationType == null ) {
1244 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
1245 for( final Sequence seq : sequenceRelationQueries ) {
1246 if ( seq.hasSequenceRelations() ) {
1247 boolean fFoundForCurrentType = false;
1248 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
1249 if ( sq.getType().equals( relationType ) ) {
1250 fFoundForCurrentType = true;
1254 if ( fFoundForCurrentType ) {
1255 sequenceNamesToAdd.add( seq.getName() );
1256 sequencesByName.put( seq.getName(), seq );
1260 // sort sequences by name before adding them to the combo
1261 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
1262 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
1263 for( final String seqName : sequenceNameArray ) {
1264 box.addItem( seqName );
1266 for( final ItemListener oldItemListener : box.getItemListeners() ) {
1267 box.removeItemListener( oldItemListener );
1269 box.addItemListener( new ItemListener() {
1272 public void itemStateChanged( final ItemEvent e ) {
1273 _selected_query_seq = sequencesByName.get( e.getItem() );
1274 _mainpanel.getCurrentTreePanel().repaint();
1279 void setShowEvents( final boolean show_events ) {
1280 if ( getShowEventsCb() == null ) {
1281 _show_events = new JCheckBox( "" );
1283 getShowEventsCb().setSelected( show_events );
1286 void setSpeciesColors( final Map<String, Color> species_colors ) {
1287 _species_colors = species_colors;
1290 private void setupClickToOptions() {
1291 final int default_option = _configuration.getDefaultDisplayClicktoOption();
1292 int selected_index = 0;
1294 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1295 _show_data_item = cb_index;
1296 addClickToOption( Configuration.display_node_data,
1297 _configuration.getClickToTitle( Configuration.display_node_data ) );
1298 if ( default_option == Configuration.display_node_data ) {
1299 selected_index = cb_index;
1303 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1304 _collapse_cb_item = cb_index;
1305 addClickToOption( Configuration.collapse_uncollapse,
1306 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
1307 if ( default_option == Configuration.collapse_uncollapse ) {
1308 selected_index = cb_index;
1312 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1313 _reroot_cb_item = cb_index;
1314 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1315 if ( default_option == Configuration.reroot ) {
1316 selected_index = cb_index;
1320 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1321 _subtree_cb_item = cb_index;
1322 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1323 if ( default_option == Configuration.subtree ) {
1324 selected_index = cb_index;
1328 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1329 _swap_cb_item = cb_index;
1330 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1331 if ( default_option == Configuration.swap ) {
1332 selected_index = cb_index;
1336 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1337 _color_subtree_cb_item = cb_index;
1338 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1339 if ( default_option == Configuration.color_subtree ) {
1340 selected_index = cb_index;
1344 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1345 _open_seq_web_item = cb_index;
1346 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1347 if ( default_option == Configuration.open_seq_web ) {
1348 selected_index = cb_index;
1352 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1353 _open_tax_web_item = cb_index;
1354 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1355 if ( default_option == Configuration.open_tax_web ) {
1356 selected_index = cb_index;
1360 if ( getOptions().isEditable() ) {
1361 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
1362 _cut_subtree_item = cb_index;
1363 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
1364 if ( default_option == Configuration.cut_subtree ) {
1365 selected_index = cb_index;
1369 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
1370 _copy_subtree_item = cb_index;
1371 addClickToOption( Configuration.copy_subtree,
1372 _configuration.getClickToTitle( Configuration.copy_subtree ) );
1373 if ( default_option == Configuration.copy_subtree ) {
1374 selected_index = cb_index;
1378 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
1379 _paste_subtree_item = cb_index;
1380 addClickToOption( Configuration.paste_subtree,
1381 _configuration.getClickToTitle( Configuration.paste_subtree ) );
1382 if ( default_option == Configuration.paste_subtree ) {
1383 selected_index = cb_index;
1387 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
1388 _delete_node_or_subtree_item = cb_index;
1389 addClickToOption( Configuration.delete_subtree_or_node,
1390 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
1391 if ( default_option == Configuration.delete_subtree_or_node ) {
1392 selected_index = cb_index;
1396 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
1397 _add_new_node_item = cb_index;
1398 addClickToOption( Configuration.add_new_node,
1399 _configuration.getClickToTitle( Configuration.add_new_node ) );
1400 if ( default_option == Configuration.add_new_node ) {
1401 selected_index = cb_index;
1405 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
1406 _edit_node_data_item = cb_index;
1407 addClickToOption( Configuration.edit_node_data,
1408 _configuration.getClickToTitle( Configuration.edit_node_data ) );
1409 if ( default_option == Configuration.edit_node_data ) {
1410 selected_index = cb_index;
1414 if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
1415 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1416 _blast_item = cb_index;
1417 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
1418 if ( default_option == Configuration.blast ) {
1419 selected_index = cb_index;
1425 // Set default selection and its action
1426 _click_to_combobox.setSelectedIndex( selected_index );
1427 setClickToAction( selected_index );
1432 * Set up the controls from the config settings. 11/26/05
1434 void setupControls() {
1435 // The tree display options:
1436 setupDisplayCheckboxes();
1438 // The sequence relation query selection combo-box
1439 if ( _configuration.displaySequenceRelations() ) {
1440 addSequenceRelationBlock();
1444 startClickToOptions();
1445 setupClickToOptions();
1446 endClickToOptions();
1447 // Zoom and quick edit buttons
1452 void setUpControlsForDomainStrucures() {
1453 _domain_display_label = new JLabel( "Domain Display:" );
1454 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1455 add( _domain_display_label );
1456 _zoom_in_domain_structure = new JButton( "d+" );
1457 _zoom_out_domain_structure = new JButton( "d-" );
1458 _decr_domain_structure_evalue_thr = new JButton( "-" );
1459 _incr_domain_structure_evalue_thr = new JButton( "+" );
1460 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1461 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1462 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1463 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1464 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1465 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1466 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1467 _domain_structure_evalue_thr_tf.setEditable( false );
1468 if ( !getConfiguration().isUseNativeUI() ) {
1469 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1470 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1471 _domain_structure_evalue_thr_tf.setBorder( null );
1473 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1474 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1475 if ( !_configuration.isUseNativeUI() ) {
1476 d1_panel.setBackground( getBackground() );
1477 d2_panel.setBackground( getBackground() );
1481 addJButton( _zoom_out_domain_structure, d1_panel );
1482 addJButton( _zoom_in_domain_structure, d1_panel );
1483 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1484 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1485 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1488 private void setupDisplayCheckboxes() {
1489 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
1490 addCheckbox( Configuration.display_as_phylogram,
1491 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
1492 setCheckbox( Configuration.display_as_phylogram,
1493 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
1495 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1496 addCheckbox( Configuration.dynamically_hide_data,
1497 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
1498 setCheckbox( Configuration.dynamically_hide_data,
1499 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
1501 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1502 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1503 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1505 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1506 addCheckbox( Configuration.display_internal_data,
1507 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
1508 setCheckbox( Configuration.display_internal_data,
1509 _configuration.doCheckOption( Configuration.display_internal_data ) );
1511 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1512 addCheckbox( Configuration.color_according_to_species,
1513 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
1514 setCheckbox( Configuration.color_according_to_species,
1515 _configuration.doCheckOption( Configuration.color_according_to_species ) );
1517 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1518 addCheckbox( Configuration.color_according_to_annotation,
1519 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
1520 setCheckbox( Configuration.color_according_to_annotation,
1521 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
1523 if ( _configuration.doDisplayOption( Configuration.color_branches ) ) {
1524 addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) );
1525 setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) );
1527 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1528 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1529 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1531 final JLabel label = new JLabel( "Display Data:" );
1532 label.setFont( ControlPanel.jcb_bold_font );
1533 if ( !getConfiguration().isUseNativeUI() ) {
1534 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1537 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1538 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
1539 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1541 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1542 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1543 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1545 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1546 addCheckbox( Configuration.show_taxonomy_scientific_names,
1547 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1548 setCheckbox( Configuration.show_taxonomy_scientific_names,
1549 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1551 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1552 addCheckbox( Configuration.show_taxonomy_common_names,
1553 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1554 setCheckbox( Configuration.show_taxonomy_common_names,
1555 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1557 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1558 addCheckbox( Configuration.show_taxonomy_images,
1559 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1560 setCheckbox( Configuration.show_taxonomy_images,
1561 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1563 if ( _configuration.doDisplayOption( Configuration.show_gene_symbols ) ) {
1564 addCheckbox( Configuration.show_gene_symbols,
1565 _configuration.getDisplayTitle( Configuration.show_gene_symbols ) );
1566 setCheckbox( Configuration.show_gene_symbols,
1567 _configuration.doCheckOption( Configuration.show_gene_symbols ) );
1569 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1570 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1571 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1573 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1574 addCheckbox( Configuration.show_sequence_acc,
1575 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1576 setCheckbox( Configuration.show_sequence_acc,
1577 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1579 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1580 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
1581 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1583 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1584 addCheckbox( Configuration.show_binary_characters,
1585 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1586 setCheckbox( Configuration.show_binary_characters,
1587 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1589 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1590 addCheckbox( Configuration.show_binary_character_counts,
1591 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1592 setCheckbox( Configuration.show_binary_character_counts,
1593 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1595 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1596 addCheckbox( Configuration.show_domain_architectures,
1597 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1598 setCheckbox( Configuration.show_domain_architectures,
1599 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1601 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1602 addCheckbox( Configuration.write_confidence_values,
1603 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1604 setCheckbox( Configuration.write_confidence_values,
1605 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1606 addCheckbox( Configuration.write_confidence_values_sd,
1607 _configuration.getDisplayTitle( Configuration.write_confidence_values_sd ) );
1608 setCheckbox( Configuration.write_confidence_values_sd,
1609 _configuration.doCheckOption( Configuration.write_confidence_values_sd ) );
1611 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1612 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1613 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1615 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1616 addCheckbox( Configuration.show_vector_data,
1617 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1618 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
1620 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1621 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
1622 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1626 void setupSearchTools() {
1627 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1628 final JLabel search_label = new JLabel( "Search:" );
1629 search_label.setFont( ControlPanel.jcb_bold_font );
1630 if ( !getConfiguration().isUseNativeUI() ) {
1631 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1633 add( search_label );
1634 search_label.setToolTipText( tip );
1635 _search_found_label = new JLabel();
1636 getSearchFoundCountsLabel().setVisible( false );
1637 _search_found_label.setFont( ControlPanel.jcb_bold_font );
1638 if ( !getConfiguration().isUseNativeUI() ) {
1639 _search_found_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1641 _search_tf = new JTextField( 3 );
1642 _search_tf.setToolTipText( tip );
1643 _search_tf.setEditable( true );
1644 if ( !getConfiguration().isUseNativeUI() ) {
1645 _search_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1646 _search_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1647 _search_tf.setBorder( null );
1649 _search_reset_button = new JButton();
1650 getSearchResetButton().setText( "Reset" );
1651 getSearchResetButton().setEnabled( false );
1652 getSearchResetButton().setVisible( false );
1653 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1654 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1655 s_panel_1.setBackground( getBackground() );
1657 s_panel_2.setBackground( getBackground() );
1659 final KeyAdapter key_adapter = new KeyAdapter() {
1662 public void keyReleased( final KeyEvent key_event ) {
1664 displayedPhylogenyMightHaveChanged( true );
1667 final ActionListener action_listener = new ActionListener() {
1670 public void actionPerformed( final ActionEvent e ) {
1672 setSearchFoundCountsOnLabel( 0 );
1673 getSearchFoundCountsLabel().setVisible( false );
1674 getSearchTextField().setText( "" );
1675 getSearchResetButton().setEnabled( false );
1676 getSearchResetButton().setVisible( false );
1677 displayedPhylogenyMightHaveChanged( true );
1680 _search_reset_button.addActionListener( action_listener );
1681 _search_tf.addKeyListener( key_adapter );
1682 addJTextField( _search_tf, s_panel_1 );
1683 s_panel_2.add( _search_found_label );
1684 addJButton( _search_reset_button, s_panel_2 );
1687 private void setVisibilityOfDomainStrucureControls() {
1688 if ( _zoom_in_domain_structure != null ) {
1689 if ( isShowDomainArchitectures() ) {
1690 _domain_display_label.setVisible( true );
1691 _zoom_in_domain_structure.setVisible( true );
1692 _zoom_out_domain_structure.setVisible( true );
1693 _decr_domain_structure_evalue_thr.setVisible( true );
1694 _incr_domain_structure_evalue_thr.setVisible( true );
1695 _domain_structure_evalue_thr_tf.setVisible( true );
1698 _domain_display_label.setVisible( false );
1699 _zoom_in_domain_structure.setVisible( false );
1700 _zoom_out_domain_structure.setVisible( false );
1701 _decr_domain_structure_evalue_thr.setVisible( false );
1702 _incr_domain_structure_evalue_thr.setVisible( false );
1703 _domain_structure_evalue_thr_tf.setVisible( false );
1709 * Fit entire tree into window.
1712 if ( _mainpanel.getCurrentScrollPane() == null ) {
1715 displayedPhylogenyMightHaveChanged( false );
1716 _mainpanel.getCurrentTreePanel().updateOvSettings();
1717 _mainpanel.getCurrentTreePanel().validate();
1718 _mainpanel.validate();
1719 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1720 _mainpanel.getSizeOfViewport().height,
1722 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1723 _mainpanel.adjustJScrollPane();
1724 _mainpanel.getCurrentTreePanel().repaint();
1725 _mainpanel.getCurrentTreePanel().validate();
1726 _mainpanel.validate();
1727 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1728 _mainpanel.getSizeOfViewport().height,
1730 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1731 _mainpanel.adjustJScrollPane();
1732 _mainpanel.getCurrentTreePanel().repaint();
1733 _mainpanel.getCurrentTreePanel().updateOvSizes();
1736 void showWholeAll() {
1737 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1738 if ( tree_panel != null ) {
1739 tree_panel.validate();
1740 tree_panel.setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1741 _mainpanel.getSizeOfViewport().height,
1743 tree_panel.resetPreferredSize();
1744 tree_panel.repaint();
1749 // Create header for click-to combo box.
1750 void startClickToOptions() {
1751 final JLabel spacer = new JLabel( "" );
1752 spacer.setFont( ControlPanel.jcb_font );
1754 _click_to_label = new JLabel( "Click on Node to:" );
1755 add( customizeLabel( _click_to_label, getConfiguration() ) );
1756 _click_to_combobox = new JComboBox();
1757 _click_to_combobox.setFocusable( false );
1758 _click_to_combobox.setMaximumRowCount( 14 );
1759 _click_to_combobox.setFont( ControlPanel.js_font );
1760 if ( !_configuration.isUseNativeUI() ) {
1761 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1763 // don't add listener until all items are set (or each one will trigger
1765 // click_to_list.addActionListener(this);
1766 add( _click_to_combobox );
1767 // Correlates option names to titles
1768 _all_click_to_names = new HashMap<Integer, String>();
1769 _click_to_names = new ArrayList<String>();
1773 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1774 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1775 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1776 setDrawPhylogramEnabled( true );
1777 setDrawPhylogram( isDrawPhylogram() );
1780 setDrawPhylogramEnabled( false );
1781 setDrawPhylogram( false );
1783 if ( getMainPanel().getMainFrame() == null ) {
1784 // Must be "E" applet version.
1785 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1786 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1789 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1790 .getPhylogenyGraphicsType() );
1792 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1793 getMainPanel().getControlPanel().search();
1794 getSequenceRelationTypeBox().removeAllItems();
1795 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1796 .getRelevantSequenceRelationTypes() ) {
1797 _sequence_relation_type_box.addItem( type );
1799 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1800 // according to GUILHEM the line above can be removed.
1805 * Uncollapse all nodes.
1807 void uncollapseAll( final TreePanel tp ) {
1808 final Phylogeny t = tp.getPhylogeny();
1809 if ( ( t != null ) && !t.isEmpty() ) {
1810 t.setAllNodesToNotCollapse();
1811 t.recalculateNumberOfExternalDescendants( false );
1816 void updateDomainStructureEvaluethresholdDisplay() {
1817 if ( _domain_structure_evalue_thr_tf != null ) {
1818 _domain_structure_evalue_thr_tf.setText( "10^"
1819 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1823 void zoomInX( final float factor, final float x_correction_factor ) {
1824 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1825 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1826 treepanel.multiplyUrtFactor( 1f );
1827 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1828 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1829 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1830 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1831 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1832 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1833 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1834 getMainPanel().adjustJScrollPane();
1835 treepanel.resetPreferredSize();
1836 getMainPanel().getCurrentScrollPane().getViewport().validate();
1837 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1838 - ( sb.getVisibleAmount() / 2.0 ) ) );
1841 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1842 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1843 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1844 getMainPanel().adjustJScrollPane();
1845 treepanel.resetPreferredSize();
1846 getMainPanel().getCurrentScrollPane().getViewport().validate();
1847 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1849 treepanel.resetPreferredSize();
1850 treepanel.updateOvSizes();
1853 void zoomInY( final float factor ) {
1854 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1855 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1856 treepanel.multiplyUrtFactor( 1.1f );
1857 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1858 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1859 getMainPanel().adjustJScrollPane();
1860 treepanel.resetPreferredSize();
1861 getMainPanel().getCurrentScrollPane().getViewport().validate();
1862 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1863 - ( sb.getVisibleAmount() / 2.0 ) ) );
1864 treepanel.resetPreferredSize();
1865 treepanel.updateOvSizes();
1868 void zoomOutX( final float factor, final float x_correction_factor ) {
1869 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1870 treepanel.multiplyUrtFactor( 1f );
1871 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1872 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1873 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1874 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1875 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1876 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1877 getMainPanel().adjustJScrollPane();
1878 treepanel.resetPreferredSize();
1879 getMainPanel().getCurrentScrollPane().getViewport().validate();
1880 final double x = ( sb.getMaximum() - sb.getMinimum() )
1881 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1882 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1883 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1884 getMainPanel().adjustJScrollPane();
1885 treepanel.resetPreferredSize();
1886 getMainPanel().getCurrentScrollPane().getViewport().validate();
1887 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1888 - ( sb.getVisibleAmount() / 2.0 ) ) );
1891 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1892 treepanel.setXdistance( treepanel.getXdistance() * factor );
1893 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
1895 getMainPanel().adjustJScrollPane();
1896 treepanel.resetPreferredSize();
1897 getMainPanel().getCurrentScrollPane().getViewport().validate();
1898 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1901 treepanel.resetPreferredSize();
1902 treepanel.updateOvSizes();
1906 void zoomOutY( final float factor ) {
1907 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1908 treepanel.multiplyUrtFactor( 0.9f );
1909 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1910 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1911 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1912 treepanel.setYdistance( ( treepanel.getYdistance() * 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 ) ) );
1918 treepanel.resetPreferredSize();
1919 treepanel.updateOvSizes();
1923 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
1924 label.setFont( ControlPanel.jcb_bold_font );
1925 if ( !configuration.isUseNativeUI() ) {
1926 label.setForeground( configuration.getGuiCheckboxTextColor() );
1927 label.setBackground( configuration.getGuiBackgroundColor() );
1932 enum NodeClickAction {
1943 DELETE_NODE_OR_SUBTREE,