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: https://sites.google.com/site/cmzmasek/home/software/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;
49 import javax.swing.BorderFactory;
50 import javax.swing.ButtonGroup;
51 import javax.swing.DefaultListCellRenderer;
52 import javax.swing.JButton;
53 import javax.swing.JCheckBox;
54 import javax.swing.JComboBox;
55 import javax.swing.JLabel;
56 import javax.swing.JList;
57 import javax.swing.JPanel;
58 import javax.swing.JRadioButton;
59 import javax.swing.JScrollBar;
60 import javax.swing.JTextField;
61 import javax.swing.ListCellRenderer;
63 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
64 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
65 import org.forester.archaeopteryx.util.TypomaticJButton;
66 import org.forester.phylogeny.Phylogeny;
67 import org.forester.phylogeny.PhylogenyMethods;
68 import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
69 import org.forester.phylogeny.PhylogenyNode;
70 import org.forester.phylogeny.data.Sequence;
71 import org.forester.phylogeny.data.SequenceRelation;
72 import org.forester.phylogeny.data.SequenceRelation.SEQUENCE_RELATION_TYPE;
73 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
74 import org.forester.util.ForesterUtil;
76 public final class ControlPanel extends JPanel implements ActionListener {
78 enum NodeClickAction {
85 DELETE_NODE_OR_SUBTREE,
103 final static Font jcb_bold_font = new Font( Configuration
104 .getDefaultFontFamilyName(), Font.BOLD, Configuration.getGuiFontSize() );
105 final static Font jcb_font = new Font( Configuration
106 .getDefaultFontFamilyName(), Font.PLAIN, Configuration.getGuiFontSize() );
107 final static Font js_font = new Font( Configuration
108 .getDefaultFontFamilyName(), Font.PLAIN, Configuration.getGuiFontSize() );
109 private static final String RETURN_TO_SUPER_TREE_TEXT = "R";
110 private static final String SEARCH_TIP_TEXT = "Enter text to search for. Use ',' for logical OR and '+' for logical AND (not used in this manner for regular expression searches).";
111 private static final long serialVersionUID = -8463483932821545633L;
112 private NodeClickAction _action_when_node_clicked;
113 private int _add_new_node_item;
114 private Map<Integer, String> _all_click_to_names;
115 private Map<String, Color> _annotation_colors;
116 private int _blast_item;
117 private JComboBox<String> _click_to_combobox;
118 private JLabel _click_to_label;
119 private List<String> _click_to_names;
120 private int _collapse_cb_item;
121 private int _uncollapse_all_cb_item;
122 private int _order_subtree_cb_item;
123 private JCheckBox _color_acc_species;
124 private JCheckBox _color_acc_sequence;
125 private JCheckBox _color_according_to_annotation;
126 private boolean _color_branches;
127 private JCheckBox _use_visual_styles_cb;
128 private int _color_subtree_cb_item;
129 private int _change_node_font_item;
130 // The settings from the conf file
131 private final Configuration _configuration;
132 private int _copy_subtree_item;
133 private int _cut_subtree_item;
134 private JButton _decr_domain_structure_evalue_thr;
135 private int _delete_node_or_subtree_item;
136 private JRadioButton _display_as_unaligned_phylogram_rb;
137 private JRadioButton _display_as_aligned_phylogram_rb;
138 private JRadioButton _display_as_cladogram_rb;
139 private ButtonGroup _display_as_buttongroup;
141 private JCheckBox _display_internal_data;
142 private JCheckBox _display_external_data;
143 private JLabel _domain_display_label;
144 private JTextField _domain_structure_evalue_thr_tf;
145 private JTextField _depth_collapse_depth_tf;
146 private JTextField _rank_collapse_depth_tf;
147 private List<Options.PHYLOGENY_DISPLAY_TYPE> _tree_display_types;
148 private JCheckBox _dynamically_hide_data;
149 private int _edit_node_data_item;
150 private int _get_ext_desc_data;
151 private JButton _incr_domain_structure_evalue_thr;
152 private final MainPanel _mainpanel;
153 private JCheckBox _node_desc_popup_cb;
154 private int _open_pdb_item;
155 private int _open_seq_web_item;
156 private int _open_tax_web_item;
157 private int _color_node_font_item;
158 private JButton _order;
159 private int _paste_subtree_item;
160 private int _reroot_cb_item;
161 private JButton _return_to_super_tree;
163 private JLabel _search_found_label_0;
164 private JLabel _search_found_label_1;
165 private JButton _search_reset_button_0;
166 private JButton _search_reset_button_1;
167 private JTextField _search_tf_0;
168 private JTextField _search_tf_1;
169 private int _select_nodes_item;
170 private Sequence _selected_query_seq;
171 private JCheckBox _seq_relation_confidence_switch;
172 private JComboBox<SEQUENCE_RELATION_TYPE> _sequence_relation_type_box;
173 private JCheckBox _show_annotation;
174 private JCheckBox _show_binary_character_counts;
175 private JCheckBox _show_binary_characters;
176 // Indices for the click-to options in the combo box
177 private int _show_data_item;
178 private JCheckBox _show_domain_architectures;
179 private JCheckBox _show_mol_seqs;
180 private JCheckBox _write_branch_length_values;
181 private JCheckBox _show_events;
182 private JCheckBox _show_gene_names;
183 private JCheckBox _show_node_names;
184 private JCheckBox _show_properties_cb;
185 private JCheckBox _show_seq_names;
186 private JCheckBox _show_seq_symbols;
187 private JCheckBox _show_sequence_acc;
188 private JComboBox<String> _show_sequence_relations;
189 private JCheckBox _show_taxo_code;
190 private JCheckBox _show_taxo_rank;
191 private JCheckBox _show_taxo_common_names;
192 private JCheckBox _show_taxo_images_cb;
193 private JCheckBox _show_taxo_scientific_names;
194 private JCheckBox _show_vector_data_cb;
195 private JButton _show_whole;
196 private int _sort_descendents_item;
197 private Map<String, Color> _species_colors;
198 private Map<String, Color> _sequence_colors;
199 private int _subtree_cb_item;
200 private int _swap_cb_item;
201 private JButton _uncollapse_all;
202 private JCheckBox _width_branches;
203 private JCheckBox _write_confidence;
204 private JButton _zoom_in_domain_structure;
205 private JButton _zoom_in_x;
206 private JButton _zoom_in_y;
207 private JLabel _zoom_label;
208 private JButton _zoom_out_domain_structure;
209 private JButton _zoom_out_x;
210 private JButton _zoom_out_y;
211 private JButton _decr_depth_collapse_level;
212 private JButton _incr_depth_collapse_level;
213 private JLabel _depth_collapse_label;
214 private JButton _decr_rank_collapse_level;
215 private JButton _incr_rank_collapse_level;
216 private JLabel _rank_collapse_label;
218 ControlPanel( final MainPanel ap, final Configuration configuration ) {
221 _configuration = configuration;
222 if ( !_configuration.isUseNativeUI() ) {
223 setBackground( getConfiguration().getGuiBackgroundColor() );
224 setBorder( BorderFactory.createRaisedBevelBorder() );
226 setLayout( new GridLayout( 0, 1, 2, 2 ) );
234 public void actionPerformed( final ActionEvent e ) {
236 if ( e.getSource() == _color_acc_sequence ) {
237 if ( _color_acc_species != null ) {
238 _color_acc_species.setSelected( false );
241 else if ( e.getSource() == _color_acc_species ) {
242 if ( _color_acc_sequence != null ) {
243 _color_acc_sequence.setSelected( false );
246 final TreePanel tp = getMainPanel().getCurrentTreePanel();
250 if ( e.getSource() == _click_to_combobox ) {
251 setClickToAction( _click_to_combobox.getSelectedIndex() );
252 getCurrentTreePanel().repaint();
254 else if ( e.getSource() == _show_binary_characters ) {
255 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
256 _show_binary_character_counts.setSelected( false );
258 displayedPhylogenyMightHaveChanged( true );
260 else if ( e.getSource() == _show_binary_character_counts ) {
261 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
262 _show_binary_characters.setSelected( false );
264 displayedPhylogenyMightHaveChanged( true );
266 else if ( e.getSource() == _show_domain_architectures ) {
269 displayedPhylogenyMightHaveChanged( true );
271 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
272 if ( e.getSource() == getDisplayAsUnalignedPhylogramRb() ) {
273 setTreeDisplayType( Options.PHYLOGENY_DISPLAY_TYPE.UNALIGNED_PHYLOGRAM );
276 if ( e.getSource() == getDisplayAsAlignedPhylogramRb() ) {
277 setTreeDisplayType( Options.PHYLOGENY_DISPLAY_TYPE.ALIGNED_PHYLOGRAM );
280 if ( e.getSource() == getDisplayAsCladogramRb() ) {
281 setTreeDisplayType( Options.PHYLOGENY_DISPLAY_TYPE.CLADOGRAM );
285 else if ( e.getSource() == _zoom_in_x ) {
286 zoomInX( AptxConstants.BUTTON_ZOOM_IN_FACTOR, AptxConstants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
287 displayedPhylogenyMightHaveChanged( false );
289 else if ( e.getSource() == _zoom_in_y ) {
290 zoomInY( AptxConstants.BUTTON_ZOOM_IN_FACTOR );
291 displayedPhylogenyMightHaveChanged( false );
293 else if ( e.getSource() == _zoom_out_x ) {
294 zoomOutX( AptxConstants.BUTTON_ZOOM_OUT_FACTOR, AptxConstants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
295 displayedPhylogenyMightHaveChanged( false );
297 else if ( e.getSource() == _zoom_out_y ) {
298 zoomOutY( AptxConstants.BUTTON_ZOOM_OUT_FACTOR );
299 displayedPhylogenyMightHaveChanged( false );
301 else if ( e.getSource() == _show_whole ) {
302 displayedPhylogenyMightHaveChanged( true );
305 else if ( e.getSource() == _return_to_super_tree ) {
306 returnedToSuperTreePressed();
308 else if ( e.getSource() == _order ) {
311 else if ( e.getSource() == _uncollapse_all ) {
313 displayedPhylogenyMightHaveChanged( false );
315 else if ( e.getSource() == _zoom_in_domain_structure ) {
316 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
317 displayedPhylogenyMightHaveChanged( true );
319 else if ( e.getSource() == _zoom_out_domain_structure ) {
320 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
321 displayedPhylogenyMightHaveChanged( true );
323 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
324 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThresholdExp();
327 displayedPhylogenyMightHaveChanged( true );
329 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
330 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThresholdExp();
333 displayedPhylogenyMightHaveChanged( true );
335 else if ( e.getSource() == _search_tf_0 ) {
337 displayedPhylogenyMightHaveChanged( true );
339 else if ( e.getSource() == _search_tf_1 ) {
341 displayedPhylogenyMightHaveChanged( true );
343 else if ( ( _dynamically_hide_data != null ) && ( e.getSource() == _dynamically_hide_data )
344 && !_dynamically_hide_data.isSelected() ) {
345 setDynamicHidingIsOn( false );
346 displayedPhylogenyMightHaveChanged( true );
348 else if ( ( e.getSource() == _decr_depth_collapse_level )
349 || ( e.getSource() == _incr_depth_collapse_level ) ) {
350 if ( e.getSource() == _decr_depth_collapse_level ) {
351 _mainpanel.getCurrentTreePanel().decreaseDepthCollapseLevel();
354 _mainpanel.getCurrentTreePanel().increaseDepthCollapseLevel();
358 _mainpanel.getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
359 _mainpanel.getCurrentTreePanel().getPhylogeny().recalculateNumberOfExternalDescendants( true );
360 _mainpanel.getCurrentTreePanel().resetNodeIdToDistToLeafMap();
361 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
362 _mainpanel.getCurrentTreePanel().setNodeInPreorderToNull();
363 displayedPhylogenyMightHaveChanged( true );
364 _mainpanel.getCurrentTreePanel().resetPreferredSize();
365 _mainpanel.getCurrentTreePanel().updateOvSizes();
366 _mainpanel.adjustJScrollPane();
370 else if ( ( e.getSource() == _decr_rank_collapse_level )
371 || ( e.getSource() == _incr_rank_collapse_level ) ) {
372 if ( e.getSource() == _decr_rank_collapse_level ) {
373 _mainpanel.getCurrentTreePanel().decreaseRankCollapseLevel();
376 _mainpanel.getCurrentTreePanel().increaseRankCollapseLevel();
380 _mainpanel.getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
381 _mainpanel.getCurrentTreePanel().getPhylogeny().recalculateNumberOfExternalDescendants( true );
382 _mainpanel.getCurrentTreePanel().resetNodeIdToDistToLeafMap();
383 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
384 _mainpanel.getCurrentTreePanel().setNodeInPreorderToNull();
385 displayedPhylogenyMightHaveChanged( true );
386 _mainpanel.getCurrentTreePanel().resetPreferredSize();
387 _mainpanel.getCurrentTreePanel().updateOvSizes();
388 _mainpanel.adjustJScrollPane();
393 displayedPhylogenyMightHaveChanged( true );
397 tp.requestFocusInWindow();
400 catch ( final Exception ex ) {
401 AptxUtil.unexpectedException( ex );
403 catch ( final Error err ) {
404 AptxUtil.unexpectedError( err );
408 void orderPressed( final TreePanel tp ) {
409 DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
410 if ( isShowTaxonomyScientificNames() || isShowTaxonomyCode() ) {
411 pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
413 else if ( isShowSeqNames() || isShowSeqSymbols() || isShowGeneNames() ) {
414 pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
416 PhylogenyMethods.orderAppearanceX( tp.getPhylogeny().getRoot(), true, pri );
417 tp.setNodeInPreorderToNull();
418 tp.getPhylogeny().externalNodesHaveChanged();
419 tp.getPhylogeny().clearHashIdToNodeMap();
420 tp.getPhylogeny().recalculateNumberOfExternalDescendants( true );
421 tp.resetNodeIdToDistToLeafMap();
422 tp.setEdited( true );
423 displayedPhylogenyMightHaveChanged( true );
426 void returnedToSuperTreePressed() {
427 if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
428 _mainpanel.getCurrentTreePanel().superTree();
433 public JCheckBox getColorAccSequenceCb() {
434 return _color_acc_sequence;
437 public JCheckBox getColorAccSpeciesCb() {
438 return _color_acc_species;
441 public JRadioButton getDisplayAsCladogramRb() {
442 return _display_as_cladogram_rb;
445 public JRadioButton getDisplayAsAlignedPhylogramRb() {
446 return _display_as_aligned_phylogram_rb;
449 public JRadioButton getDisplayAsUnalignedPhylogramRb() {
450 return _display_as_unaligned_phylogram_rb;
453 public JCheckBox getDynamicallyHideData() {
454 return _dynamically_hide_data;
457 public JCheckBox getNodeDescPopupCb() {
458 return _node_desc_popup_cb;
461 public Sequence getSelectedQuerySequence() {
462 return _selected_query_seq;
465 public JComboBox<String> getSequenceRelationBox() {
466 if ( _show_sequence_relations == null ) {
467 _show_sequence_relations = new JComboBox<String>();
468 _show_sequence_relations.setFocusable( false );
469 _show_sequence_relations.setMaximumRowCount( 20 );
470 _show_sequence_relations.setFont( ControlPanel.js_font );
471 if ( !_configuration.isUseNativeUI() ) {
472 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
473 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
475 _show_sequence_relations.addItem( "-----" );
476 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
478 return _show_sequence_relations;
482 public JComboBox<SEQUENCE_RELATION_TYPE> getSequenceRelationTypeBox() {
483 if ( _sequence_relation_type_box == null ) {
484 _sequence_relation_type_box = new JComboBox<SEQUENCE_RELATION_TYPE>();
485 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE
487 _sequence_relation_type_box.addItem( type );
489 _sequence_relation_type_box.addActionListener( new ActionListener() {
492 public void actionPerformed( final ActionEvent e ) {
493 if ( _mainpanel.getCurrentPhylogeny() != null ) {
494 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
499 return _sequence_relation_type_box;
502 public JCheckBox getShowEventsCb() {
506 public JCheckBox getUseVisualStylesCb() {
507 return _use_visual_styles_cb;
510 public JCheckBox getWriteConfidenceCb() {
511 return _write_confidence;
514 public boolean isShowMolSequences() {
515 return ( ( _show_mol_seqs != null ) && _show_mol_seqs.isSelected() );
518 public boolean isShowProperties() {
519 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
522 public boolean isShowTaxonomyImages() {
523 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
526 public boolean isShowVectorData() {
527 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
530 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
531 final JComboBox<String> box = getSequenceRelationBox();
532 while ( box.getItemCount() > 1 ) {
533 box.removeItemAt( 1 );
535 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
536 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
538 if ( relationType == null ) {
541 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
542 for( final Sequence seq : sequenceRelationQueries ) {
543 if ( seq.isHasSequenceRelations() ) {
544 boolean fFoundForCurrentType = false;
545 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
546 if ( sq.getType().equals( relationType ) ) {
547 fFoundForCurrentType = true;
551 if ( fFoundForCurrentType ) {
552 sequenceNamesToAdd.add( seq.getName() );
553 sequencesByName.put( seq.getName(), seq );
557 // sort sequences by name before adding them to the combo
558 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
559 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
560 for( final String seqName : sequenceNameArray ) {
561 box.addItem( seqName );
563 for( final ItemListener oldItemListener : box.getItemListeners() ) {
564 box.removeItemListener( oldItemListener );
566 box.addItemListener( new ItemListener() {
569 public void itemStateChanged( final ItemEvent e ) {
570 _selected_query_seq = sequencesByName.get( e.getItem() );
571 _mainpanel.getCurrentTreePanel().repaint();
576 private void addClickToOption( final int which, final String title ) {
577 _click_to_combobox.addItem( title );
578 _click_to_names.add( title );
579 _all_click_to_names.put( new Integer( which ), title );
580 if ( !_configuration.isUseNativeUI() ) {
581 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
582 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
587 private void addSequenceRelationBlock() {
588 final JLabel spacer = new JLabel( "" );
589 spacer.setSize( 1, 1 );
591 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
592 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
593 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
594 getSequenceRelationTypeBox().setFocusable( false );
595 _sequence_relation_type_box.setFont( ControlPanel.js_font );
596 if ( !_configuration.isUseNativeUI() ) {
597 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
598 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
600 _sequence_relation_type_box.setRenderer( new ListCellRenderer<Object>() {
603 public Component getListCellRendererComponent( final JList<?> list,
606 final boolean isSelected,
607 final boolean cellHasFocus ) {
608 final Component component = new DefaultListCellRenderer()
609 .getListCellRendererComponent( list, value, index, isSelected, cellHasFocus );
610 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
611 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
612 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
617 final GridBagLayout gbl = new GridBagLayout();
618 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
619 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
620 final JPanel horizGrid = new JPanel( gbl );
621 horizGrid.setBackground( getBackground() );
622 horizGrid.add( typeLabel );
623 horizGrid.add( _sequence_relation_type_box );
624 add( customizeLabel( mainLabel, getConfiguration() ) );
626 add( getSequenceRelationBox() );
627 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
628 addCheckbox( Configuration.show_relation_confidence,
629 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
630 setCheckbox( Configuration.show_relation_confidence,
631 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
633 }// addSequenceRelationBlock
636 private List<Options.PHYLOGENY_DISPLAY_TYPE> getTreeDisplayTypes() {
637 return _tree_display_types;
640 final private MainFrame getMainFrame() {
641 return getMainPanel().getMainFrame();
644 private void init() {
645 _tree_display_types = new ArrayList<Options.PHYLOGENY_DISPLAY_TYPE>();
646 setSpeciesColors( new HashMap<String, Color>() );
647 setSequenceColors( new HashMap<String, Color>() );
648 setAnnotationColors( new HashMap<String, Color>() );
651 private Options.PHYLOGENY_DISPLAY_TYPE getTreeDisplayType( final int index ) {
652 return getTreeDisplayTypes().get( index );
655 private void search0( final MainPanel main_panel, final Phylogeny tree, String query_str ) {
656 getSearchFoundCountsLabel0().setVisible( true );
657 getSearchResetButton0().setEnabled( true );
658 getSearchResetButton0().setVisible( true );
659 String[] queries = null;
660 Set<Long> nodes = null;
661 query_str = query_str.replaceAll( "\\s+", " " );
662 if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
663 queries = query_str.split( ",+" );
666 queries = new String[ 1 ];
667 queries[ 0 ] = query_str.trim();
669 if ( ( queries != null ) && ( queries.length > 0 ) ) {
670 nodes = new HashSet<Long>();
671 for( String query : queries ) {
672 if ( ForesterUtil.isEmpty( query ) ) {
675 query = query.trim();
676 final TreePanel tp = getMainPanel().getCurrentTreePanel();
677 if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
678 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
680 getOptions().isSearchCaseSensitive(),
681 !getOptions().isMatchWholeTermsOnly(),
682 isShowDomainArchitectures(),
685 tp.getDomainStructureEvalueThresholdExp() )
689 nodes.addAll( PhylogenyMethods
692 getOptions().isSearchCaseSensitive(),
693 !getOptions().isMatchWholeTermsOnly(),
694 getOptions().isSearchWithRegex(),
695 isShowDomainArchitectures(),
696 tp != null ? Math.pow( 10, tp.getDomainStructureEvalueThresholdExp() ) : 0 ) );
699 if ( getOptions().isInverseSearchResult() ) {
700 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
701 final Set<Long> temp_nodes = nodes;
702 nodes = new HashSet<Long>();
703 for( final PhylogenyNode n : all ) {
704 if ( ( !temp_nodes.contains( n.getId() ) ) && n.isHasNodeData() ) {
705 nodes.add( n.getId() );
710 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
711 main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet<Long>() );
712 for( final Long node : nodes ) {
713 main_panel.getCurrentTreePanel().getFoundNodes0().add( node );
715 setSearchFoundCountsOnLabel0( nodes.size() );
718 setSearchFoundCountsOnLabel0( 0 );
723 private void search1( final MainPanel main_panel, final Phylogeny tree, String query_str ) {
724 getSearchFoundCountsLabel1().setVisible( true );
725 getSearchResetButton1().setEnabled( true );
726 getSearchResetButton1().setVisible( true );
727 String[] queries = null;
728 Set<Long> nodes = null;
729 query_str = query_str.replaceAll( "\\s+", " " );
730 if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
731 queries = query_str.split( ",+" );
734 queries = new String[ 1 ];
735 queries[ 0 ] = query_str.trim();
737 if ( ( queries != null ) && ( queries.length > 0 ) ) {
738 nodes = new HashSet<Long>();
739 for( String query : queries ) {
740 if ( ForesterUtil.isEmpty( query ) ) {
743 query = query.trim();
744 final TreePanel tp = getMainPanel().getCurrentTreePanel();
745 if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
746 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
748 getOptions().isSearchCaseSensitive(),
749 !getOptions().isMatchWholeTermsOnly(),
750 isShowDomainArchitectures(),
753 tp.getDomainStructureEvalueThresholdExp() )
757 nodes.addAll( PhylogenyMethods
760 getOptions().isSearchCaseSensitive(),
761 !getOptions().isMatchWholeTermsOnly(),
762 getOptions().isSearchWithRegex(),
763 isShowDomainArchitectures(),
764 tp != null ? Math.pow( 10, tp.getDomainStructureEvalueThresholdExp() ) : 0 ) );
767 if ( getOptions().isInverseSearchResult() ) {
768 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
769 final Set<Long> temp_nodes = nodes;
770 nodes = new HashSet<Long>();
771 for( final PhylogenyNode n : all ) {
772 if ( ( !temp_nodes.contains( n.getId() ) ) && n.isHasNodeData() ) {
773 nodes.add( n.getId() );
778 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
779 main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet<Long>() );
780 for( final Long node : nodes ) {
781 main_panel.getCurrentTreePanel().getFoundNodes1().add( node );
783 setSearchFoundCountsOnLabel1( nodes.size() );
786 setSearchFoundCountsOnLabel1( 0 );
791 private void setTreeDisplayType( final int index, final Options.PHYLOGENY_DISPLAY_TYPE t ) {
792 getTreeDisplayTypes().set( index, t );
795 private void setupClickToOptions() {
796 final int default_option = _configuration.getDefaultDisplayClicktoOption();
797 int selected_index = 0;
799 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
800 _show_data_item = cb_index;
801 addClickToOption( Configuration.display_node_data,
802 _configuration.getClickToTitle( Configuration.display_node_data ) );
803 if ( default_option == Configuration.display_node_data ) {
804 selected_index = cb_index;
808 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
809 _collapse_cb_item = cb_index;
810 addClickToOption( Configuration.collapse_uncollapse,
811 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
812 if ( default_option == Configuration.collapse_uncollapse ) {
813 selected_index = cb_index;
817 if ( _configuration.doDisplayClickToOption( Configuration.uncollapse_all ) ) {
818 _uncollapse_all_cb_item = cb_index;
819 addClickToOption( Configuration.uncollapse_all,
820 _configuration.getClickToTitle( Configuration.uncollapse_all ) );
821 if ( default_option == Configuration.uncollapse_all ) {
822 selected_index = cb_index;
826 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
827 _reroot_cb_item = cb_index;
828 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
829 if ( default_option == Configuration.reroot ) {
830 selected_index = cb_index;
834 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
835 _subtree_cb_item = cb_index;
836 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
837 if ( default_option == Configuration.subtree ) {
838 selected_index = cb_index;
842 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
843 _swap_cb_item = cb_index;
844 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
845 if ( default_option == Configuration.swap ) {
846 selected_index = cb_index;
850 if ( _configuration.doDisplayClickToOption( Configuration.order_subtree ) ) {
851 _order_subtree_cb_item = cb_index;
852 addClickToOption( Configuration.order_subtree,
853 _configuration.getClickToTitle( Configuration.order_subtree ) );
854 if ( default_option == Configuration.order_subtree ) {
855 selected_index = cb_index;
859 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
860 _sort_descendents_item = cb_index;
861 addClickToOption( Configuration.sort_descendents,
862 _configuration.getClickToTitle( Configuration.sort_descendents ) );
863 if ( default_option == Configuration.sort_descendents ) {
864 selected_index = cb_index;
868 if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) {
869 _color_node_font_item = cb_index;
870 addClickToOption( Configuration.color_node_font,
871 _configuration.getClickToTitle( Configuration.color_node_font ) );
872 if ( default_option == Configuration.color_node_font ) {
873 selected_index = cb_index;
877 if ( _configuration.doDisplayClickToOption( Configuration.change_node_font ) ) {
878 _change_node_font_item = cb_index;
879 addClickToOption( Configuration.change_node_font,
880 _configuration.getClickToTitle( Configuration.change_node_font ) );
881 if ( default_option == Configuration.change_node_font ) {
882 selected_index = cb_index;
886 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
887 _color_subtree_cb_item = cb_index;
888 addClickToOption( Configuration.color_subtree,
889 _configuration.getClickToTitle( Configuration.color_subtree ) );
890 if ( default_option == Configuration.color_subtree ) {
891 selected_index = cb_index;
895 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
896 _open_seq_web_item = cb_index;
897 addClickToOption( Configuration.open_seq_web,
898 _configuration.getClickToTitle( Configuration.open_seq_web ) );
899 if ( default_option == Configuration.open_seq_web ) {
900 selected_index = cb_index;
904 if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
905 _open_pdb_item = cb_index;
906 addClickToOption( Configuration.open_pdb_web,
907 _configuration.getClickToTitle( Configuration.open_pdb_web ) );
908 if ( default_option == Configuration.open_pdb_web ) {
909 selected_index = cb_index;
913 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
914 _open_tax_web_item = cb_index;
915 addClickToOption( Configuration.open_tax_web,
916 _configuration.getClickToTitle( Configuration.open_tax_web ) );
917 if ( default_option == Configuration.open_tax_web ) {
918 selected_index = cb_index;
922 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
923 _blast_item = cb_index;
924 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
925 if ( default_option == Configuration.blast ) {
926 selected_index = cb_index;
930 if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
931 _select_nodes_item = cb_index;
932 addClickToOption( Configuration.select_nodes,
933 _configuration.getClickToTitle( Configuration.select_nodes ) );
934 if ( default_option == Configuration.select_nodes ) {
935 selected_index = cb_index;
939 if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
940 _get_ext_desc_data = cb_index;
941 if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
942 addClickToOption( Configuration.get_ext_desc_data,
943 getConfiguration().getLabelForGetExtDescendentsData() );
946 addClickToOption( Configuration.get_ext_desc_data,
947 getConfiguration().getClickToTitle( Configuration.get_ext_desc_data ) );
949 if ( default_option == Configuration.get_ext_desc_data ) {
950 selected_index = cb_index;
954 if ( getOptions().isEditable() ) {
955 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
956 _cut_subtree_item = cb_index;
957 addClickToOption( Configuration.cut_subtree,
958 _configuration.getClickToTitle( Configuration.cut_subtree ) );
959 if ( default_option == Configuration.cut_subtree ) {
960 selected_index = cb_index;
964 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
965 _copy_subtree_item = cb_index;
966 addClickToOption( Configuration.copy_subtree,
967 _configuration.getClickToTitle( Configuration.copy_subtree ) );
968 if ( default_option == Configuration.copy_subtree ) {
969 selected_index = cb_index;
973 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
974 _paste_subtree_item = cb_index;
975 addClickToOption( Configuration.paste_subtree,
976 _configuration.getClickToTitle( Configuration.paste_subtree ) );
977 if ( default_option == Configuration.paste_subtree ) {
978 selected_index = cb_index;
982 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
983 _delete_node_or_subtree_item = cb_index;
984 addClickToOption( Configuration.delete_subtree_or_node,
985 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
986 if ( default_option == Configuration.delete_subtree_or_node ) {
987 selected_index = cb_index;
991 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
992 _add_new_node_item = cb_index;
993 addClickToOption( Configuration.add_new_node,
994 _configuration.getClickToTitle( Configuration.add_new_node ) );
995 if ( default_option == Configuration.add_new_node ) {
996 selected_index = cb_index;
1000 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
1001 _edit_node_data_item = cb_index;
1002 addClickToOption( Configuration.edit_node_data,
1003 _configuration.getClickToTitle( Configuration.edit_node_data ) );
1004 if ( default_option == Configuration.edit_node_data ) {
1005 selected_index = cb_index;
1010 // Set default selection and its action
1011 _click_to_combobox.setSelectedIndex( selected_index );
1012 setClickToAction( selected_index );
1015 private void setupDisplayCheckboxes() {
1016 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1017 addCheckbox( Configuration.dynamically_hide_data,
1018 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
1019 setCheckbox( Configuration.dynamically_hide_data,
1020 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
1022 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1023 addCheckbox( Configuration.node_data_popup,
1024 _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1025 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1027 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1028 addCheckbox( Configuration.display_internal_data,
1029 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
1030 setCheckbox( Configuration.display_internal_data,
1031 _configuration.doCheckOption( Configuration.display_internal_data ) );
1033 if ( _configuration.doDisplayOption( Configuration.display_external_data ) ) {
1034 addCheckbox( Configuration.display_external_data,
1035 _configuration.getDisplayTitle( Configuration.display_external_data ) );
1036 setCheckbox( Configuration.display_external_data,
1037 _configuration.doCheckOption( Configuration.display_external_data ) );
1039 if ( _configuration.doDisplayOption( Configuration.color_according_to_sequence ) ) {
1040 addCheckbox( Configuration.color_according_to_sequence,
1041 _configuration.getDisplayTitle( Configuration.color_according_to_sequence ) );
1042 setCheckbox( Configuration.color_according_to_sequence,
1043 _configuration.doCheckOption( Configuration.color_according_to_sequence ) );
1045 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1046 addCheckbox( Configuration.color_according_to_species,
1047 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
1048 setCheckbox( Configuration.color_according_to_species,
1049 _configuration.doCheckOption( Configuration.color_according_to_species ) );
1051 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1052 addCheckbox( Configuration.color_according_to_annotation,
1053 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
1054 setCheckbox( Configuration.color_according_to_annotation,
1055 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
1057 if ( _configuration.doDisplayOption( Configuration.use_style ) ) {
1058 addCheckbox( Configuration.use_style, _configuration.getDisplayTitle( Configuration.use_style ) );
1059 setCheckbox( Configuration.use_style, _configuration.doCheckOption( Configuration.use_style ) );
1061 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1062 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1063 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1065 final JLabel label = new JLabel( "Display Data:" );
1066 label.setFont( ControlPanel.jcb_bold_font );
1067 if ( !getConfiguration().isUseNativeUI() ) {
1068 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1071 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1072 addCheckbox( Configuration.show_node_names,
1073 _configuration.getDisplayTitle( Configuration.show_node_names ) );
1074 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1076 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1077 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1078 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1080 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1081 addCheckbox( Configuration.show_taxonomy_scientific_names,
1082 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1083 setCheckbox( Configuration.show_taxonomy_scientific_names,
1084 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1086 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1087 addCheckbox( Configuration.show_taxonomy_common_names,
1088 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1089 setCheckbox( Configuration.show_taxonomy_common_names,
1090 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1092 if ( _configuration.doDisplayOption( Configuration.show_tax_rank ) ) {
1093 addCheckbox( Configuration.show_tax_rank, _configuration.getDisplayTitle( Configuration.show_tax_rank ) );
1094 setCheckbox( Configuration.show_tax_rank, _configuration.doCheckOption( Configuration.show_tax_rank ) );
1096 if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
1097 addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
1098 setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
1100 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1101 addCheckbox( Configuration.show_gene_names,
1102 _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1103 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1105 if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
1106 addCheckbox( Configuration.show_seq_symbols,
1107 _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
1108 setCheckbox( Configuration.show_seq_symbols,
1109 _configuration.doCheckOption( Configuration.show_seq_symbols ) );
1111 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1112 addCheckbox( Configuration.show_sequence_acc,
1113 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1114 setCheckbox( Configuration.show_sequence_acc,
1115 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1117 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1118 addCheckbox( Configuration.show_annotation,
1119 _configuration.getDisplayTitle( Configuration.show_annotation ) );
1120 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1122 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1123 addCheckbox( Configuration.write_confidence_values,
1124 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1125 setCheckbox( Configuration.write_confidence_values,
1126 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1128 if ( _configuration.doDisplayOption( Configuration.write_branch_length_values ) ) {
1129 addCheckbox( Configuration.write_branch_length_values,
1130 _configuration.getDisplayTitle( Configuration.write_branch_length_values ) );
1131 setCheckbox( Configuration.write_branch_length_values,
1132 _configuration.doCheckOption( Configuration.write_branch_length_values ) );
1134 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1135 addCheckbox( Configuration.show_binary_characters,
1136 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1137 setCheckbox( Configuration.show_binary_characters,
1138 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1140 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1141 addCheckbox( Configuration.show_binary_character_counts,
1142 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1143 setCheckbox( Configuration.show_binary_character_counts,
1144 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1146 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1147 addCheckbox( Configuration.show_domain_architectures,
1148 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1149 setCheckbox( Configuration.show_domain_architectures,
1150 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1152 if ( _configuration.doDisplayOption( Configuration.show_mol_seqs ) ) {
1153 addCheckbox( Configuration.show_mol_seqs, _configuration.getDisplayTitle( Configuration.show_mol_seqs ) );
1154 setCheckbox( Configuration.show_mol_seqs, _configuration.doCheckOption( Configuration.show_mol_seqs ) );
1156 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1157 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1158 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1160 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1161 addCheckbox( Configuration.show_vector_data,
1162 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1163 setCheckbox( Configuration.show_vector_data,
1164 _configuration.doCheckOption( Configuration.show_vector_data ) );
1166 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1167 addCheckbox( Configuration.show_properties,
1168 _configuration.getDisplayTitle( Configuration.show_properties ) );
1169 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1171 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1172 addCheckbox( Configuration.show_taxonomy_images,
1173 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1174 setCheckbox( Configuration.show_taxonomy_images,
1175 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1179 private void setVisibilityOfDomainStrucureControls() {
1180 if ( _zoom_in_domain_structure != null ) {
1181 final MainFrame mf = getMainFrame();
1183 if ( isShowDomainArchitectures() ) {
1184 _domain_display_label.setVisible( true );
1185 _zoom_in_domain_structure.setVisible( true );
1186 _zoom_out_domain_structure.setVisible( true );
1187 _decr_domain_structure_evalue_thr.setVisible( true );
1188 _incr_domain_structure_evalue_thr.setVisible( true );
1189 _domain_structure_evalue_thr_tf.setVisible( true );
1190 if ( mf._right_line_up_domains_cbmi != null ) {
1191 mf._right_line_up_domains_cbmi.setVisible( true );
1193 if ( mf._show_domain_labels != null ) {
1194 mf._show_domain_labels.setVisible( true );
1198 _domain_display_label.setVisible( false );
1199 _zoom_in_domain_structure.setVisible( false );
1200 _zoom_out_domain_structure.setVisible( false );
1201 _decr_domain_structure_evalue_thr.setVisible( false );
1202 _incr_domain_structure_evalue_thr.setVisible( false );
1203 _domain_structure_evalue_thr_tf.setVisible( false );
1204 if ( mf._right_line_up_domains_cbmi != null ) {
1205 mf._right_line_up_domains_cbmi.setVisible( false );
1207 if ( mf._show_domain_labels != null ) {
1208 mf._show_domain_labels.setVisible( false );
1215 void activateButtonToReturnToSuperTree( int index ) {
1218 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
1221 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
1223 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1224 _return_to_super_tree.setEnabled( true );
1227 void activateButtonToUncollapseAll() {
1228 _uncollapse_all.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1229 _uncollapse_all.setEnabled( true );
1233 * Add zoom and quick edit buttons. (Last modified 8/9/04)
1236 final JLabel spacer = new JLabel( "" );
1237 spacer.setOpaque( false );
1239 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
1240 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1241 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
1242 final JPanel o_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1243 if ( !getConfiguration().isUseNativeUI() ) {
1244 x_panel.setBackground( getBackground() );
1245 y_panel.setBackground( getBackground() );
1246 z_panel.setBackground( getBackground() );
1247 o_panel.setBackground( getBackground() );
1249 add( _zoom_label = new JLabel( "Zoom:" ) );
1250 customizeLabel( _zoom_label, getConfiguration() );
1254 if ( getConfiguration().isUseNativeUI() ) {
1255 _zoom_in_x = new TypomaticJButton( "+" );
1256 _zoom_out_x = new TypomaticJButton( "-" );
1259 _zoom_in_x = new TypomaticJButton( "X+" );
1260 _zoom_out_x = new TypomaticJButton( "X-" );
1262 _zoom_in_y = new TypomaticJButton( "Y+" );
1263 _zoom_out_y = new TypomaticJButton( "Y-" );
1264 _show_whole = new JButton( "F" );
1265 _show_whole.setToolTipText( "fit and center tree display [Alt+C, Home, or Esc]" );
1266 _zoom_in_x.setToolTipText( "zoom in horizontally [Alt+Right or Shift+Alt+mousewheel]" );
1267 _zoom_in_y.setToolTipText( "zoom in vertically [Alt+Up or Shift+mousewheel]" );
1268 _zoom_out_x.setToolTipText( "zoom out horizontally [Alt+Left or Shift+Alt+mousewheel]" );
1269 _zoom_out_y.setToolTipText( "zoom out vertically [Alt+Down or Shift+mousewheel]" );
1270 if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) {
1271 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
1272 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
1275 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
1276 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
1278 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
1279 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
1280 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
1281 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
1282 _return_to_super_tree.setToolTipText( "return to the super-tree (if in sub-tree) [Alt+R]" );
1283 _return_to_super_tree.setEnabled( false );
1284 _order = new JButton( "O" );
1285 _order.setToolTipText( "order all [Alt+O]" );
1286 _uncollapse_all = new JButton( "U" );
1287 _uncollapse_all.setToolTipText( "uncollapse all [Alt+U]" );
1288 addJButton( _zoom_in_y, x_panel );
1289 addJButton( _zoom_out_x, y_panel );
1290 addJButton( _show_whole, y_panel );
1291 addJButton( _zoom_in_x, y_panel );
1292 addJButton( _zoom_out_y, z_panel );
1293 final JLabel spacer2 = new JLabel( "" );
1296 addJButton( _order, o_panel );
1297 addJButton( _return_to_super_tree, o_panel );
1298 addJButton( _uncollapse_all, o_panel );
1299 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
1300 setUpControlsForDomainStrucures();
1303 setUpControlsForDepthCollapse();
1306 setUpControlsForRankCollapse();
1308 final JLabel spacer3 = new JLabel( "" );
1310 setVisibilityOfDomainStrucureControls();
1313 void addCheckbox( final int which, final String title ) {
1314 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
1316 case Configuration.display_internal_data:
1317 _display_internal_data = new JCheckBox( title );
1318 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
1319 addJCheckBox( _display_internal_data, ch_panel );
1322 case Configuration.display_external_data:
1323 _display_external_data = new JCheckBox( title );
1324 _display_external_data.setToolTipText( "To allow or disallow display of external labels" );
1325 addJCheckBox( _display_external_data, ch_panel );
1328 case Configuration.color_according_to_species:
1329 _color_acc_species = new JCheckBox( title );
1330 _color_acc_species.setToolTipText( "To colorize node labels as a function of taxonomy" );
1331 addJCheckBox( _color_acc_species, ch_panel );
1334 case Configuration.color_according_to_sequence:
1335 _color_acc_sequence = new JCheckBox( title );
1336 _color_acc_sequence.setToolTipText( "To colorize node labels as a function of sequence name" );
1337 addJCheckBox( _color_acc_sequence, ch_panel );
1340 case Configuration.color_according_to_annotation:
1341 _color_according_to_annotation = new JCheckBox( title );
1342 _color_according_to_annotation
1343 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
1344 addJCheckBox( _color_according_to_annotation, ch_panel );
1347 case Configuration.show_node_names:
1348 _show_node_names = new JCheckBox( title );
1349 addJCheckBox( _show_node_names, ch_panel );
1352 case Configuration.show_taxonomy_scientific_names:
1353 _show_taxo_scientific_names = new JCheckBox( title );
1354 addJCheckBox( _show_taxo_scientific_names, ch_panel );
1357 case Configuration.show_taxonomy_common_names:
1358 _show_taxo_common_names = new JCheckBox( title );
1359 addJCheckBox( _show_taxo_common_names, ch_panel );
1362 case Configuration.show_tax_code:
1363 _show_taxo_code = new JCheckBox( title );
1364 addJCheckBox( _show_taxo_code, ch_panel );
1367 case Configuration.show_tax_rank:
1368 _show_taxo_rank = new JCheckBox( title );
1369 addJCheckBox( _show_taxo_rank, ch_panel );
1372 case Configuration.show_taxonomy_images:
1373 _show_taxo_images_cb = new JCheckBox( title );
1374 addJCheckBox( _show_taxo_images_cb, ch_panel );
1377 case Configuration.show_binary_characters:
1378 _show_binary_characters = new JCheckBox( title );
1379 addJCheckBox( _show_binary_characters, ch_panel );
1382 case Configuration.show_annotation:
1383 _show_annotation = new JCheckBox( title );
1384 addJCheckBox( _show_annotation, ch_panel );
1387 case Configuration.show_binary_character_counts:
1388 _show_binary_character_counts = new JCheckBox( title );
1389 addJCheckBox( _show_binary_character_counts, ch_panel );
1392 case Configuration.write_confidence_values:
1393 _write_confidence = new JCheckBox( title );
1394 addJCheckBox( getWriteConfidenceCb(), ch_panel );
1397 case Configuration.write_events:
1398 _show_events = new JCheckBox( title );
1399 addJCheckBox( getShowEventsCb(), ch_panel );
1402 case Configuration.use_style:
1403 _use_visual_styles_cb = new JCheckBox( title );
1404 getUseVisualStylesCb()
1405 .setToolTipText( "To use visual styles (node colors, fonts) and branch colors, if present" );
1406 addJCheckBox( getUseVisualStylesCb(), ch_panel );
1409 case Configuration.width_branches:
1410 _width_branches = new JCheckBox( title );
1411 _width_branches.setToolTipText( "To use branch width values, if present" );
1412 addJCheckBox( _width_branches, ch_panel );
1415 case Configuration.write_branch_length_values:
1416 _write_branch_length_values = new JCheckBox( title );
1417 addJCheckBox( _write_branch_length_values, ch_panel );
1420 case Configuration.show_domain_architectures:
1421 _show_domain_architectures = new JCheckBox( title );
1422 addJCheckBox( _show_domain_architectures, ch_panel );
1425 case Configuration.show_mol_seqs:
1426 _show_mol_seqs = new JCheckBox( title );
1427 addJCheckBox( _show_mol_seqs, ch_panel );
1430 case Configuration.show_seq_names:
1431 _show_seq_names = new JCheckBox( title );
1432 addJCheckBox( _show_seq_names, ch_panel );
1435 case Configuration.show_gene_names:
1436 _show_gene_names = new JCheckBox( title );
1437 addJCheckBox( _show_gene_names, ch_panel );
1440 case Configuration.show_seq_symbols:
1441 _show_seq_symbols = new JCheckBox( title );
1442 addJCheckBox( _show_seq_symbols, ch_panel );
1445 case Configuration.show_sequence_acc:
1446 _show_sequence_acc = new JCheckBox( title );
1447 addJCheckBox( _show_sequence_acc, ch_panel );
1450 case Configuration.dynamically_hide_data:
1451 _dynamically_hide_data = new JCheckBox( title );
1452 getDynamicallyHideData().setToolTipText( "To hide labels depending on expected visibility" );
1453 addJCheckBox( getDynamicallyHideData(), ch_panel );
1456 case Configuration.node_data_popup:
1457 _node_desc_popup_cb = new JCheckBox( title );
1458 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
1459 addJCheckBox( getNodeDescPopupCb(), ch_panel );
1462 case Configuration.show_relation_confidence:
1463 _seq_relation_confidence_switch = new JCheckBox( title );
1464 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
1467 case Configuration.show_vector_data:
1468 _show_vector_data_cb = new JCheckBox( title );
1469 addJCheckBox( _show_vector_data_cb, ch_panel );
1472 case Configuration.show_properties:
1473 _show_properties_cb = new JCheckBox( title );
1474 addJCheckBox( _show_properties_cb, ch_panel );
1478 throw new RuntimeException( "unknown checkbox: " + which );
1482 void addJButton( final JButton jb, final JPanel p ) {
1483 jb.setFocusPainted( false );
1484 jb.setFont( ControlPanel.jcb_font );
1485 if ( !_configuration.isUseNativeUI() ) {
1486 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
1487 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1488 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
1491 jb.addActionListener( this );
1494 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
1495 jcb.setFocusPainted( false );
1496 jcb.setFont( ControlPanel.jcb_font );
1497 if ( !_configuration.isUseNativeUI() ) {
1498 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
1499 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1501 p.add( jcb, "Center" );
1502 jcb.addActionListener( this );
1505 private final void setupJRadioButton( final JRadioButton rb ) {
1506 rb.setFocusPainted( false );
1507 rb.setFont( ControlPanel.jcb_font );
1508 if ( !_configuration.isUseNativeUI() ) {
1509 rb.setBackground( getConfiguration().getGuiBackgroundColor() );
1510 rb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1512 rb.addActionListener( this );
1515 void addJTextField( final JTextField tf, final JPanel p ) {
1516 if ( !_configuration.isUseNativeUI() ) {
1517 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
1518 tf.setFont( ControlPanel.jcb_font );
1521 tf.addActionListener( this );
1524 void deactivateButtonToReturnToSuperTree() {
1525 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
1526 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
1527 _return_to_super_tree.setEnabled( false );
1530 void deactivateButtonToUncollapseAll() {
1531 _uncollapse_all.setForeground( getConfiguration().getGuiButtonTextColor() );
1532 _uncollapse_all.setEnabled( false );
1535 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
1536 if ( ( _mainpanel != null )
1537 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
1538 if ( recalc_longest_ext_node_info ) {
1539 _mainpanel.getCurrentTreePanel().initNodeData();
1540 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
1542 if ( getOptions().isShowOverview() ) {
1543 _mainpanel.getCurrentTreePanel().updateOvSizes();
1545 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
1546 setVisibilityOfDomainStrucureControls();
1547 updateDomainStructureEvaluethresholdDisplay();
1548 updateDepthCollapseDepthDisplay();
1549 updateRankCollapseRankDisplay();
1550 getMainPanel().getControlPanel();
1551 _mainpanel.getCurrentTreePanel().updateButtonToUncollapseAll();
1552 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
1553 _mainpanel.getCurrentTreePanel().calcMaxDepth();
1554 _mainpanel.adjustJScrollPane();
1555 _mainpanel.getCurrentTreePanel().repaint();
1556 // _mainpanel.getCurrentTreePanel().setUpUrtFactor();
1560 void endClickToOptions() {
1561 _click_to_combobox.addActionListener( this );
1565 * Indicates what action should be execute when a node is clicked
1567 * @return the click-on action
1569 NodeClickAction getActionWhenNodeClicked() {
1570 return _action_when_node_clicked;
1573 Map<Integer, String> getAllClickToItems() {
1574 return _all_click_to_names;
1577 Map<String, Color> getAnnotationColors() {
1578 return _annotation_colors;
1581 Configuration getConfiguration() {
1582 return _configuration;
1585 TreePanel getCurrentTreePanel() {
1586 return getMainPanel().getCurrentTreePanel();
1589 MainPanel getMainPanel() {
1593 Options getOptions() {
1594 return getMainPanel().getOptions();
1597 JLabel getSearchFoundCountsLabel0() {
1598 return _search_found_label_0;
1601 JLabel getSearchFoundCountsLabel1() {
1602 return _search_found_label_1;
1605 JButton getSearchResetButton0() {
1606 return _search_reset_button_0;
1609 JButton getSearchResetButton1() {
1610 return _search_reset_button_1;
1613 JTextField getSearchTextField0() {
1614 return _search_tf_0;
1617 JTextField getSearchTextField1() {
1618 return _search_tf_1;
1621 Map<String, Color> getSequenceColors() {
1622 return _sequence_colors;
1625 List<String> getSingleClickToNames() {
1626 return _click_to_names;
1629 Map<String, Color> getSpeciesColors() {
1630 return _species_colors;
1633 boolean isAntialiasScreenText() {
1637 boolean isColorAccordingToAnnotation() {
1638 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
1641 boolean isColorAccordingToSequence() {
1642 return ( ( _color_acc_sequence != null ) && _color_acc_sequence.isSelected() );
1645 boolean isColorAccordingToTaxonomy() {
1646 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
1649 boolean isDrawPhylogram() {
1650 final Options.PHYLOGENY_DISPLAY_TYPE t = getTreeDisplayType( getMainPanel().getCurrentTabIndex() );
1651 return ( ( t == Options.PHYLOGENY_DISPLAY_TYPE.ALIGNED_PHYLOGRAM )
1652 || ( t == Options.PHYLOGENY_DISPLAY_TYPE.UNALIGNED_PHYLOGRAM ) );
1655 boolean isDynamicallyHideData() {
1656 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
1659 boolean isEvents() {
1660 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
1663 boolean isNodeDescPopup() {
1664 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
1667 boolean isShowAnnotation() {
1668 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
1671 boolean isShowBinaryCharacterCounts() {
1672 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
1675 boolean isShowBinaryCharacters() {
1676 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
1679 boolean isShowConfidenceValues() {
1680 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
1683 boolean isShowDomainArchitectures() {
1684 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
1687 boolean isShowGeneNames() {
1688 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
1691 boolean isShowInternalData() {
1692 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
1695 boolean isShowExternalData() {
1696 return ( ( _display_external_data == null ) || _display_external_data.isSelected() );
1699 boolean isShowNodeNames() {
1700 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
1703 boolean isShowSeqNames() {
1704 return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
1707 boolean isShowSeqSymbols() {
1708 return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
1711 boolean isShowSequenceAcc() {
1712 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
1715 boolean isShowSequenceRelationConfidence() {
1716 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
1719 boolean isShowSequenceRelations() {
1720 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
1723 boolean isShowTaxonomyCode() {
1724 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
1727 boolean isShowTaxonomyRank() {
1728 return ( ( _show_taxo_rank != null ) && _show_taxo_rank.isSelected() );
1731 boolean isShowTaxonomyCommonNames() {
1732 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
1735 boolean isShowTaxonomyScientificNames() {
1736 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
1739 boolean isUseVisualStyles() {
1740 return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() )
1741 || ( ( getUseVisualStylesCb() == null ) && _color_branches ) );
1744 boolean isWidthBranches() {
1745 return ( ( _width_branches != null ) && _width_branches.isSelected() );
1748 boolean isWriteBranchLengthValues() {
1749 return ( ( _write_branch_length_values != null ) && _write_branch_length_values.isSelected() );
1752 void phylogenyAdded( final Configuration configuration ) {
1753 if ( configuration.isDrawAsPhylogram() ) {
1754 getTreeDisplayTypes().add( Options.PHYLOGENY_DISPLAY_TYPE.UNALIGNED_PHYLOGRAM );
1757 getTreeDisplayTypes().add( Options.PHYLOGENY_DISPLAY_TYPE.CLADOGRAM );
1761 void phylogenyRemoved( final int index ) {
1762 getTreeDisplayTypes().remove( index );
1766 final MainPanel main_panel = getMainPanel();
1767 final Phylogeny tree = main_panel.getCurrentPhylogeny();
1768 if ( ( tree == null ) || tree.isEmpty() ) {
1771 String query = getSearchTextField0().getText();
1772 if ( query != null ) {
1773 query = query.trim();
1775 if ( !ForesterUtil.isEmpty( query ) ) {
1776 search0( main_panel, tree, query );
1779 getSearchFoundCountsLabel0().setVisible( false );
1780 getSearchResetButton0().setEnabled( false );
1781 getSearchResetButton0().setVisible( false );
1787 final MainPanel main_panel = getMainPanel();
1788 final Phylogeny tree = main_panel.getCurrentPhylogeny();
1789 if ( ( tree == null ) || tree.isEmpty() ) {
1792 String query = getSearchTextField1().getText();
1793 if ( query != null ) {
1794 query = query.trim();
1796 if ( !ForesterUtil.isEmpty( query ) ) {
1797 search1( main_panel, tree, query );
1800 getSearchFoundCountsLabel1().setVisible( false );
1801 getSearchResetButton1().setEnabled( false );
1802 getSearchResetButton1().setVisible( false );
1807 void searchReset0() {
1808 if ( getMainPanel().getCurrentTreePanel() != null ) {
1809 getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
1813 void searchReset1() {
1814 if ( getMainPanel().getCurrentTreePanel() != null ) {
1815 getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
1819 void setActionWhenNodeClicked( final NodeClickAction action ) {
1820 _action_when_node_clicked = action;
1823 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
1824 _annotation_colors = annotation_colors;
1827 void setCheckbox( final int which, final boolean state ) {
1829 case Configuration.display_as_phylogram:
1830 if ( getDisplayAsUnalignedPhylogramRb() != null ) {
1831 getDisplayAsUnalignedPhylogramRb().setSelected( state );
1832 getDisplayAsAlignedPhylogramRb().setSelected( !state );
1833 getDisplayAsCladogramRb().setSelected( !state );
1836 case Configuration.display_internal_data:
1837 if ( _display_internal_data != null ) {
1838 _display_internal_data.setSelected( state );
1841 case Configuration.display_external_data:
1842 if ( _display_external_data != null ) {
1843 _display_external_data.setSelected( state );
1846 case Configuration.color_according_to_species:
1847 if ( _color_acc_species != null ) {
1848 _color_acc_species.setSelected( state );
1851 case Configuration.color_according_to_sequence:
1852 if ( _color_acc_sequence != null ) {
1853 _color_acc_sequence.setSelected( state );
1856 case Configuration.color_according_to_annotation:
1857 if ( _color_according_to_annotation != null ) {
1858 _color_according_to_annotation.setSelected( state );
1861 case Configuration.show_node_names:
1862 if ( _show_node_names != null ) {
1863 _show_node_names.setSelected( state );
1866 case Configuration.show_taxonomy_scientific_names:
1867 if ( _show_taxo_scientific_names != null ) {
1868 _show_taxo_scientific_names.setSelected( state );
1871 case Configuration.show_taxonomy_common_names:
1872 if ( _show_taxo_common_names != null ) {
1873 _show_taxo_common_names.setSelected( state );
1876 case Configuration.show_tax_code:
1877 if ( _show_taxo_code != null ) {
1878 _show_taxo_code.setSelected( state );
1881 case Configuration.show_tax_rank:
1882 if ( _show_taxo_rank != null ) {
1883 _show_taxo_rank.setSelected( state );
1886 case Configuration.show_taxonomy_images:
1887 if ( _show_taxo_images_cb != null ) {
1888 _show_taxo_images_cb.setSelected( state );
1891 case Configuration.show_annotation:
1892 if ( _show_annotation != null ) {
1893 _show_annotation.setSelected( state );
1896 case Configuration.show_binary_characters:
1897 if ( _show_binary_characters != null ) {
1898 _show_binary_characters.setSelected( state );
1901 case Configuration.show_binary_character_counts:
1902 if ( _show_binary_character_counts != null ) {
1903 _show_binary_character_counts.setSelected( state );
1906 case Configuration.write_confidence_values:
1907 if ( getWriteConfidenceCb() != null ) {
1908 getWriteConfidenceCb().setSelected( state );
1911 case Configuration.write_events:
1912 if ( getShowEventsCb() != null ) {
1913 getShowEventsCb().setSelected( state );
1916 case Configuration.use_style:
1917 if ( getUseVisualStylesCb() != null ) {
1918 getUseVisualStylesCb().setSelected( state );
1921 case Configuration.width_branches:
1922 if ( _width_branches != null ) {
1923 _width_branches.setSelected( state );
1926 case Configuration.show_domain_architectures:
1927 if ( _show_domain_architectures != null ) {
1928 _show_domain_architectures.setSelected( state );
1931 case Configuration.write_branch_length_values:
1932 if ( _write_branch_length_values != null ) {
1933 _write_branch_length_values.setSelected( state );
1936 case Configuration.show_mol_seqs:
1937 if ( _show_mol_seqs != null ) {
1938 _show_mol_seqs.setSelected( state );
1941 case Configuration.show_seq_names:
1942 if ( _show_seq_names != null ) {
1943 _show_seq_names.setSelected( state );
1946 case Configuration.show_gene_names:
1947 if ( _show_gene_names != null ) {
1948 _show_gene_names.setSelected( state );
1951 case Configuration.show_seq_symbols:
1952 if ( _show_seq_symbols != null ) {
1953 _show_seq_symbols.setSelected( state );
1956 case Configuration.show_vector_data:
1957 if ( _show_vector_data_cb != null ) {
1958 _show_vector_data_cb.setSelected( state );
1961 case Configuration.show_properties:
1962 if ( _show_properties_cb != null ) {
1963 _show_properties_cb.setSelected( state );
1966 case Configuration.show_sequence_acc:
1967 if ( _show_sequence_acc != null ) {
1968 _show_sequence_acc.setSelected( state );
1971 case Configuration.dynamically_hide_data:
1972 if ( getDynamicallyHideData() != null ) {
1973 getDynamicallyHideData().setSelected( state );
1976 case Configuration.node_data_popup:
1977 if ( getNodeDescPopupCb() != null ) {
1978 getNodeDescPopupCb().setSelected( state );
1982 case Configuration.show_relation_confidence:
1983 if ( _seq_relation_confidence_switch != null ) {
1984 _seq_relation_confidence_switch.setSelected( state );
1989 throw new AssertionError( "unknown checkbox: " + which );
1994 * Set this checkbox state. Not all checkboxes have been instantiated
1995 * depending on the config.
1997 void setCheckbox( final JCheckBox cb, final boolean state ) {
1999 cb.setSelected( state );
2003 void setClickToAction( final int action ) {
2004 // Set click-to action
2005 if ( action == _show_data_item ) {
2006 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
2008 else if ( action == _collapse_cb_item ) {
2009 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
2011 else if ( action == _reroot_cb_item ) {
2012 setActionWhenNodeClicked( NodeClickAction.REROOT );
2014 else if ( action == _subtree_cb_item ) {
2015 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
2017 else if ( action == _swap_cb_item ) {
2018 setActionWhenNodeClicked( NodeClickAction.SWAP );
2020 else if ( action == _color_subtree_cb_item ) {
2021 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
2023 else if ( action == _open_seq_web_item ) {
2024 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
2026 else if ( action == _sort_descendents_item ) {
2027 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
2029 else if ( action == _blast_item ) {
2030 setActionWhenNodeClicked( NodeClickAction.BLAST );
2032 else if ( action == _open_tax_web_item ) {
2033 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
2035 else if ( action == _cut_subtree_item ) {
2036 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
2038 else if ( action == _copy_subtree_item ) {
2039 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
2041 else if ( action == _delete_node_or_subtree_item ) {
2042 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
2044 else if ( action == _paste_subtree_item ) {
2045 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
2047 else if ( action == _add_new_node_item ) {
2048 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
2050 else if ( action == _edit_node_data_item ) {
2051 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
2053 else if ( action == _select_nodes_item ) {
2054 setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
2056 else if ( action == _get_ext_desc_data ) {
2057 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
2059 else if ( action == _open_pdb_item ) {
2060 setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
2062 else if ( action == _color_node_font_item ) {
2063 setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
2065 else if ( action == _change_node_font_item ) {
2066 setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT );
2068 else if ( action == _uncollapse_all_cb_item ) {
2069 setActionWhenNodeClicked( NodeClickAction.UNCOLLAPSE_ALL );
2071 else if ( action == _order_subtree_cb_item ) {
2072 setActionWhenNodeClicked( NodeClickAction.ORDER_SUBTREE );
2075 throw new RuntimeException( "unknown action: " + action );
2077 // make sure drop down is displaying the correct action
2078 // in case this was called from outside the class
2079 _click_to_combobox.setSelectedIndex( action );
2082 public void setColorBranches( final boolean color_branches ) {
2083 _color_branches = color_branches;
2086 void setTreeDisplayType( final Options.PHYLOGENY_DISPLAY_TYPE t ) {
2088 case UNALIGNED_PHYLOGRAM:
2089 getDisplayAsUnalignedPhylogramRb().setSelected( true );
2091 case ALIGNED_PHYLOGRAM:
2092 getDisplayAsAlignedPhylogramRb().setSelected( true );
2095 getDisplayAsCladogramRb().setSelected( true );
2098 setTreeDisplayType( getMainPanel().getCurrentTabIndex(), t );
2101 void setDrawPhylogramEnabled( final boolean b ) {
2102 if ( getDisplayAsAlignedPhylogramRb() != null && getDisplayAsUnalignedPhylogramRb() != null
2103 && getDisplayAsCladogramRb() != null ) {
2104 getDisplayAsAlignedPhylogramRb().setEnabled( b );
2105 getDisplayAsUnalignedPhylogramRb().setEnabled( b );
2106 getDisplayAsCladogramRb().setEnabled( b );
2110 void setDynamicHidingIsOn( final boolean is_on ) {
2112 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
2115 if ( !_configuration.isUseNativeUI() ) {
2116 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
2119 getDynamicallyHideData().setForeground( Color.BLACK );
2124 void setSearchFoundCountsOnLabel0( final int counts ) {
2125 getSearchFoundCountsLabel0().setText( "Found: " + counts );
2128 void setSearchFoundCountsOnLabel1( final int counts ) {
2129 getSearchFoundCountsLabel1().setText( "Found: " + counts );
2132 void setSequenceColors( final Map<String, Color> sequence_colors ) {
2133 _sequence_colors = sequence_colors;
2136 void setShowEvents( final boolean show_events ) {
2137 if ( getShowEventsCb() == null ) {
2138 _show_events = new JCheckBox( "" );
2140 getShowEventsCb().setSelected( show_events );
2143 void setSpeciesColors( final Map<String, Color> species_colors ) {
2144 _species_colors = species_colors;
2147 void setupControls() {
2148 setupTreeDisplayTypeOptions();
2149 setupDisplayCheckboxes();
2151 // The sequence relation query selection combo-box
2152 if ( _configuration.displaySequenceRelations() ) {
2153 addSequenceRelationBlock();
2157 startClickToOptions();
2158 setupClickToOptions();
2159 endClickToOptions();
2160 // Zoom and quick edit buttons
2162 setupSearchTools0();
2163 setupSearchTools1();
2166 void setupTreeDisplayTypeOptions() {
2167 _display_as_unaligned_phylogram_rb = new JRadioButton( "P" );
2168 _display_as_aligned_phylogram_rb = new JRadioButton( "A" );
2169 _display_as_cladogram_rb = new JRadioButton( "C" );
2170 _display_as_buttongroup = new ButtonGroup();
2171 _display_as_buttongroup.add( _display_as_unaligned_phylogram_rb );
2172 _display_as_buttongroup.add( _display_as_aligned_phylogram_rb );
2173 _display_as_buttongroup.add( _display_as_cladogram_rb );
2174 getDisplayAsUnalignedPhylogramRb().setToolTipText( "(unaligned) phylogram" );
2175 getDisplayAsAlignedPhylogramRb().setToolTipText( "aligned phylogram" );
2176 getDisplayAsCladogramRb().setToolTipText( "cladogram" );
2177 setupJRadioButton( getDisplayAsUnalignedPhylogramRb() );
2178 setupJRadioButton( getDisplayAsAlignedPhylogramRb() );
2179 setupJRadioButton( getDisplayAsCladogramRb() );
2180 final JPanel p = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2181 p.setFont( ControlPanel.jcb_font );
2182 if ( !_configuration.isUseNativeUI() ) {
2183 p.setBackground( getConfiguration().getGuiBackgroundColor() );
2184 p.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2186 p.add( _display_as_unaligned_phylogram_rb );
2187 p.add( _display_as_aligned_phylogram_rb );
2188 p.add( _display_as_cladogram_rb );
2192 void setUpControlsForDomainStrucures() {
2193 _domain_display_label = new JLabel( "Domain Architectures:" );
2194 add( customizeLabel( _domain_display_label, getConfiguration() ) );
2195 add( _domain_display_label );
2196 _zoom_in_domain_structure = new TypomaticJButton( "d+" );
2197 _zoom_out_domain_structure = new TypomaticJButton( "d-" );
2198 _decr_domain_structure_evalue_thr = new JButton( "-" );
2199 _incr_domain_structure_evalue_thr = new JButton( "+" );
2200 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
2201 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
2202 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
2203 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
2204 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
2205 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
2206 _domain_structure_evalue_thr_tf = new JTextField( 3 );
2207 _domain_structure_evalue_thr_tf.setEditable( false );
2208 if ( !getConfiguration().isUseNativeUI() ) {
2209 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2210 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2211 _domain_structure_evalue_thr_tf.setBorder( null );
2213 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2214 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2215 if ( !_configuration.isUseNativeUI() ) {
2216 d1_panel.setBackground( getBackground() );
2217 d2_panel.setBackground( getBackground() );
2221 addJButton( _zoom_out_domain_structure, d1_panel );
2222 addJButton( _zoom_in_domain_structure, d1_panel );
2223 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
2224 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
2225 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
2228 void setUpControlsForDepthCollapse() {
2229 _depth_collapse_label = new JLabel( "Collapse by Node Depth:" );
2230 _depth_collapse_label
2231 .setToolTipText( "to automaticall collapse nodes with a depth equal or larger than a threshold" );
2232 add( customizeLabel( _depth_collapse_label, getConfiguration() ) );
2233 add( _depth_collapse_label );
2234 _decr_depth_collapse_level = new TypomaticJButton( "-" );
2235 _incr_depth_collapse_level = new TypomaticJButton( "+" );
2236 _decr_depth_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2237 _incr_depth_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2238 _decr_depth_collapse_level.setToolTipText( "to decrease the depth threshold (wraps around)" );
2239 _incr_depth_collapse_level.setToolTipText( "to increase the depth threshold (wraps around)" );
2240 _depth_collapse_depth_tf = new JTextField( 3 );
2241 _depth_collapse_depth_tf.setToolTipText( "the current depth threshold" );
2242 _depth_collapse_depth_tf.setEditable( false );
2243 if ( !getConfiguration().isUseNativeUI() ) {
2244 _depth_collapse_depth_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2245 _depth_collapse_depth_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2246 _depth_collapse_depth_tf.setBorder( null );
2248 final JPanel panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2249 if ( !_configuration.isUseNativeUI() ) {
2250 panel.setBackground( getBackground() );
2253 addJButton( _decr_depth_collapse_level, panel );
2254 addJTextField( _depth_collapse_depth_tf, panel );
2255 addJButton( _incr_depth_collapse_level, panel );
2258 void setUpControlsForRankCollapse() {
2259 _rank_collapse_label = new JLabel( "Collapse by Node Rank:" );
2260 _rank_collapse_label
2261 .setToolTipText( "to automatically collapse nodes with a taxonomic rank equal or lower than a threshold" );
2262 add( customizeLabel( _rank_collapse_label, getConfiguration() ) );
2263 add( _rank_collapse_label );
2264 _decr_rank_collapse_level = new TypomaticJButton( "-" );
2265 _incr_rank_collapse_level = new TypomaticJButton( "+" );
2266 _decr_rank_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2267 _incr_rank_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2268 _decr_rank_collapse_level.setToolTipText( "to decrease the taxonomic rank threshold (wraps around)" );
2269 _incr_rank_collapse_level.setToolTipText( "to increase the taxonomic rank threshold (wraps around)" );
2270 _rank_collapse_depth_tf = new JTextField( 3 );
2271 _rank_collapse_depth_tf.setToolTipText( "the current taxonomic rank threshold" );
2272 _rank_collapse_depth_tf.setEditable( false );
2273 if ( !getConfiguration().isUseNativeUI() ) {
2274 _rank_collapse_depth_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2275 _rank_collapse_depth_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2276 _rank_collapse_depth_tf.setBorder( null );
2278 final JPanel panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2279 if ( !_configuration.isUseNativeUI() ) {
2280 panel.setBackground( getBackground() );
2283 addJButton( _decr_rank_collapse_level, panel );
2284 addJTextField( _rank_collapse_depth_tf, panel );
2285 addJButton( _incr_rank_collapse_level, panel );
2288 void setupSearchTools0() {
2289 final JLabel search_label = new JLabel( "Search (A):" );
2290 search_label.setFont( ControlPanel.jcb_bold_font );
2291 if ( !getConfiguration().isUseNativeUI() ) {
2292 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2294 add( search_label );
2295 search_label.setToolTipText( SEARCH_TIP_TEXT );
2296 _search_found_label_0 = new JLabel();
2297 getSearchFoundCountsLabel0().setVisible( false );
2298 _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
2299 if ( !getConfiguration().isUseNativeUI() ) {
2300 _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2302 _search_tf_0 = new JTextField( 3 );
2303 _search_tf_0.setToolTipText( SEARCH_TIP_TEXT );
2304 _search_tf_0.setEditable( true );
2305 if ( !getConfiguration().isUseNativeUI() ) {
2306 _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2307 _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2308 _search_tf_0.setBorder( null );
2310 _search_reset_button_0 = new JButton();
2311 getSearchResetButton0().setText( "Reset" );
2312 getSearchResetButton0().setEnabled( false );
2313 getSearchResetButton0().setVisible( false );
2314 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
2315 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2316 s_panel_1.setBackground( getBackground() );
2318 s_panel_2.setBackground( getBackground() );
2320 final KeyAdapter key_adapter = new KeyAdapter() {
2323 public void keyReleased( final KeyEvent key_event ) {
2325 displayedPhylogenyMightHaveChanged( true );
2328 final ActionListener action_listener = new ActionListener() {
2331 public void actionPerformed( final ActionEvent e ) {
2333 setSearchFoundCountsOnLabel0( 0 );
2334 getSearchFoundCountsLabel0().setVisible( false );
2335 getSearchTextField0().setText( "" );
2336 getSearchResetButton0().setEnabled( false );
2337 getSearchResetButton0().setVisible( false );
2338 displayedPhylogenyMightHaveChanged( true );
2341 _search_reset_button_0.addActionListener( action_listener );
2342 _search_tf_0.addKeyListener( key_adapter );
2343 addJTextField( _search_tf_0, s_panel_1 );
2344 s_panel_2.add( _search_found_label_0 );
2345 addJButton( _search_reset_button_0, s_panel_2 );
2348 void setupSearchTools1() {
2349 final JLabel search_label = new JLabel( "Search (B):" );
2350 search_label.setFont( ControlPanel.jcb_bold_font );
2351 if ( !getConfiguration().isUseNativeUI() ) {
2352 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2354 add( search_label );
2355 search_label.setToolTipText( SEARCH_TIP_TEXT );
2356 _search_found_label_1 = new JLabel();
2357 getSearchFoundCountsLabel1().setVisible( false );
2358 _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
2359 if ( !getConfiguration().isUseNativeUI() ) {
2360 _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2362 _search_tf_1 = new JTextField( 3 );
2363 _search_tf_1.setToolTipText( SEARCH_TIP_TEXT );
2364 _search_tf_1.setEditable( true );
2365 if ( !getConfiguration().isUseNativeUI() ) {
2366 _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2367 _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2368 _search_tf_1.setBorder( null );
2370 _search_reset_button_1 = new JButton();
2371 getSearchResetButton1().setText( "Reset" );
2372 getSearchResetButton1().setEnabled( false );
2373 getSearchResetButton1().setVisible( false );
2374 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
2375 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2376 s_panel_1.setBackground( getBackground() );
2378 s_panel_2.setBackground( getBackground() );
2380 final KeyAdapter key_adapter = new KeyAdapter() {
2383 public void keyReleased( final KeyEvent key_event ) {
2385 displayedPhylogenyMightHaveChanged( true );
2388 final ActionListener action_listener = new ActionListener() {
2391 public void actionPerformed( final ActionEvent e ) {
2393 setSearchFoundCountsOnLabel1( 0 );
2394 getSearchFoundCountsLabel1().setVisible( false );
2395 getSearchTextField1().setText( "" );
2396 getSearchResetButton1().setEnabled( false );
2397 getSearchResetButton1().setVisible( false );
2398 displayedPhylogenyMightHaveChanged( true );
2401 _search_reset_button_1.addActionListener( action_listener );
2402 _search_tf_1.addKeyListener( key_adapter );
2403 addJTextField( _search_tf_1, s_panel_1 );
2404 s_panel_2.add( _search_found_label_1 );
2405 addJButton( _search_reset_button_1, s_panel_2 );
2408 void setVisibilityOfDomainStrucureCB() {
2410 if ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel()
2411 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2412 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
2413 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2414 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
2416 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2417 getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
2420 else if ( isShowDomainArchitectures() ) {
2421 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2422 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( true );
2424 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2425 getMainPanel().getMainFrame()._show_domain_labels.setVisible( true );
2429 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2430 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
2432 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2433 getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
2437 catch ( final Exception ignore ) {
2442 void setVisibilityOfX() {
2443 final MainFrame mf = getMainFrame();
2445 if ( ( getCurrentTreePanel() != null ) && ( getCurrentTreePanel().getPhylogeny() != null ) ) {
2446 if ( AptxUtil.isHasAtLeastOneBranchWithSupportSD( getCurrentTreePanel().getPhylogeny() ) ) {
2447 if ( mf._show_confidence_stddev_cbmi != null ) {
2448 mf._show_confidence_stddev_cbmi.setVisible( true );
2452 if ( mf._show_confidence_stddev_cbmi != null ) {
2453 mf._show_confidence_stddev_cbmi.setVisible( false );
2456 if ( AptxUtil.isHasAtLeastOneNodeWithScientificName( getCurrentTreePanel().getPhylogeny() ) ) {
2457 if ( mf._abbreviate_scientific_names != null ) {
2458 mf._abbreviate_scientific_names.setVisible( true );
2462 if ( mf._abbreviate_scientific_names != null ) {
2463 mf._abbreviate_scientific_names.setVisible( false );
2466 if ( AptxUtil.isHasAtLeastOneNodeWithSequenceAnnotation( getCurrentTreePanel().getPhylogeny() ) ) {
2467 if ( mf._show_annotation_ref_source != null ) {
2468 mf._show_annotation_ref_source.setVisible( true );
2472 if ( mf._show_annotation_ref_source != null ) {
2473 mf._show_annotation_ref_source.setVisible( false );
2477 if ( isDrawPhylogram() || ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel()
2478 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2479 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) ) {
2480 if ( mf._non_lined_up_cladograms_rbmi != null ) {
2481 mf._non_lined_up_cladograms_rbmi.setVisible( false );
2483 if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
2484 mf._ext_node_dependent_cladogram_rbmi.setVisible( false );
2488 if ( mf._non_lined_up_cladograms_rbmi != null ) {
2489 mf._non_lined_up_cladograms_rbmi.setVisible( true );
2491 if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
2492 mf._ext_node_dependent_cladogram_rbmi.setVisible( true );
2495 if ( isDrawPhylogram() ) {
2496 if ( mf._show_scale_cbmi != null ) {
2497 mf._show_scale_cbmi.setVisible( true );
2501 if ( mf._show_scale_cbmi != null ) {
2502 mf._show_scale_cbmi.setVisible( false );
2505 if ( getCurrentTreePanel() != null ) {
2506 if ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2507 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
2508 if ( mf._label_direction_cbmi != null ) {
2509 mf._label_direction_cbmi.setVisible( true );
2513 if ( mf._label_direction_cbmi != null ) {
2514 mf._label_direction_cbmi.setVisible( false );
2521 void showAnnotations() {
2522 if ( _show_annotation != null ) {
2523 _show_annotation.setSelected( true );
2525 if ( _color_according_to_annotation != null ) {
2526 _color_according_to_annotation.setSelected( true );
2528 if ( _color_acc_species != null ) {
2529 _color_acc_species.setSelected( false );
2531 if ( _color_acc_sequence != null ) {
2532 _color_acc_sequence.setSelected( false );
2534 _mainpanel.getCurrentTreePanel().repaint();
2538 * Fit entire tree into window.
2540 public void showWhole() {
2541 if ( ( _mainpanel.getCurrentScrollPane() == null )
2542 || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
2545 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
2546 displayedPhylogenyMightHaveChanged( true );
2547 _mainpanel.getCurrentTreePanel().updateOvSettings();
2548 _mainpanel.getCurrentTreePanel().validate();
2549 _mainpanel.validate();
2550 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2551 _mainpanel.getSizeOfViewport().height );
2552 _mainpanel.getCurrentTreePanel().resetPreferredSize();
2553 _mainpanel.adjustJScrollPane();
2554 _mainpanel.getCurrentTreePanel().repaint();
2555 _mainpanel.getCurrentTreePanel().validate();
2556 _mainpanel.validate();
2557 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2558 _mainpanel.getSizeOfViewport().height );
2559 _mainpanel.getCurrentTreePanel().resetPreferredSize();
2560 _mainpanel.adjustJScrollPane();
2561 _mainpanel.getCurrentTreePanel().repaint();
2562 _mainpanel.getCurrentTreePanel().updateOvSizes();
2565 void showWholeAll() {
2566 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
2567 if ( tree_panel != null ) {
2568 tree_panel.validate();
2569 tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2570 _mainpanel.getSizeOfViewport().height );
2571 tree_panel.resetPreferredSize();
2572 tree_panel.repaint();
2577 // Create header for click-to combo box.
2578 void startClickToOptions() {
2579 final JLabel spacer = new JLabel( "" );
2580 spacer.setFont( ControlPanel.jcb_font );
2582 _click_to_label = new JLabel( "Click on Node to:" );
2583 add( customizeLabel( _click_to_label, getConfiguration() ) );
2584 _click_to_combobox = new JComboBox<String>();
2585 _click_to_combobox.setFocusable( false );
2586 _click_to_combobox.setMaximumRowCount( 14 );
2587 _click_to_combobox.setFont( ControlPanel.js_font );
2588 if ( !_configuration.isUseNativeUI() ) {
2589 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
2591 // don't add listener until all items are set (or each one will trigger
2593 // click_to_list.addActionListener(this);
2594 add( _click_to_combobox );
2595 // Correlates option names to titles
2596 _all_click_to_names = new HashMap<Integer, String>();
2597 _click_to_names = new ArrayList<String>();
2601 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
2602 if ( getCurrentTreePanel().isPhyHasBranchLengths()
2603 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
2604 setDrawPhylogramEnabled( true );
2605 setTreeDisplayType( getTreeDisplayType( getMainPanel().getCurrentTabIndex() ) );
2608 setDrawPhylogramEnabled( false );
2609 setTreeDisplayType( Options.PHYLOGENY_DISPLAY_TYPE.CLADOGRAM );
2611 getMainPanel().getMainFrame()
2612 .setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel().getPhylogenyGraphicsType() );
2613 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
2614 getMainPanel().getCurrentTreePanel().updateButtonToUncollapseAll();
2615 getMainPanel().getControlPanel().search0();
2616 getMainPanel().getControlPanel().search1();
2617 getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
2618 getMainPanel().getControlPanel().updateDepthCollapseDepthDisplay();
2619 getMainPanel().getControlPanel().updateRankCollapseRankDisplay();
2620 getSequenceRelationTypeBox().removeAllItems();
2621 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
2622 .getRelevantSequenceRelationTypes() ) {
2623 _sequence_relation_type_box.addItem( type );
2625 getMainPanel().getCurrentTreePanel().repaint();
2626 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
2627 // according to GUILHEM the line above can be removed.
2632 * Uncollapse all nodes.
2634 final void uncollapseAll( final TreePanel tp ) {
2635 final Phylogeny t = tp.getPhylogeny();
2636 if ( ( t != null ) && !t.isEmpty() ) {
2637 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
2638 final PhylogenyNode node = iter.next();
2639 node.setCollapse( false );
2641 tp.resetNodeIdToDistToLeafMap();
2642 tp.updateSetOfCollapsedExternalNodes();
2643 t.recalculateNumberOfExternalDescendants( false );
2644 tp.setNodeInPreorderToNull();
2645 t.clearHashIdToNodeMap();
2646 tp.resetDepthCollapseDepthValue();
2647 tp.resetRankCollapseRankValue();
2652 final void updateDomainStructureEvaluethresholdDisplay() {
2653 if ( _domain_structure_evalue_thr_tf != null ) {
2654 _domain_structure_evalue_thr_tf
2655 .setText( "10^" + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThresholdExp() );
2659 private final String obtainDepthCollapseDepthValue() {
2660 if ( getMainPanel().getCurrentTreePanel() == null ) {
2663 final TreePanel tp = getMainPanel().getCurrentTreePanel();
2664 final Phylogeny p = tp.getPhylogeny();
2665 if ( ( p == null ) || ( p.getNumberOfExternalNodes() < 3 ) ) {
2668 else if ( tp.getDepthCollapseDepthValue() < 0 ) {
2669 tp.setDepthCollapseDepthValue( PhylogenyMethods.calculateMaxDepth( p ) );
2672 else if ( tp.getDepthCollapseDepthValue() == PhylogenyMethods.calculateMaxDepth( p ) ) {
2675 return String.valueOf( tp.getDepthCollapseDepthValue() );
2678 private final String obtainRankCollapseDepthValue() {
2679 if ( getMainPanel().getCurrentTreePanel() == null ) {
2682 final TreePanel tp = getMainPanel().getCurrentTreePanel();
2683 final Phylogeny p = tp.getPhylogeny();
2684 if ( ( p == null ) || ( p.getNumberOfExternalNodes() < 3 ) ) {
2688 final String ranks[] = PhylogenyMethods.obtainPresentRanksSorted( p );
2689 if ( ranks.length < 1 ) {
2692 else if ( tp.getRankCollapseRankValue() < 0 ) {
2693 tp.setRankCollapseRankValue( ranks.length - 1 );
2696 else if ( tp.getRankCollapseRankValue() == ( ranks.length - 1 ) ) {
2700 return String.valueOf( tp.getRankCollapseRankValue() );
2703 final void updateDepthCollapseDepthDisplay() {
2704 if ( _depth_collapse_depth_tf != null ) {
2705 _depth_collapse_depth_tf.setText( " " + obtainDepthCollapseDepthValue() );
2709 final void updateRankCollapseRankDisplay() {
2710 if ( _rank_collapse_depth_tf != null ) {
2711 final String r = obtainRankCollapseDepthValue();
2712 if ( r.equals( "off" ) ) {
2713 _rank_collapse_depth_tf.setText( " off" );
2714 _rank_collapse_depth_tf.setToolTipText( "the current taxonomic rank threshold" );
2717 final String ranks[] = PhylogenyMethods
2718 .obtainPresentRanksSorted( getMainPanel().getCurrentTreePanel().getPhylogeny() );
2719 final int rr = Integer.parseInt( r );
2720 _rank_collapse_depth_tf.setText( ranks[ rr ] );
2721 _rank_collapse_depth_tf.setToolTipText( ( rr + 1 ) + "/" + ( ranks.length - 1 ) + ": "
2722 + ranks[ Integer.parseInt( r ) ] );
2727 final void zoomInX( final float factor, final float x_correction_factor ) {
2728 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
2729 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2730 treepanel.multiplyUrtFactor( 1f );
2731 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2732 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
2733 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
2734 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
2735 final double x = ( sb.getMaximum() - sb.getMinimum() )
2736 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2737 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2738 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2739 getMainPanel().adjustJScrollPane();
2740 treepanel.resetPreferredSize();
2741 getMainPanel().getCurrentScrollPane().getViewport().validate();
2742 sb.setValue( ForesterUtil
2743 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2746 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
2747 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2748 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2749 getMainPanel().adjustJScrollPane();
2750 treepanel.resetPreferredSize();
2751 getMainPanel().getCurrentScrollPane().getViewport().validate();
2752 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
2754 treepanel.resetPreferredSize();
2755 treepanel.updateOvSizes();
2758 final void zoomInY( final float factor ) {
2759 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
2760 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2761 treepanel.multiplyUrtFactor( 1.1f );
2762 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2763 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
2764 getMainPanel().adjustJScrollPane();
2765 treepanel.resetPreferredSize();
2766 getMainPanel().getCurrentScrollPane().getViewport().validate();
2767 sb.setValue( ForesterUtil
2768 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2769 treepanel.resetPreferredSize();
2770 treepanel.updateOvSizes();
2773 final void zoomOutX( final float factor, final float x_correction_factor ) {
2774 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2775 treepanel.multiplyUrtFactor( 1f );
2776 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
2777 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
2778 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2779 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
2780 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
2781 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
2782 getMainPanel().adjustJScrollPane();
2783 treepanel.resetPreferredSize();
2784 getMainPanel().getCurrentScrollPane().getViewport().validate();
2785 final double x = ( sb.getMaximum() - sb.getMinimum() )
2786 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2787 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2788 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2789 getMainPanel().adjustJScrollPane();
2790 treepanel.resetPreferredSize();
2791 getMainPanel().getCurrentScrollPane().getViewport().validate();
2792 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
2793 - ( sb.getVisibleAmount() / 2.0 ) ) );
2796 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
2797 treepanel.setXdistance( treepanel.getXdistance() * factor );
2798 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
2800 getMainPanel().adjustJScrollPane();
2801 treepanel.resetPreferredSize();
2802 getMainPanel().getCurrentScrollPane().getViewport().validate();
2803 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
2806 treepanel.resetPreferredSize();
2807 treepanel.updateOvSizes();
2811 private final boolean isDrawPhylogram( int currentTabIndex ) {
2812 Options.PHYLOGENY_DISPLAY_TYPE t = getTreeDisplayType( currentTabIndex );
2813 return ( ( t == Options.PHYLOGENY_DISPLAY_TYPE.ALIGNED_PHYLOGRAM )
2814 | ( t == Options.PHYLOGENY_DISPLAY_TYPE.UNALIGNED_PHYLOGRAM ) );
2817 final void zoomOutY( final float factor ) {
2818 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2819 treepanel.multiplyUrtFactor( 0.9f );
2820 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
2821 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
2822 final double x = ( sb.getMaximum() - sb.getMinimum() )
2823 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2824 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
2825 getMainPanel().adjustJScrollPane();
2826 treepanel.resetPreferredSize();
2827 getMainPanel().getCurrentScrollPane().getViewport().validate();
2828 sb.setValue( ForesterUtil
2829 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2830 treepanel.resetPreferredSize();
2831 treepanel.updateOvSizes();
2835 final static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2836 label.setFont( ControlPanel.jcb_bold_font );
2837 if ( !configuration.isUseNativeUI() ) {
2838 label.setForeground( configuration.getGuiCheckboxTextColor() );
2839 label.setBackground( configuration.getGuiBackgroundColor() );
2844 final public JCheckBox getUseBranchWidthsCb() {
2845 return _width_branches;
2848 public Options.PHYLOGENY_DISPLAY_TYPE getTreeDisplayType() {
2849 if ( _display_as_unaligned_phylogram_rb.isSelected() ) {
2850 return Options.PHYLOGENY_DISPLAY_TYPE.UNALIGNED_PHYLOGRAM;
2852 else if ( _display_as_aligned_phylogram_rb.isSelected() ) {
2853 return Options.PHYLOGENY_DISPLAY_TYPE.ALIGNED_PHYLOGRAM;
2855 return Options.PHYLOGENY_DISPLAY_TYPE.CLADOGRAM;