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 if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
1393 addClickToOption( Configuration.get_ext_desc_data, getConfiguration()
1394 .getLabelForGetExtDescendentsData() );
1398 switch ( getConfiguration().getExtDescNodeDataToReturn() ) {
1403 s = "Sequence Accessors";
1405 case SEQUENCE_MOL_SEQ:
1406 s = "Molecular Sequence";
1409 s = "Sequence Names";
1411 case SEQUENCE_SYMBOL:
1412 s = "Sequence Symbols";
1415 s = "Taxonomy Codes";
1417 case TAXONOMY_SCIENTIFIC_NAME:
1418 s = "Scientific Names";
1421 s = "User Selected Data";
1424 final String label = _configuration.getClickToTitle( Configuration.get_ext_desc_data ) + " " + s;
1425 addClickToOption( Configuration.get_ext_desc_data, label );
1427 if ( default_option == Configuration.get_ext_desc_data ) {
1428 selected_index = cb_index;
1432 if ( getOptions().isEditable() ) {
1433 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
1434 _cut_subtree_item = cb_index;
1435 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
1436 if ( default_option == Configuration.cut_subtree ) {
1437 selected_index = cb_index;
1441 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
1442 _copy_subtree_item = cb_index;
1443 addClickToOption( Configuration.copy_subtree,
1444 _configuration.getClickToTitle( Configuration.copy_subtree ) );
1445 if ( default_option == Configuration.copy_subtree ) {
1446 selected_index = cb_index;
1450 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
1451 _paste_subtree_item = cb_index;
1452 addClickToOption( Configuration.paste_subtree,
1453 _configuration.getClickToTitle( Configuration.paste_subtree ) );
1454 if ( default_option == Configuration.paste_subtree ) {
1455 selected_index = cb_index;
1459 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
1460 _delete_node_or_subtree_item = cb_index;
1461 addClickToOption( Configuration.delete_subtree_or_node,
1462 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
1463 if ( default_option == Configuration.delete_subtree_or_node ) {
1464 selected_index = cb_index;
1468 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
1469 _add_new_node_item = cb_index;
1470 addClickToOption( Configuration.add_new_node,
1471 _configuration.getClickToTitle( Configuration.add_new_node ) );
1472 if ( default_option == Configuration.add_new_node ) {
1473 selected_index = cb_index;
1477 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
1478 _edit_node_data_item = cb_index;
1479 addClickToOption( Configuration.edit_node_data,
1480 _configuration.getClickToTitle( Configuration.edit_node_data ) );
1481 if ( default_option == Configuration.edit_node_data ) {
1482 selected_index = cb_index;
1487 // Set default selection and its action
1488 _click_to_combobox.setSelectedIndex( selected_index );
1489 setClickToAction( selected_index );
1494 * Set up the controls from the config settings. 11/26/05
1496 void setupControls() {
1497 // The tree display options:
1498 setupDisplayCheckboxes();
1500 // The sequence relation query selection combo-box
1501 if ( _configuration.displaySequenceRelations() ) {
1502 addSequenceRelationBlock();
1506 startClickToOptions();
1507 setupClickToOptions();
1508 endClickToOptions();
1509 // Zoom and quick edit buttons
1514 void setUpControlsForDomainStrucures() {
1515 _domain_display_label = new JLabel( "Domain Display:" );
1516 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1517 add( _domain_display_label );
1518 _zoom_in_domain_structure = new JButton( "d+" );
1519 _zoom_out_domain_structure = new JButton( "d-" );
1520 _decr_domain_structure_evalue_thr = new JButton( "-" );
1521 _incr_domain_structure_evalue_thr = new JButton( "+" );
1522 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1523 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1524 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1525 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1526 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1527 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1528 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1529 _domain_structure_evalue_thr_tf.setEditable( false );
1530 if ( !getConfiguration().isUseNativeUI() ) {
1531 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1532 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1533 _domain_structure_evalue_thr_tf.setBorder( null );
1535 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1536 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1537 if ( !_configuration.isUseNativeUI() ) {
1538 d1_panel.setBackground( getBackground() );
1539 d2_panel.setBackground( getBackground() );
1543 addJButton( _zoom_out_domain_structure, d1_panel );
1544 addJButton( _zoom_in_domain_structure, d1_panel );
1545 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1546 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1547 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1550 private void setupDisplayCheckboxes() {
1551 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
1552 addCheckbox( Configuration.display_as_phylogram,
1553 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
1554 setCheckbox( Configuration.display_as_phylogram,
1555 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
1557 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1558 addCheckbox( Configuration.dynamically_hide_data,
1559 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
1560 setCheckbox( Configuration.dynamically_hide_data,
1561 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
1563 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1564 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1565 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1567 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1568 addCheckbox( Configuration.display_internal_data,
1569 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
1570 setCheckbox( Configuration.display_internal_data,
1571 _configuration.doCheckOption( Configuration.display_internal_data ) );
1573 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1574 addCheckbox( Configuration.color_according_to_species,
1575 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
1576 setCheckbox( Configuration.color_according_to_species,
1577 _configuration.doCheckOption( Configuration.color_according_to_species ) );
1579 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1580 addCheckbox( Configuration.color_according_to_annotation,
1581 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
1582 setCheckbox( Configuration.color_according_to_annotation,
1583 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
1585 if ( _configuration.doDisplayOption( Configuration.color_branches ) ) {
1586 addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) );
1587 setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) );
1589 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1590 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1591 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1593 final JLabel label = new JLabel( "Display Data:" );
1594 label.setFont( ControlPanel.jcb_bold_font );
1595 if ( !getConfiguration().isUseNativeUI() ) {
1596 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1599 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1600 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
1601 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1603 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1604 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1605 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1607 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1608 addCheckbox( Configuration.show_taxonomy_scientific_names,
1609 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1610 setCheckbox( Configuration.show_taxonomy_scientific_names,
1611 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1613 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1614 addCheckbox( Configuration.show_taxonomy_common_names,
1615 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1616 setCheckbox( Configuration.show_taxonomy_common_names,
1617 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1619 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1620 addCheckbox( Configuration.show_taxonomy_images,
1621 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1622 setCheckbox( Configuration.show_taxonomy_images,
1623 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1625 if ( _configuration.doDisplayOption( Configuration.show_gene_symbols ) ) {
1626 addCheckbox( Configuration.show_gene_symbols,
1627 _configuration.getDisplayTitle( Configuration.show_gene_symbols ) );
1628 setCheckbox( Configuration.show_gene_symbols,
1629 _configuration.doCheckOption( Configuration.show_gene_symbols ) );
1631 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1632 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1633 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1635 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1636 addCheckbox( Configuration.show_sequence_acc,
1637 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1638 setCheckbox( Configuration.show_sequence_acc,
1639 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1641 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1642 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
1643 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1645 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1646 addCheckbox( Configuration.show_binary_characters,
1647 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1648 setCheckbox( Configuration.show_binary_characters,
1649 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1651 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1652 addCheckbox( Configuration.show_binary_character_counts,
1653 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1654 setCheckbox( Configuration.show_binary_character_counts,
1655 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1657 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1658 addCheckbox( Configuration.show_domain_architectures,
1659 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1660 setCheckbox( Configuration.show_domain_architectures,
1661 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1663 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1664 addCheckbox( Configuration.write_confidence_values,
1665 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1666 setCheckbox( Configuration.write_confidence_values,
1667 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1669 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1670 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1671 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1673 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1674 addCheckbox( Configuration.show_vector_data,
1675 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1676 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
1678 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1679 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
1680 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1684 void setupSearchTools() {
1685 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1686 final JLabel search_label = new JLabel( "Search:" );
1687 search_label.setFont( ControlPanel.jcb_bold_font );
1688 if ( !getConfiguration().isUseNativeUI() ) {
1689 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1691 add( search_label );
1692 search_label.setToolTipText( tip );
1693 _search_found_label = new JLabel();
1694 getSearchFoundCountsLabel().setVisible( false );
1695 _search_found_label.setFont( ControlPanel.jcb_bold_font );
1696 if ( !getConfiguration().isUseNativeUI() ) {
1697 _search_found_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1699 _search_tf = new JTextField( 3 );
1700 _search_tf.setToolTipText( tip );
1701 _search_tf.setEditable( true );
1702 if ( !getConfiguration().isUseNativeUI() ) {
1703 _search_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1704 _search_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1705 _search_tf.setBorder( null );
1707 _search_reset_button = new JButton();
1708 getSearchResetButton().setText( "Reset" );
1709 getSearchResetButton().setEnabled( false );
1710 getSearchResetButton().setVisible( false );
1711 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1712 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1713 s_panel_1.setBackground( getBackground() );
1715 s_panel_2.setBackground( getBackground() );
1717 final KeyAdapter key_adapter = new KeyAdapter() {
1720 public void keyReleased( final KeyEvent key_event ) {
1722 displayedPhylogenyMightHaveChanged( true );
1725 final ActionListener action_listener = new ActionListener() {
1728 public void actionPerformed( final ActionEvent e ) {
1730 setSearchFoundCountsOnLabel( 0 );
1731 getSearchFoundCountsLabel().setVisible( false );
1732 getSearchTextField().setText( "" );
1733 getSearchResetButton().setEnabled( false );
1734 getSearchResetButton().setVisible( false );
1735 displayedPhylogenyMightHaveChanged( true );
1738 _search_reset_button.addActionListener( action_listener );
1739 _search_tf.addKeyListener( key_adapter );
1740 addJTextField( _search_tf, s_panel_1 );
1741 s_panel_2.add( _search_found_label );
1742 addJButton( _search_reset_button, s_panel_2 );
1745 private void setVisibilityOfDomainStrucureControls() {
1746 if ( _zoom_in_domain_structure != null ) {
1747 if ( isShowDomainArchitectures() ) {
1748 _domain_display_label.setVisible( true );
1749 _zoom_in_domain_structure.setVisible( true );
1750 _zoom_out_domain_structure.setVisible( true );
1751 _decr_domain_structure_evalue_thr.setVisible( true );
1752 _incr_domain_structure_evalue_thr.setVisible( true );
1753 _domain_structure_evalue_thr_tf.setVisible( true );
1756 _domain_display_label.setVisible( false );
1757 _zoom_in_domain_structure.setVisible( false );
1758 _zoom_out_domain_structure.setVisible( false );
1759 _decr_domain_structure_evalue_thr.setVisible( false );
1760 _incr_domain_structure_evalue_thr.setVisible( false );
1761 _domain_structure_evalue_thr_tf.setVisible( false );
1767 * Fit entire tree into window.
1770 if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
1773 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
1774 displayedPhylogenyMightHaveChanged( true );
1775 _mainpanel.getCurrentTreePanel().updateOvSettings();
1776 _mainpanel.getCurrentTreePanel().validate();
1777 _mainpanel.validate();
1778 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1779 _mainpanel.getSizeOfViewport().height,
1781 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1782 _mainpanel.adjustJScrollPane();
1783 _mainpanel.getCurrentTreePanel().repaint();
1784 _mainpanel.getCurrentTreePanel().validate();
1785 _mainpanel.validate();
1786 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1787 _mainpanel.getSizeOfViewport().height,
1789 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1790 _mainpanel.adjustJScrollPane();
1791 _mainpanel.getCurrentTreePanel().repaint();
1792 _mainpanel.getCurrentTreePanel().updateOvSizes();
1795 void showWholeAll() {
1796 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1797 if ( tree_panel != null ) {
1798 tree_panel.validate();
1799 tree_panel.setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1800 _mainpanel.getSizeOfViewport().height,
1802 tree_panel.resetPreferredSize();
1803 tree_panel.repaint();
1808 // Create header for click-to combo box.
1809 void startClickToOptions() {
1810 final JLabel spacer = new JLabel( "" );
1811 spacer.setFont( ControlPanel.jcb_font );
1813 _click_to_label = new JLabel( "Click on Node to:" );
1814 add( customizeLabel( _click_to_label, getConfiguration() ) );
1815 _click_to_combobox = new JComboBox();
1816 _click_to_combobox.setFocusable( false );
1817 _click_to_combobox.setMaximumRowCount( 14 );
1818 _click_to_combobox.setFont( ControlPanel.js_font );
1819 if ( !_configuration.isUseNativeUI() ) {
1820 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1822 // don't add listener until all items are set (or each one will trigger
1824 // click_to_list.addActionListener(this);
1825 add( _click_to_combobox );
1826 // Correlates option names to titles
1827 _all_click_to_names = new HashMap<Integer, String>();
1828 _click_to_names = new ArrayList<String>();
1832 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1833 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1834 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1835 setDrawPhylogramEnabled( true );
1836 setDrawPhylogram( isDrawPhylogram() );
1839 setDrawPhylogramEnabled( false );
1840 setDrawPhylogram( false );
1842 if ( getMainPanel().getMainFrame() == null ) {
1843 // Must be "E" applet version.
1844 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1845 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1848 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1849 .getPhylogenyGraphicsType() );
1851 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1852 getMainPanel().getControlPanel().search();
1853 getSequenceRelationTypeBox().removeAllItems();
1854 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1855 .getRelevantSequenceRelationTypes() ) {
1856 _sequence_relation_type_box.addItem( type );
1858 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1859 // according to GUILHEM the line above can be removed.
1864 * Uncollapse all nodes.
1866 void uncollapseAll( final TreePanel tp ) {
1867 final Phylogeny t = tp.getPhylogeny();
1868 if ( ( t != null ) && !t.isEmpty() ) {
1869 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
1870 final PhylogenyNode node = iter.next();
1871 node.setCollapse( false );
1873 tp.resetNodeIdToDistToLeafMap();
1874 tp.updateSetOfCollapsedExternalNodes();
1875 t.recalculateNumberOfExternalDescendants( false );
1876 tp.setNodeInPreorderToNull();
1877 t.clearHashIdToNodeMap();
1882 void updateDomainStructureEvaluethresholdDisplay() {
1883 if ( _domain_structure_evalue_thr_tf != null ) {
1884 _domain_structure_evalue_thr_tf.setText( "10^"
1885 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1889 void zoomInX( final float factor, final float x_correction_factor ) {
1890 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1891 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1892 treepanel.multiplyUrtFactor( 1f );
1893 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1894 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1895 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1896 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1897 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1898 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1899 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1900 getMainPanel().adjustJScrollPane();
1901 treepanel.resetPreferredSize();
1902 getMainPanel().getCurrentScrollPane().getViewport().validate();
1903 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1904 - ( sb.getVisibleAmount() / 2.0 ) ) );
1907 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1908 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1909 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1910 getMainPanel().adjustJScrollPane();
1911 treepanel.resetPreferredSize();
1912 getMainPanel().getCurrentScrollPane().getViewport().validate();
1913 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1915 treepanel.resetPreferredSize();
1916 treepanel.updateOvSizes();
1919 void zoomInY( final float factor ) {
1920 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1921 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1922 treepanel.multiplyUrtFactor( 1.1f );
1923 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1924 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1925 getMainPanel().adjustJScrollPane();
1926 treepanel.resetPreferredSize();
1927 getMainPanel().getCurrentScrollPane().getViewport().validate();
1928 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1929 - ( sb.getVisibleAmount() / 2.0 ) ) );
1930 treepanel.resetPreferredSize();
1931 treepanel.updateOvSizes();
1934 void zoomOutX( final float factor, final float x_correction_factor ) {
1935 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1936 treepanel.multiplyUrtFactor( 1f );
1937 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1938 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1939 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1940 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1941 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1942 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1943 getMainPanel().adjustJScrollPane();
1944 treepanel.resetPreferredSize();
1945 getMainPanel().getCurrentScrollPane().getViewport().validate();
1946 final double x = ( sb.getMaximum() - sb.getMinimum() )
1947 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1948 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1949 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1950 getMainPanel().adjustJScrollPane();
1951 treepanel.resetPreferredSize();
1952 getMainPanel().getCurrentScrollPane().getViewport().validate();
1953 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1954 - ( sb.getVisibleAmount() / 2.0 ) ) );
1957 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1958 treepanel.setXdistance( treepanel.getXdistance() * factor );
1959 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
1961 getMainPanel().adjustJScrollPane();
1962 treepanel.resetPreferredSize();
1963 getMainPanel().getCurrentScrollPane().getViewport().validate();
1964 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1967 treepanel.resetPreferredSize();
1968 treepanel.updateOvSizes();
1972 void zoomOutY( final float factor ) {
1973 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1974 treepanel.multiplyUrtFactor( 0.9f );
1975 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1976 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1977 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1978 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1979 getMainPanel().adjustJScrollPane();
1980 treepanel.resetPreferredSize();
1981 getMainPanel().getCurrentScrollPane().getViewport().validate();
1982 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1983 - ( sb.getVisibleAmount() / 2.0 ) ) );
1984 treepanel.resetPreferredSize();
1985 treepanel.updateOvSizes();
1989 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
1990 label.setFont( ControlPanel.jcb_bold_font );
1991 if ( !configuration.isUseNativeUI() ) {
1992 label.setForeground( configuration.getGuiCheckboxTextColor() );
1993 label.setBackground( configuration.getGuiBackgroundColor() );
1998 enum NodeClickAction {
2009 DELETE_NODE_OR_SUBTREE,