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.phylogeny.Phylogeny;
64 import org.forester.phylogeny.PhylogenyMethods;
65 import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
66 import org.forester.phylogeny.PhylogenyNode;
67 import org.forester.phylogeny.data.Sequence;
68 import org.forester.phylogeny.data.SequenceRelation;
69 import org.forester.phylogeny.data.SequenceRelation.SEQUENCE_RELATION_TYPE;
70 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
71 import org.forester.util.ForesterUtil;
73 final class ControlPanel extends JPanel implements ActionListener {
75 enum NodeClickAction {
82 DELETE_NODE_OR_SUBTREE,
100 final static Font jcb_bold_font = new Font( Configuration.getDefaultFontFamilyName(),
103 final static Font jcb_font = new Font( Configuration.getDefaultFontFamilyName(),
106 final static Font js_font = new Font( Configuration.getDefaultFontFamilyName(),
109 private static final String RETURN_TO_SUPER_TREE_TEXT = "Back to Super Tree";
110 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).";
111 private static final long serialVersionUID = -8463483932821545633L;
112 private NodeClickAction _action_when_node_clicked;
113 private int _add_new_node_item;
114 private Map<Integer, String> _all_click_to_names;
115 private Map<String, Color> _annotation_colors;
116 private int _blast_item;
117 private JComboBox<String> _click_to_combobox;
118 private JLabel _click_to_label;
119 private List<String> _click_to_names;
120 private int _collapse_cb_item;
121 private int _uncollapse_all_cb_item;
122 private int _order_subtree_cb_item;
125 private JCheckBox _color_acc_species;
126 private JCheckBox _color_acc_sequence;
127 private JCheckBox _color_according_to_annotation;
128 private boolean _color_branches;
129 private JCheckBox _use_visual_styles_cb;
130 private int _color_subtree_cb_item;
131 private int _change_node_font_item;
132 // The settings from the conf file
133 private final Configuration _configuration;
134 private int _copy_subtree_item;
135 private int _cut_subtree_item;
136 private JButton _decr_domain_structure_evalue_thr;
137 private int _delete_node_or_subtree_item;
138 private JCheckBox _display_as_phylogram_cb;
140 private JCheckBox _display_internal_data;
141 private JLabel _domain_display_label;
142 private JTextField _domain_structure_evalue_thr_tf;
143 private List<Boolean> _draw_phylogram;
144 private JCheckBox _dynamically_hide_data;
145 private int _edit_node_data_item;
146 private int _get_ext_desc_data;
147 private JButton _incr_domain_structure_evalue_thr;
148 private final MainPanel _mainpanel;
149 private JCheckBox _node_desc_popup_cb;
150 private int _open_pdb_item;
151 private int _open_seq_web_item;
152 private int _open_tax_web_item;
153 private int _color_node_font_item;
154 private JButton _order;
155 private int _paste_subtree_item;
156 private int _reroot_cb_item;
157 private JButton _return_to_super_tree;
159 private JLabel _search_found_label_0;
160 private JLabel _search_found_label_1;
161 private JButton _search_reset_button_0;
162 private JButton _search_reset_button_1;
163 private JTextField _search_tf_0;
164 private JTextField _search_tf_1;
165 private int _select_nodes_item;
166 private Sequence _selected_query_seq;
167 private JCheckBox _seq_relation_confidence_switch;
168 private JComboBox<SEQUENCE_RELATION_TYPE> _sequence_relation_type_box;
169 private JCheckBox _show_annotation;
170 private JCheckBox _show_binary_character_counts;
171 private JCheckBox _show_binary_characters;
172 // Indices for the click-to options in the combo box
173 private int _show_data_item;
174 private JCheckBox _show_domain_architectures;
175 private JCheckBox _show_mol_seqs;
176 private JCheckBox _write_branch_length_values;
177 private JCheckBox _show_events;
178 private JCheckBox _show_gene_names;
179 private JCheckBox _show_node_names;
180 private JCheckBox _show_properties_cb;
181 private JCheckBox _show_seq_names;
182 private JCheckBox _show_seq_symbols;
183 private JCheckBox _show_sequence_acc;
184 private JComboBox<String> _show_sequence_relations;
185 private JCheckBox _show_taxo_code;
186 private JCheckBox _show_taxo_rank;
187 private JCheckBox _show_taxo_common_names;
188 private JCheckBox _show_taxo_images_cb;
189 private JCheckBox _show_taxo_scientific_names;
190 private JCheckBox _show_vector_data_cb;
191 private JButton _show_whole;
192 private int _sort_descendents_item;
193 private Map<String, Color> _species_colors;
194 private Map<String, Color> _sequence_colors;
195 private int _subtree_cb_item;
196 private int _swap_cb_item;
197 private JButton _uncollapse_all;
198 private JCheckBox _width_branches;
199 private JCheckBox _write_confidence;
200 private JButton _zoom_in_domain_structure;
201 private JButton _zoom_in_x;
202 private JButton _zoom_in_y;
203 private JLabel _zoom_label;
204 private JButton _zoom_out_domain_structure;
205 private JButton _zoom_out_x;
206 private JButton _zoom_out_y;
208 ControlPanel( final MainPanel ap, final Configuration configuration ) {
211 _configuration = configuration;
212 if ( !_configuration.isUseNativeUI() ) {
213 setBackground( getConfiguration().getGuiBackgroundColor() );
214 setBorder( BorderFactory.createRaisedBevelBorder() );
216 setLayout( new GridLayout( 0, 1, 2, 2 ) );
224 public void actionPerformed( final ActionEvent e ) {
226 if ( e.getSource() == _color_acc_sequence ) {
227 if ( _color_acc_species != null ) {
228 _color_acc_species.setSelected( false );
231 else if ( e.getSource() == _color_acc_species ) {
232 if ( _color_acc_sequence != null ) {
233 _color_acc_sequence.setSelected( false );
236 final TreePanel tp = getMainPanel().getCurrentTreePanel();
240 if ( e.getSource() == _click_to_combobox ) {
241 setClickToAction( _click_to_combobox.getSelectedIndex() );
242 getCurrentTreePanel().repaint();
244 else if ( e.getSource() == _show_binary_characters ) {
245 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
246 _show_binary_character_counts.setSelected( false );
248 displayedPhylogenyMightHaveChanged( true );
250 else if ( e.getSource() == _show_binary_character_counts ) {
251 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
252 _show_binary_characters.setSelected( false );
254 displayedPhylogenyMightHaveChanged( true );
256 else if ( e.getSource() == _show_domain_architectures ) {
259 displayedPhylogenyMightHaveChanged( true );
261 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
262 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
263 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
267 else if ( e.getSource() == _zoom_in_x ) {
268 zoomInX( AptxConstants.BUTTON_ZOOM_IN_FACTOR, AptxConstants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
269 displayedPhylogenyMightHaveChanged( false );
271 else if ( e.getSource() == _zoom_in_y ) {
272 zoomInY( AptxConstants.BUTTON_ZOOM_IN_FACTOR );
273 displayedPhylogenyMightHaveChanged( false );
275 else if ( e.getSource() == _zoom_out_x ) {
276 zoomOutX( AptxConstants.BUTTON_ZOOM_OUT_FACTOR, AptxConstants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
277 displayedPhylogenyMightHaveChanged( false );
279 else if ( e.getSource() == _zoom_out_y ) {
280 zoomOutY( AptxConstants.BUTTON_ZOOM_OUT_FACTOR );
281 displayedPhylogenyMightHaveChanged( false );
283 else if ( e.getSource() == _show_whole ) {
284 displayedPhylogenyMightHaveChanged( true );
287 else if ( e.getSource() == _return_to_super_tree ) {
288 _mainpanel.getCurrentTreePanel().superTree();
291 else if ( e.getSource() == _order ) {
292 DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
293 if ( isShowTaxonomyScientificNames() || isShowTaxonomyCode() ) {
294 pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
296 else if ( isShowSeqNames() || isShowSeqSymbols() || isShowGeneNames() ) {
297 pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
299 PhylogenyMethods.orderAppearanceX( tp.getPhylogeny().getRoot(), true, pri );
301 tp.setNodeInPreorderToNull();
302 tp.getPhylogeny().externalNodesHaveChanged();
303 tp.getPhylogeny().clearHashIdToNodeMap();
304 tp.getPhylogeny().recalculateNumberOfExternalDescendants( true );
305 tp.resetNodeIdToDistToLeafMap();
306 tp.setEdited( true );
307 displayedPhylogenyMightHaveChanged( true );
309 else if ( e.getSource() == _uncollapse_all ) {
311 displayedPhylogenyMightHaveChanged( false );
313 else if ( e.getSource() == _zoom_in_domain_structure ) {
314 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
315 displayedPhylogenyMightHaveChanged( true );
317 else if ( e.getSource() == _zoom_out_domain_structure ) {
318 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
319 displayedPhylogenyMightHaveChanged( true );
321 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
322 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThresholdExp();
325 displayedPhylogenyMightHaveChanged( true );
327 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
328 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThresholdExp();
331 displayedPhylogenyMightHaveChanged( true );
333 else if ( e.getSource() == _search_tf_0 ) {
335 displayedPhylogenyMightHaveChanged( true );
337 else if ( e.getSource() == _search_tf_1 ) {
339 displayedPhylogenyMightHaveChanged( true );
341 else if ( ( _dynamically_hide_data != null ) && ( e.getSource() == _dynamically_hide_data )
342 && !_dynamically_hide_data.isSelected() ) {
343 setDynamicHidingIsOn( false );
344 displayedPhylogenyMightHaveChanged( true );
347 displayedPhylogenyMightHaveChanged( true );
351 tp.requestFocusInWindow();
354 catch ( final Exception ex ) {
355 AptxUtil.unexpectedException( ex );
357 catch ( final Error err ) {
358 AptxUtil.unexpectedError( err );
362 public JCheckBox getColorAccSequenceCb() {
363 return _color_acc_sequence;
366 public JCheckBox getColorAccSpeciesCb() {
367 return _color_acc_species;
370 public JCheckBox getDisplayAsPhylogramCb() {
371 return _display_as_phylogram_cb;
374 public JCheckBox getDynamicallyHideData() {
375 return _dynamically_hide_data;
378 public JCheckBox getNodeDescPopupCb() {
379 return _node_desc_popup_cb;
382 public Sequence getSelectedQuerySequence() {
383 return _selected_query_seq;
386 public JComboBox<String> getSequenceRelationBox() {
387 if ( _show_sequence_relations == null ) {
388 _show_sequence_relations = new JComboBox<String>();
389 _show_sequence_relations.setFocusable( false );
390 _show_sequence_relations.setMaximumRowCount( 20 );
391 _show_sequence_relations.setFont( ControlPanel.js_font );
392 if ( !_configuration.isUseNativeUI() ) {
393 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
394 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
396 _show_sequence_relations.addItem( "-----" );
397 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
399 return _show_sequence_relations;
403 public JComboBox<SEQUENCE_RELATION_TYPE> getSequenceRelationTypeBox() {
404 if ( _sequence_relation_type_box == null ) {
405 _sequence_relation_type_box = new JComboBox<SEQUENCE_RELATION_TYPE>();
406 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
407 _sequence_relation_type_box.addItem( type );
409 _sequence_relation_type_box.addActionListener( new ActionListener() {
412 public void actionPerformed( final ActionEvent e ) {
413 if ( _mainpanel.getCurrentPhylogeny() != null ) {
414 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
419 return _sequence_relation_type_box;
422 public JCheckBox getShowEventsCb() {
426 public JCheckBox getUseVisualStylesCb() {
427 return _use_visual_styles_cb;
430 public JCheckBox getWriteConfidenceCb() {
431 return _write_confidence;
434 public boolean isShowMolSequences() {
435 return ( ( _show_mol_seqs != null ) && _show_mol_seqs.isSelected() );
438 public boolean isShowProperties() {
439 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
442 public boolean isShowTaxonomyImages() {
443 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
446 public boolean isShowVectorData() {
447 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
450 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
451 final JComboBox<String> box = getSequenceRelationBox();
452 while ( box.getItemCount() > 1 ) {
453 box.removeItemAt( 1 );
455 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
456 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
458 if ( relationType == null ) {
461 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
462 for( final Sequence seq : sequenceRelationQueries ) {
463 if ( seq.isHasSequenceRelations() ) {
464 boolean fFoundForCurrentType = false;
465 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
466 if ( sq.getType().equals( relationType ) ) {
467 fFoundForCurrentType = true;
471 if ( fFoundForCurrentType ) {
472 sequenceNamesToAdd.add( seq.getName() );
473 sequencesByName.put( seq.getName(), seq );
477 // sort sequences by name before adding them to the combo
478 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
479 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
480 for( final String seqName : sequenceNameArray ) {
481 box.addItem( seqName );
483 for( final ItemListener oldItemListener : box.getItemListeners() ) {
484 box.removeItemListener( oldItemListener );
486 box.addItemListener( new ItemListener() {
489 public void itemStateChanged( final ItemEvent e ) {
490 _selected_query_seq = sequencesByName.get( e.getItem() );
491 _mainpanel.getCurrentTreePanel().repaint();
496 private void addClickToOption( final int which, final String title ) {
497 _click_to_combobox.addItem( title );
498 _click_to_names.add( title );
499 _all_click_to_names.put( new Integer( which ), title );
500 if ( !_configuration.isUseNativeUI() ) {
501 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
502 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
507 private void addSequenceRelationBlock() {
508 final JLabel spacer = new JLabel( "" );
509 spacer.setSize( 1, 1 );
511 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
512 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
513 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
514 getSequenceRelationTypeBox().setFocusable( false );
515 _sequence_relation_type_box.setFont( ControlPanel.js_font );
516 if ( !_configuration.isUseNativeUI() ) {
517 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
518 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
520 _sequence_relation_type_box.setRenderer( new ListCellRenderer<Object>() {
523 public Component getListCellRendererComponent( final JList<?> list,
526 final boolean isSelected,
527 final boolean cellHasFocus ) {
528 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
533 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
534 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
535 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
540 final GridBagLayout gbl = new GridBagLayout();
541 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
542 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
543 final JPanel horizGrid = new JPanel( gbl );
544 horizGrid.setBackground( getBackground() );
545 horizGrid.add( typeLabel );
546 horizGrid.add( _sequence_relation_type_box );
547 add( customizeLabel( mainLabel, getConfiguration() ) );
549 add( getSequenceRelationBox() );
550 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
551 addCheckbox( Configuration.show_relation_confidence,
552 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
553 setCheckbox( Configuration.show_relation_confidence,
554 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
556 }// addSequenceRelationBlock
560 private List<Boolean> getIsDrawPhylogramList() {
561 return _draw_phylogram;
564 // This takes care of ArchaeopteryxE-issue.
565 // Can, and will, return null prior to ArchaeopteryxE initialization completion.
566 final private MainFrame getMainFrame() {
567 MainFrame mf = getMainPanel().getMainFrame();
569 // Must be "E" applet version.
570 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
571 if ( e.getMainPanel() == null ) {
574 mf = e.getMainPanel().getMainFrame();
579 private void init() {
580 _draw_phylogram = new ArrayList<Boolean>();
581 setSpeciesColors( new HashMap<String, Color>() );
582 setSequenceColors( new HashMap<String, Color>() );
583 setAnnotationColors( new HashMap<String, Color>() );
586 private boolean isDrawPhylogram( final int index ) {
587 return getIsDrawPhylogramList().get( index );
590 private void search0( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
591 getSearchFoundCountsLabel0().setVisible( true );
592 getSearchResetButton0().setEnabled( true );
593 getSearchResetButton0().setVisible( true );
594 String[] queries = null;
595 Set<Long> nodes = null;
596 if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
597 queries = query_str.split( ",+" );
600 queries = new String[ 1 ];
601 queries[ 0 ] = query_str.trim();
603 if ( ( queries != null ) && ( queries.length > 0 ) ) {
604 nodes = new HashSet<Long>();
605 for( String query : queries ) {
606 if ( ForesterUtil.isEmpty( query ) ) {
609 query = query.trim();
610 final TreePanel tp = getMainPanel().getCurrentTreePanel();
611 if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
612 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
614 getOptions().isSearchCaseSensitive(),
615 !getOptions().isMatchWholeTermsOnly(),
616 isShowDomainArchitectures(),
617 tp != null ? Math.pow( 10,
618 tp.getDomainStructureEvalueThresholdExp() )
622 nodes.addAll( PhylogenyMethods.searchData( query,
624 getOptions().isSearchCaseSensitive(),
625 !getOptions().isMatchWholeTermsOnly(),
626 getOptions().isSearchWithRegex(),
627 isShowDomainArchitectures(),
628 tp != null ? Math.pow( 10, tp
629 .getDomainStructureEvalueThresholdExp() ) : 0 ) );
632 if ( getOptions().isInverseSearchResult() ) {
633 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
634 final Set<Long> temp_nodes = nodes;
635 nodes = new HashSet<Long>();
636 for( final PhylogenyNode n : all ) {
637 if ( (!temp_nodes.contains( n.getId() )) && n.isHasNodeData() ) {
638 nodes.add( n.getId() );
643 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
644 main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet<Long>() );
645 for( final Long node : nodes ) {
646 main_panel.getCurrentTreePanel().getFoundNodes0().add( node );
648 setSearchFoundCountsOnLabel0( nodes.size() );
651 setSearchFoundCountsOnLabel0( 0 );
656 private void search1( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
657 getSearchFoundCountsLabel1().setVisible( true );
658 getSearchResetButton1().setEnabled( true );
659 getSearchResetButton1().setVisible( true );
660 String[] queries = null;
661 Set<Long> nodes = null;
662 if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
663 queries = query_str.split( ",+" );
666 queries = new String[ 1 ];
667 queries[ 0 ] = query_str.trim();
669 if ( ( queries != null ) && ( queries.length > 0 ) ) {
670 nodes = new HashSet<Long>();
671 for( String query : queries ) {
672 if ( ForesterUtil.isEmpty( query ) ) {
675 query = query.trim();
676 final TreePanel tp = getMainPanel().getCurrentTreePanel();
677 if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
678 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
680 getOptions().isSearchCaseSensitive(),
681 !getOptions().isMatchWholeTermsOnly(),
682 isShowDomainArchitectures(),
683 tp != null ? Math.pow( 10,
684 tp.getDomainStructureEvalueThresholdExp() )
688 nodes.addAll( PhylogenyMethods.searchData( query,
690 getOptions().isSearchCaseSensitive(),
691 !getOptions().isMatchWholeTermsOnly(),
692 getOptions().isSearchWithRegex(),
693 isShowDomainArchitectures(),
694 tp != null ? Math.pow( 10, tp
695 .getDomainStructureEvalueThresholdExp() ) : 0 ) );
698 if ( getOptions().isInverseSearchResult() ) {
699 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
700 final Set<Long> temp_nodes = nodes;
701 nodes = new HashSet<Long>();
702 for( final PhylogenyNode n : all ) {
703 if ( (!temp_nodes.contains( n.getId() )) && n.isHasNodeData() ) {
704 nodes.add( n.getId() );
709 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
710 main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet<Long>() );
711 for( final Long node : nodes ) {
712 main_panel.getCurrentTreePanel().getFoundNodes1().add( node );
714 setSearchFoundCountsOnLabel1( nodes.size() );
717 setSearchFoundCountsOnLabel1( 0 );
722 private void setDrawPhylogram( final int index, final boolean b ) {
723 getIsDrawPhylogramList().set( index, b );
726 private void setupClickToOptions() {
727 final int default_option = _configuration.getDefaultDisplayClicktoOption();
728 int selected_index = 0;
730 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
731 _show_data_item = cb_index;
732 addClickToOption( Configuration.display_node_data,
733 _configuration.getClickToTitle( Configuration.display_node_data ) );
734 if ( default_option == Configuration.display_node_data ) {
735 selected_index = cb_index;
739 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
740 _collapse_cb_item = cb_index;
741 addClickToOption( Configuration.collapse_uncollapse,
742 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
743 if ( default_option == Configuration.collapse_uncollapse ) {
744 selected_index = cb_index;
748 if ( _configuration.doDisplayClickToOption( Configuration.uncollapse_all ) ) {
749 _uncollapse_all_cb_item = cb_index;
750 addClickToOption( Configuration.uncollapse_all,
751 _configuration.getClickToTitle( Configuration.uncollapse_all ) );
752 if ( default_option == Configuration.uncollapse_all ) {
753 selected_index = cb_index;
757 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
758 _reroot_cb_item = cb_index;
759 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
760 if ( default_option == Configuration.reroot ) {
761 selected_index = cb_index;
765 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
766 _subtree_cb_item = cb_index;
767 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
768 if ( default_option == Configuration.subtree ) {
769 selected_index = cb_index;
773 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
774 _swap_cb_item = cb_index;
775 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
776 if ( default_option == Configuration.swap ) {
777 selected_index = cb_index;
781 if ( _configuration.doDisplayClickToOption( Configuration.order_subtree ) ) {
782 _order_subtree_cb_item = cb_index;
783 addClickToOption( Configuration.order_subtree,
784 _configuration.getClickToTitle( Configuration.order_subtree ) );
785 if ( default_option == Configuration.order_subtree ) {
786 selected_index = cb_index;
791 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
792 _sort_descendents_item = cb_index;
793 addClickToOption( Configuration.sort_descendents,
794 _configuration.getClickToTitle( Configuration.sort_descendents ) );
795 if ( default_option == Configuration.sort_descendents ) {
796 selected_index = cb_index;
800 if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) {
801 _color_node_font_item = cb_index;
802 addClickToOption( Configuration.color_node_font,
803 _configuration.getClickToTitle( Configuration.color_node_font ) );
804 if ( default_option == Configuration.color_node_font ) {
805 selected_index = cb_index;
809 if ( _configuration.doDisplayClickToOption( Configuration.change_node_font ) ) {
810 _change_node_font_item = cb_index;
811 addClickToOption( Configuration.change_node_font,
812 _configuration.getClickToTitle( Configuration.change_node_font ) );
813 if ( default_option == Configuration.change_node_font ) {
814 selected_index = cb_index;
818 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
819 _color_subtree_cb_item = cb_index;
820 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
821 if ( default_option == Configuration.color_subtree ) {
822 selected_index = cb_index;
826 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
827 _open_seq_web_item = cb_index;
828 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
829 if ( default_option == Configuration.open_seq_web ) {
830 selected_index = cb_index;
834 if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
835 _open_pdb_item = cb_index;
836 addClickToOption( Configuration.open_pdb_web, _configuration.getClickToTitle( Configuration.open_pdb_web ) );
837 if ( default_option == Configuration.open_pdb_web ) {
838 selected_index = cb_index;
842 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
843 _open_tax_web_item = cb_index;
844 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
845 if ( default_option == Configuration.open_tax_web ) {
846 selected_index = cb_index;
850 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
851 _blast_item = cb_index;
852 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
853 if ( default_option == Configuration.blast ) {
854 selected_index = cb_index;
858 if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
859 _select_nodes_item = cb_index;
860 addClickToOption( Configuration.select_nodes, _configuration.getClickToTitle( Configuration.select_nodes ) );
861 if ( default_option == Configuration.select_nodes ) {
862 selected_index = cb_index;
866 if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
867 _get_ext_desc_data = cb_index;
868 if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
869 addClickToOption( Configuration.get_ext_desc_data, getConfiguration()
870 .getLabelForGetExtDescendentsData() );
873 addClickToOption( Configuration.get_ext_desc_data,
874 getConfiguration().getClickToTitle( Configuration.get_ext_desc_data ) );
876 if ( default_option == Configuration.get_ext_desc_data ) {
877 selected_index = cb_index;
881 if ( getOptions().isEditable() ) {
882 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
883 _cut_subtree_item = cb_index;
884 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
885 if ( default_option == Configuration.cut_subtree ) {
886 selected_index = cb_index;
890 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
891 _copy_subtree_item = cb_index;
892 addClickToOption( Configuration.copy_subtree,
893 _configuration.getClickToTitle( Configuration.copy_subtree ) );
894 if ( default_option == Configuration.copy_subtree ) {
895 selected_index = cb_index;
899 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
900 _paste_subtree_item = cb_index;
901 addClickToOption( Configuration.paste_subtree,
902 _configuration.getClickToTitle( Configuration.paste_subtree ) );
903 if ( default_option == Configuration.paste_subtree ) {
904 selected_index = cb_index;
908 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
909 _delete_node_or_subtree_item = cb_index;
910 addClickToOption( Configuration.delete_subtree_or_node,
911 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
912 if ( default_option == Configuration.delete_subtree_or_node ) {
913 selected_index = cb_index;
917 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
918 _add_new_node_item = cb_index;
919 addClickToOption( Configuration.add_new_node,
920 _configuration.getClickToTitle( Configuration.add_new_node ) );
921 if ( default_option == Configuration.add_new_node ) {
922 selected_index = cb_index;
926 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
927 _edit_node_data_item = cb_index;
928 addClickToOption( Configuration.edit_node_data,
929 _configuration.getClickToTitle( Configuration.edit_node_data ) );
930 if ( default_option == Configuration.edit_node_data ) {
931 selected_index = cb_index;
936 // Set default selection and its action
937 _click_to_combobox.setSelectedIndex( selected_index );
938 setClickToAction( selected_index );
941 private void setupDisplayCheckboxes() {
942 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
943 addCheckbox( Configuration.display_as_phylogram,
944 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
945 setCheckbox( Configuration.display_as_phylogram,
946 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
948 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
949 addCheckbox( Configuration.dynamically_hide_data,
950 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
951 setCheckbox( Configuration.dynamically_hide_data,
952 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
954 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
955 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
956 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
958 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
959 addCheckbox( Configuration.display_internal_data,
960 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
961 setCheckbox( Configuration.display_internal_data,
962 _configuration.doCheckOption( Configuration.display_internal_data ) );
964 if ( _configuration.doDisplayOption( Configuration.color_according_to_sequence ) ) {
965 addCheckbox( Configuration.color_according_to_sequence,
966 _configuration.getDisplayTitle( Configuration.color_according_to_sequence ) );
967 setCheckbox( Configuration.color_according_to_sequence,
968 _configuration.doCheckOption( Configuration.color_according_to_sequence ) );
970 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
971 addCheckbox( Configuration.color_according_to_species,
972 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
973 setCheckbox( Configuration.color_according_to_species,
974 _configuration.doCheckOption( Configuration.color_according_to_species ) );
976 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
977 addCheckbox( Configuration.color_according_to_annotation,
978 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
979 setCheckbox( Configuration.color_according_to_annotation,
980 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
982 if ( _configuration.doDisplayOption( Configuration.use_style ) ) {
983 addCheckbox( Configuration.use_style, _configuration.getDisplayTitle( Configuration.use_style ) );
984 setCheckbox( Configuration.use_style, _configuration.doCheckOption( Configuration.use_style ) );
986 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
987 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
988 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
990 final JLabel label = new JLabel( "Display Data:" );
991 label.setFont( ControlPanel.jcb_bold_font );
992 if ( !getConfiguration().isUseNativeUI() ) {
993 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
996 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
997 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
998 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
1000 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
1001 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
1002 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
1004 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
1005 addCheckbox( Configuration.show_taxonomy_scientific_names,
1006 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
1007 setCheckbox( Configuration.show_taxonomy_scientific_names,
1008 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
1010 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
1011 addCheckbox( Configuration.show_taxonomy_common_names,
1012 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
1013 setCheckbox( Configuration.show_taxonomy_common_names,
1014 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
1016 if ( _configuration.doDisplayOption( Configuration.show_tax_rank ) ) {
1017 addCheckbox( Configuration.show_tax_rank, _configuration.getDisplayTitle( Configuration.show_tax_rank ) );
1018 setCheckbox( Configuration.show_tax_rank, _configuration.doCheckOption( Configuration.show_tax_rank ) );
1020 if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
1021 addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
1022 setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
1024 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
1025 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
1026 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1028 if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
1029 addCheckbox( Configuration.show_seq_symbols,
1030 _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
1031 setCheckbox( Configuration.show_seq_symbols, _configuration.doCheckOption( Configuration.show_seq_symbols ) );
1033 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1034 addCheckbox( Configuration.show_sequence_acc,
1035 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1036 setCheckbox( Configuration.show_sequence_acc,
1037 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1039 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1040 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
1041 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1043 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1044 addCheckbox( Configuration.write_confidence_values,
1045 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1046 setCheckbox( Configuration.write_confidence_values,
1047 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1049 if ( _configuration.doDisplayOption( Configuration.write_branch_length_values ) ) {
1050 addCheckbox( Configuration.write_branch_length_values,
1051 _configuration.getDisplayTitle( Configuration.write_branch_length_values ) );
1052 setCheckbox( Configuration.write_branch_length_values,
1053 _configuration.doCheckOption( Configuration.write_branch_length_values ) );
1055 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1056 addCheckbox( Configuration.show_binary_characters,
1057 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1058 setCheckbox( Configuration.show_binary_characters,
1059 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1061 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1062 addCheckbox( Configuration.show_binary_character_counts,
1063 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1064 setCheckbox( Configuration.show_binary_character_counts,
1065 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1067 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1068 addCheckbox( Configuration.show_domain_architectures,
1069 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1070 setCheckbox( Configuration.show_domain_architectures,
1071 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1073 if ( _configuration.doDisplayOption( Configuration.show_mol_seqs ) ) {
1074 addCheckbox( Configuration.show_mol_seqs, _configuration.getDisplayTitle( Configuration.show_mol_seqs ) );
1075 setCheckbox( Configuration.show_mol_seqs, _configuration.doCheckOption( Configuration.show_mol_seqs ) );
1077 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1078 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1079 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1081 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1082 addCheckbox( Configuration.show_vector_data,
1083 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1084 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
1086 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1087 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
1088 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1090 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1091 addCheckbox( Configuration.show_taxonomy_images,
1092 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1093 setCheckbox( Configuration.show_taxonomy_images,
1094 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1098 private void setVisibilityOfDomainStrucureControls() {
1099 if ( _zoom_in_domain_structure != null ) {
1100 final MainFrame mf = getMainFrame();
1102 if ( isShowDomainArchitectures() ) {
1103 _domain_display_label.setVisible( true );
1104 _zoom_in_domain_structure.setVisible( true );
1105 _zoom_out_domain_structure.setVisible( true );
1106 _decr_domain_structure_evalue_thr.setVisible( true );
1107 _incr_domain_structure_evalue_thr.setVisible( true );
1108 _domain_structure_evalue_thr_tf.setVisible( true );
1109 if ( mf._right_line_up_domains_cbmi != null ) {
1110 mf._right_line_up_domains_cbmi.setVisible( true );
1112 if ( mf._show_domain_labels != null ) {
1113 mf._show_domain_labels.setVisible( true );
1117 _domain_display_label.setVisible( false );
1118 _zoom_in_domain_structure.setVisible( false );
1119 _zoom_out_domain_structure.setVisible( false );
1120 _decr_domain_structure_evalue_thr.setVisible( false );
1121 _incr_domain_structure_evalue_thr.setVisible( false );
1122 _domain_structure_evalue_thr_tf.setVisible( false );
1123 if ( mf._right_line_up_domains_cbmi != null ) {
1124 mf._right_line_up_domains_cbmi.setVisible( false );
1126 if ( mf._show_domain_labels != null ) {
1127 mf._show_domain_labels.setVisible( false );
1134 void activateButtonToReturnToSuperTree( int index ) {
1137 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
1140 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
1142 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1143 _return_to_super_tree.setEnabled( true );
1147 * Add zoom and quick edit buttons. (Last modified 8/9/04)
1150 final JLabel spacer = new JLabel( "" );
1151 spacer.setOpaque( false );
1153 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
1154 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1155 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
1156 if ( !getConfiguration().isUseNativeUI() ) {
1157 x_panel.setBackground( getBackground() );
1158 y_panel.setBackground( getBackground() );
1159 z_panel.setBackground( getBackground() );
1161 add( _zoom_label = new JLabel( "Zoom:" ) );
1162 customizeLabel( _zoom_label, getConfiguration() );
1166 if ( getConfiguration().isUseNativeUI() ) {
1167 _zoom_in_x = new JButton( "+" );
1168 _zoom_out_x = new JButton( "-" );
1171 _zoom_in_x = new JButton( "X+" );
1172 _zoom_out_x = new JButton( "X-" );
1174 _zoom_in_y = new JButton( "Y+" );
1175 _zoom_out_y = new JButton( "Y-" );
1176 _show_whole = new JButton( "F" );
1177 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [F or Home]" );
1178 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+cursor-right]" );
1179 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+cursor-up]" );
1180 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+cursor-left]" );
1181 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+cursor-down]" );
1182 if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) {
1183 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
1184 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
1187 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
1188 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
1190 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
1191 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
1192 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
1193 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
1194 _return_to_super_tree.setEnabled( false );
1195 _order = new JButton( "Order Tree" );
1196 _uncollapse_all = new JButton( "Uncollapse All" );
1198 addJButton( _zoom_in_y, x_panel );
1199 addJButton( _zoom_out_x, y_panel );
1200 addJButton( _show_whole, y_panel );
1201 addJButton( _zoom_in_x, y_panel );
1202 addJButton( _zoom_out_y, z_panel );
1203 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
1204 setUpControlsForDomainStrucures();
1206 final JLabel spacer2 = new JLabel( "" );
1208 addJButton( _return_to_super_tree, this );
1209 addJButton( _order, this );
1210 addJButton( _uncollapse_all, this );
1211 final JLabel spacer3 = new JLabel( "" );
1213 setVisibilityOfDomainStrucureControls();
1216 void addCheckbox( final int which, final String title ) {
1217 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
1219 case Configuration.display_as_phylogram:
1220 _display_as_phylogram_cb = new JCheckBox( title );
1221 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
1222 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
1225 case Configuration.display_internal_data:
1226 _display_internal_data = new JCheckBox( title );
1227 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
1228 addJCheckBox( _display_internal_data, ch_panel );
1231 case Configuration.color_according_to_species:
1232 _color_acc_species = new JCheckBox( title );
1233 _color_acc_species.setToolTipText( "To colorize node labels as a function of taxonomy" );
1234 addJCheckBox( _color_acc_species, ch_panel );
1237 case Configuration.color_according_to_sequence:
1238 _color_acc_sequence = new JCheckBox( title );
1239 _color_acc_sequence.setToolTipText( "To colorize node labels as a function of sequence name" );
1240 addJCheckBox( _color_acc_sequence, ch_panel );
1243 case Configuration.color_according_to_annotation:
1244 _color_according_to_annotation = new JCheckBox( title );
1245 _color_according_to_annotation
1246 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
1247 addJCheckBox( _color_according_to_annotation, ch_panel );
1250 case Configuration.show_node_names:
1251 _show_node_names = new JCheckBox( title );
1252 addJCheckBox( _show_node_names, ch_panel );
1255 case Configuration.show_taxonomy_scientific_names:
1256 _show_taxo_scientific_names = new JCheckBox( title );
1257 addJCheckBox( _show_taxo_scientific_names, ch_panel );
1260 case Configuration.show_taxonomy_common_names:
1261 _show_taxo_common_names = new JCheckBox( title );
1262 addJCheckBox( _show_taxo_common_names, ch_panel );
1265 case Configuration.show_tax_code:
1266 _show_taxo_code = new JCheckBox( title );
1267 addJCheckBox( _show_taxo_code, ch_panel );
1270 case Configuration.show_tax_rank:
1271 _show_taxo_rank = new JCheckBox( title );
1272 addJCheckBox( _show_taxo_rank, ch_panel );
1275 case Configuration.show_taxonomy_images:
1276 _show_taxo_images_cb = new JCheckBox( title );
1277 addJCheckBox( _show_taxo_images_cb, ch_panel );
1280 case Configuration.show_binary_characters:
1281 _show_binary_characters = new JCheckBox( title );
1282 addJCheckBox( _show_binary_characters, ch_panel );
1285 case Configuration.show_annotation:
1286 _show_annotation = new JCheckBox( title );
1287 addJCheckBox( _show_annotation, ch_panel );
1290 case Configuration.show_binary_character_counts:
1291 _show_binary_character_counts = new JCheckBox( title );
1292 addJCheckBox( _show_binary_character_counts, ch_panel );
1295 case Configuration.write_confidence_values:
1296 _write_confidence = new JCheckBox( title );
1297 addJCheckBox( getWriteConfidenceCb(), ch_panel );
1300 case Configuration.write_events:
1301 _show_events = new JCheckBox( title );
1302 addJCheckBox( getShowEventsCb(), ch_panel );
1305 case Configuration.use_style:
1306 _use_visual_styles_cb = new JCheckBox( title );
1307 getUseVisualStylesCb()
1308 .setToolTipText( "To use visual styles (node colors, fonts) and branch colors, if present" );
1309 addJCheckBox( getUseVisualStylesCb(), ch_panel );
1312 case Configuration.width_branches:
1313 _width_branches = new JCheckBox( title );
1314 _width_branches.setToolTipText( "To use branch width values, if present" );
1315 addJCheckBox( _width_branches, ch_panel );
1318 case Configuration.write_branch_length_values:
1319 _write_branch_length_values = new JCheckBox( title );
1320 addJCheckBox( _write_branch_length_values, ch_panel );
1323 case Configuration.show_domain_architectures:
1324 _show_domain_architectures = new JCheckBox( title );
1325 addJCheckBox( _show_domain_architectures, ch_panel );
1328 case Configuration.show_mol_seqs:
1329 _show_mol_seqs = new JCheckBox( title );
1330 addJCheckBox( _show_mol_seqs, ch_panel );
1333 case Configuration.show_seq_names:
1334 _show_seq_names = new JCheckBox( title );
1335 addJCheckBox( _show_seq_names, ch_panel );
1338 case Configuration.show_gene_names:
1339 _show_gene_names = new JCheckBox( title );
1340 addJCheckBox( _show_gene_names, ch_panel );
1343 case Configuration.show_seq_symbols:
1344 _show_seq_symbols = new JCheckBox( title );
1345 addJCheckBox( _show_seq_symbols, ch_panel );
1348 case Configuration.show_sequence_acc:
1349 _show_sequence_acc = new JCheckBox( title );
1350 addJCheckBox( _show_sequence_acc, ch_panel );
1353 case Configuration.dynamically_hide_data:
1354 _dynamically_hide_data = new JCheckBox( title );
1355 getDynamicallyHideData().setToolTipText( "To hide labels depending on expected visibility" );
1356 addJCheckBox( getDynamicallyHideData(), ch_panel );
1359 case Configuration.node_data_popup:
1360 _node_desc_popup_cb = new JCheckBox( title );
1361 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
1362 addJCheckBox( getNodeDescPopupCb(), ch_panel );
1365 case Configuration.show_relation_confidence:
1366 _seq_relation_confidence_switch = new JCheckBox( title );
1367 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
1370 case Configuration.show_vector_data:
1371 _show_vector_data_cb = new JCheckBox( title );
1372 addJCheckBox( _show_vector_data_cb, ch_panel );
1375 case Configuration.show_properties:
1376 _show_properties_cb = new JCheckBox( title );
1377 addJCheckBox( _show_properties_cb, ch_panel );
1381 throw new RuntimeException( "unknown checkbox: " + which );
1385 void addJButton( final JButton jb, final JPanel p ) {
1386 jb.setFocusPainted( false );
1387 jb.setFont( ControlPanel.jcb_font );
1388 if ( !_configuration.isUseNativeUI() ) {
1389 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
1390 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1391 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
1394 jb.addActionListener( this );
1397 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
1398 jcb.setFocusPainted( false );
1399 jcb.setFont( ControlPanel.jcb_font );
1400 if ( !_configuration.isUseNativeUI() ) {
1401 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
1402 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1404 p.add( jcb, "Center" );
1405 jcb.addActionListener( this );
1408 void addJTextField( final JTextField tf, final JPanel p ) {
1409 if ( !_configuration.isUseNativeUI() ) {
1410 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
1411 tf.setFont( ControlPanel.jcb_font );
1414 tf.addActionListener( this );
1417 void deactivateButtonToReturnToSuperTree() {
1418 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
1419 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
1420 _return_to_super_tree.setEnabled( false );
1423 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
1424 if ( ( _mainpanel != null )
1425 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
1427 if ( recalc_longest_ext_node_info ) {
1428 _mainpanel.getCurrentTreePanel().initNodeData();
1429 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
1431 if ( getOptions().isShowOverview() ) {
1432 _mainpanel.getCurrentTreePanel().updateOvSizes();
1434 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
1435 setVisibilityOfDomainStrucureControls();
1436 updateDomainStructureEvaluethresholdDisplay();
1437 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
1438 _mainpanel.getCurrentTreePanel().calcMaxDepth();
1439 _mainpanel.adjustJScrollPane();
1441 _mainpanel.getCurrentTreePanel().repaint();
1442 // _mainpanel.getCurrentTreePanel().setUpUrtFactor();
1446 void endClickToOptions() {
1447 _click_to_combobox.addActionListener( this );
1451 * Indicates what action should be execute when a node is clicked
1453 * @return the click-on action
1455 NodeClickAction getActionWhenNodeClicked() {
1456 return _action_when_node_clicked;
1459 Map<Integer, String> getAllClickToItems() {
1460 return _all_click_to_names;
1463 Map<String, Color> getAnnotationColors() {
1464 return _annotation_colors;
1467 Configuration getConfiguration() {
1468 return _configuration;
1471 TreePanel getCurrentTreePanel() {
1472 return getMainPanel().getCurrentTreePanel();
1475 MainPanel getMainPanel() {
1479 Options getOptions() {
1480 return getMainPanel().getOptions();
1483 JLabel getSearchFoundCountsLabel0() {
1484 return _search_found_label_0;
1487 JLabel getSearchFoundCountsLabel1() {
1488 return _search_found_label_1;
1491 JButton getSearchResetButton0() {
1492 return _search_reset_button_0;
1495 JButton getSearchResetButton1() {
1496 return _search_reset_button_1;
1499 JTextField getSearchTextField0() {
1500 return _search_tf_0;
1503 JTextField getSearchTextField1() {
1504 return _search_tf_1;
1507 Map<String, Color> getSequenceColors() {
1508 return _sequence_colors;
1511 List<String> getSingleClickToNames() {
1512 return _click_to_names;
1515 Map<String, Color> getSpeciesColors() {
1516 return _species_colors;
1519 boolean isAntialiasScreenText() {
1523 boolean isColorAccordingToAnnotation() {
1524 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
1527 boolean isColorAccordingToSequence() {
1528 return ( ( _color_acc_sequence != null ) && _color_acc_sequence.isSelected() );
1531 boolean isColorAccordingToTaxonomy() {
1532 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
1535 boolean isDrawPhylogram() {
1536 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
1539 boolean isDynamicallyHideData() {
1540 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
1543 boolean isEvents() {
1544 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
1547 boolean isNodeDescPopup() {
1548 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
1551 boolean isShowAnnotation() {
1552 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
1555 boolean isShowBinaryCharacterCounts() {
1556 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
1559 boolean isShowBinaryCharacters() {
1560 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
1563 boolean isShowConfidenceValues() {
1564 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
1567 boolean isShowDomainArchitectures() {
1568 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
1571 boolean isShowGeneNames() {
1572 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
1575 boolean isShowInternalData() {
1576 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
1579 boolean isShowNodeNames() {
1580 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
1583 boolean isShowSeqNames() {
1584 return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
1587 boolean isShowSeqSymbols() {
1588 return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
1591 boolean isShowSequenceAcc() {
1592 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
1595 boolean isShowSequenceRelationConfidence() {
1596 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
1599 boolean isShowSequenceRelations() {
1600 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
1603 boolean isShowTaxonomyCode() {
1604 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
1607 boolean isShowTaxonomyRank() {
1608 return ( ( _show_taxo_rank != null ) && _show_taxo_rank.isSelected() );
1611 boolean isShowTaxonomyCommonNames() {
1612 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
1615 boolean isShowTaxonomyScientificNames() {
1616 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
1619 boolean isUseVisualStyles() {
1620 return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() ) || ( ( getUseVisualStylesCb() == null ) && _color_branches ) );
1623 boolean isWidthBranches() {
1624 return ( ( _width_branches != null ) && _width_branches.isSelected() );
1627 boolean isWriteBranchLengthValues() {
1628 return ( ( _write_branch_length_values != null ) && _write_branch_length_values.isSelected() );
1631 void phylogenyAdded( final Configuration configuration ) {
1632 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
1635 void phylogenyRemoved( final int index ) {
1636 getIsDrawPhylogramList().remove( index );
1640 final MainPanel main_panel = getMainPanel();
1641 final Phylogeny tree = main_panel.getCurrentPhylogeny();
1642 if ( ( tree == null ) || tree.isEmpty() ) {
1645 String query = getSearchTextField0().getText();
1646 if ( query != null ) {
1647 query = query.trim();
1649 if ( !ForesterUtil.isEmpty( query ) ) {
1650 search0( main_panel, tree, query );
1653 getSearchFoundCountsLabel0().setVisible( false );
1654 getSearchResetButton0().setEnabled( false );
1655 getSearchResetButton0().setVisible( false );
1661 final MainPanel main_panel = getMainPanel();
1662 final Phylogeny tree = main_panel.getCurrentPhylogeny();
1663 if ( ( tree == null ) || tree.isEmpty() ) {
1666 String query = getSearchTextField1().getText();
1667 if ( query != null ) {
1668 query = query.trim();
1670 if ( !ForesterUtil.isEmpty( query ) ) {
1671 search1( main_panel, tree, query );
1674 getSearchFoundCountsLabel1().setVisible( false );
1675 getSearchResetButton1().setEnabled( false );
1676 getSearchResetButton1().setVisible( false );
1681 void searchReset0() {
1682 if ( getMainPanel().getCurrentTreePanel() != null ) {
1683 getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
1687 void searchReset1() {
1688 if ( getMainPanel().getCurrentTreePanel() != null ) {
1689 getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
1693 void setActionWhenNodeClicked( final NodeClickAction action ) {
1694 _action_when_node_clicked = action;
1697 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
1698 _annotation_colors = annotation_colors;
1701 void setCheckbox( final int which, final boolean state ) {
1703 case Configuration.display_as_phylogram:
1704 if ( getDisplayAsPhylogramCb() != null ) {
1705 getDisplayAsPhylogramCb().setSelected( state );
1708 case Configuration.display_internal_data:
1709 if ( _display_internal_data != null ) {
1710 _display_internal_data.setSelected( state );
1713 case Configuration.color_according_to_species:
1714 if ( _color_acc_species != null ) {
1715 _color_acc_species.setSelected( state );
1718 case Configuration.color_according_to_sequence:
1719 if ( _color_acc_sequence != null ) {
1720 _color_acc_sequence.setSelected( state );
1723 case Configuration.color_according_to_annotation:
1724 if ( _color_according_to_annotation != null ) {
1725 _color_according_to_annotation.setSelected( state );
1728 case Configuration.show_node_names:
1729 if ( _show_node_names != null ) {
1730 _show_node_names.setSelected( state );
1733 case Configuration.show_taxonomy_scientific_names:
1734 if ( _show_taxo_scientific_names != null ) {
1735 _show_taxo_scientific_names.setSelected( state );
1738 case Configuration.show_taxonomy_common_names:
1739 if ( _show_taxo_common_names != null ) {
1740 _show_taxo_common_names.setSelected( state );
1743 case Configuration.show_tax_code:
1744 if ( _show_taxo_code != null ) {
1745 _show_taxo_code.setSelected( state );
1748 case Configuration.show_tax_rank:
1749 if ( _show_taxo_rank != null ) {
1750 _show_taxo_rank.setSelected( state );
1753 case Configuration.show_taxonomy_images:
1754 if ( _show_taxo_images_cb != null ) {
1755 _show_taxo_images_cb.setSelected( state );
1758 case Configuration.show_annotation:
1759 if ( _show_annotation != null ) {
1760 _show_annotation.setSelected( state );
1763 case Configuration.show_binary_characters:
1764 if ( _show_binary_characters != null ) {
1765 _show_binary_characters.setSelected( state );
1768 case Configuration.show_binary_character_counts:
1769 if ( _show_binary_character_counts != null ) {
1770 _show_binary_character_counts.setSelected( state );
1773 case Configuration.write_confidence_values:
1774 if ( getWriteConfidenceCb() != null ) {
1775 getWriteConfidenceCb().setSelected( state );
1778 case Configuration.write_events:
1779 if ( getShowEventsCb() != null ) {
1780 getShowEventsCb().setSelected( state );
1783 case Configuration.use_style:
1784 if ( getUseVisualStylesCb() != null ) {
1785 getUseVisualStylesCb().setSelected( state );
1788 case Configuration.width_branches:
1789 if ( _width_branches != null ) {
1790 _width_branches.setSelected( state );
1793 case Configuration.show_domain_architectures:
1794 if ( _show_domain_architectures != null ) {
1795 _show_domain_architectures.setSelected( state );
1798 case Configuration.write_branch_length_values:
1799 if ( _write_branch_length_values != null ) {
1800 _write_branch_length_values.setSelected( state );
1803 case Configuration.show_mol_seqs:
1804 if ( _show_mol_seqs != null ) {
1805 _show_mol_seqs.setSelected( state );
1808 case Configuration.show_seq_names:
1809 if ( _show_seq_names != null ) {
1810 _show_seq_names.setSelected( state );
1813 case Configuration.show_gene_names:
1814 if ( _show_gene_names != null ) {
1815 _show_gene_names.setSelected( state );
1818 case Configuration.show_seq_symbols:
1819 if ( _show_seq_symbols != null ) {
1820 _show_seq_symbols.setSelected( state );
1823 case Configuration.show_vector_data:
1824 if ( _show_vector_data_cb != null ) {
1825 _show_vector_data_cb.setSelected( state );
1828 case Configuration.show_properties:
1829 if ( _show_properties_cb != null ) {
1830 _show_properties_cb.setSelected( state );
1833 case Configuration.show_sequence_acc:
1834 if ( _show_sequence_acc != null ) {
1835 _show_sequence_acc.setSelected( state );
1838 case Configuration.dynamically_hide_data:
1839 if ( getDynamicallyHideData() != null ) {
1840 getDynamicallyHideData().setSelected( state );
1843 case Configuration.node_data_popup:
1844 if ( getNodeDescPopupCb() != null ) {
1845 getNodeDescPopupCb().setSelected( state );
1849 case Configuration.show_relation_confidence:
1850 if ( _seq_relation_confidence_switch != null ) {
1851 _seq_relation_confidence_switch.setSelected( state );
1856 throw new AssertionError( "unknown checkbox: " + which );
1861 * Set this checkbox state. Not all checkboxes have been instantiated
1862 * depending on the config.
1864 void setCheckbox( final JCheckBox cb, final boolean state ) {
1866 cb.setSelected( state );
1870 void setClickToAction( final int action ) {
1871 // Set click-to action
1872 if ( action == _show_data_item ) {
1873 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1875 else if ( action == _collapse_cb_item ) {
1876 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1878 else if ( action == _reroot_cb_item ) {
1879 setActionWhenNodeClicked( NodeClickAction.REROOT );
1881 else if ( action == _subtree_cb_item ) {
1882 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1884 else if ( action == _swap_cb_item ) {
1885 setActionWhenNodeClicked( NodeClickAction.SWAP );
1887 else if ( action == _color_subtree_cb_item ) {
1888 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1890 else if ( action == _open_seq_web_item ) {
1891 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1893 else if ( action == _sort_descendents_item ) {
1894 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1896 else if ( action == _blast_item ) {
1897 setActionWhenNodeClicked( NodeClickAction.BLAST );
1899 else if ( action == _open_tax_web_item ) {
1900 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1902 else if ( action == _cut_subtree_item ) {
1903 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1905 else if ( action == _copy_subtree_item ) {
1906 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1908 else if ( action == _delete_node_or_subtree_item ) {
1909 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1911 else if ( action == _paste_subtree_item ) {
1912 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1914 else if ( action == _add_new_node_item ) {
1915 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1917 else if ( action == _edit_node_data_item ) {
1918 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1920 else if ( action == _select_nodes_item ) {
1921 setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
1923 else if ( action == _get_ext_desc_data ) {
1924 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
1926 else if ( action == _open_pdb_item ) {
1927 setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
1929 else if ( action == _color_node_font_item ) {
1930 setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
1932 else if ( action == _change_node_font_item ) {
1933 setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT );
1935 else if ( action == _uncollapse_all_cb_item ) {
1936 setActionWhenNodeClicked( NodeClickAction.UNCOLLAPSE_ALL );
1938 else if ( action == _order_subtree_cb_item ) {
1939 setActionWhenNodeClicked( NodeClickAction.ORDER_SUBTREE );
1942 throw new RuntimeException( "unknown action: " + action );
1944 // make sure drop down is displaying the correct action
1945 // in case this was called from outside the class
1946 _click_to_combobox.setSelectedIndex( action );
1949 void setColorBranches( final boolean color_branches ) {
1950 _color_branches = color_branches;
1953 void setDrawPhylogram( final boolean b ) {
1954 getDisplayAsPhylogramCb().setSelected( b );
1955 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1958 void setDrawPhylogramEnabled( final boolean b ) {
1959 getDisplayAsPhylogramCb().setEnabled( b );
1962 void setDynamicHidingIsOn( final boolean is_on ) {
1964 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1967 if ( !_configuration.isUseNativeUI() ) {
1968 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1971 getDynamicallyHideData().setForeground( Color.BLACK );
1976 void setSearchFoundCountsOnLabel0( final int counts ) {
1977 getSearchFoundCountsLabel0().setText( "Found: " + counts );
1980 void setSearchFoundCountsOnLabel1( final int counts ) {
1981 getSearchFoundCountsLabel1().setText( "Found: " + counts );
1984 void setSequenceColors( final Map<String, Color> sequence_colors ) {
1985 _sequence_colors = sequence_colors;
1988 void setShowEvents( final boolean show_events ) {
1989 if ( getShowEventsCb() == null ) {
1990 _show_events = new JCheckBox( "" );
1992 getShowEventsCb().setSelected( show_events );
1995 void setSpeciesColors( final Map<String, Color> species_colors ) {
1996 _species_colors = species_colors;
1999 void setupControls() {
2000 // The tree display options:
2001 setupDisplayCheckboxes();
2003 // The sequence relation query selection combo-box
2004 if ( _configuration.displaySequenceRelations() ) {
2005 addSequenceRelationBlock();
2009 startClickToOptions();
2010 setupClickToOptions();
2011 endClickToOptions();
2012 // Zoom and quick edit buttons
2014 setupSearchTools0();
2015 setupSearchTools1();
2018 void setUpControlsForDomainStrucures() {
2019 _domain_display_label = new JLabel( "Domain Architectures:" );
2020 add( customizeLabel( _domain_display_label, getConfiguration() ) );
2021 add( _domain_display_label );
2022 _zoom_in_domain_structure = new JButton( "d+" );
2023 _zoom_out_domain_structure = new JButton( "d-" );
2024 _decr_domain_structure_evalue_thr = new JButton( "-" );
2025 _incr_domain_structure_evalue_thr = new JButton( "+" );
2026 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
2027 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
2028 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
2029 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
2030 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
2031 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
2032 _domain_structure_evalue_thr_tf = new JTextField( 3 );
2033 _domain_structure_evalue_thr_tf.setEditable( false );
2034 if ( !getConfiguration().isUseNativeUI() ) {
2035 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2036 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2037 _domain_structure_evalue_thr_tf.setBorder( null );
2039 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2040 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
2041 if ( !_configuration.isUseNativeUI() ) {
2042 d1_panel.setBackground( getBackground() );
2043 d2_panel.setBackground( getBackground() );
2047 addJButton( _zoom_out_domain_structure, d1_panel );
2048 addJButton( _zoom_in_domain_structure, d1_panel );
2049 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
2050 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
2051 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
2054 void setupSearchTools0() {
2055 final JLabel search_label = new JLabel( "Search (A):" );
2056 search_label.setFont( ControlPanel.jcb_bold_font );
2057 if ( !getConfiguration().isUseNativeUI() ) {
2058 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2060 add( search_label );
2061 search_label.setToolTipText( SEARCH_TIP_TEXT );
2062 _search_found_label_0 = new JLabel();
2063 getSearchFoundCountsLabel0().setVisible( false );
2064 _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
2065 if ( !getConfiguration().isUseNativeUI() ) {
2066 _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2068 _search_tf_0 = new JTextField( 3 );
2069 _search_tf_0.setToolTipText( SEARCH_TIP_TEXT );
2070 _search_tf_0.setEditable( true );
2071 if ( !getConfiguration().isUseNativeUI() ) {
2072 _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2073 _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2074 _search_tf_0.setBorder( null );
2076 _search_reset_button_0 = new JButton();
2077 getSearchResetButton0().setText( "Reset" );
2078 getSearchResetButton0().setEnabled( false );
2079 getSearchResetButton0().setVisible( false );
2080 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
2081 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2082 s_panel_1.setBackground( getBackground() );
2084 s_panel_2.setBackground( getBackground() );
2086 final KeyAdapter key_adapter = new KeyAdapter() {
2089 public void keyReleased( final KeyEvent key_event ) {
2091 displayedPhylogenyMightHaveChanged( true );
2094 final ActionListener action_listener = new ActionListener() {
2097 public void actionPerformed( final ActionEvent e ) {
2099 setSearchFoundCountsOnLabel0( 0 );
2100 getSearchFoundCountsLabel0().setVisible( false );
2101 getSearchTextField0().setText( "" );
2102 getSearchResetButton0().setEnabled( false );
2103 getSearchResetButton0().setVisible( false );
2104 displayedPhylogenyMightHaveChanged( true );
2107 _search_reset_button_0.addActionListener( action_listener );
2108 _search_tf_0.addKeyListener( key_adapter );
2109 addJTextField( _search_tf_0, s_panel_1 );
2110 s_panel_2.add( _search_found_label_0 );
2111 addJButton( _search_reset_button_0, s_panel_2 );
2114 void setupSearchTools1() {
2115 final JLabel search_label = new JLabel( "Search (B):" );
2116 search_label.setFont( ControlPanel.jcb_bold_font );
2117 if ( !getConfiguration().isUseNativeUI() ) {
2118 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2120 add( search_label );
2121 search_label.setToolTipText( SEARCH_TIP_TEXT );
2122 _search_found_label_1 = new JLabel();
2123 getSearchFoundCountsLabel1().setVisible( false );
2124 _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
2125 if ( !getConfiguration().isUseNativeUI() ) {
2126 _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2128 _search_tf_1 = new JTextField( 3 );
2129 _search_tf_1.setToolTipText( SEARCH_TIP_TEXT );
2130 _search_tf_1.setEditable( true );
2131 if ( !getConfiguration().isUseNativeUI() ) {
2132 _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2133 _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2134 _search_tf_1.setBorder( null );
2136 _search_reset_button_1 = new JButton();
2137 getSearchResetButton1().setText( "Reset" );
2138 getSearchResetButton1().setEnabled( false );
2139 getSearchResetButton1().setVisible( false );
2140 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
2141 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2142 s_panel_1.setBackground( getBackground() );
2144 s_panel_2.setBackground( getBackground() );
2146 final KeyAdapter key_adapter = new KeyAdapter() {
2149 public void keyReleased( final KeyEvent key_event ) {
2151 displayedPhylogenyMightHaveChanged( true );
2154 final ActionListener action_listener = new ActionListener() {
2157 public void actionPerformed( final ActionEvent e ) {
2159 setSearchFoundCountsOnLabel1( 0 );
2160 getSearchFoundCountsLabel1().setVisible( false );
2161 getSearchTextField1().setText( "" );
2162 getSearchResetButton1().setEnabled( false );
2163 getSearchResetButton1().setVisible( false );
2164 displayedPhylogenyMightHaveChanged( true );
2167 _search_reset_button_1.addActionListener( action_listener );
2168 _search_tf_1.addKeyListener( key_adapter );
2169 addJTextField( _search_tf_1, s_panel_1 );
2170 s_panel_2.add( _search_found_label_1 );
2171 addJButton( _search_reset_button_1, s_panel_2 );
2174 void setVisibilityOfDomainStrucureCB() {
2176 if ( ( getCurrentTreePanel() != null )
2177 && ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( getCurrentTreePanel()
2178 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
2179 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2180 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
2182 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2183 getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
2186 else if ( isShowDomainArchitectures() ) {
2187 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2188 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( true );
2190 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2191 getMainPanel().getMainFrame()._show_domain_labels.setVisible( true );
2195 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2196 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
2198 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2199 getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
2203 catch ( final Exception ignore ) {
2208 void setVisibilityOfX() {
2209 final MainFrame mf = getMainFrame();
2211 if ( ( getCurrentTreePanel() != null ) && ( getCurrentTreePanel().getPhylogeny() != null ) ) {
2212 if ( AptxUtil.isHasAtLeastOneBranchWithSupportSD( getCurrentTreePanel().getPhylogeny() ) ) {
2213 if ( mf._show_confidence_stddev_cbmi != null ) {
2214 mf._show_confidence_stddev_cbmi.setVisible( true );
2218 if ( mf._show_confidence_stddev_cbmi != null ) {
2219 mf._show_confidence_stddev_cbmi.setVisible( false );
2222 if ( AptxUtil.isHasAtLeastOneNodeWithScientificName( getCurrentTreePanel().getPhylogeny() ) ) {
2223 if ( mf._abbreviate_scientific_names != null ) {
2224 mf._abbreviate_scientific_names.setVisible( true );
2228 if ( mf._abbreviate_scientific_names != null ) {
2229 mf._abbreviate_scientific_names.setVisible( false );
2232 if ( AptxUtil.isHasAtLeastOneNodeWithSequenceAnnotation( getCurrentTreePanel().getPhylogeny() ) ) {
2233 if ( mf._show_annotation_ref_source != null ) {
2234 mf._show_annotation_ref_source.setVisible( true );
2238 if ( mf._show_annotation_ref_source != null ) {
2239 mf._show_annotation_ref_source.setVisible( false );
2243 if ( isDrawPhylogram()
2244 || ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( getCurrentTreePanel()
2245 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) ) {
2246 if ( mf._non_lined_up_cladograms_rbmi != null ) {
2247 mf._non_lined_up_cladograms_rbmi.setVisible( false );
2249 if ( mf._uniform_cladograms_rbmi != null ) {
2250 mf._uniform_cladograms_rbmi.setVisible( false );
2252 if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
2253 mf._ext_node_dependent_cladogram_rbmi.setVisible( false );
2257 if ( mf._non_lined_up_cladograms_rbmi != null ) {
2258 mf._non_lined_up_cladograms_rbmi.setVisible( true );
2260 if ( mf._uniform_cladograms_rbmi != null ) {
2261 mf._uniform_cladograms_rbmi.setVisible( true );
2263 if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
2264 mf._ext_node_dependent_cladogram_rbmi.setVisible( true );
2267 if ( isDrawPhylogram() ) {
2268 if ( mf._show_scale_cbmi != null ) {
2269 mf._show_scale_cbmi.setVisible( true );
2273 if ( mf._show_scale_cbmi != null ) {
2274 mf._show_scale_cbmi.setVisible( false );
2277 if ( getCurrentTreePanel() != null ) {
2278 if ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2279 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
2280 if ( mf._label_direction_cbmi != null ) {
2281 mf._label_direction_cbmi.setVisible( true );
2285 if ( mf._label_direction_cbmi != null ) {
2286 mf._label_direction_cbmi.setVisible( false );
2293 void showAnnotations() {
2294 if ( _show_annotation != null ) {
2295 _show_annotation.setSelected( true );
2297 if ( _color_according_to_annotation != null ) {
2298 _color_according_to_annotation.setSelected( true );
2300 if ( _color_acc_species != null ) {
2301 _color_acc_species.setSelected( false );
2303 if ( _color_acc_sequence != null ) {
2304 _color_acc_sequence.setSelected( false );
2306 _mainpanel.getCurrentTreePanel().repaint();
2310 * Fit entire tree into window.
2313 if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
2316 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
2317 displayedPhylogenyMightHaveChanged( true );
2318 _mainpanel.getCurrentTreePanel().updateOvSettings();
2319 _mainpanel.getCurrentTreePanel().validate();
2320 _mainpanel.validate();
2321 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2322 _mainpanel.getSizeOfViewport().height );
2323 _mainpanel.getCurrentTreePanel().resetPreferredSize();
2324 _mainpanel.adjustJScrollPane();
2325 _mainpanel.getCurrentTreePanel().repaint();
2326 _mainpanel.getCurrentTreePanel().validate();
2327 _mainpanel.validate();
2328 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2329 _mainpanel.getSizeOfViewport().height );
2330 _mainpanel.getCurrentTreePanel().resetPreferredSize();
2331 _mainpanel.adjustJScrollPane();
2332 _mainpanel.getCurrentTreePanel().repaint();
2333 _mainpanel.getCurrentTreePanel().updateOvSizes();
2336 void showWholeAll() {
2337 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
2338 if ( tree_panel != null ) {
2339 tree_panel.validate();
2340 tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2341 _mainpanel.getSizeOfViewport().height );
2342 tree_panel.resetPreferredSize();
2343 tree_panel.repaint();
2348 // Create header for click-to combo box.
2349 void startClickToOptions() {
2350 final JLabel spacer = new JLabel( "" );
2351 spacer.setFont( ControlPanel.jcb_font );
2353 _click_to_label = new JLabel( "Click on Node to:" );
2354 add( customizeLabel( _click_to_label, getConfiguration() ) );
2355 _click_to_combobox = new JComboBox<String>();
2356 _click_to_combobox.setFocusable( false );
2357 _click_to_combobox.setMaximumRowCount( 14 );
2358 _click_to_combobox.setFont( ControlPanel.js_font );
2359 if ( !_configuration.isUseNativeUI() ) {
2360 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
2362 // don't add listener until all items are set (or each one will trigger
2364 // click_to_list.addActionListener(this);
2365 add( _click_to_combobox );
2366 // Correlates option names to titles
2367 _all_click_to_names = new HashMap<Integer, String>();
2368 _click_to_names = new ArrayList<String>();
2372 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
2373 if ( getCurrentTreePanel().isPhyHasBranchLengths()
2374 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
2375 setDrawPhylogramEnabled( true );
2376 setDrawPhylogram( isDrawPhylogram() );
2379 setDrawPhylogramEnabled( false );
2380 setDrawPhylogram( false );
2382 if ( getMainPanel().getMainFrame() == null ) {
2383 // Must be "E" applet version.
2384 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
2385 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
2388 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
2389 .getPhylogenyGraphicsType() );
2391 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
2392 getMainPanel().getControlPanel().search0();
2393 getMainPanel().getControlPanel().search1();
2394 getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
2395 getSequenceRelationTypeBox().removeAllItems();
2396 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
2397 .getRelevantSequenceRelationTypes() ) {
2398 _sequence_relation_type_box.addItem( type );
2400 getMainPanel().getCurrentTreePanel().repaint();
2401 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
2402 // according to GUILHEM the line above can be removed.
2407 * Uncollapse all nodes.
2409 void uncollapseAll( final TreePanel tp ) {
2410 final Phylogeny t = tp.getPhylogeny();
2411 if ( ( t != null ) && !t.isEmpty() ) {
2412 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
2413 final PhylogenyNode node = iter.next();
2414 node.setCollapse( false );
2416 tp.resetNodeIdToDistToLeafMap();
2417 tp.updateSetOfCollapsedExternalNodes();
2418 t.recalculateNumberOfExternalDescendants( false );
2419 tp.setNodeInPreorderToNull();
2420 t.clearHashIdToNodeMap();
2425 void updateDomainStructureEvaluethresholdDisplay() {
2426 if ( _domain_structure_evalue_thr_tf != null ) {
2427 _domain_structure_evalue_thr_tf.setText( "10^"
2428 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThresholdExp() );
2432 void zoomInX( final float factor, final float x_correction_factor ) {
2433 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
2434 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2435 treepanel.multiplyUrtFactor( 1f );
2436 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2437 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
2438 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
2439 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
2440 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2441 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2442 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2443 getMainPanel().adjustJScrollPane();
2444 treepanel.resetPreferredSize();
2445 getMainPanel().getCurrentScrollPane().getViewport().validate();
2446 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
2447 - ( sb.getVisibleAmount() / 2.0 ) ) );
2450 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
2451 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2452 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2453 getMainPanel().adjustJScrollPane();
2454 treepanel.resetPreferredSize();
2455 getMainPanel().getCurrentScrollPane().getViewport().validate();
2456 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
2458 treepanel.resetPreferredSize();
2459 treepanel.updateOvSizes();
2462 void zoomInY( final float factor ) {
2463 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
2464 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2465 treepanel.multiplyUrtFactor( 1.1f );
2466 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2467 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
2468 getMainPanel().adjustJScrollPane();
2469 treepanel.resetPreferredSize();
2470 getMainPanel().getCurrentScrollPane().getViewport().validate();
2471 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
2472 - ( sb.getVisibleAmount() / 2.0 ) ) );
2473 treepanel.resetPreferredSize();
2474 treepanel.updateOvSizes();
2477 void zoomOutX( final float factor, final float x_correction_factor ) {
2478 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2479 treepanel.multiplyUrtFactor( 1f );
2480 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
2481 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
2482 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2483 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
2484 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
2485 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
2486 getMainPanel().adjustJScrollPane();
2487 treepanel.resetPreferredSize();
2488 getMainPanel().getCurrentScrollPane().getViewport().validate();
2489 final double x = ( sb.getMaximum() - sb.getMinimum() )
2490 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2491 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2492 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2493 getMainPanel().adjustJScrollPane();
2494 treepanel.resetPreferredSize();
2495 getMainPanel().getCurrentScrollPane().getViewport().validate();
2496 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
2497 - ( sb.getVisibleAmount() / 2.0 ) ) );
2500 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
2501 treepanel.setXdistance( treepanel.getXdistance() * factor );
2502 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
2504 getMainPanel().adjustJScrollPane();
2505 treepanel.resetPreferredSize();
2506 getMainPanel().getCurrentScrollPane().getViewport().validate();
2507 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
2510 treepanel.resetPreferredSize();
2511 treepanel.updateOvSizes();
2515 void zoomOutY( final float factor ) {
2516 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2517 treepanel.multiplyUrtFactor( 0.9f );
2518 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
2519 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
2520 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2521 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
2522 getMainPanel().adjustJScrollPane();
2523 treepanel.resetPreferredSize();
2524 getMainPanel().getCurrentScrollPane().getViewport().validate();
2525 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
2526 - ( sb.getVisibleAmount() / 2.0 ) ) );
2527 treepanel.resetPreferredSize();
2528 treepanel.updateOvSizes();
2532 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2533 label.setFont( ControlPanel.jcb_bold_font );
2534 if ( !configuration.isUseNativeUI() ) {
2535 label.setForeground( configuration.getGuiCheckboxTextColor() );
2536 label.setBackground( configuration.getGuiBackgroundColor() );
2541 public JCheckBox getUseBranchWidthsCb() {
2542 return _width_branches;