2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2010 Christian M. Zmasek
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: www.phylosoft.org/forester
25 package org.forester.archaeopteryx;
27 import java.awt.Container;
29 import java.awt.event.ActionEvent;
30 import java.awt.event.ActionListener;
31 import java.io.IOException;
32 import java.util.List;
33 import java.util.Locale;
36 import javax.swing.JApplet;
37 import javax.swing.JCheckBoxMenuItem;
38 import javax.swing.JFrame;
39 import javax.swing.JMenu;
40 import javax.swing.JMenuBar;
41 import javax.swing.JMenuItem;
42 import javax.swing.JOptionPane;
43 import javax.swing.JRadioButtonMenuItem;
45 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
46 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
47 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
48 import org.forester.phylogeny.Phylogeny;
49 import org.forester.util.ForesterConstants;
50 import org.forester.util.ForesterUtil;
52 public abstract class MainFrame extends JFrame implements ActionListener {
54 static final String USE_MOUSEWHEEL_SHIFT_TO_ROTATE = "In this display type, use mousewheel + Shift to rotate [or A and S]";
55 static final String PHYLOXML_REF_TOOL_TIP = Constants.PHYLOXML_REFERENCE; //TODO //FIXME
56 static final String APTX_REF_TOOL_TIP = Constants.APTX_REFERENCE;
57 private static final long serialVersionUID = 3655000897845508358L;
58 final static Font menu_font = new Font( Configuration.getDefaultFontFamilyName(),
61 static final String TYPE_MENU_HEADER = "Type";
62 static final String RECTANGULAR_TYPE_CBMI_LABEL = "Rectangular";
63 static final String EURO_TYPE_CBMI_LABEL = "Euro Type";
64 static final String CURVED_TYPE_CBMI_LABEL = "Curved";
65 static final String TRIANGULAR_TYPE_CBMI_LABEL = "Triangular";
66 static final String CONVEX_TYPE_CBMI_LABEL = "Convex";
67 static final String ROUNDED_TYPE_CBMI_LABEL = "Rounded";
68 static final String UNROOTED_TYPE_CBMI_LABEL = "Unrooted (alpha)"; //TODO
69 static final String CIRCULAR_TYPE_CBMI_LABEL = "Circular (alpha)"; //TODO
70 static final String OPTIONS_HEADER = "Options";
71 static final String SEARCH_SUBHEADER = "Search:";
72 static final String DISPLAY_SUBHEADER = "Display:";
73 static final String SEARCH_TERMS_ONLY_LABEL = "Match Complete Terms Only";
74 static final String SEARCH_CASE_SENSITIVE_LABEL = "Case Sensitive";
75 static final String INVERSE_SEARCH_RESULT_LABEL = "Negate Result";
76 static final String DISPLAY_BRANCH_LENGTH_VALUES_LABEL = "Display Branch Length Values";
77 static final String DISPLAY_SCALE_LABEL = "Display Scale";
78 static final String NON_LINED_UP_CLADOGRAMS_LABEL = "Non-Lined Up Cladograms";
79 static final String UNIFORM_CLADOGRAMS_LABEL = "Total Node Sum Dependent Cladograms";
80 static final String LABEL_DIRECTION_LABEL = "Radial Labels";
81 static final String LABEL_DIRECTION_TIP = "To use radial node labels in radial and unrooted display types";
82 static final String SCREEN_ANTIALIAS_LABEL = "Antialias";
83 static final String COLOR_LABELS_LABEL = "Colorize Labels Same as Parent Branch";
84 static final String BG_GRAD_LABEL = "Background Color Gradient";
85 static final String DISPLAY_NODE_BOXES_LABEL = "Display Node Boxes";
86 static final String SHOW_OVERVIEW_LABEL = "Show Overview";
87 static final String FONT_SIZE_MENU_LABEL = "Font Size";
88 static final String NONUNIFORM_CLADOGRAMS_LABEL = "External Node Sum Dependent Cladograms";
89 static final String SHOW_DOMAIN_LABELS_LABEL = "Show Domain Labels";
90 static final String COLOR_LABELS_TIP = "To use parent branch colors for node labels as well, need to turn off taxonomy dependent colorization and turn on branch colorization for this to become apparent";
91 static final String ABBREV_SN_LABEL = "Abbreviate Scientific Taxonomic Names";
97 JMenu _font_size_menu;
99 JMenuItem[] _load_phylogeny_from_webservice_menu_items;
101 JMenuItem _open_item;
102 JMenuItem _open_url_item;
103 JMenuItem _save_item;
104 JMenuItem _save_all_item;
105 JMenuItem _close_item;
106 JMenuItem _exit_item;
109 JMenuItem _midpoint_root_item;
110 JMenuItem _taxcolor_item;
111 JMenuItem _confcolor_item;
112 JMenuItem _infer_common_sn_names_item;
113 JMenuItem _collapse_species_specific_subtrees;
114 JMenuItem _collapse_below_threshold; //TODO implememt me
115 JMenuItem _obtain_detailed_taxonomic_information_jmi;
116 JMenuItem _obtain_uniprot_seq_information_jmi;
117 JMenuItem _move_node_names_to_tax_sn_jmi;
118 JMenuItem _move_node_names_to_seq_names_jmi;
119 JMenuItem _extract_tax_code_from_node_names_jmi;
121 JMenuItem _super_tiny_fonts_item;
122 JMenuItem _tiny_fonts_item;
123 JMenuItem _small_fonts_item;
124 JMenuItem _medium_fonts_item;
125 JMenuItem _large_fonts_item;
127 // _ screen and print
128 JMenuItem _choose_font_mi;
129 JMenuItem _switch_colors_mi;
130 JCheckBoxMenuItem _label_direction_cbmi;
132 JCheckBoxMenuItem _screen_antialias_cbmi;
133 JCheckBoxMenuItem _background_gradient_cbmi;
134 JCheckBoxMenuItem _show_node_boxes_cbmi;
135 JRadioButtonMenuItem _non_lined_up_cladograms_rbmi;
136 JRadioButtonMenuItem _uniform_cladograms_rbmi;
137 JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi;
138 JCheckBoxMenuItem _show_branch_length_values_cbmi;
139 JCheckBoxMenuItem _show_scale_cbmi; //TODO fix me
140 JCheckBoxMenuItem _show_overview_cbmi;
141 JCheckBoxMenuItem _show_domain_labels;
142 JCheckBoxMenuItem _abbreviate_scientific_names;
143 JCheckBoxMenuItem _color_labels_same_as_parent_branch;
144 JMenuItem _overview_placment_mi;
145 JMenuItem _choose_minimal_confidence_mi;
147 JCheckBoxMenuItem _graphics_export_visible_only_cbmi;
148 JCheckBoxMenuItem _antialias_print_cbmi;
149 JCheckBoxMenuItem _print_black_and_white_cbmi;
150 JCheckBoxMenuItem _print_using_actual_size_cbmi;
151 JCheckBoxMenuItem _graphics_export_using_actual_size_cbmi;
152 JMenuItem _print_size_mi;
153 JMenuItem _choose_pdf_width_mi;
155 JCheckBoxMenuItem _internal_number_are_confidence_for_nh_parsing_cbmi;
156 JCheckBoxMenuItem _extract_pfam_style_tax_codes_cbmi;
157 JCheckBoxMenuItem _replace_underscores_cbmi;
159 JCheckBoxMenuItem _search_case_senstive_cbmi;
160 JCheckBoxMenuItem _search_whole_words_only_cbmi;
161 JCheckBoxMenuItem _inverse_search_result_cbmi;
164 JCheckBoxMenuItem _rectangular_type_cbmi;
165 JCheckBoxMenuItem _triangular_type_cbmi;
166 JCheckBoxMenuItem _curved_type_cbmi;
167 JCheckBoxMenuItem _convex_type_cbmi;
168 JCheckBoxMenuItem _euro_type_cbmi;
169 JCheckBoxMenuItem _rounded_type_cbmi;
170 JCheckBoxMenuItem _unrooted_type_cbmi;
171 JCheckBoxMenuItem _circular_type_cbmi;
172 // view as text menu:
173 JMenuItem _view_as_NH_item;
174 JMenuItem _view_as_NHX_item;
175 JMenuItem _view_as_XML_item;
176 JMenuItem _view_as_nexus_item;
177 JMenuItem _display_basic_information_item;
179 JMenuItem _about_item;
180 JMenuItem _help_item;
181 JMenuItem _website_item;
182 JMenuItem _phyloxml_website_item;
183 JMenuItem _phyloxml_ref_item;
184 JMenuItem _aptx_ref_item;
185 // Handy pointers to child components:
186 MainPanel _mainpanel;
187 Container _contentpane;
188 TextFrame _textframe;
189 Configuration _configuration;
190 JMenuItem _remove_branch_color_item;
194 // Empty constructor.
200 public void actionPerformed( final ActionEvent e ) {
201 final Object o = e.getSource();
202 boolean is_applet = false;
203 JApplet applet = null;
204 if ( getCurrentTreePanel() != null ) {
205 is_applet = getCurrentTreePanel().isApplet();
207 applet = getCurrentTreePanel().obtainApplet();
210 if ( o == _open_url_item ) {
211 readPhylogeniesFromURL();
213 else if ( o == _exit_item ) {
216 else if ( o == _taxcolor_item ) {
219 else if ( o == _confcolor_item ) {
222 else if ( o == _infer_common_sn_names_item ) {
223 if ( isSubtreeDisplayed() ) {
226 if ( getCurrentTreePanel() != null ) {
227 getCurrentTreePanel().inferCommonPartOfScientificNames();
230 else if ( o == _collapse_species_specific_subtrees ) {
231 if ( isSubtreeDisplayed() ) {
234 if ( getCurrentTreePanel() != null ) {
235 getCurrentTreePanel().collapseSpeciesSpecificSubtrees();
238 else if ( o == _remove_branch_color_item ) {
239 if ( isSubtreeDisplayed() ) {
242 removeBranchColors();
244 else if ( o == _midpoint_root_item ) {
245 if ( isSubtreeDisplayed() ) {
250 else if ( o == _switch_colors_mi ) {
253 else if ( o == _display_basic_information_item ) {
254 displayBasicInformation();
256 else if ( o == _view_as_NH_item ) {
259 else if ( o == _view_as_NHX_item ) {
262 else if ( o == _view_as_XML_item ) {
265 else if ( o == _view_as_nexus_item ) {
268 else if ( o == _super_tiny_fonts_item ) {
269 if ( getCurrentTreePanel() != null ) {
270 getCurrentTreePanel().setSuperTinyFonts();
271 getCurrentTreePanel().repaint();
274 else if ( o == _tiny_fonts_item ) {
275 if ( getCurrentTreePanel() != null ) {
276 getCurrentTreePanel().setTinyFonts();
277 getCurrentTreePanel().repaint();
280 else if ( o == _small_fonts_item ) {
281 if ( getCurrentTreePanel() != null ) {
282 getCurrentTreePanel().setSmallFonts();
283 getCurrentTreePanel().repaint();
286 else if ( o == _medium_fonts_item ) {
287 if ( getCurrentTreePanel() != null ) {
288 getCurrentTreePanel().setMediumFonts();
289 getCurrentTreePanel().repaint();
292 else if ( o == _large_fonts_item ) {
293 if ( getCurrentTreePanel() != null ) {
294 getCurrentTreePanel().setLargeFonts();
295 getCurrentTreePanel().repaint();
298 else if ( o == _choose_font_mi ) {
301 else if ( o == _choose_minimal_confidence_mi ) {
302 chooseMinimalConfidence();
304 else if ( o == _overview_placment_mi ) {
305 MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
307 else if ( o == _screen_antialias_cbmi ) {
308 updateOptions( getOptions() );
309 updateScreenTextAntialias( getMainPanel().getTreePanels() );
311 else if ( o == _background_gradient_cbmi ) {
312 updateOptions( getOptions() );
314 else if ( o == _show_domain_labels ) {
315 updateOptions( getOptions() );
317 else if ( o == _abbreviate_scientific_names ) {
318 updateOptions( getOptions() );
320 else if ( o == _color_labels_same_as_parent_branch ) {
321 updateOptions( getOptions() );
323 else if ( o == _show_node_boxes_cbmi ) {
324 updateOptions( getOptions() );
326 else if ( o == _non_lined_up_cladograms_rbmi ) {
327 updateOptions( getOptions() );
330 else if ( o == _uniform_cladograms_rbmi ) {
331 updateOptions( getOptions() );
334 else if ( o == _ext_node_dependent_cladogram_rbmi ) {
335 updateOptions( getOptions() );
338 else if ( o == _search_case_senstive_cbmi ) {
339 updateOptions( getOptions() );
340 getMainPanel().getControlPanel().search();
342 else if ( o == _search_whole_words_only_cbmi ) {
343 updateOptions( getOptions() );
344 getMainPanel().getControlPanel().search();
346 else if ( o == _inverse_search_result_cbmi ) {
347 updateOptions( getOptions() );
348 getMainPanel().getControlPanel().search();
350 else if ( o == _show_scale_cbmi ) {
351 updateOptions( getOptions() );
353 else if ( o == _show_branch_length_values_cbmi ) {
354 updateOptions( getOptions() );
356 else if ( o == _label_direction_cbmi ) {
357 updateOptions( getOptions() );
359 else if ( o == _show_overview_cbmi ) {
360 updateOptions( getOptions() );
361 if ( getCurrentTreePanel() != null ) {
362 getCurrentTreePanel().updateOvSizes();
365 else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
366 || ( o == _convex_type_cbmi ) || ( o == _euro_type_cbmi ) || ( o == _rounded_type_cbmi )
367 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
370 else if ( o == _about_item ) {
373 else if ( o == _help_item ) {
374 help( getConfiguration().getWebLinks() );
376 else if ( o == _website_item ) {
378 Util.openWebsite( Constants.APTX_WEB_SITE, is_applet, applet );
380 catch ( final IOException e1 ) {
381 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
384 else if ( o == _phyloxml_website_item ) {
386 Util.openWebsite( Constants.PHYLOXML_WEB_SITE, is_applet, applet );
388 catch ( final IOException e1 ) {
389 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
392 else if ( o == _aptx_ref_item ) {
394 Util.openWebsite( Constants.APTX_REFERENCE_URL, is_applet, applet );
396 catch ( final IOException e1 ) {
397 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
400 else if ( o == _phyloxml_ref_item ) {
402 Util.openWebsite( Constants.PHYLOXML_REFERENCE_URL, is_applet, applet );
404 catch ( final IOException e1 ) {
405 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
409 if ( _load_phylogeny_from_webservice_menu_items != null ) {
410 for( int i = 0; i < _load_phylogeny_from_webservice_menu_items.length; ++i ) {
411 if ( o == _load_phylogeny_from_webservice_menu_items[ i ] ) {
412 readPhylogeniesFromWebservice( i );
417 _contentpane.repaint();
420 boolean isSubtreeDisplayed() {
421 if ( getCurrentTreePanel() != null ) {
422 if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
424 .showMessageDialog( this,
425 "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",
426 "Operation can not be exectuted on a sub-tree",
427 JOptionPane.WARNING_MESSAGE );
434 void activateSaveAllIfNeeded() {
435 if ( ( getMainPanel().getTabbedPane() != null ) && ( getMainPanel().getTabbedPane().getTabCount() > 1 ) ) {
436 _save_all_item.setEnabled( true );
439 _save_all_item.setEnabled( false );
443 void buildFileMenu() {
444 _file_jmenu = createMenu( "File", getConfiguration() );
445 _file_jmenu.add( _open_url_item = new JMenuItem( "Read tree from URL/webservice..." ) );
446 _file_jmenu.addSeparator();
447 _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );
448 customizeJMenuItem( _open_url_item );
449 customizeJMenuItem( _exit_item );
450 _jmenubar.add( _file_jmenu );
453 void buildFontSizeMenu() {
454 _font_size_menu = createMenu( FONT_SIZE_MENU_LABEL, getConfiguration() );
455 _font_size_menu.add( _super_tiny_fonts_item = new JMenuItem( "Super Tiny Fonts" ) );
456 _font_size_menu.add( _tiny_fonts_item = new JMenuItem( "Tiny Fonts" ) );
457 _font_size_menu.add( _small_fonts_item = new JMenuItem( "Small Fonts" ) );
458 _font_size_menu.add( _medium_fonts_item = new JMenuItem( "Medium Fonts" ) );
459 _font_size_menu.add( _large_fonts_item = new JMenuItem( "Large Fonts" ) );
460 customizeJMenuItem( _super_tiny_fonts_item );
461 customizeJMenuItem( _tiny_fonts_item );
462 customizeJMenuItem( _small_fonts_item );
463 customizeJMenuItem( _medium_fonts_item );
464 customizeJMenuItem( _large_fonts_item );
465 _jmenubar.add( _font_size_menu );
468 void buildHelpMenu() {
469 _help_jmenu = createMenu( "Help", getConfiguration() );
470 _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
471 _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
472 _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
473 _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
474 _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
475 _help_jmenu.addSeparator();
476 _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
477 customizeJMenuItem( _help_item );
478 customizeJMenuItem( _website_item );
479 customizeJMenuItem( _phyloxml_website_item );
480 customizeJMenuItem( _aptx_ref_item );
481 customizeJMenuItem( _phyloxml_ref_item );
482 customizeJMenuItem( _about_item );
483 _phyloxml_ref_item.setToolTipText( PHYLOXML_REF_TOOL_TIP );
484 _aptx_ref_item.setToolTipText( APTX_REF_TOOL_TIP );
485 _jmenubar.add( _help_jmenu );
488 void buildTypeMenu() {
489 _type_menu = createMenu( TYPE_MENU_HEADER, getConfiguration() );
490 _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
491 _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
492 _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
493 _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
494 _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
495 _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
496 _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
497 _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
498 customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
499 customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
500 customizeCheckBoxMenuItem( _euro_type_cbmi, false );
501 customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
502 customizeCheckBoxMenuItem( _curved_type_cbmi, false );
503 customizeCheckBoxMenuItem( _convex_type_cbmi, false );
504 customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
505 customizeCheckBoxMenuItem( _circular_type_cbmi, false );
506 _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
507 _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
508 initializeTypeMenu( getOptions() );
509 _jmenubar.add( _type_menu );
512 void buildViewMenu() {
513 _view_jmenu = createMenu( "View", getConfiguration() );
514 _view_jmenu.add( _display_basic_information_item = new JMenuItem( "Display Basic Information" ) );
515 _view_jmenu.addSeparator();
516 _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) );
517 _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) );
518 _view_jmenu.add( _view_as_NHX_item = new JMenuItem( "View as NHX" ) );
519 _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "View as Nexus" ) );
520 customizeJMenuItem( _display_basic_information_item );
521 customizeJMenuItem( _view_as_NH_item );
522 customizeJMenuItem( _view_as_NHX_item );
523 customizeJMenuItem( _view_as_XML_item );
524 customizeJMenuItem( _view_as_nexus_item );
525 _jmenubar.add( _view_jmenu );
528 private void chooseFont() {
529 final FontChooser fc = new FontChooser();
530 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
531 fc.showDialog( this, "Select the Base Font" );
532 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
535 private void chooseMinimalConfidence() {
536 final String s = ( String ) JOptionPane
537 .showInputDialog( this,
538 "Please enter the minimum for confidence values to be displayed.\n"
539 + "[current value: " + getOptions().getMinConfidenceValue() + "]\n",
540 "Minimal Confidence Value",
541 JOptionPane.QUESTION_MESSAGE,
544 getOptions().getMinConfidenceValue() );
545 if ( !ForesterUtil.isEmpty( s ) ) {
546 boolean success = true;
548 final String m_str = s.trim();
549 if ( !ForesterUtil.isEmpty( m_str ) ) {
551 m = Double.parseDouble( m_str );
553 catch ( final Exception ex ) {
560 if ( success && ( m >= 0.0 ) ) {
561 getOptions().setMinConfidenceValue( m );
568 if ( _mainpanel != null ) {
569 _mainpanel.terminate();
571 if ( _contentpane != null ) {
572 _contentpane.removeAll();
579 if ( _mainpanel.getCurrentTreePanel() != null ) {
580 _mainpanel.getCurrentTreePanel().confColor();
584 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
585 if ( item != null ) {
586 item.setFont( MainFrame.menu_font );
587 if ( !getConfiguration().isUseNativeUI() ) {
588 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
589 item.setForeground( getConfiguration().getGuiMenuTextColor() );
591 item.setSelected( is_selected );
592 item.addActionListener( this );
596 void customizeJMenuItem( final JMenuItem jmi ) {
598 jmi.setFont( MainFrame.menu_font );
599 if ( !getConfiguration().isUseNativeUI() ) {
600 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
601 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
603 jmi.addActionListener( this );
607 void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
608 if ( item != null ) {
609 item.setFont( MainFrame.menu_font );
610 if ( !getConfiguration().isUseNativeUI() ) {
611 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
612 item.setForeground( getConfiguration().getGuiMenuTextColor() );
614 item.setSelected( is_selected );
615 item.addActionListener( this );
619 void exceptionOccuredDuringOpenFile( final Exception e ) {
621 _mainpanel.getCurrentTreePanel().setArrowCursor();
623 catch ( final Exception ex ) {
626 JOptionPane.showMessageDialog( this,
627 ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
628 "Error during File|Open",
629 JOptionPane.ERROR_MESSAGE );
632 void exceptionOccuredDuringSaveAs( final Exception e ) {
634 _mainpanel.getCurrentTreePanel().setArrowCursor();
636 catch ( final Exception ex ) {
639 JOptionPane.showMessageDialog( this, "Exception" + e, "Error during File|SaveAs", JOptionPane.ERROR_MESSAGE );
642 boolean GAndSDoHaveMoreThanOneSpeciesInComman( final Phylogeny gene_tree ) {
643 if ( ( gene_tree == null ) || gene_tree.isEmpty() ) {
644 JOptionPane.showMessageDialog( this,
645 "Gene tree and species tree have no species in common.",
647 JOptionPane.ERROR_MESSAGE );
650 else if ( gene_tree.getNumberOfExternalNodes() < 2 ) {
651 JOptionPane.showMessageDialog( this,
652 "Gene tree and species tree have only one species in common.",
654 JOptionPane.ERROR_MESSAGE );
662 public Configuration getConfiguration() {
663 return _configuration;
666 TreePanel getCurrentTreePanel() {
667 return getMainPanel().getCurrentTreePanel();
670 JMenu getHelpMenu() {
674 JCheckBoxMenuItem getlabelDirectionCbmi() {
675 return _label_direction_cbmi;
678 MainPanel getMainPanel() {
682 JMenuBar getMenuBarOfMainFrame() {
686 Options getOptions() {
690 void initializeTypeMenu( final Options options ) {
691 setTypeMenuToAllUnselected();
692 switch ( options.getPhylogenyGraphicsType() ) {
694 _convex_type_cbmi.setSelected( true );
697 _curved_type_cbmi.setSelected( true );
700 _euro_type_cbmi.setSelected( true );
703 _rounded_type_cbmi.setSelected( true );
706 _triangular_type_cbmi.setSelected( true );
709 _unrooted_type_cbmi.setSelected( true );
712 _circular_type_cbmi.setSelected( true );
715 _rectangular_type_cbmi.setSelected( true );
720 void midpointRoot() {
721 if ( _mainpanel.getCurrentTreePanel() != null ) {
722 _mainpanel.getCurrentTreePanel().midpointRoot();
726 abstract void readPhylogeniesFromURL();
728 void readPhylogeniesFromWebservice( final int i ) {
729 final UrlTreeReader reader = new UrlTreeReader( this, i );
730 new Thread( reader ).start();
733 private void removeBranchColors() {
734 if ( getMainPanel().getCurrentPhylogeny() != null ) {
735 Util.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
739 void removeTextFrame() {
740 if ( _textframe != null ) {
746 void setConfiguration( final Configuration configuration ) {
747 _configuration = configuration;
750 void setOptions( final Options options ) {
754 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
755 setTypeMenuToAllUnselected();
758 _circular_type_cbmi.setSelected( true );
761 _convex_type_cbmi.setSelected( true );
764 _curved_type_cbmi.setSelected( true );
767 _euro_type_cbmi.setSelected( true );
770 _rounded_type_cbmi.setSelected( true );
773 _rectangular_type_cbmi.setSelected( true );
776 _triangular_type_cbmi.setSelected( true );
779 _unrooted_type_cbmi.setSelected( true );
782 throw new IllegalArgumentException( "unknown type: " + type );
786 void setTypeMenuToAllUnselected() {
787 _convex_type_cbmi.setSelected( false );
788 _curved_type_cbmi.setSelected( false );
789 _euro_type_cbmi.setSelected( false );
790 _rounded_type_cbmi.setSelected( false );
791 _triangular_type_cbmi.setSelected( false );
792 _rectangular_type_cbmi.setSelected( false );
793 _unrooted_type_cbmi.setSelected( false );
794 _circular_type_cbmi.setSelected( false );
797 public void showWhole() {
798 _mainpanel.getControlPanel().showWhole();
801 void switchColors() {
802 final TreeColorSet colorset = _mainpanel.getTreeColorSet();
803 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
804 csc.setVisible( true );
808 if ( _mainpanel.getCurrentTreePanel() != null ) {
809 _mainpanel.getCurrentTreePanel().taxColor();
813 void typeChanged( final Object o ) {
814 updateTypeCheckboxes( getOptions(), o );
815 updateOptions( getOptions() );
816 if ( getCurrentTreePanel() != null ) {
817 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
818 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
819 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
820 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
821 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
822 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
823 getCurrentTreePanel().getControlPanel().showWhole();
825 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
826 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
829 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
831 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
832 updateScreenTextAntialias( getMainPanel().getTreePanels() );
833 if ( getCurrentTreePanel().getControlPanel().getDynamicallyHideData() != null ) {
834 if ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
835 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( false );
838 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( true );
844 void updateOptions( final Options options ) {
845 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
846 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
847 && _background_gradient_cbmi.isSelected() );
848 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
849 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
850 && _abbreviate_scientific_names.isSelected() );
851 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
852 && _color_labels_same_as_parent_branch.isSelected() );
854 //options.setShowNodeBoxes( ( _show_node_boxes_cbmi != null ) && _show_node_boxes_cbmi.isSelected() );
856 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
857 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
859 else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
860 options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
862 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
863 options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
865 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
866 && _search_case_senstive_cbmi.isSelected() );
867 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
868 options.setShowScale( _show_scale_cbmi.isSelected() );
870 if ( _label_direction_cbmi != null ) {
871 if ( _label_direction_cbmi.isSelected() ) {
872 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
875 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
878 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
879 if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
880 options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
882 options.setPrintUsingActualSize( ( _print_using_actual_size_cbmi != null )
883 && ( _print_using_actual_size_cbmi.isSelected() ) );
884 options.setGraphicsExportUsingActualSize( ( _graphics_export_using_actual_size_cbmi != null )
885 && ( _graphics_export_using_actual_size_cbmi.isSelected() ) );
886 options.setAntialiasPrint( ( _antialias_print_cbmi != null ) && _antialias_print_cbmi.isSelected() );
887 options.setPrintBlackAndWhite( ( _print_black_and_white_cbmi != null )
888 && _print_black_and_white_cbmi.isSelected() );
889 options.setInternalNumberAreConfidenceForNhParsing( ( _internal_number_are_confidence_for_nh_parsing_cbmi != null )
890 && _internal_number_are_confidence_for_nh_parsing_cbmi.isSelected() );
891 options.setExtractPfamTaxonomyCodesInNhParsing( ( _extract_pfam_style_tax_codes_cbmi != null )
892 && _extract_pfam_style_tax_codes_cbmi.isSelected() );
893 options.setReplaceUnderscoresInNhParsing( ( _replace_underscores_cbmi != null )
894 && _replace_underscores_cbmi.isSelected() );
895 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
896 && _search_whole_words_only_cbmi.isSelected() );
897 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
898 && _inverse_search_result_cbmi.isSelected() );
899 if ( _graphics_export_visible_only_cbmi != null ) {
900 options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() );
901 if ( _graphics_export_visible_only_cbmi.isSelected() && ( _graphics_export_using_actual_size_cbmi != null ) ) {
902 _graphics_export_using_actual_size_cbmi.setSelected( true );
903 _graphics_export_using_actual_size_cbmi.setEnabled( false );
906 _graphics_export_using_actual_size_cbmi.setEnabled( true );
909 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
910 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
912 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
913 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
915 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
916 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
918 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
919 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
921 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
922 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
924 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
925 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
927 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
928 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
930 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
931 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
935 void updateTypeCheckboxes( final Options options, final Object o ) {
936 setTypeMenuToAllUnselected();
937 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
940 void displayBasicInformation() {
941 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty() ) {
944 _textframe = TextFrame.instantiate( Util.crateBasicInformation( _mainpanel.getCurrentPhylogeny() ) );
949 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty()
950 || ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
953 _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny().toNexus() );
958 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty()
959 || ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
962 _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny().toNewHampshire( false ) );
967 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty()
968 || ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
971 _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny().toNewHampshireX() );
976 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty()
977 && ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() <= 10000 ) ) {
978 _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny().toPhyloXML( 0 ) );
983 * Display the about box.
985 static void about() {
986 final StringBuffer about = new StringBuffer( "Archaeopteryx\nVersion " + Constants.VERSION + "\n" );
987 about.append( "Copyright (C) 2007-2011 Christian Zmasek\n" );
988 about.append( "All Rights Reserved\n" );
989 about.append( "License: GNU Lesser General Public License (LGPL)\n" );
990 about.append( "Last modified: " + Constants.PRG_DATE + "\n" );
991 about.append( "phyloXML version : " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
992 about.append( "phyloXML location: " + ForesterConstants.PHYLO_XML_LOCATION + "\n" );
993 if ( !ForesterUtil.isEmpty( ForesterUtil.JAVA_VERSION ) && !ForesterUtil.isEmpty( ForesterUtil.JAVA_VENDOR ) ) {
994 about.append( "[your Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]\n" );
996 if ( !ForesterUtil.isEmpty( ForesterUtil.OS_NAME ) && !ForesterUtil.isEmpty( ForesterUtil.OS_ARCH )
997 && !ForesterUtil.isEmpty( ForesterUtil.OS_VERSION ) ) {
998 about.append( "[your OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " "
999 + ForesterUtil.OS_VERSION + "]\n" );
1001 final Runtime rt = java.lang.Runtime.getRuntime();
1002 final long free_memory = rt.freeMemory() / 1000000;
1003 final long total_memory = rt.totalMemory() / 1000000;
1004 about.append( "[free memory: " + free_memory + "MB, total memory: " + total_memory + "MB]\n" );
1005 about.append( "[locale: " + Locale.getDefault() + "]\n" );
1006 about.append( "References:\n" );
1007 about.append( Constants.PHYLOXML_REFERENCE_SHORT + "\n" );
1008 about.append( "For more information & download:\n" );
1009 about.append( Constants.APTX_WEB_SITE + "\n" );
1010 about.append( "Comments: " + Constants.AUTHOR_EMAIL );
1011 JOptionPane.showMessageDialog( null, about, Constants.PRG_NAME, JOptionPane.PLAIN_MESSAGE );
1014 static String createCurrentFontDesc( final TreeFontSet tree_font_set ) {
1015 return tree_font_set.getLargeFont().getFamily() + " " + tree_font_set.getLargeFont().getSize();
1018 static JMenu createMenu( final String title, final Configuration conf ) {
1019 final JMenu jmenu = new JMenu( title );
1020 if ( !conf.isUseNativeUI() ) {
1021 jmenu.setFont( MainFrame.menu_font );
1022 jmenu.setBackground( conf.getGuiMenuBackgroundColor() );
1023 jmenu.setForeground( conf.getGuiMenuTextColor() );
1028 static JMenuItem customizeMenuItemAsLabel( final JMenuItem label, final Configuration configuration ) {
1029 label.setFont( MainFrame.menu_font.deriveFont( Font.BOLD ) );
1030 if ( !configuration.isUseNativeUI() ) {
1031 label.setBackground( configuration.getGuiMenuBackgroundColor() );
1032 label.setForeground( configuration.getGuiMenuTextColor() );
1033 label.setOpaque( true );
1035 label.setSelected( false );
1036 label.setEnabled( false );
1040 static void cycleOverview( final Options op, final TreePanel tree_panel ) {
1041 switch ( op.getOvPlacement() ) {
1043 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1046 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1049 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1052 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1055 throw new RuntimeException( "unknown placement: " + op.getOvPlacement() );
1057 tree_panel.updateOvSettings();
1060 static void help( final Map<String, WebLink> weblinks ) {
1061 final StringBuilder sb = new StringBuilder();
1062 sb.append( "Display options\n" );
1063 sb.append( "-------------------\n" );
1064 sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
1065 sb.append( "Clickable tree nodes\n" );
1066 sb.append( "--------------------\n" );
1067 sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
1068 sb.append( "or by right clicking:\n" );
1069 sb.append( "o Display Node Data -- display information for a node\n" );
1070 sb.append( "o Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
1071 sb.append( "o Root/Reroot -- change tree root to clicked node\n" );
1072 sb.append( "o Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
1073 sb.append( "o Swap Descendants -- switch descendant on either side of clicked node\n" );
1074 sb.append( "o Colorize Subtree -- color a subtree\n" );
1075 sb.append( "o Open Sequence Web -- launch a web browser to display sequence information\n" );
1076 sb.append( "o Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
1077 sb.append( "- there may be additional choices depending on this particular setup\n\n" );
1078 sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
1079 sb.append( "Zooming\n" );
1080 sb.append( "---------\n" );
1081 sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
1082 sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
1083 sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
1084 sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
1085 sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
1086 sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
1087 sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
1088 sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
1089 sb.append( "Quick tree manipulation:\n" );
1090 sb.append( "------------------------\n" );
1091 sb.append( "Order Subtrees -- order the tree by branch length\n" );
1092 sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
1093 sb.append( "Memory problems (Java heap space error)\n" );
1094 sb.append( "---------------------------------------\n" );
1095 sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
1096 sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
1097 sb.append( "the '-Xmx' Java command line option. For example:\n" );
1098 sb.append( "java -Xms32m -Xmx256m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
1099 if ( ( weblinks != null ) && ( weblinks.size() > 0 ) ) {
1100 sb.append( "Active web links\n" );
1101 sb.append( "--------------------\n" );
1102 for( final String key : weblinks.keySet() ) {
1103 sb.append( " " + weblinks.get( key ).toString() + "\n" );
1106 // + "General remarks\n"
1107 // + "---------------\n"
1109 // "o The application version permits copying to the clipboard \n"
1111 // " in the \"View\"|\"View as ...\" frame (either by control-c or button press).\n"
1113 // "o Changes made to a subtree affect this subtree and its subtrees,\n"
1114 // + " but not any of its parent tree(s).\n"
1116 // "o Archaeopteryx tries to detect whether the numerical values in a NH tree\n"
1118 // " are likely to be bootstrap values instead of branch length values.\n\n"
1120 // " Remarks regarding SDI (Speciation Duplication Inference):\n"
1122 // "o Each external node of the gene tree (in display) needs to be associated with\n"
1124 // " a species: either directly through the \"Species\" field, or the species\n"
1126 // " is part of the sequence name in the form \"XXXX_SPECIES\"\n"
1128 // " (e.g. \"ACON_DROME\" or \"ACON_DROME/123-4489\" which is also acceptable).\n"
1130 // "o A species tree for each species of the gene tree needs to be loaded with\n"
1132 // " \"SDI\"|\"Load species tree\" prior the SDI execution.\n"
1134 // "o !External nodes of the gene tree associated with species not present in\n"
1136 // " the species tree are REMOVED prior to SDI execution!\n"
1138 // "o Both the gene tree and the species tree must be completely binary.\n"
1140 // "o Duplications and speciations are a function of the position of the root.\n"
1142 // " Hence, after each manual \"Root/Reroot\"ing some duplications will be\n"
1143 // + " incorrect and need to be inferred again\n"
1145 // " with: \"SDI\"|\"SDI (Speciation Duplication Inference)\n\n"
1147 sb.append( "phyloXML\n" );
1148 sb.append( "-------------------\n" );
1149 sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
1150 sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
1151 sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1153 sb.append( "For more information: http://www.phylosoft.org/archaeopteryx/\n" );
1154 sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
1155 TextFrame.instantiate( sb.toString() );
1158 static void setOvPlacementColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {
1159 if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {
1160 mi.setText( "Overview Placement... (current: " + tree_panel.getOptions().getOvPlacement() + ")" );
1163 mi.setText( "Overview Placement..." );
1167 static void setTextColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {
1168 if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {
1169 mi.setText( "Select Colors... (current: " + tree_panel.getTreeColorSet().getCurrentColorSchemeName() + ")" );
1172 mi.setText( "Select Colors..." );
1176 static void setTextForFontChooserMenuItem( final JMenuItem mi, final String font_desc ) {
1177 mi.setText( "Select Font... (current: " + font_desc + ")" );
1180 static void setTextMinSupportMenuItem( final JMenuItem mi, final Options options, final TreePanel current_tree_panel ) {
1181 if ( ( current_tree_panel == null ) || ( current_tree_panel.getPhylogeny() == null ) ) {
1182 mi.setEnabled( true );
1184 else if ( ForesterUtil.isHasAtLeastOneBranchWithSupportValues( current_tree_panel.getPhylogeny() ) ) {
1185 mi.setEnabled( true );
1188 mi.setEnabled( false );
1190 mi.setText( "Enter Min Confidence Value... (current: " + options.getMinConfidenceValue() + ")" );
1193 static void updateOptionsMenuDependingOnPhylogenyType( final MainPanel main_panel,
1194 final JCheckBoxMenuItem scale,
1195 final JCheckBoxMenuItem branch_lengths,
1196 final JRadioButtonMenuItem non_lined_up,
1197 final JRadioButtonMenuItem uniform_clado,
1198 final JRadioButtonMenuItem nonuniform_clado,
1199 final JCheckBoxMenuItem label_direction_cbmi ) {
1200 final TreePanel tree_panel = main_panel.getCurrentTreePanel();
1201 final ControlPanel control = main_panel.getControlPanel();
1202 final Options options = main_panel.getOptions();
1203 scale.setSelected( options.isShowScale() );
1204 branch_lengths.setSelected( options.isShowBranchLengthValues() );
1205 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1206 if ( ( tree_panel != null ) && ( !tree_panel.isPhyHasBranchLengths() ) ) {
1207 scale.setSelected( false );
1208 scale.setEnabled( false );
1209 branch_lengths.setSelected( false );
1210 branch_lengths.setEnabled( false );
1212 else if ( ( tree_panel != null ) && !control.isDrawPhylogram() ) {
1213 scale.setSelected( false );
1214 scale.setEnabled( false );
1215 branch_lengths.setEnabled( true );
1218 scale.setEnabled( true );
1219 branch_lengths.setEnabled( true );
1221 if ( ( tree_panel != null )
1222 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.ROUNDED )
1223 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1224 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1225 branch_lengths.setSelected( false );
1226 branch_lengths.setEnabled( false );
1228 if ( tree_panel != null ) {
1229 if ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1230 || ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
1231 non_lined_up.setEnabled( false );
1232 uniform_clado.setEnabled( false );
1233 nonuniform_clado.setEnabled( false );
1236 non_lined_up.setEnabled( true );
1237 uniform_clado.setEnabled( true );
1238 nonuniform_clado.setEnabled( true );
1242 if ( ( tree_panel != null )
1243 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1244 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1245 branch_lengths.setSelected( false );
1246 branch_lengths.setEnabled( false );
1248 if ( ( tree_panel != null )
1249 && ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( tree_panel
1250 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
1251 non_lined_up.setEnabled( false );
1254 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1255 non_lined_up.setEnabled( true );
1258 label_direction_cbmi.setEnabled( true );
1259 if ( tree_panel != null ) {
1260 if ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1261 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1262 label_direction_cbmi.setEnabled( false );
1264 if ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
1265 scale.setSelected( false );
1266 scale.setEnabled( false );
1271 static void updateScreenTextAntialias( final List<TreePanel> treepanels ) {
1272 for( final TreePanel tree_panel : treepanels ) {
1273 tree_panel.setTextAntialias();