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 ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
216 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
217 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
221 else if ( e.getSource() == _zoom_in_x ) {
222 zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
223 displayedPhylogenyMightHaveChanged( false );
225 else if ( e.getSource() == _zoom_in_y ) {
226 zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR );
227 displayedPhylogenyMightHaveChanged( false );
229 else if ( e.getSource() == _zoom_out_x ) {
230 zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
231 displayedPhylogenyMightHaveChanged( false );
233 else if ( e.getSource() == _zoom_out_y ) {
234 zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR );
235 displayedPhylogenyMightHaveChanged( false );
237 else if ( e.getSource() == _show_whole ) {
240 else if ( e.getSource() == _return_to_super_tree ) {
241 _mainpanel.getCurrentTreePanel().superTree();
244 else if ( e.getSource() == _order ) {
245 DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
246 if ( ( !isShowTaxonomyScientificNames() && !isShowTaxonomyCode() && !isShowTaxonomyCommonNames() ) ) {
247 if ( ( isShowSequenceAcc() || isShowGeneNames() || isShowGeneSymbols() ) ) {
248 pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
250 else if ( isShowNodeNames() ) {
251 pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
254 PhylogenyMethods.orderAppearance( tp.getPhylogeny().getRoot(), _order_of_appearance, true, pri );
255 _order_of_appearance = !_order_of_appearance;
256 tp.setNodeInPreorderToNull();
257 tp.getPhylogeny().externalNodesHaveChanged();
258 tp.getPhylogeny().clearHashIdToNodeMap();
259 tp.getPhylogeny().recalculateNumberOfExternalDescendants( true );
260 tp.resetNodeIdToDistToLeafMap();
261 tp.setEdited( true );
262 displayedPhylogenyMightHaveChanged( false );
264 else if ( e.getSource() == _uncollapse_all ) {
266 displayedPhylogenyMightHaveChanged( false );
268 else if ( e.getSource() == _zoom_in_domain_structure ) {
269 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
270 displayedPhylogenyMightHaveChanged( true );
272 else if ( e.getSource() == _zoom_out_domain_structure ) {
273 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
274 displayedPhylogenyMightHaveChanged( true );
276 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
277 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThreshold();
278 displayedPhylogenyMightHaveChanged( true );
280 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
281 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThreshold();
282 displayedPhylogenyMightHaveChanged( true );
284 else if ( e.getSource() == _search_tf ) {
286 displayedPhylogenyMightHaveChanged( true );
289 displayedPhylogenyMightHaveChanged( true );
293 tp.requestFocusInWindow();
296 catch ( final Exception ex ) {
297 AptxUtil.unexpectedException( ex );
299 catch ( final Error err ) {
300 AptxUtil.unexpectedError( err );
304 void activateButtonToReturnToSuperTree( int index ) {
307 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
310 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
312 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
313 _return_to_super_tree.setEnabled( true );
317 * Add zoom and quick edit buttons. (Last modified 8/9/04)
320 final JLabel spacer = new JLabel( "" );
321 spacer.setOpaque( false );
323 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
324 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
325 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
326 if ( !getConfiguration().isUseNativeUI() ) {
327 x_panel.setBackground( getBackground() );
328 y_panel.setBackground( getBackground() );
329 z_panel.setBackground( getBackground() );
331 add( _zoom_label = new JLabel( "Zoom:" ) );
332 customizeLabel( _zoom_label, getConfiguration() );
336 if ( getConfiguration().isUseNativeUI() ) {
337 _zoom_in_x = new JButton( "+" );
338 _zoom_out_x = new JButton( "-" );
341 _zoom_in_x = new JButton( "X+" );
342 _zoom_out_x = new JButton( "X-" );
344 _zoom_in_y = new JButton( "Y+" );
345 _zoom_out_y = new JButton( "Y-" );
346 _show_whole = new JButton( "F" );
347 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [Backspace]" );
348 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+Right]" );
349 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+Up]" );
350 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+Left]" );
351 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+Down]" );
352 if ( getConfiguration().isUseNativeUI() && AptxUtil.isMac() ) {
353 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
354 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
357 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
358 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
360 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
361 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
362 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
363 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
364 _return_to_super_tree.setEnabled( false );
365 _order = new JButton( "Order Subtrees" );
366 _uncollapse_all = new JButton( "Uncollapse All" );
367 addJButton( _zoom_in_y, x_panel );
368 addJButton( _zoom_out_x, y_panel );
369 addJButton( _show_whole, y_panel );
370 addJButton( _zoom_in_x, y_panel );
371 addJButton( _zoom_out_y, z_panel );
372 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
373 setUpControlsForDomainStrucures();
375 final JLabel spacer2 = new JLabel( "" );
377 addJButton( _return_to_super_tree, this );
378 addJButton( _order, this );
379 addJButton( _uncollapse_all, this );
380 final JLabel spacer3 = new JLabel( "" );
382 setVisibilityOfDomainStrucureControls();
385 void addCheckbox( final int which, final String title ) {
386 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
388 case Configuration.display_as_phylogram:
389 _display_as_phylogram_cb = new JCheckBox( title );
390 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
391 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
394 case Configuration.display_internal_data:
395 _display_internal_data = new JCheckBox( title );
396 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
397 addJCheckBox( _display_internal_data, ch_panel );
400 case Configuration.color_according_to_species:
401 _color_acc_species = new JCheckBox( title );
403 .setToolTipText( "To colorize taxonomy and sequence labels as a function of taxonomy" );
404 addJCheckBox( _color_acc_species, ch_panel );
407 case Configuration.color_according_to_annotation:
408 _color_according_to_annotation = new JCheckBox( title );
409 _color_according_to_annotation
410 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
411 addJCheckBox( _color_according_to_annotation, ch_panel );
414 case Configuration.show_node_names:
415 _show_node_names = new JCheckBox( title );
416 addJCheckBox( _show_node_names, ch_panel );
419 case Configuration.show_taxonomy_scientific_names:
420 _show_taxo_scientific_names = new JCheckBox( title );
421 addJCheckBox( _show_taxo_scientific_names, ch_panel );
424 case Configuration.show_taxonomy_common_names:
425 _show_taxo_common_names = new JCheckBox( title );
426 addJCheckBox( _show_taxo_common_names, ch_panel );
429 case Configuration.show_tax_code:
430 _show_taxo_code = new JCheckBox( title );
431 addJCheckBox( _show_taxo_code, ch_panel );
434 case Configuration.show_taxonomy_images:
435 _show_taxo_images_cb = new JCheckBox( title );
436 addJCheckBox( _show_taxo_images_cb, ch_panel );
439 case Configuration.show_binary_characters:
440 _show_binary_characters = new JCheckBox( title );
441 addJCheckBox( _show_binary_characters, ch_panel );
444 case Configuration.show_annotation:
445 _show_annotation = new JCheckBox( title );
446 addJCheckBox( _show_annotation, ch_panel );
449 case Configuration.show_binary_character_counts:
450 _show_binary_character_counts = new JCheckBox( title );
451 addJCheckBox( _show_binary_character_counts, ch_panel );
454 case Configuration.write_confidence_values:
455 _write_confidence = new JCheckBox( title );
456 addJCheckBox( getWriteConfidenceCb(), ch_panel );
459 case Configuration.write_events:
460 _show_events = new JCheckBox( title );
461 addJCheckBox( getShowEventsCb(), ch_panel );
464 case Configuration.color_branches:
465 _color_branches_cb = new JCheckBox( title );
466 getColorBranchesCb().setToolTipText( "To use branch color values, if present" );
467 addJCheckBox( getColorBranchesCb(), ch_panel );
470 case Configuration.width_branches:
471 _width_branches = new JCheckBox( title );
472 _width_branches.setToolTipText( "To use branch width values, if present" );
473 addJCheckBox( _width_branches, ch_panel );
476 case Configuration.show_domain_architectures:
477 _show_domain_architectures = new JCheckBox( title );
478 addJCheckBox( _show_domain_architectures, ch_panel );
481 case Configuration.show_gene_names:
482 _show_gene_names = new JCheckBox( title );
483 addJCheckBox( _show_gene_names, ch_panel );
486 case Configuration.show_gene_symbols:
487 _show_gene_symbols = new JCheckBox( title );
488 addJCheckBox( _show_gene_symbols, ch_panel );
491 case Configuration.show_sequence_acc:
492 _show_sequence_acc = new JCheckBox( title );
493 addJCheckBox( _show_sequence_acc, ch_panel );
496 case Configuration.dynamically_hide_data:
497 _dynamically_hide_data = new JCheckBox( title );
498 getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" );
499 addJCheckBox( getDynamicallyHideData(), ch_panel );
502 case Configuration.node_data_popup:
503 _node_desc_popup_cb = new JCheckBox( title );
504 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
505 addJCheckBox( getNodeDescPopupCb(), ch_panel );
508 case Configuration.show_relation_confidence:
509 _seq_relation_confidence_switch = new JCheckBox( title );
510 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
513 case Configuration.show_vector_data:
514 _show_vector_data_cb = new JCheckBox( title );
515 addJCheckBox( _show_vector_data_cb, ch_panel );
518 case Configuration.show_properties:
519 _show_properties_cb = new JCheckBox( title );
520 addJCheckBox( _show_properties_cb, ch_panel );
524 throw new RuntimeException( "unknown checkbox: " + which );
528 private void addClickToOption( final int which, final String title ) {
529 _click_to_combobox.addItem( title );
530 _click_to_names.add( title );
531 _all_click_to_names.put( new Integer( which ), title );
532 if ( !_configuration.isUseNativeUI() ) {
533 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
534 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
538 void addJButton( final JButton jb, final JPanel p ) {
539 jb.setFocusPainted( false );
540 jb.setFont( ControlPanel.jcb_font );
541 if ( !_configuration.isUseNativeUI() ) {
542 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
543 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
544 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
547 jb.addActionListener( this );
550 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
551 jcb.setFocusPainted( false );
552 jcb.setFont( ControlPanel.jcb_font );
553 if ( !_configuration.isUseNativeUI() ) {
554 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
555 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
557 p.add( jcb, "Center" );
558 jcb.addActionListener( this );
561 void addJTextField( final JTextField tf, final JPanel p ) {
562 if ( !_configuration.isUseNativeUI() ) {
563 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
564 tf.setFont( ControlPanel.jcb_font );
567 tf.addActionListener( this );
571 private void addSequenceRelationBlock() {
572 final JLabel spacer = new JLabel( "" );
573 spacer.setSize( 1, 1 );
575 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
576 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
577 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
578 getSequenceRelationTypeBox().setFocusable( false );
579 _sequence_relation_type_box.setFont( ControlPanel.js_font );
580 if ( !_configuration.isUseNativeUI() ) {
581 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
582 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
584 _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
587 public Component getListCellRendererComponent( final JList list,
590 final boolean isSelected,
591 final boolean cellHasFocus ) {
592 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
597 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
598 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
599 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
604 final GridBagLayout gbl = new GridBagLayout();
605 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
606 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
607 final JPanel horizGrid = new JPanel( gbl );
608 horizGrid.setBackground( getBackground() );
609 horizGrid.add( typeLabel );
610 horizGrid.add( _sequence_relation_type_box );
611 add( customizeLabel( mainLabel, getConfiguration() ) );
613 add( getSequenceRelationBox() );
614 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
615 addCheckbox( Configuration.show_relation_confidence,
616 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
617 setCheckbox( Configuration.show_relation_confidence,
618 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
620 }// addSequenceRelationBlock
622 void deactivateButtonToReturnToSuperTree() {
623 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
624 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
625 _return_to_super_tree.setEnabled( false );
628 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
629 if ( ( _mainpanel != null )
630 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
631 if ( getOptions().isShowOverview() ) {
632 _mainpanel.getCurrentTreePanel().updateOvSizes();
634 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
635 setVisibilityOfDomainStrucureControls();
636 updateDomainStructureEvaluethresholdDisplay();
637 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
638 _mainpanel.getCurrentTreePanel().calcMaxDepth();
639 _mainpanel.adjustJScrollPane();
640 if ( recalc_longest_ext_node_info ) {
641 _mainpanel.getCurrentTreePanel().initNodeData();
642 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
644 _mainpanel.getCurrentTreePanel().repaint();
645 // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
649 void endClickToOptions() {
650 _click_to_combobox.addActionListener( this );
654 * Indicates what action should be execute when a node is clicked
656 * @return the click-on action
658 NodeClickAction getActionWhenNodeClicked() {
659 return _action_when_node_clicked;
662 Map<Integer, String> getAllClickToItems() {
663 return _all_click_to_names;
666 Map<String, Color> getAnnotationColors() {
667 return _annotation_colors;
670 public JCheckBox getColorBranchesCb() {
671 return _color_branches_cb;
674 public JCheckBox getColorAccSpeciesCb() {
675 return _color_acc_species;
678 Configuration getConfiguration() {
679 return _configuration;
682 TreePanel getCurrentTreePanel() {
683 return getMainPanel().getCurrentTreePanel();
686 public JCheckBox getDisplayAsPhylogramCb() {
687 return _display_as_phylogram_cb;
690 public JCheckBox getDynamicallyHideData() {
691 return _dynamically_hide_data;
695 private List<Boolean> getIsDrawPhylogramList() {
696 return _draw_phylogram;
699 MainPanel getMainPanel() {
703 public JCheckBox getNodeDescPopupCb() {
704 return _node_desc_popup_cb;
707 Options getOptions() {
708 return getMainPanel().getOptions();
711 private JLabel getSearchFoundCountsLabel() {
712 return _search_found_label;
715 private JButton getSearchResetButton() {
716 return _search_reset_button;
719 JTextField getSearchTextField() {
723 public Sequence getSelectedQuerySequence() {
724 return _selected_query_seq;
727 public JComboBox getSequenceRelationBox() {
728 if ( _show_sequence_relations == null ) {
729 _show_sequence_relations = new JComboBox();
730 _show_sequence_relations.setFocusable( false );
731 _show_sequence_relations.setMaximumRowCount( 20 );
732 _show_sequence_relations.setFont( ControlPanel.js_font );
733 if ( !_configuration.isUseNativeUI() ) {
734 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
735 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
737 _show_sequence_relations.addItem( "-----" );
738 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
740 return _show_sequence_relations;
744 public JComboBox getSequenceRelationTypeBox() {
745 if ( _sequence_relation_type_box == null ) {
746 _sequence_relation_type_box = new JComboBox();
747 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
748 _sequence_relation_type_box.addItem( type );
750 _sequence_relation_type_box.addActionListener( new ActionListener() {
753 public void actionPerformed( final ActionEvent e ) {
754 if ( _mainpanel.getCurrentPhylogeny() != null ) {
755 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
760 return _sequence_relation_type_box;
763 public JCheckBox getShowEventsCb() {
767 List<String> getSingleClickToNames() {
768 return _click_to_names;
771 Map<String, Color> getSpeciesColors() {
772 return _species_colors;
775 public JCheckBox getWriteConfidenceCb() {
776 return _write_confidence;
779 private void init() {
780 _draw_phylogram = new ArrayList<Boolean>();
781 setSpeciesColors( new HashMap<String, Color>() );
782 setAnnotationColors( new HashMap<String, Color>() );
785 boolean isAntialiasScreenText() {
789 boolean isColorAccordingToAnnotation() {
790 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
793 boolean isColorAccordingToTaxonomy() {
794 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
797 boolean isColorBranches() {
798 return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) );
801 boolean isDrawPhylogram() {
802 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
805 private boolean isDrawPhylogram( final int index ) {
806 return getIsDrawPhylogramList().get( index );
809 boolean isDynamicallyHideData() {
810 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
814 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
817 boolean isNodeDescPopup() {
818 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
821 boolean isShowAnnotation() {
822 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
825 boolean isShowBinaryCharacterCounts() {
826 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
829 boolean isShowBinaryCharacters() {
830 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
833 boolean isShowConfidenceValues() {
834 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
837 boolean isShowDomainArchitectures() {
838 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
841 boolean isShowGeneNames() {
842 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
845 public boolean isShowVectorData() {
846 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
849 public boolean isShowProperties() {
850 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
853 boolean isShowGeneSymbols() {
854 return ( ( _show_gene_symbols != null ) && _show_gene_symbols.isSelected() );
857 boolean isShowInternalData() {
858 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
861 boolean isShowNodeNames() {
862 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
865 boolean isShowSequenceAcc() {
866 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
869 boolean isShowSequenceRelationConfidence() {
870 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
873 boolean isShowSequenceRelations() {
874 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
877 boolean isShowTaxonomyCode() {
878 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
881 public boolean isShowTaxonomyImages() {
882 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
885 boolean isShowTaxonomyCommonNames() {
886 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
889 boolean isShowTaxonomyScientificNames() {
890 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
893 boolean isWidthBranches() {
894 return ( ( _width_branches != null ) && _width_branches.isSelected() );
897 void phylogenyAdded( final Configuration configuration ) {
898 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
901 void phylogenyRemoved( final int index ) {
902 getIsDrawPhylogramList().remove( index );
906 final MainPanel main_panel = getMainPanel();
907 final Phylogeny tree = main_panel.getCurrentPhylogeny();
908 if ( ( tree == null ) || tree.isEmpty() ) {
911 String query = getSearchTextField().getText();
912 if ( query != null ) {
913 query = query.trim();
916 getSearchFoundCountsLabel().setVisible( false );
917 getSearchResetButton().setEnabled( false );
918 getSearchResetButton().setVisible( false );
921 if ( !ForesterUtil.isEmpty( query ) ) {
922 search( main_panel, tree, query );
925 getSearchFoundCountsLabel().setVisible( false );
926 getSearchResetButton().setEnabled( false );
927 getSearchResetButton().setVisible( false );
932 private void search( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
933 getSearchFoundCountsLabel().setVisible( true );
934 getSearchResetButton().setEnabled( true );
935 getSearchResetButton().setVisible( true );
936 String[] queries = null;
937 List<PhylogenyNode> nodes = null;
938 if ( query_str.indexOf( ',' ) >= 0 ) {
939 queries = query_str.split( ",+" );
942 queries = new String[ 1 ];
943 queries[ 0 ] = query_str.trim();
945 if ( ( queries != null ) && ( queries.length > 0 ) ) {
946 nodes = new ArrayList<PhylogenyNode>();
947 for( String query : queries ) {
948 if ( ForesterUtil.isEmpty( query ) ) {
951 query = query.trim();
952 if ( query.indexOf( '+' ) >= 0 ) {
953 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ), tree, getOptions()
954 .isSearchCaseSensitive(), !getOptions().isMatchWholeTermsOnly() ) );
957 nodes.addAll( PhylogenyMethods.searchData( query,
959 getOptions().isSearchCaseSensitive(),
960 !getOptions().isMatchWholeTermsOnly() ) );
963 if ( getOptions().isInverseSearchResult() ) {
964 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
965 all.removeAll( nodes );
969 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
970 main_panel.getCurrentTreePanel().setFoundNodes( new HashSet<Integer>() );
971 for( final PhylogenyNode node : nodes ) {
972 main_panel.getCurrentTreePanel().getFoundNodes().add( node.getId() );
974 setSearchFoundCountsOnLabel( nodes.size() );
977 setSearchFoundCountsOnLabel( 0 );
982 private void searchReset() {
983 if ( getMainPanel().getCurrentTreePanel() != null ) {
984 getMainPanel().getCurrentTreePanel().setFoundNodes( null );
988 void setActionWhenNodeClicked( final NodeClickAction action ) {
989 _action_when_node_clicked = action;
992 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
993 _annotation_colors = annotation_colors;
996 void setCheckbox( final int which, final boolean state ) {
998 case Configuration.display_as_phylogram:
999 if ( getDisplayAsPhylogramCb() != null ) {
1000 getDisplayAsPhylogramCb().setSelected( state );
1003 case Configuration.display_internal_data:
1004 if ( _display_internal_data != null ) {
1005 _display_internal_data.setSelected( state );
1008 case Configuration.color_according_to_species:
1009 if ( _color_acc_species != null ) {
1010 _color_acc_species.setSelected( state );
1013 case Configuration.color_according_to_annotation:
1014 if ( _color_according_to_annotation != null ) {
1015 _color_according_to_annotation.setSelected( state );
1018 case Configuration.show_node_names:
1019 if ( _show_node_names != null ) {
1020 _show_node_names.setSelected( state );
1023 case Configuration.show_taxonomy_scientific_names:
1024 if ( _show_taxo_scientific_names != null ) {
1025 _show_taxo_scientific_names.setSelected( state );
1028 case Configuration.show_taxonomy_common_names:
1029 if ( _show_taxo_common_names != null ) {
1030 _show_taxo_common_names.setSelected( state );
1033 case Configuration.show_tax_code:
1034 if ( _show_taxo_code != null ) {
1035 _show_taxo_code.setSelected( state );
1038 case Configuration.show_taxonomy_images:
1039 if ( _show_taxo_images_cb != null ) {
1040 _show_taxo_images_cb.setSelected( state );
1043 case Configuration.show_annotation:
1044 if ( _show_annotation != null ) {
1045 _show_annotation.setSelected( state );
1048 case Configuration.show_binary_characters:
1049 if ( _show_binary_characters != null ) {
1050 _show_binary_characters.setSelected( state );
1053 case Configuration.show_binary_character_counts:
1054 if ( _show_binary_character_counts != null ) {
1055 _show_binary_character_counts.setSelected( state );
1058 case Configuration.write_confidence_values:
1059 if ( getWriteConfidenceCb() != null ) {
1060 getWriteConfidenceCb().setSelected( state );
1063 case Configuration.write_events:
1064 if ( getShowEventsCb() != null ) {
1065 getShowEventsCb().setSelected( state );
1068 case Configuration.color_branches:
1069 if ( getColorBranchesCb() != null ) {
1070 getColorBranchesCb().setSelected( state );
1073 case Configuration.width_branches:
1074 if ( _width_branches != null ) {
1075 _width_branches.setSelected( state );
1078 case Configuration.show_domain_architectures:
1079 if ( _show_domain_architectures != null ) {
1080 _show_domain_architectures.setSelected( state );
1083 case Configuration.show_gene_names:
1084 if ( _show_gene_names != null ) {
1085 _show_gene_names.setSelected( state );
1088 case Configuration.show_gene_symbols:
1089 if ( _show_gene_symbols != null ) {
1090 _show_gene_symbols.setSelected( state );
1093 case Configuration.show_vector_data:
1094 if ( _show_vector_data_cb != null ) {
1095 _show_vector_data_cb.setSelected( state );
1098 case Configuration.show_properties:
1099 if ( _show_properties_cb != null ) {
1100 _show_properties_cb.setSelected( state );
1103 case Configuration.show_sequence_acc:
1104 if ( _show_sequence_acc != null ) {
1105 _show_sequence_acc.setSelected( state );
1108 case Configuration.dynamically_hide_data:
1109 if ( getDynamicallyHideData() != null ) {
1110 getDynamicallyHideData().setSelected( state );
1113 case Configuration.node_data_popup:
1114 if ( getNodeDescPopupCb() != null ) {
1115 getNodeDescPopupCb().setSelected( state );
1119 case Configuration.show_relation_confidence:
1120 if ( _seq_relation_confidence_switch != null ) {
1121 _seq_relation_confidence_switch.setSelected( state );
1126 throw new AssertionError( "unknown checkbox: " + which );
1131 * Set this checkbox state. Not all checkboxes have been instantiated
1132 * depending on the config.
1134 void setCheckbox( final JCheckBox cb, final boolean state ) {
1136 cb.setSelected( state );
1140 void setClickToAction( final int action ) {
1141 // Set click-to action
1142 if ( action == _show_data_item ) {
1143 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1145 else if ( action == _collapse_cb_item ) {
1146 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1148 else if ( action == _reroot_cb_item ) {
1149 setActionWhenNodeClicked( NodeClickAction.REROOT );
1151 else if ( action == _subtree_cb_item ) {
1152 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1154 else if ( action == _swap_cb_item ) {
1155 setActionWhenNodeClicked( NodeClickAction.SWAP );
1157 else if ( action == _color_subtree_cb_item ) {
1158 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1160 else if ( action == _open_seq_web_item ) {
1161 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1163 else if ( action == _sort_descendents_item ) {
1164 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1166 else if ( action == _blast_item ) {
1167 setActionWhenNodeClicked( NodeClickAction.BLAST );
1169 else if ( action == _open_tax_web_item ) {
1170 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1172 else if ( action == _cut_subtree_item ) {
1173 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1175 else if ( action == _copy_subtree_item ) {
1176 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1178 else if ( action == _delete_node_or_subtree_item ) {
1179 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1181 else if ( action == _paste_subtree_item ) {
1182 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1184 else if ( action == _add_new_node_item ) {
1185 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1187 else if ( action == _edit_node_data_item ) {
1188 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1190 else if ( action == _get_ext_desc_data ) {
1191 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
1194 throw new RuntimeException( "unknown action: " + action );
1196 // make sure drop down is displaying the correct action
1197 // in case this was called from outside the class
1198 _click_to_combobox.setSelectedIndex( action );
1201 void setColorBranches( final boolean color_branches ) {
1202 _color_branches = color_branches;
1205 void setDrawPhylogram( final boolean b ) {
1206 getDisplayAsPhylogramCb().setSelected( b );
1207 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1210 private void setDrawPhylogram( final int index, final boolean b ) {
1211 getIsDrawPhylogramList().set( index, b );
1214 void setDrawPhylogramEnabled( final boolean b ) {
1215 getDisplayAsPhylogramCb().setEnabled( b );
1218 void setDynamicHidingIsOn( final boolean is_on ) {
1219 // if ( !_configuration.isUseNativeUI() ) {
1221 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1224 if ( !_configuration.isUseNativeUI() ) {
1225 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1228 getDynamicallyHideData().setForeground( Color.BLACK );
1234 private void setSearchFoundCountsOnLabel( final int counts ) {
1235 getSearchFoundCountsLabel().setText( "Found: " + counts );
1238 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
1239 final JComboBox box = getSequenceRelationBox();
1240 while ( box.getItemCount() > 1 ) {
1241 box.removeItemAt( 1 );
1243 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
1244 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
1246 if ( relationType == null ) {
1249 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
1250 for( final Sequence seq : sequenceRelationQueries ) {
1251 if ( seq.hasSequenceRelations() ) {
1252 boolean fFoundForCurrentType = false;
1253 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
1254 if ( sq.getType().equals( relationType ) ) {
1255 fFoundForCurrentType = true;
1259 if ( fFoundForCurrentType ) {
1260 sequenceNamesToAdd.add( seq.getName() );
1261 sequencesByName.put( seq.getName(), seq );
1265 // sort sequences by name before adding them to the combo
1266 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
1267 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
1268 for( final String seqName : sequenceNameArray ) {
1269 box.addItem( seqName );
1271 for( final ItemListener oldItemListener : box.getItemListeners() ) {
1272 box.removeItemListener( oldItemListener );
1274 box.addItemListener( new ItemListener() {
1277 public void itemStateChanged( final ItemEvent e ) {
1278 _selected_query_seq = sequencesByName.get( e.getItem() );
1279 _mainpanel.getCurrentTreePanel().repaint();
1284 void setShowEvents( final boolean show_events ) {
1285 if ( getShowEventsCb() == null ) {
1286 _show_events = new JCheckBox( "" );
1288 getShowEventsCb().setSelected( show_events );
1291 void setSpeciesColors( final Map<String, Color> species_colors ) {
1292 _species_colors = species_colors;
1295 private void setupClickToOptions() {
1296 final int default_option = _configuration.getDefaultDisplayClicktoOption();
1297 int selected_index = 0;
1299 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
1300 _show_data_item = cb_index;
1301 addClickToOption( Configuration.display_node_data,
1302 _configuration.getClickToTitle( Configuration.display_node_data ) );
1303 if ( default_option == Configuration.display_node_data ) {
1304 selected_index = cb_index;
1308 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
1309 _collapse_cb_item = cb_index;
1310 addClickToOption( Configuration.collapse_uncollapse,
1311 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
1312 if ( default_option == Configuration.collapse_uncollapse ) {
1313 selected_index = cb_index;
1317 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
1318 _reroot_cb_item = cb_index;
1319 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
1320 if ( default_option == Configuration.reroot ) {
1321 selected_index = cb_index;
1325 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
1326 _subtree_cb_item = cb_index;
1327 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
1328 if ( default_option == Configuration.subtree ) {
1329 selected_index = cb_index;
1333 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
1334 _swap_cb_item = cb_index;
1335 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
1336 if ( default_option == Configuration.swap ) {
1337 selected_index = cb_index;
1341 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
1342 _sort_descendents_item = cb_index;
1343 addClickToOption( Configuration.sort_descendents,
1344 _configuration.getClickToTitle( Configuration.sort_descendents ) );
1345 if ( default_option == Configuration.sort_descendents ) {
1346 selected_index = cb_index;
1350 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
1351 _color_subtree_cb_item = cb_index;
1352 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
1353 if ( default_option == Configuration.color_subtree ) {
1354 selected_index = cb_index;
1358 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
1359 _open_seq_web_item = cb_index;
1360 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
1361 if ( default_option == Configuration.open_seq_web ) {
1362 selected_index = cb_index;
1366 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
1367 _open_tax_web_item = cb_index;
1368 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
1369 if ( default_option == Configuration.open_tax_web ) {
1370 selected_index = cb_index;
1374 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
1375 _blast_item = cb_index;
1376 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
1377 if ( default_option == Configuration.blast ) {
1378 selected_index = cb_index;
1382 if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
1383 _get_ext_desc_data = cb_index;
1384 addClickToOption( Configuration.get_ext_desc_data,
1385 _configuration.getClickToTitle( Configuration.get_ext_desc_data ) );
1386 if ( default_option == Configuration.get_ext_desc_data ) {
1387 selected_index = cb_index;
1391 if ( getOptions().isEditable() ) {
1392 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
1393 _cut_subtree_item = cb_index;
1394 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
1395 if ( default_option == Configuration.cut_subtree ) {
1396 selected_index = cb_index;
1400 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
1401 _copy_subtree_item = cb_index;
1402 addClickToOption( Configuration.copy_subtree,
1403 _configuration.getClickToTitle( Configuration.copy_subtree ) );
1404 if ( default_option == Configuration.copy_subtree ) {
1405 selected_index = cb_index;
1409 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
1410 _paste_subtree_item = cb_index;
1411 addClickToOption( Configuration.paste_subtree,
1412 _configuration.getClickToTitle( Configuration.paste_subtree ) );
1413 if ( default_option == Configuration.paste_subtree ) {
1414 selected_index = cb_index;
1418 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
1419 _delete_node_or_subtree_item = cb_index;
1420 addClickToOption( Configuration.delete_subtree_or_node,
1421 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
1422 if ( default_option == Configuration.delete_subtree_or_node ) {
1423 selected_index = cb_index;
1427 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
1428 _add_new_node_item = cb_index;
1429 addClickToOption( Configuration.add_new_node,
1430 _configuration.getClickToTitle( Configuration.add_new_node ) );
1431 if ( default_option == Configuration.add_new_node ) {
1432 selected_index = cb_index;
1436 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
1437 _edit_node_data_item = cb_index;
1438 addClickToOption( Configuration.edit_node_data,
1439 _configuration.getClickToTitle( Configuration.edit_node_data ) );
1440 if ( default_option == Configuration.edit_node_data ) {
1441 selected_index = cb_index;
1446 // Set default selection and its action
1447 _click_to_combobox.setSelectedIndex( selected_index );
1448 setClickToAction( selected_index );
1453 * Set up the controls from the config settings. 11/26/05
1455 void setupControls() {
1456 // The tree display options:
1457 setupDisplayCheckboxes();
1459 // The sequence relation query selection combo-box
1460 if ( _configuration.displaySequenceRelations() ) {
1461 addSequenceRelationBlock();
1465 startClickToOptions();
1466 setupClickToOptions();
1467 endClickToOptions();
1468 // Zoom and quick edit buttons
1473 void setUpControlsForDomainStrucures() {
1474 _domain_display_label = new JLabel( "Domain Display:" );
1475 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1476 add( _domain_display_label );
1477 _zoom_in_domain_structure = new JButton( "d+" );
1478 _zoom_out_domain_structure = new JButton( "d-" );
1479 _decr_domain_structure_evalue_thr = new JButton( "-" );
1480 _incr_domain_structure_evalue_thr = new JButton( "+" );
1481 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1482 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1483 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1484 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1485 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1486 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1487 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1488 _domain_structure_evalue_thr_tf.setEditable( false );
1489 if ( !getConfiguration().isUseNativeUI() ) {
1490 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1491 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1492 _domain_structure_evalue_thr_tf.setBorder( null );
1494 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1495 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1496 if ( !_configuration.isUseNativeUI() ) {
1497 d1_panel.setBackground( getBackground() );
1498 d2_panel.setBackground( getBackground() );
1502 addJButton( _zoom_out_domain_structure, d1_panel );
1503 addJButton( _zoom_in_domain_structure, d1_panel );
1504 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
1505 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
1506 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
1509 private void setupDisplayCheckboxes() {
1510 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
1511 addCheckbox( Configuration.display_as_phylogram,
1512 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
1513 setCheckbox( Configuration.display_as_phylogram,
1514 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
1516 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1517 addCheckbox( Configuration.dynamically_hide_data,
1518 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
1519 setCheckbox( Configuration.dynamically_hide_data,
1520 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
1522 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1523 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1524 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1526 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1527 addCheckbox( Configuration.display_internal_data,
1528 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
1529 setCheckbox( Configuration.display_internal_data,
1530 _configuration.doCheckOption( Configuration.display_internal_data ) );
1532 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1533 addCheckbox( Configuration.color_according_to_species,
1534 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
1535 setCheckbox( Configuration.color_according_to_species,
1536 _configuration.doCheckOption( Configuration.color_according_to_species ) );
1538 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1539 addCheckbox( Configuration.color_according_to_annotation,
1540 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
1541 setCheckbox( Configuration.color_according_to_annotation,
1542 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
1544 if ( _configuration.doDisplayOption( Configuration.color_branches ) ) {
1545 addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) );
1546 setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) );
1548 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1549 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1550 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1552 final JLabel label = new JLabel( "Display Data:" );
1553 label.setFont( ControlPanel.jcb_bold_font );
1554 if ( !getConfiguration().isUseNativeUI() ) {
1555 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1558 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1559 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
1560 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1562 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1563 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1564 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1566 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1567 addCheckbox( Configuration.show_taxonomy_scientific_names,
1568 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1569 setCheckbox( Configuration.show_taxonomy_scientific_names,
1570 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1572 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1573 addCheckbox( Configuration.show_taxonomy_common_names,
1574 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1575 setCheckbox( Configuration.show_taxonomy_common_names,
1576 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1578 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1579 addCheckbox( Configuration.show_taxonomy_images,
1580 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1581 setCheckbox( Configuration.show_taxonomy_images,
1582 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1584 if ( _configuration.doDisplayOption( Configuration.show_gene_symbols ) ) {
1585 addCheckbox( Configuration.show_gene_symbols,
1586 _configuration.getDisplayTitle( Configuration.show_gene_symbols ) );
1587 setCheckbox( Configuration.show_gene_symbols,
1588 _configuration.doCheckOption( Configuration.show_gene_symbols ) );
1590 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1591 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1592 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1594 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1595 addCheckbox( Configuration.show_sequence_acc,
1596 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1597 setCheckbox( Configuration.show_sequence_acc,
1598 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1600 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1601 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
1602 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1604 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1605 addCheckbox( Configuration.show_binary_characters,
1606 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1607 setCheckbox( Configuration.show_binary_characters,
1608 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1610 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1611 addCheckbox( Configuration.show_binary_character_counts,
1612 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1613 setCheckbox( Configuration.show_binary_character_counts,
1614 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1616 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1617 addCheckbox( Configuration.show_domain_architectures,
1618 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1619 setCheckbox( Configuration.show_domain_architectures,
1620 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1622 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1623 addCheckbox( Configuration.write_confidence_values,
1624 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1625 setCheckbox( Configuration.write_confidence_values,
1626 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1628 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1629 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1630 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1632 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1633 addCheckbox( Configuration.show_vector_data,
1634 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1635 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
1637 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1638 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
1639 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1643 void setupSearchTools() {
1644 final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
1645 final JLabel search_label = new JLabel( "Search:" );
1646 search_label.setFont( ControlPanel.jcb_bold_font );
1647 if ( !getConfiguration().isUseNativeUI() ) {
1648 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1650 add( search_label );
1651 search_label.setToolTipText( tip );
1652 _search_found_label = new JLabel();
1653 getSearchFoundCountsLabel().setVisible( false );
1654 _search_found_label.setFont( ControlPanel.jcb_bold_font );
1655 if ( !getConfiguration().isUseNativeUI() ) {
1656 _search_found_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1658 _search_tf = new JTextField( 3 );
1659 _search_tf.setToolTipText( tip );
1660 _search_tf.setEditable( true );
1661 if ( !getConfiguration().isUseNativeUI() ) {
1662 _search_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1663 _search_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1664 _search_tf.setBorder( null );
1666 _search_reset_button = new JButton();
1667 getSearchResetButton().setText( "Reset" );
1668 getSearchResetButton().setEnabled( false );
1669 getSearchResetButton().setVisible( false );
1670 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
1671 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1672 s_panel_1.setBackground( getBackground() );
1674 s_panel_2.setBackground( getBackground() );
1676 final KeyAdapter key_adapter = new KeyAdapter() {
1679 public void keyReleased( final KeyEvent key_event ) {
1681 displayedPhylogenyMightHaveChanged( true );
1684 final ActionListener action_listener = new ActionListener() {
1687 public void actionPerformed( final ActionEvent e ) {
1689 setSearchFoundCountsOnLabel( 0 );
1690 getSearchFoundCountsLabel().setVisible( false );
1691 getSearchTextField().setText( "" );
1692 getSearchResetButton().setEnabled( false );
1693 getSearchResetButton().setVisible( false );
1694 displayedPhylogenyMightHaveChanged( true );
1697 _search_reset_button.addActionListener( action_listener );
1698 _search_tf.addKeyListener( key_adapter );
1699 addJTextField( _search_tf, s_panel_1 );
1700 s_panel_2.add( _search_found_label );
1701 addJButton( _search_reset_button, s_panel_2 );
1704 private void setVisibilityOfDomainStrucureControls() {
1705 if ( _zoom_in_domain_structure != null ) {
1706 if ( isShowDomainArchitectures() ) {
1707 _domain_display_label.setVisible( true );
1708 _zoom_in_domain_structure.setVisible( true );
1709 _zoom_out_domain_structure.setVisible( true );
1710 _decr_domain_structure_evalue_thr.setVisible( true );
1711 _incr_domain_structure_evalue_thr.setVisible( true );
1712 _domain_structure_evalue_thr_tf.setVisible( true );
1715 _domain_display_label.setVisible( false );
1716 _zoom_in_domain_structure.setVisible( false );
1717 _zoom_out_domain_structure.setVisible( false );
1718 _decr_domain_structure_evalue_thr.setVisible( false );
1719 _incr_domain_structure_evalue_thr.setVisible( false );
1720 _domain_structure_evalue_thr_tf.setVisible( false );
1726 * Fit entire tree into window.
1729 if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
1732 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
1733 displayedPhylogenyMightHaveChanged( true );
1734 _mainpanel.getCurrentTreePanel().updateOvSettings();
1735 _mainpanel.getCurrentTreePanel().validate();
1736 _mainpanel.validate();
1737 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1738 _mainpanel.getSizeOfViewport().height,
1740 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1741 _mainpanel.adjustJScrollPane();
1742 _mainpanel.getCurrentTreePanel().repaint();
1743 _mainpanel.getCurrentTreePanel().validate();
1744 _mainpanel.validate();
1745 _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1746 _mainpanel.getSizeOfViewport().height,
1748 _mainpanel.getCurrentTreePanel().resetPreferredSize();
1749 _mainpanel.adjustJScrollPane();
1750 _mainpanel.getCurrentTreePanel().repaint();
1751 _mainpanel.getCurrentTreePanel().updateOvSizes();
1754 void showWholeAll() {
1755 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
1756 if ( tree_panel != null ) {
1757 tree_panel.validate();
1758 tree_panel.setParametersForPainting( _mainpanel.getSizeOfViewport().width,
1759 _mainpanel.getSizeOfViewport().height,
1761 tree_panel.resetPreferredSize();
1762 tree_panel.repaint();
1767 // Create header for click-to combo box.
1768 void startClickToOptions() {
1769 final JLabel spacer = new JLabel( "" );
1770 spacer.setFont( ControlPanel.jcb_font );
1772 _click_to_label = new JLabel( "Click on Node to:" );
1773 add( customizeLabel( _click_to_label, getConfiguration() ) );
1774 _click_to_combobox = new JComboBox();
1775 _click_to_combobox.setFocusable( false );
1776 _click_to_combobox.setMaximumRowCount( 14 );
1777 _click_to_combobox.setFont( ControlPanel.js_font );
1778 if ( !_configuration.isUseNativeUI() ) {
1779 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
1781 // don't add listener until all items are set (or each one will trigger
1783 // click_to_list.addActionListener(this);
1784 add( _click_to_combobox );
1785 // Correlates option names to titles
1786 _all_click_to_names = new HashMap<Integer, String>();
1787 _click_to_names = new ArrayList<String>();
1791 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
1792 if ( getCurrentTreePanel().isPhyHasBranchLengths()
1793 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1794 setDrawPhylogramEnabled( true );
1795 setDrawPhylogram( isDrawPhylogram() );
1798 setDrawPhylogramEnabled( false );
1799 setDrawPhylogram( false );
1801 if ( getMainPanel().getMainFrame() == null ) {
1802 // Must be "E" applet version.
1803 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
1804 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
1807 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
1808 .getPhylogenyGraphicsType() );
1810 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
1811 getMainPanel().getControlPanel().search();
1812 getSequenceRelationTypeBox().removeAllItems();
1813 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
1814 .getRelevantSequenceRelationTypes() ) {
1815 _sequence_relation_type_box.addItem( type );
1817 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
1818 // according to GUILHEM the line above can be removed.
1823 * Uncollapse all nodes.
1825 void uncollapseAll( final TreePanel tp ) {
1826 final Phylogeny t = tp.getPhylogeny();
1827 if ( ( t != null ) && !t.isEmpty() ) {
1828 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
1829 final PhylogenyNode node = iter.next();
1830 node.setCollapse( false );
1832 tp.resetNodeIdToDistToLeafMap();
1833 tp.updateSetOfCollapsedExternalNodes();
1834 t.recalculateNumberOfExternalDescendants( false );
1835 tp.setNodeInPreorderToNull();
1836 t.clearHashIdToNodeMap();
1841 void updateDomainStructureEvaluethresholdDisplay() {
1842 if ( _domain_structure_evalue_thr_tf != null ) {
1843 _domain_structure_evalue_thr_tf.setText( "10^"
1844 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
1848 void zoomInX( final float factor, final float x_correction_factor ) {
1849 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1850 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1851 treepanel.multiplyUrtFactor( 1f );
1852 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1853 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1854 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1855 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1856 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1857 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1858 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1859 getMainPanel().adjustJScrollPane();
1860 treepanel.resetPreferredSize();
1861 getMainPanel().getCurrentScrollPane().getViewport().validate();
1862 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1863 - ( sb.getVisibleAmount() / 2.0 ) ) );
1866 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1867 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1868 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1869 getMainPanel().adjustJScrollPane();
1870 treepanel.resetPreferredSize();
1871 getMainPanel().getCurrentScrollPane().getViewport().validate();
1872 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1874 treepanel.resetPreferredSize();
1875 treepanel.updateOvSizes();
1878 void zoomInY( final float factor ) {
1879 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1880 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1881 treepanel.multiplyUrtFactor( 1.1f );
1882 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1883 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1884 getMainPanel().adjustJScrollPane();
1885 treepanel.resetPreferredSize();
1886 getMainPanel().getCurrentScrollPane().getViewport().validate();
1887 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1888 - ( sb.getVisibleAmount() / 2.0 ) ) );
1889 treepanel.resetPreferredSize();
1890 treepanel.updateOvSizes();
1893 void zoomOutX( final float factor, final float x_correction_factor ) {
1894 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1895 treepanel.multiplyUrtFactor( 1f );
1896 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
1897 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
1898 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1899 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1900 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
1901 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
1902 getMainPanel().adjustJScrollPane();
1903 treepanel.resetPreferredSize();
1904 getMainPanel().getCurrentScrollPane().getViewport().validate();
1905 final double x = ( sb.getMaximum() - sb.getMinimum() )
1906 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1907 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
1908 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
1909 getMainPanel().adjustJScrollPane();
1910 treepanel.resetPreferredSize();
1911 getMainPanel().getCurrentScrollPane().getViewport().validate();
1912 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1913 - ( sb.getVisibleAmount() / 2.0 ) ) );
1916 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
1917 treepanel.setXdistance( treepanel.getXdistance() * factor );
1918 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
1920 getMainPanel().adjustJScrollPane();
1921 treepanel.resetPreferredSize();
1922 getMainPanel().getCurrentScrollPane().getViewport().validate();
1923 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
1926 treepanel.resetPreferredSize();
1927 treepanel.updateOvSizes();
1931 void zoomOutY( final float factor ) {
1932 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
1933 treepanel.multiplyUrtFactor( 0.9f );
1934 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
1935 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
1936 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
1937 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
1938 getMainPanel().adjustJScrollPane();
1939 treepanel.resetPreferredSize();
1940 getMainPanel().getCurrentScrollPane().getViewport().validate();
1941 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
1942 - ( sb.getVisibleAmount() / 2.0 ) ) );
1943 treepanel.resetPreferredSize();
1944 treepanel.updateOvSizes();
1948 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
1949 label.setFont( ControlPanel.jcb_bold_font );
1950 if ( !configuration.isUseNativeUI() ) {
1951 label.setForeground( configuration.getGuiCheckboxTextColor() );
1952 label.setBackground( configuration.getGuiBackgroundColor() );
1957 enum NodeClickAction {
1968 DELETE_NODE_OR_SUBTREE,