2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 // Contact: phylosoft @ gmail . com
23 // WWW: www.phylosoft.org/forester
25 package org.forester.archaeopteryx;
27 import java.awt.BorderLayout;
28 import java.awt.Color;
29 import java.awt.Component;
30 import java.awt.Dimension;
32 import java.awt.GridBagLayout;
33 import java.awt.GridLayout;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.ActionListener;
36 import java.awt.event.ItemEvent;
37 import java.awt.event.ItemListener;
38 import java.awt.event.KeyAdapter;
39 import java.awt.event.KeyEvent;
40 import java.util.ArrayList;
41 import java.util.Arrays;
42 import java.util.Collection;
43 import java.util.HashMap;
44 import java.util.HashSet;
45 import java.util.List;
48 import javax.swing.BorderFactory;
49 import javax.swing.DefaultListCellRenderer;
50 import javax.swing.JButton;
51 import javax.swing.JCheckBox;
52 import javax.swing.JComboBox;
53 import javax.swing.JLabel;
54 import javax.swing.JList;
55 import javax.swing.JPanel;
56 import javax.swing.JScrollBar;
57 import javax.swing.JTextField;
58 import javax.swing.ListCellRenderer;
60 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
61 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
62 import org.forester.phylogeny.Phylogeny;
63 import org.forester.phylogeny.PhylogenyMethods;
64 import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
65 import org.forester.phylogeny.PhylogenyNode;
66 import org.forester.phylogeny.data.Sequence;
67 import org.forester.phylogeny.data.SequenceRelation;
68 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
69 import org.forester.util.ForesterUtil;
71 final class ControlPanel extends JPanel implements ActionListener {
73 private static final String RETURN_TO_SUPER_TREE_TEXT = "Back to Super Tree";
74 final static Font jcb_font = new Font( Configuration.getDefaultFontFamilyName(),
77 final static Font js_font = new Font( Configuration.getDefaultFontFamilyName(),
80 final static Font jcb_bold_font = new Font( Configuration.getDefaultFontFamilyName(),
83 private static final long serialVersionUID = -8463483932821545633L;
84 private final MainPanel _mainpanel;
85 // The settings from the conf file
86 private final Configuration _configuration;
88 private JCheckBox _display_internal_data;
89 private JCheckBox _show_node_names;
90 private JCheckBox _show_taxo_code;
91 private JCheckBox _write_confidence;
92 private JCheckBox _show_events;
93 private JCheckBox _color_acc_species;
94 private JCheckBox _color_branches_cb;
95 private JCheckBox _width_branches;
96 private JCheckBox _show_domain_architectures;
97 private JCheckBox _show_annotation;
98 private JCheckBox _show_binary_characters;
99 private JCheckBox _show_binary_character_counts;
100 private JCheckBox _show_gene_names;
101 private JCheckBox _show_gene_symbols;
102 private JCheckBox _show_sequence_acc;
103 private JCheckBox _node_desc_popup_cb;
104 private JCheckBox _dynamically_hide_data;
105 private JCheckBox _show_taxo_scientific_names;
106 private JCheckBox _show_taxo_common_names;
107 private JCheckBox _show_taxo_images_cb;
108 private JCheckBox _color_according_to_annotation;
109 private JCheckBox _display_as_phylogram_cb;
110 private JCheckBox _seq_relation_confidence_switch;
111 private JComboBox _show_sequence_relations;
112 private JComboBox _sequence_relation_type_box;
113 private JCheckBox _show_vector_data_cb;
114 private JCheckBox _show_properties_cb;
115 private JLabel _click_to_label;
116 private JLabel _zoom_label;
117 private JLabel _domain_display_label;
118 private JComboBox _click_to_combobox;
119 private Map<Integer, String> _all_click_to_names;
120 private List<String> _click_to_names;
121 // Indices for the click-to options in the combo box
122 private int _show_data_item;
123 private int _collapse_cb_item;
124 private int _reroot_cb_item;
125 private int _swap_cb_item;
126 private int _subtree_cb_item;
127 private int _color_subtree_cb_item;
128 private int _open_seq_web_item;
129 private int _sort_descendents_item;
130 private int _open_tax_web_item;
131 private int _cut_subtree_item;
132 private int _copy_subtree_item;
133 private int _delete_node_or_subtree_item;
134 private int _paste_subtree_item;
135 private int _add_new_node_item;
136 private int _edit_node_data_item;
137 private int _get_ext_desc_data;
138 private int _blast_item;
139 // zooming and quick tree manipulation buttons:
140 private JButton _zoom_in_x;
141 private JButton _zoom_in_y;
142 private JButton _zoom_out_x;
143 private JButton _zoom_out_y;
144 private JButton _show_whole;
145 private JButton _order;
146 private JButton _uncollapse_all;
147 private JButton _zoom_in_domain_structure;
148 private JButton _zoom_out_domain_structure;
149 private JButton _decr_domain_structure_evalue_thr;
150 private JButton _incr_domain_structure_evalue_thr;
151 private JButton _return_to_super_tree;
152 private JTextField _domain_structure_evalue_thr_tf;
153 private JTextField _search_tf;
154 private boolean _order_of_appearance;
155 private boolean _color_branches;
156 private NodeClickAction _action_when_node_clicked;
157 private List<Boolean> _draw_phylogram;
158 private Map<String, Color> _annotation_colors;
159 private Map<String, Color> _species_colors;
160 private JButton _search_reset_button;
161 private JLabel _search_found_label;
162 private Sequence _selected_query_seq;
164 ControlPanel( final MainPanel ap, final Configuration configuration ) {
167 _configuration = configuration;
168 if ( !_configuration.isUseNativeUI() ) {
169 setBackground( getConfiguration().getGuiBackgroundColor() );
170 setBorder( BorderFactory.createRaisedBevelBorder() );
172 setLayout( new GridLayout( 0, 1, 2, 2 ) );
173 _order_of_appearance = true;
181 public void actionPerformed( final ActionEvent e ) {
183 final TreePanel tp = getMainPanel().getCurrentTreePanel();
187 if ( e.getSource() == _click_to_combobox ) {
188 setClickToAction( _click_to_combobox.getSelectedIndex() );
189 getCurrentTreePanel().repaint();
191 else if ( e.getSource() == _show_binary_characters ) {
192 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
193 _show_binary_character_counts.setSelected( false );
195 displayedPhylogenyMightHaveChanged( true );
197 else if ( e.getSource() == _show_binary_character_counts ) {
198 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
199 _show_binary_characters.setSelected( false );
201 displayedPhylogenyMightHaveChanged( true );
203 else if ( e.getSource() == _color_according_to_annotation ) {
204 if ( ( _show_annotation != null ) && _color_according_to_annotation.isSelected() ) {
205 _show_annotation.setSelected( true );
207 displayedPhylogenyMightHaveChanged( false );
209 else if ( e.getSource() == _show_annotation ) {
210 if ( ( _color_according_to_annotation != null ) && !_show_annotation.isSelected() ) {
211 _color_according_to_annotation.setSelected( false );
213 displayedPhylogenyMightHaveChanged( false );
215 else if ( e.getSource() == _show_domain_architectures ) {
217 displayedPhylogenyMightHaveChanged( false );
219 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
220 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
221 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
225 else if ( e.getSource() == _zoom_in_x ) {
226 zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
227 displayedPhylogenyMightHaveChanged( false );
229 else if ( e.getSource() == _zoom_in_y ) {
230 zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR );
231 displayedPhylogenyMightHaveChanged( false );
233 else if ( e.getSource() == _zoom_out_x ) {
234 zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
235 displayedPhylogenyMightHaveChanged( false );
237 else if ( e.getSource() == _zoom_out_y ) {
238 zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR );
239 displayedPhylogenyMightHaveChanged( false );
241 else if ( e.getSource() == _show_whole ) {
244 else if ( e.getSource() == _return_to_super_tree ) {
245 _mainpanel.getCurrentTreePanel().superTree();
248 else if ( e.getSource() == _order ) {
249 DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
250 if ( ( !isShowTaxonomyScientificNames() && !isShowTaxonomyCode() && !isShowTaxonomyCommonNames() ) ) {
251 if ( ( isShowSequenceAcc() || isShowGeneNames() || isShowGeneSymbols() ) ) {
252 pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
254 else if ( isShowNodeNames() ) {
255 pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
258 PhylogenyMethods.orderAppearance( tp.getPhylogeny().getRoot(), _order_of_appearance, true, pri );
259 _order_of_appearance = !_order_of_appearance;
260 tp.setNodeInPreorderToNull();
261 tp.getPhylogeny().externalNodesHaveChanged();
262 tp.getPhylogeny().clearHashIdToNodeMap();
263 tp.getPhylogeny().recalculateNumberOfExternalDescendants( true );
264 tp.resetNodeIdToDistToLeafMap();
265 tp.setEdited( true );
266 displayedPhylogenyMightHaveChanged( false );
268 else if ( e.getSource() == _uncollapse_all ) {
270 displayedPhylogenyMightHaveChanged( false );
272 else if ( e.getSource() == _zoom_in_domain_structure ) {
273 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
274 displayedPhylogenyMightHaveChanged( true );
276 else if ( e.getSource() == _zoom_out_domain_structure ) {
277 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
278 displayedPhylogenyMightHaveChanged( true );
280 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
281 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThreshold();
282 displayedPhylogenyMightHaveChanged( true );
284 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
285 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThreshold();
286 displayedPhylogenyMightHaveChanged( true );
288 else if ( e.getSource() == _search_tf ) {
290 displayedPhylogenyMightHaveChanged( true );
293 displayedPhylogenyMightHaveChanged( true );
297 tp.requestFocusInWindow();
300 catch ( final Exception ex ) {
301 AptxUtil.unexpectedException( ex );
303 catch ( final Error err ) {
304 AptxUtil.unexpectedError( err );
308 void activateButtonToReturnToSuperTree( int index ) {
311 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
314 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
316 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
317 _return_to_super_tree.setEnabled( true );
321 * Add zoom and quick edit buttons. (Last modified 8/9/04)
324 final JLabel spacer = new JLabel( "" );
325 spacer.setOpaque( false );
327 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
328 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
329 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
330 if ( !getConfiguration().isUseNativeUI() ) {
331 x_panel.setBackground( getBackground() );
332 y_panel.setBackground( getBackground() );
333 z_panel.setBackground( getBackground() );
335 add( _zoom_label = new JLabel( "Zoom:" ) );
336 customizeLabel( _zoom_label, getConfiguration() );
340 if ( getConfiguration().isUseNativeUI() ) {
341 _zoom_in_x = new JButton( "+" );
342 _zoom_out_x = new JButton( "-" );
345 _zoom_in_x = new JButton( "X+" );
346 _zoom_out_x = new JButton( "X-" );
348 _zoom_in_y = new JButton( "Y+" );
349 _zoom_out_y = new JButton( "Y-" );
350 _show_whole = new JButton( "F" );
351 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [Backspace]" );
352 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+Right]" );
353 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+Up]" );
354 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+Left]" );
355 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+Down]" );
356 if ( getConfiguration().isUseNativeUI() && AptxUtil.isMac() ) {
357 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
358 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
361 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
362 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
364 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
365 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
366 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
367 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
368 _return_to_super_tree.setEnabled( false );
369 _order = new JButton( "Order Subtrees" );
370 _uncollapse_all = new JButton( "Uncollapse All" );
371 addJButton( _zoom_in_y, x_panel );
372 addJButton( _zoom_out_x, y_panel );
373 addJButton( _show_whole, y_panel );
374 addJButton( _zoom_in_x, y_panel );
375 addJButton( _zoom_out_y, z_panel );
376 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
377 setUpControlsForDomainStrucures();
379 final JLabel spacer2 = new JLabel( "" );
381 addJButton( _return_to_super_tree, this );
382 addJButton( _order, this );
383 addJButton( _uncollapse_all, this );
384 final JLabel spacer3 = new JLabel( "" );
386 setVisibilityOfDomainStrucureControls();
389 void addCheckbox( final int which, final String title ) {
390 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
392 case Configuration.display_as_phylogram:
393 _display_as_phylogram_cb = new JCheckBox( title );
394 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
395 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
398 case Configuration.display_internal_data:
399 _display_internal_data = new JCheckBox( title );
400 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
401 addJCheckBox( _display_internal_data, ch_panel );
404 case Configuration.color_according_to_species:
405 _color_acc_species = new JCheckBox( title );
407 .setToolTipText( "To colorize taxonomy and sequence labels as a function of taxonomy" );
408 addJCheckBox( _color_acc_species, ch_panel );
411 case Configuration.color_according_to_annotation:
412 _color_according_to_annotation = new JCheckBox( title );
413 _color_according_to_annotation
414 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
415 addJCheckBox( _color_according_to_annotation, ch_panel );
418 case Configuration.show_node_names:
419 _show_node_names = new JCheckBox( title );
420 addJCheckBox( _show_node_names, ch_panel );
423 case Configuration.show_taxonomy_scientific_names:
424 _show_taxo_scientific_names = new JCheckBox( title );
425 addJCheckBox( _show_taxo_scientific_names, ch_panel );
428 case Configuration.show_taxonomy_common_names:
429 _show_taxo_common_names = new JCheckBox( title );
430 addJCheckBox( _show_taxo_common_names, ch_panel );
433 case Configuration.show_tax_code:
434 _show_taxo_code = new JCheckBox( title );
435 addJCheckBox( _show_taxo_code, ch_panel );
438 case Configuration.show_taxonomy_images:
439 _show_taxo_images_cb = new JCheckBox( title );
440 addJCheckBox( _show_taxo_images_cb, ch_panel );
443 case Configuration.show_binary_characters:
444 _show_binary_characters = new JCheckBox( title );
445 addJCheckBox( _show_binary_characters, ch_panel );
448 case Configuration.show_annotation:
449 _show_annotation = new JCheckBox( title );
450 addJCheckBox( _show_annotation, ch_panel );
453 case Configuration.show_binary_character_counts:
454 _show_binary_character_counts = new JCheckBox( title );
455 addJCheckBox( _show_binary_character_counts, ch_panel );
458 case Configuration.write_confidence_values:
459 _write_confidence = new JCheckBox( title );
460 addJCheckBox( getWriteConfidenceCb(), ch_panel );
463 case Configuration.write_events:
464 _show_events = new JCheckBox( title );
465 addJCheckBox( getShowEventsCb(), ch_panel );
468 case Configuration.color_branches:
469 _color_branches_cb = new JCheckBox( title );
470 getColorBranchesCb().setToolTipText( "To use branch color values, if present" );
471 addJCheckBox( getColorBranchesCb(), ch_panel );
474 case Configuration.width_branches:
475 _width_branches = new JCheckBox( title );
476 _width_branches.setToolTipText( "To use branch width values, if present" );
477 addJCheckBox( _width_branches, ch_panel );
480 case Configuration.show_domain_architectures:
481 _show_domain_architectures = new JCheckBox( title );
482 addJCheckBox( _show_domain_architectures, ch_panel );
485 case Configuration.show_gene_names:
486 _show_gene_names = new JCheckBox( title );
487 addJCheckBox( _show_gene_names, ch_panel );
490 case Configuration.show_gene_symbols:
491 _show_gene_symbols = new JCheckBox( title );
492 addJCheckBox( _show_gene_symbols, ch_panel );
495 case Configuration.show_sequence_acc:
496 _show_sequence_acc = new JCheckBox( title );
497 addJCheckBox( _show_sequence_acc, ch_panel );
500 case Configuration.dynamically_hide_data:
501 _dynamically_hide_data = new JCheckBox( title );
502 getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" );
503 addJCheckBox( getDynamicallyHideData(), ch_panel );
506 case Configuration.node_data_popup:
507 _node_desc_popup_cb = new JCheckBox( title );
508 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
509 addJCheckBox( getNodeDescPopupCb(), ch_panel );
512 case Configuration.show_relation_confidence:
513 _seq_relation_confidence_switch = new JCheckBox( title );
514 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
517 case Configuration.show_vector_data:
518 _show_vector_data_cb = new JCheckBox( title );
519 addJCheckBox( _show_vector_data_cb, ch_panel );
522 case Configuration.show_properties:
523 _show_properties_cb = new JCheckBox( title );
524 addJCheckBox( _show_properties_cb, ch_panel );
528 throw new RuntimeException( "unknown checkbox: " + which );
532 private void addClickToOption( final int which, final String title ) {
533 _click_to_combobox.addItem( title );
534 _click_to_names.add( title );
535 _all_click_to_names.put( new Integer( which ), title );
536 if ( !_configuration.isUseNativeUI() ) {
537 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
538 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
542 void addJButton( final JButton jb, final JPanel p ) {
543 jb.setFocusPainted( false );
544 jb.setFont( ControlPanel.jcb_font );
545 if ( !_configuration.isUseNativeUI() ) {
546 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
547 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
548 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
551 jb.addActionListener( this );
554 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
555 jcb.setFocusPainted( false );
556 jcb.setFont( ControlPanel.jcb_font );
557 if ( !_configuration.isUseNativeUI() ) {
558 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
559 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
561 p.add( jcb, "Center" );
562 jcb.addActionListener( this );
565 void addJTextField( final JTextField tf, final JPanel p ) {
566 if ( !_configuration.isUseNativeUI() ) {
567 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
568 tf.setFont( ControlPanel.jcb_font );
571 tf.addActionListener( this );
575 private void addSequenceRelationBlock() {
576 final JLabel spacer = new JLabel( "" );
577 spacer.setSize( 1, 1 );
579 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
580 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
581 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
582 getSequenceRelationTypeBox().setFocusable( false );
583 _sequence_relation_type_box.setFont( ControlPanel.js_font );
584 if ( !_configuration.isUseNativeUI() ) {
585 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
586 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
588 _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
591 public Component getListCellRendererComponent( final JList list,
594 final boolean isSelected,
595 final boolean cellHasFocus ) {
596 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
601 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
602 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
603 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
608 final GridBagLayout gbl = new GridBagLayout();
609 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
610 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
611 final JPanel horizGrid = new JPanel( gbl );
612 horizGrid.setBackground( getBackground() );
613 horizGrid.add( typeLabel );
614 horizGrid.add( _sequence_relation_type_box );
615 add( customizeLabel( mainLabel, getConfiguration() ) );
617 add( getSequenceRelationBox() );
618 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
619 addCheckbox( Configuration.show_relation_confidence,
620 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
621 setCheckbox( Configuration.show_relation_confidence,
622 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
624 }// addSequenceRelationBlock
626 void deactivateButtonToReturnToSuperTree() {
627 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
628 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
629 _return_to_super_tree.setEnabled( false );
632 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
633 if ( ( _mainpanel != null )
634 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
635 if ( getOptions().isShowOverview() ) {
636 _mainpanel.getCurrentTreePanel().updateOvSizes();
638 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
639 setVisibilityOfDomainStrucureControls();
640 updateDomainStructureEvaluethresholdDisplay();
641 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
642 _mainpanel.getCurrentTreePanel().calcMaxDepth();
643 _mainpanel.adjustJScrollPane();
644 if ( recalc_longest_ext_node_info ) {
645 _mainpanel.getCurrentTreePanel().initNodeData();
646 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
648 _mainpanel.getCurrentTreePanel().repaint();
649 // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
653 void endClickToOptions() {
654 _click_to_combobox.addActionListener( this );
658 * Indicates what action should be execute when a node is clicked
660 * @return the click-on action
662 NodeClickAction getActionWhenNodeClicked() {
663 return _action_when_node_clicked;
666 Map<Integer, String> getAllClickToItems() {
667 return _all_click_to_names;
670 Map<String, Color> getAnnotationColors() {
671 return _annotation_colors;
674 public JCheckBox getColorBranchesCb() {
675 return _color_branches_cb;
678 public JCheckBox getColorAccSpeciesCb() {
679 return _color_acc_species;
682 Configuration getConfiguration() {
683 return _configuration;
686 TreePanel getCurrentTreePanel() {
687 return getMainPanel().getCurrentTreePanel();
690 public JCheckBox getDisplayAsPhylogramCb() {
691 return _display_as_phylogram_cb;
694 public JCheckBox getDynamicallyHideData() {
695 return _dynamically_hide_data;
699 private List<Boolean> getIsDrawPhylogramList() {
700 return _draw_phylogram;
703 MainPanel getMainPanel() {
707 public JCheckBox getNodeDescPopupCb() {
708 return _node_desc_popup_cb;
711 Options getOptions() {
712 return getMainPanel().getOptions();
715 private JLabel getSearchFoundCountsLabel() {
716 return _search_found_label;
719 private JButton getSearchResetButton() {
720 return _search_reset_button;
723 JTextField getSearchTextField() {
727 public Sequence getSelectedQuerySequence() {
728 return _selected_query_seq;
731 public JComboBox getSequenceRelationBox() {
732 if ( _show_sequence_relations == null ) {
733 _show_sequence_relations = new JComboBox();
734 _show_sequence_relations.setFocusable( false );
735 _show_sequence_relations.setMaximumRowCount( 20 );
736 _show_sequence_relations.setFont( ControlPanel.js_font );
737 if ( !_configuration.isUseNativeUI() ) {
738 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
739 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
741 _show_sequence_relations.addItem( "-----" );
742 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
744 return _show_sequence_relations;
748 public JComboBox getSequenceRelationTypeBox() {
749 if ( _sequence_relation_type_box == null ) {
750 _sequence_relation_type_box = new JComboBox();
751 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
752 _sequence_relation_type_box.addItem( type );
754 _sequence_relation_type_box.addActionListener( new ActionListener() {
757 public void actionPerformed( final ActionEvent e ) {
758 if ( _mainpanel.getCurrentPhylogeny() != null ) {
759 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
764 return _sequence_relation_type_box;
767 public JCheckBox getShowEventsCb() {
771 List<String> getSingleClickToNames() {
772 return _click_to_names;
775 Map<String, Color> getSpeciesColors() {
776 return _species_colors;
779 public JCheckBox getWriteConfidenceCb() {
780 return _write_confidence;
783 private void init() {
784 _draw_phylogram = new ArrayList<Boolean>();
785 setSpeciesColors( new HashMap<String, Color>() );
786 setAnnotationColors( new HashMap<String, Color>() );
789 boolean isAntialiasScreenText() {
793 boolean isColorAccordingToAnnotation() {
794 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
797 boolean isColorAccordingToTaxonomy() {
798 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
801 boolean isColorBranches() {
802 return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) );
805 boolean isDrawPhylogram() {
806 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
809 private boolean isDrawPhylogram( final int index ) {
810 return getIsDrawPhylogramList().get( index );
813 boolean isDynamicallyHideData() {
814 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
818 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
821 boolean isNodeDescPopup() {
822 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
825 boolean isShowAnnotation() {
826 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
829 boolean isShowBinaryCharacterCounts() {
830 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
833 boolean isShowBinaryCharacters() {
834 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
837 boolean isShowConfidenceValues() {
838 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
841 boolean isShowDomainArchitectures() {
842 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
845 boolean isShowGeneNames() {
846 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
849 public boolean isShowVectorData() {
850 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
853 public boolean isShowProperties() {
854 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
857 boolean isShowGeneSymbols() {
858 return ( ( _show_gene_symbols != null ) && _show_gene_symbols.isSelected() );
861 boolean isShowInternalData() {
862 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
865 boolean isShowNodeNames() {
866 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
869 boolean isShowSequenceAcc() {
870 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
873 boolean isShowSequenceRelationConfidence() {
874 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
877 boolean isShowSequenceRelations() {
878 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
881 boolean isShowTaxonomyCode() {
882 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
885 public boolean isShowTaxonomyImages() {
886 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
889 boolean isShowTaxonomyCommonNames() {
890 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
893 boolean isShowTaxonomyScientificNames() {
894 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
897 boolean isWidthBranches() {
898 return ( ( _width_branches != null ) && _width_branches.isSelected() );
901 void phylogenyAdded( final Configuration configuration ) {
902 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
905 void phylogenyRemoved( final int index ) {
906 getIsDrawPhylogramList().remove( index );
910 final MainPanel main_panel = getMainPanel();
911 final Phylogeny tree = main_panel.getCurrentPhylogeny();
912 if ( ( tree == null ) || tree.isEmpty() ) {
915 String query = getSearchTextField().getText();
916 if ( query != null ) {
917 query = query.trim();
920 getSearchFoundCountsLabel().setVisible( false );
921 getSearchResetButton().setEnabled( false );
922 getSearchResetButton().setVisible( false );
925 if ( !ForesterUtil.isEmpty( query ) ) {
926 search( main_panel, tree, query );
929 getSearchFoundCountsLabel().setVisible( false );
930 getSearchResetButton().setEnabled( false );
931 getSearchResetButton().setVisible( false );
936 private void search( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
937 getSearchFoundCountsLabel().setVisible( true );
938 getSearchResetButton().setEnabled( true );
939 getSearchResetButton().setVisible( true );
940 String[] queries = null;
941 List<PhylogenyNode> nodes = null;
942 if ( query_str.indexOf( ',' ) >= 0 ) {
943 queries = query_str.split( ",+" );
946 queries = new String[ 1 ];
947 queries[ 0 ] = query_str.trim();
949 if ( ( queries != null ) && ( queries.length > 0 ) ) {
950 nodes = new ArrayList<PhylogenyNode>();
951 for( String query : queries ) {
952 if ( ForesterUtil.isEmpty( query ) ) {
955 query = query.trim();
956 if ( query.indexOf( '+' ) >= 0 ) {
957 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
959 getOptions().isSearchCaseSensitive(),
960 !getOptions().isMatchWholeTermsOnly(),
961 isShowDomainArchitectures() ) );
964 nodes.addAll( PhylogenyMethods.searchData( query,
966 getOptions().isSearchCaseSensitive(),
967 !getOptions().isMatchWholeTermsOnly(),
968 isShowDomainArchitectures() ) );
971 if ( getOptions().isInverseSearchResult() ) {
972 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
973 all.removeAll( nodes );
977 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
978 main_panel.getCurrentTreePanel().setFoundNodes( new HashSet<Integer>() );
979 for( final PhylogenyNode node : nodes ) {
980 main_panel.getCurrentTreePanel().getFoundNodes().add( node.getId() );
982 setSearchFoundCountsOnLabel( nodes.size() );
985 setSearchFoundCountsOnLabel( 0 );
990 private void searchReset() {
991 if ( getMainPanel().getCurrentTreePanel() != null ) {
992 getMainPanel().getCurrentTreePanel().setFoundNodes( null );
996 void setActionWhenNodeClicked( final NodeClickAction action ) {
997 _action_when_node_clicked = action;
1000 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
1001 _annotation_colors = annotation_colors;
1004 void setCheckbox( final int which, final boolean state ) {
1006 case Configuration.display_as_phylogram:
1007 if ( getDisplayAsPhylogramCb() != null ) {
1008 getDisplayAsPhylogramCb().setSelected( state );
1011 case Configuration.display_internal_data:
1012 if ( _display_internal_data != null ) {
1013 _display_internal_data.setSelected( state );
1016 case Configuration.color_according_to_species:
1017 if ( _color_acc_species != null ) {
1018 _color_acc_species.setSelected( state );
1021 case Configuration.color_according_to_annotation:
1022 if ( _color_according_to_annotation != null ) {
1023 _color_according_to_annotation.setSelected( state );
1026 case Configuration.show_node_names:
1027 if ( _show_node_names != null ) {
1028 _show_node_names.setSelected( state );
1031 case Configuration.show_taxonomy_scientific_names:
1032 if ( _show_taxo_scientific_names != null ) {
1033 _show_taxo_scientific_names.setSelected( state );
1036 case Configuration.show_taxonomy_common_names:
1037 if ( _show_taxo_common_names != null ) {
1038 _show_taxo_common_names.setSelected( state );
1041 case Configuration.show_tax_code:
1042 if ( _show_taxo_code != null ) {
1043 _show_taxo_code.setSelected( state );
1046 case Configuration.show_taxonomy_images:
1047 if ( _show_taxo_images_cb != null ) {
1048 _show_taxo_images_cb.setSelected( state );
1051 case Configuration.show_annotation:
1052 if ( _show_annotation != null ) {
1053 _show_annotation.setSelected( state );
1056 case Configuration.show_binary_characters:
1057 if ( _show_binary_characters != null ) {
1058 _show_binary_characters.setSelected( state );
1061 case Configuration.show_binary_character_counts:
1062 if ( _show_binary_character_counts != null ) {
1063 _show_binary_character_counts.setSelected( state );
1066 case Configuration.write_confidence_values:
1067 if ( getWriteConfidenceCb() != null ) {
1068 getWriteConfidenceCb().setSelected( state );
1071 case Configuration.write_events:
1072 if ( getShowEventsCb() != null ) {
1073 getShowEventsCb().setSelected( state );
1076 case Configuration.color_branches:
1077 if ( getColorBranchesCb() != null ) {
1078 getColorBranchesCb().setSelected( state );
1081 case Configuration.width_branches:
1082 if ( _width_branches != null ) {
1083 _width_branches.setSelected( state );
1086 case Configuration.show_domain_architectures:
1087 if ( _show_domain_architectures != null ) {
1088 _show_domain_architectures.setSelected( state );
1091 case Configuration.show_gene_names:
1092 if ( _show_gene_names != null ) {
1093 _show_gene_names.setSelected( state );
1096 case Configuration.show_gene_symbols:
1097 if ( _show_gene_symbols != null ) {
1098 _show_gene_symbols.setSelected( state );
1101 case Configuration.show_vector_data:
1102 if ( _show_vector_data_cb != null ) {
1103 _show_vector_data_cb.setSelected( state );
1106 case Configuration.show_properties:
1107 if ( _show_properties_cb != null ) {
1108 _show_properties_cb.setSelected( state );
1111 case Configuration.show_sequence_acc:
1112 if ( _show_sequence_acc != null ) {
1113 _show_sequence_acc.setSelected( state );
1116 case Configuration.dynamically_hide_data:
1117 if ( getDynamicallyHideData() != null ) {
1118 getDynamicallyHideData().setSelected( state );
1121 case Configuration.node_data_popup:
1122 if ( getNodeDescPopupCb() != null ) {
1123 getNodeDescPopupCb().setSelected( state );
1127 case Configuration.show_relation_confidence:
1128 if ( _seq_relation_confidence_switch != null ) {
1129 _seq_relation_confidence_switch.setSelected( state );
1134 throw new AssertionError( "unknown checkbox: " + which );
1139 * Set this checkbox state. Not all checkboxes have been instantiated
1140 * depending on the config.
1142 void setCheckbox( final JCheckBox cb, final boolean state ) {
1144 cb.setSelected( state );
1148 void setClickToAction( final int action ) {
1149 // Set click-to action
1150 if ( action == _show_data_item ) {
1151 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1153 else if ( action == _collapse_cb_item ) {
1154 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1156 else if ( action == _reroot_cb_item ) {
1157 setActionWhenNodeClicked( NodeClickAction.REROOT );
1159 else if ( action == _subtree_cb_item ) {
1160 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1162 else if ( action == _swap_cb_item ) {
1163 setActionWhenNodeClicked( NodeClickAction.SWAP );
1165 else if ( action == _color_subtree_cb_item ) {
1166 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1168 else if ( action == _open_seq_web_item ) {
1169 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1171 else if ( action == _sort_descendents_item ) {
1172 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1174 else if ( action == _blast_item ) {
1175 setActionWhenNodeClicked( NodeClickAction.BLAST );
1177 else if ( action == _open_tax_web_item ) {
1178 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1180 else if ( action == _cut_subtree_item ) {
1181 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1183 else if ( action == _copy_subtree_item ) {
1184 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1186 else if ( action == _delete_node_or_subtree_item ) {
1187 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1189 else if ( action == _paste_subtree_item ) {
1190 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1192 else if ( action == _add_new_node_item ) {
1193 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1195 else if ( action == _edit_node_data_item ) {
1196 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1198 else if ( action == _get_ext_desc_data ) {
1199 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
1202 throw new RuntimeException( "unknown action: " + action );
1204 // make sure drop down is displaying the correct action
1205 // in case this was called from outside the class
1206 _click_to_combobox.setSelectedIndex( action );
1209 void setColorBranches( final boolean color_branches ) {
1210 _color_branches = color_branches;
1213 void setDrawPhylogram( final boolean b ) {
1214 getDisplayAsPhylogramCb().setSelected( b );
1215 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1218 private void setDrawPhylogram( final int index, final boolean b ) {
1219 getIsDrawPhylogramList().set( index, b );
1222 void setDrawPhylogramEnabled( final boolean b ) {
1223 getDisplayAsPhylogramCb().setEnabled( b );
1226 void setDynamicHidingIsOn( final boolean is_on ) {
1227 // if ( !_configuration.isUseNativeUI() ) {
1229 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1232 if ( !_configuration.isUseNativeUI() ) {
1233 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1236 getDynamicallyHideData().setForeground( Color.BLACK );
1242 private void setSearchFoundCountsOnLabel( final int counts ) {
1243 getSearchFoundCountsLabel().setText( "Found: " + counts );
1246 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
1247 final JComboBox box = getSequenceRelationBox();
1248 while ( box.getItemCount() > 1 ) {
1249 box.removeItemAt( 1 );
1251 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
1252 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
1254 if ( relationType == null ) {
1257 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
1258 for( final Sequence seq : sequenceRelationQueries ) {
1259 if ( seq.hasSequenceRelations() ) {
1260 boolean fFoundForCurrentType = false;
1261 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
1262 if ( sq.getType().equals( relationType ) ) {
1263 fFoundForCurrentType = true;
1267 if ( fFoundForCurrentType ) {
1268 sequenceNamesToAdd.add( seq.getName() );
1269 sequencesByName.put( seq.getName(), seq );
1273 // sort sequences by name before adding them to the combo
1274 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
1275 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
1276 for( final String seqName : sequenceNameArray ) {
1277 box.addItem( seqName );
1279 for( final ItemListener oldItemListener : box.getItemListeners() ) {
1280 box.removeItemListener( oldItemListener );
1282 box.addItemListener( new ItemListener() {
1285 public void itemStateChanged( final ItemEvent e ) {
1286 _selected_query_seq = sequencesByName.get( e.getItem() );
1287 _mainpanel.getCurrentTreePanel().repaint();
1292 void setShowEvents( final boolean show_events ) {
1293 if ( getShowEventsCb() == null ) {
1294 _show_events = new JCheckBox( "" );
1296 getShowEventsCb().setSelected( show_events );
1299 void setSpeciesColors( final Map<String, Color> species_colors ) {
1300 _species_colors = species_colors;
1303 private void setupClickToOptions() {
1304 final int default_option = _configuration.getDefaultDisplayClicktoOption();
1305 int selected_index = 0;
1307 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1308 _show_data_item = cb_index;
1309 addClickToOption( Configuration.display_node_data,
1310 _configuration.getClickToTitle( Configuration.display_node_data ) );
1311 if ( default_option == Configuration.display_node_data ) {
1312 selected_index = cb_index;
1316 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1317 _collapse_cb_item = cb_index;
1318 addClickToOption( Configuration.collapse_uncollapse,
1319 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
1320 if ( default_option == Configuration.collapse_uncollapse ) {
1321 selected_index = cb_index;
1325 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1326 _reroot_cb_item = cb_index;
1327 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1328 if ( default_option == Configuration.reroot ) {
1329 selected_index = cb_index;
1333 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1334 _subtree_cb_item = cb_index;
1335 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1336 if ( default_option == Configuration.subtree ) {
1337 selected_index = cb_index;
1341 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1342 _swap_cb_item = cb_index;
1343 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1344 if ( default_option == Configuration.swap ) {
1345 selected_index = cb_index;
1349 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
1350 _sort_descendents_item = cb_index;
1351 addClickToOption( Configuration.sort_descendents,
1352 _configuration.getClickToTitle( Configuration.sort_descendents ) );
1353 if ( default_option == Configuration.sort_descendents ) {
1354 selected_index = cb_index;
1358 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1359 _color_subtree_cb_item = cb_index;
1360 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1361 if ( default_option == Configuration.color_subtree ) {
1362 selected_index = cb_index;
1366 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1367 _open_seq_web_item = cb_index;
1368 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1369 if ( default_option == Configuration.open_seq_web ) {
1370 selected_index = cb_index;
1374 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1375 _open_tax_web_item = cb_index;
1376 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1377 if ( default_option == Configuration.open_tax_web ) {
1378 selected_index = cb_index;
1382 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1383 _blast_item = cb_index;
1384 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
1385 if ( default_option == Configuration.blast ) {
1386 selected_index = cb_index;
1390 if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
1391 _get_ext_desc_data = cb_index;
1392 addClickToOption( Configuration.get_ext_desc_data,
1393 _configuration.getClickToTitle( Configuration.get_ext_desc_data ) );
1394 if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
1396 getConfiguration().getLabelForGetExtDescendentsData();
1399 if ( default_option == Configuration.get_ext_desc_data ) {
1400 selected_index = cb_index;
1404 if ( getOptions().isEditable() ) {
1405 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
1406 _cut_subtree_item = cb_index;
1407 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
1408 if ( default_option == Configuration.cut_subtree ) {
1409 selected_index = cb_index;
1413 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
1414 _copy_subtree_item = cb_index;
1415 addClickToOption( Configuration.copy_subtree,
1416 _configuration.getClickToTitle( Configuration.copy_subtree ) );
1417 if ( default_option == Configuration.copy_subtree ) {
1418 selected_index = cb_index;
1422 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
1423 _paste_subtree_item = cb_index;
1424 addClickToOption( Configuration.paste_subtree,
1425 _configuration.getClickToTitle( Configuration.paste_subtree ) );
1426 if ( default_option == Configuration.paste_subtree ) {
1427 selected_index = cb_index;
1431 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
1432 _delete_node_or_subtree_item = cb_index;
1433 addClickToOption( Configuration.delete_subtree_or_node,
1434 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
1435 if ( default_option == Configuration.delete_subtree_or_node ) {
1436 selected_index = cb_index;
1440 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
1441 _add_new_node_item = cb_index;
1442 addClickToOption( Configuration.add_new_node,
1443 _configuration.getClickToTitle( Configuration.add_new_node ) );
1444 if ( default_option == Configuration.add_new_node ) {
1445 selected_index = cb_index;
1449 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
1450 _edit_node_data_item = cb_index;
1451 addClickToOption( Configuration.edit_node_data,
1452 _configuration.getClickToTitle( Configuration.edit_node_data ) );
1453 if ( default_option == Configuration.edit_node_data ) {
1454 selected_index = cb_index;
1459 // Set default selection and its action
1460 _click_to_combobox.setSelectedIndex( selected_index );
1461 setClickToAction( selected_index );
1466 * Set up the controls from the config settings. 11/26/05
1468 void setupControls() {
1469 // The tree display options:
1470 setupDisplayCheckboxes();
1472 // The sequence relation query selection combo-box
1473 if ( _configuration.displaySequenceRelations() ) {
1474 addSequenceRelationBlock();
1478 startClickToOptions();
1479 setupClickToOptions();
1480 endClickToOptions();
1481 // Zoom and quick edit buttons
1486 void setUpControlsForDomainStrucures() {
1487 _domain_display_label = new JLabel( "Domain Display:" );
1488 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1489 add( _domain_display_label );
1490 _zoom_in_domain_structure = new JButton( "d+" );
1491 _zoom_out_domain_structure = new JButton( "d-" );
1492 _decr_domain_structure_evalue_thr = new JButton( "-" );
1493 _incr_domain_structure_evalue_thr = new JButton( "+" );
1494 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1495 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1496 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1497 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1498 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1499 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1500 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1501 _domain_structure_evalue_thr_tf.setEditable( false );
1502 if ( !getConfiguration().isUseNativeUI() ) {
1503 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1504 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1505 _domain_structure_evalue_thr_tf.setBorder( null );
1507 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1508 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1509 if ( !_configuration.isUseNativeUI() ) {
1510 d1_panel.setBackground( getBackground() );
1511 d2_panel.setBackground( getBackground() );
1515 addJButton( _zoom_out_domain_structure, d1_panel );
1516 addJButton( _zoom_in_domain_structure, d1_panel );
1517 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1518 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1519 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1522 private void setupDisplayCheckboxes() {
1523 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
1524 addCheckbox( Configuration.display_as_phylogram,
1525 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
1526 setCheckbox( Configuration.display_as_phylogram,
1527 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
1529 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1530 addCheckbox( Configuration.dynamically_hide_data,
1531 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
1532 setCheckbox( Configuration.dynamically_hide_data,
1533 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
1535 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1536 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1537 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1539 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1540 addCheckbox( Configuration.display_internal_data,
1541 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
1542 setCheckbox( Configuration.display_internal_data,
1543 _configuration.doCheckOption( Configuration.display_internal_data ) );
1545 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1546 addCheckbox( Configuration.color_according_to_species,
1547 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
1548 setCheckbox( Configuration.color_according_to_species,
1549 _configuration.doCheckOption( Configuration.color_according_to_species ) );
1551 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1552 addCheckbox( Configuration.color_according_to_annotation,
1553 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
1554 setCheckbox( Configuration.color_according_to_annotation,
1555 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
1557 if ( _configuration.doDisplayOption( Configuration.color_branches ) ) {
1558 addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) );
1559 setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) );
1561 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1562 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1563 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1565 final JLabel label = new JLabel( "Display Data:" );
1566 label.setFont( ControlPanel.jcb_bold_font );
1567 if ( !getConfiguration().isUseNativeUI() ) {
1568 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1571 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1572 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
1573 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1575 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1576 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1577 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1579 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1580 addCheckbox( Configuration.show_taxonomy_scientific_names,
1581 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1582 setCheckbox( Configuration.show_taxonomy_scientific_names,
1583 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1585 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1586 addCheckbox( Configuration.show_taxonomy_common_names,
1587 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1588 setCheckbox( Configuration.show_taxonomy_common_names,
1589 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1591 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1592 addCheckbox( Configuration.show_taxonomy_images,
1593 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1594 setCheckbox( Configuration.show_taxonomy_images,
1595 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1597 if ( _configuration.doDisplayOption( Configuration.show_gene_symbols ) ) {
1598 addCheckbox( Configuration.show_gene_symbols,
1599 _configuration.getDisplayTitle( Configuration.show_gene_symbols ) );
1600 setCheckbox( Configuration.show_gene_symbols,
1601 _configuration.doCheckOption( Configuration.show_gene_symbols ) );
1603 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1604 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1605 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1607 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1608 addCheckbox( Configuration.show_sequence_acc,
1609 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1610 setCheckbox( Configuration.show_sequence_acc,
1611 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1613 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1614 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
1615 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1617 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1618 addCheckbox( Configuration.show_binary_characters,
1619 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1620 setCheckbox( Configuration.show_binary_characters,
1621 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1623 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1624 addCheckbox( Configuration.show_binary_character_counts,
1625 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1626 setCheckbox( Configuration.show_binary_character_counts,
1627 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1629 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1630 addCheckbox( Configuration.show_domain_architectures,
1631 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1632 setCheckbox( Configuration.show_domain_architectures,
1633 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1635 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1636 addCheckbox( Configuration.write_confidence_values,
1637 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1638 setCheckbox( Configuration.write_confidence_values,
1639 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1641 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1642 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1643 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1645 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1646 addCheckbox( Configuration.show_vector_data,
1647 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1648 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
1650 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1651 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
1652 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1656 void setupSearchTools() {
1657 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1658 final JLabel search_label = new JLabel( "Search:" );
1659 search_label.setFont( ControlPanel.jcb_bold_font );
1660 if ( !getConfiguration().isUseNativeUI() ) {
1661 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1663 add( search_label );
1664 search_label.setToolTipText( tip );
1665 _search_found_label = new JLabel();
1666 getSearchFoundCountsLabel().setVisible( false );
1667 _search_found_label.setFont( ControlPanel.jcb_bold_font );
1668 if ( !getConfiguration().isUseNativeUI() ) {
1669 _search_found_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1671 _search_tf = new JTextField( 3 );
1672 _search_tf.setToolTipText( tip );
1673 _search_tf.setEditable( true );
1674 if ( !getConfiguration().isUseNativeUI() ) {
1675 _search_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1676 _search_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1677 _search_tf.setBorder( null );
1679 _search_reset_button = new JButton();
1680 getSearchResetButton().setText( "Reset" );
1681 getSearchResetButton().setEnabled( false );
1682 getSearchResetButton().setVisible( false );
1683 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1684 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1685 s_panel_1.setBackground( getBackground() );
1687 s_panel_2.setBackground( getBackground() );
1689 final KeyAdapter key_adapter = new KeyAdapter() {
1692 public void keyReleased( final KeyEvent key_event ) {
1694 displayedPhylogenyMightHaveChanged( true );
1697 final ActionListener action_listener = new ActionListener() {
1700 public void actionPerformed( final ActionEvent e ) {
1702 setSearchFoundCountsOnLabel( 0 );
1703 getSearchFoundCountsLabel().setVisible( false );
1704 getSearchTextField().setText( "" );
1705 getSearchResetButton().setEnabled( false );
1706 getSearchResetButton().setVisible( false );
1707 displayedPhylogenyMightHaveChanged( true );
1710 _search_reset_button.addActionListener( action_listener );
1711 _search_tf.addKeyListener( key_adapter );
1712 addJTextField( _search_tf, s_panel_1 );
1713 s_panel_2.add( _search_found_label );
1714 addJButton( _search_reset_button, s_panel_2 );
1717 private void setVisibilityOfDomainStrucureControls() {
1718 if ( _zoom_in_domain_structure != null ) {
1719 if ( isShowDomainArchitectures() ) {
1720 _domain_display_label.setVisible( true );
1721 _zoom_in_domain_structure.setVisible( true );
1722 _zoom_out_domain_structure.setVisible( true );
1723 _decr_domain_structure_evalue_thr.setVisible( true );
1724 _incr_domain_structure_evalue_thr.setVisible( true );
1725 _domain_structure_evalue_thr_tf.setVisible( true );
1728 _domain_display_label.setVisible( false );
1729 _zoom_in_domain_structure.setVisible( false );
1730 _zoom_out_domain_structure.setVisible( false );
1731 _decr_domain_structure_evalue_thr.setVisible( false );
1732 _incr_domain_structure_evalue_thr.setVisible( false );
1733 _domain_structure_evalue_thr_tf.setVisible( false );
1739 * Fit entire tree into window.
1742 if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
1745 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
1746 displayedPhylogenyMightHaveChanged( true );
1747 _mainpanel.getCurrentTreePanel().updateOvSettings();
1748 _mainpanel.getCurrentTreePanel().validate();
1749 _mainpanel.validate();
1750 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1751 _mainpanel.getSizeOfViewport().height,
1753 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1754 _mainpanel.adjustJScrollPane();
1755 _mainpanel.getCurrentTreePanel().repaint();
1756 _mainpanel.getCurrentTreePanel().validate();
1757 _mainpanel.validate();
1758 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1759 _mainpanel.getSizeOfViewport().height,
1761 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1762 _mainpanel.adjustJScrollPane();
1763 _mainpanel.getCurrentTreePanel().repaint();
1764 _mainpanel.getCurrentTreePanel().updateOvSizes();
1767 void showWholeAll() {
1768 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1769 if ( tree_panel != null ) {
1770 tree_panel.validate();
1771 tree_panel.setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1772 _mainpanel.getSizeOfViewport().height,
1774 tree_panel.resetPreferredSize();
1775 tree_panel.repaint();
1780 // Create header for click-to combo box.
1781 void startClickToOptions() {
1782 final JLabel spacer = new JLabel( "" );
1783 spacer.setFont( ControlPanel.jcb_font );
1785 _click_to_label = new JLabel( "Click on Node to:" );
1786 add( customizeLabel( _click_to_label, getConfiguration() ) );
1787 _click_to_combobox = new JComboBox();
1788 _click_to_combobox.setFocusable( false );
1789 _click_to_combobox.setMaximumRowCount( 14 );
1790 _click_to_combobox.setFont( ControlPanel.js_font );
1791 if ( !_configuration.isUseNativeUI() ) {
1792 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1794 // don't add listener until all items are set (or each one will trigger
1796 // click_to_list.addActionListener(this);
1797 add( _click_to_combobox );
1798 // Correlates option names to titles
1799 _all_click_to_names = new HashMap<Integer, String>();
1800 _click_to_names = new ArrayList<String>();
1804 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1805 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1806 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1807 setDrawPhylogramEnabled( true );
1808 setDrawPhylogram( isDrawPhylogram() );
1811 setDrawPhylogramEnabled( false );
1812 setDrawPhylogram( false );
1814 if ( getMainPanel().getMainFrame() == null ) {
1815 // Must be "E" applet version.
1816 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1817 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1820 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1821 .getPhylogenyGraphicsType() );
1823 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1824 getMainPanel().getControlPanel().search();
1825 getSequenceRelationTypeBox().removeAllItems();
1826 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1827 .getRelevantSequenceRelationTypes() ) {
1828 _sequence_relation_type_box.addItem( type );
1830 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1831 // according to GUILHEM the line above can be removed.
1836 * Uncollapse all nodes.
1838 void uncollapseAll( final TreePanel tp ) {
1839 final Phylogeny t = tp.getPhylogeny();
1840 if ( ( t != null ) && !t.isEmpty() ) {
1841 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
1842 final PhylogenyNode node = iter.next();
1843 node.setCollapse( false );
1845 tp.resetNodeIdToDistToLeafMap();
1846 tp.updateSetOfCollapsedExternalNodes();
1847 t.recalculateNumberOfExternalDescendants( false );
1848 tp.setNodeInPreorderToNull();
1849 t.clearHashIdToNodeMap();
1854 void updateDomainStructureEvaluethresholdDisplay() {
1855 if ( _domain_structure_evalue_thr_tf != null ) {
1856 _domain_structure_evalue_thr_tf.setText( "10^"
1857 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1861 void zoomInX( final float factor, final float x_correction_factor ) {
1862 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1863 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1864 treepanel.multiplyUrtFactor( 1f );
1865 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1866 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1867 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1868 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1869 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1870 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1871 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1872 getMainPanel().adjustJScrollPane();
1873 treepanel.resetPreferredSize();
1874 getMainPanel().getCurrentScrollPane().getViewport().validate();
1875 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1876 - ( sb.getVisibleAmount() / 2.0 ) ) );
1879 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1880 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1881 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1882 getMainPanel().adjustJScrollPane();
1883 treepanel.resetPreferredSize();
1884 getMainPanel().getCurrentScrollPane().getViewport().validate();
1885 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1887 treepanel.resetPreferredSize();
1888 treepanel.updateOvSizes();
1891 void zoomInY( final float factor ) {
1892 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1893 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1894 treepanel.multiplyUrtFactor( 1.1f );
1895 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1896 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1897 getMainPanel().adjustJScrollPane();
1898 treepanel.resetPreferredSize();
1899 getMainPanel().getCurrentScrollPane().getViewport().validate();
1900 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1901 - ( sb.getVisibleAmount() / 2.0 ) ) );
1902 treepanel.resetPreferredSize();
1903 treepanel.updateOvSizes();
1906 void zoomOutX( final float factor, final float x_correction_factor ) {
1907 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1908 treepanel.multiplyUrtFactor( 1f );
1909 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1910 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1911 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1912 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1913 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1914 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1915 getMainPanel().adjustJScrollPane();
1916 treepanel.resetPreferredSize();
1917 getMainPanel().getCurrentScrollPane().getViewport().validate();
1918 final double x = ( sb.getMaximum() - sb.getMinimum() )
1919 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1920 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1921 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1922 getMainPanel().adjustJScrollPane();
1923 treepanel.resetPreferredSize();
1924 getMainPanel().getCurrentScrollPane().getViewport().validate();
1925 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1926 - ( sb.getVisibleAmount() / 2.0 ) ) );
1929 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1930 treepanel.setXdistance( treepanel.getXdistance() * factor );
1931 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
1933 getMainPanel().adjustJScrollPane();
1934 treepanel.resetPreferredSize();
1935 getMainPanel().getCurrentScrollPane().getViewport().validate();
1936 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1939 treepanel.resetPreferredSize();
1940 treepanel.updateOvSizes();
1944 void zoomOutY( final float factor ) {
1945 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1946 treepanel.multiplyUrtFactor( 0.9f );
1947 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1948 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1949 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1950 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1951 getMainPanel().adjustJScrollPane();
1952 treepanel.resetPreferredSize();
1953 getMainPanel().getCurrentScrollPane().getViewport().validate();
1954 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1955 - ( sb.getVisibleAmount() / 2.0 ) ) );
1956 treepanel.resetPreferredSize();
1957 treepanel.updateOvSizes();
1961 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
1962 label.setFont( ControlPanel.jcb_bold_font );
1963 if ( !configuration.isUseNativeUI() ) {
1964 label.setForeground( configuration.getGuiCheckboxTextColor() );
1965 label.setBackground( configuration.getGuiBackgroundColor() );
1970 enum NodeClickAction {
1981 DELETE_NODE_OR_SUBTREE,