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;
77 final class ControlPanel extends JPanel implements ActionListener {
79 enum NodeClickAction {
86 DELETE_NODE_OR_SUBTREE,
104 final static Font jcb_bold_font = new Font( Configuration
105 .getDefaultFontFamilyName(), Font.BOLD, 9 );
106 final static Font jcb_font = new Font( Configuration
107 .getDefaultFontFamilyName(), Font.PLAIN, 9 );
108 final static Font js_font = new Font( Configuration
109 .getDefaultFontFamilyName(), Font.PLAIN, 9 );
110 private static final String RETURN_TO_SUPER_TREE_TEXT = "R";
111 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).";
112 private static final long serialVersionUID = -8463483932821545633L;
113 private NodeClickAction _action_when_node_clicked;
114 private int _add_new_node_item;
115 private Map<Integer, String> _all_click_to_names;
116 private Map<String, Color> _annotation_colors;
117 private int _blast_item;
118 private JComboBox<String> _click_to_combobox;
119 private JLabel _click_to_label;
120 private List<String> _click_to_names;
121 private int _collapse_cb_item;
122 private int _uncollapse_all_cb_item;
123 private int _order_subtree_cb_item;
124 private JCheckBox _color_acc_species;
125 private JCheckBox _color_acc_sequence;
126 private JCheckBox _color_according_to_annotation;
127 private boolean _color_branches;
128 private JCheckBox _use_visual_styles_cb;
129 private int _color_subtree_cb_item;
130 private int _change_node_font_item;
131 // The settings from the conf file
132 private final Configuration _configuration;
133 private int _copy_subtree_item;
134 private int _cut_subtree_item;
135 private JButton _decr_domain_structure_evalue_thr;
136 private int _delete_node_or_subtree_item;
137 private JRadioButton _display_as_unaligned_phylogram_rb;
138 private JRadioButton _display_as_aligned_phylogram_rb;
139 private JRadioButton _display_as_cladogram_rb;
140 private ButtonGroup _display_as_buttongroup;
142 private JCheckBox _display_internal_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() {
1017 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1018 addCheckbox( Configuration.dynamically_hide_data,
1019 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
1020 setCheckbox( Configuration.dynamically_hide_data,
1021 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
1023 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1024 addCheckbox( Configuration.node_data_popup,
1025 _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1026 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1028 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1029 addCheckbox( Configuration.display_internal_data,
1030 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
1031 setCheckbox( Configuration.display_internal_data,
1032 _configuration.doCheckOption( Configuration.display_internal_data ) );
1034 if ( _configuration.doDisplayOption( Configuration.color_according_to_sequence ) ) {
1035 addCheckbox( Configuration.color_according_to_sequence,
1036 _configuration.getDisplayTitle( Configuration.color_according_to_sequence ) );
1037 setCheckbox( Configuration.color_according_to_sequence,
1038 _configuration.doCheckOption( Configuration.color_according_to_sequence ) );
1040 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1041 addCheckbox( Configuration.color_according_to_species,
1042 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
1043 setCheckbox( Configuration.color_according_to_species,
1044 _configuration.doCheckOption( Configuration.color_according_to_species ) );
1046 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1047 addCheckbox( Configuration.color_according_to_annotation,
1048 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
1049 setCheckbox( Configuration.color_according_to_annotation,
1050 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
1052 if ( _configuration.doDisplayOption( Configuration.use_style ) ) {
1053 addCheckbox( Configuration.use_style, _configuration.getDisplayTitle( Configuration.use_style ) );
1054 setCheckbox( Configuration.use_style, _configuration.doCheckOption( Configuration.use_style ) );
1056 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1057 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1058 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1060 final JLabel label = new JLabel( "Display Data:" );
1061 label.setFont( ControlPanel.jcb_bold_font );
1062 if ( !getConfiguration().isUseNativeUI() ) {
1063 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1066 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1067 addCheckbox( Configuration.show_node_names,
1068 _configuration.getDisplayTitle( Configuration.show_node_names ) );
1069 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1071 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1072 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1073 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1075 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1076 addCheckbox( Configuration.show_taxonomy_scientific_names,
1077 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1078 setCheckbox( Configuration.show_taxonomy_scientific_names,
1079 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1081 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1082 addCheckbox( Configuration.show_taxonomy_common_names,
1083 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1084 setCheckbox( Configuration.show_taxonomy_common_names,
1085 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1087 if ( _configuration.doDisplayOption( Configuration.show_tax_rank ) ) {
1088 addCheckbox( Configuration.show_tax_rank, _configuration.getDisplayTitle( Configuration.show_tax_rank ) );
1089 setCheckbox( Configuration.show_tax_rank, _configuration.doCheckOption( Configuration.show_tax_rank ) );
1091 if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
1092 addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
1093 setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
1095 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1096 addCheckbox( Configuration.show_gene_names,
1097 _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1098 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1100 if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
1101 addCheckbox( Configuration.show_seq_symbols,
1102 _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
1103 setCheckbox( Configuration.show_seq_symbols,
1104 _configuration.doCheckOption( Configuration.show_seq_symbols ) );
1106 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1107 addCheckbox( Configuration.show_sequence_acc,
1108 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1109 setCheckbox( Configuration.show_sequence_acc,
1110 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1112 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1113 addCheckbox( Configuration.show_annotation,
1114 _configuration.getDisplayTitle( Configuration.show_annotation ) );
1115 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1117 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1118 addCheckbox( Configuration.write_confidence_values,
1119 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1120 setCheckbox( Configuration.write_confidence_values,
1121 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1123 if ( _configuration.doDisplayOption( Configuration.write_branch_length_values ) ) {
1124 addCheckbox( Configuration.write_branch_length_values,
1125 _configuration.getDisplayTitle( Configuration.write_branch_length_values ) );
1126 setCheckbox( Configuration.write_branch_length_values,
1127 _configuration.doCheckOption( Configuration.write_branch_length_values ) );
1129 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1130 addCheckbox( Configuration.show_binary_characters,
1131 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1132 setCheckbox( Configuration.show_binary_characters,
1133 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1135 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1136 addCheckbox( Configuration.show_binary_character_counts,
1137 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1138 setCheckbox( Configuration.show_binary_character_counts,
1139 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1141 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1142 addCheckbox( Configuration.show_domain_architectures,
1143 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1144 setCheckbox( Configuration.show_domain_architectures,
1145 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1147 if ( _configuration.doDisplayOption( Configuration.show_mol_seqs ) ) {
1148 addCheckbox( Configuration.show_mol_seqs, _configuration.getDisplayTitle( Configuration.show_mol_seqs ) );
1149 setCheckbox( Configuration.show_mol_seqs, _configuration.doCheckOption( Configuration.show_mol_seqs ) );
1151 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1152 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1153 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1155 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1156 addCheckbox( Configuration.show_vector_data,
1157 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1158 setCheckbox( Configuration.show_vector_data,
1159 _configuration.doCheckOption( Configuration.show_vector_data ) );
1161 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1162 addCheckbox( Configuration.show_properties,
1163 _configuration.getDisplayTitle( Configuration.show_properties ) );
1164 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1166 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1167 addCheckbox( Configuration.show_taxonomy_images,
1168 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1169 setCheckbox( Configuration.show_taxonomy_images,
1170 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1174 private void setVisibilityOfDomainStrucureControls() {
1175 if ( _zoom_in_domain_structure != null ) {
1176 final MainFrame mf = getMainFrame();
1178 if ( isShowDomainArchitectures() ) {
1179 _domain_display_label.setVisible( true );
1180 _zoom_in_domain_structure.setVisible( true );
1181 _zoom_out_domain_structure.setVisible( true );
1182 _decr_domain_structure_evalue_thr.setVisible( true );
1183 _incr_domain_structure_evalue_thr.setVisible( true );
1184 _domain_structure_evalue_thr_tf.setVisible( true );
1185 if ( mf._right_line_up_domains_cbmi != null ) {
1186 mf._right_line_up_domains_cbmi.setVisible( true );
1188 if ( mf._show_domain_labels != null ) {
1189 mf._show_domain_labels.setVisible( true );
1193 _domain_display_label.setVisible( false );
1194 _zoom_in_domain_structure.setVisible( false );
1195 _zoom_out_domain_structure.setVisible( false );
1196 _decr_domain_structure_evalue_thr.setVisible( false );
1197 _incr_domain_structure_evalue_thr.setVisible( false );
1198 _domain_structure_evalue_thr_tf.setVisible( false );
1199 if ( mf._right_line_up_domains_cbmi != null ) {
1200 mf._right_line_up_domains_cbmi.setVisible( false );
1202 if ( mf._show_domain_labels != null ) {
1203 mf._show_domain_labels.setVisible( false );
1210 void activateButtonToReturnToSuperTree( int index ) {
1213 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
1216 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
1218 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1219 _return_to_super_tree.setEnabled( true );
1222 void activateButtonToUncollapseAll() {
1223 _uncollapse_all.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1224 _uncollapse_all.setEnabled( true );
1228 * Add zoom and quick edit buttons. (Last modified 8/9/04)
1231 final JLabel spacer = new JLabel( "" );
1232 spacer.setOpaque( false );
1234 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
1235 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1236 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
1237 final JPanel o_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1238 if ( !getConfiguration().isUseNativeUI() ) {
1239 x_panel.setBackground( getBackground() );
1240 y_panel.setBackground( getBackground() );
1241 z_panel.setBackground( getBackground() );
1242 o_panel.setBackground( getBackground() );
1244 add( _zoom_label = new JLabel( "Zoom:" ) );
1245 customizeLabel( _zoom_label, getConfiguration() );
1249 if ( getConfiguration().isUseNativeUI() ) {
1250 _zoom_in_x = new TypomaticJButton( "+" );
1251 _zoom_out_x = new TypomaticJButton( "-" );
1254 _zoom_in_x = new TypomaticJButton( "X+" );
1255 _zoom_out_x = new TypomaticJButton( "X-" );
1257 _zoom_in_y = new TypomaticJButton( "Y+" );
1258 _zoom_out_y = new TypomaticJButton( "Y-" );
1259 _show_whole = new JButton( "F" );
1260 _show_whole.setToolTipText( "fit and center tree display [Alt+C, Home, or Esc]" );
1261 _zoom_in_x.setToolTipText( "zoom in horizontally [Alt+Right or Shift+Alt+mousewheel]" );
1262 _zoom_in_y.setToolTipText( "zoom in vertically [Alt+Up or Shift+mousewheel]" );
1263 _zoom_out_x.setToolTipText( "zoom out horizontally [Alt+Left or Shift+Alt+mousewheel]" );
1264 _zoom_out_y.setToolTipText( "zoom out vertically [Alt+Down or Shift+mousewheel]" );
1265 if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) {
1266 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
1267 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
1270 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
1271 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
1273 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
1274 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
1275 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
1276 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
1277 _return_to_super_tree.setToolTipText( "return to the super-tree (if in sub-tree) [Alt+R]" );
1278 _return_to_super_tree.setEnabled( false );
1279 _order = new JButton( "O" );
1280 _order.setToolTipText( "order all [Alt+O]" );
1281 _uncollapse_all = new JButton( "U" );
1282 _uncollapse_all.setToolTipText( "uncollapse all [Alt+U]" );
1283 addJButton( _zoom_in_y, x_panel );
1284 addJButton( _zoom_out_x, y_panel );
1285 addJButton( _show_whole, y_panel );
1286 addJButton( _zoom_in_x, y_panel );
1287 addJButton( _zoom_out_y, z_panel );
1288 final JLabel spacer2 = new JLabel( "" );
1291 addJButton( _order, o_panel );
1292 addJButton( _return_to_super_tree, o_panel );
1293 addJButton( _uncollapse_all, o_panel );
1294 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
1295 setUpControlsForDomainStrucures();
1298 setUpControlsForDepthCollapse();
1301 setUpControlsForRankCollapse();
1303 final JLabel spacer3 = new JLabel( "" );
1305 setVisibilityOfDomainStrucureControls();
1308 void addCheckbox( final int which, final String title ) {
1309 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
1311 case Configuration.display_internal_data:
1312 _display_internal_data = new JCheckBox( title );
1313 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
1314 addJCheckBox( _display_internal_data, ch_panel );
1317 case Configuration.color_according_to_species:
1318 _color_acc_species = new JCheckBox( title );
1319 _color_acc_species.setToolTipText( "To colorize node labels as a function of taxonomy" );
1320 addJCheckBox( _color_acc_species, ch_panel );
1323 case Configuration.color_according_to_sequence:
1324 _color_acc_sequence = new JCheckBox( title );
1325 _color_acc_sequence.setToolTipText( "To colorize node labels as a function of sequence name" );
1326 addJCheckBox( _color_acc_sequence, ch_panel );
1329 case Configuration.color_according_to_annotation:
1330 _color_according_to_annotation = new JCheckBox( title );
1331 _color_according_to_annotation
1332 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
1333 addJCheckBox( _color_according_to_annotation, ch_panel );
1336 case Configuration.show_node_names:
1337 _show_node_names = new JCheckBox( title );
1338 addJCheckBox( _show_node_names, ch_panel );
1341 case Configuration.show_taxonomy_scientific_names:
1342 _show_taxo_scientific_names = new JCheckBox( title );
1343 addJCheckBox( _show_taxo_scientific_names, ch_panel );
1346 case Configuration.show_taxonomy_common_names:
1347 _show_taxo_common_names = new JCheckBox( title );
1348 addJCheckBox( _show_taxo_common_names, ch_panel );
1351 case Configuration.show_tax_code:
1352 _show_taxo_code = new JCheckBox( title );
1353 addJCheckBox( _show_taxo_code, ch_panel );
1356 case Configuration.show_tax_rank:
1357 _show_taxo_rank = new JCheckBox( title );
1358 addJCheckBox( _show_taxo_rank, ch_panel );
1361 case Configuration.show_taxonomy_images:
1362 _show_taxo_images_cb = new JCheckBox( title );
1363 addJCheckBox( _show_taxo_images_cb, ch_panel );
1366 case Configuration.show_binary_characters:
1367 _show_binary_characters = new JCheckBox( title );
1368 addJCheckBox( _show_binary_characters, ch_panel );
1371 case Configuration.show_annotation:
1372 _show_annotation = new JCheckBox( title );
1373 addJCheckBox( _show_annotation, ch_panel );
1376 case Configuration.show_binary_character_counts:
1377 _show_binary_character_counts = new JCheckBox( title );
1378 addJCheckBox( _show_binary_character_counts, ch_panel );
1381 case Configuration.write_confidence_values:
1382 _write_confidence = new JCheckBox( title );
1383 addJCheckBox( getWriteConfidenceCb(), ch_panel );
1386 case Configuration.write_events:
1387 _show_events = new JCheckBox( title );
1388 addJCheckBox( getShowEventsCb(), ch_panel );
1391 case Configuration.use_style:
1392 _use_visual_styles_cb = new JCheckBox( title );
1393 getUseVisualStylesCb()
1394 .setToolTipText( "To use visual styles (node colors, fonts) and branch colors, if present" );
1395 addJCheckBox( getUseVisualStylesCb(), ch_panel );
1398 case Configuration.width_branches:
1399 _width_branches = new JCheckBox( title );
1400 _width_branches.setToolTipText( "To use branch width values, if present" );
1401 addJCheckBox( _width_branches, ch_panel );
1404 case Configuration.write_branch_length_values:
1405 _write_branch_length_values = new JCheckBox( title );
1406 addJCheckBox( _write_branch_length_values, ch_panel );
1409 case Configuration.show_domain_architectures:
1410 _show_domain_architectures = new JCheckBox( title );
1411 addJCheckBox( _show_domain_architectures, ch_panel );
1414 case Configuration.show_mol_seqs:
1415 _show_mol_seqs = new JCheckBox( title );
1416 addJCheckBox( _show_mol_seqs, ch_panel );
1419 case Configuration.show_seq_names:
1420 _show_seq_names = new JCheckBox( title );
1421 addJCheckBox( _show_seq_names, ch_panel );
1424 case Configuration.show_gene_names:
1425 _show_gene_names = new JCheckBox( title );
1426 addJCheckBox( _show_gene_names, ch_panel );
1429 case Configuration.show_seq_symbols:
1430 _show_seq_symbols = new JCheckBox( title );
1431 addJCheckBox( _show_seq_symbols, ch_panel );
1434 case Configuration.show_sequence_acc:
1435 _show_sequence_acc = new JCheckBox( title );
1436 addJCheckBox( _show_sequence_acc, ch_panel );
1439 case Configuration.dynamically_hide_data:
1440 _dynamically_hide_data = new JCheckBox( title );
1441 getDynamicallyHideData().setToolTipText( "To hide labels depending on expected visibility" );
1442 addJCheckBox( getDynamicallyHideData(), ch_panel );
1445 case Configuration.node_data_popup:
1446 _node_desc_popup_cb = new JCheckBox( title );
1447 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
1448 addJCheckBox( getNodeDescPopupCb(), ch_panel );
1451 case Configuration.show_relation_confidence:
1452 _seq_relation_confidence_switch = new JCheckBox( title );
1453 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
1456 case Configuration.show_vector_data:
1457 _show_vector_data_cb = new JCheckBox( title );
1458 addJCheckBox( _show_vector_data_cb, ch_panel );
1461 case Configuration.show_properties:
1462 _show_properties_cb = new JCheckBox( title );
1463 addJCheckBox( _show_properties_cb, ch_panel );
1467 throw new RuntimeException( "unknown checkbox: " + which );
1471 void addJButton( final JButton jb, final JPanel p ) {
1472 jb.setFocusPainted( false );
1473 jb.setFont( ControlPanel.jcb_font );
1474 if ( !_configuration.isUseNativeUI() ) {
1475 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
1476 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1477 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
1480 jb.addActionListener( this );
1483 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
1484 jcb.setFocusPainted( false );
1485 jcb.setFont( ControlPanel.jcb_font );
1486 if ( !_configuration.isUseNativeUI() ) {
1487 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
1488 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1490 p.add( jcb, "Center" );
1491 jcb.addActionListener( this );
1494 private final void setupJRadioButton( final JRadioButton rb ) {
1495 rb.setFocusPainted( false );
1496 rb.setFont( ControlPanel.jcb_font );
1497 if ( !_configuration.isUseNativeUI() ) {
1498 rb.setBackground( getConfiguration().getGuiBackgroundColor() );
1499 rb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1501 rb.addActionListener( this );
1504 void addJTextField( final JTextField tf, final JPanel p ) {
1505 if ( !_configuration.isUseNativeUI() ) {
1506 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
1507 tf.setFont( ControlPanel.jcb_font );
1510 tf.addActionListener( this );
1513 void deactivateButtonToReturnToSuperTree() {
1514 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
1515 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
1516 _return_to_super_tree.setEnabled( false );
1519 void deactivateButtonToUncollapseAll() {
1520 _uncollapse_all.setForeground( getConfiguration().getGuiButtonTextColor() );
1521 _uncollapse_all.setEnabled( false );
1524 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
1525 if ( ( _mainpanel != null )
1526 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
1527 if ( recalc_longest_ext_node_info ) {
1528 _mainpanel.getCurrentTreePanel().initNodeData();
1529 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
1531 if ( getOptions().isShowOverview() ) {
1532 _mainpanel.getCurrentTreePanel().updateOvSizes();
1534 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
1535 setVisibilityOfDomainStrucureControls();
1536 updateDomainStructureEvaluethresholdDisplay();
1537 updateDepthCollapseDepthDisplay();
1538 updateRankCollapseRankDisplay();
1539 getMainPanel().getControlPanel();
1540 _mainpanel.getCurrentTreePanel().updateButtonToUncollapseAll();
1541 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
1542 _mainpanel.getCurrentTreePanel().calcMaxDepth();
1543 _mainpanel.adjustJScrollPane();
1544 _mainpanel.getCurrentTreePanel().repaint();
1545 // _mainpanel.getCurrentTreePanel().setUpUrtFactor();
1549 void endClickToOptions() {
1550 _click_to_combobox.addActionListener( this );
1554 * Indicates what action should be execute when a node is clicked
1556 * @return the click-on action
1558 NodeClickAction getActionWhenNodeClicked() {
1559 return _action_when_node_clicked;
1562 Map<Integer, String> getAllClickToItems() {
1563 return _all_click_to_names;
1566 Map<String, Color> getAnnotationColors() {
1567 return _annotation_colors;
1570 Configuration getConfiguration() {
1571 return _configuration;
1574 TreePanel getCurrentTreePanel() {
1575 return getMainPanel().getCurrentTreePanel();
1578 MainPanel getMainPanel() {
1582 Options getOptions() {
1583 return getMainPanel().getOptions();
1586 JLabel getSearchFoundCountsLabel0() {
1587 return _search_found_label_0;
1590 JLabel getSearchFoundCountsLabel1() {
1591 return _search_found_label_1;
1594 JButton getSearchResetButton0() {
1595 return _search_reset_button_0;
1598 JButton getSearchResetButton1() {
1599 return _search_reset_button_1;
1602 JTextField getSearchTextField0() {
1603 return _search_tf_0;
1606 JTextField getSearchTextField1() {
1607 return _search_tf_1;
1610 Map<String, Color> getSequenceColors() {
1611 return _sequence_colors;
1614 List<String> getSingleClickToNames() {
1615 return _click_to_names;
1618 Map<String, Color> getSpeciesColors() {
1619 return _species_colors;
1622 boolean isAntialiasScreenText() {
1626 boolean isColorAccordingToAnnotation() {
1627 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
1630 boolean isColorAccordingToSequence() {
1631 return ( ( _color_acc_sequence != null ) && _color_acc_sequence.isSelected() );
1634 boolean isColorAccordingToTaxonomy() {
1635 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
1638 boolean isDrawPhylogram() {
1639 final Options.PHYLOGENY_DISPLAY_TYPE t = getTreeDisplayType( getMainPanel().getCurrentTabIndex() );
1640 return ((t == Options.PHYLOGENY_DISPLAY_TYPE.ALIGNED_PHYLOGRAM) ||( t == Options.PHYLOGENY_DISPLAY_TYPE.UNALIGNED_PHYLOGRAM));
1643 boolean isDynamicallyHideData() {
1644 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
1647 boolean isEvents() {
1648 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
1651 boolean isNodeDescPopup() {
1652 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
1655 boolean isShowAnnotation() {
1656 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
1659 boolean isShowBinaryCharacterCounts() {
1660 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
1663 boolean isShowBinaryCharacters() {
1664 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
1667 boolean isShowConfidenceValues() {
1668 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
1671 boolean isShowDomainArchitectures() {
1672 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
1675 boolean isShowGeneNames() {
1676 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
1679 boolean isShowInternalData() {
1680 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
1683 boolean isShowNodeNames() {
1684 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
1687 boolean isShowSeqNames() {
1688 return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
1691 boolean isShowSeqSymbols() {
1692 return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
1695 boolean isShowSequenceAcc() {
1696 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
1699 boolean isShowSequenceRelationConfidence() {
1700 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
1703 boolean isShowSequenceRelations() {
1704 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
1707 boolean isShowTaxonomyCode() {
1708 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
1711 boolean isShowTaxonomyRank() {
1712 return ( ( _show_taxo_rank != null ) && _show_taxo_rank.isSelected() );
1715 boolean isShowTaxonomyCommonNames() {
1716 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
1719 boolean isShowTaxonomyScientificNames() {
1720 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
1723 boolean isUseVisualStyles() {
1724 return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() )
1725 || ( ( getUseVisualStylesCb() == null ) && _color_branches ) );
1728 boolean isWidthBranches() {
1729 return ( ( _width_branches != null ) && _width_branches.isSelected() );
1732 boolean isWriteBranchLengthValues() {
1733 return ( ( _write_branch_length_values != null ) && _write_branch_length_values.isSelected() );
1736 void phylogenyAdded( final Configuration configuration ) {
1737 if (configuration.isDrawAsPhylogram()) {
1738 getTreeDisplayTypes().add( Options.PHYLOGENY_DISPLAY_TYPE.UNALIGNED_PHYLOGRAM);
1741 getTreeDisplayTypes().add( Options.PHYLOGENY_DISPLAY_TYPE.CLADOGRAM);
1745 void phylogenyRemoved( final int index ) {
1746 getTreeDisplayTypes().remove( index );
1750 final MainPanel main_panel = getMainPanel();
1751 final Phylogeny tree = main_panel.getCurrentPhylogeny();
1752 if ( ( tree == null ) || tree.isEmpty() ) {
1755 String query = getSearchTextField0().getText();
1756 if ( query != null ) {
1757 query = query.trim();
1759 if ( !ForesterUtil.isEmpty( query ) ) {
1760 search0( main_panel, tree, query );
1763 getSearchFoundCountsLabel0().setVisible( false );
1764 getSearchResetButton0().setEnabled( false );
1765 getSearchResetButton0().setVisible( false );
1771 final MainPanel main_panel = getMainPanel();
1772 final Phylogeny tree = main_panel.getCurrentPhylogeny();
1773 if ( ( tree == null ) || tree.isEmpty() ) {
1776 String query = getSearchTextField1().getText();
1777 if ( query != null ) {
1778 query = query.trim();
1780 if ( !ForesterUtil.isEmpty( query ) ) {
1781 search1( main_panel, tree, query );
1784 getSearchFoundCountsLabel1().setVisible( false );
1785 getSearchResetButton1().setEnabled( false );
1786 getSearchResetButton1().setVisible( false );
1791 void searchReset0() {
1792 if ( getMainPanel().getCurrentTreePanel() != null ) {
1793 getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
1797 void searchReset1() {
1798 if ( getMainPanel().getCurrentTreePanel() != null ) {
1799 getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
1803 void setActionWhenNodeClicked( final NodeClickAction action ) {
1804 _action_when_node_clicked = action;
1807 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
1808 _annotation_colors = annotation_colors;
1811 void setCheckbox( final int which, final boolean state ) {
1813 case Configuration.display_as_phylogram:
1814 if ( getDisplayAsUnalignedPhylogramRb() != null ) {
1815 getDisplayAsUnalignedPhylogramRb().setSelected( state );
1816 getDisplayAsAlignedPhylogramRb().setSelected( !state );
1817 getDisplayAsCladogramRb().setSelected( !state );
1820 case Configuration.display_internal_data:
1821 if ( _display_internal_data != null ) {
1822 _display_internal_data.setSelected( state );
1825 case Configuration.color_according_to_species:
1826 if ( _color_acc_species != null ) {
1827 _color_acc_species.setSelected( state );
1830 case Configuration.color_according_to_sequence:
1831 if ( _color_acc_sequence != null ) {
1832 _color_acc_sequence.setSelected( state );
1835 case Configuration.color_according_to_annotation:
1836 if ( _color_according_to_annotation != null ) {
1837 _color_according_to_annotation.setSelected( state );
1840 case Configuration.show_node_names:
1841 if ( _show_node_names != null ) {
1842 _show_node_names.setSelected( state );
1845 case Configuration.show_taxonomy_scientific_names:
1846 if ( _show_taxo_scientific_names != null ) {
1847 _show_taxo_scientific_names.setSelected( state );
1850 case Configuration.show_taxonomy_common_names:
1851 if ( _show_taxo_common_names != null ) {
1852 _show_taxo_common_names.setSelected( state );
1855 case Configuration.show_tax_code:
1856 if ( _show_taxo_code != null ) {
1857 _show_taxo_code.setSelected( state );
1860 case Configuration.show_tax_rank:
1861 if ( _show_taxo_rank != null ) {
1862 _show_taxo_rank.setSelected( state );
1865 case Configuration.show_taxonomy_images:
1866 if ( _show_taxo_images_cb != null ) {
1867 _show_taxo_images_cb.setSelected( state );
1870 case Configuration.show_annotation:
1871 if ( _show_annotation != null ) {
1872 _show_annotation.setSelected( state );
1875 case Configuration.show_binary_characters:
1876 if ( _show_binary_characters != null ) {
1877 _show_binary_characters.setSelected( state );
1880 case Configuration.show_binary_character_counts:
1881 if ( _show_binary_character_counts != null ) {
1882 _show_binary_character_counts.setSelected( state );
1885 case Configuration.write_confidence_values:
1886 if ( getWriteConfidenceCb() != null ) {
1887 getWriteConfidenceCb().setSelected( state );
1890 case Configuration.write_events:
1891 if ( getShowEventsCb() != null ) {
1892 getShowEventsCb().setSelected( state );
1895 case Configuration.use_style:
1896 if ( getUseVisualStylesCb() != null ) {
1897 getUseVisualStylesCb().setSelected( state );
1900 case Configuration.width_branches:
1901 if ( _width_branches != null ) {
1902 _width_branches.setSelected( state );
1905 case Configuration.show_domain_architectures:
1906 if ( _show_domain_architectures != null ) {
1907 _show_domain_architectures.setSelected( state );
1910 case Configuration.write_branch_length_values:
1911 if ( _write_branch_length_values != null ) {
1912 _write_branch_length_values.setSelected( state );
1915 case Configuration.show_mol_seqs:
1916 if ( _show_mol_seqs != null ) {
1917 _show_mol_seqs.setSelected( state );
1920 case Configuration.show_seq_names:
1921 if ( _show_seq_names != null ) {
1922 _show_seq_names.setSelected( state );
1925 case Configuration.show_gene_names:
1926 if ( _show_gene_names != null ) {
1927 _show_gene_names.setSelected( state );
1930 case Configuration.show_seq_symbols:
1931 if ( _show_seq_symbols != null ) {
1932 _show_seq_symbols.setSelected( state );
1935 case Configuration.show_vector_data:
1936 if ( _show_vector_data_cb != null ) {
1937 _show_vector_data_cb.setSelected( state );
1940 case Configuration.show_properties:
1941 if ( _show_properties_cb != null ) {
1942 _show_properties_cb.setSelected( state );
1945 case Configuration.show_sequence_acc:
1946 if ( _show_sequence_acc != null ) {
1947 _show_sequence_acc.setSelected( state );
1950 case Configuration.dynamically_hide_data:
1951 if ( getDynamicallyHideData() != null ) {
1952 getDynamicallyHideData().setSelected( state );
1955 case Configuration.node_data_popup:
1956 if ( getNodeDescPopupCb() != null ) {
1957 getNodeDescPopupCb().setSelected( state );
1961 case Configuration.show_relation_confidence:
1962 if ( _seq_relation_confidence_switch != null ) {
1963 _seq_relation_confidence_switch.setSelected( state );
1968 throw new AssertionError( "unknown checkbox: " + which );
1973 * Set this checkbox state. Not all checkboxes have been instantiated
1974 * depending on the config.
1976 void setCheckbox( final JCheckBox cb, final boolean state ) {
1978 cb.setSelected( state );
1982 void setClickToAction( final int action ) {
1983 // Set click-to action
1984 if ( action == _show_data_item ) {
1985 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1987 else if ( action == _collapse_cb_item ) {
1988 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1990 else if ( action == _reroot_cb_item ) {
1991 setActionWhenNodeClicked( NodeClickAction.REROOT );
1993 else if ( action == _subtree_cb_item ) {
1994 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1996 else if ( action == _swap_cb_item ) {
1997 setActionWhenNodeClicked( NodeClickAction.SWAP );
1999 else if ( action == _color_subtree_cb_item ) {
2000 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
2002 else if ( action == _open_seq_web_item ) {
2003 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
2005 else if ( action == _sort_descendents_item ) {
2006 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
2008 else if ( action == _blast_item ) {
2009 setActionWhenNodeClicked( NodeClickAction.BLAST );
2011 else if ( action == _open_tax_web_item ) {
2012 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
2014 else if ( action == _cut_subtree_item ) {
2015 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
2017 else if ( action == _copy_subtree_item ) {
2018 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
2020 else if ( action == _delete_node_or_subtree_item ) {
2021 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
2023 else if ( action == _paste_subtree_item ) {
2024 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
2026 else if ( action == _add_new_node_item ) {
2027 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
2029 else if ( action == _edit_node_data_item ) {
2030 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
2032 else if ( action == _select_nodes_item ) {
2033 setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
2035 else if ( action == _get_ext_desc_data ) {
2036 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
2038 else if ( action == _open_pdb_item ) {
2039 setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
2041 else if ( action == _color_node_font_item ) {
2042 setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
2044 else if ( action == _change_node_font_item ) {
2045 setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT );
2047 else if ( action == _uncollapse_all_cb_item ) {
2048 setActionWhenNodeClicked( NodeClickAction.UNCOLLAPSE_ALL );
2050 else if ( action == _order_subtree_cb_item ) {
2051 setActionWhenNodeClicked( NodeClickAction.ORDER_SUBTREE );
2054 throw new RuntimeException( "unknown action: " + action );
2056 // make sure drop down is displaying the correct action
2057 // in case this was called from outside the class
2058 _click_to_combobox.setSelectedIndex( action );
2061 void setColorBranches( final boolean color_branches ) {
2062 _color_branches = color_branches;
2065 void setTreeDisplayType( final Options.PHYLOGENY_DISPLAY_TYPE t ) {
2067 case UNALIGNED_PHYLOGRAM:
2068 getDisplayAsUnalignedPhylogramRb().setSelected( true );
2070 case ALIGNED_PHYLOGRAM:
2071 getDisplayAsAlignedPhylogramRb().setSelected( true );
2074 getDisplayAsCladogramRb().setSelected( true );
2077 setTreeDisplayType( getMainPanel().getCurrentTabIndex(), t );
2080 void setDrawPhylogramEnabled( final boolean b ) {
2081 if ( getDisplayAsAlignedPhylogramRb() != null &&
2082 getDisplayAsUnalignedPhylogramRb() != null &&
2083 getDisplayAsCladogramRb() != null
2086 getDisplayAsAlignedPhylogramRb().setEnabled( b );
2087 getDisplayAsUnalignedPhylogramRb().setEnabled( b );
2088 getDisplayAsCladogramRb().setEnabled( b );
2092 void setDynamicHidingIsOn( final boolean is_on ) {
2094 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
2097 if ( !_configuration.isUseNativeUI() ) {
2098 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
2101 getDynamicallyHideData().setForeground( Color.BLACK );
2106 void setSearchFoundCountsOnLabel0( final int counts ) {
2107 getSearchFoundCountsLabel0().setText( "Found: " + counts );
2110 void setSearchFoundCountsOnLabel1( final int counts ) {
2111 getSearchFoundCountsLabel1().setText( "Found: " + counts );
2114 void setSequenceColors( final Map<String, Color> sequence_colors ) {
2115 _sequence_colors = sequence_colors;
2118 void setShowEvents( final boolean show_events ) {
2119 if ( getShowEventsCb() == null ) {
2120 _show_events = new JCheckBox( "" );
2122 getShowEventsCb().setSelected( show_events );
2125 void setSpeciesColors( final Map<String, Color> species_colors ) {
2126 _species_colors = species_colors;
2129 void setupControls() {
2131 setupTreeDisplayTypeOptions();
2132 setupDisplayCheckboxes();
2134 // The sequence relation query selection combo-box
2135 if ( _configuration.displaySequenceRelations() ) {
2136 addSequenceRelationBlock();
2140 startClickToOptions();
2141 setupClickToOptions();
2142 endClickToOptions();
2143 // Zoom and quick edit buttons
2145 setupSearchTools0();
2146 setupSearchTools1();
2149 void setupTreeDisplayTypeOptions() {
2150 _display_as_unaligned_phylogram_rb = new JRadioButton( "P" );
2151 _display_as_aligned_phylogram_rb = new JRadioButton( "A" );
2152 _display_as_cladogram_rb = new JRadioButton( "C" );
2153 _display_as_buttongroup = new ButtonGroup();
2154 _display_as_buttongroup.add( _display_as_unaligned_phylogram_rb );
2155 _display_as_buttongroup.add( _display_as_aligned_phylogram_rb );
2156 _display_as_buttongroup.add( _display_as_cladogram_rb );
2157 getDisplayAsUnalignedPhylogramRb().setToolTipText( "(unaligned) phylogram" );
2158 getDisplayAsAlignedPhylogramRb().setToolTipText( "aligned phylogram" );
2159 getDisplayAsCladogramRb().setToolTipText( "cladogram" );
2160 setupJRadioButton( getDisplayAsUnalignedPhylogramRb() );
2161 setupJRadioButton( getDisplayAsAlignedPhylogramRb() );
2162 setupJRadioButton( getDisplayAsCladogramRb() );
2163 final JPanel p = new JPanel(new GridLayout( 1, 3, 0, 0 ));
2164 p.setFont( ControlPanel.jcb_font );
2165 if ( !_configuration.isUseNativeUI() ) {
2166 p.setBackground( getConfiguration().getGuiBackgroundColor() );
2167 p.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2169 p.add( _display_as_unaligned_phylogram_rb );
2170 p.add( _display_as_aligned_phylogram_rb );
2171 p.add( _display_as_cladogram_rb );
2176 void setUpControlsForDomainStrucures() {
2177 _domain_display_label = new JLabel( "Domain Architectures:" );
2178 add( customizeLabel( _domain_display_label, getConfiguration() ) );
2179 add( _domain_display_label );
2180 _zoom_in_domain_structure = new TypomaticJButton( "d+" );
2181 _zoom_out_domain_structure = new TypomaticJButton( "d-" );
2182 _decr_domain_structure_evalue_thr = new JButton( "-" );
2183 _incr_domain_structure_evalue_thr = new JButton( "+" );
2184 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
2185 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
2186 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
2187 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
2188 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
2189 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
2190 _domain_structure_evalue_thr_tf = new JTextField( 3 );
2191 _domain_structure_evalue_thr_tf.setEditable( false );
2192 if ( !getConfiguration().isUseNativeUI() ) {
2193 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2194 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2195 _domain_structure_evalue_thr_tf.setBorder( null );
2197 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2198 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2199 if ( !_configuration.isUseNativeUI() ) {
2200 d1_panel.setBackground( getBackground() );
2201 d2_panel.setBackground( getBackground() );
2205 addJButton( _zoom_out_domain_structure, d1_panel );
2206 addJButton( _zoom_in_domain_structure, d1_panel );
2207 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
2208 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
2209 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
2212 void setUpControlsForDepthCollapse() {
2213 _depth_collapse_label = new JLabel( "Collapse by Node Depth:" );
2214 _depth_collapse_label
2215 .setToolTipText( "to automaticall collapse nodes with a depth equal or larger than a threshold" );
2216 add( customizeLabel( _depth_collapse_label, getConfiguration() ) );
2217 add( _depth_collapse_label );
2218 _decr_depth_collapse_level = new TypomaticJButton( "-" );
2219 _incr_depth_collapse_level = new TypomaticJButton( "+" );
2220 _decr_depth_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2221 _incr_depth_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2222 _decr_depth_collapse_level.setToolTipText( "to decrease the depth threshold (wraps around)" );
2223 _incr_depth_collapse_level.setToolTipText( "to increase the depth threshold (wraps around)" );
2224 _depth_collapse_depth_tf = new JTextField( 3 );
2225 _depth_collapse_depth_tf.setToolTipText( "the current depth threshold" );
2226 _depth_collapse_depth_tf.setEditable( false );
2227 if ( !getConfiguration().isUseNativeUI() ) {
2228 _depth_collapse_depth_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2229 _depth_collapse_depth_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2230 _depth_collapse_depth_tf.setBorder( null );
2232 final JPanel panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2233 if ( !_configuration.isUseNativeUI() ) {
2234 panel.setBackground( getBackground() );
2237 addJButton( _decr_depth_collapse_level, panel );
2238 addJTextField( _depth_collapse_depth_tf, panel );
2239 addJButton( _incr_depth_collapse_level, panel );
2242 void setUpControlsForRankCollapse() {
2243 _rank_collapse_label = new JLabel( "Collapse by Node Rank:" );
2244 _rank_collapse_label
2245 .setToolTipText( "to automatically collapse nodes with a taxonomic rank equal or lower than a threshold" );
2246 add( customizeLabel( _rank_collapse_label, getConfiguration() ) );
2247 add( _rank_collapse_label );
2248 _decr_rank_collapse_level = new TypomaticJButton( "-" );
2249 _incr_rank_collapse_level = new TypomaticJButton( "+" );
2250 _decr_rank_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2251 _incr_rank_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2252 _decr_rank_collapse_level.setToolTipText( "to decrease the taxonomic rank threshold (wraps around)" );
2253 _incr_rank_collapse_level.setToolTipText( "to increase the taxonomic rank threshold (wraps around)" );
2254 _rank_collapse_depth_tf = new JTextField( 3 );
2255 _rank_collapse_depth_tf.setToolTipText( "the current taxonomic rank threshold" );
2256 _rank_collapse_depth_tf.setEditable( false );
2257 if ( !getConfiguration().isUseNativeUI() ) {
2258 _rank_collapse_depth_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2259 _rank_collapse_depth_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2260 _rank_collapse_depth_tf.setBorder( null );
2262 final JPanel panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2263 if ( !_configuration.isUseNativeUI() ) {
2264 panel.setBackground( getBackground() );
2267 addJButton( _decr_rank_collapse_level, panel );
2268 addJTextField( _rank_collapse_depth_tf, panel );
2269 addJButton( _incr_rank_collapse_level, panel );
2272 void setupSearchTools0() {
2273 final JLabel search_label = new JLabel( "Search (A):" );
2274 search_label.setFont( ControlPanel.jcb_bold_font );
2275 if ( !getConfiguration().isUseNativeUI() ) {
2276 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2278 add( search_label );
2279 search_label.setToolTipText( SEARCH_TIP_TEXT );
2280 _search_found_label_0 = new JLabel();
2281 getSearchFoundCountsLabel0().setVisible( false );
2282 _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
2283 if ( !getConfiguration().isUseNativeUI() ) {
2284 _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2286 _search_tf_0 = new JTextField( 3 );
2287 _search_tf_0.setToolTipText( SEARCH_TIP_TEXT );
2288 _search_tf_0.setEditable( true );
2289 if ( !getConfiguration().isUseNativeUI() ) {
2290 _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2291 _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2292 _search_tf_0.setBorder( null );
2294 _search_reset_button_0 = new JButton();
2295 getSearchResetButton0().setText( "Reset" );
2296 getSearchResetButton0().setEnabled( false );
2297 getSearchResetButton0().setVisible( false );
2298 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
2299 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2300 s_panel_1.setBackground( getBackground() );
2302 s_panel_2.setBackground( getBackground() );
2304 final KeyAdapter key_adapter = new KeyAdapter() {
2307 public void keyReleased( final KeyEvent key_event ) {
2309 displayedPhylogenyMightHaveChanged( true );
2312 final ActionListener action_listener = new ActionListener() {
2315 public void actionPerformed( final ActionEvent e ) {
2317 setSearchFoundCountsOnLabel0( 0 );
2318 getSearchFoundCountsLabel0().setVisible( false );
2319 getSearchTextField0().setText( "" );
2320 getSearchResetButton0().setEnabled( false );
2321 getSearchResetButton0().setVisible( false );
2322 displayedPhylogenyMightHaveChanged( true );
2325 _search_reset_button_0.addActionListener( action_listener );
2326 _search_tf_0.addKeyListener( key_adapter );
2327 addJTextField( _search_tf_0, s_panel_1 );
2328 s_panel_2.add( _search_found_label_0 );
2329 addJButton( _search_reset_button_0, s_panel_2 );
2332 void setupSearchTools1() {
2333 final JLabel search_label = new JLabel( "Search (B):" );
2334 search_label.setFont( ControlPanel.jcb_bold_font );
2335 if ( !getConfiguration().isUseNativeUI() ) {
2336 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2338 add( search_label );
2339 search_label.setToolTipText( SEARCH_TIP_TEXT );
2340 _search_found_label_1 = new JLabel();
2341 getSearchFoundCountsLabel1().setVisible( false );
2342 _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
2343 if ( !getConfiguration().isUseNativeUI() ) {
2344 _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2346 _search_tf_1 = new JTextField( 3 );
2347 _search_tf_1.setToolTipText( SEARCH_TIP_TEXT );
2348 _search_tf_1.setEditable( true );
2349 if ( !getConfiguration().isUseNativeUI() ) {
2350 _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2351 _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2352 _search_tf_1.setBorder( null );
2354 _search_reset_button_1 = new JButton();
2355 getSearchResetButton1().setText( "Reset" );
2356 getSearchResetButton1().setEnabled( false );
2357 getSearchResetButton1().setVisible( false );
2358 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
2359 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2360 s_panel_1.setBackground( getBackground() );
2362 s_panel_2.setBackground( getBackground() );
2364 final KeyAdapter key_adapter = new KeyAdapter() {
2367 public void keyReleased( final KeyEvent key_event ) {
2369 displayedPhylogenyMightHaveChanged( true );
2372 final ActionListener action_listener = new ActionListener() {
2375 public void actionPerformed( final ActionEvent e ) {
2377 setSearchFoundCountsOnLabel1( 0 );
2378 getSearchFoundCountsLabel1().setVisible( false );
2379 getSearchTextField1().setText( "" );
2380 getSearchResetButton1().setEnabled( false );
2381 getSearchResetButton1().setVisible( false );
2382 displayedPhylogenyMightHaveChanged( true );
2385 _search_reset_button_1.addActionListener( action_listener );
2386 _search_tf_1.addKeyListener( key_adapter );
2387 addJTextField( _search_tf_1, s_panel_1 );
2388 s_panel_2.add( _search_found_label_1 );
2389 addJButton( _search_reset_button_1, s_panel_2 );
2392 void setVisibilityOfDomainStrucureCB() {
2394 if ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel()
2395 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2396 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
2397 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2398 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
2400 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2401 getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
2404 else if ( isShowDomainArchitectures() ) {
2405 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2406 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( true );
2408 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2409 getMainPanel().getMainFrame()._show_domain_labels.setVisible( true );
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 );
2421 catch ( final Exception ignore ) {
2426 void setVisibilityOfX() {
2427 final MainFrame mf = getMainFrame();
2429 if ( ( getCurrentTreePanel() != null ) && ( getCurrentTreePanel().getPhylogeny() != null ) ) {
2430 if ( AptxUtil.isHasAtLeastOneBranchWithSupportSD( getCurrentTreePanel().getPhylogeny() ) ) {
2431 if ( mf._show_confidence_stddev_cbmi != null ) {
2432 mf._show_confidence_stddev_cbmi.setVisible( true );
2436 if ( mf._show_confidence_stddev_cbmi != null ) {
2437 mf._show_confidence_stddev_cbmi.setVisible( false );
2440 if ( AptxUtil.isHasAtLeastOneNodeWithScientificName( getCurrentTreePanel().getPhylogeny() ) ) {
2441 if ( mf._abbreviate_scientific_names != null ) {
2442 mf._abbreviate_scientific_names.setVisible( true );
2446 if ( mf._abbreviate_scientific_names != null ) {
2447 mf._abbreviate_scientific_names.setVisible( false );
2450 if ( AptxUtil.isHasAtLeastOneNodeWithSequenceAnnotation( getCurrentTreePanel().getPhylogeny() ) ) {
2451 if ( mf._show_annotation_ref_source != null ) {
2452 mf._show_annotation_ref_source.setVisible( true );
2456 if ( mf._show_annotation_ref_source != null ) {
2457 mf._show_annotation_ref_source.setVisible( false );
2461 if ( isDrawPhylogram() || ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel()
2462 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2463 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) ) {
2464 if ( mf._non_lined_up_cladograms_rbmi != null ) {
2465 mf._non_lined_up_cladograms_rbmi.setVisible( false );
2467 if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
2468 mf._ext_node_dependent_cladogram_rbmi.setVisible( false );
2472 if ( mf._non_lined_up_cladograms_rbmi != null ) {
2473 mf._non_lined_up_cladograms_rbmi.setVisible( true );
2475 if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
2476 mf._ext_node_dependent_cladogram_rbmi.setVisible( true );
2479 if ( isDrawPhylogram() ) {
2480 if ( mf._show_scale_cbmi != null ) {
2481 mf._show_scale_cbmi.setVisible( true );
2485 if ( mf._show_scale_cbmi != null ) {
2486 mf._show_scale_cbmi.setVisible( false );
2489 if ( getCurrentTreePanel() != null ) {
2490 if ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2491 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
2492 if ( mf._label_direction_cbmi != null ) {
2493 mf._label_direction_cbmi.setVisible( true );
2497 if ( mf._label_direction_cbmi != null ) {
2498 mf._label_direction_cbmi.setVisible( false );
2505 void showAnnotations() {
2506 if ( _show_annotation != null ) {
2507 _show_annotation.setSelected( true );
2509 if ( _color_according_to_annotation != null ) {
2510 _color_according_to_annotation.setSelected( true );
2512 if ( _color_acc_species != null ) {
2513 _color_acc_species.setSelected( false );
2515 if ( _color_acc_sequence != null ) {
2516 _color_acc_sequence.setSelected( false );
2518 _mainpanel.getCurrentTreePanel().repaint();
2522 * Fit entire tree into window.
2525 if ( ( _mainpanel.getCurrentScrollPane() == null )
2526 || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
2529 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
2530 displayedPhylogenyMightHaveChanged( true );
2531 _mainpanel.getCurrentTreePanel().updateOvSettings();
2532 _mainpanel.getCurrentTreePanel().validate();
2533 _mainpanel.validate();
2534 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2535 _mainpanel.getSizeOfViewport().height );
2536 _mainpanel.getCurrentTreePanel().resetPreferredSize();
2537 _mainpanel.adjustJScrollPane();
2538 _mainpanel.getCurrentTreePanel().repaint();
2539 _mainpanel.getCurrentTreePanel().validate();
2540 _mainpanel.validate();
2541 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2542 _mainpanel.getSizeOfViewport().height );
2543 _mainpanel.getCurrentTreePanel().resetPreferredSize();
2544 _mainpanel.adjustJScrollPane();
2545 _mainpanel.getCurrentTreePanel().repaint();
2546 _mainpanel.getCurrentTreePanel().updateOvSizes();
2549 void showWholeAll() {
2550 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
2551 if ( tree_panel != null ) {
2552 tree_panel.validate();
2553 tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2554 _mainpanel.getSizeOfViewport().height );
2555 tree_panel.resetPreferredSize();
2556 tree_panel.repaint();
2561 // Create header for click-to combo box.
2562 void startClickToOptions() {
2563 final JLabel spacer = new JLabel( "" );
2564 spacer.setFont( ControlPanel.jcb_font );
2566 _click_to_label = new JLabel( "Click on Node to:" );
2567 add( customizeLabel( _click_to_label, getConfiguration() ) );
2568 _click_to_combobox = new JComboBox<String>();
2569 _click_to_combobox.setFocusable( false );
2570 _click_to_combobox.setMaximumRowCount( 14 );
2571 _click_to_combobox.setFont( ControlPanel.js_font );
2572 if ( !_configuration.isUseNativeUI() ) {
2573 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
2575 // don't add listener until all items are set (or each one will trigger
2577 // click_to_list.addActionListener(this);
2578 add( _click_to_combobox );
2579 // Correlates option names to titles
2580 _all_click_to_names = new HashMap<Integer, String>();
2581 _click_to_names = new ArrayList<String>();
2585 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
2586 if ( getCurrentTreePanel().isPhyHasBranchLengths()
2587 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
2588 setDrawPhylogramEnabled( true );
2590 setTreeDisplayType( getTreeDisplayType( getMainPanel().getCurrentTabIndex() ) );
2593 setDrawPhylogramEnabled( false );
2594 setTreeDisplayType( Options.PHYLOGENY_DISPLAY_TYPE.CLADOGRAM );
2597 getMainPanel().getMainFrame()
2598 .setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel().getPhylogenyGraphicsType() );
2600 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
2601 getMainPanel().getCurrentTreePanel().updateButtonToUncollapseAll();
2602 getMainPanel().getControlPanel().search0();
2603 getMainPanel().getControlPanel().search1();
2604 getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
2605 getMainPanel().getControlPanel().updateDepthCollapseDepthDisplay();
2606 getMainPanel().getControlPanel().updateRankCollapseRankDisplay();
2607 getSequenceRelationTypeBox().removeAllItems();
2608 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
2609 .getRelevantSequenceRelationTypes() ) {
2610 _sequence_relation_type_box.addItem( type );
2612 getMainPanel().getCurrentTreePanel().repaint();
2613 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
2614 // according to GUILHEM the line above can be removed.
2619 * Uncollapse all nodes.
2621 final void uncollapseAll( final TreePanel tp ) {
2622 final Phylogeny t = tp.getPhylogeny();
2623 if ( ( t != null ) && !t.isEmpty() ) {
2624 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
2625 final PhylogenyNode node = iter.next();
2626 node.setCollapse( false );
2628 tp.resetNodeIdToDistToLeafMap();
2629 tp.updateSetOfCollapsedExternalNodes();
2630 t.recalculateNumberOfExternalDescendants( false );
2631 tp.setNodeInPreorderToNull();
2632 t.clearHashIdToNodeMap();
2633 tp.resetDepthCollapseDepthValue();
2634 tp.resetRankCollapseRankValue();
2639 final void updateDomainStructureEvaluethresholdDisplay() {
2640 if ( _domain_structure_evalue_thr_tf != null ) {
2641 _domain_structure_evalue_thr_tf
2642 .setText( "10^" + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThresholdExp() );
2646 private final String obtainDepthCollapseDepthValue() {
2647 if ( getMainPanel().getCurrentTreePanel() == null ) {
2650 final TreePanel tp = getMainPanel().getCurrentTreePanel();
2651 final Phylogeny p = tp.getPhylogeny();
2652 if ( ( p == null ) || ( p.getNumberOfExternalNodes() < 3 ) ) {
2655 else if ( tp.getDepthCollapseDepthValue() < 0 ) {
2656 tp.setDepthCollapseDepthValue( PhylogenyMethods.calculateMaxDepth( p ) );
2659 else if ( tp.getDepthCollapseDepthValue() == PhylogenyMethods.calculateMaxDepth( p ) ) {
2662 return String.valueOf( tp.getDepthCollapseDepthValue() );
2665 private final String obtainRankCollapseDepthValue() {
2666 if ( getMainPanel().getCurrentTreePanel() == null ) {
2669 final TreePanel tp = getMainPanel().getCurrentTreePanel();
2670 final Phylogeny p = tp.getPhylogeny();
2671 if ( ( p == null ) || ( p.getNumberOfExternalNodes() < 3 ) ) {
2675 final String ranks[] = PhylogenyMethods.obtainPresentRanksSorted( p );
2676 if ( ranks.length < 1 ) {
2679 else if ( tp.getRankCollapseRankValue() < 0 ) {
2680 tp.setRankCollapseRankValue( ranks.length - 1 );
2683 else if ( tp.getRankCollapseRankValue() == ( ranks.length - 1 ) ) {
2687 return String.valueOf( tp.getRankCollapseRankValue() );
2690 final void updateDepthCollapseDepthDisplay() {
2691 if ( _depth_collapse_depth_tf != null ) {
2692 _depth_collapse_depth_tf.setText( " " + obtainDepthCollapseDepthValue() );
2696 final void updateRankCollapseRankDisplay() {
2697 if ( _rank_collapse_depth_tf != null ) {
2698 final String r = obtainRankCollapseDepthValue();
2699 if ( r.equals( "off" ) ) {
2700 _rank_collapse_depth_tf.setText( " off" );
2701 _rank_collapse_depth_tf.setToolTipText( "the current taxonomic rank threshold" );
2704 final String ranks[] = PhylogenyMethods
2705 .obtainPresentRanksSorted( getMainPanel().getCurrentTreePanel().getPhylogeny() );
2706 final int rr = Integer.parseInt( r );
2707 _rank_collapse_depth_tf.setText( ranks[ rr ] );
2708 _rank_collapse_depth_tf.setToolTipText( ( rr + 1 ) + "/" + ( ranks.length - 1 ) + ": "
2709 + ranks[ Integer.parseInt( r ) ] );
2714 final void zoomInX( final float factor, final float x_correction_factor ) {
2715 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
2716 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2717 treepanel.multiplyUrtFactor( 1f );
2718 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2719 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
2720 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
2721 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
2722 final double x = ( sb.getMaximum() - sb.getMinimum() )
2723 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2724 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2725 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2726 getMainPanel().adjustJScrollPane();
2727 treepanel.resetPreferredSize();
2728 getMainPanel().getCurrentScrollPane().getViewport().validate();
2729 sb.setValue( ForesterUtil
2730 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2733 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
2734 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2735 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2736 getMainPanel().adjustJScrollPane();
2737 treepanel.resetPreferredSize();
2738 getMainPanel().getCurrentScrollPane().getViewport().validate();
2739 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
2741 treepanel.resetPreferredSize();
2742 treepanel.updateOvSizes();
2745 final void zoomInY( final float factor ) {
2746 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
2747 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2748 treepanel.multiplyUrtFactor( 1.1f );
2749 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2750 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
2751 getMainPanel().adjustJScrollPane();
2752 treepanel.resetPreferredSize();
2753 getMainPanel().getCurrentScrollPane().getViewport().validate();
2754 sb.setValue( ForesterUtil
2755 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2756 treepanel.resetPreferredSize();
2757 treepanel.updateOvSizes();
2760 final void zoomOutX( final float factor, final float x_correction_factor ) {
2761 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2762 treepanel.multiplyUrtFactor( 1f );
2763 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
2764 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
2765 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2766 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
2767 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
2768 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
2769 getMainPanel().adjustJScrollPane();
2770 treepanel.resetPreferredSize();
2771 getMainPanel().getCurrentScrollPane().getViewport().validate();
2772 final double x = ( sb.getMaximum() - sb.getMinimum() )
2773 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2774 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2775 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2776 getMainPanel().adjustJScrollPane();
2777 treepanel.resetPreferredSize();
2778 getMainPanel().getCurrentScrollPane().getViewport().validate();
2779 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
2780 - ( sb.getVisibleAmount() / 2.0 ) ) );
2783 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
2784 treepanel.setXdistance( treepanel.getXdistance() * factor );
2785 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
2787 getMainPanel().adjustJScrollPane();
2788 treepanel.resetPreferredSize();
2789 getMainPanel().getCurrentScrollPane().getViewport().validate();
2790 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
2793 treepanel.resetPreferredSize();
2794 treepanel.updateOvSizes();
2798 private final boolean isDrawPhylogram( int currentTabIndex ) {
2799 Options.PHYLOGENY_DISPLAY_TYPE t = getTreeDisplayType( currentTabIndex );
2800 return ((t==Options.PHYLOGENY_DISPLAY_TYPE.ALIGNED_PHYLOGRAM)|(t==Options.PHYLOGENY_DISPLAY_TYPE.UNALIGNED_PHYLOGRAM));
2804 final void zoomOutY( final float factor ) {
2805 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2806 treepanel.multiplyUrtFactor( 0.9f );
2807 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
2808 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
2809 final double x = ( sb.getMaximum() - sb.getMinimum() )
2810 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2811 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
2812 getMainPanel().adjustJScrollPane();
2813 treepanel.resetPreferredSize();
2814 getMainPanel().getCurrentScrollPane().getViewport().validate();
2815 sb.setValue( ForesterUtil
2816 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2817 treepanel.resetPreferredSize();
2818 treepanel.updateOvSizes();
2822 final static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2823 label.setFont( ControlPanel.jcb_bold_font );
2824 if ( !configuration.isUseNativeUI() ) {
2825 label.setForeground( configuration.getGuiCheckboxTextColor() );
2826 label.setBackground( configuration.getGuiBackgroundColor() );
2831 final public JCheckBox getUseBranchWidthsCb() {
2832 return _width_branches;
2835 public Options.PHYLOGENY_DISPLAY_TYPE getTreeDisplayType() {
2836 if (_display_as_unaligned_phylogram_rb.isSelected() ) {
2837 return Options.PHYLOGENY_DISPLAY_TYPE.UNALIGNED_PHYLOGRAM;
2839 else if (_display_as_aligned_phylogram_rb.isSelected() ) {
2840 return Options.PHYLOGENY_DISPLAY_TYPE.ALIGNED_PHYLOGRAM;
2842 return Options.PHYLOGENY_DISPLAY_TYPE.CLADOGRAM;