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 _taxonomy_colorize_node_shapes_cbmi;
196 JCheckBoxMenuItem _show_confidence_stddev_cbmi;
198 JCheckBoxMenuItem _graphics_export_visible_only_cbmi;
199 JCheckBoxMenuItem _antialias_print_cbmi;
200 JCheckBoxMenuItem _print_black_and_white_cbmi;
201 JCheckBoxMenuItem _print_using_actual_size_cbmi;
202 JCheckBoxMenuItem _graphics_export_using_actual_size_cbmi;
203 JMenuItem _print_size_mi;
204 JMenuItem _choose_pdf_width_mi;
206 JCheckBoxMenuItem _internal_number_are_confidence_for_nh_parsing_cbmi;
207 JRadioButtonMenuItem _extract_taxonomy_no_rbmi;
208 JRadioButtonMenuItem _extract_taxonomy_agressive_rbmi;
209 JRadioButtonMenuItem _extract_taxonomy_pfam_strict_rbmi;
210 JRadioButtonMenuItem _extract_taxonomy_pfam_relaxed_rbmi;
211 JCheckBoxMenuItem _replace_underscores_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 == _taxonomy_colorize_node_shapes_cbmi ) {
411 updateOptions( getOptions() );
413 else if ( o == _non_lined_up_cladograms_rbmi ) {
414 updateOptions( getOptions() );
417 else if ( o == _uniform_cladograms_rbmi ) {
418 updateOptions( getOptions() );
421 else if ( o == _ext_node_dependent_cladogram_rbmi ) {
422 updateOptions( getOptions() );
425 else if ( o == _search_case_senstive_cbmi ) {
426 updateOptions( getOptions() );
427 getMainPanel().getControlPanel().search0();
428 getMainPanel().getControlPanel().search1();
430 else if ( o == _search_whole_words_only_cbmi ) {
431 updateOptions( getOptions() );
432 getMainPanel().getControlPanel().search0();
433 getMainPanel().getControlPanel().search1();
435 else if ( o == _inverse_search_result_cbmi ) {
436 updateOptions( getOptions() );
437 getMainPanel().getControlPanel().search0();
438 getMainPanel().getControlPanel().search1();
440 else if ( o == _show_scale_cbmi ) {
441 updateOptions( getOptions() );
443 else if ( o == _show_branch_length_values_cbmi ) {
444 updateOptions( getOptions() );
446 else if ( o == _color_by_taxonomic_group_cbmi ) {
447 updateOptions( getOptions() );
449 else if ( o == _show_confidence_stddev_cbmi ) {
450 updateOptions( getOptions() );
452 else if ( o == _use_brackets_for_conf_in_nh_export_cbmi ) {
453 if ( _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {
454 _use_internal_names_for_conf_in_nh_export_cbmi.setSelected( false );
456 updateOptions( getOptions() );
458 else if ( o == _use_internal_names_for_conf_in_nh_export_cbmi ) {
459 if ( _use_internal_names_for_conf_in_nh_export_cbmi.isSelected() ) {
460 _use_brackets_for_conf_in_nh_export_cbmi.setSelected( false );
462 updateOptions( getOptions() );
464 else if ( o == _label_direction_cbmi ) {
465 updateOptions( getOptions() );
467 else if ( o == _show_overview_cbmi ) {
468 updateOptions( getOptions() );
469 if ( getCurrentTreePanel() != null ) {
470 getCurrentTreePanel().updateOvSizes();
473 else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
474 || ( o == _convex_type_cbmi ) || ( o == _euro_type_cbmi ) || ( o == _rounded_type_cbmi )
475 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
478 else if ( o == _about_item ) {
481 else if ( o == _help_item ) {
484 else if ( o == _website_item ) {
486 AptxUtil.openWebsite( Constants.APTX_WEB_SITE, is_applet, applet );
488 catch ( final IOException e1 ) {
489 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
492 else if ( o == _phyloxml_website_item ) {
494 AptxUtil.openWebsite( Constants.PHYLOXML_WEB_SITE, is_applet, applet );
496 catch ( final IOException e1 ) {
497 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
500 else if ( o == _aptx_ref_item ) {
502 AptxUtil.openWebsite( Constants.APTX_REFERENCE_URL, is_applet, applet );
504 catch ( final IOException e1 ) {
505 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
508 else if ( o == _phyloxml_ref_item ) {
510 AptxUtil.openWebsite( Constants.PHYLOXML_REFERENCE_URL, is_applet, applet );
512 catch ( final IOException e1 ) {
513 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
517 if ( _load_phylogeny_from_webservice_menu_items != null ) {
518 for( int i = 0; i < _load_phylogeny_from_webservice_menu_items.length; ++i ) {
519 if ( o == _load_phylogeny_from_webservice_menu_items[ i ] ) {
520 readPhylogeniesFromWebservice( i );
525 _contentpane.repaint();
528 public Configuration getConfiguration() {
529 return _configuration;
533 * This method returns the current external node data which
534 * has been selected by the user by clicking the "Return ..."
535 * menu item. This method is expected to be called from Javascript or
538 * @return current external node data as String
540 public String getCurrentExternalNodesDataBuffer() {
541 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString();
544 public int getCurrentExternalNodesDataBufferChangeCounter() {
545 return getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter();
548 public int getCurrentExternalNodesDataBufferLength() {
549 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length();
552 public InferenceManager getInferenceManager() {
553 return _inference_manager;
556 public MainPanel getMainPanel() {
560 public Options getOptions() {
564 public ProcessPool getProcessPool() {
565 return _process_pool;
568 public void showTextFrame( final String s, final String title ) {
570 _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
573 public void showWhole() {
574 _mainpanel.getControlPanel().showWhole();
577 public void updateProcessMenu() {
578 // In general Swing is not thread safe.
579 // See "Swing's Threading Policy".
580 SwingUtilities.invokeLater( new Runnable() {
584 doUpdateProcessMenu();
589 void activateSaveAllIfNeeded() {
590 if ( ( getMainPanel().getTabbedPane() != null ) && ( getMainPanel().getTabbedPane().getTabCount() > 1 ) ) {
591 _save_all_item.setEnabled( true );
594 _save_all_item.setEnabled( false );
598 void buildFileMenu() {
599 _file_jmenu = createMenu( "File", getConfiguration() );
600 _file_jmenu.add( _open_url_item = new JMenuItem( "Read tree from URL/webservice..." ) );
601 _file_jmenu.addSeparator();
602 _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );
603 customizeJMenuItem( _open_url_item );
604 customizeJMenuItem( _exit_item );
605 _jmenubar.add( _file_jmenu );
608 void buildFontSizeMenu() {
609 _font_size_menu = createMenu( FONT_SIZE_MENU_LABEL, getConfiguration() );
610 _font_size_menu.add( _super_tiny_fonts_item = new JMenuItem( "Super Tiny Fonts" ) );
611 _font_size_menu.add( _tiny_fonts_item = new JMenuItem( "Tiny Fonts" ) );
612 _font_size_menu.add( _small_fonts_item = new JMenuItem( "Small Fonts" ) );
613 _font_size_menu.add( _medium_fonts_item = new JMenuItem( "Medium Fonts" ) );
614 _font_size_menu.add( _large_fonts_item = new JMenuItem( "Large Fonts" ) );
615 customizeJMenuItem( _super_tiny_fonts_item );
616 customizeJMenuItem( _tiny_fonts_item );
617 customizeJMenuItem( _small_fonts_item );
618 customizeJMenuItem( _medium_fonts_item );
619 customizeJMenuItem( _large_fonts_item );
620 _jmenubar.add( _font_size_menu );
623 void buildHelpMenu() {
624 _help_jmenu = createMenu( "Help", getConfiguration() );
625 _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
626 _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
627 _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
628 _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
629 _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
630 _help_jmenu.addSeparator();
631 _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
632 customizeJMenuItem( _help_item );
633 customizeJMenuItem( _website_item );
634 customizeJMenuItem( _phyloxml_website_item );
635 customizeJMenuItem( _aptx_ref_item );
636 customizeJMenuItem( _phyloxml_ref_item );
637 customizeJMenuItem( _about_item );
638 _phyloxml_ref_item.setToolTipText( PHYLOXML_REF_TOOL_TIP );
639 _aptx_ref_item.setToolTipText( APTX_REF_TOOL_TIP );
640 _jmenubar.add( _help_jmenu );
643 void buildTypeMenu() {
644 _type_menu = createMenu( TYPE_MENU_HEADER, getConfiguration() );
645 _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
646 _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
647 _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
648 _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
649 _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
650 _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
651 _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
652 _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
653 customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
654 customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
655 customizeCheckBoxMenuItem( _euro_type_cbmi, false );
656 customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
657 customizeCheckBoxMenuItem( _curved_type_cbmi, false );
658 customizeCheckBoxMenuItem( _convex_type_cbmi, false );
659 customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
660 customizeCheckBoxMenuItem( _circular_type_cbmi, false );
661 _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
662 _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
663 initializeTypeMenu( getOptions() );
664 _jmenubar.add( _type_menu );
667 void buildViewMenu() {
668 _view_jmenu = createMenu( "View", getConfiguration() );
669 _view_jmenu.add( _display_basic_information_item = new JMenuItem( SHOW_BASIC_TREE_INFORMATION_LABEL ) );
670 _view_jmenu.addSeparator();
671 _view_jmenu.add( _view_as_XML_item = new JMenuItem( "as phyloXML" ) );
672 _view_jmenu.add( _view_as_NH_item = new JMenuItem( "as Newick" ) );
673 _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "as Nexus" ) );
674 customizeJMenuItem( _display_basic_information_item );
675 customizeJMenuItem( _view_as_NH_item );
676 customizeJMenuItem( _view_as_XML_item );
677 customizeJMenuItem( _view_as_nexus_item );
678 _jmenubar.add( _view_jmenu );
681 void checkTextFrames() {
682 if ( _textframes.size() > 5 ) {
684 if ( _textframes.getFirst() != null ) {
685 _textframes.getFirst().removeMe();
688 _textframes.removeFirst();
691 catch ( final NoSuchElementException e ) {
698 removeAllTextFrames();
699 if ( _mainpanel != null ) {
700 _mainpanel.terminate();
702 if ( _contentpane != null ) {
703 _contentpane.removeAll();
710 if ( _mainpanel.getCurrentTreePanel() != null ) {
711 final String[] ranks = AptxUtil.getAllPossibleRanks();
712 final String rank = ( String ) JOptionPane
713 .showInputDialog( this,
714 "What rank should the colorization be based on",
716 JOptionPane.QUESTION_MESSAGE,
720 if ( !ForesterUtil.isEmpty( rank ) ) {
721 _mainpanel.getCurrentTreePanel().colorRank( rank );
727 if ( _mainpanel.getCurrentTreePanel() != null ) {
728 _mainpanel.getCurrentTreePanel().confColor();
732 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
733 if ( item != null ) {
734 item.setFont( MainFrame.menu_font );
735 if ( !getConfiguration().isUseNativeUI() ) {
736 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
737 item.setForeground( getConfiguration().getGuiMenuTextColor() );
739 item.setSelected( is_selected );
740 item.addActionListener( this );
744 JMenuItem customizeJMenuItem( final JMenuItem jmi ) {
746 jmi.setFont( MainFrame.menu_font );
747 if ( !getConfiguration().isUseNativeUI() ) {
748 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
749 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
751 jmi.addActionListener( this );
756 void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
757 if ( item != null ) {
758 item.setFont( MainFrame.menu_font );
759 if ( !getConfiguration().isUseNativeUI() ) {
760 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
761 item.setForeground( getConfiguration().getGuiMenuTextColor() );
763 item.setSelected( is_selected );
764 item.addActionListener( this );
768 void displayBasicInformation( final File treefile ) {
769 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
770 String title = "Basic Information";
771 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
772 title = title + " for \"" + _mainpanel.getCurrentPhylogeny().getName() + "\"";
774 showTextFrame( AptxUtil.createBasicInformation( _mainpanel.getCurrentPhylogeny(), treefile ), title );
778 void exceptionOccuredDuringOpenFile( final Exception e ) {
780 _mainpanel.getCurrentTreePanel().setArrowCursor();
782 catch ( final Exception ex ) {
785 JOptionPane.showMessageDialog( this,
786 ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
787 "Error during File|Open",
788 JOptionPane.ERROR_MESSAGE );
791 void exceptionOccuredDuringSaveAs( final Exception e ) {
793 _mainpanel.getCurrentTreePanel().setArrowCursor();
795 catch ( final Exception ex ) {
798 JOptionPane.showMessageDialog( this, "Exception" + e, "Error during File|SaveAs", JOptionPane.ERROR_MESSAGE );
802 if ( !isOKforSDI( false, true ) ) {
805 if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {
806 JOptionPane.showMessageDialog( this,
807 "Gene tree is not rooted.",
808 "Cannot execute GSDI",
809 JOptionPane.ERROR_MESSAGE );
812 final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
813 gene_tree.setAllNodesToNotCollapse();
814 gene_tree.recalculateNumberOfExternalDescendants( false );
816 final Phylogeny species_tree = getSpeciesTree().copy();
818 gsdi = new GSDI( gene_tree, species_tree, false, true, true, true );
820 catch ( final SDIException e ) {
821 JOptionPane.showMessageDialog( this,
822 e.getLocalizedMessage(),
824 JOptionPane.ERROR_MESSAGE );
827 catch ( final Exception e ) {
828 AptxUtil.unexpectedException( e );
831 gene_tree.setRerootable( false );
832 gene_tree.clearHashIdToNodeMap();
833 gene_tree.recalculateNumberOfExternalDescendants( true );
834 _mainpanel.addPhylogenyInNewTab( gene_tree, getConfiguration(), "gene tree", null );
835 getMainPanel().getControlPanel().setShowEvents( true );
837 final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
838 _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
840 _mainpanel.getTabbedPane().setSelectedIndex( selected );
842 _mainpanel.getCurrentTreePanel().setEdited( true );
843 final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
844 if ( gsdi.getStrippedExternalGeneTreeNodes().size() > 0 ) {
845 JOptionPane.showMessageDialog( this,
846 "Duplications: " + gsdi.getDuplicationsSum() + "\n"
847 + "Potential duplications: "
848 + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
849 + "Speciations: " + gsdi.getSpeciationsSum() + "\n"
850 + "Stripped gene tree nodes: "
851 + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
852 + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
853 + "Number of polytomies in species tree used: " + poly + "\n",
854 "GSDI successfully completed",
855 JOptionPane.WARNING_MESSAGE );
858 JOptionPane.showMessageDialog( this,
859 "Duplications: " + gsdi.getDuplicationsSum() + "\n"
860 + "Potential duplications: "
861 + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
862 + "Speciations: " + gsdi.getSpeciationsSum() + "\n"
863 + "Stripped gene tree nodes: "
864 + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
865 + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
866 + "Number of polytomies in species tree used: " + poly + "\n",
867 "GSDI successfully completed",
868 JOptionPane.INFORMATION_MESSAGE );
872 void executeGSDIR() {
873 if ( !isOKforSDI( false, false ) ) {
876 final int p = PhylogenyMethods.countNumberOfPolytomies( _mainpanel.getCurrentPhylogeny() );
878 && !( ( p == 1 ) && ( _mainpanel.getCurrentPhylogeny().getRoot().getNumberOfDescendants() == 3 ) ) ) {
879 JOptionPane.showMessageDialog( this,
880 "Gene tree is not completely binary",
881 "Cannot execute GSDI",
882 JOptionPane.ERROR_MESSAGE );
885 final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
886 gene_tree.setAllNodesToNotCollapse();
887 gene_tree.recalculateNumberOfExternalDescendants( false );
889 final Phylogeny species_tree = getSpeciesTree().copy();
891 gsdir = new GSDIR( gene_tree, species_tree, true, true, true );
893 catch ( final SDIException e ) {
894 JOptionPane.showMessageDialog( this,
895 e.getLocalizedMessage(),
896 "Error during GSDIR",
897 JOptionPane.ERROR_MESSAGE );
900 catch ( final Exception e ) {
901 AptxUtil.unexpectedException( e );
904 final Phylogeny result_gene_tree = gsdir.getMinDuplicationsSumGeneTree();
905 result_gene_tree.setRerootable( false );
906 result_gene_tree.clearHashIdToNodeMap();
907 result_gene_tree.recalculateNumberOfExternalDescendants( true );
908 PhylogenyMethods.orderAppearance( result_gene_tree.getRoot(), true, true, DESCENDANT_SORT_PRIORITY.NODE_NAME );
909 _mainpanel.addPhylogenyInNewTab( result_gene_tree, getConfiguration(), "gene tree", null );
910 getMainPanel().getControlPanel().setShowEvents( true );
912 final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
913 _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
915 _mainpanel.getTabbedPane().setSelectedIndex( selected );
917 _mainpanel.getCurrentTreePanel().setEdited( true );
918 final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
919 if ( gsdir.getStrippedExternalGeneTreeNodes().size() > 0 ) {
920 JOptionPane.showMessageDialog( this,
921 "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
922 + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
923 + "Stripped gene tree nodes: "
924 + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
925 + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
926 + "Number of polytomies in species tree used: " + poly + "\n",
927 "GSDIR successfully completed",
928 JOptionPane.WARNING_MESSAGE );
931 JOptionPane.showMessageDialog( this,
932 "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
933 + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
934 + "Stripped gene tree nodes: "
935 + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
936 + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
937 + "Number of polytomies in species tree used: " + poly + "\n",
938 "GSDIR successfully completed",
939 JOptionPane.INFORMATION_MESSAGE );
943 boolean GAndSDoHaveMoreThanOneSpeciesInComman( final Phylogeny gene_tree ) {
944 if ( ( gene_tree == null ) || gene_tree.isEmpty() ) {
945 JOptionPane.showMessageDialog( this,
946 "Gene tree and species tree have no species in common.",
948 JOptionPane.ERROR_MESSAGE );
951 else if ( gene_tree.getNumberOfExternalNodes() < 2 ) {
952 JOptionPane.showMessageDialog( this,
953 "Gene tree and species tree have only one species in common.",
955 JOptionPane.ERROR_MESSAGE );
963 TreePanel getCurrentTreePanel() {
964 return getMainPanel().getCurrentTreePanel();
967 JMenu getHelpMenu() {
971 JCheckBoxMenuItem getlabelDirectionCbmi() {
972 return _label_direction_cbmi;
975 JMenuBar getMenuBarOfMainFrame() {
979 final Phylogeny getSpeciesTree() {
980 return _species_tree;
984 final StringBuilder sb = new StringBuilder();
985 sb.append( "Display options\n" );
986 sb.append( "-------------------\n" );
987 sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
988 sb.append( "Clickable tree nodes\n" );
989 sb.append( "--------------------\n" );
990 sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
991 sb.append( "or by right clicking:\n" );
992 sb.append( "o Display Node Data -- display information for a node\n" );
993 sb.append( "o Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
994 sb.append( "o Root/Reroot -- change tree root to clicked node\n" );
995 sb.append( "o Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
996 sb.append( "o Swap Descendants -- switch descendant on either side of clicked node\n" );
997 sb.append( "o Colorize Subtree -- color a subtree\n" );
998 sb.append( "o Open Sequence Web -- launch a web browser to display sequence information\n" );
999 sb.append( "o Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
1000 sb.append( "- there may be additional choices depending on this particular setup\n\n" );
1001 sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
1002 sb.append( "Zooming\n" );
1003 sb.append( "---------\n" );
1004 sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
1005 sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
1006 sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
1007 sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
1008 sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
1009 sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
1010 sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
1011 sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
1012 sb.append( "Quick tree manipulation:\n" );
1013 sb.append( "------------------------\n" );
1014 sb.append( "Order Subtrees -- order the tree by branch length\n" );
1015 sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
1016 sb.append( "Memory problems (Java heap space error)\n" );
1017 sb.append( "---------------------------------------\n" );
1018 sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
1019 sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
1020 sb.append( "the '-Xmx' Java command line option. For example:\n" );
1021 sb.append( "java -Xmx1024m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
1022 // + "General remarks\n"
1023 // + "---------------\n"
1025 // "o The application version permits copying to the clipboard \n"
1027 // " in the \"View\"|\"View as ...\" frame (either by control-c or button press).\n"
1029 // "o Changes made to a subtree affect this subtree and its subtrees,\n"
1030 // + " but not any of its parent tree(s).\n"
1032 // "o Archaeopteryx tries to detect whether the numerical values in a NH tree\n"
1034 // " are likely to be bootstrap values instead of branch length values.\n\n"
1036 // " Remarks regarding SDI (Speciation Duplication Inference):\n"
1038 // "o Each external node of the gene tree (in display) needs to be associated with\n"
1040 // " a species: either directly through the \"Species\" field, or the species\n"
1042 // " is part of the sequence name in the form \"XXXX_SPECIES\"\n"
1044 // " (e.g. \"ACON_DROME\" or \"ACON_DROME/123-4489\" which is also acceptable).\n"
1046 // "o A species tree for each species of the gene tree needs to be loaded with\n"
1048 // " \"SDI\"|\"Load species tree\" prior the SDI execution.\n"
1050 // "o !External nodes of the gene tree associated with species not present in\n"
1052 // " the species tree are REMOVED prior to SDI execution!\n"
1054 // "o Both the gene tree and the species tree must be completely binary.\n"
1056 // "o Duplications and speciations are a function of the position of the root.\n"
1058 // " Hence, after each manual \"Root/Reroot\"ing some duplications will be\n"
1059 // + " incorrect and need to be inferred again\n"
1061 // " with: \"SDI\"|\"SDI (Speciation Duplication Inference)\n\n"
1062 sb.append( "phyloXML\n" );
1063 sb.append( "-------------------\n" );
1064 sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
1065 sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
1066 sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1068 sb.append( "For more information: https://sites.google.com/site/cmzmasek/home/software/archaeopteryx\n" );
1069 sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
1070 TextFrame.instantiate( sb.toString(), "Help", _textframes );
1073 void initializeTypeMenu( final Options options ) {
1074 setTypeMenuToAllUnselected();
1075 switch ( options.getPhylogenyGraphicsType() ) {
1077 _convex_type_cbmi.setSelected( true );
1080 _curved_type_cbmi.setSelected( true );
1083 _euro_type_cbmi.setSelected( true );
1086 _rounded_type_cbmi.setSelected( true );
1089 _triangular_type_cbmi.setSelected( true );
1092 _unrooted_type_cbmi.setSelected( true );
1095 _circular_type_cbmi.setSelected( true );
1098 _rectangular_type_cbmi.setSelected( true );
1103 boolean isOKforSDI( final boolean species_tree_has_to_binary, final boolean gene_tree_has_to_binary ) {
1104 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty() ) {
1107 else if ( ( getSpeciesTree() == null ) || getSpeciesTree().isEmpty() ) {
1108 JOptionPane.showMessageDialog( this,
1109 "No species tree loaded",
1110 "Cannot execute GSDI",
1111 JOptionPane.ERROR_MESSAGE );
1114 else if ( species_tree_has_to_binary && !getSpeciesTree().isCompletelyBinary() ) {
1115 JOptionPane.showMessageDialog( this,
1116 "Species tree is not completely binary",
1117 "Cannot execute GSDI",
1118 JOptionPane.ERROR_MESSAGE );
1121 else if ( gene_tree_has_to_binary && !_mainpanel.getCurrentPhylogeny().isCompletelyBinary() ) {
1122 JOptionPane.showMessageDialog( this,
1123 "Gene tree is not completely binary",
1124 "Cannot execute GSDI",
1125 JOptionPane.ERROR_MESSAGE );
1133 boolean isSubtreeDisplayed() {
1134 if ( getCurrentTreePanel() != null ) {
1135 if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
1137 .showMessageDialog( this,
1138 "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",
1139 "Operation can not be exectuted on a sub-tree",
1140 JOptionPane.WARNING_MESSAGE );
1147 void midpointRoot() {
1148 if ( _mainpanel.getCurrentTreePanel() != null ) {
1149 _mainpanel.getCurrentTreePanel().midpointRoot();
1153 abstract void readPhylogeniesFromURL();
1155 void readPhylogeniesFromWebservice( final int i ) {
1156 final UrlTreeReader reader = new UrlTreeReader( this, i );
1157 new Thread( reader ).start();
1160 void removeAllTextFrames() {
1161 for( final TextFrame tf : _textframes ) {
1166 _textframes.clear();
1169 void setConfiguration( final Configuration configuration ) {
1170 _configuration = configuration;
1173 void setInferenceManager( final InferenceManager i ) {
1174 _inference_manager = i;
1177 void setOptions( final Options options ) {
1181 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
1182 setTypeMenuToAllUnselected();
1185 _circular_type_cbmi.setSelected( true );
1188 _convex_type_cbmi.setSelected( true );
1191 _curved_type_cbmi.setSelected( true );
1194 _euro_type_cbmi.setSelected( true );
1197 _rounded_type_cbmi.setSelected( true );
1200 _rectangular_type_cbmi.setSelected( true );
1203 _triangular_type_cbmi.setSelected( true );
1206 _unrooted_type_cbmi.setSelected( true );
1209 throw new IllegalArgumentException( "unknown type: " + type );
1213 final void setSpeciesTree( final Phylogeny species_tree ) {
1214 _species_tree = species_tree;
1217 void setTypeMenuToAllUnselected() {
1218 _convex_type_cbmi.setSelected( false );
1219 _curved_type_cbmi.setSelected( false );
1220 _euro_type_cbmi.setSelected( false );
1221 _rounded_type_cbmi.setSelected( false );
1222 _triangular_type_cbmi.setSelected( false );
1223 _rectangular_type_cbmi.setSelected( false );
1224 _unrooted_type_cbmi.setSelected( false );
1225 _circular_type_cbmi.setSelected( false );
1228 void switchColors() {
1229 final TreeColorSet colorset = _mainpanel.getTreeColorSet();
1230 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
1231 csc.setVisible( true );
1235 if ( _mainpanel.getCurrentTreePanel() != null ) {
1236 _mainpanel.getCurrentTreePanel().taxColor();
1240 void typeChanged( final Object o ) {
1241 updateTypeCheckboxes( getOptions(), o );
1242 updateOptions( getOptions() );
1243 if ( getCurrentTreePanel() != null ) {
1244 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
1245 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
1246 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1247 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
1248 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1249 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
1250 getCurrentTreePanel().getControlPanel().showWhole();
1252 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1253 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
1256 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
1258 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
1259 updateScreenTextAntialias( getMainPanel().getTreePanels() );
1260 if ( getCurrentTreePanel().getControlPanel().getDynamicallyHideData() != null ) {
1261 if ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
1262 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( false );
1265 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( true );
1271 void updateOptions( final Options options ) {
1272 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
1273 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
1274 && _background_gradient_cbmi.isSelected() );
1275 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
1276 options.setShowAnnotationRefSource( ( _show_annotation_ref_source != null )
1277 && _show_annotation_ref_source.isSelected() );
1278 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
1279 && _abbreviate_scientific_names.isSelected() );
1280 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
1281 && _color_labels_same_as_parent_branch.isSelected() );
1282 options.setShowDefaultNodeShapesInternal( ( _show_default_node_shapes_internal_cbmi != null )
1283 && _show_default_node_shapes_internal_cbmi.isSelected() );
1284 options.setShowDefaultNodeShapesExternal( ( _show_default_node_shapes_external_cbmi != null )
1285 && _show_default_node_shapes_external_cbmi.isSelected() );
1286 options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null )
1287 && _taxonomy_colorize_node_shapes_cbmi.isSelected() );
1288 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
1289 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
1291 else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
1292 options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1294 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
1295 options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1297 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
1298 && _search_case_senstive_cbmi.isSelected() );
1299 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
1300 options.setShowScale( _show_scale_cbmi.isSelected() );
1302 if ( _label_direction_cbmi != null ) {
1303 if ( _label_direction_cbmi.isSelected() ) {
1304 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1307 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1310 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
1311 options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )
1312 && _show_confidence_stddev_cbmi.isSelected() );
1313 if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
1314 options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
1316 if ( ( _color_by_taxonomic_group_cbmi != null ) && _color_by_taxonomic_group_cbmi.isEnabled() ) {
1317 options.setColorByTaxonomicGroup( _color_by_taxonomic_group_cbmi.isSelected() );
1319 options.setPrintUsingActualSize( ( _print_using_actual_size_cbmi != null )
1320 && ( _print_using_actual_size_cbmi.isSelected() ) );
1321 options.setGraphicsExportUsingActualSize( ( _graphics_export_using_actual_size_cbmi != null )
1322 && ( _graphics_export_using_actual_size_cbmi.isSelected() ) );
1323 options.setAntialiasPrint( ( _antialias_print_cbmi != null ) && _antialias_print_cbmi.isSelected() );
1324 if ( ( _use_brackets_for_conf_in_nh_export_cbmi != null )
1325 && _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {
1326 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );
1328 else if ( ( _use_internal_names_for_conf_in_nh_export_cbmi != null )
1329 && _use_internal_names_for_conf_in_nh_export_cbmi.isSelected() ) {
1330 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES );
1333 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE );
1335 options.setPrintBlackAndWhite( ( _print_black_and_white_cbmi != null )
1336 && _print_black_and_white_cbmi.isSelected() );
1337 options.setInternalNumberAreConfidenceForNhParsing( ( _internal_number_are_confidence_for_nh_parsing_cbmi != null )
1338 && _internal_number_are_confidence_for_nh_parsing_cbmi.isSelected() );
1339 if ( ( _extract_taxonomy_pfam_strict_rbmi != null ) && _extract_taxonomy_pfam_strict_rbmi.isSelected() ) {
1340 options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1342 else if ( ( _extract_taxonomy_pfam_relaxed_rbmi != null ) && _extract_taxonomy_pfam_relaxed_rbmi.isSelected() ) {
1343 options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
1345 else if ( ( _extract_taxonomy_agressive_rbmi != null ) && _extract_taxonomy_agressive_rbmi.isSelected() ) {
1346 options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.AGGRESSIVE );
1348 else if ( ( _extract_taxonomy_no_rbmi != null ) && _extract_taxonomy_no_rbmi.isSelected() ) {
1349 options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.NO );
1351 options.setReplaceUnderscoresInNhParsing( ( _replace_underscores_cbmi != null )
1352 && _replace_underscores_cbmi.isSelected() );
1353 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
1354 && _search_whole_words_only_cbmi.isSelected() );
1355 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
1356 && _inverse_search_result_cbmi.isSelected() );
1357 if ( _graphics_export_visible_only_cbmi != null ) {
1358 options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() );
1359 if ( _graphics_export_visible_only_cbmi.isSelected() && ( _graphics_export_using_actual_size_cbmi != null ) ) {
1360 _graphics_export_using_actual_size_cbmi.setSelected( true );
1361 _graphics_export_using_actual_size_cbmi.setEnabled( false );
1364 _graphics_export_using_actual_size_cbmi.setEnabled( true );
1367 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
1368 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1370 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
1371 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1373 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
1374 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1376 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
1377 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1379 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
1380 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1382 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
1383 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1385 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
1386 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1388 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
1389 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1393 void updateTypeCheckboxes( final Options options, final Object o ) {
1394 setTypeMenuToAllUnselected();
1395 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
1398 void viewAsNexus() {
1399 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1400 String title = "Nexus";
1401 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1402 title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;
1404 showTextFrame( _mainpanel.getCurrentPhylogeny().toNexus( getOptions().getNhConversionSupportValueStyle() ),
1410 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1411 String title = "New Hampshire";
1412 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1413 title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;
1415 showTextFrame( _mainpanel.getCurrentPhylogeny()
1416 .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ),
1422 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1423 String title = "phyloXML";
1424 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1425 title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;
1427 showTextFrame( _mainpanel.getCurrentPhylogeny().toPhyloXML( 0 ), title );
1431 private void annotateSequences() {
1432 if ( getCurrentTreePanel() != null ) {
1433 final Set<Long> nodes = getCurrentTreePanel().getFoundNodes0();
1434 if ( ( nodes == null ) || nodes.isEmpty() ) {
1436 .showMessageDialog( this,
1437 "Need to select nodes, either via direct selection or via the \"Search\" function",
1438 "No nodes selected for annotation",
1439 JOptionPane.ERROR_MESSAGE );
1442 final Phylogeny phy = getMainPanel().getCurrentPhylogeny();
1443 if ( ( phy != null ) && !phy.isEmpty() ) {
1444 final JTextField ref_field = new JTextField( 10 );
1445 final JTextField desc_filed = new JTextField( 20 );
1446 ref_field.setText( ForesterUtil.isEmpty( getPreviousNodeAnnotationReference() ) ? ""
1447 : getPreviousNodeAnnotationReference() );
1448 final JPanel my_panel = new JPanel();
1449 my_panel.add( new JLabel( "Reference " ) );
1450 my_panel.add( ref_field );
1451 my_panel.add( Box.createHorizontalStrut( 15 ) );
1452 my_panel.add( new JLabel( "Description " ) );
1453 my_panel.add( desc_filed );
1454 final int result = JOptionPane.showConfirmDialog( null,
1456 "Enter the sequence annotation(s) for the "
1457 + nodes.size() + " selected nodes",
1458 JOptionPane.OK_CANCEL_OPTION );
1459 if ( result == JOptionPane.OK_OPTION ) {
1460 String ref = ref_field.getText();
1461 String desc = desc_filed.getText();
1462 if ( !ForesterUtil.isEmpty( ref ) ) {
1464 ref = ref.replaceAll( "\\s+", " " );
1465 if ( ( ref.indexOf( ':' ) < 1 ) || ( ref.indexOf( ':' ) > ref.length() - 2 )
1466 || ( ref.length() < 3 ) ) {
1467 JOptionPane.showMessageDialog( this,
1468 "Reference needs to be in the form of \"GO:1234567\"",
1469 "Illegal Format for Annotation Reference",
1470 JOptionPane.ERROR_MESSAGE );
1474 if ( ref != null ) {
1475 setPreviousNodeAnnotationReference( ref );
1477 if ( desc != null ) {
1479 desc = desc.replaceAll( "\\s+", " " );
1481 if ( !ForesterUtil.isEmpty( ref ) || !ForesterUtil.isEmpty( desc ) ) {
1482 for( final Long id : nodes ) {
1483 final PhylogenyNode n = phy.getNode( id );
1484 ForesterUtil.ensurePresenceOfSequence( n );
1485 final Annotation ann = ForesterUtil.isEmpty( ref ) ? new Annotation()
1486 : new Annotation( ref );
1487 if ( !ForesterUtil.isEmpty( desc ) ) {
1488 ann.setDesc( desc );
1490 n.getNodeData().getSequence().addAnnotation( ann );
1493 getMainPanel().getControlPanel().showAnnotations();
1499 private void chooseFont() {
1500 final FontChooser fc = new FontChooser();
1501 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
1502 fc.showDialog( this, "Select the Base Font" );
1503 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
1506 private void chooseMinimalConfidence() {
1507 final String s = ( String ) JOptionPane
1508 .showInputDialog( this,
1509 "Please enter the minimum for confidence values to be displayed.\n"
1510 + "[current value: " + getOptions().getMinConfidenceValue() + "]\n",
1511 "Minimal Confidence Value",
1512 JOptionPane.QUESTION_MESSAGE,
1515 getOptions().getMinConfidenceValue() );
1516 if ( !ForesterUtil.isEmpty( s ) ) {
1517 boolean success = true;
1519 final String m_str = s.trim();
1520 if ( !ForesterUtil.isEmpty( m_str ) ) {
1522 m = Double.parseDouble( m_str );
1524 catch ( final Exception ex ) {
1531 if ( success && ( m >= 0.0 ) ) {
1532 getOptions().setMinConfidenceValue( m );
1537 private void doUpdateProcessMenu() {
1538 if ( _process_pool.size() > 0 ) {
1539 if ( _process_menu == null ) {
1540 _process_menu = createMenu( "", getConfiguration() );
1541 _process_menu.setForeground( Color.RED );
1543 _process_menu.removeAll();
1544 final String text = "processes running: " + _process_pool.size();
1545 _process_menu.setText( text );
1546 _jmenubar.add( _process_menu );
1547 for( int i = 0; i < _process_pool.size(); ++i ) {
1548 final ProcessRunning p = _process_pool.getProcessByIndex( i );
1549 _process_menu.add( customizeJMenuItem( new JMenuItem( p.getName() + " [" + p.getStart() + "]" ) ) );
1553 if ( _process_menu != null ) {
1554 _process_menu.removeAll();
1555 _jmenubar.remove( _process_menu );
1558 _jmenubar.validate();
1559 _jmenubar.repaint();
1563 private String getPreviousNodeAnnotationReference() {
1564 return _previous_node_annotation_ref;
1567 private void removeBranchColors() {
1568 if ( getMainPanel().getCurrentPhylogeny() != null ) {
1569 AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
1573 private void setPreviousNodeAnnotationReference( final String previous_node_annotation_ref ) {
1574 _previous_node_annotation_ref = previous_node_annotation_ref;
1578 * Display the about box.
1580 static void about() {
1581 final StringBuffer about = new StringBuffer( "Archaeopteryx\nVersion " + Constants.VERSION + "\n" );
1582 about.append( "Copyright (C) 2013 Christian M. Zmasek\n" );
1583 about.append( "All Rights Reserved\n" );
1584 about.append( "License: GNU Lesser General Public License (LGPL)\n" );
1585 about.append( "Last modified: " + Constants.PRG_DATE + "\n" );
1586 about.append( "Based on: " + ForesterUtil.getForesterLibraryInformation() + "\n" );
1587 about.append( "phyloXML version : " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1588 about.append( "phyloXML location: " + ForesterConstants.PHYLO_XML_LOCATION + "\n" );
1589 if ( !ForesterUtil.isEmpty( ForesterUtil.JAVA_VERSION ) && !ForesterUtil.isEmpty( ForesterUtil.JAVA_VENDOR ) ) {
1590 about.append( "[your Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]\n" );
1592 if ( !ForesterUtil.isEmpty( ForesterUtil.OS_NAME ) && !ForesterUtil.isEmpty( ForesterUtil.OS_ARCH )
1593 && !ForesterUtil.isEmpty( ForesterUtil.OS_VERSION ) ) {
1594 about.append( "[your OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " "
1595 + ForesterUtil.OS_VERSION + "]\n" );
1597 final Runtime rt = java.lang.Runtime.getRuntime();
1598 final long free_memory = rt.freeMemory() / 1000000;
1599 final long total_memory = rt.totalMemory() / 1000000;
1600 about.append( "[free memory: " + free_memory + "MB, total memory: " + total_memory + "MB]\n" );
1601 about.append( "[locale: " + Locale.getDefault() + "]\n" );
1602 about.append( "References:\n" );
1603 about.append( Constants.PHYLOXML_REFERENCE_SHORT + "\n" );
1604 about.append( "For more information & download:\n" );
1605 about.append( Constants.APTX_WEB_SITE + "\n" );
1606 about.append( "Comments: " + Constants.AUTHOR_EMAIL );
1607 JOptionPane.showMessageDialog( null, about, Constants.PRG_NAME, JOptionPane.PLAIN_MESSAGE );
1610 static void chooseNodeSize( final Options options, final Component parent ) {
1611 final String s = ( String ) JOptionPane.showInputDialog( parent,
1612 "Please enter the default size for node shapes.\n"
1613 + "[current value: "
1614 + options.getDefaultNodeShapeSize() + "]\n",
1616 JOptionPane.QUESTION_MESSAGE,
1619 options.getDefaultNodeShapeSize() );
1620 if ( !ForesterUtil.isEmpty( s ) ) {
1621 boolean success = true;
1623 final String m_str = s.trim();
1624 if ( !ForesterUtil.isEmpty( m_str ) ) {
1626 m = Double.parseDouble( m_str );
1628 catch ( final Exception ex ) {
1635 if ( success && ( m >= 0.0 ) ) {
1636 final short size = ForesterUtil.roundToShort( m );
1637 if ( size >= 0.0 ) {
1638 options.setDefaultNodeShapeSize( size );
1644 static String createCurrentFontDesc( final TreeFontSet tree_font_set ) {
1645 return tree_font_set.getLargeFont().getFamily() + " " + tree_font_set.getLargeFont().getSize();
1648 static JMenu createMenu( final String title, final Configuration conf ) {
1649 final JMenu jmenu = new JMenu( title );
1650 if ( !conf.isUseNativeUI() ) {
1651 jmenu.setFont( MainFrame.menu_font );
1652 jmenu.setBackground( conf.getGuiMenuBackgroundColor() );
1653 jmenu.setForeground( conf.getGuiMenuTextColor() );
1658 static JMenuItem customizeMenuItemAsLabel( final JMenuItem label, final Configuration configuration ) {
1659 label.setFont( MainFrame.menu_font.deriveFont( Font.BOLD ) );
1660 if ( !configuration.isUseNativeUI() ) {
1661 label.setBackground( configuration.getGuiMenuBackgroundColor() );
1662 label.setForeground( configuration.getGuiMenuTextColor() );
1663 label.setOpaque( true );
1665 label.setSelected( false );
1666 label.setEnabled( false );
1670 static void cycleNodeFill( final Options op, final TreePanel tree_panel ) {
1671 switch ( op.getDefaultNodeFill() ) {
1673 op.setDefaultNodeFill( NodeFill.SOLID );
1676 op.setDefaultNodeFill( NodeFill.GRADIENT );
1679 op.setDefaultNodeFill( NodeFill.NONE );
1682 throw new RuntimeException( "unknown fill: " + op.getDefaultNodeFill() );
1686 static void cycleNodeShape( final Options op, final TreePanel tree_panel ) {
1687 switch ( op.getDefaultNodeShape() ) {
1689 op.setDefaultNodeShape( NodeShape.RECTANGLE );
1692 op.setDefaultNodeShape( NodeShape.CIRCLE );
1695 throw new RuntimeException( "unknown shape: " + op.getDefaultNodeShape() );
1699 static void cycleOverview( final Options op, final TreePanel tree_panel ) {
1700 switch ( op.getOvPlacement() ) {
1702 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1705 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1708 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1711 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1714 throw new RuntimeException( "unknown placement: " + op.getOvPlacement() );
1716 if ( tree_panel != null ) {
1717 tree_panel.updateOvSettings();
1721 static void setCycleNodeFillMenuItem( final JMenuItem mi, final Options options ) {
1722 if ( ( options != null ) && ( options.getDefaultNodeFill() != null ) ) {
1723 mi.setText( "Cycle Node Shape Fill Type... (current: "
1724 + options.getDefaultNodeFill().toString().toLowerCase() + ")" );
1727 mi.setText( "Cycle Node Shape Fill Type..." );
1731 static void setCycleNodeShapeMenuItem( final JMenuItem mi, final Options options ) {
1732 if ( ( options != null ) && ( options.getDefaultNodeShape() != null ) ) {
1733 mi.setText( "Cycle Node Shape Fill Type... (current: "
1734 + options.getDefaultNodeShape().toString().toLowerCase() + ")" );
1737 mi.setText( "Cycle Node Shape Fill Type..." );
1741 static void setOvPlacementColorChooseMenuItem( final JMenuItem mi, final Options options ) {
1742 if ( ( options != null ) && ( options.getOvPlacement() != null ) ) {
1743 mi.setText( "Cycle Overview Placement... (current: " + options.getOvPlacement() + ")" );
1746 mi.setText( "Cycle Overview Placement..." );
1750 static void setTextColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {
1751 if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {
1752 mi.setText( "Select Colors... (current: " + tree_panel.getTreeColorSet().getCurrentColorSchemeName() + ")" );
1755 mi.setText( "Select Colors..." );
1759 static void setTextForFontChooserMenuItem( final JMenuItem mi, final String font_desc ) {
1760 mi.setText( "Select Font... (current: " + font_desc + ")" );
1763 static void setTextMinSupportMenuItem( final JMenuItem mi, final Options options, final TreePanel current_tree_panel ) {
1764 if ( ( current_tree_panel == null ) || ( current_tree_panel.getPhylogeny() == null ) ) {
1765 mi.setEnabled( true );
1767 else if ( AptxUtil.isHasAtLeastOneBranchWithSupportValues( current_tree_panel.getPhylogeny() ) ) {
1768 mi.setEnabled( true );
1771 mi.setEnabled( false );
1773 mi.setText( "Enter Min Confidence Value... (current: " + options.getMinConfidenceValue() + ")" );
1776 static void setTextNodeSizeMenuItem( final JMenuItem mi, final Options options ) {
1777 mi.setText( "Enter Default Node Shape Size... (current: " + options.getDefaultNodeShapeSize() + ")" );
1780 static void updateOptionsMenuDependingOnPhylogenyType( final MainPanel main_panel,
1781 final JCheckBoxMenuItem scale,
1782 final JCheckBoxMenuItem branch_lengths,
1783 final JRadioButtonMenuItem non_lined_up,
1784 final JRadioButtonMenuItem uniform_clado,
1785 final JRadioButtonMenuItem nonuniform_clado,
1786 final JCheckBoxMenuItem label_direction_cbmi ) {
1787 final TreePanel tree_panel = main_panel.getCurrentTreePanel();
1788 final ControlPanel control = main_panel.getControlPanel();
1789 final Options options = main_panel.getOptions();
1790 scale.setSelected( options.isShowScale() );
1791 branch_lengths.setSelected( options.isShowBranchLengthValues() );
1792 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1793 if ( ( tree_panel != null ) && ( !tree_panel.isPhyHasBranchLengths() ) ) {
1794 scale.setSelected( false );
1795 scale.setEnabled( false );
1796 branch_lengths.setSelected( false );
1797 branch_lengths.setEnabled( false );
1799 else if ( ( tree_panel != null ) && !control.isDrawPhylogram() ) {
1800 scale.setSelected( false );
1801 scale.setEnabled( false );
1802 branch_lengths.setEnabled( true );
1805 scale.setEnabled( true );
1806 branch_lengths.setEnabled( true );
1808 if ( ( tree_panel != null )
1809 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.ROUNDED )
1810 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1811 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1812 branch_lengths.setSelected( false );
1813 branch_lengths.setEnabled( false );
1815 if ( tree_panel != null ) {
1816 if ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1817 || ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
1818 non_lined_up.setEnabled( false );
1819 uniform_clado.setEnabled( false );
1820 nonuniform_clado.setEnabled( false );
1823 non_lined_up.setEnabled( true );
1824 uniform_clado.setEnabled( true );
1825 nonuniform_clado.setEnabled( true );
1829 if ( ( tree_panel != null )
1830 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1831 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1832 branch_lengths.setSelected( false );
1833 branch_lengths.setEnabled( false );
1835 if ( ( tree_panel != null )
1836 && ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( tree_panel
1837 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
1838 non_lined_up.setEnabled( false );
1841 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1842 non_lined_up.setEnabled( true );
1845 label_direction_cbmi.setEnabled( true );
1846 if ( tree_panel != null ) {
1847 if ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1848 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1849 label_direction_cbmi.setEnabled( false );
1851 if ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
1852 scale.setSelected( false );
1853 scale.setEnabled( false );
1858 static void updateScreenTextAntialias( final List<TreePanel> treepanels ) {
1859 for( final TreePanel tree_panel : treepanels ) {
1860 tree_panel.setTextAntialias();