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.PhylogenyNode;
64 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
65 import org.forester.phylogeny.data.Annotation;
66 import org.forester.phylogeny.data.NodeVisualization.NodeFill;
67 import org.forester.phylogeny.data.NodeVisualization.NodeShape;
68 import org.forester.sdi.GSDI;
69 import org.forester.sdi.GSDIR;
70 import org.forester.sdi.SDIException;
71 import org.forester.util.ForesterConstants;
72 import org.forester.util.ForesterUtil;
74 public abstract class MainFrame extends JFrame implements ActionListener {
76 static final String USE_MOUSEWHEEL_SHIFT_TO_ROTATE = "In this display type, use mousewheel + Shift to rotate [or A and S]";
77 static final String PHYLOXML_REF_TOOL_TIP = Constants.PHYLOXML_REFERENCE; //TODO //FIXME
78 static final String APTX_REF_TOOL_TIP = Constants.APTX_REFERENCE;
79 private static final long serialVersionUID = 3655000897845508358L;
80 final static Font menu_font = new Font( Configuration.getDefaultFontFamilyName(),
83 static final String TYPE_MENU_HEADER = "Type";
84 static final String RECTANGULAR_TYPE_CBMI_LABEL = "Rectangular";
85 static final String EURO_TYPE_CBMI_LABEL = "Euro Type";
86 static final String CURVED_TYPE_CBMI_LABEL = "Curved";
87 static final String TRIANGULAR_TYPE_CBMI_LABEL = "Triangular";
88 static final String CONVEX_TYPE_CBMI_LABEL = "Convex";
89 static final String ROUNDED_TYPE_CBMI_LABEL = "Rounded";
90 static final String UNROOTED_TYPE_CBMI_LABEL = "Unrooted (alpha)"; //TODO
91 static final String CIRCULAR_TYPE_CBMI_LABEL = "Circular (alpha)"; //TODO
92 static final String OPTIONS_HEADER = "Options";
93 static final String SEARCH_SUBHEADER = "Search:";
94 static final String DISPLAY_SUBHEADER = "Display:";
95 static final String SEARCH_TERMS_ONLY_LABEL = "Match Complete Terms Only";
96 static final String SEARCH_CASE_SENSITIVE_LABEL = "Case Sensitive";
97 static final String INVERSE_SEARCH_RESULT_LABEL = "Negate Result";
98 static final String DISPLAY_BRANCH_LENGTH_VALUES_LABEL = "Display Branch Length Values";
99 static final String DISPLAY_SCALE_LABEL = "Display Scale";
100 static final String NON_LINED_UP_CLADOGRAMS_LABEL = "Non-Lined Up Cladograms";
101 static final String UNIFORM_CLADOGRAMS_LABEL = "Total Node Sum Dependent Cladograms";
102 static final String LABEL_DIRECTION_LABEL = "Radial Labels";
103 static final String LABEL_DIRECTION_TIP = "To use radial node labels in radial and unrooted display types";
104 static final String SCREEN_ANTIALIAS_LABEL = "Antialias";
105 static final String COLOR_LABELS_LABEL = "Colorize Labels Same as Parent Branch";
106 static final String BG_GRAD_LABEL = "Background Color Gradient";
107 static final String DISPLAY_NODE_BOXES_LABEL_EXT = "Show External Node Shapes";
108 static final String DISPLAY_NODE_BOXES_LABEL_INT = "Show Internal Node Shapes";
109 static final String SHOW_OVERVIEW_LABEL = "Show Overview";
110 static final String FONT_SIZE_MENU_LABEL = "Font Size";
111 static final String NONUNIFORM_CLADOGRAMS_LABEL = "External Node Sum Dependent Cladograms";
112 static final String SHOW_DOMAIN_LABELS_LABEL = "Show Domain Labels";
113 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";
114 static final String ABBREV_SN_LABEL = "Abbreviate Scientific Taxonomic Names";
115 static final String TAXONOMY_COLORIZE_NODE_SHAPES_LABEL = "Colorize Node Shapes According to Taxonomy";
116 static final String CYCLE_NODE_SHAPE_LABEL = "Cycle Node Shapes";
117 static final String CYCLE_NODE_FILL_LABEL = "Cycle Node Fill Type";
118 static final String CHOOSE_NODE_SIZE_LABEL = "Choose Node Shape Size";
119 static final String SHOW_CONF_STDDEV_LABEL = "Show Confidence Standard Deviations";
120 static final String USE_BRACKETS_FOR_CONF_IN_NH_LABEL = "Use Brackets for Confidence Values";
121 static final String USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL = "Use Internal Node Names for Confidence Values";
126 JMenu _options_jmenu;
127 JMenu _font_size_menu;
129 JMenuItem[] _load_phylogeny_from_webservice_menu_items;
131 JMenu _analysis_menu;
132 JMenuItem _load_species_tree_item;
133 JMenuItem _gsdi_item;
134 JMenuItem _gsdir_item;
135 JMenuItem _lineage_inference;
136 JMenuItem _function_analysis;
138 JMenuItem _open_item;
139 JMenuItem _open_url_item;
140 JMenuItem _save_item;
141 JMenuItem _save_all_item;
142 JMenuItem _close_item;
143 JMenuItem _exit_item;
146 JMenuItem _midpoint_root_item;
147 JMenuItem _taxcolor_item;
148 JMenuItem _confcolor_item;
149 JMenuItem _color_rank_jmi;
150 JMenuItem _collapse_species_specific_subtrees;
151 JMenuItem _collapse_below_threshold; //TODO implememt me
152 JMenuItem _obtain_detailed_taxonomic_information_jmi;
153 JMenuItem _obtain_detailed_taxonomic_information_deleting_jmi;
154 JMenuItem _obtain_seq_information_jmi;
155 JMenuItem _move_node_names_to_tax_sn_jmi;
156 JMenuItem _move_node_names_to_seq_names_jmi;
157 JMenuItem _extract_tax_code_from_node_names_jmi;
158 JMenuItem _annotate_item;
160 JMenuItem _super_tiny_fonts_item;
161 JMenuItem _tiny_fonts_item;
162 JMenuItem _small_fonts_item;
163 JMenuItem _medium_fonts_item;
164 JMenuItem _large_fonts_item;
166 // _ screen and print
167 JMenuItem _choose_font_mi;
168 JMenuItem _switch_colors_mi;
169 JCheckBoxMenuItem _label_direction_cbmi;
171 JCheckBoxMenuItem _screen_antialias_cbmi;
172 JCheckBoxMenuItem _background_gradient_cbmi;
173 JRadioButtonMenuItem _non_lined_up_cladograms_rbmi;
174 JRadioButtonMenuItem _uniform_cladograms_rbmi;
175 JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi;
176 JCheckBoxMenuItem _show_branch_length_values_cbmi;
177 JCheckBoxMenuItem _show_scale_cbmi; //TODO fix me
178 JCheckBoxMenuItem _show_overview_cbmi;
179 JCheckBoxMenuItem _show_domain_labels;
180 JCheckBoxMenuItem _abbreviate_scientific_names;
181 JCheckBoxMenuItem _color_labels_same_as_parent_branch;
182 JMenuItem _overview_placment_mi;
183 JMenuItem _choose_minimal_confidence_mi;
184 JCheckBoxMenuItem _show_default_node_shapes_internal_cbmi;
185 JCheckBoxMenuItem _show_default_node_shapes_external_cbmi;
186 JMenuItem _cycle_node_shape_mi;
187 JMenuItem _cycle_node_fill_mi;
188 JMenuItem _choose_node_size_mi;
189 JCheckBoxMenuItem _taxonomy_colorize_node_shapes_cbmi;
190 JCheckBoxMenuItem _show_confidence_stddev_cbmi;
192 JCheckBoxMenuItem _graphics_export_visible_only_cbmi;
193 JCheckBoxMenuItem _antialias_print_cbmi;
194 JCheckBoxMenuItem _print_black_and_white_cbmi;
195 JCheckBoxMenuItem _print_using_actual_size_cbmi;
196 JCheckBoxMenuItem _graphics_export_using_actual_size_cbmi;
197 JMenuItem _print_size_mi;
198 JMenuItem _choose_pdf_width_mi;
200 JCheckBoxMenuItem _internal_number_are_confidence_for_nh_parsing_cbmi;
201 JRadioButtonMenuItem _extract_taxonomy_no_rbmi;
202 JRadioButtonMenuItem _extract_taxonomy_yes_rbmi;
203 JRadioButtonMenuItem _extract_taxonomy_pfam_rbmi;
204 JCheckBoxMenuItem _replace_underscores_cbmi;
205 JCheckBoxMenuItem _use_brackets_for_conf_in_nh_export_cbmi;
206 JCheckBoxMenuItem _use_internal_names_for_conf_in_nh_export_cbmi;
208 JCheckBoxMenuItem _search_case_senstive_cbmi;
209 JCheckBoxMenuItem _search_whole_words_only_cbmi;
210 JCheckBoxMenuItem _inverse_search_result_cbmi;
213 JCheckBoxMenuItem _rectangular_type_cbmi;
214 JCheckBoxMenuItem _triangular_type_cbmi;
215 JCheckBoxMenuItem _curved_type_cbmi;
216 JCheckBoxMenuItem _convex_type_cbmi;
217 JCheckBoxMenuItem _euro_type_cbmi;
218 JCheckBoxMenuItem _rounded_type_cbmi;
219 JCheckBoxMenuItem _unrooted_type_cbmi;
220 JCheckBoxMenuItem _circular_type_cbmi;
221 // view as text menu:
222 JMenuItem _view_as_NH_item;
223 JMenuItem _view_as_XML_item;
224 JMenuItem _view_as_nexus_item;
225 JMenuItem _display_basic_information_item;
227 JMenuItem _about_item;
228 JMenuItem _help_item;
229 JMenuItem _website_item;
230 JMenuItem _phyloxml_website_item;
231 JMenuItem _phyloxml_ref_item;
232 JMenuItem _aptx_ref_item;
235 // Handy pointers to child components:
236 MainPanel _mainpanel;
237 Container _contentpane;
238 final LinkedList<TextFrame> _textframes = new LinkedList<TextFrame>(); ;
239 Configuration _configuration;
240 JMenuItem _remove_branch_color_item;
242 Phylogeny _species_tree;
243 InferenceManager _inference_manager;
244 final ProcessPool _process_pool;
245 private String _previous_node_annotation_ref;
248 _process_pool = ProcessPool.createInstance();
255 public void actionPerformed( final ActionEvent e ) {
256 final Object o = e.getSource();
257 boolean is_applet = false;
258 JApplet applet = null;
259 if ( getCurrentTreePanel() != null ) {
260 is_applet = getCurrentTreePanel().isApplet();
262 applet = getCurrentTreePanel().obtainApplet();
265 if ( o == _open_url_item ) {
266 readPhylogeniesFromURL();
268 else if ( o == _exit_item ) {
271 else if ( o == _gsdi_item ) {
272 if ( isSubtreeDisplayed() ) {
277 else if ( o == _gsdir_item ) {
278 if ( isSubtreeDisplayed() ) {
283 else if ( o == _taxcolor_item ) {
286 else if ( o == _confcolor_item ) {
289 else if ( o == _color_rank_jmi ) {
292 else if ( o == _collapse_species_specific_subtrees ) {
293 if ( isSubtreeDisplayed() ) {
296 if ( getCurrentTreePanel() != null ) {
297 getCurrentTreePanel().collapseSpeciesSpecificSubtrees();
300 else if ( o == _remove_branch_color_item ) {
301 if ( isSubtreeDisplayed() ) {
304 removeBranchColors();
306 else if ( o == _midpoint_root_item ) {
307 if ( isSubtreeDisplayed() ) {
312 else if ( o == _annotate_item ) {
315 else if ( o == _switch_colors_mi ) {
318 else if ( o == _display_basic_information_item ) {
319 displayBasicInformation();
321 else if ( o == _view_as_NH_item ) {
324 else if ( o == _view_as_XML_item ) {
327 else if ( o == _view_as_nexus_item ) {
330 else if ( o == _super_tiny_fonts_item ) {
331 if ( getCurrentTreePanel() != null ) {
332 getCurrentTreePanel().setSuperTinyFonts();
333 getCurrentTreePanel().repaint();
336 else if ( o == _tiny_fonts_item ) {
337 if ( getCurrentTreePanel() != null ) {
338 getCurrentTreePanel().setTinyFonts();
339 getCurrentTreePanel().repaint();
342 else if ( o == _small_fonts_item ) {
343 if ( getCurrentTreePanel() != null ) {
344 getCurrentTreePanel().setSmallFonts();
345 getCurrentTreePanel().repaint();
348 else if ( o == _medium_fonts_item ) {
349 if ( getCurrentTreePanel() != null ) {
350 getCurrentTreePanel().setMediumFonts();
351 getCurrentTreePanel().repaint();
354 else if ( o == _large_fonts_item ) {
355 if ( getCurrentTreePanel() != null ) {
356 getCurrentTreePanel().setLargeFonts();
357 getCurrentTreePanel().repaint();
360 else if ( o == _choose_font_mi ) {
363 else if ( o == _choose_minimal_confidence_mi ) {
364 chooseMinimalConfidence();
366 else if ( o == _choose_node_size_mi ) {
367 chooseNodeSize( getOptions(), this );
369 else if ( o == _overview_placment_mi ) {
370 MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
372 else if ( o == _cycle_node_fill_mi ) {
373 MainFrame.cycleNodeFill( getOptions(), getCurrentTreePanel() );
375 else if ( o == _cycle_node_shape_mi ) {
376 MainFrame.cycleNodeShape( getOptions(), getCurrentTreePanel() );
378 else if ( o == _screen_antialias_cbmi ) {
379 updateOptions( getOptions() );
380 updateScreenTextAntialias( getMainPanel().getTreePanels() );
382 else if ( o == _background_gradient_cbmi ) {
383 updateOptions( getOptions() );
385 else if ( o == _show_domain_labels ) {
386 updateOptions( getOptions() );
388 else if ( o == _abbreviate_scientific_names ) {
389 updateOptions( getOptions() );
391 else if ( o == _color_labels_same_as_parent_branch ) {
392 updateOptions( getOptions() );
394 else if ( o == _show_default_node_shapes_internal_cbmi ) {
395 updateOptions( getOptions() );
397 else if ( o == _show_default_node_shapes_external_cbmi ) {
398 updateOptions( getOptions() );
400 else if ( o == _taxonomy_colorize_node_shapes_cbmi ) {
401 updateOptions( getOptions() );
403 else if ( o == _non_lined_up_cladograms_rbmi ) {
404 updateOptions( getOptions() );
407 else if ( o == _uniform_cladograms_rbmi ) {
408 updateOptions( getOptions() );
411 else if ( o == _ext_node_dependent_cladogram_rbmi ) {
412 updateOptions( getOptions() );
415 else if ( o == _search_case_senstive_cbmi ) {
416 updateOptions( getOptions() );
417 getMainPanel().getControlPanel().search();
419 else if ( o == _search_whole_words_only_cbmi ) {
420 updateOptions( getOptions() );
421 getMainPanel().getControlPanel().search();
423 else if ( o == _inverse_search_result_cbmi ) {
424 updateOptions( getOptions() );
425 getMainPanel().getControlPanel().search();
427 else if ( o == _show_scale_cbmi ) {
428 updateOptions( getOptions() );
430 else if ( o == _show_branch_length_values_cbmi ) {
431 updateOptions( getOptions() );
433 else if ( o == _show_confidence_stddev_cbmi ) {
434 updateOptions( getOptions() );
436 else if ( o == _use_brackets_for_conf_in_nh_export_cbmi ) {
437 if ( _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {
438 _use_internal_names_for_conf_in_nh_export_cbmi.setSelected( false );
440 updateOptions( getOptions() );
442 else if ( o == _use_internal_names_for_conf_in_nh_export_cbmi ) {
443 if ( _use_internal_names_for_conf_in_nh_export_cbmi.isSelected() ) {
444 _use_brackets_for_conf_in_nh_export_cbmi.setSelected( false );
446 updateOptions( getOptions() );
448 else if ( o == _label_direction_cbmi ) {
449 updateOptions( getOptions() );
451 else if ( o == _show_overview_cbmi ) {
452 updateOptions( getOptions() );
453 if ( getCurrentTreePanel() != null ) {
454 getCurrentTreePanel().updateOvSizes();
457 else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
458 || ( o == _convex_type_cbmi ) || ( o == _euro_type_cbmi ) || ( o == _rounded_type_cbmi )
459 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
462 else if ( o == _about_item ) {
465 else if ( o == _help_item ) {
468 else if ( o == _website_item ) {
470 AptxUtil.openWebsite( Constants.APTX_WEB_SITE, is_applet, applet );
472 catch ( final IOException e1 ) {
473 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
476 else if ( o == _phyloxml_website_item ) {
478 AptxUtil.openWebsite( Constants.PHYLOXML_WEB_SITE, is_applet, applet );
480 catch ( final IOException e1 ) {
481 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
484 else if ( o == _aptx_ref_item ) {
486 AptxUtil.openWebsite( Constants.APTX_REFERENCE_URL, is_applet, applet );
488 catch ( final IOException e1 ) {
489 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
492 else if ( o == _phyloxml_ref_item ) {
494 AptxUtil.openWebsite( Constants.PHYLOXML_REFERENCE_URL, is_applet, applet );
496 catch ( final IOException e1 ) {
497 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
501 if ( _load_phylogeny_from_webservice_menu_items != null ) {
502 for( int i = 0; i < _load_phylogeny_from_webservice_menu_items.length; ++i ) {
503 if ( o == _load_phylogeny_from_webservice_menu_items[ i ] ) {
504 readPhylogeniesFromWebservice( i );
509 _contentpane.repaint();
512 public Configuration getConfiguration() {
513 return _configuration;
517 * This method returns the current external node data which
518 * has been selected by the user by clicking the "Return ..."
519 * menu item. This method is expected to be called from Javascript or
522 * @return current external node data as String
524 public String getCurrentExternalNodesDataBuffer() {
525 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString();
528 public int getCurrentExternalNodesDataBufferChangeCounter() {
529 return getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter();
532 public int getCurrentExternalNodesDataBufferLength() {
533 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length();
536 public InferenceManager getInferenceManager() {
537 return _inference_manager;
540 public MainPanel getMainPanel() {
544 public Options getOptions() {
548 public ProcessPool getProcessPool() {
549 return _process_pool;
552 public void showTextFrame( final String s, final String title ) {
554 _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
557 public void showWhole() {
558 _mainpanel.getControlPanel().showWhole();
561 public void updateProcessMenu() {
562 // In general Swing is not thread safe.
563 // See "Swing's Threading Policy".
564 SwingUtilities.invokeLater( new Runnable() {
568 doUpdateProcessMenu();
573 void activateSaveAllIfNeeded() {
574 if ( ( getMainPanel().getTabbedPane() != null ) && ( getMainPanel().getTabbedPane().getTabCount() > 1 ) ) {
575 _save_all_item.setEnabled( true );
578 _save_all_item.setEnabled( false );
582 void buildFileMenu() {
583 _file_jmenu = createMenu( "File", getConfiguration() );
584 _file_jmenu.add( _open_url_item = new JMenuItem( "Read tree from URL/webservice..." ) );
585 _file_jmenu.addSeparator();
586 _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );
587 customizeJMenuItem( _open_url_item );
588 customizeJMenuItem( _exit_item );
589 _jmenubar.add( _file_jmenu );
592 void buildFontSizeMenu() {
593 _font_size_menu = createMenu( FONT_SIZE_MENU_LABEL, getConfiguration() );
594 _font_size_menu.add( _super_tiny_fonts_item = new JMenuItem( "Super Tiny Fonts" ) );
595 _font_size_menu.add( _tiny_fonts_item = new JMenuItem( "Tiny Fonts" ) );
596 _font_size_menu.add( _small_fonts_item = new JMenuItem( "Small Fonts" ) );
597 _font_size_menu.add( _medium_fonts_item = new JMenuItem( "Medium Fonts" ) );
598 _font_size_menu.add( _large_fonts_item = new JMenuItem( "Large Fonts" ) );
599 customizeJMenuItem( _super_tiny_fonts_item );
600 customizeJMenuItem( _tiny_fonts_item );
601 customizeJMenuItem( _small_fonts_item );
602 customizeJMenuItem( _medium_fonts_item );
603 customizeJMenuItem( _large_fonts_item );
604 _jmenubar.add( _font_size_menu );
607 void buildHelpMenu() {
608 _help_jmenu = createMenu( "Help", getConfiguration() );
609 _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
610 _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
611 _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
612 _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
613 _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
614 _help_jmenu.addSeparator();
615 _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
616 customizeJMenuItem( _help_item );
617 customizeJMenuItem( _website_item );
618 customizeJMenuItem( _phyloxml_website_item );
619 customizeJMenuItem( _aptx_ref_item );
620 customizeJMenuItem( _phyloxml_ref_item );
621 customizeJMenuItem( _about_item );
622 _phyloxml_ref_item.setToolTipText( PHYLOXML_REF_TOOL_TIP );
623 _aptx_ref_item.setToolTipText( APTX_REF_TOOL_TIP );
624 _jmenubar.add( _help_jmenu );
627 void buildTypeMenu() {
628 _type_menu = createMenu( TYPE_MENU_HEADER, getConfiguration() );
629 _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
630 _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
631 _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
632 _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
633 _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
634 _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
635 _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
636 _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
637 customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
638 customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
639 customizeCheckBoxMenuItem( _euro_type_cbmi, false );
640 customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
641 customizeCheckBoxMenuItem( _curved_type_cbmi, false );
642 customizeCheckBoxMenuItem( _convex_type_cbmi, false );
643 customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
644 customizeCheckBoxMenuItem( _circular_type_cbmi, false );
645 _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
646 _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
647 initializeTypeMenu( getOptions() );
648 _jmenubar.add( _type_menu );
651 void buildViewMenu() {
652 _view_jmenu = createMenu( "View", getConfiguration() );
653 _view_jmenu.add( _display_basic_information_item = new JMenuItem( "Display Basic Information" ) );
654 _view_jmenu.addSeparator();
655 _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) );
656 _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) );
657 _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "View as Nexus" ) );
658 customizeJMenuItem( _display_basic_information_item );
659 customizeJMenuItem( _view_as_NH_item );
660 customizeJMenuItem( _view_as_XML_item );
661 customizeJMenuItem( _view_as_nexus_item );
662 _jmenubar.add( _view_jmenu );
665 void checkTextFrames() {
666 if ( _textframes.size() > 5 ) {
668 if ( _textframes.getFirst() != null ) {
669 _textframes.getFirst().removeMe();
672 _textframes.removeFirst();
675 catch ( final NoSuchElementException e ) {
682 removeAllTextFrames();
683 if ( _mainpanel != null ) {
684 _mainpanel.terminate();
686 if ( _contentpane != null ) {
687 _contentpane.removeAll();
694 if ( _mainpanel.getCurrentTreePanel() != null ) {
695 final String[] ranks = AptxUtil.getAllPossibleRanks();
696 final String rank = ( String ) JOptionPane
697 .showInputDialog( this,
698 "What rank should the colorization be based on",
700 JOptionPane.QUESTION_MESSAGE,
704 if ( !ForesterUtil.isEmpty( rank ) ) {
705 _mainpanel.getCurrentTreePanel().colorRank( rank );
711 if ( _mainpanel.getCurrentTreePanel() != null ) {
712 _mainpanel.getCurrentTreePanel().confColor();
716 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
717 if ( item != null ) {
718 item.setFont( MainFrame.menu_font );
719 if ( !getConfiguration().isUseNativeUI() ) {
720 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
721 item.setForeground( getConfiguration().getGuiMenuTextColor() );
723 item.setSelected( is_selected );
724 item.addActionListener( this );
728 JMenuItem customizeJMenuItem( final JMenuItem jmi ) {
730 jmi.setFont( MainFrame.menu_font );
731 if ( !getConfiguration().isUseNativeUI() ) {
732 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
733 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
735 jmi.addActionListener( this );
740 void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
741 if ( item != null ) {
742 item.setFont( MainFrame.menu_font );
743 if ( !getConfiguration().isUseNativeUI() ) {
744 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
745 item.setForeground( getConfiguration().getGuiMenuTextColor() );
747 item.setSelected( is_selected );
748 item.addActionListener( this );
752 void displayBasicInformation() {
753 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
754 String title = "Basic Information";
755 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
756 title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
758 showTextFrame( AptxUtil.createBasicInformation( _mainpanel.getCurrentPhylogeny() ), title );
762 void exceptionOccuredDuringOpenFile( final Exception e ) {
764 _mainpanel.getCurrentTreePanel().setArrowCursor();
766 catch ( final Exception ex ) {
769 JOptionPane.showMessageDialog( this,
770 ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
771 "Error during File|Open",
772 JOptionPane.ERROR_MESSAGE );
775 void exceptionOccuredDuringSaveAs( final Exception e ) {
777 _mainpanel.getCurrentTreePanel().setArrowCursor();
779 catch ( final Exception ex ) {
782 JOptionPane.showMessageDialog( this, "Exception" + e, "Error during File|SaveAs", JOptionPane.ERROR_MESSAGE );
786 if ( !isOKforSDI( false, true ) ) {
789 if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {
790 JOptionPane.showMessageDialog( this,
791 "Gene tree is not rooted.",
792 "Cannot execute GSDI",
793 JOptionPane.ERROR_MESSAGE );
796 final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
797 gene_tree.setAllNodesToNotCollapse();
798 gene_tree.recalculateNumberOfExternalDescendants( false );
800 final Phylogeny species_tree = _species_tree.copy();
802 gsdi = new GSDI( gene_tree, species_tree, false, true, true );
804 catch ( final SDIException e ) {
805 JOptionPane.showMessageDialog( this,
806 e.getLocalizedMessage(),
808 JOptionPane.ERROR_MESSAGE );
811 catch ( final Exception e ) {
812 AptxUtil.unexpectedException( e );
815 gene_tree.setRerootable( false );
816 gene_tree.clearHashIdToNodeMap();
817 gene_tree.recalculateNumberOfExternalDescendants( true );
818 _mainpanel.addPhylogenyInNewTab( gene_tree, getConfiguration(), "gene tree", null );
819 getMainPanel().getControlPanel().setShowEvents( true );
821 final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
822 _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
824 _mainpanel.getTabbedPane().setSelectedIndex( selected );
826 _mainpanel.getCurrentTreePanel().setEdited( true );
827 final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
828 if ( gsdi.getStrippedExternalGeneTreeNodes().size() > 0 ) {
829 JOptionPane.showMessageDialog( this,
830 "Duplications: " + gsdi.getDuplicationsSum() + "\n"
831 + "Potential duplications: "
832 + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
833 + "Speciations: " + gsdi.getSpeciationsSum() + "\n"
834 + "Stripped gene tree nodes: "
835 + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
836 + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
837 + "Number of polytomies in species tree used: " + poly + "\n",
838 "GSDI successfully completed",
839 JOptionPane.WARNING_MESSAGE );
842 JOptionPane.showMessageDialog( this,
843 "Duplications: " + gsdi.getDuplicationsSum() + "\n"
844 + "Potential duplications: "
845 + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
846 + "Speciations: " + gsdi.getSpeciationsSum() + "\n"
847 + "Stripped gene tree nodes: "
848 + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
849 + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
850 + "Number of polytomies in species tree used: " + poly + "\n",
851 "GSDI successfully completed",
852 JOptionPane.INFORMATION_MESSAGE );
856 void executeGSDIR() {
857 if ( !isOKforSDI( false, false ) ) {
860 final int p = PhylogenyMethods.countNumberOfPolytomies( _mainpanel.getCurrentPhylogeny() );
862 && !( ( p == 1 ) && ( _mainpanel.getCurrentPhylogeny().getRoot().getNumberOfDescendants() == 3 ) ) ) {
863 JOptionPane.showMessageDialog( this,
864 "Gene tree is not completely binary",
865 "Cannot execute GSDI",
866 JOptionPane.ERROR_MESSAGE );
869 final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
870 gene_tree.setAllNodesToNotCollapse();
871 gene_tree.recalculateNumberOfExternalDescendants( false );
873 final Phylogeny species_tree = _species_tree.copy();
875 gsdir = new GSDIR( gene_tree, species_tree, true, true );
877 catch ( final SDIException e ) {
878 JOptionPane.showMessageDialog( this,
879 e.getLocalizedMessage(),
880 "Error during GSDIR",
881 JOptionPane.ERROR_MESSAGE );
884 catch ( final Exception e ) {
885 AptxUtil.unexpectedException( e );
888 final Phylogeny result_gene_tree = gsdir.getMinDuplicationsSumGeneTree();
889 result_gene_tree.setRerootable( false );
890 result_gene_tree.clearHashIdToNodeMap();
891 result_gene_tree.recalculateNumberOfExternalDescendants( true );
892 _mainpanel.addPhylogenyInNewTab( result_gene_tree, getConfiguration(), "gene tree", null );
893 getMainPanel().getControlPanel().setShowEvents( true );
895 final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
896 _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
898 _mainpanel.getTabbedPane().setSelectedIndex( selected );
900 _mainpanel.getCurrentTreePanel().setEdited( true );
901 final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
902 if ( gsdir.getStrippedExternalGeneTreeNodes().size() > 0 ) {
903 JOptionPane.showMessageDialog( this,
904 "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
905 + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
906 + "Stripped gene tree nodes: "
907 + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
908 + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
909 + "Number of polytomies in species tree used: " + poly + "\n",
910 "GSDIR successfully completed",
911 JOptionPane.WARNING_MESSAGE );
914 JOptionPane.showMessageDialog( this,
915 "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
916 + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
917 + "Stripped gene tree nodes: "
918 + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
919 + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
920 + "Number of polytomies in species tree used: " + poly + "\n",
921 "GSDIR successfully completed",
922 JOptionPane.INFORMATION_MESSAGE );
926 boolean GAndSDoHaveMoreThanOneSpeciesInComman( final Phylogeny gene_tree ) {
927 if ( ( gene_tree == null ) || gene_tree.isEmpty() ) {
928 JOptionPane.showMessageDialog( this,
929 "Gene tree and species tree have no species in common.",
931 JOptionPane.ERROR_MESSAGE );
934 else if ( gene_tree.getNumberOfExternalNodes() < 2 ) {
935 JOptionPane.showMessageDialog( this,
936 "Gene tree and species tree have only one species in common.",
938 JOptionPane.ERROR_MESSAGE );
946 TreePanel getCurrentTreePanel() {
947 return getMainPanel().getCurrentTreePanel();
950 JMenu getHelpMenu() {
954 JCheckBoxMenuItem getlabelDirectionCbmi() {
955 return _label_direction_cbmi;
958 JMenuBar getMenuBarOfMainFrame() {
963 final StringBuilder sb = new StringBuilder();
964 sb.append( "Display options\n" );
965 sb.append( "-------------------\n" );
966 sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
967 sb.append( "Clickable tree nodes\n" );
968 sb.append( "--------------------\n" );
969 sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
970 sb.append( "or by right clicking:\n" );
971 sb.append( "o Display Node Data -- display information for a node\n" );
972 sb.append( "o Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
973 sb.append( "o Root/Reroot -- change tree root to clicked node\n" );
974 sb.append( "o Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
975 sb.append( "o Swap Descendants -- switch descendant on either side of clicked node\n" );
976 sb.append( "o Colorize Subtree -- color a subtree\n" );
977 sb.append( "o Open Sequence Web -- launch a web browser to display sequence information\n" );
978 sb.append( "o Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
979 sb.append( "- there may be additional choices depending on this particular setup\n\n" );
980 sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
981 sb.append( "Zooming\n" );
982 sb.append( "---------\n" );
983 sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
984 sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
985 sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
986 sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
987 sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
988 sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
989 sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
990 sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
991 sb.append( "Quick tree manipulation:\n" );
992 sb.append( "------------------------\n" );
993 sb.append( "Order Subtrees -- order the tree by branch length\n" );
994 sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
995 sb.append( "Memory problems (Java heap space error)\n" );
996 sb.append( "---------------------------------------\n" );
997 sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
998 sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
999 sb.append( "the '-Xmx' Java command line option. For example:\n" );
1000 sb.append( "java -Xmx1024m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
1001 // + "General remarks\n"
1002 // + "---------------\n"
1004 // "o The application version permits copying to the clipboard \n"
1006 // " in the \"View\"|\"View as ...\" frame (either by control-c or button press).\n"
1008 // "o Changes made to a subtree affect this subtree and its subtrees,\n"
1009 // + " but not any of its parent tree(s).\n"
1011 // "o Archaeopteryx tries to detect whether the numerical values in a NH tree\n"
1013 // " are likely to be bootstrap values instead of branch length values.\n\n"
1015 // " Remarks regarding SDI (Speciation Duplication Inference):\n"
1017 // "o Each external node of the gene tree (in display) needs to be associated with\n"
1019 // " a species: either directly through the \"Species\" field, or the species\n"
1021 // " is part of the sequence name in the form \"XXXX_SPECIES\"\n"
1023 // " (e.g. \"ACON_DROME\" or \"ACON_DROME/123-4489\" which is also acceptable).\n"
1025 // "o A species tree for each species of the gene tree needs to be loaded with\n"
1027 // " \"SDI\"|\"Load species tree\" prior the SDI execution.\n"
1029 // "o !External nodes of the gene tree associated with species not present in\n"
1031 // " the species tree are REMOVED prior to SDI execution!\n"
1033 // "o Both the gene tree and the species tree must be completely binary.\n"
1035 // "o Duplications and speciations are a function of the position of the root.\n"
1037 // " Hence, after each manual \"Root/Reroot\"ing some duplications will be\n"
1038 // + " incorrect and need to be inferred again\n"
1040 // " with: \"SDI\"|\"SDI (Speciation Duplication Inference)\n\n"
1041 sb.append( "phyloXML\n" );
1042 sb.append( "-------------------\n" );
1043 sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
1044 sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
1045 sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1047 sb.append( "For more information: https://sites.google.com/site/cmzmasek/home/software/archaeopteryx\n" );
1048 sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
1049 TextFrame.instantiate( sb.toString(), "Help", _textframes );
1052 void initializeTypeMenu( final Options options ) {
1053 setTypeMenuToAllUnselected();
1054 switch ( options.getPhylogenyGraphicsType() ) {
1056 _convex_type_cbmi.setSelected( true );
1059 _curved_type_cbmi.setSelected( true );
1062 _euro_type_cbmi.setSelected( true );
1065 _rounded_type_cbmi.setSelected( true );
1068 _triangular_type_cbmi.setSelected( true );
1071 _unrooted_type_cbmi.setSelected( true );
1074 _circular_type_cbmi.setSelected( true );
1077 _rectangular_type_cbmi.setSelected( true );
1082 boolean isOKforSDI( final boolean species_tree_has_to_binary, final boolean gene_tree_has_to_binary ) {
1083 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty() ) {
1086 else if ( ( _species_tree == null ) || _species_tree.isEmpty() ) {
1087 JOptionPane.showMessageDialog( this,
1088 "No species tree loaded",
1089 "Cannot execute GSDI",
1090 JOptionPane.ERROR_MESSAGE );
1093 else if ( species_tree_has_to_binary && !_species_tree.isCompletelyBinary() ) {
1094 JOptionPane.showMessageDialog( this,
1095 "Species tree is not completely binary",
1096 "Cannot execute GSDI",
1097 JOptionPane.ERROR_MESSAGE );
1100 else if ( gene_tree_has_to_binary && !_mainpanel.getCurrentPhylogeny().isCompletelyBinary() ) {
1101 JOptionPane.showMessageDialog( this,
1102 "Gene tree is not completely binary",
1103 "Cannot execute GSDI",
1104 JOptionPane.ERROR_MESSAGE );
1112 boolean isSubtreeDisplayed() {
1113 if ( getCurrentTreePanel() != null ) {
1114 if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
1116 .showMessageDialog( this,
1117 "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",
1118 "Operation can not be exectuted on a sub-tree",
1119 JOptionPane.WARNING_MESSAGE );
1126 void midpointRoot() {
1127 if ( _mainpanel.getCurrentTreePanel() != null ) {
1128 _mainpanel.getCurrentTreePanel().midpointRoot();
1132 abstract void readPhylogeniesFromURL();
1134 void readPhylogeniesFromWebservice( final int i ) {
1135 final UrlTreeReader reader = new UrlTreeReader( this, i );
1136 new Thread( reader ).start();
1139 void removeAllTextFrames() {
1140 for( final TextFrame tf : _textframes ) {
1145 _textframes.clear();
1148 void setConfiguration( final Configuration configuration ) {
1149 _configuration = configuration;
1152 void setInferenceManager( final InferenceManager i ) {
1153 _inference_manager = i;
1156 void setOptions( final Options options ) {
1160 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
1161 setTypeMenuToAllUnselected();
1164 _circular_type_cbmi.setSelected( true );
1167 _convex_type_cbmi.setSelected( true );
1170 _curved_type_cbmi.setSelected( true );
1173 _euro_type_cbmi.setSelected( true );
1176 _rounded_type_cbmi.setSelected( true );
1179 _rectangular_type_cbmi.setSelected( true );
1182 _triangular_type_cbmi.setSelected( true );
1185 _unrooted_type_cbmi.setSelected( true );
1188 throw new IllegalArgumentException( "unknown type: " + type );
1192 void setTypeMenuToAllUnselected() {
1193 _convex_type_cbmi.setSelected( false );
1194 _curved_type_cbmi.setSelected( false );
1195 _euro_type_cbmi.setSelected( false );
1196 _rounded_type_cbmi.setSelected( false );
1197 _triangular_type_cbmi.setSelected( false );
1198 _rectangular_type_cbmi.setSelected( false );
1199 _unrooted_type_cbmi.setSelected( false );
1200 _circular_type_cbmi.setSelected( false );
1203 void switchColors() {
1204 final TreeColorSet colorset = _mainpanel.getTreeColorSet();
1205 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
1206 csc.setVisible( true );
1210 if ( _mainpanel.getCurrentTreePanel() != null ) {
1211 _mainpanel.getCurrentTreePanel().taxColor();
1215 void typeChanged( final Object o ) {
1216 updateTypeCheckboxes( getOptions(), o );
1217 updateOptions( getOptions() );
1218 if ( getCurrentTreePanel() != null ) {
1219 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
1220 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
1221 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1222 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
1223 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1224 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
1225 getCurrentTreePanel().getControlPanel().showWhole();
1227 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1228 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
1231 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
1233 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
1234 updateScreenTextAntialias( getMainPanel().getTreePanels() );
1235 if ( getCurrentTreePanel().getControlPanel().getDynamicallyHideData() != null ) {
1236 if ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
1237 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( false );
1240 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( true );
1246 void updateOptions( final Options options ) {
1247 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
1248 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
1249 && _background_gradient_cbmi.isSelected() );
1250 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
1251 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
1252 && _abbreviate_scientific_names.isSelected() );
1253 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
1254 && _color_labels_same_as_parent_branch.isSelected() );
1255 options.setShowDefaultNodeShapesInternal( ( _show_default_node_shapes_internal_cbmi != null )
1256 && _show_default_node_shapes_internal_cbmi.isSelected() );
1257 options.setShowDefaultNodeShapesExternal( ( _show_default_node_shapes_external_cbmi != null )
1258 && _show_default_node_shapes_external_cbmi.isSelected() );
1259 options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null )
1260 && _taxonomy_colorize_node_shapes_cbmi.isSelected() );
1261 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
1262 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
1264 else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
1265 options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1267 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
1268 options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1270 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
1271 && _search_case_senstive_cbmi.isSelected() );
1272 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
1273 options.setShowScale( _show_scale_cbmi.isSelected() );
1275 if ( _label_direction_cbmi != null ) {
1276 if ( _label_direction_cbmi.isSelected() ) {
1277 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1280 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1283 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
1284 options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )
1285 && _show_confidence_stddev_cbmi.isSelected() );
1286 if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
1287 options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
1289 options.setPrintUsingActualSize( ( _print_using_actual_size_cbmi != null )
1290 && ( _print_using_actual_size_cbmi.isSelected() ) );
1291 options.setGraphicsExportUsingActualSize( ( _graphics_export_using_actual_size_cbmi != null )
1292 && ( _graphics_export_using_actual_size_cbmi.isSelected() ) );
1293 options.setAntialiasPrint( ( _antialias_print_cbmi != null ) && _antialias_print_cbmi.isSelected() );
1294 if ( ( _use_brackets_for_conf_in_nh_export_cbmi != null )
1295 && _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {
1296 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );
1298 else if ( ( _use_internal_names_for_conf_in_nh_export_cbmi != null )
1299 && _use_internal_names_for_conf_in_nh_export_cbmi.isSelected() ) {
1300 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES );
1303 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE );
1305 options.setPrintBlackAndWhite( ( _print_black_and_white_cbmi != null )
1306 && _print_black_and_white_cbmi.isSelected() );
1307 options.setInternalNumberAreConfidenceForNhParsing( ( _internal_number_are_confidence_for_nh_parsing_cbmi != null )
1308 && _internal_number_are_confidence_for_nh_parsing_cbmi.isSelected() );
1309 if ( ( _extract_taxonomy_yes_rbmi != null ) && _extract_taxonomy_yes_rbmi.isSelected() ) {
1310 options.setTaxonomyExtractio( TAXONOMY_EXTRACTION.AGRESSIVE );
1312 else if ( ( _extract_taxonomy_pfam_rbmi != null ) && _extract_taxonomy_pfam_rbmi.isSelected() ) {
1313 options.setTaxonomyExtractio( TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1315 else if ( ( _extract_taxonomy_no_rbmi != null ) && _extract_taxonomy_no_rbmi.isSelected() ) {
1316 options.setTaxonomyExtractio( TAXONOMY_EXTRACTION.NO );
1318 options.setReplaceUnderscoresInNhParsing( ( _replace_underscores_cbmi != null )
1319 && _replace_underscores_cbmi.isSelected() );
1320 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
1321 && _search_whole_words_only_cbmi.isSelected() );
1322 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
1323 && _inverse_search_result_cbmi.isSelected() );
1324 if ( _graphics_export_visible_only_cbmi != null ) {
1325 options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() );
1326 if ( _graphics_export_visible_only_cbmi.isSelected() && ( _graphics_export_using_actual_size_cbmi != null ) ) {
1327 _graphics_export_using_actual_size_cbmi.setSelected( true );
1328 _graphics_export_using_actual_size_cbmi.setEnabled( false );
1331 _graphics_export_using_actual_size_cbmi.setEnabled( true );
1334 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
1335 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1337 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
1338 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1340 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
1341 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1343 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
1344 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1346 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
1347 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1349 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
1350 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1352 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
1353 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1355 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
1356 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1360 void updateTypeCheckboxes( final Options options, final Object o ) {
1361 setTypeMenuToAllUnselected();
1362 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
1365 void viewAsNexus() {
1366 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1367 String title = "Nexus";
1368 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1369 title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
1371 showTextFrame( _mainpanel.getCurrentPhylogeny().toNexus( getOptions().getNhConversionSupportValueStyle() ),
1377 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1378 String title = "New Hampshire";
1379 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1380 title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
1382 showTextFrame( _mainpanel.getCurrentPhylogeny()
1383 .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ),
1389 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1390 String title = "phyloXML";
1391 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1392 title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
1394 showTextFrame( _mainpanel.getCurrentPhylogeny().toPhyloXML( 0 ), title );
1398 private void annotateSequences() {
1399 if ( getCurrentTreePanel() != null ) {
1400 final Set<Long> nodes = getCurrentTreePanel().getFoundNodes();
1401 if ( ( nodes == null ) || nodes.isEmpty() ) {
1403 .showMessageDialog( this,
1404 "Need to select nodes, either via direct selection or via the \"Search\" function",
1405 "No nodes selected for annotation",
1406 JOptionPane.ERROR_MESSAGE );
1409 final Phylogeny phy = getMainPanel().getCurrentPhylogeny();
1410 if ( ( phy != null ) && !phy.isEmpty() ) {
1411 final JTextField ref_field = new JTextField( 10 );
1412 final JTextField desc_filed = new JTextField( 20 );
1413 ref_field.setText( ForesterUtil.isEmpty( getPreviousNodeAnnotationReference() ) ? ""
1414 : getPreviousNodeAnnotationReference() );
1415 final JPanel my_panel = new JPanel();
1416 my_panel.add( new JLabel( "Reference " ) );
1417 my_panel.add( ref_field );
1418 my_panel.add( Box.createHorizontalStrut( 15 ) );
1419 my_panel.add( new JLabel( "Description " ) );
1420 my_panel.add( desc_filed );
1421 final int result = JOptionPane.showConfirmDialog( null,
1423 "Enter the sequence annotation(s) for the "
1424 + nodes.size() + " selected nodes",
1425 JOptionPane.OK_CANCEL_OPTION );
1426 if ( result == JOptionPane.OK_OPTION ) {
1427 String ref = ref_field.getText();
1428 String desc = desc_filed.getText();
1429 if ( !ForesterUtil.isEmpty( ref ) ) {
1431 ref = ref.replaceAll( "\\s+", " " );
1432 if ( ( ref.indexOf( ':' ) < 1 ) || ( ref.indexOf( ':' ) > ref.length() - 2 )
1433 || ( ref.length() < 3 ) ) {
1434 JOptionPane.showMessageDialog( this,
1435 "Reference needs to be in the form of \"GO:1234567\"",
1436 "Illegal Format for Annotation Reference",
1437 JOptionPane.ERROR_MESSAGE );
1441 if ( ref != null ) {
1442 setPreviousNodeAnnotationReference( ref );
1444 if ( desc != null ) {
1446 desc = desc.replaceAll( "\\s+", " " );
1448 if ( !ForesterUtil.isEmpty( ref ) || !ForesterUtil.isEmpty( desc ) ) {
1449 for( final Long id : nodes ) {
1450 final PhylogenyNode n = phy.getNode( id );
1451 ForesterUtil.ensurePresenceOfSequence( n );
1452 final Annotation ann = ForesterUtil.isEmpty( ref ) ? new Annotation()
1453 : new Annotation( ref );
1454 if ( !ForesterUtil.isEmpty( desc ) ) {
1455 ann.setDesc( desc );
1457 n.getNodeData().getSequence().addAnnotation( ann );
1460 getMainPanel().getControlPanel().showAnnotations();
1466 private void chooseFont() {
1467 final FontChooser fc = new FontChooser();
1468 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
1469 fc.showDialog( this, "Select the Base Font" );
1470 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
1473 private void chooseMinimalConfidence() {
1474 final String s = ( String ) JOptionPane
1475 .showInputDialog( this,
1476 "Please enter the minimum for confidence values to be displayed.\n"
1477 + "[current value: " + getOptions().getMinConfidenceValue() + "]\n",
1478 "Minimal Confidence Value",
1479 JOptionPane.QUESTION_MESSAGE,
1482 getOptions().getMinConfidenceValue() );
1483 if ( !ForesterUtil.isEmpty( s ) ) {
1484 boolean success = true;
1486 final String m_str = s.trim();
1487 if ( !ForesterUtil.isEmpty( m_str ) ) {
1489 m = Double.parseDouble( m_str );
1491 catch ( final Exception ex ) {
1498 if ( success && ( m >= 0.0 ) ) {
1499 getOptions().setMinConfidenceValue( m );
1504 private void doUpdateProcessMenu() {
1505 if ( _process_pool.size() > 0 ) {
1506 if ( _process_menu == null ) {
1507 _process_menu = createMenu( "", getConfiguration() );
1508 _process_menu.setForeground( Color.RED );
1510 _process_menu.removeAll();
1511 final String text = "processes running: " + _process_pool.size();
1512 _process_menu.setText( text );
1513 _jmenubar.add( _process_menu );
1514 for( int i = 0; i < _process_pool.size(); ++i ) {
1515 final ProcessRunning p = _process_pool.getProcessByIndex( i );
1516 _process_menu.add( customizeJMenuItem( new JMenuItem( p.getName() + " [" + p.getStart() + "]" ) ) );
1520 if ( _process_menu != null ) {
1521 _process_menu.removeAll();
1522 _jmenubar.remove( _process_menu );
1525 _jmenubar.validate();
1526 _jmenubar.repaint();
1530 private String getPreviousNodeAnnotationReference() {
1531 return _previous_node_annotation_ref;
1534 private void removeBranchColors() {
1535 if ( getMainPanel().getCurrentPhylogeny() != null ) {
1536 AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
1540 private void setPreviousNodeAnnotationReference( final String previous_node_annotation_ref ) {
1541 _previous_node_annotation_ref = previous_node_annotation_ref;
1545 * Display the about box.
1547 static void about() {
1548 final StringBuffer about = new StringBuffer( "Archaeopteryx\nVersion " + Constants.VERSION + "\n" );
1549 about.append( "Copyright (C) 2013 Christian M. Zmasek\n" );
1550 about.append( "All Rights Reserved\n" );
1551 about.append( "License: GNU Lesser General Public License (LGPL)\n" );
1552 about.append( "Last modified: " + Constants.PRG_DATE + "\n" );
1553 about.append( "Based on: " + ForesterUtil.getForesterLibraryInformation() + "\n" );
1554 about.append( "phyloXML version : " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1555 about.append( "phyloXML location: " + ForesterConstants.PHYLO_XML_LOCATION + "\n" );
1556 if ( !ForesterUtil.isEmpty( ForesterUtil.JAVA_VERSION ) && !ForesterUtil.isEmpty( ForesterUtil.JAVA_VENDOR ) ) {
1557 about.append( "[your Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]\n" );
1559 if ( !ForesterUtil.isEmpty( ForesterUtil.OS_NAME ) && !ForesterUtil.isEmpty( ForesterUtil.OS_ARCH )
1560 && !ForesterUtil.isEmpty( ForesterUtil.OS_VERSION ) ) {
1561 about.append( "[your OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " "
1562 + ForesterUtil.OS_VERSION + "]\n" );
1564 final Runtime rt = java.lang.Runtime.getRuntime();
1565 final long free_memory = rt.freeMemory() / 1000000;
1566 final long total_memory = rt.totalMemory() / 1000000;
1567 about.append( "[free memory: " + free_memory + "MB, total memory: " + total_memory + "MB]\n" );
1568 about.append( "[locale: " + Locale.getDefault() + "]\n" );
1569 about.append( "References:\n" );
1570 about.append( Constants.PHYLOXML_REFERENCE_SHORT + "\n" );
1571 about.append( "For more information & download:\n" );
1572 about.append( Constants.APTX_WEB_SITE + "\n" );
1573 about.append( "Comments: " + Constants.AUTHOR_EMAIL );
1574 JOptionPane.showMessageDialog( null, about, Constants.PRG_NAME, JOptionPane.PLAIN_MESSAGE );
1577 static void chooseNodeSize( final Options options, final Component parent ) {
1578 final String s = ( String ) JOptionPane.showInputDialog( parent,
1579 "Please enter the default size for node shapes.\n"
1580 + "[current value: "
1581 + options.getDefaultNodeShapeSize() + "]\n",
1583 JOptionPane.QUESTION_MESSAGE,
1586 options.getDefaultNodeShapeSize() );
1587 if ( !ForesterUtil.isEmpty( s ) ) {
1588 boolean success = true;
1590 final String m_str = s.trim();
1591 if ( !ForesterUtil.isEmpty( m_str ) ) {
1593 m = Double.parseDouble( m_str );
1595 catch ( final Exception ex ) {
1602 if ( success && ( m >= 0.0 ) ) {
1603 final short size = ForesterUtil.roundToShort( m );
1604 if ( size >= 0.0 ) {
1605 options.setDefaultNodeShapeSize( size );
1611 static String createCurrentFontDesc( final TreeFontSet tree_font_set ) {
1612 return tree_font_set.getLargeFont().getFamily() + " " + tree_font_set.getLargeFont().getSize();
1615 static JMenu createMenu( final String title, final Configuration conf ) {
1616 final JMenu jmenu = new JMenu( title );
1617 if ( !conf.isUseNativeUI() ) {
1618 jmenu.setFont( MainFrame.menu_font );
1619 jmenu.setBackground( conf.getGuiMenuBackgroundColor() );
1620 jmenu.setForeground( conf.getGuiMenuTextColor() );
1625 static JMenuItem customizeMenuItemAsLabel( final JMenuItem label, final Configuration configuration ) {
1626 label.setFont( MainFrame.menu_font.deriveFont( Font.BOLD ) );
1627 if ( !configuration.isUseNativeUI() ) {
1628 label.setBackground( configuration.getGuiMenuBackgroundColor() );
1629 label.setForeground( configuration.getGuiMenuTextColor() );
1630 label.setOpaque( true );
1632 label.setSelected( false );
1633 label.setEnabled( false );
1637 static void cycleNodeFill( final Options op, final TreePanel tree_panel ) {
1638 switch ( op.getDefaultNodeFill() ) {
1640 op.setDefaultNodeFill( NodeFill.SOLID );
1643 op.setDefaultNodeFill( NodeFill.GRADIENT );
1646 op.setDefaultNodeFill( NodeFill.NONE );
1649 throw new RuntimeException( "unknown fill: " + op.getDefaultNodeFill() );
1653 static void cycleNodeShape( final Options op, final TreePanel tree_panel ) {
1654 switch ( op.getDefaultNodeShape() ) {
1656 op.setDefaultNodeShape( NodeShape.RECTANGLE );
1659 op.setDefaultNodeShape( NodeShape.CIRCLE );
1662 throw new RuntimeException( "unknown shape: " + op.getDefaultNodeShape() );
1666 static void cycleOverview( final Options op, final TreePanel tree_panel ) {
1667 switch ( op.getOvPlacement() ) {
1669 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1672 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1675 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1678 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1681 throw new RuntimeException( "unknown placement: " + op.getOvPlacement() );
1683 if ( tree_panel != null ) {
1684 tree_panel.updateOvSettings();
1688 static void setCycleNodeFillMenuItem( final JMenuItem mi, final Options options ) {
1689 if ( ( options != null ) && ( options.getDefaultNodeFill() != null ) ) {
1690 mi.setText( "Cycle Node Shape Fill Type... (current: "
1691 + options.getDefaultNodeFill().toString().toLowerCase() + ")" );
1694 mi.setText( "Cycle Node Shape Fill Type..." );
1698 static void setCycleNodeShapeMenuItem( final JMenuItem mi, final Options options ) {
1699 if ( ( options != null ) && ( options.getDefaultNodeShape() != null ) ) {
1700 mi.setText( "Cycle Node Shape Fill Type... (current: "
1701 + options.getDefaultNodeShape().toString().toLowerCase() + ")" );
1704 mi.setText( "Cycle Node Shape Fill Type..." );
1708 static void setOvPlacementColorChooseMenuItem( final JMenuItem mi, final Options options ) {
1709 if ( ( options != null ) && ( options.getOvPlacement() != null ) ) {
1710 mi.setText( "Cycle Overview Placement... (current: " + options.getOvPlacement() + ")" );
1713 mi.setText( "Cycle Overview Placement..." );
1717 static void setTextColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {
1718 if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {
1719 mi.setText( "Select Colors... (current: " + tree_panel.getTreeColorSet().getCurrentColorSchemeName() + ")" );
1722 mi.setText( "Select Colors..." );
1726 static void setTextForFontChooserMenuItem( final JMenuItem mi, final String font_desc ) {
1727 mi.setText( "Select Font... (current: " + font_desc + ")" );
1730 static void setTextMinSupportMenuItem( final JMenuItem mi, final Options options, final TreePanel current_tree_panel ) {
1731 if ( ( current_tree_panel == null ) || ( current_tree_panel.getPhylogeny() == null ) ) {
1732 mi.setEnabled( true );
1734 else if ( AptxUtil.isHasAtLeastOneBranchWithSupportValues( current_tree_panel.getPhylogeny() ) ) {
1735 mi.setEnabled( true );
1738 mi.setEnabled( false );
1740 mi.setText( "Enter Min Confidence Value... (current: " + options.getMinConfidenceValue() + ")" );
1743 static void setTextNodeSizeMenuItem( final JMenuItem mi, final Options options ) {
1744 mi.setText( "Enter Default Node Shape Size... (current: " + options.getDefaultNodeShapeSize() + ")" );
1747 static void updateOptionsMenuDependingOnPhylogenyType( final MainPanel main_panel,
1748 final JCheckBoxMenuItem scale,
1749 final JCheckBoxMenuItem branch_lengths,
1750 final JRadioButtonMenuItem non_lined_up,
1751 final JRadioButtonMenuItem uniform_clado,
1752 final JRadioButtonMenuItem nonuniform_clado,
1753 final JCheckBoxMenuItem label_direction_cbmi ) {
1754 final TreePanel tree_panel = main_panel.getCurrentTreePanel();
1755 final ControlPanel control = main_panel.getControlPanel();
1756 final Options options = main_panel.getOptions();
1757 scale.setSelected( options.isShowScale() );
1758 branch_lengths.setSelected( options.isShowBranchLengthValues() );
1759 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1760 if ( ( tree_panel != null ) && ( !tree_panel.isPhyHasBranchLengths() ) ) {
1761 scale.setSelected( false );
1762 scale.setEnabled( false );
1763 branch_lengths.setSelected( false );
1764 branch_lengths.setEnabled( false );
1766 else if ( ( tree_panel != null ) && !control.isDrawPhylogram() ) {
1767 scale.setSelected( false );
1768 scale.setEnabled( false );
1769 branch_lengths.setEnabled( true );
1772 scale.setEnabled( true );
1773 branch_lengths.setEnabled( true );
1775 if ( ( tree_panel != null )
1776 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.ROUNDED )
1777 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1778 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1779 branch_lengths.setSelected( false );
1780 branch_lengths.setEnabled( false );
1782 if ( tree_panel != null ) {
1783 if ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1784 || ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
1785 non_lined_up.setEnabled( false );
1786 uniform_clado.setEnabled( false );
1787 nonuniform_clado.setEnabled( false );
1790 non_lined_up.setEnabled( true );
1791 uniform_clado.setEnabled( true );
1792 nonuniform_clado.setEnabled( true );
1796 if ( ( tree_panel != null )
1797 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1798 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1799 branch_lengths.setSelected( false );
1800 branch_lengths.setEnabled( false );
1802 if ( ( tree_panel != null )
1803 && ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( tree_panel
1804 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
1805 non_lined_up.setEnabled( false );
1808 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1809 non_lined_up.setEnabled( true );
1812 label_direction_cbmi.setEnabled( true );
1813 if ( tree_panel != null ) {
1814 if ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1815 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1816 label_direction_cbmi.setEnabled( false );
1818 if ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
1819 scale.setSelected( false );
1820 scale.setEnabled( false );
1825 static void updateScreenTextAntialias( final List<TreePanel> treepanels ) {
1826 for( final TreePanel tree_panel : treepanels ) {
1827 tree_panel.setTextAntialias();