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 _sort_descendents_item;
129 private int _open_tax_web_item;
130 private int _cut_subtree_item;
131 private int _copy_subtree_item;
132 private int _delete_node_or_subtree_item;
133 private int _paste_subtree_item;
134 private int _add_new_node_item;
135 private int _edit_node_data_item;
136 private int _blast_item;
137 // zooming and quick tree manipulation buttons:
138 private JButton _zoom_in_x;
139 private JButton _zoom_in_y;
140 private JButton _zoom_out_x;
141 private JButton _zoom_out_y;
142 private JButton _show_whole;
143 private JButton _order;
144 private JButton _uncollapse_all;
145 private JButton _zoom_in_domain_structure;
146 private JButton _zoom_out_domain_structure;
147 private JButton _decr_domain_structure_evalue_thr;
148 private JButton _incr_domain_structure_evalue_thr;
149 private JButton _return_to_super_tree;
150 private JTextField _domain_structure_evalue_thr_tf;
151 private JTextField _search_tf;
152 private boolean _order_of_appearance;
153 private boolean _color_branches;
154 private NodeClickAction _action_when_node_clicked;
155 private List<Boolean> _draw_phylogram;
156 private Map<String, Color> _annotation_colors;
157 private Map<String, Color> _species_colors;
158 private JButton _search_reset_button;
159 private JLabel _search_found_label;
160 private Sequence _selected_query_seq;
162 ControlPanel( final MainPanel ap, final Configuration configuration ) {
165 _configuration = configuration;
166 if ( !_configuration.isUseNativeUI() ) {
167 setBackground( getConfiguration().getGuiBackgroundColor() );
168 setBorder( BorderFactory.createRaisedBevelBorder() );
170 setLayout( new GridLayout( 0, 1, 2, 2 ) );
171 _order_of_appearance = true;
179 public void actionPerformed( final ActionEvent e ) {
181 final TreePanel tp = getMainPanel().getCurrentTreePanel();
185 if ( e.getSource() == _click_to_combobox ) {
186 setClickToAction( _click_to_combobox.getSelectedIndex() );
187 getCurrentTreePanel().repaint();
189 else if ( e.getSource() == _show_binary_characters ) {
190 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
191 _show_binary_character_counts.setSelected( false );
193 displayedPhylogenyMightHaveChanged( true );
195 else if ( e.getSource() == _show_binary_character_counts ) {
196 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
197 _show_binary_characters.setSelected( false );
199 displayedPhylogenyMightHaveChanged( true );
201 else if ( e.getSource() == _color_according_to_annotation ) {
202 if ( ( _show_annotation != null ) && _color_according_to_annotation.isSelected() ) {
203 _show_annotation.setSelected( true );
205 displayedPhylogenyMightHaveChanged( false );
207 else if ( e.getSource() == _show_annotation ) {
208 if ( ( _color_according_to_annotation != null ) && !_show_annotation.isSelected() ) {
209 _color_according_to_annotation.setSelected( false );
211 displayedPhylogenyMightHaveChanged( false );
213 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
214 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
215 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
219 else if ( e.getSource() == _zoom_in_x ) {
220 zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
221 displayedPhylogenyMightHaveChanged( false );
223 else if ( e.getSource() == _zoom_in_y ) {
224 zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR );
225 displayedPhylogenyMightHaveChanged( false );
227 else if ( e.getSource() == _zoom_out_x ) {
228 zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
229 displayedPhylogenyMightHaveChanged( false );
231 else if ( e.getSource() == _zoom_out_y ) {
232 zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR );
233 displayedPhylogenyMightHaveChanged( false );
235 else if ( e.getSource() == _show_whole ) {
238 else if ( e.getSource() == _return_to_super_tree ) {
239 _mainpanel.getCurrentTreePanel().superTree();
242 else if ( e.getSource() == _order ) {
243 tp.getPhylogeny().orderAppearance( _order_of_appearance );
244 _order_of_appearance = !_order_of_appearance;
245 displayedPhylogenyMightHaveChanged( false );
247 else if ( e.getSource() == _uncollapse_all ) {
249 displayedPhylogenyMightHaveChanged( false );
251 else if ( e.getSource() == _zoom_in_domain_structure ) {
252 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
253 displayedPhylogenyMightHaveChanged( true );
255 else if ( e.getSource() == _zoom_out_domain_structure ) {
256 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
257 displayedPhylogenyMightHaveChanged( true );
259 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
260 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThreshold();
261 displayedPhylogenyMightHaveChanged( true );
263 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
264 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThreshold();
265 displayedPhylogenyMightHaveChanged( true );
267 else if ( e.getSource() == _search_tf ) {
269 displayedPhylogenyMightHaveChanged( true );
272 displayedPhylogenyMightHaveChanged( true );
276 tp.requestFocusInWindow();
279 catch ( final Exception ex ) {
280 AptxUtil.unexpectedException( ex );
282 catch ( final Error err ) {
283 AptxUtil.unexpectedError( err );
287 void activateButtonToReturnToSuperTree( int index ) {
290 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
293 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
295 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
296 _return_to_super_tree.setEnabled( true );
300 * Add zoom and quick edit buttons. (Last modified 8/9/04)
303 final JLabel spacer = new JLabel( "" );
304 spacer.setOpaque( false );
306 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
307 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
308 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
309 if ( !getConfiguration().isUseNativeUI() ) {
310 x_panel.setBackground( getBackground() );
311 y_panel.setBackground( getBackground() );
312 z_panel.setBackground( getBackground() );
314 add( _zoom_label = new JLabel( "Zoom:" ) );
315 customizeLabel( _zoom_label, getConfiguration() );
319 if ( getConfiguration().isUseNativeUI() ) {
320 _zoom_in_x = new JButton( "+" );
321 _zoom_out_x = new JButton( "-" );
324 _zoom_in_x = new JButton( "X+" );
325 _zoom_out_x = new JButton( "X-" );
327 _zoom_in_y = new JButton( "Y+" );
328 _zoom_out_y = new JButton( "Y-" );
329 _show_whole = new JButton( "F" );
330 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [Backspace]" );
331 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+Right]" );
332 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+Up]" );
333 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+Left]" );
334 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+Down]" );
335 if ( getConfiguration().isUseNativeUI() && AptxUtil.isMac() ) {
336 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
337 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
340 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
341 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
343 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
344 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
345 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
346 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
347 _return_to_super_tree.setEnabled( false );
348 _order = new JButton( "Order Subtrees" );
349 _uncollapse_all = new JButton( "Uncollapse All" );
350 addJButton( _zoom_in_y, x_panel );
351 addJButton( _zoom_out_x, y_panel );
352 addJButton( _show_whole, y_panel );
353 addJButton( _zoom_in_x, y_panel );
354 addJButton( _zoom_out_y, z_panel );
355 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
356 setUpControlsForDomainStrucures();
358 final JLabel spacer2 = new JLabel( "" );
360 addJButton( _return_to_super_tree, this );
361 addJButton( _order, this );
362 addJButton( _uncollapse_all, this );
363 final JLabel spacer3 = new JLabel( "" );
365 setVisibilityOfDomainStrucureControls();
368 void addCheckbox( final int which, final String title ) {
369 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
371 case Configuration.display_as_phylogram:
372 _display_as_phylogram_cb = new JCheckBox( title );
373 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
374 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
377 case Configuration.display_internal_data:
378 _display_internal_data = new JCheckBox( title );
379 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
380 addJCheckBox( _display_internal_data, ch_panel );
383 case Configuration.color_according_to_species:
384 _color_acc_species = new JCheckBox( title );
386 .setToolTipText( "To colorize taxonomy and sequence labels as a function of taxonomy" );
387 addJCheckBox( _color_acc_species, ch_panel );
390 case Configuration.color_according_to_annotation:
391 _color_according_to_annotation = new JCheckBox( title );
392 _color_according_to_annotation
393 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
394 addJCheckBox( _color_according_to_annotation, ch_panel );
397 case Configuration.show_node_names:
398 _show_node_names = new JCheckBox( title );
399 addJCheckBox( _show_node_names, ch_panel );
402 case Configuration.show_taxonomy_scientific_names:
403 _show_taxo_scientific_names = new JCheckBox( title );
404 addJCheckBox( _show_taxo_scientific_names, ch_panel );
407 case Configuration.show_taxonomy_common_names:
408 _show_taxo_common_names = new JCheckBox( title );
409 addJCheckBox( _show_taxo_common_names, ch_panel );
412 case Configuration.show_tax_code:
413 _show_taxo_code = new JCheckBox( title );
414 addJCheckBox( _show_taxo_code, ch_panel );
417 case Configuration.show_taxonomy_images:
418 _show_taxo_images_cb = new JCheckBox( title );
419 addJCheckBox( _show_taxo_images_cb, ch_panel );
422 case Configuration.show_binary_characters:
423 _show_binary_characters = new JCheckBox( title );
424 addJCheckBox( _show_binary_characters, ch_panel );
427 case Configuration.show_annotation:
428 _show_annotation = new JCheckBox( title );
429 addJCheckBox( _show_annotation, ch_panel );
432 case Configuration.show_binary_character_counts:
433 _show_binary_character_counts = new JCheckBox( title );
434 addJCheckBox( _show_binary_character_counts, ch_panel );
437 case Configuration.write_confidence_values:
438 _write_confidence = new JCheckBox( title );
439 addJCheckBox( getWriteConfidenceCb(), ch_panel );
442 case Configuration.write_events:
443 _show_events = new JCheckBox( title );
444 addJCheckBox( getShowEventsCb(), ch_panel );
447 case Configuration.color_branches:
448 _color_branches_cb = new JCheckBox( title );
449 getColorBranchesCb().setToolTipText( "To use branch color values, if present" );
450 addJCheckBox( getColorBranchesCb(), ch_panel );
453 case Configuration.width_branches:
454 _width_branches = new JCheckBox( title );
455 _width_branches.setToolTipText( "To use branch width values, if present" );
456 addJCheckBox( _width_branches, ch_panel );
459 case Configuration.show_domain_architectures:
460 _show_domain_architectures = new JCheckBox( title );
461 addJCheckBox( _show_domain_architectures, ch_panel );
464 case Configuration.show_gene_names:
465 _show_gene_names = new JCheckBox( title );
466 addJCheckBox( _show_gene_names, ch_panel );
469 case Configuration.show_gene_symbols:
470 _show_gene_symbols = new JCheckBox( title );
471 addJCheckBox( _show_gene_symbols, ch_panel );
474 case Configuration.show_sequence_acc:
475 _show_sequence_acc = new JCheckBox( title );
476 addJCheckBox( _show_sequence_acc, ch_panel );
479 case Configuration.dynamically_hide_data:
480 _dynamically_hide_data = new JCheckBox( title );
481 getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" );
482 addJCheckBox( getDynamicallyHideData(), ch_panel );
485 case Configuration.node_data_popup:
486 _node_desc_popup_cb = new JCheckBox( title );
487 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
488 addJCheckBox( getNodeDescPopupCb(), ch_panel );
491 case Configuration.show_relation_confidence:
492 _seq_relation_confidence_switch = new JCheckBox( title );
493 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
496 case Configuration.show_vector_data:
497 _show_vector_data_cb = new JCheckBox( title );
498 addJCheckBox( _show_vector_data_cb, ch_panel );
501 case Configuration.show_properties:
502 _show_properties_cb = new JCheckBox( title );
503 addJCheckBox( _show_properties_cb, ch_panel );
507 throw new RuntimeException( "unknown checkbox: " + which );
511 private void addClickToOption( final int which, final String title ) {
512 _click_to_combobox.addItem( title );
513 _click_to_names.add( title );
514 _all_click_to_names.put( new Integer( which ), title );
515 if ( !_configuration.isUseNativeUI() ) {
516 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
517 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
521 void addJButton( final JButton jb, final JPanel p ) {
522 jb.setFocusPainted( false );
523 jb.setFont( ControlPanel.jcb_font );
524 if ( !_configuration.isUseNativeUI() ) {
525 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
526 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
527 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
530 jb.addActionListener( this );
533 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
534 jcb.setFocusPainted( false );
535 jcb.setFont( ControlPanel.jcb_font );
536 if ( !_configuration.isUseNativeUI() ) {
537 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
538 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
540 p.add( jcb, "Center" );
541 jcb.addActionListener( this );
544 void addJTextField( final JTextField tf, final JPanel p ) {
545 if ( !_configuration.isUseNativeUI() ) {
546 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
547 tf.setFont( ControlPanel.jcb_font );
550 tf.addActionListener( this );
554 private void addSequenceRelationBlock() {
555 final JLabel spacer = new JLabel( "" );
556 spacer.setSize( 1, 1 );
558 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
559 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
560 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
561 getSequenceRelationTypeBox().setFocusable( false );
562 _sequence_relation_type_box.setFont( ControlPanel.js_font );
563 if ( !_configuration.isUseNativeUI() ) {
564 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
565 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
567 _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
570 public Component getListCellRendererComponent( final JList list,
573 final boolean isSelected,
574 final boolean cellHasFocus ) {
575 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
580 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
581 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
582 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
587 final GridBagLayout gbl = new GridBagLayout();
588 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
589 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
590 final JPanel horizGrid = new JPanel( gbl );
591 horizGrid.setBackground( getBackground() );
592 horizGrid.add( typeLabel );
593 horizGrid.add( _sequence_relation_type_box );
594 add( customizeLabel( mainLabel, getConfiguration() ) );
596 add( getSequenceRelationBox() );
597 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
598 addCheckbox( Configuration.show_relation_confidence,
599 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
600 setCheckbox( Configuration.show_relation_confidence,
601 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
603 }// addSequenceRelationBlock
605 void deactivateButtonToReturnToSuperTree() {
606 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
607 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
608 _return_to_super_tree.setEnabled( false );
611 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
612 if ( ( _mainpanel != null ) && ( _mainpanel.getCurrentPhylogeny() != null ) ) {
613 if ( getOptions().isShowOverview() ) {
614 _mainpanel.getCurrentTreePanel().updateOvSizes();
616 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
617 setVisibilityOfDomainStrucureControls();
618 updateDomainStructureEvaluethresholdDisplay();
619 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
620 _mainpanel.getCurrentTreePanel().calcMaxDepth();
621 _mainpanel.adjustJScrollPane();
622 if ( recalc_longest_ext_node_info ) {
623 _mainpanel.getCurrentTreePanel().initNodeData();
624 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
626 _mainpanel.getCurrentTreePanel().repaint();
627 // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
631 void endClickToOptions() {
632 _click_to_combobox.addActionListener( this );
636 * Indicates what action should be execute when a node is clicked
638 * @return the click-on action
640 NodeClickAction getActionWhenNodeClicked() {
641 return _action_when_node_clicked;
644 Map<Integer, String> getAllClickToItems() {
645 return _all_click_to_names;
648 Map<String, Color> getAnnotationColors() {
649 return _annotation_colors;
652 public JCheckBox getColorBranchesCb() {
653 return _color_branches_cb;
656 public JCheckBox getColorAccSpeciesCb() {
657 return _color_acc_species;
660 Configuration getConfiguration() {
661 return _configuration;
664 TreePanel getCurrentTreePanel() {
665 return getMainPanel().getCurrentTreePanel();
668 public JCheckBox getDisplayAsPhylogramCb() {
669 return _display_as_phylogram_cb;
672 public JCheckBox getDynamicallyHideData() {
673 return _dynamically_hide_data;
677 private List<Boolean> getIsDrawPhylogramList() {
678 return _draw_phylogram;
681 MainPanel getMainPanel() {
685 public JCheckBox getNodeDescPopupCb() {
686 return _node_desc_popup_cb;
689 Options getOptions() {
690 return getMainPanel().getOptions();
693 private JLabel getSearchFoundCountsLabel() {
694 return _search_found_label;
697 private JButton getSearchResetButton() {
698 return _search_reset_button;
701 JTextField getSearchTextField() {
705 public Sequence getSelectedQuerySequence() {
706 return _selected_query_seq;
709 public JComboBox getSequenceRelationBox() {
710 if ( _show_sequence_relations == null ) {
711 _show_sequence_relations = new JComboBox();
712 _show_sequence_relations.setFocusable( false );
713 _show_sequence_relations.setMaximumRowCount( 20 );
714 _show_sequence_relations.setFont( ControlPanel.js_font );
715 if ( !_configuration.isUseNativeUI() ) {
716 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
717 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
719 _show_sequence_relations.addItem( "-----" );
720 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
722 return _show_sequence_relations;
726 public JComboBox getSequenceRelationTypeBox() {
727 if ( _sequence_relation_type_box == null ) {
728 _sequence_relation_type_box = new JComboBox();
729 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
730 _sequence_relation_type_box.addItem( type );
732 _sequence_relation_type_box.addActionListener( new ActionListener() {
735 public void actionPerformed( final ActionEvent e ) {
736 if ( _mainpanel.getCurrentPhylogeny() != null ) {
737 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
742 return _sequence_relation_type_box;
745 public JCheckBox getShowEventsCb() {
749 List<String> getSingleClickToNames() {
750 return _click_to_names;
753 Map<String, Color> getSpeciesColors() {
754 return _species_colors;
757 public JCheckBox getWriteConfidenceCb() {
758 return _write_confidence;
761 private void init() {
762 _draw_phylogram = new ArrayList<Boolean>();
763 setSpeciesColors( new HashMap<String, Color>() );
764 setAnnotationColors( new HashMap<String, Color>() );
767 boolean isAntialiasScreenText() {
771 boolean isColorAccordingToAnnotation() {
772 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
775 boolean isColorAccordingToTaxonomy() {
776 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
779 boolean isColorBranches() {
780 return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) );
783 boolean isDrawPhylogram() {
784 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
787 private boolean isDrawPhylogram( final int index ) {
788 return getIsDrawPhylogramList().get( index );
791 boolean isDynamicallyHideData() {
792 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
796 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
799 boolean isNodeDescPopup() {
800 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
803 boolean isShowAnnotation() {
804 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
807 boolean isShowBinaryCharacterCounts() {
808 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
811 boolean isShowBinaryCharacters() {
812 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
815 boolean isShowConfidenceValues() {
816 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
819 boolean isShowDomainArchitectures() {
820 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
823 boolean isShowGeneNames() {
824 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
827 public boolean isShowVectorData() {
828 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
831 public boolean isShowProperties() {
832 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
835 boolean isShowGeneSymbols() {
836 return ( ( _show_gene_symbols != null ) && _show_gene_symbols.isSelected() );
839 boolean isShowInternalData() {
840 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
843 boolean isShowNodeNames() {
844 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
847 boolean isShowSequenceAcc() {
848 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
851 boolean isShowSequenceRelationConfidence() {
852 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
855 boolean isShowSequenceRelations() {
856 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
859 boolean isShowTaxonomyCode() {
860 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
863 public boolean isShowTaxonomyImages() {
864 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
867 boolean isShowTaxonomyCommonNames() {
868 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
871 boolean isShowTaxonomyScientificNames() {
872 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
875 boolean isWidthBranches() {
876 return ( ( _width_branches != null ) && _width_branches.isSelected() );
879 void phylogenyAdded( final Configuration configuration ) {
880 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
883 void phylogenyRemoved( final int index ) {
884 getIsDrawPhylogramList().remove( index );
888 final MainPanel main_panel = getMainPanel();
889 final Phylogeny tree = main_panel.getCurrentPhylogeny();
890 if ( ( tree == null ) || tree.isEmpty() ) {
893 String query = getSearchTextField().getText();
894 if ( query != null ) {
895 query = query.trim();
898 getSearchFoundCountsLabel().setVisible( false );
899 getSearchResetButton().setEnabled( false );
900 getSearchResetButton().setVisible( false );
903 if ( !ForesterUtil.isEmpty( query ) ) {
904 search( main_panel, tree, query );
907 getSearchFoundCountsLabel().setVisible( false );
908 getSearchResetButton().setEnabled( false );
909 getSearchResetButton().setVisible( false );
914 private void search( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
915 getSearchFoundCountsLabel().setVisible( true );
916 getSearchResetButton().setEnabled( true );
917 getSearchResetButton().setVisible( true );
918 String[] queries = null;
919 List<PhylogenyNode> nodes = null;
920 if ( query_str.indexOf( ',' ) >= 0 ) {
921 queries = query_str.split( ",+" );
924 queries = new String[ 1 ];
925 queries[ 0 ] = query_str.trim();
927 if ( ( queries != null ) && ( queries.length > 0 ) ) {
928 nodes = new ArrayList<PhylogenyNode>();
929 for( String query : queries ) {
930 if ( ForesterUtil.isEmpty( query ) ) {
933 query = query.trim();
934 if ( query.indexOf( '+' ) >= 0 ) {
935 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ), tree, getOptions()
936 .isSearchCaseSensitive(), !getOptions().isMatchWholeTermsOnly() ) );
939 nodes.addAll( PhylogenyMethods.searchData( query,
941 getOptions().isSearchCaseSensitive(),
942 !getOptions().isMatchWholeTermsOnly() ) );
945 if ( getOptions().isInverseSearchResult() ) {
946 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
947 all.removeAll( nodes );
951 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
952 main_panel.getCurrentTreePanel().setFoundNodes( new HashSet<Integer>() );
953 for( final PhylogenyNode node : nodes ) {
954 main_panel.getCurrentTreePanel().getFoundNodes().add( node.getId() );
956 setSearchFoundCountsOnLabel( nodes.size() );
959 setSearchFoundCountsOnLabel( 0 );
964 private void searchReset() {
965 if ( getMainPanel().getCurrentTreePanel() != null ) {
966 getMainPanel().getCurrentTreePanel().setFoundNodes( null );
970 void setActionWhenNodeClicked( final NodeClickAction action ) {
971 _action_when_node_clicked = action;
974 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
975 _annotation_colors = annotation_colors;
978 void setCheckbox( final int which, final boolean state ) {
980 case Configuration.display_as_phylogram:
981 if ( getDisplayAsPhylogramCb() != null ) {
982 getDisplayAsPhylogramCb().setSelected( state );
985 case Configuration.display_internal_data:
986 if ( _display_internal_data != null ) {
987 _display_internal_data.setSelected( state );
990 case Configuration.color_according_to_species:
991 if ( _color_acc_species != null ) {
992 _color_acc_species.setSelected( state );
995 case Configuration.color_according_to_annotation:
996 if ( _color_according_to_annotation != null ) {
997 _color_according_to_annotation.setSelected( state );
1000 case Configuration.show_node_names:
1001 if ( _show_node_names != null ) {
1002 _show_node_names.setSelected( state );
1005 case Configuration.show_taxonomy_scientific_names:
1006 if ( _show_taxo_scientific_names != null ) {
1007 _show_taxo_scientific_names.setSelected( state );
1010 case Configuration.show_taxonomy_common_names:
1011 if ( _show_taxo_common_names != null ) {
1012 _show_taxo_common_names.setSelected( state );
1015 case Configuration.show_tax_code:
1016 if ( _show_taxo_code != null ) {
1017 _show_taxo_code.setSelected( state );
1020 case Configuration.show_taxonomy_images:
1021 if ( _show_taxo_images_cb != null ) {
1022 _show_taxo_images_cb.setSelected( state );
1025 case Configuration.show_annotation:
1026 if ( _show_annotation != null ) {
1027 _show_annotation.setSelected( state );
1030 case Configuration.show_binary_characters:
1031 if ( _show_binary_characters != null ) {
1032 _show_binary_characters.setSelected( state );
1035 case Configuration.show_binary_character_counts:
1036 if ( _show_binary_character_counts != null ) {
1037 _show_binary_character_counts.setSelected( state );
1040 case Configuration.write_confidence_values:
1041 if ( getWriteConfidenceCb() != null ) {
1042 getWriteConfidenceCb().setSelected( state );
1045 case Configuration.write_events:
1046 if ( getShowEventsCb() != null ) {
1047 getShowEventsCb().setSelected( state );
1050 case Configuration.color_branches:
1051 if ( getColorBranchesCb() != null ) {
1052 getColorBranchesCb().setSelected( state );
1055 case Configuration.width_branches:
1056 if ( _width_branches != null ) {
1057 _width_branches.setSelected( state );
1060 case Configuration.show_domain_architectures:
1061 if ( _show_domain_architectures != null ) {
1062 _show_domain_architectures.setSelected( state );
1065 case Configuration.show_gene_names:
1066 if ( _show_gene_names != null ) {
1067 _show_gene_names.setSelected( state );
1070 case Configuration.show_gene_symbols:
1071 if ( _show_gene_symbols != null ) {
1072 _show_gene_symbols.setSelected( state );
1075 case Configuration.show_vector_data:
1076 if ( _show_vector_data_cb != null ) {
1077 _show_vector_data_cb.setSelected( state );
1080 case Configuration.show_properties:
1081 if ( _show_properties_cb != null ) {
1082 _show_properties_cb.setSelected( state );
1085 case Configuration.show_sequence_acc:
1086 if ( _show_sequence_acc != null ) {
1087 _show_sequence_acc.setSelected( state );
1090 case Configuration.dynamically_hide_data:
1091 if ( getDynamicallyHideData() != null ) {
1092 getDynamicallyHideData().setSelected( state );
1095 case Configuration.node_data_popup:
1096 if ( getNodeDescPopupCb() != null ) {
1097 getNodeDescPopupCb().setSelected( state );
1101 case Configuration.show_relation_confidence:
1102 if ( _seq_relation_confidence_switch != null ) {
1103 _seq_relation_confidence_switch.setSelected( state );
1108 throw new AssertionError( "unknown checkbox: " + which );
1113 * Set this checkbox state. Not all checkboxes have been instantiated
1114 * depending on the config.
1116 void setCheckbox( final JCheckBox cb, final boolean state ) {
1118 cb.setSelected( state );
1122 void setClickToAction( final int action ) {
1123 // Set click-to action
1124 if ( action == _show_data_item ) {
1125 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1127 else if ( action == _collapse_cb_item ) {
1128 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1130 else if ( action == _reroot_cb_item ) {
1131 setActionWhenNodeClicked( NodeClickAction.REROOT );
1133 else if ( action == _subtree_cb_item ) {
1134 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1136 else if ( action == _swap_cb_item ) {
1137 setActionWhenNodeClicked( NodeClickAction.SWAP );
1139 else if ( action == _color_subtree_cb_item ) {
1140 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1142 else if ( action == _open_seq_web_item ) {
1143 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1145 else if ( action == _sort_descendents_item ) {
1146 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1148 else if ( action == _blast_item ) {
1149 if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
1150 setActionWhenNodeClicked( NodeClickAction.BLAST );
1153 else if ( action == _open_tax_web_item ) {
1154 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1156 else if ( action == _cut_subtree_item ) {
1157 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1159 else if ( action == _copy_subtree_item ) {
1160 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1162 else if ( action == _delete_node_or_subtree_item ) {
1163 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1165 else if ( action == _paste_subtree_item ) {
1166 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1168 else if ( action == _add_new_node_item ) {
1169 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1171 else if ( action == _edit_node_data_item ) {
1172 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1175 throw new RuntimeException( "unknown action: " + action );
1177 // make sure drop down is displaying the correct action
1178 // in case this was called from outside the class
1179 _click_to_combobox.setSelectedIndex( action );
1182 void setColorBranches( final boolean color_branches ) {
1183 _color_branches = color_branches;
1186 void setDrawPhylogram( final boolean b ) {
1187 getDisplayAsPhylogramCb().setSelected( b );
1188 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1191 private void setDrawPhylogram( final int index, final boolean b ) {
1192 getIsDrawPhylogramList().set( index, b );
1195 void setDrawPhylogramEnabled( final boolean b ) {
1196 getDisplayAsPhylogramCb().setEnabled( b );
1199 void setDynamicHidingIsOn( final boolean is_on ) {
1200 // if ( !_configuration.isUseNativeUI() ) {
1202 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1205 if ( !_configuration.isUseNativeUI() ) {
1206 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1209 getDynamicallyHideData().setForeground( Color.BLACK );
1215 private void setSearchFoundCountsOnLabel( final int counts ) {
1216 getSearchFoundCountsLabel().setText( "Found: " + counts );
1219 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
1220 final JComboBox box = getSequenceRelationBox();
1221 while ( box.getItemCount() > 1 ) {
1222 box.removeItemAt( 1 );
1224 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
1225 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
1227 if ( relationType == null ) {
1230 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
1231 for( final Sequence seq : sequenceRelationQueries ) {
1232 if ( seq.hasSequenceRelations() ) {
1233 boolean fFoundForCurrentType = false;
1234 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
1235 if ( sq.getType().equals( relationType ) ) {
1236 fFoundForCurrentType = true;
1240 if ( fFoundForCurrentType ) {
1241 sequenceNamesToAdd.add( seq.getName() );
1242 sequencesByName.put( seq.getName(), seq );
1246 // sort sequences by name before adding them to the combo
1247 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
1248 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
1249 for( final String seqName : sequenceNameArray ) {
1250 box.addItem( seqName );
1252 for( final ItemListener oldItemListener : box.getItemListeners() ) {
1253 box.removeItemListener( oldItemListener );
1255 box.addItemListener( new ItemListener() {
1258 public void itemStateChanged( final ItemEvent e ) {
1259 _selected_query_seq = sequencesByName.get( e.getItem() );
1260 _mainpanel.getCurrentTreePanel().repaint();
1265 void setShowEvents( final boolean show_events ) {
1266 if ( getShowEventsCb() == null ) {
1267 _show_events = new JCheckBox( "" );
1269 getShowEventsCb().setSelected( show_events );
1272 void setSpeciesColors( final Map<String, Color> species_colors ) {
1273 _species_colors = species_colors;
1276 private void setupClickToOptions() {
1277 final int default_option = _configuration.getDefaultDisplayClicktoOption();
1278 int selected_index = 0;
1280 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1281 _show_data_item = cb_index;
1282 addClickToOption( Configuration.display_node_data,
1283 _configuration.getClickToTitle( Configuration.display_node_data ) );
1284 if ( default_option == Configuration.display_node_data ) {
1285 selected_index = cb_index;
1289 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1290 _collapse_cb_item = cb_index;
1291 addClickToOption( Configuration.collapse_uncollapse,
1292 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
1293 if ( default_option == Configuration.collapse_uncollapse ) {
1294 selected_index = cb_index;
1298 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1299 _reroot_cb_item = cb_index;
1300 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1301 if ( default_option == Configuration.reroot ) {
1302 selected_index = cb_index;
1306 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1307 _subtree_cb_item = cb_index;
1308 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1309 if ( default_option == Configuration.subtree ) {
1310 selected_index = cb_index;
1314 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1315 _swap_cb_item = cb_index;
1316 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1317 if ( default_option == Configuration.swap ) {
1318 selected_index = cb_index;
1322 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
1323 _sort_descendents_item = cb_index;
1324 addClickToOption( Configuration.sort_descendents,
1325 _configuration.getClickToTitle( Configuration.sort_descendents ) );
1326 if ( default_option == Configuration.sort_descendents ) {
1327 selected_index = cb_index;
1331 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1332 _color_subtree_cb_item = cb_index;
1333 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1334 if ( default_option == Configuration.color_subtree ) {
1335 selected_index = cb_index;
1339 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1340 _open_seq_web_item = cb_index;
1341 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1342 if ( default_option == Configuration.open_seq_web ) {
1343 selected_index = cb_index;
1347 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1348 _open_tax_web_item = cb_index;
1349 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1350 if ( default_option == Configuration.open_tax_web ) {
1351 selected_index = cb_index;
1355 if ( getOptions().isEditable() ) {
1356 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
1357 _cut_subtree_item = cb_index;
1358 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
1359 if ( default_option == Configuration.cut_subtree ) {
1360 selected_index = cb_index;
1364 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
1365 _copy_subtree_item = cb_index;
1366 addClickToOption( Configuration.copy_subtree,
1367 _configuration.getClickToTitle( Configuration.copy_subtree ) );
1368 if ( default_option == Configuration.copy_subtree ) {
1369 selected_index = cb_index;
1373 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
1374 _paste_subtree_item = cb_index;
1375 addClickToOption( Configuration.paste_subtree,
1376 _configuration.getClickToTitle( Configuration.paste_subtree ) );
1377 if ( default_option == Configuration.paste_subtree ) {
1378 selected_index = cb_index;
1382 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
1383 _delete_node_or_subtree_item = cb_index;
1384 addClickToOption( Configuration.delete_subtree_or_node,
1385 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
1386 if ( default_option == Configuration.delete_subtree_or_node ) {
1387 selected_index = cb_index;
1391 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
1392 _add_new_node_item = cb_index;
1393 addClickToOption( Configuration.add_new_node,
1394 _configuration.getClickToTitle( Configuration.add_new_node ) );
1395 if ( default_option == Configuration.add_new_node ) {
1396 selected_index = cb_index;
1400 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
1401 _edit_node_data_item = cb_index;
1402 addClickToOption( Configuration.edit_node_data,
1403 _configuration.getClickToTitle( Configuration.edit_node_data ) );
1404 if ( default_option == Configuration.edit_node_data ) {
1405 selected_index = cb_index;
1409 if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
1410 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1411 _blast_item = cb_index;
1412 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
1413 if ( default_option == Configuration.blast ) {
1414 selected_index = cb_index;
1420 // Set default selection and its action
1421 _click_to_combobox.setSelectedIndex( selected_index );
1422 setClickToAction( selected_index );
1427 * Set up the controls from the config settings. 11/26/05
1429 void setupControls() {
1430 // The tree display options:
1431 setupDisplayCheckboxes();
1433 // The sequence relation query selection combo-box
1434 if ( _configuration.displaySequenceRelations() ) {
1435 addSequenceRelationBlock();
1439 startClickToOptions();
1440 setupClickToOptions();
1441 endClickToOptions();
1442 // Zoom and quick edit buttons
1447 void setUpControlsForDomainStrucures() {
1448 _domain_display_label = new JLabel( "Domain Display:" );
1449 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1450 add( _domain_display_label );
1451 _zoom_in_domain_structure = new JButton( "d+" );
1452 _zoom_out_domain_structure = new JButton( "d-" );
1453 _decr_domain_structure_evalue_thr = new JButton( "-" );
1454 _incr_domain_structure_evalue_thr = new JButton( "+" );
1455 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1456 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1457 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1458 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1459 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1460 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1461 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1462 _domain_structure_evalue_thr_tf.setEditable( false );
1463 if ( !getConfiguration().isUseNativeUI() ) {
1464 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1465 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1466 _domain_structure_evalue_thr_tf.setBorder( null );
1468 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1469 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1470 if ( !_configuration.isUseNativeUI() ) {
1471 d1_panel.setBackground( getBackground() );
1472 d2_panel.setBackground( getBackground() );
1476 addJButton( _zoom_out_domain_structure, d1_panel );
1477 addJButton( _zoom_in_domain_structure, d1_panel );
1478 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1479 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1480 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1483 private void setupDisplayCheckboxes() {
1484 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
1485 addCheckbox( Configuration.display_as_phylogram,
1486 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
1487 setCheckbox( Configuration.display_as_phylogram,
1488 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
1490 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1491 addCheckbox( Configuration.dynamically_hide_data,
1492 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
1493 setCheckbox( Configuration.dynamically_hide_data,
1494 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
1496 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1497 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1498 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1500 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1501 addCheckbox( Configuration.display_internal_data,
1502 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
1503 setCheckbox( Configuration.display_internal_data,
1504 _configuration.doCheckOption( Configuration.display_internal_data ) );
1506 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1507 addCheckbox( Configuration.color_according_to_species,
1508 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
1509 setCheckbox( Configuration.color_according_to_species,
1510 _configuration.doCheckOption( Configuration.color_according_to_species ) );
1512 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1513 addCheckbox( Configuration.color_according_to_annotation,
1514 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
1515 setCheckbox( Configuration.color_according_to_annotation,
1516 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
1518 if ( _configuration.doDisplayOption( Configuration.color_branches ) ) {
1519 addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) );
1520 setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) );
1522 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1523 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1524 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1526 final JLabel label = new JLabel( "Display Data:" );
1527 label.setFont( ControlPanel.jcb_bold_font );
1528 if ( !getConfiguration().isUseNativeUI() ) {
1529 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1532 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1533 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
1534 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1536 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1537 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1538 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1540 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1541 addCheckbox( Configuration.show_taxonomy_scientific_names,
1542 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1543 setCheckbox( Configuration.show_taxonomy_scientific_names,
1544 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1546 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1547 addCheckbox( Configuration.show_taxonomy_common_names,
1548 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1549 setCheckbox( Configuration.show_taxonomy_common_names,
1550 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1552 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1553 addCheckbox( Configuration.show_taxonomy_images,
1554 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1555 setCheckbox( Configuration.show_taxonomy_images,
1556 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1558 if ( _configuration.doDisplayOption( Configuration.show_gene_symbols ) ) {
1559 addCheckbox( Configuration.show_gene_symbols,
1560 _configuration.getDisplayTitle( Configuration.show_gene_symbols ) );
1561 setCheckbox( Configuration.show_gene_symbols,
1562 _configuration.doCheckOption( Configuration.show_gene_symbols ) );
1564 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1565 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1566 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1568 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1569 addCheckbox( Configuration.show_sequence_acc,
1570 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1571 setCheckbox( Configuration.show_sequence_acc,
1572 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1574 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1575 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
1576 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1578 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1579 addCheckbox( Configuration.show_binary_characters,
1580 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1581 setCheckbox( Configuration.show_binary_characters,
1582 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1584 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1585 addCheckbox( Configuration.show_binary_character_counts,
1586 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1587 setCheckbox( Configuration.show_binary_character_counts,
1588 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1590 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1591 addCheckbox( Configuration.show_domain_architectures,
1592 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1593 setCheckbox( Configuration.show_domain_architectures,
1594 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1596 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1597 addCheckbox( Configuration.write_confidence_values,
1598 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1599 setCheckbox( Configuration.write_confidence_values,
1600 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1602 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1603 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1604 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1606 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1607 addCheckbox( Configuration.show_vector_data,
1608 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1609 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
1611 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1612 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
1613 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1617 void setupSearchTools() {
1618 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1619 final JLabel search_label = new JLabel( "Search:" );
1620 search_label.setFont( ControlPanel.jcb_bold_font );
1621 if ( !getConfiguration().isUseNativeUI() ) {
1622 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1624 add( search_label );
1625 search_label.setToolTipText( tip );
1626 _search_found_label = new JLabel();
1627 getSearchFoundCountsLabel().setVisible( false );
1628 _search_found_label.setFont( ControlPanel.jcb_bold_font );
1629 if ( !getConfiguration().isUseNativeUI() ) {
1630 _search_found_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1632 _search_tf = new JTextField( 3 );
1633 _search_tf.setToolTipText( tip );
1634 _search_tf.setEditable( true );
1635 if ( !getConfiguration().isUseNativeUI() ) {
1636 _search_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1637 _search_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1638 _search_tf.setBorder( null );
1640 _search_reset_button = new JButton();
1641 getSearchResetButton().setText( "Reset" );
1642 getSearchResetButton().setEnabled( false );
1643 getSearchResetButton().setVisible( false );
1644 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1645 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1646 s_panel_1.setBackground( getBackground() );
1648 s_panel_2.setBackground( getBackground() );
1650 final KeyAdapter key_adapter = new KeyAdapter() {
1653 public void keyReleased( final KeyEvent key_event ) {
1655 displayedPhylogenyMightHaveChanged( true );
1658 final ActionListener action_listener = new ActionListener() {
1661 public void actionPerformed( final ActionEvent e ) {
1663 setSearchFoundCountsOnLabel( 0 );
1664 getSearchFoundCountsLabel().setVisible( false );
1665 getSearchTextField().setText( "" );
1666 getSearchResetButton().setEnabled( false );
1667 getSearchResetButton().setVisible( false );
1668 displayedPhylogenyMightHaveChanged( true );
1671 _search_reset_button.addActionListener( action_listener );
1672 _search_tf.addKeyListener( key_adapter );
1673 addJTextField( _search_tf, s_panel_1 );
1674 s_panel_2.add( _search_found_label );
1675 addJButton( _search_reset_button, s_panel_2 );
1678 private void setVisibilityOfDomainStrucureControls() {
1679 if ( _zoom_in_domain_structure != null ) {
1680 if ( isShowDomainArchitectures() ) {
1681 _domain_display_label.setVisible( true );
1682 _zoom_in_domain_structure.setVisible( true );
1683 _zoom_out_domain_structure.setVisible( true );
1684 _decr_domain_structure_evalue_thr.setVisible( true );
1685 _incr_domain_structure_evalue_thr.setVisible( true );
1686 _domain_structure_evalue_thr_tf.setVisible( true );
1689 _domain_display_label.setVisible( false );
1690 _zoom_in_domain_structure.setVisible( false );
1691 _zoom_out_domain_structure.setVisible( false );
1692 _decr_domain_structure_evalue_thr.setVisible( false );
1693 _incr_domain_structure_evalue_thr.setVisible( false );
1694 _domain_structure_evalue_thr_tf.setVisible( false );
1700 * Fit entire tree into window.
1703 if ( _mainpanel.getCurrentScrollPane() == null ) {
1706 displayedPhylogenyMightHaveChanged( false );
1707 _mainpanel.getCurrentTreePanel().updateOvSettings();
1708 _mainpanel.getCurrentTreePanel().validate();
1709 _mainpanel.validate();
1710 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1711 _mainpanel.getSizeOfViewport().height,
1713 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1714 _mainpanel.adjustJScrollPane();
1715 _mainpanel.getCurrentTreePanel().repaint();
1716 _mainpanel.getCurrentTreePanel().validate();
1717 _mainpanel.validate();
1718 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1719 _mainpanel.getSizeOfViewport().height,
1721 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1722 _mainpanel.adjustJScrollPane();
1723 _mainpanel.getCurrentTreePanel().repaint();
1724 _mainpanel.getCurrentTreePanel().updateOvSizes();
1727 void showWholeAll() {
1728 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1729 if ( tree_panel != null ) {
1730 tree_panel.validate();
1731 tree_panel.setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1732 _mainpanel.getSizeOfViewport().height,
1734 tree_panel.resetPreferredSize();
1735 tree_panel.repaint();
1740 // Create header for click-to combo box.
1741 void startClickToOptions() {
1742 final JLabel spacer = new JLabel( "" );
1743 spacer.setFont( ControlPanel.jcb_font );
1745 _click_to_label = new JLabel( "Click on Node to:" );
1746 add( customizeLabel( _click_to_label, getConfiguration() ) );
1747 _click_to_combobox = new JComboBox();
1748 _click_to_combobox.setFocusable( false );
1749 _click_to_combobox.setMaximumRowCount( 14 );
1750 _click_to_combobox.setFont( ControlPanel.js_font );
1751 if ( !_configuration.isUseNativeUI() ) {
1752 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1754 // don't add listener until all items are set (or each one will trigger
1756 // click_to_list.addActionListener(this);
1757 add( _click_to_combobox );
1758 // Correlates option names to titles
1759 _all_click_to_names = new HashMap<Integer, String>();
1760 _click_to_names = new ArrayList<String>();
1764 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1765 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1766 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1767 setDrawPhylogramEnabled( true );
1768 setDrawPhylogram( isDrawPhylogram() );
1771 setDrawPhylogramEnabled( false );
1772 setDrawPhylogram( false );
1774 if ( getMainPanel().getMainFrame() == null ) {
1775 // Must be "E" applet version.
1776 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1777 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1780 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1781 .getPhylogenyGraphicsType() );
1783 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1784 getMainPanel().getControlPanel().search();
1785 getSequenceRelationTypeBox().removeAllItems();
1786 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1787 .getRelevantSequenceRelationTypes() ) {
1788 _sequence_relation_type_box.addItem( type );
1790 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1791 // according to GUILHEM the line above can be removed.
1796 * Uncollapse all nodes.
1798 void uncollapseAll( final TreePanel tp ) {
1799 final Phylogeny t = tp.getPhylogeny();
1800 if ( ( t != null ) && !t.isEmpty() ) {
1801 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
1802 final PhylogenyNode node = iter.next();
1803 node.setCollapse( false );
1805 tp.resetNodeIdToDistToLeafMap();
1806 tp.updateSetOfCollapsedExternalNodes( t );
1807 t.recalculateNumberOfExternalDescendants( false );
1808 tp.setNodeInPreorderToNull();
1814 void updateDomainStructureEvaluethresholdDisplay() {
1815 if ( _domain_structure_evalue_thr_tf != null ) {
1816 _domain_structure_evalue_thr_tf.setText( "10^"
1817 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1821 void zoomInX( final float factor, final float x_correction_factor ) {
1822 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1823 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1824 treepanel.multiplyUrtFactor( 1f );
1825 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1826 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1827 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1828 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1829 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1830 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1831 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1832 getMainPanel().adjustJScrollPane();
1833 treepanel.resetPreferredSize();
1834 getMainPanel().getCurrentScrollPane().getViewport().validate();
1835 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1836 - ( sb.getVisibleAmount() / 2.0 ) ) );
1839 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1840 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1841 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1842 getMainPanel().adjustJScrollPane();
1843 treepanel.resetPreferredSize();
1844 getMainPanel().getCurrentScrollPane().getViewport().validate();
1845 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1847 treepanel.resetPreferredSize();
1848 treepanel.updateOvSizes();
1851 void zoomInY( final float factor ) {
1852 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1853 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1854 treepanel.multiplyUrtFactor( 1.1f );
1855 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1856 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1857 getMainPanel().adjustJScrollPane();
1858 treepanel.resetPreferredSize();
1859 getMainPanel().getCurrentScrollPane().getViewport().validate();
1860 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1861 - ( sb.getVisibleAmount() / 2.0 ) ) );
1862 treepanel.resetPreferredSize();
1863 treepanel.updateOvSizes();
1866 void zoomOutX( final float factor, final float x_correction_factor ) {
1867 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1868 treepanel.multiplyUrtFactor( 1f );
1869 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1870 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1871 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1872 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1873 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1874 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1875 getMainPanel().adjustJScrollPane();
1876 treepanel.resetPreferredSize();
1877 getMainPanel().getCurrentScrollPane().getViewport().validate();
1878 final double x = ( sb.getMaximum() - sb.getMinimum() )
1879 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1880 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1881 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1882 getMainPanel().adjustJScrollPane();
1883 treepanel.resetPreferredSize();
1884 getMainPanel().getCurrentScrollPane().getViewport().validate();
1885 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1886 - ( sb.getVisibleAmount() / 2.0 ) ) );
1889 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1890 treepanel.setXdistance( treepanel.getXdistance() * factor );
1891 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
1893 getMainPanel().adjustJScrollPane();
1894 treepanel.resetPreferredSize();
1895 getMainPanel().getCurrentScrollPane().getViewport().validate();
1896 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1899 treepanel.resetPreferredSize();
1900 treepanel.updateOvSizes();
1904 void zoomOutY( final float factor ) {
1905 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1906 treepanel.multiplyUrtFactor( 0.9f );
1907 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1908 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1909 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1910 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1911 getMainPanel().adjustJScrollPane();
1912 treepanel.resetPreferredSize();
1913 getMainPanel().getCurrentScrollPane().getViewport().validate();
1914 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1915 - ( sb.getVisibleAmount() / 2.0 ) ) );
1916 treepanel.resetPreferredSize();
1917 treepanel.updateOvSizes();
1921 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
1922 label.setFont( ControlPanel.jcb_bold_font );
1923 if ( !configuration.isUseNativeUI() ) {
1924 label.setForeground( configuration.getGuiCheckboxTextColor() );
1925 label.setBackground( configuration.getGuiBackgroundColor() );
1930 enum NodeClickAction {
1941 DELETE_NODE_OR_SUBTREE,