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: https://sites.google.com/site/cmzmasek/home/software/forester
25 package org.forester.archaeopteryx;
27 import java.awt.Color;
28 import java.awt.Component;
29 import java.awt.Container;
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
33 import java.io.IOException;
34 import java.util.LinkedList;
35 import java.util.List;
36 import java.util.Locale;
37 import java.util.NoSuchElementException;
40 import javax.swing.Box;
41 import javax.swing.JApplet;
42 import javax.swing.JCheckBoxMenuItem;
43 import javax.swing.JFrame;
44 import javax.swing.JLabel;
45 import javax.swing.JMenu;
46 import javax.swing.JMenuBar;
47 import javax.swing.JMenuItem;
48 import javax.swing.JOptionPane;
49 import javax.swing.JPanel;
50 import javax.swing.JRadioButtonMenuItem;
51 import javax.swing.JTextField;
52 import javax.swing.SwingUtilities;
54 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
55 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
56 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
57 import org.forester.archaeopteryx.tools.InferenceManager;
58 import org.forester.archaeopteryx.tools.ProcessPool;
59 import org.forester.archaeopteryx.tools.ProcessRunning;
60 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
61 import org.forester.phylogeny.Phylogeny;
62 import org.forester.phylogeny.PhylogenyMethods;
63 import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
64 import org.forester.phylogeny.PhylogenyNode;
65 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
66 import org.forester.phylogeny.data.Annotation;
67 import org.forester.phylogeny.data.NodeVisualization.NodeFill;
68 import org.forester.phylogeny.data.NodeVisualization.NodeShape;
69 import org.forester.sdi.GSDI;
70 import org.forester.sdi.GSDIR;
71 import org.forester.sdi.SDIException;
72 import org.forester.util.ForesterConstants;
73 import org.forester.util.ForesterUtil;
75 public abstract class MainFrame extends JFrame implements ActionListener {
77 static final String USE_MOUSEWHEEL_SHIFT_TO_ROTATE = "In this display type, use mousewheel + Shift to rotate [or A and S]";
78 static final String PHYLOXML_REF_TOOL_TIP = Constants.PHYLOXML_REFERENCE; //TODO //FIXME
79 static final String APTX_REF_TOOL_TIP = Constants.APTX_REFERENCE;
80 private static final long serialVersionUID = 3655000897845508358L;
81 final static Font menu_font = new Font( Configuration.getDefaultFontFamilyName(),
84 static final String TYPE_MENU_HEADER = "Type";
85 static final String RECTANGULAR_TYPE_CBMI_LABEL = "Rectangular";
86 static final String EURO_TYPE_CBMI_LABEL = "Euro Type";
87 static final String CURVED_TYPE_CBMI_LABEL = "Curved";
88 static final String TRIANGULAR_TYPE_CBMI_LABEL = "Triangular";
89 static final String CONVEX_TYPE_CBMI_LABEL = "Convex";
90 static final String ROUNDED_TYPE_CBMI_LABEL = "Rounded";
91 static final String UNROOTED_TYPE_CBMI_LABEL = "Unrooted (alpha)"; //TODO
92 static final String CIRCULAR_TYPE_CBMI_LABEL = "Circular (alpha)"; //TODO
93 static final String OPTIONS_HEADER = "Options";
94 static final String SEARCH_SUBHEADER = "Search:";
95 static final String DISPLAY_SUBHEADER = "Display:";
96 static final String SEARCH_TERMS_ONLY_LABEL = "Match Complete Terms Only";
97 static final String SEARCH_CASE_SENSITIVE_LABEL = "Case Sensitive";
98 static final String INVERSE_SEARCH_RESULT_LABEL = "Negate Result";
99 static final String DISPLAY_BRANCH_LENGTH_VALUES_LABEL = "Display Branch Length Values";
100 static final String DISPLAY_SCALE_LABEL = "Display Scale";
101 static final String NON_LINED_UP_CLADOGRAMS_LABEL = "Non-Lined Up Cladograms";
102 static final String UNIFORM_CLADOGRAMS_LABEL = "Total Node Sum Dependent Cladograms";
103 static final String LABEL_DIRECTION_LABEL = "Radial Labels";
104 static final String LABEL_DIRECTION_TIP = "To use radial node labels in radial and unrooted display types";
105 static final String SCREEN_ANTIALIAS_LABEL = "Antialias";
106 static final String COLOR_LABELS_LABEL = "Colorize Labels Same as Parent Branch";
107 static final String BG_GRAD_LABEL = "Background Color Gradient";
108 static final String DISPLAY_NODE_BOXES_LABEL_EXT = "Show External Node Shapes";
109 static final String DISPLAY_NODE_BOXES_LABEL_INT = "Show Internal Node Shapes";
110 static final String SHOW_OVERVIEW_LABEL = "Show Overview";
111 static final String FONT_SIZE_MENU_LABEL = "Font Size";
112 static final String NONUNIFORM_CLADOGRAMS_LABEL = "External Node Sum Dependent Cladograms";
113 static final String SHOW_DOMAIN_LABELS_LABEL = "Show Domain Labels";
114 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";
115 static final String ABBREV_SN_LABEL = "Abbreviate Scientific Taxonomic Names";
116 static final String TAXONOMY_COLORIZE_NODE_SHAPES_LABEL = "Colorize Node Shapes According to Taxonomy";
117 static final String CYCLE_NODE_SHAPE_LABEL = "Cycle Node Shapes";
118 static final String CYCLE_NODE_FILL_LABEL = "Cycle Node Fill Type";
119 static final String CHOOSE_NODE_SIZE_LABEL = "Choose Node Shape Size";
120 static final String SHOW_CONF_STDDEV_LABEL = "Show Confidence Standard Deviations";
121 static final String USE_BRACKETS_FOR_CONF_IN_NH_LABEL = "Use Brackets for Confidence Values";
122 static final String USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL = "Use Internal Node Names for Confidence Values";
127 JMenu _options_jmenu;
128 JMenu _font_size_menu;
130 JMenuItem[] _load_phylogeny_from_webservice_menu_items;
132 JMenu _analysis_menu;
133 JMenuItem _load_species_tree_item;
134 JMenuItem _gsdi_item;
135 JMenuItem _gsdir_item;
136 JMenuItem _lineage_inference;
137 JMenuItem _function_analysis;
139 JMenuItem _open_item;
140 JMenuItem _open_url_item;
141 JMenuItem _save_item;
142 JMenuItem _save_all_item;
143 JMenuItem _close_item;
144 JMenuItem _exit_item;
147 JMenuItem _midpoint_root_item;
148 JMenuItem _taxcolor_item;
149 JMenuItem _confcolor_item;
150 JMenuItem _color_rank_jmi;
151 JMenuItem _collapse_species_specific_subtrees;
152 JMenuItem _collapse_below_threshold; //TODO implememt me
153 JMenuItem _obtain_detailed_taxonomic_information_jmi;
154 JMenuItem _obtain_detailed_taxonomic_information_deleting_jmi;
155 JMenuItem _obtain_seq_information_jmi;
156 JMenuItem _move_node_names_to_tax_sn_jmi;
157 JMenuItem _move_node_names_to_seq_names_jmi;
158 JMenuItem _extract_tax_code_from_node_names_jmi;
159 JMenuItem _annotate_item;
161 JMenuItem _super_tiny_fonts_item;
162 JMenuItem _tiny_fonts_item;
163 JMenuItem _small_fonts_item;
164 JMenuItem _medium_fonts_item;
165 JMenuItem _large_fonts_item;
167 // _ screen and print
168 JMenuItem _choose_font_mi;
169 JMenuItem _switch_colors_mi;
170 JCheckBoxMenuItem _label_direction_cbmi;
172 JCheckBoxMenuItem _screen_antialias_cbmi;
173 JCheckBoxMenuItem _background_gradient_cbmi;
174 JRadioButtonMenuItem _non_lined_up_cladograms_rbmi;
175 JRadioButtonMenuItem _uniform_cladograms_rbmi;
176 JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi;
177 JCheckBoxMenuItem _show_branch_length_values_cbmi;
178 JCheckBoxMenuItem _show_scale_cbmi; //TODO fix me
179 JCheckBoxMenuItem _show_overview_cbmi;
180 JCheckBoxMenuItem _show_domain_labels;
181 JCheckBoxMenuItem _abbreviate_scientific_names;
182 JCheckBoxMenuItem _color_labels_same_as_parent_branch;
183 JMenuItem _overview_placment_mi;
184 JMenuItem _choose_minimal_confidence_mi;
185 JCheckBoxMenuItem _show_default_node_shapes_internal_cbmi;
186 JCheckBoxMenuItem _show_default_node_shapes_external_cbmi;
187 JMenuItem _cycle_node_shape_mi;
188 JMenuItem _cycle_node_fill_mi;
189 JMenuItem _choose_node_size_mi;
190 JCheckBoxMenuItem _taxonomy_colorize_node_shapes_cbmi;
191 JCheckBoxMenuItem _show_confidence_stddev_cbmi;
193 JCheckBoxMenuItem _graphics_export_visible_only_cbmi;
194 JCheckBoxMenuItem _antialias_print_cbmi;
195 JCheckBoxMenuItem _print_black_and_white_cbmi;
196 JCheckBoxMenuItem _print_using_actual_size_cbmi;
197 JCheckBoxMenuItem _graphics_export_using_actual_size_cbmi;
198 JMenuItem _print_size_mi;
199 JMenuItem _choose_pdf_width_mi;
201 JCheckBoxMenuItem _internal_number_are_confidence_for_nh_parsing_cbmi;
202 JRadioButtonMenuItem _extract_taxonomy_no_rbmi;
203 JRadioButtonMenuItem _extract_taxonomy_yes_rbmi;
204 JRadioButtonMenuItem _extract_taxonomy_pfam_rbmi;
205 JCheckBoxMenuItem _replace_underscores_cbmi;
206 JCheckBoxMenuItem _use_brackets_for_conf_in_nh_export_cbmi;
207 JCheckBoxMenuItem _use_internal_names_for_conf_in_nh_export_cbmi;
209 JCheckBoxMenuItem _search_case_senstive_cbmi;
210 JCheckBoxMenuItem _search_whole_words_only_cbmi;
211 JCheckBoxMenuItem _inverse_search_result_cbmi;
214 JCheckBoxMenuItem _rectangular_type_cbmi;
215 JCheckBoxMenuItem _triangular_type_cbmi;
216 JCheckBoxMenuItem _curved_type_cbmi;
217 JCheckBoxMenuItem _convex_type_cbmi;
218 JCheckBoxMenuItem _euro_type_cbmi;
219 JCheckBoxMenuItem _rounded_type_cbmi;
220 JCheckBoxMenuItem _unrooted_type_cbmi;
221 JCheckBoxMenuItem _circular_type_cbmi;
222 // view as text menu:
223 JMenuItem _view_as_NH_item;
224 JMenuItem _view_as_XML_item;
225 JMenuItem _view_as_nexus_item;
226 JMenuItem _display_basic_information_item;
228 JMenuItem _about_item;
229 JMenuItem _help_item;
230 JMenuItem _website_item;
231 JMenuItem _phyloxml_website_item;
232 JMenuItem _phyloxml_ref_item;
233 JMenuItem _aptx_ref_item;
236 // Handy pointers to child components:
237 MainPanel _mainpanel;
238 Container _contentpane;
239 final LinkedList<TextFrame> _textframes = new LinkedList<TextFrame>(); ;
240 Configuration _configuration;
241 JMenuItem _remove_branch_color_item;
243 private Phylogeny _species_tree;
244 InferenceManager _inference_manager;
245 final ProcessPool _process_pool;
246 private String _previous_node_annotation_ref;
249 _process_pool = ProcessPool.createInstance();
256 public void actionPerformed( final ActionEvent e ) {
257 final Object o = e.getSource();
258 boolean is_applet = false;
259 JApplet applet = null;
260 if ( getCurrentTreePanel() != null ) {
261 is_applet = getCurrentTreePanel().isApplet();
263 applet = getCurrentTreePanel().obtainApplet();
266 if ( o == _open_url_item ) {
267 readPhylogeniesFromURL();
269 else if ( o == _exit_item ) {
272 else if ( o == _gsdi_item ) {
273 if ( isSubtreeDisplayed() ) {
278 else if ( o == _gsdir_item ) {
279 if ( isSubtreeDisplayed() ) {
284 else if ( o == _taxcolor_item ) {
287 else if ( o == _confcolor_item ) {
290 else if ( o == _color_rank_jmi ) {
293 else if ( o == _collapse_species_specific_subtrees ) {
294 if ( isSubtreeDisplayed() ) {
297 if ( getCurrentTreePanel() != null ) {
298 getCurrentTreePanel().collapseSpeciesSpecificSubtrees();
301 else if ( o == _remove_branch_color_item ) {
302 if ( isSubtreeDisplayed() ) {
305 removeBranchColors();
307 else if ( o == _midpoint_root_item ) {
308 if ( isSubtreeDisplayed() ) {
313 else if ( o == _annotate_item ) {
316 else if ( o == _switch_colors_mi ) {
319 else if ( o == _display_basic_information_item ) {
320 displayBasicInformation();
322 else if ( o == _view_as_NH_item ) {
325 else if ( o == _view_as_XML_item ) {
328 else if ( o == _view_as_nexus_item ) {
331 else if ( o == _super_tiny_fonts_item ) {
332 if ( getCurrentTreePanel() != null ) {
333 getCurrentTreePanel().setSuperTinyFonts();
334 getCurrentTreePanel().repaint();
337 else if ( o == _tiny_fonts_item ) {
338 if ( getCurrentTreePanel() != null ) {
339 getCurrentTreePanel().setTinyFonts();
340 getCurrentTreePanel().repaint();
343 else if ( o == _small_fonts_item ) {
344 if ( getCurrentTreePanel() != null ) {
345 getCurrentTreePanel().setSmallFonts();
346 getCurrentTreePanel().repaint();
349 else if ( o == _medium_fonts_item ) {
350 if ( getCurrentTreePanel() != null ) {
351 getCurrentTreePanel().setMediumFonts();
352 getCurrentTreePanel().repaint();
355 else if ( o == _large_fonts_item ) {
356 if ( getCurrentTreePanel() != null ) {
357 getCurrentTreePanel().setLargeFonts();
358 getCurrentTreePanel().repaint();
361 else if ( o == _choose_font_mi ) {
364 else if ( o == _choose_minimal_confidence_mi ) {
365 chooseMinimalConfidence();
367 else if ( o == _choose_node_size_mi ) {
368 chooseNodeSize( getOptions(), this );
370 else if ( o == _overview_placment_mi ) {
371 MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
373 else if ( o == _cycle_node_fill_mi ) {
374 MainFrame.cycleNodeFill( getOptions(), getCurrentTreePanel() );
376 else if ( o == _cycle_node_shape_mi ) {
377 MainFrame.cycleNodeShape( getOptions(), getCurrentTreePanel() );
379 else if ( o == _screen_antialias_cbmi ) {
380 updateOptions( getOptions() );
381 updateScreenTextAntialias( getMainPanel().getTreePanels() );
383 else if ( o == _background_gradient_cbmi ) {
384 updateOptions( getOptions() );
386 else if ( o == _show_domain_labels ) {
387 updateOptions( getOptions() );
389 else if ( o == _abbreviate_scientific_names ) {
390 updateOptions( getOptions() );
392 else if ( o == _color_labels_same_as_parent_branch ) {
393 updateOptions( getOptions() );
395 else if ( o == _show_default_node_shapes_internal_cbmi ) {
396 updateOptions( getOptions() );
398 else if ( o == _show_default_node_shapes_external_cbmi ) {
399 updateOptions( getOptions() );
401 else if ( o == _taxonomy_colorize_node_shapes_cbmi ) {
402 updateOptions( getOptions() );
404 else if ( o == _non_lined_up_cladograms_rbmi ) {
405 updateOptions( getOptions() );
408 else if ( o == _uniform_cladograms_rbmi ) {
409 updateOptions( getOptions() );
412 else if ( o == _ext_node_dependent_cladogram_rbmi ) {
413 updateOptions( getOptions() );
416 else if ( o == _search_case_senstive_cbmi ) {
417 updateOptions( getOptions() );
418 getMainPanel().getControlPanel().search();
420 else if ( o == _search_whole_words_only_cbmi ) {
421 updateOptions( getOptions() );
422 getMainPanel().getControlPanel().search();
424 else if ( o == _inverse_search_result_cbmi ) {
425 updateOptions( getOptions() );
426 getMainPanel().getControlPanel().search();
428 else if ( o == _show_scale_cbmi ) {
429 updateOptions( getOptions() );
431 else if ( o == _show_branch_length_values_cbmi ) {
432 updateOptions( getOptions() );
434 else if ( o == _show_confidence_stddev_cbmi ) {
435 updateOptions( getOptions() );
437 else if ( o == _use_brackets_for_conf_in_nh_export_cbmi ) {
438 if ( _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {
439 _use_internal_names_for_conf_in_nh_export_cbmi.setSelected( false );
441 updateOptions( getOptions() );
443 else if ( o == _use_internal_names_for_conf_in_nh_export_cbmi ) {
444 if ( _use_internal_names_for_conf_in_nh_export_cbmi.isSelected() ) {
445 _use_brackets_for_conf_in_nh_export_cbmi.setSelected( false );
447 updateOptions( getOptions() );
449 else if ( o == _label_direction_cbmi ) {
450 updateOptions( getOptions() );
452 else if ( o == _show_overview_cbmi ) {
453 updateOptions( getOptions() );
454 if ( getCurrentTreePanel() != null ) {
455 getCurrentTreePanel().updateOvSizes();
458 else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
459 || ( o == _convex_type_cbmi ) || ( o == _euro_type_cbmi ) || ( o == _rounded_type_cbmi )
460 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
463 else if ( o == _about_item ) {
466 else if ( o == _help_item ) {
469 else if ( o == _website_item ) {
471 AptxUtil.openWebsite( Constants.APTX_WEB_SITE, is_applet, applet );
473 catch ( final IOException e1 ) {
474 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
477 else if ( o == _phyloxml_website_item ) {
479 AptxUtil.openWebsite( Constants.PHYLOXML_WEB_SITE, is_applet, applet );
481 catch ( final IOException e1 ) {
482 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
485 else if ( o == _aptx_ref_item ) {
487 AptxUtil.openWebsite( Constants.APTX_REFERENCE_URL, is_applet, applet );
489 catch ( final IOException e1 ) {
490 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
493 else if ( o == _phyloxml_ref_item ) {
495 AptxUtil.openWebsite( Constants.PHYLOXML_REFERENCE_URL, is_applet, applet );
497 catch ( final IOException e1 ) {
498 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
502 if ( _load_phylogeny_from_webservice_menu_items != null ) {
503 for( int i = 0; i < _load_phylogeny_from_webservice_menu_items.length; ++i ) {
504 if ( o == _load_phylogeny_from_webservice_menu_items[ i ] ) {
505 readPhylogeniesFromWebservice( i );
510 _contentpane.repaint();
513 public Configuration getConfiguration() {
514 return _configuration;
518 * This method returns the current external node data which
519 * has been selected by the user by clicking the "Return ..."
520 * menu item. This method is expected to be called from Javascript or
523 * @return current external node data as String
525 public String getCurrentExternalNodesDataBuffer() {
526 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString();
529 public int getCurrentExternalNodesDataBufferChangeCounter() {
530 return getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter();
533 public int getCurrentExternalNodesDataBufferLength() {
534 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length();
537 public InferenceManager getInferenceManager() {
538 return _inference_manager;
541 public MainPanel getMainPanel() {
545 public Options getOptions() {
549 public ProcessPool getProcessPool() {
550 return _process_pool;
553 public void showTextFrame( final String s, final String title ) {
555 _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
558 public void showWhole() {
559 _mainpanel.getControlPanel().showWhole();
562 public void updateProcessMenu() {
563 // In general Swing is not thread safe.
564 // See "Swing's Threading Policy".
565 SwingUtilities.invokeLater( new Runnable() {
569 doUpdateProcessMenu();
574 void activateSaveAllIfNeeded() {
575 if ( ( getMainPanel().getTabbedPane() != null ) && ( getMainPanel().getTabbedPane().getTabCount() > 1 ) ) {
576 _save_all_item.setEnabled( true );
579 _save_all_item.setEnabled( false );
583 void buildFileMenu() {
584 _file_jmenu = createMenu( "File", getConfiguration() );
585 _file_jmenu.add( _open_url_item = new JMenuItem( "Read tree from URL/webservice..." ) );
586 _file_jmenu.addSeparator();
587 _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );
588 customizeJMenuItem( _open_url_item );
589 customizeJMenuItem( _exit_item );
590 _jmenubar.add( _file_jmenu );
593 void buildFontSizeMenu() {
594 _font_size_menu = createMenu( FONT_SIZE_MENU_LABEL, getConfiguration() );
595 _font_size_menu.add( _super_tiny_fonts_item = new JMenuItem( "Super Tiny Fonts" ) );
596 _font_size_menu.add( _tiny_fonts_item = new JMenuItem( "Tiny Fonts" ) );
597 _font_size_menu.add( _small_fonts_item = new JMenuItem( "Small Fonts" ) );
598 _font_size_menu.add( _medium_fonts_item = new JMenuItem( "Medium Fonts" ) );
599 _font_size_menu.add( _large_fonts_item = new JMenuItem( "Large Fonts" ) );
600 customizeJMenuItem( _super_tiny_fonts_item );
601 customizeJMenuItem( _tiny_fonts_item );
602 customizeJMenuItem( _small_fonts_item );
603 customizeJMenuItem( _medium_fonts_item );
604 customizeJMenuItem( _large_fonts_item );
605 _jmenubar.add( _font_size_menu );
608 void buildHelpMenu() {
609 _help_jmenu = createMenu( "Help", getConfiguration() );
610 _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
611 _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
612 _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
613 _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
614 _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
615 _help_jmenu.addSeparator();
616 _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
617 customizeJMenuItem( _help_item );
618 customizeJMenuItem( _website_item );
619 customizeJMenuItem( _phyloxml_website_item );
620 customizeJMenuItem( _aptx_ref_item );
621 customizeJMenuItem( _phyloxml_ref_item );
622 customizeJMenuItem( _about_item );
623 _phyloxml_ref_item.setToolTipText( PHYLOXML_REF_TOOL_TIP );
624 _aptx_ref_item.setToolTipText( APTX_REF_TOOL_TIP );
625 _jmenubar.add( _help_jmenu );
628 void buildTypeMenu() {
629 _type_menu = createMenu( TYPE_MENU_HEADER, getConfiguration() );
630 _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
631 _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
632 _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
633 _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
634 _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
635 _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
636 _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
637 _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
638 customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
639 customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
640 customizeCheckBoxMenuItem( _euro_type_cbmi, false );
641 customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
642 customizeCheckBoxMenuItem( _curved_type_cbmi, false );
643 customizeCheckBoxMenuItem( _convex_type_cbmi, false );
644 customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
645 customizeCheckBoxMenuItem( _circular_type_cbmi, false );
646 _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
647 _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
648 initializeTypeMenu( getOptions() );
649 _jmenubar.add( _type_menu );
652 void buildViewMenu() {
653 _view_jmenu = createMenu( "View", getConfiguration() );
654 _view_jmenu.add( _display_basic_information_item = new JMenuItem( "Display Basic Information" ) );
655 _view_jmenu.addSeparator();
656 _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) );
657 _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) );
658 _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "View as Nexus" ) );
659 customizeJMenuItem( _display_basic_information_item );
660 customizeJMenuItem( _view_as_NH_item );
661 customizeJMenuItem( _view_as_XML_item );
662 customizeJMenuItem( _view_as_nexus_item );
663 _jmenubar.add( _view_jmenu );
666 void checkTextFrames() {
667 if ( _textframes.size() > 5 ) {
669 if ( _textframes.getFirst() != null ) {
670 _textframes.getFirst().removeMe();
673 _textframes.removeFirst();
676 catch ( final NoSuchElementException e ) {
683 removeAllTextFrames();
684 if ( _mainpanel != null ) {
685 _mainpanel.terminate();
687 if ( _contentpane != null ) {
688 _contentpane.removeAll();
695 if ( _mainpanel.getCurrentTreePanel() != null ) {
696 final String[] ranks = AptxUtil.getAllPossibleRanks();
697 final String rank = ( String ) JOptionPane
698 .showInputDialog( this,
699 "What rank should the colorization be based on",
701 JOptionPane.QUESTION_MESSAGE,
705 if ( !ForesterUtil.isEmpty( rank ) ) {
706 _mainpanel.getCurrentTreePanel().colorRank( rank );
712 if ( _mainpanel.getCurrentTreePanel() != null ) {
713 _mainpanel.getCurrentTreePanel().confColor();
717 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
718 if ( item != null ) {
719 item.setFont( MainFrame.menu_font );
720 if ( !getConfiguration().isUseNativeUI() ) {
721 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
722 item.setForeground( getConfiguration().getGuiMenuTextColor() );
724 item.setSelected( is_selected );
725 item.addActionListener( this );
729 JMenuItem customizeJMenuItem( final JMenuItem jmi ) {
731 jmi.setFont( MainFrame.menu_font );
732 if ( !getConfiguration().isUseNativeUI() ) {
733 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
734 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
736 jmi.addActionListener( this );
741 void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
742 if ( item != null ) {
743 item.setFont( MainFrame.menu_font );
744 if ( !getConfiguration().isUseNativeUI() ) {
745 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
746 item.setForeground( getConfiguration().getGuiMenuTextColor() );
748 item.setSelected( is_selected );
749 item.addActionListener( this );
753 void displayBasicInformation() {
754 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
755 String title = "Basic Information";
756 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
757 title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
759 showTextFrame( AptxUtil.createBasicInformation( _mainpanel.getCurrentPhylogeny() ), title );
763 void exceptionOccuredDuringOpenFile( final Exception e ) {
765 _mainpanel.getCurrentTreePanel().setArrowCursor();
767 catch ( final Exception ex ) {
770 JOptionPane.showMessageDialog( this,
771 ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
772 "Error during File|Open",
773 JOptionPane.ERROR_MESSAGE );
776 void exceptionOccuredDuringSaveAs( final Exception e ) {
778 _mainpanel.getCurrentTreePanel().setArrowCursor();
780 catch ( final Exception ex ) {
783 JOptionPane.showMessageDialog( this, "Exception" + e, "Error during File|SaveAs", JOptionPane.ERROR_MESSAGE );
787 if ( !isOKforSDI( false, true ) ) {
790 if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {
791 JOptionPane.showMessageDialog( this,
792 "Gene tree is not rooted.",
793 "Cannot execute GSDI",
794 JOptionPane.ERROR_MESSAGE );
797 final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
798 gene_tree.setAllNodesToNotCollapse();
799 gene_tree.recalculateNumberOfExternalDescendants( false );
801 final Phylogeny species_tree = getSpeciesTree().copy();
803 gsdi = new GSDI( gene_tree, species_tree, false, true, true );
805 catch ( final SDIException e ) {
806 JOptionPane.showMessageDialog( this,
807 e.getLocalizedMessage(),
809 JOptionPane.ERROR_MESSAGE );
812 catch ( final Exception e ) {
813 AptxUtil.unexpectedException( e );
816 gene_tree.setRerootable( false );
817 gene_tree.clearHashIdToNodeMap();
818 gene_tree.recalculateNumberOfExternalDescendants( true );
819 _mainpanel.addPhylogenyInNewTab( gene_tree, getConfiguration(), "gene tree", null );
820 getMainPanel().getControlPanel().setShowEvents( true );
822 final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
823 _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
825 _mainpanel.getTabbedPane().setSelectedIndex( selected );
827 _mainpanel.getCurrentTreePanel().setEdited( true );
828 final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
829 if ( gsdi.getStrippedExternalGeneTreeNodes().size() > 0 ) {
830 JOptionPane.showMessageDialog( this,
831 "Duplications: " + gsdi.getDuplicationsSum() + "\n"
832 + "Potential duplications: "
833 + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
834 + "Speciations: " + gsdi.getSpeciationsSum() + "\n"
835 + "Stripped gene tree nodes: "
836 + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
837 + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
838 + "Number of polytomies in species tree used: " + poly + "\n",
839 "GSDI successfully completed",
840 JOptionPane.WARNING_MESSAGE );
843 JOptionPane.showMessageDialog( this,
844 "Duplications: " + gsdi.getDuplicationsSum() + "\n"
845 + "Potential duplications: "
846 + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
847 + "Speciations: " + gsdi.getSpeciationsSum() + "\n"
848 + "Stripped gene tree nodes: "
849 + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
850 + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
851 + "Number of polytomies in species tree used: " + poly + "\n",
852 "GSDI successfully completed",
853 JOptionPane.INFORMATION_MESSAGE );
857 void executeGSDIR() {
858 if ( !isOKforSDI( false, false ) ) {
861 final int p = PhylogenyMethods.countNumberOfPolytomies( _mainpanel.getCurrentPhylogeny() );
863 && !( ( p == 1 ) && ( _mainpanel.getCurrentPhylogeny().getRoot().getNumberOfDescendants() == 3 ) ) ) {
864 JOptionPane.showMessageDialog( this,
865 "Gene tree is not completely binary",
866 "Cannot execute GSDI",
867 JOptionPane.ERROR_MESSAGE );
870 final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
871 gene_tree.setAllNodesToNotCollapse();
872 gene_tree.recalculateNumberOfExternalDescendants( false );
874 final Phylogeny species_tree = getSpeciesTree().copy();
876 gsdir = new GSDIR( gene_tree, species_tree, true, true );
878 catch ( final SDIException e ) {
879 JOptionPane.showMessageDialog( this,
880 e.getLocalizedMessage(),
881 "Error during GSDIR",
882 JOptionPane.ERROR_MESSAGE );
885 catch ( final Exception e ) {
886 AptxUtil.unexpectedException( e );
889 final Phylogeny result_gene_tree = gsdir.getMinDuplicationsSumGeneTree();
890 result_gene_tree.setRerootable( false );
891 result_gene_tree.clearHashIdToNodeMap();
892 result_gene_tree.recalculateNumberOfExternalDescendants( true );
893 PhylogenyMethods.orderAppearance( result_gene_tree.getRoot(), true, true, DESCENDANT_SORT_PRIORITY.NODE_NAME );
894 _mainpanel.addPhylogenyInNewTab( result_gene_tree, getConfiguration(), "gene tree", null );
895 getMainPanel().getControlPanel().setShowEvents( true );
897 final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
898 _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
900 _mainpanel.getTabbedPane().setSelectedIndex( selected );
902 _mainpanel.getCurrentTreePanel().setEdited( true );
903 final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
904 if ( gsdir.getStrippedExternalGeneTreeNodes().size() > 0 ) {
905 JOptionPane.showMessageDialog( this,
906 "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
907 + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
908 + "Stripped gene tree nodes: "
909 + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
910 + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
911 + "Number of polytomies in species tree used: " + poly + "\n",
912 "GSDIR successfully completed",
913 JOptionPane.WARNING_MESSAGE );
916 JOptionPane.showMessageDialog( this,
917 "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
918 + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
919 + "Stripped gene tree nodes: "
920 + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
921 + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
922 + "Number of polytomies in species tree used: " + poly + "\n",
923 "GSDIR successfully completed",
924 JOptionPane.INFORMATION_MESSAGE );
928 boolean GAndSDoHaveMoreThanOneSpeciesInComman( final Phylogeny gene_tree ) {
929 if ( ( gene_tree == null ) || gene_tree.isEmpty() ) {
930 JOptionPane.showMessageDialog( this,
931 "Gene tree and species tree have no species in common.",
933 JOptionPane.ERROR_MESSAGE );
936 else if ( gene_tree.getNumberOfExternalNodes() < 2 ) {
937 JOptionPane.showMessageDialog( this,
938 "Gene tree and species tree have only one species in common.",
940 JOptionPane.ERROR_MESSAGE );
948 TreePanel getCurrentTreePanel() {
949 return getMainPanel().getCurrentTreePanel();
952 JMenu getHelpMenu() {
956 JCheckBoxMenuItem getlabelDirectionCbmi() {
957 return _label_direction_cbmi;
960 JMenuBar getMenuBarOfMainFrame() {
964 final Phylogeny getSpeciesTree() {
965 return _species_tree;
969 final StringBuilder sb = new StringBuilder();
970 sb.append( "Display options\n" );
971 sb.append( "-------------------\n" );
972 sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
973 sb.append( "Clickable tree nodes\n" );
974 sb.append( "--------------------\n" );
975 sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
976 sb.append( "or by right clicking:\n" );
977 sb.append( "o Display Node Data -- display information for a node\n" );
978 sb.append( "o Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
979 sb.append( "o Root/Reroot -- change tree root to clicked node\n" );
980 sb.append( "o Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
981 sb.append( "o Swap Descendants -- switch descendant on either side of clicked node\n" );
982 sb.append( "o Colorize Subtree -- color a subtree\n" );
983 sb.append( "o Open Sequence Web -- launch a web browser to display sequence information\n" );
984 sb.append( "o Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
985 sb.append( "- there may be additional choices depending on this particular setup\n\n" );
986 sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
987 sb.append( "Zooming\n" );
988 sb.append( "---------\n" );
989 sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
990 sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
991 sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
992 sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
993 sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
994 sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
995 sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
996 sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
997 sb.append( "Quick tree manipulation:\n" );
998 sb.append( "------------------------\n" );
999 sb.append( "Order Subtrees -- order the tree by branch length\n" );
1000 sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
1001 sb.append( "Memory problems (Java heap space error)\n" );
1002 sb.append( "---------------------------------------\n" );
1003 sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
1004 sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
1005 sb.append( "the '-Xmx' Java command line option. For example:\n" );
1006 sb.append( "java -Xmx1024m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
1007 // + "General remarks\n"
1008 // + "---------------\n"
1010 // "o The application version permits copying to the clipboard \n"
1012 // " in the \"View\"|\"View as ...\" frame (either by control-c or button press).\n"
1014 // "o Changes made to a subtree affect this subtree and its subtrees,\n"
1015 // + " but not any of its parent tree(s).\n"
1017 // "o Archaeopteryx tries to detect whether the numerical values in a NH tree\n"
1019 // " are likely to be bootstrap values instead of branch length values.\n\n"
1021 // " Remarks regarding SDI (Speciation Duplication Inference):\n"
1023 // "o Each external node of the gene tree (in display) needs to be associated with\n"
1025 // " a species: either directly through the \"Species\" field, or the species\n"
1027 // " is part of the sequence name in the form \"XXXX_SPECIES\"\n"
1029 // " (e.g. \"ACON_DROME\" or \"ACON_DROME/123-4489\" which is also acceptable).\n"
1031 // "o A species tree for each species of the gene tree needs to be loaded with\n"
1033 // " \"SDI\"|\"Load species tree\" prior the SDI execution.\n"
1035 // "o !External nodes of the gene tree associated with species not present in\n"
1037 // " the species tree are REMOVED prior to SDI execution!\n"
1039 // "o Both the gene tree and the species tree must be completely binary.\n"
1041 // "o Duplications and speciations are a function of the position of the root.\n"
1043 // " Hence, after each manual \"Root/Reroot\"ing some duplications will be\n"
1044 // + " incorrect and need to be inferred again\n"
1046 // " with: \"SDI\"|\"SDI (Speciation Duplication Inference)\n\n"
1047 sb.append( "phyloXML\n" );
1048 sb.append( "-------------------\n" );
1049 sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
1050 sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
1051 sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1053 sb.append( "For more information: https://sites.google.com/site/cmzmasek/home/software/archaeopteryx\n" );
1054 sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
1055 TextFrame.instantiate( sb.toString(), "Help", _textframes );
1058 void initializeTypeMenu( final Options options ) {
1059 setTypeMenuToAllUnselected();
1060 switch ( options.getPhylogenyGraphicsType() ) {
1062 _convex_type_cbmi.setSelected( true );
1065 _curved_type_cbmi.setSelected( true );
1068 _euro_type_cbmi.setSelected( true );
1071 _rounded_type_cbmi.setSelected( true );
1074 _triangular_type_cbmi.setSelected( true );
1077 _unrooted_type_cbmi.setSelected( true );
1080 _circular_type_cbmi.setSelected( true );
1083 _rectangular_type_cbmi.setSelected( true );
1088 boolean isOKforSDI( final boolean species_tree_has_to_binary, final boolean gene_tree_has_to_binary ) {
1089 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty() ) {
1092 else if ( ( getSpeciesTree() == null ) || getSpeciesTree().isEmpty() ) {
1093 JOptionPane.showMessageDialog( this,
1094 "No species tree loaded",
1095 "Cannot execute GSDI",
1096 JOptionPane.ERROR_MESSAGE );
1099 else if ( species_tree_has_to_binary && !getSpeciesTree().isCompletelyBinary() ) {
1100 JOptionPane.showMessageDialog( this,
1101 "Species tree is not completely binary",
1102 "Cannot execute GSDI",
1103 JOptionPane.ERROR_MESSAGE );
1106 else if ( gene_tree_has_to_binary && !_mainpanel.getCurrentPhylogeny().isCompletelyBinary() ) {
1107 JOptionPane.showMessageDialog( this,
1108 "Gene tree is not completely binary",
1109 "Cannot execute GSDI",
1110 JOptionPane.ERROR_MESSAGE );
1118 boolean isSubtreeDisplayed() {
1119 if ( getCurrentTreePanel() != null ) {
1120 if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
1122 .showMessageDialog( this,
1123 "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",
1124 "Operation can not be exectuted on a sub-tree",
1125 JOptionPane.WARNING_MESSAGE );
1132 void midpointRoot() {
1133 if ( _mainpanel.getCurrentTreePanel() != null ) {
1134 _mainpanel.getCurrentTreePanel().midpointRoot();
1138 abstract void readPhylogeniesFromURL();
1140 void readPhylogeniesFromWebservice( final int i ) {
1141 final UrlTreeReader reader = new UrlTreeReader( this, i );
1142 new Thread( reader ).start();
1145 void removeAllTextFrames() {
1146 for( final TextFrame tf : _textframes ) {
1151 _textframes.clear();
1154 void setConfiguration( final Configuration configuration ) {
1155 _configuration = configuration;
1158 void setInferenceManager( final InferenceManager i ) {
1159 _inference_manager = i;
1162 void setOptions( final Options options ) {
1166 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
1167 setTypeMenuToAllUnselected();
1170 _circular_type_cbmi.setSelected( true );
1173 _convex_type_cbmi.setSelected( true );
1176 _curved_type_cbmi.setSelected( true );
1179 _euro_type_cbmi.setSelected( true );
1182 _rounded_type_cbmi.setSelected( true );
1185 _rectangular_type_cbmi.setSelected( true );
1188 _triangular_type_cbmi.setSelected( true );
1191 _unrooted_type_cbmi.setSelected( true );
1194 throw new IllegalArgumentException( "unknown type: " + type );
1198 final void setSpeciesTree( final Phylogeny species_tree ) {
1199 _species_tree = species_tree;
1202 void setTypeMenuToAllUnselected() {
1203 _convex_type_cbmi.setSelected( false );
1204 _curved_type_cbmi.setSelected( false );
1205 _euro_type_cbmi.setSelected( false );
1206 _rounded_type_cbmi.setSelected( false );
1207 _triangular_type_cbmi.setSelected( false );
1208 _rectangular_type_cbmi.setSelected( false );
1209 _unrooted_type_cbmi.setSelected( false );
1210 _circular_type_cbmi.setSelected( false );
1213 void switchColors() {
1214 final TreeColorSet colorset = _mainpanel.getTreeColorSet();
1215 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
1216 csc.setVisible( true );
1220 if ( _mainpanel.getCurrentTreePanel() != null ) {
1221 _mainpanel.getCurrentTreePanel().taxColor();
1225 void typeChanged( final Object o ) {
1226 updateTypeCheckboxes( getOptions(), o );
1227 updateOptions( getOptions() );
1228 if ( getCurrentTreePanel() != null ) {
1229 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
1230 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
1231 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1232 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
1233 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1234 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
1235 getCurrentTreePanel().getControlPanel().showWhole();
1237 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1238 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
1241 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
1243 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
1244 updateScreenTextAntialias( getMainPanel().getTreePanels() );
1245 if ( getCurrentTreePanel().getControlPanel().getDynamicallyHideData() != null ) {
1246 if ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
1247 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( false );
1250 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( true );
1256 void updateOptions( final Options options ) {
1257 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
1258 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
1259 && _background_gradient_cbmi.isSelected() );
1260 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
1261 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
1262 && _abbreviate_scientific_names.isSelected() );
1263 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
1264 && _color_labels_same_as_parent_branch.isSelected() );
1265 options.setShowDefaultNodeShapesInternal( ( _show_default_node_shapes_internal_cbmi != null )
1266 && _show_default_node_shapes_internal_cbmi.isSelected() );
1267 options.setShowDefaultNodeShapesExternal( ( _show_default_node_shapes_external_cbmi != null )
1268 && _show_default_node_shapes_external_cbmi.isSelected() );
1269 options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null )
1270 && _taxonomy_colorize_node_shapes_cbmi.isSelected() );
1271 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
1272 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
1274 else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
1275 options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1277 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
1278 options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1280 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
1281 && _search_case_senstive_cbmi.isSelected() );
1282 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
1283 options.setShowScale( _show_scale_cbmi.isSelected() );
1285 if ( _label_direction_cbmi != null ) {
1286 if ( _label_direction_cbmi.isSelected() ) {
1287 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1290 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1293 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
1294 options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )
1295 && _show_confidence_stddev_cbmi.isSelected() );
1296 if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
1297 options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
1299 options.setPrintUsingActualSize( ( _print_using_actual_size_cbmi != null )
1300 && ( _print_using_actual_size_cbmi.isSelected() ) );
1301 options.setGraphicsExportUsingActualSize( ( _graphics_export_using_actual_size_cbmi != null )
1302 && ( _graphics_export_using_actual_size_cbmi.isSelected() ) );
1303 options.setAntialiasPrint( ( _antialias_print_cbmi != null ) && _antialias_print_cbmi.isSelected() );
1304 if ( ( _use_brackets_for_conf_in_nh_export_cbmi != null )
1305 && _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {
1306 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );
1308 else if ( ( _use_internal_names_for_conf_in_nh_export_cbmi != null )
1309 && _use_internal_names_for_conf_in_nh_export_cbmi.isSelected() ) {
1310 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES );
1313 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE );
1315 options.setPrintBlackAndWhite( ( _print_black_and_white_cbmi != null )
1316 && _print_black_and_white_cbmi.isSelected() );
1317 options.setInternalNumberAreConfidenceForNhParsing( ( _internal_number_are_confidence_for_nh_parsing_cbmi != null )
1318 && _internal_number_are_confidence_for_nh_parsing_cbmi.isSelected() );
1319 if ( ( _extract_taxonomy_yes_rbmi != null ) && _extract_taxonomy_yes_rbmi.isSelected() ) {
1320 options.setTaxonomyExtractio( TAXONOMY_EXTRACTION.AGRESSIVE );
1322 else if ( ( _extract_taxonomy_pfam_rbmi != null ) && _extract_taxonomy_pfam_rbmi.isSelected() ) {
1323 options.setTaxonomyExtractio( TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1325 else if ( ( _extract_taxonomy_no_rbmi != null ) && _extract_taxonomy_no_rbmi.isSelected() ) {
1326 options.setTaxonomyExtractio( TAXONOMY_EXTRACTION.NO );
1328 options.setReplaceUnderscoresInNhParsing( ( _replace_underscores_cbmi != null )
1329 && _replace_underscores_cbmi.isSelected() );
1330 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
1331 && _search_whole_words_only_cbmi.isSelected() );
1332 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
1333 && _inverse_search_result_cbmi.isSelected() );
1334 if ( _graphics_export_visible_only_cbmi != null ) {
1335 options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() );
1336 if ( _graphics_export_visible_only_cbmi.isSelected() && ( _graphics_export_using_actual_size_cbmi != null ) ) {
1337 _graphics_export_using_actual_size_cbmi.setSelected( true );
1338 _graphics_export_using_actual_size_cbmi.setEnabled( false );
1341 _graphics_export_using_actual_size_cbmi.setEnabled( true );
1344 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
1345 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1347 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
1348 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1350 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
1351 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1353 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
1354 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1356 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
1357 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1359 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
1360 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1362 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
1363 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1365 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
1366 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1370 void updateTypeCheckboxes( final Options options, final Object o ) {
1371 setTypeMenuToAllUnselected();
1372 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
1375 void viewAsNexus() {
1376 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1377 String title = "Nexus";
1378 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1379 title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
1381 showTextFrame( _mainpanel.getCurrentPhylogeny().toNexus( getOptions().getNhConversionSupportValueStyle() ),
1387 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1388 String title = "New Hampshire";
1389 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1390 title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
1392 showTextFrame( _mainpanel.getCurrentPhylogeny()
1393 .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ),
1399 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1400 String title = "phyloXML";
1401 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1402 title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
1404 showTextFrame( _mainpanel.getCurrentPhylogeny().toPhyloXML( 0 ), title );
1408 private void annotateSequences() {
1409 if ( getCurrentTreePanel() != null ) {
1410 final Set<Long> nodes = getCurrentTreePanel().getFoundNodes();
1411 if ( ( nodes == null ) || nodes.isEmpty() ) {
1413 .showMessageDialog( this,
1414 "Need to select nodes, either via direct selection or via the \"Search\" function",
1415 "No nodes selected for annotation",
1416 JOptionPane.ERROR_MESSAGE );
1419 final Phylogeny phy = getMainPanel().getCurrentPhylogeny();
1420 if ( ( phy != null ) && !phy.isEmpty() ) {
1421 final JTextField ref_field = new JTextField( 10 );
1422 final JTextField desc_filed = new JTextField( 20 );
1423 ref_field.setText( ForesterUtil.isEmpty( getPreviousNodeAnnotationReference() ) ? ""
1424 : getPreviousNodeAnnotationReference() );
1425 final JPanel my_panel = new JPanel();
1426 my_panel.add( new JLabel( "Reference " ) );
1427 my_panel.add( ref_field );
1428 my_panel.add( Box.createHorizontalStrut( 15 ) );
1429 my_panel.add( new JLabel( "Description " ) );
1430 my_panel.add( desc_filed );
1431 final int result = JOptionPane.showConfirmDialog( null,
1433 "Enter the sequence annotation(s) for the "
1434 + nodes.size() + " selected nodes",
1435 JOptionPane.OK_CANCEL_OPTION );
1436 if ( result == JOptionPane.OK_OPTION ) {
1437 String ref = ref_field.getText();
1438 String desc = desc_filed.getText();
1439 if ( !ForesterUtil.isEmpty( ref ) ) {
1441 ref = ref.replaceAll( "\\s+", " " );
1442 if ( ( ref.indexOf( ':' ) < 1 ) || ( ref.indexOf( ':' ) > ref.length() - 2 )
1443 || ( ref.length() < 3 ) ) {
1444 JOptionPane.showMessageDialog( this,
1445 "Reference needs to be in the form of \"GO:1234567\"",
1446 "Illegal Format for Annotation Reference",
1447 JOptionPane.ERROR_MESSAGE );
1451 if ( ref != null ) {
1452 setPreviousNodeAnnotationReference( ref );
1454 if ( desc != null ) {
1456 desc = desc.replaceAll( "\\s+", " " );
1458 if ( !ForesterUtil.isEmpty( ref ) || !ForesterUtil.isEmpty( desc ) ) {
1459 for( final Long id : nodes ) {
1460 final PhylogenyNode n = phy.getNode( id );
1461 ForesterUtil.ensurePresenceOfSequence( n );
1462 final Annotation ann = ForesterUtil.isEmpty( ref ) ? new Annotation()
1463 : new Annotation( ref );
1464 if ( !ForesterUtil.isEmpty( desc ) ) {
1465 ann.setDesc( desc );
1467 n.getNodeData().getSequence().addAnnotation( ann );
1470 getMainPanel().getControlPanel().showAnnotations();
1476 private void chooseFont() {
1477 final FontChooser fc = new FontChooser();
1478 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
1479 fc.showDialog( this, "Select the Base Font" );
1480 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
1483 private void chooseMinimalConfidence() {
1484 final String s = ( String ) JOptionPane
1485 .showInputDialog( this,
1486 "Please enter the minimum for confidence values to be displayed.\n"
1487 + "[current value: " + getOptions().getMinConfidenceValue() + "]\n",
1488 "Minimal Confidence Value",
1489 JOptionPane.QUESTION_MESSAGE,
1492 getOptions().getMinConfidenceValue() );
1493 if ( !ForesterUtil.isEmpty( s ) ) {
1494 boolean success = true;
1496 final String m_str = s.trim();
1497 if ( !ForesterUtil.isEmpty( m_str ) ) {
1499 m = Double.parseDouble( m_str );
1501 catch ( final Exception ex ) {
1508 if ( success && ( m >= 0.0 ) ) {
1509 getOptions().setMinConfidenceValue( m );
1514 private void doUpdateProcessMenu() {
1515 if ( _process_pool.size() > 0 ) {
1516 if ( _process_menu == null ) {
1517 _process_menu = createMenu( "", getConfiguration() );
1518 _process_menu.setForeground( Color.RED );
1520 _process_menu.removeAll();
1521 final String text = "processes running: " + _process_pool.size();
1522 _process_menu.setText( text );
1523 _jmenubar.add( _process_menu );
1524 for( int i = 0; i < _process_pool.size(); ++i ) {
1525 final ProcessRunning p = _process_pool.getProcessByIndex( i );
1526 _process_menu.add( customizeJMenuItem( new JMenuItem( p.getName() + " [" + p.getStart() + "]" ) ) );
1530 if ( _process_menu != null ) {
1531 _process_menu.removeAll();
1532 _jmenubar.remove( _process_menu );
1535 _jmenubar.validate();
1536 _jmenubar.repaint();
1540 private String getPreviousNodeAnnotationReference() {
1541 return _previous_node_annotation_ref;
1544 private void removeBranchColors() {
1545 if ( getMainPanel().getCurrentPhylogeny() != null ) {
1546 AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
1550 private void setPreviousNodeAnnotationReference( final String previous_node_annotation_ref ) {
1551 _previous_node_annotation_ref = previous_node_annotation_ref;
1555 * Display the about box.
1557 static void about() {
1558 final StringBuffer about = new StringBuffer( "Archaeopteryx\nVersion " + Constants.VERSION + "\n" );
1559 about.append( "Copyright (C) 2013 Christian M. Zmasek\n" );
1560 about.append( "All Rights Reserved\n" );
1561 about.append( "License: GNU Lesser General Public License (LGPL)\n" );
1562 about.append( "Last modified: " + Constants.PRG_DATE + "\n" );
1563 about.append( "Based on: " + ForesterUtil.getForesterLibraryInformation() + "\n" );
1564 about.append( "phyloXML version : " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1565 about.append( "phyloXML location: " + ForesterConstants.PHYLO_XML_LOCATION + "\n" );
1566 if ( !ForesterUtil.isEmpty( ForesterUtil.JAVA_VERSION ) && !ForesterUtil.isEmpty( ForesterUtil.JAVA_VENDOR ) ) {
1567 about.append( "[your Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]\n" );
1569 if ( !ForesterUtil.isEmpty( ForesterUtil.OS_NAME ) && !ForesterUtil.isEmpty( ForesterUtil.OS_ARCH )
1570 && !ForesterUtil.isEmpty( ForesterUtil.OS_VERSION ) ) {
1571 about.append( "[your OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " "
1572 + ForesterUtil.OS_VERSION + "]\n" );
1574 final Runtime rt = java.lang.Runtime.getRuntime();
1575 final long free_memory = rt.freeMemory() / 1000000;
1576 final long total_memory = rt.totalMemory() / 1000000;
1577 about.append( "[free memory: " + free_memory + "MB, total memory: " + total_memory + "MB]\n" );
1578 about.append( "[locale: " + Locale.getDefault() + "]\n" );
1579 about.append( "References:\n" );
1580 about.append( Constants.PHYLOXML_REFERENCE_SHORT + "\n" );
1581 about.append( "For more information & download:\n" );
1582 about.append( Constants.APTX_WEB_SITE + "\n" );
1583 about.append( "Comments: " + Constants.AUTHOR_EMAIL );
1584 JOptionPane.showMessageDialog( null, about, Constants.PRG_NAME, JOptionPane.PLAIN_MESSAGE );
1587 static void chooseNodeSize( final Options options, final Component parent ) {
1588 final String s = ( String ) JOptionPane.showInputDialog( parent,
1589 "Please enter the default size for node shapes.\n"
1590 + "[current value: "
1591 + options.getDefaultNodeShapeSize() + "]\n",
1593 JOptionPane.QUESTION_MESSAGE,
1596 options.getDefaultNodeShapeSize() );
1597 if ( !ForesterUtil.isEmpty( s ) ) {
1598 boolean success = true;
1600 final String m_str = s.trim();
1601 if ( !ForesterUtil.isEmpty( m_str ) ) {
1603 m = Double.parseDouble( m_str );
1605 catch ( final Exception ex ) {
1612 if ( success && ( m >= 0.0 ) ) {
1613 final short size = ForesterUtil.roundToShort( m );
1614 if ( size >= 0.0 ) {
1615 options.setDefaultNodeShapeSize( size );
1621 static String createCurrentFontDesc( final TreeFontSet tree_font_set ) {
1622 return tree_font_set.getLargeFont().getFamily() + " " + tree_font_set.getLargeFont().getSize();
1625 static JMenu createMenu( final String title, final Configuration conf ) {
1626 final JMenu jmenu = new JMenu( title );
1627 if ( !conf.isUseNativeUI() ) {
1628 jmenu.setFont( MainFrame.menu_font );
1629 jmenu.setBackground( conf.getGuiMenuBackgroundColor() );
1630 jmenu.setForeground( conf.getGuiMenuTextColor() );
1635 static JMenuItem customizeMenuItemAsLabel( final JMenuItem label, final Configuration configuration ) {
1636 label.setFont( MainFrame.menu_font.deriveFont( Font.BOLD ) );
1637 if ( !configuration.isUseNativeUI() ) {
1638 label.setBackground( configuration.getGuiMenuBackgroundColor() );
1639 label.setForeground( configuration.getGuiMenuTextColor() );
1640 label.setOpaque( true );
1642 label.setSelected( false );
1643 label.setEnabled( false );
1647 static void cycleNodeFill( final Options op, final TreePanel tree_panel ) {
1648 switch ( op.getDefaultNodeFill() ) {
1650 op.setDefaultNodeFill( NodeFill.SOLID );
1653 op.setDefaultNodeFill( NodeFill.GRADIENT );
1656 op.setDefaultNodeFill( NodeFill.NONE );
1659 throw new RuntimeException( "unknown fill: " + op.getDefaultNodeFill() );
1663 static void cycleNodeShape( final Options op, final TreePanel tree_panel ) {
1664 switch ( op.getDefaultNodeShape() ) {
1666 op.setDefaultNodeShape( NodeShape.RECTANGLE );
1669 op.setDefaultNodeShape( NodeShape.CIRCLE );
1672 throw new RuntimeException( "unknown shape: " + op.getDefaultNodeShape() );
1676 static void cycleOverview( final Options op, final TreePanel tree_panel ) {
1677 switch ( op.getOvPlacement() ) {
1679 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1682 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1685 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1688 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1691 throw new RuntimeException( "unknown placement: " + op.getOvPlacement() );
1693 if ( tree_panel != null ) {
1694 tree_panel.updateOvSettings();
1698 static void setCycleNodeFillMenuItem( final JMenuItem mi, final Options options ) {
1699 if ( ( options != null ) && ( options.getDefaultNodeFill() != null ) ) {
1700 mi.setText( "Cycle Node Shape Fill Type... (current: "
1701 + options.getDefaultNodeFill().toString().toLowerCase() + ")" );
1704 mi.setText( "Cycle Node Shape Fill Type..." );
1708 static void setCycleNodeShapeMenuItem( final JMenuItem mi, final Options options ) {
1709 if ( ( options != null ) && ( options.getDefaultNodeShape() != null ) ) {
1710 mi.setText( "Cycle Node Shape Fill Type... (current: "
1711 + options.getDefaultNodeShape().toString().toLowerCase() + ")" );
1714 mi.setText( "Cycle Node Shape Fill Type..." );
1718 static void setOvPlacementColorChooseMenuItem( final JMenuItem mi, final Options options ) {
1719 if ( ( options != null ) && ( options.getOvPlacement() != null ) ) {
1720 mi.setText( "Cycle Overview Placement... (current: " + options.getOvPlacement() + ")" );
1723 mi.setText( "Cycle Overview Placement..." );
1727 static void setTextColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {
1728 if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {
1729 mi.setText( "Select Colors... (current: " + tree_panel.getTreeColorSet().getCurrentColorSchemeName() + ")" );
1732 mi.setText( "Select Colors..." );
1736 static void setTextForFontChooserMenuItem( final JMenuItem mi, final String font_desc ) {
1737 mi.setText( "Select Font... (current: " + font_desc + ")" );
1740 static void setTextMinSupportMenuItem( final JMenuItem mi, final Options options, final TreePanel current_tree_panel ) {
1741 if ( ( current_tree_panel == null ) || ( current_tree_panel.getPhylogeny() == null ) ) {
1742 mi.setEnabled( true );
1744 else if ( AptxUtil.isHasAtLeastOneBranchWithSupportValues( current_tree_panel.getPhylogeny() ) ) {
1745 mi.setEnabled( true );
1748 mi.setEnabled( false );
1750 mi.setText( "Enter Min Confidence Value... (current: " + options.getMinConfidenceValue() + ")" );
1753 static void setTextNodeSizeMenuItem( final JMenuItem mi, final Options options ) {
1754 mi.setText( "Enter Default Node Shape Size... (current: " + options.getDefaultNodeShapeSize() + ")" );
1757 static void updateOptionsMenuDependingOnPhylogenyType( final MainPanel main_panel,
1758 final JCheckBoxMenuItem scale,
1759 final JCheckBoxMenuItem branch_lengths,
1760 final JRadioButtonMenuItem non_lined_up,
1761 final JRadioButtonMenuItem uniform_clado,
1762 final JRadioButtonMenuItem nonuniform_clado,
1763 final JCheckBoxMenuItem label_direction_cbmi ) {
1764 final TreePanel tree_panel = main_panel.getCurrentTreePanel();
1765 final ControlPanel control = main_panel.getControlPanel();
1766 final Options options = main_panel.getOptions();
1767 scale.setSelected( options.isShowScale() );
1768 branch_lengths.setSelected( options.isShowBranchLengthValues() );
1769 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1770 if ( ( tree_panel != null ) && ( !tree_panel.isPhyHasBranchLengths() ) ) {
1771 scale.setSelected( false );
1772 scale.setEnabled( false );
1773 branch_lengths.setSelected( false );
1774 branch_lengths.setEnabled( false );
1776 else if ( ( tree_panel != null ) && !control.isDrawPhylogram() ) {
1777 scale.setSelected( false );
1778 scale.setEnabled( false );
1779 branch_lengths.setEnabled( true );
1782 scale.setEnabled( true );
1783 branch_lengths.setEnabled( true );
1785 if ( ( tree_panel != null )
1786 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.ROUNDED )
1787 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1788 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1789 branch_lengths.setSelected( false );
1790 branch_lengths.setEnabled( false );
1792 if ( tree_panel != null ) {
1793 if ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1794 || ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
1795 non_lined_up.setEnabled( false );
1796 uniform_clado.setEnabled( false );
1797 nonuniform_clado.setEnabled( false );
1800 non_lined_up.setEnabled( true );
1801 uniform_clado.setEnabled( true );
1802 nonuniform_clado.setEnabled( true );
1806 if ( ( tree_panel != null )
1807 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1808 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1809 branch_lengths.setSelected( false );
1810 branch_lengths.setEnabled( false );
1812 if ( ( tree_panel != null )
1813 && ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( tree_panel
1814 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
1815 non_lined_up.setEnabled( false );
1818 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1819 non_lined_up.setEnabled( true );
1822 label_direction_cbmi.setEnabled( true );
1823 if ( tree_panel != null ) {
1824 if ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1825 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1826 label_direction_cbmi.setEnabled( false );
1828 if ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
1829 scale.setSelected( false );
1830 scale.setEnabled( false );
1835 static void updateScreenTextAntialias( final List<TreePanel> treepanels ) {
1836 for( final TreePanel tree_panel : treepanels ) {
1837 tree_panel.setTextAntialias();