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 JLabel _click_to_label;
113 private JLabel _zoom_label;
114 private JLabel _domain_display_label;
115 private JComboBox _click_to_combobox;
116 private Map<Integer, String> _all_click_to_names;
117 private List<String> _click_to_names;
118 // Indices for the click-to options in the combo box
119 private int _show_data_item;
120 private int _collapse_cb_item;
121 private int _reroot_cb_item;
122 private int _swap_cb_item;
123 private int _subtree_cb_item;
124 private int _color_subtree_cb_item;
125 private int _open_seq_web_item;
126 private int _open_tax_web_item;
127 private int _cut_subtree_item;
128 private int _copy_subtree_item;
129 private int _delete_node_or_subtree_item;
130 private int _paste_subtree_item;
131 private int _add_new_node_item;
132 private int _edit_node_data_item;
133 private int _blast_item;
134 // zooming and quick tree manipulation buttons:
135 private JButton _zoom_in_x;
136 private JButton _zoom_in_y;
137 private JButton _zoom_out_x;
138 private JButton _zoom_out_y;
139 private JButton _show_whole;
140 private JButton _order;
141 private JButton _uncollapse_all;
142 private JButton _zoom_in_domain_structure;
143 private JButton _zoom_out_domain_structure;
144 private JButton _decr_domain_structure_evalue_thr;
145 private JButton _incr_domain_structure_evalue_thr;
146 private JButton _return_to_super_tree;
147 private JTextField _domain_structure_evalue_thr_tf;
148 private JTextField _search_tf;
149 private boolean _order_of_appearance;
150 private boolean _color_branches;
151 private NodeClickAction _action_when_node_clicked;
152 private List<Boolean> _draw_phylogram;
153 private Map<String, Color> _annotation_colors;
154 private Map<String, Color> _species_colors;
155 private JButton _search_reset_button;
156 private JLabel _search_found_label;
157 private Sequence _selected_query_seq;
159 ControlPanel( final MainPanel ap, final Configuration configuration ) {
162 _configuration = configuration;
163 if ( !_configuration.isUseNativeUI() ) {
164 setBackground( getConfiguration().getGuiBackgroundColor() );
165 setBorder( BorderFactory.createRaisedBevelBorder() );
167 setLayout( new GridLayout( 0, 1, 2, 2 ) );
168 _order_of_appearance = true;
175 public void actionPerformed( final ActionEvent e ) {
177 final TreePanel tp = getMainPanel().getCurrentTreePanel();
181 if ( e.getSource() == _click_to_combobox ) {
182 setClickToAction( _click_to_combobox.getSelectedIndex() );
183 getCurrentTreePanel().repaint();
185 else if ( e.getSource() == _show_binary_characters ) {
186 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
187 _show_binary_character_counts.setSelected( false );
189 displayedPhylogenyMightHaveChanged( true );
191 else if ( e.getSource() == _show_binary_character_counts ) {
192 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
193 _show_binary_characters.setSelected( false );
195 displayedPhylogenyMightHaveChanged( true );
197 else if ( e.getSource() == _color_according_to_annotation ) {
198 if ( ( _show_annotation != null ) && _color_according_to_annotation.isSelected() ) {
199 _show_annotation.setSelected( true );
201 displayedPhylogenyMightHaveChanged( false );
203 else if ( e.getSource() == _show_annotation ) {
204 if ( ( _color_according_to_annotation != null ) && !_show_annotation.isSelected() ) {
205 _color_according_to_annotation.setSelected( false );
207 displayedPhylogenyMightHaveChanged( false );
209 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
210 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
211 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
215 else if ( e.getSource() == _zoom_in_x ) {
216 zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
217 displayedPhylogenyMightHaveChanged( false );
219 else if ( e.getSource() == _zoom_in_y ) {
220 zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR );
221 displayedPhylogenyMightHaveChanged( false );
223 else if ( e.getSource() == _zoom_out_x ) {
224 zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
225 displayedPhylogenyMightHaveChanged( false );
227 else if ( e.getSource() == _zoom_out_y ) {
228 zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR );
229 displayedPhylogenyMightHaveChanged( false );
231 else if ( e.getSource() == _show_whole ) {
234 else if ( e.getSource() == _return_to_super_tree ) {
235 _mainpanel.getCurrentTreePanel().superTree();
238 else if ( e.getSource() == _order ) {
239 tp.getPhylogeny().orderAppearance( _order_of_appearance );
240 _order_of_appearance = !_order_of_appearance;
241 displayedPhylogenyMightHaveChanged( false );
243 else if ( e.getSource() == _uncollapse_all ) {
245 displayedPhylogenyMightHaveChanged( false );
247 else if ( e.getSource() == _zoom_in_domain_structure ) {
248 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
249 displayedPhylogenyMightHaveChanged( true );
251 else if ( e.getSource() == _zoom_out_domain_structure ) {
252 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
253 displayedPhylogenyMightHaveChanged( true );
255 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
256 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThreshold();
257 displayedPhylogenyMightHaveChanged( true );
259 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
260 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThreshold();
261 displayedPhylogenyMightHaveChanged( true );
263 else if ( e.getSource() == _search_tf ) {
265 displayedPhylogenyMightHaveChanged( true );
268 displayedPhylogenyMightHaveChanged( true );
272 tp.requestFocusInWindow();
275 catch ( final Exception ex ) {
276 Util.unexpectedException( ex );
278 catch ( final Error err ) {
279 Util.unexpectedError( err );
283 void activateButtonToReturnToSuperTree( int index ) {
286 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
289 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
291 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
292 _return_to_super_tree.setEnabled( true );
296 * Add zoom and quick edit buttons. (Last modified 8/9/04)
299 final JLabel spacer = new JLabel( "" );
300 spacer.setOpaque( false );
302 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
303 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
304 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
305 if ( !getConfiguration().isUseNativeUI() ) {
306 x_panel.setBackground( getBackground() );
307 y_panel.setBackground( getBackground() );
308 z_panel.setBackground( getBackground() );
310 add( _zoom_label = new JLabel( "Zoom:" ) );
311 customizeLabel( _zoom_label, getConfiguration() );
315 if ( getConfiguration().isUseNativeUI() ) {
316 _zoom_in_x = new JButton( "+" );
317 _zoom_out_x = new JButton( "-" );
320 _zoom_in_x = new JButton( "X+" );
321 _zoom_out_x = new JButton( "X-" );
323 _zoom_in_y = new JButton( "Y+" );
324 _zoom_out_y = new JButton( "Y-" );
325 _show_whole = new JButton( "F" );
326 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [Backspace]" );
327 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+Right]" );
328 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+Up]" );
329 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+Left]" );
330 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+Down]" );
331 if ( getConfiguration().isUseNativeUI() && Util.isMac() ) {
332 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
333 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
336 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
337 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
339 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
340 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
341 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
342 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
343 _return_to_super_tree.setEnabled( false );
344 _order = new JButton( "Order Subtrees" );
345 _uncollapse_all = new JButton( "Uncollapse All" );
346 addJButton( _zoom_in_y, x_panel );
347 addJButton( _zoom_out_x, y_panel );
348 addJButton( _show_whole, y_panel );
349 addJButton( _zoom_in_x, y_panel );
350 addJButton( _zoom_out_y, z_panel );
351 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
352 setUpControlsForDomainStrucures();
354 final JLabel spacer2 = new JLabel( "" );
356 addJButton( _return_to_super_tree, this );
357 addJButton( _order, this );
358 addJButton( _uncollapse_all, this );
359 final JLabel spacer3 = new JLabel( "" );
361 setVisibilityOfDomainStrucureControls();
364 void addCheckbox( final int which, final String title ) {
365 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
367 case Configuration.display_as_phylogram:
368 _display_as_phylogram_cb = new JCheckBox( title );
369 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
370 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
373 case Configuration.display_internal_data:
374 _display_internal_data = new JCheckBox( title );
375 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
376 addJCheckBox( _display_internal_data, ch_panel );
379 case Configuration.color_according_to_species:
380 _color_acc_species = new JCheckBox( title );
382 .setToolTipText( "To colorize taxonomy and sequence labels as a function of taxonomy" );
383 addJCheckBox( _color_acc_species, ch_panel );
386 case Configuration.color_according_to_annotation:
387 _color_according_to_annotation = new JCheckBox( title );
388 _color_according_to_annotation
389 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
390 addJCheckBox( _color_according_to_annotation, ch_panel );
393 case Configuration.show_node_names:
394 _show_node_names = new JCheckBox( title );
395 addJCheckBox( _show_node_names, ch_panel );
398 case Configuration.show_tax_code:
399 _show_taxo_code = new JCheckBox( title );
400 addJCheckBox( _show_taxo_code, ch_panel );
403 case Configuration.show_taxonomy_scientific_names:
404 _show_taxo_scientific_names = new JCheckBox( title );
405 addJCheckBox( _show_taxo_scientific_names, ch_panel );
408 case Configuration.show_taxonomy_common_names:
409 _show_taxo_common_names = new JCheckBox( title );
410 addJCheckBox( _show_taxo_common_names, ch_panel );
413 case Configuration.show_taxonomy_images:
414 _show_taxo_images_cb = new JCheckBox( title );
415 addJCheckBox( _show_taxo_images_cb, ch_panel );
418 case Configuration.show_binary_characters:
419 _show_binary_characters = new JCheckBox( title );
420 addJCheckBox( _show_binary_characters, ch_panel );
423 case Configuration.show_annotation:
424 _show_annotation = new JCheckBox( title );
425 addJCheckBox( _show_annotation, ch_panel );
428 case Configuration.show_binary_character_counts:
429 _show_binary_character_counts = new JCheckBox( title );
430 addJCheckBox( _show_binary_character_counts, ch_panel );
433 case Configuration.write_confidence_values:
434 _write_confidence = new JCheckBox( title );
435 addJCheckBox( getWriteConfidenceCb(), ch_panel );
438 case Configuration.write_events:
439 _show_events = new JCheckBox( title );
440 addJCheckBox( getShowEventsCb(), ch_panel );
443 case Configuration.color_branches:
444 _color_branches_cb = new JCheckBox( title );
445 getColorBranchesCb().setToolTipText( "To use branch color values, if present" );
446 addJCheckBox( getColorBranchesCb(), ch_panel );
449 case Configuration.width_branches:
450 _width_branches = new JCheckBox( title );
451 _width_branches.setToolTipText( "To use branch width values, if present" );
452 addJCheckBox( _width_branches, ch_panel );
455 case Configuration.show_domain_architectures:
456 _show_domain_architectures = new JCheckBox( title );
457 addJCheckBox( _show_domain_architectures, ch_panel );
460 case Configuration.show_gene_names:
461 _show_gene_names = new JCheckBox( title );
462 addJCheckBox( _show_gene_names, ch_panel );
465 case Configuration.show_gene_symbols:
466 _show_gene_symbols = new JCheckBox( title );
467 addJCheckBox( _show_gene_symbols, ch_panel );
470 case Configuration.show_sequence_acc:
471 _show_sequence_acc = new JCheckBox( title );
472 addJCheckBox( _show_sequence_acc, ch_panel );
475 case Configuration.dynamically_hide_data:
476 _dynamically_hide_data = new JCheckBox( title );
477 getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" );
478 addJCheckBox( getDynamicallyHideData(), ch_panel );
481 case Configuration.node_data_popup:
482 _node_desc_popup_cb = new JCheckBox( title );
483 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
484 addJCheckBox( getNodeDescPopupCb(), ch_panel );
487 case Configuration.show_relation_confidence:
488 _seq_relation_confidence_switch = new JCheckBox( title );
489 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
492 case Configuration.show_vector_data:
493 _show_vector_data_cb = new JCheckBox( title );
494 addJCheckBox( _show_vector_data_cb, ch_panel );
498 throw new RuntimeException( "unknown checkbox: " + which );
502 private void addClickToOption( final int which, final String title ) {
503 _click_to_combobox.addItem( title );
504 _click_to_names.add( title );
505 _all_click_to_names.put( new Integer( which ), title );
506 if ( !_configuration.isUseNativeUI() ) {
507 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
508 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
512 void addJButton( final JButton jb, final JPanel p ) {
513 jb.setFocusPainted( false );
514 jb.setFont( ControlPanel.jcb_font );
515 if ( !_configuration.isUseNativeUI() ) {
516 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
517 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
518 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
521 jb.addActionListener( this );
524 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
525 jcb.setFocusPainted( false );
526 jcb.setFont( ControlPanel.jcb_font );
527 if ( !_configuration.isUseNativeUI() ) {
528 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
529 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
531 p.add( jcb, "Center" );
532 jcb.addActionListener( this );
535 void addJTextField( final JTextField tf, final JPanel p ) {
536 if ( !_configuration.isUseNativeUI() ) {
537 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
538 tf.setFont( ControlPanel.jcb_font );
541 tf.addActionListener( this );
545 private void addSequenceRelationBlock() {
546 final JLabel spacer = new JLabel( "" );
547 spacer.setSize( 1, 1 );
549 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
550 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
551 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
552 getSequenceRelationTypeBox().setFocusable( false );
553 _sequence_relation_type_box.setFont( ControlPanel.js_font );
554 if ( !_configuration.isUseNativeUI() ) {
555 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
556 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
558 _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
561 public Component getListCellRendererComponent( final JList list,
564 final boolean isSelected,
565 final boolean cellHasFocus ) {
566 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
571 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
572 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
573 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
578 final GridBagLayout gbl = new GridBagLayout();
579 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
580 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
581 final JPanel horizGrid = new JPanel( gbl );
582 horizGrid.setBackground( getBackground() );
583 horizGrid.add( typeLabel );
584 horizGrid.add( _sequence_relation_type_box );
585 add( customizeLabel( mainLabel, getConfiguration() ) );
587 add( getSequenceRelationBox() );
588 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
589 addCheckbox( Configuration.show_relation_confidence, _configuration
590 .getDisplayTitle( Configuration.show_relation_confidence ) );
591 setCheckbox( Configuration.show_relation_confidence, _configuration
592 .doCheckOption( Configuration.show_relation_confidence ) );
594 }// addSequenceRelationBlock
596 void deactivateButtonToReturnToSuperTree() {
597 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
598 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
599 _return_to_super_tree.setEnabled( false );
602 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
603 if ( ( _mainpanel != null ) && ( _mainpanel.getCurrentPhylogeny() != null ) ) {
604 if ( getOptions().isShowOverview() ) {
605 _mainpanel.getCurrentTreePanel().updateOvSizes();
607 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
608 setVisibilityOfDomainStrucureControls();
609 updateDomainStructureEvaluethresholdDisplay();
610 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
611 _mainpanel.getCurrentTreePanel().calcMaxDepth();
612 _mainpanel.adjustJScrollPane();
613 if ( recalc_longest_ext_node_info ) {
614 _mainpanel.getCurrentTreePanel().initNodeData();
615 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
617 _mainpanel.getCurrentTreePanel().repaint();
618 // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
622 void endClickToOptions() {
623 _click_to_combobox.addActionListener( this );
627 * Indicates what action should be execute when a node is clicked
629 * @return the click-on action
631 NodeClickAction getActionWhenNodeClicked() {
632 return _action_when_node_clicked;
635 Map<Integer, String> getAllClickToItems() {
636 return _all_click_to_names;
639 Map<String, Color> getAnnotationColors() {
640 return _annotation_colors;
643 public JCheckBox getColorBranchesCb() {
644 return _color_branches_cb;
647 Configuration getConfiguration() {
648 return _configuration;
651 TreePanel getCurrentTreePanel() {
652 return getMainPanel().getCurrentTreePanel();
655 public JCheckBox getDisplayAsPhylogramCb() {
656 return _display_as_phylogram_cb;
659 public JCheckBox getDynamicallyHideData() {
660 return _dynamically_hide_data;
664 private List<Boolean> getIsDrawPhylogramList() {
665 return _draw_phylogram;
668 MainPanel getMainPanel() {
672 public JCheckBox getNodeDescPopupCb() {
673 return _node_desc_popup_cb;
676 Options getOptions() {
677 return getMainPanel().getOptions();
680 private JLabel getSearchFoundCountsLabel() {
681 return _search_found_label;
684 private JButton getSearchResetButton() {
685 return _search_reset_button;
688 JTextField getSearchTextField() {
692 public Sequence getSelectedQuerySequence() {
693 return _selected_query_seq;
696 public JComboBox getSequenceRelationBox() {
697 if ( _show_sequence_relations == null ) {
698 _show_sequence_relations = new JComboBox();
699 _show_sequence_relations.setFocusable( false );
700 _show_sequence_relations.setMaximumRowCount( 20 );
701 _show_sequence_relations.setFont( ControlPanel.js_font );
702 if ( !_configuration.isUseNativeUI() ) {
703 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
704 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
706 _show_sequence_relations.addItem( "-----" );
707 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
709 return _show_sequence_relations;
713 public JComboBox getSequenceRelationTypeBox() {
714 if ( _sequence_relation_type_box == null ) {
715 _sequence_relation_type_box = new JComboBox();
716 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
717 _sequence_relation_type_box.addItem( type );
719 _sequence_relation_type_box.addActionListener( new ActionListener() {
722 public void actionPerformed( final ActionEvent e ) {
723 if ( _mainpanel.getCurrentPhylogeny() != null ) {
724 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
729 return _sequence_relation_type_box;
732 public JCheckBox getShowEventsCb() {
736 List<String> getSingleClickToNames() {
737 return _click_to_names;
740 Map<String, Color> getSpeciesColors() {
741 return _species_colors;
744 public JCheckBox getWriteConfidenceCb() {
745 return _write_confidence;
748 private void init() {
749 _draw_phylogram = new ArrayList<Boolean>();
750 setSpeciesColors( new HashMap<String, Color>() );
751 setAnnotationColors( new HashMap<String, Color>() );
754 boolean isAntialiasScreenText() {
758 boolean isColorAccordingToAnnotation() {
759 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
762 boolean isColorAccordingToTaxonomy() {
763 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
766 boolean isColorBranches() {
767 return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) );
770 boolean isDrawPhylogram() {
771 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
774 private boolean isDrawPhylogram( final int index ) {
775 return getIsDrawPhylogramList().get( index );
778 boolean isDynamicallyHideData() {
779 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
783 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
786 boolean isNodeDescPopup() {
787 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
790 boolean isShowAnnotation() {
791 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
794 boolean isShowBinaryCharacterCounts() {
795 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
798 boolean isShowBinaryCharacters() {
799 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
802 boolean isShowBootstrapValues() {
803 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
806 boolean isShowDomainArchitectures() {
807 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
810 boolean isShowGeneNames() {
811 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
814 public boolean isShowVectorData() {
815 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
818 boolean isShowGeneSymbols() {
819 return ( ( _show_gene_symbols != null ) && _show_gene_symbols.isSelected() );
822 boolean isShowInternalData() {
823 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
826 boolean isShowNodeNames() {
827 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
830 boolean isShowProperty() {
831 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
834 boolean isShowSequenceAcc() {
835 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
838 boolean isShowSequenceRelationConfidence() {
839 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
842 boolean isShowSequenceRelations() {
843 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
846 boolean isShowTaxonomyCode() {
847 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
850 public boolean isShowTaxonomyImages() {
851 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
854 boolean isShowTaxonomyCommonNames() {
855 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
858 boolean isShowTaxonomyScientificNames() {
859 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
862 boolean isWidthBranches() {
863 return ( ( _width_branches != null ) && _width_branches.isSelected() );
866 void phylogenyAdded( final Configuration configuration ) {
867 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
870 void phylogenyRemoved( final int index ) {
871 getIsDrawPhylogramList().remove( index );
875 final MainPanel main_panel = getMainPanel();
876 final Phylogeny tree = main_panel.getCurrentPhylogeny();
877 if ( ( tree == null ) || tree.isEmpty() ) {
880 String query = getSearchTextField().getText();
881 if ( query != null ) {
882 query = query.trim();
885 getSearchFoundCountsLabel().setVisible( false );
886 getSearchResetButton().setEnabled( false );
887 getSearchResetButton().setVisible( false );
890 if ( !ForesterUtil.isEmpty( query ) ) {
891 search( main_panel, tree, query );
894 getSearchFoundCountsLabel().setVisible( false );
895 getSearchResetButton().setEnabled( false );
896 getSearchResetButton().setVisible( false );
901 private void search( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
902 getSearchFoundCountsLabel().setVisible( true );
903 getSearchResetButton().setEnabled( true );
904 getSearchResetButton().setVisible( true );
905 String[] queries = null;
906 List<PhylogenyNode> nodes = null;
907 if ( query_str.indexOf( ',' ) >= 0 ) {
908 queries = query_str.split( ",+" );
911 queries = new String[ 1 ];
912 queries[ 0 ] = query_str.trim();
914 if ( ( queries != null ) && ( queries.length > 0 ) ) {
915 nodes = new ArrayList<PhylogenyNode>();
916 for( String query : queries ) {
917 if ( ForesterUtil.isEmpty( query ) ) {
920 query = query.trim();
921 if ( query.indexOf( '+' ) >= 0 ) {
922 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ), tree, getOptions()
923 .isSearchCaseSensitive(), !getOptions().isMatchWholeTermsOnly() ) );
926 nodes.addAll( PhylogenyMethods.searchData( query,
928 getOptions().isSearchCaseSensitive(),
929 !getOptions().isMatchWholeTermsOnly() ) );
932 if ( getOptions().isInverseSearchResult() ) {
933 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
934 all.removeAll( nodes );
938 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
939 main_panel.getCurrentTreePanel().setFoundNodes( new HashSet<Integer>() );
940 for( final PhylogenyNode node : nodes ) {
941 main_panel.getCurrentTreePanel().getFoundNodes().add( node.getId() );
943 setSearchFoundCountsOnLabel( nodes.size() );
946 setSearchFoundCountsOnLabel( 0 );
951 private void searchReset() {
952 if ( getMainPanel().getCurrentTreePanel() != null ) {
953 getMainPanel().getCurrentTreePanel().setFoundNodes( null );
957 void setActionWhenNodeClicked( final NodeClickAction action ) {
958 _action_when_node_clicked = action;
961 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
962 _annotation_colors = annotation_colors;
965 void setCheckbox( final int which, final boolean state ) {
967 case Configuration.display_as_phylogram:
968 if ( getDisplayAsPhylogramCb() != null ) {
969 getDisplayAsPhylogramCb().setSelected( state );
972 case Configuration.display_internal_data:
973 if ( _display_internal_data != null ) {
974 _display_internal_data.setSelected( state );
977 case Configuration.color_according_to_species:
978 if ( _color_acc_species != null ) {
979 _color_acc_species.setSelected( state );
982 case Configuration.color_according_to_annotation:
983 if ( _color_according_to_annotation != null ) {
984 _color_according_to_annotation.setSelected( state );
987 case Configuration.show_node_names:
988 if ( _show_node_names != null ) {
989 _show_node_names.setSelected( state );
992 case Configuration.show_tax_code:
993 if ( _show_taxo_code != null ) {
994 _show_taxo_code.setSelected( state );
997 case Configuration.show_taxonomy_scientific_names:
998 if ( _show_taxo_scientific_names != null ) {
999 _show_taxo_scientific_names.setSelected( state );
1002 case Configuration.show_taxonomy_common_names:
1003 if ( _show_taxo_common_names != null ) {
1004 _show_taxo_common_names.setSelected( state );
1007 case Configuration.show_taxonomy_images:
1008 if ( _show_taxo_images_cb != null ) {
1009 _show_taxo_images_cb.setSelected( state );
1012 case Configuration.show_annotation:
1013 if ( _show_annotation != null ) {
1014 _show_annotation.setSelected( state );
1017 case Configuration.show_binary_characters:
1018 if ( _show_binary_characters != null ) {
1019 _show_binary_characters.setSelected( state );
1022 case Configuration.show_binary_character_counts:
1023 if ( _show_binary_character_counts != null ) {
1024 _show_binary_character_counts.setSelected( state );
1027 case Configuration.write_confidence_values:
1028 if ( getWriteConfidenceCb() != null ) {
1029 getWriteConfidenceCb().setSelected( state );
1032 case Configuration.write_events:
1033 if ( getShowEventsCb() != null ) {
1034 getShowEventsCb().setSelected( state );
1037 case Configuration.color_branches:
1038 if ( getColorBranchesCb() != null ) {
1039 getColorBranchesCb().setSelected( state );
1042 case Configuration.width_branches:
1043 if ( _width_branches != null ) {
1044 _width_branches.setSelected( state );
1047 case Configuration.show_domain_architectures:
1048 if ( _show_domain_architectures != null ) {
1049 _show_domain_architectures.setSelected( state );
1052 case Configuration.show_gene_names:
1053 if ( _show_gene_names != null ) {
1054 _show_gene_names.setSelected( state );
1057 case Configuration.show_gene_symbols:
1058 if ( _show_gene_symbols != null ) {
1059 _show_gene_symbols.setSelected( state );
1062 case Configuration.show_vector_data:
1063 if ( _show_vector_data_cb != null ) {
1064 _show_vector_data_cb.setSelected( state );
1067 case Configuration.show_sequence_acc:
1068 if ( _show_sequence_acc != null ) {
1069 _show_sequence_acc.setSelected( state );
1072 case Configuration.dynamically_hide_data:
1073 if ( getDynamicallyHideData() != null ) {
1074 getDynamicallyHideData().setSelected( state );
1077 case Configuration.node_data_popup:
1078 if ( getNodeDescPopupCb() != null ) {
1079 getNodeDescPopupCb().setSelected( state );
1083 case Configuration.show_relation_confidence:
1084 if ( _seq_relation_confidence_switch != null ) {
1085 _seq_relation_confidence_switch.setSelected( state );
1090 throw new AssertionError( "unknown checkbox: " + which );
1095 * Set this checkbox state. Not all checkboxes have been instantiated
1096 * depending on the config.
1098 void setCheckbox( final JCheckBox cb, final boolean state ) {
1100 cb.setSelected( state );
1104 void setClickToAction( final int action ) {
1105 // Set click-to action
1106 if ( action == _show_data_item ) {
1107 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1109 else if ( action == _collapse_cb_item ) {
1110 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1112 else if ( action == _reroot_cb_item ) {
1113 setActionWhenNodeClicked( NodeClickAction.REROOT );
1115 else if ( action == _subtree_cb_item ) {
1116 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1118 else if ( action == _swap_cb_item ) {
1119 setActionWhenNodeClicked( NodeClickAction.SWAP );
1121 else if ( action == _color_subtree_cb_item ) {
1122 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1124 else if ( action == _open_seq_web_item ) {
1125 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1127 else if ( action == _blast_item ) {
1128 if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
1129 setActionWhenNodeClicked( NodeClickAction.BLAST );
1132 else if ( action == _open_tax_web_item ) {
1133 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1135 else if ( action == _cut_subtree_item ) {
1136 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1138 else if ( action == _copy_subtree_item ) {
1139 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1141 else if ( action == _delete_node_or_subtree_item ) {
1142 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1144 else if ( action == _paste_subtree_item ) {
1145 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1147 else if ( action == _add_new_node_item ) {
1148 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1150 else if ( action == _edit_node_data_item ) {
1151 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1154 throw new RuntimeException( "unknown action: " + action );
1156 // make sure drop down is displaying the correct action
1157 // in case this was called from outside the class
1158 _click_to_combobox.setSelectedIndex( action );
1161 void setColorBranches( final boolean color_branches ) {
1162 _color_branches = color_branches;
1165 void setDrawPhylogram( final boolean b ) {
1166 getDisplayAsPhylogramCb().setSelected( b );
1167 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1170 private void setDrawPhylogram( final int index, final boolean b ) {
1171 getIsDrawPhylogramList().set( index, b );
1174 void setDrawPhylogramEnabled( final boolean b ) {
1175 getDisplayAsPhylogramCb().setEnabled( b );
1178 void setDynamicHidingIsOn( final boolean is_on ) {
1179 // if ( !_configuration.isUseNativeUI() ) {
1181 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1184 if ( !_configuration.isUseNativeUI() ) {
1185 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1188 getDynamicallyHideData().setForeground( Color.BLACK );
1194 private void setSearchFoundCountsOnLabel( final int counts ) {
1195 getSearchFoundCountsLabel().setText( "Found: " + counts );
1198 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
1199 final JComboBox box = getSequenceRelationBox();
1200 while ( box.getItemCount() > 1 ) {
1201 box.removeItemAt( 1 );
1203 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
1204 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
1206 if ( relationType == null ) {
1209 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
1210 for( final Sequence seq : sequenceRelationQueries ) {
1211 if ( seq.hasSequenceRelations() ) {
1212 boolean fFoundForCurrentType = false;
1213 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
1214 if ( sq.getType().equals( relationType ) ) {
1215 fFoundForCurrentType = true;
1219 if ( fFoundForCurrentType ) {
1220 sequenceNamesToAdd.add( seq.getName() );
1221 sequencesByName.put( seq.getName(), seq );
1225 // sort sequences by name before adding them to the combo
1226 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
1227 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
1228 for( final String seqName : sequenceNameArray ) {
1229 box.addItem( seqName );
1231 for( final ItemListener oldItemListener : box.getItemListeners() ) {
1232 box.removeItemListener( oldItemListener );
1234 box.addItemListener( new ItemListener() {
1237 public void itemStateChanged( final ItemEvent e ) {
1238 _selected_query_seq = sequencesByName.get( e.getItem() );
1239 _mainpanel.getCurrentTreePanel().repaint();
1244 void setShowEvents( final boolean show_events ) {
1245 if ( getShowEventsCb() == null ) {
1246 _show_events = new JCheckBox( "" );
1248 getShowEventsCb().setSelected( show_events );
1251 void setSpeciesColors( final Map<String, Color> species_colors ) {
1252 _species_colors = species_colors;
1255 private void setupClickToOptions() {
1256 final int default_option = _configuration.getDefaultDisplayClicktoOption();
1257 int selected_index = 0;
1259 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1260 _show_data_item = cb_index;
1261 addClickToOption( Configuration.display_node_data, _configuration
1262 .getClickToTitle( Configuration.display_node_data ) );
1263 if ( default_option == Configuration.display_node_data ) {
1264 selected_index = cb_index;
1268 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1269 _collapse_cb_item = cb_index;
1270 addClickToOption( Configuration.collapse_uncollapse, _configuration
1271 .getClickToTitle( Configuration.collapse_uncollapse ) );
1272 if ( default_option == Configuration.collapse_uncollapse ) {
1273 selected_index = cb_index;
1277 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1278 _reroot_cb_item = cb_index;
1279 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1280 if ( default_option == Configuration.reroot ) {
1281 selected_index = cb_index;
1285 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1286 _subtree_cb_item = cb_index;
1287 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1288 if ( default_option == Configuration.subtree ) {
1289 selected_index = cb_index;
1293 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1294 _swap_cb_item = cb_index;
1295 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1296 if ( default_option == Configuration.swap ) {
1297 selected_index = cb_index;
1301 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1302 _color_subtree_cb_item = cb_index;
1303 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1304 if ( default_option == Configuration.color_subtree ) {
1305 selected_index = cb_index;
1309 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1310 _open_seq_web_item = cb_index;
1311 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1312 if ( default_option == Configuration.open_seq_web ) {
1313 selected_index = cb_index;
1317 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1318 _open_tax_web_item = cb_index;
1319 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1320 if ( default_option == Configuration.open_tax_web ) {
1321 selected_index = cb_index;
1325 if ( getOptions().isEditable() ) {
1326 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
1327 _cut_subtree_item = cb_index;
1328 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
1329 if ( default_option == Configuration.cut_subtree ) {
1330 selected_index = cb_index;
1334 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
1335 _copy_subtree_item = cb_index;
1336 addClickToOption( Configuration.copy_subtree, _configuration
1337 .getClickToTitle( Configuration.copy_subtree ) );
1338 if ( default_option == Configuration.copy_subtree ) {
1339 selected_index = cb_index;
1343 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
1344 _paste_subtree_item = cb_index;
1345 addClickToOption( Configuration.paste_subtree, _configuration
1346 .getClickToTitle( Configuration.paste_subtree ) );
1347 if ( default_option == Configuration.paste_subtree ) {
1348 selected_index = cb_index;
1352 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
1353 _delete_node_or_subtree_item = cb_index;
1354 addClickToOption( Configuration.delete_subtree_or_node, _configuration
1355 .getClickToTitle( Configuration.delete_subtree_or_node ) );
1356 if ( default_option == Configuration.delete_subtree_or_node ) {
1357 selected_index = cb_index;
1361 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
1362 _add_new_node_item = cb_index;
1363 addClickToOption( Configuration.add_new_node, _configuration
1364 .getClickToTitle( Configuration.add_new_node ) );
1365 if ( default_option == Configuration.add_new_node ) {
1366 selected_index = cb_index;
1370 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
1371 _edit_node_data_item = cb_index;
1372 addClickToOption( Configuration.edit_node_data, _configuration
1373 .getClickToTitle( Configuration.edit_node_data ) );
1374 if ( default_option == Configuration.edit_node_data ) {
1375 selected_index = cb_index;
1379 if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
1380 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1381 _blast_item = cb_index;
1382 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
1383 if ( default_option == Configuration.blast ) {
1384 selected_index = cb_index;
1390 // Set default selection and its action
1391 _click_to_combobox.setSelectedIndex( selected_index );
1392 setClickToAction( selected_index );
1397 * Set up the controls from the config settings. 11/26/05
1399 void setupControls() {
1400 // The tree display options:
1401 setupDisplayCheckboxes();
1403 // The sequence relation query selection combo-box
1404 if ( _configuration.displaySequenceRelations() ) {
1405 addSequenceRelationBlock();
1409 startClickToOptions();
1410 setupClickToOptions();
1411 endClickToOptions();
1412 // Zoom and quick edit buttons
1417 void setUpControlsForDomainStrucures() {
1418 _domain_display_label = new JLabel( "Domain Display:" );
1419 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1420 add( _domain_display_label );
1421 _zoom_in_domain_structure = new JButton( "d+" );
1422 _zoom_out_domain_structure = new JButton( "d-" );
1423 _decr_domain_structure_evalue_thr = new JButton( "-" );
1424 _incr_domain_structure_evalue_thr = new JButton( "+" );
1425 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1426 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1427 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1428 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1429 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1430 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1431 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1432 _domain_structure_evalue_thr_tf.setEditable( false );
1433 if ( !getConfiguration().isUseNativeUI() ) {
1434 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1435 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1436 _domain_structure_evalue_thr_tf.setBorder( null );
1438 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1439 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1440 if ( !_configuration.isUseNativeUI() ) {
1441 d1_panel.setBackground( getBackground() );
1442 d2_panel.setBackground( getBackground() );
1446 addJButton( _zoom_out_domain_structure, d1_panel );
1447 addJButton( _zoom_in_domain_structure, d1_panel );
1448 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1449 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1450 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1453 private void setupDisplayCheckboxes() {
1454 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
1455 addCheckbox( Configuration.display_as_phylogram, _configuration
1456 .getDisplayTitle( Configuration.display_as_phylogram ) );
1457 setCheckbox( Configuration.display_as_phylogram, _configuration
1458 .doCheckOption( Configuration.display_as_phylogram ) );
1460 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1461 addCheckbox( Configuration.dynamically_hide_data, _configuration
1462 .getDisplayTitle( Configuration.dynamically_hide_data ) );
1463 setCheckbox( Configuration.dynamically_hide_data, _configuration
1464 .doCheckOption( Configuration.dynamically_hide_data ) );
1466 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1467 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1468 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1470 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1471 addCheckbox( Configuration.display_internal_data, _configuration
1472 .getDisplayTitle( Configuration.display_internal_data ) );
1473 setCheckbox( Configuration.display_internal_data, _configuration
1474 .doCheckOption( Configuration.display_internal_data ) );
1476 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1477 addCheckbox( Configuration.color_according_to_species, _configuration
1478 .getDisplayTitle( Configuration.color_according_to_species ) );
1479 setCheckbox( Configuration.color_according_to_species, _configuration
1480 .doCheckOption( Configuration.color_according_to_species ) );
1482 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1483 addCheckbox( Configuration.color_according_to_annotation, _configuration
1484 .getDisplayTitle( Configuration.color_according_to_annotation ) );
1485 setCheckbox( Configuration.color_according_to_annotation, _configuration
1486 .doCheckOption( Configuration.color_according_to_annotation ) );
1488 if ( _configuration.doDisplayOption( Configuration.color_branches ) ) {
1489 addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) );
1490 setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) );
1492 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1493 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1494 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1496 final JLabel label = new JLabel( "Display Data:" );
1497 label.setFont( ControlPanel.jcb_bold_font );
1498 if ( !getConfiguration().isUseNativeUI() ) {
1499 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1502 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1503 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
1504 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1506 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1507 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1508 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1510 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1511 addCheckbox( Configuration.show_taxonomy_scientific_names, _configuration
1512 .getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1513 setCheckbox( Configuration.show_taxonomy_scientific_names, _configuration
1514 .doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1516 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1517 addCheckbox( Configuration.show_taxonomy_common_names, _configuration
1518 .getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1519 setCheckbox( Configuration.show_taxonomy_common_names, _configuration
1520 .doCheckOption( Configuration.show_taxonomy_common_names ) );
1522 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1523 addCheckbox( Configuration.show_taxonomy_images, _configuration
1524 .getDisplayTitle( Configuration.show_taxonomy_images ) );
1525 setCheckbox( Configuration.show_taxonomy_images, _configuration
1526 .doCheckOption( Configuration.show_taxonomy_images ) );
1528 if ( _configuration.doDisplayOption( Configuration.show_gene_symbols ) ) {
1529 addCheckbox( Configuration.show_gene_symbols, _configuration
1530 .getDisplayTitle( Configuration.show_gene_symbols ) );
1531 setCheckbox( Configuration.show_gene_symbols, _configuration
1532 .doCheckOption( Configuration.show_gene_symbols ) );
1534 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1535 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1536 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1538 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1539 addCheckbox( Configuration.show_sequence_acc, _configuration
1540 .getDisplayTitle( Configuration.show_sequence_acc ) );
1541 setCheckbox( Configuration.show_sequence_acc, _configuration
1542 .doCheckOption( Configuration.show_sequence_acc ) );
1544 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1545 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
1546 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1548 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1549 addCheckbox( Configuration.show_binary_characters, _configuration
1550 .getDisplayTitle( Configuration.show_binary_characters ) );
1551 setCheckbox( Configuration.show_binary_characters, _configuration
1552 .doCheckOption( Configuration.show_binary_characters ) );
1554 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1555 addCheckbox( Configuration.show_binary_character_counts, _configuration
1556 .getDisplayTitle( Configuration.show_binary_character_counts ) );
1557 setCheckbox( Configuration.show_binary_character_counts, _configuration
1558 .doCheckOption( Configuration.show_binary_character_counts ) );
1560 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1561 addCheckbox( Configuration.show_domain_architectures, _configuration
1562 .getDisplayTitle( Configuration.show_domain_architectures ) );
1563 setCheckbox( Configuration.show_domain_architectures, _configuration
1564 .doCheckOption( Configuration.show_domain_architectures ) );
1566 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1567 addCheckbox( Configuration.write_confidence_values, _configuration
1568 .getDisplayTitle( Configuration.write_confidence_values ) );
1569 setCheckbox( Configuration.write_confidence_values, _configuration
1570 .doCheckOption( Configuration.write_confidence_values ) );
1572 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1573 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1574 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1576 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1577 addCheckbox( Configuration.show_vector_data, _configuration
1578 .getDisplayTitle( Configuration.show_vector_data ) );
1579 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
1583 void setupSearchTools() {
1584 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1585 final JLabel search_label = new JLabel( "Search:" );
1586 search_label.setFont( ControlPanel.jcb_bold_font );
1587 if ( !getConfiguration().isUseNativeUI() ) {
1588 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1590 add( search_label );
1591 search_label.setToolTipText( tip );
1592 _search_found_label = new JLabel();
1593 getSearchFoundCountsLabel().setVisible( false );
1594 _search_found_label.setFont( ControlPanel.jcb_bold_font );
1595 if ( !getConfiguration().isUseNativeUI() ) {
1596 _search_found_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1598 _search_tf = new JTextField( 3 );
1599 _search_tf.setToolTipText( tip );
1600 _search_tf.setEditable( true );
1601 if ( !getConfiguration().isUseNativeUI() ) {
1602 _search_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1603 _search_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1604 _search_tf.setBorder( null );
1606 _search_reset_button = new JButton();
1607 getSearchResetButton().setText( "Reset" );
1608 getSearchResetButton().setEnabled( false );
1609 getSearchResetButton().setVisible( false );
1610 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1611 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1612 s_panel_1.setBackground( getBackground() );
1614 s_panel_2.setBackground( getBackground() );
1616 final KeyAdapter key_adapter = new KeyAdapter() {
1619 public void keyReleased( final KeyEvent key_event ) {
1621 displayedPhylogenyMightHaveChanged( true );
1624 final ActionListener action_listener = new ActionListener() {
1627 public void actionPerformed( final ActionEvent e ) {
1629 setSearchFoundCountsOnLabel( 0 );
1630 getSearchFoundCountsLabel().setVisible( false );
1631 getSearchTextField().setText( "" );
1632 getSearchResetButton().setEnabled( false );
1633 getSearchResetButton().setVisible( false );
1634 displayedPhylogenyMightHaveChanged( true );
1637 _search_reset_button.addActionListener( action_listener );
1638 _search_tf.addKeyListener( key_adapter );
1639 addJTextField( _search_tf, s_panel_1 );
1640 s_panel_2.add( _search_found_label );
1641 addJButton( _search_reset_button, s_panel_2 );
1644 private void setVisibilityOfDomainStrucureControls() {
1645 if ( _zoom_in_domain_structure != null ) {
1646 if ( isShowDomainArchitectures() ) {
1647 _domain_display_label.setVisible( true );
1648 _zoom_in_domain_structure.setVisible( true );
1649 _zoom_out_domain_structure.setVisible( true );
1650 _decr_domain_structure_evalue_thr.setVisible( true );
1651 _incr_domain_structure_evalue_thr.setVisible( true );
1652 _domain_structure_evalue_thr_tf.setVisible( true );
1655 _domain_display_label.setVisible( false );
1656 _zoom_in_domain_structure.setVisible( false );
1657 _zoom_out_domain_structure.setVisible( false );
1658 _decr_domain_structure_evalue_thr.setVisible( false );
1659 _incr_domain_structure_evalue_thr.setVisible( false );
1660 _domain_structure_evalue_thr_tf.setVisible( false );
1666 * Fit entire tree into window.
1669 if ( _mainpanel.getCurrentScrollPane() == null ) {
1672 displayedPhylogenyMightHaveChanged( false );
1673 _mainpanel.getCurrentTreePanel().updateOvSettings();
1674 _mainpanel.getCurrentTreePanel().validate();
1675 _mainpanel.validate();
1676 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1677 _mainpanel.getSizeOfViewport().height,
1679 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1680 _mainpanel.adjustJScrollPane();
1681 _mainpanel.getCurrentTreePanel().repaint();
1682 _mainpanel.getCurrentTreePanel().validate();
1683 _mainpanel.validate();
1684 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1685 _mainpanel.getSizeOfViewport().height,
1687 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1688 _mainpanel.adjustJScrollPane();
1689 _mainpanel.getCurrentTreePanel().repaint();
1690 _mainpanel.getCurrentTreePanel().updateOvSizes();
1693 void showWholeAll() {
1694 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1695 if ( tree_panel != null ) {
1696 tree_panel.validate();
1697 tree_panel.setParametersForPainting( _mainpanel.getSizeOfViewport().width, _mainpanel
1698 .getSizeOfViewport().height, true );
1699 tree_panel.resetPreferredSize();
1700 tree_panel.repaint();
1705 // Create header for click-to combo box.
1706 void startClickToOptions() {
1707 final JLabel spacer = new JLabel( "" );
1708 spacer.setFont( ControlPanel.jcb_font );
1710 _click_to_label = new JLabel( "Click on Node to:" );
1711 add( customizeLabel( _click_to_label, getConfiguration() ) );
1712 _click_to_combobox = new JComboBox();
1713 _click_to_combobox.setFocusable( false );
1714 _click_to_combobox.setMaximumRowCount( 14 );
1715 _click_to_combobox.setFont( ControlPanel.js_font );
1716 if ( !_configuration.isUseNativeUI() ) {
1717 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1719 // don't add listener until all items are set (or each one will trigger
1721 // click_to_list.addActionListener(this);
1722 add( _click_to_combobox );
1723 // Correlates option names to titles
1724 _all_click_to_names = new HashMap<Integer, String>();
1725 _click_to_names = new ArrayList<String>();
1729 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1730 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1731 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1732 setDrawPhylogramEnabled( true );
1733 setDrawPhylogram( isDrawPhylogram() );
1736 setDrawPhylogramEnabled( false );
1737 setDrawPhylogram( false );
1739 if ( getMainPanel().getMainFrame() == null ) {
1740 // Must be "E" applet version.
1741 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1742 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1745 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1746 .getPhylogenyGraphicsType() );
1748 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1749 getMainPanel().getControlPanel().search();
1750 getSequenceRelationTypeBox().removeAllItems();
1751 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1752 .getRelevantSequenceRelationTypes() ) {
1753 _sequence_relation_type_box.addItem( type );
1755 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1756 // according to GUILHEM the line above can be removed.
1761 * Uncollapse all nodes.
1763 void uncollapseAll( final TreePanel tp ) {
1764 final Phylogeny t = tp.getPhylogeny();
1765 if ( ( t != null ) && !t.isEmpty() ) {
1766 t.setAllNodesToNotCollapse();
1767 t.recalculateNumberOfExternalDescendants( false );
1772 void updateDomainStructureEvaluethresholdDisplay() {
1773 if ( _domain_structure_evalue_thr_tf != null ) {
1774 _domain_structure_evalue_thr_tf.setText( "10^"
1775 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1779 void zoomInX( final float factor, final float x_correction_factor ) {
1780 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1781 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1782 treepanel.multiplyUrtFactor( 1f );
1783 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1784 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1785 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1786 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1787 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1788 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1789 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1790 getMainPanel().adjustJScrollPane();
1791 treepanel.resetPreferredSize();
1792 getMainPanel().getCurrentScrollPane().getViewport().validate();
1793 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1794 - ( sb.getVisibleAmount() / 2.0 ) ) );
1797 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1798 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1799 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1800 getMainPanel().adjustJScrollPane();
1801 treepanel.resetPreferredSize();
1802 getMainPanel().getCurrentScrollPane().getViewport().validate();
1803 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1805 treepanel.resetPreferredSize();
1806 treepanel.updateOvSizes();
1809 void zoomInY( final float factor ) {
1810 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1811 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1812 treepanel.multiplyUrtFactor( 1.1f );
1813 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1814 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1815 getMainPanel().adjustJScrollPane();
1816 treepanel.resetPreferredSize();
1817 getMainPanel().getCurrentScrollPane().getViewport().validate();
1818 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1819 - ( sb.getVisibleAmount() / 2.0 ) ) );
1820 treepanel.resetPreferredSize();
1821 treepanel.updateOvSizes();
1824 void zoomOutX( final float factor, final float x_correction_factor ) {
1825 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1826 treepanel.multiplyUrtFactor( 1f );
1827 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1828 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1829 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1830 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1831 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1832 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1833 getMainPanel().adjustJScrollPane();
1834 treepanel.resetPreferredSize();
1835 getMainPanel().getCurrentScrollPane().getViewport().validate();
1836 final double x = ( sb.getMaximum() - sb.getMinimum() )
1837 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1838 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1839 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1840 getMainPanel().adjustJScrollPane();
1841 treepanel.resetPreferredSize();
1842 getMainPanel().getCurrentScrollPane().getViewport().validate();
1843 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1844 - ( sb.getVisibleAmount() / 2.0 ) ) );
1847 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1848 treepanel.setXdistance( treepanel.getXdistance() * factor );
1849 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
1851 getMainPanel().adjustJScrollPane();
1852 treepanel.resetPreferredSize();
1853 getMainPanel().getCurrentScrollPane().getViewport().validate();
1854 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1857 treepanel.resetPreferredSize();
1858 treepanel.updateOvSizes();
1862 void zoomOutY( final float factor ) {
1863 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1864 treepanel.multiplyUrtFactor( 0.9f );
1865 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1866 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1867 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1868 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1869 getMainPanel().adjustJScrollPane();
1870 treepanel.resetPreferredSize();
1871 getMainPanel().getCurrentScrollPane().getViewport().validate();
1872 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1873 - ( sb.getVisibleAmount() / 2.0 ) ) );
1874 treepanel.resetPreferredSize();
1875 treepanel.updateOvSizes();
1879 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
1880 label.setFont( ControlPanel.jcb_bold_font );
1881 if ( !configuration.isUseNativeUI() ) {
1882 label.setForeground( configuration.getGuiCheckboxTextColor() );
1883 label.setBackground( configuration.getGuiBackgroundColor() );
1888 enum NodeClickAction {
1899 DELETE_NODE_OR_SUBTREE,