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;
34 import java.io.IOException;
35 import java.util.LinkedList;
36 import java.util.List;
37 import java.util.Locale;
38 import java.util.NoSuchElementException;
41 import javax.swing.Box;
42 import javax.swing.JApplet;
43 import javax.swing.JCheckBoxMenuItem;
44 import javax.swing.JFrame;
45 import javax.swing.JLabel;
46 import javax.swing.JMenu;
47 import javax.swing.JMenuBar;
48 import javax.swing.JMenuItem;
49 import javax.swing.JOptionPane;
50 import javax.swing.JPanel;
51 import javax.swing.JRadioButtonMenuItem;
52 import javax.swing.JTextField;
53 import javax.swing.SwingUtilities;
55 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
56 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
57 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
58 import org.forester.archaeopteryx.tools.InferenceManager;
59 import org.forester.archaeopteryx.tools.ProcessPool;
60 import org.forester.archaeopteryx.tools.ProcessRunning;
61 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
62 import org.forester.phylogeny.Phylogeny;
63 import org.forester.phylogeny.PhylogenyMethods;
64 import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
65 import org.forester.phylogeny.PhylogenyNode;
66 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
67 import org.forester.phylogeny.data.Annotation;
68 import org.forester.phylogeny.data.NodeVisualization.NodeFill;
69 import org.forester.phylogeny.data.NodeVisualization.NodeShape;
70 import org.forester.sdi.GSDI;
71 import org.forester.sdi.GSDIR;
72 import org.forester.sdi.SDIException;
73 import org.forester.util.ForesterConstants;
74 import org.forester.util.ForesterUtil;
76 public abstract class MainFrame extends JFrame implements ActionListener {
78 static final String USE_MOUSEWHEEL_SHIFT_TO_ROTATE = "In this display type, use mousewheel + Shift to rotate [or A and S]";
79 static final String PHYLOXML_REF_TOOL_TIP = Constants.PHYLOXML_REFERENCE; //TODO //FIXME
80 static final String APTX_REF_TOOL_TIP = Constants.APTX_REFERENCE;
81 private static final long serialVersionUID = 3655000897845508358L;
82 final static Font menu_font = new Font( Configuration.getDefaultFontFamilyName(),
85 static final String TYPE_MENU_HEADER = "Type";
86 static final String RECTANGULAR_TYPE_CBMI_LABEL = "Rectangular";
87 static final String EURO_TYPE_CBMI_LABEL = "Euro Type";
88 static final String CURVED_TYPE_CBMI_LABEL = "Curved";
89 static final String TRIANGULAR_TYPE_CBMI_LABEL = "Triangular";
90 static final String CONVEX_TYPE_CBMI_LABEL = "Convex";
91 static final String ROUNDED_TYPE_CBMI_LABEL = "Rounded";
92 static final String UNROOTED_TYPE_CBMI_LABEL = "Unrooted (alpha)"; //TODO
93 static final String CIRCULAR_TYPE_CBMI_LABEL = "Circular (alpha)"; //TODO
94 static final String OPTIONS_HEADER = "Options";
95 static final String SEARCH_SUBHEADER = "Search:";
96 static final String DISPLAY_SUBHEADER = "Display:";
97 static final String SEARCH_TERMS_ONLY_LABEL = "Match Complete Terms Only";
98 static final String SEARCH_CASE_SENSITIVE_LABEL = "Case Sensitive";
99 static final String INVERSE_SEARCH_RESULT_LABEL = "Negate Result";
100 static final String DISPLAY_BRANCH_LENGTH_VALUES_LABEL = "Branch Length Values";
101 static final String COLOR_BY_TAXONOMIC_GROUP = "Colorize by Taxonomic Group";
102 static final String DISPLAY_SCALE_LABEL = "Scale";
103 static final String NON_LINED_UP_CLADOGRAMS_LABEL = "Non-Lined Up Cladograms";
104 static final String UNIFORM_CLADOGRAMS_LABEL = "Total Node Sum Dependent Cladograms";
105 static final String LABEL_DIRECTION_LABEL = "Radial Labels";
106 static final String LABEL_DIRECTION_TIP = "To use radial node labels in radial and unrooted display types";
107 static final String SCREEN_ANTIALIAS_LABEL = "Antialias";
108 static final String COLOR_LABELS_LABEL = "Colorize Labels Same as Parent Branch";
109 static final String BG_GRAD_LABEL = "Background Color Gradient";
110 static final String DISPLAY_NODE_BOXES_LABEL_EXT = "External Node Shapes";
111 static final String DISPLAY_NODE_BOXES_LABEL_INT = "Internal Node Shapes";
112 static final String SHOW_OVERVIEW_LABEL = "Overview";
113 static final String FONT_SIZE_MENU_LABEL = "Font Size";
114 static final String NONUNIFORM_CLADOGRAMS_LABEL = "External Node Sum Dependent Cladograms";
115 static final String SHOW_DOMAIN_LABELS_LABEL = "Domain Labels";
116 static final String SHOW_ANN_REF_SOURCE_LABEL = "Seq Annotation Ref Sources";
117 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";
118 static final String ABBREV_SN_LABEL = "Abbreviate Scientific Taxonomic Names";
119 static final String TAXONOMY_COLORIZE_NODE_SHAPES_LABEL = "Colorize Node Shapes According to Taxonomy";
120 static final String CYCLE_NODE_SHAPE_LABEL = "Cycle Node Shapes";
121 static final String CYCLE_NODE_FILL_LABEL = "Cycle Node Fill Type";
122 static final String CHOOSE_NODE_SIZE_LABEL = "Choose Node Shape Size";
123 static final String SHOW_CONF_STDDEV_LABEL = "Confidence Standard Deviations";
124 static final String USE_BRACKETS_FOR_CONF_IN_NH_LABEL = "Use Brackets for Confidence Values";
125 static final String USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL = "Use Internal Node Names for Confidence Values";
126 static final String SHOW_BASIC_TREE_INFORMATION_LABEL = "Basic Tree Information";
131 JMenu _options_jmenu;
132 JMenu _font_size_menu;
134 JMenuItem[] _load_phylogeny_from_webservice_menu_items;
136 JMenu _analysis_menu;
137 JMenuItem _load_species_tree_item;
138 JMenuItem _gsdi_item;
139 JMenuItem _gsdir_item;
140 JMenuItem _lineage_inference;
142 JMenuItem _open_item;
143 JMenuItem _open_url_item;
144 JMenuItem _save_item;
145 JMenuItem _save_all_item;
146 JMenuItem _close_item;
147 JMenuItem _exit_item;
150 JMenuItem _midpoint_root_item;
151 JMenuItem _taxcolor_item;
152 JMenuItem _confcolor_item;
153 JMenuItem _color_rank_jmi;
154 JMenuItem _collapse_species_specific_subtrees;
155 JMenuItem _collapse_below_threshold; //TODO implememt me
156 JMenuItem _obtain_detailed_taxonomic_information_jmi;
157 JMenuItem _obtain_detailed_taxonomic_information_deleting_jmi;
158 JMenuItem _obtain_seq_information_jmi;
159 JMenuItem _move_node_names_to_tax_sn_jmi;
160 JMenuItem _move_node_names_to_seq_names_jmi;
161 JMenuItem _extract_tax_code_from_node_names_jmi;
162 JMenuItem _annotate_item;
164 JMenuItem _super_tiny_fonts_item;
165 JMenuItem _tiny_fonts_item;
166 JMenuItem _small_fonts_item;
167 JMenuItem _medium_fonts_item;
168 JMenuItem _large_fonts_item;
170 // _ screen and print
171 JMenuItem _choose_font_mi;
172 JMenuItem _switch_colors_mi;
173 JCheckBoxMenuItem _label_direction_cbmi;
175 JCheckBoxMenuItem _screen_antialias_cbmi;
176 JCheckBoxMenuItem _background_gradient_cbmi;
177 JRadioButtonMenuItem _non_lined_up_cladograms_rbmi;
178 JRadioButtonMenuItem _uniform_cladograms_rbmi;
179 JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi;
180 JCheckBoxMenuItem _show_branch_length_values_cbmi;
181 JCheckBoxMenuItem _color_by_taxonomic_group_cbmi;
182 JCheckBoxMenuItem _show_scale_cbmi; //TODO fix me
183 JCheckBoxMenuItem _show_overview_cbmi;
184 JCheckBoxMenuItem _show_domain_labels;
185 JCheckBoxMenuItem _show_annotation_ref_source;
186 JCheckBoxMenuItem _abbreviate_scientific_names;
187 JCheckBoxMenuItem _color_labels_same_as_parent_branch;
188 JMenuItem _overview_placment_mi;
189 JMenuItem _choose_minimal_confidence_mi;
190 JCheckBoxMenuItem _show_default_node_shapes_internal_cbmi;
191 JCheckBoxMenuItem _show_default_node_shapes_external_cbmi;
192 JMenuItem _cycle_node_shape_mi;
193 JMenuItem _cycle_node_fill_mi;
194 JMenuItem _choose_node_size_mi;
195 JCheckBoxMenuItem _show_confidence_stddev_cbmi;
197 JCheckBoxMenuItem _graphics_export_visible_only_cbmi;
198 JCheckBoxMenuItem _antialias_print_cbmi;
199 JCheckBoxMenuItem _print_black_and_white_cbmi;
200 JCheckBoxMenuItem _print_using_actual_size_cbmi;
201 JCheckBoxMenuItem _graphics_export_using_actual_size_cbmi;
202 JMenuItem _print_size_mi;
203 JMenuItem _choose_pdf_width_mi;
205 JCheckBoxMenuItem _internal_number_are_confidence_for_nh_parsing_cbmi;
206 JRadioButtonMenuItem _extract_taxonomy_no_rbmi;
207 JRadioButtonMenuItem _extract_taxonomy_agressive_rbmi;
208 JRadioButtonMenuItem _extract_taxonomy_pfam_strict_rbmi;
209 JRadioButtonMenuItem _extract_taxonomy_pfam_relaxed_rbmi;
210 JCheckBoxMenuItem _replace_underscores_cbmi;
211 JCheckBoxMenuItem _allow_errors_in_distance_to_parent_cbmi;
212 JCheckBoxMenuItem _use_brackets_for_conf_in_nh_export_cbmi;
213 JCheckBoxMenuItem _use_internal_names_for_conf_in_nh_export_cbmi;
215 JCheckBoxMenuItem _search_case_senstive_cbmi;
216 JCheckBoxMenuItem _search_whole_words_only_cbmi;
217 JCheckBoxMenuItem _inverse_search_result_cbmi;
220 JCheckBoxMenuItem _rectangular_type_cbmi;
221 JCheckBoxMenuItem _triangular_type_cbmi;
222 JCheckBoxMenuItem _curved_type_cbmi;
223 JCheckBoxMenuItem _convex_type_cbmi;
224 JCheckBoxMenuItem _euro_type_cbmi;
225 JCheckBoxMenuItem _rounded_type_cbmi;
226 JCheckBoxMenuItem _unrooted_type_cbmi;
227 JCheckBoxMenuItem _circular_type_cbmi;
228 // view as text menu:
229 JMenuItem _view_as_NH_item;
230 JMenuItem _view_as_XML_item;
231 JMenuItem _view_as_nexus_item;
232 JMenuItem _display_basic_information_item;
234 JMenuItem _about_item;
235 JMenuItem _help_item;
236 JMenuItem _website_item;
237 JMenuItem _phyloxml_website_item;
238 JMenuItem _phyloxml_ref_item;
239 JMenuItem _aptx_ref_item;
242 // Handy pointers to child components:
243 MainPanel _mainpanel;
244 Container _contentpane;
245 final LinkedList<TextFrame> _textframes = new LinkedList<TextFrame>(); ;
246 Configuration _configuration;
247 JMenuItem _remove_branch_color_item;
249 private Phylogeny _species_tree;
250 InferenceManager _inference_manager;
251 final ProcessPool _process_pool;
252 private String _previous_node_annotation_ref;
255 _process_pool = ProcessPool.createInstance();
262 public void actionPerformed( final ActionEvent e ) {
263 final Object o = e.getSource();
264 boolean is_applet = false;
265 JApplet applet = null;
266 if ( getCurrentTreePanel() != null ) {
267 is_applet = getCurrentTreePanel().isApplet();
269 applet = getCurrentTreePanel().obtainApplet();
272 if ( o == _open_url_item ) {
273 readPhylogeniesFromURL();
275 else if ( o == _exit_item ) {
278 else if ( o == _gsdi_item ) {
279 if ( isSubtreeDisplayed() ) {
284 else if ( o == _gsdir_item ) {
285 if ( isSubtreeDisplayed() ) {
290 else if ( o == _taxcolor_item ) {
293 else if ( o == _confcolor_item ) {
296 else if ( o == _color_rank_jmi ) {
299 else if ( o == _collapse_species_specific_subtrees ) {
300 if ( isSubtreeDisplayed() ) {
303 if ( getCurrentTreePanel() != null ) {
304 getCurrentTreePanel().collapseSpeciesSpecificSubtrees();
307 else if ( o == _remove_branch_color_item ) {
308 if ( isSubtreeDisplayed() ) {
311 removeBranchColors();
313 else if ( o == _midpoint_root_item ) {
314 if ( isSubtreeDisplayed() ) {
319 else if ( o == _annotate_item ) {
322 else if ( o == _switch_colors_mi ) {
325 else if ( o == _display_basic_information_item ) {
326 displayBasicInformation( getCurrentTreePanel().getTreeFile() );
328 else if ( o == _view_as_NH_item ) {
331 else if ( o == _view_as_XML_item ) {
334 else if ( o == _view_as_nexus_item ) {
337 else if ( o == _super_tiny_fonts_item ) {
338 if ( getCurrentTreePanel() != null ) {
339 getCurrentTreePanel().setSuperTinyFonts();
340 getCurrentTreePanel().repaint();
343 else if ( o == _tiny_fonts_item ) {
344 if ( getCurrentTreePanel() != null ) {
345 getCurrentTreePanel().setTinyFonts();
346 getCurrentTreePanel().repaint();
349 else if ( o == _small_fonts_item ) {
350 if ( getCurrentTreePanel() != null ) {
351 getCurrentTreePanel().setSmallFonts();
352 getCurrentTreePanel().repaint();
355 else if ( o == _medium_fonts_item ) {
356 if ( getCurrentTreePanel() != null ) {
357 getCurrentTreePanel().setMediumFonts();
358 getCurrentTreePanel().repaint();
361 else if ( o == _large_fonts_item ) {
362 if ( getCurrentTreePanel() != null ) {
363 getCurrentTreePanel().setLargeFonts();
364 getCurrentTreePanel().repaint();
367 else if ( o == _choose_font_mi ) {
370 else if ( o == _choose_minimal_confidence_mi ) {
371 chooseMinimalConfidence();
373 else if ( o == _choose_node_size_mi ) {
374 chooseNodeSize( getOptions(), this );
376 else if ( o == _overview_placment_mi ) {
377 MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
379 else if ( o == _cycle_node_fill_mi ) {
380 MainFrame.cycleNodeFill( getOptions(), getCurrentTreePanel() );
382 else if ( o == _cycle_node_shape_mi ) {
383 MainFrame.cycleNodeShape( getOptions(), getCurrentTreePanel() );
385 else if ( o == _screen_antialias_cbmi ) {
386 updateOptions( getOptions() );
387 updateScreenTextAntialias( getMainPanel().getTreePanels() );
389 else if ( o == _background_gradient_cbmi ) {
390 updateOptions( getOptions() );
392 else if ( o == _show_domain_labels ) {
393 updateOptions( getOptions() );
395 else if ( o == _show_annotation_ref_source ) {
396 updateOptions( getOptions() );
398 else if ( o == _abbreviate_scientific_names ) {
399 updateOptions( getOptions() );
401 else if ( o == _color_labels_same_as_parent_branch ) {
402 updateOptions( getOptions() );
404 else if ( o == _show_default_node_shapes_internal_cbmi ) {
405 updateOptions( getOptions() );
407 else if ( o == _show_default_node_shapes_external_cbmi ) {
408 updateOptions( getOptions() );
410 else if ( o == _non_lined_up_cladograms_rbmi ) {
411 updateOptions( getOptions() );
414 else if ( o == _uniform_cladograms_rbmi ) {
415 updateOptions( getOptions() );
418 else if ( o == _ext_node_dependent_cladogram_rbmi ) {
419 updateOptions( getOptions() );
422 else if ( o == _search_case_senstive_cbmi ) {
423 updateOptions( getOptions() );
424 getMainPanel().getControlPanel().search0();
425 getMainPanel().getControlPanel().search1();
427 else if ( o == _search_whole_words_only_cbmi ) {
428 updateOptions( getOptions() );
429 getMainPanel().getControlPanel().search0();
430 getMainPanel().getControlPanel().search1();
432 else if ( o == _inverse_search_result_cbmi ) {
433 updateOptions( getOptions() );
434 getMainPanel().getControlPanel().search0();
435 getMainPanel().getControlPanel().search1();
437 else if ( o == _show_scale_cbmi ) {
438 updateOptions( getOptions() );
440 else if ( o == _show_branch_length_values_cbmi ) {
441 updateOptions( getOptions() );
443 else if ( o == _color_by_taxonomic_group_cbmi ) {
444 updateOptions( getOptions() );
446 else if ( o == _show_confidence_stddev_cbmi ) {
447 updateOptions( getOptions() );
449 else if ( o == _use_brackets_for_conf_in_nh_export_cbmi ) {
450 if ( _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {
451 _use_internal_names_for_conf_in_nh_export_cbmi.setSelected( false );
453 updateOptions( getOptions() );
455 else if ( o == _use_internal_names_for_conf_in_nh_export_cbmi ) {
456 if ( _use_internal_names_for_conf_in_nh_export_cbmi.isSelected() ) {
457 _use_brackets_for_conf_in_nh_export_cbmi.setSelected( false );
459 updateOptions( getOptions() );
461 else if ( o == _label_direction_cbmi ) {
462 updateOptions( getOptions() );
464 else if ( o == _show_overview_cbmi ) {
465 updateOptions( getOptions() );
466 if ( getCurrentTreePanel() != null ) {
467 getCurrentTreePanel().updateOvSizes();
470 else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
471 || ( o == _convex_type_cbmi ) || ( o == _euro_type_cbmi ) || ( o == _rounded_type_cbmi )
472 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
475 else if ( o == _about_item ) {
478 else if ( o == _help_item ) {
481 else if ( o == _website_item ) {
483 AptxUtil.openWebsite( Constants.APTX_WEB_SITE, is_applet, applet );
485 catch ( final IOException e1 ) {
486 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
489 else if ( o == _phyloxml_website_item ) {
491 AptxUtil.openWebsite( Constants.PHYLOXML_WEB_SITE, is_applet, applet );
493 catch ( final IOException e1 ) {
494 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
497 else if ( o == _aptx_ref_item ) {
499 AptxUtil.openWebsite( Constants.APTX_REFERENCE_URL, is_applet, applet );
501 catch ( final IOException e1 ) {
502 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
505 else if ( o == _phyloxml_ref_item ) {
507 AptxUtil.openWebsite( Constants.PHYLOXML_REFERENCE_URL, is_applet, applet );
509 catch ( final IOException e1 ) {
510 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
514 if ( _load_phylogeny_from_webservice_menu_items != null ) {
515 for( int i = 0; i < _load_phylogeny_from_webservice_menu_items.length; ++i ) {
516 if ( o == _load_phylogeny_from_webservice_menu_items[ i ] ) {
517 readPhylogeniesFromWebservice( i );
522 _contentpane.repaint();
525 public Configuration getConfiguration() {
526 return _configuration;
530 * This method returns the current external node data which
531 * has been selected by the user by clicking the "Return ..."
532 * menu item. This method is expected to be called from Javascript or
535 * @return current external node data as String
537 public String getCurrentExternalNodesDataBuffer() {
538 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString();
541 public int getCurrentExternalNodesDataBufferChangeCounter() {
542 return getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter();
545 public int getCurrentExternalNodesDataBufferLength() {
546 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length();
549 public InferenceManager getInferenceManager() {
550 return _inference_manager;
553 public MainPanel getMainPanel() {
557 public Options getOptions() {
561 public ProcessPool getProcessPool() {
562 return _process_pool;
565 public void showTextFrame( final String s, final String title ) {
567 _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
570 public void showWhole() {
571 _mainpanel.getControlPanel().showWhole();
574 public void updateProcessMenu() {
575 // In general Swing is not thread safe.
576 // See "Swing's Threading Policy".
577 SwingUtilities.invokeLater( new Runnable() {
581 doUpdateProcessMenu();
586 void activateSaveAllIfNeeded() {
587 if ( ( getMainPanel().getTabbedPane() != null ) && ( getMainPanel().getTabbedPane().getTabCount() > 1 ) ) {
588 _save_all_item.setEnabled( true );
591 _save_all_item.setEnabled( false );
595 void buildFileMenu() {
596 _file_jmenu = createMenu( "File", getConfiguration() );
597 _file_jmenu.add( _open_url_item = new JMenuItem( "Read tree from URL/webservice..." ) );
598 _file_jmenu.addSeparator();
599 _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );
600 customizeJMenuItem( _open_url_item );
601 customizeJMenuItem( _exit_item );
602 _jmenubar.add( _file_jmenu );
605 void buildFontSizeMenu() {
606 _font_size_menu = createMenu( FONT_SIZE_MENU_LABEL, getConfiguration() );
607 _font_size_menu.add( _super_tiny_fonts_item = new JMenuItem( "Super Tiny Fonts" ) );
608 _font_size_menu.add( _tiny_fonts_item = new JMenuItem( "Tiny Fonts" ) );
609 _font_size_menu.add( _small_fonts_item = new JMenuItem( "Small Fonts" ) );
610 _font_size_menu.add( _medium_fonts_item = new JMenuItem( "Medium Fonts" ) );
611 _font_size_menu.add( _large_fonts_item = new JMenuItem( "Large Fonts" ) );
612 customizeJMenuItem( _super_tiny_fonts_item );
613 customizeJMenuItem( _tiny_fonts_item );
614 customizeJMenuItem( _small_fonts_item );
615 customizeJMenuItem( _medium_fonts_item );
616 customizeJMenuItem( _large_fonts_item );
617 _jmenubar.add( _font_size_menu );
620 void buildHelpMenu() {
621 _help_jmenu = createMenu( "Help", getConfiguration() );
622 _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
623 _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
624 _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
625 _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
626 _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
627 _help_jmenu.addSeparator();
628 _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
629 customizeJMenuItem( _help_item );
630 customizeJMenuItem( _website_item );
631 customizeJMenuItem( _phyloxml_website_item );
632 customizeJMenuItem( _aptx_ref_item );
633 customizeJMenuItem( _phyloxml_ref_item );
634 customizeJMenuItem( _about_item );
635 _phyloxml_ref_item.setToolTipText( PHYLOXML_REF_TOOL_TIP );
636 _aptx_ref_item.setToolTipText( APTX_REF_TOOL_TIP );
637 _jmenubar.add( _help_jmenu );
640 void buildTypeMenu() {
641 _type_menu = createMenu( TYPE_MENU_HEADER, getConfiguration() );
642 _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
643 _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
644 _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
645 _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
646 _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
647 _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
648 _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
649 _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
650 customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
651 customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
652 customizeCheckBoxMenuItem( _euro_type_cbmi, false );
653 customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
654 customizeCheckBoxMenuItem( _curved_type_cbmi, false );
655 customizeCheckBoxMenuItem( _convex_type_cbmi, false );
656 customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
657 customizeCheckBoxMenuItem( _circular_type_cbmi, false );
658 _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
659 _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
660 initializeTypeMenu( getOptions() );
661 _jmenubar.add( _type_menu );
664 void buildViewMenu() {
665 _view_jmenu = createMenu( "View", getConfiguration() );
666 _view_jmenu.add( _display_basic_information_item = new JMenuItem( SHOW_BASIC_TREE_INFORMATION_LABEL ) );
667 _view_jmenu.addSeparator();
668 _view_jmenu.add( _view_as_XML_item = new JMenuItem( "as phyloXML" ) );
669 _view_jmenu.add( _view_as_NH_item = new JMenuItem( "as Newick" ) );
670 _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "as Nexus" ) );
671 customizeJMenuItem( _display_basic_information_item );
672 customizeJMenuItem( _view_as_NH_item );
673 customizeJMenuItem( _view_as_XML_item );
674 customizeJMenuItem( _view_as_nexus_item );
675 _jmenubar.add( _view_jmenu );
678 void checkTextFrames() {
679 if ( _textframes.size() > 5 ) {
681 if ( _textframes.getFirst() != null ) {
682 _textframes.getFirst().removeMe();
685 _textframes.removeFirst();
688 catch ( final NoSuchElementException e ) {
695 removeAllTextFrames();
696 if ( _mainpanel != null ) {
697 _mainpanel.terminate();
699 if ( _contentpane != null ) {
700 _contentpane.removeAll();
707 if ( _mainpanel.getCurrentTreePanel() != null ) {
708 final String[] ranks = AptxUtil.getAllPossibleRanks();
709 final String rank = ( String ) JOptionPane
710 .showInputDialog( this,
711 "What rank should the colorization be based on",
713 JOptionPane.QUESTION_MESSAGE,
717 if ( !ForesterUtil.isEmpty( rank ) ) {
718 _mainpanel.getCurrentTreePanel().colorRank( rank );
724 if ( _mainpanel.getCurrentTreePanel() != null ) {
725 _mainpanel.getCurrentTreePanel().confColor();
729 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
730 if ( item != null ) {
731 item.setFont( MainFrame.menu_font );
732 if ( !getConfiguration().isUseNativeUI() ) {
733 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
734 item.setForeground( getConfiguration().getGuiMenuTextColor() );
736 item.setSelected( is_selected );
737 item.addActionListener( this );
741 JMenuItem customizeJMenuItem( final JMenuItem jmi ) {
743 jmi.setFont( MainFrame.menu_font );
744 if ( !getConfiguration().isUseNativeUI() ) {
745 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
746 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
748 jmi.addActionListener( this );
753 void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
754 if ( item != null ) {
755 item.setFont( MainFrame.menu_font );
756 if ( !getConfiguration().isUseNativeUI() ) {
757 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
758 item.setForeground( getConfiguration().getGuiMenuTextColor() );
760 item.setSelected( is_selected );
761 item.addActionListener( this );
765 void displayBasicInformation( final File treefile ) {
766 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
767 String title = "Basic Information";
768 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
769 title = title + " for \"" + _mainpanel.getCurrentPhylogeny().getName() + "\"";
771 showTextFrame( AptxUtil.createBasicInformation( _mainpanel.getCurrentPhylogeny(), treefile ), title );
775 void exceptionOccuredDuringOpenFile( final Exception e ) {
777 _mainpanel.getCurrentTreePanel().setArrowCursor();
779 catch ( final Exception ex ) {
782 JOptionPane.showMessageDialog( this,
783 ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
784 "Error during File|Open",
785 JOptionPane.ERROR_MESSAGE );
788 void exceptionOccuredDuringSaveAs( final Exception e ) {
790 _mainpanel.getCurrentTreePanel().setArrowCursor();
792 catch ( final Exception ex ) {
795 JOptionPane.showMessageDialog( this, "Exception" + e, "Error during File|SaveAs", JOptionPane.ERROR_MESSAGE );
799 if ( !isOKforSDI( false, true ) ) {
802 if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {
803 JOptionPane.showMessageDialog( this,
804 "Gene tree is not rooted.",
805 "Cannot execute GSDI",
806 JOptionPane.ERROR_MESSAGE );
809 final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
810 gene_tree.setAllNodesToNotCollapse();
811 gene_tree.recalculateNumberOfExternalDescendants( false );
813 final Phylogeny species_tree = getSpeciesTree().copy();
815 gsdi = new GSDI( gene_tree, species_tree, false, true, true, true );
817 catch ( final SDIException e ) {
818 JOptionPane.showMessageDialog( this,
819 e.getLocalizedMessage(),
821 JOptionPane.ERROR_MESSAGE );
824 catch ( final Exception e ) {
825 AptxUtil.unexpectedException( e );
828 gene_tree.setRerootable( false );
829 gene_tree.clearHashIdToNodeMap();
830 gene_tree.recalculateNumberOfExternalDescendants( true );
831 _mainpanel.addPhylogenyInNewTab( gene_tree, getConfiguration(), "gene tree", null );
832 getMainPanel().getControlPanel().setShowEvents( true );
834 final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
835 _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
837 _mainpanel.getTabbedPane().setSelectedIndex( selected );
839 _mainpanel.getCurrentTreePanel().setEdited( true );
840 final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
841 if ( gsdi.getStrippedExternalGeneTreeNodes().size() > 0 ) {
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.WARNING_MESSAGE );
855 JOptionPane.showMessageDialog( this,
856 "Duplications: " + gsdi.getDuplicationsSum() + "\n"
857 + "Potential duplications: "
858 + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
859 + "Speciations: " + gsdi.getSpeciationsSum() + "\n"
860 + "Stripped gene tree nodes: "
861 + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
862 + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
863 + "Number of polytomies in species tree used: " + poly + "\n",
864 "GSDI successfully completed",
865 JOptionPane.INFORMATION_MESSAGE );
869 void executeGSDIR() {
870 if ( !isOKforSDI( false, false ) ) {
873 final int p = PhylogenyMethods.countNumberOfPolytomies( _mainpanel.getCurrentPhylogeny() );
875 && !( ( p == 1 ) && ( _mainpanel.getCurrentPhylogeny().getRoot().getNumberOfDescendants() == 3 ) ) ) {
876 JOptionPane.showMessageDialog( this,
877 "Gene tree is not completely binary",
878 "Cannot execute GSDI",
879 JOptionPane.ERROR_MESSAGE );
882 final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
883 gene_tree.setAllNodesToNotCollapse();
884 gene_tree.recalculateNumberOfExternalDescendants( false );
886 final Phylogeny species_tree = getSpeciesTree().copy();
888 gsdir = new GSDIR( gene_tree, species_tree, true, true, true );
890 catch ( final SDIException e ) {
891 JOptionPane.showMessageDialog( this,
892 e.getLocalizedMessage(),
893 "Error during GSDIR",
894 JOptionPane.ERROR_MESSAGE );
897 catch ( final Exception e ) {
898 AptxUtil.unexpectedException( e );
901 final Phylogeny result_gene_tree = gsdir.getMinDuplicationsSumGeneTree();
902 result_gene_tree.setRerootable( false );
903 result_gene_tree.clearHashIdToNodeMap();
904 result_gene_tree.recalculateNumberOfExternalDescendants( true );
905 PhylogenyMethods.orderAppearance( result_gene_tree.getRoot(), true, true, DESCENDANT_SORT_PRIORITY.NODE_NAME );
906 _mainpanel.addPhylogenyInNewTab( result_gene_tree, getConfiguration(), "gene tree", null );
907 getMainPanel().getControlPanel().setShowEvents( true );
909 final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
910 _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
912 _mainpanel.getTabbedPane().setSelectedIndex( selected );
914 _mainpanel.getCurrentTreePanel().setEdited( true );
915 final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
916 if ( gsdir.getStrippedExternalGeneTreeNodes().size() > 0 ) {
917 JOptionPane.showMessageDialog( this,
918 "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
919 + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
920 + "Stripped gene tree nodes: "
921 + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
922 + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
923 + "Number of polytomies in species tree used: " + poly + "\n",
924 "GSDIR successfully completed",
925 JOptionPane.WARNING_MESSAGE );
928 JOptionPane.showMessageDialog( this,
929 "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
930 + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
931 + "Stripped gene tree nodes: "
932 + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
933 + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
934 + "Number of polytomies in species tree used: " + poly + "\n",
935 "GSDIR successfully completed",
936 JOptionPane.INFORMATION_MESSAGE );
940 boolean GAndSDoHaveMoreThanOneSpeciesInComman( final Phylogeny gene_tree ) {
941 if ( ( gene_tree == null ) || gene_tree.isEmpty() ) {
942 JOptionPane.showMessageDialog( this,
943 "Gene tree and species tree have no species in common.",
945 JOptionPane.ERROR_MESSAGE );
948 else if ( gene_tree.getNumberOfExternalNodes() < 2 ) {
949 JOptionPane.showMessageDialog( this,
950 "Gene tree and species tree have only one species in common.",
952 JOptionPane.ERROR_MESSAGE );
960 TreePanel getCurrentTreePanel() {
961 return getMainPanel().getCurrentTreePanel();
964 JMenu getHelpMenu() {
968 JCheckBoxMenuItem getlabelDirectionCbmi() {
969 return _label_direction_cbmi;
972 JMenuBar getMenuBarOfMainFrame() {
976 final Phylogeny getSpeciesTree() {
977 return _species_tree;
981 final StringBuilder sb = new StringBuilder();
982 sb.append( "Display options\n" );
983 sb.append( "-------------------\n" );
984 sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
985 sb.append( "Clickable tree nodes\n" );
986 sb.append( "--------------------\n" );
987 sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
988 sb.append( "or by right clicking:\n" );
989 sb.append( "o Display Node Data -- display information for a node\n" );
990 sb.append( "o Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
991 sb.append( "o Root/Reroot -- change tree root to clicked node\n" );
992 sb.append( "o Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
993 sb.append( "o Swap Descendants -- switch descendant on either side of clicked node\n" );
994 sb.append( "o Colorize Subtree -- color a subtree\n" );
995 sb.append( "o Open Sequence Web -- launch a web browser to display sequence information\n" );
996 sb.append( "o Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
997 sb.append( "- there may be additional choices depending on this particular setup\n\n" );
998 sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
999 sb.append( "Zooming\n" );
1000 sb.append( "---------\n" );
1001 sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
1002 sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
1003 sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
1004 sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
1005 sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
1006 sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
1007 sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
1008 sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
1009 sb.append( "Quick tree manipulation:\n" );
1010 sb.append( "------------------------\n" );
1011 sb.append( "Order Subtrees -- order the tree by branch length\n" );
1012 sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
1013 sb.append( "Memory problems (Java heap space error)\n" );
1014 sb.append( "---------------------------------------\n" );
1015 sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
1016 sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
1017 sb.append( "the '-Xmx' Java command line option. For example:\n" );
1018 sb.append( "java -Xmx1024m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
1019 // + "General remarks\n"
1020 // + "---------------\n"
1022 // "o The application version permits copying to the clipboard \n"
1024 // " in the \"View\"|\"View as ...\" frame (either by control-c or button press).\n"
1026 // "o Changes made to a subtree affect this subtree and its subtrees,\n"
1027 // + " but not any of its parent tree(s).\n"
1029 // "o Archaeopteryx tries to detect whether the numerical values in a NH tree\n"
1031 // " are likely to be bootstrap values instead of branch length values.\n\n"
1033 // " Remarks regarding SDI (Speciation Duplication Inference):\n"
1035 // "o Each external node of the gene tree (in display) needs to be associated with\n"
1037 // " a species: either directly through the \"Species\" field, or the species\n"
1039 // " is part of the sequence name in the form \"XXXX_SPECIES\"\n"
1041 // " (e.g. \"ACON_DROME\" or \"ACON_DROME/123-4489\" which is also acceptable).\n"
1043 // "o A species tree for each species of the gene tree needs to be loaded with\n"
1045 // " \"SDI\"|\"Load species tree\" prior the SDI execution.\n"
1047 // "o !External nodes of the gene tree associated with species not present in\n"
1049 // " the species tree are REMOVED prior to SDI execution!\n"
1051 // "o Both the gene tree and the species tree must be completely binary.\n"
1053 // "o Duplications and speciations are a function of the position of the root.\n"
1055 // " Hence, after each manual \"Root/Reroot\"ing some duplications will be\n"
1056 // + " incorrect and need to be inferred again\n"
1058 // " with: \"SDI\"|\"SDI (Speciation Duplication Inference)\n\n"
1059 sb.append( "phyloXML\n" );
1060 sb.append( "-------------------\n" );
1061 sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
1062 sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
1063 sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1065 sb.append( "For more information: https://sites.google.com/site/cmzmasek/home/software/archaeopteryx\n" );
1066 sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
1067 TextFrame.instantiate( sb.toString(), "Help", _textframes );
1070 void initializeTypeMenu( final Options options ) {
1071 setTypeMenuToAllUnselected();
1072 switch ( options.getPhylogenyGraphicsType() ) {
1074 _convex_type_cbmi.setSelected( true );
1077 _curved_type_cbmi.setSelected( true );
1080 _euro_type_cbmi.setSelected( true );
1083 _rounded_type_cbmi.setSelected( true );
1086 _triangular_type_cbmi.setSelected( true );
1089 _unrooted_type_cbmi.setSelected( true );
1092 _circular_type_cbmi.setSelected( true );
1095 _rectangular_type_cbmi.setSelected( true );
1100 boolean isOKforSDI( final boolean species_tree_has_to_binary, final boolean gene_tree_has_to_binary ) {
1101 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty() ) {
1104 else if ( ( getSpeciesTree() == null ) || getSpeciesTree().isEmpty() ) {
1105 JOptionPane.showMessageDialog( this,
1106 "No species tree loaded",
1107 "Cannot execute GSDI",
1108 JOptionPane.ERROR_MESSAGE );
1111 else if ( species_tree_has_to_binary && !getSpeciesTree().isCompletelyBinary() ) {
1112 JOptionPane.showMessageDialog( this,
1113 "Species tree is not completely binary",
1114 "Cannot execute GSDI",
1115 JOptionPane.ERROR_MESSAGE );
1118 else if ( gene_tree_has_to_binary && !_mainpanel.getCurrentPhylogeny().isCompletelyBinary() ) {
1119 JOptionPane.showMessageDialog( this,
1120 "Gene tree is not completely binary",
1121 "Cannot execute GSDI",
1122 JOptionPane.ERROR_MESSAGE );
1130 boolean isSubtreeDisplayed() {
1131 if ( getCurrentTreePanel() != null ) {
1132 if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
1134 .showMessageDialog( this,
1135 "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",
1136 "Operation can not be exectuted on a sub-tree",
1137 JOptionPane.WARNING_MESSAGE );
1144 void midpointRoot() {
1145 if ( _mainpanel.getCurrentTreePanel() != null ) {
1146 _mainpanel.getCurrentTreePanel().midpointRoot();
1150 abstract void readPhylogeniesFromURL();
1152 void readPhylogeniesFromWebservice( final int i ) {
1153 final UrlTreeReader reader = new UrlTreeReader( this, i );
1154 new Thread( reader ).start();
1157 void removeAllTextFrames() {
1158 for( final TextFrame tf : _textframes ) {
1163 _textframes.clear();
1166 void setConfiguration( final Configuration configuration ) {
1167 _configuration = configuration;
1170 void setInferenceManager( final InferenceManager i ) {
1171 _inference_manager = i;
1174 void setOptions( final Options options ) {
1178 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
1179 setTypeMenuToAllUnselected();
1182 _circular_type_cbmi.setSelected( true );
1185 _convex_type_cbmi.setSelected( true );
1188 _curved_type_cbmi.setSelected( true );
1191 _euro_type_cbmi.setSelected( true );
1194 _rounded_type_cbmi.setSelected( true );
1197 _rectangular_type_cbmi.setSelected( true );
1200 _triangular_type_cbmi.setSelected( true );
1203 _unrooted_type_cbmi.setSelected( true );
1206 throw new IllegalArgumentException( "unknown type: " + type );
1210 final void setSpeciesTree( final Phylogeny species_tree ) {
1211 _species_tree = species_tree;
1214 void setTypeMenuToAllUnselected() {
1215 _convex_type_cbmi.setSelected( false );
1216 _curved_type_cbmi.setSelected( false );
1217 _euro_type_cbmi.setSelected( false );
1218 _rounded_type_cbmi.setSelected( false );
1219 _triangular_type_cbmi.setSelected( false );
1220 _rectangular_type_cbmi.setSelected( false );
1221 _unrooted_type_cbmi.setSelected( false );
1222 _circular_type_cbmi.setSelected( false );
1225 void switchColors() {
1226 final TreeColorSet colorset = _mainpanel.getTreeColorSet();
1227 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
1228 csc.setVisible( true );
1232 if ( _mainpanel.getCurrentTreePanel() != null ) {
1233 _mainpanel.getCurrentTreePanel().taxColor();
1237 void typeChanged( final Object o ) {
1238 updateTypeCheckboxes( getOptions(), o );
1239 updateOptions( getOptions() );
1240 if ( getCurrentTreePanel() != null ) {
1241 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
1242 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
1243 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1244 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
1245 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1246 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
1247 getCurrentTreePanel().getControlPanel().showWhole();
1249 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1250 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
1253 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
1255 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
1256 updateScreenTextAntialias( getMainPanel().getTreePanels() );
1257 if ( getCurrentTreePanel().getControlPanel().getDynamicallyHideData() != null ) {
1258 if ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
1259 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( false );
1262 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( true );
1268 void updateOptions( final Options options ) {
1269 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
1270 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
1271 && _background_gradient_cbmi.isSelected() );
1272 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
1273 options.setShowAnnotationRefSource( ( _show_annotation_ref_source != null )
1274 && _show_annotation_ref_source.isSelected() );
1275 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
1276 && _abbreviate_scientific_names.isSelected() );
1277 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
1278 && _color_labels_same_as_parent_branch.isSelected() );
1279 options.setShowDefaultNodeShapesInternal( ( _show_default_node_shapes_internal_cbmi != null )
1280 && _show_default_node_shapes_internal_cbmi.isSelected() );
1281 options.setShowDefaultNodeShapesExternal( ( _show_default_node_shapes_external_cbmi != null )
1282 && _show_default_node_shapes_external_cbmi.isSelected() );
1283 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
1284 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
1286 else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
1287 options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1289 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
1290 options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1292 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
1293 && _search_case_senstive_cbmi.isSelected() );
1294 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
1295 options.setShowScale( _show_scale_cbmi.isSelected() );
1297 if ( _label_direction_cbmi != null ) {
1298 if ( _label_direction_cbmi.isSelected() ) {
1299 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1302 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1305 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
1306 options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )
1307 && _show_confidence_stddev_cbmi.isSelected() );
1308 if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
1309 options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
1311 if ( ( _color_by_taxonomic_group_cbmi != null ) && _color_by_taxonomic_group_cbmi.isEnabled() ) {
1312 options.setColorByTaxonomicGroup( _color_by_taxonomic_group_cbmi.isSelected() );
1314 options.setPrintUsingActualSize( ( _print_using_actual_size_cbmi != null )
1315 && ( _print_using_actual_size_cbmi.isSelected() ) );
1316 options.setGraphicsExportUsingActualSize( ( _graphics_export_using_actual_size_cbmi != null )
1317 && ( _graphics_export_using_actual_size_cbmi.isSelected() ) );
1318 options.setAntialiasPrint( ( _antialias_print_cbmi != null ) && _antialias_print_cbmi.isSelected() );
1319 if ( ( _use_brackets_for_conf_in_nh_export_cbmi != null )
1320 && _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {
1321 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );
1323 else if ( ( _use_internal_names_for_conf_in_nh_export_cbmi != null )
1324 && _use_internal_names_for_conf_in_nh_export_cbmi.isSelected() ) {
1325 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES );
1328 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE );
1330 options.setPrintBlackAndWhite( ( _print_black_and_white_cbmi != null )
1331 && _print_black_and_white_cbmi.isSelected() );
1332 options.setInternalNumberAreConfidenceForNhParsing( ( _internal_number_are_confidence_for_nh_parsing_cbmi != null )
1333 && _internal_number_are_confidence_for_nh_parsing_cbmi.isSelected() );
1334 if ( ( _extract_taxonomy_pfam_strict_rbmi != null ) && _extract_taxonomy_pfam_strict_rbmi.isSelected() ) {
1335 options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1337 else if ( ( _extract_taxonomy_pfam_relaxed_rbmi != null ) && _extract_taxonomy_pfam_relaxed_rbmi.isSelected() ) {
1338 options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
1340 else if ( ( _extract_taxonomy_agressive_rbmi != null ) && _extract_taxonomy_agressive_rbmi.isSelected() ) {
1341 options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.AGGRESSIVE );
1343 else if ( ( _extract_taxonomy_no_rbmi != null ) && _extract_taxonomy_no_rbmi.isSelected() ) {
1344 options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.NO );
1346 options.setReplaceUnderscoresInNhParsing( ( _replace_underscores_cbmi != null )
1347 && _replace_underscores_cbmi.isSelected() );
1348 options.setAllowErrorsInDistanceToParent( ( _allow_errors_in_distance_to_parent_cbmi != null )
1349 && _allow_errors_in_distance_to_parent_cbmi.isSelected() );
1350 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
1351 && _search_whole_words_only_cbmi.isSelected() );
1352 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
1353 && _inverse_search_result_cbmi.isSelected() );
1354 if ( _graphics_export_visible_only_cbmi != null ) {
1355 options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() );
1356 if ( _graphics_export_visible_only_cbmi.isSelected() && ( _graphics_export_using_actual_size_cbmi != null ) ) {
1357 _graphics_export_using_actual_size_cbmi.setSelected( true );
1358 _graphics_export_using_actual_size_cbmi.setEnabled( false );
1361 _graphics_export_using_actual_size_cbmi.setEnabled( true );
1364 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
1365 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1367 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
1368 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1370 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
1371 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1373 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
1374 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1376 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
1377 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1379 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
1380 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1382 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
1383 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1385 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
1386 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1390 void updateTypeCheckboxes( final Options options, final Object o ) {
1391 setTypeMenuToAllUnselected();
1392 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
1395 void viewAsNexus() {
1396 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1397 String title = "Nexus";
1398 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1399 title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;
1401 showTextFrame( _mainpanel.getCurrentPhylogeny().toNexus( getOptions().getNhConversionSupportValueStyle() ),
1407 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1408 String title = "New Hampshire";
1409 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1410 title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;
1412 showTextFrame( _mainpanel.getCurrentPhylogeny()
1413 .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ),
1419 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1420 String title = "phyloXML";
1421 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1422 title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;
1424 showTextFrame( _mainpanel.getCurrentPhylogeny().toPhyloXML( 0 ), title );
1428 private void annotateSequences() {
1429 if ( getCurrentTreePanel() != null ) {
1430 final Set<Long> nodes = getCurrentTreePanel().getFoundNodes0();
1431 if ( ( nodes == null ) || nodes.isEmpty() ) {
1433 .showMessageDialog( this,
1434 "Need to select nodes, either via direct selection or via the \"Search\" function",
1435 "No nodes selected for annotation",
1436 JOptionPane.ERROR_MESSAGE );
1439 final Phylogeny phy = getMainPanel().getCurrentPhylogeny();
1440 if ( ( phy != null ) && !phy.isEmpty() ) {
1441 final JTextField ref_field = new JTextField( 10 );
1442 final JTextField desc_filed = new JTextField( 20 );
1443 ref_field.setText( ForesterUtil.isEmpty( getPreviousNodeAnnotationReference() ) ? ""
1444 : getPreviousNodeAnnotationReference() );
1445 final JPanel my_panel = new JPanel();
1446 my_panel.add( new JLabel( "Reference " ) );
1447 my_panel.add( ref_field );
1448 my_panel.add( Box.createHorizontalStrut( 15 ) );
1449 my_panel.add( new JLabel( "Description " ) );
1450 my_panel.add( desc_filed );
1451 final int result = JOptionPane.showConfirmDialog( null,
1453 "Enter the sequence annotation(s) for the "
1454 + nodes.size() + " selected nodes",
1455 JOptionPane.OK_CANCEL_OPTION );
1456 if ( result == JOptionPane.OK_OPTION ) {
1457 String ref = ref_field.getText();
1458 String desc = desc_filed.getText();
1459 if ( !ForesterUtil.isEmpty( ref ) ) {
1461 ref = ref.replaceAll( "\\s+", " " );
1462 if ( ( ref.indexOf( ':' ) < 1 ) || ( ref.indexOf( ':' ) > ref.length() - 2 )
1463 || ( ref.length() < 3 ) ) {
1464 JOptionPane.showMessageDialog( this,
1465 "Reference needs to be in the form of \"GO:1234567\"",
1466 "Illegal Format for Annotation Reference",
1467 JOptionPane.ERROR_MESSAGE );
1471 if ( ref != null ) {
1472 setPreviousNodeAnnotationReference( ref );
1474 if ( desc != null ) {
1476 desc = desc.replaceAll( "\\s+", " " );
1478 if ( !ForesterUtil.isEmpty( ref ) || !ForesterUtil.isEmpty( desc ) ) {
1479 for( final Long id : nodes ) {
1480 final PhylogenyNode n = phy.getNode( id );
1481 ForesterUtil.ensurePresenceOfSequence( n );
1482 final Annotation ann = ForesterUtil.isEmpty( ref ) ? new Annotation()
1483 : new Annotation( ref );
1484 if ( !ForesterUtil.isEmpty( desc ) ) {
1485 ann.setDesc( desc );
1487 n.getNodeData().getSequence().addAnnotation( ann );
1490 getMainPanel().getControlPanel().showAnnotations();
1496 private void chooseFont() {
1497 final FontChooser fc = new FontChooser();
1498 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
1499 fc.showDialog( this, "Select the Base Font" );
1500 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
1503 private void chooseMinimalConfidence() {
1504 final String s = ( String ) JOptionPane
1505 .showInputDialog( this,
1506 "Please enter the minimum for confidence values to be displayed.\n"
1507 + "[current value: " + getOptions().getMinConfidenceValue() + "]\n",
1508 "Minimal Confidence Value",
1509 JOptionPane.QUESTION_MESSAGE,
1512 getOptions().getMinConfidenceValue() );
1513 if ( !ForesterUtil.isEmpty( s ) ) {
1514 boolean success = true;
1516 final String m_str = s.trim();
1517 if ( !ForesterUtil.isEmpty( m_str ) ) {
1519 m = Double.parseDouble( m_str );
1521 catch ( final Exception ex ) {
1528 if ( success && ( m >= 0.0 ) ) {
1529 getOptions().setMinConfidenceValue( m );
1534 private void doUpdateProcessMenu() {
1535 if ( _process_pool.size() > 0 ) {
1536 if ( _process_menu == null ) {
1537 _process_menu = createMenu( "", getConfiguration() );
1538 _process_menu.setForeground( Color.RED );
1540 _process_menu.removeAll();
1541 final String text = "processes running: " + _process_pool.size();
1542 _process_menu.setText( text );
1543 _jmenubar.add( _process_menu );
1544 for( int i = 0; i < _process_pool.size(); ++i ) {
1545 final ProcessRunning p = _process_pool.getProcessByIndex( i );
1546 _process_menu.add( customizeJMenuItem( new JMenuItem( p.getName() + " [" + p.getStart() + "]" ) ) );
1550 if ( _process_menu != null ) {
1551 _process_menu.removeAll();
1552 _jmenubar.remove( _process_menu );
1555 _jmenubar.validate();
1556 _jmenubar.repaint();
1560 private String getPreviousNodeAnnotationReference() {
1561 return _previous_node_annotation_ref;
1564 private void removeBranchColors() {
1565 if ( getMainPanel().getCurrentPhylogeny() != null ) {
1566 AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
1570 private void setPreviousNodeAnnotationReference( final String previous_node_annotation_ref ) {
1571 _previous_node_annotation_ref = previous_node_annotation_ref;
1575 * Display the about box.
1577 static void about() {
1578 final StringBuffer about = new StringBuffer( "Archaeopteryx\nVersion " + Constants.VERSION + "\n" );
1579 about.append( "Copyright (C) 2013 Christian M. Zmasek\n" );
1580 about.append( "All Rights Reserved\n" );
1581 about.append( "License: GNU Lesser General Public License (LGPL)\n" );
1582 about.append( "Last modified: " + Constants.PRG_DATE + "\n" );
1583 about.append( "Based on: " + ForesterUtil.getForesterLibraryInformation() + "\n" );
1584 about.append( "phyloXML version : " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1585 about.append( "phyloXML location: " + ForesterConstants.PHYLO_XML_LOCATION + "\n" );
1586 if ( !ForesterUtil.isEmpty( ForesterUtil.JAVA_VERSION ) && !ForesterUtil.isEmpty( ForesterUtil.JAVA_VENDOR ) ) {
1587 about.append( "[your Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]\n" );
1589 if ( !ForesterUtil.isEmpty( ForesterUtil.OS_NAME ) && !ForesterUtil.isEmpty( ForesterUtil.OS_ARCH )
1590 && !ForesterUtil.isEmpty( ForesterUtil.OS_VERSION ) ) {
1591 about.append( "[your OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " "
1592 + ForesterUtil.OS_VERSION + "]\n" );
1594 final Runtime rt = java.lang.Runtime.getRuntime();
1595 final long free_memory = rt.freeMemory() / 1000000;
1596 final long total_memory = rt.totalMemory() / 1000000;
1597 about.append( "[free memory: " + free_memory + "MB, total memory: " + total_memory + "MB]\n" );
1598 about.append( "[locale: " + Locale.getDefault() + "]\n" );
1599 about.append( "References:\n" );
1600 about.append( Constants.PHYLOXML_REFERENCE_SHORT + "\n" );
1601 about.append( "For more information & download:\n" );
1602 about.append( Constants.APTX_WEB_SITE + "\n" );
1603 about.append( "Comments: " + Constants.AUTHOR_EMAIL );
1604 JOptionPane.showMessageDialog( null, about, Constants.PRG_NAME, JOptionPane.PLAIN_MESSAGE );
1607 static void chooseNodeSize( final Options options, final Component parent ) {
1608 final String s = ( String ) JOptionPane.showInputDialog( parent,
1609 "Please enter the default size for node shapes.\n"
1610 + "[current value: "
1611 + options.getDefaultNodeShapeSize() + "]\n",
1613 JOptionPane.QUESTION_MESSAGE,
1616 options.getDefaultNodeShapeSize() );
1617 if ( !ForesterUtil.isEmpty( s ) ) {
1618 boolean success = true;
1620 final String m_str = s.trim();
1621 if ( !ForesterUtil.isEmpty( m_str ) ) {
1623 m = Double.parseDouble( m_str );
1625 catch ( final Exception ex ) {
1632 if ( success && ( m >= 0.0 ) ) {
1633 final short size = ForesterUtil.roundToShort( m );
1634 if ( size >= 0.0 ) {
1635 options.setDefaultNodeShapeSize( size );
1641 static String createCurrentFontDesc( final TreeFontSet tree_font_set ) {
1642 return tree_font_set.getLargeFont().getFamily() + " " + tree_font_set.getLargeFont().getSize();
1645 static JMenu createMenu( final String title, final Configuration conf ) {
1646 final JMenu jmenu = new JMenu( title );
1647 if ( !conf.isUseNativeUI() ) {
1648 jmenu.setFont( MainFrame.menu_font );
1649 jmenu.setBackground( conf.getGuiMenuBackgroundColor() );
1650 jmenu.setForeground( conf.getGuiMenuTextColor() );
1655 static JMenuItem customizeMenuItemAsLabel( final JMenuItem label, final Configuration configuration ) {
1656 label.setFont( MainFrame.menu_font.deriveFont( Font.BOLD ) );
1657 if ( !configuration.isUseNativeUI() ) {
1658 label.setBackground( configuration.getGuiMenuBackgroundColor() );
1659 label.setForeground( configuration.getGuiMenuTextColor() );
1660 label.setOpaque( true );
1662 label.setSelected( false );
1663 label.setEnabled( false );
1667 static void cycleNodeFill( final Options op, final TreePanel tree_panel ) {
1668 switch ( op.getDefaultNodeFill() ) {
1670 op.setDefaultNodeFill( NodeFill.SOLID );
1673 op.setDefaultNodeFill( NodeFill.GRADIENT );
1676 op.setDefaultNodeFill( NodeFill.NONE );
1679 throw new RuntimeException( "unknown fill: " + op.getDefaultNodeFill() );
1683 static void cycleNodeShape( final Options op, final TreePanel tree_panel ) {
1684 switch ( op.getDefaultNodeShape() ) {
1686 op.setDefaultNodeShape( NodeShape.RECTANGLE );
1689 op.setDefaultNodeShape( NodeShape.CIRCLE );
1692 throw new RuntimeException( "unknown shape: " + op.getDefaultNodeShape() );
1696 static void cycleOverview( final Options op, final TreePanel tree_panel ) {
1697 switch ( op.getOvPlacement() ) {
1699 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1702 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1705 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1708 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1711 throw new RuntimeException( "unknown placement: " + op.getOvPlacement() );
1713 if ( tree_panel != null ) {
1714 tree_panel.updateOvSettings();
1718 static void setCycleNodeFillMenuItem( final JMenuItem mi, final Options options ) {
1719 if ( ( options != null ) && ( options.getDefaultNodeFill() != null ) ) {
1720 mi.setText( "Cycle Node Shape Fill Type... (current: "
1721 + options.getDefaultNodeFill().toString().toLowerCase() + ")" );
1724 mi.setText( "Cycle Node Shape Fill Type..." );
1728 static void setCycleNodeShapeMenuItem( final JMenuItem mi, final Options options ) {
1729 if ( ( options != null ) && ( options.getDefaultNodeShape() != null ) ) {
1730 mi.setText( "Cycle Node Shape Fill Type... (current: "
1731 + options.getDefaultNodeShape().toString().toLowerCase() + ")" );
1734 mi.setText( "Cycle Node Shape Fill Type..." );
1738 static void setOvPlacementColorChooseMenuItem( final JMenuItem mi, final Options options ) {
1739 if ( ( options != null ) && ( options.getOvPlacement() != null ) ) {
1740 mi.setText( "Cycle Overview Placement... (current: " + options.getOvPlacement() + ")" );
1743 mi.setText( "Cycle Overview Placement..." );
1747 static void setTextColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {
1748 if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {
1749 mi.setText( "Select Colors... (current: " + tree_panel.getTreeColorSet().getCurrentColorSchemeName() + ")" );
1752 mi.setText( "Select Colors..." );
1756 static void setTextForFontChooserMenuItem( final JMenuItem mi, final String font_desc ) {
1757 mi.setText( "Select Font... (current: " + font_desc + ")" );
1760 static void setTextMinSupportMenuItem( final JMenuItem mi, final Options options, final TreePanel current_tree_panel ) {
1761 if ( ( current_tree_panel == null ) || ( current_tree_panel.getPhylogeny() == null ) ) {
1762 mi.setEnabled( true );
1764 else if ( AptxUtil.isHasAtLeastOneBranchWithSupportValues( current_tree_panel.getPhylogeny() ) ) {
1765 mi.setEnabled( true );
1768 mi.setEnabled( false );
1770 mi.setText( "Enter Min Confidence Value... (current: " + options.getMinConfidenceValue() + ")" );
1773 static void setTextNodeSizeMenuItem( final JMenuItem mi, final Options options ) {
1774 mi.setText( "Enter Default Node Shape Size... (current: " + options.getDefaultNodeShapeSize() + ")" );
1777 static void updateOptionsMenuDependingOnPhylogenyType( final MainPanel main_panel,
1778 final JCheckBoxMenuItem scale,
1779 final JCheckBoxMenuItem branch_lengths,
1780 final JRadioButtonMenuItem non_lined_up,
1781 final JRadioButtonMenuItem uniform_clado,
1782 final JRadioButtonMenuItem nonuniform_clado,
1783 final JCheckBoxMenuItem label_direction_cbmi ) {
1784 final TreePanel tree_panel = main_panel.getCurrentTreePanel();
1785 final ControlPanel control = main_panel.getControlPanel();
1786 final Options options = main_panel.getOptions();
1787 scale.setSelected( options.isShowScale() );
1788 branch_lengths.setSelected( options.isShowBranchLengthValues() );
1789 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1790 if ( ( tree_panel != null ) && ( !tree_panel.isPhyHasBranchLengths() ) ) {
1791 scale.setSelected( false );
1792 scale.setEnabled( false );
1793 branch_lengths.setSelected( false );
1794 branch_lengths.setEnabled( false );
1796 else if ( ( tree_panel != null ) && !control.isDrawPhylogram() ) {
1797 scale.setSelected( false );
1798 scale.setEnabled( false );
1799 branch_lengths.setEnabled( true );
1802 scale.setEnabled( true );
1803 branch_lengths.setEnabled( true );
1805 if ( ( tree_panel != null )
1806 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.ROUNDED )
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 if ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1814 || ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
1815 non_lined_up.setEnabled( false );
1816 uniform_clado.setEnabled( false );
1817 nonuniform_clado.setEnabled( false );
1820 non_lined_up.setEnabled( true );
1821 uniform_clado.setEnabled( true );
1822 nonuniform_clado.setEnabled( true );
1826 if ( ( tree_panel != null )
1827 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1828 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1829 branch_lengths.setSelected( false );
1830 branch_lengths.setEnabled( false );
1832 if ( ( tree_panel != null )
1833 && ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( tree_panel
1834 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
1835 non_lined_up.setEnabled( false );
1838 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1839 non_lined_up.setEnabled( true );
1842 label_direction_cbmi.setEnabled( true );
1843 if ( tree_panel != null ) {
1844 if ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1845 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1846 label_direction_cbmi.setEnabled( false );
1848 if ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
1849 scale.setSelected( false );
1850 scale.setEnabled( false );
1855 static void updateScreenTextAntialias( final List<TreePanel> treepanels ) {
1856 for( final TreePanel tree_panel : treepanels ) {
1857 tree_panel.setTextAntialias();