2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 // Contact: phylosoft @ gmail . com
23 // WWW: www.phylosoft.org/forester
25 package org.forester.archaeopteryx;
27 import java.awt.BorderLayout;
28 import java.awt.Color;
29 import java.awt.Component;
30 import java.awt.Dimension;
32 import java.awt.GridBagLayout;
33 import java.awt.GridLayout;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.ActionListener;
36 import java.awt.event.ItemEvent;
37 import java.awt.event.ItemListener;
38 import java.awt.event.KeyAdapter;
39 import java.awt.event.KeyEvent;
40 import java.util.ArrayList;
41 import java.util.Arrays;
42 import java.util.Collection;
43 import java.util.HashMap;
44 import java.util.HashSet;
45 import java.util.List;
48 import javax.swing.BorderFactory;
49 import javax.swing.DefaultListCellRenderer;
50 import javax.swing.JButton;
51 import javax.swing.JCheckBox;
52 import javax.swing.JComboBox;
53 import javax.swing.JLabel;
54 import javax.swing.JList;
55 import javax.swing.JPanel;
56 import javax.swing.JScrollBar;
57 import javax.swing.JTextField;
58 import javax.swing.ListCellRenderer;
60 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
61 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
62 import org.forester.phylogeny.Phylogeny;
63 import org.forester.phylogeny.PhylogenyMethods;
64 import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
65 import org.forester.phylogeny.PhylogenyNode;
66 import org.forester.phylogeny.data.Sequence;
67 import org.forester.phylogeny.data.SequenceRelation;
68 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
69 import org.forester.util.ForesterUtil;
71 final class ControlPanel extends JPanel implements ActionListener {
73 private static final String RETURN_TO_SUPER_TREE_TEXT = "Back to Super Tree";
74 final static Font jcb_font = new Font( Configuration.getDefaultFontFamilyName(),
77 final static Font js_font = new Font( Configuration.getDefaultFontFamilyName(),
80 final static Font jcb_bold_font = new Font( Configuration.getDefaultFontFamilyName(),
83 private static final long serialVersionUID = -8463483932821545633L;
84 private final MainPanel _mainpanel;
85 // The settings from the conf file
86 private final Configuration _configuration;
88 private JCheckBox _display_internal_data;
89 private JCheckBox _show_node_names;
90 private JCheckBox _show_taxo_code;
91 private JCheckBox _write_confidence;
92 private JCheckBox _show_events;
93 private JCheckBox _color_acc_species;
94 private JCheckBox _color_branches_cb;
95 private JCheckBox _width_branches;
96 private JCheckBox _show_domain_architectures;
97 private JCheckBox _show_annotation;
98 private JCheckBox _show_binary_characters;
99 private JCheckBox _show_binary_character_counts;
100 private JCheckBox _show_gene_names;
101 private JCheckBox _show_gene_symbols;
102 private JCheckBox _show_sequence_acc;
103 private JCheckBox _node_desc_popup_cb;
104 private JCheckBox _dynamically_hide_data;
105 private JCheckBox _show_taxo_scientific_names;
106 private JCheckBox _show_taxo_common_names;
107 private JCheckBox _show_taxo_images_cb;
108 private JCheckBox _color_according_to_annotation;
109 private JCheckBox _display_as_phylogram_cb;
110 private JCheckBox _seq_relation_confidence_switch;
111 private JComboBox _show_sequence_relations;
112 private JComboBox _sequence_relation_type_box;
113 private JCheckBox _show_vector_data_cb;
114 private JCheckBox _show_properties_cb;
115 private JLabel _click_to_label;
116 private JLabel _zoom_label;
117 private JLabel _domain_display_label;
118 private JComboBox _click_to_combobox;
119 private Map<Integer, String> _all_click_to_names;
120 private List<String> _click_to_names;
121 // Indices for the click-to options in the combo box
122 private int _show_data_item;
123 private int _collapse_cb_item;
124 private int _reroot_cb_item;
125 private int _swap_cb_item;
126 private int _subtree_cb_item;
127 private int _color_subtree_cb_item;
128 private int _open_seq_web_item;
129 private int _sort_descendents_item;
130 private int _open_tax_web_item;
131 private int _cut_subtree_item;
132 private int _copy_subtree_item;
133 private int _delete_node_or_subtree_item;
134 private int _paste_subtree_item;
135 private int _add_new_node_item;
136 private int _edit_node_data_item;
137 private int _blast_item;
138 // zooming and quick tree manipulation buttons:
139 private JButton _zoom_in_x;
140 private JButton _zoom_in_y;
141 private JButton _zoom_out_x;
142 private JButton _zoom_out_y;
143 private JButton _show_whole;
144 private JButton _order;
145 private JButton _uncollapse_all;
146 private JButton _zoom_in_domain_structure;
147 private JButton _zoom_out_domain_structure;
148 private JButton _decr_domain_structure_evalue_thr;
149 private JButton _incr_domain_structure_evalue_thr;
150 private JButton _return_to_super_tree;
151 private JTextField _domain_structure_evalue_thr_tf;
152 private JTextField _search_tf;
153 private boolean _order_of_appearance;
154 private boolean _color_branches;
155 private NodeClickAction _action_when_node_clicked;
156 private List<Boolean> _draw_phylogram;
157 private Map<String, Color> _annotation_colors;
158 private Map<String, Color> _species_colors;
159 private JButton _search_reset_button;
160 private JLabel _search_found_label;
161 private Sequence _selected_query_seq;
163 ControlPanel( final MainPanel ap, final Configuration configuration ) {
166 _configuration = configuration;
167 if ( !_configuration.isUseNativeUI() ) {
168 setBackground( getConfiguration().getGuiBackgroundColor() );
169 setBorder( BorderFactory.createRaisedBevelBorder() );
171 setLayout( new GridLayout( 0, 1, 2, 2 ) );
172 _order_of_appearance = true;
180 public void actionPerformed( final ActionEvent e ) {
182 final TreePanel tp = getMainPanel().getCurrentTreePanel();
186 if ( e.getSource() == _click_to_combobox ) {
187 setClickToAction( _click_to_combobox.getSelectedIndex() );
188 getCurrentTreePanel().repaint();
190 else if ( e.getSource() == _show_binary_characters ) {
191 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
192 _show_binary_character_counts.setSelected( false );
194 displayedPhylogenyMightHaveChanged( true );
196 else if ( e.getSource() == _show_binary_character_counts ) {
197 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
198 _show_binary_characters.setSelected( false );
200 displayedPhylogenyMightHaveChanged( true );
202 else if ( e.getSource() == _color_according_to_annotation ) {
203 if ( ( _show_annotation != null ) && _color_according_to_annotation.isSelected() ) {
204 _show_annotation.setSelected( true );
206 displayedPhylogenyMightHaveChanged( false );
208 else if ( e.getSource() == _show_annotation ) {
209 if ( ( _color_according_to_annotation != null ) && !_show_annotation.isSelected() ) {
210 _color_according_to_annotation.setSelected( false );
212 displayedPhylogenyMightHaveChanged( false );
214 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
215 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
216 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
220 else if ( e.getSource() == _zoom_in_x ) {
221 zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
222 displayedPhylogenyMightHaveChanged( false );
224 else if ( e.getSource() == _zoom_in_y ) {
225 zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR );
226 displayedPhylogenyMightHaveChanged( false );
228 else if ( e.getSource() == _zoom_out_x ) {
229 zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
230 displayedPhylogenyMightHaveChanged( false );
232 else if ( e.getSource() == _zoom_out_y ) {
233 zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR );
234 displayedPhylogenyMightHaveChanged( false );
236 else if ( e.getSource() == _show_whole ) {
239 else if ( e.getSource() == _return_to_super_tree ) {
240 _mainpanel.getCurrentTreePanel().superTree();
243 else if ( e.getSource() == _order ) {
244 DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
245 if ( ( !isShowTaxonomyScientificNames() && !isShowTaxonomyCode() && !isShowTaxonomyCommonNames() ) ) {
246 if ( ( isShowSequenceAcc() || isShowGeneNames() || isShowGeneSymbols() ) ) {
247 pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
249 else if ( isShowNodeNames() ) {
250 pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
253 PhylogenyMethods.orderAppearance( tp.getPhylogeny().getRoot(), _order_of_appearance, true, pri );
254 _order_of_appearance = !_order_of_appearance;
255 displayedPhylogenyMightHaveChanged( false );
257 else if ( e.getSource() == _uncollapse_all ) {
259 displayedPhylogenyMightHaveChanged( false );
261 else if ( e.getSource() == _zoom_in_domain_structure ) {
262 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
263 displayedPhylogenyMightHaveChanged( true );
265 else if ( e.getSource() == _zoom_out_domain_structure ) {
266 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
267 displayedPhylogenyMightHaveChanged( true );
269 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
270 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThreshold();
271 displayedPhylogenyMightHaveChanged( true );
273 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
274 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThreshold();
275 displayedPhylogenyMightHaveChanged( true );
277 else if ( e.getSource() == _search_tf ) {
279 displayedPhylogenyMightHaveChanged( true );
282 displayedPhylogenyMightHaveChanged( true );
286 tp.requestFocusInWindow();
289 catch ( final Exception ex ) {
290 AptxUtil.unexpectedException( ex );
292 catch ( final Error err ) {
293 AptxUtil.unexpectedError( err );
297 void activateButtonToReturnToSuperTree( int index ) {
300 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
303 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
305 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
306 _return_to_super_tree.setEnabled( true );
310 * Add zoom and quick edit buttons. (Last modified 8/9/04)
313 final JLabel spacer = new JLabel( "" );
314 spacer.setOpaque( false );
316 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
317 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
318 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
319 if ( !getConfiguration().isUseNativeUI() ) {
320 x_panel.setBackground( getBackground() );
321 y_panel.setBackground( getBackground() );
322 z_panel.setBackground( getBackground() );
324 add( _zoom_label = new JLabel( "Zoom:" ) );
325 customizeLabel( _zoom_label, getConfiguration() );
329 if ( getConfiguration().isUseNativeUI() ) {
330 _zoom_in_x = new JButton( "+" );
331 _zoom_out_x = new JButton( "-" );
334 _zoom_in_x = new JButton( "X+" );
335 _zoom_out_x = new JButton( "X-" );
337 _zoom_in_y = new JButton( "Y+" );
338 _zoom_out_y = new JButton( "Y-" );
339 _show_whole = new JButton( "F" );
340 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [Backspace]" );
341 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+Right]" );
342 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+Up]" );
343 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+Left]" );
344 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+Down]" );
345 if ( getConfiguration().isUseNativeUI() && AptxUtil.isMac() ) {
346 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
347 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
350 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
351 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
353 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
354 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
355 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
356 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
357 _return_to_super_tree.setEnabled( false );
358 _order = new JButton( "Order Subtrees" );
359 _uncollapse_all = new JButton( "Uncollapse All" );
360 addJButton( _zoom_in_y, x_panel );
361 addJButton( _zoom_out_x, y_panel );
362 addJButton( _show_whole, y_panel );
363 addJButton( _zoom_in_x, y_panel );
364 addJButton( _zoom_out_y, z_panel );
365 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
366 setUpControlsForDomainStrucures();
368 final JLabel spacer2 = new JLabel( "" );
370 addJButton( _return_to_super_tree, this );
371 addJButton( _order, this );
372 addJButton( _uncollapse_all, this );
373 final JLabel spacer3 = new JLabel( "" );
375 setVisibilityOfDomainStrucureControls();
378 void addCheckbox( final int which, final String title ) {
379 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
381 case Configuration.display_as_phylogram:
382 _display_as_phylogram_cb = new JCheckBox( title );
383 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
384 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
387 case Configuration.display_internal_data:
388 _display_internal_data = new JCheckBox( title );
389 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
390 addJCheckBox( _display_internal_data, ch_panel );
393 case Configuration.color_according_to_species:
394 _color_acc_species = new JCheckBox( title );
396 .setToolTipText( "To colorize taxonomy and sequence labels as a function of taxonomy" );
397 addJCheckBox( _color_acc_species, ch_panel );
400 case Configuration.color_according_to_annotation:
401 _color_according_to_annotation = new JCheckBox( title );
402 _color_according_to_annotation
403 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
404 addJCheckBox( _color_according_to_annotation, ch_panel );
407 case Configuration.show_node_names:
408 _show_node_names = new JCheckBox( title );
409 addJCheckBox( _show_node_names, ch_panel );
412 case Configuration.show_taxonomy_scientific_names:
413 _show_taxo_scientific_names = new JCheckBox( title );
414 addJCheckBox( _show_taxo_scientific_names, ch_panel );
417 case Configuration.show_taxonomy_common_names:
418 _show_taxo_common_names = new JCheckBox( title );
419 addJCheckBox( _show_taxo_common_names, ch_panel );
422 case Configuration.show_tax_code:
423 _show_taxo_code = new JCheckBox( title );
424 addJCheckBox( _show_taxo_code, ch_panel );
427 case Configuration.show_taxonomy_images:
428 _show_taxo_images_cb = new JCheckBox( title );
429 addJCheckBox( _show_taxo_images_cb, ch_panel );
432 case Configuration.show_binary_characters:
433 _show_binary_characters = new JCheckBox( title );
434 addJCheckBox( _show_binary_characters, ch_panel );
437 case Configuration.show_annotation:
438 _show_annotation = new JCheckBox( title );
439 addJCheckBox( _show_annotation, ch_panel );
442 case Configuration.show_binary_character_counts:
443 _show_binary_character_counts = new JCheckBox( title );
444 addJCheckBox( _show_binary_character_counts, ch_panel );
447 case Configuration.write_confidence_values:
448 _write_confidence = new JCheckBox( title );
449 addJCheckBox( getWriteConfidenceCb(), ch_panel );
452 case Configuration.write_events:
453 _show_events = new JCheckBox( title );
454 addJCheckBox( getShowEventsCb(), ch_panel );
457 case Configuration.color_branches:
458 _color_branches_cb = new JCheckBox( title );
459 getColorBranchesCb().setToolTipText( "To use branch color values, if present" );
460 addJCheckBox( getColorBranchesCb(), ch_panel );
463 case Configuration.width_branches:
464 _width_branches = new JCheckBox( title );
465 _width_branches.setToolTipText( "To use branch width values, if present" );
466 addJCheckBox( _width_branches, ch_panel );
469 case Configuration.show_domain_architectures:
470 _show_domain_architectures = new JCheckBox( title );
471 addJCheckBox( _show_domain_architectures, ch_panel );
474 case Configuration.show_gene_names:
475 _show_gene_names = new JCheckBox( title );
476 addJCheckBox( _show_gene_names, ch_panel );
479 case Configuration.show_gene_symbols:
480 _show_gene_symbols = new JCheckBox( title );
481 addJCheckBox( _show_gene_symbols, ch_panel );
484 case Configuration.show_sequence_acc:
485 _show_sequence_acc = new JCheckBox( title );
486 addJCheckBox( _show_sequence_acc, ch_panel );
489 case Configuration.dynamically_hide_data:
490 _dynamically_hide_data = new JCheckBox( title );
491 getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" );
492 addJCheckBox( getDynamicallyHideData(), ch_panel );
495 case Configuration.node_data_popup:
496 _node_desc_popup_cb = new JCheckBox( title );
497 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
498 addJCheckBox( getNodeDescPopupCb(), ch_panel );
501 case Configuration.show_relation_confidence:
502 _seq_relation_confidence_switch = new JCheckBox( title );
503 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
506 case Configuration.show_vector_data:
507 _show_vector_data_cb = new JCheckBox( title );
508 addJCheckBox( _show_vector_data_cb, ch_panel );
511 case Configuration.show_properties:
512 _show_properties_cb = new JCheckBox( title );
513 addJCheckBox( _show_properties_cb, ch_panel );
517 throw new RuntimeException( "unknown checkbox: " + which );
521 private void addClickToOption( final int which, final String title ) {
522 _click_to_combobox.addItem( title );
523 _click_to_names.add( title );
524 _all_click_to_names.put( new Integer( which ), title );
525 if ( !_configuration.isUseNativeUI() ) {
526 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
527 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
531 void addJButton( final JButton jb, final JPanel p ) {
532 jb.setFocusPainted( false );
533 jb.setFont( ControlPanel.jcb_font );
534 if ( !_configuration.isUseNativeUI() ) {
535 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
536 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
537 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
540 jb.addActionListener( this );
543 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
544 jcb.setFocusPainted( false );
545 jcb.setFont( ControlPanel.jcb_font );
546 if ( !_configuration.isUseNativeUI() ) {
547 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
548 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
550 p.add( jcb, "Center" );
551 jcb.addActionListener( this );
554 void addJTextField( final JTextField tf, final JPanel p ) {
555 if ( !_configuration.isUseNativeUI() ) {
556 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
557 tf.setFont( ControlPanel.jcb_font );
560 tf.addActionListener( this );
564 private void addSequenceRelationBlock() {
565 final JLabel spacer = new JLabel( "" );
566 spacer.setSize( 1, 1 );
568 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
569 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
570 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
571 getSequenceRelationTypeBox().setFocusable( false );
572 _sequence_relation_type_box.setFont( ControlPanel.js_font );
573 if ( !_configuration.isUseNativeUI() ) {
574 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
575 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
577 _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
580 public Component getListCellRendererComponent( final JList list,
583 final boolean isSelected,
584 final boolean cellHasFocus ) {
585 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
590 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
591 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
592 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
597 final GridBagLayout gbl = new GridBagLayout();
598 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
599 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
600 final JPanel horizGrid = new JPanel( gbl );
601 horizGrid.setBackground( getBackground() );
602 horizGrid.add( typeLabel );
603 horizGrid.add( _sequence_relation_type_box );
604 add( customizeLabel( mainLabel, getConfiguration() ) );
606 add( getSequenceRelationBox() );
607 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
608 addCheckbox( Configuration.show_relation_confidence,
609 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
610 setCheckbox( Configuration.show_relation_confidence,
611 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
613 }// addSequenceRelationBlock
615 void deactivateButtonToReturnToSuperTree() {
616 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
617 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
618 _return_to_super_tree.setEnabled( false );
621 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
622 if ( ( _mainpanel != null ) && ( _mainpanel.getCurrentPhylogeny() != null ) ) {
623 if ( getOptions().isShowOverview() ) {
624 _mainpanel.getCurrentTreePanel().updateOvSizes();
626 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
627 setVisibilityOfDomainStrucureControls();
628 updateDomainStructureEvaluethresholdDisplay();
629 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
630 _mainpanel.getCurrentTreePanel().calcMaxDepth();
631 _mainpanel.adjustJScrollPane();
632 if ( recalc_longest_ext_node_info ) {
633 _mainpanel.getCurrentTreePanel().initNodeData();
634 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
636 _mainpanel.getCurrentTreePanel().repaint();
637 // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
641 void endClickToOptions() {
642 _click_to_combobox.addActionListener( this );
646 * Indicates what action should be execute when a node is clicked
648 * @return the click-on action
650 NodeClickAction getActionWhenNodeClicked() {
651 return _action_when_node_clicked;
654 Map<Integer, String> getAllClickToItems() {
655 return _all_click_to_names;
658 Map<String, Color> getAnnotationColors() {
659 return _annotation_colors;
662 public JCheckBox getColorBranchesCb() {
663 return _color_branches_cb;
666 public JCheckBox getColorAccSpeciesCb() {
667 return _color_acc_species;
670 Configuration getConfiguration() {
671 return _configuration;
674 TreePanel getCurrentTreePanel() {
675 return getMainPanel().getCurrentTreePanel();
678 public JCheckBox getDisplayAsPhylogramCb() {
679 return _display_as_phylogram_cb;
682 public JCheckBox getDynamicallyHideData() {
683 return _dynamically_hide_data;
687 private List<Boolean> getIsDrawPhylogramList() {
688 return _draw_phylogram;
691 MainPanel getMainPanel() {
695 public JCheckBox getNodeDescPopupCb() {
696 return _node_desc_popup_cb;
699 Options getOptions() {
700 return getMainPanel().getOptions();
703 private JLabel getSearchFoundCountsLabel() {
704 return _search_found_label;
707 private JButton getSearchResetButton() {
708 return _search_reset_button;
711 JTextField getSearchTextField() {
715 public Sequence getSelectedQuerySequence() {
716 return _selected_query_seq;
719 public JComboBox getSequenceRelationBox() {
720 if ( _show_sequence_relations == null ) {
721 _show_sequence_relations = new JComboBox();
722 _show_sequence_relations.setFocusable( false );
723 _show_sequence_relations.setMaximumRowCount( 20 );
724 _show_sequence_relations.setFont( ControlPanel.js_font );
725 if ( !_configuration.isUseNativeUI() ) {
726 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
727 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
729 _show_sequence_relations.addItem( "-----" );
730 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
732 return _show_sequence_relations;
736 public JComboBox getSequenceRelationTypeBox() {
737 if ( _sequence_relation_type_box == null ) {
738 _sequence_relation_type_box = new JComboBox();
739 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
740 _sequence_relation_type_box.addItem( type );
742 _sequence_relation_type_box.addActionListener( new ActionListener() {
745 public void actionPerformed( final ActionEvent e ) {
746 if ( _mainpanel.getCurrentPhylogeny() != null ) {
747 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
752 return _sequence_relation_type_box;
755 public JCheckBox getShowEventsCb() {
759 List<String> getSingleClickToNames() {
760 return _click_to_names;
763 Map<String, Color> getSpeciesColors() {
764 return _species_colors;
767 public JCheckBox getWriteConfidenceCb() {
768 return _write_confidence;
771 private void init() {
772 _draw_phylogram = new ArrayList<Boolean>();
773 setSpeciesColors( new HashMap<String, Color>() );
774 setAnnotationColors( new HashMap<String, Color>() );
777 boolean isAntialiasScreenText() {
781 boolean isColorAccordingToAnnotation() {
782 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
785 boolean isColorAccordingToTaxonomy() {
786 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
789 boolean isColorBranches() {
790 return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) );
793 boolean isDrawPhylogram() {
794 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
797 private boolean isDrawPhylogram( final int index ) {
798 return getIsDrawPhylogramList().get( index );
801 boolean isDynamicallyHideData() {
802 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
806 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
809 boolean isNodeDescPopup() {
810 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
813 boolean isShowAnnotation() {
814 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
817 boolean isShowBinaryCharacterCounts() {
818 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
821 boolean isShowBinaryCharacters() {
822 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
825 boolean isShowConfidenceValues() {
826 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
829 boolean isShowDomainArchitectures() {
830 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
833 boolean isShowGeneNames() {
834 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
837 public boolean isShowVectorData() {
838 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
841 public boolean isShowProperties() {
842 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
845 boolean isShowGeneSymbols() {
846 return ( ( _show_gene_symbols != null ) && _show_gene_symbols.isSelected() );
849 boolean isShowInternalData() {
850 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
853 boolean isShowNodeNames() {
854 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
857 boolean isShowSequenceAcc() {
858 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
861 boolean isShowSequenceRelationConfidence() {
862 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
865 boolean isShowSequenceRelations() {
866 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
869 boolean isShowTaxonomyCode() {
870 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
873 public boolean isShowTaxonomyImages() {
874 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
877 boolean isShowTaxonomyCommonNames() {
878 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
881 boolean isShowTaxonomyScientificNames() {
882 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
885 boolean isWidthBranches() {
886 return ( ( _width_branches != null ) && _width_branches.isSelected() );
889 void phylogenyAdded( final Configuration configuration ) {
890 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
893 void phylogenyRemoved( final int index ) {
894 getIsDrawPhylogramList().remove( index );
898 final MainPanel main_panel = getMainPanel();
899 final Phylogeny tree = main_panel.getCurrentPhylogeny();
900 if ( ( tree == null ) || tree.isEmpty() ) {
903 String query = getSearchTextField().getText();
904 if ( query != null ) {
905 query = query.trim();
908 getSearchFoundCountsLabel().setVisible( false );
909 getSearchResetButton().setEnabled( false );
910 getSearchResetButton().setVisible( false );
913 if ( !ForesterUtil.isEmpty( query ) ) {
914 search( main_panel, tree, query );
917 getSearchFoundCountsLabel().setVisible( false );
918 getSearchResetButton().setEnabled( false );
919 getSearchResetButton().setVisible( false );
924 private void search( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
925 getSearchFoundCountsLabel().setVisible( true );
926 getSearchResetButton().setEnabled( true );
927 getSearchResetButton().setVisible( true );
928 String[] queries = null;
929 List<PhylogenyNode> nodes = null;
930 if ( query_str.indexOf( ',' ) >= 0 ) {
931 queries = query_str.split( ",+" );
934 queries = new String[ 1 ];
935 queries[ 0 ] = query_str.trim();
937 if ( ( queries != null ) && ( queries.length > 0 ) ) {
938 nodes = new ArrayList<PhylogenyNode>();
939 for( String query : queries ) {
940 if ( ForesterUtil.isEmpty( query ) ) {
943 query = query.trim();
944 if ( query.indexOf( '+' ) >= 0 ) {
945 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ), tree, getOptions()
946 .isSearchCaseSensitive(), !getOptions().isMatchWholeTermsOnly() ) );
949 nodes.addAll( PhylogenyMethods.searchData( query,
951 getOptions().isSearchCaseSensitive(),
952 !getOptions().isMatchWholeTermsOnly() ) );
955 if ( getOptions().isInverseSearchResult() ) {
956 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
957 all.removeAll( nodes );
961 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
962 main_panel.getCurrentTreePanel().setFoundNodes( new HashSet<Integer>() );
963 for( final PhylogenyNode node : nodes ) {
964 main_panel.getCurrentTreePanel().getFoundNodes().add( node.getId() );
966 setSearchFoundCountsOnLabel( nodes.size() );
969 setSearchFoundCountsOnLabel( 0 );
974 private void searchReset() {
975 if ( getMainPanel().getCurrentTreePanel() != null ) {
976 getMainPanel().getCurrentTreePanel().setFoundNodes( null );
980 void setActionWhenNodeClicked( final NodeClickAction action ) {
981 _action_when_node_clicked = action;
984 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
985 _annotation_colors = annotation_colors;
988 void setCheckbox( final int which, final boolean state ) {
990 case Configuration.display_as_phylogram:
991 if ( getDisplayAsPhylogramCb() != null ) {
992 getDisplayAsPhylogramCb().setSelected( state );
995 case Configuration.display_internal_data:
996 if ( _display_internal_data != null ) {
997 _display_internal_data.setSelected( state );
1000 case Configuration.color_according_to_species:
1001 if ( _color_acc_species != null ) {
1002 _color_acc_species.setSelected( state );
1005 case Configuration.color_according_to_annotation:
1006 if ( _color_according_to_annotation != null ) {
1007 _color_according_to_annotation.setSelected( state );
1010 case Configuration.show_node_names:
1011 if ( _show_node_names != null ) {
1012 _show_node_names.setSelected( state );
1015 case Configuration.show_taxonomy_scientific_names:
1016 if ( _show_taxo_scientific_names != null ) {
1017 _show_taxo_scientific_names.setSelected( state );
1020 case Configuration.show_taxonomy_common_names:
1021 if ( _show_taxo_common_names != null ) {
1022 _show_taxo_common_names.setSelected( state );
1025 case Configuration.show_tax_code:
1026 if ( _show_taxo_code != null ) {
1027 _show_taxo_code.setSelected( state );
1030 case Configuration.show_taxonomy_images:
1031 if ( _show_taxo_images_cb != null ) {
1032 _show_taxo_images_cb.setSelected( state );
1035 case Configuration.show_annotation:
1036 if ( _show_annotation != null ) {
1037 _show_annotation.setSelected( state );
1040 case Configuration.show_binary_characters:
1041 if ( _show_binary_characters != null ) {
1042 _show_binary_characters.setSelected( state );
1045 case Configuration.show_binary_character_counts:
1046 if ( _show_binary_character_counts != null ) {
1047 _show_binary_character_counts.setSelected( state );
1050 case Configuration.write_confidence_values:
1051 if ( getWriteConfidenceCb() != null ) {
1052 getWriteConfidenceCb().setSelected( state );
1055 case Configuration.write_events:
1056 if ( getShowEventsCb() != null ) {
1057 getShowEventsCb().setSelected( state );
1060 case Configuration.color_branches:
1061 if ( getColorBranchesCb() != null ) {
1062 getColorBranchesCb().setSelected( state );
1065 case Configuration.width_branches:
1066 if ( _width_branches != null ) {
1067 _width_branches.setSelected( state );
1070 case Configuration.show_domain_architectures:
1071 if ( _show_domain_architectures != null ) {
1072 _show_domain_architectures.setSelected( state );
1075 case Configuration.show_gene_names:
1076 if ( _show_gene_names != null ) {
1077 _show_gene_names.setSelected( state );
1080 case Configuration.show_gene_symbols:
1081 if ( _show_gene_symbols != null ) {
1082 _show_gene_symbols.setSelected( state );
1085 case Configuration.show_vector_data:
1086 if ( _show_vector_data_cb != null ) {
1087 _show_vector_data_cb.setSelected( state );
1090 case Configuration.show_properties:
1091 if ( _show_properties_cb != null ) {
1092 _show_properties_cb.setSelected( state );
1095 case Configuration.show_sequence_acc:
1096 if ( _show_sequence_acc != null ) {
1097 _show_sequence_acc.setSelected( state );
1100 case Configuration.dynamically_hide_data:
1101 if ( getDynamicallyHideData() != null ) {
1102 getDynamicallyHideData().setSelected( state );
1105 case Configuration.node_data_popup:
1106 if ( getNodeDescPopupCb() != null ) {
1107 getNodeDescPopupCb().setSelected( state );
1111 case Configuration.show_relation_confidence:
1112 if ( _seq_relation_confidence_switch != null ) {
1113 _seq_relation_confidence_switch.setSelected( state );
1118 throw new AssertionError( "unknown checkbox: " + which );
1123 * Set this checkbox state. Not all checkboxes have been instantiated
1124 * depending on the config.
1126 void setCheckbox( final JCheckBox cb, final boolean state ) {
1128 cb.setSelected( state );
1132 void setClickToAction( final int action ) {
1133 // Set click-to action
1134 if ( action == _show_data_item ) {
1135 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1137 else if ( action == _collapse_cb_item ) {
1138 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1140 else if ( action == _reroot_cb_item ) {
1141 setActionWhenNodeClicked( NodeClickAction.REROOT );
1143 else if ( action == _subtree_cb_item ) {
1144 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1146 else if ( action == _swap_cb_item ) {
1147 setActionWhenNodeClicked( NodeClickAction.SWAP );
1149 else if ( action == _color_subtree_cb_item ) {
1150 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1152 else if ( action == _open_seq_web_item ) {
1153 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1155 else if ( action == _sort_descendents_item ) {
1156 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1158 else if ( action == _blast_item ) {
1159 if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
1160 setActionWhenNodeClicked( NodeClickAction.BLAST );
1163 else if ( action == _open_tax_web_item ) {
1164 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1166 else if ( action == _cut_subtree_item ) {
1167 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1169 else if ( action == _copy_subtree_item ) {
1170 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1172 else if ( action == _delete_node_or_subtree_item ) {
1173 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1175 else if ( action == _paste_subtree_item ) {
1176 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1178 else if ( action == _add_new_node_item ) {
1179 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1181 else if ( action == _edit_node_data_item ) {
1182 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1185 throw new RuntimeException( "unknown action: " + action );
1187 // make sure drop down is displaying the correct action
1188 // in case this was called from outside the class
1189 _click_to_combobox.setSelectedIndex( action );
1192 void setColorBranches( final boolean color_branches ) {
1193 _color_branches = color_branches;
1196 void setDrawPhylogram( final boolean b ) {
1197 getDisplayAsPhylogramCb().setSelected( b );
1198 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1201 private void setDrawPhylogram( final int index, final boolean b ) {
1202 getIsDrawPhylogramList().set( index, b );
1205 void setDrawPhylogramEnabled( final boolean b ) {
1206 getDisplayAsPhylogramCb().setEnabled( b );
1209 void setDynamicHidingIsOn( final boolean is_on ) {
1210 // if ( !_configuration.isUseNativeUI() ) {
1212 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1215 if ( !_configuration.isUseNativeUI() ) {
1216 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1219 getDynamicallyHideData().setForeground( Color.BLACK );
1225 private void setSearchFoundCountsOnLabel( final int counts ) {
1226 getSearchFoundCountsLabel().setText( "Found: " + counts );
1229 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
1230 final JComboBox box = getSequenceRelationBox();
1231 while ( box.getItemCount() > 1 ) {
1232 box.removeItemAt( 1 );
1234 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
1235 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
1237 if ( relationType == null ) {
1240 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
1241 for( final Sequence seq : sequenceRelationQueries ) {
1242 if ( seq.hasSequenceRelations() ) {
1243 boolean fFoundForCurrentType = false;
1244 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
1245 if ( sq.getType().equals( relationType ) ) {
1246 fFoundForCurrentType = true;
1250 if ( fFoundForCurrentType ) {
1251 sequenceNamesToAdd.add( seq.getName() );
1252 sequencesByName.put( seq.getName(), seq );
1256 // sort sequences by name before adding them to the combo
1257 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
1258 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
1259 for( final String seqName : sequenceNameArray ) {
1260 box.addItem( seqName );
1262 for( final ItemListener oldItemListener : box.getItemListeners() ) {
1263 box.removeItemListener( oldItemListener );
1265 box.addItemListener( new ItemListener() {
1268 public void itemStateChanged( final ItemEvent e ) {
1269 _selected_query_seq = sequencesByName.get( e.getItem() );
1270 _mainpanel.getCurrentTreePanel().repaint();
1275 void setShowEvents( final boolean show_events ) {
1276 if ( getShowEventsCb() == null ) {
1277 _show_events = new JCheckBox( "" );
1279 getShowEventsCb().setSelected( show_events );
1282 void setSpeciesColors( final Map<String, Color> species_colors ) {
1283 _species_colors = species_colors;
1286 private void setupClickToOptions() {
1287 final int default_option = _configuration.getDefaultDisplayClicktoOption();
1288 int selected_index = 0;
1290 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1291 _show_data_item = cb_index;
1292 addClickToOption( Configuration.display_node_data,
1293 _configuration.getClickToTitle( Configuration.display_node_data ) );
1294 if ( default_option == Configuration.display_node_data ) {
1295 selected_index = cb_index;
1299 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1300 _collapse_cb_item = cb_index;
1301 addClickToOption( Configuration.collapse_uncollapse,
1302 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
1303 if ( default_option == Configuration.collapse_uncollapse ) {
1304 selected_index = cb_index;
1308 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1309 _reroot_cb_item = cb_index;
1310 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1311 if ( default_option == Configuration.reroot ) {
1312 selected_index = cb_index;
1316 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1317 _subtree_cb_item = cb_index;
1318 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1319 if ( default_option == Configuration.subtree ) {
1320 selected_index = cb_index;
1324 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1325 _swap_cb_item = cb_index;
1326 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1327 if ( default_option == Configuration.swap ) {
1328 selected_index = cb_index;
1332 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
1333 _sort_descendents_item = cb_index;
1334 addClickToOption( Configuration.sort_descendents,
1335 _configuration.getClickToTitle( Configuration.sort_descendents ) );
1336 if ( default_option == Configuration.sort_descendents ) {
1337 selected_index = cb_index;
1341 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1342 _color_subtree_cb_item = cb_index;
1343 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1344 if ( default_option == Configuration.color_subtree ) {
1345 selected_index = cb_index;
1349 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1350 _open_seq_web_item = cb_index;
1351 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1352 if ( default_option == Configuration.open_seq_web ) {
1353 selected_index = cb_index;
1357 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1358 _open_tax_web_item = cb_index;
1359 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1360 if ( default_option == Configuration.open_tax_web ) {
1361 selected_index = cb_index;
1365 if ( getOptions().isEditable() ) {
1366 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
1367 _cut_subtree_item = cb_index;
1368 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
1369 if ( default_option == Configuration.cut_subtree ) {
1370 selected_index = cb_index;
1374 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
1375 _copy_subtree_item = cb_index;
1376 addClickToOption( Configuration.copy_subtree,
1377 _configuration.getClickToTitle( Configuration.copy_subtree ) );
1378 if ( default_option == Configuration.copy_subtree ) {
1379 selected_index = cb_index;
1383 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
1384 _paste_subtree_item = cb_index;
1385 addClickToOption( Configuration.paste_subtree,
1386 _configuration.getClickToTitle( Configuration.paste_subtree ) );
1387 if ( default_option == Configuration.paste_subtree ) {
1388 selected_index = cb_index;
1392 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
1393 _delete_node_or_subtree_item = cb_index;
1394 addClickToOption( Configuration.delete_subtree_or_node,
1395 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
1396 if ( default_option == Configuration.delete_subtree_or_node ) {
1397 selected_index = cb_index;
1401 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
1402 _add_new_node_item = cb_index;
1403 addClickToOption( Configuration.add_new_node,
1404 _configuration.getClickToTitle( Configuration.add_new_node ) );
1405 if ( default_option == Configuration.add_new_node ) {
1406 selected_index = cb_index;
1410 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
1411 _edit_node_data_item = cb_index;
1412 addClickToOption( Configuration.edit_node_data,
1413 _configuration.getClickToTitle( Configuration.edit_node_data ) );
1414 if ( default_option == Configuration.edit_node_data ) {
1415 selected_index = cb_index;
1419 if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
1420 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1421 _blast_item = cb_index;
1422 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
1423 if ( default_option == Configuration.blast ) {
1424 selected_index = cb_index;
1430 // Set default selection and its action
1431 _click_to_combobox.setSelectedIndex( selected_index );
1432 setClickToAction( selected_index );
1437 * Set up the controls from the config settings. 11/26/05
1439 void setupControls() {
1440 // The tree display options:
1441 setupDisplayCheckboxes();
1443 // The sequence relation query selection combo-box
1444 if ( _configuration.displaySequenceRelations() ) {
1445 addSequenceRelationBlock();
1449 startClickToOptions();
1450 setupClickToOptions();
1451 endClickToOptions();
1452 // Zoom and quick edit buttons
1457 void setUpControlsForDomainStrucures() {
1458 _domain_display_label = new JLabel( "Domain Display:" );
1459 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1460 add( _domain_display_label );
1461 _zoom_in_domain_structure = new JButton( "d+" );
1462 _zoom_out_domain_structure = new JButton( "d-" );
1463 _decr_domain_structure_evalue_thr = new JButton( "-" );
1464 _incr_domain_structure_evalue_thr = new JButton( "+" );
1465 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1466 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1467 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1468 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1469 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1470 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1471 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1472 _domain_structure_evalue_thr_tf.setEditable( false );
1473 if ( !getConfiguration().isUseNativeUI() ) {
1474 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1475 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1476 _domain_structure_evalue_thr_tf.setBorder( null );
1478 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1479 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1480 if ( !_configuration.isUseNativeUI() ) {
1481 d1_panel.setBackground( getBackground() );
1482 d2_panel.setBackground( getBackground() );
1486 addJButton( _zoom_out_domain_structure, d1_panel );
1487 addJButton( _zoom_in_domain_structure, d1_panel );
1488 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1489 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1490 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1493 private void setupDisplayCheckboxes() {
1494 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
1495 addCheckbox( Configuration.display_as_phylogram,
1496 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
1497 setCheckbox( Configuration.display_as_phylogram,
1498 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
1500 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1501 addCheckbox( Configuration.dynamically_hide_data,
1502 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
1503 setCheckbox( Configuration.dynamically_hide_data,
1504 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
1506 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1507 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1508 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1510 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1511 addCheckbox( Configuration.display_internal_data,
1512 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
1513 setCheckbox( Configuration.display_internal_data,
1514 _configuration.doCheckOption( Configuration.display_internal_data ) );
1516 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1517 addCheckbox( Configuration.color_according_to_species,
1518 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
1519 setCheckbox( Configuration.color_according_to_species,
1520 _configuration.doCheckOption( Configuration.color_according_to_species ) );
1522 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1523 addCheckbox( Configuration.color_according_to_annotation,
1524 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
1525 setCheckbox( Configuration.color_according_to_annotation,
1526 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
1528 if ( _configuration.doDisplayOption( Configuration.color_branches ) ) {
1529 addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) );
1530 setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) );
1532 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1533 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1534 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1536 final JLabel label = new JLabel( "Display Data:" );
1537 label.setFont( ControlPanel.jcb_bold_font );
1538 if ( !getConfiguration().isUseNativeUI() ) {
1539 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1542 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1543 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
1544 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1546 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1547 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1548 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1550 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1551 addCheckbox( Configuration.show_taxonomy_scientific_names,
1552 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1553 setCheckbox( Configuration.show_taxonomy_scientific_names,
1554 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1556 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1557 addCheckbox( Configuration.show_taxonomy_common_names,
1558 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1559 setCheckbox( Configuration.show_taxonomy_common_names,
1560 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1562 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1563 addCheckbox( Configuration.show_taxonomy_images,
1564 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1565 setCheckbox( Configuration.show_taxonomy_images,
1566 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1568 if ( _configuration.doDisplayOption( Configuration.show_gene_symbols ) ) {
1569 addCheckbox( Configuration.show_gene_symbols,
1570 _configuration.getDisplayTitle( Configuration.show_gene_symbols ) );
1571 setCheckbox( Configuration.show_gene_symbols,
1572 _configuration.doCheckOption( Configuration.show_gene_symbols ) );
1574 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1575 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1576 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1578 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1579 addCheckbox( Configuration.show_sequence_acc,
1580 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1581 setCheckbox( Configuration.show_sequence_acc,
1582 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1584 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1585 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
1586 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1588 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1589 addCheckbox( Configuration.show_binary_characters,
1590 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1591 setCheckbox( Configuration.show_binary_characters,
1592 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1594 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1595 addCheckbox( Configuration.show_binary_character_counts,
1596 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1597 setCheckbox( Configuration.show_binary_character_counts,
1598 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1600 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1601 addCheckbox( Configuration.show_domain_architectures,
1602 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1603 setCheckbox( Configuration.show_domain_architectures,
1604 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1606 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1607 addCheckbox( Configuration.write_confidence_values,
1608 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1609 setCheckbox( Configuration.write_confidence_values,
1610 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1612 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1613 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1614 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1616 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1617 addCheckbox( Configuration.show_vector_data,
1618 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1619 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
1621 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1622 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
1623 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1627 void setupSearchTools() {
1628 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1629 final JLabel search_label = new JLabel( "Search:" );
1630 search_label.setFont( ControlPanel.jcb_bold_font );
1631 if ( !getConfiguration().isUseNativeUI() ) {
1632 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1634 add( search_label );
1635 search_label.setToolTipText( tip );
1636 _search_found_label = new JLabel();
1637 getSearchFoundCountsLabel().setVisible( false );
1638 _search_found_label.setFont( ControlPanel.jcb_bold_font );
1639 if ( !getConfiguration().isUseNativeUI() ) {
1640 _search_found_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1642 _search_tf = new JTextField( 3 );
1643 _search_tf.setToolTipText( tip );
1644 _search_tf.setEditable( true );
1645 if ( !getConfiguration().isUseNativeUI() ) {
1646 _search_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1647 _search_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1648 _search_tf.setBorder( null );
1650 _search_reset_button = new JButton();
1651 getSearchResetButton().setText( "Reset" );
1652 getSearchResetButton().setEnabled( false );
1653 getSearchResetButton().setVisible( false );
1654 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1655 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1656 s_panel_1.setBackground( getBackground() );
1658 s_panel_2.setBackground( getBackground() );
1660 final KeyAdapter key_adapter = new KeyAdapter() {
1663 public void keyReleased( final KeyEvent key_event ) {
1665 displayedPhylogenyMightHaveChanged( true );
1668 final ActionListener action_listener = new ActionListener() {
1671 public void actionPerformed( final ActionEvent e ) {
1673 setSearchFoundCountsOnLabel( 0 );
1674 getSearchFoundCountsLabel().setVisible( false );
1675 getSearchTextField().setText( "" );
1676 getSearchResetButton().setEnabled( false );
1677 getSearchResetButton().setVisible( false );
1678 displayedPhylogenyMightHaveChanged( true );
1681 _search_reset_button.addActionListener( action_listener );
1682 _search_tf.addKeyListener( key_adapter );
1683 addJTextField( _search_tf, s_panel_1 );
1684 s_panel_2.add( _search_found_label );
1685 addJButton( _search_reset_button, s_panel_2 );
1688 private void setVisibilityOfDomainStrucureControls() {
1689 if ( _zoom_in_domain_structure != null ) {
1690 if ( isShowDomainArchitectures() ) {
1691 _domain_display_label.setVisible( true );
1692 _zoom_in_domain_structure.setVisible( true );
1693 _zoom_out_domain_structure.setVisible( true );
1694 _decr_domain_structure_evalue_thr.setVisible( true );
1695 _incr_domain_structure_evalue_thr.setVisible( true );
1696 _domain_structure_evalue_thr_tf.setVisible( true );
1699 _domain_display_label.setVisible( false );
1700 _zoom_in_domain_structure.setVisible( false );
1701 _zoom_out_domain_structure.setVisible( false );
1702 _decr_domain_structure_evalue_thr.setVisible( false );
1703 _incr_domain_structure_evalue_thr.setVisible( false );
1704 _domain_structure_evalue_thr_tf.setVisible( false );
1710 * Fit entire tree into window.
1713 if ( _mainpanel.getCurrentScrollPane() == null ) {
1716 displayedPhylogenyMightHaveChanged( false );
1717 _mainpanel.getCurrentTreePanel().updateOvSettings();
1718 _mainpanel.getCurrentTreePanel().validate();
1719 _mainpanel.validate();
1720 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1721 _mainpanel.getSizeOfViewport().height,
1723 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1724 _mainpanel.adjustJScrollPane();
1725 _mainpanel.getCurrentTreePanel().repaint();
1726 _mainpanel.getCurrentTreePanel().validate();
1727 _mainpanel.validate();
1728 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1729 _mainpanel.getSizeOfViewport().height,
1731 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1732 _mainpanel.adjustJScrollPane();
1733 _mainpanel.getCurrentTreePanel().repaint();
1734 _mainpanel.getCurrentTreePanel().updateOvSizes();
1737 void showWholeAll() {
1738 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1739 if ( tree_panel != null ) {
1740 tree_panel.validate();
1741 tree_panel.setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1742 _mainpanel.getSizeOfViewport().height,
1744 tree_panel.resetPreferredSize();
1745 tree_panel.repaint();
1750 // Create header for click-to combo box.
1751 void startClickToOptions() {
1752 final JLabel spacer = new JLabel( "" );
1753 spacer.setFont( ControlPanel.jcb_font );
1755 _click_to_label = new JLabel( "Click on Node to:" );
1756 add( customizeLabel( _click_to_label, getConfiguration() ) );
1757 _click_to_combobox = new JComboBox();
1758 _click_to_combobox.setFocusable( false );
1759 _click_to_combobox.setMaximumRowCount( 14 );
1760 _click_to_combobox.setFont( ControlPanel.js_font );
1761 if ( !_configuration.isUseNativeUI() ) {
1762 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1764 // don't add listener until all items are set (or each one will trigger
1766 // click_to_list.addActionListener(this);
1767 add( _click_to_combobox );
1768 // Correlates option names to titles
1769 _all_click_to_names = new HashMap<Integer, String>();
1770 _click_to_names = new ArrayList<String>();
1774 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1775 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1776 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1777 setDrawPhylogramEnabled( true );
1778 setDrawPhylogram( isDrawPhylogram() );
1781 setDrawPhylogramEnabled( false );
1782 setDrawPhylogram( false );
1784 if ( getMainPanel().getMainFrame() == null ) {
1785 // Must be "E" applet version.
1786 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1787 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1790 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1791 .getPhylogenyGraphicsType() );
1793 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1794 getMainPanel().getControlPanel().search();
1795 getSequenceRelationTypeBox().removeAllItems();
1796 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1797 .getRelevantSequenceRelationTypes() ) {
1798 _sequence_relation_type_box.addItem( type );
1800 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1801 // according to GUILHEM the line above can be removed.
1806 * Uncollapse all nodes.
1808 void uncollapseAll( final TreePanel tp ) {
1809 final Phylogeny t = tp.getPhylogeny();
1810 if ( ( t != null ) && !t.isEmpty() ) {
1811 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
1812 final PhylogenyNode node = iter.next();
1813 node.setCollapse( false );
1815 tp.resetNodeIdToDistToLeafMap();
1816 tp.updateSetOfCollapsedExternalNodes( t );
1817 t.recalculateNumberOfExternalDescendants( false );
1818 tp.setNodeInPreorderToNull();
1824 void updateDomainStructureEvaluethresholdDisplay() {
1825 if ( _domain_structure_evalue_thr_tf != null ) {
1826 _domain_structure_evalue_thr_tf.setText( "10^"
1827 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1831 void zoomInX( final float factor, final float x_correction_factor ) {
1832 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1833 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1834 treepanel.multiplyUrtFactor( 1f );
1835 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1836 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1837 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1838 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1839 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
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( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1846 - ( sb.getVisibleAmount() / 2.0 ) ) );
1849 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1850 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1851 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1852 getMainPanel().adjustJScrollPane();
1853 treepanel.resetPreferredSize();
1854 getMainPanel().getCurrentScrollPane().getViewport().validate();
1855 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1857 treepanel.resetPreferredSize();
1858 treepanel.updateOvSizes();
1861 void zoomInY( final float factor ) {
1862 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1863 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1864 treepanel.multiplyUrtFactor( 1.1f );
1865 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1866 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1867 getMainPanel().adjustJScrollPane();
1868 treepanel.resetPreferredSize();
1869 getMainPanel().getCurrentScrollPane().getViewport().validate();
1870 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1871 - ( sb.getVisibleAmount() / 2.0 ) ) );
1872 treepanel.resetPreferredSize();
1873 treepanel.updateOvSizes();
1876 void zoomOutX( final float factor, final float x_correction_factor ) {
1877 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1878 treepanel.multiplyUrtFactor( 1f );
1879 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1880 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1881 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1882 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1883 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1884 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1885 getMainPanel().adjustJScrollPane();
1886 treepanel.resetPreferredSize();
1887 getMainPanel().getCurrentScrollPane().getViewport().validate();
1888 final double x = ( sb.getMaximum() - sb.getMinimum() )
1889 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1890 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1891 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1892 getMainPanel().adjustJScrollPane();
1893 treepanel.resetPreferredSize();
1894 getMainPanel().getCurrentScrollPane().getViewport().validate();
1895 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1896 - ( sb.getVisibleAmount() / 2.0 ) ) );
1899 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1900 treepanel.setXdistance( treepanel.getXdistance() * factor );
1901 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
1903 getMainPanel().adjustJScrollPane();
1904 treepanel.resetPreferredSize();
1905 getMainPanel().getCurrentScrollPane().getViewport().validate();
1906 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1909 treepanel.resetPreferredSize();
1910 treepanel.updateOvSizes();
1914 void zoomOutY( final float factor ) {
1915 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1916 treepanel.multiplyUrtFactor( 0.9f );
1917 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1918 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1919 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1920 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1921 getMainPanel().adjustJScrollPane();
1922 treepanel.resetPreferredSize();
1923 getMainPanel().getCurrentScrollPane().getViewport().validate();
1924 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1925 - ( sb.getVisibleAmount() / 2.0 ) ) );
1926 treepanel.resetPreferredSize();
1927 treepanel.updateOvSizes();
1931 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
1932 label.setFont( ControlPanel.jcb_bold_font );
1933 if ( !configuration.isUseNativeUI() ) {
1934 label.setForeground( configuration.getGuiCheckboxTextColor() );
1935 label.setBackground( configuration.getGuiBackgroundColor() );
1940 enum NodeClickAction {
1951 DELETE_NODE_OR_SUBTREE,