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.ControlPanel.TreeDisplayType;
64 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
65 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
66 import org.forester.archaeopteryx.util.TypomaticJButton;
67 import org.forester.phylogeny.Phylogeny;
68 import org.forester.phylogeny.PhylogenyMethods;
69 import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
70 import org.forester.phylogeny.PhylogenyNode;
71 import org.forester.phylogeny.data.Sequence;
72 import org.forester.phylogeny.data.SequenceRelation;
73 import org.forester.phylogeny.data.SequenceRelation.SEQUENCE_RELATION_TYPE;
74 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
75 import org.forester.util.ForesterUtil;
78 final class ControlPanel extends JPanel implements ActionListener {
80 enum TreeDisplayType {
86 enum NodeClickAction {
93 DELETE_NODE_OR_SUBTREE,
111 final static Font jcb_bold_font = new Font( Configuration
112 .getDefaultFontFamilyName(), Font.BOLD, 9 );
113 final static Font jcb_font = new Font( Configuration
114 .getDefaultFontFamilyName(), Font.PLAIN, 9 );
115 final static Font js_font = new Font( Configuration
116 .getDefaultFontFamilyName(), Font.PLAIN, 9 );
117 private static final String RETURN_TO_SUPER_TREE_TEXT = "R";
118 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).";
119 private static final long serialVersionUID = -8463483932821545633L;
120 private NodeClickAction _action_when_node_clicked;
121 private int _add_new_node_item;
122 private Map<Integer, String> _all_click_to_names;
123 private Map<String, Color> _annotation_colors;
124 private int _blast_item;
125 private JComboBox<String> _click_to_combobox;
126 private JLabel _click_to_label;
127 private List<String> _click_to_names;
128 private int _collapse_cb_item;
129 private int _uncollapse_all_cb_item;
130 private int _order_subtree_cb_item;
131 private JCheckBox _color_acc_species;
132 private JCheckBox _color_acc_sequence;
133 private JCheckBox _color_according_to_annotation;
134 private boolean _color_branches;
135 private JCheckBox _use_visual_styles_cb;
136 private int _color_subtree_cb_item;
137 private int _change_node_font_item;
138 // The settings from the conf file
139 private final Configuration _configuration;
140 private int _copy_subtree_item;
141 private int _cut_subtree_item;
142 private JButton _decr_domain_structure_evalue_thr;
143 private int _delete_node_or_subtree_item;
144 private JRadioButton _display_as_unaligned_phylogram_rb;
145 private JRadioButton _display_as_aligned_phylogram_rb;
146 private JRadioButton _display_as_cladogram_rb;
147 private ButtonGroup _display_as_buttongroup;
149 private JCheckBox _display_internal_data;
150 private JLabel _domain_display_label;
151 private JTextField _domain_structure_evalue_thr_tf;
152 private JTextField _depth_collapse_depth_tf;
153 private JTextField _rank_collapse_depth_tf;
154 private List<TreeDisplayType> _tree_display_types;
155 private JCheckBox _dynamically_hide_data;
156 private int _edit_node_data_item;
157 private int _get_ext_desc_data;
158 private JButton _incr_domain_structure_evalue_thr;
159 private final MainPanel _mainpanel;
160 private JCheckBox _node_desc_popup_cb;
161 private int _open_pdb_item;
162 private int _open_seq_web_item;
163 private int _open_tax_web_item;
164 private int _color_node_font_item;
165 private JButton _order;
166 private int _paste_subtree_item;
167 private int _reroot_cb_item;
168 private JButton _return_to_super_tree;
170 private JLabel _search_found_label_0;
171 private JLabel _search_found_label_1;
172 private JButton _search_reset_button_0;
173 private JButton _search_reset_button_1;
174 private JTextField _search_tf_0;
175 private JTextField _search_tf_1;
176 private int _select_nodes_item;
177 private Sequence _selected_query_seq;
178 private JCheckBox _seq_relation_confidence_switch;
179 private JComboBox<SEQUENCE_RELATION_TYPE> _sequence_relation_type_box;
180 private JCheckBox _show_annotation;
181 private JCheckBox _show_binary_character_counts;
182 private JCheckBox _show_binary_characters;
183 // Indices for the click-to options in the combo box
184 private int _show_data_item;
185 private JCheckBox _show_domain_architectures;
186 private JCheckBox _show_mol_seqs;
187 private JCheckBox _write_branch_length_values;
188 private JCheckBox _show_events;
189 private JCheckBox _show_gene_names;
190 private JCheckBox _show_node_names;
191 private JCheckBox _show_properties_cb;
192 private JCheckBox _show_seq_names;
193 private JCheckBox _show_seq_symbols;
194 private JCheckBox _show_sequence_acc;
195 private JComboBox<String> _show_sequence_relations;
196 private JCheckBox _show_taxo_code;
197 private JCheckBox _show_taxo_rank;
198 private JCheckBox _show_taxo_common_names;
199 private JCheckBox _show_taxo_images_cb;
200 private JCheckBox _show_taxo_scientific_names;
201 private JCheckBox _show_vector_data_cb;
202 private JButton _show_whole;
203 private int _sort_descendents_item;
204 private Map<String, Color> _species_colors;
205 private Map<String, Color> _sequence_colors;
206 private int _subtree_cb_item;
207 private int _swap_cb_item;
208 private JButton _uncollapse_all;
209 private JCheckBox _width_branches;
210 private JCheckBox _write_confidence;
211 private JButton _zoom_in_domain_structure;
212 private JButton _zoom_in_x;
213 private JButton _zoom_in_y;
214 private JLabel _zoom_label;
215 private JButton _zoom_out_domain_structure;
216 private JButton _zoom_out_x;
217 private JButton _zoom_out_y;
218 private JButton _decr_depth_collapse_level;
219 private JButton _incr_depth_collapse_level;
220 private JLabel _depth_collapse_label;
221 private JButton _decr_rank_collapse_level;
222 private JButton _incr_rank_collapse_level;
223 private JLabel _rank_collapse_label;
225 ControlPanel( final MainPanel ap, final Configuration configuration ) {
228 _configuration = configuration;
229 if ( !_configuration.isUseNativeUI() ) {
230 setBackground( getConfiguration().getGuiBackgroundColor() );
231 setBorder( BorderFactory.createRaisedBevelBorder() );
233 setLayout( new GridLayout( 0, 1, 2, 2 ) );
241 public void actionPerformed( final ActionEvent e ) {
243 if ( e.getSource() == _color_acc_sequence ) {
244 if ( _color_acc_species != null ) {
245 _color_acc_species.setSelected( false );
248 else if ( e.getSource() == _color_acc_species ) {
249 if ( _color_acc_sequence != null ) {
250 _color_acc_sequence.setSelected( false );
253 final TreePanel tp = getMainPanel().getCurrentTreePanel();
257 if ( e.getSource() == _click_to_combobox ) {
258 setClickToAction( _click_to_combobox.getSelectedIndex() );
259 getCurrentTreePanel().repaint();
261 else if ( e.getSource() == _show_binary_characters ) {
262 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
263 _show_binary_character_counts.setSelected( false );
265 displayedPhylogenyMightHaveChanged( true );
267 else if ( e.getSource() == _show_binary_character_counts ) {
268 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
269 _show_binary_characters.setSelected( false );
271 displayedPhylogenyMightHaveChanged( true );
273 else if ( e.getSource() == _show_domain_architectures ) {
276 displayedPhylogenyMightHaveChanged( true );
278 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
279 if ( e.getSource() == getDisplayAsUnalignedPhylogramRb() ) {
280 setTreeDisplayType( TreeDisplayType.UNALIGNED_PHYLOGRAM );
283 if ( e.getSource() == getDisplayAsAlignedPhylogramRb() ) {
284 setTreeDisplayType( TreeDisplayType.ALIGNED_PHYLOGRAM );
287 if ( e.getSource() == getDisplayAsCladogramRb() ) {
288 setTreeDisplayType( TreeDisplayType.CLADOGRAM );
292 else if ( e.getSource() == _zoom_in_x ) {
293 zoomInX( AptxConstants.BUTTON_ZOOM_IN_FACTOR, AptxConstants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
294 displayedPhylogenyMightHaveChanged( false );
296 else if ( e.getSource() == _zoom_in_y ) {
297 zoomInY( AptxConstants.BUTTON_ZOOM_IN_FACTOR );
298 displayedPhylogenyMightHaveChanged( false );
300 else if ( e.getSource() == _zoom_out_x ) {
301 zoomOutX( AptxConstants.BUTTON_ZOOM_OUT_FACTOR, AptxConstants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
302 displayedPhylogenyMightHaveChanged( false );
304 else if ( e.getSource() == _zoom_out_y ) {
305 zoomOutY( AptxConstants.BUTTON_ZOOM_OUT_FACTOR );
306 displayedPhylogenyMightHaveChanged( false );
308 else if ( e.getSource() == _show_whole ) {
309 displayedPhylogenyMightHaveChanged( true );
312 else if ( e.getSource() == _return_to_super_tree ) {
313 returnedToSuperTreePressed();
315 else if ( e.getSource() == _order ) {
318 else if ( e.getSource() == _uncollapse_all ) {
320 displayedPhylogenyMightHaveChanged( false );
322 else if ( e.getSource() == _zoom_in_domain_structure ) {
323 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
324 displayedPhylogenyMightHaveChanged( true );
326 else if ( e.getSource() == _zoom_out_domain_structure ) {
327 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
328 displayedPhylogenyMightHaveChanged( true );
330 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
331 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThresholdExp();
334 displayedPhylogenyMightHaveChanged( true );
336 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
337 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThresholdExp();
340 displayedPhylogenyMightHaveChanged( true );
342 else if ( e.getSource() == _search_tf_0 ) {
344 displayedPhylogenyMightHaveChanged( true );
346 else if ( e.getSource() == _search_tf_1 ) {
348 displayedPhylogenyMightHaveChanged( true );
350 else if ( ( _dynamically_hide_data != null ) && ( e.getSource() == _dynamically_hide_data )
351 && !_dynamically_hide_data.isSelected() ) {
352 setDynamicHidingIsOn( false );
353 displayedPhylogenyMightHaveChanged( true );
355 else if ( ( e.getSource() == _decr_depth_collapse_level )
356 || ( e.getSource() == _incr_depth_collapse_level ) ) {
357 if ( e.getSource() == _decr_depth_collapse_level ) {
358 _mainpanel.getCurrentTreePanel().decreaseDepthCollapseLevel();
361 _mainpanel.getCurrentTreePanel().increaseDepthCollapseLevel();
365 _mainpanel.getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
366 _mainpanel.getCurrentTreePanel().getPhylogeny().recalculateNumberOfExternalDescendants( true );
367 _mainpanel.getCurrentTreePanel().resetNodeIdToDistToLeafMap();
368 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
369 _mainpanel.getCurrentTreePanel().setNodeInPreorderToNull();
370 displayedPhylogenyMightHaveChanged( true );
371 _mainpanel.getCurrentTreePanel().resetPreferredSize();
372 _mainpanel.getCurrentTreePanel().updateOvSizes();
373 _mainpanel.adjustJScrollPane();
377 else if ( ( e.getSource() == _decr_rank_collapse_level )
378 || ( e.getSource() == _incr_rank_collapse_level ) ) {
379 if ( e.getSource() == _decr_rank_collapse_level ) {
380 _mainpanel.getCurrentTreePanel().decreaseRankCollapseLevel();
383 _mainpanel.getCurrentTreePanel().increaseRankCollapseLevel();
387 _mainpanel.getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
388 _mainpanel.getCurrentTreePanel().getPhylogeny().recalculateNumberOfExternalDescendants( true );
389 _mainpanel.getCurrentTreePanel().resetNodeIdToDistToLeafMap();
390 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
391 _mainpanel.getCurrentTreePanel().setNodeInPreorderToNull();
392 displayedPhylogenyMightHaveChanged( true );
393 _mainpanel.getCurrentTreePanel().resetPreferredSize();
394 _mainpanel.getCurrentTreePanel().updateOvSizes();
395 _mainpanel.adjustJScrollPane();
400 displayedPhylogenyMightHaveChanged( true );
404 tp.requestFocusInWindow();
407 catch ( final Exception ex ) {
408 AptxUtil.unexpectedException( ex );
410 catch ( final Error err ) {
411 AptxUtil.unexpectedError( err );
415 void orderPressed( final TreePanel tp ) {
416 DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
417 if ( isShowTaxonomyScientificNames() || isShowTaxonomyCode() ) {
418 pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
420 else if ( isShowSeqNames() || isShowSeqSymbols() || isShowGeneNames() ) {
421 pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
423 PhylogenyMethods.orderAppearanceX( tp.getPhylogeny().getRoot(), true, pri );
424 tp.setNodeInPreorderToNull();
425 tp.getPhylogeny().externalNodesHaveChanged();
426 tp.getPhylogeny().clearHashIdToNodeMap();
427 tp.getPhylogeny().recalculateNumberOfExternalDescendants( true );
428 tp.resetNodeIdToDistToLeafMap();
429 tp.setEdited( true );
430 displayedPhylogenyMightHaveChanged( true );
433 void returnedToSuperTreePressed() {
434 if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
435 _mainpanel.getCurrentTreePanel().superTree();
440 public JCheckBox getColorAccSequenceCb() {
441 return _color_acc_sequence;
444 public JCheckBox getColorAccSpeciesCb() {
445 return _color_acc_species;
448 public JRadioButton getDisplayAsCladogramRb() {
449 return _display_as_cladogram_rb;
452 public JRadioButton getDisplayAsAlignedPhylogramRb() {
453 return _display_as_aligned_phylogram_rb;
456 public JRadioButton getDisplayAsUnalignedPhylogramRb() {
457 return _display_as_unaligned_phylogram_rb;
460 public JCheckBox getDynamicallyHideData() {
461 return _dynamically_hide_data;
464 public JCheckBox getNodeDescPopupCb() {
465 return _node_desc_popup_cb;
468 public Sequence getSelectedQuerySequence() {
469 return _selected_query_seq;
472 public JComboBox<String> getSequenceRelationBox() {
473 if ( _show_sequence_relations == null ) {
474 _show_sequence_relations = new JComboBox<String>();
475 _show_sequence_relations.setFocusable( false );
476 _show_sequence_relations.setMaximumRowCount( 20 );
477 _show_sequence_relations.setFont( ControlPanel.js_font );
478 if ( !_configuration.isUseNativeUI() ) {
479 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
480 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
482 _show_sequence_relations.addItem( "-----" );
483 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
485 return _show_sequence_relations;
489 public JComboBox<SEQUENCE_RELATION_TYPE> getSequenceRelationTypeBox() {
490 if ( _sequence_relation_type_box == null ) {
491 _sequence_relation_type_box = new JComboBox<SEQUENCE_RELATION_TYPE>();
492 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE
494 _sequence_relation_type_box.addItem( type );
496 _sequence_relation_type_box.addActionListener( new ActionListener() {
499 public void actionPerformed( final ActionEvent e ) {
500 if ( _mainpanel.getCurrentPhylogeny() != null ) {
501 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
506 return _sequence_relation_type_box;
509 public JCheckBox getShowEventsCb() {
513 public JCheckBox getUseVisualStylesCb() {
514 return _use_visual_styles_cb;
517 public JCheckBox getWriteConfidenceCb() {
518 return _write_confidence;
521 public boolean isShowMolSequences() {
522 return ( ( _show_mol_seqs != null ) && _show_mol_seqs.isSelected() );
525 public boolean isShowProperties() {
526 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
529 public boolean isShowTaxonomyImages() {
530 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
533 public boolean isShowVectorData() {
534 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
537 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
538 final JComboBox<String> box = getSequenceRelationBox();
539 while ( box.getItemCount() > 1 ) {
540 box.removeItemAt( 1 );
542 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
543 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
545 if ( relationType == null ) {
548 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
549 for( final Sequence seq : sequenceRelationQueries ) {
550 if ( seq.isHasSequenceRelations() ) {
551 boolean fFoundForCurrentType = false;
552 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
553 if ( sq.getType().equals( relationType ) ) {
554 fFoundForCurrentType = true;
558 if ( fFoundForCurrentType ) {
559 sequenceNamesToAdd.add( seq.getName() );
560 sequencesByName.put( seq.getName(), seq );
564 // sort sequences by name before adding them to the combo
565 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
566 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
567 for( final String seqName : sequenceNameArray ) {
568 box.addItem( seqName );
570 for( final ItemListener oldItemListener : box.getItemListeners() ) {
571 box.removeItemListener( oldItemListener );
573 box.addItemListener( new ItemListener() {
576 public void itemStateChanged( final ItemEvent e ) {
577 _selected_query_seq = sequencesByName.get( e.getItem() );
578 _mainpanel.getCurrentTreePanel().repaint();
583 private void addClickToOption( final int which, final String title ) {
584 _click_to_combobox.addItem( title );
585 _click_to_names.add( title );
586 _all_click_to_names.put( new Integer( which ), title );
587 if ( !_configuration.isUseNativeUI() ) {
588 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
589 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
594 private void addSequenceRelationBlock() {
595 final JLabel spacer = new JLabel( "" );
596 spacer.setSize( 1, 1 );
598 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
599 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
600 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
601 getSequenceRelationTypeBox().setFocusable( false );
602 _sequence_relation_type_box.setFont( ControlPanel.js_font );
603 if ( !_configuration.isUseNativeUI() ) {
604 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
605 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
607 _sequence_relation_type_box.setRenderer( new ListCellRenderer<Object>() {
610 public Component getListCellRendererComponent( final JList<?> list,
613 final boolean isSelected,
614 final boolean cellHasFocus ) {
615 final Component component = new DefaultListCellRenderer()
616 .getListCellRendererComponent( list, value, index, isSelected, cellHasFocus );
617 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
618 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
619 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
624 final GridBagLayout gbl = new GridBagLayout();
625 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
626 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
627 final JPanel horizGrid = new JPanel( gbl );
628 horizGrid.setBackground( getBackground() );
629 horizGrid.add( typeLabel );
630 horizGrid.add( _sequence_relation_type_box );
631 add( customizeLabel( mainLabel, getConfiguration() ) );
633 add( getSequenceRelationBox() );
634 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
635 addCheckbox( Configuration.show_relation_confidence,
636 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
637 setCheckbox( Configuration.show_relation_confidence,
638 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
640 }// addSequenceRelationBlock
643 private List<TreeDisplayType> getTreeDisplayTypes() {
644 return _tree_display_types;
647 // This takes care of ArchaeopteryxE-issue.
648 // Can, and will, return null prior to ArchaeopteryxE initialization completion.
649 final private MainFrame getMainFrame() {
650 MainFrame mf = getMainPanel().getMainFrame();
652 // Must be "E" applet version.
653 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
654 if ( e.getMainPanel() == null ) {
657 mf = e.getMainPanel().getMainFrame();
662 private void init() {
663 _tree_display_types = new ArrayList<TreeDisplayType>();
664 setSpeciesColors( new HashMap<String, Color>() );
665 setSequenceColors( new HashMap<String, Color>() );
666 setAnnotationColors( new HashMap<String, Color>() );
669 private TreeDisplayType getTreeDisplayType( final int index ) {
670 return getTreeDisplayTypes().get( index );
673 private void search0( final MainPanel main_panel, final Phylogeny tree, String query_str ) {
674 getSearchFoundCountsLabel0().setVisible( true );
675 getSearchResetButton0().setEnabled( true );
676 getSearchResetButton0().setVisible( true );
677 String[] queries = null;
678 Set<Long> nodes = null;
679 query_str = query_str.replaceAll( "\\s+", " " );
680 if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
681 queries = query_str.split( ",+" );
684 queries = new String[ 1 ];
685 queries[ 0 ] = query_str.trim();
687 if ( ( queries != null ) && ( queries.length > 0 ) ) {
688 nodes = new HashSet<Long>();
689 for( String query : queries ) {
690 if ( ForesterUtil.isEmpty( query ) ) {
693 query = query.trim();
694 final TreePanel tp = getMainPanel().getCurrentTreePanel();
695 if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
696 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
698 getOptions().isSearchCaseSensitive(),
699 !getOptions().isMatchWholeTermsOnly(),
700 isShowDomainArchitectures(),
703 tp.getDomainStructureEvalueThresholdExp() )
707 nodes.addAll( PhylogenyMethods
710 getOptions().isSearchCaseSensitive(),
711 !getOptions().isMatchWholeTermsOnly(),
712 getOptions().isSearchWithRegex(),
713 isShowDomainArchitectures(),
714 tp != null ? Math.pow( 10, tp.getDomainStructureEvalueThresholdExp() ) : 0 ) );
717 if ( getOptions().isInverseSearchResult() ) {
718 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
719 final Set<Long> temp_nodes = nodes;
720 nodes = new HashSet<Long>();
721 for( final PhylogenyNode n : all ) {
722 if ( ( !temp_nodes.contains( n.getId() ) ) && n.isHasNodeData() ) {
723 nodes.add( n.getId() );
728 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
729 main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet<Long>() );
730 for( final Long node : nodes ) {
731 main_panel.getCurrentTreePanel().getFoundNodes0().add( node );
733 setSearchFoundCountsOnLabel0( nodes.size() );
736 setSearchFoundCountsOnLabel0( 0 );
741 private void search1( final MainPanel main_panel, final Phylogeny tree, String query_str ) {
742 getSearchFoundCountsLabel1().setVisible( true );
743 getSearchResetButton1().setEnabled( true );
744 getSearchResetButton1().setVisible( true );
745 String[] queries = null;
746 Set<Long> nodes = null;
747 query_str = query_str.replaceAll( "\\s+", " " );
748 if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
749 queries = query_str.split( ",+" );
752 queries = new String[ 1 ];
753 queries[ 0 ] = query_str.trim();
755 if ( ( queries != null ) && ( queries.length > 0 ) ) {
756 nodes = new HashSet<Long>();
757 for( String query : queries ) {
758 if ( ForesterUtil.isEmpty( query ) ) {
761 query = query.trim();
762 final TreePanel tp = getMainPanel().getCurrentTreePanel();
763 if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
764 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
766 getOptions().isSearchCaseSensitive(),
767 !getOptions().isMatchWholeTermsOnly(),
768 isShowDomainArchitectures(),
771 tp.getDomainStructureEvalueThresholdExp() )
775 nodes.addAll( PhylogenyMethods
778 getOptions().isSearchCaseSensitive(),
779 !getOptions().isMatchWholeTermsOnly(),
780 getOptions().isSearchWithRegex(),
781 isShowDomainArchitectures(),
782 tp != null ? Math.pow( 10, tp.getDomainStructureEvalueThresholdExp() ) : 0 ) );
785 if ( getOptions().isInverseSearchResult() ) {
786 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
787 final Set<Long> temp_nodes = nodes;
788 nodes = new HashSet<Long>();
789 for( final PhylogenyNode n : all ) {
790 if ( ( !temp_nodes.contains( n.getId() ) ) && n.isHasNodeData() ) {
791 nodes.add( n.getId() );
796 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
797 main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet<Long>() );
798 for( final Long node : nodes ) {
799 main_panel.getCurrentTreePanel().getFoundNodes1().add( node );
801 setSearchFoundCountsOnLabel1( nodes.size() );
804 setSearchFoundCountsOnLabel1( 0 );
809 private void setTreeDisplayType( final int index, final TreeDisplayType t ) {
810 getTreeDisplayTypes().set( index, t );
813 private void setupClickToOptions() {
814 final int default_option = _configuration.getDefaultDisplayClicktoOption();
815 int selected_index = 0;
817 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
818 _show_data_item = cb_index;
819 addClickToOption( Configuration.display_node_data,
820 _configuration.getClickToTitle( Configuration.display_node_data ) );
821 if ( default_option == Configuration.display_node_data ) {
822 selected_index = cb_index;
826 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
827 _collapse_cb_item = cb_index;
828 addClickToOption( Configuration.collapse_uncollapse,
829 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
830 if ( default_option == Configuration.collapse_uncollapse ) {
831 selected_index = cb_index;
835 if ( _configuration.doDisplayClickToOption( Configuration.uncollapse_all ) ) {
836 _uncollapse_all_cb_item = cb_index;
837 addClickToOption( Configuration.uncollapse_all,
838 _configuration.getClickToTitle( Configuration.uncollapse_all ) );
839 if ( default_option == Configuration.uncollapse_all ) {
840 selected_index = cb_index;
844 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
845 _reroot_cb_item = cb_index;
846 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
847 if ( default_option == Configuration.reroot ) {
848 selected_index = cb_index;
852 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
853 _subtree_cb_item = cb_index;
854 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
855 if ( default_option == Configuration.subtree ) {
856 selected_index = cb_index;
860 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
861 _swap_cb_item = cb_index;
862 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
863 if ( default_option == Configuration.swap ) {
864 selected_index = cb_index;
868 if ( _configuration.doDisplayClickToOption( Configuration.order_subtree ) ) {
869 _order_subtree_cb_item = cb_index;
870 addClickToOption( Configuration.order_subtree,
871 _configuration.getClickToTitle( Configuration.order_subtree ) );
872 if ( default_option == Configuration.order_subtree ) {
873 selected_index = cb_index;
877 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
878 _sort_descendents_item = cb_index;
879 addClickToOption( Configuration.sort_descendents,
880 _configuration.getClickToTitle( Configuration.sort_descendents ) );
881 if ( default_option == Configuration.sort_descendents ) {
882 selected_index = cb_index;
886 if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) {
887 _color_node_font_item = cb_index;
888 addClickToOption( Configuration.color_node_font,
889 _configuration.getClickToTitle( Configuration.color_node_font ) );
890 if ( default_option == Configuration.color_node_font ) {
891 selected_index = cb_index;
895 if ( _configuration.doDisplayClickToOption( Configuration.change_node_font ) ) {
896 _change_node_font_item = cb_index;
897 addClickToOption( Configuration.change_node_font,
898 _configuration.getClickToTitle( Configuration.change_node_font ) );
899 if ( default_option == Configuration.change_node_font ) {
900 selected_index = cb_index;
904 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
905 _color_subtree_cb_item = cb_index;
906 addClickToOption( Configuration.color_subtree,
907 _configuration.getClickToTitle( Configuration.color_subtree ) );
908 if ( default_option == Configuration.color_subtree ) {
909 selected_index = cb_index;
913 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
914 _open_seq_web_item = cb_index;
915 addClickToOption( Configuration.open_seq_web,
916 _configuration.getClickToTitle( Configuration.open_seq_web ) );
917 if ( default_option == Configuration.open_seq_web ) {
918 selected_index = cb_index;
922 if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
923 _open_pdb_item = cb_index;
924 addClickToOption( Configuration.open_pdb_web,
925 _configuration.getClickToTitle( Configuration.open_pdb_web ) );
926 if ( default_option == Configuration.open_pdb_web ) {
927 selected_index = cb_index;
931 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
932 _open_tax_web_item = cb_index;
933 addClickToOption( Configuration.open_tax_web,
934 _configuration.getClickToTitle( Configuration.open_tax_web ) );
935 if ( default_option == Configuration.open_tax_web ) {
936 selected_index = cb_index;
940 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
941 _blast_item = cb_index;
942 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
943 if ( default_option == Configuration.blast ) {
944 selected_index = cb_index;
948 if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
949 _select_nodes_item = cb_index;
950 addClickToOption( Configuration.select_nodes,
951 _configuration.getClickToTitle( Configuration.select_nodes ) );
952 if ( default_option == Configuration.select_nodes ) {
953 selected_index = cb_index;
957 if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
958 _get_ext_desc_data = cb_index;
959 if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
960 addClickToOption( Configuration.get_ext_desc_data,
961 getConfiguration().getLabelForGetExtDescendentsData() );
964 addClickToOption( Configuration.get_ext_desc_data,
965 getConfiguration().getClickToTitle( Configuration.get_ext_desc_data ) );
967 if ( default_option == Configuration.get_ext_desc_data ) {
968 selected_index = cb_index;
972 if ( getOptions().isEditable() ) {
973 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
974 _cut_subtree_item = cb_index;
975 addClickToOption( Configuration.cut_subtree,
976 _configuration.getClickToTitle( Configuration.cut_subtree ) );
977 if ( default_option == Configuration.cut_subtree ) {
978 selected_index = cb_index;
982 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
983 _copy_subtree_item = cb_index;
984 addClickToOption( Configuration.copy_subtree,
985 _configuration.getClickToTitle( Configuration.copy_subtree ) );
986 if ( default_option == Configuration.copy_subtree ) {
987 selected_index = cb_index;
991 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
992 _paste_subtree_item = cb_index;
993 addClickToOption( Configuration.paste_subtree,
994 _configuration.getClickToTitle( Configuration.paste_subtree ) );
995 if ( default_option == Configuration.paste_subtree ) {
996 selected_index = cb_index;
1000 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
1001 _delete_node_or_subtree_item = cb_index;
1002 addClickToOption( Configuration.delete_subtree_or_node,
1003 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
1004 if ( default_option == Configuration.delete_subtree_or_node ) {
1005 selected_index = cb_index;
1009 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
1010 _add_new_node_item = cb_index;
1011 addClickToOption( Configuration.add_new_node,
1012 _configuration.getClickToTitle( Configuration.add_new_node ) );
1013 if ( default_option == Configuration.add_new_node ) {
1014 selected_index = cb_index;
1018 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
1019 _edit_node_data_item = cb_index;
1020 addClickToOption( Configuration.edit_node_data,
1021 _configuration.getClickToTitle( Configuration.edit_node_data ) );
1022 if ( default_option == Configuration.edit_node_data ) {
1023 selected_index = cb_index;
1028 // Set default selection and its action
1029 _click_to_combobox.setSelectedIndex( selected_index );
1030 setClickToAction( selected_index );
1033 private void setupDisplayCheckboxes() {
1035 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1036 addCheckbox( Configuration.dynamically_hide_data,
1037 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
1038 setCheckbox( Configuration.dynamically_hide_data,
1039 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
1041 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1042 addCheckbox( Configuration.node_data_popup,
1043 _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1044 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1046 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1047 addCheckbox( Configuration.display_internal_data,
1048 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
1049 setCheckbox( Configuration.display_internal_data,
1050 _configuration.doCheckOption( Configuration.display_internal_data ) );
1052 if ( _configuration.doDisplayOption( Configuration.color_according_to_sequence ) ) {
1053 addCheckbox( Configuration.color_according_to_sequence,
1054 _configuration.getDisplayTitle( Configuration.color_according_to_sequence ) );
1055 setCheckbox( Configuration.color_according_to_sequence,
1056 _configuration.doCheckOption( Configuration.color_according_to_sequence ) );
1058 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1059 addCheckbox( Configuration.color_according_to_species,
1060 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
1061 setCheckbox( Configuration.color_according_to_species,
1062 _configuration.doCheckOption( Configuration.color_according_to_species ) );
1064 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1065 addCheckbox( Configuration.color_according_to_annotation,
1066 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
1067 setCheckbox( Configuration.color_according_to_annotation,
1068 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
1070 if ( _configuration.doDisplayOption( Configuration.use_style ) ) {
1071 addCheckbox( Configuration.use_style, _configuration.getDisplayTitle( Configuration.use_style ) );
1072 setCheckbox( Configuration.use_style, _configuration.doCheckOption( Configuration.use_style ) );
1074 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1075 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1076 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1078 final JLabel label = new JLabel( "Display Data:" );
1079 label.setFont( ControlPanel.jcb_bold_font );
1080 if ( !getConfiguration().isUseNativeUI() ) {
1081 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1084 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1085 addCheckbox( Configuration.show_node_names,
1086 _configuration.getDisplayTitle( Configuration.show_node_names ) );
1087 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1089 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1090 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1091 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1093 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1094 addCheckbox( Configuration.show_taxonomy_scientific_names,
1095 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1096 setCheckbox( Configuration.show_taxonomy_scientific_names,
1097 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1099 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1100 addCheckbox( Configuration.show_taxonomy_common_names,
1101 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1102 setCheckbox( Configuration.show_taxonomy_common_names,
1103 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1105 if ( _configuration.doDisplayOption( Configuration.show_tax_rank ) ) {
1106 addCheckbox( Configuration.show_tax_rank, _configuration.getDisplayTitle( Configuration.show_tax_rank ) );
1107 setCheckbox( Configuration.show_tax_rank, _configuration.doCheckOption( Configuration.show_tax_rank ) );
1109 if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
1110 addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
1111 setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
1113 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1114 addCheckbox( Configuration.show_gene_names,
1115 _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1116 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1118 if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
1119 addCheckbox( Configuration.show_seq_symbols,
1120 _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
1121 setCheckbox( Configuration.show_seq_symbols,
1122 _configuration.doCheckOption( Configuration.show_seq_symbols ) );
1124 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1125 addCheckbox( Configuration.show_sequence_acc,
1126 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1127 setCheckbox( Configuration.show_sequence_acc,
1128 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1130 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1131 addCheckbox( Configuration.show_annotation,
1132 _configuration.getDisplayTitle( Configuration.show_annotation ) );
1133 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1135 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1136 addCheckbox( Configuration.write_confidence_values,
1137 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1138 setCheckbox( Configuration.write_confidence_values,
1139 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1141 if ( _configuration.doDisplayOption( Configuration.write_branch_length_values ) ) {
1142 addCheckbox( Configuration.write_branch_length_values,
1143 _configuration.getDisplayTitle( Configuration.write_branch_length_values ) );
1144 setCheckbox( Configuration.write_branch_length_values,
1145 _configuration.doCheckOption( Configuration.write_branch_length_values ) );
1147 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1148 addCheckbox( Configuration.show_binary_characters,
1149 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1150 setCheckbox( Configuration.show_binary_characters,
1151 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1153 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1154 addCheckbox( Configuration.show_binary_character_counts,
1155 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1156 setCheckbox( Configuration.show_binary_character_counts,
1157 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1159 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1160 addCheckbox( Configuration.show_domain_architectures,
1161 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1162 setCheckbox( Configuration.show_domain_architectures,
1163 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1165 if ( _configuration.doDisplayOption( Configuration.show_mol_seqs ) ) {
1166 addCheckbox( Configuration.show_mol_seqs, _configuration.getDisplayTitle( Configuration.show_mol_seqs ) );
1167 setCheckbox( Configuration.show_mol_seqs, _configuration.doCheckOption( Configuration.show_mol_seqs ) );
1169 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1170 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1171 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1173 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1174 addCheckbox( Configuration.show_vector_data,
1175 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1176 setCheckbox( Configuration.show_vector_data,
1177 _configuration.doCheckOption( Configuration.show_vector_data ) );
1179 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1180 addCheckbox( Configuration.show_properties,
1181 _configuration.getDisplayTitle( Configuration.show_properties ) );
1182 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1184 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1185 addCheckbox( Configuration.show_taxonomy_images,
1186 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1187 setCheckbox( Configuration.show_taxonomy_images,
1188 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1192 private void setVisibilityOfDomainStrucureControls() {
1193 if ( _zoom_in_domain_structure != null ) {
1194 final MainFrame mf = getMainFrame();
1196 if ( isShowDomainArchitectures() ) {
1197 _domain_display_label.setVisible( true );
1198 _zoom_in_domain_structure.setVisible( true );
1199 _zoom_out_domain_structure.setVisible( true );
1200 _decr_domain_structure_evalue_thr.setVisible( true );
1201 _incr_domain_structure_evalue_thr.setVisible( true );
1202 _domain_structure_evalue_thr_tf.setVisible( true );
1203 if ( mf._right_line_up_domains_cbmi != null ) {
1204 mf._right_line_up_domains_cbmi.setVisible( true );
1206 if ( mf._show_domain_labels != null ) {
1207 mf._show_domain_labels.setVisible( true );
1211 _domain_display_label.setVisible( false );
1212 _zoom_in_domain_structure.setVisible( false );
1213 _zoom_out_domain_structure.setVisible( false );
1214 _decr_domain_structure_evalue_thr.setVisible( false );
1215 _incr_domain_structure_evalue_thr.setVisible( false );
1216 _domain_structure_evalue_thr_tf.setVisible( false );
1217 if ( mf._right_line_up_domains_cbmi != null ) {
1218 mf._right_line_up_domains_cbmi.setVisible( false );
1220 if ( mf._show_domain_labels != null ) {
1221 mf._show_domain_labels.setVisible( false );
1228 void activateButtonToReturnToSuperTree( int index ) {
1231 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
1234 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
1236 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1237 _return_to_super_tree.setEnabled( true );
1240 void activateButtonToUncollapseAll() {
1241 _uncollapse_all.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1242 _uncollapse_all.setEnabled( true );
1246 * Add zoom and quick edit buttons. (Last modified 8/9/04)
1249 final JLabel spacer = new JLabel( "" );
1250 spacer.setOpaque( false );
1252 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
1253 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1254 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
1255 final JPanel o_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1256 if ( !getConfiguration().isUseNativeUI() ) {
1257 x_panel.setBackground( getBackground() );
1258 y_panel.setBackground( getBackground() );
1259 z_panel.setBackground( getBackground() );
1260 o_panel.setBackground( getBackground() );
1262 add( _zoom_label = new JLabel( "Zoom:" ) );
1263 customizeLabel( _zoom_label, getConfiguration() );
1267 if ( getConfiguration().isUseNativeUI() ) {
1268 _zoom_in_x = new TypomaticJButton( "+" );
1269 _zoom_out_x = new TypomaticJButton( "-" );
1272 _zoom_in_x = new TypomaticJButton( "X+" );
1273 _zoom_out_x = new TypomaticJButton( "X-" );
1275 _zoom_in_y = new TypomaticJButton( "Y+" );
1276 _zoom_out_y = new TypomaticJButton( "Y-" );
1277 _show_whole = new JButton( "F" );
1278 _show_whole.setToolTipText( "fit and center to display [Alt+C or Home]" );
1279 _zoom_in_x.setToolTipText( "zoom in horizontally [Alt+Right or Shift+Alt+mousewheel]" );
1280 _zoom_in_y.setToolTipText( "zoom in vertically [Alt+Up or Shift+mousewheel]" );
1281 _zoom_out_x.setToolTipText( "zoom out horizontally [Alt+Left or Shift+Alt+mousewheel]" );
1282 _zoom_out_y.setToolTipText( "zoom out vertically [Alt+Down or Shift+mousewheel]" );
1283 if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) {
1284 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
1285 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
1288 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
1289 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
1291 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
1292 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
1293 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
1294 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
1295 _return_to_super_tree.setToolTipText( "return to the super-tree (if in sub-tree) [Alt+R]" );
1296 _return_to_super_tree.setEnabled( false );
1297 _order = new JButton( "O" );
1298 _order.setToolTipText( "order all [Alt+O]" );
1299 _uncollapse_all = new JButton( "U" );
1300 _uncollapse_all.setToolTipText( "uncollapse all [Alt+U]" );
1301 addJButton( _zoom_in_y, x_panel );
1302 addJButton( _zoom_out_x, y_panel );
1303 addJButton( _show_whole, y_panel );
1304 addJButton( _zoom_in_x, y_panel );
1305 addJButton( _zoom_out_y, z_panel );
1306 final JLabel spacer2 = new JLabel( "" );
1309 addJButton( _order, o_panel );
1310 addJButton( _return_to_super_tree, o_panel );
1311 addJButton( _uncollapse_all, o_panel );
1312 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
1313 setUpControlsForDomainStrucures();
1316 setUpControlsForDepthCollapse();
1319 setUpControlsForRankCollapse();
1321 final JLabel spacer3 = new JLabel( "" );
1323 setVisibilityOfDomainStrucureControls();
1326 void addCheckbox( final int which, final String title ) {
1327 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
1329 case Configuration.display_internal_data:
1330 _display_internal_data = new JCheckBox( title );
1331 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
1332 addJCheckBox( _display_internal_data, ch_panel );
1335 case Configuration.color_according_to_species:
1336 _color_acc_species = new JCheckBox( title );
1337 _color_acc_species.setToolTipText( "To colorize node labels as a function of taxonomy" );
1338 addJCheckBox( _color_acc_species, ch_panel );
1341 case Configuration.color_according_to_sequence:
1342 _color_acc_sequence = new JCheckBox( title );
1343 _color_acc_sequence.setToolTipText( "To colorize node labels as a function of sequence name" );
1344 addJCheckBox( _color_acc_sequence, ch_panel );
1347 case Configuration.color_according_to_annotation:
1348 _color_according_to_annotation = new JCheckBox( title );
1349 _color_according_to_annotation
1350 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
1351 addJCheckBox( _color_according_to_annotation, ch_panel );
1354 case Configuration.show_node_names:
1355 _show_node_names = new JCheckBox( title );
1356 addJCheckBox( _show_node_names, ch_panel );
1359 case Configuration.show_taxonomy_scientific_names:
1360 _show_taxo_scientific_names = new JCheckBox( title );
1361 addJCheckBox( _show_taxo_scientific_names, ch_panel );
1364 case Configuration.show_taxonomy_common_names:
1365 _show_taxo_common_names = new JCheckBox( title );
1366 addJCheckBox( _show_taxo_common_names, ch_panel );
1369 case Configuration.show_tax_code:
1370 _show_taxo_code = new JCheckBox( title );
1371 addJCheckBox( _show_taxo_code, ch_panel );
1374 case Configuration.show_tax_rank:
1375 _show_taxo_rank = new JCheckBox( title );
1376 addJCheckBox( _show_taxo_rank, ch_panel );
1379 case Configuration.show_taxonomy_images:
1380 _show_taxo_images_cb = new JCheckBox( title );
1381 addJCheckBox( _show_taxo_images_cb, ch_panel );
1384 case Configuration.show_binary_characters:
1385 _show_binary_characters = new JCheckBox( title );
1386 addJCheckBox( _show_binary_characters, ch_panel );
1389 case Configuration.show_annotation:
1390 _show_annotation = new JCheckBox( title );
1391 addJCheckBox( _show_annotation, ch_panel );
1394 case Configuration.show_binary_character_counts:
1395 _show_binary_character_counts = new JCheckBox( title );
1396 addJCheckBox( _show_binary_character_counts, ch_panel );
1399 case Configuration.write_confidence_values:
1400 _write_confidence = new JCheckBox( title );
1401 addJCheckBox( getWriteConfidenceCb(), ch_panel );
1404 case Configuration.write_events:
1405 _show_events = new JCheckBox( title );
1406 addJCheckBox( getShowEventsCb(), ch_panel );
1409 case Configuration.use_style:
1410 _use_visual_styles_cb = new JCheckBox( title );
1411 getUseVisualStylesCb()
1412 .setToolTipText( "To use visual styles (node colors, fonts) and branch colors, if present" );
1413 addJCheckBox( getUseVisualStylesCb(), ch_panel );
1416 case Configuration.width_branches:
1417 _width_branches = new JCheckBox( title );
1418 _width_branches.setToolTipText( "To use branch width values, if present" );
1419 addJCheckBox( _width_branches, ch_panel );
1422 case Configuration.write_branch_length_values:
1423 _write_branch_length_values = new JCheckBox( title );
1424 addJCheckBox( _write_branch_length_values, ch_panel );
1427 case Configuration.show_domain_architectures:
1428 _show_domain_architectures = new JCheckBox( title );
1429 addJCheckBox( _show_domain_architectures, ch_panel );
1432 case Configuration.show_mol_seqs:
1433 _show_mol_seqs = new JCheckBox( title );
1434 addJCheckBox( _show_mol_seqs, ch_panel );
1437 case Configuration.show_seq_names:
1438 _show_seq_names = new JCheckBox( title );
1439 addJCheckBox( _show_seq_names, ch_panel );
1442 case Configuration.show_gene_names:
1443 _show_gene_names = new JCheckBox( title );
1444 addJCheckBox( _show_gene_names, ch_panel );
1447 case Configuration.show_seq_symbols:
1448 _show_seq_symbols = new JCheckBox( title );
1449 addJCheckBox( _show_seq_symbols, ch_panel );
1452 case Configuration.show_sequence_acc:
1453 _show_sequence_acc = new JCheckBox( title );
1454 addJCheckBox( _show_sequence_acc, ch_panel );
1457 case Configuration.dynamically_hide_data:
1458 _dynamically_hide_data = new JCheckBox( title );
1459 getDynamicallyHideData().setToolTipText( "To hide labels depending on expected visibility" );
1460 addJCheckBox( getDynamicallyHideData(), ch_panel );
1463 case Configuration.node_data_popup:
1464 _node_desc_popup_cb = new JCheckBox( title );
1465 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
1466 addJCheckBox( getNodeDescPopupCb(), ch_panel );
1469 case Configuration.show_relation_confidence:
1470 _seq_relation_confidence_switch = new JCheckBox( title );
1471 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
1474 case Configuration.show_vector_data:
1475 _show_vector_data_cb = new JCheckBox( title );
1476 addJCheckBox( _show_vector_data_cb, ch_panel );
1479 case Configuration.show_properties:
1480 _show_properties_cb = new JCheckBox( title );
1481 addJCheckBox( _show_properties_cb, ch_panel );
1485 throw new RuntimeException( "unknown checkbox: " + which );
1489 void addJButton( final JButton jb, final JPanel p ) {
1490 jb.setFocusPainted( false );
1491 jb.setFont( ControlPanel.jcb_font );
1492 if ( !_configuration.isUseNativeUI() ) {
1493 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
1494 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1495 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
1498 jb.addActionListener( this );
1501 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
1502 jcb.setFocusPainted( false );
1503 jcb.setFont( ControlPanel.jcb_font );
1504 if ( !_configuration.isUseNativeUI() ) {
1505 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
1506 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1508 p.add( jcb, "Center" );
1509 jcb.addActionListener( this );
1512 private final void setupJRadioButton( final JRadioButton rb ) {
1513 rb.setFocusPainted( false );
1514 rb.setFont( ControlPanel.jcb_font );
1515 if ( !_configuration.isUseNativeUI() ) {
1516 rb.setBackground( getConfiguration().getGuiBackgroundColor() );
1517 rb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1519 rb.addActionListener( this );
1522 void addJTextField( final JTextField tf, final JPanel p ) {
1523 if ( !_configuration.isUseNativeUI() ) {
1524 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
1525 tf.setFont( ControlPanel.jcb_font );
1528 tf.addActionListener( this );
1531 void deactivateButtonToReturnToSuperTree() {
1532 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
1533 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
1534 _return_to_super_tree.setEnabled( false );
1537 void deactivateButtonToUncollapseAll() {
1538 _uncollapse_all.setForeground( getConfiguration().getGuiButtonTextColor() );
1539 _uncollapse_all.setEnabled( false );
1542 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
1543 if ( ( _mainpanel != null )
1544 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
1545 if ( recalc_longest_ext_node_info ) {
1546 _mainpanel.getCurrentTreePanel().initNodeData();
1547 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
1549 if ( getOptions().isShowOverview() ) {
1550 _mainpanel.getCurrentTreePanel().updateOvSizes();
1552 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
1553 setVisibilityOfDomainStrucureControls();
1554 updateDomainStructureEvaluethresholdDisplay();
1555 updateDepthCollapseDepthDisplay();
1556 updateRankCollapseRankDisplay();
1557 getMainPanel().getControlPanel();
1558 _mainpanel.getCurrentTreePanel().updateButtonToUncollapseAll();
1559 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
1560 _mainpanel.getCurrentTreePanel().calcMaxDepth();
1561 _mainpanel.adjustJScrollPane();
1562 _mainpanel.getCurrentTreePanel().repaint();
1563 // _mainpanel.getCurrentTreePanel().setUpUrtFactor();
1567 void endClickToOptions() {
1568 _click_to_combobox.addActionListener( this );
1572 * Indicates what action should be execute when a node is clicked
1574 * @return the click-on action
1576 NodeClickAction getActionWhenNodeClicked() {
1577 return _action_when_node_clicked;
1580 Map<Integer, String> getAllClickToItems() {
1581 return _all_click_to_names;
1584 Map<String, Color> getAnnotationColors() {
1585 return _annotation_colors;
1588 Configuration getConfiguration() {
1589 return _configuration;
1592 TreePanel getCurrentTreePanel() {
1593 return getMainPanel().getCurrentTreePanel();
1596 MainPanel getMainPanel() {
1600 Options getOptions() {
1601 return getMainPanel().getOptions();
1604 JLabel getSearchFoundCountsLabel0() {
1605 return _search_found_label_0;
1608 JLabel getSearchFoundCountsLabel1() {
1609 return _search_found_label_1;
1612 JButton getSearchResetButton0() {
1613 return _search_reset_button_0;
1616 JButton getSearchResetButton1() {
1617 return _search_reset_button_1;
1620 JTextField getSearchTextField0() {
1621 return _search_tf_0;
1624 JTextField getSearchTextField1() {
1625 return _search_tf_1;
1628 Map<String, Color> getSequenceColors() {
1629 return _sequence_colors;
1632 List<String> getSingleClickToNames() {
1633 return _click_to_names;
1636 Map<String, Color> getSpeciesColors() {
1637 return _species_colors;
1640 boolean isAntialiasScreenText() {
1644 boolean isColorAccordingToAnnotation() {
1645 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
1648 boolean isColorAccordingToSequence() {
1649 return ( ( _color_acc_sequence != null ) && _color_acc_sequence.isSelected() );
1652 boolean isColorAccordingToTaxonomy() {
1653 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
1656 boolean isDrawPhylogram() {
1657 final TreeDisplayType t = getTreeDisplayType( getMainPanel().getCurrentTabIndex() );
1658 return ((t == TreeDisplayType.ALIGNED_PHYLOGRAM) ||( t == TreeDisplayType.UNALIGNED_PHYLOGRAM));
1661 boolean isDynamicallyHideData() {
1662 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
1665 boolean isEvents() {
1666 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
1669 boolean isNodeDescPopup() {
1670 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
1673 boolean isShowAnnotation() {
1674 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
1677 boolean isShowBinaryCharacterCounts() {
1678 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
1681 boolean isShowBinaryCharacters() {
1682 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
1685 boolean isShowConfidenceValues() {
1686 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
1689 boolean isShowDomainArchitectures() {
1690 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
1693 boolean isShowGeneNames() {
1694 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
1697 boolean isShowInternalData() {
1698 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
1701 boolean isShowNodeNames() {
1702 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
1705 boolean isShowSeqNames() {
1706 return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
1709 boolean isShowSeqSymbols() {
1710 return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
1713 boolean isShowSequenceAcc() {
1714 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
1717 boolean isShowSequenceRelationConfidence() {
1718 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
1721 boolean isShowSequenceRelations() {
1722 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
1725 boolean isShowTaxonomyCode() {
1726 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
1729 boolean isShowTaxonomyRank() {
1730 return ( ( _show_taxo_rank != null ) && _show_taxo_rank.isSelected() );
1733 boolean isShowTaxonomyCommonNames() {
1734 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
1737 boolean isShowTaxonomyScientificNames() {
1738 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
1741 boolean isUseVisualStyles() {
1742 return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() )
1743 || ( ( getUseVisualStylesCb() == null ) && _color_branches ) );
1746 boolean isWidthBranches() {
1747 return ( ( _width_branches != null ) && _width_branches.isSelected() );
1750 boolean isWriteBranchLengthValues() {
1751 return ( ( _write_branch_length_values != null ) && _write_branch_length_values.isSelected() );
1754 void phylogenyAdded( final Configuration configuration ) {
1755 if (configuration.isDrawAsPhylogram()) {
1756 getTreeDisplayTypes().add( TreeDisplayType.UNALIGNED_PHYLOGRAM);
1759 getTreeDisplayTypes().add( TreeDisplayType.CLADOGRAM);
1763 void phylogenyRemoved( final int index ) {
1764 getTreeDisplayTypes().remove( index );
1768 final MainPanel main_panel = getMainPanel();
1769 final Phylogeny tree = main_panel.getCurrentPhylogeny();
1770 if ( ( tree == null ) || tree.isEmpty() ) {
1773 String query = getSearchTextField0().getText();
1774 if ( query != null ) {
1775 query = query.trim();
1777 if ( !ForesterUtil.isEmpty( query ) ) {
1778 search0( main_panel, tree, query );
1781 getSearchFoundCountsLabel0().setVisible( false );
1782 getSearchResetButton0().setEnabled( false );
1783 getSearchResetButton0().setVisible( false );
1789 final MainPanel main_panel = getMainPanel();
1790 final Phylogeny tree = main_panel.getCurrentPhylogeny();
1791 if ( ( tree == null ) || tree.isEmpty() ) {
1794 String query = getSearchTextField1().getText();
1795 if ( query != null ) {
1796 query = query.trim();
1798 if ( !ForesterUtil.isEmpty( query ) ) {
1799 search1( main_panel, tree, query );
1802 getSearchFoundCountsLabel1().setVisible( false );
1803 getSearchResetButton1().setEnabled( false );
1804 getSearchResetButton1().setVisible( false );
1809 void searchReset0() {
1810 if ( getMainPanel().getCurrentTreePanel() != null ) {
1811 getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
1815 void searchReset1() {
1816 if ( getMainPanel().getCurrentTreePanel() != null ) {
1817 getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
1821 void setActionWhenNodeClicked( final NodeClickAction action ) {
1822 _action_when_node_clicked = action;
1825 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
1826 _annotation_colors = annotation_colors;
1829 void setCheckbox( final int which, final boolean state ) {
1831 case Configuration.display_as_phylogram:
1832 if ( getDisplayAsUnalignedPhylogramRb() != null ) {
1833 getDisplayAsUnalignedPhylogramRb().setSelected( state );
1834 getDisplayAsAlignedPhylogramRb().setSelected( !state );
1835 getDisplayAsCladogramRb().setSelected( !state );
1838 case Configuration.display_internal_data:
1839 if ( _display_internal_data != null ) {
1840 _display_internal_data.setSelected( state );
1843 case Configuration.color_according_to_species:
1844 if ( _color_acc_species != null ) {
1845 _color_acc_species.setSelected( state );
1848 case Configuration.color_according_to_sequence:
1849 if ( _color_acc_sequence != null ) {
1850 _color_acc_sequence.setSelected( state );
1853 case Configuration.color_according_to_annotation:
1854 if ( _color_according_to_annotation != null ) {
1855 _color_according_to_annotation.setSelected( state );
1858 case Configuration.show_node_names:
1859 if ( _show_node_names != null ) {
1860 _show_node_names.setSelected( state );
1863 case Configuration.show_taxonomy_scientific_names:
1864 if ( _show_taxo_scientific_names != null ) {
1865 _show_taxo_scientific_names.setSelected( state );
1868 case Configuration.show_taxonomy_common_names:
1869 if ( _show_taxo_common_names != null ) {
1870 _show_taxo_common_names.setSelected( state );
1873 case Configuration.show_tax_code:
1874 if ( _show_taxo_code != null ) {
1875 _show_taxo_code.setSelected( state );
1878 case Configuration.show_tax_rank:
1879 if ( _show_taxo_rank != null ) {
1880 _show_taxo_rank.setSelected( state );
1883 case Configuration.show_taxonomy_images:
1884 if ( _show_taxo_images_cb != null ) {
1885 _show_taxo_images_cb.setSelected( state );
1888 case Configuration.show_annotation:
1889 if ( _show_annotation != null ) {
1890 _show_annotation.setSelected( state );
1893 case Configuration.show_binary_characters:
1894 if ( _show_binary_characters != null ) {
1895 _show_binary_characters.setSelected( state );
1898 case Configuration.show_binary_character_counts:
1899 if ( _show_binary_character_counts != null ) {
1900 _show_binary_character_counts.setSelected( state );
1903 case Configuration.write_confidence_values:
1904 if ( getWriteConfidenceCb() != null ) {
1905 getWriteConfidenceCb().setSelected( state );
1908 case Configuration.write_events:
1909 if ( getShowEventsCb() != null ) {
1910 getShowEventsCb().setSelected( state );
1913 case Configuration.use_style:
1914 if ( getUseVisualStylesCb() != null ) {
1915 getUseVisualStylesCb().setSelected( state );
1918 case Configuration.width_branches:
1919 if ( _width_branches != null ) {
1920 _width_branches.setSelected( state );
1923 case Configuration.show_domain_architectures:
1924 if ( _show_domain_architectures != null ) {
1925 _show_domain_architectures.setSelected( state );
1928 case Configuration.write_branch_length_values:
1929 if ( _write_branch_length_values != null ) {
1930 _write_branch_length_values.setSelected( state );
1933 case Configuration.show_mol_seqs:
1934 if ( _show_mol_seqs != null ) {
1935 _show_mol_seqs.setSelected( state );
1938 case Configuration.show_seq_names:
1939 if ( _show_seq_names != null ) {
1940 _show_seq_names.setSelected( state );
1943 case Configuration.show_gene_names:
1944 if ( _show_gene_names != null ) {
1945 _show_gene_names.setSelected( state );
1948 case Configuration.show_seq_symbols:
1949 if ( _show_seq_symbols != null ) {
1950 _show_seq_symbols.setSelected( state );
1953 case Configuration.show_vector_data:
1954 if ( _show_vector_data_cb != null ) {
1955 _show_vector_data_cb.setSelected( state );
1958 case Configuration.show_properties:
1959 if ( _show_properties_cb != null ) {
1960 _show_properties_cb.setSelected( state );
1963 case Configuration.show_sequence_acc:
1964 if ( _show_sequence_acc != null ) {
1965 _show_sequence_acc.setSelected( state );
1968 case Configuration.dynamically_hide_data:
1969 if ( getDynamicallyHideData() != null ) {
1970 getDynamicallyHideData().setSelected( state );
1973 case Configuration.node_data_popup:
1974 if ( getNodeDescPopupCb() != null ) {
1975 getNodeDescPopupCb().setSelected( state );
1979 case Configuration.show_relation_confidence:
1980 if ( _seq_relation_confidence_switch != null ) {
1981 _seq_relation_confidence_switch.setSelected( state );
1986 throw new AssertionError( "unknown checkbox: " + which );
1991 * Set this checkbox state. Not all checkboxes have been instantiated
1992 * depending on the config.
1994 void setCheckbox( final JCheckBox cb, final boolean state ) {
1996 cb.setSelected( state );
2000 void setClickToAction( final int action ) {
2001 // Set click-to action
2002 if ( action == _show_data_item ) {
2003 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
2005 else if ( action == _collapse_cb_item ) {
2006 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
2008 else if ( action == _reroot_cb_item ) {
2009 setActionWhenNodeClicked( NodeClickAction.REROOT );
2011 else if ( action == _subtree_cb_item ) {
2012 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
2014 else if ( action == _swap_cb_item ) {
2015 setActionWhenNodeClicked( NodeClickAction.SWAP );
2017 else if ( action == _color_subtree_cb_item ) {
2018 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
2020 else if ( action == _open_seq_web_item ) {
2021 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
2023 else if ( action == _sort_descendents_item ) {
2024 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
2026 else if ( action == _blast_item ) {
2027 setActionWhenNodeClicked( NodeClickAction.BLAST );
2029 else if ( action == _open_tax_web_item ) {
2030 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
2032 else if ( action == _cut_subtree_item ) {
2033 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
2035 else if ( action == _copy_subtree_item ) {
2036 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
2038 else if ( action == _delete_node_or_subtree_item ) {
2039 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
2041 else if ( action == _paste_subtree_item ) {
2042 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
2044 else if ( action == _add_new_node_item ) {
2045 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
2047 else if ( action == _edit_node_data_item ) {
2048 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
2050 else if ( action == _select_nodes_item ) {
2051 setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
2053 else if ( action == _get_ext_desc_data ) {
2054 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
2056 else if ( action == _open_pdb_item ) {
2057 setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
2059 else if ( action == _color_node_font_item ) {
2060 setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
2062 else if ( action == _change_node_font_item ) {
2063 setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT );
2065 else if ( action == _uncollapse_all_cb_item ) {
2066 setActionWhenNodeClicked( NodeClickAction.UNCOLLAPSE_ALL );
2068 else if ( action == _order_subtree_cb_item ) {
2069 setActionWhenNodeClicked( NodeClickAction.ORDER_SUBTREE );
2072 throw new RuntimeException( "unknown action: " + action );
2074 // make sure drop down is displaying the correct action
2075 // in case this was called from outside the class
2076 _click_to_combobox.setSelectedIndex( action );
2079 void setColorBranches( final boolean color_branches ) {
2080 _color_branches = color_branches;
2083 void setTreeDisplayType( final TreeDisplayType t ) {
2085 case UNALIGNED_PHYLOGRAM:
2086 getDisplayAsUnalignedPhylogramRb().setSelected( true );
2088 case ALIGNED_PHYLOGRAM:
2089 getDisplayAsAlignedPhylogramRb().setSelected( true );
2092 getDisplayAsCladogramRb().setSelected( true );
2095 setTreeDisplayType( getMainPanel().getCurrentTabIndex(), t );
2098 void setDrawPhylogramEnabled( final boolean b ) {
2099 if ( getDisplayAsAlignedPhylogramRb() != null &&
2100 getDisplayAsUnalignedPhylogramRb() != null &&
2101 getDisplayAsCladogramRb() != null
2104 getDisplayAsAlignedPhylogramRb().setEnabled( b );
2105 getDisplayAsUnalignedPhylogramRb().setEnabled( b );
2106 getDisplayAsCladogramRb().setEnabled( b );
2110 void setDynamicHidingIsOn( final boolean is_on ) {
2112 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
2115 if ( !_configuration.isUseNativeUI() ) {
2116 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
2119 getDynamicallyHideData().setForeground( Color.BLACK );
2124 void setSearchFoundCountsOnLabel0( final int counts ) {
2125 getSearchFoundCountsLabel0().setText( "Found: " + counts );
2128 void setSearchFoundCountsOnLabel1( final int counts ) {
2129 getSearchFoundCountsLabel1().setText( "Found: " + counts );
2132 void setSequenceColors( final Map<String, Color> sequence_colors ) {
2133 _sequence_colors = sequence_colors;
2136 void setShowEvents( final boolean show_events ) {
2137 if ( getShowEventsCb() == null ) {
2138 _show_events = new JCheckBox( "" );
2140 getShowEventsCb().setSelected( show_events );
2143 void setSpeciesColors( final Map<String, Color> species_colors ) {
2144 _species_colors = species_colors;
2147 void setupControls() {
2149 setupTreeDisplayTypeOptions();
2150 setupDisplayCheckboxes();
2152 // The sequence relation query selection combo-box
2153 if ( _configuration.displaySequenceRelations() ) {
2154 addSequenceRelationBlock();
2158 startClickToOptions();
2159 setupClickToOptions();
2160 endClickToOptions();
2161 // Zoom and quick edit buttons
2163 setupSearchTools0();
2164 setupSearchTools1();
2167 void setupTreeDisplayTypeOptions() {
2168 _display_as_unaligned_phylogram_rb = new JRadioButton( "PH" );
2169 _display_as_aligned_phylogram_rb = new JRadioButton( "aPH" );
2170 _display_as_cladogram_rb = new JRadioButton( "CL" );
2171 _display_as_buttongroup = new ButtonGroup();
2172 _display_as_buttongroup.add( _display_as_unaligned_phylogram_rb );
2173 _display_as_buttongroup.add( _display_as_aligned_phylogram_rb );
2174 _display_as_buttongroup.add( _display_as_cladogram_rb );
2175 getDisplayAsUnalignedPhylogramRb().setToolTipText( "(unaligned) phylogram" );
2176 getDisplayAsAlignedPhylogramRb().setToolTipText( "aligned phylogram" );
2177 getDisplayAsCladogramRb().setToolTipText( "cladogram" );
2178 setupJRadioButton( getDisplayAsUnalignedPhylogramRb() );
2179 setupJRadioButton( getDisplayAsAlignedPhylogramRb() );
2180 setupJRadioButton( getDisplayAsCladogramRb() );
2181 final JPanel p = new JPanel(new GridLayout( 1, 3, 0, 0 ));
2182 p.setFont( ControlPanel.jcb_font );
2183 if ( !_configuration.isUseNativeUI() ) {
2184 p.setBackground( getConfiguration().getGuiBackgroundColor() );
2185 p.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2187 p.add( _display_as_unaligned_phylogram_rb );
2188 p.add( _display_as_aligned_phylogram_rb );
2189 p.add( _display_as_cladogram_rb );
2194 void setUpControlsForDomainStrucures() {
2195 _domain_display_label = new JLabel( "Domain Architectures:" );
2196 add( customizeLabel( _domain_display_label, getConfiguration() ) );
2197 add( _domain_display_label );
2198 _zoom_in_domain_structure = new TypomaticJButton( "d+" );
2199 _zoom_out_domain_structure = new TypomaticJButton( "d-" );
2200 _decr_domain_structure_evalue_thr = new JButton( "-" );
2201 _incr_domain_structure_evalue_thr = new JButton( "+" );
2202 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
2203 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
2204 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
2205 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
2206 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
2207 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
2208 _domain_structure_evalue_thr_tf = new JTextField( 3 );
2209 _domain_structure_evalue_thr_tf.setEditable( false );
2210 if ( !getConfiguration().isUseNativeUI() ) {
2211 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2212 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2213 _domain_structure_evalue_thr_tf.setBorder( null );
2215 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2216 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2217 if ( !_configuration.isUseNativeUI() ) {
2218 d1_panel.setBackground( getBackground() );
2219 d2_panel.setBackground( getBackground() );
2223 addJButton( _zoom_out_domain_structure, d1_panel );
2224 addJButton( _zoom_in_domain_structure, d1_panel );
2225 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
2226 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
2227 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
2230 void setUpControlsForDepthCollapse() {
2231 _depth_collapse_label = new JLabel( "Collapse by Node Depth:" );
2232 _depth_collapse_label
2233 .setToolTipText( "to automaticall collapse nodes with a depth equal or larger than a threshold" );
2234 add( customizeLabel( _depth_collapse_label, getConfiguration() ) );
2235 add( _depth_collapse_label );
2236 _decr_depth_collapse_level = new TypomaticJButton( "-" );
2237 _incr_depth_collapse_level = new TypomaticJButton( "+" );
2238 _decr_depth_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2239 _incr_depth_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2240 _decr_depth_collapse_level.setToolTipText( "to decrease the depth threshold (wraps around)" );
2241 _incr_depth_collapse_level.setToolTipText( "to increase the depth threshold (wraps around)" );
2242 _depth_collapse_depth_tf = new JTextField( 3 );
2243 _depth_collapse_depth_tf.setToolTipText( "the current depth threshold" );
2244 _depth_collapse_depth_tf.setEditable( false );
2245 if ( !getConfiguration().isUseNativeUI() ) {
2246 _depth_collapse_depth_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2247 _depth_collapse_depth_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2248 _depth_collapse_depth_tf.setBorder( null );
2250 final JPanel panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2251 if ( !_configuration.isUseNativeUI() ) {
2252 panel.setBackground( getBackground() );
2255 addJButton( _decr_depth_collapse_level, panel );
2256 addJTextField( _depth_collapse_depth_tf, panel );
2257 addJButton( _incr_depth_collapse_level, panel );
2260 void setUpControlsForRankCollapse() {
2261 _rank_collapse_label = new JLabel( "Collapse by Node Rank:" );
2262 _rank_collapse_label
2263 .setToolTipText( "to automatically collapse nodes with a taxonomic rank equal or lower than a threshold" );
2264 add( customizeLabel( _rank_collapse_label, getConfiguration() ) );
2265 add( _rank_collapse_label );
2266 _decr_rank_collapse_level = new TypomaticJButton( "-" );
2267 _incr_rank_collapse_level = new TypomaticJButton( "+" );
2268 _decr_rank_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2269 _incr_rank_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2270 _decr_rank_collapse_level.setToolTipText( "to decrease the taxonomic rank threshold (wraps around)" );
2271 _incr_rank_collapse_level.setToolTipText( "to increase the taxonomic rank threshold (wraps around)" );
2272 _rank_collapse_depth_tf = new JTextField( 3 );
2273 _rank_collapse_depth_tf.setToolTipText( "the current taxonomic rank threshold" );
2274 _rank_collapse_depth_tf.setEditable( false );
2275 if ( !getConfiguration().isUseNativeUI() ) {
2276 _rank_collapse_depth_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2277 _rank_collapse_depth_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2278 _rank_collapse_depth_tf.setBorder( null );
2280 final JPanel panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2281 if ( !_configuration.isUseNativeUI() ) {
2282 panel.setBackground( getBackground() );
2285 addJButton( _decr_rank_collapse_level, panel );
2286 addJTextField( _rank_collapse_depth_tf, panel );
2287 addJButton( _incr_rank_collapse_level, panel );
2290 void setupSearchTools0() {
2291 final JLabel search_label = new JLabel( "Search (A):" );
2292 search_label.setFont( ControlPanel.jcb_bold_font );
2293 if ( !getConfiguration().isUseNativeUI() ) {
2294 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2296 add( search_label );
2297 search_label.setToolTipText( SEARCH_TIP_TEXT );
2298 _search_found_label_0 = new JLabel();
2299 getSearchFoundCountsLabel0().setVisible( false );
2300 _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
2301 if ( !getConfiguration().isUseNativeUI() ) {
2302 _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2304 _search_tf_0 = new JTextField( 3 );
2305 _search_tf_0.setToolTipText( SEARCH_TIP_TEXT );
2306 _search_tf_0.setEditable( true );
2307 if ( !getConfiguration().isUseNativeUI() ) {
2308 _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2309 _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2310 _search_tf_0.setBorder( null );
2312 _search_reset_button_0 = new JButton();
2313 getSearchResetButton0().setText( "Reset" );
2314 getSearchResetButton0().setEnabled( false );
2315 getSearchResetButton0().setVisible( false );
2316 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
2317 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2318 s_panel_1.setBackground( getBackground() );
2320 s_panel_2.setBackground( getBackground() );
2322 final KeyAdapter key_adapter = new KeyAdapter() {
2325 public void keyReleased( final KeyEvent key_event ) {
2327 displayedPhylogenyMightHaveChanged( true );
2330 final ActionListener action_listener = new ActionListener() {
2333 public void actionPerformed( final ActionEvent e ) {
2335 setSearchFoundCountsOnLabel0( 0 );
2336 getSearchFoundCountsLabel0().setVisible( false );
2337 getSearchTextField0().setText( "" );
2338 getSearchResetButton0().setEnabled( false );
2339 getSearchResetButton0().setVisible( false );
2340 displayedPhylogenyMightHaveChanged( true );
2343 _search_reset_button_0.addActionListener( action_listener );
2344 _search_tf_0.addKeyListener( key_adapter );
2345 addJTextField( _search_tf_0, s_panel_1 );
2346 s_panel_2.add( _search_found_label_0 );
2347 addJButton( _search_reset_button_0, s_panel_2 );
2350 void setupSearchTools1() {
2351 final JLabel search_label = new JLabel( "Search (B):" );
2352 search_label.setFont( ControlPanel.jcb_bold_font );
2353 if ( !getConfiguration().isUseNativeUI() ) {
2354 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2356 add( search_label );
2357 search_label.setToolTipText( SEARCH_TIP_TEXT );
2358 _search_found_label_1 = new JLabel();
2359 getSearchFoundCountsLabel1().setVisible( false );
2360 _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
2361 if ( !getConfiguration().isUseNativeUI() ) {
2362 _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2364 _search_tf_1 = new JTextField( 3 );
2365 _search_tf_1.setToolTipText( SEARCH_TIP_TEXT );
2366 _search_tf_1.setEditable( true );
2367 if ( !getConfiguration().isUseNativeUI() ) {
2368 _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2369 _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2370 _search_tf_1.setBorder( null );
2372 _search_reset_button_1 = new JButton();
2373 getSearchResetButton1().setText( "Reset" );
2374 getSearchResetButton1().setEnabled( false );
2375 getSearchResetButton1().setVisible( false );
2376 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
2377 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2378 s_panel_1.setBackground( getBackground() );
2380 s_panel_2.setBackground( getBackground() );
2382 final KeyAdapter key_adapter = new KeyAdapter() {
2385 public void keyReleased( final KeyEvent key_event ) {
2387 displayedPhylogenyMightHaveChanged( true );
2390 final ActionListener action_listener = new ActionListener() {
2393 public void actionPerformed( final ActionEvent e ) {
2395 setSearchFoundCountsOnLabel1( 0 );
2396 getSearchFoundCountsLabel1().setVisible( false );
2397 getSearchTextField1().setText( "" );
2398 getSearchResetButton1().setEnabled( false );
2399 getSearchResetButton1().setVisible( false );
2400 displayedPhylogenyMightHaveChanged( true );
2403 _search_reset_button_1.addActionListener( action_listener );
2404 _search_tf_1.addKeyListener( key_adapter );
2405 addJTextField( _search_tf_1, s_panel_1 );
2406 s_panel_2.add( _search_found_label_1 );
2407 addJButton( _search_reset_button_1, s_panel_2 );
2410 void setVisibilityOfDomainStrucureCB() {
2412 if ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel()
2413 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2414 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
2415 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2416 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
2418 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2419 getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
2422 else if ( isShowDomainArchitectures() ) {
2423 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2424 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( true );
2426 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2427 getMainPanel().getMainFrame()._show_domain_labels.setVisible( true );
2431 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2432 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
2434 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2435 getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
2439 catch ( final Exception ignore ) {
2444 void setVisibilityOfX() {
2445 final MainFrame mf = getMainFrame();
2447 if ( ( getCurrentTreePanel() != null ) && ( getCurrentTreePanel().getPhylogeny() != null ) ) {
2448 if ( AptxUtil.isHasAtLeastOneBranchWithSupportSD( getCurrentTreePanel().getPhylogeny() ) ) {
2449 if ( mf._show_confidence_stddev_cbmi != null ) {
2450 mf._show_confidence_stddev_cbmi.setVisible( true );
2454 if ( mf._show_confidence_stddev_cbmi != null ) {
2455 mf._show_confidence_stddev_cbmi.setVisible( false );
2458 if ( AptxUtil.isHasAtLeastOneNodeWithScientificName( getCurrentTreePanel().getPhylogeny() ) ) {
2459 if ( mf._abbreviate_scientific_names != null ) {
2460 mf._abbreviate_scientific_names.setVisible( true );
2464 if ( mf._abbreviate_scientific_names != null ) {
2465 mf._abbreviate_scientific_names.setVisible( false );
2468 if ( AptxUtil.isHasAtLeastOneNodeWithSequenceAnnotation( getCurrentTreePanel().getPhylogeny() ) ) {
2469 if ( mf._show_annotation_ref_source != null ) {
2470 mf._show_annotation_ref_source.setVisible( true );
2474 if ( mf._show_annotation_ref_source != null ) {
2475 mf._show_annotation_ref_source.setVisible( false );
2479 if ( isDrawPhylogram() || ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel()
2480 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2481 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) ) {
2482 if ( mf._non_lined_up_cladograms_rbmi != null ) {
2483 mf._non_lined_up_cladograms_rbmi.setVisible( false );
2485 if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
2486 mf._ext_node_dependent_cladogram_rbmi.setVisible( false );
2490 if ( mf._non_lined_up_cladograms_rbmi != null ) {
2491 mf._non_lined_up_cladograms_rbmi.setVisible( true );
2493 if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
2494 mf._ext_node_dependent_cladogram_rbmi.setVisible( true );
2497 if ( isDrawPhylogram() ) {
2498 if ( mf._show_scale_cbmi != null ) {
2499 mf._show_scale_cbmi.setVisible( true );
2503 if ( mf._show_scale_cbmi != null ) {
2504 mf._show_scale_cbmi.setVisible( false );
2507 if ( getCurrentTreePanel() != null ) {
2508 if ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2509 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
2510 if ( mf._label_direction_cbmi != null ) {
2511 mf._label_direction_cbmi.setVisible( true );
2515 if ( mf._label_direction_cbmi != null ) {
2516 mf._label_direction_cbmi.setVisible( false );
2523 void showAnnotations() {
2524 if ( _show_annotation != null ) {
2525 _show_annotation.setSelected( true );
2527 if ( _color_according_to_annotation != null ) {
2528 _color_according_to_annotation.setSelected( true );
2530 if ( _color_acc_species != null ) {
2531 _color_acc_species.setSelected( false );
2533 if ( _color_acc_sequence != null ) {
2534 _color_acc_sequence.setSelected( false );
2536 _mainpanel.getCurrentTreePanel().repaint();
2540 * Fit entire tree into window.
2543 if ( ( _mainpanel.getCurrentScrollPane() == null )
2544 || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
2547 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
2548 displayedPhylogenyMightHaveChanged( true );
2549 _mainpanel.getCurrentTreePanel().updateOvSettings();
2550 _mainpanel.getCurrentTreePanel().validate();
2551 _mainpanel.validate();
2552 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2553 _mainpanel.getSizeOfViewport().height );
2554 _mainpanel.getCurrentTreePanel().resetPreferredSize();
2555 _mainpanel.adjustJScrollPane();
2556 _mainpanel.getCurrentTreePanel().repaint();
2557 _mainpanel.getCurrentTreePanel().validate();
2558 _mainpanel.validate();
2559 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2560 _mainpanel.getSizeOfViewport().height );
2561 _mainpanel.getCurrentTreePanel().resetPreferredSize();
2562 _mainpanel.adjustJScrollPane();
2563 _mainpanel.getCurrentTreePanel().repaint();
2564 _mainpanel.getCurrentTreePanel().updateOvSizes();
2567 void showWholeAll() {
2568 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
2569 if ( tree_panel != null ) {
2570 tree_panel.validate();
2571 tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2572 _mainpanel.getSizeOfViewport().height );
2573 tree_panel.resetPreferredSize();
2574 tree_panel.repaint();
2579 // Create header for click-to combo box.
2580 void startClickToOptions() {
2581 final JLabel spacer = new JLabel( "" );
2582 spacer.setFont( ControlPanel.jcb_font );
2584 _click_to_label = new JLabel( "Click on Node to:" );
2585 add( customizeLabel( _click_to_label, getConfiguration() ) );
2586 _click_to_combobox = new JComboBox<String>();
2587 _click_to_combobox.setFocusable( false );
2588 _click_to_combobox.setMaximumRowCount( 14 );
2589 _click_to_combobox.setFont( ControlPanel.js_font );
2590 if ( !_configuration.isUseNativeUI() ) {
2591 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
2593 // don't add listener until all items are set (or each one will trigger
2595 // click_to_list.addActionListener(this);
2596 add( _click_to_combobox );
2597 // Correlates option names to titles
2598 _all_click_to_names = new HashMap<Integer, String>();
2599 _click_to_names = new ArrayList<String>();
2603 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
2604 if ( getCurrentTreePanel().isPhyHasBranchLengths()
2605 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
2606 setDrawPhylogramEnabled( true );
2608 setTreeDisplayType( getTreeDisplayType( getMainPanel().getCurrentTabIndex() ) );
2611 setDrawPhylogramEnabled( false );
2612 setTreeDisplayType( TreeDisplayType.CLADOGRAM );
2614 if ( getMainPanel().getMainFrame() == null ) {
2615 // Must be "E" applet version.
2616 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
2617 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
2620 getMainPanel().getMainFrame()
2621 .setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel().getPhylogenyGraphicsType() );
2623 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
2624 getMainPanel().getCurrentTreePanel().updateButtonToUncollapseAll();
2625 getMainPanel().getControlPanel().search0();
2626 getMainPanel().getControlPanel().search1();
2627 getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
2628 getMainPanel().getControlPanel().updateDepthCollapseDepthDisplay();
2629 getMainPanel().getControlPanel().updateRankCollapseRankDisplay();
2630 getSequenceRelationTypeBox().removeAllItems();
2631 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
2632 .getRelevantSequenceRelationTypes() ) {
2633 _sequence_relation_type_box.addItem( type );
2635 getMainPanel().getCurrentTreePanel().repaint();
2636 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
2637 // according to GUILHEM the line above can be removed.
2642 * Uncollapse all nodes.
2644 final void uncollapseAll( final TreePanel tp ) {
2645 final Phylogeny t = tp.getPhylogeny();
2646 if ( ( t != null ) && !t.isEmpty() ) {
2647 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
2648 final PhylogenyNode node = iter.next();
2649 node.setCollapse( false );
2651 tp.resetNodeIdToDistToLeafMap();
2652 tp.updateSetOfCollapsedExternalNodes();
2653 t.recalculateNumberOfExternalDescendants( false );
2654 tp.setNodeInPreorderToNull();
2655 t.clearHashIdToNodeMap();
2656 tp.resetDepthCollapseDepthValue();
2657 tp.resetRankCollapseRankValue();
2662 final void updateDomainStructureEvaluethresholdDisplay() {
2663 if ( _domain_structure_evalue_thr_tf != null ) {
2664 _domain_structure_evalue_thr_tf
2665 .setText( "10^" + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThresholdExp() );
2669 private final String obtainDepthCollapseDepthValue() {
2670 if ( getMainPanel().getCurrentTreePanel() == null ) {
2673 final TreePanel tp = getMainPanel().getCurrentTreePanel();
2674 final Phylogeny p = tp.getPhylogeny();
2675 if ( ( p == null ) || ( p.getNumberOfExternalNodes() < 3 ) ) {
2678 else if ( tp.getDepthCollapseDepthValue() < 0 ) {
2679 tp.setDepthCollapseDepthValue( PhylogenyMethods.calculateMaxDepth( p ) );
2682 else if ( tp.getDepthCollapseDepthValue() == PhylogenyMethods.calculateMaxDepth( p ) ) {
2685 return String.valueOf( tp.getDepthCollapseDepthValue() );
2688 private final String obtainRankCollapseDepthValue() {
2689 if ( getMainPanel().getCurrentTreePanel() == null ) {
2692 final TreePanel tp = getMainPanel().getCurrentTreePanel();
2693 final Phylogeny p = tp.getPhylogeny();
2694 if ( ( p == null ) || ( p.getNumberOfExternalNodes() < 3 ) ) {
2698 final String ranks[] = PhylogenyMethods.obtainPresentRanksSorted( p );
2699 if ( ranks.length < 1 ) {
2702 else if ( tp.getRankCollapseRankValue() < 0 ) {
2703 tp.setRankCollapseRankValue( ranks.length - 1 );
2706 else if ( tp.getRankCollapseRankValue() == ( ranks.length - 1 ) ) {
2710 return String.valueOf( tp.getRankCollapseRankValue() );
2713 final void updateDepthCollapseDepthDisplay() {
2714 if ( _depth_collapse_depth_tf != null ) {
2715 _depth_collapse_depth_tf.setText( " " + obtainDepthCollapseDepthValue() );
2719 final void updateRankCollapseRankDisplay() {
2720 if ( _rank_collapse_depth_tf != null ) {
2721 final String r = obtainRankCollapseDepthValue();
2722 if ( r.equals( "off" ) ) {
2723 _rank_collapse_depth_tf.setText( " off" );
2724 _rank_collapse_depth_tf.setToolTipText( "the current taxonomic rank threshold" );
2727 final String ranks[] = PhylogenyMethods
2728 .obtainPresentRanksSorted( getMainPanel().getCurrentTreePanel().getPhylogeny() );
2729 final int rr = Integer.parseInt( r );
2730 _rank_collapse_depth_tf.setText( ranks[ rr ] );
2731 _rank_collapse_depth_tf.setToolTipText( ( rr + 1 ) + "/" + ( ranks.length - 1 ) + ": "
2732 + ranks[ Integer.parseInt( r ) ] );
2737 final void zoomInX( final float factor, final float x_correction_factor ) {
2738 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
2739 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2740 treepanel.multiplyUrtFactor( 1f );
2741 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2742 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
2743 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
2744 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
2745 final double x = ( sb.getMaximum() - sb.getMinimum() )
2746 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2747 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2748 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2749 getMainPanel().adjustJScrollPane();
2750 treepanel.resetPreferredSize();
2751 getMainPanel().getCurrentScrollPane().getViewport().validate();
2752 sb.setValue( ForesterUtil
2753 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2756 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
2757 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2758 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2759 getMainPanel().adjustJScrollPane();
2760 treepanel.resetPreferredSize();
2761 getMainPanel().getCurrentScrollPane().getViewport().validate();
2762 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
2764 treepanel.resetPreferredSize();
2765 treepanel.updateOvSizes();
2768 final void zoomInY( final float factor ) {
2769 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
2770 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2771 treepanel.multiplyUrtFactor( 1.1f );
2772 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2773 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
2774 getMainPanel().adjustJScrollPane();
2775 treepanel.resetPreferredSize();
2776 getMainPanel().getCurrentScrollPane().getViewport().validate();
2777 sb.setValue( ForesterUtil
2778 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2779 treepanel.resetPreferredSize();
2780 treepanel.updateOvSizes();
2783 final void zoomOutX( final float factor, final float x_correction_factor ) {
2784 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2785 treepanel.multiplyUrtFactor( 1f );
2786 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
2787 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
2788 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2789 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
2790 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
2791 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
2792 getMainPanel().adjustJScrollPane();
2793 treepanel.resetPreferredSize();
2794 getMainPanel().getCurrentScrollPane().getViewport().validate();
2795 final double x = ( sb.getMaximum() - sb.getMinimum() )
2796 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2797 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2798 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2799 getMainPanel().adjustJScrollPane();
2800 treepanel.resetPreferredSize();
2801 getMainPanel().getCurrentScrollPane().getViewport().validate();
2802 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
2803 - ( sb.getVisibleAmount() / 2.0 ) ) );
2806 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
2807 treepanel.setXdistance( treepanel.getXdistance() * factor );
2808 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
2810 getMainPanel().adjustJScrollPane();
2811 treepanel.resetPreferredSize();
2812 getMainPanel().getCurrentScrollPane().getViewport().validate();
2813 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
2816 treepanel.resetPreferredSize();
2817 treepanel.updateOvSizes();
2821 private final boolean isDrawPhylogram( int currentTabIndex ) {
2822 TreeDisplayType t = getTreeDisplayType( currentTabIndex );
2823 return ((t==TreeDisplayType.ALIGNED_PHYLOGRAM)|(t==TreeDisplayType.UNALIGNED_PHYLOGRAM));
2827 final void zoomOutY( final float factor ) {
2828 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2829 treepanel.multiplyUrtFactor( 0.9f );
2830 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
2831 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
2832 final double x = ( sb.getMaximum() - sb.getMinimum() )
2833 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2834 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
2835 getMainPanel().adjustJScrollPane();
2836 treepanel.resetPreferredSize();
2837 getMainPanel().getCurrentScrollPane().getViewport().validate();
2838 sb.setValue( ForesterUtil
2839 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2840 treepanel.resetPreferredSize();
2841 treepanel.updateOvSizes();
2845 final static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2846 label.setFont( ControlPanel.jcb_bold_font );
2847 if ( !configuration.isUseNativeUI() ) {
2848 label.setForeground( configuration.getGuiCheckboxTextColor() );
2849 label.setBackground( configuration.getGuiBackgroundColor() );
2854 final public JCheckBox getUseBranchWidthsCb() {
2855 return _width_branches;
2858 public TreeDisplayType getTreeDisplayType() {
2859 if (_display_as_unaligned_phylogram_rb.isSelected() ) {
2860 return TreeDisplayType.UNALIGNED_PHYLOGRAM;
2862 else if (_display_as_aligned_phylogram_rb.isSelected() ) {
2863 return TreeDisplayType.ALIGNED_PHYLOGRAM;
2865 return TreeDisplayType.CLADOGRAM;