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 _move_node_names_to_tax_sn_jmi;
117 JMenuItem _move_node_names_to_seq_names_jmi;
118 JMenuItem _extract_tax_code_from_node_names_jmi;
120 JMenuItem _super_tiny_fonts_item;
121 JMenuItem _tiny_fonts_item;
122 JMenuItem _small_fonts_item;
123 JMenuItem _medium_fonts_item;
124 JMenuItem _large_fonts_item;
126 // _ screen and print
127 JMenuItem _choose_font_mi;
128 JMenuItem _switch_colors_mi;
129 JCheckBoxMenuItem _label_direction_cbmi;
131 JCheckBoxMenuItem _screen_antialias_cbmi;
132 JCheckBoxMenuItem _background_gradient_cbmi;
133 JCheckBoxMenuItem _show_node_boxes_cbmi;
134 JRadioButtonMenuItem _non_lined_up_cladograms_rbmi;
135 JRadioButtonMenuItem _uniform_cladograms_rbmi;
136 JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi;
137 JCheckBoxMenuItem _show_branch_length_values_cbmi;
138 JCheckBoxMenuItem _show_scale_cbmi; //TODO fix me
139 JCheckBoxMenuItem _show_overview_cbmi;
140 JCheckBoxMenuItem _show_domain_labels;
141 JCheckBoxMenuItem _abbreviate_scientific_names;
142 JCheckBoxMenuItem _color_labels_same_as_parent_branch;
143 JMenuItem _overview_placment_mi;
144 JMenuItem _choose_minimal_confidence_mi;
146 JCheckBoxMenuItem _graphics_export_visible_only_cbmi;
147 JCheckBoxMenuItem _antialias_print_cbmi;
148 JCheckBoxMenuItem _print_black_and_white_cbmi;
149 JCheckBoxMenuItem _print_using_actual_size_cbmi;
150 JCheckBoxMenuItem _graphics_export_using_actual_size_cbmi;
151 JMenuItem _print_size_mi;
152 JMenuItem _choose_pdf_width_mi;
154 JCheckBoxMenuItem _internal_number_are_confidence_for_nh_parsing_cbmi;
155 JCheckBoxMenuItem _extract_pfam_style_tax_codes_cbmi;
156 JCheckBoxMenuItem _replace_underscores_cbmi;
158 JCheckBoxMenuItem _search_case_senstive_cbmi;
159 JCheckBoxMenuItem _search_whole_words_only_cbmi;
160 JCheckBoxMenuItem _inverse_search_result_cbmi;
163 JCheckBoxMenuItem _rectangular_type_cbmi;
164 JCheckBoxMenuItem _triangular_type_cbmi;
165 JCheckBoxMenuItem _curved_type_cbmi;
166 JCheckBoxMenuItem _convex_type_cbmi;
167 JCheckBoxMenuItem _euro_type_cbmi;
168 JCheckBoxMenuItem _rounded_type_cbmi;
169 JCheckBoxMenuItem _unrooted_type_cbmi;
170 JCheckBoxMenuItem _circular_type_cbmi;
171 // view as text menu:
172 JMenuItem _view_as_NH_item;
173 JMenuItem _view_as_NHX_item;
174 JMenuItem _view_as_XML_item;
175 JMenuItem _view_as_nexus_item;
176 JMenuItem _display_basic_information_item;
178 JMenuItem _about_item;
179 JMenuItem _help_item;
180 JMenuItem _website_item;
181 JMenuItem _phyloxml_website_item;
182 JMenuItem _phyloxml_ref_item;
183 JMenuItem _aptx_ref_item;
184 // Handy pointers to child components:
185 MainPanel _mainpanel;
186 Container _contentpane;
187 TextFrame _textframe;
188 Configuration _configuration;
189 JMenuItem _remove_branch_color_item;
193 // Empty constructor.
199 public void actionPerformed( final ActionEvent e ) {
200 final Object o = e.getSource();
201 boolean is_applet = false;
202 JApplet applet = null;
203 if ( getCurrentTreePanel() != null ) {
204 is_applet = getCurrentTreePanel().isApplet();
206 applet = getCurrentTreePanel().obtainApplet();
209 if ( o == _open_url_item ) {
210 readPhylogeniesFromURL();
212 else if ( o == _exit_item ) {
215 else if ( o == _taxcolor_item ) {
218 else if ( o == _confcolor_item ) {
221 else if ( o == _infer_common_sn_names_item ) {
222 if ( isSubtreeDisplayed() ) {
225 if ( getCurrentTreePanel() != null ) {
226 getCurrentTreePanel().inferCommonPartOfScientificNames();
229 else if ( o == _collapse_species_specific_subtrees ) {
230 if ( isSubtreeDisplayed() ) {
233 if ( getCurrentTreePanel() != null ) {
234 getCurrentTreePanel().collapseSpeciesSpecificSubtrees();
237 else if ( o == _remove_branch_color_item ) {
238 if ( isSubtreeDisplayed() ) {
241 removeBranchColors();
243 else if ( o == _midpoint_root_item ) {
244 if ( isSubtreeDisplayed() ) {
249 else if ( o == _switch_colors_mi ) {
252 else if ( o == _display_basic_information_item ) {
253 displayBasicInformation();
255 else if ( o == _view_as_NH_item ) {
258 else if ( o == _view_as_NHX_item ) {
261 else if ( o == _view_as_XML_item ) {
264 else if ( o == _view_as_nexus_item ) {
267 else if ( o == _super_tiny_fonts_item ) {
268 if ( getCurrentTreePanel() != null ) {
269 getCurrentTreePanel().setSuperTinyFonts();
270 getCurrentTreePanel().repaint();
273 else if ( o == _tiny_fonts_item ) {
274 if ( getCurrentTreePanel() != null ) {
275 getCurrentTreePanel().setTinyFonts();
276 getCurrentTreePanel().repaint();
279 else if ( o == _small_fonts_item ) {
280 if ( getCurrentTreePanel() != null ) {
281 getCurrentTreePanel().setSmallFonts();
282 getCurrentTreePanel().repaint();
285 else if ( o == _medium_fonts_item ) {
286 if ( getCurrentTreePanel() != null ) {
287 getCurrentTreePanel().setMediumFonts();
288 getCurrentTreePanel().repaint();
291 else if ( o == _large_fonts_item ) {
292 if ( getCurrentTreePanel() != null ) {
293 getCurrentTreePanel().setLargeFonts();
294 getCurrentTreePanel().repaint();
297 else if ( o == _choose_font_mi ) {
300 else if ( o == _choose_minimal_confidence_mi ) {
301 chooseMinimalConfidence();
303 else if ( o == _overview_placment_mi ) {
304 MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
306 else if ( o == _screen_antialias_cbmi ) {
307 updateOptions( getOptions() );
308 updateScreenTextAntialias( getMainPanel().getTreePanels() );
310 else if ( o == _background_gradient_cbmi ) {
311 updateOptions( getOptions() );
313 else if ( o == _show_domain_labels ) {
314 updateOptions( getOptions() );
316 else if ( o == _abbreviate_scientific_names ) {
317 updateOptions( getOptions() );
319 else if ( o == _color_labels_same_as_parent_branch ) {
320 updateOptions( getOptions() );
322 else if ( o == _show_node_boxes_cbmi ) {
323 updateOptions( getOptions() );
325 else if ( o == _non_lined_up_cladograms_rbmi ) {
326 updateOptions( getOptions() );
329 else if ( o == _uniform_cladograms_rbmi ) {
330 updateOptions( getOptions() );
333 else if ( o == _ext_node_dependent_cladogram_rbmi ) {
334 updateOptions( getOptions() );
337 else if ( o == _search_case_senstive_cbmi ) {
338 updateOptions( getOptions() );
339 getMainPanel().getControlPanel().search();
341 else if ( o == _search_whole_words_only_cbmi ) {
342 updateOptions( getOptions() );
343 getMainPanel().getControlPanel().search();
345 else if ( o == _inverse_search_result_cbmi ) {
346 updateOptions( getOptions() );
347 getMainPanel().getControlPanel().search();
349 else if ( o == _show_scale_cbmi ) {
350 updateOptions( getOptions() );
352 else if ( o == _show_branch_length_values_cbmi ) {
353 updateOptions( getOptions() );
355 else if ( o == _label_direction_cbmi ) {
356 updateOptions( getOptions() );
358 else if ( o == _show_overview_cbmi ) {
359 updateOptions( getOptions() );
360 if ( getCurrentTreePanel() != null ) {
361 getCurrentTreePanel().updateOvSizes();
364 else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
365 || ( o == _convex_type_cbmi ) || ( o == _euro_type_cbmi ) || ( o == _rounded_type_cbmi )
366 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
369 else if ( o == _about_item ) {
372 else if ( o == _help_item ) {
373 help( getConfiguration().getWebLinks() );
375 else if ( o == _website_item ) {
377 Util.openWebsite( Constants.APTX_WEB_SITE, is_applet, applet );
379 catch ( final IOException e1 ) {
380 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
383 else if ( o == _phyloxml_website_item ) {
385 Util.openWebsite( Constants.PHYLOXML_WEB_SITE, is_applet, applet );
387 catch ( final IOException e1 ) {
388 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
391 else if ( o == _aptx_ref_item ) {
393 Util.openWebsite( Constants.APTX_REFERENCE_URL, is_applet, applet );
395 catch ( final IOException e1 ) {
396 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
399 else if ( o == _phyloxml_ref_item ) {
401 Util.openWebsite( Constants.PHYLOXML_REFERENCE_URL, is_applet, applet );
403 catch ( final IOException e1 ) {
404 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
408 if ( _load_phylogeny_from_webservice_menu_items != null ) {
409 for( int i = 0; i < _load_phylogeny_from_webservice_menu_items.length; ++i ) {
410 if ( o == _load_phylogeny_from_webservice_menu_items[ i ] ) {
411 readPhylogeniesFromWebservice( i );
416 _contentpane.repaint();
419 boolean isSubtreeDisplayed() {
420 if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
422 .showMessageDialog( this,
423 "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",
424 "Operation can not be exectuted on a sub-tree",
425 JOptionPane.WARNING_MESSAGE );
431 void activateSaveAllIfNeeded() {
432 if ( ( getMainPanel().getTabbedPane() != null ) && ( getMainPanel().getTabbedPane().getTabCount() > 1 ) ) {
433 _save_all_item.setEnabled( true );
436 _save_all_item.setEnabled( false );
440 void buildFileMenu() {
441 _file_jmenu = createMenu( "File", getConfiguration() );
442 _file_jmenu.add( _open_url_item = new JMenuItem( "Read tree from URL/webservice..." ) );
443 _file_jmenu.addSeparator();
444 _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );
445 customizeJMenuItem( _open_url_item );
446 customizeJMenuItem( _exit_item );
447 _jmenubar.add( _file_jmenu );
450 void buildFontSizeMenu() {
451 _font_size_menu = createMenu( FONT_SIZE_MENU_LABEL, getConfiguration() );
452 _font_size_menu.add( _super_tiny_fonts_item = new JMenuItem( "Super Tiny Fonts" ) );
453 _font_size_menu.add( _tiny_fonts_item = new JMenuItem( "Tiny Fonts" ) );
454 _font_size_menu.add( _small_fonts_item = new JMenuItem( "Small Fonts" ) );
455 _font_size_menu.add( _medium_fonts_item = new JMenuItem( "Medium Fonts" ) );
456 _font_size_menu.add( _large_fonts_item = new JMenuItem( "Large Fonts" ) );
457 customizeJMenuItem( _super_tiny_fonts_item );
458 customizeJMenuItem( _tiny_fonts_item );
459 customizeJMenuItem( _small_fonts_item );
460 customizeJMenuItem( _medium_fonts_item );
461 customizeJMenuItem( _large_fonts_item );
462 _jmenubar.add( _font_size_menu );
465 void buildHelpMenu() {
466 _help_jmenu = createMenu( "Help", getConfiguration() );
467 _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
468 _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
469 _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
470 _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
471 _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
472 _help_jmenu.addSeparator();
473 _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
474 customizeJMenuItem( _help_item );
475 customizeJMenuItem( _website_item );
476 customizeJMenuItem( _phyloxml_website_item );
477 customizeJMenuItem( _aptx_ref_item );
478 customizeJMenuItem( _phyloxml_ref_item );
479 customizeJMenuItem( _about_item );
480 _phyloxml_ref_item.setToolTipText( PHYLOXML_REF_TOOL_TIP );
481 _aptx_ref_item.setToolTipText( APTX_REF_TOOL_TIP );
482 _jmenubar.add( _help_jmenu );
485 void buildTypeMenu() {
486 _type_menu = createMenu( TYPE_MENU_HEADER, getConfiguration() );
487 _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
488 _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
489 _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
490 _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
491 _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
492 _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
493 _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
494 _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
495 customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
496 customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
497 customizeCheckBoxMenuItem( _euro_type_cbmi, false );
498 customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
499 customizeCheckBoxMenuItem( _curved_type_cbmi, false );
500 customizeCheckBoxMenuItem( _convex_type_cbmi, false );
501 customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
502 customizeCheckBoxMenuItem( _circular_type_cbmi, false );
503 _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
504 _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
505 initializeTypeMenu( getOptions() );
506 _jmenubar.add( _type_menu );
509 void buildViewMenu() {
510 _view_jmenu = createMenu( "View", getConfiguration() );
511 _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) );
512 _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) );
513 _view_jmenu.add( _view_as_NHX_item = new JMenuItem( "View as NHX" ) );
514 _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "View as Nexus" ) );
515 _view_jmenu.add( _display_basic_information_item = new JMenuItem( "Display Basic Information" ) );
516 customizeJMenuItem( _display_basic_information_item );
517 customizeJMenuItem( _view_as_NH_item );
518 customizeJMenuItem( _view_as_NHX_item );
519 customizeJMenuItem( _view_as_XML_item );
520 customizeJMenuItem( _view_as_nexus_item );
521 _jmenubar.add( _view_jmenu );
524 private void chooseFont() {
525 final FontChooser fc = new FontChooser();
526 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
527 fc.showDialog( this, "Select the Base Font" );
528 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
531 private void chooseMinimalConfidence() {
532 final String s = ( String ) JOptionPane
533 .showInputDialog( this,
534 "Please enter the minimum for confidence values to be displayed.\n"
535 + "[current value: " + getOptions().getMinConfidenceValue() + "]\n",
536 "Minimal Confidence Value",
537 JOptionPane.QUESTION_MESSAGE,
540 getOptions().getMinConfidenceValue() );
541 if ( !ForesterUtil.isEmpty( s ) ) {
542 boolean success = true;
544 final String m_str = s.trim();
545 if ( !ForesterUtil.isEmpty( m_str ) ) {
547 m = Double.parseDouble( m_str );
549 catch ( final Exception ex ) {
556 if ( success && ( m >= 0.0 ) ) {
557 getOptions().setMinConfidenceValue( m );
564 if ( _mainpanel != null ) {
565 _mainpanel.terminate();
567 if ( _contentpane != null ) {
568 _contentpane.removeAll();
575 if ( _mainpanel.getCurrentTreePanel() != null ) {
576 _mainpanel.getCurrentTreePanel().confColor();
580 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
581 if ( item != null ) {
582 item.setFont( MainFrame.menu_font );
583 if ( !getConfiguration().isUseNativeUI() ) {
584 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
585 item.setForeground( getConfiguration().getGuiMenuTextColor() );
587 item.setSelected( is_selected );
588 item.addActionListener( this );
592 void customizeJMenuItem( final JMenuItem jmi ) {
594 jmi.setFont( MainFrame.menu_font );
595 if ( !getConfiguration().isUseNativeUI() ) {
596 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
597 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
599 jmi.addActionListener( this );
603 void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
604 if ( item != null ) {
605 item.setFont( MainFrame.menu_font );
606 if ( !getConfiguration().isUseNativeUI() ) {
607 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
608 item.setForeground( getConfiguration().getGuiMenuTextColor() );
610 item.setSelected( is_selected );
611 item.addActionListener( this );
615 void exceptionOccuredDuringOpenFile( final Exception e ) {
617 _mainpanel.getCurrentTreePanel().setArrowCursor();
619 catch ( final Exception ex ) {
622 JOptionPane.showMessageDialog( this,
623 ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
624 "Error during File|Open",
625 JOptionPane.ERROR_MESSAGE );
628 void exceptionOccuredDuringSaveAs( final Exception e ) {
630 _mainpanel.getCurrentTreePanel().setArrowCursor();
632 catch ( final Exception ex ) {
635 JOptionPane.showMessageDialog( this, "Exception" + e, "Error during File|SaveAs", JOptionPane.ERROR_MESSAGE );
638 boolean GAndSDoHaveMoreThanOneSpeciesInComman( final Phylogeny gene_tree ) {
639 if ( ( gene_tree == null ) || gene_tree.isEmpty() ) {
640 JOptionPane.showMessageDialog( this,
641 "Gene tree and species tree have no species in common.",
643 JOptionPane.ERROR_MESSAGE );
646 else if ( gene_tree.getNumberOfExternalNodes() < 2 ) {
647 JOptionPane.showMessageDialog( this,
648 "Gene tree and species tree have only one species in common.",
650 JOptionPane.ERROR_MESSAGE );
658 Configuration getConfiguration() {
659 return _configuration;
662 TreePanel getCurrentTreePanel() {
663 return getMainPanel().getCurrentTreePanel();
666 JMenu getHelpMenu() {
670 JCheckBoxMenuItem getlabelDirectionCbmi() {
671 return _label_direction_cbmi;
674 MainPanel getMainPanel() {
678 JMenuBar getMenuBarOfMainFrame() {
682 Options getOptions() {
686 void initializeTypeMenu( final Options options ) {
687 setTypeMenuToAllUnselected();
688 switch ( options.getPhylogenyGraphicsType() ) {
690 _convex_type_cbmi.setSelected( true );
693 _curved_type_cbmi.setSelected( true );
696 _euro_type_cbmi.setSelected( true );
699 _rounded_type_cbmi.setSelected( true );
702 _triangular_type_cbmi.setSelected( true );
705 _unrooted_type_cbmi.setSelected( true );
708 _circular_type_cbmi.setSelected( true );
711 _rectangular_type_cbmi.setSelected( true );
716 void midpointRoot() {
717 if ( _mainpanel.getCurrentTreePanel() != null ) {
718 _mainpanel.getCurrentTreePanel().midpointRoot();
722 abstract void readPhylogeniesFromURL();
724 void readPhylogeniesFromWebservice( final int i ) {
725 final UrlTreeReader reader = new UrlTreeReader( this, i );
726 new Thread( reader ).start();
729 private void removeBranchColors() {
730 if ( getMainPanel().getCurrentPhylogeny() != null ) {
731 Util.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
735 void removeTextFrame() {
736 if ( _textframe != null ) {
742 void setConfiguration( final Configuration configuration ) {
743 _configuration = configuration;
746 void setOptions( final Options options ) {
750 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
751 setTypeMenuToAllUnselected();
754 _circular_type_cbmi.setSelected( true );
757 _convex_type_cbmi.setSelected( true );
760 _curved_type_cbmi.setSelected( true );
763 _euro_type_cbmi.setSelected( true );
766 _rounded_type_cbmi.setSelected( true );
769 _rectangular_type_cbmi.setSelected( true );
772 _triangular_type_cbmi.setSelected( true );
775 _unrooted_type_cbmi.setSelected( true );
778 throw new IllegalArgumentException( "unknown type: " + type );
782 void setTypeMenuToAllUnselected() {
783 _convex_type_cbmi.setSelected( false );
784 _curved_type_cbmi.setSelected( false );
785 _euro_type_cbmi.setSelected( false );
786 _rounded_type_cbmi.setSelected( false );
787 _triangular_type_cbmi.setSelected( false );
788 _rectangular_type_cbmi.setSelected( false );
789 _unrooted_type_cbmi.setSelected( false );
790 _circular_type_cbmi.setSelected( false );
794 _mainpanel.getControlPanel().showWhole();
797 void switchColors() {
798 final TreeColorSet colorset = _mainpanel.getTreeColorSet();
799 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
800 csc.setVisible( true );
804 if ( _mainpanel.getCurrentTreePanel() != null ) {
805 _mainpanel.getCurrentTreePanel().taxColor();
809 void typeChanged( final Object o ) {
810 updateTypeCheckboxes( getOptions(), o );
811 updateOptions( getOptions() );
812 if ( getCurrentTreePanel() != null ) {
813 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
814 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
815 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
816 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
817 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
818 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
819 getCurrentTreePanel().getControlPanel().showWhole();
821 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
822 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
825 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
827 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
828 updateScreenTextAntialias( getMainPanel().getTreePanels() );
829 if ( getCurrentTreePanel().getControlPanel().getDynamicallyHideData() != null ) {
830 if ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
831 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( false );
834 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( true );
840 void updateOptions( final Options options ) {
841 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
842 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
843 && _background_gradient_cbmi.isSelected() );
844 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
845 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
846 && _abbreviate_scientific_names.isSelected() );
847 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
848 && _color_labels_same_as_parent_branch.isSelected() );
849 options.setShowNodeBoxes( ( _show_node_boxes_cbmi != null ) && _show_node_boxes_cbmi.isSelected() );
850 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
851 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
853 else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
854 options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
856 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
857 options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
859 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
860 && _search_case_senstive_cbmi.isSelected() );
861 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
862 options.setShowScale( _show_scale_cbmi.isSelected() );
864 if ( _label_direction_cbmi != null ) {
865 if ( _label_direction_cbmi.isSelected() ) {
866 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
869 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
872 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
873 if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
874 options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
876 options.setPrintUsingActualSize( ( _print_using_actual_size_cbmi != null )
877 && ( _print_using_actual_size_cbmi.isSelected() ) );
878 options.setGraphicsExportUsingActualSize( ( _graphics_export_using_actual_size_cbmi != null )
879 && ( _graphics_export_using_actual_size_cbmi.isSelected() ) );
880 options.setAntialiasPrint( ( _antialias_print_cbmi != null ) && _antialias_print_cbmi.isSelected() );
881 options.setPrintBlackAndWhite( ( _print_black_and_white_cbmi != null )
882 && _print_black_and_white_cbmi.isSelected() );
883 options.setInternalNumberAreConfidenceForNhParsing( ( _internal_number_are_confidence_for_nh_parsing_cbmi != null )
884 && _internal_number_are_confidence_for_nh_parsing_cbmi.isSelected() );
885 options.setExtractPfamTaxonomyCodesInNhParsing( ( _extract_pfam_style_tax_codes_cbmi != null )
886 && _extract_pfam_style_tax_codes_cbmi.isSelected() );
887 options.setReplaceUnderscoresInNhParsing( ( _replace_underscores_cbmi != null )
888 && _replace_underscores_cbmi.isSelected() );
889 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
890 && _search_whole_words_only_cbmi.isSelected() );
891 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
892 && _inverse_search_result_cbmi.isSelected() );
893 if ( _graphics_export_visible_only_cbmi != null ) {
894 options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() );
895 if ( _graphics_export_visible_only_cbmi.isSelected() && ( _graphics_export_using_actual_size_cbmi != null ) ) {
896 _graphics_export_using_actual_size_cbmi.setSelected( true );
897 _graphics_export_using_actual_size_cbmi.setEnabled( false );
900 _graphics_export_using_actual_size_cbmi.setEnabled( true );
903 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
904 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
906 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
907 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
909 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
910 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
912 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
913 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
915 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
916 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
918 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
919 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
921 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
922 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
924 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
925 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
929 void updateTypeCheckboxes( final Options options, final Object o ) {
930 setTypeMenuToAllUnselected();
931 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
934 void displayBasicInformation() {
935 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty() ) {
938 _textframe = TextFrame.instantiate( Util.crateBasicInformation( _mainpanel.getCurrentPhylogeny() ) );
943 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty()
944 || ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
947 _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny().toNexus() );
952 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty()
953 || ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
956 _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny().toNewHampshire( false ) );
961 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty()
962 || ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
965 _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny().toNewHampshireX() );
970 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty()
971 && ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() <= 10000 ) ) {
972 _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny().toPhyloXML( 0 ) );
977 * Display the about box.
979 static void about() {
980 final StringBuffer about = new StringBuffer( "Archaeopteryx\nVersion " + Constants.VERSION + "\n" );
981 about.append( "Copyright (C) 2007-2011 Christian Zmasek\n" );
982 about.append( "All Rights Reserved\n" );
983 about.append( "License: GNU Lesser General Public License (LGPL)\n" );
984 about.append( "Last modified: " + Constants.PRG_DATE + "\n" );
985 about.append( "phyloXML version : " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
986 about.append( "phyloXML location: " + ForesterConstants.PHYLO_XML_LOCATION + "\n" );
987 if ( !ForesterUtil.isEmpty( ForesterUtil.JAVA_VERSION ) && !ForesterUtil.isEmpty( ForesterUtil.JAVA_VENDOR ) ) {
988 about.append( "[your Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]\n" );
990 if ( !ForesterUtil.isEmpty( ForesterUtil.OS_NAME ) && !ForesterUtil.isEmpty( ForesterUtil.OS_ARCH )
991 && !ForesterUtil.isEmpty( ForesterUtil.OS_VERSION ) ) {
992 about.append( "[your OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " "
993 + ForesterUtil.OS_VERSION + "]\n" );
995 final Runtime rt = java.lang.Runtime.getRuntime();
996 final long free_memory = rt.freeMemory() / 1000000;
997 final long total_memory = rt.totalMemory() / 1000000;
998 about.append( "[free memory: " + free_memory + "MB, total memory: " + total_memory + "MB]\n" );
999 about.append( "[locale: " + Locale.getDefault() + "]\n" );
1000 about.append( "References:\n" );
1001 about.append( Constants.PHYLOXML_REFERENCE_SHORT + "\n" );
1002 about.append( "For more information & download:\n" );
1003 about.append( Constants.APTX_WEB_SITE + "\n" );
1004 about.append( "Comments: " + Constants.AUTHOR_EMAIL );
1005 JOptionPane.showMessageDialog( null, about, Constants.PRG_NAME, JOptionPane.PLAIN_MESSAGE );
1008 static String createCurrentFontDesc( final TreeFontSet tree_font_set ) {
1009 return tree_font_set.getLargeFont().getFamily() + " " + tree_font_set.getLargeFont().getSize();
1012 static JMenu createMenu( final String title, final Configuration conf ) {
1013 final JMenu jmenu = new JMenu( title );
1014 if ( !conf.isUseNativeUI() ) {
1015 jmenu.setFont( MainFrame.menu_font );
1016 jmenu.setBackground( conf.getGuiMenuBackgroundColor() );
1017 jmenu.setForeground( conf.getGuiMenuTextColor() );
1022 static JMenuItem customizeMenuItemAsLabel( final JMenuItem label, final Configuration configuration ) {
1023 label.setFont( MainFrame.menu_font.deriveFont( Font.BOLD ) );
1024 if ( !configuration.isUseNativeUI() ) {
1025 label.setBackground( configuration.getGuiMenuBackgroundColor() );
1026 label.setForeground( configuration.getGuiMenuTextColor() );
1027 label.setOpaque( true );
1029 label.setSelected( false );
1030 label.setEnabled( false );
1034 static void cycleOverview( final Options op, final TreePanel tree_panel ) {
1035 switch ( op.getOvPlacement() ) {
1037 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1040 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1043 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1046 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1049 throw new RuntimeException( "unknown placement: " + op.getOvPlacement() );
1051 tree_panel.updateOvSettings();
1054 static void help( final Map<String, WebLink> weblinks ) {
1055 final StringBuilder sb = new StringBuilder();
1056 sb.append( "Display options\n" );
1057 sb.append( "-------------------\n" );
1058 sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
1059 sb.append( "Clickable tree nodes\n" );
1060 sb.append( "--------------------\n" );
1061 sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
1062 sb.append( "or by right clicking:\n" );
1063 sb.append( "o Display Node Data -- display information for a node\n" );
1064 sb.append( "o Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
1065 sb.append( "o Root/Reroot -- change tree root to clicked node\n" );
1066 sb.append( "o Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
1067 sb.append( "o Swap Descendants -- switch descendant on either side of clicked node\n" );
1068 sb.append( "o Colorize Subtree -- color a subtree\n" );
1069 sb.append( "o Open Sequence Web -- launch a web browser to display sequence information\n" );
1070 sb.append( "o Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
1071 sb.append( "- there may be additional choices depending on this particular setup\n\n" );
1072 sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
1073 sb.append( "Zooming\n" );
1074 sb.append( "---------\n" );
1075 sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
1076 sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
1077 sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
1078 sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
1079 sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
1080 sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
1081 sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
1082 sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
1083 sb.append( "Quick tree manipulation:\n" );
1084 sb.append( "------------------------\n" );
1085 sb.append( "Order Subtrees -- order the tree by branch length\n" );
1086 sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
1087 sb.append( "Memory problems (Java heap space error)\n" );
1088 sb.append( "---------------------------------------\n" );
1089 sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
1090 sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
1091 sb.append( "the '-Xmx' Java command line option. For example:\n" );
1092 sb.append( "java -Xms32m -Xmx256m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
1093 if ( ( weblinks != null ) && ( weblinks.size() > 0 ) ) {
1094 sb.append( "Active web links\n" );
1095 sb.append( "--------------------\n" );
1096 for( final String key : weblinks.keySet() ) {
1097 sb.append( " " + weblinks.get( key ).toString() + "\n" );
1100 // + "General remarks\n"
1101 // + "---------------\n"
1103 // "o The application version permits copying to the clipboard \n"
1105 // " in the \"View\"|\"View as ...\" frame (either by control-c or button press).\n"
1107 // "o Changes made to a subtree affect this subtree and its subtrees,\n"
1108 // + " but not any of its parent tree(s).\n"
1110 // "o Archaeopteryx tries to detect whether the numerical values in a NH tree\n"
1112 // " are likely to be bootstrap values instead of branch length values.\n\n"
1114 // " Remarks regarding SDI (Speciation Duplication Inference):\n"
1116 // "o Each external node of the gene tree (in display) needs to be associated with\n"
1118 // " a species: either directly through the \"Species\" field, or the species\n"
1120 // " is part of the sequence name in the form \"XXXX_SPECIES\"\n"
1122 // " (e.g. \"ACON_DROME\" or \"ACON_DROME/123-4489\" which is also acceptable).\n"
1124 // "o A species tree for each species of the gene tree needs to be loaded with\n"
1126 // " \"SDI\"|\"Load species tree\" prior the SDI execution.\n"
1128 // "o !External nodes of the gene tree associated with species not present in\n"
1130 // " the species tree are REMOVED prior to SDI execution!\n"
1132 // "o Both the gene tree and the species tree must be completely binary.\n"
1134 // "o Duplications and speciations are a function of the position of the root.\n"
1136 // " Hence, after each manual \"Root/Reroot\"ing some duplications will be\n"
1137 // + " incorrect and need to be inferred again\n"
1139 // " with: \"SDI\"|\"SDI (Speciation Duplication Inference)\n\n"
1141 sb.append( "phyloXML\n" );
1142 sb.append( "-------------------\n" );
1143 sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
1144 sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
1145 sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1147 sb.append( "For more information: http://www.phylosoft.org/archaeopteryx/\n" );
1148 sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
1149 TextFrame.instantiate( sb.toString() );
1152 static void setOvPlacementColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {
1153 if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {
1154 mi.setText( "Overview Placement... (current: " + tree_panel.getOptions().getOvPlacement() + ")" );
1157 mi.setText( "Overview Placement..." );
1161 static void setTextColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {
1162 if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {
1163 mi.setText( "Select Colors... (current: " + tree_panel.getTreeColorSet().getCurrentColorSchemeName() + ")" );
1166 mi.setText( "Select Colors..." );
1170 static void setTextForFontChooserMenuItem( final JMenuItem mi, final String font_desc ) {
1171 mi.setText( "Select Font... (current: " + font_desc + ")" );
1174 static void setTextMinSupportMenuItem( final JMenuItem mi, final Options options, final TreePanel current_tree_panel ) {
1175 if ( ( current_tree_panel == null ) || ( current_tree_panel.getPhylogeny() == null ) ) {
1176 mi.setEnabled( true );
1178 else if ( ForesterUtil.isHasAtLeastOneBranchWithSupportValues( current_tree_panel.getPhylogeny() ) ) {
1179 mi.setEnabled( true );
1182 mi.setEnabled( false );
1184 mi.setText( "Enter Min Confidence Value... (current: " + options.getMinConfidenceValue() + ")" );
1187 static void updateOptionsMenuDependingOnPhylogenyType( final MainPanel main_panel,
1188 final JCheckBoxMenuItem scale,
1189 final JCheckBoxMenuItem branch_lengths,
1190 final JRadioButtonMenuItem non_lined_up,
1191 final JRadioButtonMenuItem uniform_clado,
1192 final JRadioButtonMenuItem nonuniform_clado,
1193 final JCheckBoxMenuItem label_direction_cbmi ) {
1194 final TreePanel tree_panel = main_panel.getCurrentTreePanel();
1195 final ControlPanel control = main_panel.getControlPanel();
1196 final Options options = main_panel.getOptions();
1197 scale.setSelected( options.isShowScale() );
1198 branch_lengths.setSelected( options.isShowBranchLengthValues() );
1199 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1200 if ( ( tree_panel != null ) && ( !tree_panel.isPhyHasBranchLengths() ) ) {
1201 scale.setSelected( false );
1202 scale.setEnabled( false );
1203 branch_lengths.setSelected( false );
1204 branch_lengths.setEnabled( false );
1206 else if ( ( tree_panel != null ) && !control.isDrawPhylogram() ) {
1207 scale.setSelected( false );
1208 scale.setEnabled( false );
1209 branch_lengths.setEnabled( true );
1212 scale.setEnabled( true );
1213 branch_lengths.setEnabled( true );
1215 if ( ( tree_panel != null )
1216 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.ROUNDED )
1217 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1218 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1219 branch_lengths.setSelected( false );
1220 branch_lengths.setEnabled( false );
1222 if ( tree_panel != null ) {
1223 if ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1224 || ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
1225 non_lined_up.setEnabled( false );
1226 uniform_clado.setEnabled( false );
1227 nonuniform_clado.setEnabled( false );
1230 non_lined_up.setEnabled( true );
1231 uniform_clado.setEnabled( true );
1232 nonuniform_clado.setEnabled( true );
1236 if ( ( tree_panel != null )
1237 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1238 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1239 branch_lengths.setSelected( false );
1240 branch_lengths.setEnabled( false );
1242 if ( ( tree_panel != null )
1243 && ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( tree_panel
1244 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
1245 non_lined_up.setEnabled( false );
1248 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1249 non_lined_up.setEnabled( true );
1252 label_direction_cbmi.setEnabled( true );
1253 if ( tree_panel != null ) {
1254 if ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1255 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1256 label_direction_cbmi.setEnabled( false );
1258 if ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
1259 scale.setSelected( false );
1260 scale.setEnabled( false );
1265 static void updateScreenTextAntialias( final List<TreePanel> treepanels ) {
1266 for( final TreePanel tree_panel : treepanels ) {
1267 tree_panel.setTextAntialias();