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;
176 public void actionPerformed( final ActionEvent e ) {
178 final TreePanel tp = getMainPanel().getCurrentTreePanel();
182 if ( e.getSource() == _click_to_combobox ) {
183 setClickToAction( _click_to_combobox.getSelectedIndex() );
184 getCurrentTreePanel().repaint();
186 else if ( e.getSource() == _show_binary_characters ) {
187 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
188 _show_binary_character_counts.setSelected( false );
190 displayedPhylogenyMightHaveChanged( true );
192 else if ( e.getSource() == _show_binary_character_counts ) {
193 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
194 _show_binary_characters.setSelected( false );
196 displayedPhylogenyMightHaveChanged( true );
198 else if ( e.getSource() == _color_according_to_annotation ) {
199 if ( ( _show_annotation != null ) && _color_according_to_annotation.isSelected() ) {
200 _show_annotation.setSelected( true );
202 displayedPhylogenyMightHaveChanged( false );
204 else if ( e.getSource() == _show_annotation ) {
205 if ( ( _color_according_to_annotation != null ) && !_show_annotation.isSelected() ) {
206 _color_according_to_annotation.setSelected( false );
208 displayedPhylogenyMightHaveChanged( false );
210 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
211 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
212 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
216 else if ( e.getSource() == _zoom_in_x ) {
217 zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
218 displayedPhylogenyMightHaveChanged( false );
220 else if ( e.getSource() == _zoom_in_y ) {
221 zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR );
222 displayedPhylogenyMightHaveChanged( false );
224 else if ( e.getSource() == _zoom_out_x ) {
225 zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
226 displayedPhylogenyMightHaveChanged( false );
228 else if ( e.getSource() == _zoom_out_y ) {
229 zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR );
230 displayedPhylogenyMightHaveChanged( false );
232 else if ( e.getSource() == _show_whole ) {
235 else if ( e.getSource() == _return_to_super_tree ) {
236 _mainpanel.getCurrentTreePanel().superTree();
239 else if ( e.getSource() == _order ) {
240 tp.getPhylogeny().orderAppearance( _order_of_appearance );
241 _order_of_appearance = !_order_of_appearance;
242 displayedPhylogenyMightHaveChanged( false );
244 else if ( e.getSource() == _uncollapse_all ) {
246 displayedPhylogenyMightHaveChanged( false );
248 else if ( e.getSource() == _zoom_in_domain_structure ) {
249 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
250 displayedPhylogenyMightHaveChanged( true );
252 else if ( e.getSource() == _zoom_out_domain_structure ) {
253 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
254 displayedPhylogenyMightHaveChanged( true );
256 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
257 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThreshold();
258 displayedPhylogenyMightHaveChanged( true );
260 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
261 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThreshold();
262 displayedPhylogenyMightHaveChanged( true );
264 else if ( e.getSource() == _search_tf ) {
266 displayedPhylogenyMightHaveChanged( true );
269 displayedPhylogenyMightHaveChanged( true );
273 tp.requestFocusInWindow();
276 catch ( final Exception ex ) {
277 Util.unexpectedException( ex );
279 catch ( final Error err ) {
280 Util.unexpectedError( err );
284 void activateButtonToReturnToSuperTree( int index ) {
287 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
290 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
292 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
293 _return_to_super_tree.setEnabled( true );
297 * Add zoom and quick edit buttons. (Last modified 8/9/04)
300 final JLabel spacer = new JLabel( "" );
301 spacer.setOpaque( false );
303 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
304 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
305 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
306 if ( !getConfiguration().isUseNativeUI() ) {
307 x_panel.setBackground( getBackground() );
308 y_panel.setBackground( getBackground() );
309 z_panel.setBackground( getBackground() );
311 add( _zoom_label = new JLabel( "Zoom:" ) );
312 customizeLabel( _zoom_label, getConfiguration() );
316 if ( getConfiguration().isUseNativeUI() ) {
317 _zoom_in_x = new JButton( "+" );
318 _zoom_out_x = new JButton( "-" );
321 _zoom_in_x = new JButton( "X+" );
322 _zoom_out_x = new JButton( "X-" );
324 _zoom_in_y = new JButton( "Y+" );
325 _zoom_out_y = new JButton( "Y-" );
326 _show_whole = new JButton( "F" );
327 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [Backspace]" );
328 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+Right]" );
329 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+Up]" );
330 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+Left]" );
331 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+Down]" );
332 if ( getConfiguration().isUseNativeUI() && Util.isMac() ) {
333 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
334 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
337 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
338 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
340 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
341 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
342 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
343 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
344 _return_to_super_tree.setEnabled( false );
345 _order = new JButton( "Order Subtrees" );
346 _uncollapse_all = new JButton( "Uncollapse All" );
347 addJButton( _zoom_in_y, x_panel );
348 addJButton( _zoom_out_x, y_panel );
349 addJButton( _show_whole, y_panel );
350 addJButton( _zoom_in_x, y_panel );
351 addJButton( _zoom_out_y, z_panel );
352 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
353 setUpControlsForDomainStrucures();
355 final JLabel spacer2 = new JLabel( "" );
357 addJButton( _return_to_super_tree, this );
358 addJButton( _order, this );
359 addJButton( _uncollapse_all, this );
360 final JLabel spacer3 = new JLabel( "" );
362 setVisibilityOfDomainStrucureControls();
365 void addCheckbox( final int which, final String title ) {
366 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
368 case Configuration.display_as_phylogram:
369 _display_as_phylogram_cb = new JCheckBox( title );
370 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
371 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
374 case Configuration.display_internal_data:
375 _display_internal_data = new JCheckBox( title );
376 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
377 addJCheckBox( _display_internal_data, ch_panel );
380 case Configuration.color_according_to_species:
381 _color_acc_species = new JCheckBox( title );
383 .setToolTipText( "To colorize taxonomy and sequence labels as a function of taxonomy" );
384 addJCheckBox( _color_acc_species, ch_panel );
387 case Configuration.color_according_to_annotation:
388 _color_according_to_annotation = new JCheckBox( title );
389 _color_according_to_annotation
390 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
391 addJCheckBox( _color_according_to_annotation, ch_panel );
394 case Configuration.show_node_names:
395 _show_node_names = new JCheckBox( title );
396 addJCheckBox( _show_node_names, ch_panel );
399 case Configuration.show_tax_code:
400 _show_taxo_code = new JCheckBox( title );
401 addJCheckBox( _show_taxo_code, ch_panel );
404 case Configuration.show_taxonomy_scientific_names:
405 _show_taxo_scientific_names = new JCheckBox( title );
406 addJCheckBox( _show_taxo_scientific_names, ch_panel );
409 case Configuration.show_taxonomy_common_names:
410 _show_taxo_common_names = new JCheckBox( title );
411 addJCheckBox( _show_taxo_common_names, ch_panel );
414 case Configuration.show_taxonomy_images:
415 _show_taxo_images_cb = new JCheckBox( title );
416 addJCheckBox( _show_taxo_images_cb, ch_panel );
419 case Configuration.show_binary_characters:
420 _show_binary_characters = new JCheckBox( title );
421 addJCheckBox( _show_binary_characters, ch_panel );
424 case Configuration.show_annotation:
425 _show_annotation = new JCheckBox( title );
426 addJCheckBox( _show_annotation, ch_panel );
429 case Configuration.show_binary_character_counts:
430 _show_binary_character_counts = new JCheckBox( title );
431 addJCheckBox( _show_binary_character_counts, ch_panel );
434 case Configuration.write_confidence_values:
435 _write_confidence = new JCheckBox( title );
436 addJCheckBox( getWriteConfidenceCb(), ch_panel );
439 case Configuration.write_events:
440 _show_events = new JCheckBox( title );
441 addJCheckBox( getShowEventsCb(), ch_panel );
444 case Configuration.color_branches:
445 _color_branches_cb = new JCheckBox( title );
446 getColorBranchesCb().setToolTipText( "To use branch color values, if present" );
447 addJCheckBox( getColorBranchesCb(), ch_panel );
450 case Configuration.width_branches:
451 _width_branches = new JCheckBox( title );
452 _width_branches.setToolTipText( "To use branch width values, if present" );
453 addJCheckBox( _width_branches, ch_panel );
456 case Configuration.show_domain_architectures:
457 _show_domain_architectures = new JCheckBox( title );
458 addJCheckBox( _show_domain_architectures, ch_panel );
461 case Configuration.show_gene_names:
462 _show_gene_names = new JCheckBox( title );
463 addJCheckBox( _show_gene_names, ch_panel );
466 case Configuration.show_gene_symbols:
467 _show_gene_symbols = new JCheckBox( title );
468 addJCheckBox( _show_gene_symbols, ch_panel );
471 case Configuration.show_sequence_acc:
472 _show_sequence_acc = new JCheckBox( title );
473 addJCheckBox( _show_sequence_acc, ch_panel );
476 case Configuration.dynamically_hide_data:
477 _dynamically_hide_data = new JCheckBox( title );
478 getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" );
479 addJCheckBox( getDynamicallyHideData(), ch_panel );
482 case Configuration.node_data_popup:
483 _node_desc_popup_cb = new JCheckBox( title );
484 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
485 addJCheckBox( getNodeDescPopupCb(), ch_panel );
488 case Configuration.show_relation_confidence:
489 _seq_relation_confidence_switch = new JCheckBox( title );
490 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
493 case Configuration.show_vector_data:
494 _show_vector_data_cb = new JCheckBox( title );
495 addJCheckBox( _show_vector_data_cb, ch_panel );
499 throw new RuntimeException( "unknown checkbox: " + which );
503 private void addClickToOption( final int which, final String title ) {
504 _click_to_combobox.addItem( title );
505 _click_to_names.add( title );
506 _all_click_to_names.put( new Integer( which ), title );
507 if ( !_configuration.isUseNativeUI() ) {
508 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
509 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
513 void addJButton( final JButton jb, final JPanel p ) {
514 jb.setFocusPainted( false );
515 jb.setFont( ControlPanel.jcb_font );
516 if ( !_configuration.isUseNativeUI() ) {
517 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
518 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
519 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
522 jb.addActionListener( this );
525 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
526 jcb.setFocusPainted( false );
527 jcb.setFont( ControlPanel.jcb_font );
528 if ( !_configuration.isUseNativeUI() ) {
529 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
530 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
532 p.add( jcb, "Center" );
533 jcb.addActionListener( this );
536 void addJTextField( final JTextField tf, final JPanel p ) {
537 if ( !_configuration.isUseNativeUI() ) {
538 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
539 tf.setFont( ControlPanel.jcb_font );
542 tf.addActionListener( this );
546 private void addSequenceRelationBlock() {
547 final JLabel spacer = new JLabel( "" );
548 spacer.setSize( 1, 1 );
550 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
551 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
552 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
553 getSequenceRelationTypeBox().setFocusable( false );
554 _sequence_relation_type_box.setFont( ControlPanel.js_font );
555 if ( !_configuration.isUseNativeUI() ) {
556 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
557 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
559 _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
562 public Component getListCellRendererComponent( final JList list,
565 final boolean isSelected,
566 final boolean cellHasFocus ) {
567 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
572 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
573 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
574 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
579 final GridBagLayout gbl = new GridBagLayout();
580 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
581 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
582 final JPanel horizGrid = new JPanel( gbl );
583 horizGrid.setBackground( getBackground() );
584 horizGrid.add( typeLabel );
585 horizGrid.add( _sequence_relation_type_box );
586 add( customizeLabel( mainLabel, getConfiguration() ) );
588 add( getSequenceRelationBox() );
589 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
590 addCheckbox( Configuration.show_relation_confidence,
591 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
592 setCheckbox( Configuration.show_relation_confidence,
593 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
595 }// addSequenceRelationBlock
597 void deactivateButtonToReturnToSuperTree() {
598 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
599 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
600 _return_to_super_tree.setEnabled( false );
603 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
604 if ( ( _mainpanel != null ) && ( _mainpanel.getCurrentPhylogeny() != null ) ) {
605 if ( getOptions().isShowOverview() ) {
606 _mainpanel.getCurrentTreePanel().updateOvSizes();
608 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
609 setVisibilityOfDomainStrucureControls();
610 updateDomainStructureEvaluethresholdDisplay();
611 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
612 _mainpanel.getCurrentTreePanel().calcMaxDepth();
613 _mainpanel.adjustJScrollPane();
614 if ( recalc_longest_ext_node_info ) {
615 _mainpanel.getCurrentTreePanel().initNodeData();
616 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
618 _mainpanel.getCurrentTreePanel().repaint();
619 // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
623 void endClickToOptions() {
624 _click_to_combobox.addActionListener( this );
628 * Indicates what action should be execute when a node is clicked
630 * @return the click-on action
632 NodeClickAction getActionWhenNodeClicked() {
633 return _action_when_node_clicked;
636 Map<Integer, String> getAllClickToItems() {
637 return _all_click_to_names;
640 Map<String, Color> getAnnotationColors() {
641 return _annotation_colors;
644 public JCheckBox getColorBranchesCb() {
645 return _color_branches_cb;
648 Configuration getConfiguration() {
649 return _configuration;
652 TreePanel getCurrentTreePanel() {
653 return getMainPanel().getCurrentTreePanel();
656 public JCheckBox getDisplayAsPhylogramCb() {
657 return _display_as_phylogram_cb;
660 public JCheckBox getDynamicallyHideData() {
661 return _dynamically_hide_data;
665 private List<Boolean> getIsDrawPhylogramList() {
666 return _draw_phylogram;
669 MainPanel getMainPanel() {
673 public JCheckBox getNodeDescPopupCb() {
674 return _node_desc_popup_cb;
677 Options getOptions() {
678 return getMainPanel().getOptions();
681 private JLabel getSearchFoundCountsLabel() {
682 return _search_found_label;
685 private JButton getSearchResetButton() {
686 return _search_reset_button;
689 JTextField getSearchTextField() {
693 public Sequence getSelectedQuerySequence() {
694 return _selected_query_seq;
697 public JComboBox getSequenceRelationBox() {
698 if ( _show_sequence_relations == null ) {
699 _show_sequence_relations = new JComboBox();
700 _show_sequence_relations.setFocusable( false );
701 _show_sequence_relations.setMaximumRowCount( 20 );
702 _show_sequence_relations.setFont( ControlPanel.js_font );
703 if ( !_configuration.isUseNativeUI() ) {
704 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
705 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
707 _show_sequence_relations.addItem( "-----" );
708 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
710 return _show_sequence_relations;
714 public JComboBox getSequenceRelationTypeBox() {
715 if ( _sequence_relation_type_box == null ) {
716 _sequence_relation_type_box = new JComboBox();
717 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
718 _sequence_relation_type_box.addItem( type );
720 _sequence_relation_type_box.addActionListener( new ActionListener() {
723 public void actionPerformed( final ActionEvent e ) {
724 if ( _mainpanel.getCurrentPhylogeny() != null ) {
725 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
730 return _sequence_relation_type_box;
733 public JCheckBox getShowEventsCb() {
737 List<String> getSingleClickToNames() {
738 return _click_to_names;
741 Map<String, Color> getSpeciesColors() {
742 return _species_colors;
745 public JCheckBox getWriteConfidenceCb() {
746 return _write_confidence;
749 private void init() {
750 _draw_phylogram = new ArrayList<Boolean>();
751 setSpeciesColors( new HashMap<String, Color>() );
752 setAnnotationColors( new HashMap<String, Color>() );
755 boolean isAntialiasScreenText() {
759 boolean isColorAccordingToAnnotation() {
760 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
763 boolean isColorAccordingToTaxonomy() {
764 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
767 boolean isColorBranches() {
768 return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) );
771 boolean isDrawPhylogram() {
772 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
775 private boolean isDrawPhylogram( final int index ) {
776 return getIsDrawPhylogramList().get( index );
779 boolean isDynamicallyHideData() {
780 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
784 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
787 boolean isNodeDescPopup() {
788 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
791 boolean isShowAnnotation() {
792 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
795 boolean isShowBinaryCharacterCounts() {
796 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
799 boolean isShowBinaryCharacters() {
800 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
803 boolean isShowBootstrapValues() {
804 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
807 boolean isShowDomainArchitectures() {
808 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
811 boolean isShowGeneNames() {
812 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
815 public boolean isShowVectorData() {
816 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
819 boolean isShowGeneSymbols() {
820 return ( ( _show_gene_symbols != null ) && _show_gene_symbols.isSelected() );
823 boolean isShowInternalData() {
824 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
827 boolean isShowNodeNames() {
828 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
831 boolean isShowProperty() {
832 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
835 boolean isShowSequenceAcc() {
836 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
839 boolean isShowSequenceRelationConfidence() {
840 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
843 boolean isShowSequenceRelations() {
844 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
847 boolean isShowTaxonomyCode() {
848 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
851 public boolean isShowTaxonomyImages() {
852 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
855 boolean isShowTaxonomyCommonNames() {
856 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
859 boolean isShowTaxonomyScientificNames() {
860 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
863 boolean isWidthBranches() {
864 return ( ( _width_branches != null ) && _width_branches.isSelected() );
867 void phylogenyAdded( final Configuration configuration ) {
868 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
871 void phylogenyRemoved( final int index ) {
872 getIsDrawPhylogramList().remove( index );
876 final MainPanel main_panel = getMainPanel();
877 final Phylogeny tree = main_panel.getCurrentPhylogeny();
878 if ( ( tree == null ) || tree.isEmpty() ) {
881 String query = getSearchTextField().getText();
882 if ( query != null ) {
883 query = query.trim();
886 getSearchFoundCountsLabel().setVisible( false );
887 getSearchResetButton().setEnabled( false );
888 getSearchResetButton().setVisible( false );
891 if ( !ForesterUtil.isEmpty( query ) ) {
892 search( main_panel, tree, query );
895 getSearchFoundCountsLabel().setVisible( false );
896 getSearchResetButton().setEnabled( false );
897 getSearchResetButton().setVisible( false );
902 private void search( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
903 getSearchFoundCountsLabel().setVisible( true );
904 getSearchResetButton().setEnabled( true );
905 getSearchResetButton().setVisible( true );
906 String[] queries = null;
907 List<PhylogenyNode> nodes = null;
908 if ( query_str.indexOf( ',' ) >= 0 ) {
909 queries = query_str.split( ",+" );
912 queries = new String[ 1 ];
913 queries[ 0 ] = query_str.trim();
915 if ( ( queries != null ) && ( queries.length > 0 ) ) {
916 nodes = new ArrayList<PhylogenyNode>();
917 for( String query : queries ) {
918 if ( ForesterUtil.isEmpty( query ) ) {
921 query = query.trim();
922 if ( query.indexOf( '+' ) >= 0 ) {
923 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ), tree, getOptions()
924 .isSearchCaseSensitive(), !getOptions().isMatchWholeTermsOnly() ) );
927 nodes.addAll( PhylogenyMethods.searchData( query,
929 getOptions().isSearchCaseSensitive(),
930 !getOptions().isMatchWholeTermsOnly() ) );
933 if ( getOptions().isInverseSearchResult() ) {
934 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
935 all.removeAll( nodes );
939 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
940 main_panel.getCurrentTreePanel().setFoundNodes( new HashSet<Integer>() );
941 for( final PhylogenyNode node : nodes ) {
942 main_panel.getCurrentTreePanel().getFoundNodes().add( node.getId() );
944 setSearchFoundCountsOnLabel( nodes.size() );
947 setSearchFoundCountsOnLabel( 0 );
952 private void searchReset() {
953 if ( getMainPanel().getCurrentTreePanel() != null ) {
954 getMainPanel().getCurrentTreePanel().setFoundNodes( null );
958 void setActionWhenNodeClicked( final NodeClickAction action ) {
959 _action_when_node_clicked = action;
962 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
963 _annotation_colors = annotation_colors;
966 void setCheckbox( final int which, final boolean state ) {
968 case Configuration.display_as_phylogram:
969 if ( getDisplayAsPhylogramCb() != null ) {
970 getDisplayAsPhylogramCb().setSelected( state );
973 case Configuration.display_internal_data:
974 if ( _display_internal_data != null ) {
975 _display_internal_data.setSelected( state );
978 case Configuration.color_according_to_species:
979 if ( _color_acc_species != null ) {
980 _color_acc_species.setSelected( state );
983 case Configuration.color_according_to_annotation:
984 if ( _color_according_to_annotation != null ) {
985 _color_according_to_annotation.setSelected( state );
988 case Configuration.show_node_names:
989 if ( _show_node_names != null ) {
990 _show_node_names.setSelected( state );
993 case Configuration.show_tax_code:
994 if ( _show_taxo_code != null ) {
995 _show_taxo_code.setSelected( state );
998 case Configuration.show_taxonomy_scientific_names:
999 if ( _show_taxo_scientific_names != null ) {
1000 _show_taxo_scientific_names.setSelected( state );
1003 case Configuration.show_taxonomy_common_names:
1004 if ( _show_taxo_common_names != null ) {
1005 _show_taxo_common_names.setSelected( state );
1008 case Configuration.show_taxonomy_images:
1009 if ( _show_taxo_images_cb != null ) {
1010 _show_taxo_images_cb.setSelected( state );
1013 case Configuration.show_annotation:
1014 if ( _show_annotation != null ) {
1015 _show_annotation.setSelected( state );
1018 case Configuration.show_binary_characters:
1019 if ( _show_binary_characters != null ) {
1020 _show_binary_characters.setSelected( state );
1023 case Configuration.show_binary_character_counts:
1024 if ( _show_binary_character_counts != null ) {
1025 _show_binary_character_counts.setSelected( state );
1028 case Configuration.write_confidence_values:
1029 if ( getWriteConfidenceCb() != null ) {
1030 getWriteConfidenceCb().setSelected( state );
1033 case Configuration.write_events:
1034 if ( getShowEventsCb() != null ) {
1035 getShowEventsCb().setSelected( state );
1038 case Configuration.color_branches:
1039 if ( getColorBranchesCb() != null ) {
1040 getColorBranchesCb().setSelected( state );
1043 case Configuration.width_branches:
1044 if ( _width_branches != null ) {
1045 _width_branches.setSelected( state );
1048 case Configuration.show_domain_architectures:
1049 if ( _show_domain_architectures != null ) {
1050 _show_domain_architectures.setSelected( state );
1053 case Configuration.show_gene_names:
1054 if ( _show_gene_names != null ) {
1055 _show_gene_names.setSelected( state );
1058 case Configuration.show_gene_symbols:
1059 if ( _show_gene_symbols != null ) {
1060 _show_gene_symbols.setSelected( state );
1063 case Configuration.show_vector_data:
1064 if ( _show_vector_data_cb != null ) {
1065 _show_vector_data_cb.setSelected( state );
1068 case Configuration.show_sequence_acc:
1069 if ( _show_sequence_acc != null ) {
1070 _show_sequence_acc.setSelected( state );
1073 case Configuration.dynamically_hide_data:
1074 if ( getDynamicallyHideData() != null ) {
1075 getDynamicallyHideData().setSelected( state );
1078 case Configuration.node_data_popup:
1079 if ( getNodeDescPopupCb() != null ) {
1080 getNodeDescPopupCb().setSelected( state );
1084 case Configuration.show_relation_confidence:
1085 if ( _seq_relation_confidence_switch != null ) {
1086 _seq_relation_confidence_switch.setSelected( state );
1091 throw new AssertionError( "unknown checkbox: " + which );
1096 * Set this checkbox state. Not all checkboxes have been instantiated
1097 * depending on the config.
1099 void setCheckbox( final JCheckBox cb, final boolean state ) {
1101 cb.setSelected( state );
1105 void setClickToAction( final int action ) {
1106 // Set click-to action
1107 if ( action == _show_data_item ) {
1108 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1110 else if ( action == _collapse_cb_item ) {
1111 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1113 else if ( action == _reroot_cb_item ) {
1114 setActionWhenNodeClicked( NodeClickAction.REROOT );
1116 else if ( action == _subtree_cb_item ) {
1117 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1119 else if ( action == _swap_cb_item ) {
1120 setActionWhenNodeClicked( NodeClickAction.SWAP );
1122 else if ( action == _color_subtree_cb_item ) {
1123 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1125 else if ( action == _open_seq_web_item ) {
1126 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1128 else if ( action == _blast_item ) {
1129 if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
1130 setActionWhenNodeClicked( NodeClickAction.BLAST );
1133 else if ( action == _open_tax_web_item ) {
1134 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1136 else if ( action == _cut_subtree_item ) {
1137 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1139 else if ( action == _copy_subtree_item ) {
1140 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1142 else if ( action == _delete_node_or_subtree_item ) {
1143 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1145 else if ( action == _paste_subtree_item ) {
1146 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1148 else if ( action == _add_new_node_item ) {
1149 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1151 else if ( action == _edit_node_data_item ) {
1152 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1155 throw new RuntimeException( "unknown action: " + action );
1157 // make sure drop down is displaying the correct action
1158 // in case this was called from outside the class
1159 _click_to_combobox.setSelectedIndex( action );
1162 void setColorBranches( final boolean color_branches ) {
1163 _color_branches = color_branches;
1166 void setDrawPhylogram( final boolean b ) {
1167 getDisplayAsPhylogramCb().setSelected( b );
1168 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1171 private void setDrawPhylogram( final int index, final boolean b ) {
1172 getIsDrawPhylogramList().set( index, b );
1175 void setDrawPhylogramEnabled( final boolean b ) {
1176 getDisplayAsPhylogramCb().setEnabled( b );
1179 void setDynamicHidingIsOn( final boolean is_on ) {
1180 // if ( !_configuration.isUseNativeUI() ) {
1182 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1185 if ( !_configuration.isUseNativeUI() ) {
1186 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1189 getDynamicallyHideData().setForeground( Color.BLACK );
1195 private void setSearchFoundCountsOnLabel( final int counts ) {
1196 getSearchFoundCountsLabel().setText( "Found: " + counts );
1199 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
1200 final JComboBox box = getSequenceRelationBox();
1201 while ( box.getItemCount() > 1 ) {
1202 box.removeItemAt( 1 );
1204 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
1205 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
1207 if ( relationType == null ) {
1210 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
1211 for( final Sequence seq : sequenceRelationQueries ) {
1212 if ( seq.hasSequenceRelations() ) {
1213 boolean fFoundForCurrentType = false;
1214 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
1215 if ( sq.getType().equals( relationType ) ) {
1216 fFoundForCurrentType = true;
1220 if ( fFoundForCurrentType ) {
1221 sequenceNamesToAdd.add( seq.getName() );
1222 sequencesByName.put( seq.getName(), seq );
1226 // sort sequences by name before adding them to the combo
1227 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
1228 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
1229 for( final String seqName : sequenceNameArray ) {
1230 box.addItem( seqName );
1232 for( final ItemListener oldItemListener : box.getItemListeners() ) {
1233 box.removeItemListener( oldItemListener );
1235 box.addItemListener( new ItemListener() {
1238 public void itemStateChanged( final ItemEvent e ) {
1239 _selected_query_seq = sequencesByName.get( e.getItem() );
1240 _mainpanel.getCurrentTreePanel().repaint();
1245 void setShowEvents( final boolean show_events ) {
1246 if ( getShowEventsCb() == null ) {
1247 _show_events = new JCheckBox( "" );
1249 getShowEventsCb().setSelected( show_events );
1252 void setSpeciesColors( final Map<String, Color> species_colors ) {
1253 _species_colors = species_colors;
1256 private void setupClickToOptions() {
1257 final int default_option = _configuration.getDefaultDisplayClicktoOption();
1258 int selected_index = 0;
1260 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1261 _show_data_item = cb_index;
1262 addClickToOption( Configuration.display_node_data,
1263 _configuration.getClickToTitle( Configuration.display_node_data ) );
1264 if ( default_option == Configuration.display_node_data ) {
1265 selected_index = cb_index;
1269 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1270 _collapse_cb_item = cb_index;
1271 addClickToOption( Configuration.collapse_uncollapse,
1272 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
1273 if ( default_option == Configuration.collapse_uncollapse ) {
1274 selected_index = cb_index;
1278 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1279 _reroot_cb_item = cb_index;
1280 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1281 if ( default_option == Configuration.reroot ) {
1282 selected_index = cb_index;
1286 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1287 _subtree_cb_item = cb_index;
1288 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1289 if ( default_option == Configuration.subtree ) {
1290 selected_index = cb_index;
1294 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1295 _swap_cb_item = cb_index;
1296 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1297 if ( default_option == Configuration.swap ) {
1298 selected_index = cb_index;
1302 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1303 _color_subtree_cb_item = cb_index;
1304 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1305 if ( default_option == Configuration.color_subtree ) {
1306 selected_index = cb_index;
1310 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1311 _open_seq_web_item = cb_index;
1312 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1313 if ( default_option == Configuration.open_seq_web ) {
1314 selected_index = cb_index;
1318 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1319 _open_tax_web_item = cb_index;
1320 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1321 if ( default_option == Configuration.open_tax_web ) {
1322 selected_index = cb_index;
1326 if ( getOptions().isEditable() ) {
1327 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
1328 _cut_subtree_item = cb_index;
1329 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
1330 if ( default_option == Configuration.cut_subtree ) {
1331 selected_index = cb_index;
1335 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
1336 _copy_subtree_item = cb_index;
1337 addClickToOption( Configuration.copy_subtree,
1338 _configuration.getClickToTitle( Configuration.copy_subtree ) );
1339 if ( default_option == Configuration.copy_subtree ) {
1340 selected_index = cb_index;
1344 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
1345 _paste_subtree_item = cb_index;
1346 addClickToOption( Configuration.paste_subtree,
1347 _configuration.getClickToTitle( Configuration.paste_subtree ) );
1348 if ( default_option == Configuration.paste_subtree ) {
1349 selected_index = cb_index;
1353 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
1354 _delete_node_or_subtree_item = cb_index;
1355 addClickToOption( Configuration.delete_subtree_or_node,
1356 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
1357 if ( default_option == Configuration.delete_subtree_or_node ) {
1358 selected_index = cb_index;
1362 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
1363 _add_new_node_item = cb_index;
1364 addClickToOption( Configuration.add_new_node,
1365 _configuration.getClickToTitle( Configuration.add_new_node ) );
1366 if ( default_option == Configuration.add_new_node ) {
1367 selected_index = cb_index;
1371 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
1372 _edit_node_data_item = cb_index;
1373 addClickToOption( Configuration.edit_node_data,
1374 _configuration.getClickToTitle( Configuration.edit_node_data ) );
1375 if ( default_option == Configuration.edit_node_data ) {
1376 selected_index = cb_index;
1380 if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
1381 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1382 _blast_item = cb_index;
1383 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
1384 if ( default_option == Configuration.blast ) {
1385 selected_index = cb_index;
1391 // Set default selection and its action
1392 _click_to_combobox.setSelectedIndex( selected_index );
1393 setClickToAction( selected_index );
1398 * Set up the controls from the config settings. 11/26/05
1400 void setupControls() {
1401 // The tree display options:
1402 setupDisplayCheckboxes();
1404 // The sequence relation query selection combo-box
1405 if ( _configuration.displaySequenceRelations() ) {
1406 addSequenceRelationBlock();
1410 startClickToOptions();
1411 setupClickToOptions();
1412 endClickToOptions();
1413 // Zoom and quick edit buttons
1418 void setUpControlsForDomainStrucures() {
1419 _domain_display_label = new JLabel( "Domain Display:" );
1420 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1421 add( _domain_display_label );
1422 _zoom_in_domain_structure = new JButton( "d+" );
1423 _zoom_out_domain_structure = new JButton( "d-" );
1424 _decr_domain_structure_evalue_thr = new JButton( "-" );
1425 _incr_domain_structure_evalue_thr = new JButton( "+" );
1426 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1427 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1428 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1429 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1430 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1431 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1432 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1433 _domain_structure_evalue_thr_tf.setEditable( false );
1434 if ( !getConfiguration().isUseNativeUI() ) {
1435 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1436 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1437 _domain_structure_evalue_thr_tf.setBorder( null );
1439 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1440 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1441 if ( !_configuration.isUseNativeUI() ) {
1442 d1_panel.setBackground( getBackground() );
1443 d2_panel.setBackground( getBackground() );
1447 addJButton( _zoom_out_domain_structure, d1_panel );
1448 addJButton( _zoom_in_domain_structure, d1_panel );
1449 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1450 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1451 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1454 private void setupDisplayCheckboxes() {
1455 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
1456 addCheckbox( Configuration.display_as_phylogram,
1457 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
1458 setCheckbox( Configuration.display_as_phylogram,
1459 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
1461 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1462 addCheckbox( Configuration.dynamically_hide_data,
1463 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
1464 setCheckbox( Configuration.dynamically_hide_data,
1465 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
1467 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1468 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1469 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1471 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1472 addCheckbox( Configuration.display_internal_data,
1473 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
1474 setCheckbox( Configuration.display_internal_data,
1475 _configuration.doCheckOption( Configuration.display_internal_data ) );
1477 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1478 addCheckbox( Configuration.color_according_to_species,
1479 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
1480 setCheckbox( Configuration.color_according_to_species,
1481 _configuration.doCheckOption( Configuration.color_according_to_species ) );
1483 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1484 addCheckbox( Configuration.color_according_to_annotation,
1485 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
1486 setCheckbox( Configuration.color_according_to_annotation,
1487 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
1489 if ( _configuration.doDisplayOption( Configuration.color_branches ) ) {
1490 addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) );
1491 setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) );
1493 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1494 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1495 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1497 final JLabel label = new JLabel( "Display Data:" );
1498 label.setFont( ControlPanel.jcb_bold_font );
1499 if ( !getConfiguration().isUseNativeUI() ) {
1500 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1503 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1504 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
1505 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1507 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1508 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1509 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1511 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1512 addCheckbox( Configuration.show_taxonomy_scientific_names,
1513 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1514 setCheckbox( Configuration.show_taxonomy_scientific_names,
1515 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1517 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1518 addCheckbox( Configuration.show_taxonomy_common_names,
1519 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1520 setCheckbox( Configuration.show_taxonomy_common_names,
1521 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1523 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1524 addCheckbox( Configuration.show_taxonomy_images,
1525 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1526 setCheckbox( Configuration.show_taxonomy_images,
1527 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1529 if ( _configuration.doDisplayOption( Configuration.show_gene_symbols ) ) {
1530 addCheckbox( Configuration.show_gene_symbols,
1531 _configuration.getDisplayTitle( Configuration.show_gene_symbols ) );
1532 setCheckbox( Configuration.show_gene_symbols,
1533 _configuration.doCheckOption( Configuration.show_gene_symbols ) );
1535 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1536 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1537 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1539 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1540 addCheckbox( Configuration.show_sequence_acc,
1541 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1542 setCheckbox( Configuration.show_sequence_acc,
1543 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1545 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1546 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
1547 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1549 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1550 addCheckbox( Configuration.show_binary_characters,
1551 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1552 setCheckbox( Configuration.show_binary_characters,
1553 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1555 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1556 addCheckbox( Configuration.show_binary_character_counts,
1557 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1558 setCheckbox( Configuration.show_binary_character_counts,
1559 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1561 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1562 addCheckbox( Configuration.show_domain_architectures,
1563 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1564 setCheckbox( Configuration.show_domain_architectures,
1565 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1567 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1568 addCheckbox( Configuration.write_confidence_values,
1569 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1570 setCheckbox( Configuration.write_confidence_values,
1571 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1573 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1574 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1575 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1577 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1578 addCheckbox( Configuration.show_vector_data,
1579 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1580 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
1584 void setupSearchTools() {
1585 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1586 final JLabel search_label = new JLabel( "Search:" );
1587 search_label.setFont( ControlPanel.jcb_bold_font );
1588 if ( !getConfiguration().isUseNativeUI() ) {
1589 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1591 add( search_label );
1592 search_label.setToolTipText( tip );
1593 _search_found_label = new JLabel();
1594 getSearchFoundCountsLabel().setVisible( false );
1595 _search_found_label.setFont( ControlPanel.jcb_bold_font );
1596 if ( !getConfiguration().isUseNativeUI() ) {
1597 _search_found_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1599 _search_tf = new JTextField( 3 );
1600 _search_tf.setToolTipText( tip );
1601 _search_tf.setEditable( true );
1602 if ( !getConfiguration().isUseNativeUI() ) {
1603 _search_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1604 _search_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1605 _search_tf.setBorder( null );
1607 _search_reset_button = new JButton();
1608 getSearchResetButton().setText( "Reset" );
1609 getSearchResetButton().setEnabled( false );
1610 getSearchResetButton().setVisible( false );
1611 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1612 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1613 s_panel_1.setBackground( getBackground() );
1615 s_panel_2.setBackground( getBackground() );
1617 final KeyAdapter key_adapter = new KeyAdapter() {
1620 public void keyReleased( final KeyEvent key_event ) {
1622 displayedPhylogenyMightHaveChanged( true );
1625 final ActionListener action_listener = new ActionListener() {
1628 public void actionPerformed( final ActionEvent e ) {
1630 setSearchFoundCountsOnLabel( 0 );
1631 getSearchFoundCountsLabel().setVisible( false );
1632 getSearchTextField().setText( "" );
1633 getSearchResetButton().setEnabled( false );
1634 getSearchResetButton().setVisible( false );
1635 displayedPhylogenyMightHaveChanged( true );
1638 _search_reset_button.addActionListener( action_listener );
1639 _search_tf.addKeyListener( key_adapter );
1640 addJTextField( _search_tf, s_panel_1 );
1641 s_panel_2.add( _search_found_label );
1642 addJButton( _search_reset_button, s_panel_2 );
1645 private void setVisibilityOfDomainStrucureControls() {
1646 if ( _zoom_in_domain_structure != null ) {
1647 if ( isShowDomainArchitectures() ) {
1648 _domain_display_label.setVisible( true );
1649 _zoom_in_domain_structure.setVisible( true );
1650 _zoom_out_domain_structure.setVisible( true );
1651 _decr_domain_structure_evalue_thr.setVisible( true );
1652 _incr_domain_structure_evalue_thr.setVisible( true );
1653 _domain_structure_evalue_thr_tf.setVisible( true );
1656 _domain_display_label.setVisible( false );
1657 _zoom_in_domain_structure.setVisible( false );
1658 _zoom_out_domain_structure.setVisible( false );
1659 _decr_domain_structure_evalue_thr.setVisible( false );
1660 _incr_domain_structure_evalue_thr.setVisible( false );
1661 _domain_structure_evalue_thr_tf.setVisible( false );
1667 * Fit entire tree into window.
1670 if ( _mainpanel.getCurrentScrollPane() == null ) {
1673 displayedPhylogenyMightHaveChanged( false );
1674 _mainpanel.getCurrentTreePanel().updateOvSettings();
1675 _mainpanel.getCurrentTreePanel().validate();
1676 _mainpanel.validate();
1677 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1678 _mainpanel.getSizeOfViewport().height,
1680 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1681 _mainpanel.adjustJScrollPane();
1682 _mainpanel.getCurrentTreePanel().repaint();
1683 _mainpanel.getCurrentTreePanel().validate();
1684 _mainpanel.validate();
1685 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1686 _mainpanel.getSizeOfViewport().height,
1688 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1689 _mainpanel.adjustJScrollPane();
1690 _mainpanel.getCurrentTreePanel().repaint();
1691 _mainpanel.getCurrentTreePanel().updateOvSizes();
1694 void showWholeAll() {
1695 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1696 if ( tree_panel != null ) {
1697 tree_panel.validate();
1698 tree_panel.setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1699 _mainpanel.getSizeOfViewport().height,
1701 tree_panel.resetPreferredSize();
1702 tree_panel.repaint();
1707 // Create header for click-to combo box.
1708 void startClickToOptions() {
1709 final JLabel spacer = new JLabel( "" );
1710 spacer.setFont( ControlPanel.jcb_font );
1712 _click_to_label = new JLabel( "Click on Node to:" );
1713 add( customizeLabel( _click_to_label, getConfiguration() ) );
1714 _click_to_combobox = new JComboBox();
1715 _click_to_combobox.setFocusable( false );
1716 _click_to_combobox.setMaximumRowCount( 14 );
1717 _click_to_combobox.setFont( ControlPanel.js_font );
1718 if ( !_configuration.isUseNativeUI() ) {
1719 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1721 // don't add listener until all items are set (or each one will trigger
1723 // click_to_list.addActionListener(this);
1724 add( _click_to_combobox );
1725 // Correlates option names to titles
1726 _all_click_to_names = new HashMap<Integer, String>();
1727 _click_to_names = new ArrayList<String>();
1731 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1732 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1733 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1734 setDrawPhylogramEnabled( true );
1735 setDrawPhylogram( isDrawPhylogram() );
1738 setDrawPhylogramEnabled( false );
1739 setDrawPhylogram( false );
1741 if ( getMainPanel().getMainFrame() == null ) {
1742 // Must be "E" applet version.
1743 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1744 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1747 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1748 .getPhylogenyGraphicsType() );
1750 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1751 getMainPanel().getControlPanel().search();
1752 getSequenceRelationTypeBox().removeAllItems();
1753 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1754 .getRelevantSequenceRelationTypes() ) {
1755 _sequence_relation_type_box.addItem( type );
1757 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1758 // according to GUILHEM the line above can be removed.
1763 * Uncollapse all nodes.
1765 void uncollapseAll( final TreePanel tp ) {
1766 final Phylogeny t = tp.getPhylogeny();
1767 if ( ( t != null ) && !t.isEmpty() ) {
1768 t.setAllNodesToNotCollapse();
1769 t.recalculateNumberOfExternalDescendants( false );
1774 void updateDomainStructureEvaluethresholdDisplay() {
1775 if ( _domain_structure_evalue_thr_tf != null ) {
1776 _domain_structure_evalue_thr_tf.setText( "10^"
1777 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1781 void zoomInX( final float factor, final float x_correction_factor ) {
1782 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1783 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1784 treepanel.multiplyUrtFactor( 1f );
1785 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1786 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1787 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1788 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1789 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1790 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1791 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1792 getMainPanel().adjustJScrollPane();
1793 treepanel.resetPreferredSize();
1794 getMainPanel().getCurrentScrollPane().getViewport().validate();
1795 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1796 - ( sb.getVisibleAmount() / 2.0 ) ) );
1799 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1800 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1801 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1802 getMainPanel().adjustJScrollPane();
1803 treepanel.resetPreferredSize();
1804 getMainPanel().getCurrentScrollPane().getViewport().validate();
1805 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1807 treepanel.resetPreferredSize();
1808 treepanel.updateOvSizes();
1811 void zoomInY( final float factor ) {
1812 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1813 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1814 treepanel.multiplyUrtFactor( 1.1f );
1815 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1816 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1817 getMainPanel().adjustJScrollPane();
1818 treepanel.resetPreferredSize();
1819 getMainPanel().getCurrentScrollPane().getViewport().validate();
1820 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1821 - ( sb.getVisibleAmount() / 2.0 ) ) );
1822 treepanel.resetPreferredSize();
1823 treepanel.updateOvSizes();
1826 void zoomOutX( final float factor, final float x_correction_factor ) {
1827 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1828 treepanel.multiplyUrtFactor( 1f );
1829 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1830 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1831 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1832 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1833 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1834 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1835 getMainPanel().adjustJScrollPane();
1836 treepanel.resetPreferredSize();
1837 getMainPanel().getCurrentScrollPane().getViewport().validate();
1838 final double x = ( sb.getMaximum() - sb.getMinimum() )
1839 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1840 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1841 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1842 getMainPanel().adjustJScrollPane();
1843 treepanel.resetPreferredSize();
1844 getMainPanel().getCurrentScrollPane().getViewport().validate();
1845 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1846 - ( sb.getVisibleAmount() / 2.0 ) ) );
1849 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1850 treepanel.setXdistance( treepanel.getXdistance() * factor );
1851 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
1853 getMainPanel().adjustJScrollPane();
1854 treepanel.resetPreferredSize();
1855 getMainPanel().getCurrentScrollPane().getViewport().validate();
1856 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1859 treepanel.resetPreferredSize();
1860 treepanel.updateOvSizes();
1864 void zoomOutY( final float factor ) {
1865 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1866 treepanel.multiplyUrtFactor( 0.9f );
1867 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1868 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1869 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1870 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1871 getMainPanel().adjustJScrollPane();
1872 treepanel.resetPreferredSize();
1873 getMainPanel().getCurrentScrollPane().getViewport().validate();
1874 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1875 - ( sb.getVisibleAmount() / 2.0 ) ) );
1876 treepanel.resetPreferredSize();
1877 treepanel.updateOvSizes();
1881 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
1882 label.setFont( ControlPanel.jcb_bold_font );
1883 if ( !configuration.isUseNativeUI() ) {
1884 label.setForeground( configuration.getGuiCheckboxTextColor() );
1885 label.setBackground( configuration.getGuiBackgroundColor() );
1890 enum NodeClickAction {
1901 DELETE_NODE_OR_SUBTREE,