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.phylogeny.iterators.PhylogenyNodeIterator;
68 import org.forester.util.ForesterUtil;
70 final class ControlPanel extends JPanel implements ActionListener {
72 private static final String RETURN_TO_SUPER_TREE_TEXT = "Back to Super Tree";
73 final static Font jcb_font = new Font( Configuration.getDefaultFontFamilyName(),
76 final static Font js_font = new Font( Configuration.getDefaultFontFamilyName(),
79 final static Font jcb_bold_font = new Font( Configuration.getDefaultFontFamilyName(),
82 private static final long serialVersionUID = -8463483932821545633L;
83 private final MainPanel _mainpanel;
84 // The settings from the conf file
85 private final Configuration _configuration;
87 private JCheckBox _display_internal_data;
88 private JCheckBox _show_node_names;
89 private JCheckBox _show_taxo_code;
90 private JCheckBox _write_confidence;
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_events:
442 _show_events = new JCheckBox( title );
443 addJCheckBox( getShowEventsCb(), ch_panel );
446 case Configuration.color_branches:
447 _color_branches_cb = new JCheckBox( title );
448 getColorBranchesCb().setToolTipText( "To use branch color values, if present" );
449 addJCheckBox( getColorBranchesCb(), ch_panel );
452 case Configuration.width_branches:
453 _width_branches = new JCheckBox( title );
454 _width_branches.setToolTipText( "To use branch width values, if present" );
455 addJCheckBox( _width_branches, ch_panel );
458 case Configuration.show_domain_architectures:
459 _show_domain_architectures = new JCheckBox( title );
460 addJCheckBox( _show_domain_architectures, ch_panel );
463 case Configuration.show_gene_names:
464 _show_gene_names = new JCheckBox( title );
465 addJCheckBox( _show_gene_names, ch_panel );
468 case Configuration.show_gene_symbols:
469 _show_gene_symbols = new JCheckBox( title );
470 addJCheckBox( _show_gene_symbols, ch_panel );
473 case Configuration.show_sequence_acc:
474 _show_sequence_acc = new JCheckBox( title );
475 addJCheckBox( _show_sequence_acc, ch_panel );
478 case Configuration.dynamically_hide_data:
479 _dynamically_hide_data = new JCheckBox( title );
480 getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" );
481 addJCheckBox( getDynamicallyHideData(), ch_panel );
484 case Configuration.node_data_popup:
485 _node_desc_popup_cb = new JCheckBox( title );
486 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
487 addJCheckBox( getNodeDescPopupCb(), ch_panel );
490 case Configuration.show_relation_confidence:
491 _seq_relation_confidence_switch = new JCheckBox( title );
492 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
495 case Configuration.show_vector_data:
496 _show_vector_data_cb = new JCheckBox( title );
497 addJCheckBox( _show_vector_data_cb, ch_panel );
500 case Configuration.show_properties:
501 _show_properties_cb = new JCheckBox( title );
502 addJCheckBox( _show_properties_cb, ch_panel );
506 throw new RuntimeException( "unknown checkbox: " + which );
510 private void addClickToOption( final int which, final String title ) {
511 _click_to_combobox.addItem( title );
512 _click_to_names.add( title );
513 _all_click_to_names.put( new Integer( which ), title );
514 if ( !_configuration.isUseNativeUI() ) {
515 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
516 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
520 void addJButton( final JButton jb, final JPanel p ) {
521 jb.setFocusPainted( false );
522 jb.setFont( ControlPanel.jcb_font );
523 if ( !_configuration.isUseNativeUI() ) {
524 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
525 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
526 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
529 jb.addActionListener( this );
532 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
533 jcb.setFocusPainted( false );
534 jcb.setFont( ControlPanel.jcb_font );
535 if ( !_configuration.isUseNativeUI() ) {
536 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
537 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
539 p.add( jcb, "Center" );
540 jcb.addActionListener( this );
543 void addJTextField( final JTextField tf, final JPanel p ) {
544 if ( !_configuration.isUseNativeUI() ) {
545 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
546 tf.setFont( ControlPanel.jcb_font );
549 tf.addActionListener( this );
553 private void addSequenceRelationBlock() {
554 final JLabel spacer = new JLabel( "" );
555 spacer.setSize( 1, 1 );
557 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
558 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
559 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
560 getSequenceRelationTypeBox().setFocusable( false );
561 _sequence_relation_type_box.setFont( ControlPanel.js_font );
562 if ( !_configuration.isUseNativeUI() ) {
563 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
564 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
566 _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
569 public Component getListCellRendererComponent( final JList list,
572 final boolean isSelected,
573 final boolean cellHasFocus ) {
574 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
579 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
580 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
581 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
586 final GridBagLayout gbl = new GridBagLayout();
587 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
588 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
589 final JPanel horizGrid = new JPanel( gbl );
590 horizGrid.setBackground( getBackground() );
591 horizGrid.add( typeLabel );
592 horizGrid.add( _sequence_relation_type_box );
593 add( customizeLabel( mainLabel, getConfiguration() ) );
595 add( getSequenceRelationBox() );
596 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
597 addCheckbox( Configuration.show_relation_confidence,
598 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
599 setCheckbox( Configuration.show_relation_confidence,
600 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
602 }// addSequenceRelationBlock
604 void deactivateButtonToReturnToSuperTree() {
605 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
606 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
607 _return_to_super_tree.setEnabled( false );
610 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
611 if ( ( _mainpanel != null ) && ( _mainpanel.getCurrentPhylogeny() != null ) ) {
612 if ( getOptions().isShowOverview() ) {
613 _mainpanel.getCurrentTreePanel().updateOvSizes();
615 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
616 setVisibilityOfDomainStrucureControls();
617 updateDomainStructureEvaluethresholdDisplay();
618 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
619 _mainpanel.getCurrentTreePanel().calcMaxDepth();
620 _mainpanel.adjustJScrollPane();
621 if ( recalc_longest_ext_node_info ) {
622 _mainpanel.getCurrentTreePanel().initNodeData();
623 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
625 _mainpanel.getCurrentTreePanel().repaint();
626 // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
630 void endClickToOptions() {
631 _click_to_combobox.addActionListener( this );
635 * Indicates what action should be execute when a node is clicked
637 * @return the click-on action
639 NodeClickAction getActionWhenNodeClicked() {
640 return _action_when_node_clicked;
643 Map<Integer, String> getAllClickToItems() {
644 return _all_click_to_names;
647 Map<String, Color> getAnnotationColors() {
648 return _annotation_colors;
651 public JCheckBox getColorBranchesCb() {
652 return _color_branches_cb;
655 public JCheckBox getColorAccSpeciesCb() {
656 return _color_acc_species;
659 Configuration getConfiguration() {
660 return _configuration;
663 TreePanel getCurrentTreePanel() {
664 return getMainPanel().getCurrentTreePanel();
667 public JCheckBox getDisplayAsPhylogramCb() {
668 return _display_as_phylogram_cb;
671 public JCheckBox getDynamicallyHideData() {
672 return _dynamically_hide_data;
676 private List<Boolean> getIsDrawPhylogramList() {
677 return _draw_phylogram;
680 MainPanel getMainPanel() {
684 public JCheckBox getNodeDescPopupCb() {
685 return _node_desc_popup_cb;
688 Options getOptions() {
689 return getMainPanel().getOptions();
692 private JLabel getSearchFoundCountsLabel() {
693 return _search_found_label;
696 private JButton getSearchResetButton() {
697 return _search_reset_button;
700 JTextField getSearchTextField() {
704 public Sequence getSelectedQuerySequence() {
705 return _selected_query_seq;
708 public JComboBox getSequenceRelationBox() {
709 if ( _show_sequence_relations == null ) {
710 _show_sequence_relations = new JComboBox();
711 _show_sequence_relations.setFocusable( false );
712 _show_sequence_relations.setMaximumRowCount( 20 );
713 _show_sequence_relations.setFont( ControlPanel.js_font );
714 if ( !_configuration.isUseNativeUI() ) {
715 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
716 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
718 _show_sequence_relations.addItem( "-----" );
719 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
721 return _show_sequence_relations;
725 public JComboBox getSequenceRelationTypeBox() {
726 if ( _sequence_relation_type_box == null ) {
727 _sequence_relation_type_box = new JComboBox();
728 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
729 _sequence_relation_type_box.addItem( type );
731 _sequence_relation_type_box.addActionListener( new ActionListener() {
734 public void actionPerformed( final ActionEvent e ) {
735 if ( _mainpanel.getCurrentPhylogeny() != null ) {
736 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
741 return _sequence_relation_type_box;
744 public JCheckBox getShowEventsCb() {
748 List<String> getSingleClickToNames() {
749 return _click_to_names;
752 Map<String, Color> getSpeciesColors() {
753 return _species_colors;
756 public JCheckBox getWriteConfidenceCb() {
757 return _write_confidence;
760 private void init() {
761 _draw_phylogram = new ArrayList<Boolean>();
762 setSpeciesColors( new HashMap<String, Color>() );
763 setAnnotationColors( new HashMap<String, Color>() );
766 boolean isAntialiasScreenText() {
770 boolean isColorAccordingToAnnotation() {
771 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
774 boolean isColorAccordingToTaxonomy() {
775 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
778 boolean isColorBranches() {
779 return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) );
782 boolean isDrawPhylogram() {
783 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
786 private boolean isDrawPhylogram( final int index ) {
787 return getIsDrawPhylogramList().get( index );
790 boolean isDynamicallyHideData() {
791 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
795 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
798 boolean isNodeDescPopup() {
799 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
802 boolean isShowAnnotation() {
803 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
806 boolean isShowBinaryCharacterCounts() {
807 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
810 boolean isShowBinaryCharacters() {
811 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
814 boolean isShowConfidenceValues() {
815 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
818 boolean isShowDomainArchitectures() {
819 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
822 boolean isShowGeneNames() {
823 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
826 public boolean isShowVectorData() {
827 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
830 public boolean isShowProperties() {
831 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
834 boolean isShowGeneSymbols() {
835 return ( ( _show_gene_symbols != null ) && _show_gene_symbols.isSelected() );
838 boolean isShowInternalData() {
839 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
842 boolean isShowNodeNames() {
843 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
846 boolean isShowSequenceAcc() {
847 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
850 boolean isShowSequenceRelationConfidence() {
851 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
854 boolean isShowSequenceRelations() {
855 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
858 boolean isShowTaxonomyCode() {
859 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
862 public boolean isShowTaxonomyImages() {
863 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
866 boolean isShowTaxonomyCommonNames() {
867 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
870 boolean isShowTaxonomyScientificNames() {
871 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
874 boolean isWidthBranches() {
875 return ( ( _width_branches != null ) && _width_branches.isSelected() );
878 void phylogenyAdded( final Configuration configuration ) {
879 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
882 void phylogenyRemoved( final int index ) {
883 getIsDrawPhylogramList().remove( index );
887 final MainPanel main_panel = getMainPanel();
888 final Phylogeny tree = main_panel.getCurrentPhylogeny();
889 if ( ( tree == null ) || tree.isEmpty() ) {
892 String query = getSearchTextField().getText();
893 if ( query != null ) {
894 query = query.trim();
897 getSearchFoundCountsLabel().setVisible( false );
898 getSearchResetButton().setEnabled( false );
899 getSearchResetButton().setVisible( false );
902 if ( !ForesterUtil.isEmpty( query ) ) {
903 search( main_panel, tree, query );
906 getSearchFoundCountsLabel().setVisible( false );
907 getSearchResetButton().setEnabled( false );
908 getSearchResetButton().setVisible( false );
913 private void search( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
914 getSearchFoundCountsLabel().setVisible( true );
915 getSearchResetButton().setEnabled( true );
916 getSearchResetButton().setVisible( true );
917 String[] queries = null;
918 List<PhylogenyNode> nodes = null;
919 if ( query_str.indexOf( ',' ) >= 0 ) {
920 queries = query_str.split( ",+" );
923 queries = new String[ 1 ];
924 queries[ 0 ] = query_str.trim();
926 if ( ( queries != null ) && ( queries.length > 0 ) ) {
927 nodes = new ArrayList<PhylogenyNode>();
928 for( String query : queries ) {
929 if ( ForesterUtil.isEmpty( query ) ) {
932 query = query.trim();
933 if ( query.indexOf( '+' ) >= 0 ) {
934 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ), tree, getOptions()
935 .isSearchCaseSensitive(), !getOptions().isMatchWholeTermsOnly() ) );
938 nodes.addAll( PhylogenyMethods.searchData( query,
940 getOptions().isSearchCaseSensitive(),
941 !getOptions().isMatchWholeTermsOnly() ) );
944 if ( getOptions().isInverseSearchResult() ) {
945 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
946 all.removeAll( nodes );
950 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
951 main_panel.getCurrentTreePanel().setFoundNodes( new HashSet<Integer>() );
952 for( final PhylogenyNode node : nodes ) {
953 main_panel.getCurrentTreePanel().getFoundNodes().add( node.getId() );
955 setSearchFoundCountsOnLabel( nodes.size() );
958 setSearchFoundCountsOnLabel( 0 );
963 private void searchReset() {
964 if ( getMainPanel().getCurrentTreePanel() != null ) {
965 getMainPanel().getCurrentTreePanel().setFoundNodes( null );
969 void setActionWhenNodeClicked( final NodeClickAction action ) {
970 _action_when_node_clicked = action;
973 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
974 _annotation_colors = annotation_colors;
977 void setCheckbox( final int which, final boolean state ) {
979 case Configuration.display_as_phylogram:
980 if ( getDisplayAsPhylogramCb() != null ) {
981 getDisplayAsPhylogramCb().setSelected( state );
984 case Configuration.display_internal_data:
985 if ( _display_internal_data != null ) {
986 _display_internal_data.setSelected( state );
989 case Configuration.color_according_to_species:
990 if ( _color_acc_species != null ) {
991 _color_acc_species.setSelected( state );
994 case Configuration.color_according_to_annotation:
995 if ( _color_according_to_annotation != null ) {
996 _color_according_to_annotation.setSelected( state );
999 case Configuration.show_node_names:
1000 if ( _show_node_names != null ) {
1001 _show_node_names.setSelected( state );
1004 case Configuration.show_taxonomy_scientific_names:
1005 if ( _show_taxo_scientific_names != null ) {
1006 _show_taxo_scientific_names.setSelected( state );
1009 case Configuration.show_taxonomy_common_names:
1010 if ( _show_taxo_common_names != null ) {
1011 _show_taxo_common_names.setSelected( state );
1014 case Configuration.show_tax_code:
1015 if ( _show_taxo_code != null ) {
1016 _show_taxo_code.setSelected( state );
1019 case Configuration.show_taxonomy_images:
1020 if ( _show_taxo_images_cb != null ) {
1021 _show_taxo_images_cb.setSelected( state );
1024 case Configuration.show_annotation:
1025 if ( _show_annotation != null ) {
1026 _show_annotation.setSelected( state );
1029 case Configuration.show_binary_characters:
1030 if ( _show_binary_characters != null ) {
1031 _show_binary_characters.setSelected( state );
1034 case Configuration.show_binary_character_counts:
1035 if ( _show_binary_character_counts != null ) {
1036 _show_binary_character_counts.setSelected( state );
1039 case Configuration.write_confidence_values:
1040 if ( getWriteConfidenceCb() != null ) {
1041 getWriteConfidenceCb().setSelected( state );
1044 case Configuration.write_events:
1045 if ( getShowEventsCb() != null ) {
1046 getShowEventsCb().setSelected( state );
1049 case Configuration.color_branches:
1050 if ( getColorBranchesCb() != null ) {
1051 getColorBranchesCb().setSelected( state );
1054 case Configuration.width_branches:
1055 if ( _width_branches != null ) {
1056 _width_branches.setSelected( state );
1059 case Configuration.show_domain_architectures:
1060 if ( _show_domain_architectures != null ) {
1061 _show_domain_architectures.setSelected( state );
1064 case Configuration.show_gene_names:
1065 if ( _show_gene_names != null ) {
1066 _show_gene_names.setSelected( state );
1069 case Configuration.show_gene_symbols:
1070 if ( _show_gene_symbols != null ) {
1071 _show_gene_symbols.setSelected( state );
1074 case Configuration.show_vector_data:
1075 if ( _show_vector_data_cb != null ) {
1076 _show_vector_data_cb.setSelected( state );
1079 case Configuration.show_properties:
1080 if ( _show_properties_cb != null ) {
1081 _show_properties_cb.setSelected( state );
1084 case Configuration.show_sequence_acc:
1085 if ( _show_sequence_acc != null ) {
1086 _show_sequence_acc.setSelected( state );
1089 case Configuration.dynamically_hide_data:
1090 if ( getDynamicallyHideData() != null ) {
1091 getDynamicallyHideData().setSelected( state );
1094 case Configuration.node_data_popup:
1095 if ( getNodeDescPopupCb() != null ) {
1096 getNodeDescPopupCb().setSelected( state );
1100 case Configuration.show_relation_confidence:
1101 if ( _seq_relation_confidence_switch != null ) {
1102 _seq_relation_confidence_switch.setSelected( state );
1107 throw new AssertionError( "unknown checkbox: " + which );
1112 * Set this checkbox state. Not all checkboxes have been instantiated
1113 * depending on the config.
1115 void setCheckbox( final JCheckBox cb, final boolean state ) {
1117 cb.setSelected( state );
1121 void setClickToAction( final int action ) {
1122 // Set click-to action
1123 if ( action == _show_data_item ) {
1124 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1126 else if ( action == _collapse_cb_item ) {
1127 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1129 else if ( action == _reroot_cb_item ) {
1130 setActionWhenNodeClicked( NodeClickAction.REROOT );
1132 else if ( action == _subtree_cb_item ) {
1133 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1135 else if ( action == _swap_cb_item ) {
1136 setActionWhenNodeClicked( NodeClickAction.SWAP );
1138 else if ( action == _color_subtree_cb_item ) {
1139 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1141 else if ( action == _open_seq_web_item ) {
1142 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1144 else if ( action == _blast_item ) {
1145 if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
1146 setActionWhenNodeClicked( NodeClickAction.BLAST );
1149 else if ( action == _open_tax_web_item ) {
1150 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1152 else if ( action == _cut_subtree_item ) {
1153 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1155 else if ( action == _copy_subtree_item ) {
1156 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1158 else if ( action == _delete_node_or_subtree_item ) {
1159 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1161 else if ( action == _paste_subtree_item ) {
1162 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1164 else if ( action == _add_new_node_item ) {
1165 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1167 else if ( action == _edit_node_data_item ) {
1168 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1171 throw new RuntimeException( "unknown action: " + action );
1173 // make sure drop down is displaying the correct action
1174 // in case this was called from outside the class
1175 _click_to_combobox.setSelectedIndex( action );
1178 void setColorBranches( final boolean color_branches ) {
1179 _color_branches = color_branches;
1182 void setDrawPhylogram( final boolean b ) {
1183 getDisplayAsPhylogramCb().setSelected( b );
1184 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1187 private void setDrawPhylogram( final int index, final boolean b ) {
1188 getIsDrawPhylogramList().set( index, b );
1191 void setDrawPhylogramEnabled( final boolean b ) {
1192 getDisplayAsPhylogramCb().setEnabled( b );
1195 void setDynamicHidingIsOn( final boolean is_on ) {
1196 // if ( !_configuration.isUseNativeUI() ) {
1198 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1201 if ( !_configuration.isUseNativeUI() ) {
1202 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1205 getDynamicallyHideData().setForeground( Color.BLACK );
1211 private void setSearchFoundCountsOnLabel( final int counts ) {
1212 getSearchFoundCountsLabel().setText( "Found: " + counts );
1215 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
1216 final JComboBox box = getSequenceRelationBox();
1217 while ( box.getItemCount() > 1 ) {
1218 box.removeItemAt( 1 );
1220 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
1221 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
1223 if ( relationType == null ) {
1226 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
1227 for( final Sequence seq : sequenceRelationQueries ) {
1228 if ( seq.hasSequenceRelations() ) {
1229 boolean fFoundForCurrentType = false;
1230 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
1231 if ( sq.getType().equals( relationType ) ) {
1232 fFoundForCurrentType = true;
1236 if ( fFoundForCurrentType ) {
1237 sequenceNamesToAdd.add( seq.getName() );
1238 sequencesByName.put( seq.getName(), seq );
1242 // sort sequences by name before adding them to the combo
1243 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
1244 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
1245 for( final String seqName : sequenceNameArray ) {
1246 box.addItem( seqName );
1248 for( final ItemListener oldItemListener : box.getItemListeners() ) {
1249 box.removeItemListener( oldItemListener );
1251 box.addItemListener( new ItemListener() {
1254 public void itemStateChanged( final ItemEvent e ) {
1255 _selected_query_seq = sequencesByName.get( e.getItem() );
1256 _mainpanel.getCurrentTreePanel().repaint();
1261 void setShowEvents( final boolean show_events ) {
1262 if ( getShowEventsCb() == null ) {
1263 _show_events = new JCheckBox( "" );
1265 getShowEventsCb().setSelected( show_events );
1268 void setSpeciesColors( final Map<String, Color> species_colors ) {
1269 _species_colors = species_colors;
1272 private void setupClickToOptions() {
1273 final int default_option = _configuration.getDefaultDisplayClicktoOption();
1274 int selected_index = 0;
1276 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1277 _show_data_item = cb_index;
1278 addClickToOption( Configuration.display_node_data,
1279 _configuration.getClickToTitle( Configuration.display_node_data ) );
1280 if ( default_option == Configuration.display_node_data ) {
1281 selected_index = cb_index;
1285 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1286 _collapse_cb_item = cb_index;
1287 addClickToOption( Configuration.collapse_uncollapse,
1288 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
1289 if ( default_option == Configuration.collapse_uncollapse ) {
1290 selected_index = cb_index;
1294 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1295 _reroot_cb_item = cb_index;
1296 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1297 if ( default_option == Configuration.reroot ) {
1298 selected_index = cb_index;
1302 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1303 _subtree_cb_item = cb_index;
1304 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1305 if ( default_option == Configuration.subtree ) {
1306 selected_index = cb_index;
1310 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1311 _swap_cb_item = cb_index;
1312 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1313 if ( default_option == Configuration.swap ) {
1314 selected_index = cb_index;
1318 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1319 _color_subtree_cb_item = cb_index;
1320 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1321 if ( default_option == Configuration.color_subtree ) {
1322 selected_index = cb_index;
1326 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1327 _open_seq_web_item = cb_index;
1328 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1329 if ( default_option == Configuration.open_seq_web ) {
1330 selected_index = cb_index;
1334 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1335 _open_tax_web_item = cb_index;
1336 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1337 if ( default_option == Configuration.open_tax_web ) {
1338 selected_index = cb_index;
1342 if ( getOptions().isEditable() ) {
1343 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
1344 _cut_subtree_item = cb_index;
1345 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
1346 if ( default_option == Configuration.cut_subtree ) {
1347 selected_index = cb_index;
1351 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
1352 _copy_subtree_item = cb_index;
1353 addClickToOption( Configuration.copy_subtree,
1354 _configuration.getClickToTitle( Configuration.copy_subtree ) );
1355 if ( default_option == Configuration.copy_subtree ) {
1356 selected_index = cb_index;
1360 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
1361 _paste_subtree_item = cb_index;
1362 addClickToOption( Configuration.paste_subtree,
1363 _configuration.getClickToTitle( Configuration.paste_subtree ) );
1364 if ( default_option == Configuration.paste_subtree ) {
1365 selected_index = cb_index;
1369 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
1370 _delete_node_or_subtree_item = cb_index;
1371 addClickToOption( Configuration.delete_subtree_or_node,
1372 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
1373 if ( default_option == Configuration.delete_subtree_or_node ) {
1374 selected_index = cb_index;
1378 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
1379 _add_new_node_item = cb_index;
1380 addClickToOption( Configuration.add_new_node,
1381 _configuration.getClickToTitle( Configuration.add_new_node ) );
1382 if ( default_option == Configuration.add_new_node ) {
1383 selected_index = cb_index;
1387 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
1388 _edit_node_data_item = cb_index;
1389 addClickToOption( Configuration.edit_node_data,
1390 _configuration.getClickToTitle( Configuration.edit_node_data ) );
1391 if ( default_option == Configuration.edit_node_data ) {
1392 selected_index = cb_index;
1396 if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
1397 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1398 _blast_item = cb_index;
1399 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
1400 if ( default_option == Configuration.blast ) {
1401 selected_index = cb_index;
1407 // Set default selection and its action
1408 _click_to_combobox.setSelectedIndex( selected_index );
1409 setClickToAction( selected_index );
1414 * Set up the controls from the config settings. 11/26/05
1416 void setupControls() {
1417 // The tree display options:
1418 setupDisplayCheckboxes();
1420 // The sequence relation query selection combo-box
1421 if ( _configuration.displaySequenceRelations() ) {
1422 addSequenceRelationBlock();
1426 startClickToOptions();
1427 setupClickToOptions();
1428 endClickToOptions();
1429 // Zoom and quick edit buttons
1434 void setUpControlsForDomainStrucures() {
1435 _domain_display_label = new JLabel( "Domain Display:" );
1436 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1437 add( _domain_display_label );
1438 _zoom_in_domain_structure = new JButton( "d+" );
1439 _zoom_out_domain_structure = new JButton( "d-" );
1440 _decr_domain_structure_evalue_thr = new JButton( "-" );
1441 _incr_domain_structure_evalue_thr = new JButton( "+" );
1442 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1443 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1444 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1445 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1446 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1447 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1448 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1449 _domain_structure_evalue_thr_tf.setEditable( false );
1450 if ( !getConfiguration().isUseNativeUI() ) {
1451 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1452 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1453 _domain_structure_evalue_thr_tf.setBorder( null );
1455 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1456 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1457 if ( !_configuration.isUseNativeUI() ) {
1458 d1_panel.setBackground( getBackground() );
1459 d2_panel.setBackground( getBackground() );
1463 addJButton( _zoom_out_domain_structure, d1_panel );
1464 addJButton( _zoom_in_domain_structure, d1_panel );
1465 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1466 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1467 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1470 private void setupDisplayCheckboxes() {
1471 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
1472 addCheckbox( Configuration.display_as_phylogram,
1473 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
1474 setCheckbox( Configuration.display_as_phylogram,
1475 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
1477 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1478 addCheckbox( Configuration.dynamically_hide_data,
1479 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
1480 setCheckbox( Configuration.dynamically_hide_data,
1481 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
1483 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1484 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1485 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1487 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1488 addCheckbox( Configuration.display_internal_data,
1489 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
1490 setCheckbox( Configuration.display_internal_data,
1491 _configuration.doCheckOption( Configuration.display_internal_data ) );
1493 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1494 addCheckbox( Configuration.color_according_to_species,
1495 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
1496 setCheckbox( Configuration.color_according_to_species,
1497 _configuration.doCheckOption( Configuration.color_according_to_species ) );
1499 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1500 addCheckbox( Configuration.color_according_to_annotation,
1501 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
1502 setCheckbox( Configuration.color_according_to_annotation,
1503 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
1505 if ( _configuration.doDisplayOption( Configuration.color_branches ) ) {
1506 addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) );
1507 setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) );
1509 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1510 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1511 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1513 final JLabel label = new JLabel( "Display Data:" );
1514 label.setFont( ControlPanel.jcb_bold_font );
1515 if ( !getConfiguration().isUseNativeUI() ) {
1516 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1519 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1520 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
1521 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1523 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1524 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1525 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1527 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1528 addCheckbox( Configuration.show_taxonomy_scientific_names,
1529 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1530 setCheckbox( Configuration.show_taxonomy_scientific_names,
1531 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1533 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1534 addCheckbox( Configuration.show_taxonomy_common_names,
1535 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1536 setCheckbox( Configuration.show_taxonomy_common_names,
1537 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1539 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1540 addCheckbox( Configuration.show_taxonomy_images,
1541 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1542 setCheckbox( Configuration.show_taxonomy_images,
1543 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1545 if ( _configuration.doDisplayOption( Configuration.show_gene_symbols ) ) {
1546 addCheckbox( Configuration.show_gene_symbols,
1547 _configuration.getDisplayTitle( Configuration.show_gene_symbols ) );
1548 setCheckbox( Configuration.show_gene_symbols,
1549 _configuration.doCheckOption( Configuration.show_gene_symbols ) );
1551 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1552 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1553 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1555 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1556 addCheckbox( Configuration.show_sequence_acc,
1557 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1558 setCheckbox( Configuration.show_sequence_acc,
1559 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1561 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1562 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
1563 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1565 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1566 addCheckbox( Configuration.show_binary_characters,
1567 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1568 setCheckbox( Configuration.show_binary_characters,
1569 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1571 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1572 addCheckbox( Configuration.show_binary_character_counts,
1573 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1574 setCheckbox( Configuration.show_binary_character_counts,
1575 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1577 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1578 addCheckbox( Configuration.show_domain_architectures,
1579 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1580 setCheckbox( Configuration.show_domain_architectures,
1581 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1583 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1584 addCheckbox( Configuration.write_confidence_values,
1585 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1586 setCheckbox( Configuration.write_confidence_values,
1587 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1589 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1590 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1591 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1593 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1594 addCheckbox( Configuration.show_vector_data,
1595 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1596 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
1598 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1599 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
1600 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1604 void setupSearchTools() {
1605 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1606 final JLabel search_label = new JLabel( "Search:" );
1607 search_label.setFont( ControlPanel.jcb_bold_font );
1608 if ( !getConfiguration().isUseNativeUI() ) {
1609 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1611 add( search_label );
1612 search_label.setToolTipText( tip );
1613 _search_found_label = new JLabel();
1614 getSearchFoundCountsLabel().setVisible( false );
1615 _search_found_label.setFont( ControlPanel.jcb_bold_font );
1616 if ( !getConfiguration().isUseNativeUI() ) {
1617 _search_found_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1619 _search_tf = new JTextField( 3 );
1620 _search_tf.setToolTipText( tip );
1621 _search_tf.setEditable( true );
1622 if ( !getConfiguration().isUseNativeUI() ) {
1623 _search_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1624 _search_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1625 _search_tf.setBorder( null );
1627 _search_reset_button = new JButton();
1628 getSearchResetButton().setText( "Reset" );
1629 getSearchResetButton().setEnabled( false );
1630 getSearchResetButton().setVisible( false );
1631 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1632 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1633 s_panel_1.setBackground( getBackground() );
1635 s_panel_2.setBackground( getBackground() );
1637 final KeyAdapter key_adapter = new KeyAdapter() {
1640 public void keyReleased( final KeyEvent key_event ) {
1642 displayedPhylogenyMightHaveChanged( true );
1645 final ActionListener action_listener = new ActionListener() {
1648 public void actionPerformed( final ActionEvent e ) {
1650 setSearchFoundCountsOnLabel( 0 );
1651 getSearchFoundCountsLabel().setVisible( false );
1652 getSearchTextField().setText( "" );
1653 getSearchResetButton().setEnabled( false );
1654 getSearchResetButton().setVisible( false );
1655 displayedPhylogenyMightHaveChanged( true );
1658 _search_reset_button.addActionListener( action_listener );
1659 _search_tf.addKeyListener( key_adapter );
1660 addJTextField( _search_tf, s_panel_1 );
1661 s_panel_2.add( _search_found_label );
1662 addJButton( _search_reset_button, s_panel_2 );
1665 private void setVisibilityOfDomainStrucureControls() {
1666 if ( _zoom_in_domain_structure != null ) {
1667 if ( isShowDomainArchitectures() ) {
1668 _domain_display_label.setVisible( true );
1669 _zoom_in_domain_structure.setVisible( true );
1670 _zoom_out_domain_structure.setVisible( true );
1671 _decr_domain_structure_evalue_thr.setVisible( true );
1672 _incr_domain_structure_evalue_thr.setVisible( true );
1673 _domain_structure_evalue_thr_tf.setVisible( true );
1676 _domain_display_label.setVisible( false );
1677 _zoom_in_domain_structure.setVisible( false );
1678 _zoom_out_domain_structure.setVisible( false );
1679 _decr_domain_structure_evalue_thr.setVisible( false );
1680 _incr_domain_structure_evalue_thr.setVisible( false );
1681 _domain_structure_evalue_thr_tf.setVisible( false );
1687 * Fit entire tree into window.
1690 if ( _mainpanel.getCurrentScrollPane() == null ) {
1693 displayedPhylogenyMightHaveChanged( false );
1694 _mainpanel.getCurrentTreePanel().updateOvSettings();
1695 _mainpanel.getCurrentTreePanel().validate();
1696 _mainpanel.validate();
1697 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1698 _mainpanel.getSizeOfViewport().height,
1700 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1701 _mainpanel.adjustJScrollPane();
1702 _mainpanel.getCurrentTreePanel().repaint();
1703 _mainpanel.getCurrentTreePanel().validate();
1704 _mainpanel.validate();
1705 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1706 _mainpanel.getSizeOfViewport().height,
1708 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1709 _mainpanel.adjustJScrollPane();
1710 _mainpanel.getCurrentTreePanel().repaint();
1711 _mainpanel.getCurrentTreePanel().updateOvSizes();
1714 void showWholeAll() {
1715 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1716 if ( tree_panel != null ) {
1717 tree_panel.validate();
1718 tree_panel.setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1719 _mainpanel.getSizeOfViewport().height,
1721 tree_panel.resetPreferredSize();
1722 tree_panel.repaint();
1727 // Create header for click-to combo box.
1728 void startClickToOptions() {
1729 final JLabel spacer = new JLabel( "" );
1730 spacer.setFont( ControlPanel.jcb_font );
1732 _click_to_label = new JLabel( "Click on Node to:" );
1733 add( customizeLabel( _click_to_label, getConfiguration() ) );
1734 _click_to_combobox = new JComboBox();
1735 _click_to_combobox.setFocusable( false );
1736 _click_to_combobox.setMaximumRowCount( 14 );
1737 _click_to_combobox.setFont( ControlPanel.js_font );
1738 if ( !_configuration.isUseNativeUI() ) {
1739 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1741 // don't add listener until all items are set (or each one will trigger
1743 // click_to_list.addActionListener(this);
1744 add( _click_to_combobox );
1745 // Correlates option names to titles
1746 _all_click_to_names = new HashMap<Integer, String>();
1747 _click_to_names = new ArrayList<String>();
1751 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1752 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1753 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1754 setDrawPhylogramEnabled( true );
1755 setDrawPhylogram( isDrawPhylogram() );
1758 setDrawPhylogramEnabled( false );
1759 setDrawPhylogram( false );
1761 if ( getMainPanel().getMainFrame() == null ) {
1762 // Must be "E" applet version.
1763 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1764 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1767 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1768 .getPhylogenyGraphicsType() );
1770 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1771 getMainPanel().getControlPanel().search();
1772 getSequenceRelationTypeBox().removeAllItems();
1773 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1774 .getRelevantSequenceRelationTypes() ) {
1775 _sequence_relation_type_box.addItem( type );
1777 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1778 // according to GUILHEM the line above can be removed.
1783 * Uncollapse all nodes.
1785 void uncollapseAll( final TreePanel tp ) {
1786 final Phylogeny t = tp.getPhylogeny();
1787 if ( ( t != null ) && !t.isEmpty() ) {
1788 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
1789 final PhylogenyNode node = iter.next();
1790 node.setCollapse( false );
1792 tp.resetNodeIdToDistToLeafMap();
1793 tp.updateSetOfCollapsedExternalNodes( t );
1794 t.recalculateNumberOfExternalDescendants( false );
1795 tp.setNodeInPreorderToNull();
1801 void updateDomainStructureEvaluethresholdDisplay() {
1802 if ( _domain_structure_evalue_thr_tf != null ) {
1803 _domain_structure_evalue_thr_tf.setText( "10^"
1804 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1808 void zoomInX( final float factor, final float x_correction_factor ) {
1809 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1810 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1811 treepanel.multiplyUrtFactor( 1f );
1812 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1813 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1814 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1815 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1816 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1817 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1818 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1819 getMainPanel().adjustJScrollPane();
1820 treepanel.resetPreferredSize();
1821 getMainPanel().getCurrentScrollPane().getViewport().validate();
1822 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1823 - ( sb.getVisibleAmount() / 2.0 ) ) );
1826 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1827 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1828 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1829 getMainPanel().adjustJScrollPane();
1830 treepanel.resetPreferredSize();
1831 getMainPanel().getCurrentScrollPane().getViewport().validate();
1832 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1834 treepanel.resetPreferredSize();
1835 treepanel.updateOvSizes();
1838 void zoomInY( final float factor ) {
1839 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1840 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1841 treepanel.multiplyUrtFactor( 1.1f );
1842 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1843 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1844 getMainPanel().adjustJScrollPane();
1845 treepanel.resetPreferredSize();
1846 getMainPanel().getCurrentScrollPane().getViewport().validate();
1847 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1848 - ( sb.getVisibleAmount() / 2.0 ) ) );
1849 treepanel.resetPreferredSize();
1850 treepanel.updateOvSizes();
1853 void zoomOutX( final float factor, final float x_correction_factor ) {
1854 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1855 treepanel.multiplyUrtFactor( 1f );
1856 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1857 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1858 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1859 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1860 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1861 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1862 getMainPanel().adjustJScrollPane();
1863 treepanel.resetPreferredSize();
1864 getMainPanel().getCurrentScrollPane().getViewport().validate();
1865 final double x = ( sb.getMaximum() - sb.getMinimum() )
1866 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1867 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1868 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1869 getMainPanel().adjustJScrollPane();
1870 treepanel.resetPreferredSize();
1871 getMainPanel().getCurrentScrollPane().getViewport().validate();
1872 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1873 - ( sb.getVisibleAmount() / 2.0 ) ) );
1876 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1877 treepanel.setXdistance( treepanel.getXdistance() * factor );
1878 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
1880 getMainPanel().adjustJScrollPane();
1881 treepanel.resetPreferredSize();
1882 getMainPanel().getCurrentScrollPane().getViewport().validate();
1883 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1886 treepanel.resetPreferredSize();
1887 treepanel.updateOvSizes();
1891 void zoomOutY( final float factor ) {
1892 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1893 treepanel.multiplyUrtFactor( 0.9f );
1894 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1895 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1896 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1897 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1898 getMainPanel().adjustJScrollPane();
1899 treepanel.resetPreferredSize();
1900 getMainPanel().getCurrentScrollPane().getViewport().validate();
1901 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1902 - ( sb.getVisibleAmount() / 2.0 ) ) );
1903 treepanel.resetPreferredSize();
1904 treepanel.updateOvSizes();
1908 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
1909 label.setFont( ControlPanel.jcb_bold_font );
1910 if ( !configuration.isUseNativeUI() ) {
1911 label.setForeground( configuration.getGuiCheckboxTextColor() );
1912 label.setBackground( configuration.getGuiBackgroundColor() );
1917 enum NodeClickAction {
1928 DELETE_NODE_OR_SUBTREE,