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.Component;
28 import java.awt.Container;
30 import java.awt.event.ActionEvent;
31 import java.awt.event.ActionListener;
32 import java.io.IOException;
33 import java.util.List;
34 import java.util.Locale;
37 import javax.swing.JApplet;
38 import javax.swing.JCheckBoxMenuItem;
39 import javax.swing.JFrame;
40 import javax.swing.JMenu;
41 import javax.swing.JMenuBar;
42 import javax.swing.JMenuItem;
43 import javax.swing.JOptionPane;
44 import javax.swing.JRadioButtonMenuItem;
46 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
47 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
48 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
49 import org.forester.phylogeny.Phylogeny;
50 import org.forester.phylogeny.PhylogenyNodeI.NH_CONVERSION_SUPPORT_VALUE_STYLE;
51 import org.forester.phylogeny.data.NodeVisualization.NodeFill;
52 import org.forester.phylogeny.data.NodeVisualization.NodeShape;
53 import org.forester.util.ForesterConstants;
54 import org.forester.util.ForesterUtil;
56 public abstract class MainFrame extends JFrame implements ActionListener {
58 static final String USE_MOUSEWHEEL_SHIFT_TO_ROTATE = "In this display type, use mousewheel + Shift to rotate [or A and S]";
59 static final String PHYLOXML_REF_TOOL_TIP = Constants.PHYLOXML_REFERENCE; //TODO //FIXME
60 static final String APTX_REF_TOOL_TIP = Constants.APTX_REFERENCE;
61 private static final long serialVersionUID = 3655000897845508358L;
62 final static Font menu_font = new Font( Configuration.getDefaultFontFamilyName(),
65 static final String TYPE_MENU_HEADER = "Type";
66 static final String RECTANGULAR_TYPE_CBMI_LABEL = "Rectangular";
67 static final String EURO_TYPE_CBMI_LABEL = "Euro Type";
68 static final String CURVED_TYPE_CBMI_LABEL = "Curved";
69 static final String TRIANGULAR_TYPE_CBMI_LABEL = "Triangular";
70 static final String CONVEX_TYPE_CBMI_LABEL = "Convex";
71 static final String ROUNDED_TYPE_CBMI_LABEL = "Rounded";
72 static final String UNROOTED_TYPE_CBMI_LABEL = "Unrooted (alpha)"; //TODO
73 static final String CIRCULAR_TYPE_CBMI_LABEL = "Circular (alpha)"; //TODO
74 static final String OPTIONS_HEADER = "Options";
75 static final String SEARCH_SUBHEADER = "Search:";
76 static final String DISPLAY_SUBHEADER = "Display:";
77 static final String SEARCH_TERMS_ONLY_LABEL = "Match Complete Terms Only";
78 static final String SEARCH_CASE_SENSITIVE_LABEL = "Case Sensitive";
79 static final String INVERSE_SEARCH_RESULT_LABEL = "Negate Result";
80 static final String DISPLAY_BRANCH_LENGTH_VALUES_LABEL = "Display Branch Length Values";
81 static final String DISPLAY_SCALE_LABEL = "Display Scale";
82 static final String NON_LINED_UP_CLADOGRAMS_LABEL = "Non-Lined Up Cladograms";
83 static final String UNIFORM_CLADOGRAMS_LABEL = "Total Node Sum Dependent Cladograms";
84 static final String LABEL_DIRECTION_LABEL = "Radial Labels";
85 static final String LABEL_DIRECTION_TIP = "To use radial node labels in radial and unrooted display types";
86 static final String SCREEN_ANTIALIAS_LABEL = "Antialias";
87 static final String COLOR_LABELS_LABEL = "Colorize Labels Same as Parent Branch";
88 static final String BG_GRAD_LABEL = "Background Color Gradient";
89 static final String DISPLAY_NODE_BOXES_LABEL = "Show Node Shapes";
90 static final String SHOW_OVERVIEW_LABEL = "Show Overview";
91 static final String FONT_SIZE_MENU_LABEL = "Font Size";
92 static final String NONUNIFORM_CLADOGRAMS_LABEL = "External Node Sum Dependent Cladograms";
93 static final String SHOW_DOMAIN_LABELS_LABEL = "Show Domain Labels";
94 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";
95 static final String ABBREV_SN_LABEL = "Abbreviate Scientific Taxonomic Names";
96 static final String TAXONOMY_COLORIZE_NODE_SHAPES_LABEL = "Colorize Node Shapes According to Taxonomy";
97 static final String CYCLE_NODE_SHAPE_LABEL = "Cycle Node Shapes";
98 static final String CYCLE_NODE_FILL_LABEL = "Cycle Node Fill Type";
99 static final String CHOOSE_NODE_SIZE_LABEL = "Choose Node Shape Size";
100 static final String SHOW_CONF_STDDEV_LABEL = "Show Confidence Standard Deviations";
101 static final String USE_BRACKETS_FOR_CONF_IN_NH_LABEL = "Use Brackets for Confidence Values";
102 static final String USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL = "Use Internal Node Names for Confidence Values";
107 JMenu _options_jmenu;
108 JMenu _font_size_menu;
110 JMenuItem[] _load_phylogeny_from_webservice_menu_items;
112 JMenuItem _open_item;
113 JMenuItem _open_url_item;
114 JMenuItem _save_item;
115 JMenuItem _save_all_item;
116 JMenuItem _close_item;
117 JMenuItem _exit_item;
120 JMenuItem _midpoint_root_item;
121 JMenuItem _taxcolor_item;
122 JMenuItem _confcolor_item;
123 JMenuItem _color_rank_jmi;
124 JMenuItem _infer_common_sn_names_item;
125 JMenuItem _collapse_species_specific_subtrees;
126 JMenuItem _collapse_below_threshold; //TODO implememt me
127 JMenuItem _obtain_detailed_taxonomic_information_jmi;
128 JMenuItem _obtain_detailed_taxonomic_information_deleting_jmi;
129 JMenuItem _obtain_uniprot_seq_information_jmi;
130 JMenuItem _move_node_names_to_tax_sn_jmi;
131 JMenuItem _move_node_names_to_seq_names_jmi;
132 JMenuItem _extract_tax_code_from_node_names_jmi;
134 JMenuItem _super_tiny_fonts_item;
135 JMenuItem _tiny_fonts_item;
136 JMenuItem _small_fonts_item;
137 JMenuItem _medium_fonts_item;
138 JMenuItem _large_fonts_item;
140 // _ screen and print
141 JMenuItem _choose_font_mi;
142 JMenuItem _switch_colors_mi;
143 JCheckBoxMenuItem _label_direction_cbmi;
145 JCheckBoxMenuItem _screen_antialias_cbmi;
146 JCheckBoxMenuItem _background_gradient_cbmi;
147 JRadioButtonMenuItem _non_lined_up_cladograms_rbmi;
148 JRadioButtonMenuItem _uniform_cladograms_rbmi;
149 JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi;
150 JCheckBoxMenuItem _show_branch_length_values_cbmi;
151 JCheckBoxMenuItem _show_scale_cbmi; //TODO fix me
152 JCheckBoxMenuItem _show_overview_cbmi;
153 JCheckBoxMenuItem _show_domain_labels;
154 JCheckBoxMenuItem _abbreviate_scientific_names;
155 JCheckBoxMenuItem _color_labels_same_as_parent_branch;
156 JMenuItem _overview_placment_mi;
157 JMenuItem _choose_minimal_confidence_mi;
158 JCheckBoxMenuItem _show_default_node_shapes_cbmi;
159 JMenuItem _cycle_node_shape_mi;
160 JMenuItem _cycle_node_fill_mi;
161 JMenuItem _choose_node_size_mi;
162 JCheckBoxMenuItem _taxonomy_colorize_node_shapes_cbmi;
163 JCheckBoxMenuItem _show_confidence_stddev_cbmi;
165 JCheckBoxMenuItem _graphics_export_visible_only_cbmi;
166 JCheckBoxMenuItem _antialias_print_cbmi;
167 JCheckBoxMenuItem _print_black_and_white_cbmi;
168 JCheckBoxMenuItem _print_using_actual_size_cbmi;
169 JCheckBoxMenuItem _graphics_export_using_actual_size_cbmi;
170 JMenuItem _print_size_mi;
171 JMenuItem _choose_pdf_width_mi;
173 JCheckBoxMenuItem _internal_number_are_confidence_for_nh_parsing_cbmi;
174 JCheckBoxMenuItem _extract_pfam_style_tax_codes_cbmi;
175 JCheckBoxMenuItem _replace_underscores_cbmi;
176 JCheckBoxMenuItem _use_brackets_for_conf_in_nh_export_cbmi;
177 JCheckBoxMenuItem _use_internal_names_for_conf_in_nh_export_cbmi;
179 JCheckBoxMenuItem _search_case_senstive_cbmi;
180 JCheckBoxMenuItem _search_whole_words_only_cbmi;
181 JCheckBoxMenuItem _inverse_search_result_cbmi;
184 JCheckBoxMenuItem _rectangular_type_cbmi;
185 JCheckBoxMenuItem _triangular_type_cbmi;
186 JCheckBoxMenuItem _curved_type_cbmi;
187 JCheckBoxMenuItem _convex_type_cbmi;
188 JCheckBoxMenuItem _euro_type_cbmi;
189 JCheckBoxMenuItem _rounded_type_cbmi;
190 JCheckBoxMenuItem _unrooted_type_cbmi;
191 JCheckBoxMenuItem _circular_type_cbmi;
192 // view as text menu:
193 JMenuItem _view_as_NH_item;
194 JMenuItem _view_as_NHX_item;
195 JMenuItem _view_as_XML_item;
196 JMenuItem _view_as_nexus_item;
197 JMenuItem _display_basic_information_item;
199 JMenuItem _about_item;
200 JMenuItem _help_item;
201 JMenuItem _website_item;
202 JMenuItem _phyloxml_website_item;
203 JMenuItem _phyloxml_ref_item;
204 JMenuItem _aptx_ref_item;
205 // Handy pointers to child components:
206 MainPanel _mainpanel;
207 Container _contentpane;
208 TextFrame _textframe;
209 Configuration _configuration;
210 JMenuItem _remove_branch_color_item;
214 // Empty constructor.
220 public void actionPerformed( final ActionEvent e ) {
221 final Object o = e.getSource();
222 boolean is_applet = false;
223 JApplet applet = null;
224 if ( getCurrentTreePanel() != null ) {
225 is_applet = getCurrentTreePanel().isApplet();
227 applet = getCurrentTreePanel().obtainApplet();
230 if ( o == _open_url_item ) {
231 readPhylogeniesFromURL();
233 else if ( o == _exit_item ) {
236 else if ( o == _taxcolor_item ) {
239 else if ( o == _confcolor_item ) {
242 else if ( o == _color_rank_jmi ) {
245 else if ( o == _infer_common_sn_names_item ) {
246 if ( isSubtreeDisplayed() ) {
249 if ( getCurrentTreePanel() != null ) {
250 getCurrentTreePanel().inferCommonPartOfScientificNames();
253 else if ( o == _collapse_species_specific_subtrees ) {
254 if ( isSubtreeDisplayed() ) {
257 if ( getCurrentTreePanel() != null ) {
258 getCurrentTreePanel().collapseSpeciesSpecificSubtrees();
261 else if ( o == _remove_branch_color_item ) {
262 if ( isSubtreeDisplayed() ) {
265 removeBranchColors();
267 else if ( o == _midpoint_root_item ) {
268 if ( isSubtreeDisplayed() ) {
273 else if ( o == _switch_colors_mi ) {
276 else if ( o == _display_basic_information_item ) {
277 displayBasicInformation();
279 else if ( o == _view_as_NH_item ) {
282 else if ( o == _view_as_NHX_item ) {
285 else if ( o == _view_as_XML_item ) {
288 else if ( o == _view_as_nexus_item ) {
291 else if ( o == _super_tiny_fonts_item ) {
292 if ( getCurrentTreePanel() != null ) {
293 getCurrentTreePanel().setSuperTinyFonts();
294 getCurrentTreePanel().repaint();
297 else if ( o == _tiny_fonts_item ) {
298 if ( getCurrentTreePanel() != null ) {
299 getCurrentTreePanel().setTinyFonts();
300 getCurrentTreePanel().repaint();
303 else if ( o == _small_fonts_item ) {
304 if ( getCurrentTreePanel() != null ) {
305 getCurrentTreePanel().setSmallFonts();
306 getCurrentTreePanel().repaint();
309 else if ( o == _medium_fonts_item ) {
310 if ( getCurrentTreePanel() != null ) {
311 getCurrentTreePanel().setMediumFonts();
312 getCurrentTreePanel().repaint();
315 else if ( o == _large_fonts_item ) {
316 if ( getCurrentTreePanel() != null ) {
317 getCurrentTreePanel().setLargeFonts();
318 getCurrentTreePanel().repaint();
321 else if ( o == _choose_font_mi ) {
324 else if ( o == _choose_minimal_confidence_mi ) {
325 chooseMinimalConfidence();
327 else if ( o == _choose_node_size_mi ) {
328 chooseNodeSize( getOptions(), this );
330 else if ( o == _overview_placment_mi ) {
331 MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
333 else if ( o == _cycle_node_fill_mi ) {
334 MainFrame.cycleNodeFill( getOptions(), getCurrentTreePanel() );
336 else if ( o == _cycle_node_shape_mi ) {
337 MainFrame.cycleNodeShape( getOptions(), getCurrentTreePanel() );
339 else if ( o == _screen_antialias_cbmi ) {
340 updateOptions( getOptions() );
341 updateScreenTextAntialias( getMainPanel().getTreePanels() );
343 else if ( o == _background_gradient_cbmi ) {
344 updateOptions( getOptions() );
346 else if ( o == _show_domain_labels ) {
347 updateOptions( getOptions() );
349 else if ( o == _abbreviate_scientific_names ) {
350 updateOptions( getOptions() );
352 else if ( o == _color_labels_same_as_parent_branch ) {
353 updateOptions( getOptions() );
355 else if ( o == _show_default_node_shapes_cbmi ) {
356 updateOptions( getOptions() );
358 else if ( o == _taxonomy_colorize_node_shapes_cbmi ) {
359 updateOptions( getOptions() );
361 else if ( o == _non_lined_up_cladograms_rbmi ) {
362 updateOptions( getOptions() );
365 else if ( o == _uniform_cladograms_rbmi ) {
366 updateOptions( getOptions() );
369 else if ( o == _ext_node_dependent_cladogram_rbmi ) {
370 updateOptions( getOptions() );
373 else if ( o == _search_case_senstive_cbmi ) {
374 updateOptions( getOptions() );
375 getMainPanel().getControlPanel().search();
377 else if ( o == _search_whole_words_only_cbmi ) {
378 updateOptions( getOptions() );
379 getMainPanel().getControlPanel().search();
381 else if ( o == _inverse_search_result_cbmi ) {
382 updateOptions( getOptions() );
383 getMainPanel().getControlPanel().search();
385 else if ( o == _show_scale_cbmi ) {
386 updateOptions( getOptions() );
388 else if ( o == _show_branch_length_values_cbmi ) {
389 updateOptions( getOptions() );
391 else if ( o == _show_confidence_stddev_cbmi ) {
392 updateOptions( getOptions() );
394 else if ( o == _use_brackets_for_conf_in_nh_export_cbmi ) {
395 if ( _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {
396 _use_internal_names_for_conf_in_nh_export_cbmi.setSelected( false );
398 updateOptions( getOptions() );
400 else if ( o == _use_internal_names_for_conf_in_nh_export_cbmi ) {
401 if ( _use_internal_names_for_conf_in_nh_export_cbmi.isSelected() ) {
402 _use_brackets_for_conf_in_nh_export_cbmi.setSelected( false );
404 updateOptions( getOptions() );
406 else if ( o == _label_direction_cbmi ) {
407 updateOptions( getOptions() );
409 else if ( o == _show_overview_cbmi ) {
410 updateOptions( getOptions() );
411 if ( getCurrentTreePanel() != null ) {
412 getCurrentTreePanel().updateOvSizes();
415 else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
416 || ( o == _convex_type_cbmi ) || ( o == _euro_type_cbmi ) || ( o == _rounded_type_cbmi )
417 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
420 else if ( o == _about_item ) {
423 else if ( o == _help_item ) {
424 help( getConfiguration().getWebLinks() );
426 else if ( o == _website_item ) {
428 AptxUtil.openWebsite( Constants.APTX_WEB_SITE, is_applet, applet );
430 catch ( final IOException e1 ) {
431 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
434 else if ( o == _phyloxml_website_item ) {
436 AptxUtil.openWebsite( Constants.PHYLOXML_WEB_SITE, is_applet, applet );
438 catch ( final IOException e1 ) {
439 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
442 else if ( o == _aptx_ref_item ) {
444 AptxUtil.openWebsite( Constants.APTX_REFERENCE_URL, is_applet, applet );
446 catch ( final IOException e1 ) {
447 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
450 else if ( o == _phyloxml_ref_item ) {
452 AptxUtil.openWebsite( Constants.PHYLOXML_REFERENCE_URL, is_applet, applet );
454 catch ( final IOException e1 ) {
455 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
459 if ( _load_phylogeny_from_webservice_menu_items != null ) {
460 for( int i = 0; i < _load_phylogeny_from_webservice_menu_items.length; ++i ) {
461 if ( o == _load_phylogeny_from_webservice_menu_items[ i ] ) {
462 readPhylogeniesFromWebservice( i );
467 _contentpane.repaint();
470 boolean isSubtreeDisplayed() {
471 if ( getCurrentTreePanel() != null ) {
472 if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
474 .showMessageDialog( this,
475 "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",
476 "Operation can not be exectuted on a sub-tree",
477 JOptionPane.WARNING_MESSAGE );
484 void activateSaveAllIfNeeded() {
485 if ( ( getMainPanel().getTabbedPane() != null ) && ( getMainPanel().getTabbedPane().getTabCount() > 1 ) ) {
486 _save_all_item.setEnabled( true );
489 _save_all_item.setEnabled( false );
493 void buildFileMenu() {
494 _file_jmenu = createMenu( "File", getConfiguration() );
495 _file_jmenu.add( _open_url_item = new JMenuItem( "Read tree from URL/webservice..." ) );
496 _file_jmenu.addSeparator();
497 _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );
498 customizeJMenuItem( _open_url_item );
499 customizeJMenuItem( _exit_item );
500 _jmenubar.add( _file_jmenu );
503 void buildFontSizeMenu() {
504 _font_size_menu = createMenu( FONT_SIZE_MENU_LABEL, getConfiguration() );
505 _font_size_menu.add( _super_tiny_fonts_item = new JMenuItem( "Super Tiny Fonts" ) );
506 _font_size_menu.add( _tiny_fonts_item = new JMenuItem( "Tiny Fonts" ) );
507 _font_size_menu.add( _small_fonts_item = new JMenuItem( "Small Fonts" ) );
508 _font_size_menu.add( _medium_fonts_item = new JMenuItem( "Medium Fonts" ) );
509 _font_size_menu.add( _large_fonts_item = new JMenuItem( "Large Fonts" ) );
510 customizeJMenuItem( _super_tiny_fonts_item );
511 customizeJMenuItem( _tiny_fonts_item );
512 customizeJMenuItem( _small_fonts_item );
513 customizeJMenuItem( _medium_fonts_item );
514 customizeJMenuItem( _large_fonts_item );
515 _jmenubar.add( _font_size_menu );
518 void buildHelpMenu() {
519 _help_jmenu = createMenu( "Help", getConfiguration() );
520 _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
521 _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
522 _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
523 _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
524 _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
525 _help_jmenu.addSeparator();
526 _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
527 customizeJMenuItem( _help_item );
528 customizeJMenuItem( _website_item );
529 customizeJMenuItem( _phyloxml_website_item );
530 customizeJMenuItem( _aptx_ref_item );
531 customizeJMenuItem( _phyloxml_ref_item );
532 customizeJMenuItem( _about_item );
533 _phyloxml_ref_item.setToolTipText( PHYLOXML_REF_TOOL_TIP );
534 _aptx_ref_item.setToolTipText( APTX_REF_TOOL_TIP );
535 _jmenubar.add( _help_jmenu );
538 void buildTypeMenu() {
539 _type_menu = createMenu( TYPE_MENU_HEADER, getConfiguration() );
540 _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
541 _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
542 _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
543 _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
544 _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
545 _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
546 _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
547 _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
548 customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
549 customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
550 customizeCheckBoxMenuItem( _euro_type_cbmi, false );
551 customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
552 customizeCheckBoxMenuItem( _curved_type_cbmi, false );
553 customizeCheckBoxMenuItem( _convex_type_cbmi, false );
554 customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
555 customizeCheckBoxMenuItem( _circular_type_cbmi, false );
556 _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
557 _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
558 initializeTypeMenu( getOptions() );
559 _jmenubar.add( _type_menu );
562 void buildViewMenu() {
563 _view_jmenu = createMenu( "View", getConfiguration() );
564 _view_jmenu.add( _display_basic_information_item = new JMenuItem( "Display Basic Information" ) );
565 _view_jmenu.addSeparator();
566 _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) );
567 _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) );
568 _view_jmenu.add( _view_as_NHX_item = new JMenuItem( "View as NHX" ) );
569 _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "View as Nexus" ) );
570 customizeJMenuItem( _display_basic_information_item );
571 customizeJMenuItem( _view_as_NH_item );
572 customizeJMenuItem( _view_as_NHX_item );
573 customizeJMenuItem( _view_as_XML_item );
574 customizeJMenuItem( _view_as_nexus_item );
575 _jmenubar.add( _view_jmenu );
578 private void chooseFont() {
579 final FontChooser fc = new FontChooser();
580 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
581 fc.showDialog( this, "Select the Base Font" );
582 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
585 private void chooseMinimalConfidence() {
586 final String s = ( String ) JOptionPane
587 .showInputDialog( this,
588 "Please enter the minimum for confidence values to be displayed.\n"
589 + "[current value: " + getOptions().getMinConfidenceValue() + "]\n",
590 "Minimal Confidence Value",
591 JOptionPane.QUESTION_MESSAGE,
594 getOptions().getMinConfidenceValue() );
595 if ( !ForesterUtil.isEmpty( s ) ) {
596 boolean success = true;
598 final String m_str = s.trim();
599 if ( !ForesterUtil.isEmpty( m_str ) ) {
601 m = Double.parseDouble( m_str );
603 catch ( final Exception ex ) {
610 if ( success && ( m >= 0.0 ) ) {
611 getOptions().setMinConfidenceValue( m );
616 static void chooseNodeSize( final Options options, final Component parent ) {
617 final String s = ( String ) JOptionPane.showInputDialog( parent,
618 "Please enter the default size for node shapes.\n"
620 + options.getDefaultNodeShapeSize() + "]\n",
622 JOptionPane.QUESTION_MESSAGE,
625 options.getDefaultNodeShapeSize() );
626 if ( !ForesterUtil.isEmpty( s ) ) {
627 boolean success = true;
629 final String m_str = s.trim();
630 if ( !ForesterUtil.isEmpty( m_str ) ) {
632 m = Double.parseDouble( m_str );
634 catch ( final Exception ex ) {
641 if ( success && ( m >= 0.0 ) ) {
642 final short size = ForesterUtil.roundToShort( m );
644 options.setDefaultNodeShapeSize( size );
652 if ( _mainpanel != null ) {
653 _mainpanel.terminate();
655 if ( _contentpane != null ) {
656 _contentpane.removeAll();
663 if ( _mainpanel.getCurrentTreePanel() != null ) {
664 _mainpanel.getCurrentTreePanel().confColor();
669 if ( _mainpanel.getCurrentTreePanel() != null ) {
670 final String[] ranks = AptxUtil.getAllPossibleRanks();
671 final String rank = ( String ) JOptionPane
672 .showInputDialog( this,
673 "What rank should the colorization be based on",
675 JOptionPane.QUESTION_MESSAGE,
679 if ( !ForesterUtil.isEmpty( rank ) ) {
680 _mainpanel.getCurrentTreePanel().colorRank( rank );
685 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
686 if ( item != null ) {
687 item.setFont( MainFrame.menu_font );
688 if ( !getConfiguration().isUseNativeUI() ) {
689 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
690 item.setForeground( getConfiguration().getGuiMenuTextColor() );
692 item.setSelected( is_selected );
693 item.addActionListener( this );
697 void customizeJMenuItem( final JMenuItem jmi ) {
699 jmi.setFont( MainFrame.menu_font );
700 if ( !getConfiguration().isUseNativeUI() ) {
701 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
702 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
704 jmi.addActionListener( this );
708 void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
709 if ( item != null ) {
710 item.setFont( MainFrame.menu_font );
711 if ( !getConfiguration().isUseNativeUI() ) {
712 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
713 item.setForeground( getConfiguration().getGuiMenuTextColor() );
715 item.setSelected( is_selected );
716 item.addActionListener( this );
720 void exceptionOccuredDuringOpenFile( final Exception e ) {
722 _mainpanel.getCurrentTreePanel().setArrowCursor();
724 catch ( final Exception ex ) {
727 JOptionPane.showMessageDialog( this,
728 ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
729 "Error during File|Open",
730 JOptionPane.ERROR_MESSAGE );
733 void exceptionOccuredDuringSaveAs( final Exception e ) {
735 _mainpanel.getCurrentTreePanel().setArrowCursor();
737 catch ( final Exception ex ) {
740 JOptionPane.showMessageDialog( this, "Exception" + e, "Error during File|SaveAs", JOptionPane.ERROR_MESSAGE );
743 boolean GAndSDoHaveMoreThanOneSpeciesInComman( final Phylogeny gene_tree ) {
744 if ( ( gene_tree == null ) || gene_tree.isEmpty() ) {
745 JOptionPane.showMessageDialog( this,
746 "Gene tree and species tree have no species in common.",
748 JOptionPane.ERROR_MESSAGE );
751 else if ( gene_tree.getNumberOfExternalNodes() < 2 ) {
752 JOptionPane.showMessageDialog( this,
753 "Gene tree and species tree have only one species in common.",
755 JOptionPane.ERROR_MESSAGE );
763 public Configuration getConfiguration() {
764 return _configuration;
767 TreePanel getCurrentTreePanel() {
768 return getMainPanel().getCurrentTreePanel();
771 JMenu getHelpMenu() {
775 JCheckBoxMenuItem getlabelDirectionCbmi() {
776 return _label_direction_cbmi;
779 MainPanel getMainPanel() {
783 JMenuBar getMenuBarOfMainFrame() {
787 public Options getOptions() {
791 void initializeTypeMenu( final Options options ) {
792 setTypeMenuToAllUnselected();
793 switch ( options.getPhylogenyGraphicsType() ) {
795 _convex_type_cbmi.setSelected( true );
798 _curved_type_cbmi.setSelected( true );
801 _euro_type_cbmi.setSelected( true );
804 _rounded_type_cbmi.setSelected( true );
807 _triangular_type_cbmi.setSelected( true );
810 _unrooted_type_cbmi.setSelected( true );
813 _circular_type_cbmi.setSelected( true );
816 _rectangular_type_cbmi.setSelected( true );
821 void midpointRoot() {
822 if ( _mainpanel.getCurrentTreePanel() != null ) {
823 _mainpanel.getCurrentTreePanel().midpointRoot();
827 abstract void readPhylogeniesFromURL();
829 void readPhylogeniesFromWebservice( final int i ) {
830 final UrlTreeReader reader = new UrlTreeReader( this, i );
831 new Thread( reader ).start();
834 private void removeBranchColors() {
835 if ( getMainPanel().getCurrentPhylogeny() != null ) {
836 AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
840 void removeTextFrame() {
841 if ( _textframe != null ) {
847 void setConfiguration( final Configuration configuration ) {
848 _configuration = configuration;
851 void setOptions( final Options options ) {
855 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
856 setTypeMenuToAllUnselected();
859 _circular_type_cbmi.setSelected( true );
862 _convex_type_cbmi.setSelected( true );
865 _curved_type_cbmi.setSelected( true );
868 _euro_type_cbmi.setSelected( true );
871 _rounded_type_cbmi.setSelected( true );
874 _rectangular_type_cbmi.setSelected( true );
877 _triangular_type_cbmi.setSelected( true );
880 _unrooted_type_cbmi.setSelected( true );
883 throw new IllegalArgumentException( "unknown type: " + type );
887 void setTypeMenuToAllUnselected() {
888 _convex_type_cbmi.setSelected( false );
889 _curved_type_cbmi.setSelected( false );
890 _euro_type_cbmi.setSelected( false );
891 _rounded_type_cbmi.setSelected( false );
892 _triangular_type_cbmi.setSelected( false );
893 _rectangular_type_cbmi.setSelected( false );
894 _unrooted_type_cbmi.setSelected( false );
895 _circular_type_cbmi.setSelected( false );
898 public void showWhole() {
899 _mainpanel.getControlPanel().showWhole();
902 void switchColors() {
903 final TreeColorSet colorset = _mainpanel.getTreeColorSet();
904 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
905 csc.setVisible( true );
909 if ( _mainpanel.getCurrentTreePanel() != null ) {
910 _mainpanel.getCurrentTreePanel().taxColor();
914 void typeChanged( final Object o ) {
915 updateTypeCheckboxes( getOptions(), o );
916 updateOptions( getOptions() );
917 if ( getCurrentTreePanel() != null ) {
918 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
919 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
920 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
921 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
922 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
923 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
924 getCurrentTreePanel().getControlPanel().showWhole();
926 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
927 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
930 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
932 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
933 updateScreenTextAntialias( getMainPanel().getTreePanels() );
934 if ( getCurrentTreePanel().getControlPanel().getDynamicallyHideData() != null ) {
935 if ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
936 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( false );
939 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( true );
945 void updateOptions( final Options options ) {
946 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
947 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
948 && _background_gradient_cbmi.isSelected() );
949 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
950 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
951 && _abbreviate_scientific_names.isSelected() );
952 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
953 && _color_labels_same_as_parent_branch.isSelected() );
954 options.setShowDefaultNodeShapes( ( _show_default_node_shapes_cbmi != null )
955 && _show_default_node_shapes_cbmi.isSelected() );
956 options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null )
957 && _taxonomy_colorize_node_shapes_cbmi.isSelected() );
958 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
959 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
961 else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
962 options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
964 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
965 options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
967 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
968 && _search_case_senstive_cbmi.isSelected() );
969 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
970 options.setShowScale( _show_scale_cbmi.isSelected() );
972 if ( _label_direction_cbmi != null ) {
973 if ( _label_direction_cbmi.isSelected() ) {
974 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
977 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
980 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
981 options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )
982 && _show_confidence_stddev_cbmi.isSelected() );
983 if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
984 options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
986 options.setPrintUsingActualSize( ( _print_using_actual_size_cbmi != null )
987 && ( _print_using_actual_size_cbmi.isSelected() ) );
988 options.setGraphicsExportUsingActualSize( ( _graphics_export_using_actual_size_cbmi != null )
989 && ( _graphics_export_using_actual_size_cbmi.isSelected() ) );
990 options.setAntialiasPrint( ( _antialias_print_cbmi != null ) && _antialias_print_cbmi.isSelected() );
991 if ( ( _use_brackets_for_conf_in_nh_export_cbmi != null )
992 && _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {
993 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );
995 else if ( ( _use_internal_names_for_conf_in_nh_export_cbmi != null )
996 && _use_internal_names_for_conf_in_nh_export_cbmi.isSelected() ) {
997 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES );
1000 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE );
1002 options.setPrintBlackAndWhite( ( _print_black_and_white_cbmi != null )
1003 && _print_black_and_white_cbmi.isSelected() );
1004 options.setInternalNumberAreConfidenceForNhParsing( ( _internal_number_are_confidence_for_nh_parsing_cbmi != null )
1005 && _internal_number_are_confidence_for_nh_parsing_cbmi.isSelected() );
1006 options.setExtractPfamTaxonomyCodesInNhParsing( ( _extract_pfam_style_tax_codes_cbmi != null )
1007 && _extract_pfam_style_tax_codes_cbmi.isSelected() );
1008 options.setReplaceUnderscoresInNhParsing( ( _replace_underscores_cbmi != null )
1009 && _replace_underscores_cbmi.isSelected() );
1010 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
1011 && _search_whole_words_only_cbmi.isSelected() );
1012 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
1013 && _inverse_search_result_cbmi.isSelected() );
1014 if ( _graphics_export_visible_only_cbmi != null ) {
1015 options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() );
1016 if ( _graphics_export_visible_only_cbmi.isSelected() && ( _graphics_export_using_actual_size_cbmi != null ) ) {
1017 _graphics_export_using_actual_size_cbmi.setSelected( true );
1018 _graphics_export_using_actual_size_cbmi.setEnabled( false );
1021 _graphics_export_using_actual_size_cbmi.setEnabled( true );
1024 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
1025 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1027 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
1028 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1030 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
1031 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1033 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
1034 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1036 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
1037 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1039 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
1040 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1042 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
1043 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1045 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
1046 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1050 void updateTypeCheckboxes( final Options options, final Object o ) {
1051 setTypeMenuToAllUnselected();
1052 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
1055 void displayBasicInformation() {
1056 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty() ) {
1059 _textframe = TextFrame.instantiate( AptxUtil.createBasicInformation( _mainpanel.getCurrentPhylogeny() ) );
1062 void viewAsNexus() {
1064 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty()
1065 || ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() > 20000 ) ) {
1068 _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny().toNexus( getOptions()
1069 .getNhConversionSupportValueStyle() ) );
1074 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty()
1075 || ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() > 20000 ) ) {
1078 _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny()
1079 .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ) );
1084 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty()
1085 || ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
1088 _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny().toNewHampshireX() );
1093 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty()
1094 && ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() <= 10000 ) ) {
1095 _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny().toPhyloXML( 0 ) );
1100 * Display the about box.
1102 static void about() {
1103 final StringBuffer about = new StringBuffer( "Archaeopteryx\nVersion " + Constants.VERSION + "\n" );
1104 about.append( "Copyright (C) 2007-2011 Christian Zmasek\n" );
1105 about.append( "All Rights Reserved\n" );
1106 about.append( "License: GNU Lesser General Public License (LGPL)\n" );
1107 about.append( "Last modified: " + Constants.PRG_DATE + "\n" );
1108 about.append( "phyloXML version : " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1109 about.append( "phyloXML location: " + ForesterConstants.PHYLO_XML_LOCATION + "\n" );
1110 if ( !ForesterUtil.isEmpty( ForesterUtil.JAVA_VERSION ) && !ForesterUtil.isEmpty( ForesterUtil.JAVA_VENDOR ) ) {
1111 about.append( "[your Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]\n" );
1113 if ( !ForesterUtil.isEmpty( ForesterUtil.OS_NAME ) && !ForesterUtil.isEmpty( ForesterUtil.OS_ARCH )
1114 && !ForesterUtil.isEmpty( ForesterUtil.OS_VERSION ) ) {
1115 about.append( "[your OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " "
1116 + ForesterUtil.OS_VERSION + "]\n" );
1118 final Runtime rt = java.lang.Runtime.getRuntime();
1119 final long free_memory = rt.freeMemory() / 1000000;
1120 final long total_memory = rt.totalMemory() / 1000000;
1121 about.append( "[free memory: " + free_memory + "MB, total memory: " + total_memory + "MB]\n" );
1122 about.append( "[locale: " + Locale.getDefault() + "]\n" );
1123 about.append( "References:\n" );
1124 about.append( Constants.PHYLOXML_REFERENCE_SHORT + "\n" );
1125 about.append( "For more information & download:\n" );
1126 about.append( Constants.APTX_WEB_SITE + "\n" );
1127 about.append( "Comments: " + Constants.AUTHOR_EMAIL );
1128 JOptionPane.showMessageDialog( null, about, Constants.PRG_NAME, JOptionPane.PLAIN_MESSAGE );
1131 static String createCurrentFontDesc( final TreeFontSet tree_font_set ) {
1132 return tree_font_set.getLargeFont().getFamily() + " " + tree_font_set.getLargeFont().getSize();
1135 static JMenu createMenu( final String title, final Configuration conf ) {
1136 final JMenu jmenu = new JMenu( title );
1137 if ( !conf.isUseNativeUI() ) {
1138 jmenu.setFont( MainFrame.menu_font );
1139 jmenu.setBackground( conf.getGuiMenuBackgroundColor() );
1140 jmenu.setForeground( conf.getGuiMenuTextColor() );
1145 static JMenuItem customizeMenuItemAsLabel( final JMenuItem label, final Configuration configuration ) {
1146 label.setFont( MainFrame.menu_font.deriveFont( Font.BOLD ) );
1147 if ( !configuration.isUseNativeUI() ) {
1148 label.setBackground( configuration.getGuiMenuBackgroundColor() );
1149 label.setForeground( configuration.getGuiMenuTextColor() );
1150 label.setOpaque( true );
1152 label.setSelected( false );
1153 label.setEnabled( false );
1157 static void cycleOverview( final Options op, final TreePanel tree_panel ) {
1158 switch ( op.getOvPlacement() ) {
1160 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1163 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1166 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1169 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1172 throw new RuntimeException( "unknown placement: " + op.getOvPlacement() );
1174 if ( tree_panel != null ) {
1175 tree_panel.updateOvSettings();
1179 static void cycleNodeFill( final Options op, final TreePanel tree_panel ) {
1180 switch ( op.getDefaultNodeFill() ) {
1182 op.setDefaultNodeFill( NodeFill.SOLID );
1185 op.setDefaultNodeFill( NodeFill.GRADIENT );
1188 op.setDefaultNodeFill( NodeFill.NONE );
1191 throw new RuntimeException( "unknown fill: " + op.getDefaultNodeFill() );
1195 static void cycleNodeShape( final Options op, final TreePanel tree_panel ) {
1196 switch ( op.getDefaultNodeShape() ) {
1198 op.setDefaultNodeShape( NodeShape.RECTANGLE );
1201 op.setDefaultNodeShape( NodeShape.CIRCLE );
1204 throw new RuntimeException( "unknown shape: " + op.getDefaultNodeShape() );
1208 static void help( final Map<String, WebLink> weblinks ) {
1209 final StringBuilder sb = new StringBuilder();
1210 sb.append( "Display options\n" );
1211 sb.append( "-------------------\n" );
1212 sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
1213 sb.append( "Clickable tree nodes\n" );
1214 sb.append( "--------------------\n" );
1215 sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
1216 sb.append( "or by right clicking:\n" );
1217 sb.append( "o Display Node Data -- display information for a node\n" );
1218 sb.append( "o Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
1219 sb.append( "o Root/Reroot -- change tree root to clicked node\n" );
1220 sb.append( "o Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
1221 sb.append( "o Swap Descendants -- switch descendant on either side of clicked node\n" );
1222 sb.append( "o Colorize Subtree -- color a subtree\n" );
1223 sb.append( "o Open Sequence Web -- launch a web browser to display sequence information\n" );
1224 sb.append( "o Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
1225 sb.append( "- there may be additional choices depending on this particular setup\n\n" );
1226 sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
1227 sb.append( "Zooming\n" );
1228 sb.append( "---------\n" );
1229 sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
1230 sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
1231 sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
1232 sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
1233 sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
1234 sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
1235 sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
1236 sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
1237 sb.append( "Quick tree manipulation:\n" );
1238 sb.append( "------------------------\n" );
1239 sb.append( "Order Subtrees -- order the tree by branch length\n" );
1240 sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
1241 sb.append( "Memory problems (Java heap space error)\n" );
1242 sb.append( "---------------------------------------\n" );
1243 sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
1244 sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
1245 sb.append( "the '-Xmx' Java command line option. For example:\n" );
1246 sb.append( "java -Xms32m -Xmx256m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
1247 if ( ( weblinks != null ) && ( weblinks.size() > 0 ) ) {
1248 sb.append( "Active web links\n" );
1249 sb.append( "--------------------\n" );
1250 for( final String key : weblinks.keySet() ) {
1251 sb.append( " " + weblinks.get( key ).toString() + "\n" );
1254 // + "General remarks\n"
1255 // + "---------------\n"
1257 // "o The application version permits copying to the clipboard \n"
1259 // " in the \"View\"|\"View as ...\" frame (either by control-c or button press).\n"
1261 // "o Changes made to a subtree affect this subtree and its subtrees,\n"
1262 // + " but not any of its parent tree(s).\n"
1264 // "o Archaeopteryx tries to detect whether the numerical values in a NH tree\n"
1266 // " are likely to be bootstrap values instead of branch length values.\n\n"
1268 // " Remarks regarding SDI (Speciation Duplication Inference):\n"
1270 // "o Each external node of the gene tree (in display) needs to be associated with\n"
1272 // " a species: either directly through the \"Species\" field, or the species\n"
1274 // " is part of the sequence name in the form \"XXXX_SPECIES\"\n"
1276 // " (e.g. \"ACON_DROME\" or \"ACON_DROME/123-4489\" which is also acceptable).\n"
1278 // "o A species tree for each species of the gene tree needs to be loaded with\n"
1280 // " \"SDI\"|\"Load species tree\" prior the SDI execution.\n"
1282 // "o !External nodes of the gene tree associated with species not present in\n"
1284 // " the species tree are REMOVED prior to SDI execution!\n"
1286 // "o Both the gene tree and the species tree must be completely binary.\n"
1288 // "o Duplications and speciations are a function of the position of the root.\n"
1290 // " Hence, after each manual \"Root/Reroot\"ing some duplications will be\n"
1291 // + " incorrect and need to be inferred again\n"
1293 // " with: \"SDI\"|\"SDI (Speciation Duplication Inference)\n\n"
1295 sb.append( "phyloXML\n" );
1296 sb.append( "-------------------\n" );
1297 sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
1298 sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
1299 sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1301 sb.append( "For more information: http://www.phylosoft.org/archaeopteryx/\n" );
1302 sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
1303 TextFrame.instantiate( sb.toString() );
1306 static void setOvPlacementColorChooseMenuItem( final JMenuItem mi, final Options options ) {
1307 if ( ( options != null ) && ( options.getOvPlacement() != null ) ) {
1308 mi.setText( "Cycle Overview Placement... (current: " + options.getOvPlacement() + ")" );
1311 mi.setText( "Cycle Overview Placement..." );
1315 static void setCycleNodeFillMenuItem( final JMenuItem mi, final Options options ) {
1316 if ( ( options != null ) && ( options.getDefaultNodeFill() != null ) ) {
1317 mi.setText( "Cycle Node Shape Fill Type... (current: "
1318 + options.getDefaultNodeFill().toString().toLowerCase() + ")" );
1321 mi.setText( "Cycle Node Shape Fill Type..." );
1325 static void setCycleNodeShapeMenuItem( final JMenuItem mi, final Options options ) {
1326 if ( ( options != null ) && ( options.getDefaultNodeShape() != null ) ) {
1327 mi.setText( "Cycle Node Shape Fill Type... (current: "
1328 + options.getDefaultNodeShape().toString().toLowerCase() + ")" );
1331 mi.setText( "Cycle Node Shape Fill Type..." );
1335 static void setTextColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {
1336 if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {
1337 mi.setText( "Select Colors... (current: " + tree_panel.getTreeColorSet().getCurrentColorSchemeName() + ")" );
1340 mi.setText( "Select Colors..." );
1344 static void setTextForFontChooserMenuItem( final JMenuItem mi, final String font_desc ) {
1345 mi.setText( "Select Font... (current: " + font_desc + ")" );
1348 static void setTextMinSupportMenuItem( final JMenuItem mi, final Options options, final TreePanel current_tree_panel ) {
1349 if ( ( current_tree_panel == null ) || ( current_tree_panel.getPhylogeny() == null ) ) {
1350 mi.setEnabled( true );
1352 else if ( AptxUtil.isHasAtLeastOneBranchWithSupportValues( current_tree_panel.getPhylogeny() ) ) {
1353 mi.setEnabled( true );
1356 mi.setEnabled( false );
1358 mi.setText( "Enter Min Confidence Value... (current: " + options.getMinConfidenceValue() + ")" );
1361 static void setTextNodeSizeMenuItem( final JMenuItem mi, final Options options ) {
1362 mi.setText( "Enter Default Node Shape Size... (current: " + options.getDefaultNodeShapeSize() + ")" );
1365 static void updateOptionsMenuDependingOnPhylogenyType( final MainPanel main_panel,
1366 final JCheckBoxMenuItem scale,
1367 final JCheckBoxMenuItem branch_lengths,
1368 final JRadioButtonMenuItem non_lined_up,
1369 final JRadioButtonMenuItem uniform_clado,
1370 final JRadioButtonMenuItem nonuniform_clado,
1371 final JCheckBoxMenuItem label_direction_cbmi ) {
1372 final TreePanel tree_panel = main_panel.getCurrentTreePanel();
1373 final ControlPanel control = main_panel.getControlPanel();
1374 final Options options = main_panel.getOptions();
1375 scale.setSelected( options.isShowScale() );
1376 branch_lengths.setSelected( options.isShowBranchLengthValues() );
1377 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1378 if ( ( tree_panel != null ) && ( !tree_panel.isPhyHasBranchLengths() ) ) {
1379 scale.setSelected( false );
1380 scale.setEnabled( false );
1381 branch_lengths.setSelected( false );
1382 branch_lengths.setEnabled( false );
1384 else if ( ( tree_panel != null ) && !control.isDrawPhylogram() ) {
1385 scale.setSelected( false );
1386 scale.setEnabled( false );
1387 branch_lengths.setEnabled( true );
1390 scale.setEnabled( true );
1391 branch_lengths.setEnabled( true );
1393 if ( ( tree_panel != null )
1394 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.ROUNDED )
1395 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1396 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1397 branch_lengths.setSelected( false );
1398 branch_lengths.setEnabled( false );
1400 if ( tree_panel != null ) {
1401 if ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1402 || ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
1403 non_lined_up.setEnabled( false );
1404 uniform_clado.setEnabled( false );
1405 nonuniform_clado.setEnabled( false );
1408 non_lined_up.setEnabled( true );
1409 uniform_clado.setEnabled( true );
1410 nonuniform_clado.setEnabled( true );
1414 if ( ( tree_panel != null )
1415 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1416 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1417 branch_lengths.setSelected( false );
1418 branch_lengths.setEnabled( false );
1420 if ( ( tree_panel != null )
1421 && ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( tree_panel
1422 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
1423 non_lined_up.setEnabled( false );
1426 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1427 non_lined_up.setEnabled( true );
1430 label_direction_cbmi.setEnabled( true );
1431 if ( tree_panel != null ) {
1432 if ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1433 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1434 label_direction_cbmi.setEnabled( false );
1436 if ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
1437 scale.setSelected( false );
1438 scale.setEnabled( false );
1443 static void updateScreenTextAntialias( final List<TreePanel> treepanels ) {
1444 for( final TreePanel tree_panel : treepanels ) {
1445 tree_panel.setTextAntialias();