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;
177 JMenuItem _about_item;
178 JMenuItem _help_item;
179 JMenuItem _website_item;
180 JMenuItem _phyloxml_website_item;
181 JMenuItem _phyloxml_ref_item;
182 JMenuItem _aptx_ref_item;
183 // Handy pointers to child components:
184 MainPanel _mainpanel;
185 Container _contentpane;
186 TextFrame _textframe;
187 Configuration _configuration;
188 JMenuItem _remove_branch_color_item;
192 // Empty constructor.
198 public void actionPerformed( final ActionEvent e ) {
199 final Object o = e.getSource();
200 boolean is_applet = false;
201 JApplet applet = null;
202 if ( getCurrentTreePanel() != null ) {
203 is_applet = getCurrentTreePanel().isApplet();
205 applet = getCurrentTreePanel().obtainApplet();
208 if ( o == _open_url_item ) {
209 readPhylogeniesFromURL();
211 else if ( o == _exit_item ) {
214 else if ( o == _taxcolor_item ) {
217 else if ( o == _confcolor_item ) {
220 else if ( o == _infer_common_sn_names_item ) {
221 if ( isSubtreeDisplayed() ) {
224 if ( getCurrentTreePanel() != null ) {
225 getCurrentTreePanel().inferCommonPartOfScientificNames();
228 else if ( o == _collapse_species_specific_subtrees ) {
229 if ( isSubtreeDisplayed() ) {
232 if ( getCurrentTreePanel() != null ) {
233 getCurrentTreePanel().collapseSpeciesSpecificSubtrees();
236 else if ( o == _remove_branch_color_item ) {
237 if ( isSubtreeDisplayed() ) {
240 removeBranchColors();
242 else if ( o == _midpoint_root_item ) {
243 if ( isSubtreeDisplayed() ) {
248 else if ( o == _switch_colors_mi ) {
251 else if ( o == _view_as_NH_item ) {
254 else if ( o == _view_as_NHX_item ) {
257 else if ( o == _view_as_XML_item ) {
260 else if ( o == _view_as_nexus_item ) {
263 else if ( o == _super_tiny_fonts_item ) {
264 if ( getCurrentTreePanel() != null ) {
265 getCurrentTreePanel().setSuperTinyFonts();
266 getCurrentTreePanel().repaint();
269 else if ( o == _tiny_fonts_item ) {
270 if ( getCurrentTreePanel() != null ) {
271 getCurrentTreePanel().setTinyFonts();
272 getCurrentTreePanel().repaint();
275 else if ( o == _small_fonts_item ) {
276 if ( getCurrentTreePanel() != null ) {
277 getCurrentTreePanel().setSmallFonts();
278 getCurrentTreePanel().repaint();
281 else if ( o == _medium_fonts_item ) {
282 if ( getCurrentTreePanel() != null ) {
283 getCurrentTreePanel().setMediumFonts();
284 getCurrentTreePanel().repaint();
287 else if ( o == _large_fonts_item ) {
288 if ( getCurrentTreePanel() != null ) {
289 getCurrentTreePanel().setLargeFonts();
290 getCurrentTreePanel().repaint();
293 else if ( o == _choose_font_mi ) {
296 else if ( o == _choose_minimal_confidence_mi ) {
297 chooseMinimalConfidence();
299 else if ( o == _overview_placment_mi ) {
300 MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
302 else if ( o == _screen_antialias_cbmi ) {
303 updateOptions( getOptions() );
304 updateScreenTextAntialias( getMainPanel().getTreePanels() );
306 else if ( o == _background_gradient_cbmi ) {
307 updateOptions( getOptions() );
309 else if ( o == _show_domain_labels ) {
310 updateOptions( getOptions() );
312 else if ( o == _abbreviate_scientific_names ) {
313 updateOptions( getOptions() );
315 else if ( o == _color_labels_same_as_parent_branch ) {
316 updateOptions( getOptions() );
318 else if ( o == _show_node_boxes_cbmi ) {
319 updateOptions( getOptions() );
321 else if ( o == _non_lined_up_cladograms_rbmi ) {
322 updateOptions( getOptions() );
325 else if ( o == _uniform_cladograms_rbmi ) {
326 updateOptions( getOptions() );
329 else if ( o == _ext_node_dependent_cladogram_rbmi ) {
330 updateOptions( getOptions() );
333 else if ( o == _search_case_senstive_cbmi ) {
334 updateOptions( getOptions() );
335 getMainPanel().getControlPanel().search();
337 else if ( o == _search_whole_words_only_cbmi ) {
338 updateOptions( getOptions() );
339 getMainPanel().getControlPanel().search();
341 else if ( o == _inverse_search_result_cbmi ) {
342 updateOptions( getOptions() );
343 getMainPanel().getControlPanel().search();
345 else if ( o == _show_scale_cbmi ) {
346 updateOptions( getOptions() );
348 else if ( o == _show_branch_length_values_cbmi ) {
349 updateOptions( getOptions() );
351 else if ( o == _label_direction_cbmi ) {
352 updateOptions( getOptions() );
354 else if ( o == _show_overview_cbmi ) {
355 updateOptions( getOptions() );
356 if ( getCurrentTreePanel() != null ) {
357 getCurrentTreePanel().updateOvSizes();
360 else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
361 || ( o == _convex_type_cbmi ) || ( o == _euro_type_cbmi ) || ( o == _rounded_type_cbmi )
362 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
365 else if ( o == _about_item ) {
368 else if ( o == _help_item ) {
369 help( getConfiguration().getWebLinks() );
371 else if ( o == _website_item ) {
373 Util.openWebsite( Constants.APTX_WEB_SITE, is_applet, applet );
375 catch ( final IOException e1 ) {
376 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
379 else if ( o == _phyloxml_website_item ) {
381 Util.openWebsite( Constants.PHYLOXML_WEB_SITE, is_applet, applet );
383 catch ( final IOException e1 ) {
384 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
387 else if ( o == _aptx_ref_item ) {
389 Util.openWebsite( Constants.APTX_REFERENCE_URL, is_applet, applet );
391 catch ( final IOException e1 ) {
392 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
395 else if ( o == _phyloxml_ref_item ) {
397 Util.openWebsite( Constants.PHYLOXML_REFERENCE_URL, is_applet, applet );
399 catch ( final IOException e1 ) {
400 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
404 if ( _load_phylogeny_from_webservice_menu_items != null ) {
405 for( int i = 0; i < _load_phylogeny_from_webservice_menu_items.length; ++i ) {
406 if ( o == _load_phylogeny_from_webservice_menu_items[ i ] ) {
407 readPhylogeniesFromWebservice( i );
412 _contentpane.repaint();
415 boolean isSubtreeDisplayed() {
416 if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
418 .showMessageDialog( this,
419 "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",
420 "Operation can not be exectuted on a sub-tree",
421 JOptionPane.WARNING_MESSAGE );
427 void activateSaveAllIfNeeded() {
428 if ( ( getMainPanel().getTabbedPane() != null ) && ( getMainPanel().getTabbedPane().getTabCount() > 1 ) ) {
429 _save_all_item.setEnabled( true );
432 _save_all_item.setEnabled( false );
436 void buildFileMenu() {
437 _file_jmenu = createMenu( "File", getConfiguration() );
438 _file_jmenu.add( _open_url_item = new JMenuItem( "Read tree from URL/webservice..." ) );
439 _file_jmenu.addSeparator();
440 _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );
441 customizeJMenuItem( _open_url_item );
442 customizeJMenuItem( _exit_item );
443 _jmenubar.add( _file_jmenu );
446 void buildFontSizeMenu() {
447 _font_size_menu = createMenu( FONT_SIZE_MENU_LABEL, getConfiguration() );
448 _font_size_menu.add( _super_tiny_fonts_item = new JMenuItem( "Super Tiny Fonts" ) );
449 _font_size_menu.add( _tiny_fonts_item = new JMenuItem( "Tiny Fonts" ) );
450 _font_size_menu.add( _small_fonts_item = new JMenuItem( "Small Fonts" ) );
451 _font_size_menu.add( _medium_fonts_item = new JMenuItem( "Medium Fonts" ) );
452 _font_size_menu.add( _large_fonts_item = new JMenuItem( "Large Fonts" ) );
453 customizeJMenuItem( _super_tiny_fonts_item );
454 customizeJMenuItem( _tiny_fonts_item );
455 customizeJMenuItem( _small_fonts_item );
456 customizeJMenuItem( _medium_fonts_item );
457 customizeJMenuItem( _large_fonts_item );
458 _jmenubar.add( _font_size_menu );
461 void buildHelpMenu() {
462 _help_jmenu = createMenu( "Help", getConfiguration() );
463 _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
464 _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
465 _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
466 _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
467 _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
468 _help_jmenu.addSeparator();
469 _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
470 customizeJMenuItem( _help_item );
471 customizeJMenuItem( _website_item );
472 customizeJMenuItem( _phyloxml_website_item );
473 customizeJMenuItem( _aptx_ref_item );
474 customizeJMenuItem( _phyloxml_ref_item );
475 customizeJMenuItem( _about_item );
476 _phyloxml_ref_item.setToolTipText( PHYLOXML_REF_TOOL_TIP );
477 _aptx_ref_item.setToolTipText( APTX_REF_TOOL_TIP );
478 _jmenubar.add( _help_jmenu );
481 void buildTypeMenu() {
482 _type_menu = createMenu( TYPE_MENU_HEADER, getConfiguration() );
483 _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
484 _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
485 _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
486 _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
487 _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
488 _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
489 _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
490 _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
491 customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
492 customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
493 customizeCheckBoxMenuItem( _euro_type_cbmi, false );
494 customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
495 customizeCheckBoxMenuItem( _curved_type_cbmi, false );
496 customizeCheckBoxMenuItem( _convex_type_cbmi, false );
497 customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
498 customizeCheckBoxMenuItem( _circular_type_cbmi, false );
499 _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
500 _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
501 initializeTypeMenu( getOptions() );
502 _jmenubar.add( _type_menu );
505 void buildViewMenu() {
506 _view_jmenu = createMenu( "View as Text", getConfiguration() );
507 _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) );
508 _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) );
509 _view_jmenu.add( _view_as_NHX_item = new JMenuItem( "View as NHX" ) );
510 _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "View as Nexus" ) );
511 customizeJMenuItem( _view_as_NH_item );
512 customizeJMenuItem( _view_as_NHX_item );
513 customizeJMenuItem( _view_as_XML_item );
514 customizeJMenuItem( _view_as_nexus_item );
515 _jmenubar.add( _view_jmenu );
518 private void chooseFont() {
519 final FontChooser fc = new FontChooser();
520 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
521 fc.showDialog( this, "Select the Base Font" );
522 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
525 private void chooseMinimalConfidence() {
526 final String s = ( String ) JOptionPane
527 .showInputDialog( this,
528 "Please enter the minimum for confidence values to be displayed.\n"
529 + "[current value: " + getOptions().getMinConfidenceValue() + "]\n",
530 "Minimal Confidence Value",
531 JOptionPane.QUESTION_MESSAGE,
534 getOptions().getMinConfidenceValue() );
535 if ( !ForesterUtil.isEmpty( s ) ) {
536 boolean success = true;
538 final String m_str = s.trim();
539 if ( !ForesterUtil.isEmpty( m_str ) ) {
541 m = Double.parseDouble( m_str );
543 catch ( final Exception ex ) {
550 if ( success && ( m >= 0.0 ) ) {
551 getOptions().setMinConfidenceValue( m );
558 if ( _mainpanel != null ) {
559 _mainpanel.terminate();
561 if ( _contentpane != null ) {
562 _contentpane.removeAll();
569 if ( _mainpanel.getCurrentTreePanel() != null ) {
570 _mainpanel.getCurrentTreePanel().confColor();
574 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
575 if ( item != null ) {
576 item.setFont( MainFrame.menu_font );
577 if ( !getConfiguration().isUseNativeUI() ) {
578 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
579 item.setForeground( getConfiguration().getGuiMenuTextColor() );
581 item.setSelected( is_selected );
582 item.addActionListener( this );
586 void customizeJMenuItem( final JMenuItem jmi ) {
588 jmi.setFont( MainFrame.menu_font );
589 if ( !getConfiguration().isUseNativeUI() ) {
590 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
591 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
593 jmi.addActionListener( this );
597 void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
598 if ( item != null ) {
599 item.setFont( MainFrame.menu_font );
600 if ( !getConfiguration().isUseNativeUI() ) {
601 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
602 item.setForeground( getConfiguration().getGuiMenuTextColor() );
604 item.setSelected( is_selected );
605 item.addActionListener( this );
609 void exceptionOccuredDuringOpenFile( final Exception e ) {
611 _mainpanel.getCurrentTreePanel().setArrowCursor();
613 catch ( final Exception ex ) {
616 JOptionPane.showMessageDialog( this,
617 ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
618 "Error during File|Open",
619 JOptionPane.ERROR_MESSAGE );
622 void exceptionOccuredDuringSaveAs( final Exception e ) {
624 _mainpanel.getCurrentTreePanel().setArrowCursor();
626 catch ( final Exception ex ) {
629 JOptionPane.showMessageDialog( this, "Exception" + e, "Error during File|SaveAs", JOptionPane.ERROR_MESSAGE );
632 boolean GAndSDoHaveMoreThanOneSpeciesInComman( final Phylogeny gene_tree ) {
633 if ( ( gene_tree == null ) || gene_tree.isEmpty() ) {
634 JOptionPane.showMessageDialog( this,
635 "Gene tree and species tree have no species in common.",
637 JOptionPane.ERROR_MESSAGE );
640 else if ( gene_tree.getNumberOfExternalNodes() < 2 ) {
641 JOptionPane.showMessageDialog( this,
642 "Gene tree and species tree have only one species in common.",
644 JOptionPane.ERROR_MESSAGE );
652 Configuration getConfiguration() {
653 return _configuration;
656 TreePanel getCurrentTreePanel() {
657 return getMainPanel().getCurrentTreePanel();
660 JMenu getHelpMenu() {
664 JCheckBoxMenuItem getlabelDirectionCbmi() {
665 return _label_direction_cbmi;
668 MainPanel getMainPanel() {
672 JMenuBar getMenuBarOfMainFrame() {
676 Options getOptions() {
680 void initializeTypeMenu( final Options options ) {
681 setTypeMenuToAllUnselected();
682 switch ( options.getPhylogenyGraphicsType() ) {
684 _convex_type_cbmi.setSelected( true );
687 _curved_type_cbmi.setSelected( true );
690 _euro_type_cbmi.setSelected( true );
693 _rounded_type_cbmi.setSelected( true );
696 _triangular_type_cbmi.setSelected( true );
699 _unrooted_type_cbmi.setSelected( true );
702 _circular_type_cbmi.setSelected( true );
705 _rectangular_type_cbmi.setSelected( true );
710 void midpointRoot() {
711 if ( _mainpanel.getCurrentTreePanel() != null ) {
712 _mainpanel.getCurrentTreePanel().midpointRoot();
716 abstract void readPhylogeniesFromURL();
718 void readPhylogeniesFromWebservice( final int i ) {
719 final UrlTreeReader reader = new UrlTreeReader( this, i );
720 new Thread( reader ).start();
723 private void removeBranchColors() {
724 if ( getMainPanel().getCurrentPhylogeny() != null ) {
725 Util.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
729 void removeTextFrame() {
730 if ( _textframe != null ) {
736 void setConfiguration( final Configuration configuration ) {
737 _configuration = configuration;
740 void setOptions( final Options options ) {
744 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
745 setTypeMenuToAllUnselected();
748 _circular_type_cbmi.setSelected( true );
751 _convex_type_cbmi.setSelected( true );
754 _curved_type_cbmi.setSelected( true );
757 _euro_type_cbmi.setSelected( true );
760 _rounded_type_cbmi.setSelected( true );
763 _rectangular_type_cbmi.setSelected( true );
766 _triangular_type_cbmi.setSelected( true );
769 _unrooted_type_cbmi.setSelected( true );
772 throw new IllegalArgumentException( "unknown type: " + type );
776 void setTypeMenuToAllUnselected() {
777 _convex_type_cbmi.setSelected( false );
778 _curved_type_cbmi.setSelected( false );
779 _euro_type_cbmi.setSelected( false );
780 _rounded_type_cbmi.setSelected( false );
781 _triangular_type_cbmi.setSelected( false );
782 _rectangular_type_cbmi.setSelected( false );
783 _unrooted_type_cbmi.setSelected( false );
784 _circular_type_cbmi.setSelected( false );
788 _mainpanel.getControlPanel().showWhole();
791 void switchColors() {
792 final TreeColorSet colorset = _mainpanel.getTreeColorSet();
793 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
794 csc.setVisible( true );
798 if ( _mainpanel.getCurrentTreePanel() != null ) {
799 _mainpanel.getCurrentTreePanel().taxColor();
803 void typeChanged( final Object o ) {
804 updateTypeCheckboxes( getOptions(), o );
805 updateOptions( getOptions() );
806 if ( getCurrentTreePanel() != null ) {
807 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
808 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
809 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
810 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
811 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
812 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
813 getCurrentTreePanel().getControlPanel().showWhole();
815 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
816 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
819 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
821 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
822 updateScreenTextAntialias( getMainPanel().getTreePanels() );
823 if ( getCurrentTreePanel().getControlPanel().getDynamicallyHideData() != null ) {
824 if ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
825 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( false );
828 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( true );
834 void updateOptions( final Options options ) {
835 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
836 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
837 && _background_gradient_cbmi.isSelected() );
838 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
839 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
840 && _abbreviate_scientific_names.isSelected() );
841 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
842 && _color_labels_same_as_parent_branch.isSelected() );
843 options.setShowNodeBoxes( ( _show_node_boxes_cbmi != null ) && _show_node_boxes_cbmi.isSelected() );
844 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
845 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
847 else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
848 options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
850 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
851 options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
853 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
854 && _search_case_senstive_cbmi.isSelected() );
855 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
856 options.setShowScale( _show_scale_cbmi.isSelected() );
858 if ( _label_direction_cbmi != null ) {
859 if ( _label_direction_cbmi.isSelected() ) {
860 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
863 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
866 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
867 if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
868 options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
870 options.setPrintUsingActualSize( ( _print_using_actual_size_cbmi != null )
871 && ( _print_using_actual_size_cbmi.isSelected() ) );
872 options.setGraphicsExportUsingActualSize( ( _graphics_export_using_actual_size_cbmi != null )
873 && ( _graphics_export_using_actual_size_cbmi.isSelected() ) );
874 options.setAntialiasPrint( ( _antialias_print_cbmi != null ) && _antialias_print_cbmi.isSelected() );
875 options.setPrintBlackAndWhite( ( _print_black_and_white_cbmi != null )
876 && _print_black_and_white_cbmi.isSelected() );
878 .setInternalNumberAreConfidenceForNhParsing( ( _internal_number_are_confidence_for_nh_parsing_cbmi != null )
879 && _internal_number_are_confidence_for_nh_parsing_cbmi.isSelected() );
880 options.setExtractPfamTaxonomyCodesInNhParsing( ( _extract_pfam_style_tax_codes_cbmi != null )
881 && _extract_pfam_style_tax_codes_cbmi.isSelected() );
882 options.setReplaceUnderscoresInNhParsing( ( _replace_underscores_cbmi != null )
883 && _replace_underscores_cbmi.isSelected() );
884 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
885 && _search_whole_words_only_cbmi.isSelected() );
886 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
887 && _inverse_search_result_cbmi.isSelected() );
888 if ( _graphics_export_visible_only_cbmi != null ) {
889 options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() );
890 if ( _graphics_export_visible_only_cbmi.isSelected() && ( _graphics_export_using_actual_size_cbmi != null ) ) {
891 _graphics_export_using_actual_size_cbmi.setSelected( true );
892 _graphics_export_using_actual_size_cbmi.setEnabled( false );
895 _graphics_export_using_actual_size_cbmi.setEnabled( true );
898 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
899 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
901 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
902 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
904 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
905 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
907 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
908 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
910 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
911 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
913 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
914 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
916 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
917 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
919 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
920 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
924 void updateTypeCheckboxes( final Options options, final Object o ) {
925 setTypeMenuToAllUnselected();
926 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
931 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty()
932 || ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
935 _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny().toNexus() );
940 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty()
941 || ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
944 _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny().toNewHampshire( false ) );
949 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty()
950 || ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
953 _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny().toNewHampshireX() );
958 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty()
959 && ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() <= 10000 ) ) {
960 _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny().toPhyloXML( 0 ) );
965 * Display the about box.
967 static void about() {
968 final StringBuffer about = new StringBuffer( "Archaeopteryx\nVersion " + Constants.VERSION + "\n" );
969 about.append( "Copyright (C) 2007-2011 Christian Zmasek\n" );
970 about.append( "All Rights Reserved\n" );
971 about.append( "License: GNU Lesser General Public License (LGPL)\n" );
972 about.append( "Last modified: " + Constants.PRG_DATE + "\n" );
973 about.append( "phyloXML version : " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
974 about.append( "phyloXML location: " + ForesterConstants.PHYLO_XML_LOCATION + "\n" );
975 if ( !ForesterUtil.isEmpty( ForesterUtil.JAVA_VERSION ) && !ForesterUtil.isEmpty( ForesterUtil.JAVA_VENDOR ) ) {
976 about.append( "[your Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]\n" );
978 if ( !ForesterUtil.isEmpty( ForesterUtil.OS_NAME ) && !ForesterUtil.isEmpty( ForesterUtil.OS_ARCH )
979 && !ForesterUtil.isEmpty( ForesterUtil.OS_VERSION ) ) {
980 about.append( "[your OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " "
981 + ForesterUtil.OS_VERSION + "]\n" );
983 final Runtime rt = java.lang.Runtime.getRuntime();
984 final long free_memory = rt.freeMemory() / 1000000;
985 final long total_memory = rt.totalMemory() / 1000000;
986 about.append( "[free memory: " + free_memory + "MB, total memory: " + total_memory + "MB]\n" );
987 about.append( "[locale: " + Locale.getDefault() + "]\n" );
988 about.append( "References:\n" );
989 about.append( Constants.PHYLOXML_REFERENCE_SHORT + "\n" );
990 about.append( "For more information & download:\n" );
991 about.append( Constants.APTX_WEB_SITE + "\n" );
992 about.append( "Comments: " + Constants.AUTHOR_EMAIL );
993 JOptionPane.showMessageDialog( null, about, Constants.PRG_NAME, JOptionPane.PLAIN_MESSAGE );
996 static String createCurrentFontDesc( final TreeFontSet tree_font_set ) {
997 return tree_font_set.getLargeFont().getFamily() + " " + tree_font_set.getLargeFont().getSize();
1000 static JMenu createMenu( final String title, final Configuration conf ) {
1001 final JMenu jmenu = new JMenu( title );
1002 if ( !conf.isUseNativeUI() ) {
1003 jmenu.setFont( MainFrame.menu_font );
1004 jmenu.setBackground( conf.getGuiMenuBackgroundColor() );
1005 jmenu.setForeground( conf.getGuiMenuTextColor() );
1010 static JMenuItem customizeMenuItemAsLabel( final JMenuItem label, final Configuration configuration ) {
1011 label.setFont( MainFrame.menu_font.deriveFont( Font.BOLD ) );
1012 if ( !configuration.isUseNativeUI() ) {
1013 label.setBackground( configuration.getGuiMenuBackgroundColor() );
1014 label.setForeground( configuration.getGuiMenuTextColor() );
1015 label.setOpaque( true );
1017 label.setSelected( false );
1018 label.setEnabled( false );
1022 static void cycleOverview( final Options op, final TreePanel tree_panel ) {
1023 switch ( op.getOvPlacement() ) {
1025 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1028 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1031 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1034 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1037 throw new RuntimeException( "unknown placement: " + op.getOvPlacement() );
1039 tree_panel.updateOvSettings();
1042 static void help( final Map<String, WebLink> weblinks ) {
1043 final StringBuilder sb = new StringBuilder();
1044 sb.append( "Display options\n" );
1045 sb.append( "-------------------\n" );
1046 sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
1047 sb.append( "Clickable tree nodes\n" );
1048 sb.append( "--------------------\n" );
1049 sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
1050 sb.append( "or by right clicking:\n" );
1051 sb.append( "o Display Node Data -- display information for a node\n" );
1052 sb.append( "o Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
1053 sb.append( "o Root/Reroot -- change tree root to clicked node\n" );
1054 sb.append( "o Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
1055 sb.append( "o Swap Descendants -- switch descendant on either side of clicked node\n" );
1056 sb.append( "o Colorize Subtree -- color a subtree\n" );
1057 sb.append( "o Open Sequence Web -- launch a web browser to display sequence information\n" );
1058 sb.append( "o Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
1059 sb.append( "- there may be additional choices depending on this particular setup\n\n" );
1060 sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
1061 sb.append( "Zooming\n" );
1062 sb.append( "---------\n" );
1063 sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
1064 sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
1065 sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
1066 sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
1068 .append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
1069 sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
1070 sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
1071 sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
1072 sb.append( "Quick tree manipulation:\n" );
1073 sb.append( "------------------------\n" );
1074 sb.append( "Order Subtrees -- order the tree by branch length\n" );
1075 sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
1076 sb.append( "Memory problems (Java heap space error)\n" );
1077 sb.append( "---------------------------------------\n" );
1078 sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
1080 .append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
1081 sb.append( "the '-Xmx' Java command line option. For example:\n" );
1082 sb.append( "java -Xms32m -Xmx256m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
1083 if ( ( weblinks != null ) && ( weblinks.size() > 0 ) ) {
1084 sb.append( "Active web links\n" );
1085 sb.append( "--------------------\n" );
1086 for( final String key : weblinks.keySet() ) {
1087 sb.append( " " + weblinks.get( key ).toString() + "\n" );
1090 // + "General remarks\n"
1091 // + "---------------\n"
1093 // "o The application version permits copying to the clipboard \n"
1095 // " in the \"View\"|\"View as ...\" frame (either by control-c or button press).\n"
1097 // "o Changes made to a subtree affect this subtree and its subtrees,\n"
1098 // + " but not any of its parent tree(s).\n"
1100 // "o Archaeopteryx tries to detect whether the numerical values in a NH tree\n"
1102 // " are likely to be bootstrap values instead of branch length values.\n\n"
1104 // " Remarks regarding SDI (Speciation Duplication Inference):\n"
1106 // "o Each external node of the gene tree (in display) needs to be associated with\n"
1108 // " a species: either directly through the \"Species\" field, or the species\n"
1110 // " is part of the sequence name in the form \"XXXX_SPECIES\"\n"
1112 // " (e.g. \"ACON_DROME\" or \"ACON_DROME/123-4489\" which is also acceptable).\n"
1114 // "o A species tree for each species of the gene tree needs to be loaded with\n"
1116 // " \"SDI\"|\"Load species tree\" prior the SDI execution.\n"
1118 // "o !External nodes of the gene tree associated with species not present in\n"
1120 // " the species tree are REMOVED prior to SDI execution!\n"
1122 // "o Both the gene tree and the species tree must be completely binary.\n"
1124 // "o Duplications and speciations are a function of the position of the root.\n"
1126 // " Hence, after each manual \"Root/Reroot\"ing some duplications will be\n"
1127 // + " incorrect and need to be inferred again\n"
1129 // " with: \"SDI\"|\"SDI (Speciation Duplication Inference)\n\n"
1131 sb.append( "phyloXML\n" );
1132 sb.append( "-------------------\n" );
1133 sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
1134 sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
1135 sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1137 sb.append( "For more information: http://www.phylosoft.org/archaeopteryx/\n" );
1138 sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
1139 TextFrame.instantiate( sb.toString() );
1142 static void setOvPlacementColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {
1143 if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {
1144 mi.setText( "Overview Placement... (current: " + tree_panel.getOptions().getOvPlacement() + ")" );
1147 mi.setText( "Overview Placement..." );
1151 static void setTextColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {
1152 if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {
1153 mi.setText( "Select Colors... (current: " + tree_panel.getTreeColorSet().getCurrentColorSchemeName() + ")" );
1156 mi.setText( "Select Colors..." );
1160 static void setTextForFontChooserMenuItem( final JMenuItem mi, final String font_desc ) {
1161 mi.setText( "Select Font... (current: " + font_desc + ")" );
1164 static void setTextMinSupportMenuItem( final JMenuItem mi, final Options options, final TreePanel current_tree_panel ) {
1165 if ( ( current_tree_panel == null ) || ( current_tree_panel.getPhylogeny() == null ) ) {
1166 mi.setEnabled( true );
1168 else if ( ForesterUtil.isHasAtLeastOneBranchWithSupportValues( current_tree_panel.getPhylogeny() ) ) {
1169 mi.setEnabled( true );
1172 mi.setEnabled( false );
1174 mi.setText( "Enter Min Confidence Value... (current: " + options.getMinConfidenceValue() + ")" );
1177 static void updateOptionsMenuDependingOnPhylogenyType( final MainPanel main_panel,
1178 final JCheckBoxMenuItem scale,
1179 final JCheckBoxMenuItem branch_lengths,
1180 final JRadioButtonMenuItem non_lined_up,
1181 final JRadioButtonMenuItem uniform_clado,
1182 final JRadioButtonMenuItem nonuniform_clado,
1183 final JCheckBoxMenuItem label_direction_cbmi ) {
1184 final TreePanel tree_panel = main_panel.getCurrentTreePanel();
1185 final ControlPanel control = main_panel.getControlPanel();
1186 final Options options = main_panel.getOptions();
1187 scale.setSelected( options.isShowScale() );
1188 branch_lengths.setSelected( options.isShowBranchLengthValues() );
1189 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1190 if ( ( tree_panel != null ) && ( !tree_panel.isPhyHasBranchLengths() ) ) {
1191 scale.setSelected( false );
1192 scale.setEnabled( false );
1193 branch_lengths.setSelected( false );
1194 branch_lengths.setEnabled( false );
1196 else if ( ( tree_panel != null ) && !control.isDrawPhylogram() ) {
1197 scale.setSelected( false );
1198 scale.setEnabled( false );
1199 branch_lengths.setEnabled( true );
1202 scale.setEnabled( true );
1203 branch_lengths.setEnabled( true );
1205 if ( ( tree_panel != null )
1206 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.ROUNDED )
1207 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1208 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1209 branch_lengths.setSelected( false );
1210 branch_lengths.setEnabled( false );
1212 if ( tree_panel != null ) {
1213 if ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1214 || ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
1215 non_lined_up.setEnabled( false );
1216 uniform_clado.setEnabled( false );
1217 nonuniform_clado.setEnabled( false );
1220 non_lined_up.setEnabled( true );
1221 uniform_clado.setEnabled( true );
1222 nonuniform_clado.setEnabled( true );
1226 if ( ( tree_panel != null )
1227 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1228 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1229 branch_lengths.setSelected( false );
1230 branch_lengths.setEnabled( false );
1232 if ( ( tree_panel != null )
1233 && ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( tree_panel
1234 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
1235 non_lined_up.setEnabled( false );
1238 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1239 non_lined_up.setEnabled( true );
1242 label_direction_cbmi.setEnabled( true );
1243 if ( tree_panel != null ) {
1244 if ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1245 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1246 label_direction_cbmi.setEnabled( false );
1248 if ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
1249 scale.setSelected( false );
1250 scale.setEnabled( false );
1255 static void updateScreenTextAntialias( final List<TreePanel> treepanels ) {
1256 for( final TreePanel tree_panel : treepanels ) {
1257 tree_panel.setTextAntialias();