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.DefaultListCellRenderer;
51 import javax.swing.JButton;
52 import javax.swing.JCheckBox;
53 import javax.swing.JComboBox;
54 import javax.swing.JLabel;
55 import javax.swing.JList;
56 import javax.swing.JPanel;
57 import javax.swing.JScrollBar;
58 import javax.swing.JTextField;
59 import javax.swing.ListCellRenderer;
61 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
62 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
63 import org.forester.archaeopteryx.util.TypomaticJButton;
64 import org.forester.phylogeny.Phylogeny;
65 import org.forester.phylogeny.PhylogenyMethods;
66 import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
67 import org.forester.phylogeny.PhylogenyNode;
68 import org.forester.phylogeny.data.Sequence;
69 import org.forester.phylogeny.data.SequenceRelation;
70 import org.forester.phylogeny.data.SequenceRelation.SEQUENCE_RELATION_TYPE;
71 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
72 import org.forester.util.ForesterUtil;
74 final class ControlPanel extends JPanel implements ActionListener {
76 enum NodeClickAction {
83 DELETE_NODE_OR_SUBTREE,
101 final static Font jcb_bold_font = new Font( Configuration
102 .getDefaultFontFamilyName(), Font.BOLD, 9 );
103 final static Font jcb_font = new Font( Configuration
104 .getDefaultFontFamilyName(), Font.PLAIN, 9 );
105 final static Font js_font = new Font( Configuration
106 .getDefaultFontFamilyName(), Font.PLAIN, 9 );
107 private static final String RETURN_TO_SUPER_TREE_TEXT = "R";
108 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).";
109 private static final long serialVersionUID = -8463483932821545633L;
110 private NodeClickAction _action_when_node_clicked;
111 private int _add_new_node_item;
112 private Map<Integer, String> _all_click_to_names;
113 private Map<String, Color> _annotation_colors;
114 private int _blast_item;
115 private JComboBox<String> _click_to_combobox;
116 private JLabel _click_to_label;
117 private List<String> _click_to_names;
118 private int _collapse_cb_item;
119 private int _uncollapse_all_cb_item;
120 private int _order_subtree_cb_item;
121 private JCheckBox _color_acc_species;
122 private JCheckBox _color_acc_sequence;
123 private JCheckBox _color_according_to_annotation;
124 private boolean _color_branches;
125 private JCheckBox _use_visual_styles_cb;
126 private int _color_subtree_cb_item;
127 private int _change_node_font_item;
128 // The settings from the conf file
129 private final Configuration _configuration;
130 private int _copy_subtree_item;
131 private int _cut_subtree_item;
132 private JButton _decr_domain_structure_evalue_thr;
133 private int _delete_node_or_subtree_item;
134 private JCheckBox _display_as_phylogram_cb;
136 private JCheckBox _display_internal_data;
137 private JLabel _domain_display_label;
138 private JTextField _domain_structure_evalue_thr_tf;
139 private JTextField _depth_collapse_depth_tf;
140 private JTextField _rank_collapse_depth_tf;
141 private List<Boolean> _draw_phylogram;
142 private JCheckBox _dynamically_hide_data;
143 private int _edit_node_data_item;
144 private int _get_ext_desc_data;
145 private JButton _incr_domain_structure_evalue_thr;
146 private final MainPanel _mainpanel;
147 private JCheckBox _node_desc_popup_cb;
148 private int _open_pdb_item;
149 private int _open_seq_web_item;
150 private int _open_tax_web_item;
151 private int _color_node_font_item;
152 private JButton _order;
153 private int _paste_subtree_item;
154 private int _reroot_cb_item;
155 private JButton _return_to_super_tree;
157 private JLabel _search_found_label_0;
158 private JLabel _search_found_label_1;
159 private JButton _search_reset_button_0;
160 private JButton _search_reset_button_1;
161 private JTextField _search_tf_0;
162 private JTextField _search_tf_1;
163 private int _select_nodes_item;
164 private Sequence _selected_query_seq;
165 private JCheckBox _seq_relation_confidence_switch;
166 private JComboBox<SEQUENCE_RELATION_TYPE> _sequence_relation_type_box;
167 private JCheckBox _show_annotation;
168 private JCheckBox _show_binary_character_counts;
169 private JCheckBox _show_binary_characters;
170 // Indices for the click-to options in the combo box
171 private int _show_data_item;
172 private JCheckBox _show_domain_architectures;
173 private JCheckBox _show_mol_seqs;
174 private JCheckBox _write_branch_length_values;
175 private JCheckBox _show_events;
176 private JCheckBox _show_gene_names;
177 private JCheckBox _show_node_names;
178 private JCheckBox _show_properties_cb;
179 private JCheckBox _show_seq_names;
180 private JCheckBox _show_seq_symbols;
181 private JCheckBox _show_sequence_acc;
182 private JComboBox<String> _show_sequence_relations;
183 private JCheckBox _show_taxo_code;
184 private JCheckBox _show_taxo_rank;
185 private JCheckBox _show_taxo_common_names;
186 private JCheckBox _show_taxo_images_cb;
187 private JCheckBox _show_taxo_scientific_names;
188 private JCheckBox _show_vector_data_cb;
189 private JButton _show_whole;
190 private int _sort_descendents_item;
191 private Map<String, Color> _species_colors;
192 private Map<String, Color> _sequence_colors;
193 private int _subtree_cb_item;
194 private int _swap_cb_item;
195 private JButton _uncollapse_all;
196 private JCheckBox _width_branches;
197 private JCheckBox _write_confidence;
198 private JButton _zoom_in_domain_structure;
199 private JButton _zoom_in_x;
200 private JButton _zoom_in_y;
201 private JLabel _zoom_label;
202 private JButton _zoom_out_domain_structure;
203 private JButton _zoom_out_x;
204 private JButton _zoom_out_y;
205 private JButton _decr_depth_collapse_level;
206 private JButton _incr_depth_collapse_level;
207 private JLabel _depth_collapse_label;
208 private JButton _decr_rank_collapse_level;
209 private JButton _incr_rank_collapse_level;
210 private JLabel _rank_collapse_label;
212 ControlPanel( final MainPanel ap, final Configuration configuration ) {
215 _configuration = configuration;
216 if ( !_configuration.isUseNativeUI() ) {
217 setBackground( getConfiguration().getGuiBackgroundColor() );
218 setBorder( BorderFactory.createRaisedBevelBorder() );
220 setLayout( new GridLayout( 0, 1, 2, 2 ) );
228 public void actionPerformed( final ActionEvent e ) {
230 if ( e.getSource() == _color_acc_sequence ) {
231 if ( _color_acc_species != null ) {
232 _color_acc_species.setSelected( false );
235 else if ( e.getSource() == _color_acc_species ) {
236 if ( _color_acc_sequence != null ) {
237 _color_acc_sequence.setSelected( false );
240 final TreePanel tp = getMainPanel().getCurrentTreePanel();
244 if ( e.getSource() == _click_to_combobox ) {
245 setClickToAction( _click_to_combobox.getSelectedIndex() );
246 getCurrentTreePanel().repaint();
248 else if ( e.getSource() == _show_binary_characters ) {
249 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
250 _show_binary_character_counts.setSelected( false );
252 displayedPhylogenyMightHaveChanged( true );
254 else if ( e.getSource() == _show_binary_character_counts ) {
255 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
256 _show_binary_characters.setSelected( false );
258 displayedPhylogenyMightHaveChanged( true );
260 else if ( e.getSource() == _show_domain_architectures ) {
263 displayedPhylogenyMightHaveChanged( true );
265 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
266 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
267 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
271 else if ( e.getSource() == _zoom_in_x ) {
272 zoomInX( AptxConstants.BUTTON_ZOOM_IN_FACTOR, AptxConstants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
273 displayedPhylogenyMightHaveChanged( false );
275 else if ( e.getSource() == _zoom_in_y ) {
276 zoomInY( AptxConstants.BUTTON_ZOOM_IN_FACTOR );
277 displayedPhylogenyMightHaveChanged( false );
279 else if ( e.getSource() == _zoom_out_x ) {
280 zoomOutX( AptxConstants.BUTTON_ZOOM_OUT_FACTOR, AptxConstants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
281 displayedPhylogenyMightHaveChanged( false );
283 else if ( e.getSource() == _zoom_out_y ) {
284 zoomOutY( AptxConstants.BUTTON_ZOOM_OUT_FACTOR );
285 displayedPhylogenyMightHaveChanged( false );
287 else if ( e.getSource() == _show_whole ) {
288 displayedPhylogenyMightHaveChanged( true );
291 else if ( e.getSource() == _return_to_super_tree ) {
292 _mainpanel.getCurrentTreePanel().superTree();
295 else if ( e.getSource() == _order ) {
296 DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
297 if ( isShowTaxonomyScientificNames() || isShowTaxonomyCode() ) {
298 pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
300 else if ( isShowSeqNames() || isShowSeqSymbols() || isShowGeneNames() ) {
301 pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
303 PhylogenyMethods.orderAppearanceX( tp.getPhylogeny().getRoot(), true, pri );
304 tp.setNodeInPreorderToNull();
305 tp.getPhylogeny().externalNodesHaveChanged();
306 tp.getPhylogeny().clearHashIdToNodeMap();
307 tp.getPhylogeny().recalculateNumberOfExternalDescendants( true );
308 tp.resetNodeIdToDistToLeafMap();
309 tp.setEdited( true );
310 displayedPhylogenyMightHaveChanged( true );
312 else if ( e.getSource() == _uncollapse_all ) {
314 displayedPhylogenyMightHaveChanged( false );
316 else if ( e.getSource() == _zoom_in_domain_structure ) {
317 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
318 displayedPhylogenyMightHaveChanged( true );
320 else if ( e.getSource() == _zoom_out_domain_structure ) {
321 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
322 displayedPhylogenyMightHaveChanged( true );
324 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
325 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThresholdExp();
328 displayedPhylogenyMightHaveChanged( true );
330 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
331 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThresholdExp();
334 displayedPhylogenyMightHaveChanged( true );
336 else if ( e.getSource() == _search_tf_0 ) {
338 displayedPhylogenyMightHaveChanged( true );
340 else if ( e.getSource() == _search_tf_1 ) {
342 displayedPhylogenyMightHaveChanged( true );
344 else if ( ( _dynamically_hide_data != null ) && ( e.getSource() == _dynamically_hide_data )
345 && !_dynamically_hide_data.isSelected() ) {
346 setDynamicHidingIsOn( false );
347 displayedPhylogenyMightHaveChanged( true );
349 else if ( ( e.getSource() == _decr_depth_collapse_level )
350 || ( e.getSource() == _incr_depth_collapse_level ) ) {
351 if ( e.getSource() == _decr_depth_collapse_level ) {
352 _mainpanel.getCurrentTreePanel().decreaseDepthCollapseLevel();
355 _mainpanel.getCurrentTreePanel().increaseDepthCollapseLevel();
359 _mainpanel.getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
360 _mainpanel.getCurrentTreePanel().getPhylogeny().recalculateNumberOfExternalDescendants( true );
361 _mainpanel.getCurrentTreePanel().resetNodeIdToDistToLeafMap();
362 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
363 _mainpanel.getCurrentTreePanel().setNodeInPreorderToNull();
364 displayedPhylogenyMightHaveChanged( true );
365 _mainpanel.getCurrentTreePanel().resetPreferredSize();
366 _mainpanel.getCurrentTreePanel().updateOvSizes();
367 _mainpanel.adjustJScrollPane();
371 else if ( ( e.getSource() == _decr_rank_collapse_level )
372 || ( e.getSource() == _incr_rank_collapse_level ) ) {
373 if ( e.getSource() == _decr_rank_collapse_level ) {
374 _mainpanel.getCurrentTreePanel().decreaseRankCollapseLevel();
377 _mainpanel.getCurrentTreePanel().increaseRankCollapseLevel();
381 _mainpanel.getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
382 _mainpanel.getCurrentTreePanel().getPhylogeny().recalculateNumberOfExternalDescendants( true );
383 _mainpanel.getCurrentTreePanel().resetNodeIdToDistToLeafMap();
384 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
385 _mainpanel.getCurrentTreePanel().setNodeInPreorderToNull();
386 displayedPhylogenyMightHaveChanged( true );
387 _mainpanel.getCurrentTreePanel().resetPreferredSize();
388 _mainpanel.getCurrentTreePanel().updateOvSizes();
389 _mainpanel.adjustJScrollPane();
394 displayedPhylogenyMightHaveChanged( true );
398 tp.requestFocusInWindow();
401 catch ( final Exception ex ) {
402 AptxUtil.unexpectedException( ex );
404 catch ( final Error err ) {
405 AptxUtil.unexpectedError( err );
409 public JCheckBox getColorAccSequenceCb() {
410 return _color_acc_sequence;
413 public JCheckBox getColorAccSpeciesCb() {
414 return _color_acc_species;
417 public JCheckBox getDisplayAsPhylogramCb() {
418 return _display_as_phylogram_cb;
421 public JCheckBox getDynamicallyHideData() {
422 return _dynamically_hide_data;
425 public JCheckBox getNodeDescPopupCb() {
426 return _node_desc_popup_cb;
429 public Sequence getSelectedQuerySequence() {
430 return _selected_query_seq;
433 public JComboBox<String> getSequenceRelationBox() {
434 if ( _show_sequence_relations == null ) {
435 _show_sequence_relations = new JComboBox<String>();
436 _show_sequence_relations.setFocusable( false );
437 _show_sequence_relations.setMaximumRowCount( 20 );
438 _show_sequence_relations.setFont( ControlPanel.js_font );
439 if ( !_configuration.isUseNativeUI() ) {
440 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
441 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
443 _show_sequence_relations.addItem( "-----" );
444 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
446 return _show_sequence_relations;
450 public JComboBox<SEQUENCE_RELATION_TYPE> getSequenceRelationTypeBox() {
451 if ( _sequence_relation_type_box == null ) {
452 _sequence_relation_type_box = new JComboBox<SEQUENCE_RELATION_TYPE>();
453 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE
455 _sequence_relation_type_box.addItem( type );
457 _sequence_relation_type_box.addActionListener( new ActionListener() {
460 public void actionPerformed( final ActionEvent e ) {
461 if ( _mainpanel.getCurrentPhylogeny() != null ) {
462 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
467 return _sequence_relation_type_box;
470 public JCheckBox getShowEventsCb() {
474 public JCheckBox getUseVisualStylesCb() {
475 return _use_visual_styles_cb;
478 public JCheckBox getWriteConfidenceCb() {
479 return _write_confidence;
482 public boolean isShowMolSequences() {
483 return ( ( _show_mol_seqs != null ) && _show_mol_seqs.isSelected() );
486 public boolean isShowProperties() {
487 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
490 public boolean isShowTaxonomyImages() {
491 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
494 public boolean isShowVectorData() {
495 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
498 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
499 final JComboBox<String> box = getSequenceRelationBox();
500 while ( box.getItemCount() > 1 ) {
501 box.removeItemAt( 1 );
503 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
504 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
506 if ( relationType == null ) {
509 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
510 for( final Sequence seq : sequenceRelationQueries ) {
511 if ( seq.isHasSequenceRelations() ) {
512 boolean fFoundForCurrentType = false;
513 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
514 if ( sq.getType().equals( relationType ) ) {
515 fFoundForCurrentType = true;
519 if ( fFoundForCurrentType ) {
520 sequenceNamesToAdd.add( seq.getName() );
521 sequencesByName.put( seq.getName(), seq );
525 // sort sequences by name before adding them to the combo
526 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
527 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
528 for( final String seqName : sequenceNameArray ) {
529 box.addItem( seqName );
531 for( final ItemListener oldItemListener : box.getItemListeners() ) {
532 box.removeItemListener( oldItemListener );
534 box.addItemListener( new ItemListener() {
537 public void itemStateChanged( final ItemEvent e ) {
538 _selected_query_seq = sequencesByName.get( e.getItem() );
539 _mainpanel.getCurrentTreePanel().repaint();
544 private void addClickToOption( final int which, final String title ) {
545 _click_to_combobox.addItem( title );
546 _click_to_names.add( title );
547 _all_click_to_names.put( new Integer( which ), title );
548 if ( !_configuration.isUseNativeUI() ) {
549 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
550 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
555 private void addSequenceRelationBlock() {
556 final JLabel spacer = new JLabel( "" );
557 spacer.setSize( 1, 1 );
559 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
560 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
561 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
562 getSequenceRelationTypeBox().setFocusable( false );
563 _sequence_relation_type_box.setFont( ControlPanel.js_font );
564 if ( !_configuration.isUseNativeUI() ) {
565 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
566 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
568 _sequence_relation_type_box.setRenderer( new ListCellRenderer<Object>() {
571 public Component getListCellRendererComponent( final JList<?> list,
574 final boolean isSelected,
575 final boolean cellHasFocus ) {
576 final Component component = new DefaultListCellRenderer()
577 .getListCellRendererComponent( list, value, index, isSelected, cellHasFocus );
578 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
579 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
580 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
585 final GridBagLayout gbl = new GridBagLayout();
586 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
587 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
588 final JPanel horizGrid = new JPanel( gbl );
589 horizGrid.setBackground( getBackground() );
590 horizGrid.add( typeLabel );
591 horizGrid.add( _sequence_relation_type_box );
592 add( customizeLabel( mainLabel, getConfiguration() ) );
594 add( getSequenceRelationBox() );
595 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
596 addCheckbox( Configuration.show_relation_confidence,
597 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
598 setCheckbox( Configuration.show_relation_confidence,
599 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
601 }// addSequenceRelationBlock
604 private List<Boolean> getIsDrawPhylogramList() {
605 return _draw_phylogram;
608 // This takes care of ArchaeopteryxE-issue.
609 // Can, and will, return null prior to ArchaeopteryxE initialization completion.
610 final private MainFrame getMainFrame() {
611 MainFrame mf = getMainPanel().getMainFrame();
613 // Must be "E" applet version.
614 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
615 if ( e.getMainPanel() == null ) {
618 mf = e.getMainPanel().getMainFrame();
623 private void init() {
624 _draw_phylogram = new ArrayList<Boolean>();
625 setSpeciesColors( new HashMap<String, Color>() );
626 setSequenceColors( new HashMap<String, Color>() );
627 setAnnotationColors( new HashMap<String, Color>() );
630 private boolean isDrawPhylogram( final int index ) {
631 return getIsDrawPhylogramList().get( index );
634 private void search0( final MainPanel main_panel, final Phylogeny tree, String query_str ) {
635 getSearchFoundCountsLabel0().setVisible( true );
636 getSearchResetButton0().setEnabled( true );
637 getSearchResetButton0().setVisible( true );
638 String[] queries = null;
639 Set<Long> nodes = null;
640 query_str = query_str.replaceAll("\\s+", " " );
641 if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
642 queries = query_str.split( ",+" );
645 queries = new String[ 1 ];
646 queries[ 0 ] = query_str.trim();
648 if ( ( queries != null ) && ( queries.length > 0 ) ) {
649 nodes = new HashSet<Long>();
650 for( String query : queries ) {
651 if ( ForesterUtil.isEmpty( query ) ) {
654 query = query.trim();
655 final TreePanel tp = getMainPanel().getCurrentTreePanel();
656 if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
657 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
659 getOptions().isSearchCaseSensitive(),
660 !getOptions().isMatchWholeTermsOnly(),
661 isShowDomainArchitectures(),
664 tp.getDomainStructureEvalueThresholdExp() )
668 nodes.addAll( PhylogenyMethods
671 getOptions().isSearchCaseSensitive(),
672 !getOptions().isMatchWholeTermsOnly(),
673 getOptions().isSearchWithRegex(),
674 isShowDomainArchitectures(),
675 tp != null ? Math.pow( 10, tp.getDomainStructureEvalueThresholdExp() ) : 0 ) );
678 if ( getOptions().isInverseSearchResult() ) {
679 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
680 final Set<Long> temp_nodes = nodes;
681 nodes = new HashSet<Long>();
682 for( final PhylogenyNode n : all ) {
683 if ( ( !temp_nodes.contains( n.getId() ) ) && n.isHasNodeData() ) {
684 nodes.add( n.getId() );
689 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
690 main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet<Long>() );
691 for( final Long node : nodes ) {
692 main_panel.getCurrentTreePanel().getFoundNodes0().add( node );
694 setSearchFoundCountsOnLabel0( nodes.size() );
697 setSearchFoundCountsOnLabel0( 0 );
702 private void search1( final MainPanel main_panel, final Phylogeny tree, String query_str ) {
703 getSearchFoundCountsLabel1().setVisible( true );
704 getSearchResetButton1().setEnabled( true );
705 getSearchResetButton1().setVisible( true );
706 String[] queries = null;
707 Set<Long> nodes = null;
708 query_str = query_str.replaceAll("\\s+", " " );
709 if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
710 queries = query_str.split( ",+" );
713 queries = new String[ 1 ];
714 queries[ 0 ] = query_str.trim();
716 if ( ( queries != null ) && ( queries.length > 0 ) ) {
717 nodes = new HashSet<Long>();
718 for( String query : queries ) {
719 if ( ForesterUtil.isEmpty( query ) ) {
722 query = query.trim();
723 final TreePanel tp = getMainPanel().getCurrentTreePanel();
724 if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
725 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
727 getOptions().isSearchCaseSensitive(),
728 !getOptions().isMatchWholeTermsOnly(),
729 isShowDomainArchitectures(),
732 tp.getDomainStructureEvalueThresholdExp() )
736 nodes.addAll( PhylogenyMethods
739 getOptions().isSearchCaseSensitive(),
740 !getOptions().isMatchWholeTermsOnly(),
741 getOptions().isSearchWithRegex(),
742 isShowDomainArchitectures(),
743 tp != null ? Math.pow( 10, tp.getDomainStructureEvalueThresholdExp() ) : 0 ) );
746 if ( getOptions().isInverseSearchResult() ) {
747 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
748 final Set<Long> temp_nodes = nodes;
749 nodes = new HashSet<Long>();
750 for( final PhylogenyNode n : all ) {
751 if ( ( !temp_nodes.contains( n.getId() ) ) && n.isHasNodeData() ) {
752 nodes.add( n.getId() );
757 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
758 main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet<Long>() );
759 for( final Long node : nodes ) {
760 main_panel.getCurrentTreePanel().getFoundNodes1().add( node );
762 setSearchFoundCountsOnLabel1( nodes.size() );
765 setSearchFoundCountsOnLabel1( 0 );
770 private void setDrawPhylogram( final int index, final boolean b ) {
771 getIsDrawPhylogramList().set( index, b );
774 private void setupClickToOptions() {
775 final int default_option = _configuration.getDefaultDisplayClicktoOption();
776 int selected_index = 0;
778 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
779 _show_data_item = cb_index;
780 addClickToOption( Configuration.display_node_data,
781 _configuration.getClickToTitle( Configuration.display_node_data ) );
782 if ( default_option == Configuration.display_node_data ) {
783 selected_index = cb_index;
787 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
788 _collapse_cb_item = cb_index;
789 addClickToOption( Configuration.collapse_uncollapse,
790 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
791 if ( default_option == Configuration.collapse_uncollapse ) {
792 selected_index = cb_index;
796 if ( _configuration.doDisplayClickToOption( Configuration.uncollapse_all ) ) {
797 _uncollapse_all_cb_item = cb_index;
798 addClickToOption( Configuration.uncollapse_all,
799 _configuration.getClickToTitle( Configuration.uncollapse_all ) );
800 if ( default_option == Configuration.uncollapse_all ) {
801 selected_index = cb_index;
805 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
806 _reroot_cb_item = cb_index;
807 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
808 if ( default_option == Configuration.reroot ) {
809 selected_index = cb_index;
813 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
814 _subtree_cb_item = cb_index;
815 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
816 if ( default_option == Configuration.subtree ) {
817 selected_index = cb_index;
821 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
822 _swap_cb_item = cb_index;
823 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
824 if ( default_option == Configuration.swap ) {
825 selected_index = cb_index;
829 if ( _configuration.doDisplayClickToOption( Configuration.order_subtree ) ) {
830 _order_subtree_cb_item = cb_index;
831 addClickToOption( Configuration.order_subtree,
832 _configuration.getClickToTitle( Configuration.order_subtree ) );
833 if ( default_option == Configuration.order_subtree ) {
834 selected_index = cb_index;
838 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
839 _sort_descendents_item = cb_index;
840 addClickToOption( Configuration.sort_descendents,
841 _configuration.getClickToTitle( Configuration.sort_descendents ) );
842 if ( default_option == Configuration.sort_descendents ) {
843 selected_index = cb_index;
847 if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) {
848 _color_node_font_item = cb_index;
849 addClickToOption( Configuration.color_node_font,
850 _configuration.getClickToTitle( Configuration.color_node_font ) );
851 if ( default_option == Configuration.color_node_font ) {
852 selected_index = cb_index;
856 if ( _configuration.doDisplayClickToOption( Configuration.change_node_font ) ) {
857 _change_node_font_item = cb_index;
858 addClickToOption( Configuration.change_node_font,
859 _configuration.getClickToTitle( Configuration.change_node_font ) );
860 if ( default_option == Configuration.change_node_font ) {
861 selected_index = cb_index;
865 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
866 _color_subtree_cb_item = cb_index;
867 addClickToOption( Configuration.color_subtree,
868 _configuration.getClickToTitle( Configuration.color_subtree ) );
869 if ( default_option == Configuration.color_subtree ) {
870 selected_index = cb_index;
874 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
875 _open_seq_web_item = cb_index;
876 addClickToOption( Configuration.open_seq_web,
877 _configuration.getClickToTitle( Configuration.open_seq_web ) );
878 if ( default_option == Configuration.open_seq_web ) {
879 selected_index = cb_index;
883 if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
884 _open_pdb_item = cb_index;
885 addClickToOption( Configuration.open_pdb_web,
886 _configuration.getClickToTitle( Configuration.open_pdb_web ) );
887 if ( default_option == Configuration.open_pdb_web ) {
888 selected_index = cb_index;
892 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
893 _open_tax_web_item = cb_index;
894 addClickToOption( Configuration.open_tax_web,
895 _configuration.getClickToTitle( Configuration.open_tax_web ) );
896 if ( default_option == Configuration.open_tax_web ) {
897 selected_index = cb_index;
901 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
902 _blast_item = cb_index;
903 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
904 if ( default_option == Configuration.blast ) {
905 selected_index = cb_index;
909 if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
910 _select_nodes_item = cb_index;
911 addClickToOption( Configuration.select_nodes,
912 _configuration.getClickToTitle( Configuration.select_nodes ) );
913 if ( default_option == Configuration.select_nodes ) {
914 selected_index = cb_index;
918 if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
919 _get_ext_desc_data = cb_index;
920 if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
921 addClickToOption( Configuration.get_ext_desc_data,
922 getConfiguration().getLabelForGetExtDescendentsData() );
925 addClickToOption( Configuration.get_ext_desc_data,
926 getConfiguration().getClickToTitle( Configuration.get_ext_desc_data ) );
928 if ( default_option == Configuration.get_ext_desc_data ) {
929 selected_index = cb_index;
933 if ( getOptions().isEditable() ) {
934 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
935 _cut_subtree_item = cb_index;
936 addClickToOption( Configuration.cut_subtree,
937 _configuration.getClickToTitle( Configuration.cut_subtree ) );
938 if ( default_option == Configuration.cut_subtree ) {
939 selected_index = cb_index;
943 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
944 _copy_subtree_item = cb_index;
945 addClickToOption( Configuration.copy_subtree,
946 _configuration.getClickToTitle( Configuration.copy_subtree ) );
947 if ( default_option == Configuration.copy_subtree ) {
948 selected_index = cb_index;
952 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
953 _paste_subtree_item = cb_index;
954 addClickToOption( Configuration.paste_subtree,
955 _configuration.getClickToTitle( Configuration.paste_subtree ) );
956 if ( default_option == Configuration.paste_subtree ) {
957 selected_index = cb_index;
961 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
962 _delete_node_or_subtree_item = cb_index;
963 addClickToOption( Configuration.delete_subtree_or_node,
964 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
965 if ( default_option == Configuration.delete_subtree_or_node ) {
966 selected_index = cb_index;
970 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
971 _add_new_node_item = cb_index;
972 addClickToOption( Configuration.add_new_node,
973 _configuration.getClickToTitle( Configuration.add_new_node ) );
974 if ( default_option == Configuration.add_new_node ) {
975 selected_index = cb_index;
979 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
980 _edit_node_data_item = cb_index;
981 addClickToOption( Configuration.edit_node_data,
982 _configuration.getClickToTitle( Configuration.edit_node_data ) );
983 if ( default_option == Configuration.edit_node_data ) {
984 selected_index = cb_index;
989 // Set default selection and its action
990 _click_to_combobox.setSelectedIndex( selected_index );
991 setClickToAction( selected_index );
994 private void setupDisplayCheckboxes() {
995 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
996 addCheckbox( Configuration.display_as_phylogram,
997 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
998 setCheckbox( Configuration.display_as_phylogram,
999 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
1001 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1002 addCheckbox( Configuration.dynamically_hide_data,
1003 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
1004 setCheckbox( Configuration.dynamically_hide_data,
1005 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
1007 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1008 addCheckbox( Configuration.node_data_popup,
1009 _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1010 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1012 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1013 addCheckbox( Configuration.display_internal_data,
1014 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
1015 setCheckbox( Configuration.display_internal_data,
1016 _configuration.doCheckOption( Configuration.display_internal_data ) );
1018 if ( _configuration.doDisplayOption( Configuration.color_according_to_sequence ) ) {
1019 addCheckbox( Configuration.color_according_to_sequence,
1020 _configuration.getDisplayTitle( Configuration.color_according_to_sequence ) );
1021 setCheckbox( Configuration.color_according_to_sequence,
1022 _configuration.doCheckOption( Configuration.color_according_to_sequence ) );
1024 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1025 addCheckbox( Configuration.color_according_to_species,
1026 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
1027 setCheckbox( Configuration.color_according_to_species,
1028 _configuration.doCheckOption( Configuration.color_according_to_species ) );
1030 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1031 addCheckbox( Configuration.color_according_to_annotation,
1032 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
1033 setCheckbox( Configuration.color_according_to_annotation,
1034 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
1036 if ( _configuration.doDisplayOption( Configuration.use_style ) ) {
1037 addCheckbox( Configuration.use_style, _configuration.getDisplayTitle( Configuration.use_style ) );
1038 setCheckbox( Configuration.use_style, _configuration.doCheckOption( Configuration.use_style ) );
1040 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1041 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1042 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1044 final JLabel label = new JLabel( "Display Data:" );
1045 label.setFont( ControlPanel.jcb_bold_font );
1046 if ( !getConfiguration().isUseNativeUI() ) {
1047 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1050 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1051 addCheckbox( Configuration.show_node_names,
1052 _configuration.getDisplayTitle( Configuration.show_node_names ) );
1053 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1055 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1056 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1057 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1059 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1060 addCheckbox( Configuration.show_taxonomy_scientific_names,
1061 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1062 setCheckbox( Configuration.show_taxonomy_scientific_names,
1063 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1065 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1066 addCheckbox( Configuration.show_taxonomy_common_names,
1067 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1068 setCheckbox( Configuration.show_taxonomy_common_names,
1069 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1071 if ( _configuration.doDisplayOption( Configuration.show_tax_rank ) ) {
1072 addCheckbox( Configuration.show_tax_rank, _configuration.getDisplayTitle( Configuration.show_tax_rank ) );
1073 setCheckbox( Configuration.show_tax_rank, _configuration.doCheckOption( Configuration.show_tax_rank ) );
1075 if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
1076 addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
1077 setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
1079 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1080 addCheckbox( Configuration.show_gene_names,
1081 _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1082 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1084 if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
1085 addCheckbox( Configuration.show_seq_symbols,
1086 _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
1087 setCheckbox( Configuration.show_seq_symbols,
1088 _configuration.doCheckOption( Configuration.show_seq_symbols ) );
1090 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1091 addCheckbox( Configuration.show_sequence_acc,
1092 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1093 setCheckbox( Configuration.show_sequence_acc,
1094 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1096 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1097 addCheckbox( Configuration.show_annotation,
1098 _configuration.getDisplayTitle( Configuration.show_annotation ) );
1099 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1101 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1102 addCheckbox( Configuration.write_confidence_values,
1103 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1104 setCheckbox( Configuration.write_confidence_values,
1105 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1107 if ( _configuration.doDisplayOption( Configuration.write_branch_length_values ) ) {
1108 addCheckbox( Configuration.write_branch_length_values,
1109 _configuration.getDisplayTitle( Configuration.write_branch_length_values ) );
1110 setCheckbox( Configuration.write_branch_length_values,
1111 _configuration.doCheckOption( Configuration.write_branch_length_values ) );
1113 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1114 addCheckbox( Configuration.show_binary_characters,
1115 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1116 setCheckbox( Configuration.show_binary_characters,
1117 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1119 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1120 addCheckbox( Configuration.show_binary_character_counts,
1121 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1122 setCheckbox( Configuration.show_binary_character_counts,
1123 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1125 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1126 addCheckbox( Configuration.show_domain_architectures,
1127 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1128 setCheckbox( Configuration.show_domain_architectures,
1129 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1131 if ( _configuration.doDisplayOption( Configuration.show_mol_seqs ) ) {
1132 addCheckbox( Configuration.show_mol_seqs, _configuration.getDisplayTitle( Configuration.show_mol_seqs ) );
1133 setCheckbox( Configuration.show_mol_seqs, _configuration.doCheckOption( Configuration.show_mol_seqs ) );
1135 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1136 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1137 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1139 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1140 addCheckbox( Configuration.show_vector_data,
1141 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1142 setCheckbox( Configuration.show_vector_data,
1143 _configuration.doCheckOption( Configuration.show_vector_data ) );
1145 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1146 addCheckbox( Configuration.show_properties,
1147 _configuration.getDisplayTitle( Configuration.show_properties ) );
1148 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1150 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1151 addCheckbox( Configuration.show_taxonomy_images,
1152 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1153 setCheckbox( Configuration.show_taxonomy_images,
1154 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1158 private void setVisibilityOfDomainStrucureControls() {
1159 if ( _zoom_in_domain_structure != null ) {
1160 final MainFrame mf = getMainFrame();
1162 if ( isShowDomainArchitectures() ) {
1163 _domain_display_label.setVisible( true );
1164 _zoom_in_domain_structure.setVisible( true );
1165 _zoom_out_domain_structure.setVisible( true );
1166 _decr_domain_structure_evalue_thr.setVisible( true );
1167 _incr_domain_structure_evalue_thr.setVisible( true );
1168 _domain_structure_evalue_thr_tf.setVisible( true );
1169 if ( mf._right_line_up_domains_cbmi != null ) {
1170 mf._right_line_up_domains_cbmi.setVisible( true );
1172 if ( mf._show_domain_labels != null ) {
1173 mf._show_domain_labels.setVisible( true );
1177 _domain_display_label.setVisible( false );
1178 _zoom_in_domain_structure.setVisible( false );
1179 _zoom_out_domain_structure.setVisible( false );
1180 _decr_domain_structure_evalue_thr.setVisible( false );
1181 _incr_domain_structure_evalue_thr.setVisible( false );
1182 _domain_structure_evalue_thr_tf.setVisible( false );
1183 if ( mf._right_line_up_domains_cbmi != null ) {
1184 mf._right_line_up_domains_cbmi.setVisible( false );
1186 if ( mf._show_domain_labels != null ) {
1187 mf._show_domain_labels.setVisible( false );
1194 void activateButtonToReturnToSuperTree( int index ) {
1197 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
1200 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
1202 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1203 _return_to_super_tree.setEnabled( true );
1206 void activateButtonToUncollapseAll() {
1207 _uncollapse_all.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1208 _uncollapse_all.setEnabled( true );
1213 * Add zoom and quick edit buttons. (Last modified 8/9/04)
1216 final JLabel spacer = new JLabel( "" );
1217 spacer.setOpaque( false );
1219 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
1220 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1221 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
1222 final JPanel o_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1223 if ( !getConfiguration().isUseNativeUI() ) {
1224 x_panel.setBackground( getBackground() );
1225 y_panel.setBackground( getBackground() );
1226 z_panel.setBackground( getBackground() );
1227 o_panel.setBackground( getBackground() );
1229 add( _zoom_label = new JLabel( "Zoom:" ) );
1230 customizeLabel( _zoom_label, getConfiguration() );
1234 if ( getConfiguration().isUseNativeUI() ) {
1235 _zoom_in_x = new TypomaticJButton( "+" );
1236 _zoom_out_x = new TypomaticJButton( "-" );
1239 _zoom_in_x = new TypomaticJButton( "X+" );
1240 _zoom_out_x = new TypomaticJButton( "X-" );
1242 _zoom_in_y = new TypomaticJButton( "Y+" );
1243 _zoom_out_y = new TypomaticJButton( "Y-" );
1244 _show_whole = new JButton( "F" );
1245 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [F or Home]" );
1246 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+cursor-right]" );
1247 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+cursor-up]" );
1248 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+cursor-left]" );
1249 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+cursor-down]" );
1250 if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) {
1251 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
1252 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
1255 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
1256 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
1258 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
1259 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
1260 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
1261 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
1262 _return_to_super_tree.setToolTipText( "return to the super-tree (if in sub-tree)" );
1263 _return_to_super_tree.setEnabled( false );
1264 _order = new JButton( "O" );
1265 _order.setToolTipText( "order all" );
1266 _uncollapse_all = new JButton( "U" );
1267 _uncollapse_all.setToolTipText( "uncollapse all" );
1268 addJButton( _zoom_in_y, x_panel );
1269 addJButton( _zoom_out_x, y_panel );
1270 addJButton( _show_whole, y_panel );
1271 addJButton( _zoom_in_x, y_panel );
1272 addJButton( _zoom_out_y, z_panel );
1274 final JLabel spacer2 = new JLabel( "" );
1277 addJButton( _order, o_panel );
1278 addJButton( _return_to_super_tree, o_panel );
1279 addJButton( _uncollapse_all, o_panel );
1281 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
1282 setUpControlsForDomainStrucures();
1285 setUpControlsForDepthCollapse();
1288 setUpControlsForRankCollapse();
1291 final JLabel spacer3 = new JLabel( "" );
1293 setVisibilityOfDomainStrucureControls();
1296 void addCheckbox( final int which, final String title ) {
1297 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
1299 case Configuration.display_as_phylogram:
1300 _display_as_phylogram_cb = new JCheckBox( title );
1301 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
1302 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
1305 case Configuration.display_internal_data:
1306 _display_internal_data = new JCheckBox( title );
1307 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
1308 addJCheckBox( _display_internal_data, ch_panel );
1311 case Configuration.color_according_to_species:
1312 _color_acc_species = new JCheckBox( title );
1313 _color_acc_species.setToolTipText( "To colorize node labels as a function of taxonomy" );
1314 addJCheckBox( _color_acc_species, ch_panel );
1317 case Configuration.color_according_to_sequence:
1318 _color_acc_sequence = new JCheckBox( title );
1319 _color_acc_sequence.setToolTipText( "To colorize node labels as a function of sequence name" );
1320 addJCheckBox( _color_acc_sequence, ch_panel );
1323 case Configuration.color_according_to_annotation:
1324 _color_according_to_annotation = new JCheckBox( title );
1325 _color_according_to_annotation
1326 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
1327 addJCheckBox( _color_according_to_annotation, ch_panel );
1330 case Configuration.show_node_names:
1331 _show_node_names = new JCheckBox( title );
1332 addJCheckBox( _show_node_names, ch_panel );
1335 case Configuration.show_taxonomy_scientific_names:
1336 _show_taxo_scientific_names = new JCheckBox( title );
1337 addJCheckBox( _show_taxo_scientific_names, ch_panel );
1340 case Configuration.show_taxonomy_common_names:
1341 _show_taxo_common_names = new JCheckBox( title );
1342 addJCheckBox( _show_taxo_common_names, ch_panel );
1345 case Configuration.show_tax_code:
1346 _show_taxo_code = new JCheckBox( title );
1347 addJCheckBox( _show_taxo_code, ch_panel );
1350 case Configuration.show_tax_rank:
1351 _show_taxo_rank = new JCheckBox( title );
1352 addJCheckBox( _show_taxo_rank, ch_panel );
1355 case Configuration.show_taxonomy_images:
1356 _show_taxo_images_cb = new JCheckBox( title );
1357 addJCheckBox( _show_taxo_images_cb, ch_panel );
1360 case Configuration.show_binary_characters:
1361 _show_binary_characters = new JCheckBox( title );
1362 addJCheckBox( _show_binary_characters, ch_panel );
1365 case Configuration.show_annotation:
1366 _show_annotation = new JCheckBox( title );
1367 addJCheckBox( _show_annotation, ch_panel );
1370 case Configuration.show_binary_character_counts:
1371 _show_binary_character_counts = new JCheckBox( title );
1372 addJCheckBox( _show_binary_character_counts, ch_panel );
1375 case Configuration.write_confidence_values:
1376 _write_confidence = new JCheckBox( title );
1377 addJCheckBox( getWriteConfidenceCb(), ch_panel );
1380 case Configuration.write_events:
1381 _show_events = new JCheckBox( title );
1382 addJCheckBox( getShowEventsCb(), ch_panel );
1385 case Configuration.use_style:
1386 _use_visual_styles_cb = new JCheckBox( title );
1387 getUseVisualStylesCb()
1388 .setToolTipText( "To use visual styles (node colors, fonts) and branch colors, if present" );
1389 addJCheckBox( getUseVisualStylesCb(), ch_panel );
1392 case Configuration.width_branches:
1393 _width_branches = new JCheckBox( title );
1394 _width_branches.setToolTipText( "To use branch width values, if present" );
1395 addJCheckBox( _width_branches, ch_panel );
1398 case Configuration.write_branch_length_values:
1399 _write_branch_length_values = new JCheckBox( title );
1400 addJCheckBox( _write_branch_length_values, ch_panel );
1403 case Configuration.show_domain_architectures:
1404 _show_domain_architectures = new JCheckBox( title );
1405 addJCheckBox( _show_domain_architectures, ch_panel );
1408 case Configuration.show_mol_seqs:
1409 _show_mol_seqs = new JCheckBox( title );
1410 addJCheckBox( _show_mol_seqs, ch_panel );
1413 case Configuration.show_seq_names:
1414 _show_seq_names = new JCheckBox( title );
1415 addJCheckBox( _show_seq_names, ch_panel );
1418 case Configuration.show_gene_names:
1419 _show_gene_names = new JCheckBox( title );
1420 addJCheckBox( _show_gene_names, ch_panel );
1423 case Configuration.show_seq_symbols:
1424 _show_seq_symbols = new JCheckBox( title );
1425 addJCheckBox( _show_seq_symbols, ch_panel );
1428 case Configuration.show_sequence_acc:
1429 _show_sequence_acc = new JCheckBox( title );
1430 addJCheckBox( _show_sequence_acc, ch_panel );
1433 case Configuration.dynamically_hide_data:
1434 _dynamically_hide_data = new JCheckBox( title );
1435 getDynamicallyHideData().setToolTipText( "To hide labels depending on expected visibility" );
1436 addJCheckBox( getDynamicallyHideData(), ch_panel );
1439 case Configuration.node_data_popup:
1440 _node_desc_popup_cb = new JCheckBox( title );
1441 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
1442 addJCheckBox( getNodeDescPopupCb(), ch_panel );
1445 case Configuration.show_relation_confidence:
1446 _seq_relation_confidence_switch = new JCheckBox( title );
1447 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
1450 case Configuration.show_vector_data:
1451 _show_vector_data_cb = new JCheckBox( title );
1452 addJCheckBox( _show_vector_data_cb, ch_panel );
1455 case Configuration.show_properties:
1456 _show_properties_cb = new JCheckBox( title );
1457 addJCheckBox( _show_properties_cb, ch_panel );
1461 throw new RuntimeException( "unknown checkbox: " + which );
1465 void addJButton( final JButton jb, final JPanel p ) {
1466 jb.setFocusPainted( false );
1467 jb.setFont( ControlPanel.jcb_font );
1468 if ( !_configuration.isUseNativeUI() ) {
1469 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
1470 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1471 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
1474 jb.addActionListener( this );
1477 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
1478 jcb.setFocusPainted( false );
1479 jcb.setFont( ControlPanel.jcb_font );
1480 if ( !_configuration.isUseNativeUI() ) {
1481 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
1482 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1484 p.add( jcb, "Center" );
1485 jcb.addActionListener( this );
1488 void addJTextField( final JTextField tf, final JPanel p ) {
1489 if ( !_configuration.isUseNativeUI() ) {
1490 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
1491 tf.setFont( ControlPanel.jcb_font );
1494 tf.addActionListener( this );
1497 void deactivateButtonToReturnToSuperTree() {
1498 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
1499 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
1500 _return_to_super_tree.setEnabled( false );
1503 void deactivateButtonToUncollapseAll() {
1504 _uncollapse_all.setForeground( getConfiguration().getGuiButtonTextColor() );
1505 _uncollapse_all.setEnabled( false );
1509 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
1510 if ( ( _mainpanel != null )
1511 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
1512 if ( recalc_longest_ext_node_info ) {
1513 _mainpanel.getCurrentTreePanel().initNodeData();
1514 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
1516 if ( getOptions().isShowOverview() ) {
1517 _mainpanel.getCurrentTreePanel().updateOvSizes();
1519 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
1520 setVisibilityOfDomainStrucureControls();
1521 updateDomainStructureEvaluethresholdDisplay();
1522 updateDepthCollapseDepthDisplay();
1523 updateRankCollapseRankDisplay();
1524 getMainPanel().getControlPanel();
1525 _mainpanel.getCurrentTreePanel().updateButtonToUncollapseAll();
1526 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
1527 _mainpanel.getCurrentTreePanel().calcMaxDepth();
1528 _mainpanel.adjustJScrollPane();
1529 _mainpanel.getCurrentTreePanel().repaint();
1530 // _mainpanel.getCurrentTreePanel().setUpUrtFactor();
1534 void endClickToOptions() {
1535 _click_to_combobox.addActionListener( this );
1539 * Indicates what action should be execute when a node is clicked
1541 * @return the click-on action
1543 NodeClickAction getActionWhenNodeClicked() {
1544 return _action_when_node_clicked;
1547 Map<Integer, String> getAllClickToItems() {
1548 return _all_click_to_names;
1551 Map<String, Color> getAnnotationColors() {
1552 return _annotation_colors;
1555 Configuration getConfiguration() {
1556 return _configuration;
1559 TreePanel getCurrentTreePanel() {
1560 return getMainPanel().getCurrentTreePanel();
1563 MainPanel getMainPanel() {
1567 Options getOptions() {
1568 return getMainPanel().getOptions();
1571 JLabel getSearchFoundCountsLabel0() {
1572 return _search_found_label_0;
1575 JLabel getSearchFoundCountsLabel1() {
1576 return _search_found_label_1;
1579 JButton getSearchResetButton0() {
1580 return _search_reset_button_0;
1583 JButton getSearchResetButton1() {
1584 return _search_reset_button_1;
1587 JTextField getSearchTextField0() {
1588 return _search_tf_0;
1591 JTextField getSearchTextField1() {
1592 return _search_tf_1;
1595 Map<String, Color> getSequenceColors() {
1596 return _sequence_colors;
1599 List<String> getSingleClickToNames() {
1600 return _click_to_names;
1603 Map<String, Color> getSpeciesColors() {
1604 return _species_colors;
1607 boolean isAntialiasScreenText() {
1611 boolean isColorAccordingToAnnotation() {
1612 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
1615 boolean isColorAccordingToSequence() {
1616 return ( ( _color_acc_sequence != null ) && _color_acc_sequence.isSelected() );
1619 boolean isColorAccordingToTaxonomy() {
1620 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
1623 boolean isDrawPhylogram() {
1624 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
1627 boolean isDynamicallyHideData() {
1628 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
1631 boolean isEvents() {
1632 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
1635 boolean isNodeDescPopup() {
1636 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
1639 boolean isShowAnnotation() {
1640 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
1643 boolean isShowBinaryCharacterCounts() {
1644 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
1647 boolean isShowBinaryCharacters() {
1648 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
1651 boolean isShowConfidenceValues() {
1652 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
1655 boolean isShowDomainArchitectures() {
1656 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
1659 boolean isShowGeneNames() {
1660 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
1663 boolean isShowInternalData() {
1664 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
1667 boolean isShowNodeNames() {
1668 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
1671 boolean isShowSeqNames() {
1672 return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
1675 boolean isShowSeqSymbols() {
1676 return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
1679 boolean isShowSequenceAcc() {
1680 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
1683 boolean isShowSequenceRelationConfidence() {
1684 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
1687 boolean isShowSequenceRelations() {
1688 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
1691 boolean isShowTaxonomyCode() {
1692 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
1695 boolean isShowTaxonomyRank() {
1696 return ( ( _show_taxo_rank != null ) && _show_taxo_rank.isSelected() );
1699 boolean isShowTaxonomyCommonNames() {
1700 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
1703 boolean isShowTaxonomyScientificNames() {
1704 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
1707 boolean isUseVisualStyles() {
1708 return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() )
1709 || ( ( getUseVisualStylesCb() == null ) && _color_branches ) );
1712 boolean isWidthBranches() {
1713 return ( ( _width_branches != null ) && _width_branches.isSelected() );
1716 boolean isWriteBranchLengthValues() {
1717 return ( ( _write_branch_length_values != null ) && _write_branch_length_values.isSelected() );
1720 void phylogenyAdded( final Configuration configuration ) {
1721 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
1724 void phylogenyRemoved( final int index ) {
1725 getIsDrawPhylogramList().remove( index );
1729 final MainPanel main_panel = getMainPanel();
1730 final Phylogeny tree = main_panel.getCurrentPhylogeny();
1731 if ( ( tree == null ) || tree.isEmpty() ) {
1734 String query = getSearchTextField0().getText();
1735 if ( query != null ) {
1736 query = query.trim();
1738 if ( !ForesterUtil.isEmpty( query ) ) {
1739 search0( main_panel, tree, query );
1742 getSearchFoundCountsLabel0().setVisible( false );
1743 getSearchResetButton0().setEnabled( false );
1744 getSearchResetButton0().setVisible( false );
1750 final MainPanel main_panel = getMainPanel();
1751 final Phylogeny tree = main_panel.getCurrentPhylogeny();
1752 if ( ( tree == null ) || tree.isEmpty() ) {
1755 String query = getSearchTextField1().getText();
1756 if ( query != null ) {
1757 query = query.trim();
1759 if ( !ForesterUtil.isEmpty( query ) ) {
1760 search1( main_panel, tree, query );
1763 getSearchFoundCountsLabel1().setVisible( false );
1764 getSearchResetButton1().setEnabled( false );
1765 getSearchResetButton1().setVisible( false );
1770 void searchReset0() {
1771 if ( getMainPanel().getCurrentTreePanel() != null ) {
1772 getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
1776 void searchReset1() {
1777 if ( getMainPanel().getCurrentTreePanel() != null ) {
1778 getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
1782 void setActionWhenNodeClicked( final NodeClickAction action ) {
1783 _action_when_node_clicked = action;
1786 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
1787 _annotation_colors = annotation_colors;
1790 void setCheckbox( final int which, final boolean state ) {
1792 case Configuration.display_as_phylogram:
1793 if ( getDisplayAsPhylogramCb() != null ) {
1794 getDisplayAsPhylogramCb().setSelected( state );
1797 case Configuration.display_internal_data:
1798 if ( _display_internal_data != null ) {
1799 _display_internal_data.setSelected( state );
1802 case Configuration.color_according_to_species:
1803 if ( _color_acc_species != null ) {
1804 _color_acc_species.setSelected( state );
1807 case Configuration.color_according_to_sequence:
1808 if ( _color_acc_sequence != null ) {
1809 _color_acc_sequence.setSelected( state );
1812 case Configuration.color_according_to_annotation:
1813 if ( _color_according_to_annotation != null ) {
1814 _color_according_to_annotation.setSelected( state );
1817 case Configuration.show_node_names:
1818 if ( _show_node_names != null ) {
1819 _show_node_names.setSelected( state );
1822 case Configuration.show_taxonomy_scientific_names:
1823 if ( _show_taxo_scientific_names != null ) {
1824 _show_taxo_scientific_names.setSelected( state );
1827 case Configuration.show_taxonomy_common_names:
1828 if ( _show_taxo_common_names != null ) {
1829 _show_taxo_common_names.setSelected( state );
1832 case Configuration.show_tax_code:
1833 if ( _show_taxo_code != null ) {
1834 _show_taxo_code.setSelected( state );
1837 case Configuration.show_tax_rank:
1838 if ( _show_taxo_rank != null ) {
1839 _show_taxo_rank.setSelected( state );
1842 case Configuration.show_taxonomy_images:
1843 if ( _show_taxo_images_cb != null ) {
1844 _show_taxo_images_cb.setSelected( state );
1847 case Configuration.show_annotation:
1848 if ( _show_annotation != null ) {
1849 _show_annotation.setSelected( state );
1852 case Configuration.show_binary_characters:
1853 if ( _show_binary_characters != null ) {
1854 _show_binary_characters.setSelected( state );
1857 case Configuration.show_binary_character_counts:
1858 if ( _show_binary_character_counts != null ) {
1859 _show_binary_character_counts.setSelected( state );
1862 case Configuration.write_confidence_values:
1863 if ( getWriteConfidenceCb() != null ) {
1864 getWriteConfidenceCb().setSelected( state );
1867 case Configuration.write_events:
1868 if ( getShowEventsCb() != null ) {
1869 getShowEventsCb().setSelected( state );
1872 case Configuration.use_style:
1873 if ( getUseVisualStylesCb() != null ) {
1874 getUseVisualStylesCb().setSelected( state );
1877 case Configuration.width_branches:
1878 if ( _width_branches != null ) {
1879 _width_branches.setSelected( state );
1882 case Configuration.show_domain_architectures:
1883 if ( _show_domain_architectures != null ) {
1884 _show_domain_architectures.setSelected( state );
1887 case Configuration.write_branch_length_values:
1888 if ( _write_branch_length_values != null ) {
1889 _write_branch_length_values.setSelected( state );
1892 case Configuration.show_mol_seqs:
1893 if ( _show_mol_seqs != null ) {
1894 _show_mol_seqs.setSelected( state );
1897 case Configuration.show_seq_names:
1898 if ( _show_seq_names != null ) {
1899 _show_seq_names.setSelected( state );
1902 case Configuration.show_gene_names:
1903 if ( _show_gene_names != null ) {
1904 _show_gene_names.setSelected( state );
1907 case Configuration.show_seq_symbols:
1908 if ( _show_seq_symbols != null ) {
1909 _show_seq_symbols.setSelected( state );
1912 case Configuration.show_vector_data:
1913 if ( _show_vector_data_cb != null ) {
1914 _show_vector_data_cb.setSelected( state );
1917 case Configuration.show_properties:
1918 if ( _show_properties_cb != null ) {
1919 _show_properties_cb.setSelected( state );
1922 case Configuration.show_sequence_acc:
1923 if ( _show_sequence_acc != null ) {
1924 _show_sequence_acc.setSelected( state );
1927 case Configuration.dynamically_hide_data:
1928 if ( getDynamicallyHideData() != null ) {
1929 getDynamicallyHideData().setSelected( state );
1932 case Configuration.node_data_popup:
1933 if ( getNodeDescPopupCb() != null ) {
1934 getNodeDescPopupCb().setSelected( state );
1938 case Configuration.show_relation_confidence:
1939 if ( _seq_relation_confidence_switch != null ) {
1940 _seq_relation_confidence_switch.setSelected( state );
1945 throw new AssertionError( "unknown checkbox: " + which );
1950 * Set this checkbox state. Not all checkboxes have been instantiated
1951 * depending on the config.
1953 void setCheckbox( final JCheckBox cb, final boolean state ) {
1955 cb.setSelected( state );
1959 void setClickToAction( final int action ) {
1960 // Set click-to action
1961 if ( action == _show_data_item ) {
1962 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1964 else if ( action == _collapse_cb_item ) {
1965 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1967 else if ( action == _reroot_cb_item ) {
1968 setActionWhenNodeClicked( NodeClickAction.REROOT );
1970 else if ( action == _subtree_cb_item ) {
1971 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1973 else if ( action == _swap_cb_item ) {
1974 setActionWhenNodeClicked( NodeClickAction.SWAP );
1976 else if ( action == _color_subtree_cb_item ) {
1977 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1979 else if ( action == _open_seq_web_item ) {
1980 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1982 else if ( action == _sort_descendents_item ) {
1983 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1985 else if ( action == _blast_item ) {
1986 setActionWhenNodeClicked( NodeClickAction.BLAST );
1988 else if ( action == _open_tax_web_item ) {
1989 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1991 else if ( action == _cut_subtree_item ) {
1992 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1994 else if ( action == _copy_subtree_item ) {
1995 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1997 else if ( action == _delete_node_or_subtree_item ) {
1998 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
2000 else if ( action == _paste_subtree_item ) {
2001 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
2003 else if ( action == _add_new_node_item ) {
2004 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
2006 else if ( action == _edit_node_data_item ) {
2007 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
2009 else if ( action == _select_nodes_item ) {
2010 setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
2012 else if ( action == _get_ext_desc_data ) {
2013 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
2015 else if ( action == _open_pdb_item ) {
2016 setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
2018 else if ( action == _color_node_font_item ) {
2019 setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
2021 else if ( action == _change_node_font_item ) {
2022 setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT );
2024 else if ( action == _uncollapse_all_cb_item ) {
2025 setActionWhenNodeClicked( NodeClickAction.UNCOLLAPSE_ALL );
2027 else if ( action == _order_subtree_cb_item ) {
2028 setActionWhenNodeClicked( NodeClickAction.ORDER_SUBTREE );
2031 throw new RuntimeException( "unknown action: " + action );
2033 // make sure drop down is displaying the correct action
2034 // in case this was called from outside the class
2035 _click_to_combobox.setSelectedIndex( action );
2038 void setColorBranches( final boolean color_branches ) {
2039 _color_branches = color_branches;
2042 void setDrawPhylogram( final boolean b ) {
2043 getDisplayAsPhylogramCb().setSelected( b );
2044 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
2047 void setDrawPhylogramEnabled( final boolean b ) {
2048 getDisplayAsPhylogramCb().setEnabled( b );
2051 void setDynamicHidingIsOn( final boolean is_on ) {
2053 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
2056 if ( !_configuration.isUseNativeUI() ) {
2057 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
2060 getDynamicallyHideData().setForeground( Color.BLACK );
2065 void setSearchFoundCountsOnLabel0( final int counts ) {
2066 getSearchFoundCountsLabel0().setText( "Found: " + counts );
2069 void setSearchFoundCountsOnLabel1( final int counts ) {
2070 getSearchFoundCountsLabel1().setText( "Found: " + counts );
2073 void setSequenceColors( final Map<String, Color> sequence_colors ) {
2074 _sequence_colors = sequence_colors;
2077 void setShowEvents( final boolean show_events ) {
2078 if ( getShowEventsCb() == null ) {
2079 _show_events = new JCheckBox( "" );
2081 getShowEventsCb().setSelected( show_events );
2084 void setSpeciesColors( final Map<String, Color> species_colors ) {
2085 _species_colors = species_colors;
2088 void setupControls() {
2089 // The tree display options:
2090 setupDisplayCheckboxes();
2092 // The sequence relation query selection combo-box
2093 if ( _configuration.displaySequenceRelations() ) {
2094 addSequenceRelationBlock();
2098 startClickToOptions();
2099 setupClickToOptions();
2100 endClickToOptions();
2101 // Zoom and quick edit buttons
2103 setupSearchTools0();
2104 setupSearchTools1();
2107 void setUpControlsForDomainStrucures() {
2108 _domain_display_label = new JLabel( "Domain Architectures:" );
2109 add( customizeLabel( _domain_display_label, getConfiguration() ) );
2110 add( _domain_display_label );
2111 _zoom_in_domain_structure = new TypomaticJButton( "d+" );
2112 _zoom_out_domain_structure = new TypomaticJButton( "d-" );
2113 _decr_domain_structure_evalue_thr = new JButton( "-" );
2114 _incr_domain_structure_evalue_thr = new JButton( "+" );
2115 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
2116 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
2117 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
2118 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
2119 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
2120 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
2121 _domain_structure_evalue_thr_tf = new JTextField( 3 );
2122 _domain_structure_evalue_thr_tf.setEditable( false );
2123 if ( !getConfiguration().isUseNativeUI() ) {
2124 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2125 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2126 _domain_structure_evalue_thr_tf.setBorder( null );
2128 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2129 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2130 if ( !_configuration.isUseNativeUI() ) {
2131 d1_panel.setBackground( getBackground() );
2132 d2_panel.setBackground( getBackground() );
2136 addJButton( _zoom_out_domain_structure, d1_panel );
2137 addJButton( _zoom_in_domain_structure, d1_panel );
2138 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
2139 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
2140 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
2143 void setUpControlsForDepthCollapse() {
2144 _depth_collapse_label = new JLabel( "Collapse by Node Depth:" );
2145 _depth_collapse_label
2146 .setToolTipText( "to automaticall collapse nodes with a depth equal or larger than a threshold" );
2147 add( customizeLabel( _depth_collapse_label, getConfiguration() ) );
2148 add( _depth_collapse_label );
2149 _decr_depth_collapse_level = new TypomaticJButton( "-" );
2150 _incr_depth_collapse_level = new TypomaticJButton( "+" );
2151 _decr_depth_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2152 _incr_depth_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2153 _decr_depth_collapse_level.setToolTipText( "to decrease the depth threshold (wraps around)" );
2154 _incr_depth_collapse_level.setToolTipText( "to increase the depth threshold (wraps around)" );
2155 _depth_collapse_depth_tf = new JTextField( 3 );
2156 _depth_collapse_depth_tf.setToolTipText( "the current depth threshold" );
2157 _depth_collapse_depth_tf.setEditable( false );
2158 if ( !getConfiguration().isUseNativeUI() ) {
2159 _depth_collapse_depth_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2160 _depth_collapse_depth_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2161 _depth_collapse_depth_tf.setBorder( null );
2163 final JPanel panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2164 if ( !_configuration.isUseNativeUI() ) {
2165 panel.setBackground( getBackground() );
2168 addJButton( _decr_depth_collapse_level, panel );
2169 addJTextField( _depth_collapse_depth_tf, panel );
2170 addJButton( _incr_depth_collapse_level, panel );
2173 void setUpControlsForRankCollapse() {
2174 _rank_collapse_label = new JLabel( "Collapse by Node Rank:" );
2175 _rank_collapse_label
2176 .setToolTipText( "to automatically collapse nodes with a taxonomic rank equal or lower than a threshold" );
2177 add( customizeLabel( _rank_collapse_label, getConfiguration() ) );
2178 add( _rank_collapse_label );
2179 _decr_rank_collapse_level = new TypomaticJButton( "-" );
2180 _incr_rank_collapse_level = new TypomaticJButton( "+" );
2181 _decr_rank_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2182 _incr_rank_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2183 _decr_rank_collapse_level.setToolTipText( "to decrease the taxonomic rank threshold (wraps around)" );
2184 _incr_rank_collapse_level.setToolTipText( "to increase the taxonomic rank threshold (wraps around)" );
2185 _rank_collapse_depth_tf = new JTextField( 3 );
2186 _rank_collapse_depth_tf.setToolTipText( "the current taxonomic rank threshold" );
2187 _rank_collapse_depth_tf.setEditable( false );
2188 if ( !getConfiguration().isUseNativeUI() ) {
2189 _rank_collapse_depth_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2190 _rank_collapse_depth_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2191 _rank_collapse_depth_tf.setBorder( null );
2193 final JPanel panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2194 if ( !_configuration.isUseNativeUI() ) {
2195 panel.setBackground( getBackground() );
2198 addJButton( _decr_rank_collapse_level, panel );
2199 addJTextField( _rank_collapse_depth_tf, panel );
2200 addJButton( _incr_rank_collapse_level, panel );
2203 void setupSearchTools0() {
2204 final JLabel search_label = new JLabel( "Search (A):" );
2205 search_label.setFont( ControlPanel.jcb_bold_font );
2206 if ( !getConfiguration().isUseNativeUI() ) {
2207 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2209 add( search_label );
2210 search_label.setToolTipText( SEARCH_TIP_TEXT );
2211 _search_found_label_0 = new JLabel();
2212 getSearchFoundCountsLabel0().setVisible( false );
2213 _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
2214 if ( !getConfiguration().isUseNativeUI() ) {
2215 _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2217 _search_tf_0 = new JTextField( 3 );
2218 _search_tf_0.setToolTipText( SEARCH_TIP_TEXT );
2219 _search_tf_0.setEditable( true );
2220 if ( !getConfiguration().isUseNativeUI() ) {
2221 _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2222 _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2223 _search_tf_0.setBorder( null );
2225 _search_reset_button_0 = new JButton();
2226 getSearchResetButton0().setText( "Reset" );
2227 getSearchResetButton0().setEnabled( false );
2228 getSearchResetButton0().setVisible( false );
2229 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
2230 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2231 s_panel_1.setBackground( getBackground() );
2233 s_panel_2.setBackground( getBackground() );
2235 final KeyAdapter key_adapter = new KeyAdapter() {
2238 public void keyReleased( final KeyEvent key_event ) {
2240 displayedPhylogenyMightHaveChanged( true );
2243 final ActionListener action_listener = new ActionListener() {
2246 public void actionPerformed( final ActionEvent e ) {
2248 setSearchFoundCountsOnLabel0( 0 );
2249 getSearchFoundCountsLabel0().setVisible( false );
2250 getSearchTextField0().setText( "" );
2251 getSearchResetButton0().setEnabled( false );
2252 getSearchResetButton0().setVisible( false );
2253 displayedPhylogenyMightHaveChanged( true );
2256 _search_reset_button_0.addActionListener( action_listener );
2257 _search_tf_0.addKeyListener( key_adapter );
2258 addJTextField( _search_tf_0, s_panel_1 );
2259 s_panel_2.add( _search_found_label_0 );
2260 addJButton( _search_reset_button_0, s_panel_2 );
2263 void setupSearchTools1() {
2264 final JLabel search_label = new JLabel( "Search (B):" );
2265 search_label.setFont( ControlPanel.jcb_bold_font );
2266 if ( !getConfiguration().isUseNativeUI() ) {
2267 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2269 add( search_label );
2270 search_label.setToolTipText( SEARCH_TIP_TEXT );
2271 _search_found_label_1 = new JLabel();
2272 getSearchFoundCountsLabel1().setVisible( false );
2273 _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
2274 if ( !getConfiguration().isUseNativeUI() ) {
2275 _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2277 _search_tf_1 = new JTextField( 3 );
2278 _search_tf_1.setToolTipText( SEARCH_TIP_TEXT );
2279 _search_tf_1.setEditable( true );
2280 if ( !getConfiguration().isUseNativeUI() ) {
2281 _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2282 _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2283 _search_tf_1.setBorder( null );
2285 _search_reset_button_1 = new JButton();
2286 getSearchResetButton1().setText( "Reset" );
2287 getSearchResetButton1().setEnabled( false );
2288 getSearchResetButton1().setVisible( false );
2289 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
2290 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2291 s_panel_1.setBackground( getBackground() );
2293 s_panel_2.setBackground( getBackground() );
2295 final KeyAdapter key_adapter = new KeyAdapter() {
2298 public void keyReleased( final KeyEvent key_event ) {
2300 displayedPhylogenyMightHaveChanged( true );
2303 final ActionListener action_listener = new ActionListener() {
2306 public void actionPerformed( final ActionEvent e ) {
2308 setSearchFoundCountsOnLabel1( 0 );
2309 getSearchFoundCountsLabel1().setVisible( false );
2310 getSearchTextField1().setText( "" );
2311 getSearchResetButton1().setEnabled( false );
2312 getSearchResetButton1().setVisible( false );
2313 displayedPhylogenyMightHaveChanged( true );
2316 _search_reset_button_1.addActionListener( action_listener );
2317 _search_tf_1.addKeyListener( key_adapter );
2318 addJTextField( _search_tf_1, s_panel_1 );
2319 s_panel_2.add( _search_found_label_1 );
2320 addJButton( _search_reset_button_1, s_panel_2 );
2323 void setVisibilityOfDomainStrucureCB() {
2325 if ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel()
2326 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2327 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
2328 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2329 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
2331 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2332 getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
2335 else if ( isShowDomainArchitectures() ) {
2336 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2337 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( true );
2339 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2340 getMainPanel().getMainFrame()._show_domain_labels.setVisible( true );
2344 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2345 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
2347 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2348 getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
2352 catch ( final Exception ignore ) {
2357 void setVisibilityOfX() {
2358 final MainFrame mf = getMainFrame();
2360 if ( ( getCurrentTreePanel() != null ) && ( getCurrentTreePanel().getPhylogeny() != null ) ) {
2361 if ( AptxUtil.isHasAtLeastOneBranchWithSupportSD( getCurrentTreePanel().getPhylogeny() ) ) {
2362 if ( mf._show_confidence_stddev_cbmi != null ) {
2363 mf._show_confidence_stddev_cbmi.setVisible( true );
2367 if ( mf._show_confidence_stddev_cbmi != null ) {
2368 mf._show_confidence_stddev_cbmi.setVisible( false );
2371 if ( AptxUtil.isHasAtLeastOneNodeWithScientificName( getCurrentTreePanel().getPhylogeny() ) ) {
2372 if ( mf._abbreviate_scientific_names != null ) {
2373 mf._abbreviate_scientific_names.setVisible( true );
2377 if ( mf._abbreviate_scientific_names != null ) {
2378 mf._abbreviate_scientific_names.setVisible( false );
2381 if ( AptxUtil.isHasAtLeastOneNodeWithSequenceAnnotation( getCurrentTreePanel().getPhylogeny() ) ) {
2382 if ( mf._show_annotation_ref_source != null ) {
2383 mf._show_annotation_ref_source.setVisible( true );
2387 if ( mf._show_annotation_ref_source != null ) {
2388 mf._show_annotation_ref_source.setVisible( false );
2392 if ( isDrawPhylogram() || ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel()
2393 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2394 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) ) {
2395 if ( mf._non_lined_up_cladograms_rbmi != null ) {
2396 mf._non_lined_up_cladograms_rbmi.setVisible( false );
2398 if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
2399 mf._ext_node_dependent_cladogram_rbmi.setVisible( false );
2403 if ( mf._non_lined_up_cladograms_rbmi != null ) {
2404 mf._non_lined_up_cladograms_rbmi.setVisible( true );
2406 if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
2407 mf._ext_node_dependent_cladogram_rbmi.setVisible( true );
2410 if ( isDrawPhylogram() ) {
2411 if ( mf._show_scale_cbmi != null ) {
2412 mf._show_scale_cbmi.setVisible( true );
2416 if ( mf._show_scale_cbmi != null ) {
2417 mf._show_scale_cbmi.setVisible( false );
2420 if ( getCurrentTreePanel() != null ) {
2421 if ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2422 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
2423 if ( mf._label_direction_cbmi != null ) {
2424 mf._label_direction_cbmi.setVisible( true );
2428 if ( mf._label_direction_cbmi != null ) {
2429 mf._label_direction_cbmi.setVisible( false );
2436 void showAnnotations() {
2437 if ( _show_annotation != null ) {
2438 _show_annotation.setSelected( true );
2440 if ( _color_according_to_annotation != null ) {
2441 _color_according_to_annotation.setSelected( true );
2443 if ( _color_acc_species != null ) {
2444 _color_acc_species.setSelected( false );
2446 if ( _color_acc_sequence != null ) {
2447 _color_acc_sequence.setSelected( false );
2449 _mainpanel.getCurrentTreePanel().repaint();
2453 * Fit entire tree into window.
2456 if ( ( _mainpanel.getCurrentScrollPane() == null )
2457 || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
2460 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
2461 displayedPhylogenyMightHaveChanged( true );
2462 _mainpanel.getCurrentTreePanel().updateOvSettings();
2463 _mainpanel.getCurrentTreePanel().validate();
2464 _mainpanel.validate();
2465 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2466 _mainpanel.getSizeOfViewport().height );
2467 _mainpanel.getCurrentTreePanel().resetPreferredSize();
2468 _mainpanel.adjustJScrollPane();
2469 _mainpanel.getCurrentTreePanel().repaint();
2470 _mainpanel.getCurrentTreePanel().validate();
2471 _mainpanel.validate();
2472 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2473 _mainpanel.getSizeOfViewport().height );
2474 _mainpanel.getCurrentTreePanel().resetPreferredSize();
2475 _mainpanel.adjustJScrollPane();
2476 _mainpanel.getCurrentTreePanel().repaint();
2477 _mainpanel.getCurrentTreePanel().updateOvSizes();
2480 void showWholeAll() {
2481 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
2482 if ( tree_panel != null ) {
2483 tree_panel.validate();
2484 tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2485 _mainpanel.getSizeOfViewport().height );
2486 tree_panel.resetPreferredSize();
2487 tree_panel.repaint();
2492 // Create header for click-to combo box.
2493 void startClickToOptions() {
2494 final JLabel spacer = new JLabel( "" );
2495 spacer.setFont( ControlPanel.jcb_font );
2497 _click_to_label = new JLabel( "Click on Node to:" );
2498 add( customizeLabel( _click_to_label, getConfiguration() ) );
2499 _click_to_combobox = new JComboBox<String>();
2500 _click_to_combobox.setFocusable( false );
2501 _click_to_combobox.setMaximumRowCount( 14 );
2502 _click_to_combobox.setFont( ControlPanel.js_font );
2503 if ( !_configuration.isUseNativeUI() ) {
2504 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
2506 // don't add listener until all items are set (or each one will trigger
2508 // click_to_list.addActionListener(this);
2509 add( _click_to_combobox );
2510 // Correlates option names to titles
2511 _all_click_to_names = new HashMap<Integer, String>();
2512 _click_to_names = new ArrayList<String>();
2516 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
2517 if ( getCurrentTreePanel().isPhyHasBranchLengths()
2518 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
2519 setDrawPhylogramEnabled( true );
2520 setDrawPhylogram( isDrawPhylogram() );
2523 setDrawPhylogramEnabled( false );
2524 setDrawPhylogram( false );
2526 if ( getMainPanel().getMainFrame() == null ) {
2527 // Must be "E" applet version.
2528 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
2529 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
2532 getMainPanel().getMainFrame()
2533 .setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel().getPhylogenyGraphicsType() );
2535 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
2536 getMainPanel().getCurrentTreePanel().updateButtonToUncollapseAll();
2537 getMainPanel().getControlPanel().search0();
2538 getMainPanel().getControlPanel().search1();
2539 getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
2540 getMainPanel().getControlPanel().updateDepthCollapseDepthDisplay();
2541 getMainPanel().getControlPanel().updateRankCollapseRankDisplay();
2542 getSequenceRelationTypeBox().removeAllItems();
2543 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
2544 .getRelevantSequenceRelationTypes() ) {
2545 _sequence_relation_type_box.addItem( type );
2547 getMainPanel().getCurrentTreePanel().repaint();
2548 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
2549 // according to GUILHEM the line above can be removed.
2554 * Uncollapse all nodes.
2556 final void uncollapseAll( final TreePanel tp ) {
2557 final Phylogeny t = tp.getPhylogeny();
2558 if ( ( t != null ) && !t.isEmpty() ) {
2559 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
2560 final PhylogenyNode node = iter.next();
2561 node.setCollapse( false );
2563 tp.resetNodeIdToDistToLeafMap();
2564 tp.updateSetOfCollapsedExternalNodes();
2565 t.recalculateNumberOfExternalDescendants( false );
2566 tp.setNodeInPreorderToNull();
2567 t.clearHashIdToNodeMap();
2568 tp.resetDepthCollapseDepthValue();
2569 tp.resetRankCollapseRankValue();
2574 final void updateDomainStructureEvaluethresholdDisplay() {
2575 if ( _domain_structure_evalue_thr_tf != null ) {
2576 _domain_structure_evalue_thr_tf
2577 .setText( "10^" + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThresholdExp() );
2581 private final String obtainDepthCollapseDepthValue() {
2582 if ( getMainPanel().getCurrentTreePanel() == null ) {
2585 final TreePanel tp = getMainPanel().getCurrentTreePanel();
2586 final Phylogeny p = tp.getPhylogeny();
2587 if ( ( p == null ) || ( p.getNumberOfExternalNodes() < 3 ) ) {
2590 else if ( tp.getDepthCollapseDepthValue() < 0 ) {
2591 tp.setDepthCollapseDepthValue( PhylogenyMethods.calculateMaxDepth( p ) );
2594 else if ( tp.getDepthCollapseDepthValue() == PhylogenyMethods.calculateMaxDepth( p ) ) {
2597 return String.valueOf( tp.getDepthCollapseDepthValue() );
2600 private final String obtainRankCollapseDepthValue() {
2601 if ( getMainPanel().getCurrentTreePanel() == null ) {
2604 final TreePanel tp = getMainPanel().getCurrentTreePanel();
2605 final Phylogeny p = tp.getPhylogeny();
2606 if ( ( p == null ) || ( p.getNumberOfExternalNodes() < 3 ) ) {
2610 final String ranks[] = PhylogenyMethods.obtainPresentRanksSorted( p );
2611 if ( ranks.length < 1 ) {
2614 else if ( tp.getRankCollapseRankValue() < 0 ) {
2615 tp.setRankCollapseRankValue( ranks.length - 1 );
2618 else if ( tp.getRankCollapseRankValue() == ( ranks.length - 1 ) ) {
2622 return String.valueOf( tp.getRankCollapseRankValue() );
2625 final void updateDepthCollapseDepthDisplay() {
2626 if ( _depth_collapse_depth_tf != null ) {
2627 _depth_collapse_depth_tf.setText( " " + obtainDepthCollapseDepthValue() );
2631 final void updateRankCollapseRankDisplay() {
2634 if ( _rank_collapse_depth_tf != null ) {
2635 final String r = obtainRankCollapseDepthValue();
2636 if ( r.equals( "off" ) ) {
2637 _rank_collapse_depth_tf.setText( " off" );
2638 _rank_collapse_depth_tf.setToolTipText( "the current taxonomic rank threshold" );
2641 final String ranks[] = PhylogenyMethods
2642 .obtainPresentRanksSorted( getMainPanel().getCurrentTreePanel().getPhylogeny() );
2643 final int rr = Integer.parseInt( r );
2644 _rank_collapse_depth_tf.setText( ranks[ rr ] );
2645 _rank_collapse_depth_tf.setToolTipText( ( rr + 1 ) + "/" + ( ranks.length - 1 ) + ": "
2646 + ranks[ Integer.parseInt( r ) ] );
2651 final void zoomInX( final float factor, final float x_correction_factor ) {
2652 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
2653 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2654 treepanel.multiplyUrtFactor( 1f );
2655 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2656 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
2657 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
2658 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
2659 final double x = ( sb.getMaximum() - sb.getMinimum() )
2660 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2661 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2662 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2663 getMainPanel().adjustJScrollPane();
2664 treepanel.resetPreferredSize();
2665 getMainPanel().getCurrentScrollPane().getViewport().validate();
2666 sb.setValue( ForesterUtil
2667 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2670 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
2671 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2672 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2673 getMainPanel().adjustJScrollPane();
2674 treepanel.resetPreferredSize();
2675 getMainPanel().getCurrentScrollPane().getViewport().validate();
2676 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
2678 treepanel.resetPreferredSize();
2679 treepanel.updateOvSizes();
2682 final void zoomInY( final float factor ) {
2683 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
2684 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2685 treepanel.multiplyUrtFactor( 1.1f );
2686 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2687 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
2688 getMainPanel().adjustJScrollPane();
2689 treepanel.resetPreferredSize();
2690 getMainPanel().getCurrentScrollPane().getViewport().validate();
2691 sb.setValue( ForesterUtil
2692 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2693 treepanel.resetPreferredSize();
2694 treepanel.updateOvSizes();
2697 final void zoomOutX( final float factor, final float x_correction_factor ) {
2698 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2699 treepanel.multiplyUrtFactor( 1f );
2700 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
2701 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
2702 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2703 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
2704 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
2705 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
2706 getMainPanel().adjustJScrollPane();
2707 treepanel.resetPreferredSize();
2708 getMainPanel().getCurrentScrollPane().getViewport().validate();
2709 final double x = ( sb.getMaximum() - sb.getMinimum() )
2710 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2711 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2712 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2713 getMainPanel().adjustJScrollPane();
2714 treepanel.resetPreferredSize();
2715 getMainPanel().getCurrentScrollPane().getViewport().validate();
2716 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
2717 - ( sb.getVisibleAmount() / 2.0 ) ) );
2720 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
2721 treepanel.setXdistance( treepanel.getXdistance() * factor );
2722 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
2724 getMainPanel().adjustJScrollPane();
2725 treepanel.resetPreferredSize();
2726 getMainPanel().getCurrentScrollPane().getViewport().validate();
2727 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
2730 treepanel.resetPreferredSize();
2731 treepanel.updateOvSizes();
2735 final void zoomOutY( final float factor ) {
2736 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2737 treepanel.multiplyUrtFactor( 0.9f );
2738 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
2739 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
2740 final double x = ( sb.getMaximum() - sb.getMinimum() )
2741 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2742 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
2743 getMainPanel().adjustJScrollPane();
2744 treepanel.resetPreferredSize();
2745 getMainPanel().getCurrentScrollPane().getViewport().validate();
2746 sb.setValue( ForesterUtil
2747 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2748 treepanel.resetPreferredSize();
2749 treepanel.updateOvSizes();
2753 final static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2754 label.setFont( ControlPanel.jcb_bold_font );
2755 if ( !configuration.isUseNativeUI() ) {
2756 label.setForeground( configuration.getGuiCheckboxTextColor() );
2757 label.setBackground( configuration.getGuiBackgroundColor() );
2762 final public JCheckBox getUseBranchWidthsCb() {
2763 return _width_branches;