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 _show_events;
91 private JCheckBox _color_acc_species;
92 private JCheckBox _color_branches_cb;
93 private JCheckBox _width_branches;
94 private JCheckBox _show_domain_architectures;
95 private JCheckBox _show_annotation;
96 private JCheckBox _show_binary_characters;
97 private JCheckBox _show_binary_character_counts;
98 private JCheckBox _show_gene_names;
99 private JCheckBox _show_gene_symbols;
100 private JCheckBox _show_sequence_acc;
101 private JCheckBox _node_desc_popup_cb;
102 private JCheckBox _dynamically_hide_data;
103 private JCheckBox _show_taxo_scientific_names;
104 private JCheckBox _show_taxo_common_names;
105 private JCheckBox _show_taxo_images_cb;
106 private JCheckBox _color_according_to_annotation;
107 private JCheckBox _display_as_phylogram_cb;
108 private JCheckBox _seq_relation_confidence_switch;
109 private JComboBox _show_sequence_relations;
110 private JComboBox _sequence_relation_type_box;
111 private JCheckBox _show_vector_data_cb;
112 private JCheckBox _show_properties_cb;
113 private JLabel _click_to_label;
114 private JLabel _zoom_label;
115 private JLabel _domain_display_label;
116 private JComboBox _click_to_combobox;
117 private Map<Integer, String> _all_click_to_names;
118 private List<String> _click_to_names;
119 // Indices for the click-to options in the combo box
120 private int _show_data_item;
121 private int _collapse_cb_item;
122 private int _reroot_cb_item;
123 private int _swap_cb_item;
124 private int _subtree_cb_item;
125 private int _color_subtree_cb_item;
126 private int _open_seq_web_item;
127 private int _open_tax_web_item;
128 private int _cut_subtree_item;
129 private int _copy_subtree_item;
130 private int _delete_node_or_subtree_item;
131 private int _paste_subtree_item;
132 private int _add_new_node_item;
133 private int _edit_node_data_item;
134 private int _blast_item;
135 // zooming and quick tree manipulation buttons:
136 private JButton _zoom_in_x;
137 private JButton _zoom_in_y;
138 private JButton _zoom_out_x;
139 private JButton _zoom_out_y;
140 private JButton _show_whole;
141 private JButton _order;
142 private JButton _uncollapse_all;
143 private JButton _zoom_in_domain_structure;
144 private JButton _zoom_out_domain_structure;
145 private JButton _decr_domain_structure_evalue_thr;
146 private JButton _incr_domain_structure_evalue_thr;
147 private JButton _return_to_super_tree;
148 private JTextField _domain_structure_evalue_thr_tf;
149 private JTextField _search_tf;
150 private boolean _order_of_appearance;
151 private boolean _color_branches;
152 private NodeClickAction _action_when_node_clicked;
153 private List<Boolean> _draw_phylogram;
154 private Map<String, Color> _annotation_colors;
155 private Map<String, Color> _species_colors;
156 private JButton _search_reset_button;
157 private JLabel _search_found_label;
158 private Sequence _selected_query_seq;
160 ControlPanel( final MainPanel ap, final Configuration configuration ) {
163 _configuration = configuration;
164 if ( !_configuration.isUseNativeUI() ) {
165 setBackground( getConfiguration().getGuiBackgroundColor() );
166 setBorder( BorderFactory.createRaisedBevelBorder() );
168 setLayout( new GridLayout( 0, 1, 2, 2 ) );
169 _order_of_appearance = true;
177 public void actionPerformed( final ActionEvent e ) {
179 final TreePanel tp = getMainPanel().getCurrentTreePanel();
183 if ( e.getSource() == _click_to_combobox ) {
184 setClickToAction( _click_to_combobox.getSelectedIndex() );
185 getCurrentTreePanel().repaint();
187 else if ( e.getSource() == _show_binary_characters ) {
188 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
189 _show_binary_character_counts.setSelected( false );
191 displayedPhylogenyMightHaveChanged( true );
193 else if ( e.getSource() == _show_binary_character_counts ) {
194 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
195 _show_binary_characters.setSelected( false );
197 displayedPhylogenyMightHaveChanged( true );
199 else if ( e.getSource() == _color_according_to_annotation ) {
200 if ( ( _show_annotation != null ) && _color_according_to_annotation.isSelected() ) {
201 _show_annotation.setSelected( true );
203 displayedPhylogenyMightHaveChanged( false );
205 else if ( e.getSource() == _show_annotation ) {
206 if ( ( _color_according_to_annotation != null ) && !_show_annotation.isSelected() ) {
207 _color_according_to_annotation.setSelected( false );
209 displayedPhylogenyMightHaveChanged( false );
211 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
212 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
213 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
217 else if ( e.getSource() == _zoom_in_x ) {
218 zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
219 displayedPhylogenyMightHaveChanged( false );
221 else if ( e.getSource() == _zoom_in_y ) {
222 zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR );
223 displayedPhylogenyMightHaveChanged( false );
225 else if ( e.getSource() == _zoom_out_x ) {
226 zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
227 displayedPhylogenyMightHaveChanged( false );
229 else if ( e.getSource() == _zoom_out_y ) {
230 zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR );
231 displayedPhylogenyMightHaveChanged( false );
233 else if ( e.getSource() == _show_whole ) {
236 else if ( e.getSource() == _return_to_super_tree ) {
237 _mainpanel.getCurrentTreePanel().superTree();
240 else if ( e.getSource() == _order ) {
241 tp.getPhylogeny().orderAppearance( _order_of_appearance );
242 _order_of_appearance = !_order_of_appearance;
243 displayedPhylogenyMightHaveChanged( false );
245 else if ( e.getSource() == _uncollapse_all ) {
247 displayedPhylogenyMightHaveChanged( false );
249 else if ( e.getSource() == _zoom_in_domain_structure ) {
250 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
251 displayedPhylogenyMightHaveChanged( true );
253 else if ( e.getSource() == _zoom_out_domain_structure ) {
254 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
255 displayedPhylogenyMightHaveChanged( true );
257 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
258 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThreshold();
259 displayedPhylogenyMightHaveChanged( true );
261 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
262 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThreshold();
263 displayedPhylogenyMightHaveChanged( true );
265 else if ( e.getSource() == _search_tf ) {
267 displayedPhylogenyMightHaveChanged( true );
270 displayedPhylogenyMightHaveChanged( true );
274 tp.requestFocusInWindow();
277 catch ( final Exception ex ) {
278 Util.unexpectedException( ex );
280 catch ( final Error err ) {
281 Util.unexpectedError( err );
285 void activateButtonToReturnToSuperTree( int index ) {
288 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
291 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
293 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
294 _return_to_super_tree.setEnabled( true );
298 * Add zoom and quick edit buttons. (Last modified 8/9/04)
301 final JLabel spacer = new JLabel( "" );
302 spacer.setOpaque( false );
304 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
305 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
306 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
307 if ( !getConfiguration().isUseNativeUI() ) {
308 x_panel.setBackground( getBackground() );
309 y_panel.setBackground( getBackground() );
310 z_panel.setBackground( getBackground() );
312 add( _zoom_label = new JLabel( "Zoom:" ) );
313 customizeLabel( _zoom_label, getConfiguration() );
317 if ( getConfiguration().isUseNativeUI() ) {
318 _zoom_in_x = new JButton( "+" );
319 _zoom_out_x = new JButton( "-" );
322 _zoom_in_x = new JButton( "X+" );
323 _zoom_out_x = new JButton( "X-" );
325 _zoom_in_y = new JButton( "Y+" );
326 _zoom_out_y = new JButton( "Y-" );
327 _show_whole = new JButton( "F" );
328 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [Backspace]" );
329 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+Right]" );
330 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+Up]" );
331 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+Left]" );
332 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+Down]" );
333 if ( getConfiguration().isUseNativeUI() && Util.isMac() ) {
334 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
335 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
338 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
339 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
341 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
342 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
343 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
344 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
345 _return_to_super_tree.setEnabled( false );
346 _order = new JButton( "Order Subtrees" );
347 _uncollapse_all = new JButton( "Uncollapse All" );
348 addJButton( _zoom_in_y, x_panel );
349 addJButton( _zoom_out_x, y_panel );
350 addJButton( _show_whole, y_panel );
351 addJButton( _zoom_in_x, y_panel );
352 addJButton( _zoom_out_y, z_panel );
353 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
354 setUpControlsForDomainStrucures();
356 final JLabel spacer2 = new JLabel( "" );
358 addJButton( _return_to_super_tree, this );
359 addJButton( _order, this );
360 addJButton( _uncollapse_all, this );
361 final JLabel spacer3 = new JLabel( "" );
363 setVisibilityOfDomainStrucureControls();
366 void addCheckbox( final int which, final String title ) {
367 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
369 case Configuration.display_as_phylogram:
370 _display_as_phylogram_cb = new JCheckBox( title );
371 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
372 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
375 case Configuration.display_internal_data:
376 _display_internal_data = new JCheckBox( title );
377 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
378 addJCheckBox( _display_internal_data, ch_panel );
381 case Configuration.color_according_to_species:
382 _color_acc_species = new JCheckBox( title );
384 .setToolTipText( "To colorize taxonomy and sequence labels as a function of taxonomy" );
385 addJCheckBox( _color_acc_species, ch_panel );
388 case Configuration.color_according_to_annotation:
389 _color_according_to_annotation = new JCheckBox( title );
390 _color_according_to_annotation
391 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
392 addJCheckBox( _color_according_to_annotation, ch_panel );
395 case Configuration.show_node_names:
396 _show_node_names = new JCheckBox( title );
397 addJCheckBox( _show_node_names, ch_panel );
400 case Configuration.show_taxonomy_scientific_names:
401 _show_taxo_scientific_names = new JCheckBox( title );
402 addJCheckBox( _show_taxo_scientific_names, ch_panel );
405 case Configuration.show_taxonomy_common_names:
406 _show_taxo_common_names = new JCheckBox( title );
407 addJCheckBox( _show_taxo_common_names, ch_panel );
410 case Configuration.show_tax_code:
411 _show_taxo_code = new JCheckBox( title );
412 addJCheckBox( _show_taxo_code, ch_panel );
415 case Configuration.show_taxonomy_images:
416 _show_taxo_images_cb = new JCheckBox( title );
417 addJCheckBox( _show_taxo_images_cb, ch_panel );
420 case Configuration.show_binary_characters:
421 _show_binary_characters = new JCheckBox( title );
422 addJCheckBox( _show_binary_characters, ch_panel );
425 case Configuration.show_annotation:
426 _show_annotation = new JCheckBox( title );
427 addJCheckBox( _show_annotation, ch_panel );
430 case Configuration.show_binary_character_counts:
431 _show_binary_character_counts = new JCheckBox( title );
432 addJCheckBox( _show_binary_character_counts, ch_panel );
435 case Configuration.write_confidence_values:
436 _write_confidence = new JCheckBox( title );
437 addJCheckBox( getWriteConfidenceCb(), ch_panel );
440 case Configuration.write_events:
441 _show_events = new JCheckBox( title );
442 addJCheckBox( getShowEventsCb(), ch_panel );
445 case Configuration.color_branches:
446 _color_branches_cb = new JCheckBox( title );
447 getColorBranchesCb().setToolTipText( "To use branch color values, if present" );
448 addJCheckBox( getColorBranchesCb(), ch_panel );
451 case Configuration.width_branches:
452 _width_branches = new JCheckBox( title );
453 _width_branches.setToolTipText( "To use branch width values, if present" );
454 addJCheckBox( _width_branches, ch_panel );
457 case Configuration.show_domain_architectures:
458 _show_domain_architectures = new JCheckBox( title );
459 addJCheckBox( _show_domain_architectures, ch_panel );
462 case Configuration.show_gene_names:
463 _show_gene_names = new JCheckBox( title );
464 addJCheckBox( _show_gene_names, ch_panel );
467 case Configuration.show_gene_symbols:
468 _show_gene_symbols = new JCheckBox( title );
469 addJCheckBox( _show_gene_symbols, ch_panel );
472 case Configuration.show_sequence_acc:
473 _show_sequence_acc = new JCheckBox( title );
474 addJCheckBox( _show_sequence_acc, ch_panel );
477 case Configuration.dynamically_hide_data:
478 _dynamically_hide_data = new JCheckBox( title );
479 getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" );
480 addJCheckBox( getDynamicallyHideData(), ch_panel );
483 case Configuration.node_data_popup:
484 _node_desc_popup_cb = new JCheckBox( title );
485 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
486 addJCheckBox( getNodeDescPopupCb(), ch_panel );
489 case Configuration.show_relation_confidence:
490 _seq_relation_confidence_switch = new JCheckBox( title );
491 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
494 case Configuration.show_vector_data:
495 _show_vector_data_cb = new JCheckBox( title );
496 addJCheckBox( _show_vector_data_cb, ch_panel );
499 case Configuration.show_properties:
500 _show_properties_cb = new JCheckBox( title );
501 addJCheckBox( _show_properties_cb, ch_panel );
505 throw new RuntimeException( "unknown checkbox: " + which );
509 private void addClickToOption( final int which, final String title ) {
510 _click_to_combobox.addItem( title );
511 _click_to_names.add( title );
512 _all_click_to_names.put( new Integer( which ), title );
513 if ( !_configuration.isUseNativeUI() ) {
514 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
515 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
519 void addJButton( final JButton jb, final JPanel p ) {
520 jb.setFocusPainted( false );
521 jb.setFont( ControlPanel.jcb_font );
522 if ( !_configuration.isUseNativeUI() ) {
523 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
524 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
525 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
528 jb.addActionListener( this );
531 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
532 jcb.setFocusPainted( false );
533 jcb.setFont( ControlPanel.jcb_font );
534 if ( !_configuration.isUseNativeUI() ) {
535 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
536 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
538 p.add( jcb, "Center" );
539 jcb.addActionListener( this );
542 void addJTextField( final JTextField tf, final JPanel p ) {
543 if ( !_configuration.isUseNativeUI() ) {
544 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
545 tf.setFont( ControlPanel.jcb_font );
548 tf.addActionListener( this );
552 private void addSequenceRelationBlock() {
553 final JLabel spacer = new JLabel( "" );
554 spacer.setSize( 1, 1 );
556 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
557 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
558 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
559 getSequenceRelationTypeBox().setFocusable( false );
560 _sequence_relation_type_box.setFont( ControlPanel.js_font );
561 if ( !_configuration.isUseNativeUI() ) {
562 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
563 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
565 _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
568 public Component getListCellRendererComponent( final JList list,
571 final boolean isSelected,
572 final boolean cellHasFocus ) {
573 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
578 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
579 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
580 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
585 final GridBagLayout gbl = new GridBagLayout();
586 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
587 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
588 final JPanel horizGrid = new JPanel( gbl );
589 horizGrid.setBackground( getBackground() );
590 horizGrid.add( typeLabel );
591 horizGrid.add( _sequence_relation_type_box );
592 add( customizeLabel( mainLabel, getConfiguration() ) );
594 add( getSequenceRelationBox() );
595 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
596 addCheckbox( Configuration.show_relation_confidence,
597 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
598 setCheckbox( Configuration.show_relation_confidence,
599 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
601 }// addSequenceRelationBlock
603 void deactivateButtonToReturnToSuperTree() {
604 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
605 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
606 _return_to_super_tree.setEnabled( false );
609 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
610 if ( ( _mainpanel != null ) && ( _mainpanel.getCurrentPhylogeny() != null ) ) {
611 if ( getOptions().isShowOverview() ) {
612 _mainpanel.getCurrentTreePanel().updateOvSizes();
614 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
615 setVisibilityOfDomainStrucureControls();
616 updateDomainStructureEvaluethresholdDisplay();
617 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
618 _mainpanel.getCurrentTreePanel().calcMaxDepth();
619 _mainpanel.adjustJScrollPane();
620 if ( recalc_longest_ext_node_info ) {
621 _mainpanel.getCurrentTreePanel().initNodeData();
622 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
624 _mainpanel.getCurrentTreePanel().repaint();
625 // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
629 void endClickToOptions() {
630 _click_to_combobox.addActionListener( this );
634 * Indicates what action should be execute when a node is clicked
636 * @return the click-on action
638 NodeClickAction getActionWhenNodeClicked() {
639 return _action_when_node_clicked;
642 Map<Integer, String> getAllClickToItems() {
643 return _all_click_to_names;
646 Map<String, Color> getAnnotationColors() {
647 return _annotation_colors;
650 public JCheckBox getColorBranchesCb() {
651 return _color_branches_cb;
654 public JCheckBox getColorAccSpeciesCb() {
655 return _color_acc_species;
658 Configuration getConfiguration() {
659 return _configuration;
662 TreePanel getCurrentTreePanel() {
663 return getMainPanel().getCurrentTreePanel();
666 public JCheckBox getDisplayAsPhylogramCb() {
667 return _display_as_phylogram_cb;
670 public JCheckBox getDynamicallyHideData() {
671 return _dynamically_hide_data;
675 private List<Boolean> getIsDrawPhylogramList() {
676 return _draw_phylogram;
679 MainPanel getMainPanel() {
683 public JCheckBox getNodeDescPopupCb() {
684 return _node_desc_popup_cb;
687 Options getOptions() {
688 return getMainPanel().getOptions();
691 private JLabel getSearchFoundCountsLabel() {
692 return _search_found_label;
695 private JButton getSearchResetButton() {
696 return _search_reset_button;
699 JTextField getSearchTextField() {
703 public Sequence getSelectedQuerySequence() {
704 return _selected_query_seq;
707 public JComboBox getSequenceRelationBox() {
708 if ( _show_sequence_relations == null ) {
709 _show_sequence_relations = new JComboBox();
710 _show_sequence_relations.setFocusable( false );
711 _show_sequence_relations.setMaximumRowCount( 20 );
712 _show_sequence_relations.setFont( ControlPanel.js_font );
713 if ( !_configuration.isUseNativeUI() ) {
714 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
715 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
717 _show_sequence_relations.addItem( "-----" );
718 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
720 return _show_sequence_relations;
724 public JComboBox getSequenceRelationTypeBox() {
725 if ( _sequence_relation_type_box == null ) {
726 _sequence_relation_type_box = new JComboBox();
727 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
728 _sequence_relation_type_box.addItem( type );
730 _sequence_relation_type_box.addActionListener( new ActionListener() {
733 public void actionPerformed( final ActionEvent e ) {
734 if ( _mainpanel.getCurrentPhylogeny() != null ) {
735 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
740 return _sequence_relation_type_box;
743 public JCheckBox getShowEventsCb() {
747 List<String> getSingleClickToNames() {
748 return _click_to_names;
751 Map<String, Color> getSpeciesColors() {
752 return _species_colors;
755 public JCheckBox getWriteConfidenceCb() {
756 return _write_confidence;
759 private void init() {
760 _draw_phylogram = new ArrayList<Boolean>();
761 setSpeciesColors( new HashMap<String, Color>() );
762 setAnnotationColors( new HashMap<String, Color>() );
765 boolean isAntialiasScreenText() {
769 boolean isColorAccordingToAnnotation() {
770 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
773 boolean isColorAccordingToTaxonomy() {
774 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
777 boolean isColorBranches() {
778 return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) );
781 boolean isDrawPhylogram() {
782 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
785 private boolean isDrawPhylogram( final int index ) {
786 return getIsDrawPhylogramList().get( index );
789 boolean isDynamicallyHideData() {
790 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
794 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
797 boolean isNodeDescPopup() {
798 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
801 boolean isShowAnnotation() {
802 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
805 boolean isShowBinaryCharacterCounts() {
806 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
809 boolean isShowBinaryCharacters() {
810 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
813 boolean isShowBootstrapValues() {
814 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
817 boolean isShowDomainArchitectures() {
818 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
821 boolean isShowGeneNames() {
822 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
825 public boolean isShowVectorData() {
826 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
829 public boolean isShowProperties() {
830 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
833 boolean isShowGeneSymbols() {
834 return ( ( _show_gene_symbols != null ) && _show_gene_symbols.isSelected() );
837 boolean isShowInternalData() {
838 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
841 boolean isShowNodeNames() {
842 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
845 boolean isShowSequenceAcc() {
846 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
849 boolean isShowSequenceRelationConfidence() {
850 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
853 boolean isShowSequenceRelations() {
854 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
857 boolean isShowTaxonomyCode() {
858 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
861 public boolean isShowTaxonomyImages() {
862 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
865 boolean isShowTaxonomyCommonNames() {
866 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
869 boolean isShowTaxonomyScientificNames() {
870 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
873 boolean isWidthBranches() {
874 return ( ( _width_branches != null ) && _width_branches.isSelected() );
877 void phylogenyAdded( final Configuration configuration ) {
878 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
881 void phylogenyRemoved( final int index ) {
882 getIsDrawPhylogramList().remove( index );
886 final MainPanel main_panel = getMainPanel();
887 final Phylogeny tree = main_panel.getCurrentPhylogeny();
888 if ( ( tree == null ) || tree.isEmpty() ) {
891 String query = getSearchTextField().getText();
892 if ( query != null ) {
893 query = query.trim();
896 getSearchFoundCountsLabel().setVisible( false );
897 getSearchResetButton().setEnabled( false );
898 getSearchResetButton().setVisible( false );
901 if ( !ForesterUtil.isEmpty( query ) ) {
902 search( main_panel, tree, query );
905 getSearchFoundCountsLabel().setVisible( false );
906 getSearchResetButton().setEnabled( false );
907 getSearchResetButton().setVisible( false );
912 private void search( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
913 getSearchFoundCountsLabel().setVisible( true );
914 getSearchResetButton().setEnabled( true );
915 getSearchResetButton().setVisible( true );
916 String[] queries = null;
917 List<PhylogenyNode> nodes = null;
918 if ( query_str.indexOf( ',' ) >= 0 ) {
919 queries = query_str.split( ",+" );
922 queries = new String[ 1 ];
923 queries[ 0 ] = query_str.trim();
925 if ( ( queries != null ) && ( queries.length > 0 ) ) {
926 nodes = new ArrayList<PhylogenyNode>();
927 for( String query : queries ) {
928 if ( ForesterUtil.isEmpty( query ) ) {
931 query = query.trim();
932 if ( query.indexOf( '+' ) >= 0 ) {
933 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ), tree, getOptions()
934 .isSearchCaseSensitive(), !getOptions().isMatchWholeTermsOnly() ) );
937 nodes.addAll( PhylogenyMethods.searchData( query,
939 getOptions().isSearchCaseSensitive(),
940 !getOptions().isMatchWholeTermsOnly() ) );
943 if ( getOptions().isInverseSearchResult() ) {
944 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
945 all.removeAll( nodes );
949 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
950 main_panel.getCurrentTreePanel().setFoundNodes( new HashSet<Integer>() );
951 for( final PhylogenyNode node : nodes ) {
952 main_panel.getCurrentTreePanel().getFoundNodes().add( node.getId() );
954 setSearchFoundCountsOnLabel( nodes.size() );
957 setSearchFoundCountsOnLabel( 0 );
962 private void searchReset() {
963 if ( getMainPanel().getCurrentTreePanel() != null ) {
964 getMainPanel().getCurrentTreePanel().setFoundNodes( null );
968 void setActionWhenNodeClicked( final NodeClickAction action ) {
969 _action_when_node_clicked = action;
972 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
973 _annotation_colors = annotation_colors;
976 void setCheckbox( final int which, final boolean state ) {
978 case Configuration.display_as_phylogram:
979 if ( getDisplayAsPhylogramCb() != null ) {
980 getDisplayAsPhylogramCb().setSelected( state );
983 case Configuration.display_internal_data:
984 if ( _display_internal_data != null ) {
985 _display_internal_data.setSelected( state );
988 case Configuration.color_according_to_species:
989 if ( _color_acc_species != null ) {
990 _color_acc_species.setSelected( state );
993 case Configuration.color_according_to_annotation:
994 if ( _color_according_to_annotation != null ) {
995 _color_according_to_annotation.setSelected( state );
998 case Configuration.show_node_names:
999 if ( _show_node_names != null ) {
1000 _show_node_names.setSelected( state );
1003 case Configuration.show_taxonomy_scientific_names:
1004 if ( _show_taxo_scientific_names != null ) {
1005 _show_taxo_scientific_names.setSelected( state );
1008 case Configuration.show_taxonomy_common_names:
1009 if ( _show_taxo_common_names != null ) {
1010 _show_taxo_common_names.setSelected( state );
1013 case Configuration.show_tax_code:
1014 if ( _show_taxo_code != null ) {
1015 _show_taxo_code.setSelected( state );
1018 case Configuration.show_taxonomy_images:
1019 if ( _show_taxo_images_cb != null ) {
1020 _show_taxo_images_cb.setSelected( state );
1023 case Configuration.show_annotation:
1024 if ( _show_annotation != null ) {
1025 _show_annotation.setSelected( state );
1028 case Configuration.show_binary_characters:
1029 if ( _show_binary_characters != null ) {
1030 _show_binary_characters.setSelected( state );
1033 case Configuration.show_binary_character_counts:
1034 if ( _show_binary_character_counts != null ) {
1035 _show_binary_character_counts.setSelected( state );
1038 case Configuration.write_confidence_values:
1039 if ( getWriteConfidenceCb() != null ) {
1040 getWriteConfidenceCb().setSelected( state );
1043 case Configuration.write_events:
1044 if ( getShowEventsCb() != null ) {
1045 getShowEventsCb().setSelected( state );
1048 case Configuration.color_branches:
1049 if ( getColorBranchesCb() != null ) {
1050 getColorBranchesCb().setSelected( state );
1053 case Configuration.width_branches:
1054 if ( _width_branches != null ) {
1055 _width_branches.setSelected( state );
1058 case Configuration.show_domain_architectures:
1059 if ( _show_domain_architectures != null ) {
1060 _show_domain_architectures.setSelected( state );
1063 case Configuration.show_gene_names:
1064 if ( _show_gene_names != null ) {
1065 _show_gene_names.setSelected( state );
1068 case Configuration.show_gene_symbols:
1069 if ( _show_gene_symbols != null ) {
1070 _show_gene_symbols.setSelected( state );
1073 case Configuration.show_vector_data:
1074 if ( _show_vector_data_cb != null ) {
1075 _show_vector_data_cb.setSelected( state );
1078 case Configuration.show_properties:
1079 if ( _show_properties_cb != null ) {
1080 _show_properties_cb.setSelected( state );
1083 case Configuration.show_sequence_acc:
1084 if ( _show_sequence_acc != null ) {
1085 _show_sequence_acc.setSelected( state );
1088 case Configuration.dynamically_hide_data:
1089 if ( getDynamicallyHideData() != null ) {
1090 getDynamicallyHideData().setSelected( state );
1093 case Configuration.node_data_popup:
1094 if ( getNodeDescPopupCb() != null ) {
1095 getNodeDescPopupCb().setSelected( state );
1099 case Configuration.show_relation_confidence:
1100 if ( _seq_relation_confidence_switch != null ) {
1101 _seq_relation_confidence_switch.setSelected( state );
1106 throw new AssertionError( "unknown checkbox: " + which );
1111 * Set this checkbox state. Not all checkboxes have been instantiated
1112 * depending on the config.
1114 void setCheckbox( final JCheckBox cb, final boolean state ) {
1116 cb.setSelected( state );
1120 void setClickToAction( final int action ) {
1121 // Set click-to action
1122 if ( action == _show_data_item ) {
1123 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1125 else if ( action == _collapse_cb_item ) {
1126 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1128 else if ( action == _reroot_cb_item ) {
1129 setActionWhenNodeClicked( NodeClickAction.REROOT );
1131 else if ( action == _subtree_cb_item ) {
1132 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1134 else if ( action == _swap_cb_item ) {
1135 setActionWhenNodeClicked( NodeClickAction.SWAP );
1137 else if ( action == _color_subtree_cb_item ) {
1138 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1140 else if ( action == _open_seq_web_item ) {
1141 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1143 else if ( action == _blast_item ) {
1144 if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
1145 setActionWhenNodeClicked( NodeClickAction.BLAST );
1148 else if ( action == _open_tax_web_item ) {
1149 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1151 else if ( action == _cut_subtree_item ) {
1152 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1154 else if ( action == _copy_subtree_item ) {
1155 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1157 else if ( action == _delete_node_or_subtree_item ) {
1158 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1160 else if ( action == _paste_subtree_item ) {
1161 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1163 else if ( action == _add_new_node_item ) {
1164 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1166 else if ( action == _edit_node_data_item ) {
1167 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1170 throw new RuntimeException( "unknown action: " + action );
1172 // make sure drop down is displaying the correct action
1173 // in case this was called from outside the class
1174 _click_to_combobox.setSelectedIndex( action );
1177 void setColorBranches( final boolean color_branches ) {
1178 _color_branches = color_branches;
1181 void setDrawPhylogram( final boolean b ) {
1182 getDisplayAsPhylogramCb().setSelected( b );
1183 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1186 private void setDrawPhylogram( final int index, final boolean b ) {
1187 getIsDrawPhylogramList().set( index, b );
1190 void setDrawPhylogramEnabled( final boolean b ) {
1191 getDisplayAsPhylogramCb().setEnabled( b );
1194 void setDynamicHidingIsOn( final boolean is_on ) {
1195 // if ( !_configuration.isUseNativeUI() ) {
1197 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1200 if ( !_configuration.isUseNativeUI() ) {
1201 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1204 getDynamicallyHideData().setForeground( Color.BLACK );
1210 private void setSearchFoundCountsOnLabel( final int counts ) {
1211 getSearchFoundCountsLabel().setText( "Found: " + counts );
1214 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
1215 final JComboBox box = getSequenceRelationBox();
1216 while ( box.getItemCount() > 1 ) {
1217 box.removeItemAt( 1 );
1219 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
1220 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
1222 if ( relationType == null ) {
1225 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
1226 for( final Sequence seq : sequenceRelationQueries ) {
1227 if ( seq.hasSequenceRelations() ) {
1228 boolean fFoundForCurrentType = false;
1229 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
1230 if ( sq.getType().equals( relationType ) ) {
1231 fFoundForCurrentType = true;
1235 if ( fFoundForCurrentType ) {
1236 sequenceNamesToAdd.add( seq.getName() );
1237 sequencesByName.put( seq.getName(), seq );
1241 // sort sequences by name before adding them to the combo
1242 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
1243 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
1244 for( final String seqName : sequenceNameArray ) {
1245 box.addItem( seqName );
1247 for( final ItemListener oldItemListener : box.getItemListeners() ) {
1248 box.removeItemListener( oldItemListener );
1250 box.addItemListener( new ItemListener() {
1253 public void itemStateChanged( final ItemEvent e ) {
1254 _selected_query_seq = sequencesByName.get( e.getItem() );
1255 _mainpanel.getCurrentTreePanel().repaint();
1260 void setShowEvents( final boolean show_events ) {
1261 if ( getShowEventsCb() == null ) {
1262 _show_events = new JCheckBox( "" );
1264 getShowEventsCb().setSelected( show_events );
1267 void setSpeciesColors( final Map<String, Color> species_colors ) {
1268 _species_colors = species_colors;
1271 private void setupClickToOptions() {
1272 final int default_option = _configuration.getDefaultDisplayClicktoOption();
1273 int selected_index = 0;
1275 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1276 _show_data_item = cb_index;
1277 addClickToOption( Configuration.display_node_data,
1278 _configuration.getClickToTitle( Configuration.display_node_data ) );
1279 if ( default_option == Configuration.display_node_data ) {
1280 selected_index = cb_index;
1284 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1285 _collapse_cb_item = cb_index;
1286 addClickToOption( Configuration.collapse_uncollapse,
1287 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
1288 if ( default_option == Configuration.collapse_uncollapse ) {
1289 selected_index = cb_index;
1293 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1294 _reroot_cb_item = cb_index;
1295 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1296 if ( default_option == Configuration.reroot ) {
1297 selected_index = cb_index;
1301 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1302 _subtree_cb_item = cb_index;
1303 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1304 if ( default_option == Configuration.subtree ) {
1305 selected_index = cb_index;
1309 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1310 _swap_cb_item = cb_index;
1311 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1312 if ( default_option == Configuration.swap ) {
1313 selected_index = cb_index;
1317 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1318 _color_subtree_cb_item = cb_index;
1319 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1320 if ( default_option == Configuration.color_subtree ) {
1321 selected_index = cb_index;
1325 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1326 _open_seq_web_item = cb_index;
1327 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1328 if ( default_option == Configuration.open_seq_web ) {
1329 selected_index = cb_index;
1333 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1334 _open_tax_web_item = cb_index;
1335 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1336 if ( default_option == Configuration.open_tax_web ) {
1337 selected_index = cb_index;
1341 if ( getOptions().isEditable() ) {
1342 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
1343 _cut_subtree_item = cb_index;
1344 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
1345 if ( default_option == Configuration.cut_subtree ) {
1346 selected_index = cb_index;
1350 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
1351 _copy_subtree_item = cb_index;
1352 addClickToOption( Configuration.copy_subtree,
1353 _configuration.getClickToTitle( Configuration.copy_subtree ) );
1354 if ( default_option == Configuration.copy_subtree ) {
1355 selected_index = cb_index;
1359 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
1360 _paste_subtree_item = cb_index;
1361 addClickToOption( Configuration.paste_subtree,
1362 _configuration.getClickToTitle( Configuration.paste_subtree ) );
1363 if ( default_option == Configuration.paste_subtree ) {
1364 selected_index = cb_index;
1368 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
1369 _delete_node_or_subtree_item = cb_index;
1370 addClickToOption( Configuration.delete_subtree_or_node,
1371 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
1372 if ( default_option == Configuration.delete_subtree_or_node ) {
1373 selected_index = cb_index;
1377 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
1378 _add_new_node_item = cb_index;
1379 addClickToOption( Configuration.add_new_node,
1380 _configuration.getClickToTitle( Configuration.add_new_node ) );
1381 if ( default_option == Configuration.add_new_node ) {
1382 selected_index = cb_index;
1386 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
1387 _edit_node_data_item = cb_index;
1388 addClickToOption( Configuration.edit_node_data,
1389 _configuration.getClickToTitle( Configuration.edit_node_data ) );
1390 if ( default_option == Configuration.edit_node_data ) {
1391 selected_index = cb_index;
1395 if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
1396 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1397 _blast_item = cb_index;
1398 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
1399 if ( default_option == Configuration.blast ) {
1400 selected_index = cb_index;
1406 // Set default selection and its action
1407 _click_to_combobox.setSelectedIndex( selected_index );
1408 setClickToAction( selected_index );
1413 * Set up the controls from the config settings. 11/26/05
1415 void setupControls() {
1416 // The tree display options:
1417 setupDisplayCheckboxes();
1419 // The sequence relation query selection combo-box
1420 if ( _configuration.displaySequenceRelations() ) {
1421 addSequenceRelationBlock();
1425 startClickToOptions();
1426 setupClickToOptions();
1427 endClickToOptions();
1428 // Zoom and quick edit buttons
1433 void setUpControlsForDomainStrucures() {
1434 _domain_display_label = new JLabel( "Domain Display:" );
1435 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1436 add( _domain_display_label );
1437 _zoom_in_domain_structure = new JButton( "d+" );
1438 _zoom_out_domain_structure = new JButton( "d-" );
1439 _decr_domain_structure_evalue_thr = new JButton( "-" );
1440 _incr_domain_structure_evalue_thr = new JButton( "+" );
1441 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1442 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1443 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1444 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1445 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1446 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1447 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1448 _domain_structure_evalue_thr_tf.setEditable( false );
1449 if ( !getConfiguration().isUseNativeUI() ) {
1450 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1451 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1452 _domain_structure_evalue_thr_tf.setBorder( null );
1454 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1455 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1456 if ( !_configuration.isUseNativeUI() ) {
1457 d1_panel.setBackground( getBackground() );
1458 d2_panel.setBackground( getBackground() );
1462 addJButton( _zoom_out_domain_structure, d1_panel );
1463 addJButton( _zoom_in_domain_structure, d1_panel );
1464 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1465 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1466 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1469 private void setupDisplayCheckboxes() {
1470 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
1471 addCheckbox( Configuration.display_as_phylogram,
1472 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
1473 setCheckbox( Configuration.display_as_phylogram,
1474 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
1476 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1477 addCheckbox( Configuration.dynamically_hide_data,
1478 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
1479 setCheckbox( Configuration.dynamically_hide_data,
1480 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
1482 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1483 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1484 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1486 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1487 addCheckbox( Configuration.display_internal_data,
1488 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
1489 setCheckbox( Configuration.display_internal_data,
1490 _configuration.doCheckOption( Configuration.display_internal_data ) );
1492 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1493 addCheckbox( Configuration.color_according_to_species,
1494 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
1495 setCheckbox( Configuration.color_according_to_species,
1496 _configuration.doCheckOption( Configuration.color_according_to_species ) );
1498 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1499 addCheckbox( Configuration.color_according_to_annotation,
1500 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
1501 setCheckbox( Configuration.color_according_to_annotation,
1502 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
1504 if ( _configuration.doDisplayOption( Configuration.color_branches ) ) {
1505 addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) );
1506 setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) );
1508 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1509 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1510 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1512 final JLabel label = new JLabel( "Display Data:" );
1513 label.setFont( ControlPanel.jcb_bold_font );
1514 if ( !getConfiguration().isUseNativeUI() ) {
1515 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1518 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1519 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
1520 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1522 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1523 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1524 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1526 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1527 addCheckbox( Configuration.show_taxonomy_scientific_names,
1528 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1529 setCheckbox( Configuration.show_taxonomy_scientific_names,
1530 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1532 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1533 addCheckbox( Configuration.show_taxonomy_common_names,
1534 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1535 setCheckbox( Configuration.show_taxonomy_common_names,
1536 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1538 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1539 addCheckbox( Configuration.show_taxonomy_images,
1540 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1541 setCheckbox( Configuration.show_taxonomy_images,
1542 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1544 if ( _configuration.doDisplayOption( Configuration.show_gene_symbols ) ) {
1545 addCheckbox( Configuration.show_gene_symbols,
1546 _configuration.getDisplayTitle( Configuration.show_gene_symbols ) );
1547 setCheckbox( Configuration.show_gene_symbols,
1548 _configuration.doCheckOption( Configuration.show_gene_symbols ) );
1550 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1551 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1552 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1554 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1555 addCheckbox( Configuration.show_sequence_acc,
1556 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1557 setCheckbox( Configuration.show_sequence_acc,
1558 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1560 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1561 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
1562 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1564 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1565 addCheckbox( Configuration.show_binary_characters,
1566 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1567 setCheckbox( Configuration.show_binary_characters,
1568 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1570 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1571 addCheckbox( Configuration.show_binary_character_counts,
1572 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1573 setCheckbox( Configuration.show_binary_character_counts,
1574 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1576 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1577 addCheckbox( Configuration.show_domain_architectures,
1578 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1579 setCheckbox( Configuration.show_domain_architectures,
1580 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1582 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1583 addCheckbox( Configuration.write_confidence_values,
1584 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1585 setCheckbox( Configuration.write_confidence_values,
1586 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1588 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1589 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1590 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1592 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1593 addCheckbox( Configuration.show_vector_data,
1594 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1595 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
1597 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1598 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
1599 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1603 void setupSearchTools() {
1604 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1605 final JLabel search_label = new JLabel( "Search:" );
1606 search_label.setFont( ControlPanel.jcb_bold_font );
1607 if ( !getConfiguration().isUseNativeUI() ) {
1608 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1610 add( search_label );
1611 search_label.setToolTipText( tip );
1612 _search_found_label = new JLabel();
1613 getSearchFoundCountsLabel().setVisible( false );
1614 _search_found_label.setFont( ControlPanel.jcb_bold_font );
1615 if ( !getConfiguration().isUseNativeUI() ) {
1616 _search_found_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1618 _search_tf = new JTextField( 3 );
1619 _search_tf.setToolTipText( tip );
1620 _search_tf.setEditable( true );
1621 if ( !getConfiguration().isUseNativeUI() ) {
1622 _search_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1623 _search_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1624 _search_tf.setBorder( null );
1626 _search_reset_button = new JButton();
1627 getSearchResetButton().setText( "Reset" );
1628 getSearchResetButton().setEnabled( false );
1629 getSearchResetButton().setVisible( false );
1630 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1631 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1632 s_panel_1.setBackground( getBackground() );
1634 s_panel_2.setBackground( getBackground() );
1636 final KeyAdapter key_adapter = new KeyAdapter() {
1639 public void keyReleased( final KeyEvent key_event ) {
1641 displayedPhylogenyMightHaveChanged( true );
1644 final ActionListener action_listener = new ActionListener() {
1647 public void actionPerformed( final ActionEvent e ) {
1649 setSearchFoundCountsOnLabel( 0 );
1650 getSearchFoundCountsLabel().setVisible( false );
1651 getSearchTextField().setText( "" );
1652 getSearchResetButton().setEnabled( false );
1653 getSearchResetButton().setVisible( false );
1654 displayedPhylogenyMightHaveChanged( true );
1657 _search_reset_button.addActionListener( action_listener );
1658 _search_tf.addKeyListener( key_adapter );
1659 addJTextField( _search_tf, s_panel_1 );
1660 s_panel_2.add( _search_found_label );
1661 addJButton( _search_reset_button, s_panel_2 );
1664 private void setVisibilityOfDomainStrucureControls() {
1665 if ( _zoom_in_domain_structure != null ) {
1666 if ( isShowDomainArchitectures() ) {
1667 _domain_display_label.setVisible( true );
1668 _zoom_in_domain_structure.setVisible( true );
1669 _zoom_out_domain_structure.setVisible( true );
1670 _decr_domain_structure_evalue_thr.setVisible( true );
1671 _incr_domain_structure_evalue_thr.setVisible( true );
1672 _domain_structure_evalue_thr_tf.setVisible( true );
1675 _domain_display_label.setVisible( false );
1676 _zoom_in_domain_structure.setVisible( false );
1677 _zoom_out_domain_structure.setVisible( false );
1678 _decr_domain_structure_evalue_thr.setVisible( false );
1679 _incr_domain_structure_evalue_thr.setVisible( false );
1680 _domain_structure_evalue_thr_tf.setVisible( false );
1686 * Fit entire tree into window.
1689 if ( _mainpanel.getCurrentScrollPane() == null ) {
1692 displayedPhylogenyMightHaveChanged( false );
1693 _mainpanel.getCurrentTreePanel().updateOvSettings();
1694 _mainpanel.getCurrentTreePanel().validate();
1695 _mainpanel.validate();
1696 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1697 _mainpanel.getSizeOfViewport().height,
1699 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1700 _mainpanel.adjustJScrollPane();
1701 _mainpanel.getCurrentTreePanel().repaint();
1702 _mainpanel.getCurrentTreePanel().validate();
1703 _mainpanel.validate();
1704 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1705 _mainpanel.getSizeOfViewport().height,
1707 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1708 _mainpanel.adjustJScrollPane();
1709 _mainpanel.getCurrentTreePanel().repaint();
1710 _mainpanel.getCurrentTreePanel().updateOvSizes();
1713 void showWholeAll() {
1714 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1715 if ( tree_panel != null ) {
1716 tree_panel.validate();
1717 tree_panel.setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1718 _mainpanel.getSizeOfViewport().height,
1720 tree_panel.resetPreferredSize();
1721 tree_panel.repaint();
1726 // Create header for click-to combo box.
1727 void startClickToOptions() {
1728 final JLabel spacer = new JLabel( "" );
1729 spacer.setFont( ControlPanel.jcb_font );
1731 _click_to_label = new JLabel( "Click on Node to:" );
1732 add( customizeLabel( _click_to_label, getConfiguration() ) );
1733 _click_to_combobox = new JComboBox();
1734 _click_to_combobox.setFocusable( false );
1735 _click_to_combobox.setMaximumRowCount( 14 );
1736 _click_to_combobox.setFont( ControlPanel.js_font );
1737 if ( !_configuration.isUseNativeUI() ) {
1738 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1740 // don't add listener until all items are set (or each one will trigger
1742 // click_to_list.addActionListener(this);
1743 add( _click_to_combobox );
1744 // Correlates option names to titles
1745 _all_click_to_names = new HashMap<Integer, String>();
1746 _click_to_names = new ArrayList<String>();
1750 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1751 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1752 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1753 setDrawPhylogramEnabled( true );
1754 setDrawPhylogram( isDrawPhylogram() );
1757 setDrawPhylogramEnabled( false );
1758 setDrawPhylogram( false );
1760 if ( getMainPanel().getMainFrame() == null ) {
1761 // Must be "E" applet version.
1762 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1763 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1766 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1767 .getPhylogenyGraphicsType() );
1769 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1770 getMainPanel().getControlPanel().search();
1771 getSequenceRelationTypeBox().removeAllItems();
1772 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1773 .getRelevantSequenceRelationTypes() ) {
1774 _sequence_relation_type_box.addItem( type );
1776 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1777 // according to GUILHEM the line above can be removed.
1782 * Uncollapse all nodes.
1784 void uncollapseAll( final TreePanel tp ) {
1785 final Phylogeny t = tp.getPhylogeny();
1786 if ( ( t != null ) && !t.isEmpty() ) {
1787 t.setAllNodesToNotCollapse();
1788 t.recalculateNumberOfExternalDescendants( false );
1793 void updateDomainStructureEvaluethresholdDisplay() {
1794 if ( _domain_structure_evalue_thr_tf != null ) {
1795 _domain_structure_evalue_thr_tf.setText( "10^"
1796 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1800 void zoomInX( final float factor, final float x_correction_factor ) {
1801 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1802 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1803 treepanel.multiplyUrtFactor( 1f );
1804 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1805 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1806 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1807 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1808 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1809 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1810 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1811 getMainPanel().adjustJScrollPane();
1812 treepanel.resetPreferredSize();
1813 getMainPanel().getCurrentScrollPane().getViewport().validate();
1814 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1815 - ( sb.getVisibleAmount() / 2.0 ) ) );
1818 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1819 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1820 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1821 getMainPanel().adjustJScrollPane();
1822 treepanel.resetPreferredSize();
1823 getMainPanel().getCurrentScrollPane().getViewport().validate();
1824 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1826 treepanel.resetPreferredSize();
1827 treepanel.updateOvSizes();
1830 void zoomInY( final float factor ) {
1831 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1832 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1833 treepanel.multiplyUrtFactor( 1.1f );
1834 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1835 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1836 getMainPanel().adjustJScrollPane();
1837 treepanel.resetPreferredSize();
1838 getMainPanel().getCurrentScrollPane().getViewport().validate();
1839 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1840 - ( sb.getVisibleAmount() / 2.0 ) ) );
1841 treepanel.resetPreferredSize();
1842 treepanel.updateOvSizes();
1845 void zoomOutX( final float factor, final float x_correction_factor ) {
1846 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1847 treepanel.multiplyUrtFactor( 1f );
1848 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1849 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1850 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1851 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1852 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1853 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1854 getMainPanel().adjustJScrollPane();
1855 treepanel.resetPreferredSize();
1856 getMainPanel().getCurrentScrollPane().getViewport().validate();
1857 final double x = ( sb.getMaximum() - sb.getMinimum() )
1858 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1859 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1860 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1861 getMainPanel().adjustJScrollPane();
1862 treepanel.resetPreferredSize();
1863 getMainPanel().getCurrentScrollPane().getViewport().validate();
1864 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1865 - ( sb.getVisibleAmount() / 2.0 ) ) );
1868 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1869 treepanel.setXdistance( treepanel.getXdistance() * factor );
1870 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
1872 getMainPanel().adjustJScrollPane();
1873 treepanel.resetPreferredSize();
1874 getMainPanel().getCurrentScrollPane().getViewport().validate();
1875 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1878 treepanel.resetPreferredSize();
1879 treepanel.updateOvSizes();
1883 void zoomOutY( final float factor ) {
1884 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1885 treepanel.multiplyUrtFactor( 0.9f );
1886 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1887 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1888 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1889 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1890 getMainPanel().adjustJScrollPane();
1891 treepanel.resetPreferredSize();
1892 getMainPanel().getCurrentScrollPane().getViewport().validate();
1893 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1894 - ( sb.getVisibleAmount() / 2.0 ) ) );
1895 treepanel.resetPreferredSize();
1896 treepanel.updateOvSizes();
1900 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
1901 label.setFont( ControlPanel.jcb_bold_font );
1902 if ( !configuration.isUseNativeUI() ) {
1903 label.setForeground( configuration.getGuiCheckboxTextColor() );
1904 label.setBackground( configuration.getGuiBackgroundColor() );
1909 enum NodeClickAction {
1920 DELETE_NODE_OR_SUBTREE,