2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 // Contact: phylosoft @ gmail . com
23 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
25 package org.forester.archaeopteryx;
27 import java.awt.BorderLayout;
28 import java.awt.Color;
29 import java.awt.Component;
30 import java.awt.Dimension;
32 import java.awt.GridBagLayout;
33 import java.awt.GridLayout;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.ActionListener;
36 import java.awt.event.ItemEvent;
37 import java.awt.event.ItemListener;
38 import java.awt.event.KeyAdapter;
39 import java.awt.event.KeyEvent;
40 import java.util.ArrayList;
41 import java.util.Arrays;
42 import java.util.Collection;
43 import java.util.HashMap;
44 import java.util.HashSet;
45 import java.util.List;
49 import javax.swing.BorderFactory;
50 import javax.swing.DefaultListCellRenderer;
51 import javax.swing.JButton;
52 import javax.swing.JCheckBox;
53 import javax.swing.JComboBox;
54 import javax.swing.JLabel;
55 import javax.swing.JList;
56 import javax.swing.JPanel;
57 import javax.swing.JScrollBar;
58 import javax.swing.JTextField;
59 import javax.swing.ListCellRenderer;
61 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
62 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
63 import org.forester.archaeopteryx.util.TypomaticJButton;
64 import org.forester.phylogeny.Phylogeny;
65 import org.forester.phylogeny.PhylogenyMethods;
66 import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
67 import org.forester.phylogeny.PhylogenyNode;
68 import org.forester.phylogeny.data.Sequence;
69 import org.forester.phylogeny.data.SequenceRelation;
70 import org.forester.phylogeny.data.SequenceRelation.SEQUENCE_RELATION_TYPE;
71 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
72 import org.forester.util.ForesterUtil;
74 final class ControlPanel extends JPanel implements ActionListener {
76 enum NodeClickAction {
83 DELETE_NODE_OR_SUBTREE,
101 final static Font jcb_bold_font = new Font( Configuration
102 .getDefaultFontFamilyName(), Font.BOLD, 9 );
103 final static Font jcb_font = new Font( Configuration
104 .getDefaultFontFamilyName(), Font.PLAIN, 9 );
105 final static Font js_font = new Font( Configuration
106 .getDefaultFontFamilyName(), Font.PLAIN, 9 );
107 private static final String RETURN_TO_SUPER_TREE_TEXT = "R";
108 private static final String SEARCH_TIP_TEXT = "Enter text to search for. Use ',' for logical OR and '+' for logical AND (not used in this manner for regular expression searches).";
109 private static final long serialVersionUID = -8463483932821545633L;
110 private NodeClickAction _action_when_node_clicked;
111 private int _add_new_node_item;
112 private Map<Integer, String> _all_click_to_names;
113 private Map<String, Color> _annotation_colors;
114 private int _blast_item;
115 private JComboBox<String> _click_to_combobox;
116 private JLabel _click_to_label;
117 private List<String> _click_to_names;
118 private int _collapse_cb_item;
119 private int _uncollapse_all_cb_item;
120 private int _order_subtree_cb_item;
121 private JCheckBox _color_acc_species;
122 private JCheckBox _color_acc_sequence;
123 private JCheckBox _color_according_to_annotation;
124 private boolean _color_branches;
125 private JCheckBox _use_visual_styles_cb;
126 private int _color_subtree_cb_item;
127 private int _change_node_font_item;
128 // The settings from the conf file
129 private final Configuration _configuration;
130 private int _copy_subtree_item;
131 private int _cut_subtree_item;
132 private JButton _decr_domain_structure_evalue_thr;
133 private int _delete_node_or_subtree_item;
134 private JCheckBox _display_as_phylogram_cb;
136 private JCheckBox _display_internal_data;
137 private JLabel _domain_display_label;
138 private JTextField _domain_structure_evalue_thr_tf;
139 private JTextField _depth_collapse_depth_tf;
140 private JTextField _rank_collapse_depth_tf;
141 private List<Boolean> _draw_phylogram;
142 private JCheckBox _dynamically_hide_data;
143 private int _edit_node_data_item;
144 private int _get_ext_desc_data;
145 private JButton _incr_domain_structure_evalue_thr;
146 private final MainPanel _mainpanel;
147 private JCheckBox _node_desc_popup_cb;
148 private int _open_pdb_item;
149 private int _open_seq_web_item;
150 private int _open_tax_web_item;
151 private int _color_node_font_item;
152 private JButton _order;
153 private int _paste_subtree_item;
154 private int _reroot_cb_item;
155 private JButton _return_to_super_tree;
157 private JLabel _search_found_label_0;
158 private JLabel _search_found_label_1;
159 private JButton _search_reset_button_0;
160 private JButton _search_reset_button_1;
161 private JTextField _search_tf_0;
162 private JTextField _search_tf_1;
163 private int _select_nodes_item;
164 private Sequence _selected_query_seq;
165 private JCheckBox _seq_relation_confidence_switch;
166 private JComboBox<SEQUENCE_RELATION_TYPE> _sequence_relation_type_box;
167 private JCheckBox _show_annotation;
168 private JCheckBox _show_binary_character_counts;
169 private JCheckBox _show_binary_characters;
170 // Indices for the click-to options in the combo box
171 private int _show_data_item;
172 private JCheckBox _show_domain_architectures;
173 private JCheckBox _show_mol_seqs;
174 private JCheckBox _write_branch_length_values;
175 private JCheckBox _show_events;
176 private JCheckBox _show_gene_names;
177 private JCheckBox _show_node_names;
178 private JCheckBox _show_properties_cb;
179 private JCheckBox _show_seq_names;
180 private JCheckBox _show_seq_symbols;
181 private JCheckBox _show_sequence_acc;
182 private JComboBox<String> _show_sequence_relations;
183 private JCheckBox _show_taxo_code;
184 private JCheckBox _show_taxo_rank;
185 private JCheckBox _show_taxo_common_names;
186 private JCheckBox _show_taxo_images_cb;
187 private JCheckBox _show_taxo_scientific_names;
188 private JCheckBox _show_vector_data_cb;
189 private JButton _show_whole;
190 private int _sort_descendents_item;
191 private Map<String, Color> _species_colors;
192 private Map<String, Color> _sequence_colors;
193 private int _subtree_cb_item;
194 private int _swap_cb_item;
195 private JButton _uncollapse_all;
196 private JCheckBox _width_branches;
197 private JCheckBox _write_confidence;
198 private JButton _zoom_in_domain_structure;
199 private JButton _zoom_in_x;
200 private JButton _zoom_in_y;
201 private JLabel _zoom_label;
202 private JButton _zoom_out_domain_structure;
203 private JButton _zoom_out_x;
204 private JButton _zoom_out_y;
205 private JButton _decr_depth_collapse_level;
206 private JButton _incr_depth_collapse_level;
207 private JLabel _depth_collapse_label;
208 private JButton _decr_rank_collapse_level;
209 private JButton _incr_rank_collapse_level;
210 private JLabel _rank_collapse_label;
212 ControlPanel( final MainPanel ap, final Configuration configuration ) {
215 _configuration = configuration;
216 if ( !_configuration.isUseNativeUI() ) {
217 setBackground( getConfiguration().getGuiBackgroundColor() );
218 setBorder( BorderFactory.createRaisedBevelBorder() );
220 setLayout( new GridLayout( 0, 1, 2, 2 ) );
228 public void actionPerformed( final ActionEvent e ) {
230 if ( e.getSource() == _color_acc_sequence ) {
231 if ( _color_acc_species != null ) {
232 _color_acc_species.setSelected( false );
235 else if ( e.getSource() == _color_acc_species ) {
236 if ( _color_acc_sequence != null ) {
237 _color_acc_sequence.setSelected( false );
240 final TreePanel tp = getMainPanel().getCurrentTreePanel();
244 if ( e.getSource() == _click_to_combobox ) {
245 setClickToAction( _click_to_combobox.getSelectedIndex() );
246 getCurrentTreePanel().repaint();
248 else if ( e.getSource() == _show_binary_characters ) {
249 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
250 _show_binary_character_counts.setSelected( false );
252 displayedPhylogenyMightHaveChanged( true );
254 else if ( e.getSource() == _show_binary_character_counts ) {
255 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
256 _show_binary_characters.setSelected( false );
258 displayedPhylogenyMightHaveChanged( true );
260 else if ( e.getSource() == _show_domain_architectures ) {
263 displayedPhylogenyMightHaveChanged( true );
265 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
266 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
267 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
271 else if ( e.getSource() == _zoom_in_x ) {
272 zoomInX( AptxConstants.BUTTON_ZOOM_IN_FACTOR, AptxConstants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
273 displayedPhylogenyMightHaveChanged( false );
275 else if ( e.getSource() == _zoom_in_y ) {
276 zoomInY( AptxConstants.BUTTON_ZOOM_IN_FACTOR );
277 displayedPhylogenyMightHaveChanged( false );
279 else if ( e.getSource() == _zoom_out_x ) {
280 zoomOutX( AptxConstants.BUTTON_ZOOM_OUT_FACTOR, AptxConstants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
281 displayedPhylogenyMightHaveChanged( false );
283 else if ( e.getSource() == _zoom_out_y ) {
284 zoomOutY( AptxConstants.BUTTON_ZOOM_OUT_FACTOR );
285 displayedPhylogenyMightHaveChanged( false );
287 else if ( e.getSource() == _show_whole ) {
288 displayedPhylogenyMightHaveChanged( true );
291 else if ( e.getSource() == _return_to_super_tree ) {
292 returnedToSuperTreePressed();
294 else if ( e.getSource() == _order ) {
297 else if ( e.getSource() == _uncollapse_all ) {
299 displayedPhylogenyMightHaveChanged( false );
301 else if ( e.getSource() == _zoom_in_domain_structure ) {
302 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
303 displayedPhylogenyMightHaveChanged( true );
305 else if ( e.getSource() == _zoom_out_domain_structure ) {
306 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
307 displayedPhylogenyMightHaveChanged( true );
309 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
310 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThresholdExp();
313 displayedPhylogenyMightHaveChanged( true );
315 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
316 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThresholdExp();
319 displayedPhylogenyMightHaveChanged( true );
321 else if ( e.getSource() == _search_tf_0 ) {
323 displayedPhylogenyMightHaveChanged( true );
325 else if ( e.getSource() == _search_tf_1 ) {
327 displayedPhylogenyMightHaveChanged( true );
329 else if ( ( _dynamically_hide_data != null ) && ( e.getSource() == _dynamically_hide_data )
330 && !_dynamically_hide_data.isSelected() ) {
331 setDynamicHidingIsOn( false );
332 displayedPhylogenyMightHaveChanged( true );
334 else if ( ( e.getSource() == _decr_depth_collapse_level )
335 || ( e.getSource() == _incr_depth_collapse_level ) ) {
336 if ( e.getSource() == _decr_depth_collapse_level ) {
337 _mainpanel.getCurrentTreePanel().decreaseDepthCollapseLevel();
340 _mainpanel.getCurrentTreePanel().increaseDepthCollapseLevel();
344 _mainpanel.getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
345 _mainpanel.getCurrentTreePanel().getPhylogeny().recalculateNumberOfExternalDescendants( true );
346 _mainpanel.getCurrentTreePanel().resetNodeIdToDistToLeafMap();
347 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
348 _mainpanel.getCurrentTreePanel().setNodeInPreorderToNull();
349 displayedPhylogenyMightHaveChanged( true );
350 _mainpanel.getCurrentTreePanel().resetPreferredSize();
351 _mainpanel.getCurrentTreePanel().updateOvSizes();
352 _mainpanel.adjustJScrollPane();
356 else if ( ( e.getSource() == _decr_rank_collapse_level )
357 || ( e.getSource() == _incr_rank_collapse_level ) ) {
358 if ( e.getSource() == _decr_rank_collapse_level ) {
359 _mainpanel.getCurrentTreePanel().decreaseRankCollapseLevel();
362 _mainpanel.getCurrentTreePanel().increaseRankCollapseLevel();
366 _mainpanel.getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
367 _mainpanel.getCurrentTreePanel().getPhylogeny().recalculateNumberOfExternalDescendants( true );
368 _mainpanel.getCurrentTreePanel().resetNodeIdToDistToLeafMap();
369 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
370 _mainpanel.getCurrentTreePanel().setNodeInPreorderToNull();
371 displayedPhylogenyMightHaveChanged( true );
372 _mainpanel.getCurrentTreePanel().resetPreferredSize();
373 _mainpanel.getCurrentTreePanel().updateOvSizes();
374 _mainpanel.adjustJScrollPane();
379 displayedPhylogenyMightHaveChanged( true );
383 tp.requestFocusInWindow();
386 catch ( final Exception ex ) {
387 AptxUtil.unexpectedException( ex );
389 catch ( final Error err ) {
390 AptxUtil.unexpectedError( err );
394 void orderPressed( final TreePanel tp ) {
395 DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
396 if ( isShowTaxonomyScientificNames() || isShowTaxonomyCode() ) {
397 pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
399 else if ( isShowSeqNames() || isShowSeqSymbols() || isShowGeneNames() ) {
400 pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
402 PhylogenyMethods.orderAppearanceX( tp.getPhylogeny().getRoot(), true, pri );
403 tp.setNodeInPreorderToNull();
404 tp.getPhylogeny().externalNodesHaveChanged();
405 tp.getPhylogeny().clearHashIdToNodeMap();
406 tp.getPhylogeny().recalculateNumberOfExternalDescendants( true );
407 tp.resetNodeIdToDistToLeafMap();
408 tp.setEdited( true );
409 displayedPhylogenyMightHaveChanged( true );
412 void returnedToSuperTreePressed() {
413 if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
414 _mainpanel.getCurrentTreePanel().superTree();
419 public JCheckBox getColorAccSequenceCb() {
420 return _color_acc_sequence;
423 public JCheckBox getColorAccSpeciesCb() {
424 return _color_acc_species;
427 public JCheckBox getDisplayAsPhylogramCb() {
428 return _display_as_phylogram_cb;
431 public JCheckBox getDynamicallyHideData() {
432 return _dynamically_hide_data;
435 public JCheckBox getNodeDescPopupCb() {
436 return _node_desc_popup_cb;
439 public Sequence getSelectedQuerySequence() {
440 return _selected_query_seq;
443 public JComboBox<String> getSequenceRelationBox() {
444 if ( _show_sequence_relations == null ) {
445 _show_sequence_relations = new JComboBox<String>();
446 _show_sequence_relations.setFocusable( false );
447 _show_sequence_relations.setMaximumRowCount( 20 );
448 _show_sequence_relations.setFont( ControlPanel.js_font );
449 if ( !_configuration.isUseNativeUI() ) {
450 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
451 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
453 _show_sequence_relations.addItem( "-----" );
454 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
456 return _show_sequence_relations;
460 public JComboBox<SEQUENCE_RELATION_TYPE> getSequenceRelationTypeBox() {
461 if ( _sequence_relation_type_box == null ) {
462 _sequence_relation_type_box = new JComboBox<SEQUENCE_RELATION_TYPE>();
463 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE
465 _sequence_relation_type_box.addItem( type );
467 _sequence_relation_type_box.addActionListener( new ActionListener() {
470 public void actionPerformed( final ActionEvent e ) {
471 if ( _mainpanel.getCurrentPhylogeny() != null ) {
472 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
477 return _sequence_relation_type_box;
480 public JCheckBox getShowEventsCb() {
484 public JCheckBox getUseVisualStylesCb() {
485 return _use_visual_styles_cb;
488 public JCheckBox getWriteConfidenceCb() {
489 return _write_confidence;
492 public boolean isShowMolSequences() {
493 return ( ( _show_mol_seqs != null ) && _show_mol_seqs.isSelected() );
496 public boolean isShowProperties() {
497 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
500 public boolean isShowTaxonomyImages() {
501 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
504 public boolean isShowVectorData() {
505 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
508 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
509 final JComboBox<String> box = getSequenceRelationBox();
510 while ( box.getItemCount() > 1 ) {
511 box.removeItemAt( 1 );
513 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
514 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
516 if ( relationType == null ) {
519 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
520 for( final Sequence seq : sequenceRelationQueries ) {
521 if ( seq.isHasSequenceRelations() ) {
522 boolean fFoundForCurrentType = false;
523 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
524 if ( sq.getType().equals( relationType ) ) {
525 fFoundForCurrentType = true;
529 if ( fFoundForCurrentType ) {
530 sequenceNamesToAdd.add( seq.getName() );
531 sequencesByName.put( seq.getName(), seq );
535 // sort sequences by name before adding them to the combo
536 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
537 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
538 for( final String seqName : sequenceNameArray ) {
539 box.addItem( seqName );
541 for( final ItemListener oldItemListener : box.getItemListeners() ) {
542 box.removeItemListener( oldItemListener );
544 box.addItemListener( new ItemListener() {
547 public void itemStateChanged( final ItemEvent e ) {
548 _selected_query_seq = sequencesByName.get( e.getItem() );
549 _mainpanel.getCurrentTreePanel().repaint();
554 private void addClickToOption( final int which, final String title ) {
555 _click_to_combobox.addItem( title );
556 _click_to_names.add( title );
557 _all_click_to_names.put( new Integer( which ), title );
558 if ( !_configuration.isUseNativeUI() ) {
559 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
560 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
565 private void addSequenceRelationBlock() {
566 final JLabel spacer = new JLabel( "" );
567 spacer.setSize( 1, 1 );
569 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
570 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
571 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
572 getSequenceRelationTypeBox().setFocusable( false );
573 _sequence_relation_type_box.setFont( ControlPanel.js_font );
574 if ( !_configuration.isUseNativeUI() ) {
575 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
576 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
578 _sequence_relation_type_box.setRenderer( new ListCellRenderer<Object>() {
581 public Component getListCellRendererComponent( final JList<?> list,
584 final boolean isSelected,
585 final boolean cellHasFocus ) {
586 final Component component = new DefaultListCellRenderer()
587 .getListCellRendererComponent( list, value, index, isSelected, cellHasFocus );
588 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
589 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
590 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
595 final GridBagLayout gbl = new GridBagLayout();
596 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
597 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
598 final JPanel horizGrid = new JPanel( gbl );
599 horizGrid.setBackground( getBackground() );
600 horizGrid.add( typeLabel );
601 horizGrid.add( _sequence_relation_type_box );
602 add( customizeLabel( mainLabel, getConfiguration() ) );
604 add( getSequenceRelationBox() );
605 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
606 addCheckbox( Configuration.show_relation_confidence,
607 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
608 setCheckbox( Configuration.show_relation_confidence,
609 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
611 }// addSequenceRelationBlock
614 private List<Boolean> getIsDrawPhylogramList() {
615 return _draw_phylogram;
618 // This takes care of ArchaeopteryxE-issue.
619 // Can, and will, return null prior to ArchaeopteryxE initialization completion.
620 final private MainFrame getMainFrame() {
621 MainFrame mf = getMainPanel().getMainFrame();
623 // Must be "E" applet version.
624 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
625 if ( e.getMainPanel() == null ) {
628 mf = e.getMainPanel().getMainFrame();
633 private void init() {
634 _draw_phylogram = new ArrayList<Boolean>();
635 setSpeciesColors( new HashMap<String, Color>() );
636 setSequenceColors( new HashMap<String, Color>() );
637 setAnnotationColors( new HashMap<String, Color>() );
640 private boolean isDrawPhylogram( final int index ) {
641 return getIsDrawPhylogramList().get( index );
644 private void search0( final MainPanel main_panel, final Phylogeny tree, String query_str ) {
645 getSearchFoundCountsLabel0().setVisible( true );
646 getSearchResetButton0().setEnabled( true );
647 getSearchResetButton0().setVisible( true );
648 String[] queries = null;
649 Set<Long> nodes = null;
650 query_str = query_str.replaceAll( "\\s+", " " );
651 if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
652 queries = query_str.split( ",+" );
655 queries = new String[ 1 ];
656 queries[ 0 ] = query_str.trim();
658 if ( ( queries != null ) && ( queries.length > 0 ) ) {
659 nodes = new HashSet<Long>();
660 for( String query : queries ) {
661 if ( ForesterUtil.isEmpty( query ) ) {
664 query = query.trim();
665 final TreePanel tp = getMainPanel().getCurrentTreePanel();
666 if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
667 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
669 getOptions().isSearchCaseSensitive(),
670 !getOptions().isMatchWholeTermsOnly(),
671 isShowDomainArchitectures(),
674 tp.getDomainStructureEvalueThresholdExp() )
678 nodes.addAll( PhylogenyMethods
681 getOptions().isSearchCaseSensitive(),
682 !getOptions().isMatchWholeTermsOnly(),
683 getOptions().isSearchWithRegex(),
684 isShowDomainArchitectures(),
685 tp != null ? Math.pow( 10, tp.getDomainStructureEvalueThresholdExp() ) : 0 ) );
688 if ( getOptions().isInverseSearchResult() ) {
689 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
690 final Set<Long> temp_nodes = nodes;
691 nodes = new HashSet<Long>();
692 for( final PhylogenyNode n : all ) {
693 if ( ( !temp_nodes.contains( n.getId() ) ) && n.isHasNodeData() ) {
694 nodes.add( n.getId() );
699 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
700 main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet<Long>() );
701 for( final Long node : nodes ) {
702 main_panel.getCurrentTreePanel().getFoundNodes0().add( node );
704 setSearchFoundCountsOnLabel0( nodes.size() );
707 setSearchFoundCountsOnLabel0( 0 );
712 private void search1( final MainPanel main_panel, final Phylogeny tree, String query_str ) {
713 getSearchFoundCountsLabel1().setVisible( true );
714 getSearchResetButton1().setEnabled( true );
715 getSearchResetButton1().setVisible( true );
716 String[] queries = null;
717 Set<Long> nodes = null;
718 query_str = query_str.replaceAll( "\\s+", " " );
719 if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
720 queries = query_str.split( ",+" );
723 queries = new String[ 1 ];
724 queries[ 0 ] = query_str.trim();
726 if ( ( queries != null ) && ( queries.length > 0 ) ) {
727 nodes = new HashSet<Long>();
728 for( String query : queries ) {
729 if ( ForesterUtil.isEmpty( query ) ) {
732 query = query.trim();
733 final TreePanel tp = getMainPanel().getCurrentTreePanel();
734 if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
735 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
737 getOptions().isSearchCaseSensitive(),
738 !getOptions().isMatchWholeTermsOnly(),
739 isShowDomainArchitectures(),
742 tp.getDomainStructureEvalueThresholdExp() )
746 nodes.addAll( PhylogenyMethods
749 getOptions().isSearchCaseSensitive(),
750 !getOptions().isMatchWholeTermsOnly(),
751 getOptions().isSearchWithRegex(),
752 isShowDomainArchitectures(),
753 tp != null ? Math.pow( 10, tp.getDomainStructureEvalueThresholdExp() ) : 0 ) );
756 if ( getOptions().isInverseSearchResult() ) {
757 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
758 final Set<Long> temp_nodes = nodes;
759 nodes = new HashSet<Long>();
760 for( final PhylogenyNode n : all ) {
761 if ( ( !temp_nodes.contains( n.getId() ) ) && n.isHasNodeData() ) {
762 nodes.add( n.getId() );
767 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
768 main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet<Long>() );
769 for( final Long node : nodes ) {
770 main_panel.getCurrentTreePanel().getFoundNodes1().add( node );
772 setSearchFoundCountsOnLabel1( nodes.size() );
775 setSearchFoundCountsOnLabel1( 0 );
780 private void setDrawPhylogram( final int index, final boolean b ) {
781 getIsDrawPhylogramList().set( index, b );
784 private void setupClickToOptions() {
785 final int default_option = _configuration.getDefaultDisplayClicktoOption();
786 int selected_index = 0;
788 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
789 _show_data_item = cb_index;
790 addClickToOption( Configuration.display_node_data,
791 _configuration.getClickToTitle( Configuration.display_node_data ) );
792 if ( default_option == Configuration.display_node_data ) {
793 selected_index = cb_index;
797 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
798 _collapse_cb_item = cb_index;
799 addClickToOption( Configuration.collapse_uncollapse,
800 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
801 if ( default_option == Configuration.collapse_uncollapse ) {
802 selected_index = cb_index;
806 if ( _configuration.doDisplayClickToOption( Configuration.uncollapse_all ) ) {
807 _uncollapse_all_cb_item = cb_index;
808 addClickToOption( Configuration.uncollapse_all,
809 _configuration.getClickToTitle( Configuration.uncollapse_all ) );
810 if ( default_option == Configuration.uncollapse_all ) {
811 selected_index = cb_index;
815 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
816 _reroot_cb_item = cb_index;
817 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
818 if ( default_option == Configuration.reroot ) {
819 selected_index = cb_index;
823 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
824 _subtree_cb_item = cb_index;
825 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
826 if ( default_option == Configuration.subtree ) {
827 selected_index = cb_index;
831 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
832 _swap_cb_item = cb_index;
833 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
834 if ( default_option == Configuration.swap ) {
835 selected_index = cb_index;
839 if ( _configuration.doDisplayClickToOption( Configuration.order_subtree ) ) {
840 _order_subtree_cb_item = cb_index;
841 addClickToOption( Configuration.order_subtree,
842 _configuration.getClickToTitle( Configuration.order_subtree ) );
843 if ( default_option == Configuration.order_subtree ) {
844 selected_index = cb_index;
848 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
849 _sort_descendents_item = cb_index;
850 addClickToOption( Configuration.sort_descendents,
851 _configuration.getClickToTitle( Configuration.sort_descendents ) );
852 if ( default_option == Configuration.sort_descendents ) {
853 selected_index = cb_index;
857 if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) {
858 _color_node_font_item = cb_index;
859 addClickToOption( Configuration.color_node_font,
860 _configuration.getClickToTitle( Configuration.color_node_font ) );
861 if ( default_option == Configuration.color_node_font ) {
862 selected_index = cb_index;
866 if ( _configuration.doDisplayClickToOption( Configuration.change_node_font ) ) {
867 _change_node_font_item = cb_index;
868 addClickToOption( Configuration.change_node_font,
869 _configuration.getClickToTitle( Configuration.change_node_font ) );
870 if ( default_option == Configuration.change_node_font ) {
871 selected_index = cb_index;
875 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
876 _color_subtree_cb_item = cb_index;
877 addClickToOption( Configuration.color_subtree,
878 _configuration.getClickToTitle( Configuration.color_subtree ) );
879 if ( default_option == Configuration.color_subtree ) {
880 selected_index = cb_index;
884 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
885 _open_seq_web_item = cb_index;
886 addClickToOption( Configuration.open_seq_web,
887 _configuration.getClickToTitle( Configuration.open_seq_web ) );
888 if ( default_option == Configuration.open_seq_web ) {
889 selected_index = cb_index;
893 if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
894 _open_pdb_item = cb_index;
895 addClickToOption( Configuration.open_pdb_web,
896 _configuration.getClickToTitle( Configuration.open_pdb_web ) );
897 if ( default_option == Configuration.open_pdb_web ) {
898 selected_index = cb_index;
902 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
903 _open_tax_web_item = cb_index;
904 addClickToOption( Configuration.open_tax_web,
905 _configuration.getClickToTitle( Configuration.open_tax_web ) );
906 if ( default_option == Configuration.open_tax_web ) {
907 selected_index = cb_index;
911 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
912 _blast_item = cb_index;
913 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
914 if ( default_option == Configuration.blast ) {
915 selected_index = cb_index;
919 if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
920 _select_nodes_item = cb_index;
921 addClickToOption( Configuration.select_nodes,
922 _configuration.getClickToTitle( Configuration.select_nodes ) );
923 if ( default_option == Configuration.select_nodes ) {
924 selected_index = cb_index;
928 if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
929 _get_ext_desc_data = cb_index;
930 if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
931 addClickToOption( Configuration.get_ext_desc_data,
932 getConfiguration().getLabelForGetExtDescendentsData() );
935 addClickToOption( Configuration.get_ext_desc_data,
936 getConfiguration().getClickToTitle( Configuration.get_ext_desc_data ) );
938 if ( default_option == Configuration.get_ext_desc_data ) {
939 selected_index = cb_index;
943 if ( getOptions().isEditable() ) {
944 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
945 _cut_subtree_item = cb_index;
946 addClickToOption( Configuration.cut_subtree,
947 _configuration.getClickToTitle( Configuration.cut_subtree ) );
948 if ( default_option == Configuration.cut_subtree ) {
949 selected_index = cb_index;
953 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
954 _copy_subtree_item = cb_index;
955 addClickToOption( Configuration.copy_subtree,
956 _configuration.getClickToTitle( Configuration.copy_subtree ) );
957 if ( default_option == Configuration.copy_subtree ) {
958 selected_index = cb_index;
962 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
963 _paste_subtree_item = cb_index;
964 addClickToOption( Configuration.paste_subtree,
965 _configuration.getClickToTitle( Configuration.paste_subtree ) );
966 if ( default_option == Configuration.paste_subtree ) {
967 selected_index = cb_index;
971 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
972 _delete_node_or_subtree_item = cb_index;
973 addClickToOption( Configuration.delete_subtree_or_node,
974 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
975 if ( default_option == Configuration.delete_subtree_or_node ) {
976 selected_index = cb_index;
980 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
981 _add_new_node_item = cb_index;
982 addClickToOption( Configuration.add_new_node,
983 _configuration.getClickToTitle( Configuration.add_new_node ) );
984 if ( default_option == Configuration.add_new_node ) {
985 selected_index = cb_index;
989 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
990 _edit_node_data_item = cb_index;
991 addClickToOption( Configuration.edit_node_data,
992 _configuration.getClickToTitle( Configuration.edit_node_data ) );
993 if ( default_option == Configuration.edit_node_data ) {
994 selected_index = cb_index;
999 // Set default selection and its action
1000 _click_to_combobox.setSelectedIndex( selected_index );
1001 setClickToAction( selected_index );
1004 private void setupDisplayCheckboxes() {
1005 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
1006 addCheckbox( Configuration.display_as_phylogram,
1007 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
1008 setCheckbox( Configuration.display_as_phylogram,
1009 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
1011 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
1012 addCheckbox( Configuration.dynamically_hide_data,
1013 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
1014 setCheckbox( Configuration.dynamically_hide_data,
1015 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
1017 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
1018 addCheckbox( Configuration.node_data_popup,
1019 _configuration.getDisplayTitle( Configuration.node_data_popup ) );
1020 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
1022 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
1023 addCheckbox( Configuration.display_internal_data,
1024 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
1025 setCheckbox( Configuration.display_internal_data,
1026 _configuration.doCheckOption( Configuration.display_internal_data ) );
1028 if ( _configuration.doDisplayOption( Configuration.color_according_to_sequence ) ) {
1029 addCheckbox( Configuration.color_according_to_sequence,
1030 _configuration.getDisplayTitle( Configuration.color_according_to_sequence ) );
1031 setCheckbox( Configuration.color_according_to_sequence,
1032 _configuration.doCheckOption( Configuration.color_according_to_sequence ) );
1034 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
1035 addCheckbox( Configuration.color_according_to_species,
1036 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
1037 setCheckbox( Configuration.color_according_to_species,
1038 _configuration.doCheckOption( Configuration.color_according_to_species ) );
1040 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
1041 addCheckbox( Configuration.color_according_to_annotation,
1042 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
1043 setCheckbox( Configuration.color_according_to_annotation,
1044 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
1046 if ( _configuration.doDisplayOption( Configuration.use_style ) ) {
1047 addCheckbox( Configuration.use_style, _configuration.getDisplayTitle( Configuration.use_style ) );
1048 setCheckbox( Configuration.use_style, _configuration.doCheckOption( Configuration.use_style ) );
1050 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
1051 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
1052 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
1054 final JLabel label = new JLabel( "Display Data:" );
1055 label.setFont( ControlPanel.jcb_bold_font );
1056 if ( !getConfiguration().isUseNativeUI() ) {
1057 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1060 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
1061 addCheckbox( Configuration.show_node_names,
1062 _configuration.getDisplayTitle( Configuration.show_node_names ) );
1063 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1065 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1066 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1067 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1069 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1070 addCheckbox( Configuration.show_taxonomy_scientific_names,
1071 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1072 setCheckbox( Configuration.show_taxonomy_scientific_names,
1073 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1075 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1076 addCheckbox( Configuration.show_taxonomy_common_names,
1077 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1078 setCheckbox( Configuration.show_taxonomy_common_names,
1079 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1081 if ( _configuration.doDisplayOption( Configuration.show_tax_rank ) ) {
1082 addCheckbox( Configuration.show_tax_rank, _configuration.getDisplayTitle( Configuration.show_tax_rank ) );
1083 setCheckbox( Configuration.show_tax_rank, _configuration.doCheckOption( Configuration.show_tax_rank ) );
1085 if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
1086 addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
1087 setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
1089 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1090 addCheckbox( Configuration.show_gene_names,
1091 _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1092 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1094 if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
1095 addCheckbox( Configuration.show_seq_symbols,
1096 _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
1097 setCheckbox( Configuration.show_seq_symbols,
1098 _configuration.doCheckOption( Configuration.show_seq_symbols ) );
1100 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1101 addCheckbox( Configuration.show_sequence_acc,
1102 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1103 setCheckbox( Configuration.show_sequence_acc,
1104 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1106 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1107 addCheckbox( Configuration.show_annotation,
1108 _configuration.getDisplayTitle( Configuration.show_annotation ) );
1109 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1111 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1112 addCheckbox( Configuration.write_confidence_values,
1113 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1114 setCheckbox( Configuration.write_confidence_values,
1115 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1117 if ( _configuration.doDisplayOption( Configuration.write_branch_length_values ) ) {
1118 addCheckbox( Configuration.write_branch_length_values,
1119 _configuration.getDisplayTitle( Configuration.write_branch_length_values ) );
1120 setCheckbox( Configuration.write_branch_length_values,
1121 _configuration.doCheckOption( Configuration.write_branch_length_values ) );
1123 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1124 addCheckbox( Configuration.show_binary_characters,
1125 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1126 setCheckbox( Configuration.show_binary_characters,
1127 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1129 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1130 addCheckbox( Configuration.show_binary_character_counts,
1131 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1132 setCheckbox( Configuration.show_binary_character_counts,
1133 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1135 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1136 addCheckbox( Configuration.show_domain_architectures,
1137 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1138 setCheckbox( Configuration.show_domain_architectures,
1139 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1141 if ( _configuration.doDisplayOption( Configuration.show_mol_seqs ) ) {
1142 addCheckbox( Configuration.show_mol_seqs, _configuration.getDisplayTitle( Configuration.show_mol_seqs ) );
1143 setCheckbox( Configuration.show_mol_seqs, _configuration.doCheckOption( Configuration.show_mol_seqs ) );
1145 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1146 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1147 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1149 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1150 addCheckbox( Configuration.show_vector_data,
1151 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1152 setCheckbox( Configuration.show_vector_data,
1153 _configuration.doCheckOption( Configuration.show_vector_data ) );
1155 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1156 addCheckbox( Configuration.show_properties,
1157 _configuration.getDisplayTitle( Configuration.show_properties ) );
1158 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1160 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1161 addCheckbox( Configuration.show_taxonomy_images,
1162 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1163 setCheckbox( Configuration.show_taxonomy_images,
1164 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1168 private void setVisibilityOfDomainStrucureControls() {
1169 if ( _zoom_in_domain_structure != null ) {
1170 final MainFrame mf = getMainFrame();
1172 if ( isShowDomainArchitectures() ) {
1173 _domain_display_label.setVisible( true );
1174 _zoom_in_domain_structure.setVisible( true );
1175 _zoom_out_domain_structure.setVisible( true );
1176 _decr_domain_structure_evalue_thr.setVisible( true );
1177 _incr_domain_structure_evalue_thr.setVisible( true );
1178 _domain_structure_evalue_thr_tf.setVisible( true );
1179 if ( mf._right_line_up_domains_cbmi != null ) {
1180 mf._right_line_up_domains_cbmi.setVisible( true );
1182 if ( mf._show_domain_labels != null ) {
1183 mf._show_domain_labels.setVisible( true );
1187 _domain_display_label.setVisible( false );
1188 _zoom_in_domain_structure.setVisible( false );
1189 _zoom_out_domain_structure.setVisible( false );
1190 _decr_domain_structure_evalue_thr.setVisible( false );
1191 _incr_domain_structure_evalue_thr.setVisible( false );
1192 _domain_structure_evalue_thr_tf.setVisible( false );
1193 if ( mf._right_line_up_domains_cbmi != null ) {
1194 mf._right_line_up_domains_cbmi.setVisible( false );
1196 if ( mf._show_domain_labels != null ) {
1197 mf._show_domain_labels.setVisible( false );
1204 void activateButtonToReturnToSuperTree( int index ) {
1207 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
1210 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
1212 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1213 _return_to_super_tree.setEnabled( true );
1216 void activateButtonToUncollapseAll() {
1217 _uncollapse_all.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1218 _uncollapse_all.setEnabled( true );
1222 * Add zoom and quick edit buttons. (Last modified 8/9/04)
1225 final JLabel spacer = new JLabel( "" );
1226 spacer.setOpaque( false );
1228 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
1229 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1230 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
1231 final JPanel o_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1232 if ( !getConfiguration().isUseNativeUI() ) {
1233 x_panel.setBackground( getBackground() );
1234 y_panel.setBackground( getBackground() );
1235 z_panel.setBackground( getBackground() );
1236 o_panel.setBackground( getBackground() );
1238 add( _zoom_label = new JLabel( "Zoom:" ) );
1239 customizeLabel( _zoom_label, getConfiguration() );
1243 if ( getConfiguration().isUseNativeUI() ) {
1244 _zoom_in_x = new TypomaticJButton( "+" );
1245 _zoom_out_x = new TypomaticJButton( "-" );
1248 _zoom_in_x = new TypomaticJButton( "X+" );
1249 _zoom_out_x = new TypomaticJButton( "X-" );
1251 _zoom_in_y = new TypomaticJButton( "Y+" );
1252 _zoom_out_y = new TypomaticJButton( "Y-" );
1253 _show_whole = new JButton( "F" );
1254 _show_whole.setToolTipText( "fit and center to display [Alt+C or Home]" );
1255 _zoom_in_x.setToolTipText( "zoom in horizontally [Alt+Right or Shift+Alt+mousewheel]" );
1256 _zoom_in_y.setToolTipText( "zoom in vertically [Alt+Up or Shift+mousewheel]" );
1257 _zoom_out_x.setToolTipText( "zoom out horizontally [Alt+Left or Shift+Alt+mousewheel]" );
1258 _zoom_out_y.setToolTipText( "zoom out vertically [Alt+Down or Shift+mousewheel]" );
1259 if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) {
1260 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
1261 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
1264 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
1265 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
1267 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
1268 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
1269 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
1270 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
1271 _return_to_super_tree.setToolTipText( "return to the super-tree (if in sub-tree) [Alt+R]" );
1272 _return_to_super_tree.setEnabled( false );
1273 _order = new JButton( "O" );
1274 _order.setToolTipText( "order all [Alt+O]" );
1275 _uncollapse_all = new JButton( "U" );
1276 _uncollapse_all.setToolTipText( "uncollapse all [Alt+U]" );
1277 addJButton( _zoom_in_y, x_panel );
1278 addJButton( _zoom_out_x, y_panel );
1279 addJButton( _show_whole, y_panel );
1280 addJButton( _zoom_in_x, y_panel );
1281 addJButton( _zoom_out_y, z_panel );
1282 final JLabel spacer2 = new JLabel( "" );
1285 addJButton( _order, o_panel );
1286 addJButton( _return_to_super_tree, o_panel );
1287 addJButton( _uncollapse_all, o_panel );
1288 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
1289 setUpControlsForDomainStrucures();
1292 setUpControlsForDepthCollapse();
1295 setUpControlsForRankCollapse();
1297 final JLabel spacer3 = new JLabel( "" );
1299 setVisibilityOfDomainStrucureControls();
1302 void addCheckbox( final int which, final String title ) {
1303 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
1305 case Configuration.display_as_phylogram:
1306 _display_as_phylogram_cb = new JCheckBox( title );
1307 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
1308 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
1311 case Configuration.display_internal_data:
1312 _display_internal_data = new JCheckBox( title );
1313 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
1314 addJCheckBox( _display_internal_data, ch_panel );
1317 case Configuration.color_according_to_species:
1318 _color_acc_species = new JCheckBox( title );
1319 _color_acc_species.setToolTipText( "To colorize node labels as a function of taxonomy" );
1320 addJCheckBox( _color_acc_species, ch_panel );
1323 case Configuration.color_according_to_sequence:
1324 _color_acc_sequence = new JCheckBox( title );
1325 _color_acc_sequence.setToolTipText( "To colorize node labels as a function of sequence name" );
1326 addJCheckBox( _color_acc_sequence, ch_panel );
1329 case Configuration.color_according_to_annotation:
1330 _color_according_to_annotation = new JCheckBox( title );
1331 _color_according_to_annotation
1332 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
1333 addJCheckBox( _color_according_to_annotation, ch_panel );
1336 case Configuration.show_node_names:
1337 _show_node_names = new JCheckBox( title );
1338 addJCheckBox( _show_node_names, ch_panel );
1341 case Configuration.show_taxonomy_scientific_names:
1342 _show_taxo_scientific_names = new JCheckBox( title );
1343 addJCheckBox( _show_taxo_scientific_names, ch_panel );
1346 case Configuration.show_taxonomy_common_names:
1347 _show_taxo_common_names = new JCheckBox( title );
1348 addJCheckBox( _show_taxo_common_names, ch_panel );
1351 case Configuration.show_tax_code:
1352 _show_taxo_code = new JCheckBox( title );
1353 addJCheckBox( _show_taxo_code, ch_panel );
1356 case Configuration.show_tax_rank:
1357 _show_taxo_rank = new JCheckBox( title );
1358 addJCheckBox( _show_taxo_rank, ch_panel );
1361 case Configuration.show_taxonomy_images:
1362 _show_taxo_images_cb = new JCheckBox( title );
1363 addJCheckBox( _show_taxo_images_cb, ch_panel );
1366 case Configuration.show_binary_characters:
1367 _show_binary_characters = new JCheckBox( title );
1368 addJCheckBox( _show_binary_characters, ch_panel );
1371 case Configuration.show_annotation:
1372 _show_annotation = new JCheckBox( title );
1373 addJCheckBox( _show_annotation, ch_panel );
1376 case Configuration.show_binary_character_counts:
1377 _show_binary_character_counts = new JCheckBox( title );
1378 addJCheckBox( _show_binary_character_counts, ch_panel );
1381 case Configuration.write_confidence_values:
1382 _write_confidence = new JCheckBox( title );
1383 addJCheckBox( getWriteConfidenceCb(), ch_panel );
1386 case Configuration.write_events:
1387 _show_events = new JCheckBox( title );
1388 addJCheckBox( getShowEventsCb(), ch_panel );
1391 case Configuration.use_style:
1392 _use_visual_styles_cb = new JCheckBox( title );
1393 getUseVisualStylesCb()
1394 .setToolTipText( "To use visual styles (node colors, fonts) and branch colors, if present" );
1395 addJCheckBox( getUseVisualStylesCb(), ch_panel );
1398 case Configuration.width_branches:
1399 _width_branches = new JCheckBox( title );
1400 _width_branches.setToolTipText( "To use branch width values, if present" );
1401 addJCheckBox( _width_branches, ch_panel );
1404 case Configuration.write_branch_length_values:
1405 _write_branch_length_values = new JCheckBox( title );
1406 addJCheckBox( _write_branch_length_values, ch_panel );
1409 case Configuration.show_domain_architectures:
1410 _show_domain_architectures = new JCheckBox( title );
1411 addJCheckBox( _show_domain_architectures, ch_panel );
1414 case Configuration.show_mol_seqs:
1415 _show_mol_seqs = new JCheckBox( title );
1416 addJCheckBox( _show_mol_seqs, ch_panel );
1419 case Configuration.show_seq_names:
1420 _show_seq_names = new JCheckBox( title );
1421 addJCheckBox( _show_seq_names, ch_panel );
1424 case Configuration.show_gene_names:
1425 _show_gene_names = new JCheckBox( title );
1426 addJCheckBox( _show_gene_names, ch_panel );
1429 case Configuration.show_seq_symbols:
1430 _show_seq_symbols = new JCheckBox( title );
1431 addJCheckBox( _show_seq_symbols, ch_panel );
1434 case Configuration.show_sequence_acc:
1435 _show_sequence_acc = new JCheckBox( title );
1436 addJCheckBox( _show_sequence_acc, ch_panel );
1439 case Configuration.dynamically_hide_data:
1440 _dynamically_hide_data = new JCheckBox( title );
1441 getDynamicallyHideData().setToolTipText( "To hide labels depending on expected visibility" );
1442 addJCheckBox( getDynamicallyHideData(), ch_panel );
1445 case Configuration.node_data_popup:
1446 _node_desc_popup_cb = new JCheckBox( title );
1447 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
1448 addJCheckBox( getNodeDescPopupCb(), ch_panel );
1451 case Configuration.show_relation_confidence:
1452 _seq_relation_confidence_switch = new JCheckBox( title );
1453 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
1456 case Configuration.show_vector_data:
1457 _show_vector_data_cb = new JCheckBox( title );
1458 addJCheckBox( _show_vector_data_cb, ch_panel );
1461 case Configuration.show_properties:
1462 _show_properties_cb = new JCheckBox( title );
1463 addJCheckBox( _show_properties_cb, ch_panel );
1467 throw new RuntimeException( "unknown checkbox: " + which );
1471 void addJButton( final JButton jb, final JPanel p ) {
1472 jb.setFocusPainted( false );
1473 jb.setFont( ControlPanel.jcb_font );
1474 if ( !_configuration.isUseNativeUI() ) {
1475 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
1476 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1477 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
1480 jb.addActionListener( this );
1483 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
1484 jcb.setFocusPainted( false );
1485 jcb.setFont( ControlPanel.jcb_font );
1486 if ( !_configuration.isUseNativeUI() ) {
1487 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
1488 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1490 p.add( jcb, "Center" );
1491 jcb.addActionListener( this );
1494 void addJTextField( final JTextField tf, final JPanel p ) {
1495 if ( !_configuration.isUseNativeUI() ) {
1496 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
1497 tf.setFont( ControlPanel.jcb_font );
1500 tf.addActionListener( this );
1503 void deactivateButtonToReturnToSuperTree() {
1504 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
1505 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
1506 _return_to_super_tree.setEnabled( false );
1509 void deactivateButtonToUncollapseAll() {
1510 _uncollapse_all.setForeground( getConfiguration().getGuiButtonTextColor() );
1511 _uncollapse_all.setEnabled( false );
1514 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
1515 if ( ( _mainpanel != null )
1516 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
1517 if ( recalc_longest_ext_node_info ) {
1518 _mainpanel.getCurrentTreePanel().initNodeData();
1519 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
1521 if ( getOptions().isShowOverview() ) {
1522 _mainpanel.getCurrentTreePanel().updateOvSizes();
1524 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
1525 setVisibilityOfDomainStrucureControls();
1526 updateDomainStructureEvaluethresholdDisplay();
1527 updateDepthCollapseDepthDisplay();
1528 updateRankCollapseRankDisplay();
1529 getMainPanel().getControlPanel();
1530 _mainpanel.getCurrentTreePanel().updateButtonToUncollapseAll();
1531 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
1532 _mainpanel.getCurrentTreePanel().calcMaxDepth();
1533 _mainpanel.adjustJScrollPane();
1534 _mainpanel.getCurrentTreePanel().repaint();
1535 // _mainpanel.getCurrentTreePanel().setUpUrtFactor();
1539 void endClickToOptions() {
1540 _click_to_combobox.addActionListener( this );
1544 * Indicates what action should be execute when a node is clicked
1546 * @return the click-on action
1548 NodeClickAction getActionWhenNodeClicked() {
1549 return _action_when_node_clicked;
1552 Map<Integer, String> getAllClickToItems() {
1553 return _all_click_to_names;
1556 Map<String, Color> getAnnotationColors() {
1557 return _annotation_colors;
1560 Configuration getConfiguration() {
1561 return _configuration;
1564 TreePanel getCurrentTreePanel() {
1565 return getMainPanel().getCurrentTreePanel();
1568 MainPanel getMainPanel() {
1572 Options getOptions() {
1573 return getMainPanel().getOptions();
1576 JLabel getSearchFoundCountsLabel0() {
1577 return _search_found_label_0;
1580 JLabel getSearchFoundCountsLabel1() {
1581 return _search_found_label_1;
1584 JButton getSearchResetButton0() {
1585 return _search_reset_button_0;
1588 JButton getSearchResetButton1() {
1589 return _search_reset_button_1;
1592 JTextField getSearchTextField0() {
1593 return _search_tf_0;
1596 JTextField getSearchTextField1() {
1597 return _search_tf_1;
1600 Map<String, Color> getSequenceColors() {
1601 return _sequence_colors;
1604 List<String> getSingleClickToNames() {
1605 return _click_to_names;
1608 Map<String, Color> getSpeciesColors() {
1609 return _species_colors;
1612 boolean isAntialiasScreenText() {
1616 boolean isColorAccordingToAnnotation() {
1617 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
1620 boolean isColorAccordingToSequence() {
1621 return ( ( _color_acc_sequence != null ) && _color_acc_sequence.isSelected() );
1624 boolean isColorAccordingToTaxonomy() {
1625 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
1628 boolean isDrawPhylogram() {
1629 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
1632 boolean isDynamicallyHideData() {
1633 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
1636 boolean isEvents() {
1637 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
1640 boolean isNodeDescPopup() {
1641 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
1644 boolean isShowAnnotation() {
1645 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
1648 boolean isShowBinaryCharacterCounts() {
1649 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
1652 boolean isShowBinaryCharacters() {
1653 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
1656 boolean isShowConfidenceValues() {
1657 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
1660 boolean isShowDomainArchitectures() {
1661 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
1664 boolean isShowGeneNames() {
1665 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
1668 boolean isShowInternalData() {
1669 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
1672 boolean isShowNodeNames() {
1673 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
1676 boolean isShowSeqNames() {
1677 return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
1680 boolean isShowSeqSymbols() {
1681 return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
1684 boolean isShowSequenceAcc() {
1685 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
1688 boolean isShowSequenceRelationConfidence() {
1689 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
1692 boolean isShowSequenceRelations() {
1693 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
1696 boolean isShowTaxonomyCode() {
1697 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
1700 boolean isShowTaxonomyRank() {
1701 return ( ( _show_taxo_rank != null ) && _show_taxo_rank.isSelected() );
1704 boolean isShowTaxonomyCommonNames() {
1705 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
1708 boolean isShowTaxonomyScientificNames() {
1709 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
1712 boolean isUseVisualStyles() {
1713 return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() )
1714 || ( ( getUseVisualStylesCb() == null ) && _color_branches ) );
1717 boolean isWidthBranches() {
1718 return ( ( _width_branches != null ) && _width_branches.isSelected() );
1721 boolean isWriteBranchLengthValues() {
1722 return ( ( _write_branch_length_values != null ) && _write_branch_length_values.isSelected() );
1725 void phylogenyAdded( final Configuration configuration ) {
1726 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
1729 void phylogenyRemoved( final int index ) {
1730 getIsDrawPhylogramList().remove( index );
1734 final MainPanel main_panel = getMainPanel();
1735 final Phylogeny tree = main_panel.getCurrentPhylogeny();
1736 if ( ( tree == null ) || tree.isEmpty() ) {
1739 String query = getSearchTextField0().getText();
1740 if ( query != null ) {
1741 query = query.trim();
1743 if ( !ForesterUtil.isEmpty( query ) ) {
1744 search0( main_panel, tree, query );
1747 getSearchFoundCountsLabel0().setVisible( false );
1748 getSearchResetButton0().setEnabled( false );
1749 getSearchResetButton0().setVisible( false );
1755 final MainPanel main_panel = getMainPanel();
1756 final Phylogeny tree = main_panel.getCurrentPhylogeny();
1757 if ( ( tree == null ) || tree.isEmpty() ) {
1760 String query = getSearchTextField1().getText();
1761 if ( query != null ) {
1762 query = query.trim();
1764 if ( !ForesterUtil.isEmpty( query ) ) {
1765 search1( main_panel, tree, query );
1768 getSearchFoundCountsLabel1().setVisible( false );
1769 getSearchResetButton1().setEnabled( false );
1770 getSearchResetButton1().setVisible( false );
1775 void searchReset0() {
1776 if ( getMainPanel().getCurrentTreePanel() != null ) {
1777 getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
1781 void searchReset1() {
1782 if ( getMainPanel().getCurrentTreePanel() != null ) {
1783 getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
1787 void setActionWhenNodeClicked( final NodeClickAction action ) {
1788 _action_when_node_clicked = action;
1791 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
1792 _annotation_colors = annotation_colors;
1795 void setCheckbox( final int which, final boolean state ) {
1797 case Configuration.display_as_phylogram:
1798 if ( getDisplayAsPhylogramCb() != null ) {
1799 getDisplayAsPhylogramCb().setSelected( state );
1802 case Configuration.display_internal_data:
1803 if ( _display_internal_data != null ) {
1804 _display_internal_data.setSelected( state );
1807 case Configuration.color_according_to_species:
1808 if ( _color_acc_species != null ) {
1809 _color_acc_species.setSelected( state );
1812 case Configuration.color_according_to_sequence:
1813 if ( _color_acc_sequence != null ) {
1814 _color_acc_sequence.setSelected( state );
1817 case Configuration.color_according_to_annotation:
1818 if ( _color_according_to_annotation != null ) {
1819 _color_according_to_annotation.setSelected( state );
1822 case Configuration.show_node_names:
1823 if ( _show_node_names != null ) {
1824 _show_node_names.setSelected( state );
1827 case Configuration.show_taxonomy_scientific_names:
1828 if ( _show_taxo_scientific_names != null ) {
1829 _show_taxo_scientific_names.setSelected( state );
1832 case Configuration.show_taxonomy_common_names:
1833 if ( _show_taxo_common_names != null ) {
1834 _show_taxo_common_names.setSelected( state );
1837 case Configuration.show_tax_code:
1838 if ( _show_taxo_code != null ) {
1839 _show_taxo_code.setSelected( state );
1842 case Configuration.show_tax_rank:
1843 if ( _show_taxo_rank != null ) {
1844 _show_taxo_rank.setSelected( state );
1847 case Configuration.show_taxonomy_images:
1848 if ( _show_taxo_images_cb != null ) {
1849 _show_taxo_images_cb.setSelected( state );
1852 case Configuration.show_annotation:
1853 if ( _show_annotation != null ) {
1854 _show_annotation.setSelected( state );
1857 case Configuration.show_binary_characters:
1858 if ( _show_binary_characters != null ) {
1859 _show_binary_characters.setSelected( state );
1862 case Configuration.show_binary_character_counts:
1863 if ( _show_binary_character_counts != null ) {
1864 _show_binary_character_counts.setSelected( state );
1867 case Configuration.write_confidence_values:
1868 if ( getWriteConfidenceCb() != null ) {
1869 getWriteConfidenceCb().setSelected( state );
1872 case Configuration.write_events:
1873 if ( getShowEventsCb() != null ) {
1874 getShowEventsCb().setSelected( state );
1877 case Configuration.use_style:
1878 if ( getUseVisualStylesCb() != null ) {
1879 getUseVisualStylesCb().setSelected( state );
1882 case Configuration.width_branches:
1883 if ( _width_branches != null ) {
1884 _width_branches.setSelected( state );
1887 case Configuration.show_domain_architectures:
1888 if ( _show_domain_architectures != null ) {
1889 _show_domain_architectures.setSelected( state );
1892 case Configuration.write_branch_length_values:
1893 if ( _write_branch_length_values != null ) {
1894 _write_branch_length_values.setSelected( state );
1897 case Configuration.show_mol_seqs:
1898 if ( _show_mol_seqs != null ) {
1899 _show_mol_seqs.setSelected( state );
1902 case Configuration.show_seq_names:
1903 if ( _show_seq_names != null ) {
1904 _show_seq_names.setSelected( state );
1907 case Configuration.show_gene_names:
1908 if ( _show_gene_names != null ) {
1909 _show_gene_names.setSelected( state );
1912 case Configuration.show_seq_symbols:
1913 if ( _show_seq_symbols != null ) {
1914 _show_seq_symbols.setSelected( state );
1917 case Configuration.show_vector_data:
1918 if ( _show_vector_data_cb != null ) {
1919 _show_vector_data_cb.setSelected( state );
1922 case Configuration.show_properties:
1923 if ( _show_properties_cb != null ) {
1924 _show_properties_cb.setSelected( state );
1927 case Configuration.show_sequence_acc:
1928 if ( _show_sequence_acc != null ) {
1929 _show_sequence_acc.setSelected( state );
1932 case Configuration.dynamically_hide_data:
1933 if ( getDynamicallyHideData() != null ) {
1934 getDynamicallyHideData().setSelected( state );
1937 case Configuration.node_data_popup:
1938 if ( getNodeDescPopupCb() != null ) {
1939 getNodeDescPopupCb().setSelected( state );
1943 case Configuration.show_relation_confidence:
1944 if ( _seq_relation_confidence_switch != null ) {
1945 _seq_relation_confidence_switch.setSelected( state );
1950 throw new AssertionError( "unknown checkbox: " + which );
1955 * Set this checkbox state. Not all checkboxes have been instantiated
1956 * depending on the config.
1958 void setCheckbox( final JCheckBox cb, final boolean state ) {
1960 cb.setSelected( state );
1964 void setClickToAction( final int action ) {
1965 // Set click-to action
1966 if ( action == _show_data_item ) {
1967 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1969 else if ( action == _collapse_cb_item ) {
1970 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1972 else if ( action == _reroot_cb_item ) {
1973 setActionWhenNodeClicked( NodeClickAction.REROOT );
1975 else if ( action == _subtree_cb_item ) {
1976 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1978 else if ( action == _swap_cb_item ) {
1979 setActionWhenNodeClicked( NodeClickAction.SWAP );
1981 else if ( action == _color_subtree_cb_item ) {
1982 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1984 else if ( action == _open_seq_web_item ) {
1985 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1987 else if ( action == _sort_descendents_item ) {
1988 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1990 else if ( action == _blast_item ) {
1991 setActionWhenNodeClicked( NodeClickAction.BLAST );
1993 else if ( action == _open_tax_web_item ) {
1994 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1996 else if ( action == _cut_subtree_item ) {
1997 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1999 else if ( action == _copy_subtree_item ) {
2000 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
2002 else if ( action == _delete_node_or_subtree_item ) {
2003 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
2005 else if ( action == _paste_subtree_item ) {
2006 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
2008 else if ( action == _add_new_node_item ) {
2009 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
2011 else if ( action == _edit_node_data_item ) {
2012 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
2014 else if ( action == _select_nodes_item ) {
2015 setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
2017 else if ( action == _get_ext_desc_data ) {
2018 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
2020 else if ( action == _open_pdb_item ) {
2021 setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
2023 else if ( action == _color_node_font_item ) {
2024 setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
2026 else if ( action == _change_node_font_item ) {
2027 setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT );
2029 else if ( action == _uncollapse_all_cb_item ) {
2030 setActionWhenNodeClicked( NodeClickAction.UNCOLLAPSE_ALL );
2032 else if ( action == _order_subtree_cb_item ) {
2033 setActionWhenNodeClicked( NodeClickAction.ORDER_SUBTREE );
2036 throw new RuntimeException( "unknown action: " + action );
2038 // make sure drop down is displaying the correct action
2039 // in case this was called from outside the class
2040 _click_to_combobox.setSelectedIndex( action );
2043 void setColorBranches( final boolean color_branches ) {
2044 _color_branches = color_branches;
2047 void setDrawPhylogram( final boolean b ) {
2048 getDisplayAsPhylogramCb().setSelected( b );
2049 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
2052 void setDrawPhylogramEnabled( final boolean b ) {
2053 getDisplayAsPhylogramCb().setEnabled( b );
2056 void setDynamicHidingIsOn( final boolean is_on ) {
2058 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
2061 if ( !_configuration.isUseNativeUI() ) {
2062 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
2065 getDynamicallyHideData().setForeground( Color.BLACK );
2070 void setSearchFoundCountsOnLabel0( final int counts ) {
2071 getSearchFoundCountsLabel0().setText( "Found: " + counts );
2074 void setSearchFoundCountsOnLabel1( final int counts ) {
2075 getSearchFoundCountsLabel1().setText( "Found: " + counts );
2078 void setSequenceColors( final Map<String, Color> sequence_colors ) {
2079 _sequence_colors = sequence_colors;
2082 void setShowEvents( final boolean show_events ) {
2083 if ( getShowEventsCb() == null ) {
2084 _show_events = new JCheckBox( "" );
2086 getShowEventsCb().setSelected( show_events );
2089 void setSpeciesColors( final Map<String, Color> species_colors ) {
2090 _species_colors = species_colors;
2093 void setupControls() {
2094 // The tree display options:
2095 setupDisplayCheckboxes();
2097 // The sequence relation query selection combo-box
2098 if ( _configuration.displaySequenceRelations() ) {
2099 addSequenceRelationBlock();
2103 startClickToOptions();
2104 setupClickToOptions();
2105 endClickToOptions();
2106 // Zoom and quick edit buttons
2108 setupSearchTools0();
2109 setupSearchTools1();
2112 void setUpControlsForDomainStrucures() {
2113 _domain_display_label = new JLabel( "Domain Architectures:" );
2114 add( customizeLabel( _domain_display_label, getConfiguration() ) );
2115 add( _domain_display_label );
2116 _zoom_in_domain_structure = new TypomaticJButton( "d+" );
2117 _zoom_out_domain_structure = new TypomaticJButton( "d-" );
2118 _decr_domain_structure_evalue_thr = new JButton( "-" );
2119 _incr_domain_structure_evalue_thr = new JButton( "+" );
2120 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
2121 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
2122 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
2123 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
2124 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
2125 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
2126 _domain_structure_evalue_thr_tf = new JTextField( 3 );
2127 _domain_structure_evalue_thr_tf.setEditable( false );
2128 if ( !getConfiguration().isUseNativeUI() ) {
2129 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2130 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2131 _domain_structure_evalue_thr_tf.setBorder( null );
2133 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2134 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2135 if ( !_configuration.isUseNativeUI() ) {
2136 d1_panel.setBackground( getBackground() );
2137 d2_panel.setBackground( getBackground() );
2141 addJButton( _zoom_out_domain_structure, d1_panel );
2142 addJButton( _zoom_in_domain_structure, d1_panel );
2143 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
2144 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
2145 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
2148 void setUpControlsForDepthCollapse() {
2149 _depth_collapse_label = new JLabel( "Collapse by Node Depth:" );
2150 _depth_collapse_label
2151 .setToolTipText( "to automaticall collapse nodes with a depth equal or larger than a threshold" );
2152 add( customizeLabel( _depth_collapse_label, getConfiguration() ) );
2153 add( _depth_collapse_label );
2154 _decr_depth_collapse_level = new TypomaticJButton( "-" );
2155 _incr_depth_collapse_level = new TypomaticJButton( "+" );
2156 _decr_depth_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2157 _incr_depth_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2158 _decr_depth_collapse_level.setToolTipText( "to decrease the depth threshold (wraps around)" );
2159 _incr_depth_collapse_level.setToolTipText( "to increase the depth threshold (wraps around)" );
2160 _depth_collapse_depth_tf = new JTextField( 3 );
2161 _depth_collapse_depth_tf.setToolTipText( "the current depth threshold" );
2162 _depth_collapse_depth_tf.setEditable( false );
2163 if ( !getConfiguration().isUseNativeUI() ) {
2164 _depth_collapse_depth_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2165 _depth_collapse_depth_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2166 _depth_collapse_depth_tf.setBorder( null );
2168 final JPanel panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2169 if ( !_configuration.isUseNativeUI() ) {
2170 panel.setBackground( getBackground() );
2173 addJButton( _decr_depth_collapse_level, panel );
2174 addJTextField( _depth_collapse_depth_tf, panel );
2175 addJButton( _incr_depth_collapse_level, panel );
2178 void setUpControlsForRankCollapse() {
2179 _rank_collapse_label = new JLabel( "Collapse by Node Rank:" );
2180 _rank_collapse_label
2181 .setToolTipText( "to automatically collapse nodes with a taxonomic rank equal or lower than a threshold" );
2182 add( customizeLabel( _rank_collapse_label, getConfiguration() ) );
2183 add( _rank_collapse_label );
2184 _decr_rank_collapse_level = new TypomaticJButton( "-" );
2185 _incr_rank_collapse_level = new TypomaticJButton( "+" );
2186 _decr_rank_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2187 _incr_rank_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
2188 _decr_rank_collapse_level.setToolTipText( "to decrease the taxonomic rank threshold (wraps around)" );
2189 _incr_rank_collapse_level.setToolTipText( "to increase the taxonomic rank threshold (wraps around)" );
2190 _rank_collapse_depth_tf = new JTextField( 3 );
2191 _rank_collapse_depth_tf.setToolTipText( "the current taxonomic rank threshold" );
2192 _rank_collapse_depth_tf.setEditable( false );
2193 if ( !getConfiguration().isUseNativeUI() ) {
2194 _rank_collapse_depth_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2195 _rank_collapse_depth_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2196 _rank_collapse_depth_tf.setBorder( null );
2198 final JPanel panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2199 if ( !_configuration.isUseNativeUI() ) {
2200 panel.setBackground( getBackground() );
2203 addJButton( _decr_rank_collapse_level, panel );
2204 addJTextField( _rank_collapse_depth_tf, panel );
2205 addJButton( _incr_rank_collapse_level, panel );
2208 void setupSearchTools0() {
2209 final JLabel search_label = new JLabel( "Search (A):" );
2210 search_label.setFont( ControlPanel.jcb_bold_font );
2211 if ( !getConfiguration().isUseNativeUI() ) {
2212 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2214 add( search_label );
2215 search_label.setToolTipText( SEARCH_TIP_TEXT );
2216 _search_found_label_0 = new JLabel();
2217 getSearchFoundCountsLabel0().setVisible( false );
2218 _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
2219 if ( !getConfiguration().isUseNativeUI() ) {
2220 _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2222 _search_tf_0 = new JTextField( 3 );
2223 _search_tf_0.setToolTipText( SEARCH_TIP_TEXT );
2224 _search_tf_0.setEditable( true );
2225 if ( !getConfiguration().isUseNativeUI() ) {
2226 _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2227 _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2228 _search_tf_0.setBorder( null );
2230 _search_reset_button_0 = new JButton();
2231 getSearchResetButton0().setText( "Reset" );
2232 getSearchResetButton0().setEnabled( false );
2233 getSearchResetButton0().setVisible( false );
2234 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
2235 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2236 s_panel_1.setBackground( getBackground() );
2238 s_panel_2.setBackground( getBackground() );
2240 final KeyAdapter key_adapter = new KeyAdapter() {
2243 public void keyReleased( final KeyEvent key_event ) {
2245 displayedPhylogenyMightHaveChanged( true );
2248 final ActionListener action_listener = new ActionListener() {
2251 public void actionPerformed( final ActionEvent e ) {
2253 setSearchFoundCountsOnLabel0( 0 );
2254 getSearchFoundCountsLabel0().setVisible( false );
2255 getSearchTextField0().setText( "" );
2256 getSearchResetButton0().setEnabled( false );
2257 getSearchResetButton0().setVisible( false );
2258 displayedPhylogenyMightHaveChanged( true );
2261 _search_reset_button_0.addActionListener( action_listener );
2262 _search_tf_0.addKeyListener( key_adapter );
2263 addJTextField( _search_tf_0, s_panel_1 );
2264 s_panel_2.add( _search_found_label_0 );
2265 addJButton( _search_reset_button_0, s_panel_2 );
2268 void setupSearchTools1() {
2269 final JLabel search_label = new JLabel( "Search (B):" );
2270 search_label.setFont( ControlPanel.jcb_bold_font );
2271 if ( !getConfiguration().isUseNativeUI() ) {
2272 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2274 add( search_label );
2275 search_label.setToolTipText( SEARCH_TIP_TEXT );
2276 _search_found_label_1 = new JLabel();
2277 getSearchFoundCountsLabel1().setVisible( false );
2278 _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
2279 if ( !getConfiguration().isUseNativeUI() ) {
2280 _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2282 _search_tf_1 = new JTextField( 3 );
2283 _search_tf_1.setToolTipText( SEARCH_TIP_TEXT );
2284 _search_tf_1.setEditable( true );
2285 if ( !getConfiguration().isUseNativeUI() ) {
2286 _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2287 _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2288 _search_tf_1.setBorder( null );
2290 _search_reset_button_1 = new JButton();
2291 getSearchResetButton1().setText( "Reset" );
2292 getSearchResetButton1().setEnabled( false );
2293 getSearchResetButton1().setVisible( false );
2294 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
2295 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2296 s_panel_1.setBackground( getBackground() );
2298 s_panel_2.setBackground( getBackground() );
2300 final KeyAdapter key_adapter = new KeyAdapter() {
2303 public void keyReleased( final KeyEvent key_event ) {
2305 displayedPhylogenyMightHaveChanged( true );
2308 final ActionListener action_listener = new ActionListener() {
2311 public void actionPerformed( final ActionEvent e ) {
2313 setSearchFoundCountsOnLabel1( 0 );
2314 getSearchFoundCountsLabel1().setVisible( false );
2315 getSearchTextField1().setText( "" );
2316 getSearchResetButton1().setEnabled( false );
2317 getSearchResetButton1().setVisible( false );
2318 displayedPhylogenyMightHaveChanged( true );
2321 _search_reset_button_1.addActionListener( action_listener );
2322 _search_tf_1.addKeyListener( key_adapter );
2323 addJTextField( _search_tf_1, s_panel_1 );
2324 s_panel_2.add( _search_found_label_1 );
2325 addJButton( _search_reset_button_1, s_panel_2 );
2328 void setVisibilityOfDomainStrucureCB() {
2330 if ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel()
2331 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2332 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
2333 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2334 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
2336 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2337 getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
2340 else if ( isShowDomainArchitectures() ) {
2341 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2342 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( true );
2344 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2345 getMainPanel().getMainFrame()._show_domain_labels.setVisible( true );
2349 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2350 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
2352 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2353 getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
2357 catch ( final Exception ignore ) {
2362 void setVisibilityOfX() {
2363 final MainFrame mf = getMainFrame();
2365 if ( ( getCurrentTreePanel() != null ) && ( getCurrentTreePanel().getPhylogeny() != null ) ) {
2366 if ( AptxUtil.isHasAtLeastOneBranchWithSupportSD( getCurrentTreePanel().getPhylogeny() ) ) {
2367 if ( mf._show_confidence_stddev_cbmi != null ) {
2368 mf._show_confidence_stddev_cbmi.setVisible( true );
2372 if ( mf._show_confidence_stddev_cbmi != null ) {
2373 mf._show_confidence_stddev_cbmi.setVisible( false );
2376 if ( AptxUtil.isHasAtLeastOneNodeWithScientificName( getCurrentTreePanel().getPhylogeny() ) ) {
2377 if ( mf._abbreviate_scientific_names != null ) {
2378 mf._abbreviate_scientific_names.setVisible( true );
2382 if ( mf._abbreviate_scientific_names != null ) {
2383 mf._abbreviate_scientific_names.setVisible( false );
2386 if ( AptxUtil.isHasAtLeastOneNodeWithSequenceAnnotation( getCurrentTreePanel().getPhylogeny() ) ) {
2387 if ( mf._show_annotation_ref_source != null ) {
2388 mf._show_annotation_ref_source.setVisible( true );
2392 if ( mf._show_annotation_ref_source != null ) {
2393 mf._show_annotation_ref_source.setVisible( false );
2397 if ( isDrawPhylogram() || ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel()
2398 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2399 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) ) {
2400 if ( mf._non_lined_up_cladograms_rbmi != null ) {
2401 mf._non_lined_up_cladograms_rbmi.setVisible( false );
2403 if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
2404 mf._ext_node_dependent_cladogram_rbmi.setVisible( false );
2408 if ( mf._non_lined_up_cladograms_rbmi != null ) {
2409 mf._non_lined_up_cladograms_rbmi.setVisible( true );
2411 if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
2412 mf._ext_node_dependent_cladogram_rbmi.setVisible( true );
2415 if ( isDrawPhylogram() ) {
2416 if ( mf._show_scale_cbmi != null ) {
2417 mf._show_scale_cbmi.setVisible( true );
2421 if ( mf._show_scale_cbmi != null ) {
2422 mf._show_scale_cbmi.setVisible( false );
2425 if ( getCurrentTreePanel() != null ) {
2426 if ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2427 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
2428 if ( mf._label_direction_cbmi != null ) {
2429 mf._label_direction_cbmi.setVisible( true );
2433 if ( mf._label_direction_cbmi != null ) {
2434 mf._label_direction_cbmi.setVisible( false );
2441 void showAnnotations() {
2442 if ( _show_annotation != null ) {
2443 _show_annotation.setSelected( true );
2445 if ( _color_according_to_annotation != null ) {
2446 _color_according_to_annotation.setSelected( true );
2448 if ( _color_acc_species != null ) {
2449 _color_acc_species.setSelected( false );
2451 if ( _color_acc_sequence != null ) {
2452 _color_acc_sequence.setSelected( false );
2454 _mainpanel.getCurrentTreePanel().repaint();
2458 * Fit entire tree into window.
2461 if ( ( _mainpanel.getCurrentScrollPane() == null )
2462 || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
2465 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
2466 displayedPhylogenyMightHaveChanged( true );
2467 _mainpanel.getCurrentTreePanel().updateOvSettings();
2468 _mainpanel.getCurrentTreePanel().validate();
2469 _mainpanel.validate();
2470 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2471 _mainpanel.getSizeOfViewport().height );
2472 _mainpanel.getCurrentTreePanel().resetPreferredSize();
2473 _mainpanel.adjustJScrollPane();
2474 _mainpanel.getCurrentTreePanel().repaint();
2475 _mainpanel.getCurrentTreePanel().validate();
2476 _mainpanel.validate();
2477 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2478 _mainpanel.getSizeOfViewport().height );
2479 _mainpanel.getCurrentTreePanel().resetPreferredSize();
2480 _mainpanel.adjustJScrollPane();
2481 _mainpanel.getCurrentTreePanel().repaint();
2482 _mainpanel.getCurrentTreePanel().updateOvSizes();
2485 void showWholeAll() {
2486 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
2487 if ( tree_panel != null ) {
2488 tree_panel.validate();
2489 tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2490 _mainpanel.getSizeOfViewport().height );
2491 tree_panel.resetPreferredSize();
2492 tree_panel.repaint();
2497 // Create header for click-to combo box.
2498 void startClickToOptions() {
2499 final JLabel spacer = new JLabel( "" );
2500 spacer.setFont( ControlPanel.jcb_font );
2502 _click_to_label = new JLabel( "Click on Node to:" );
2503 add( customizeLabel( _click_to_label, getConfiguration() ) );
2504 _click_to_combobox = new JComboBox<String>();
2505 _click_to_combobox.setFocusable( false );
2506 _click_to_combobox.setMaximumRowCount( 14 );
2507 _click_to_combobox.setFont( ControlPanel.js_font );
2508 if ( !_configuration.isUseNativeUI() ) {
2509 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
2511 // don't add listener until all items are set (or each one will trigger
2513 // click_to_list.addActionListener(this);
2514 add( _click_to_combobox );
2515 // Correlates option names to titles
2516 _all_click_to_names = new HashMap<Integer, String>();
2517 _click_to_names = new ArrayList<String>();
2521 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
2522 if ( getCurrentTreePanel().isPhyHasBranchLengths()
2523 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
2524 setDrawPhylogramEnabled( true );
2525 setDrawPhylogram( isDrawPhylogram() );
2528 setDrawPhylogramEnabled( false );
2529 setDrawPhylogram( false );
2531 if ( getMainPanel().getMainFrame() == null ) {
2532 // Must be "E" applet version.
2533 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
2534 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
2537 getMainPanel().getMainFrame()
2538 .setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel().getPhylogenyGraphicsType() );
2540 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
2541 getMainPanel().getCurrentTreePanel().updateButtonToUncollapseAll();
2542 getMainPanel().getControlPanel().search0();
2543 getMainPanel().getControlPanel().search1();
2544 getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
2545 getMainPanel().getControlPanel().updateDepthCollapseDepthDisplay();
2546 getMainPanel().getControlPanel().updateRankCollapseRankDisplay();
2547 getSequenceRelationTypeBox().removeAllItems();
2548 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
2549 .getRelevantSequenceRelationTypes() ) {
2550 _sequence_relation_type_box.addItem( type );
2552 getMainPanel().getCurrentTreePanel().repaint();
2553 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
2554 // according to GUILHEM the line above can be removed.
2559 * Uncollapse all nodes.
2561 final void uncollapseAll( final TreePanel tp ) {
2562 final Phylogeny t = tp.getPhylogeny();
2563 if ( ( t != null ) && !t.isEmpty() ) {
2564 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
2565 final PhylogenyNode node = iter.next();
2566 node.setCollapse( false );
2568 tp.resetNodeIdToDistToLeafMap();
2569 tp.updateSetOfCollapsedExternalNodes();
2570 t.recalculateNumberOfExternalDescendants( false );
2571 tp.setNodeInPreorderToNull();
2572 t.clearHashIdToNodeMap();
2573 tp.resetDepthCollapseDepthValue();
2574 tp.resetRankCollapseRankValue();
2579 final void updateDomainStructureEvaluethresholdDisplay() {
2580 if ( _domain_structure_evalue_thr_tf != null ) {
2581 _domain_structure_evalue_thr_tf
2582 .setText( "10^" + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThresholdExp() );
2586 private final String obtainDepthCollapseDepthValue() {
2587 if ( getMainPanel().getCurrentTreePanel() == null ) {
2590 final TreePanel tp = getMainPanel().getCurrentTreePanel();
2591 final Phylogeny p = tp.getPhylogeny();
2592 if ( ( p == null ) || ( p.getNumberOfExternalNodes() < 3 ) ) {
2595 else if ( tp.getDepthCollapseDepthValue() < 0 ) {
2596 tp.setDepthCollapseDepthValue( PhylogenyMethods.calculateMaxDepth( p ) );
2599 else if ( tp.getDepthCollapseDepthValue() == PhylogenyMethods.calculateMaxDepth( p ) ) {
2602 return String.valueOf( tp.getDepthCollapseDepthValue() );
2605 private final String obtainRankCollapseDepthValue() {
2606 if ( getMainPanel().getCurrentTreePanel() == null ) {
2609 final TreePanel tp = getMainPanel().getCurrentTreePanel();
2610 final Phylogeny p = tp.getPhylogeny();
2611 if ( ( p == null ) || ( p.getNumberOfExternalNodes() < 3 ) ) {
2615 final String ranks[] = PhylogenyMethods.obtainPresentRanksSorted( p );
2616 if ( ranks.length < 1 ) {
2619 else if ( tp.getRankCollapseRankValue() < 0 ) {
2620 tp.setRankCollapseRankValue( ranks.length - 1 );
2623 else if ( tp.getRankCollapseRankValue() == ( ranks.length - 1 ) ) {
2627 return String.valueOf( tp.getRankCollapseRankValue() );
2630 final void updateDepthCollapseDepthDisplay() {
2631 if ( _depth_collapse_depth_tf != null ) {
2632 _depth_collapse_depth_tf.setText( " " + obtainDepthCollapseDepthValue() );
2636 final void updateRankCollapseRankDisplay() {
2637 if ( _rank_collapse_depth_tf != null ) {
2638 final String r = obtainRankCollapseDepthValue();
2639 if ( r.equals( "off" ) ) {
2640 _rank_collapse_depth_tf.setText( " off" );
2641 _rank_collapse_depth_tf.setToolTipText( "the current taxonomic rank threshold" );
2644 final String ranks[] = PhylogenyMethods
2645 .obtainPresentRanksSorted( getMainPanel().getCurrentTreePanel().getPhylogeny() );
2646 final int rr = Integer.parseInt( r );
2647 _rank_collapse_depth_tf.setText( ranks[ rr ] );
2648 _rank_collapse_depth_tf.setToolTipText( ( rr + 1 ) + "/" + ( ranks.length - 1 ) + ": "
2649 + ranks[ Integer.parseInt( r ) ] );
2654 final void zoomInX( final float factor, final float x_correction_factor ) {
2655 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
2656 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2657 treepanel.multiplyUrtFactor( 1f );
2658 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2659 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
2660 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
2661 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
2662 final double x = ( sb.getMaximum() - sb.getMinimum() )
2663 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2664 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2665 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2666 getMainPanel().adjustJScrollPane();
2667 treepanel.resetPreferredSize();
2668 getMainPanel().getCurrentScrollPane().getViewport().validate();
2669 sb.setValue( ForesterUtil
2670 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2673 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
2674 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2675 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2676 getMainPanel().adjustJScrollPane();
2677 treepanel.resetPreferredSize();
2678 getMainPanel().getCurrentScrollPane().getViewport().validate();
2679 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
2681 treepanel.resetPreferredSize();
2682 treepanel.updateOvSizes();
2685 final void zoomInY( final float factor ) {
2686 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
2687 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2688 treepanel.multiplyUrtFactor( 1.1f );
2689 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2690 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
2691 getMainPanel().adjustJScrollPane();
2692 treepanel.resetPreferredSize();
2693 getMainPanel().getCurrentScrollPane().getViewport().validate();
2694 sb.setValue( ForesterUtil
2695 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2696 treepanel.resetPreferredSize();
2697 treepanel.updateOvSizes();
2700 final void zoomOutX( final float factor, final float x_correction_factor ) {
2701 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2702 treepanel.multiplyUrtFactor( 1f );
2703 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
2704 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
2705 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2706 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
2707 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
2708 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
2709 getMainPanel().adjustJScrollPane();
2710 treepanel.resetPreferredSize();
2711 getMainPanel().getCurrentScrollPane().getViewport().validate();
2712 final double x = ( sb.getMaximum() - sb.getMinimum() )
2713 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2714 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2715 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2716 getMainPanel().adjustJScrollPane();
2717 treepanel.resetPreferredSize();
2718 getMainPanel().getCurrentScrollPane().getViewport().validate();
2719 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
2720 - ( sb.getVisibleAmount() / 2.0 ) ) );
2723 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
2724 treepanel.setXdistance( treepanel.getXdistance() * factor );
2725 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
2727 getMainPanel().adjustJScrollPane();
2728 treepanel.resetPreferredSize();
2729 getMainPanel().getCurrentScrollPane().getViewport().validate();
2730 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
2733 treepanel.resetPreferredSize();
2734 treepanel.updateOvSizes();
2738 final void zoomOutY( final float factor ) {
2739 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2740 treepanel.multiplyUrtFactor( 0.9f );
2741 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
2742 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
2743 final double x = ( sb.getMaximum() - sb.getMinimum() )
2744 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2745 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
2746 getMainPanel().adjustJScrollPane();
2747 treepanel.resetPreferredSize();
2748 getMainPanel().getCurrentScrollPane().getViewport().validate();
2749 sb.setValue( ForesterUtil
2750 .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
2751 treepanel.resetPreferredSize();
2752 treepanel.updateOvSizes();
2756 final static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2757 label.setFont( ControlPanel.jcb_bold_font );
2758 if ( !configuration.isUseNativeUI() ) {
2759 label.setForeground( configuration.getGuiCheckboxTextColor() );
2760 label.setBackground( configuration.getGuiBackgroundColor() );
2765 final public JCheckBox getUseBranchWidthsCb() {
2766 return _width_branches;