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,
98 final static Font jcb_bold_font = new Font( Configuration.getDefaultFontFamilyName(),
101 final static Font jcb_font = new Font( Configuration.getDefaultFontFamilyName(),
104 final static Font js_font = new Font( Configuration.getDefaultFontFamilyName(),
107 private static final String RETURN_TO_SUPER_TREE_TEXT = "Back to Super Tree";
108 private static final String SEARCH_TIP_TEXT = "Enter text to search for. Use ',' for logical OR and '+' for logical AND (not used in this manner for regular expression searches).";
109 private static final long serialVersionUID = -8463483932821545633L;
110 private NodeClickAction _action_when_node_clicked;
111 private int _add_new_node_item;
112 private Map<Integer, String> _all_click_to_names;
113 private Map<String, Color> _annotation_colors;
114 private int _blast_item;
115 private JComboBox<String> _click_to_combobox;
116 private JLabel _click_to_label;
117 private List<String> _click_to_names;
118 private int _collapse_cb_item;
119 private JCheckBox _color_acc_species;
120 private JCheckBox _color_acc_sequence;
121 private JCheckBox _color_according_to_annotation;
122 private boolean _color_branches;
123 private JCheckBox _use_visual_styles_cb;
124 private int _color_subtree_cb_item;
125 private int _change_node_font_item;
126 // The settings from the conf file
127 private final Configuration _configuration;
128 private int _copy_subtree_item;
129 private int _cut_subtree_item;
130 private JButton _decr_domain_structure_evalue_thr;
131 private int _delete_node_or_subtree_item;
132 private JCheckBox _display_as_phylogram_cb;
134 private JCheckBox _display_internal_data;
135 private JLabel _domain_display_label;
136 private JTextField _domain_structure_evalue_thr_tf;
137 private List<Boolean> _draw_phylogram;
138 private JCheckBox _dynamically_hide_data;
139 private int _edit_node_data_item;
140 private int _get_ext_desc_data;
141 private JButton _incr_domain_structure_evalue_thr;
142 private final MainPanel _mainpanel;
143 private JCheckBox _node_desc_popup_cb;
144 private int _open_pdb_item;
145 private int _open_seq_web_item;
146 private int _open_tax_web_item;
147 private int _color_node_font_item;
148 private JButton _order;
149 private boolean _order_of_appearance;
150 private int _paste_subtree_item;
151 private int _reroot_cb_item;
152 private JButton _return_to_super_tree;
154 private JLabel _search_found_label_0;
155 private JLabel _search_found_label_1;
156 private JButton _search_reset_button_0;
157 private JButton _search_reset_button_1;
158 private JTextField _search_tf_0;
159 private JTextField _search_tf_1;
160 private int _select_nodes_item;
161 private Sequence _selected_query_seq;
162 private JCheckBox _seq_relation_confidence_switch;
163 private JComboBox<SEQUENCE_RELATION_TYPE> _sequence_relation_type_box;
164 private JCheckBox _show_annotation;
165 private JCheckBox _show_binary_character_counts;
166 private JCheckBox _show_binary_characters;
167 // Indices for the click-to options in the combo box
168 private int _show_data_item;
169 private JCheckBox _show_domain_architectures;
170 private JCheckBox _show_mol_seqs;
171 private JCheckBox _write_branch_length_values;
172 private JCheckBox _show_events;
173 private JCheckBox _show_gene_names;
174 private JCheckBox _show_node_names;
175 private JCheckBox _show_properties_cb;
176 private JCheckBox _show_seq_names;
177 private JCheckBox _show_seq_symbols;
178 private JCheckBox _show_sequence_acc;
179 private JComboBox<String> _show_sequence_relations;
180 private JCheckBox _show_taxo_code;
181 private JCheckBox _show_taxo_common_names;
182 private JCheckBox _show_taxo_images_cb;
183 private JCheckBox _show_taxo_scientific_names;
184 private JCheckBox _show_vector_data_cb;
185 private JButton _show_whole;
186 private int _sort_descendents_item;
187 private Map<String, Color> _species_colors;
188 private Map<String, Color> _sequence_colors;
189 private int _subtree_cb_item;
190 private int _swap_cb_item;
191 private JButton _uncollapse_all;
192 private JCheckBox _width_branches;
193 private JCheckBox _write_confidence;
194 private JButton _zoom_in_domain_structure;
195 private JButton _zoom_in_x;
196 private JButton _zoom_in_y;
197 private JLabel _zoom_label;
198 private JButton _zoom_out_domain_structure;
199 private JButton _zoom_out_x;
200 private JButton _zoom_out_y;
202 ControlPanel( final MainPanel ap, final Configuration configuration ) {
205 _configuration = configuration;
206 if ( !_configuration.isUseNativeUI() ) {
207 setBackground( getConfiguration().getGuiBackgroundColor() );
208 setBorder( BorderFactory.createRaisedBevelBorder() );
210 setLayout( new GridLayout( 0, 1, 2, 2 ) );
211 _order_of_appearance = true;
219 public void actionPerformed( final ActionEvent e ) {
221 if ( e.getSource() == _color_acc_sequence ) {
222 if ( _color_acc_species != null ) {
223 _color_acc_species.setSelected( false );
226 else if ( e.getSource() == _color_acc_species ) {
227 if ( _color_acc_sequence != null ) {
228 _color_acc_sequence.setSelected( false );
231 final TreePanel tp = getMainPanel().getCurrentTreePanel();
235 if ( e.getSource() == _click_to_combobox ) {
236 setClickToAction( _click_to_combobox.getSelectedIndex() );
237 getCurrentTreePanel().repaint();
239 else if ( e.getSource() == _show_binary_characters ) {
240 if ( ( _show_binary_character_counts != null ) && _show_binary_characters.isSelected() ) {
241 _show_binary_character_counts.setSelected( false );
243 displayedPhylogenyMightHaveChanged( true );
245 else if ( e.getSource() == _show_binary_character_counts ) {
246 if ( ( _show_binary_characters != null ) && _show_binary_character_counts.isSelected() ) {
247 _show_binary_characters.setSelected( false );
249 displayedPhylogenyMightHaveChanged( true );
251 else if ( e.getSource() == _show_domain_architectures ) {
254 displayedPhylogenyMightHaveChanged( true );
256 else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
257 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
258 setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
262 else if ( e.getSource() == _zoom_in_x ) {
263 zoomInX( AptxConstants.BUTTON_ZOOM_IN_FACTOR, AptxConstants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR );
264 displayedPhylogenyMightHaveChanged( false );
266 else if ( e.getSource() == _zoom_in_y ) {
267 zoomInY( AptxConstants.BUTTON_ZOOM_IN_FACTOR );
268 displayedPhylogenyMightHaveChanged( false );
270 else if ( e.getSource() == _zoom_out_x ) {
271 zoomOutX( AptxConstants.BUTTON_ZOOM_OUT_FACTOR, AptxConstants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR );
272 displayedPhylogenyMightHaveChanged( false );
274 else if ( e.getSource() == _zoom_out_y ) {
275 zoomOutY( AptxConstants.BUTTON_ZOOM_OUT_FACTOR );
276 displayedPhylogenyMightHaveChanged( false );
278 else if ( e.getSource() == _show_whole ) {
279 displayedPhylogenyMightHaveChanged( true );
282 else if ( e.getSource() == _return_to_super_tree ) {
283 _mainpanel.getCurrentTreePanel().superTree();
286 else if ( e.getSource() == _order ) {
287 DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
288 if ( isShowTaxonomyScientificNames() || isShowTaxonomyCode() ) {
289 pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
291 else if ( isShowSeqNames() || isShowSeqSymbols() || isShowGeneNames() ) {
292 pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
294 PhylogenyMethods.orderAppearance( tp.getPhylogeny().getRoot(), _order_of_appearance, true, pri );
295 _order_of_appearance = !_order_of_appearance;
296 tp.setNodeInPreorderToNull();
297 tp.getPhylogeny().externalNodesHaveChanged();
298 tp.getPhylogeny().clearHashIdToNodeMap();
299 tp.getPhylogeny().recalculateNumberOfExternalDescendants( true );
300 tp.resetNodeIdToDistToLeafMap();
301 tp.setEdited( true );
302 displayedPhylogenyMightHaveChanged( true );
304 else if ( e.getSource() == _uncollapse_all ) {
306 displayedPhylogenyMightHaveChanged( false );
308 else if ( e.getSource() == _zoom_in_domain_structure ) {
309 _mainpanel.getCurrentTreePanel().zoomInDomainStructure();
310 displayedPhylogenyMightHaveChanged( true );
312 else if ( e.getSource() == _zoom_out_domain_structure ) {
313 _mainpanel.getCurrentTreePanel().zoomOutDomainStructure();
314 displayedPhylogenyMightHaveChanged( true );
316 else if ( e.getSource() == _decr_domain_structure_evalue_thr ) {
317 _mainpanel.getCurrentTreePanel().decreaseDomainStructureEvalueThresholdExp();
320 displayedPhylogenyMightHaveChanged( true );
322 else if ( e.getSource() == _incr_domain_structure_evalue_thr ) {
323 _mainpanel.getCurrentTreePanel().increaseDomainStructureEvalueThresholdExp();
326 displayedPhylogenyMightHaveChanged( true );
328 else if ( e.getSource() == _search_tf_0 ) {
330 displayedPhylogenyMightHaveChanged( true );
332 else if ( e.getSource() == _search_tf_1 ) {
334 displayedPhylogenyMightHaveChanged( true );
336 else if ( ( _dynamically_hide_data != null ) && ( e.getSource() == _dynamically_hide_data )
337 && !_dynamically_hide_data.isSelected() ) {
338 setDynamicHidingIsOn( false );
339 displayedPhylogenyMightHaveChanged( true );
342 displayedPhylogenyMightHaveChanged( true );
346 tp.requestFocusInWindow();
349 catch ( final Exception ex ) {
350 AptxUtil.unexpectedException( ex );
352 catch ( final Error err ) {
353 AptxUtil.unexpectedError( err );
357 public JCheckBox getColorAccSequenceCb() {
358 return _color_acc_sequence;
361 public JCheckBox getColorAccSpeciesCb() {
362 return _color_acc_species;
365 public JCheckBox getDisplayAsPhylogramCb() {
366 return _display_as_phylogram_cb;
369 public JCheckBox getDynamicallyHideData() {
370 return _dynamically_hide_data;
373 public JCheckBox getNodeDescPopupCb() {
374 return _node_desc_popup_cb;
377 public Sequence getSelectedQuerySequence() {
378 return _selected_query_seq;
381 public JComboBox<String> getSequenceRelationBox() {
382 if ( _show_sequence_relations == null ) {
383 _show_sequence_relations = new JComboBox<String>();
384 _show_sequence_relations.setFocusable( false );
385 _show_sequence_relations.setMaximumRowCount( 20 );
386 _show_sequence_relations.setFont( ControlPanel.js_font );
387 if ( !_configuration.isUseNativeUI() ) {
388 _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
389 _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
391 _show_sequence_relations.addItem( "-----" );
392 _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
394 return _show_sequence_relations;
398 public JComboBox<SEQUENCE_RELATION_TYPE> getSequenceRelationTypeBox() {
399 if ( _sequence_relation_type_box == null ) {
400 _sequence_relation_type_box = new JComboBox<SEQUENCE_RELATION_TYPE>();
401 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
402 _sequence_relation_type_box.addItem( type );
404 _sequence_relation_type_box.addActionListener( new ActionListener() {
407 public void actionPerformed( final ActionEvent e ) {
408 if ( _mainpanel.getCurrentPhylogeny() != null ) {
409 setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
414 return _sequence_relation_type_box;
417 public JCheckBox getShowEventsCb() {
421 public JCheckBox getUseVisualStylesCb() {
422 return _use_visual_styles_cb;
425 public JCheckBox getWriteConfidenceCb() {
426 return _write_confidence;
429 public boolean isShowMolSequences() {
430 return ( ( _show_mol_seqs != null ) && _show_mol_seqs.isSelected() );
433 public boolean isShowProperties() {
434 return ( ( _show_properties_cb != null ) && _show_properties_cb.isSelected() );
437 public boolean isShowTaxonomyImages() {
438 return ( ( _show_taxo_images_cb != null ) && _show_taxo_images_cb.isSelected() );
441 public boolean isShowVectorData() {
442 return ( ( _show_vector_data_cb != null ) && _show_vector_data_cb.isSelected() );
445 public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
446 final JComboBox<String> box = getSequenceRelationBox();
447 while ( box.getItemCount() > 1 ) {
448 box.removeItemAt( 1 );
450 final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
451 final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = ( SequenceRelation.SEQUENCE_RELATION_TYPE ) _sequence_relation_type_box
453 if ( relationType == null ) {
456 final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
457 for( final Sequence seq : sequenceRelationQueries ) {
458 if ( seq.hasSequenceRelations() ) {
459 boolean fFoundForCurrentType = false;
460 for( final SequenceRelation sq : seq.getSequenceRelations() ) {
461 if ( sq.getType().equals( relationType ) ) {
462 fFoundForCurrentType = true;
466 if ( fFoundForCurrentType ) {
467 sequenceNamesToAdd.add( seq.getName() );
468 sequencesByName.put( seq.getName(), seq );
472 // sort sequences by name before adding them to the combo
473 final String[] sequenceNameArray = sequenceNamesToAdd.toArray( new String[ sequenceNamesToAdd.size() ] );
474 Arrays.sort( sequenceNameArray, String.CASE_INSENSITIVE_ORDER );
475 for( final String seqName : sequenceNameArray ) {
476 box.addItem( seqName );
478 for( final ItemListener oldItemListener : box.getItemListeners() ) {
479 box.removeItemListener( oldItemListener );
481 box.addItemListener( new ItemListener() {
484 public void itemStateChanged( final ItemEvent e ) {
485 _selected_query_seq = sequencesByName.get( e.getItem() );
486 _mainpanel.getCurrentTreePanel().repaint();
491 private void addClickToOption( final int which, final String title ) {
492 _click_to_combobox.addItem( title );
493 _click_to_names.add( title );
494 _all_click_to_names.put( new Integer( which ), title );
495 if ( !_configuration.isUseNativeUI() ) {
496 _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
497 _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
502 private void addSequenceRelationBlock() {
503 final JLabel spacer = new JLabel( "" );
504 spacer.setSize( 1, 1 );
506 final JLabel mainLabel = new JLabel( "Sequence relations to display" );
507 final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
508 typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
509 getSequenceRelationTypeBox().setFocusable( false );
510 _sequence_relation_type_box.setFont( ControlPanel.js_font );
511 if ( !_configuration.isUseNativeUI() ) {
512 _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
513 _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
515 _sequence_relation_type_box.setRenderer( new ListCellRenderer<Object>() {
518 public Component getListCellRendererComponent( final JList<?> list,
521 final boolean isSelected,
522 final boolean cellHasFocus ) {
523 final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
528 if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
529 ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
530 .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
535 final GridBagLayout gbl = new GridBagLayout();
536 _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
537 _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
538 final JPanel horizGrid = new JPanel( gbl );
539 horizGrid.setBackground( getBackground() );
540 horizGrid.add( typeLabel );
541 horizGrid.add( _sequence_relation_type_box );
542 add( customizeLabel( mainLabel, getConfiguration() ) );
544 add( getSequenceRelationBox() );
545 if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
546 addCheckbox( Configuration.show_relation_confidence,
547 _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
548 setCheckbox( Configuration.show_relation_confidence,
549 _configuration.doCheckOption( Configuration.show_relation_confidence ) );
551 }// addSequenceRelationBlock
555 private List<Boolean> getIsDrawPhylogramList() {
556 return _draw_phylogram;
559 // This takes care of ArchaeopteryxE-issue.
560 // Can, and will, return null prior to ArchaeopteryxE initialization completion.
561 final private MainFrame getMainFrame() {
562 MainFrame mf = getMainPanel().getMainFrame();
564 // Must be "E" applet version.
565 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
566 if ( e.getMainPanel() == null ) {
569 mf = e.getMainPanel().getMainFrame();
574 private void init() {
575 _draw_phylogram = new ArrayList<Boolean>();
576 setSpeciesColors( new HashMap<String, Color>() );
577 setSequenceColors( new HashMap<String, Color>() );
578 setAnnotationColors( new HashMap<String, Color>() );
581 private boolean isDrawPhylogram( final int index ) {
582 return getIsDrawPhylogramList().get( index );
585 private void search0( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
586 getSearchFoundCountsLabel0().setVisible( true );
587 getSearchResetButton0().setEnabled( true );
588 getSearchResetButton0().setVisible( true );
589 String[] queries = null;
590 Set<Long> nodes = null;
591 if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
592 queries = query_str.split( ",+" );
595 queries = new String[ 1 ];
596 queries[ 0 ] = query_str.trim();
598 if ( ( queries != null ) && ( queries.length > 0 ) ) {
599 nodes = new HashSet<Long>();
600 for( String query : queries ) {
601 if ( ForesterUtil.isEmpty( query ) ) {
604 query = query.trim();
605 final TreePanel tp = getMainPanel().getCurrentTreePanel();
606 if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
607 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
609 getOptions().isSearchCaseSensitive(),
610 !getOptions().isMatchWholeTermsOnly(),
611 isShowDomainArchitectures(),
612 tp != null ? Math.pow( 10,
613 tp.getDomainStructureEvalueThresholdExp() )
617 nodes.addAll( PhylogenyMethods.searchData( query,
619 getOptions().isSearchCaseSensitive(),
620 !getOptions().isMatchWholeTermsOnly(),
621 getOptions().isSearchWithRegex(),
622 isShowDomainArchitectures(),
623 tp != null ? Math.pow( 10, tp
624 .getDomainStructureEvalueThresholdExp() ) : 0 ) );
627 if ( getOptions().isInverseSearchResult() ) {
628 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
629 final Set<Long> temp_nodes = nodes;
630 nodes = new HashSet<Long>();
631 for( final PhylogenyNode n : all ) {
632 if ( (!temp_nodes.contains( n.getId() )) && n.isHasNodeData() ) {
633 nodes.add( n.getId() );
638 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
639 main_panel.getCurrentTreePanel().setFoundNodes0( new HashSet<Long>() );
640 for( final Long node : nodes ) {
641 main_panel.getCurrentTreePanel().getFoundNodes0().add( node );
643 setSearchFoundCountsOnLabel0( nodes.size() );
646 setSearchFoundCountsOnLabel0( 0 );
651 private void search1( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
652 getSearchFoundCountsLabel1().setVisible( true );
653 getSearchResetButton1().setEnabled( true );
654 getSearchResetButton1().setVisible( true );
655 String[] queries = null;
656 Set<Long> nodes = null;
657 if ( ( query_str.indexOf( ',' ) >= 0 ) && !getOptions().isSearchWithRegex() ) {
658 queries = query_str.split( ",+" );
661 queries = new String[ 1 ];
662 queries[ 0 ] = query_str.trim();
664 if ( ( queries != null ) && ( queries.length > 0 ) ) {
665 nodes = new HashSet<Long>();
666 for( String query : queries ) {
667 if ( ForesterUtil.isEmpty( query ) ) {
670 query = query.trim();
671 final TreePanel tp = getMainPanel().getCurrentTreePanel();
672 if ( ( query.indexOf( '+' ) > 0 ) && !getOptions().isSearchWithRegex() ) {
673 nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
675 getOptions().isSearchCaseSensitive(),
676 !getOptions().isMatchWholeTermsOnly(),
677 isShowDomainArchitectures(),
678 tp != null ? Math.pow( 10,
679 tp.getDomainStructureEvalueThresholdExp() )
683 nodes.addAll( PhylogenyMethods.searchData( query,
685 getOptions().isSearchCaseSensitive(),
686 !getOptions().isMatchWholeTermsOnly(),
687 getOptions().isSearchWithRegex(),
688 isShowDomainArchitectures(),
689 tp != null ? Math.pow( 10, tp
690 .getDomainStructureEvalueThresholdExp() ) : 0 ) );
693 if ( getOptions().isInverseSearchResult() ) {
694 final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
695 final Set<Long> temp_nodes = nodes;
696 nodes = new HashSet<Long>();
697 for( final PhylogenyNode n : all ) {
698 if ( (!temp_nodes.contains( n.getId() )) && n.isHasNodeData() ) {
699 nodes.add( n.getId() );
704 if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
705 main_panel.getCurrentTreePanel().setFoundNodes1( new HashSet<Long>() );
706 for( final Long node : nodes ) {
707 main_panel.getCurrentTreePanel().getFoundNodes1().add( node );
709 setSearchFoundCountsOnLabel1( nodes.size() );
712 setSearchFoundCountsOnLabel1( 0 );
717 private void setDrawPhylogram( final int index, final boolean b ) {
718 getIsDrawPhylogramList().set( index, b );
721 private void setupClickToOptions() {
722 final int default_option = _configuration.getDefaultDisplayClicktoOption();
723 int selected_index = 0;
725 if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
726 _show_data_item = cb_index;
727 addClickToOption( Configuration.display_node_data,
728 _configuration.getClickToTitle( Configuration.display_node_data ) );
729 if ( default_option == Configuration.display_node_data ) {
730 selected_index = cb_index;
734 if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
735 _collapse_cb_item = cb_index;
736 addClickToOption( Configuration.collapse_uncollapse,
737 _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
738 if ( default_option == Configuration.collapse_uncollapse ) {
739 selected_index = cb_index;
743 if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
744 _reroot_cb_item = cb_index;
745 addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
746 if ( default_option == Configuration.reroot ) {
747 selected_index = cb_index;
751 if ( _configuration.doDisplayClickToOption( Configuration.subtree ) ) {
752 _subtree_cb_item = cb_index;
753 addClickToOption( Configuration.subtree, _configuration.getClickToTitle( Configuration.subtree ) );
754 if ( default_option == Configuration.subtree ) {
755 selected_index = cb_index;
759 if ( _configuration.doDisplayClickToOption( Configuration.swap ) ) {
760 _swap_cb_item = cb_index;
761 addClickToOption( Configuration.swap, _configuration.getClickToTitle( Configuration.swap ) );
762 if ( default_option == Configuration.swap ) {
763 selected_index = cb_index;
767 if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
768 _sort_descendents_item = cb_index;
769 addClickToOption( Configuration.sort_descendents,
770 _configuration.getClickToTitle( Configuration.sort_descendents ) );
771 if ( default_option == Configuration.sort_descendents ) {
772 selected_index = cb_index;
776 if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) {
777 _color_node_font_item = cb_index;
778 addClickToOption( Configuration.color_node_font,
779 _configuration.getClickToTitle( Configuration.color_node_font ) );
780 if ( default_option == Configuration.color_node_font ) {
781 selected_index = cb_index;
785 if ( _configuration.doDisplayClickToOption( Configuration.change_node_font ) ) {
786 _change_node_font_item = cb_index;
787 addClickToOption( Configuration.change_node_font,
788 _configuration.getClickToTitle( Configuration.change_node_font ) );
789 if ( default_option == Configuration.change_node_font ) {
790 selected_index = cb_index;
794 if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
795 _color_subtree_cb_item = cb_index;
796 addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
797 if ( default_option == Configuration.color_subtree ) {
798 selected_index = cb_index;
802 if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
803 _open_seq_web_item = cb_index;
804 addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
805 if ( default_option == Configuration.open_seq_web ) {
806 selected_index = cb_index;
810 if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
811 _open_pdb_item = cb_index;
812 addClickToOption( Configuration.open_pdb_web, _configuration.getClickToTitle( Configuration.open_pdb_web ) );
813 if ( default_option == Configuration.open_pdb_web ) {
814 selected_index = cb_index;
818 if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
819 _open_tax_web_item = cb_index;
820 addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
821 if ( default_option == Configuration.open_tax_web ) {
822 selected_index = cb_index;
826 if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
827 _blast_item = cb_index;
828 addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
829 if ( default_option == Configuration.blast ) {
830 selected_index = cb_index;
834 if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
835 _select_nodes_item = cb_index;
836 addClickToOption( Configuration.select_nodes, _configuration.getClickToTitle( Configuration.select_nodes ) );
837 if ( default_option == Configuration.select_nodes ) {
838 selected_index = cb_index;
842 if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
843 _get_ext_desc_data = cb_index;
844 if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
845 addClickToOption( Configuration.get_ext_desc_data, getConfiguration()
846 .getLabelForGetExtDescendentsData() );
849 addClickToOption( Configuration.get_ext_desc_data,
850 getConfiguration().getClickToTitle( Configuration.get_ext_desc_data ) );
852 if ( default_option == Configuration.get_ext_desc_data ) {
853 selected_index = cb_index;
857 if ( getOptions().isEditable() ) {
858 if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
859 _cut_subtree_item = cb_index;
860 addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
861 if ( default_option == Configuration.cut_subtree ) {
862 selected_index = cb_index;
866 if ( _configuration.doDisplayClickToOption( Configuration.copy_subtree ) ) {
867 _copy_subtree_item = cb_index;
868 addClickToOption( Configuration.copy_subtree,
869 _configuration.getClickToTitle( Configuration.copy_subtree ) );
870 if ( default_option == Configuration.copy_subtree ) {
871 selected_index = cb_index;
875 if ( _configuration.doDisplayClickToOption( Configuration.paste_subtree ) ) {
876 _paste_subtree_item = cb_index;
877 addClickToOption( Configuration.paste_subtree,
878 _configuration.getClickToTitle( Configuration.paste_subtree ) );
879 if ( default_option == Configuration.paste_subtree ) {
880 selected_index = cb_index;
884 if ( _configuration.doDisplayClickToOption( Configuration.delete_subtree_or_node ) ) {
885 _delete_node_or_subtree_item = cb_index;
886 addClickToOption( Configuration.delete_subtree_or_node,
887 _configuration.getClickToTitle( Configuration.delete_subtree_or_node ) );
888 if ( default_option == Configuration.delete_subtree_or_node ) {
889 selected_index = cb_index;
893 if ( _configuration.doDisplayClickToOption( Configuration.add_new_node ) ) {
894 _add_new_node_item = cb_index;
895 addClickToOption( Configuration.add_new_node,
896 _configuration.getClickToTitle( Configuration.add_new_node ) );
897 if ( default_option == Configuration.add_new_node ) {
898 selected_index = cb_index;
902 if ( _configuration.doDisplayClickToOption( Configuration.edit_node_data ) ) {
903 _edit_node_data_item = cb_index;
904 addClickToOption( Configuration.edit_node_data,
905 _configuration.getClickToTitle( Configuration.edit_node_data ) );
906 if ( default_option == Configuration.edit_node_data ) {
907 selected_index = cb_index;
912 // Set default selection and its action
913 _click_to_combobox.setSelectedIndex( selected_index );
914 setClickToAction( selected_index );
917 private void setupDisplayCheckboxes() {
918 if ( _configuration.doDisplayOption( Configuration.display_as_phylogram ) ) {
919 addCheckbox( Configuration.display_as_phylogram,
920 _configuration.getDisplayTitle( Configuration.display_as_phylogram ) );
921 setCheckbox( Configuration.display_as_phylogram,
922 _configuration.doCheckOption( Configuration.display_as_phylogram ) );
924 if ( _configuration.doDisplayOption( Configuration.dynamically_hide_data ) ) {
925 addCheckbox( Configuration.dynamically_hide_data,
926 _configuration.getDisplayTitle( Configuration.dynamically_hide_data ) );
927 setCheckbox( Configuration.dynamically_hide_data,
928 _configuration.doCheckOption( Configuration.dynamically_hide_data ) );
930 if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
931 addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
932 setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
934 if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
935 addCheckbox( Configuration.display_internal_data,
936 _configuration.getDisplayTitle( Configuration.display_internal_data ) );
937 setCheckbox( Configuration.display_internal_data,
938 _configuration.doCheckOption( Configuration.display_internal_data ) );
940 if ( _configuration.doDisplayOption( Configuration.color_according_to_sequence ) ) {
941 addCheckbox( Configuration.color_according_to_sequence,
942 _configuration.getDisplayTitle( Configuration.color_according_to_sequence ) );
943 setCheckbox( Configuration.color_according_to_sequence,
944 _configuration.doCheckOption( Configuration.color_according_to_sequence ) );
946 if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) {
947 addCheckbox( Configuration.color_according_to_species,
948 _configuration.getDisplayTitle( Configuration.color_according_to_species ) );
949 setCheckbox( Configuration.color_according_to_species,
950 _configuration.doCheckOption( Configuration.color_according_to_species ) );
952 if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
953 addCheckbox( Configuration.color_according_to_annotation,
954 _configuration.getDisplayTitle( Configuration.color_according_to_annotation ) );
955 setCheckbox( Configuration.color_according_to_annotation,
956 _configuration.doCheckOption( Configuration.color_according_to_annotation ) );
958 if ( _configuration.doDisplayOption( Configuration.use_style ) ) {
959 addCheckbox( Configuration.use_style, _configuration.getDisplayTitle( Configuration.use_style ) );
960 setCheckbox( Configuration.use_style, _configuration.doCheckOption( Configuration.use_style ) );
962 if ( _configuration.doDisplayOption( Configuration.width_branches ) ) {
963 addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) );
964 setCheckbox( Configuration.width_branches, _configuration.doCheckOption( Configuration.width_branches ) );
966 final JLabel label = new JLabel( "Display Data:" );
967 label.setFont( ControlPanel.jcb_bold_font );
968 if ( !getConfiguration().isUseNativeUI() ) {
969 label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
972 if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
973 addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
974 setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
976 if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
977 addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
978 setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
980 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_scientific_names ) ) {
981 addCheckbox( Configuration.show_taxonomy_scientific_names,
982 _configuration.getDisplayTitle( Configuration.show_taxonomy_scientific_names ) );
983 setCheckbox( Configuration.show_taxonomy_scientific_names,
984 _configuration.doCheckOption( Configuration.show_taxonomy_scientific_names ) );
986 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_common_names ) ) {
987 addCheckbox( Configuration.show_taxonomy_common_names,
988 _configuration.getDisplayTitle( Configuration.show_taxonomy_common_names ) );
989 setCheckbox( Configuration.show_taxonomy_common_names,
990 _configuration.doCheckOption( Configuration.show_taxonomy_common_names ) );
992 if ( _configuration.doDisplayOption( Configuration.show_seq_names ) ) {
993 addCheckbox( Configuration.show_seq_names, _configuration.getDisplayTitle( Configuration.show_seq_names ) );
994 setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
996 if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
997 addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
998 setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
1000 if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
1001 addCheckbox( Configuration.show_seq_symbols,
1002 _configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
1003 setCheckbox( Configuration.show_seq_symbols, _configuration.doCheckOption( Configuration.show_seq_symbols ) );
1005 if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
1006 addCheckbox( Configuration.show_sequence_acc,
1007 _configuration.getDisplayTitle( Configuration.show_sequence_acc ) );
1008 setCheckbox( Configuration.show_sequence_acc,
1009 _configuration.doCheckOption( Configuration.show_sequence_acc ) );
1011 if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
1012 addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
1013 setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
1015 if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
1016 addCheckbox( Configuration.write_confidence_values,
1017 _configuration.getDisplayTitle( Configuration.write_confidence_values ) );
1018 setCheckbox( Configuration.write_confidence_values,
1019 _configuration.doCheckOption( Configuration.write_confidence_values ) );
1021 if ( _configuration.doDisplayOption( Configuration.write_branch_length_values ) ) {
1022 addCheckbox( Configuration.write_branch_length_values,
1023 _configuration.getDisplayTitle( Configuration.write_branch_length_values ) );
1024 setCheckbox( Configuration.write_branch_length_values,
1025 _configuration.doCheckOption( Configuration.write_branch_length_values ) );
1027 if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
1028 addCheckbox( Configuration.show_binary_characters,
1029 _configuration.getDisplayTitle( Configuration.show_binary_characters ) );
1030 setCheckbox( Configuration.show_binary_characters,
1031 _configuration.doCheckOption( Configuration.show_binary_characters ) );
1033 if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
1034 addCheckbox( Configuration.show_binary_character_counts,
1035 _configuration.getDisplayTitle( Configuration.show_binary_character_counts ) );
1036 setCheckbox( Configuration.show_binary_character_counts,
1037 _configuration.doCheckOption( Configuration.show_binary_character_counts ) );
1039 if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
1040 addCheckbox( Configuration.show_domain_architectures,
1041 _configuration.getDisplayTitle( Configuration.show_domain_architectures ) );
1042 setCheckbox( Configuration.show_domain_architectures,
1043 _configuration.doCheckOption( Configuration.show_domain_architectures ) );
1045 if ( _configuration.doDisplayOption( Configuration.show_mol_seqs ) ) {
1046 addCheckbox( Configuration.show_mol_seqs, _configuration.getDisplayTitle( Configuration.show_mol_seqs ) );
1047 setCheckbox( Configuration.show_mol_seqs, _configuration.doCheckOption( Configuration.show_mol_seqs ) );
1049 if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
1050 addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
1051 setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
1053 if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
1054 addCheckbox( Configuration.show_vector_data,
1055 _configuration.getDisplayTitle( Configuration.show_vector_data ) );
1056 setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
1058 if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
1059 addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
1060 setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
1062 if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
1063 addCheckbox( Configuration.show_taxonomy_images,
1064 _configuration.getDisplayTitle( Configuration.show_taxonomy_images ) );
1065 setCheckbox( Configuration.show_taxonomy_images,
1066 _configuration.doCheckOption( Configuration.show_taxonomy_images ) );
1070 private void setVisibilityOfDomainStrucureControls() {
1071 if ( _zoom_in_domain_structure != null ) {
1072 final MainFrame mf = getMainFrame();
1074 if ( isShowDomainArchitectures() ) {
1075 _domain_display_label.setVisible( true );
1076 _zoom_in_domain_structure.setVisible( true );
1077 _zoom_out_domain_structure.setVisible( true );
1078 _decr_domain_structure_evalue_thr.setVisible( true );
1079 _incr_domain_structure_evalue_thr.setVisible( true );
1080 _domain_structure_evalue_thr_tf.setVisible( true );
1081 if ( mf._right_line_up_domains_cbmi != null ) {
1082 mf._right_line_up_domains_cbmi.setVisible( true );
1084 if ( mf._show_domain_labels != null ) {
1085 mf._show_domain_labels.setVisible( true );
1089 _domain_display_label.setVisible( false );
1090 _zoom_in_domain_structure.setVisible( false );
1091 _zoom_out_domain_structure.setVisible( false );
1092 _decr_domain_structure_evalue_thr.setVisible( false );
1093 _incr_domain_structure_evalue_thr.setVisible( false );
1094 _domain_structure_evalue_thr_tf.setVisible( false );
1095 if ( mf._right_line_up_domains_cbmi != null ) {
1096 mf._right_line_up_domains_cbmi.setVisible( false );
1098 if ( mf._show_domain_labels != null ) {
1099 mf._show_domain_labels.setVisible( false );
1106 void activateButtonToReturnToSuperTree( int index ) {
1109 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT + " " + index );
1112 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
1114 _return_to_super_tree.setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1115 _return_to_super_tree.setEnabled( true );
1119 * Add zoom and quick edit buttons. (Last modified 8/9/04)
1122 final JLabel spacer = new JLabel( "" );
1123 spacer.setOpaque( false );
1125 final JPanel x_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
1126 final JPanel y_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1127 final JPanel z_panel = new JPanel( new GridLayout( 1, 1, 0, 0 ) );
1128 if ( !getConfiguration().isUseNativeUI() ) {
1129 x_panel.setBackground( getBackground() );
1130 y_panel.setBackground( getBackground() );
1131 z_panel.setBackground( getBackground() );
1133 add( _zoom_label = new JLabel( "Zoom:" ) );
1134 customizeLabel( _zoom_label, getConfiguration() );
1138 if ( getConfiguration().isUseNativeUI() ) {
1139 _zoom_in_x = new JButton( "+" );
1140 _zoom_out_x = new JButton( "-" );
1143 _zoom_in_x = new JButton( "X+" );
1144 _zoom_out_x = new JButton( "X-" );
1146 _zoom_in_y = new JButton( "Y+" );
1147 _zoom_out_y = new JButton( "Y-" );
1148 _show_whole = new JButton( "F" );
1149 _show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [F or Home]" );
1150 _zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+cursor-right]" );
1151 _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+cursor-up]" );
1152 _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+cursor-left]" );
1153 _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+cursor-down]" );
1154 if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) {
1155 _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
1156 _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
1159 _zoom_out_x.setPreferredSize( new Dimension( 10, 10 ) );
1160 _zoom_in_x.setPreferredSize( new Dimension( 10, 10 ) );
1162 _zoom_out_y.setPreferredSize( new Dimension( 10, 10 ) );
1163 _zoom_in_y.setPreferredSize( new Dimension( 10, 10 ) );
1164 _show_whole.setPreferredSize( new Dimension( 10, 10 ) );
1165 _return_to_super_tree = new JButton( RETURN_TO_SUPER_TREE_TEXT );
1166 _return_to_super_tree.setEnabled( false );
1167 _order = new JButton( "Order Subtrees" );
1168 _uncollapse_all = new JButton( "Uncollapse All" );
1169 addJButton( _zoom_in_y, x_panel );
1170 addJButton( _zoom_out_x, y_panel );
1171 addJButton( _show_whole, y_panel );
1172 addJButton( _zoom_in_x, y_panel );
1173 addJButton( _zoom_out_y, z_panel );
1174 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
1175 setUpControlsForDomainStrucures();
1177 final JLabel spacer2 = new JLabel( "" );
1179 addJButton( _return_to_super_tree, this );
1180 addJButton( _order, this );
1181 addJButton( _uncollapse_all, this );
1182 final JLabel spacer3 = new JLabel( "" );
1184 setVisibilityOfDomainStrucureControls();
1187 void addCheckbox( final int which, final String title ) {
1188 final JPanel ch_panel = new JPanel( new BorderLayout( 0, 0 ) );
1190 case Configuration.display_as_phylogram:
1191 _display_as_phylogram_cb = new JCheckBox( title );
1192 getDisplayAsPhylogramCb().setToolTipText( "To switch between phylogram and cladogram display" );
1193 addJCheckBox( getDisplayAsPhylogramCb(), ch_panel );
1196 case Configuration.display_internal_data:
1197 _display_internal_data = new JCheckBox( title );
1198 _display_internal_data.setToolTipText( "To allow or disallow display of internal labels" );
1199 addJCheckBox( _display_internal_data, ch_panel );
1202 case Configuration.color_according_to_species:
1203 _color_acc_species = new JCheckBox( title );
1204 _color_acc_species.setToolTipText( "To colorize node labels as a function of taxonomy" );
1205 addJCheckBox( _color_acc_species, ch_panel );
1208 case Configuration.color_according_to_sequence:
1209 _color_acc_sequence = new JCheckBox( title );
1210 _color_acc_sequence.setToolTipText( "To colorize node labels as a function of sequence name" );
1211 addJCheckBox( _color_acc_sequence, ch_panel );
1214 case Configuration.color_according_to_annotation:
1215 _color_according_to_annotation = new JCheckBox( title );
1216 _color_according_to_annotation
1217 .setToolTipText( "To colorize sequence annotation labels as a function of sequence annotation" );
1218 addJCheckBox( _color_according_to_annotation, ch_panel );
1221 case Configuration.show_node_names:
1222 _show_node_names = new JCheckBox( title );
1223 addJCheckBox( _show_node_names, ch_panel );
1226 case Configuration.show_taxonomy_scientific_names:
1227 _show_taxo_scientific_names = new JCheckBox( title );
1228 addJCheckBox( _show_taxo_scientific_names, ch_panel );
1231 case Configuration.show_taxonomy_common_names:
1232 _show_taxo_common_names = new JCheckBox( title );
1233 addJCheckBox( _show_taxo_common_names, ch_panel );
1236 case Configuration.show_tax_code:
1237 _show_taxo_code = new JCheckBox( title );
1238 addJCheckBox( _show_taxo_code, ch_panel );
1241 case Configuration.show_taxonomy_images:
1242 _show_taxo_images_cb = new JCheckBox( title );
1243 addJCheckBox( _show_taxo_images_cb, ch_panel );
1246 case Configuration.show_binary_characters:
1247 _show_binary_characters = new JCheckBox( title );
1248 addJCheckBox( _show_binary_characters, ch_panel );
1251 case Configuration.show_annotation:
1252 _show_annotation = new JCheckBox( title );
1253 addJCheckBox( _show_annotation, ch_panel );
1256 case Configuration.show_binary_character_counts:
1257 _show_binary_character_counts = new JCheckBox( title );
1258 addJCheckBox( _show_binary_character_counts, ch_panel );
1261 case Configuration.write_confidence_values:
1262 _write_confidence = new JCheckBox( title );
1263 addJCheckBox( getWriteConfidenceCb(), ch_panel );
1266 case Configuration.write_events:
1267 _show_events = new JCheckBox( title );
1268 addJCheckBox( getShowEventsCb(), ch_panel );
1271 case Configuration.use_style:
1272 _use_visual_styles_cb = new JCheckBox( title );
1273 getUseVisualStylesCb()
1274 .setToolTipText( "To use visual styles (node colors, fonts) and branch colors, if present" );
1275 addJCheckBox( getUseVisualStylesCb(), ch_panel );
1278 case Configuration.width_branches:
1279 _width_branches = new JCheckBox( title );
1280 _width_branches.setToolTipText( "To use branch width values, if present" );
1281 addJCheckBox( _width_branches, ch_panel );
1284 case Configuration.write_branch_length_values:
1285 _write_branch_length_values = new JCheckBox( title );
1286 addJCheckBox( _write_branch_length_values, ch_panel );
1289 case Configuration.show_domain_architectures:
1290 _show_domain_architectures = new JCheckBox( title );
1291 addJCheckBox( _show_domain_architectures, ch_panel );
1294 case Configuration.show_mol_seqs:
1295 _show_mol_seqs = new JCheckBox( title );
1296 addJCheckBox( _show_mol_seqs, ch_panel );
1299 case Configuration.show_seq_names:
1300 _show_seq_names = new JCheckBox( title );
1301 addJCheckBox( _show_seq_names, ch_panel );
1304 case Configuration.show_gene_names:
1305 _show_gene_names = new JCheckBox( title );
1306 addJCheckBox( _show_gene_names, ch_panel );
1309 case Configuration.show_seq_symbols:
1310 _show_seq_symbols = new JCheckBox( title );
1311 addJCheckBox( _show_seq_symbols, ch_panel );
1314 case Configuration.show_sequence_acc:
1315 _show_sequence_acc = new JCheckBox( title );
1316 addJCheckBox( _show_sequence_acc, ch_panel );
1319 case Configuration.dynamically_hide_data:
1320 _dynamically_hide_data = new JCheckBox( title );
1321 getDynamicallyHideData().setToolTipText( "To hide labels depending on expected visibility" );
1322 addJCheckBox( getDynamicallyHideData(), ch_panel );
1325 case Configuration.node_data_popup:
1326 _node_desc_popup_cb = new JCheckBox( title );
1327 getNodeDescPopupCb().setToolTipText( "To enable mouse rollover display of basic node data" );
1328 addJCheckBox( getNodeDescPopupCb(), ch_panel );
1331 case Configuration.show_relation_confidence:
1332 _seq_relation_confidence_switch = new JCheckBox( title );
1333 addJCheckBox( _seq_relation_confidence_switch, ch_panel );
1336 case Configuration.show_vector_data:
1337 _show_vector_data_cb = new JCheckBox( title );
1338 addJCheckBox( _show_vector_data_cb, ch_panel );
1341 case Configuration.show_properties:
1342 _show_properties_cb = new JCheckBox( title );
1343 addJCheckBox( _show_properties_cb, ch_panel );
1347 throw new RuntimeException( "unknown checkbox: " + which );
1351 void addJButton( final JButton jb, final JPanel p ) {
1352 jb.setFocusPainted( false );
1353 jb.setFont( ControlPanel.jcb_font );
1354 if ( !_configuration.isUseNativeUI() ) {
1355 jb.setBorder( BorderFactory.createLineBorder( getConfiguration().getGuiButtonBorderColor() ) );
1356 jb.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
1357 jb.setForeground( getConfiguration().getGuiButtonTextColor() );
1360 jb.addActionListener( this );
1363 void addJCheckBox( final JCheckBox jcb, final JPanel p ) {
1364 jcb.setFocusPainted( false );
1365 jcb.setFont( ControlPanel.jcb_font );
1366 if ( !_configuration.isUseNativeUI() ) {
1367 jcb.setBackground( getConfiguration().getGuiBackgroundColor() );
1368 jcb.setForeground( getConfiguration().getGuiCheckboxTextColor() );
1370 p.add( jcb, "Center" );
1371 jcb.addActionListener( this );
1374 void addJTextField( final JTextField tf, final JPanel p ) {
1375 if ( !_configuration.isUseNativeUI() ) {
1376 tf.setForeground( getConfiguration().getGuiBackgroundColor() );
1377 tf.setFont( ControlPanel.jcb_font );
1380 tf.addActionListener( this );
1383 void deactivateButtonToReturnToSuperTree() {
1384 _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
1385 _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
1386 _return_to_super_tree.setEnabled( false );
1389 void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
1390 if ( ( _mainpanel != null )
1391 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
1393 if ( recalc_longest_ext_node_info ) {
1394 _mainpanel.getCurrentTreePanel().initNodeData();
1395 _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
1397 if ( getOptions().isShowOverview() ) {
1398 _mainpanel.getCurrentTreePanel().updateOvSizes();
1400 _mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
1401 setVisibilityOfDomainStrucureControls();
1402 updateDomainStructureEvaluethresholdDisplay();
1403 _mainpanel.getCurrentTreePanel().calculateScaleDistance();
1404 _mainpanel.getCurrentTreePanel().calcMaxDepth();
1405 _mainpanel.adjustJScrollPane();
1407 _mainpanel.getCurrentTreePanel().repaint();
1408 // _mainpanel.getCurrentTreePanel().setUpUrtFactor();
1412 void endClickToOptions() {
1413 _click_to_combobox.addActionListener( this );
1417 * Indicates what action should be execute when a node is clicked
1419 * @return the click-on action
1421 NodeClickAction getActionWhenNodeClicked() {
1422 return _action_when_node_clicked;
1425 Map<Integer, String> getAllClickToItems() {
1426 return _all_click_to_names;
1429 Map<String, Color> getAnnotationColors() {
1430 return _annotation_colors;
1433 Configuration getConfiguration() {
1434 return _configuration;
1437 TreePanel getCurrentTreePanel() {
1438 return getMainPanel().getCurrentTreePanel();
1441 MainPanel getMainPanel() {
1445 Options getOptions() {
1446 return getMainPanel().getOptions();
1449 JLabel getSearchFoundCountsLabel0() {
1450 return _search_found_label_0;
1453 JLabel getSearchFoundCountsLabel1() {
1454 return _search_found_label_1;
1457 JButton getSearchResetButton0() {
1458 return _search_reset_button_0;
1461 JButton getSearchResetButton1() {
1462 return _search_reset_button_1;
1465 JTextField getSearchTextField0() {
1466 return _search_tf_0;
1469 JTextField getSearchTextField1() {
1470 return _search_tf_1;
1473 Map<String, Color> getSequenceColors() {
1474 return _sequence_colors;
1477 List<String> getSingleClickToNames() {
1478 return _click_to_names;
1481 Map<String, Color> getSpeciesColors() {
1482 return _species_colors;
1485 boolean isAntialiasScreenText() {
1489 boolean isColorAccordingToAnnotation() {
1490 return ( ( _color_according_to_annotation != null ) && _color_according_to_annotation.isSelected() );
1493 boolean isColorAccordingToSequence() {
1494 return ( ( _color_acc_sequence != null ) && _color_acc_sequence.isSelected() );
1497 boolean isColorAccordingToTaxonomy() {
1498 return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() );
1501 boolean isDrawPhylogram() {
1502 return isDrawPhylogram( getMainPanel().getCurrentTabIndex() );
1505 boolean isDynamicallyHideData() {
1506 return ( ( getDynamicallyHideData() != null ) && getDynamicallyHideData().isSelected() );
1509 boolean isEvents() {
1510 return ( ( getShowEventsCb() != null ) && getShowEventsCb().isSelected() );
1513 boolean isNodeDescPopup() {
1514 return ( ( getNodeDescPopupCb() != null ) && getNodeDescPopupCb().isSelected() );
1517 boolean isShowAnnotation() {
1518 return ( ( _show_annotation != null ) && _show_annotation.isSelected() );
1521 boolean isShowBinaryCharacterCounts() {
1522 return ( ( _show_binary_character_counts != null ) && _show_binary_character_counts.isSelected() );
1525 boolean isShowBinaryCharacters() {
1526 return ( ( _show_binary_characters != null ) && _show_binary_characters.isSelected() );
1529 boolean isShowConfidenceValues() {
1530 return ( ( getWriteConfidenceCb() != null ) && getWriteConfidenceCb().isSelected() );
1533 boolean isShowDomainArchitectures() {
1534 return ( ( _show_domain_architectures != null ) && _show_domain_architectures.isSelected() );
1537 boolean isShowGeneNames() {
1538 return ( ( _show_gene_names != null ) && _show_gene_names.isSelected() );
1541 boolean isShowInternalData() {
1542 return ( ( _display_internal_data == null ) || _display_internal_data.isSelected() );
1545 boolean isShowNodeNames() {
1546 return ( ( _show_node_names != null ) && _show_node_names.isSelected() );
1549 boolean isShowSeqNames() {
1550 return ( ( _show_seq_names != null ) && _show_seq_names.isSelected() );
1553 boolean isShowSeqSymbols() {
1554 return ( ( _show_seq_symbols != null ) && _show_seq_symbols.isSelected() );
1557 boolean isShowSequenceAcc() {
1558 return ( ( _show_sequence_acc != null ) && _show_sequence_acc.isSelected() );
1561 boolean isShowSequenceRelationConfidence() {
1562 return ( ( _seq_relation_confidence_switch != null ) && ( _seq_relation_confidence_switch.isSelected() ) );
1565 boolean isShowSequenceRelations() {
1566 return ( ( _show_sequence_relations != null ) && ( _show_sequence_relations.getSelectedIndex() > 0 ) );
1569 boolean isShowTaxonomyCode() {
1570 return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
1573 boolean isShowTaxonomyCommonNames() {
1574 return ( ( _show_taxo_common_names != null ) && _show_taxo_common_names.isSelected() );
1577 boolean isShowTaxonomyScientificNames() {
1578 return ( ( _show_taxo_scientific_names != null ) && _show_taxo_scientific_names.isSelected() );
1581 boolean isUseVisualStyles() {
1582 return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() ) || ( ( getUseVisualStylesCb() == null ) && _color_branches ) );
1585 boolean isWidthBranches() {
1586 return ( ( _width_branches != null ) && _width_branches.isSelected() );
1589 boolean isWriteBranchLengthValues() {
1590 return ( ( _write_branch_length_values != null ) && _write_branch_length_values.isSelected() );
1593 void phylogenyAdded( final Configuration configuration ) {
1594 getIsDrawPhylogramList().add( configuration.isDrawAsPhylogram() );
1597 void phylogenyRemoved( final int index ) {
1598 getIsDrawPhylogramList().remove( index );
1602 final MainPanel main_panel = getMainPanel();
1603 final Phylogeny tree = main_panel.getCurrentPhylogeny();
1604 if ( ( tree == null ) || tree.isEmpty() ) {
1607 String query = getSearchTextField0().getText();
1608 if ( query != null ) {
1609 query = query.trim();
1611 if ( !ForesterUtil.isEmpty( query ) ) {
1612 search0( main_panel, tree, query );
1615 getSearchFoundCountsLabel0().setVisible( false );
1616 getSearchResetButton0().setEnabled( false );
1617 getSearchResetButton0().setVisible( false );
1623 final MainPanel main_panel = getMainPanel();
1624 final Phylogeny tree = main_panel.getCurrentPhylogeny();
1625 if ( ( tree == null ) || tree.isEmpty() ) {
1628 String query = getSearchTextField1().getText();
1629 if ( query != null ) {
1630 query = query.trim();
1632 if ( !ForesterUtil.isEmpty( query ) ) {
1633 search1( main_panel, tree, query );
1636 getSearchFoundCountsLabel1().setVisible( false );
1637 getSearchResetButton1().setEnabled( false );
1638 getSearchResetButton1().setVisible( false );
1643 void searchReset0() {
1644 if ( getMainPanel().getCurrentTreePanel() != null ) {
1645 getMainPanel().getCurrentTreePanel().setFoundNodes0( null );
1649 void searchReset1() {
1650 if ( getMainPanel().getCurrentTreePanel() != null ) {
1651 getMainPanel().getCurrentTreePanel().setFoundNodes1( null );
1655 void setActionWhenNodeClicked( final NodeClickAction action ) {
1656 _action_when_node_clicked = action;
1659 void setAnnotationColors( final Map<String, Color> annotation_colors ) {
1660 _annotation_colors = annotation_colors;
1663 void setCheckbox( final int which, final boolean state ) {
1665 case Configuration.display_as_phylogram:
1666 if ( getDisplayAsPhylogramCb() != null ) {
1667 getDisplayAsPhylogramCb().setSelected( state );
1670 case Configuration.display_internal_data:
1671 if ( _display_internal_data != null ) {
1672 _display_internal_data.setSelected( state );
1675 case Configuration.color_according_to_species:
1676 if ( _color_acc_species != null ) {
1677 _color_acc_species.setSelected( state );
1680 case Configuration.color_according_to_sequence:
1681 if ( _color_acc_sequence != null ) {
1682 _color_acc_sequence.setSelected( state );
1685 case Configuration.color_according_to_annotation:
1686 if ( _color_according_to_annotation != null ) {
1687 _color_according_to_annotation.setSelected( state );
1690 case Configuration.show_node_names:
1691 if ( _show_node_names != null ) {
1692 _show_node_names.setSelected( state );
1695 case Configuration.show_taxonomy_scientific_names:
1696 if ( _show_taxo_scientific_names != null ) {
1697 _show_taxo_scientific_names.setSelected( state );
1700 case Configuration.show_taxonomy_common_names:
1701 if ( _show_taxo_common_names != null ) {
1702 _show_taxo_common_names.setSelected( state );
1705 case Configuration.show_tax_code:
1706 if ( _show_taxo_code != null ) {
1707 _show_taxo_code.setSelected( state );
1710 case Configuration.show_taxonomy_images:
1711 if ( _show_taxo_images_cb != null ) {
1712 _show_taxo_images_cb.setSelected( state );
1715 case Configuration.show_annotation:
1716 if ( _show_annotation != null ) {
1717 _show_annotation.setSelected( state );
1720 case Configuration.show_binary_characters:
1721 if ( _show_binary_characters != null ) {
1722 _show_binary_characters.setSelected( state );
1725 case Configuration.show_binary_character_counts:
1726 if ( _show_binary_character_counts != null ) {
1727 _show_binary_character_counts.setSelected( state );
1730 case Configuration.write_confidence_values:
1731 if ( getWriteConfidenceCb() != null ) {
1732 getWriteConfidenceCb().setSelected( state );
1735 case Configuration.write_events:
1736 if ( getShowEventsCb() != null ) {
1737 getShowEventsCb().setSelected( state );
1740 case Configuration.use_style:
1741 if ( getUseVisualStylesCb() != null ) {
1742 getUseVisualStylesCb().setSelected( state );
1745 case Configuration.width_branches:
1746 if ( _width_branches != null ) {
1747 _width_branches.setSelected( state );
1750 case Configuration.show_domain_architectures:
1751 if ( _show_domain_architectures != null ) {
1752 _show_domain_architectures.setSelected( state );
1755 case Configuration.write_branch_length_values:
1756 if ( _write_branch_length_values != null ) {
1757 _write_branch_length_values.setSelected( state );
1760 case Configuration.show_mol_seqs:
1761 if ( _show_mol_seqs != null ) {
1762 _show_mol_seqs.setSelected( state );
1765 case Configuration.show_seq_names:
1766 if ( _show_seq_names != null ) {
1767 _show_seq_names.setSelected( state );
1770 case Configuration.show_gene_names:
1771 if ( _show_gene_names != null ) {
1772 _show_gene_names.setSelected( state );
1775 case Configuration.show_seq_symbols:
1776 if ( _show_seq_symbols != null ) {
1777 _show_seq_symbols.setSelected( state );
1780 case Configuration.show_vector_data:
1781 if ( _show_vector_data_cb != null ) {
1782 _show_vector_data_cb.setSelected( state );
1785 case Configuration.show_properties:
1786 if ( _show_properties_cb != null ) {
1787 _show_properties_cb.setSelected( state );
1790 case Configuration.show_sequence_acc:
1791 if ( _show_sequence_acc != null ) {
1792 _show_sequence_acc.setSelected( state );
1795 case Configuration.dynamically_hide_data:
1796 if ( getDynamicallyHideData() != null ) {
1797 getDynamicallyHideData().setSelected( state );
1800 case Configuration.node_data_popup:
1801 if ( getNodeDescPopupCb() != null ) {
1802 getNodeDescPopupCb().setSelected( state );
1806 case Configuration.show_relation_confidence:
1807 if ( _seq_relation_confidence_switch != null ) {
1808 _seq_relation_confidence_switch.setSelected( state );
1813 throw new AssertionError( "unknown checkbox: " + which );
1818 * Set this checkbox state. Not all checkboxes have been instantiated
1819 * depending on the config.
1821 void setCheckbox( final JCheckBox cb, final boolean state ) {
1823 cb.setSelected( state );
1827 void setClickToAction( final int action ) {
1828 // Set click-to action
1829 if ( action == _show_data_item ) {
1830 setActionWhenNodeClicked( NodeClickAction.SHOW_DATA );
1832 else if ( action == _collapse_cb_item ) {
1833 setActionWhenNodeClicked( NodeClickAction.COLLAPSE );
1835 else if ( action == _reroot_cb_item ) {
1836 setActionWhenNodeClicked( NodeClickAction.REROOT );
1838 else if ( action == _subtree_cb_item ) {
1839 setActionWhenNodeClicked( NodeClickAction.SUBTREE );
1841 else if ( action == _swap_cb_item ) {
1842 setActionWhenNodeClicked( NodeClickAction.SWAP );
1844 else if ( action == _color_subtree_cb_item ) {
1845 setActionWhenNodeClicked( NodeClickAction.COLOR_SUBTREE );
1847 else if ( action == _open_seq_web_item ) {
1848 setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
1850 else if ( action == _sort_descendents_item ) {
1851 setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
1853 else if ( action == _blast_item ) {
1854 setActionWhenNodeClicked( NodeClickAction.BLAST );
1856 else if ( action == _open_tax_web_item ) {
1857 setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
1859 else if ( action == _cut_subtree_item ) {
1860 setActionWhenNodeClicked( NodeClickAction.CUT_SUBTREE );
1862 else if ( action == _copy_subtree_item ) {
1863 setActionWhenNodeClicked( NodeClickAction.COPY_SUBTREE );
1865 else if ( action == _delete_node_or_subtree_item ) {
1866 setActionWhenNodeClicked( NodeClickAction.DELETE_NODE_OR_SUBTREE );
1868 else if ( action == _paste_subtree_item ) {
1869 setActionWhenNodeClicked( NodeClickAction.PASTE_SUBTREE );
1871 else if ( action == _add_new_node_item ) {
1872 setActionWhenNodeClicked( NodeClickAction.ADD_NEW_NODE );
1874 else if ( action == _edit_node_data_item ) {
1875 setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
1877 else if ( action == _select_nodes_item ) {
1878 setActionWhenNodeClicked( NodeClickAction.SELECT_NODES );
1880 else if ( action == _get_ext_desc_data ) {
1881 setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
1883 else if ( action == _open_pdb_item ) {
1884 setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
1886 else if ( action == _color_node_font_item ) {
1887 setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
1889 else if ( action == _change_node_font_item ) {
1890 setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT );
1893 throw new RuntimeException( "unknown action: " + action );
1895 // make sure drop down is displaying the correct action
1896 // in case this was called from outside the class
1897 _click_to_combobox.setSelectedIndex( action );
1900 void setColorBranches( final boolean color_branches ) {
1901 _color_branches = color_branches;
1904 void setDrawPhylogram( final boolean b ) {
1905 getDisplayAsPhylogramCb().setSelected( b );
1906 setDrawPhylogram( getMainPanel().getCurrentTabIndex(), b );
1909 void setDrawPhylogramEnabled( final boolean b ) {
1910 getDisplayAsPhylogramCb().setEnabled( b );
1913 void setDynamicHidingIsOn( final boolean is_on ) {
1915 getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
1918 if ( !_configuration.isUseNativeUI() ) {
1919 getDynamicallyHideData().setForeground( getConfiguration().getGuiButtonTextColor() );
1922 getDynamicallyHideData().setForeground( Color.BLACK );
1927 void setSearchFoundCountsOnLabel0( final int counts ) {
1928 getSearchFoundCountsLabel0().setText( "Found: " + counts );
1931 void setSearchFoundCountsOnLabel1( final int counts ) {
1932 getSearchFoundCountsLabel1().setText( "Found: " + counts );
1935 void setSequenceColors( final Map<String, Color> sequence_colors ) {
1936 _sequence_colors = sequence_colors;
1939 void setShowEvents( final boolean show_events ) {
1940 if ( getShowEventsCb() == null ) {
1941 _show_events = new JCheckBox( "" );
1943 getShowEventsCb().setSelected( show_events );
1946 void setSpeciesColors( final Map<String, Color> species_colors ) {
1947 _species_colors = species_colors;
1950 void setupControls() {
1951 // The tree display options:
1952 setupDisplayCheckboxes();
1954 // The sequence relation query selection combo-box
1955 if ( _configuration.displaySequenceRelations() ) {
1956 addSequenceRelationBlock();
1960 startClickToOptions();
1961 setupClickToOptions();
1962 endClickToOptions();
1963 // Zoom and quick edit buttons
1965 setupSearchTools0();
1966 setupSearchTools1();
1969 void setUpControlsForDomainStrucures() {
1970 _domain_display_label = new JLabel( "Domain Architectures:" );
1971 add( customizeLabel( _domain_display_label, getConfiguration() ) );
1972 add( _domain_display_label );
1973 _zoom_in_domain_structure = new JButton( "d+" );
1974 _zoom_out_domain_structure = new JButton( "d-" );
1975 _decr_domain_structure_evalue_thr = new JButton( "-" );
1976 _incr_domain_structure_evalue_thr = new JButton( "+" );
1977 _zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1978 _zoom_out_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
1979 _decr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1980 _incr_domain_structure_evalue_thr.setPreferredSize( new Dimension( 10, 10 ) );
1981 _incr_domain_structure_evalue_thr.setToolTipText( "Increase the E-value threshold by a factor of 10" );
1982 _decr_domain_structure_evalue_thr.setToolTipText( "Decrease the E-value threshold by a factor of 10" );
1983 _domain_structure_evalue_thr_tf = new JTextField( 3 );
1984 _domain_structure_evalue_thr_tf.setEditable( false );
1985 if ( !getConfiguration().isUseNativeUI() ) {
1986 _domain_structure_evalue_thr_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
1987 _domain_structure_evalue_thr_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
1988 _domain_structure_evalue_thr_tf.setBorder( null );
1990 final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
1991 final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
1992 if ( !_configuration.isUseNativeUI() ) {
1993 d1_panel.setBackground( getBackground() );
1994 d2_panel.setBackground( getBackground() );
1998 addJButton( _zoom_out_domain_structure, d1_panel );
1999 addJButton( _zoom_in_domain_structure, d1_panel );
2000 addJButton( _decr_domain_structure_evalue_thr, d2_panel );
2001 addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
2002 addJButton( _incr_domain_structure_evalue_thr, d2_panel );
2005 void setupSearchTools0() {
2006 final JLabel search_label = new JLabel( "Search (A):" );
2007 search_label.setFont( ControlPanel.jcb_bold_font );
2008 if ( !getConfiguration().isUseNativeUI() ) {
2009 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2011 add( search_label );
2012 search_label.setToolTipText( SEARCH_TIP_TEXT );
2013 _search_found_label_0 = new JLabel();
2014 getSearchFoundCountsLabel0().setVisible( false );
2015 _search_found_label_0.setFont( ControlPanel.jcb_bold_font );
2016 if ( !getConfiguration().isUseNativeUI() ) {
2017 _search_found_label_0.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2019 _search_tf_0 = new JTextField( 3 );
2020 _search_tf_0.setToolTipText( SEARCH_TIP_TEXT );
2021 _search_tf_0.setEditable( true );
2022 if ( !getConfiguration().isUseNativeUI() ) {
2023 _search_tf_0.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2024 _search_tf_0.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2025 _search_tf_0.setBorder( null );
2027 _search_reset_button_0 = new JButton();
2028 getSearchResetButton0().setText( "Reset" );
2029 getSearchResetButton0().setEnabled( false );
2030 getSearchResetButton0().setVisible( false );
2031 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
2032 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2033 s_panel_1.setBackground( getBackground() );
2035 s_panel_2.setBackground( getBackground() );
2037 final KeyAdapter key_adapter = new KeyAdapter() {
2040 public void keyReleased( final KeyEvent key_event ) {
2042 displayedPhylogenyMightHaveChanged( true );
2045 final ActionListener action_listener = new ActionListener() {
2048 public void actionPerformed( final ActionEvent e ) {
2050 setSearchFoundCountsOnLabel0( 0 );
2051 getSearchFoundCountsLabel0().setVisible( false );
2052 getSearchTextField0().setText( "" );
2053 getSearchResetButton0().setEnabled( false );
2054 getSearchResetButton0().setVisible( false );
2055 displayedPhylogenyMightHaveChanged( true );
2058 _search_reset_button_0.addActionListener( action_listener );
2059 _search_tf_0.addKeyListener( key_adapter );
2060 addJTextField( _search_tf_0, s_panel_1 );
2061 s_panel_2.add( _search_found_label_0 );
2062 addJButton( _search_reset_button_0, s_panel_2 );
2065 void setupSearchTools1() {
2066 final JLabel search_label = new JLabel( "Search (B):" );
2067 search_label.setFont( ControlPanel.jcb_bold_font );
2068 if ( !getConfiguration().isUseNativeUI() ) {
2069 search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2071 add( search_label );
2072 search_label.setToolTipText( SEARCH_TIP_TEXT );
2073 _search_found_label_1 = new JLabel();
2074 getSearchFoundCountsLabel1().setVisible( false );
2075 _search_found_label_1.setFont( ControlPanel.jcb_bold_font );
2076 if ( !getConfiguration().isUseNativeUI() ) {
2077 _search_found_label_1.setForeground( getConfiguration().getGuiCheckboxTextColor() );
2079 _search_tf_1 = new JTextField( 3 );
2080 _search_tf_1.setToolTipText( SEARCH_TIP_TEXT );
2081 _search_tf_1.setEditable( true );
2082 if ( !getConfiguration().isUseNativeUI() ) {
2083 _search_tf_1.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
2084 _search_tf_1.setBackground( getConfiguration().getGuiCheckboxTextColor() );
2085 _search_tf_1.setBorder( null );
2087 _search_reset_button_1 = new JButton();
2088 getSearchResetButton1().setText( "Reset" );
2089 getSearchResetButton1().setEnabled( false );
2090 getSearchResetButton1().setVisible( false );
2091 final JPanel s_panel_1 = new JPanel( new BorderLayout() );
2092 final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
2093 s_panel_1.setBackground( getBackground() );
2095 s_panel_2.setBackground( getBackground() );
2097 final KeyAdapter key_adapter = new KeyAdapter() {
2100 public void keyReleased( final KeyEvent key_event ) {
2102 displayedPhylogenyMightHaveChanged( true );
2105 final ActionListener action_listener = new ActionListener() {
2108 public void actionPerformed( final ActionEvent e ) {
2110 setSearchFoundCountsOnLabel1( 0 );
2111 getSearchFoundCountsLabel1().setVisible( false );
2112 getSearchTextField1().setText( "" );
2113 getSearchResetButton1().setEnabled( false );
2114 getSearchResetButton1().setVisible( false );
2115 displayedPhylogenyMightHaveChanged( true );
2118 _search_reset_button_1.addActionListener( action_listener );
2119 _search_tf_1.addKeyListener( key_adapter );
2120 addJTextField( _search_tf_1, s_panel_1 );
2121 s_panel_2.add( _search_found_label_1 );
2122 addJButton( _search_reset_button_1, s_panel_2 );
2125 void setVisibilityOfDomainStrucureCB() {
2127 if ( ( getCurrentTreePanel() != null )
2128 && ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( getCurrentTreePanel()
2129 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
2130 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2131 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
2133 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2134 getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
2137 else if ( isShowDomainArchitectures() ) {
2138 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2139 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( true );
2141 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2142 getMainPanel().getMainFrame()._show_domain_labels.setVisible( true );
2146 if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
2147 getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
2149 if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
2150 getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
2154 catch ( final Exception ignore ) {
2159 void setVisibilityOfX() {
2160 final MainFrame mf = getMainFrame();
2162 if ( ( getCurrentTreePanel() != null ) && ( getCurrentTreePanel().getPhylogeny() != null ) ) {
2163 if ( AptxUtil.isHasAtLeastOneBranchWithSupportSD( getCurrentTreePanel().getPhylogeny() ) ) {
2164 if ( mf._show_confidence_stddev_cbmi != null ) {
2165 mf._show_confidence_stddev_cbmi.setVisible( true );
2169 if ( mf._show_confidence_stddev_cbmi != null ) {
2170 mf._show_confidence_stddev_cbmi.setVisible( false );
2173 if ( AptxUtil.isHasAtLeastOneNodeWithScientificName( getCurrentTreePanel().getPhylogeny() ) ) {
2174 if ( mf._abbreviate_scientific_names != null ) {
2175 mf._abbreviate_scientific_names.setVisible( true );
2179 if ( mf._abbreviate_scientific_names != null ) {
2180 mf._abbreviate_scientific_names.setVisible( false );
2183 if ( AptxUtil.isHasAtLeastOneNodeWithSequenceAnnotation( getCurrentTreePanel().getPhylogeny() ) ) {
2184 if ( mf._show_annotation_ref_source != null ) {
2185 mf._show_annotation_ref_source.setVisible( true );
2189 if ( mf._show_annotation_ref_source != null ) {
2190 mf._show_annotation_ref_source.setVisible( false );
2194 if ( isDrawPhylogram()
2195 || ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( getCurrentTreePanel()
2196 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) ) {
2197 if ( mf._non_lined_up_cladograms_rbmi != null ) {
2198 mf._non_lined_up_cladograms_rbmi.setVisible( false );
2200 if ( mf._uniform_cladograms_rbmi != null ) {
2201 mf._uniform_cladograms_rbmi.setVisible( false );
2203 if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
2204 mf._ext_node_dependent_cladogram_rbmi.setVisible( false );
2208 if ( mf._non_lined_up_cladograms_rbmi != null ) {
2209 mf._non_lined_up_cladograms_rbmi.setVisible( true );
2211 if ( mf._uniform_cladograms_rbmi != null ) {
2212 mf._uniform_cladograms_rbmi.setVisible( true );
2214 if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
2215 mf._ext_node_dependent_cladogram_rbmi.setVisible( true );
2218 if ( isDrawPhylogram() ) {
2219 if ( mf._show_scale_cbmi != null ) {
2220 mf._show_scale_cbmi.setVisible( true );
2224 if ( mf._show_scale_cbmi != null ) {
2225 mf._show_scale_cbmi.setVisible( false );
2228 if ( getCurrentTreePanel() != null ) {
2229 if ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2230 || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
2231 if ( mf._label_direction_cbmi != null ) {
2232 mf._label_direction_cbmi.setVisible( true );
2236 if ( mf._label_direction_cbmi != null ) {
2237 mf._label_direction_cbmi.setVisible( false );
2244 void showAnnotations() {
2245 if ( _show_annotation != null ) {
2246 _show_annotation.setSelected( true );
2248 if ( _color_according_to_annotation != null ) {
2249 _color_according_to_annotation.setSelected( true );
2251 if ( _color_acc_species != null ) {
2252 _color_acc_species.setSelected( false );
2254 if ( _color_acc_sequence != null ) {
2255 _color_acc_sequence.setSelected( false );
2257 _mainpanel.getCurrentTreePanel().repaint();
2261 * Fit entire tree into window.
2264 if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
2267 getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
2268 displayedPhylogenyMightHaveChanged( true );
2269 _mainpanel.getCurrentTreePanel().updateOvSettings();
2270 _mainpanel.getCurrentTreePanel().validate();
2271 _mainpanel.validate();
2272 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2273 _mainpanel.getSizeOfViewport().height );
2274 _mainpanel.getCurrentTreePanel().resetPreferredSize();
2275 _mainpanel.adjustJScrollPane();
2276 _mainpanel.getCurrentTreePanel().repaint();
2277 _mainpanel.getCurrentTreePanel().validate();
2278 _mainpanel.validate();
2279 _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2280 _mainpanel.getSizeOfViewport().height );
2281 _mainpanel.getCurrentTreePanel().resetPreferredSize();
2282 _mainpanel.adjustJScrollPane();
2283 _mainpanel.getCurrentTreePanel().repaint();
2284 _mainpanel.getCurrentTreePanel().updateOvSizes();
2287 void showWholeAll() {
2288 for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
2289 if ( tree_panel != null ) {
2290 tree_panel.validate();
2291 tree_panel.calcParametersForPainting( _mainpanel.getSizeOfViewport().width,
2292 _mainpanel.getSizeOfViewport().height );
2293 tree_panel.resetPreferredSize();
2294 tree_panel.repaint();
2299 // Create header for click-to combo box.
2300 void startClickToOptions() {
2301 final JLabel spacer = new JLabel( "" );
2302 spacer.setFont( ControlPanel.jcb_font );
2304 _click_to_label = new JLabel( "Click on Node to:" );
2305 add( customizeLabel( _click_to_label, getConfiguration() ) );
2306 _click_to_combobox = new JComboBox<String>();
2307 _click_to_combobox.setFocusable( false );
2308 _click_to_combobox.setMaximumRowCount( 14 );
2309 _click_to_combobox.setFont( ControlPanel.js_font );
2310 if ( !_configuration.isUseNativeUI() ) {
2311 _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
2313 // don't add listener until all items are set (or each one will trigger
2315 // click_to_list.addActionListener(this);
2316 add( _click_to_combobox );
2317 // Correlates option names to titles
2318 _all_click_to_names = new HashMap<Integer, String>();
2319 _click_to_names = new ArrayList<String>();
2323 if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
2324 if ( getCurrentTreePanel().isPhyHasBranchLengths()
2325 && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
2326 setDrawPhylogramEnabled( true );
2327 setDrawPhylogram( isDrawPhylogram() );
2330 setDrawPhylogramEnabled( false );
2331 setDrawPhylogram( false );
2333 if ( getMainPanel().getMainFrame() == null ) {
2334 // Must be "E" applet version.
2335 final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
2336 e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
2339 getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
2340 .getPhylogenyGraphicsType() );
2342 getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
2343 getMainPanel().getControlPanel().search0();
2344 getMainPanel().getControlPanel().search1();
2345 getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
2346 getSequenceRelationTypeBox().removeAllItems();
2347 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
2348 .getRelevantSequenceRelationTypes() ) {
2349 _sequence_relation_type_box.addItem( type );
2351 getMainPanel().getCurrentTreePanel().repaint();
2352 //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
2353 // according to GUILHEM the line above can be removed.
2358 * Uncollapse all nodes.
2360 void uncollapseAll( final TreePanel tp ) {
2361 final Phylogeny t = tp.getPhylogeny();
2362 if ( ( t != null ) && !t.isEmpty() ) {
2363 for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
2364 final PhylogenyNode node = iter.next();
2365 node.setCollapse( false );
2367 tp.resetNodeIdToDistToLeafMap();
2368 tp.updateSetOfCollapsedExternalNodes();
2369 t.recalculateNumberOfExternalDescendants( false );
2370 tp.setNodeInPreorderToNull();
2371 t.clearHashIdToNodeMap();
2376 void updateDomainStructureEvaluethresholdDisplay() {
2377 if ( _domain_structure_evalue_thr_tf != null ) {
2378 _domain_structure_evalue_thr_tf.setText( "10^"
2379 + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThresholdExp() );
2383 void zoomInX( final float factor, final float x_correction_factor ) {
2384 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
2385 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2386 treepanel.multiplyUrtFactor( 1f );
2387 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2388 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
2389 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
2390 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
2391 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2392 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2393 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2394 getMainPanel().adjustJScrollPane();
2395 treepanel.resetPreferredSize();
2396 getMainPanel().getCurrentScrollPane().getViewport().validate();
2397 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
2398 - ( sb.getVisibleAmount() / 2.0 ) ) );
2401 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
2402 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2403 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2404 getMainPanel().adjustJScrollPane();
2405 treepanel.resetPreferredSize();
2406 getMainPanel().getCurrentScrollPane().getViewport().validate();
2407 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
2409 treepanel.resetPreferredSize();
2410 treepanel.updateOvSizes();
2413 void zoomInY( final float factor ) {
2414 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
2415 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2416 treepanel.multiplyUrtFactor( 1.1f );
2417 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2418 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
2419 getMainPanel().adjustJScrollPane();
2420 treepanel.resetPreferredSize();
2421 getMainPanel().getCurrentScrollPane().getViewport().validate();
2422 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
2423 - ( sb.getVisibleAmount() / 2.0 ) ) );
2424 treepanel.resetPreferredSize();
2425 treepanel.updateOvSizes();
2428 void zoomOutX( final float factor, final float x_correction_factor ) {
2429 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2430 treepanel.multiplyUrtFactor( 1f );
2431 if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
2432 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
2433 if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
2434 || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
2435 || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
2436 || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
2437 getMainPanel().adjustJScrollPane();
2438 treepanel.resetPreferredSize();
2439 getMainPanel().getCurrentScrollPane().getViewport().validate();
2440 final double x = ( sb.getMaximum() - sb.getMinimum() )
2441 / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2442 treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
2443 treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
2444 getMainPanel().adjustJScrollPane();
2445 treepanel.resetPreferredSize();
2446 getMainPanel().getCurrentScrollPane().getViewport().validate();
2447 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
2448 - ( sb.getVisibleAmount() / 2.0 ) ) );
2451 final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
2452 treepanel.setXdistance( treepanel.getXdistance() * factor );
2453 treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
2455 getMainPanel().adjustJScrollPane();
2456 treepanel.resetPreferredSize();
2457 getMainPanel().getCurrentScrollPane().getViewport().validate();
2458 sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
2461 treepanel.resetPreferredSize();
2462 treepanel.updateOvSizes();
2466 void zoomOutY( final float factor ) {
2467 final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
2468 treepanel.multiplyUrtFactor( 0.9f );
2469 if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
2470 final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
2471 final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
2472 treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
2473 getMainPanel().adjustJScrollPane();
2474 treepanel.resetPreferredSize();
2475 getMainPanel().getCurrentScrollPane().getViewport().validate();
2476 sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
2477 - ( sb.getVisibleAmount() / 2.0 ) ) );
2478 treepanel.resetPreferredSize();
2479 treepanel.updateOvSizes();
2483 static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
2484 label.setFont( ControlPanel.jcb_bold_font );
2485 if ( !configuration.isUseNativeUI() ) {
2486 label.setForeground( configuration.getGuiCheckboxTextColor() );
2487 label.setBackground( configuration.getGuiBackgroundColor() );
2492 public JCheckBox getUseBranchWidthsCb() {
2493 return _width_branches;