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 = "Back to Super Tree";
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, final 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 if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
641 queries = query_str.split( ",+" );
644 queries = new String[ 1 ];
645 queries[ 0 ] = query_str.trim();
647 if ( ( queries != null ) && ( queries.length > 0 ) ) {
648 nodes = new HashSet<Long>();
649 for( String query : queries ) {
650 if ( ForesterUtil.isEmpty( query ) ) {
653 query = query.trim();
654 final TreePanel tp = getMainPanel().getCurrentTreePanel();
655 if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
656 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
658 getOptions().isSearchCaseSensitive(),
659 !getOptions().isMatchWholeTermsOnly(),
660 isShowDomainArchitectures(),
663 tp.getDomainStructureEvalueThresholdExp() )
667 nodes.addAll( PhylogenyMethods
670 getOptions().isSearchCaseSensitive(),
671 !getOptions().isMatchWholeTermsOnly(),
672 getOptions().isSearchWithRegex(),
673 isShowDomainArchitectures(),
674 tp != null ? Math.pow( 10, tp.getDomainStructureEvalueThresholdExp() ) : 0 ) );
677 if ( getOptions().isInverseSearchResult() ) {
678 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
679 final Set<Long> temp_nodes = nodes;
680 nodes = new HashSet<Long>();
681 for( final PhylogenyNode n : all ) {
682 if ( ( !temp_nodes.contains( n.getId() ) ) && n.isHasNodeData() ) {
683 nodes.add( n.getId() );
688 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
689 main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet<Long>() );
690 for( final Long node : nodes ) {
691 main_panel.getCurrentTreePanel().getFoundNodes0().add( node );
693 setSearchFoundCountsOnLabel0( nodes.size() );
696 setSearchFoundCountsOnLabel0( 0 );
701 private void search1( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
702 getSearchFoundCountsLabel1().setVisible( true );
703 getSearchResetButton1().setEnabled( true );
704 getSearchResetButton1().setVisible( true );
705 String[] queries = null;
706 Set<Long> nodes = null;
707 if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
708 queries = query_str.split( ",+" );
711 queries = new String[ 1 ];
712 queries[ 0 ] = query_str.trim();
714 if ( ( queries != null ) && ( queries.length > 0 ) ) {
715 nodes = new HashSet<Long>();
716 for( String query : queries ) {
717 if ( ForesterUtil.isEmpty( query ) ) {
720 query = query.trim();
721 final TreePanel tp = getMainPanel().getCurrentTreePanel();
722 if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
723 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
725 getOptions().isSearchCaseSensitive(),
726 !getOptions().isMatchWholeTermsOnly(),
727 isShowDomainArchitectures(),
730 tp.getDomainStructureEvalueThresholdExp() )
734 nodes.addAll( PhylogenyMethods
737 getOptions().isSearchCaseSensitive(),
738 !getOptions().isMatchWholeTermsOnly(),
739 getOptions().isSearchWithRegex(),
740 isShowDomainArchitectures(),
741 tp != null ? Math.pow( 10, tp.getDomainStructureEvalueThresholdExp() ) : 0 ) );
744 if ( getOptions().isInverseSearchResult() ) {
745 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
746 final Set<Long> temp_nodes = nodes;
747 nodes = new HashSet<Long>();
748 for( final PhylogenyNode n : all ) {
749 if ( ( !temp_nodes.contains( n.getId() ) ) && n.isHasNodeData() ) {
750 nodes.add( n.getId() );
755 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
756 main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet<Long>() );
757 for( final Long node : nodes ) {
758 main_panel.getCurrentTreePanel().getFoundNodes1().add( node );
760 setSearchFoundCountsOnLabel1( nodes.size() );
763 setSearchFoundCountsOnLabel1( 0 );
768 private void setDrawPhylogram( final int index, final boolean b ) {
769 getIsDrawPhylogramList().set( index, b );
772 private void setupClickToOptions() {
773 final int default_option = _configuration.getDefaultDisplayClicktoOption();
774 int selected_index = 0;
776 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
777 _show_data_item = cb_index;
778 addClickToOption( Configuration.display_node_data,
779 _configuration.getClickToTitle( Configuration.display_node_data ) );
780 if ( default_option == Configuration.display_node_data ) {
781 selected_index = cb_index;
785 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
786 _collapse_cb_item = cb_index;
787 addClickToOption( Configuration.collapse_uncollapse,
788 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
789 if ( default_option == Configuration.collapse_uncollapse ) {
790 selected_index = cb_index;
794 if ( _configuration.doDisplayClickToOption( Configuration.uncollapse_all ) ) {
795 _uncollapse_all_cb_item = cb_index;
796 addClickToOption( Configuration.uncollapse_all,
797 _configuration.getClickToTitle( Configuration.uncollapse_all ) );
798 if ( default_option == Configuration.uncollapse_all ) {
799 selected_index = cb_index;
803 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
804 _reroot_cb_item = cb_index;
805 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
806 if ( default_option == Configuration.reroot ) {
807 selected_index = cb_index;
811 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
812 _subtree_cb_item = cb_index;
813 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
814 if ( default_option == Configuration.subtree ) {
815 selected_index = cb_index;
819 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
820 _swap_cb_item = cb_index;
821 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
822 if ( default_option == Configuration.swap ) {
823 selected_index = cb_index;
827 if ( _configuration.doDisplayClickToOption( Configuration.order_subtree ) ) {
828 _order_subtree_cb_item = cb_index;
829 addClickToOption( Configuration.order_subtree,
830 _configuration.getClickToTitle( Configuration.order_subtree ) );
831 if ( default_option == Configuration.order_subtree ) {
832 selected_index = cb_index;
836 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
837 _sort_descendents_item = cb_index;
838 addClickToOption( Configuration.sort_descendents,
839 _configuration.getClickToTitle( Configuration.sort_descendents ) );
840 if ( default_option == Configuration.sort_descendents ) {
841 selected_index = cb_index;
845 if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) {
846 _color_node_font_item = cb_index;
847 addClickToOption( Configuration.color_node_font,
848 _configuration.getClickToTitle( Configuration.color_node_font ) );
849 if ( default_option == Configuration.color_node_font ) {
850 selected_index = cb_index;
854 if ( _configuration.doDisplayClickToOption( Configuration.change_node_font ) ) {
855 _change_node_font_item = cb_index;
856 addClickToOption( Configuration.change_node_font,
857 _configuration.getClickToTitle( Configuration.change_node_font ) );
858 if ( default_option == Configuration.change_node_font ) {
859 selected_index = cb_index;
863 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
864 _color_subtree_cb_item = cb_index;
865 addClickToOption( Configuration.color_subtree,
866 _configuration.getClickToTitle( Configuration.color_subtree ) );
867 if ( default_option == Configuration.color_subtree ) {
868 selected_index = cb_index;
872 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
873 _open_seq_web_item = cb_index;
874 addClickToOption( Configuration.open_seq_web,
875 _configuration.getClickToTitle( Configuration.open_seq_web ) );
876 if ( default_option == Configuration.open_seq_web ) {
877 selected_index = cb_index;
881 if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
882 _open_pdb_item = cb_index;
883 addClickToOption( Configuration.open_pdb_web,
884 _configuration.getClickToTitle( Configuration.open_pdb_web ) );
885 if ( default_option == Configuration.open_pdb_web ) {
886 selected_index = cb_index;
890 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
891 _open_tax_web_item = cb_index;
892 addClickToOption( Configuration.open_tax_web,
893 _configuration.getClickToTitle( Configuration.open_tax_web ) );
894 if ( default_option == Configuration.open_tax_web ) {
895 selected_index = cb_index;
899 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
900 _blast_item = cb_index;
901 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
902 if ( default_option == Configuration.blast ) {
903 selected_index = cb_index;
907 if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
908 _select_nodes_item = cb_index;
909 addClickToOption( Configuration.select_nodes,
910 _configuration.getClickToTitle( Configuration.select_nodes ) );
911 if ( default_option == Configuration.select_nodes ) {
912 selected_index = cb_index;
916 if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
917 _get_ext_desc_data = cb_index;
918 if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
919 addClickToOption( Configuration.get_ext_desc_data,
920 getConfiguration().getLabelForGetExtDescendentsData() );
923 addClickToOption( Configuration.get_ext_desc_data,
924 getConfiguration().getClickToTitle( Configuration.get_ext_desc_data ) );
926 if ( default_option == Configuration.get_ext_desc_data ) {
927 selected_index = cb_index;
931 if ( getOptions().isEditable() ) {
932 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
933 _cut_subtree_item = cb_index;
934 addClickToOption( Configuration.cut_subtree,
935 _configuration.getClickToTitle( Configuration.cut_subtree ) );
936 if ( default_option == Configuration.cut_subtree ) {
937 selected_index = cb_index;
941 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
942 _copy_subtree_item = cb_index;
943 addClickToOption( Configuration.copy_subtree,
944 _configuration.getClickToTitle( Configuration.copy_subtree ) );
945 if ( default_option == Configuration.copy_subtree ) {
946 selected_index = cb_index;
950 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
951 _paste_subtree_item = cb_index;
952 addClickToOption( Configuration.paste_subtree,
953 _configuration.getClickToTitle( Configuration.paste_subtree ) );
954 if ( default_option == Configuration.paste_subtree ) {
955 selected_index = cb_index;
959 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
960 _delete_node_or_subtree_item = cb_index;
961 addClickToOption( Configuration.delete_subtree_or_node,
962 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
963 if ( default_option == Configuration.delete_subtree_or_node ) {
964 selected_index = cb_index;
968 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
969 _add_new_node_item = cb_index;
970 addClickToOption( Configuration.add_new_node,
971 _configuration.getClickToTitle( Configuration.add_new_node ) );
972 if ( default_option == Configuration.add_new_node ) {
973 selected_index = cb_index;
977 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
978 _edit_node_data_item = cb_index;
979 addClickToOption( Configuration.edit_node_data,
980 _configuration.getClickToTitle( Configuration.edit_node_data ) );
981 if ( default_option == Configuration.edit_node_data ) {
982 selected_index = cb_index;
987 // Set default selection and its action
988 _click_to_combobox.setSelectedIndex( selected_index );
989 setClickToAction( selected_index );
992 private void setupDisplayCheckboxes() {
993 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
994 addCheckbox( Configuration.display_as_phylogram,
995 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
996 setCheckbox( Configuration.display_as_phylogram,
997 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
999 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1000 addCheckbox( Configuration.dynamically_hide_data,
1001 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
1002 setCheckbox( Configuration.dynamically_hide_data,
1003 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
1005 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1006 addCheckbox( Configuration.node_data_popup,
1007 _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1008 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1010 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1011 addCheckbox( Configuration.display_internal_data,
1012 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
1013 setCheckbox( Configuration.display_internal_data,
1014 _configuration.doCheckOption( Configuration.display_internal_data ) );
1016 if ( _configuration.doDisplayOption( Configuration.color_according_to_sequence ) ) {
1017 addCheckbox( Configuration.color_according_to_sequence,
1018 _configuration.getDisplayTitle( Configuration.color_according_to_sequence ) );
1019 setCheckbox( Configuration.color_according_to_sequence,
1020 _configuration.doCheckOption( Configuration.color_according_to_sequence ) );
1022 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1023 addCheckbox( Configuration.color_according_to_species,
1024 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
1025 setCheckbox( Configuration.color_according_to_species,
1026 _configuration.doCheckOption( Configuration.color_according_to_species ) );
1028 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1029 addCheckbox( Configuration.color_according_to_annotation,
1030 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
1031 setCheckbox( Configuration.color_according_to_annotation,
1032 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
1034 if ( _configuration.doDisplayOption( Configuration.use_style ) ) {
1035 addCheckbox( Configuration.use_style, _configuration.getDisplayTitle( Configuration.use_style ) );
1036 setCheckbox( Configuration.use_style, _configuration.doCheckOption( Configuration.use_style ) );
1038 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1039 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1040 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1042 final JLabel label = new JLabel( "Display Data:" );
1043 label.setFont( ControlPanel.jcb_bold_font );
1044 if ( !getConfiguration().isUseNativeUI() ) {
1045 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1048 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1049 addCheckbox( Configuration.show_node_names,
1050 _configuration.getDisplayTitle( Configuration.show_node_names ) );
1051 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1053 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1054 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1055 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1057 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1058 addCheckbox( Configuration.show_taxonomy_scientific_names,
1059 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1060 setCheckbox( Configuration.show_taxonomy_scientific_names,
1061 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1063 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1064 addCheckbox( Configuration.show_taxonomy_common_names,
1065 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1066 setCheckbox( Configuration.show_taxonomy_common_names,
1067 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1069 if ( _configuration.doDisplayOption( Configuration.show_tax_rank ) ) {
1070 addCheckbox( Configuration.show_tax_rank, _configuration.getDisplayTitle( Configuration.show_tax_rank ) );
1071 setCheckbox( Configuration.show_tax_rank, _configuration.doCheckOption( Configuration.show_tax_rank ) );
1073 if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
1074 addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
1075 setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
1077 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1078 addCheckbox( Configuration.show_gene_names,
1079 _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1080 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1082 if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
1083 addCheckbox( Configuration.show_seq_symbols,
1084 _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
1085 setCheckbox( Configuration.show_seq_symbols,
1086 _configuration.doCheckOption( Configuration.show_seq_symbols ) );
1088 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1089 addCheckbox( Configuration.show_sequence_acc,
1090 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1091 setCheckbox( Configuration.show_sequence_acc,
1092 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1094 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1095 addCheckbox( Configuration.show_annotation,
1096 _configuration.getDisplayTitle( Configuration.show_annotation ) );
1097 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1099 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1100 addCheckbox( Configuration.write_confidence_values,
1101 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1102 setCheckbox( Configuration.write_confidence_values,
1103 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1105 if ( _configuration.doDisplayOption( Configuration.write_branch_length_values ) ) {
1106 addCheckbox( Configuration.write_branch_length_values,
1107 _configuration.getDisplayTitle( Configuration.write_branch_length_values ) );
1108 setCheckbox( Configuration.write_branch_length_values,
1109 _configuration.doCheckOption( Configuration.write_branch_length_values ) );
1111 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1112 addCheckbox( Configuration.show_binary_characters,
1113 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1114 setCheckbox( Configuration.show_binary_characters,
1115 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1117 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1118 addCheckbox( Configuration.show_binary_character_counts,
1119 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1120 setCheckbox( Configuration.show_binary_character_counts,
1121 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1123 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1124 addCheckbox( Configuration.show_domain_architectures,
1125 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1126 setCheckbox( Configuration.show_domain_architectures,
1127 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1129 if ( _configuration.doDisplayOption( Configuration.show_mol_seqs ) ) {
1130 addCheckbox( Configuration.show_mol_seqs, _configuration.getDisplayTitle( Configuration.show_mol_seqs ) );
1131 setCheckbox( Configuration.show_mol_seqs, _configuration.doCheckOption( Configuration.show_mol_seqs ) );
1133 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1134 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1135 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1137 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1138 addCheckbox( Configuration.show_vector_data,
1139 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1140 setCheckbox( Configuration.show_vector_data,
1141 _configuration.doCheckOption( Configuration.show_vector_data ) );
1143 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1144 addCheckbox( Configuration.show_properties,
1145 _configuration.getDisplayTitle( Configuration.show_properties ) );
1146 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1148 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1149 addCheckbox( Configuration.show_taxonomy_images,
1150 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1151 setCheckbox( Configuration.show_taxonomy_images,
1152 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1156 private void setVisibilityOfDomainStrucureControls() {
1157 if ( _zoom_in_domain_structure != null ) {
1158 final MainFrame mf = getMainFrame();
1160 if ( isShowDomainArchitectures() ) {
1161 _domain_display_label.setVisible( true );
1162 _zoom_in_domain_structure.setVisible( true );
1163 _zoom_out_domain_structure.setVisible( true );
1164 _decr_domain_structure_evalue_thr.setVisible( true );
1165 _incr_domain_structure_evalue_thr.setVisible( true );
1166 _domain_structure_evalue_thr_tf.setVisible( true );
1167 if ( mf._right_line_up_domains_cbmi != null ) {
1168 mf._right_line_up_domains_cbmi.setVisible( true );
1170 if ( mf._show_domain_labels != null ) {
1171 mf._show_domain_labels.setVisible( true );
1175 _domain_display_label.setVisible( false );
1176 _zoom_in_domain_structure.setVisible( false );
1177 _zoom_out_domain_structure.setVisible( false );
1178 _decr_domain_structure_evalue_thr.setVisible( false );
1179 _incr_domain_structure_evalue_thr.setVisible( false );
1180 _domain_structure_evalue_thr_tf.setVisible( false );
1181 if ( mf._right_line_up_domains_cbmi != null ) {
1182 mf._right_line_up_domains_cbmi.setVisible( false );
1184 if ( mf._show_domain_labels != null ) {
1185 mf._show_domain_labels.setVisible( false );
1192 void activateButtonToReturnToSuperTree( int index ) {
1195 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
1198 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
1200 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1201 _return_to_super_tree.setEnabled( true );
1205 * Add zoom and quick edit buttons. (Last modified 8/9/04)
1208 final JLabel spacer = new JLabel( "" );
1209 spacer.setOpaque( false );
1211 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
1212 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1213 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
1214 if ( !getConfiguration().isUseNativeUI() ) {
1215 x_panel.setBackground( getBackground() );
1216 y_panel.setBackground( getBackground() );
1217 z_panel.setBackground( getBackground() );
1219 add( _zoom_label = new JLabel( "Zoom:" ) );
1220 customizeLabel( _zoom_label, getConfiguration() );
1224 if ( getConfiguration().isUseNativeUI() ) {
1225 _zoom_in_x = new TypomaticJButton( "+" );
1226 _zoom_out_x = new TypomaticJButton( "-" );
1229 _zoom_in_x = new TypomaticJButton( "X+" );
1230 _zoom_out_x = new TypomaticJButton( "X-" );
1232 _zoom_in_y = new TypomaticJButton( "Y+" );
1233 _zoom_out_y = new TypomaticJButton( "Y-" );
1234 _show_whole = new JButton( "F" );
1235 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [F or Home]" );
1236 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+cursor-right]" );
1237 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+cursor-up]" );
1238 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+cursor-left]" );
1239 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+cursor-down]" );
1240 if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) {
1241 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
1242 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
1245 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
1246 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
1248 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
1249 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
1250 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
1251 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
1252 _return_to_super_tree.setEnabled( false );
1253 _order = new JButton( "Order Tree" );
1254 _uncollapse_all = new JButton( "Uncollapse All" );
1255 addJButton( _zoom_in_y, x_panel );
1256 addJButton( _zoom_out_x, y_panel );
1257 addJButton( _show_whole, y_panel );
1258 addJButton( _zoom_in_x, y_panel );
1259 addJButton( _zoom_out_y, z_panel );
1260 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
1261 setUpControlsForDomainStrucures();
1264 setUpControlsForDepthCollapse();
1267 setUpControlsForRankCollapse();
1269 final JLabel spacer2 = new JLabel( "" );
1271 addJButton( _return_to_super_tree, this );
1272 addJButton( _order, this );
1273 addJButton( _uncollapse_all, this );
1274 final JLabel spacer3 = new JLabel( "" );
1276 setVisibilityOfDomainStrucureControls();
1279 void addCheckbox( final int which, final String title ) {
1280 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
1282 case Configuration.display_as_phylogram:
1283 _display_as_phylogram_cb = new JCheckBox( title );
1284 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
1285 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
1288 case Configuration.display_internal_data:
1289 _display_internal_data = new JCheckBox( title );
1290 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
1291 addJCheckBox( _display_internal_data, ch_panel );
1294 case Configuration.color_according_to_species:
1295 _color_acc_species = new JCheckBox( title );
1296 _color_acc_species.setToolTipText( "To colorize node labels as a function of taxonomy" );
1297 addJCheckBox( _color_acc_species, ch_panel );
1300 case Configuration.color_according_to_sequence:
1301 _color_acc_sequence = new JCheckBox( title );
1302 _color_acc_sequence.setToolTipText( "To colorize node labels as a function of sequence name" );
1303 addJCheckBox( _color_acc_sequence, ch_panel );
1306 case Configuration.color_according_to_annotation:
1307 _color_according_to_annotation = new JCheckBox( title );
1308 _color_according_to_annotation
1309 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
1310 addJCheckBox( _color_according_to_annotation, ch_panel );
1313 case Configuration.show_node_names:
1314 _show_node_names = new JCheckBox( title );
1315 addJCheckBox( _show_node_names, ch_panel );
1318 case Configuration.show_taxonomy_scientific_names:
1319 _show_taxo_scientific_names = new JCheckBox( title );
1320 addJCheckBox( _show_taxo_scientific_names, ch_panel );
1323 case Configuration.show_taxonomy_common_names:
1324 _show_taxo_common_names = new JCheckBox( title );
1325 addJCheckBox( _show_taxo_common_names, ch_panel );
1328 case Configuration.show_tax_code:
1329 _show_taxo_code = new JCheckBox( title );
1330 addJCheckBox( _show_taxo_code, ch_panel );
1333 case Configuration.show_tax_rank:
1334 _show_taxo_rank = new JCheckBox( title );
1335 addJCheckBox( _show_taxo_rank, ch_panel );
1338 case Configuration.show_taxonomy_images:
1339 _show_taxo_images_cb = new JCheckBox( title );
1340 addJCheckBox( _show_taxo_images_cb, ch_panel );
1343 case Configuration.show_binary_characters:
1344 _show_binary_characters = new JCheckBox( title );
1345 addJCheckBox( _show_binary_characters, ch_panel );
1348 case Configuration.show_annotation:
1349 _show_annotation = new JCheckBox( title );
1350 addJCheckBox( _show_annotation, ch_panel );
1353 case Configuration.show_binary_character_counts:
1354 _show_binary_character_counts = new JCheckBox( title );
1355 addJCheckBox( _show_binary_character_counts, ch_panel );
1358 case Configuration.write_confidence_values:
1359 _write_confidence = new JCheckBox( title );
1360 addJCheckBox( getWriteConfidenceCb(), ch_panel );
1363 case Configuration.write_events:
1364 _show_events = new JCheckBox( title );
1365 addJCheckBox( getShowEventsCb(), ch_panel );
1368 case Configuration.use_style:
1369 _use_visual_styles_cb = new JCheckBox( title );
1370 getUseVisualStylesCb()
1371 .setToolTipText( "To use visual styles (node colors, fonts) and branch colors, if present" );
1372 addJCheckBox( getUseVisualStylesCb(), ch_panel );
1375 case Configuration.width_branches:
1376 _width_branches = new JCheckBox( title );
1377 _width_branches.setToolTipText( "To use branch width values, if present" );
1378 addJCheckBox( _width_branches, ch_panel );
1381 case Configuration.write_branch_length_values:
1382 _write_branch_length_values = new JCheckBox( title );
1383 addJCheckBox( _write_branch_length_values, ch_panel );
1386 case Configuration.show_domain_architectures:
1387 _show_domain_architectures = new JCheckBox( title );
1388 addJCheckBox( _show_domain_architectures, ch_panel );
1391 case Configuration.show_mol_seqs:
1392 _show_mol_seqs = new JCheckBox( title );
1393 addJCheckBox( _show_mol_seqs, ch_panel );
1396 case Configuration.show_seq_names:
1397 _show_seq_names = new JCheckBox( title );
1398 addJCheckBox( _show_seq_names, ch_panel );
1401 case Configuration.show_gene_names:
1402 _show_gene_names = new JCheckBox( title );
1403 addJCheckBox( _show_gene_names, ch_panel );
1406 case Configuration.show_seq_symbols:
1407 _show_seq_symbols = new JCheckBox( title );
1408 addJCheckBox( _show_seq_symbols, ch_panel );
1411 case Configuration.show_sequence_acc:
1412 _show_sequence_acc = new JCheckBox( title );
1413 addJCheckBox( _show_sequence_acc, ch_panel );
1416 case Configuration.dynamically_hide_data:
1417 _dynamically_hide_data = new JCheckBox( title );
1418 getDynamicallyHideData().setToolTipText( "To hide labels depending on expected visibility" );
1419 addJCheckBox( getDynamicallyHideData(), ch_panel );
1422 case Configuration.node_data_popup:
1423 _node_desc_popup_cb = new JCheckBox( title );
1424 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
1425 addJCheckBox( getNodeDescPopupCb(), ch_panel );
1428 case Configuration.show_relation_confidence:
1429 _seq_relation_confidence_switch = new JCheckBox( title );
1430 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
1433 case Configuration.show_vector_data:
1434 _show_vector_data_cb = new JCheckBox( title );
1435 addJCheckBox( _show_vector_data_cb, ch_panel );
1438 case Configuration.show_properties:
1439 _show_properties_cb = new JCheckBox( title );
1440 addJCheckBox( _show_properties_cb, ch_panel );
1444 throw new RuntimeException( "unknown checkbox: " + which );
1448 void addJButton( final JButton jb, final JPanel p ) {
1449 jb.setFocusPainted( false );
1450 jb.setFont( ControlPanel.jcb_font );
1451 if ( !_configuration.isUseNativeUI() ) {
1452 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
1453 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1454 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
1457 jb.addActionListener( this );
1460 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
1461 jcb.setFocusPainted( false );
1462 jcb.setFont( ControlPanel.jcb_font );
1463 if ( !_configuration.isUseNativeUI() ) {
1464 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
1465 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1467 p.add( jcb, "Center" );
1468 jcb.addActionListener( this );
1471 void addJTextField( final JTextField tf, final JPanel p ) {
1472 if ( !_configuration.isUseNativeUI() ) {
1473 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
1474 tf.setFont( ControlPanel.jcb_font );
1477 tf.addActionListener( this );
1480 void deactivateButtonToReturnToSuperTree() {
1481 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
1482 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
1483 _return_to_super_tree.setEnabled( false );
1486 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
1487 if ( ( _mainpanel != null )
1488 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
1489 if ( recalc_longest_ext_node_info ) {
1490 _mainpanel.getCurrentTreePanel().initNodeData();
1491 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
1493 if ( getOptions().isShowOverview() ) {
1494 _mainpanel.getCurrentTreePanel().updateOvSizes();
1496 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
1497 setVisibilityOfDomainStrucureControls();
1498 updateDomainStructureEvaluethresholdDisplay();
1499 updateDepthCollapseDepthDisplay();
1500 updateRankCollapseRankDisplay();
1501 getMainPanel().getControlPanel();
1502 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
1503 _mainpanel.getCurrentTreePanel().calcMaxDepth();
1504 _mainpanel.adjustJScrollPane();
1505 _mainpanel.getCurrentTreePanel().repaint();
1506 // _mainpanel.getCurrentTreePanel().setUpUrtFactor();
1510 void endClickToOptions() {
1511 _click_to_combobox.addActionListener( this );
1515 * Indicates what action should be execute when a node is clicked
1517 * @return the click-on action
1519 NodeClickAction getActionWhenNodeClicked() {
1520 return _action_when_node_clicked;
1523 Map<Integer, String> getAllClickToItems() {
1524 return _all_click_to_names;
1527 Map<String, Color> getAnnotationColors() {
1528 return _annotation_colors;
1531 Configuration getConfiguration() {
1532 return _configuration;
1535 TreePanel getCurrentTreePanel() {
1536 return getMainPanel().getCurrentTreePanel();
1539 MainPanel getMainPanel() {
1543 Options getOptions() {
1544 return getMainPanel().getOptions();
1547 JLabel getSearchFoundCountsLabel0() {
1548 return _search_found_label_0;
1551 JLabel getSearchFoundCountsLabel1() {
1552 return _search_found_label_1;
1555 JButton getSearchResetButton0() {
1556 return _search_reset_button_0;
1559 JButton getSearchResetButton1() {
1560 return _search_reset_button_1;
1563 JTextField getSearchTextField0() {
1564 return _search_tf_0;
1567 JTextField getSearchTextField1() {
1568 return _search_tf_1;
1571 Map<String, Color> getSequenceColors() {
1572 return _sequence_colors;
1575 List<String> getSingleClickToNames() {
1576 return _click_to_names;
1579 Map<String, Color> getSpeciesColors() {
1580 return _species_colors;
1583 boolean isAntialiasScreenText() {
1587 boolean isColorAccordingToAnnotation() {
1588 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
1591 boolean isColorAccordingToSequence() {
1592 return ( ( _color_acc_sequence != null ) && _color_acc_sequence.isSelected() );
1595 boolean isColorAccordingToTaxonomy() {
1596 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
1599 boolean isDrawPhylogram() {
1600 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
1603 boolean isDynamicallyHideData() {
1604 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
1607 boolean isEvents() {
1608 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
1611 boolean isNodeDescPopup() {
1612 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
1615 boolean isShowAnnotation() {
1616 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
1619 boolean isShowBinaryCharacterCounts() {
1620 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
1623 boolean isShowBinaryCharacters() {
1624 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
1627 boolean isShowConfidenceValues() {
1628 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
1631 boolean isShowDomainArchitectures() {
1632 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
1635 boolean isShowGeneNames() {
1636 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
1639 boolean isShowInternalData() {
1640 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
1643 boolean isShowNodeNames() {
1644 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
1647 boolean isShowSeqNames() {
1648 return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
1651 boolean isShowSeqSymbols() {
1652 return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
1655 boolean isShowSequenceAcc() {
1656 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
1659 boolean isShowSequenceRelationConfidence() {
1660 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
1663 boolean isShowSequenceRelations() {
1664 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
1667 boolean isShowTaxonomyCode() {
1668 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
1671 boolean isShowTaxonomyRank() {
1672 return ( ( _show_taxo_rank != null ) && _show_taxo_rank.isSelected() );
1675 boolean isShowTaxonomyCommonNames() {
1676 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
1679 boolean isShowTaxonomyScientificNames() {
1680 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
1683 boolean isUseVisualStyles() {
1684 return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() )
1685 || ( ( getUseVisualStylesCb() == null ) && _color_branches ) );
1688 boolean isWidthBranches() {
1689 return ( ( _width_branches != null ) && _width_branches.isSelected() );
1692 boolean isWriteBranchLengthValues() {
1693 return ( ( _write_branch_length_values != null ) && _write_branch_length_values.isSelected() );
1696 void phylogenyAdded( final Configuration configuration ) {
1697 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
1700 void phylogenyRemoved( final int index ) {
1701 getIsDrawPhylogramList().remove( index );
1705 final MainPanel main_panel = getMainPanel();
1706 final Phylogeny tree = main_panel.getCurrentPhylogeny();
1707 if ( ( tree == null ) || tree.isEmpty() ) {
1710 String query = getSearchTextField0().getText();
1711 if ( query != null ) {
1712 query = query.trim();
1714 if ( !ForesterUtil.isEmpty( query ) ) {
1715 search0( main_panel, tree, query );
1718 getSearchFoundCountsLabel0().setVisible( false );
1719 getSearchResetButton0().setEnabled( false );
1720 getSearchResetButton0().setVisible( false );
1726 final MainPanel main_panel = getMainPanel();
1727 final Phylogeny tree = main_panel.getCurrentPhylogeny();
1728 if ( ( tree == null ) || tree.isEmpty() ) {
1731 String query = getSearchTextField1().getText();
1732 if ( query != null ) {
1733 query = query.trim();
1735 if ( !ForesterUtil.isEmpty( query ) ) {
1736 search1( main_panel, tree, query );
1739 getSearchFoundCountsLabel1().setVisible( false );
1740 getSearchResetButton1().setEnabled( false );
1741 getSearchResetButton1().setVisible( false );
1746 void searchReset0() {
1747 if ( getMainPanel().getCurrentTreePanel() != null ) {
1748 getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
1752 void searchReset1() {
1753 if ( getMainPanel().getCurrentTreePanel() != null ) {
1754 getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
1758 void setActionWhenNodeClicked( final NodeClickAction action ) {
1759 _action_when_node_clicked = action;
1762 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
1763 _annotation_colors = annotation_colors;
1766 void setCheckbox( final int which, final boolean state ) {
1768 case Configuration.display_as_phylogram:
1769 if ( getDisplayAsPhylogramCb() != null ) {
1770 getDisplayAsPhylogramCb().setSelected( state );
1773 case Configuration.display_internal_data:
1774 if ( _display_internal_data != null ) {
1775 _display_internal_data.setSelected( state );
1778 case Configuration.color_according_to_species:
1779 if ( _color_acc_species != null ) {
1780 _color_acc_species.setSelected( state );
1783 case Configuration.color_according_to_sequence:
1784 if ( _color_acc_sequence != null ) {
1785 _color_acc_sequence.setSelected( state );
1788 case Configuration.color_according_to_annotation:
1789 if ( _color_according_to_annotation != null ) {
1790 _color_according_to_annotation.setSelected( state );
1793 case Configuration.show_node_names:
1794 if ( _show_node_names != null ) {
1795 _show_node_names.setSelected( state );
1798 case Configuration.show_taxonomy_scientific_names:
1799 if ( _show_taxo_scientific_names != null ) {
1800 _show_taxo_scientific_names.setSelected( state );
1803 case Configuration.show_taxonomy_common_names:
1804 if ( _show_taxo_common_names != null ) {
1805 _show_taxo_common_names.setSelected( state );
1808 case Configuration.show_tax_code:
1809 if ( _show_taxo_code != null ) {
1810 _show_taxo_code.setSelected( state );
1813 case Configuration.show_tax_rank:
1814 if ( _show_taxo_rank != null ) {
1815 _show_taxo_rank.setSelected( state );
1818 case Configuration.show_taxonomy_images:
1819 if ( _show_taxo_images_cb != null ) {
1820 _show_taxo_images_cb.setSelected( state );
1823 case Configuration.show_annotation:
1824 if ( _show_annotation != null ) {
1825 _show_annotation.setSelected( state );
1828 case Configuration.show_binary_characters:
1829 if ( _show_binary_characters != null ) {
1830 _show_binary_characters.setSelected( state );
1833 case Configuration.show_binary_character_counts:
1834 if ( _show_binary_character_counts != null ) {
1835 _show_binary_character_counts.setSelected( state );
1838 case Configuration.write_confidence_values:
1839 if ( getWriteConfidenceCb() != null ) {
1840 getWriteConfidenceCb().setSelected( state );
1843 case Configuration.write_events:
1844 if ( getShowEventsCb() != null ) {
1845 getShowEventsCb().setSelected( state );
1848 case Configuration.use_style:
1849 if ( getUseVisualStylesCb() != null ) {
1850 getUseVisualStylesCb().setSelected( state );
1853 case Configuration.width_branches:
1854 if ( _width_branches != null ) {
1855 _width_branches.setSelected( state );
1858 case Configuration.show_domain_architectures:
1859 if ( _show_domain_architectures != null ) {
1860 _show_domain_architectures.setSelected( state );
1863 case Configuration.write_branch_length_values:
1864 if ( _write_branch_length_values != null ) {
1865 _write_branch_length_values.setSelected( state );
1868 case Configuration.show_mol_seqs:
1869 if ( _show_mol_seqs != null ) {
1870 _show_mol_seqs.setSelected( state );
1873 case Configuration.show_seq_names:
1874 if ( _show_seq_names != null ) {
1875 _show_seq_names.setSelected( state );
1878 case Configuration.show_gene_names:
1879 if ( _show_gene_names != null ) {
1880 _show_gene_names.setSelected( state );
1883 case Configuration.show_seq_symbols:
1884 if ( _show_seq_symbols != null ) {
1885 _show_seq_symbols.setSelected( state );
1888 case Configuration.show_vector_data:
1889 if ( _show_vector_data_cb != null ) {
1890 _show_vector_data_cb.setSelected( state );
1893 case Configuration.show_properties:
1894 if ( _show_properties_cb != null ) {
1895 _show_properties_cb.setSelected( state );
1898 case Configuration.show_sequence_acc:
1899 if ( _show_sequence_acc != null ) {
1900 _show_sequence_acc.setSelected( state );
1903 case Configuration.dynamically_hide_data:
1904 if ( getDynamicallyHideData() != null ) {
1905 getDynamicallyHideData().setSelected( state );
1908 case Configuration.node_data_popup:
1909 if ( getNodeDescPopupCb() != null ) {
1910 getNodeDescPopupCb().setSelected( state );
1914 case Configuration.show_relation_confidence:
1915 if ( _seq_relation_confidence_switch != null ) {
1916 _seq_relation_confidence_switch.setSelected( state );
1921 throw new AssertionError( "unknown checkbox: " + which );
1926 * Set this checkbox state. Not all checkboxes have been instantiated
1927 * depending on the config.
1929 void setCheckbox( final JCheckBox cb, final boolean state ) {
1931 cb.setSelected( state );
1935 void setClickToAction( final int action ) {
1936 // Set click-to action
1937 if ( action == _show_data_item ) {
1938 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1940 else if ( action == _collapse_cb_item ) {
1941 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1943 else if ( action == _reroot_cb_item ) {
1944 setActionWhenNodeClicked( NodeClickAction.REROOT );
1946 else if ( action == _subtree_cb_item ) {
1947 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1949 else if ( action == _swap_cb_item ) {
1950 setActionWhenNodeClicked( NodeClickAction.SWAP );
1952 else if ( action == _color_subtree_cb_item ) {
1953 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1955 else if ( action == _open_seq_web_item ) {
1956 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1958 else if ( action == _sort_descendents_item ) {
1959 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1961 else if ( action == _blast_item ) {
1962 setActionWhenNodeClicked( NodeClickAction.BLAST );
1964 else if ( action == _open_tax_web_item ) {
1965 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1967 else if ( action == _cut_subtree_item ) {
1968 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1970 else if ( action == _copy_subtree_item ) {
1971 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1973 else if ( action == _delete_node_or_subtree_item ) {
1974 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1976 else if ( action == _paste_subtree_item ) {
1977 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1979 else if ( action == _add_new_node_item ) {
1980 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1982 else if ( action == _edit_node_data_item ) {
1983 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1985 else if ( action == _select_nodes_item ) {
1986 setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
1988 else if ( action == _get_ext_desc_data ) {
1989 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
1991 else if ( action == _open_pdb_item ) {
1992 setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
1994 else if ( action == _color_node_font_item ) {
1995 setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
1997 else if ( action == _change_node_font_item ) {
1998 setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT );
2000 else if ( action == _uncollapse_all_cb_item ) {
2001 setActionWhenNodeClicked( NodeClickAction.UNCOLLAPSE_ALL );
2003 else if ( action == _order_subtree_cb_item ) {
2004 setActionWhenNodeClicked( NodeClickAction.ORDER_SUBTREE );
2007 throw new RuntimeException( "unknown action: " + action );
2009 // make sure drop down is displaying the correct action
2010 // in case this was called from outside the class
2011 _click_to_combobox.setSelectedIndex( action );
2014 void setColorBranches( final boolean color_branches ) {
2015 _color_branches = color_branches;
2018 void setDrawPhylogram( final boolean b ) {
2019 getDisplayAsPhylogramCb().setSelected( b );
2020 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
2023 void setDrawPhylogramEnabled( final boolean b ) {
2024 getDisplayAsPhylogramCb().setEnabled( b );
2027 void setDynamicHidingIsOn( final boolean is_on ) {
2029 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
2032 if ( !_configuration.isUseNativeUI() ) {
2033 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
2036 getDynamicallyHideData().setForeground( Color.BLACK );
2041 void setSearchFoundCountsOnLabel0( final int counts ) {
2042 getSearchFoundCountsLabel0().setText( "Found: " + counts );
2045 void setSearchFoundCountsOnLabel1( final int counts ) {
2046 getSearchFoundCountsLabel1().setText( "Found: " + counts );
2049 void setSequenceColors( final Map<String, Color> sequence_colors ) {
2050 _sequence_colors = sequence_colors;
2053 void setShowEvents( final boolean show_events ) {
2054 if ( getShowEventsCb() == null ) {
2055 _show_events = new JCheckBox( "" );
2057 getShowEventsCb().setSelected( show_events );
2060 void setSpeciesColors( final Map<String, Color> species_colors ) {
2061 _species_colors = species_colors;
2064 void setupControls() {
2065 // The tree display options:
2066 setupDisplayCheckboxes();
2068 // The sequence relation query selection combo-box
2069 if ( _configuration.displaySequenceRelations() ) {
2070 addSequenceRelationBlock();
2074 startClickToOptions();
2075 setupClickToOptions();
2076 endClickToOptions();
2077 // Zoom and quick edit buttons
2079 setupSearchTools0();
2080 setupSearchTools1();
2083 void setUpControlsForDomainStrucures() {
2084 _domain_display_label = new JLabel( "Domain Architectures:" );
2085 add( customizeLabel( _domain_display_label, getConfiguration() ) );
2086 add( _domain_display_label );
2087 _zoom_in_domain_structure = new TypomaticJButton( "d+" );
2088 _zoom_out_domain_structure = new TypomaticJButton( "d-" );
2089 _decr_domain_structure_evalue_thr = new JButton( "-" );
2090 _incr_domain_structure_evalue_thr = new JButton( "+" );
2091 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
2092 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
2093 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
2094 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
2095 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
2096 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
2097 _domain_structure_evalue_thr_tf = new JTextField( 3 );
2098 _domain_structure_evalue_thr_tf.setEditable( false );
2099 if ( !getConfiguration().isUseNativeUI() ) {
2100 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2101 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2102 _domain_structure_evalue_thr_tf.setBorder( null );
2104 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2105 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2106 if ( !_configuration.isUseNativeUI() ) {
2107 d1_panel.setBackground( getBackground() );
2108 d2_panel.setBackground( getBackground() );
2112 addJButton( _zoom_out_domain_structure, d1_panel );
2113 addJButton( _zoom_in_domain_structure, d1_panel );
2114 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
2115 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
2116 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
2119 void setUpControlsForDepthCollapse() {
2120 _depth_collapse_label = new JLabel( "Collapse by Node Depth:" );
2121 _depth_collapse_label
2122 .setToolTipText( "to automaticall collapse nodes with a depth equal or larger than a threshold" );
2123 add( customizeLabel( _depth_collapse_label, getConfiguration() ) );
2124 add( _depth_collapse_label );
2125 _decr_depth_collapse_level = new TypomaticJButton( "-" );
2126 _incr_depth_collapse_level = new TypomaticJButton( "+" );
2127 _decr_depth_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2128 _incr_depth_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2129 _decr_depth_collapse_level.setToolTipText( "to decrease the depth threshold (wraps around)" );
2130 _incr_depth_collapse_level.setToolTipText( "to increase the depth threshold (wraps around)" );
2131 _depth_collapse_depth_tf = new JTextField( 3 );
2132 _depth_collapse_depth_tf.setToolTipText( "the current depth threshold" );
2133 _depth_collapse_depth_tf.setEditable( false );
2134 if ( !getConfiguration().isUseNativeUI() ) {
2135 _depth_collapse_depth_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2136 _depth_collapse_depth_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2137 _depth_collapse_depth_tf.setBorder( null );
2139 final JPanel panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2140 if ( !_configuration.isUseNativeUI() ) {
2141 panel.setBackground( getBackground() );
2144 addJButton( _decr_depth_collapse_level, panel );
2145 addJTextField( _depth_collapse_depth_tf, panel );
2146 addJButton( _incr_depth_collapse_level, panel );
2149 void setUpControlsForRankCollapse() {
2150 _rank_collapse_label = new JLabel( "Collapse by Node Rank:" );
2151 _rank_collapse_label
2152 .setToolTipText( "to automatically collapse nodes with a taxonomic rank equal or lower than a threshold" );
2153 add( customizeLabel( _rank_collapse_label, getConfiguration() ) );
2154 add( _rank_collapse_label );
2155 _decr_rank_collapse_level = new TypomaticJButton( "-" );
2156 _incr_rank_collapse_level = new TypomaticJButton( "+" );
2157 _decr_rank_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2158 _incr_rank_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2159 _decr_rank_collapse_level.setToolTipText( "to decrease the taxonomic rank threshold (wraps around)" );
2160 _incr_rank_collapse_level.setToolTipText( "to increase the taxonomic rank threshold (wraps around)" );
2161 _rank_collapse_depth_tf = new JTextField( 3 );
2162 _rank_collapse_depth_tf.setToolTipText( "the current taxonomic rank threshold" );
2163 _rank_collapse_depth_tf.setEditable( false );
2164 if ( !getConfiguration().isUseNativeUI() ) {
2165 _rank_collapse_depth_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2166 _rank_collapse_depth_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2167 _rank_collapse_depth_tf.setBorder( null );
2169 final JPanel panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2170 if ( !_configuration.isUseNativeUI() ) {
2171 panel.setBackground( getBackground() );
2174 addJButton( _decr_rank_collapse_level, panel );
2175 addJTextField( _rank_collapse_depth_tf, panel );
2176 addJButton( _incr_rank_collapse_level, panel );
2179 void setupSearchTools0() {
2180 final JLabel search_label = new JLabel( "Search (A):" );
2181 search_label.setFont( ControlPanel.jcb_bold_font );
2182 if ( !getConfiguration().isUseNativeUI() ) {
2183 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2185 add( search_label );
2186 search_label.setToolTipText( SEARCH_TIP_TEXT );
2187 _search_found_label_0 = new JLabel();
2188 getSearchFoundCountsLabel0().setVisible( false );
2189 _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
2190 if ( !getConfiguration().isUseNativeUI() ) {
2191 _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2193 _search_tf_0 = new JTextField( 3 );
2194 _search_tf_0.setToolTipText( SEARCH_TIP_TEXT );
2195 _search_tf_0.setEditable( true );
2196 if ( !getConfiguration().isUseNativeUI() ) {
2197 _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2198 _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2199 _search_tf_0.setBorder( null );
2201 _search_reset_button_0 = new JButton();
2202 getSearchResetButton0().setText( "Reset" );
2203 getSearchResetButton0().setEnabled( false );
2204 getSearchResetButton0().setVisible( false );
2205 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
2206 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2207 s_panel_1.setBackground( getBackground() );
2209 s_panel_2.setBackground( getBackground() );
2211 final KeyAdapter key_adapter = new KeyAdapter() {
2214 public void keyReleased( final KeyEvent key_event ) {
2216 displayedPhylogenyMightHaveChanged( true );
2219 final ActionListener action_listener = new ActionListener() {
2222 public void actionPerformed( final ActionEvent e ) {
2224 setSearchFoundCountsOnLabel0( 0 );
2225 getSearchFoundCountsLabel0().setVisible( false );
2226 getSearchTextField0().setText( "" );
2227 getSearchResetButton0().setEnabled( false );
2228 getSearchResetButton0().setVisible( false );
2229 displayedPhylogenyMightHaveChanged( true );
2232 _search_reset_button_0.addActionListener( action_listener );
2233 _search_tf_0.addKeyListener( key_adapter );
2234 addJTextField( _search_tf_0, s_panel_1 );
2235 s_panel_2.add( _search_found_label_0 );
2236 addJButton( _search_reset_button_0, s_panel_2 );
2239 void setupSearchTools1() {
2240 final JLabel search_label = new JLabel( "Search (B):" );
2241 search_label.setFont( ControlPanel.jcb_bold_font );
2242 if ( !getConfiguration().isUseNativeUI() ) {
2243 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2245 add( search_label );
2246 search_label.setToolTipText( SEARCH_TIP_TEXT );
2247 _search_found_label_1 = new JLabel();
2248 getSearchFoundCountsLabel1().setVisible( false );
2249 _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
2250 if ( !getConfiguration().isUseNativeUI() ) {
2251 _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2253 _search_tf_1 = new JTextField( 3 );
2254 _search_tf_1.setToolTipText( SEARCH_TIP_TEXT );
2255 _search_tf_1.setEditable( true );
2256 if ( !getConfiguration().isUseNativeUI() ) {
2257 _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2258 _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2259 _search_tf_1.setBorder( null );
2261 _search_reset_button_1 = new JButton();
2262 getSearchResetButton1().setText( "Reset" );
2263 getSearchResetButton1().setEnabled( false );
2264 getSearchResetButton1().setVisible( false );
2265 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
2266 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2267 s_panel_1.setBackground( getBackground() );
2269 s_panel_2.setBackground( getBackground() );
2271 final KeyAdapter key_adapter = new KeyAdapter() {
2274 public void keyReleased( final KeyEvent key_event ) {
2276 displayedPhylogenyMightHaveChanged( true );
2279 final ActionListener action_listener = new ActionListener() {
2282 public void actionPerformed( final ActionEvent e ) {
2284 setSearchFoundCountsOnLabel1( 0 );
2285 getSearchFoundCountsLabel1().setVisible( false );
2286 getSearchTextField1().setText( "" );
2287 getSearchResetButton1().setEnabled( false );
2288 getSearchResetButton1().setVisible( false );
2289 displayedPhylogenyMightHaveChanged( true );
2292 _search_reset_button_1.addActionListener( action_listener );
2293 _search_tf_1.addKeyListener( key_adapter );
2294 addJTextField( _search_tf_1, s_panel_1 );
2295 s_panel_2.add( _search_found_label_1 );
2296 addJButton( _search_reset_button_1, s_panel_2 );
2299 void setVisibilityOfDomainStrucureCB() {
2301 if ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel()
2302 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2303 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
2304 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2305 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
2307 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2308 getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
2311 else if ( isShowDomainArchitectures() ) {
2312 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2313 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( true );
2315 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2316 getMainPanel().getMainFrame()._show_domain_labels.setVisible( true );
2320 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2321 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
2323 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2324 getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
2328 catch ( final Exception ignore ) {
2333 void setVisibilityOfX() {
2334 final MainFrame mf = getMainFrame();
2336 if ( ( getCurrentTreePanel() != null ) && ( getCurrentTreePanel().getPhylogeny() != null ) ) {
2337 if ( AptxUtil.isHasAtLeastOneBranchWithSupportSD( getCurrentTreePanel().getPhylogeny() ) ) {
2338 if ( mf._show_confidence_stddev_cbmi != null ) {
2339 mf._show_confidence_stddev_cbmi.setVisible( true );
2343 if ( mf._show_confidence_stddev_cbmi != null ) {
2344 mf._show_confidence_stddev_cbmi.setVisible( false );
2347 if ( AptxUtil.isHasAtLeastOneNodeWithScientificName( getCurrentTreePanel().getPhylogeny() ) ) {
2348 if ( mf._abbreviate_scientific_names != null ) {
2349 mf._abbreviate_scientific_names.setVisible( true );
2353 if ( mf._abbreviate_scientific_names != null ) {
2354 mf._abbreviate_scientific_names.setVisible( false );
2357 if ( AptxUtil.isHasAtLeastOneNodeWithSequenceAnnotation( getCurrentTreePanel().getPhylogeny() ) ) {
2358 if ( mf._show_annotation_ref_source != null ) {
2359 mf._show_annotation_ref_source.setVisible( true );
2363 if ( mf._show_annotation_ref_source != null ) {
2364 mf._show_annotation_ref_source.setVisible( false );
2368 if ( isDrawPhylogram() || ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel()
2369 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2370 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) ) {
2371 if ( mf._non_lined_up_cladograms_rbmi != null ) {
2372 mf._non_lined_up_cladograms_rbmi.setVisible( false );
2374 if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
2375 mf._ext_node_dependent_cladogram_rbmi.setVisible( false );
2379 if ( mf._non_lined_up_cladograms_rbmi != null ) {
2380 mf._non_lined_up_cladograms_rbmi.setVisible( true );
2382 if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
2383 mf._ext_node_dependent_cladogram_rbmi.setVisible( true );
2386 if ( isDrawPhylogram() ) {
2387 if ( mf._show_scale_cbmi != null ) {
2388 mf._show_scale_cbmi.setVisible( true );
2392 if ( mf._show_scale_cbmi != null ) {
2393 mf._show_scale_cbmi.setVisible( false );
2396 if ( getCurrentTreePanel() != null ) {
2397 if ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2398 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
2399 if ( mf._label_direction_cbmi != null ) {
2400 mf._label_direction_cbmi.setVisible( true );
2404 if ( mf._label_direction_cbmi != null ) {
2405 mf._label_direction_cbmi.setVisible( false );
2412 void showAnnotations() {
2413 if ( _show_annotation != null ) {
2414 _show_annotation.setSelected( true );
2416 if ( _color_according_to_annotation != null ) {
2417 _color_according_to_annotation.setSelected( true );
2419 if ( _color_acc_species != null ) {
2420 _color_acc_species.setSelected( false );
2422 if ( _color_acc_sequence != null ) {
2423 _color_acc_sequence.setSelected( false );
2425 _mainpanel.getCurrentTreePanel().repaint();
2429 * Fit entire tree into window.
2432 if ( ( _mainpanel.getCurrentScrollPane() == null )
2433 || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
2436 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
2437 displayedPhylogenyMightHaveChanged( true );
2438 _mainpanel.getCurrentTreePanel().updateOvSettings();
2439 _mainpanel.getCurrentTreePanel().validate();
2440 _mainpanel.validate();
2441 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2442 _mainpanel.getSizeOfViewport().height );
2443 _mainpanel.getCurrentTreePanel().resetPreferredSize();
2444 _mainpanel.adjustJScrollPane();
2445 _mainpanel.getCurrentTreePanel().repaint();
2446 _mainpanel.getCurrentTreePanel().validate();
2447 _mainpanel.validate();
2448 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2449 _mainpanel.getSizeOfViewport().height );
2450 _mainpanel.getCurrentTreePanel().resetPreferredSize();
2451 _mainpanel.adjustJScrollPane();
2452 _mainpanel.getCurrentTreePanel().repaint();
2453 _mainpanel.getCurrentTreePanel().updateOvSizes();
2456 void showWholeAll() {
2457 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
2458 if ( tree_panel != null ) {
2459 tree_panel.validate();
2460 tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2461 _mainpanel.getSizeOfViewport().height );
2462 tree_panel.resetPreferredSize();
2463 tree_panel.repaint();
2468 // Create header for click-to combo box.
2469 void startClickToOptions() {
2470 final JLabel spacer = new JLabel( "" );
2471 spacer.setFont( ControlPanel.jcb_font );
2473 _click_to_label = new JLabel( "Click on Node to:" );
2474 add( customizeLabel( _click_to_label, getConfiguration() ) );
2475 _click_to_combobox = new JComboBox<String>();
2476 _click_to_combobox.setFocusable( false );
2477 _click_to_combobox.setMaximumRowCount( 14 );
2478 _click_to_combobox.setFont( ControlPanel.js_font );
2479 if ( !_configuration.isUseNativeUI() ) {
2480 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
2482 // don't add listener until all items are set (or each one will trigger
2484 // click_to_list.addActionListener(this);
2485 add( _click_to_combobox );
2486 // Correlates option names to titles
2487 _all_click_to_names = new HashMap<Integer, String>();
2488 _click_to_names = new ArrayList<String>();
2492 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
2493 if ( getCurrentTreePanel().isPhyHasBranchLengths()
2494 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
2495 setDrawPhylogramEnabled( true );
2496 setDrawPhylogram( isDrawPhylogram() );
2499 setDrawPhylogramEnabled( false );
2500 setDrawPhylogram( false );
2502 if ( getMainPanel().getMainFrame() == null ) {
2503 // Must be "E" applet version.
2504 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
2505 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
2508 getMainPanel().getMainFrame()
2509 .setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel().getPhylogenyGraphicsType() );
2511 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
2512 getMainPanel().getControlPanel().search0();
2513 getMainPanel().getControlPanel().search1();
2514 getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
2515 getMainPanel().getControlPanel().updateDepthCollapseDepthDisplay();
2516 getMainPanel().getControlPanel().updateRankCollapseRankDisplay();
2517 getSequenceRelationTypeBox().removeAllItems();
2518 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
2519 .getRelevantSequenceRelationTypes() ) {
2520 _sequence_relation_type_box.addItem( type );
2522 getMainPanel().getCurrentTreePanel().repaint();
2523 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
2524 // according to GUILHEM the line above can be removed.
2529 * Uncollapse all nodes.
2531 final void uncollapseAll( final TreePanel tp ) {
2532 final Phylogeny t = tp.getPhylogeny();
2533 if ( ( t != null ) && !t.isEmpty() ) {
2534 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
2535 final PhylogenyNode node = iter.next();
2536 node.setCollapse( false );
2538 tp.resetNodeIdToDistToLeafMap();
2539 tp.updateSetOfCollapsedExternalNodes();
2540 t.recalculateNumberOfExternalDescendants( false );
2541 tp.setNodeInPreorderToNull();
2542 t.clearHashIdToNodeMap();
2543 tp.resetDepthCollapseDepthValue();
2544 tp.resetRankCollapseRankValue();
2549 final void updateDomainStructureEvaluethresholdDisplay() {
2550 if ( _domain_structure_evalue_thr_tf != null ) {
2551 _domain_structure_evalue_thr_tf
2552 .setText( "10^" + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThresholdExp() );
2556 private final String obtainDepthCollapseDepthValue() {
2557 if ( getMainPanel().getCurrentTreePanel() == null ) {
2560 final TreePanel tp = getMainPanel().getCurrentTreePanel();
2561 final Phylogeny p = tp.getPhylogeny();
2562 if ( ( p == null ) || ( p.getNumberOfExternalNodes() < 3 ) ) {
2565 else if ( tp.getDepthCollapseDepthValue() < 0 ) {
2566 tp.setDepthCollapseDepthValue( PhylogenyMethods.calculateMaxDepth( p ) );
2569 else if ( tp.getDepthCollapseDepthValue() == PhylogenyMethods.calculateMaxDepth( p ) ) {
2572 return String.valueOf( tp.getDepthCollapseDepthValue() );
2575 private final String obtainRankCollapseDepthValue() {
2576 if ( getMainPanel().getCurrentTreePanel() == null ) {
2579 final TreePanel tp = getMainPanel().getCurrentTreePanel();
2580 final Phylogeny p = tp.getPhylogeny();
2581 if ( ( p == null ) || ( p.getNumberOfExternalNodes() < 3 ) ) {
2585 final String ranks[] = PhylogenyMethods.obtainPresentRanksSorted( p );
2586 if ( ranks.length < 1 ) {
2589 else if ( tp.getRankCollapseRankValue() < 0 ) {
2590 tp.setRankCollapseRankValue( ranks.length - 1 );
2593 else if ( tp.getRankCollapseRankValue() == ( ranks.length - 1 ) ) {
2597 return String.valueOf( tp.getRankCollapseRankValue() );
2600 final void updateDepthCollapseDepthDisplay() {
2601 if ( _depth_collapse_depth_tf != null ) {
2602 _depth_collapse_depth_tf.setText( " " + obtainDepthCollapseDepthValue() );
2606 final void updateRankCollapseRankDisplay() {
2609 if ( _rank_collapse_depth_tf != null ) {
2610 final String r = obtainRankCollapseDepthValue();
2611 if ( r.equals( "off" ) ) {
2612 _rank_collapse_depth_tf.setText( " off" );
2613 _rank_collapse_depth_tf.setToolTipText( "the current taxonomic rank threshold" );
2616 final String ranks[] = PhylogenyMethods
2617 .obtainPresentRanksSorted( getMainPanel().getCurrentTreePanel().getPhylogeny() );
2618 final int rr = Integer.parseInt( r );
2619 _rank_collapse_depth_tf.setText( ranks[ rr ] );
2620 _rank_collapse_depth_tf.setToolTipText( ( rr + 1 ) + "/" + ( ranks.length - 1 ) + ": "
2621 + ranks[ Integer.parseInt( r ) ] );
2626 final void zoomInX( final float factor, final float x_correction_factor ) {
2627 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
2628 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2629 treepanel.multiplyUrtFactor( 1f );
2630 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2631 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
2632 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
2633 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
2634 final double x = ( sb.getMaximum() - sb.getMinimum() )
2635 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2636 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2637 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2638 getMainPanel().adjustJScrollPane();
2639 treepanel.resetPreferredSize();
2640 getMainPanel().getCurrentScrollPane().getViewport().validate();
2641 sb.setValue( ForesterUtil
2642 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2645 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
2646 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2647 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2648 getMainPanel().adjustJScrollPane();
2649 treepanel.resetPreferredSize();
2650 getMainPanel().getCurrentScrollPane().getViewport().validate();
2651 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
2653 treepanel.resetPreferredSize();
2654 treepanel.updateOvSizes();
2657 final void zoomInY( final float factor ) {
2658 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
2659 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2660 treepanel.multiplyUrtFactor( 1.1f );
2661 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2662 treepanel.setYdistance( ( treepanel.getYdistance() * 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 ) ) );
2668 treepanel.resetPreferredSize();
2669 treepanel.updateOvSizes();
2672 final void zoomOutX( final float factor, final float x_correction_factor ) {
2673 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2674 treepanel.multiplyUrtFactor( 1f );
2675 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
2676 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
2677 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2678 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
2679 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
2680 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
2681 getMainPanel().adjustJScrollPane();
2682 treepanel.resetPreferredSize();
2683 getMainPanel().getCurrentScrollPane().getViewport().validate();
2684 final double x = ( sb.getMaximum() - sb.getMinimum() )
2685 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2686 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2687 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2688 getMainPanel().adjustJScrollPane();
2689 treepanel.resetPreferredSize();
2690 getMainPanel().getCurrentScrollPane().getViewport().validate();
2691 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
2692 - ( sb.getVisibleAmount() / 2.0 ) ) );
2695 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
2696 treepanel.setXdistance( treepanel.getXdistance() * factor );
2697 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
2699 getMainPanel().adjustJScrollPane();
2700 treepanel.resetPreferredSize();
2701 getMainPanel().getCurrentScrollPane().getViewport().validate();
2702 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
2705 treepanel.resetPreferredSize();
2706 treepanel.updateOvSizes();
2710 final void zoomOutY( final float factor ) {
2711 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2712 treepanel.multiplyUrtFactor( 0.9f );
2713 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
2714 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
2715 final double x = ( sb.getMaximum() - sb.getMinimum() )
2716 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2717 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
2718 getMainPanel().adjustJScrollPane();
2719 treepanel.resetPreferredSize();
2720 getMainPanel().getCurrentScrollPane().getViewport().validate();
2721 sb.setValue( ForesterUtil
2722 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2723 treepanel.resetPreferredSize();
2724 treepanel.updateOvSizes();
2728 final static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2729 label.setFont( ControlPanel.jcb_bold_font );
2730 if ( !configuration.isUseNativeUI() ) {
2731 label.setForeground( configuration.getGuiCheckboxTextColor() );
2732 label.setBackground( configuration.getGuiBackgroundColor() );
2737 final public JCheckBox getUseBranchWidthsCb() {
2738 return _width_branches;