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 TreeDisplayType {
85 enum NodeClickAction {
92 DELETE_NODE_OR_SUBTREE,
110 final static Font jcb_bold_font = new Font( Configuration
111 .getDefaultFontFamilyName(), Font.BOLD, 9 );
112 final static Font jcb_font = new Font( Configuration
113 .getDefaultFontFamilyName(), Font.PLAIN, 9 );
114 final static Font js_font = new Font( Configuration
115 .getDefaultFontFamilyName(), Font.PLAIN, 9 );
116 private static final String RETURN_TO_SUPER_TREE_TEXT = "R";
117 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).";
118 private static final long serialVersionUID = -8463483932821545633L;
119 private NodeClickAction _action_when_node_clicked;
120 private int _add_new_node_item;
121 private Map<Integer, String> _all_click_to_names;
122 private Map<String, Color> _annotation_colors;
123 private int _blast_item;
124 private JComboBox<String> _click_to_combobox;
125 private JLabel _click_to_label;
126 private List<String> _click_to_names;
127 private int _collapse_cb_item;
128 private int _uncollapse_all_cb_item;
129 private int _order_subtree_cb_item;
130 private JCheckBox _color_acc_species;
131 private JCheckBox _color_acc_sequence;
132 private JCheckBox _color_according_to_annotation;
133 private boolean _color_branches;
134 private JCheckBox _use_visual_styles_cb;
135 private int _color_subtree_cb_item;
136 private int _change_node_font_item;
137 // The settings from the conf file
138 private final Configuration _configuration;
139 private int _copy_subtree_item;
140 private int _cut_subtree_item;
141 private JButton _decr_domain_structure_evalue_thr;
142 private int _delete_node_or_subtree_item;
143 private JRadioButton _display_as_unaligned_phylogram_rb;
144 private JRadioButton _display_as_aligned_phylogram_rb;
145 private JRadioButton _display_as_cladogram_rb;
146 private ButtonGroup _display_as_buttongroup;
148 private JCheckBox _display_internal_data;
149 private JLabel _domain_display_label;
150 private JTextField _domain_structure_evalue_thr_tf;
151 private JTextField _depth_collapse_depth_tf;
152 private JTextField _rank_collapse_depth_tf;
153 private List<TreeDisplayType> _tree_display_types;
154 private JCheckBox _dynamically_hide_data;
155 private int _edit_node_data_item;
156 private int _get_ext_desc_data;
157 private JButton _incr_domain_structure_evalue_thr;
158 private final MainPanel _mainpanel;
159 private JCheckBox _node_desc_popup_cb;
160 private int _open_pdb_item;
161 private int _open_seq_web_item;
162 private int _open_tax_web_item;
163 private int _color_node_font_item;
164 private JButton _order;
165 private int _paste_subtree_item;
166 private int _reroot_cb_item;
167 private JButton _return_to_super_tree;
169 private JLabel _search_found_label_0;
170 private JLabel _search_found_label_1;
171 private JButton _search_reset_button_0;
172 private JButton _search_reset_button_1;
173 private JTextField _search_tf_0;
174 private JTextField _search_tf_1;
175 private int _select_nodes_item;
176 private Sequence _selected_query_seq;
177 private JCheckBox _seq_relation_confidence_switch;
178 private JComboBox<SEQUENCE_RELATION_TYPE> _sequence_relation_type_box;
179 private JCheckBox _show_annotation;
180 private JCheckBox _show_binary_character_counts;
181 private JCheckBox _show_binary_characters;
182 // Indices for the click-to options in the combo box
183 private int _show_data_item;
184 private JCheckBox _show_domain_architectures;
185 private JCheckBox _show_mol_seqs;
186 private JCheckBox _write_branch_length_values;
187 private JCheckBox _show_events;
188 private JCheckBox _show_gene_names;
189 private JCheckBox _show_node_names;
190 private JCheckBox _show_properties_cb;
191 private JCheckBox _show_seq_names;
192 private JCheckBox _show_seq_symbols;
193 private JCheckBox _show_sequence_acc;
194 private JComboBox<String> _show_sequence_relations;
195 private JCheckBox _show_taxo_code;
196 private JCheckBox _show_taxo_rank;
197 private JCheckBox _show_taxo_common_names;
198 private JCheckBox _show_taxo_images_cb;
199 private JCheckBox _show_taxo_scientific_names;
200 private JCheckBox _show_vector_data_cb;
201 private JButton _show_whole;
202 private int _sort_descendents_item;
203 private Map<String, Color> _species_colors;
204 private Map<String, Color> _sequence_colors;
205 private int _subtree_cb_item;
206 private int _swap_cb_item;
207 private JButton _uncollapse_all;
208 private JCheckBox _width_branches;
209 private JCheckBox _write_confidence;
210 private JButton _zoom_in_domain_structure;
211 private JButton _zoom_in_x;
212 private JButton _zoom_in_y;
213 private JLabel _zoom_label;
214 private JButton _zoom_out_domain_structure;
215 private JButton _zoom_out_x;
216 private JButton _zoom_out_y;
217 private JButton _decr_depth_collapse_level;
218 private JButton _incr_depth_collapse_level;
219 private JLabel _depth_collapse_label;
220 private JButton _decr_rank_collapse_level;
221 private JButton _incr_rank_collapse_level;
222 private JLabel _rank_collapse_label;
224 ControlPanel( final MainPanel ap, final Configuration configuration ) {
227 _configuration = configuration;
228 if ( !_configuration.isUseNativeUI() ) {
229 setBackground( getConfiguration().getGuiBackgroundColor() );
230 setBorder( BorderFactory.createRaisedBevelBorder() );
232 setLayout( new GridLayout( 0, 1, 2, 2 ) );
240 public void actionPerformed( final ActionEvent e ) {
242 if ( e.getSource() == _color_acc_sequence ) {
243 if ( _color_acc_species != null ) {
244 _color_acc_species.setSelected( false );
247 else if ( e.getSource() == _color_acc_species ) {
248 if ( _color_acc_sequence != null ) {
249 _color_acc_sequence.setSelected( false );
252 final TreePanel tp = getMainPanel().getCurrentTreePanel();
256 if ( e.getSource() == _click_to_combobox ) {
257 setClickToAction( _click_to_combobox.getSelectedIndex() );
258 getCurrentTreePanel().repaint();
260 else if ( e.getSource() == _show_binary_characters ) {
261 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
262 _show_binary_character_counts.setSelected( false );
264 displayedPhylogenyMightHaveChanged( true );
266 else if ( e.getSource() == _show_binary_character_counts ) {
267 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
268 _show_binary_characters.setSelected( false );
270 displayedPhylogenyMightHaveChanged( true );
272 else if ( e.getSource() == _show_domain_architectures ) {
275 displayedPhylogenyMightHaveChanged( true );
277 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
278 if ( e.getSource() == getDisplayAsUnalignedPhylogramRb() ) {
279 setTreeDisplayType( TreeDisplayType.UNALIGNED_PHYLOGRAM );
282 if ( e.getSource() == getDisplayAsAlignedPhylogramRb() ) {
283 setTreeDisplayType( TreeDisplayType.ALIGNED_PHYLOGRAM );
286 if ( e.getSource() == getDisplayAsCladogramRb() ) {
287 setTreeDisplayType( TreeDisplayType.CLADOGRAM );
291 else if ( e.getSource() == _zoom_in_x ) {
292 zoomInX( AptxConstants.BUTTON_ZOOM_IN_FACTOR, AptxConstants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
293 displayedPhylogenyMightHaveChanged( false );
295 else if ( e.getSource() == _zoom_in_y ) {
296 zoomInY( AptxConstants.BUTTON_ZOOM_IN_FACTOR );
297 displayedPhylogenyMightHaveChanged( false );
299 else if ( e.getSource() == _zoom_out_x ) {
300 zoomOutX( AptxConstants.BUTTON_ZOOM_OUT_FACTOR, AptxConstants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
301 displayedPhylogenyMightHaveChanged( false );
303 else if ( e.getSource() == _zoom_out_y ) {
304 zoomOutY( AptxConstants.BUTTON_ZOOM_OUT_FACTOR );
305 displayedPhylogenyMightHaveChanged( false );
307 else if ( e.getSource() == _show_whole ) {
308 displayedPhylogenyMightHaveChanged( true );
311 else if ( e.getSource() == _return_to_super_tree ) {
312 returnedToSuperTreePressed();
314 else if ( e.getSource() == _order ) {
317 else if ( e.getSource() == _uncollapse_all ) {
319 displayedPhylogenyMightHaveChanged( false );
321 else if ( e.getSource() == _zoom_in_domain_structure ) {
322 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
323 displayedPhylogenyMightHaveChanged( true );
325 else if ( e.getSource() == _zoom_out_domain_structure ) {
326 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
327 displayedPhylogenyMightHaveChanged( true );
329 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
330 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThresholdExp();
333 displayedPhylogenyMightHaveChanged( true );
335 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
336 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThresholdExp();
339 displayedPhylogenyMightHaveChanged( true );
341 else if ( e.getSource() == _search_tf_0 ) {
343 displayedPhylogenyMightHaveChanged( true );
345 else if ( e.getSource() == _search_tf_1 ) {
347 displayedPhylogenyMightHaveChanged( true );
349 else if ( ( _dynamically_hide_data != null ) && ( e.getSource() == _dynamically_hide_data )
350 && !_dynamically_hide_data.isSelected() ) {
351 setDynamicHidingIsOn( false );
352 displayedPhylogenyMightHaveChanged( true );
354 else if ( ( e.getSource() == _decr_depth_collapse_level )
355 || ( e.getSource() == _incr_depth_collapse_level ) ) {
356 if ( e.getSource() == _decr_depth_collapse_level ) {
357 _mainpanel.getCurrentTreePanel().decreaseDepthCollapseLevel();
360 _mainpanel.getCurrentTreePanel().increaseDepthCollapseLevel();
364 _mainpanel.getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
365 _mainpanel.getCurrentTreePanel().getPhylogeny().recalculateNumberOfExternalDescendants( true );
366 _mainpanel.getCurrentTreePanel().resetNodeIdToDistToLeafMap();
367 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
368 _mainpanel.getCurrentTreePanel().setNodeInPreorderToNull();
369 displayedPhylogenyMightHaveChanged( true );
370 _mainpanel.getCurrentTreePanel().resetPreferredSize();
371 _mainpanel.getCurrentTreePanel().updateOvSizes();
372 _mainpanel.adjustJScrollPane();
376 else if ( ( e.getSource() == _decr_rank_collapse_level )
377 || ( e.getSource() == _incr_rank_collapse_level ) ) {
378 if ( e.getSource() == _decr_rank_collapse_level ) {
379 _mainpanel.getCurrentTreePanel().decreaseRankCollapseLevel();
382 _mainpanel.getCurrentTreePanel().increaseRankCollapseLevel();
386 _mainpanel.getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
387 _mainpanel.getCurrentTreePanel().getPhylogeny().recalculateNumberOfExternalDescendants( true );
388 _mainpanel.getCurrentTreePanel().resetNodeIdToDistToLeafMap();
389 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
390 _mainpanel.getCurrentTreePanel().setNodeInPreorderToNull();
391 displayedPhylogenyMightHaveChanged( true );
392 _mainpanel.getCurrentTreePanel().resetPreferredSize();
393 _mainpanel.getCurrentTreePanel().updateOvSizes();
394 _mainpanel.adjustJScrollPane();
399 displayedPhylogenyMightHaveChanged( true );
403 tp.requestFocusInWindow();
406 catch ( final Exception ex ) {
407 AptxUtil.unexpectedException( ex );
409 catch ( final Error err ) {
410 AptxUtil.unexpectedError( err );
414 void orderPressed( final TreePanel tp ) {
415 DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
416 if ( isShowTaxonomyScientificNames() || isShowTaxonomyCode() ) {
417 pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
419 else if ( isShowSeqNames() || isShowSeqSymbols() || isShowGeneNames() ) {
420 pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
422 PhylogenyMethods.orderAppearanceX( tp.getPhylogeny().getRoot(), true, pri );
423 tp.setNodeInPreorderToNull();
424 tp.getPhylogeny().externalNodesHaveChanged();
425 tp.getPhylogeny().clearHashIdToNodeMap();
426 tp.getPhylogeny().recalculateNumberOfExternalDescendants( true );
427 tp.resetNodeIdToDistToLeafMap();
428 tp.setEdited( true );
429 displayedPhylogenyMightHaveChanged( true );
432 void returnedToSuperTreePressed() {
433 if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
434 _mainpanel.getCurrentTreePanel().superTree();
439 public JCheckBox getColorAccSequenceCb() {
440 return _color_acc_sequence;
443 public JCheckBox getColorAccSpeciesCb() {
444 return _color_acc_species;
447 public JRadioButton getDisplayAsCladogramRb() {
448 return _display_as_cladogram_rb;
451 public JRadioButton getDisplayAsAlignedPhylogramRb() {
452 return _display_as_aligned_phylogram_rb;
455 public JRadioButton getDisplayAsUnalignedPhylogramRb() {
456 return _display_as_unaligned_phylogram_rb;
459 public JCheckBox getDynamicallyHideData() {
460 return _dynamically_hide_data;
463 public JCheckBox getNodeDescPopupCb() {
464 return _node_desc_popup_cb;
467 public Sequence getSelectedQuerySequence() {
468 return _selected_query_seq;
471 public JComboBox<String> getSequenceRelationBox() {
472 if ( _show_sequence_relations == null ) {
473 _show_sequence_relations = new JComboBox<String>();
474 _show_sequence_relations.setFocusable( false );
475 _show_sequence_relations.setMaximumRowCount( 20 );
476 _show_sequence_relations.setFont( ControlPanel.js_font );
477 if ( !_configuration.isUseNativeUI() ) {
478 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
479 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
481 _show_sequence_relations.addItem( "-----" );
482 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
484 return _show_sequence_relations;
488 public JComboBox<SEQUENCE_RELATION_TYPE> getSequenceRelationTypeBox() {
489 if ( _sequence_relation_type_box == null ) {
490 _sequence_relation_type_box = new JComboBox<SEQUENCE_RELATION_TYPE>();
491 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE
493 _sequence_relation_type_box.addItem( type );
495 _sequence_relation_type_box.addActionListener( new ActionListener() {
498 public void actionPerformed( final ActionEvent e ) {
499 if ( _mainpanel.getCurrentPhylogeny() != null ) {
500 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
505 return _sequence_relation_type_box;
508 public JCheckBox getShowEventsCb() {
512 public JCheckBox getUseVisualStylesCb() {
513 return _use_visual_styles_cb;
516 public JCheckBox getWriteConfidenceCb() {
517 return _write_confidence;
520 public boolean isShowMolSequences() {
521 return ( ( _show_mol_seqs != null ) && _show_mol_seqs.isSelected() );
524 public boolean isShowProperties() {
525 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
528 public boolean isShowTaxonomyImages() {
529 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
532 public boolean isShowVectorData() {
533 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
536 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
537 final JComboBox<String> box = getSequenceRelationBox();
538 while ( box.getItemCount() > 1 ) {
539 box.removeItemAt( 1 );
541 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
542 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
544 if ( relationType == null ) {
547 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
548 for( final Sequence seq : sequenceRelationQueries ) {
549 if ( seq.isHasSequenceRelations() ) {
550 boolean fFoundForCurrentType = false;
551 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
552 if ( sq.getType().equals( relationType ) ) {
553 fFoundForCurrentType = true;
557 if ( fFoundForCurrentType ) {
558 sequenceNamesToAdd.add( seq.getName() );
559 sequencesByName.put( seq.getName(), seq );
563 // sort sequences by name before adding them to the combo
564 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
565 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
566 for( final String seqName : sequenceNameArray ) {
567 box.addItem( seqName );
569 for( final ItemListener oldItemListener : box.getItemListeners() ) {
570 box.removeItemListener( oldItemListener );
572 box.addItemListener( new ItemListener() {
575 public void itemStateChanged( final ItemEvent e ) {
576 _selected_query_seq = sequencesByName.get( e.getItem() );
577 _mainpanel.getCurrentTreePanel().repaint();
582 private void addClickToOption( final int which, final String title ) {
583 _click_to_combobox.addItem( title );
584 _click_to_names.add( title );
585 _all_click_to_names.put( new Integer( which ), title );
586 if ( !_configuration.isUseNativeUI() ) {
587 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
588 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
593 private void addSequenceRelationBlock() {
594 final JLabel spacer = new JLabel( "" );
595 spacer.setSize( 1, 1 );
597 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
598 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
599 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
600 getSequenceRelationTypeBox().setFocusable( false );
601 _sequence_relation_type_box.setFont( ControlPanel.js_font );
602 if ( !_configuration.isUseNativeUI() ) {
603 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
604 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
606 _sequence_relation_type_box.setRenderer( new ListCellRenderer<Object>() {
609 public Component getListCellRendererComponent( final JList<?> list,
612 final boolean isSelected,
613 final boolean cellHasFocus ) {
614 final Component component = new DefaultListCellRenderer()
615 .getListCellRendererComponent( list, value, index, isSelected, cellHasFocus );
616 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
617 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
618 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
623 final GridBagLayout gbl = new GridBagLayout();
624 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
625 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
626 final JPanel horizGrid = new JPanel( gbl );
627 horizGrid.setBackground( getBackground() );
628 horizGrid.add( typeLabel );
629 horizGrid.add( _sequence_relation_type_box );
630 add( customizeLabel( mainLabel, getConfiguration() ) );
632 add( getSequenceRelationBox() );
633 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
634 addCheckbox( Configuration.show_relation_confidence,
635 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
636 setCheckbox( Configuration.show_relation_confidence,
637 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
639 }// addSequenceRelationBlock
642 private List<TreeDisplayType> getTreeDisplayTypes() {
643 return _tree_display_types;
646 final private MainFrame getMainFrame() {
647 return getMainPanel().getMainFrame();
650 private void init() {
651 _tree_display_types = new ArrayList<TreeDisplayType>();
652 setSpeciesColors( new HashMap<String, Color>() );
653 setSequenceColors( new HashMap<String, Color>() );
654 setAnnotationColors( new HashMap<String, Color>() );
657 private TreeDisplayType getTreeDisplayType( final int index ) {
658 return getTreeDisplayTypes().get( index );
661 private void search0( final MainPanel main_panel, final Phylogeny tree, String query_str ) {
662 getSearchFoundCountsLabel0().setVisible( true );
663 getSearchResetButton0().setEnabled( true );
664 getSearchResetButton0().setVisible( true );
665 String[] queries = null;
666 Set<Long> nodes = null;
667 query_str = query_str.replaceAll( "\\s+", " " );
668 if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
669 queries = query_str.split( ",+" );
672 queries = new String[ 1 ];
673 queries[ 0 ] = query_str.trim();
675 if ( ( queries != null ) && ( queries.length > 0 ) ) {
676 nodes = new HashSet<Long>();
677 for( String query : queries ) {
678 if ( ForesterUtil.isEmpty( query ) ) {
681 query = query.trim();
682 final TreePanel tp = getMainPanel().getCurrentTreePanel();
683 if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
684 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
686 getOptions().isSearchCaseSensitive(),
687 !getOptions().isMatchWholeTermsOnly(),
688 isShowDomainArchitectures(),
691 tp.getDomainStructureEvalueThresholdExp() )
695 nodes.addAll( PhylogenyMethods
698 getOptions().isSearchCaseSensitive(),
699 !getOptions().isMatchWholeTermsOnly(),
700 getOptions().isSearchWithRegex(),
701 isShowDomainArchitectures(),
702 tp != null ? Math.pow( 10, tp.getDomainStructureEvalueThresholdExp() ) : 0 ) );
705 if ( getOptions().isInverseSearchResult() ) {
706 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
707 final Set<Long> temp_nodes = nodes;
708 nodes = new HashSet<Long>();
709 for( final PhylogenyNode n : all ) {
710 if ( ( !temp_nodes.contains( n.getId() ) ) && n.isHasNodeData() ) {
711 nodes.add( n.getId() );
716 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
717 main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet<Long>() );
718 for( final Long node : nodes ) {
719 main_panel.getCurrentTreePanel().getFoundNodes0().add( node );
721 setSearchFoundCountsOnLabel0( nodes.size() );
724 setSearchFoundCountsOnLabel0( 0 );
729 private void search1( final MainPanel main_panel, final Phylogeny tree, String query_str ) {
730 getSearchFoundCountsLabel1().setVisible( true );
731 getSearchResetButton1().setEnabled( true );
732 getSearchResetButton1().setVisible( true );
733 String[] queries = null;
734 Set<Long> nodes = null;
735 query_str = query_str.replaceAll( "\\s+", " " );
736 if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
737 queries = query_str.split( ",+" );
740 queries = new String[ 1 ];
741 queries[ 0 ] = query_str.trim();
743 if ( ( queries != null ) && ( queries.length > 0 ) ) {
744 nodes = new HashSet<Long>();
745 for( String query : queries ) {
746 if ( ForesterUtil.isEmpty( query ) ) {
749 query = query.trim();
750 final TreePanel tp = getMainPanel().getCurrentTreePanel();
751 if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
752 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
754 getOptions().isSearchCaseSensitive(),
755 !getOptions().isMatchWholeTermsOnly(),
756 isShowDomainArchitectures(),
759 tp.getDomainStructureEvalueThresholdExp() )
763 nodes.addAll( PhylogenyMethods
766 getOptions().isSearchCaseSensitive(),
767 !getOptions().isMatchWholeTermsOnly(),
768 getOptions().isSearchWithRegex(),
769 isShowDomainArchitectures(),
770 tp != null ? Math.pow( 10, tp.getDomainStructureEvalueThresholdExp() ) : 0 ) );
773 if ( getOptions().isInverseSearchResult() ) {
774 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
775 final Set<Long> temp_nodes = nodes;
776 nodes = new HashSet<Long>();
777 for( final PhylogenyNode n : all ) {
778 if ( ( !temp_nodes.contains( n.getId() ) ) && n.isHasNodeData() ) {
779 nodes.add( n.getId() );
784 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
785 main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet<Long>() );
786 for( final Long node : nodes ) {
787 main_panel.getCurrentTreePanel().getFoundNodes1().add( node );
789 setSearchFoundCountsOnLabel1( nodes.size() );
792 setSearchFoundCountsOnLabel1( 0 );
797 private void setTreeDisplayType( final int index, final TreeDisplayType t ) {
798 getTreeDisplayTypes().set( index, t );
801 private void setupClickToOptions() {
802 final int default_option = _configuration.getDefaultDisplayClicktoOption();
803 int selected_index = 0;
805 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
806 _show_data_item = cb_index;
807 addClickToOption( Configuration.display_node_data,
808 _configuration.getClickToTitle( Configuration.display_node_data ) );
809 if ( default_option == Configuration.display_node_data ) {
810 selected_index = cb_index;
814 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
815 _collapse_cb_item = cb_index;
816 addClickToOption( Configuration.collapse_uncollapse,
817 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
818 if ( default_option == Configuration.collapse_uncollapse ) {
819 selected_index = cb_index;
823 if ( _configuration.doDisplayClickToOption( Configuration.uncollapse_all ) ) {
824 _uncollapse_all_cb_item = cb_index;
825 addClickToOption( Configuration.uncollapse_all,
826 _configuration.getClickToTitle( Configuration.uncollapse_all ) );
827 if ( default_option == Configuration.uncollapse_all ) {
828 selected_index = cb_index;
832 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
833 _reroot_cb_item = cb_index;
834 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
835 if ( default_option == Configuration.reroot ) {
836 selected_index = cb_index;
840 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
841 _subtree_cb_item = cb_index;
842 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
843 if ( default_option == Configuration.subtree ) {
844 selected_index = cb_index;
848 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
849 _swap_cb_item = cb_index;
850 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
851 if ( default_option == Configuration.swap ) {
852 selected_index = cb_index;
856 if ( _configuration.doDisplayClickToOption( Configuration.order_subtree ) ) {
857 _order_subtree_cb_item = cb_index;
858 addClickToOption( Configuration.order_subtree,
859 _configuration.getClickToTitle( Configuration.order_subtree ) );
860 if ( default_option == Configuration.order_subtree ) {
861 selected_index = cb_index;
865 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
866 _sort_descendents_item = cb_index;
867 addClickToOption( Configuration.sort_descendents,
868 _configuration.getClickToTitle( Configuration.sort_descendents ) );
869 if ( default_option == Configuration.sort_descendents ) {
870 selected_index = cb_index;
874 if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) {
875 _color_node_font_item = cb_index;
876 addClickToOption( Configuration.color_node_font,
877 _configuration.getClickToTitle( Configuration.color_node_font ) );
878 if ( default_option == Configuration.color_node_font ) {
879 selected_index = cb_index;
883 if ( _configuration.doDisplayClickToOption( Configuration.change_node_font ) ) {
884 _change_node_font_item = cb_index;
885 addClickToOption( Configuration.change_node_font,
886 _configuration.getClickToTitle( Configuration.change_node_font ) );
887 if ( default_option == Configuration.change_node_font ) {
888 selected_index = cb_index;
892 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
893 _color_subtree_cb_item = cb_index;
894 addClickToOption( Configuration.color_subtree,
895 _configuration.getClickToTitle( Configuration.color_subtree ) );
896 if ( default_option == Configuration.color_subtree ) {
897 selected_index = cb_index;
901 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
902 _open_seq_web_item = cb_index;
903 addClickToOption( Configuration.open_seq_web,
904 _configuration.getClickToTitle( Configuration.open_seq_web ) );
905 if ( default_option == Configuration.open_seq_web ) {
906 selected_index = cb_index;
910 if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
911 _open_pdb_item = cb_index;
912 addClickToOption( Configuration.open_pdb_web,
913 _configuration.getClickToTitle( Configuration.open_pdb_web ) );
914 if ( default_option == Configuration.open_pdb_web ) {
915 selected_index = cb_index;
919 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
920 _open_tax_web_item = cb_index;
921 addClickToOption( Configuration.open_tax_web,
922 _configuration.getClickToTitle( Configuration.open_tax_web ) );
923 if ( default_option == Configuration.open_tax_web ) {
924 selected_index = cb_index;
928 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
929 _blast_item = cb_index;
930 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
931 if ( default_option == Configuration.blast ) {
932 selected_index = cb_index;
936 if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
937 _select_nodes_item = cb_index;
938 addClickToOption( Configuration.select_nodes,
939 _configuration.getClickToTitle( Configuration.select_nodes ) );
940 if ( default_option == Configuration.select_nodes ) {
941 selected_index = cb_index;
945 if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
946 _get_ext_desc_data = cb_index;
947 if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
948 addClickToOption( Configuration.get_ext_desc_data,
949 getConfiguration().getLabelForGetExtDescendentsData() );
952 addClickToOption( Configuration.get_ext_desc_data,
953 getConfiguration().getClickToTitle( Configuration.get_ext_desc_data ) );
955 if ( default_option == Configuration.get_ext_desc_data ) {
956 selected_index = cb_index;
960 if ( getOptions().isEditable() ) {
961 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
962 _cut_subtree_item = cb_index;
963 addClickToOption( Configuration.cut_subtree,
964 _configuration.getClickToTitle( Configuration.cut_subtree ) );
965 if ( default_option == Configuration.cut_subtree ) {
966 selected_index = cb_index;
970 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
971 _copy_subtree_item = cb_index;
972 addClickToOption( Configuration.copy_subtree,
973 _configuration.getClickToTitle( Configuration.copy_subtree ) );
974 if ( default_option == Configuration.copy_subtree ) {
975 selected_index = cb_index;
979 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
980 _paste_subtree_item = cb_index;
981 addClickToOption( Configuration.paste_subtree,
982 _configuration.getClickToTitle( Configuration.paste_subtree ) );
983 if ( default_option == Configuration.paste_subtree ) {
984 selected_index = cb_index;
988 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
989 _delete_node_or_subtree_item = cb_index;
990 addClickToOption( Configuration.delete_subtree_or_node,
991 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
992 if ( default_option == Configuration.delete_subtree_or_node ) {
993 selected_index = cb_index;
997 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
998 _add_new_node_item = cb_index;
999 addClickToOption( Configuration.add_new_node,
1000 _configuration.getClickToTitle( Configuration.add_new_node ) );
1001 if ( default_option == Configuration.add_new_node ) {
1002 selected_index = cb_index;
1006 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
1007 _edit_node_data_item = cb_index;
1008 addClickToOption( Configuration.edit_node_data,
1009 _configuration.getClickToTitle( Configuration.edit_node_data ) );
1010 if ( default_option == Configuration.edit_node_data ) {
1011 selected_index = cb_index;
1016 // Set default selection and its action
1017 _click_to_combobox.setSelectedIndex( selected_index );
1018 setClickToAction( selected_index );
1021 private void setupDisplayCheckboxes() {
1023 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1024 addCheckbox( Configuration.dynamically_hide_data,
1025 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
1026 setCheckbox( Configuration.dynamically_hide_data,
1027 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
1029 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1030 addCheckbox( Configuration.node_data_popup,
1031 _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1032 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1034 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1035 addCheckbox( Configuration.display_internal_data,
1036 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
1037 setCheckbox( Configuration.display_internal_data,
1038 _configuration.doCheckOption( Configuration.display_internal_data ) );
1040 if ( _configuration.doDisplayOption( Configuration.color_according_to_sequence ) ) {
1041 addCheckbox( Configuration.color_according_to_sequence,
1042 _configuration.getDisplayTitle( Configuration.color_according_to_sequence ) );
1043 setCheckbox( Configuration.color_according_to_sequence,
1044 _configuration.doCheckOption( Configuration.color_according_to_sequence ) );
1046 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1047 addCheckbox( Configuration.color_according_to_species,
1048 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
1049 setCheckbox( Configuration.color_according_to_species,
1050 _configuration.doCheckOption( Configuration.color_according_to_species ) );
1052 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1053 addCheckbox( Configuration.color_according_to_annotation,
1054 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
1055 setCheckbox( Configuration.color_according_to_annotation,
1056 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
1058 if ( _configuration.doDisplayOption( Configuration.use_style ) ) {
1059 addCheckbox( Configuration.use_style, _configuration.getDisplayTitle( Configuration.use_style ) );
1060 setCheckbox( Configuration.use_style, _configuration.doCheckOption( Configuration.use_style ) );
1062 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1063 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1064 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1066 final JLabel label = new JLabel( "Display Data:" );
1067 label.setFont( ControlPanel.jcb_bold_font );
1068 if ( !getConfiguration().isUseNativeUI() ) {
1069 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1072 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1073 addCheckbox( Configuration.show_node_names,
1074 _configuration.getDisplayTitle( Configuration.show_node_names ) );
1075 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1077 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1078 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1079 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1081 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1082 addCheckbox( Configuration.show_taxonomy_scientific_names,
1083 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1084 setCheckbox( Configuration.show_taxonomy_scientific_names,
1085 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1087 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1088 addCheckbox( Configuration.show_taxonomy_common_names,
1089 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1090 setCheckbox( Configuration.show_taxonomy_common_names,
1091 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1093 if ( _configuration.doDisplayOption( Configuration.show_tax_rank ) ) {
1094 addCheckbox( Configuration.show_tax_rank, _configuration.getDisplayTitle( Configuration.show_tax_rank ) );
1095 setCheckbox( Configuration.show_tax_rank, _configuration.doCheckOption( Configuration.show_tax_rank ) );
1097 if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
1098 addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
1099 setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
1101 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1102 addCheckbox( Configuration.show_gene_names,
1103 _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1104 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1106 if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
1107 addCheckbox( Configuration.show_seq_symbols,
1108 _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
1109 setCheckbox( Configuration.show_seq_symbols,
1110 _configuration.doCheckOption( Configuration.show_seq_symbols ) );
1112 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1113 addCheckbox( Configuration.show_sequence_acc,
1114 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1115 setCheckbox( Configuration.show_sequence_acc,
1116 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1118 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1119 addCheckbox( Configuration.show_annotation,
1120 _configuration.getDisplayTitle( Configuration.show_annotation ) );
1121 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1123 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1124 addCheckbox( Configuration.write_confidence_values,
1125 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1126 setCheckbox( Configuration.write_confidence_values,
1127 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1129 if ( _configuration.doDisplayOption( Configuration.write_branch_length_values ) ) {
1130 addCheckbox( Configuration.write_branch_length_values,
1131 _configuration.getDisplayTitle( Configuration.write_branch_length_values ) );
1132 setCheckbox( Configuration.write_branch_length_values,
1133 _configuration.doCheckOption( Configuration.write_branch_length_values ) );
1135 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1136 addCheckbox( Configuration.show_binary_characters,
1137 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1138 setCheckbox( Configuration.show_binary_characters,
1139 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1141 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1142 addCheckbox( Configuration.show_binary_character_counts,
1143 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1144 setCheckbox( Configuration.show_binary_character_counts,
1145 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1147 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1148 addCheckbox( Configuration.show_domain_architectures,
1149 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1150 setCheckbox( Configuration.show_domain_architectures,
1151 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1153 if ( _configuration.doDisplayOption( Configuration.show_mol_seqs ) ) {
1154 addCheckbox( Configuration.show_mol_seqs, _configuration.getDisplayTitle( Configuration.show_mol_seqs ) );
1155 setCheckbox( Configuration.show_mol_seqs, _configuration.doCheckOption( Configuration.show_mol_seqs ) );
1157 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1158 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1159 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1161 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1162 addCheckbox( Configuration.show_vector_data,
1163 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1164 setCheckbox( Configuration.show_vector_data,
1165 _configuration.doCheckOption( Configuration.show_vector_data ) );
1167 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1168 addCheckbox( Configuration.show_properties,
1169 _configuration.getDisplayTitle( Configuration.show_properties ) );
1170 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1172 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1173 addCheckbox( Configuration.show_taxonomy_images,
1174 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1175 setCheckbox( Configuration.show_taxonomy_images,
1176 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1180 private void setVisibilityOfDomainStrucureControls() {
1181 if ( _zoom_in_domain_structure != null ) {
1182 final MainFrame mf = getMainFrame();
1184 if ( isShowDomainArchitectures() ) {
1185 _domain_display_label.setVisible( true );
1186 _zoom_in_domain_structure.setVisible( true );
1187 _zoom_out_domain_structure.setVisible( true );
1188 _decr_domain_structure_evalue_thr.setVisible( true );
1189 _incr_domain_structure_evalue_thr.setVisible( true );
1190 _domain_structure_evalue_thr_tf.setVisible( true );
1191 if ( mf._right_line_up_domains_cbmi != null ) {
1192 mf._right_line_up_domains_cbmi.setVisible( true );
1194 if ( mf._show_domain_labels != null ) {
1195 mf._show_domain_labels.setVisible( true );
1199 _domain_display_label.setVisible( false );
1200 _zoom_in_domain_structure.setVisible( false );
1201 _zoom_out_domain_structure.setVisible( false );
1202 _decr_domain_structure_evalue_thr.setVisible( false );
1203 _incr_domain_structure_evalue_thr.setVisible( false );
1204 _domain_structure_evalue_thr_tf.setVisible( false );
1205 if ( mf._right_line_up_domains_cbmi != null ) {
1206 mf._right_line_up_domains_cbmi.setVisible( false );
1208 if ( mf._show_domain_labels != null ) {
1209 mf._show_domain_labels.setVisible( false );
1216 void activateButtonToReturnToSuperTree( int index ) {
1219 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
1222 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
1224 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1225 _return_to_super_tree.setEnabled( true );
1228 void activateButtonToUncollapseAll() {
1229 _uncollapse_all.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1230 _uncollapse_all.setEnabled( true );
1234 * Add zoom and quick edit buttons. (Last modified 8/9/04)
1237 final JLabel spacer = new JLabel( "" );
1238 spacer.setOpaque( false );
1240 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
1241 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1242 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
1243 final JPanel o_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1244 if ( !getConfiguration().isUseNativeUI() ) {
1245 x_panel.setBackground( getBackground() );
1246 y_panel.setBackground( getBackground() );
1247 z_panel.setBackground( getBackground() );
1248 o_panel.setBackground( getBackground() );
1250 add( _zoom_label = new JLabel( "Zoom:" ) );
1251 customizeLabel( _zoom_label, getConfiguration() );
1255 if ( getConfiguration().isUseNativeUI() ) {
1256 _zoom_in_x = new TypomaticJButton( "+" );
1257 _zoom_out_x = new TypomaticJButton( "-" );
1260 _zoom_in_x = new TypomaticJButton( "X+" );
1261 _zoom_out_x = new TypomaticJButton( "X-" );
1263 _zoom_in_y = new TypomaticJButton( "Y+" );
1264 _zoom_out_y = new TypomaticJButton( "Y-" );
1265 _show_whole = new JButton( "F" );
1266 _show_whole.setToolTipText( "fit and center to display [Alt+C or Home]" );
1267 _zoom_in_x.setToolTipText( "zoom in horizontally [Alt+Right or Shift+Alt+mousewheel]" );
1268 _zoom_in_y.setToolTipText( "zoom in vertically [Alt+Up or Shift+mousewheel]" );
1269 _zoom_out_x.setToolTipText( "zoom out horizontally [Alt+Left or Shift+Alt+mousewheel]" );
1270 _zoom_out_y.setToolTipText( "zoom out vertically [Alt+Down or Shift+mousewheel]" );
1271 if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) {
1272 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
1273 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
1276 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
1277 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
1279 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
1280 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
1281 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
1282 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
1283 _return_to_super_tree.setToolTipText( "return to the super-tree (if in sub-tree) [Alt+R]" );
1284 _return_to_super_tree.setEnabled( false );
1285 _order = new JButton( "O" );
1286 _order.setToolTipText( "order all [Alt+O]" );
1287 _uncollapse_all = new JButton( "U" );
1288 _uncollapse_all.setToolTipText( "uncollapse all [Alt+U]" );
1289 addJButton( _zoom_in_y, x_panel );
1290 addJButton( _zoom_out_x, y_panel );
1291 addJButton( _show_whole, y_panel );
1292 addJButton( _zoom_in_x, y_panel );
1293 addJButton( _zoom_out_y, z_panel );
1294 final JLabel spacer2 = new JLabel( "" );
1297 addJButton( _order, o_panel );
1298 addJButton( _return_to_super_tree, o_panel );
1299 addJButton( _uncollapse_all, o_panel );
1300 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
1301 setUpControlsForDomainStrucures();
1304 setUpControlsForDepthCollapse();
1307 setUpControlsForRankCollapse();
1309 final JLabel spacer3 = new JLabel( "" );
1311 setVisibilityOfDomainStrucureControls();
1314 void addCheckbox( final int which, final String title ) {
1315 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
1317 case Configuration.display_internal_data:
1318 _display_internal_data = new JCheckBox( title );
1319 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
1320 addJCheckBox( _display_internal_data, ch_panel );
1323 case Configuration.color_according_to_species:
1324 _color_acc_species = new JCheckBox( title );
1325 _color_acc_species.setToolTipText( "To colorize node labels as a function of taxonomy" );
1326 addJCheckBox( _color_acc_species, ch_panel );
1329 case Configuration.color_according_to_sequence:
1330 _color_acc_sequence = new JCheckBox( title );
1331 _color_acc_sequence.setToolTipText( "To colorize node labels as a function of sequence name" );
1332 addJCheckBox( _color_acc_sequence, ch_panel );
1335 case Configuration.color_according_to_annotation:
1336 _color_according_to_annotation = new JCheckBox( title );
1337 _color_according_to_annotation
1338 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
1339 addJCheckBox( _color_according_to_annotation, ch_panel );
1342 case Configuration.show_node_names:
1343 _show_node_names = new JCheckBox( title );
1344 addJCheckBox( _show_node_names, ch_panel );
1347 case Configuration.show_taxonomy_scientific_names:
1348 _show_taxo_scientific_names = new JCheckBox( title );
1349 addJCheckBox( _show_taxo_scientific_names, ch_panel );
1352 case Configuration.show_taxonomy_common_names:
1353 _show_taxo_common_names = new JCheckBox( title );
1354 addJCheckBox( _show_taxo_common_names, ch_panel );
1357 case Configuration.show_tax_code:
1358 _show_taxo_code = new JCheckBox( title );
1359 addJCheckBox( _show_taxo_code, ch_panel );
1362 case Configuration.show_tax_rank:
1363 _show_taxo_rank = new JCheckBox( title );
1364 addJCheckBox( _show_taxo_rank, ch_panel );
1367 case Configuration.show_taxonomy_images:
1368 _show_taxo_images_cb = new JCheckBox( title );
1369 addJCheckBox( _show_taxo_images_cb, ch_panel );
1372 case Configuration.show_binary_characters:
1373 _show_binary_characters = new JCheckBox( title );
1374 addJCheckBox( _show_binary_characters, ch_panel );
1377 case Configuration.show_annotation:
1378 _show_annotation = new JCheckBox( title );
1379 addJCheckBox( _show_annotation, ch_panel );
1382 case Configuration.show_binary_character_counts:
1383 _show_binary_character_counts = new JCheckBox( title );
1384 addJCheckBox( _show_binary_character_counts, ch_panel );
1387 case Configuration.write_confidence_values:
1388 _write_confidence = new JCheckBox( title );
1389 addJCheckBox( getWriteConfidenceCb(), ch_panel );
1392 case Configuration.write_events:
1393 _show_events = new JCheckBox( title );
1394 addJCheckBox( getShowEventsCb(), ch_panel );
1397 case Configuration.use_style:
1398 _use_visual_styles_cb = new JCheckBox( title );
1399 getUseVisualStylesCb()
1400 .setToolTipText( "To use visual styles (node colors, fonts) and branch colors, if present" );
1401 addJCheckBox( getUseVisualStylesCb(), ch_panel );
1404 case Configuration.width_branches:
1405 _width_branches = new JCheckBox( title );
1406 _width_branches.setToolTipText( "To use branch width values, if present" );
1407 addJCheckBox( _width_branches, ch_panel );
1410 case Configuration.write_branch_length_values:
1411 _write_branch_length_values = new JCheckBox( title );
1412 addJCheckBox( _write_branch_length_values, ch_panel );
1415 case Configuration.show_domain_architectures:
1416 _show_domain_architectures = new JCheckBox( title );
1417 addJCheckBox( _show_domain_architectures, ch_panel );
1420 case Configuration.show_mol_seqs:
1421 _show_mol_seqs = new JCheckBox( title );
1422 addJCheckBox( _show_mol_seqs, ch_panel );
1425 case Configuration.show_seq_names:
1426 _show_seq_names = new JCheckBox( title );
1427 addJCheckBox( _show_seq_names, ch_panel );
1430 case Configuration.show_gene_names:
1431 _show_gene_names = new JCheckBox( title );
1432 addJCheckBox( _show_gene_names, ch_panel );
1435 case Configuration.show_seq_symbols:
1436 _show_seq_symbols = new JCheckBox( title );
1437 addJCheckBox( _show_seq_symbols, ch_panel );
1440 case Configuration.show_sequence_acc:
1441 _show_sequence_acc = new JCheckBox( title );
1442 addJCheckBox( _show_sequence_acc, ch_panel );
1445 case Configuration.dynamically_hide_data:
1446 _dynamically_hide_data = new JCheckBox( title );
1447 getDynamicallyHideData().setToolTipText( "To hide labels depending on expected visibility" );
1448 addJCheckBox( getDynamicallyHideData(), ch_panel );
1451 case Configuration.node_data_popup:
1452 _node_desc_popup_cb = new JCheckBox( title );
1453 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
1454 addJCheckBox( getNodeDescPopupCb(), ch_panel );
1457 case Configuration.show_relation_confidence:
1458 _seq_relation_confidence_switch = new JCheckBox( title );
1459 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
1462 case Configuration.show_vector_data:
1463 _show_vector_data_cb = new JCheckBox( title );
1464 addJCheckBox( _show_vector_data_cb, ch_panel );
1467 case Configuration.show_properties:
1468 _show_properties_cb = new JCheckBox( title );
1469 addJCheckBox( _show_properties_cb, ch_panel );
1473 throw new RuntimeException( "unknown checkbox: " + which );
1477 void addJButton( final JButton jb, final JPanel p ) {
1478 jb.setFocusPainted( false );
1479 jb.setFont( ControlPanel.jcb_font );
1480 if ( !_configuration.isUseNativeUI() ) {
1481 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
1482 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1483 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
1486 jb.addActionListener( this );
1489 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
1490 jcb.setFocusPainted( false );
1491 jcb.setFont( ControlPanel.jcb_font );
1492 if ( !_configuration.isUseNativeUI() ) {
1493 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
1494 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1496 p.add( jcb, "Center" );
1497 jcb.addActionListener( this );
1500 private final void setupJRadioButton( final JRadioButton rb ) {
1501 rb.setFocusPainted( false );
1502 rb.setFont( ControlPanel.jcb_font );
1503 if ( !_configuration.isUseNativeUI() ) {
1504 rb.setBackground( getConfiguration().getGuiBackgroundColor() );
1505 rb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1507 rb.addActionListener( this );
1510 void addJTextField( final JTextField tf, final JPanel p ) {
1511 if ( !_configuration.isUseNativeUI() ) {
1512 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
1513 tf.setFont( ControlPanel.jcb_font );
1516 tf.addActionListener( this );
1519 void deactivateButtonToReturnToSuperTree() {
1520 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
1521 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
1522 _return_to_super_tree.setEnabled( false );
1525 void deactivateButtonToUncollapseAll() {
1526 _uncollapse_all.setForeground( getConfiguration().getGuiButtonTextColor() );
1527 _uncollapse_all.setEnabled( false );
1530 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
1531 if ( ( _mainpanel != null )
1532 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
1533 if ( recalc_longest_ext_node_info ) {
1534 _mainpanel.getCurrentTreePanel().initNodeData();
1535 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
1537 if ( getOptions().isShowOverview() ) {
1538 _mainpanel.getCurrentTreePanel().updateOvSizes();
1540 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
1541 setVisibilityOfDomainStrucureControls();
1542 updateDomainStructureEvaluethresholdDisplay();
1543 updateDepthCollapseDepthDisplay();
1544 updateRankCollapseRankDisplay();
1545 getMainPanel().getControlPanel();
1546 _mainpanel.getCurrentTreePanel().updateButtonToUncollapseAll();
1547 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
1548 _mainpanel.getCurrentTreePanel().calcMaxDepth();
1549 _mainpanel.adjustJScrollPane();
1550 _mainpanel.getCurrentTreePanel().repaint();
1551 // _mainpanel.getCurrentTreePanel().setUpUrtFactor();
1555 void endClickToOptions() {
1556 _click_to_combobox.addActionListener( this );
1560 * Indicates what action should be execute when a node is clicked
1562 * @return the click-on action
1564 NodeClickAction getActionWhenNodeClicked() {
1565 return _action_when_node_clicked;
1568 Map<Integer, String> getAllClickToItems() {
1569 return _all_click_to_names;
1572 Map<String, Color> getAnnotationColors() {
1573 return _annotation_colors;
1576 Configuration getConfiguration() {
1577 return _configuration;
1580 TreePanel getCurrentTreePanel() {
1581 return getMainPanel().getCurrentTreePanel();
1584 MainPanel getMainPanel() {
1588 Options getOptions() {
1589 return getMainPanel().getOptions();
1592 JLabel getSearchFoundCountsLabel0() {
1593 return _search_found_label_0;
1596 JLabel getSearchFoundCountsLabel1() {
1597 return _search_found_label_1;
1600 JButton getSearchResetButton0() {
1601 return _search_reset_button_0;
1604 JButton getSearchResetButton1() {
1605 return _search_reset_button_1;
1608 JTextField getSearchTextField0() {
1609 return _search_tf_0;
1612 JTextField getSearchTextField1() {
1613 return _search_tf_1;
1616 Map<String, Color> getSequenceColors() {
1617 return _sequence_colors;
1620 List<String> getSingleClickToNames() {
1621 return _click_to_names;
1624 Map<String, Color> getSpeciesColors() {
1625 return _species_colors;
1628 boolean isAntialiasScreenText() {
1632 boolean isColorAccordingToAnnotation() {
1633 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
1636 boolean isColorAccordingToSequence() {
1637 return ( ( _color_acc_sequence != null ) && _color_acc_sequence.isSelected() );
1640 boolean isColorAccordingToTaxonomy() {
1641 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
1644 boolean isDrawPhylogram() {
1645 final TreeDisplayType t = getTreeDisplayType( getMainPanel().getCurrentTabIndex() );
1646 return ((t == TreeDisplayType.ALIGNED_PHYLOGRAM) ||( t == TreeDisplayType.UNALIGNED_PHYLOGRAM));
1649 boolean isDynamicallyHideData() {
1650 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
1653 boolean isEvents() {
1654 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
1657 boolean isNodeDescPopup() {
1658 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
1661 boolean isShowAnnotation() {
1662 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
1665 boolean isShowBinaryCharacterCounts() {
1666 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
1669 boolean isShowBinaryCharacters() {
1670 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
1673 boolean isShowConfidenceValues() {
1674 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
1677 boolean isShowDomainArchitectures() {
1678 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
1681 boolean isShowGeneNames() {
1682 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
1685 boolean isShowInternalData() {
1686 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
1689 boolean isShowNodeNames() {
1690 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
1693 boolean isShowSeqNames() {
1694 return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
1697 boolean isShowSeqSymbols() {
1698 return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
1701 boolean isShowSequenceAcc() {
1702 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
1705 boolean isShowSequenceRelationConfidence() {
1706 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
1709 boolean isShowSequenceRelations() {
1710 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
1713 boolean isShowTaxonomyCode() {
1714 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
1717 boolean isShowTaxonomyRank() {
1718 return ( ( _show_taxo_rank != null ) && _show_taxo_rank.isSelected() );
1721 boolean isShowTaxonomyCommonNames() {
1722 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
1725 boolean isShowTaxonomyScientificNames() {
1726 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
1729 boolean isUseVisualStyles() {
1730 return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() )
1731 || ( ( getUseVisualStylesCb() == null ) && _color_branches ) );
1734 boolean isWidthBranches() {
1735 return ( ( _width_branches != null ) && _width_branches.isSelected() );
1738 boolean isWriteBranchLengthValues() {
1739 return ( ( _write_branch_length_values != null ) && _write_branch_length_values.isSelected() );
1742 void phylogenyAdded( final Configuration configuration ) {
1743 if (configuration.isDrawAsPhylogram()) {
1744 getTreeDisplayTypes().add( TreeDisplayType.UNALIGNED_PHYLOGRAM);
1747 getTreeDisplayTypes().add( TreeDisplayType.CLADOGRAM);
1751 void phylogenyRemoved( final int index ) {
1752 getTreeDisplayTypes().remove( index );
1756 final MainPanel main_panel = getMainPanel();
1757 final Phylogeny tree = main_panel.getCurrentPhylogeny();
1758 if ( ( tree == null ) || tree.isEmpty() ) {
1761 String query = getSearchTextField0().getText();
1762 if ( query != null ) {
1763 query = query.trim();
1765 if ( !ForesterUtil.isEmpty( query ) ) {
1766 search0( main_panel, tree, query );
1769 getSearchFoundCountsLabel0().setVisible( false );
1770 getSearchResetButton0().setEnabled( false );
1771 getSearchResetButton0().setVisible( false );
1777 final MainPanel main_panel = getMainPanel();
1778 final Phylogeny tree = main_panel.getCurrentPhylogeny();
1779 if ( ( tree == null ) || tree.isEmpty() ) {
1782 String query = getSearchTextField1().getText();
1783 if ( query != null ) {
1784 query = query.trim();
1786 if ( !ForesterUtil.isEmpty( query ) ) {
1787 search1( main_panel, tree, query );
1790 getSearchFoundCountsLabel1().setVisible( false );
1791 getSearchResetButton1().setEnabled( false );
1792 getSearchResetButton1().setVisible( false );
1797 void searchReset0() {
1798 if ( getMainPanel().getCurrentTreePanel() != null ) {
1799 getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
1803 void searchReset1() {
1804 if ( getMainPanel().getCurrentTreePanel() != null ) {
1805 getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
1809 void setActionWhenNodeClicked( final NodeClickAction action ) {
1810 _action_when_node_clicked = action;
1813 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
1814 _annotation_colors = annotation_colors;
1817 void setCheckbox( final int which, final boolean state ) {
1819 case Configuration.display_as_phylogram:
1820 if ( getDisplayAsUnalignedPhylogramRb() != null ) {
1821 getDisplayAsUnalignedPhylogramRb().setSelected( state );
1822 getDisplayAsAlignedPhylogramRb().setSelected( !state );
1823 getDisplayAsCladogramRb().setSelected( !state );
1826 case Configuration.display_internal_data:
1827 if ( _display_internal_data != null ) {
1828 _display_internal_data.setSelected( state );
1831 case Configuration.color_according_to_species:
1832 if ( _color_acc_species != null ) {
1833 _color_acc_species.setSelected( state );
1836 case Configuration.color_according_to_sequence:
1837 if ( _color_acc_sequence != null ) {
1838 _color_acc_sequence.setSelected( state );
1841 case Configuration.color_according_to_annotation:
1842 if ( _color_according_to_annotation != null ) {
1843 _color_according_to_annotation.setSelected( state );
1846 case Configuration.show_node_names:
1847 if ( _show_node_names != null ) {
1848 _show_node_names.setSelected( state );
1851 case Configuration.show_taxonomy_scientific_names:
1852 if ( _show_taxo_scientific_names != null ) {
1853 _show_taxo_scientific_names.setSelected( state );
1856 case Configuration.show_taxonomy_common_names:
1857 if ( _show_taxo_common_names != null ) {
1858 _show_taxo_common_names.setSelected( state );
1861 case Configuration.show_tax_code:
1862 if ( _show_taxo_code != null ) {
1863 _show_taxo_code.setSelected( state );
1866 case Configuration.show_tax_rank:
1867 if ( _show_taxo_rank != null ) {
1868 _show_taxo_rank.setSelected( state );
1871 case Configuration.show_taxonomy_images:
1872 if ( _show_taxo_images_cb != null ) {
1873 _show_taxo_images_cb.setSelected( state );
1876 case Configuration.show_annotation:
1877 if ( _show_annotation != null ) {
1878 _show_annotation.setSelected( state );
1881 case Configuration.show_binary_characters:
1882 if ( _show_binary_characters != null ) {
1883 _show_binary_characters.setSelected( state );
1886 case Configuration.show_binary_character_counts:
1887 if ( _show_binary_character_counts != null ) {
1888 _show_binary_character_counts.setSelected( state );
1891 case Configuration.write_confidence_values:
1892 if ( getWriteConfidenceCb() != null ) {
1893 getWriteConfidenceCb().setSelected( state );
1896 case Configuration.write_events:
1897 if ( getShowEventsCb() != null ) {
1898 getShowEventsCb().setSelected( state );
1901 case Configuration.use_style:
1902 if ( getUseVisualStylesCb() != null ) {
1903 getUseVisualStylesCb().setSelected( state );
1906 case Configuration.width_branches:
1907 if ( _width_branches != null ) {
1908 _width_branches.setSelected( state );
1911 case Configuration.show_domain_architectures:
1912 if ( _show_domain_architectures != null ) {
1913 _show_domain_architectures.setSelected( state );
1916 case Configuration.write_branch_length_values:
1917 if ( _write_branch_length_values != null ) {
1918 _write_branch_length_values.setSelected( state );
1921 case Configuration.show_mol_seqs:
1922 if ( _show_mol_seqs != null ) {
1923 _show_mol_seqs.setSelected( state );
1926 case Configuration.show_seq_names:
1927 if ( _show_seq_names != null ) {
1928 _show_seq_names.setSelected( state );
1931 case Configuration.show_gene_names:
1932 if ( _show_gene_names != null ) {
1933 _show_gene_names.setSelected( state );
1936 case Configuration.show_seq_symbols:
1937 if ( _show_seq_symbols != null ) {
1938 _show_seq_symbols.setSelected( state );
1941 case Configuration.show_vector_data:
1942 if ( _show_vector_data_cb != null ) {
1943 _show_vector_data_cb.setSelected( state );
1946 case Configuration.show_properties:
1947 if ( _show_properties_cb != null ) {
1948 _show_properties_cb.setSelected( state );
1951 case Configuration.show_sequence_acc:
1952 if ( _show_sequence_acc != null ) {
1953 _show_sequence_acc.setSelected( state );
1956 case Configuration.dynamically_hide_data:
1957 if ( getDynamicallyHideData() != null ) {
1958 getDynamicallyHideData().setSelected( state );
1961 case Configuration.node_data_popup:
1962 if ( getNodeDescPopupCb() != null ) {
1963 getNodeDescPopupCb().setSelected( state );
1967 case Configuration.show_relation_confidence:
1968 if ( _seq_relation_confidence_switch != null ) {
1969 _seq_relation_confidence_switch.setSelected( state );
1974 throw new AssertionError( "unknown checkbox: " + which );
1979 * Set this checkbox state. Not all checkboxes have been instantiated
1980 * depending on the config.
1982 void setCheckbox( final JCheckBox cb, final boolean state ) {
1984 cb.setSelected( state );
1988 void setClickToAction( final int action ) {
1989 // Set click-to action
1990 if ( action == _show_data_item ) {
1991 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1993 else if ( action == _collapse_cb_item ) {
1994 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1996 else if ( action == _reroot_cb_item ) {
1997 setActionWhenNodeClicked( NodeClickAction.REROOT );
1999 else if ( action == _subtree_cb_item ) {
2000 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
2002 else if ( action == _swap_cb_item ) {
2003 setActionWhenNodeClicked( NodeClickAction.SWAP );
2005 else if ( action == _color_subtree_cb_item ) {
2006 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
2008 else if ( action == _open_seq_web_item ) {
2009 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
2011 else if ( action == _sort_descendents_item ) {
2012 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
2014 else if ( action == _blast_item ) {
2015 setActionWhenNodeClicked( NodeClickAction.BLAST );
2017 else if ( action == _open_tax_web_item ) {
2018 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
2020 else if ( action == _cut_subtree_item ) {
2021 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
2023 else if ( action == _copy_subtree_item ) {
2024 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
2026 else if ( action == _delete_node_or_subtree_item ) {
2027 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
2029 else if ( action == _paste_subtree_item ) {
2030 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
2032 else if ( action == _add_new_node_item ) {
2033 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
2035 else if ( action == _edit_node_data_item ) {
2036 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
2038 else if ( action == _select_nodes_item ) {
2039 setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
2041 else if ( action == _get_ext_desc_data ) {
2042 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
2044 else if ( action == _open_pdb_item ) {
2045 setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
2047 else if ( action == _color_node_font_item ) {
2048 setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
2050 else if ( action == _change_node_font_item ) {
2051 setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT );
2053 else if ( action == _uncollapse_all_cb_item ) {
2054 setActionWhenNodeClicked( NodeClickAction.UNCOLLAPSE_ALL );
2056 else if ( action == _order_subtree_cb_item ) {
2057 setActionWhenNodeClicked( NodeClickAction.ORDER_SUBTREE );
2060 throw new RuntimeException( "unknown action: " + action );
2062 // make sure drop down is displaying the correct action
2063 // in case this was called from outside the class
2064 _click_to_combobox.setSelectedIndex( action );
2067 void setColorBranches( final boolean color_branches ) {
2068 _color_branches = color_branches;
2071 void setTreeDisplayType( final TreeDisplayType t ) {
2073 case UNALIGNED_PHYLOGRAM:
2074 getDisplayAsUnalignedPhylogramRb().setSelected( true );
2076 case ALIGNED_PHYLOGRAM:
2077 getDisplayAsAlignedPhylogramRb().setSelected( true );
2080 getDisplayAsCladogramRb().setSelected( true );
2083 setTreeDisplayType( getMainPanel().getCurrentTabIndex(), t );
2086 void setDrawPhylogramEnabled( final boolean b ) {
2087 if ( getDisplayAsAlignedPhylogramRb() != null &&
2088 getDisplayAsUnalignedPhylogramRb() != null &&
2089 getDisplayAsCladogramRb() != null
2092 getDisplayAsAlignedPhylogramRb().setEnabled( b );
2093 getDisplayAsUnalignedPhylogramRb().setEnabled( b );
2094 getDisplayAsCladogramRb().setEnabled( b );
2098 void setDynamicHidingIsOn( final boolean is_on ) {
2100 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
2103 if ( !_configuration.isUseNativeUI() ) {
2104 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
2107 getDynamicallyHideData().setForeground( Color.BLACK );
2112 void setSearchFoundCountsOnLabel0( final int counts ) {
2113 getSearchFoundCountsLabel0().setText( "Found: " + counts );
2116 void setSearchFoundCountsOnLabel1( final int counts ) {
2117 getSearchFoundCountsLabel1().setText( "Found: " + counts );
2120 void setSequenceColors( final Map<String, Color> sequence_colors ) {
2121 _sequence_colors = sequence_colors;
2124 void setShowEvents( final boolean show_events ) {
2125 if ( getShowEventsCb() == null ) {
2126 _show_events = new JCheckBox( "" );
2128 getShowEventsCb().setSelected( show_events );
2131 void setSpeciesColors( final Map<String, Color> species_colors ) {
2132 _species_colors = species_colors;
2135 void setupControls() {
2137 setupTreeDisplayTypeOptions();
2138 setupDisplayCheckboxes();
2140 // The sequence relation query selection combo-box
2141 if ( _configuration.displaySequenceRelations() ) {
2142 addSequenceRelationBlock();
2146 startClickToOptions();
2147 setupClickToOptions();
2148 endClickToOptions();
2149 // Zoom and quick edit buttons
2151 setupSearchTools0();
2152 setupSearchTools1();
2155 void setupTreeDisplayTypeOptions() {
2156 _display_as_unaligned_phylogram_rb = new JRadioButton( "PH" );
2157 _display_as_aligned_phylogram_rb = new JRadioButton( "aPH" );
2158 _display_as_cladogram_rb = new JRadioButton( "CL" );
2159 _display_as_buttongroup = new ButtonGroup();
2160 _display_as_buttongroup.add( _display_as_unaligned_phylogram_rb );
2161 _display_as_buttongroup.add( _display_as_aligned_phylogram_rb );
2162 _display_as_buttongroup.add( _display_as_cladogram_rb );
2163 getDisplayAsUnalignedPhylogramRb().setToolTipText( "(unaligned) phylogram" );
2164 getDisplayAsAlignedPhylogramRb().setToolTipText( "aligned phylogram" );
2165 getDisplayAsCladogramRb().setToolTipText( "cladogram" );
2166 setupJRadioButton( getDisplayAsUnalignedPhylogramRb() );
2167 setupJRadioButton( getDisplayAsAlignedPhylogramRb() );
2168 setupJRadioButton( getDisplayAsCladogramRb() );
2169 final JPanel p = new JPanel(new GridLayout( 1, 3, 0, 0 ));
2170 p.setFont( ControlPanel.jcb_font );
2171 if ( !_configuration.isUseNativeUI() ) {
2172 p.setBackground( getConfiguration().getGuiBackgroundColor() );
2173 p.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2175 p.add( _display_as_unaligned_phylogram_rb );
2176 p.add( _display_as_aligned_phylogram_rb );
2177 p.add( _display_as_cladogram_rb );
2182 void setUpControlsForDomainStrucures() {
2183 _domain_display_label = new JLabel( "Domain Architectures:" );
2184 add( customizeLabel( _domain_display_label, getConfiguration() ) );
2185 add( _domain_display_label );
2186 _zoom_in_domain_structure = new TypomaticJButton( "d+" );
2187 _zoom_out_domain_structure = new TypomaticJButton( "d-" );
2188 _decr_domain_structure_evalue_thr = new JButton( "-" );
2189 _incr_domain_structure_evalue_thr = new JButton( "+" );
2190 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
2191 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
2192 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
2193 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
2194 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
2195 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
2196 _domain_structure_evalue_thr_tf = new JTextField( 3 );
2197 _domain_structure_evalue_thr_tf.setEditable( false );
2198 if ( !getConfiguration().isUseNativeUI() ) {
2199 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2200 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2201 _domain_structure_evalue_thr_tf.setBorder( null );
2203 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2204 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2205 if ( !_configuration.isUseNativeUI() ) {
2206 d1_panel.setBackground( getBackground() );
2207 d2_panel.setBackground( getBackground() );
2211 addJButton( _zoom_out_domain_structure, d1_panel );
2212 addJButton( _zoom_in_domain_structure, d1_panel );
2213 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
2214 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
2215 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
2218 void setUpControlsForDepthCollapse() {
2219 _depth_collapse_label = new JLabel( "Collapse by Node Depth:" );
2220 _depth_collapse_label
2221 .setToolTipText( "to automaticall collapse nodes with a depth equal or larger than a threshold" );
2222 add( customizeLabel( _depth_collapse_label, getConfiguration() ) );
2223 add( _depth_collapse_label );
2224 _decr_depth_collapse_level = new TypomaticJButton( "-" );
2225 _incr_depth_collapse_level = new TypomaticJButton( "+" );
2226 _decr_depth_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2227 _incr_depth_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2228 _decr_depth_collapse_level.setToolTipText( "to decrease the depth threshold (wraps around)" );
2229 _incr_depth_collapse_level.setToolTipText( "to increase the depth threshold (wraps around)" );
2230 _depth_collapse_depth_tf = new JTextField( 3 );
2231 _depth_collapse_depth_tf.setToolTipText( "the current depth threshold" );
2232 _depth_collapse_depth_tf.setEditable( false );
2233 if ( !getConfiguration().isUseNativeUI() ) {
2234 _depth_collapse_depth_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2235 _depth_collapse_depth_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2236 _depth_collapse_depth_tf.setBorder( null );
2238 final JPanel panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2239 if ( !_configuration.isUseNativeUI() ) {
2240 panel.setBackground( getBackground() );
2243 addJButton( _decr_depth_collapse_level, panel );
2244 addJTextField( _depth_collapse_depth_tf, panel );
2245 addJButton( _incr_depth_collapse_level, panel );
2248 void setUpControlsForRankCollapse() {
2249 _rank_collapse_label = new JLabel( "Collapse by Node Rank:" );
2250 _rank_collapse_label
2251 .setToolTipText( "to automatically collapse nodes with a taxonomic rank equal or lower than a threshold" );
2252 add( customizeLabel( _rank_collapse_label, getConfiguration() ) );
2253 add( _rank_collapse_label );
2254 _decr_rank_collapse_level = new TypomaticJButton( "-" );
2255 _incr_rank_collapse_level = new TypomaticJButton( "+" );
2256 _decr_rank_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2257 _incr_rank_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2258 _decr_rank_collapse_level.setToolTipText( "to decrease the taxonomic rank threshold (wraps around)" );
2259 _incr_rank_collapse_level.setToolTipText( "to increase the taxonomic rank threshold (wraps around)" );
2260 _rank_collapse_depth_tf = new JTextField( 3 );
2261 _rank_collapse_depth_tf.setToolTipText( "the current taxonomic rank threshold" );
2262 _rank_collapse_depth_tf.setEditable( false );
2263 if ( !getConfiguration().isUseNativeUI() ) {
2264 _rank_collapse_depth_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2265 _rank_collapse_depth_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2266 _rank_collapse_depth_tf.setBorder( null );
2268 final JPanel panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2269 if ( !_configuration.isUseNativeUI() ) {
2270 panel.setBackground( getBackground() );
2273 addJButton( _decr_rank_collapse_level, panel );
2274 addJTextField( _rank_collapse_depth_tf, panel );
2275 addJButton( _incr_rank_collapse_level, panel );
2278 void setupSearchTools0() {
2279 final JLabel search_label = new JLabel( "Search (A):" );
2280 search_label.setFont( ControlPanel.jcb_bold_font );
2281 if ( !getConfiguration().isUseNativeUI() ) {
2282 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2284 add( search_label );
2285 search_label.setToolTipText( SEARCH_TIP_TEXT );
2286 _search_found_label_0 = new JLabel();
2287 getSearchFoundCountsLabel0().setVisible( false );
2288 _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
2289 if ( !getConfiguration().isUseNativeUI() ) {
2290 _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2292 _search_tf_0 = new JTextField( 3 );
2293 _search_tf_0.setToolTipText( SEARCH_TIP_TEXT );
2294 _search_tf_0.setEditable( true );
2295 if ( !getConfiguration().isUseNativeUI() ) {
2296 _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2297 _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2298 _search_tf_0.setBorder( null );
2300 _search_reset_button_0 = new JButton();
2301 getSearchResetButton0().setText( "Reset" );
2302 getSearchResetButton0().setEnabled( false );
2303 getSearchResetButton0().setVisible( false );
2304 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
2305 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2306 s_panel_1.setBackground( getBackground() );
2308 s_panel_2.setBackground( getBackground() );
2310 final KeyAdapter key_adapter = new KeyAdapter() {
2313 public void keyReleased( final KeyEvent key_event ) {
2315 displayedPhylogenyMightHaveChanged( true );
2318 final ActionListener action_listener = new ActionListener() {
2321 public void actionPerformed( final ActionEvent e ) {
2323 setSearchFoundCountsOnLabel0( 0 );
2324 getSearchFoundCountsLabel0().setVisible( false );
2325 getSearchTextField0().setText( "" );
2326 getSearchResetButton0().setEnabled( false );
2327 getSearchResetButton0().setVisible( false );
2328 displayedPhylogenyMightHaveChanged( true );
2331 _search_reset_button_0.addActionListener( action_listener );
2332 _search_tf_0.addKeyListener( key_adapter );
2333 addJTextField( _search_tf_0, s_panel_1 );
2334 s_panel_2.add( _search_found_label_0 );
2335 addJButton( _search_reset_button_0, s_panel_2 );
2338 void setupSearchTools1() {
2339 final JLabel search_label = new JLabel( "Search (B):" );
2340 search_label.setFont( ControlPanel.jcb_bold_font );
2341 if ( !getConfiguration().isUseNativeUI() ) {
2342 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2344 add( search_label );
2345 search_label.setToolTipText( SEARCH_TIP_TEXT );
2346 _search_found_label_1 = new JLabel();
2347 getSearchFoundCountsLabel1().setVisible( false );
2348 _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
2349 if ( !getConfiguration().isUseNativeUI() ) {
2350 _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2352 _search_tf_1 = new JTextField( 3 );
2353 _search_tf_1.setToolTipText( SEARCH_TIP_TEXT );
2354 _search_tf_1.setEditable( true );
2355 if ( !getConfiguration().isUseNativeUI() ) {
2356 _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2357 _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2358 _search_tf_1.setBorder( null );
2360 _search_reset_button_1 = new JButton();
2361 getSearchResetButton1().setText( "Reset" );
2362 getSearchResetButton1().setEnabled( false );
2363 getSearchResetButton1().setVisible( false );
2364 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
2365 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2366 s_panel_1.setBackground( getBackground() );
2368 s_panel_2.setBackground( getBackground() );
2370 final KeyAdapter key_adapter = new KeyAdapter() {
2373 public void keyReleased( final KeyEvent key_event ) {
2375 displayedPhylogenyMightHaveChanged( true );
2378 final ActionListener action_listener = new ActionListener() {
2381 public void actionPerformed( final ActionEvent e ) {
2383 setSearchFoundCountsOnLabel1( 0 );
2384 getSearchFoundCountsLabel1().setVisible( false );
2385 getSearchTextField1().setText( "" );
2386 getSearchResetButton1().setEnabled( false );
2387 getSearchResetButton1().setVisible( false );
2388 displayedPhylogenyMightHaveChanged( true );
2391 _search_reset_button_1.addActionListener( action_listener );
2392 _search_tf_1.addKeyListener( key_adapter );
2393 addJTextField( _search_tf_1, s_panel_1 );
2394 s_panel_2.add( _search_found_label_1 );
2395 addJButton( _search_reset_button_1, s_panel_2 );
2398 void setVisibilityOfDomainStrucureCB() {
2400 if ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel()
2401 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2402 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
2403 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2404 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
2406 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2407 getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
2410 else if ( isShowDomainArchitectures() ) {
2411 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2412 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( true );
2414 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2415 getMainPanel().getMainFrame()._show_domain_labels.setVisible( true );
2419 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2420 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
2422 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2423 getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
2427 catch ( final Exception ignore ) {
2432 void setVisibilityOfX() {
2433 final MainFrame mf = getMainFrame();
2435 if ( ( getCurrentTreePanel() != null ) && ( getCurrentTreePanel().getPhylogeny() != null ) ) {
2436 if ( AptxUtil.isHasAtLeastOneBranchWithSupportSD( getCurrentTreePanel().getPhylogeny() ) ) {
2437 if ( mf._show_confidence_stddev_cbmi != null ) {
2438 mf._show_confidence_stddev_cbmi.setVisible( true );
2442 if ( mf._show_confidence_stddev_cbmi != null ) {
2443 mf._show_confidence_stddev_cbmi.setVisible( false );
2446 if ( AptxUtil.isHasAtLeastOneNodeWithScientificName( getCurrentTreePanel().getPhylogeny() ) ) {
2447 if ( mf._abbreviate_scientific_names != null ) {
2448 mf._abbreviate_scientific_names.setVisible( true );
2452 if ( mf._abbreviate_scientific_names != null ) {
2453 mf._abbreviate_scientific_names.setVisible( false );
2456 if ( AptxUtil.isHasAtLeastOneNodeWithSequenceAnnotation( getCurrentTreePanel().getPhylogeny() ) ) {
2457 if ( mf._show_annotation_ref_source != null ) {
2458 mf._show_annotation_ref_source.setVisible( true );
2462 if ( mf._show_annotation_ref_source != null ) {
2463 mf._show_annotation_ref_source.setVisible( false );
2467 if ( isDrawPhylogram() || ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel()
2468 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2469 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) ) {
2470 if ( mf._non_lined_up_cladograms_rbmi != null ) {
2471 mf._non_lined_up_cladograms_rbmi.setVisible( false );
2473 if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
2474 mf._ext_node_dependent_cladogram_rbmi.setVisible( false );
2478 if ( mf._non_lined_up_cladograms_rbmi != null ) {
2479 mf._non_lined_up_cladograms_rbmi.setVisible( true );
2481 if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
2482 mf._ext_node_dependent_cladogram_rbmi.setVisible( true );
2485 if ( isDrawPhylogram() ) {
2486 if ( mf._show_scale_cbmi != null ) {
2487 mf._show_scale_cbmi.setVisible( true );
2491 if ( mf._show_scale_cbmi != null ) {
2492 mf._show_scale_cbmi.setVisible( false );
2495 if ( getCurrentTreePanel() != null ) {
2496 if ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2497 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
2498 if ( mf._label_direction_cbmi != null ) {
2499 mf._label_direction_cbmi.setVisible( true );
2503 if ( mf._label_direction_cbmi != null ) {
2504 mf._label_direction_cbmi.setVisible( false );
2511 void showAnnotations() {
2512 if ( _show_annotation != null ) {
2513 _show_annotation.setSelected( true );
2515 if ( _color_according_to_annotation != null ) {
2516 _color_according_to_annotation.setSelected( true );
2518 if ( _color_acc_species != null ) {
2519 _color_acc_species.setSelected( false );
2521 if ( _color_acc_sequence != null ) {
2522 _color_acc_sequence.setSelected( false );
2524 _mainpanel.getCurrentTreePanel().repaint();
2528 * Fit entire tree into window.
2531 if ( ( _mainpanel.getCurrentScrollPane() == null )
2532 || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
2535 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
2536 displayedPhylogenyMightHaveChanged( true );
2537 _mainpanel.getCurrentTreePanel().updateOvSettings();
2538 _mainpanel.getCurrentTreePanel().validate();
2539 _mainpanel.validate();
2540 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2541 _mainpanel.getSizeOfViewport().height );
2542 _mainpanel.getCurrentTreePanel().resetPreferredSize();
2543 _mainpanel.adjustJScrollPane();
2544 _mainpanel.getCurrentTreePanel().repaint();
2545 _mainpanel.getCurrentTreePanel().validate();
2546 _mainpanel.validate();
2547 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2548 _mainpanel.getSizeOfViewport().height );
2549 _mainpanel.getCurrentTreePanel().resetPreferredSize();
2550 _mainpanel.adjustJScrollPane();
2551 _mainpanel.getCurrentTreePanel().repaint();
2552 _mainpanel.getCurrentTreePanel().updateOvSizes();
2555 void showWholeAll() {
2556 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
2557 if ( tree_panel != null ) {
2558 tree_panel.validate();
2559 tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2560 _mainpanel.getSizeOfViewport().height );
2561 tree_panel.resetPreferredSize();
2562 tree_panel.repaint();
2567 // Create header for click-to combo box.
2568 void startClickToOptions() {
2569 final JLabel spacer = new JLabel( "" );
2570 spacer.setFont( ControlPanel.jcb_font );
2572 _click_to_label = new JLabel( "Click on Node to:" );
2573 add( customizeLabel( _click_to_label, getConfiguration() ) );
2574 _click_to_combobox = new JComboBox<String>();
2575 _click_to_combobox.setFocusable( false );
2576 _click_to_combobox.setMaximumRowCount( 14 );
2577 _click_to_combobox.setFont( ControlPanel.js_font );
2578 if ( !_configuration.isUseNativeUI() ) {
2579 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
2581 // don't add listener until all items are set (or each one will trigger
2583 // click_to_list.addActionListener(this);
2584 add( _click_to_combobox );
2585 // Correlates option names to titles
2586 _all_click_to_names = new HashMap<Integer, String>();
2587 _click_to_names = new ArrayList<String>();
2591 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
2592 if ( getCurrentTreePanel().isPhyHasBranchLengths()
2593 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
2594 setDrawPhylogramEnabled( true );
2596 setTreeDisplayType( getTreeDisplayType( getMainPanel().getCurrentTabIndex() ) );
2599 setDrawPhylogramEnabled( false );
2600 setTreeDisplayType( TreeDisplayType.CLADOGRAM );
2603 getMainPanel().getMainFrame()
2604 .setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel().getPhylogenyGraphicsType() );
2606 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
2607 getMainPanel().getCurrentTreePanel().updateButtonToUncollapseAll();
2608 getMainPanel().getControlPanel().search0();
2609 getMainPanel().getControlPanel().search1();
2610 getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
2611 getMainPanel().getControlPanel().updateDepthCollapseDepthDisplay();
2612 getMainPanel().getControlPanel().updateRankCollapseRankDisplay();
2613 getSequenceRelationTypeBox().removeAllItems();
2614 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
2615 .getRelevantSequenceRelationTypes() ) {
2616 _sequence_relation_type_box.addItem( type );
2618 getMainPanel().getCurrentTreePanel().repaint();
2619 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
2620 // according to GUILHEM the line above can be removed.
2625 * Uncollapse all nodes.
2627 final void uncollapseAll( final TreePanel tp ) {
2628 final Phylogeny t = tp.getPhylogeny();
2629 if ( ( t != null ) && !t.isEmpty() ) {
2630 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
2631 final PhylogenyNode node = iter.next();
2632 node.setCollapse( false );
2634 tp.resetNodeIdToDistToLeafMap();
2635 tp.updateSetOfCollapsedExternalNodes();
2636 t.recalculateNumberOfExternalDescendants( false );
2637 tp.setNodeInPreorderToNull();
2638 t.clearHashIdToNodeMap();
2639 tp.resetDepthCollapseDepthValue();
2640 tp.resetRankCollapseRankValue();
2645 final void updateDomainStructureEvaluethresholdDisplay() {
2646 if ( _domain_structure_evalue_thr_tf != null ) {
2647 _domain_structure_evalue_thr_tf
2648 .setText( "10^" + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThresholdExp() );
2652 private final String obtainDepthCollapseDepthValue() {
2653 if ( getMainPanel().getCurrentTreePanel() == null ) {
2656 final TreePanel tp = getMainPanel().getCurrentTreePanel();
2657 final Phylogeny p = tp.getPhylogeny();
2658 if ( ( p == null ) || ( p.getNumberOfExternalNodes() < 3 ) ) {
2661 else if ( tp.getDepthCollapseDepthValue() < 0 ) {
2662 tp.setDepthCollapseDepthValue( PhylogenyMethods.calculateMaxDepth( p ) );
2665 else if ( tp.getDepthCollapseDepthValue() == PhylogenyMethods.calculateMaxDepth( p ) ) {
2668 return String.valueOf( tp.getDepthCollapseDepthValue() );
2671 private final String obtainRankCollapseDepthValue() {
2672 if ( getMainPanel().getCurrentTreePanel() == null ) {
2675 final TreePanel tp = getMainPanel().getCurrentTreePanel();
2676 final Phylogeny p = tp.getPhylogeny();
2677 if ( ( p == null ) || ( p.getNumberOfExternalNodes() < 3 ) ) {
2681 final String ranks[] = PhylogenyMethods.obtainPresentRanksSorted( p );
2682 if ( ranks.length < 1 ) {
2685 else if ( tp.getRankCollapseRankValue() < 0 ) {
2686 tp.setRankCollapseRankValue( ranks.length - 1 );
2689 else if ( tp.getRankCollapseRankValue() == ( ranks.length - 1 ) ) {
2693 return String.valueOf( tp.getRankCollapseRankValue() );
2696 final void updateDepthCollapseDepthDisplay() {
2697 if ( _depth_collapse_depth_tf != null ) {
2698 _depth_collapse_depth_tf.setText( " " + obtainDepthCollapseDepthValue() );
2702 final void updateRankCollapseRankDisplay() {
2703 if ( _rank_collapse_depth_tf != null ) {
2704 final String r = obtainRankCollapseDepthValue();
2705 if ( r.equals( "off" ) ) {
2706 _rank_collapse_depth_tf.setText( " off" );
2707 _rank_collapse_depth_tf.setToolTipText( "the current taxonomic rank threshold" );
2710 final String ranks[] = PhylogenyMethods
2711 .obtainPresentRanksSorted( getMainPanel().getCurrentTreePanel().getPhylogeny() );
2712 final int rr = Integer.parseInt( r );
2713 _rank_collapse_depth_tf.setText( ranks[ rr ] );
2714 _rank_collapse_depth_tf.setToolTipText( ( rr + 1 ) + "/" + ( ranks.length - 1 ) + ": "
2715 + ranks[ Integer.parseInt( r ) ] );
2720 final void zoomInX( final float factor, final float x_correction_factor ) {
2721 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
2722 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2723 treepanel.multiplyUrtFactor( 1f );
2724 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2725 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
2726 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
2727 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
2728 final double x = ( sb.getMaximum() - sb.getMinimum() )
2729 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2730 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2731 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2732 getMainPanel().adjustJScrollPane();
2733 treepanel.resetPreferredSize();
2734 getMainPanel().getCurrentScrollPane().getViewport().validate();
2735 sb.setValue( ForesterUtil
2736 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2739 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
2740 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2741 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2742 getMainPanel().adjustJScrollPane();
2743 treepanel.resetPreferredSize();
2744 getMainPanel().getCurrentScrollPane().getViewport().validate();
2745 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
2747 treepanel.resetPreferredSize();
2748 treepanel.updateOvSizes();
2751 final void zoomInY( final float factor ) {
2752 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
2753 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2754 treepanel.multiplyUrtFactor( 1.1f );
2755 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2756 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
2757 getMainPanel().adjustJScrollPane();
2758 treepanel.resetPreferredSize();
2759 getMainPanel().getCurrentScrollPane().getViewport().validate();
2760 sb.setValue( ForesterUtil
2761 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2762 treepanel.resetPreferredSize();
2763 treepanel.updateOvSizes();
2766 final void zoomOutX( final float factor, final float x_correction_factor ) {
2767 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2768 treepanel.multiplyUrtFactor( 1f );
2769 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
2770 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
2771 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2772 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
2773 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
2774 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
2775 getMainPanel().adjustJScrollPane();
2776 treepanel.resetPreferredSize();
2777 getMainPanel().getCurrentScrollPane().getViewport().validate();
2778 final double x = ( sb.getMaximum() - sb.getMinimum() )
2779 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2780 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2781 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2782 getMainPanel().adjustJScrollPane();
2783 treepanel.resetPreferredSize();
2784 getMainPanel().getCurrentScrollPane().getViewport().validate();
2785 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
2786 - ( sb.getVisibleAmount() / 2.0 ) ) );
2789 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
2790 treepanel.setXdistance( treepanel.getXdistance() * factor );
2791 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
2793 getMainPanel().adjustJScrollPane();
2794 treepanel.resetPreferredSize();
2795 getMainPanel().getCurrentScrollPane().getViewport().validate();
2796 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
2799 treepanel.resetPreferredSize();
2800 treepanel.updateOvSizes();
2804 private final boolean isDrawPhylogram( int currentTabIndex ) {
2805 TreeDisplayType t = getTreeDisplayType( currentTabIndex );
2806 return ((t==TreeDisplayType.ALIGNED_PHYLOGRAM)|(t==TreeDisplayType.UNALIGNED_PHYLOGRAM));
2810 final void zoomOutY( final float factor ) {
2811 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2812 treepanel.multiplyUrtFactor( 0.9f );
2813 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
2814 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
2815 final double x = ( sb.getMaximum() - sb.getMinimum() )
2816 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2817 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
2818 getMainPanel().adjustJScrollPane();
2819 treepanel.resetPreferredSize();
2820 getMainPanel().getCurrentScrollPane().getViewport().validate();
2821 sb.setValue( ForesterUtil
2822 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2823 treepanel.resetPreferredSize();
2824 treepanel.updateOvSizes();
2828 final static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2829 label.setFont( ControlPanel.jcb_bold_font );
2830 if ( !configuration.isUseNativeUI() ) {
2831 label.setForeground( configuration.getGuiCheckboxTextColor() );
2832 label.setBackground( configuration.getGuiBackgroundColor() );
2837 final public JCheckBox getUseBranchWidthsCb() {
2838 return _width_branches;
2841 public TreeDisplayType getTreeDisplayType() {
2842 if (_display_as_unaligned_phylogram_rb.isSelected() ) {
2843 return TreeDisplayType.UNALIGNED_PHYLOGRAM;
2845 else if (_display_as_aligned_phylogram_rb.isSelected() ) {
2846 return TreeDisplayType.ALIGNED_PHYLOGRAM;
2848 return TreeDisplayType.CLADOGRAM;