2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 // Contact: phylosoft @ gmail . com
23 // WWW: www.phylosoft.org/forester
25 package org.forester.archaeopteryx;
27 import java.awt.BorderLayout;
28 import java.awt.Color;
29 import java.awt.Component;
30 import java.awt.Dimension;
32 import java.awt.GridBagLayout;
33 import java.awt.GridLayout;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.ActionListener;
36 import java.awt.event.ItemEvent;
37 import java.awt.event.ItemListener;
38 import java.awt.event.KeyAdapter;
39 import java.awt.event.KeyEvent;
40 import java.util.ArrayList;
41 import java.util.Arrays;
42 import java.util.Collection;
43 import java.util.HashMap;
44 import java.util.HashSet;
45 import java.util.List;
48 import javax.swing.BorderFactory;
49 import javax.swing.DefaultListCellRenderer;
50 import javax.swing.JButton;
51 import javax.swing.JCheckBox;
52 import javax.swing.JComboBox;
53 import javax.swing.JLabel;
54 import javax.swing.JList;
55 import javax.swing.JPanel;
56 import javax.swing.JScrollBar;
57 import javax.swing.JTextField;
58 import javax.swing.ListCellRenderer;
60 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
61 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
62 import org.forester.phylogeny.Phylogeny;
63 import org.forester.phylogeny.PhylogenyMethods;
64 import org.forester.phylogeny.PhylogenyNode;
65 import org.forester.phylogeny.data.Sequence;
66 import org.forester.phylogeny.data.SequenceRelation;
67 import org.forester.util.ForesterUtil;
69 final class ControlPanel extends JPanel implements ActionListener {
71 private static final String RETURN_TO_SUPER_TREE_TEXT = "Back to Super Tree";
72 final static Font jcb_font = new Font( Configuration.getDefaultFontFamilyName(),
75 final static Font js_font = new Font( Configuration.getDefaultFontFamilyName(),
78 final static Font jcb_bold_font = new Font( Configuration.getDefaultFontFamilyName(),
81 private static final long serialVersionUID = -8463483932821545633L;
82 private final MainPanel _mainpanel;
83 // The settings from the conf file
84 private final Configuration _configuration;
86 private JCheckBox _display_internal_data;
87 private JCheckBox _show_node_names;
88 private JCheckBox _show_taxo_code;
89 private JCheckBox _write_confidence;
90 private JCheckBox _show_events;
91 private JCheckBox _color_acc_species;
92 private JCheckBox _color_branches_cb;
93 private JCheckBox _width_branches;
94 private JCheckBox _show_domain_architectures;
95 private JCheckBox _show_annotation;
96 private JCheckBox _show_binary_characters;
97 private JCheckBox _show_binary_character_counts;
98 private JCheckBox _show_gene_names;
99 private JCheckBox _show_gene_symbols;
100 private JCheckBox _show_sequence_acc;
101 private JCheckBox _node_desc_popup_cb;
102 private JCheckBox _dynamically_hide_data;
103 private JCheckBox _show_taxo_scientific_names;
104 private JCheckBox _show_taxo_common_names;
105 private JCheckBox _show_taxo_images_cb;
106 private JCheckBox _color_according_to_annotation;
107 private JCheckBox _display_as_phylogram_cb;
108 private JCheckBox _seq_relation_confidence_switch;
109 private JComboBox _show_sequence_relations;
110 private JComboBox _sequence_relation_type_box;
111 private JCheckBox _show_vector_data_cb;
112 private JCheckBox _show_properties_cb;
113 private JLabel _click_to_label;
114 private JLabel _zoom_label;
115 private JLabel _domain_display_label;
116 private JComboBox _click_to_combobox;
117 private Map<Integer, String> _all_click_to_names;
118 private List<String> _click_to_names;
119 // Indices for the click-to options in the combo box
120 private int _show_data_item;
121 private int _collapse_cb_item;
122 private int _reroot_cb_item;
123 private int _swap_cb_item;
124 private int _subtree_cb_item;
125 private int _color_subtree_cb_item;
126 private int _open_seq_web_item;
127 private int _open_tax_web_item;
128 private int _cut_subtree_item;
129 private int _copy_subtree_item;
130 private int _delete_node_or_subtree_item;
131 private int _paste_subtree_item;
132 private int _add_new_node_item;
133 private int _edit_node_data_item;
134 private int _blast_item;
135 // zooming and quick tree manipulation buttons:
136 private JButton _zoom_in_x;
137 private JButton _zoom_in_y;
138 private JButton _zoom_out_x;
139 private JButton _zoom_out_y;
140 private JButton _show_whole;
141 private JButton _order;
142 private JButton _uncollapse_all;
143 private JButton _zoom_in_domain_structure;
144 private JButton _zoom_out_domain_structure;
145 private JButton _decr_domain_structure_evalue_thr;
146 private JButton _incr_domain_structure_evalue_thr;
147 private JButton _return_to_super_tree;
148 private JTextField _domain_structure_evalue_thr_tf;
149 private JTextField _search_tf;
150 private boolean _order_of_appearance;
151 private boolean _color_branches;
152 private NodeClickAction _action_when_node_clicked;
153 private List<Boolean> _draw_phylogram;
154 private Map<String, Color> _annotation_colors;
155 private Map<String, Color> _species_colors;
156 private JButton _search_reset_button;
157 private JLabel _search_found_label;
158 private Sequence _selected_query_seq;
160 ControlPanel( final MainPanel ap, final Configuration configuration ) {
163 _configuration = configuration;
164 if ( !_configuration.isUseNativeUI() ) {
165 setBackground( getConfiguration().getGuiBackgroundColor() );
166 setBorder( BorderFactory.createRaisedBevelBorder() );
168 setLayout( new GridLayout( 0, 1, 2, 2 ) );
169 _order_of_appearance = true;
177 public void actionPerformed( final ActionEvent e ) {
179 final TreePanel tp = getMainPanel().getCurrentTreePanel();
183 if ( e.getSource() == _click_to_combobox ) {
184 setClickToAction( _click_to_combobox.getSelectedIndex() );
185 getCurrentTreePanel().repaint();
187 else if ( e.getSource() == _show_binary_characters ) {
188 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
189 _show_binary_character_counts.setSelected( false );
191 displayedPhylogenyMightHaveChanged( true );
193 else if ( e.getSource() == _show_binary_character_counts ) {
194 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
195 _show_binary_characters.setSelected( false );
197 displayedPhylogenyMightHaveChanged( true );
199 else if ( e.getSource() == _color_according_to_annotation ) {
200 if ( ( _show_annotation != null ) && _color_according_to_annotation.isSelected() ) {
201 _show_annotation.setSelected( true );
203 displayedPhylogenyMightHaveChanged( false );
205 else if ( e.getSource() == _show_annotation ) {
206 if ( ( _color_according_to_annotation != null ) && !_show_annotation.isSelected() ) {
207 _color_according_to_annotation.setSelected( false );
209 displayedPhylogenyMightHaveChanged( false );
211 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
212 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
213 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
217 else if ( e.getSource() == _zoom_in_x ) {
218 zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
219 displayedPhylogenyMightHaveChanged( false );
221 else if ( e.getSource() == _zoom_in_y ) {
222 zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR );
223 displayedPhylogenyMightHaveChanged( false );
225 else if ( e.getSource() == _zoom_out_x ) {
226 zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
227 displayedPhylogenyMightHaveChanged( false );
229 else if ( e.getSource() == _zoom_out_y ) {
230 zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR );
231 displayedPhylogenyMightHaveChanged( false );
233 else if ( e.getSource() == _show_whole ) {
236 else if ( e.getSource() == _return_to_super_tree ) {
237 _mainpanel.getCurrentTreePanel().superTree();
240 else if ( e.getSource() == _order ) {
241 tp.getPhylogeny().orderAppearance( _order_of_appearance );
242 _order_of_appearance = !_order_of_appearance;
243 displayedPhylogenyMightHaveChanged( false );
245 else if ( e.getSource() == _uncollapse_all ) {
247 displayedPhylogenyMightHaveChanged( false );
249 else if ( e.getSource() == _zoom_in_domain_structure ) {
250 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
251 displayedPhylogenyMightHaveChanged( true );
253 else if ( e.getSource() == _zoom_out_domain_structure ) {
254 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
255 displayedPhylogenyMightHaveChanged( true );
257 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
258 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThreshold();
259 displayedPhylogenyMightHaveChanged( true );
261 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
262 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThreshold();
263 displayedPhylogenyMightHaveChanged( true );
265 else if ( e.getSource() == _search_tf ) {
267 displayedPhylogenyMightHaveChanged( true );
270 displayedPhylogenyMightHaveChanged( true );
274 tp.requestFocusInWindow();
277 catch ( final Exception ex ) {
278 Util.unexpectedException( ex );
280 catch ( final Error err ) {
281 Util.unexpectedError( err );
285 void activateButtonToReturnToSuperTree( int index ) {
288 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
291 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
293 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
294 _return_to_super_tree.setEnabled( true );
298 * Add zoom and quick edit buttons. (Last modified 8/9/04)
301 final JLabel spacer = new JLabel( "" );
302 spacer.setOpaque( false );
304 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
305 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
306 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
307 if ( !getConfiguration().isUseNativeUI() ) {
308 x_panel.setBackground( getBackground() );
309 y_panel.setBackground( getBackground() );
310 z_panel.setBackground( getBackground() );
312 add( _zoom_label = new JLabel( "Zoom:" ) );
313 customizeLabel( _zoom_label, getConfiguration() );
317 if ( getConfiguration().isUseNativeUI() ) {
318 _zoom_in_x = new JButton( "+" );
319 _zoom_out_x = new JButton( "-" );
322 _zoom_in_x = new JButton( "X+" );
323 _zoom_out_x = new JButton( "X-" );
325 _zoom_in_y = new JButton( "Y+" );
326 _zoom_out_y = new JButton( "Y-" );
327 _show_whole = new JButton( "F" );
328 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [Backspace]" );
329 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+Right]" );
330 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+Up]" );
331 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+Left]" );
332 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+Down]" );
333 if ( getConfiguration().isUseNativeUI() && Util.isMac() ) {
334 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
335 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
338 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
339 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
341 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
342 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
343 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
344 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
345 _return_to_super_tree.setEnabled( false );
346 _order = new JButton( "Order Subtrees" );
347 _uncollapse_all = new JButton( "Uncollapse All" );
348 addJButton( _zoom_in_y, x_panel );
349 addJButton( _zoom_out_x, y_panel );
350 addJButton( _show_whole, y_panel );
351 addJButton( _zoom_in_x, y_panel );
352 addJButton( _zoom_out_y, z_panel );
353 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
354 setUpControlsForDomainStrucures();
356 final JLabel spacer2 = new JLabel( "" );
358 addJButton( _return_to_super_tree, this );
359 addJButton( _order, this );
360 addJButton( _uncollapse_all, this );
361 final JLabel spacer3 = new JLabel( "" );
363 setVisibilityOfDomainStrucureControls();
366 void addCheckbox( final int which, final String title ) {
367 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
369 case Configuration.display_as_phylogram:
370 _display_as_phylogram_cb = new JCheckBox( title );
371 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
372 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
375 case Configuration.display_internal_data:
376 _display_internal_data = new JCheckBox( title );
377 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
378 addJCheckBox( _display_internal_data, ch_panel );
381 case Configuration.color_according_to_species:
382 _color_acc_species = new JCheckBox( title );
384 .setToolTipText( "To colorize taxonomy and sequence labels as a function of taxonomy" );
385 addJCheckBox( _color_acc_species, ch_panel );
388 case Configuration.color_according_to_annotation:
389 _color_according_to_annotation = new JCheckBox( title );
390 _color_according_to_annotation
391 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
392 addJCheckBox( _color_according_to_annotation, ch_panel );
395 case Configuration.show_node_names:
396 _show_node_names = new JCheckBox( title );
397 addJCheckBox( _show_node_names, ch_panel );
400 case Configuration.show_tax_code:
401 _show_taxo_code = new JCheckBox( title );
402 addJCheckBox( _show_taxo_code, ch_panel );
405 case Configuration.show_taxonomy_scientific_names:
406 _show_taxo_scientific_names = new JCheckBox( title );
407 addJCheckBox( _show_taxo_scientific_names, ch_panel );
410 case Configuration.show_taxonomy_common_names:
411 _show_taxo_common_names = new JCheckBox( title );
412 addJCheckBox( _show_taxo_common_names, ch_panel );
415 case Configuration.show_taxonomy_images:
416 _show_taxo_images_cb = new JCheckBox( title );
417 addJCheckBox( _show_taxo_images_cb, ch_panel );
420 case Configuration.show_binary_characters:
421 _show_binary_characters = new JCheckBox( title );
422 addJCheckBox( _show_binary_characters, ch_panel );
425 case Configuration.show_annotation:
426 _show_annotation = new JCheckBox( title );
427 addJCheckBox( _show_annotation, ch_panel );
430 case Configuration.show_binary_character_counts:
431 _show_binary_character_counts = new JCheckBox( title );
432 addJCheckBox( _show_binary_character_counts, ch_panel );
435 case Configuration.write_confidence_values:
436 _write_confidence = new JCheckBox( title );
437 addJCheckBox( getWriteConfidenceCb(), ch_panel );
440 case Configuration.write_events:
441 _show_events = new JCheckBox( title );
442 addJCheckBox( getShowEventsCb(), ch_panel );
445 case Configuration.color_branches:
446 _color_branches_cb = new JCheckBox( title );
447 getColorBranchesCb().setToolTipText( "To use branch color values, if present" );
448 addJCheckBox( getColorBranchesCb(), ch_panel );
451 case Configuration.width_branches:
452 _width_branches = new JCheckBox( title );
453 _width_branches.setToolTipText( "To use branch width values, if present" );
454 addJCheckBox( _width_branches, ch_panel );
457 case Configuration.show_domain_architectures:
458 _show_domain_architectures = new JCheckBox( title );
459 addJCheckBox( _show_domain_architectures, ch_panel );
462 case Configuration.show_gene_names:
463 _show_gene_names = new JCheckBox( title );
464 addJCheckBox( _show_gene_names, ch_panel );
467 case Configuration.show_gene_symbols:
468 _show_gene_symbols = new JCheckBox( title );
469 addJCheckBox( _show_gene_symbols, ch_panel );
472 case Configuration.show_sequence_acc:
473 _show_sequence_acc = new JCheckBox( title );
474 addJCheckBox( _show_sequence_acc, ch_panel );
477 case Configuration.dynamically_hide_data:
478 _dynamically_hide_data = new JCheckBox( title );
479 getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" );
480 addJCheckBox( getDynamicallyHideData(), ch_panel );
483 case Configuration.node_data_popup:
484 _node_desc_popup_cb = new JCheckBox( title );
485 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
486 addJCheckBox( getNodeDescPopupCb(), ch_panel );
489 case Configuration.show_relation_confidence:
490 _seq_relation_confidence_switch = new JCheckBox( title );
491 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
494 case Configuration.show_vector_data:
495 _show_vector_data_cb = new JCheckBox( title );
496 addJCheckBox( _show_vector_data_cb, ch_panel );
499 case Configuration.show_properties:
500 _show_properties_cb = new JCheckBox( title );
501 addJCheckBox( _show_properties_cb, ch_panel );
505 throw new RuntimeException( "unknown checkbox: " + which );
509 private void addClickToOption( final int which, final String title ) {
510 _click_to_combobox.addItem( title );
511 _click_to_names.add( title );
512 _all_click_to_names.put( new Integer( which ), title );
513 if ( !_configuration.isUseNativeUI() ) {
514 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
515 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
519 void addJButton( final JButton jb, final JPanel p ) {
520 jb.setFocusPainted( false );
521 jb.setFont( ControlPanel.jcb_font );
522 if ( !_configuration.isUseNativeUI() ) {
523 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
524 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
525 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
528 jb.addActionListener( this );
531 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
532 jcb.setFocusPainted( false );
533 jcb.setFont( ControlPanel.jcb_font );
534 if ( !_configuration.isUseNativeUI() ) {
535 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
536 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
538 p.add( jcb, "Center" );
539 jcb.addActionListener( this );
542 void addJTextField( final JTextField tf, final JPanel p ) {
543 if ( !_configuration.isUseNativeUI() ) {
544 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
545 tf.setFont( ControlPanel.jcb_font );
548 tf.addActionListener( this );
552 private void addSequenceRelationBlock() {
553 final JLabel spacer = new JLabel( "" );
554 spacer.setSize( 1, 1 );
556 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
557 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
558 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
559 getSequenceRelationTypeBox().setFocusable( false );
560 _sequence_relation_type_box.setFont( ControlPanel.js_font );
561 if ( !_configuration.isUseNativeUI() ) {
562 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
563 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
565 _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
568 public Component getListCellRendererComponent( final JList list,
571 final boolean isSelected,
572 final boolean cellHasFocus ) {
573 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
578 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
579 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
580 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
585 final GridBagLayout gbl = new GridBagLayout();
586 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
587 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
588 final JPanel horizGrid = new JPanel( gbl );
589 horizGrid.setBackground( getBackground() );
590 horizGrid.add( typeLabel );
591 horizGrid.add( _sequence_relation_type_box );
592 add( customizeLabel( mainLabel, getConfiguration() ) );
594 add( getSequenceRelationBox() );
595 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
596 addCheckbox( Configuration.show_relation_confidence,
597 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
598 setCheckbox( Configuration.show_relation_confidence,
599 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
601 }// addSequenceRelationBlock
603 void deactivateButtonToReturnToSuperTree() {
604 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
605 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
606 _return_to_super_tree.setEnabled( false );
609 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
610 if ( ( _mainpanel != null ) && ( _mainpanel.getCurrentPhylogeny() != null ) ) {
611 if ( getOptions().isShowOverview() ) {
612 _mainpanel.getCurrentTreePanel().updateOvSizes();
614 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
615 setVisibilityOfDomainStrucureControls();
616 updateDomainStructureEvaluethresholdDisplay();
617 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
618 _mainpanel.getCurrentTreePanel().calcMaxDepth();
619 _mainpanel.adjustJScrollPane();
620 if ( recalc_longest_ext_node_info ) {
621 _mainpanel.getCurrentTreePanel().initNodeData();
622 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
624 _mainpanel.getCurrentTreePanel().repaint();
625 // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
629 void endClickToOptions() {
630 _click_to_combobox.addActionListener( this );
634 * Indicates what action should be execute when a node is clicked
636 * @return the click-on action
638 NodeClickAction getActionWhenNodeClicked() {
639 return _action_when_node_clicked;
642 Map<Integer, String> getAllClickToItems() {
643 return _all_click_to_names;
646 Map<String, Color> getAnnotationColors() {
647 return _annotation_colors;
650 public JCheckBox getColorBranchesCb() {
651 return _color_branches_cb;
654 Configuration getConfiguration() {
655 return _configuration;
658 TreePanel getCurrentTreePanel() {
659 return getMainPanel().getCurrentTreePanel();
662 public JCheckBox getDisplayAsPhylogramCb() {
663 return _display_as_phylogram_cb;
666 public JCheckBox getDynamicallyHideData() {
667 return _dynamically_hide_data;
671 private List<Boolean> getIsDrawPhylogramList() {
672 return _draw_phylogram;
675 MainPanel getMainPanel() {
679 public JCheckBox getNodeDescPopupCb() {
680 return _node_desc_popup_cb;
683 Options getOptions() {
684 return getMainPanel().getOptions();
687 private JLabel getSearchFoundCountsLabel() {
688 return _search_found_label;
691 private JButton getSearchResetButton() {
692 return _search_reset_button;
695 JTextField getSearchTextField() {
699 public Sequence getSelectedQuerySequence() {
700 return _selected_query_seq;
703 public JComboBox getSequenceRelationBox() {
704 if ( _show_sequence_relations == null ) {
705 _show_sequence_relations = new JComboBox();
706 _show_sequence_relations.setFocusable( false );
707 _show_sequence_relations.setMaximumRowCount( 20 );
708 _show_sequence_relations.setFont( ControlPanel.js_font );
709 if ( !_configuration.isUseNativeUI() ) {
710 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
711 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
713 _show_sequence_relations.addItem( "-----" );
714 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
716 return _show_sequence_relations;
720 public JComboBox getSequenceRelationTypeBox() {
721 if ( _sequence_relation_type_box == null ) {
722 _sequence_relation_type_box = new JComboBox();
723 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
724 _sequence_relation_type_box.addItem( type );
726 _sequence_relation_type_box.addActionListener( new ActionListener() {
729 public void actionPerformed( final ActionEvent e ) {
730 if ( _mainpanel.getCurrentPhylogeny() != null ) {
731 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
736 return _sequence_relation_type_box;
739 public JCheckBox getShowEventsCb() {
743 List<String> getSingleClickToNames() {
744 return _click_to_names;
747 Map<String, Color> getSpeciesColors() {
748 return _species_colors;
751 public JCheckBox getWriteConfidenceCb() {
752 return _write_confidence;
755 private void init() {
756 _draw_phylogram = new ArrayList<Boolean>();
757 setSpeciesColors( new HashMap<String, Color>() );
758 setAnnotationColors( new HashMap<String, Color>() );
761 boolean isAntialiasScreenText() {
765 boolean isColorAccordingToAnnotation() {
766 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
769 boolean isColorAccordingToTaxonomy() {
770 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
773 boolean isColorBranches() {
774 return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) );
777 boolean isDrawPhylogram() {
778 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
781 private boolean isDrawPhylogram( final int index ) {
782 return getIsDrawPhylogramList().get( index );
785 boolean isDynamicallyHideData() {
786 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
790 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
793 boolean isNodeDescPopup() {
794 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
797 boolean isShowAnnotation() {
798 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
801 boolean isShowBinaryCharacterCounts() {
802 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
805 boolean isShowBinaryCharacters() {
806 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
809 boolean isShowBootstrapValues() {
810 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
813 boolean isShowDomainArchitectures() {
814 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
817 boolean isShowGeneNames() {
818 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
821 public boolean isShowVectorData() {
822 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
825 public boolean isShowProperties() {
826 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
829 boolean isShowGeneSymbols() {
830 return ( ( _show_gene_symbols != null ) && _show_gene_symbols.isSelected() );
833 boolean isShowInternalData() {
834 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
837 boolean isShowNodeNames() {
838 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
841 boolean isShowSequenceAcc() {
842 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
845 boolean isShowSequenceRelationConfidence() {
846 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
849 boolean isShowSequenceRelations() {
850 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
853 boolean isShowTaxonomyCode() {
854 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
857 public boolean isShowTaxonomyImages() {
858 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
861 boolean isShowTaxonomyCommonNames() {
862 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
865 boolean isShowTaxonomyScientificNames() {
866 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
869 boolean isWidthBranches() {
870 return ( ( _width_branches != null ) && _width_branches.isSelected() );
873 void phylogenyAdded( final Configuration configuration ) {
874 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
877 void phylogenyRemoved( final int index ) {
878 getIsDrawPhylogramList().remove( index );
882 final MainPanel main_panel = getMainPanel();
883 final Phylogeny tree = main_panel.getCurrentPhylogeny();
884 if ( ( tree == null ) || tree.isEmpty() ) {
887 String query = getSearchTextField().getText();
888 if ( query != null ) {
889 query = query.trim();
892 getSearchFoundCountsLabel().setVisible( false );
893 getSearchResetButton().setEnabled( false );
894 getSearchResetButton().setVisible( false );
897 if ( !ForesterUtil.isEmpty( query ) ) {
898 search( main_panel, tree, query );
901 getSearchFoundCountsLabel().setVisible( false );
902 getSearchResetButton().setEnabled( false );
903 getSearchResetButton().setVisible( false );
908 private void search( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
909 getSearchFoundCountsLabel().setVisible( true );
910 getSearchResetButton().setEnabled( true );
911 getSearchResetButton().setVisible( true );
912 String[] queries = null;
913 List<PhylogenyNode> nodes = null;
914 if ( query_str.indexOf( ',' ) >= 0 ) {
915 queries = query_str.split( ",+" );
918 queries = new String[ 1 ];
919 queries[ 0 ] = query_str.trim();
921 if ( ( queries != null ) && ( queries.length > 0 ) ) {
922 nodes = new ArrayList<PhylogenyNode>();
923 for( String query : queries ) {
924 if ( ForesterUtil.isEmpty( query ) ) {
927 query = query.trim();
928 if ( query.indexOf( '+' ) >= 0 ) {
929 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ), tree, getOptions()
930 .isSearchCaseSensitive(), !getOptions().isMatchWholeTermsOnly() ) );
933 nodes.addAll( PhylogenyMethods.searchData( query,
935 getOptions().isSearchCaseSensitive(),
936 !getOptions().isMatchWholeTermsOnly() ) );
939 if ( getOptions().isInverseSearchResult() ) {
940 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
941 all.removeAll( nodes );
945 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
946 main_panel.getCurrentTreePanel().setFoundNodes( new HashSet<Integer>() );
947 for( final PhylogenyNode node : nodes ) {
948 main_panel.getCurrentTreePanel().getFoundNodes().add( node.getId() );
950 setSearchFoundCountsOnLabel( nodes.size() );
953 setSearchFoundCountsOnLabel( 0 );
958 private void searchReset() {
959 if ( getMainPanel().getCurrentTreePanel() != null ) {
960 getMainPanel().getCurrentTreePanel().setFoundNodes( null );
964 void setActionWhenNodeClicked( final NodeClickAction action ) {
965 _action_when_node_clicked = action;
968 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
969 _annotation_colors = annotation_colors;
972 void setCheckbox( final int which, final boolean state ) {
974 case Configuration.display_as_phylogram:
975 if ( getDisplayAsPhylogramCb() != null ) {
976 getDisplayAsPhylogramCb().setSelected( state );
979 case Configuration.display_internal_data:
980 if ( _display_internal_data != null ) {
981 _display_internal_data.setSelected( state );
984 case Configuration.color_according_to_species:
985 if ( _color_acc_species != null ) {
986 _color_acc_species.setSelected( state );
989 case Configuration.color_according_to_annotation:
990 if ( _color_according_to_annotation != null ) {
991 _color_according_to_annotation.setSelected( state );
994 case Configuration.show_node_names:
995 if ( _show_node_names != null ) {
996 _show_node_names.setSelected( state );
999 case Configuration.show_tax_code:
1000 if ( _show_taxo_code != null ) {
1001 _show_taxo_code.setSelected( state );
1004 case Configuration.show_taxonomy_scientific_names:
1005 if ( _show_taxo_scientific_names != null ) {
1006 _show_taxo_scientific_names.setSelected( state );
1009 case Configuration.show_taxonomy_common_names:
1010 if ( _show_taxo_common_names != null ) {
1011 _show_taxo_common_names.setSelected( state );
1014 case Configuration.show_taxonomy_images:
1015 if ( _show_taxo_images_cb != null ) {
1016 _show_taxo_images_cb.setSelected( state );
1019 case Configuration.show_annotation:
1020 if ( _show_annotation != null ) {
1021 _show_annotation.setSelected( state );
1024 case Configuration.show_binary_characters:
1025 if ( _show_binary_characters != null ) {
1026 _show_binary_characters.setSelected( state );
1029 case Configuration.show_binary_character_counts:
1030 if ( _show_binary_character_counts != null ) {
1031 _show_binary_character_counts.setSelected( state );
1034 case Configuration.write_confidence_values:
1035 if ( getWriteConfidenceCb() != null ) {
1036 getWriteConfidenceCb().setSelected( state );
1039 case Configuration.write_events:
1040 if ( getShowEventsCb() != null ) {
1041 getShowEventsCb().setSelected( state );
1044 case Configuration.color_branches:
1045 if ( getColorBranchesCb() != null ) {
1046 getColorBranchesCb().setSelected( state );
1049 case Configuration.width_branches:
1050 if ( _width_branches != null ) {
1051 _width_branches.setSelected( state );
1054 case Configuration.show_domain_architectures:
1055 if ( _show_domain_architectures != null ) {
1056 _show_domain_architectures.setSelected( state );
1059 case Configuration.show_gene_names:
1060 if ( _show_gene_names != null ) {
1061 _show_gene_names.setSelected( state );
1064 case Configuration.show_gene_symbols:
1065 if ( _show_gene_symbols != null ) {
1066 _show_gene_symbols.setSelected( state );
1069 case Configuration.show_vector_data:
1070 if ( _show_vector_data_cb != null ) {
1071 _show_vector_data_cb.setSelected( state );
1074 case Configuration.show_properties:
1075 if ( _show_properties_cb != null ) {
1076 _show_properties_cb.setSelected( state );
1079 case Configuration.show_sequence_acc:
1080 if ( _show_sequence_acc != null ) {
1081 _show_sequence_acc.setSelected( state );
1084 case Configuration.dynamically_hide_data:
1085 if ( getDynamicallyHideData() != null ) {
1086 getDynamicallyHideData().setSelected( state );
1089 case Configuration.node_data_popup:
1090 if ( getNodeDescPopupCb() != null ) {
1091 getNodeDescPopupCb().setSelected( state );
1095 case Configuration.show_relation_confidence:
1096 if ( _seq_relation_confidence_switch != null ) {
1097 _seq_relation_confidence_switch.setSelected( state );
1102 throw new AssertionError( "unknown checkbox: " + which );
1107 * Set this checkbox state. Not all checkboxes have been instantiated
1108 * depending on the config.
1110 void setCheckbox( final JCheckBox cb, final boolean state ) {
1112 cb.setSelected( state );
1116 void setClickToAction( final int action ) {
1117 // Set click-to action
1118 if ( action == _show_data_item ) {
1119 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1121 else if ( action == _collapse_cb_item ) {
1122 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1124 else if ( action == _reroot_cb_item ) {
1125 setActionWhenNodeClicked( NodeClickAction.REROOT );
1127 else if ( action == _subtree_cb_item ) {
1128 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1130 else if ( action == _swap_cb_item ) {
1131 setActionWhenNodeClicked( NodeClickAction.SWAP );
1133 else if ( action == _color_subtree_cb_item ) {
1134 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1136 else if ( action == _open_seq_web_item ) {
1137 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1139 else if ( action == _blast_item ) {
1140 if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
1141 setActionWhenNodeClicked( NodeClickAction.BLAST );
1144 else if ( action == _open_tax_web_item ) {
1145 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1147 else if ( action == _cut_subtree_item ) {
1148 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1150 else if ( action == _copy_subtree_item ) {
1151 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1153 else if ( action == _delete_node_or_subtree_item ) {
1154 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1156 else if ( action == _paste_subtree_item ) {
1157 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1159 else if ( action == _add_new_node_item ) {
1160 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1162 else if ( action == _edit_node_data_item ) {
1163 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1166 throw new RuntimeException( "unknown action: " + action );
1168 // make sure drop down is displaying the correct action
1169 // in case this was called from outside the class
1170 _click_to_combobox.setSelectedIndex( action );
1173 void setColorBranches( final boolean color_branches ) {
1174 _color_branches = color_branches;
1177 void setDrawPhylogram( final boolean b ) {
1178 getDisplayAsPhylogramCb().setSelected( b );
1179 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1182 private void setDrawPhylogram( final int index, final boolean b ) {
1183 getIsDrawPhylogramList().set( index, b );
1186 void setDrawPhylogramEnabled( final boolean b ) {
1187 getDisplayAsPhylogramCb().setEnabled( b );
1190 void setDynamicHidingIsOn( final boolean is_on ) {
1191 // if ( !_configuration.isUseNativeUI() ) {
1193 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1196 if ( !_configuration.isUseNativeUI() ) {
1197 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1200 getDynamicallyHideData().setForeground( Color.BLACK );
1206 private void setSearchFoundCountsOnLabel( final int counts ) {
1207 getSearchFoundCountsLabel().setText( "Found: " + counts );
1210 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
1211 final JComboBox box = getSequenceRelationBox();
1212 while ( box.getItemCount() > 1 ) {
1213 box.removeItemAt( 1 );
1215 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
1216 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
1218 if ( relationType == null ) {
1221 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
1222 for( final Sequence seq : sequenceRelationQueries ) {
1223 if ( seq.hasSequenceRelations() ) {
1224 boolean fFoundForCurrentType = false;
1225 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
1226 if ( sq.getType().equals( relationType ) ) {
1227 fFoundForCurrentType = true;
1231 if ( fFoundForCurrentType ) {
1232 sequenceNamesToAdd.add( seq.getName() );
1233 sequencesByName.put( seq.getName(), seq );
1237 // sort sequences by name before adding them to the combo
1238 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
1239 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
1240 for( final String seqName : sequenceNameArray ) {
1241 box.addItem( seqName );
1243 for( final ItemListener oldItemListener : box.getItemListeners() ) {
1244 box.removeItemListener( oldItemListener );
1246 box.addItemListener( new ItemListener() {
1249 public void itemStateChanged( final ItemEvent e ) {
1250 _selected_query_seq = sequencesByName.get( e.getItem() );
1251 _mainpanel.getCurrentTreePanel().repaint();
1256 void setShowEvents( final boolean show_events ) {
1257 if ( getShowEventsCb() == null ) {
1258 _show_events = new JCheckBox( "" );
1260 getShowEventsCb().setSelected( show_events );
1263 void setSpeciesColors( final Map<String, Color> species_colors ) {
1264 _species_colors = species_colors;
1267 private void setupClickToOptions() {
1268 final int default_option = _configuration.getDefaultDisplayClicktoOption();
1269 int selected_index = 0;
1271 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1272 _show_data_item = cb_index;
1273 addClickToOption( Configuration.display_node_data,
1274 _configuration.getClickToTitle( Configuration.display_node_data ) );
1275 if ( default_option == Configuration.display_node_data ) {
1276 selected_index = cb_index;
1280 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1281 _collapse_cb_item = cb_index;
1282 addClickToOption( Configuration.collapse_uncollapse,
1283 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
1284 if ( default_option == Configuration.collapse_uncollapse ) {
1285 selected_index = cb_index;
1289 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1290 _reroot_cb_item = cb_index;
1291 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1292 if ( default_option == Configuration.reroot ) {
1293 selected_index = cb_index;
1297 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1298 _subtree_cb_item = cb_index;
1299 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1300 if ( default_option == Configuration.subtree ) {
1301 selected_index = cb_index;
1305 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1306 _swap_cb_item = cb_index;
1307 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1308 if ( default_option == Configuration.swap ) {
1309 selected_index = cb_index;
1313 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1314 _color_subtree_cb_item = cb_index;
1315 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1316 if ( default_option == Configuration.color_subtree ) {
1317 selected_index = cb_index;
1321 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1322 _open_seq_web_item = cb_index;
1323 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1324 if ( default_option == Configuration.open_seq_web ) {
1325 selected_index = cb_index;
1329 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1330 _open_tax_web_item = cb_index;
1331 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1332 if ( default_option == Configuration.open_tax_web ) {
1333 selected_index = cb_index;
1337 if ( getOptions().isEditable() ) {
1338 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
1339 _cut_subtree_item = cb_index;
1340 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
1341 if ( default_option == Configuration.cut_subtree ) {
1342 selected_index = cb_index;
1346 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
1347 _copy_subtree_item = cb_index;
1348 addClickToOption( Configuration.copy_subtree,
1349 _configuration.getClickToTitle( Configuration.copy_subtree ) );
1350 if ( default_option == Configuration.copy_subtree ) {
1351 selected_index = cb_index;
1355 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
1356 _paste_subtree_item = cb_index;
1357 addClickToOption( Configuration.paste_subtree,
1358 _configuration.getClickToTitle( Configuration.paste_subtree ) );
1359 if ( default_option == Configuration.paste_subtree ) {
1360 selected_index = cb_index;
1364 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
1365 _delete_node_or_subtree_item = cb_index;
1366 addClickToOption( Configuration.delete_subtree_or_node,
1367 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
1368 if ( default_option == Configuration.delete_subtree_or_node ) {
1369 selected_index = cb_index;
1373 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
1374 _add_new_node_item = cb_index;
1375 addClickToOption( Configuration.add_new_node,
1376 _configuration.getClickToTitle( Configuration.add_new_node ) );
1377 if ( default_option == Configuration.add_new_node ) {
1378 selected_index = cb_index;
1382 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
1383 _edit_node_data_item = cb_index;
1384 addClickToOption( Configuration.edit_node_data,
1385 _configuration.getClickToTitle( Configuration.edit_node_data ) );
1386 if ( default_option == Configuration.edit_node_data ) {
1387 selected_index = cb_index;
1391 if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
1392 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1393 _blast_item = cb_index;
1394 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
1395 if ( default_option == Configuration.blast ) {
1396 selected_index = cb_index;
1402 // Set default selection and its action
1403 _click_to_combobox.setSelectedIndex( selected_index );
1404 setClickToAction( selected_index );
1409 * Set up the controls from the config settings. 11/26/05
1411 void setupControls() {
1412 // The tree display options:
1413 setupDisplayCheckboxes();
1415 // The sequence relation query selection combo-box
1416 if ( _configuration.displaySequenceRelations() ) {
1417 addSequenceRelationBlock();
1421 startClickToOptions();
1422 setupClickToOptions();
1423 endClickToOptions();
1424 // Zoom and quick edit buttons
1429 void setUpControlsForDomainStrucures() {
1430 _domain_display_label = new JLabel( "Domain Display:" );
1431 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1432 add( _domain_display_label );
1433 _zoom_in_domain_structure = new JButton( "d+" );
1434 _zoom_out_domain_structure = new JButton( "d-" );
1435 _decr_domain_structure_evalue_thr = new JButton( "-" );
1436 _incr_domain_structure_evalue_thr = new JButton( "+" );
1437 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1438 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1439 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1440 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1441 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1442 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1443 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1444 _domain_structure_evalue_thr_tf.setEditable( false );
1445 if ( !getConfiguration().isUseNativeUI() ) {
1446 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1447 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1448 _domain_structure_evalue_thr_tf.setBorder( null );
1450 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1451 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1452 if ( !_configuration.isUseNativeUI() ) {
1453 d1_panel.setBackground( getBackground() );
1454 d2_panel.setBackground( getBackground() );
1458 addJButton( _zoom_out_domain_structure, d1_panel );
1459 addJButton( _zoom_in_domain_structure, d1_panel );
1460 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1461 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1462 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1465 private void setupDisplayCheckboxes() {
1466 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
1467 addCheckbox( Configuration.display_as_phylogram,
1468 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
1469 setCheckbox( Configuration.display_as_phylogram,
1470 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
1472 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1473 addCheckbox( Configuration.dynamically_hide_data,
1474 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
1475 setCheckbox( Configuration.dynamically_hide_data,
1476 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
1478 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1479 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1480 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1482 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1483 addCheckbox( Configuration.display_internal_data,
1484 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
1485 setCheckbox( Configuration.display_internal_data,
1486 _configuration.doCheckOption( Configuration.display_internal_data ) );
1488 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1489 addCheckbox( Configuration.color_according_to_species,
1490 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
1491 setCheckbox( Configuration.color_according_to_species,
1492 _configuration.doCheckOption( Configuration.color_according_to_species ) );
1494 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1495 addCheckbox( Configuration.color_according_to_annotation,
1496 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
1497 setCheckbox( Configuration.color_according_to_annotation,
1498 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
1500 if ( _configuration.doDisplayOption( Configuration.color_branches ) ) {
1501 addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) );
1502 setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) );
1504 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1505 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1506 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1508 final JLabel label = new JLabel( "Display Data:" );
1509 label.setFont( ControlPanel.jcb_bold_font );
1510 if ( !getConfiguration().isUseNativeUI() ) {
1511 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1514 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1515 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
1516 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1518 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1519 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1520 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1522 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1523 addCheckbox( Configuration.show_taxonomy_scientific_names,
1524 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1525 setCheckbox( Configuration.show_taxonomy_scientific_names,
1526 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1528 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1529 addCheckbox( Configuration.show_taxonomy_common_names,
1530 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1531 setCheckbox( Configuration.show_taxonomy_common_names,
1532 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1534 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1535 addCheckbox( Configuration.show_taxonomy_images,
1536 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1537 setCheckbox( Configuration.show_taxonomy_images,
1538 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1540 if ( _configuration.doDisplayOption( Configuration.show_gene_symbols ) ) {
1541 addCheckbox( Configuration.show_gene_symbols,
1542 _configuration.getDisplayTitle( Configuration.show_gene_symbols ) );
1543 setCheckbox( Configuration.show_gene_symbols,
1544 _configuration.doCheckOption( Configuration.show_gene_symbols ) );
1546 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1547 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1548 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1550 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1551 addCheckbox( Configuration.show_sequence_acc,
1552 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1553 setCheckbox( Configuration.show_sequence_acc,
1554 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1556 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1557 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
1558 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1560 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1561 addCheckbox( Configuration.show_binary_characters,
1562 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1563 setCheckbox( Configuration.show_binary_characters,
1564 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1566 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1567 addCheckbox( Configuration.show_binary_character_counts,
1568 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1569 setCheckbox( Configuration.show_binary_character_counts,
1570 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1572 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1573 addCheckbox( Configuration.show_domain_architectures,
1574 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1575 setCheckbox( Configuration.show_domain_architectures,
1576 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1578 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1579 addCheckbox( Configuration.write_confidence_values,
1580 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1581 setCheckbox( Configuration.write_confidence_values,
1582 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1584 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1585 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1586 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1588 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1589 addCheckbox( Configuration.show_vector_data,
1590 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1591 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
1593 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1594 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
1595 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1599 void setupSearchTools() {
1600 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1601 final JLabel search_label = new JLabel( "Search:" );
1602 search_label.setFont( ControlPanel.jcb_bold_font );
1603 if ( !getConfiguration().isUseNativeUI() ) {
1604 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1606 add( search_label );
1607 search_label.setToolTipText( tip );
1608 _search_found_label = new JLabel();
1609 getSearchFoundCountsLabel().setVisible( false );
1610 _search_found_label.setFont( ControlPanel.jcb_bold_font );
1611 if ( !getConfiguration().isUseNativeUI() ) {
1612 _search_found_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1614 _search_tf = new JTextField( 3 );
1615 _search_tf.setToolTipText( tip );
1616 _search_tf.setEditable( true );
1617 if ( !getConfiguration().isUseNativeUI() ) {
1618 _search_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1619 _search_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1620 _search_tf.setBorder( null );
1622 _search_reset_button = new JButton();
1623 getSearchResetButton().setText( "Reset" );
1624 getSearchResetButton().setEnabled( false );
1625 getSearchResetButton().setVisible( false );
1626 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1627 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1628 s_panel_1.setBackground( getBackground() );
1630 s_panel_2.setBackground( getBackground() );
1632 final KeyAdapter key_adapter = new KeyAdapter() {
1635 public void keyReleased( final KeyEvent key_event ) {
1637 displayedPhylogenyMightHaveChanged( true );
1640 final ActionListener action_listener = new ActionListener() {
1643 public void actionPerformed( final ActionEvent e ) {
1645 setSearchFoundCountsOnLabel( 0 );
1646 getSearchFoundCountsLabel().setVisible( false );
1647 getSearchTextField().setText( "" );
1648 getSearchResetButton().setEnabled( false );
1649 getSearchResetButton().setVisible( false );
1650 displayedPhylogenyMightHaveChanged( true );
1653 _search_reset_button.addActionListener( action_listener );
1654 _search_tf.addKeyListener( key_adapter );
1655 addJTextField( _search_tf, s_panel_1 );
1656 s_panel_2.add( _search_found_label );
1657 addJButton( _search_reset_button, s_panel_2 );
1660 private void setVisibilityOfDomainStrucureControls() {
1661 if ( _zoom_in_domain_structure != null ) {
1662 if ( isShowDomainArchitectures() ) {
1663 _domain_display_label.setVisible( true );
1664 _zoom_in_domain_structure.setVisible( true );
1665 _zoom_out_domain_structure.setVisible( true );
1666 _decr_domain_structure_evalue_thr.setVisible( true );
1667 _incr_domain_structure_evalue_thr.setVisible( true );
1668 _domain_structure_evalue_thr_tf.setVisible( true );
1671 _domain_display_label.setVisible( false );
1672 _zoom_in_domain_structure.setVisible( false );
1673 _zoom_out_domain_structure.setVisible( false );
1674 _decr_domain_structure_evalue_thr.setVisible( false );
1675 _incr_domain_structure_evalue_thr.setVisible( false );
1676 _domain_structure_evalue_thr_tf.setVisible( false );
1682 * Fit entire tree into window.
1685 if ( _mainpanel.getCurrentScrollPane() == null ) {
1688 displayedPhylogenyMightHaveChanged( false );
1689 _mainpanel.getCurrentTreePanel().updateOvSettings();
1690 _mainpanel.getCurrentTreePanel().validate();
1691 _mainpanel.validate();
1692 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1693 _mainpanel.getSizeOfViewport().height,
1695 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1696 _mainpanel.adjustJScrollPane();
1697 _mainpanel.getCurrentTreePanel().repaint();
1698 _mainpanel.getCurrentTreePanel().validate();
1699 _mainpanel.validate();
1700 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1701 _mainpanel.getSizeOfViewport().height,
1703 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1704 _mainpanel.adjustJScrollPane();
1705 _mainpanel.getCurrentTreePanel().repaint();
1706 _mainpanel.getCurrentTreePanel().updateOvSizes();
1709 void showWholeAll() {
1710 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1711 if ( tree_panel != null ) {
1712 tree_panel.validate();
1713 tree_panel.setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1714 _mainpanel.getSizeOfViewport().height,
1716 tree_panel.resetPreferredSize();
1717 tree_panel.repaint();
1722 // Create header for click-to combo box.
1723 void startClickToOptions() {
1724 final JLabel spacer = new JLabel( "" );
1725 spacer.setFont( ControlPanel.jcb_font );
1727 _click_to_label = new JLabel( "Click on Node to:" );
1728 add( customizeLabel( _click_to_label, getConfiguration() ) );
1729 _click_to_combobox = new JComboBox();
1730 _click_to_combobox.setFocusable( false );
1731 _click_to_combobox.setMaximumRowCount( 14 );
1732 _click_to_combobox.setFont( ControlPanel.js_font );
1733 if ( !_configuration.isUseNativeUI() ) {
1734 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1736 // don't add listener until all items are set (or each one will trigger
1738 // click_to_list.addActionListener(this);
1739 add( _click_to_combobox );
1740 // Correlates option names to titles
1741 _all_click_to_names = new HashMap<Integer, String>();
1742 _click_to_names = new ArrayList<String>();
1746 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1747 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1748 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1749 setDrawPhylogramEnabled( true );
1750 setDrawPhylogram( isDrawPhylogram() );
1753 setDrawPhylogramEnabled( false );
1754 setDrawPhylogram( false );
1756 if ( getMainPanel().getMainFrame() == null ) {
1757 // Must be "E" applet version.
1758 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1759 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1762 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1763 .getPhylogenyGraphicsType() );
1765 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1766 getMainPanel().getControlPanel().search();
1767 getSequenceRelationTypeBox().removeAllItems();
1768 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1769 .getRelevantSequenceRelationTypes() ) {
1770 _sequence_relation_type_box.addItem( type );
1772 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1773 // according to GUILHEM the line above can be removed.
1778 * Uncollapse all nodes.
1780 void uncollapseAll( final TreePanel tp ) {
1781 final Phylogeny t = tp.getPhylogeny();
1782 if ( ( t != null ) && !t.isEmpty() ) {
1783 t.setAllNodesToNotCollapse();
1784 t.recalculateNumberOfExternalDescendants( false );
1789 void updateDomainStructureEvaluethresholdDisplay() {
1790 if ( _domain_structure_evalue_thr_tf != null ) {
1791 _domain_structure_evalue_thr_tf.setText( "10^"
1792 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1796 void zoomInX( final float factor, final float x_correction_factor ) {
1797 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1798 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1799 treepanel.multiplyUrtFactor( 1f );
1800 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1801 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1802 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1803 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1804 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1805 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1806 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1807 getMainPanel().adjustJScrollPane();
1808 treepanel.resetPreferredSize();
1809 getMainPanel().getCurrentScrollPane().getViewport().validate();
1810 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1811 - ( sb.getVisibleAmount() / 2.0 ) ) );
1814 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1815 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1816 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1817 getMainPanel().adjustJScrollPane();
1818 treepanel.resetPreferredSize();
1819 getMainPanel().getCurrentScrollPane().getViewport().validate();
1820 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1822 treepanel.resetPreferredSize();
1823 treepanel.updateOvSizes();
1826 void zoomInY( final float factor ) {
1827 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1828 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1829 treepanel.multiplyUrtFactor( 1.1f );
1830 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1831 treepanel.setYdistance( ( treepanel.getYdistance() * 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 ) ) );
1837 treepanel.resetPreferredSize();
1838 treepanel.updateOvSizes();
1841 void zoomOutX( final float factor, final float x_correction_factor ) {
1842 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1843 treepanel.multiplyUrtFactor( 1f );
1844 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1845 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1846 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1847 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1848 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1849 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1850 getMainPanel().adjustJScrollPane();
1851 treepanel.resetPreferredSize();
1852 getMainPanel().getCurrentScrollPane().getViewport().validate();
1853 final double x = ( sb.getMaximum() - sb.getMinimum() )
1854 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1855 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1856 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_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 ) ) );
1864 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1865 treepanel.setXdistance( treepanel.getXdistance() * factor );
1866 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
1868 getMainPanel().adjustJScrollPane();
1869 treepanel.resetPreferredSize();
1870 getMainPanel().getCurrentScrollPane().getViewport().validate();
1871 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1874 treepanel.resetPreferredSize();
1875 treepanel.updateOvSizes();
1879 void zoomOutY( final float factor ) {
1880 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1881 treepanel.multiplyUrtFactor( 0.9f );
1882 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1883 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1884 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1885 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1886 getMainPanel().adjustJScrollPane();
1887 treepanel.resetPreferredSize();
1888 getMainPanel().getCurrentScrollPane().getViewport().validate();
1889 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1890 - ( sb.getVisibleAmount() / 2.0 ) ) );
1891 treepanel.resetPreferredSize();
1892 treepanel.updateOvSizes();
1896 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
1897 label.setFont( ControlPanel.jcb_bold_font );
1898 if ( !configuration.isUseNativeUI() ) {
1899 label.setForeground( configuration.getGuiCheckboxTextColor() );
1900 label.setBackground( configuration.getGuiBackgroundColor() );
1905 enum NodeClickAction {
1916 DELETE_NODE_OR_SUBTREE,