rio, lca, refactoring
[jalview.git] / forester / java / src / org / forester / archaeopteryx / MainFrame.java
1 // $Id:
2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
4 //
5 // Copyright (C) 2008-2010 Christian M. Zmasek
6 // All rights reserved
7 //
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.
12 //
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.
17 //
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
21 //
22 // Contact: phylosoft @ gmail . com
23 // WWW: www.phylosoft.org/forester
24
25 package org.forester.archaeopteryx;
26
27 import java.awt.Color;
28 import java.awt.Component;
29 import java.awt.Container;
30 import java.awt.Font;
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
33 import java.io.IOException;
34 import java.util.LinkedList;
35 import java.util.List;
36 import java.util.Locale;
37 import java.util.Map;
38 import java.util.NoSuchElementException;
39
40 import javax.swing.JApplet;
41 import javax.swing.JCheckBoxMenuItem;
42 import javax.swing.JFrame;
43 import javax.swing.JMenu;
44 import javax.swing.JMenuBar;
45 import javax.swing.JMenuItem;
46 import javax.swing.JOptionPane;
47 import javax.swing.JRadioButtonMenuItem;
48 import javax.swing.SwingUtilities;
49
50 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
51 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
52 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
53 import org.forester.archaeopteryx.tools.InferenceManager;
54 import org.forester.archaeopteryx.tools.ProcessPool;
55 import org.forester.archaeopteryx.tools.ProcessRunning;
56 import org.forester.phylogeny.Phylogeny;
57 import org.forester.phylogeny.PhylogenyNodeI.NH_CONVERSION_SUPPORT_VALUE_STYLE;
58 import org.forester.phylogeny.data.NodeVisualization.NodeFill;
59 import org.forester.phylogeny.data.NodeVisualization.NodeShape;
60 import org.forester.util.ForesterConstants;
61 import org.forester.util.ForesterUtil;
62
63 public abstract class MainFrame extends JFrame implements ActionListener {
64
65     static final String         USE_MOUSEWHEEL_SHIFT_TO_ROTATE          = "In this display type, use mousewheel + Shift to rotate [or A and S]";
66     static final String         PHYLOXML_REF_TOOL_TIP                   = Constants.PHYLOXML_REFERENCE;                                                                                                                                       //TODO //FIXME
67     static final String         APTX_REF_TOOL_TIP                       = Constants.APTX_REFERENCE;
68     private static final long   serialVersionUID                        = 3655000897845508358L;
69     final static Font           menu_font                               = new Font( Configuration.getDefaultFontFamilyName(),
70                                                                                     Font.PLAIN,
71                                                                                     10 );
72     static final String         TYPE_MENU_HEADER                        = "Type";
73     static final String         RECTANGULAR_TYPE_CBMI_LABEL             = "Rectangular";
74     static final String         EURO_TYPE_CBMI_LABEL                    = "Euro Type";
75     static final String         CURVED_TYPE_CBMI_LABEL                  = "Curved";
76     static final String         TRIANGULAR_TYPE_CBMI_LABEL              = "Triangular";
77     static final String         CONVEX_TYPE_CBMI_LABEL                  = "Convex";
78     static final String         ROUNDED_TYPE_CBMI_LABEL                 = "Rounded";
79     static final String         UNROOTED_TYPE_CBMI_LABEL                = "Unrooted (alpha)";                                                                                                                                                 //TODO
80     static final String         CIRCULAR_TYPE_CBMI_LABEL                = "Circular (alpha)";                                                                                                                                                 //TODO
81     static final String         OPTIONS_HEADER                          = "Options";
82     static final String         SEARCH_SUBHEADER                        = "Search:";
83     static final String         DISPLAY_SUBHEADER                       = "Display:";
84     static final String         SEARCH_TERMS_ONLY_LABEL                 = "Match Complete Terms Only";
85     static final String         SEARCH_CASE_SENSITIVE_LABEL             = "Case Sensitive";
86     static final String         INVERSE_SEARCH_RESULT_LABEL             = "Negate Result";
87     static final String         DISPLAY_BRANCH_LENGTH_VALUES_LABEL      = "Display Branch Length Values";
88     static final String         DISPLAY_SCALE_LABEL                     = "Display Scale";
89     static final String         NON_LINED_UP_CLADOGRAMS_LABEL           = "Non-Lined Up Cladograms";
90     static final String         UNIFORM_CLADOGRAMS_LABEL                = "Total Node Sum Dependent Cladograms";
91     static final String         LABEL_DIRECTION_LABEL                   = "Radial Labels";
92     static final String         LABEL_DIRECTION_TIP                     = "To use radial node labels in radial and unrooted display types";
93     static final String         SCREEN_ANTIALIAS_LABEL                  = "Antialias";
94     static final String         COLOR_LABELS_LABEL                      = "Colorize Labels Same as Parent Branch";
95     static final String         BG_GRAD_LABEL                           = "Background Color Gradient";
96     static final String         DISPLAY_NODE_BOXES_LABEL                = "Show Node Shapes";
97     static final String         SHOW_OVERVIEW_LABEL                     = "Show Overview";
98     static final String         FONT_SIZE_MENU_LABEL                    = "Font Size";
99     static final String         NONUNIFORM_CLADOGRAMS_LABEL             = "External Node Sum Dependent Cladograms";
100     static final String         SHOW_DOMAIN_LABELS_LABEL                = "Show Domain Labels";
101     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";
102     static final String         ABBREV_SN_LABEL                         = "Abbreviate Scientific Taxonomic Names";
103     static final String         TAXONOMY_COLORIZE_NODE_SHAPES_LABEL     = "Colorize Node Shapes According to Taxonomy";
104     static final String         CYCLE_NODE_SHAPE_LABEL                  = "Cycle Node Shapes";
105     static final String         CYCLE_NODE_FILL_LABEL                   = "Cycle Node Fill Type";
106     static final String         CHOOSE_NODE_SIZE_LABEL                  = "Choose Node Shape Size";
107     static final String         SHOW_CONF_STDDEV_LABEL                  = "Show Confidence Standard Deviations";
108     static final String         USE_BRACKETS_FOR_CONF_IN_NH_LABEL       = "Use Brackets for Confidence Values";
109     static final String         USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL = "Use Internal Node Names for Confidence Values";
110     JMenuBar                    _jmenubar;
111     JMenu                       _file_jmenu;
112     JMenu                       _tools_menu;
113     JMenu                       _view_jmenu;
114     JMenu                       _options_jmenu;
115     JMenu                       _font_size_menu;
116     JMenu                       _help_jmenu;
117     JMenuItem[]                 _load_phylogeny_from_webservice_menu_items;
118     // file menu:
119     JMenuItem                   _open_item;
120     JMenuItem                   _open_url_item;
121     JMenuItem                   _save_item;
122     JMenuItem                   _save_all_item;
123     JMenuItem                   _close_item;
124     JMenuItem                   _exit_item;
125     JMenuItem                   _new_item;
126     // tools menu:
127     JMenuItem                   _midpoint_root_item;
128     JMenuItem                   _taxcolor_item;
129     JMenuItem                   _confcolor_item;
130     JMenuItem                   _color_rank_jmi;
131     JMenuItem                   _infer_common_sn_names_item;
132     JMenuItem                   _collapse_species_specific_subtrees;
133     JMenuItem                   _collapse_below_threshold;                                                                                                                                                                                    //TODO implememt me
134     JMenuItem                   _obtain_detailed_taxonomic_information_jmi;
135     JMenuItem                   _obtain_detailed_taxonomic_information_deleting_jmi;
136     JMenuItem                   _obtain_uniprot_seq_information_jmi;
137     JMenuItem                   _move_node_names_to_tax_sn_jmi;
138     JMenuItem                   _move_node_names_to_seq_names_jmi;
139     JMenuItem                   _extract_tax_code_from_node_names_jmi;
140     // font size menu:
141     JMenuItem                   _super_tiny_fonts_item;
142     JMenuItem                   _tiny_fonts_item;
143     JMenuItem                   _small_fonts_item;
144     JMenuItem                   _medium_fonts_item;
145     JMenuItem                   _large_fonts_item;
146     // options menu:
147     // _  screen and print
148     JMenuItem                   _choose_font_mi;
149     JMenuItem                   _switch_colors_mi;
150     JCheckBoxMenuItem           _label_direction_cbmi;
151     // _  screen display
152     JCheckBoxMenuItem           _screen_antialias_cbmi;
153     JCheckBoxMenuItem           _background_gradient_cbmi;
154     JRadioButtonMenuItem        _non_lined_up_cladograms_rbmi;
155     JRadioButtonMenuItem        _uniform_cladograms_rbmi;
156     JRadioButtonMenuItem        _ext_node_dependent_cladogram_rbmi;
157     JCheckBoxMenuItem           _show_branch_length_values_cbmi;
158     JCheckBoxMenuItem           _show_scale_cbmi;                                                                                                                                                                                             //TODO fix me
159     JCheckBoxMenuItem           _show_overview_cbmi;
160     JCheckBoxMenuItem           _show_domain_labels;
161     JCheckBoxMenuItem           _abbreviate_scientific_names;
162     JCheckBoxMenuItem           _color_labels_same_as_parent_branch;
163     JMenuItem                   _overview_placment_mi;
164     JMenuItem                   _choose_minimal_confidence_mi;
165     JCheckBoxMenuItem           _show_default_node_shapes_cbmi;
166     JMenuItem                   _cycle_node_shape_mi;
167     JMenuItem                   _cycle_node_fill_mi;
168     JMenuItem                   _choose_node_size_mi;
169     JCheckBoxMenuItem           _taxonomy_colorize_node_shapes_cbmi;
170     JCheckBoxMenuItem           _show_confidence_stddev_cbmi;
171     // _  print
172     JCheckBoxMenuItem           _graphics_export_visible_only_cbmi;
173     JCheckBoxMenuItem           _antialias_print_cbmi;
174     JCheckBoxMenuItem           _print_black_and_white_cbmi;
175     JCheckBoxMenuItem           _print_using_actual_size_cbmi;
176     JCheckBoxMenuItem           _graphics_export_using_actual_size_cbmi;
177     JMenuItem                   _print_size_mi;
178     JMenuItem                   _choose_pdf_width_mi;
179     // _  parsing
180     JCheckBoxMenuItem           _internal_number_are_confidence_for_nh_parsing_cbmi;
181     JCheckBoxMenuItem           _extract_pfam_style_tax_codes_cbmi;
182     JCheckBoxMenuItem           _replace_underscores_cbmi;
183     JCheckBoxMenuItem           _use_brackets_for_conf_in_nh_export_cbmi;
184     JCheckBoxMenuItem           _use_internal_names_for_conf_in_nh_export_cbmi;
185     // _  search
186     JCheckBoxMenuItem           _search_case_senstive_cbmi;
187     JCheckBoxMenuItem           _search_whole_words_only_cbmi;
188     JCheckBoxMenuItem           _inverse_search_result_cbmi;
189     // type menu:
190     JMenu                       _type_menu;
191     JCheckBoxMenuItem           _rectangular_type_cbmi;
192     JCheckBoxMenuItem           _triangular_type_cbmi;
193     JCheckBoxMenuItem           _curved_type_cbmi;
194     JCheckBoxMenuItem           _convex_type_cbmi;
195     JCheckBoxMenuItem           _euro_type_cbmi;
196     JCheckBoxMenuItem           _rounded_type_cbmi;
197     JCheckBoxMenuItem           _unrooted_type_cbmi;
198     JCheckBoxMenuItem           _circular_type_cbmi;
199     // view as text menu:
200     JMenuItem                   _view_as_NH_item;
201     JMenuItem                   _view_as_NHX_item;
202     JMenuItem                   _view_as_XML_item;
203     JMenuItem                   _view_as_nexus_item;
204     JMenuItem                   _display_basic_information_item;
205     // help menu:
206     JMenuItem                   _about_item;
207     JMenuItem                   _help_item;
208     JMenuItem                   _website_item;
209     JMenuItem                   _phyloxml_website_item;
210     JMenuItem                   _phyloxml_ref_item;
211     JMenuItem                   _aptx_ref_item;
212     // process menu:
213     JMenu                       _process_menu;
214     // Handy pointers to child components:
215     MainPanel                   _mainpanel;
216     Container                   _contentpane;
217     final LinkedList<TextFrame> _textframes                             = new LinkedList<TextFrame>();                                                                                                                                         ;
218     Configuration               _configuration;
219     JMenuItem                   _remove_branch_color_item;
220     Options                     _options;
221     InferenceManager            _inference_manager;
222     final ProcessPool           _process_pool;
223
224     MainFrame() {
225         _process_pool = ProcessPool.createInstance();
226     }
227
228     public ProcessPool getProcessPool() {
229         return _process_pool;
230     }
231
232     /**
233      * Action performed.
234      */
235     @Override
236     public void actionPerformed( final ActionEvent e ) {
237         final Object o = e.getSource();
238         boolean is_applet = false;
239         JApplet applet = null;
240         if ( getCurrentTreePanel() != null ) {
241             is_applet = getCurrentTreePanel().isApplet();
242             if ( is_applet ) {
243                 applet = getCurrentTreePanel().obtainApplet();
244             }
245         }
246         if ( o == _open_url_item ) {
247             readPhylogeniesFromURL();
248         }
249         else if ( o == _exit_item ) {
250             close();
251         }
252         else if ( o == _taxcolor_item ) {
253             taxColor();
254         }
255         else if ( o == _confcolor_item ) {
256             confColor();
257         }
258         else if ( o == _color_rank_jmi ) {
259             colorRank();
260         }
261         else if ( o == _infer_common_sn_names_item ) {
262             if ( isSubtreeDisplayed() ) {
263                 return;
264             }
265             if ( getCurrentTreePanel() != null ) {
266                 getCurrentTreePanel().inferCommonPartOfScientificNames();
267             }
268         }
269         else if ( o == _collapse_species_specific_subtrees ) {
270             if ( isSubtreeDisplayed() ) {
271                 return;
272             }
273             if ( getCurrentTreePanel() != null ) {
274                 getCurrentTreePanel().collapseSpeciesSpecificSubtrees();
275             }
276         }
277         else if ( o == _remove_branch_color_item ) {
278             if ( isSubtreeDisplayed() ) {
279                 return;
280             }
281             removeBranchColors();
282         }
283         else if ( o == _midpoint_root_item ) {
284             if ( isSubtreeDisplayed() ) {
285                 return;
286             }
287             midpointRoot();
288         }
289         else if ( o == _switch_colors_mi ) {
290             switchColors();
291         }
292         else if ( o == _display_basic_information_item ) {
293             displayBasicInformation();
294         }
295         else if ( o == _view_as_NH_item ) {
296             viewAsNH();
297         }
298         else if ( o == _view_as_NHX_item ) {
299             viewAsNHX();
300         }
301         else if ( o == _view_as_XML_item ) {
302             viewAsXML();
303         }
304         else if ( o == _view_as_nexus_item ) {
305             viewAsNexus();
306         }
307         else if ( o == _super_tiny_fonts_item ) {
308             if ( getCurrentTreePanel() != null ) {
309                 getCurrentTreePanel().setSuperTinyFonts();
310                 getCurrentTreePanel().repaint();
311             }
312         }
313         else if ( o == _tiny_fonts_item ) {
314             if ( getCurrentTreePanel() != null ) {
315                 getCurrentTreePanel().setTinyFonts();
316                 getCurrentTreePanel().repaint();
317             }
318         }
319         else if ( o == _small_fonts_item ) {
320             if ( getCurrentTreePanel() != null ) {
321                 getCurrentTreePanel().setSmallFonts();
322                 getCurrentTreePanel().repaint();
323             }
324         }
325         else if ( o == _medium_fonts_item ) {
326             if ( getCurrentTreePanel() != null ) {
327                 getCurrentTreePanel().setMediumFonts();
328                 getCurrentTreePanel().repaint();
329             }
330         }
331         else if ( o == _large_fonts_item ) {
332             if ( getCurrentTreePanel() != null ) {
333                 getCurrentTreePanel().setLargeFonts();
334                 getCurrentTreePanel().repaint();
335             }
336         }
337         else if ( o == _choose_font_mi ) {
338             chooseFont();
339         }
340         else if ( o == _choose_minimal_confidence_mi ) {
341             chooseMinimalConfidence();
342         }
343         else if ( o == _choose_node_size_mi ) {
344             chooseNodeSize( getOptions(), this );
345         }
346         else if ( o == _overview_placment_mi ) {
347             MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
348         }
349         else if ( o == _cycle_node_fill_mi ) {
350             MainFrame.cycleNodeFill( getOptions(), getCurrentTreePanel() );
351         }
352         else if ( o == _cycle_node_shape_mi ) {
353             MainFrame.cycleNodeShape( getOptions(), getCurrentTreePanel() );
354         }
355         else if ( o == _screen_antialias_cbmi ) {
356             updateOptions( getOptions() );
357             updateScreenTextAntialias( getMainPanel().getTreePanels() );
358         }
359         else if ( o == _background_gradient_cbmi ) {
360             updateOptions( getOptions() );
361         }
362         else if ( o == _show_domain_labels ) {
363             updateOptions( getOptions() );
364         }
365         else if ( o == _abbreviate_scientific_names ) {
366             updateOptions( getOptions() );
367         }
368         else if ( o == _color_labels_same_as_parent_branch ) {
369             updateOptions( getOptions() );
370         }
371         else if ( o == _show_default_node_shapes_cbmi ) {
372             updateOptions( getOptions() );
373         }
374         else if ( o == _taxonomy_colorize_node_shapes_cbmi ) {
375             updateOptions( getOptions() );
376         }
377         else if ( o == _non_lined_up_cladograms_rbmi ) {
378             updateOptions( getOptions() );
379             showWhole();
380         }
381         else if ( o == _uniform_cladograms_rbmi ) {
382             updateOptions( getOptions() );
383             showWhole();
384         }
385         else if ( o == _ext_node_dependent_cladogram_rbmi ) {
386             updateOptions( getOptions() );
387             showWhole();
388         }
389         else if ( o == _search_case_senstive_cbmi ) {
390             updateOptions( getOptions() );
391             getMainPanel().getControlPanel().search();
392         }
393         else if ( o == _search_whole_words_only_cbmi ) {
394             updateOptions( getOptions() );
395             getMainPanel().getControlPanel().search();
396         }
397         else if ( o == _inverse_search_result_cbmi ) {
398             updateOptions( getOptions() );
399             getMainPanel().getControlPanel().search();
400         }
401         else if ( o == _show_scale_cbmi ) {
402             updateOptions( getOptions() );
403         }
404         else if ( o == _show_branch_length_values_cbmi ) {
405             updateOptions( getOptions() );
406         }
407         else if ( o == _show_confidence_stddev_cbmi ) {
408             updateOptions( getOptions() );
409         }
410         else if ( o == _use_brackets_for_conf_in_nh_export_cbmi ) {
411             if ( _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {
412                 _use_internal_names_for_conf_in_nh_export_cbmi.setSelected( false );
413             }
414             updateOptions( getOptions() );
415         }
416         else if ( o == _use_internal_names_for_conf_in_nh_export_cbmi ) {
417             if ( _use_internal_names_for_conf_in_nh_export_cbmi.isSelected() ) {
418                 _use_brackets_for_conf_in_nh_export_cbmi.setSelected( false );
419             }
420             updateOptions( getOptions() );
421         }
422         else if ( o == _label_direction_cbmi ) {
423             updateOptions( getOptions() );
424         }
425         else if ( o == _show_overview_cbmi ) {
426             updateOptions( getOptions() );
427             if ( getCurrentTreePanel() != null ) {
428                 getCurrentTreePanel().updateOvSizes();
429             }
430         }
431         else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
432                 || ( o == _convex_type_cbmi ) || ( o == _euro_type_cbmi ) || ( o == _rounded_type_cbmi )
433                 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
434             typeChanged( o );
435         }
436         else if ( o == _about_item ) {
437             about();
438         }
439         else if ( o == _help_item ) {
440             help( getConfiguration().getWebLinks() );
441         }
442         else if ( o == _website_item ) {
443             try {
444                 AptxUtil.openWebsite( Constants.APTX_WEB_SITE, is_applet, applet );
445             }
446             catch ( final IOException e1 ) {
447                 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
448             }
449         }
450         else if ( o == _phyloxml_website_item ) {
451             try {
452                 AptxUtil.openWebsite( Constants.PHYLOXML_WEB_SITE, is_applet, applet );
453             }
454             catch ( final IOException e1 ) {
455                 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
456             }
457         }
458         else if ( o == _aptx_ref_item ) {
459             try {
460                 AptxUtil.openWebsite( Constants.APTX_REFERENCE_URL, is_applet, applet );
461             }
462             catch ( final IOException e1 ) {
463                 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
464             }
465         }
466         else if ( o == _phyloxml_ref_item ) {
467             try {
468                 AptxUtil.openWebsite( Constants.PHYLOXML_REFERENCE_URL, is_applet, applet );
469             }
470             catch ( final IOException e1 ) {
471                 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
472             }
473         }
474         else {
475             if ( _load_phylogeny_from_webservice_menu_items != null ) {
476                 for( int i = 0; i < _load_phylogeny_from_webservice_menu_items.length; ++i ) {
477                     if ( o == _load_phylogeny_from_webservice_menu_items[ i ] ) {
478                         readPhylogeniesFromWebservice( i );
479                     }
480                 }
481             }
482         }
483         _contentpane.repaint();
484     }
485
486     boolean isSubtreeDisplayed() {
487         if ( getCurrentTreePanel() != null ) {
488             if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
489                 JOptionPane
490                         .showMessageDialog( this,
491                                             "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",
492                                             "Operation can not be exectuted on a sub-tree",
493                                             JOptionPane.WARNING_MESSAGE );
494                 return true;
495             }
496         }
497         return false;
498     }
499
500     void activateSaveAllIfNeeded() {
501         if ( ( getMainPanel().getTabbedPane() != null ) && ( getMainPanel().getTabbedPane().getTabCount() > 1 ) ) {
502             _save_all_item.setEnabled( true );
503         }
504         else {
505             _save_all_item.setEnabled( false );
506         }
507     }
508
509     void buildFileMenu() {
510         _file_jmenu = createMenu( "File", getConfiguration() );
511         _file_jmenu.add( _open_url_item = new JMenuItem( "Read tree from URL/webservice..." ) );
512         _file_jmenu.addSeparator();
513         _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );
514         customizeJMenuItem( _open_url_item );
515         customizeJMenuItem( _exit_item );
516         _jmenubar.add( _file_jmenu );
517     }
518
519     void buildFontSizeMenu() {
520         _font_size_menu = createMenu( FONT_SIZE_MENU_LABEL, getConfiguration() );
521         _font_size_menu.add( _super_tiny_fonts_item = new JMenuItem( "Super Tiny Fonts" ) );
522         _font_size_menu.add( _tiny_fonts_item = new JMenuItem( "Tiny Fonts" ) );
523         _font_size_menu.add( _small_fonts_item = new JMenuItem( "Small Fonts" ) );
524         _font_size_menu.add( _medium_fonts_item = new JMenuItem( "Medium Fonts" ) );
525         _font_size_menu.add( _large_fonts_item = new JMenuItem( "Large Fonts" ) );
526         customizeJMenuItem( _super_tiny_fonts_item );
527         customizeJMenuItem( _tiny_fonts_item );
528         customizeJMenuItem( _small_fonts_item );
529         customizeJMenuItem( _medium_fonts_item );
530         customizeJMenuItem( _large_fonts_item );
531         _jmenubar.add( _font_size_menu );
532     }
533
534     void buildHelpMenu() {
535         _help_jmenu = createMenu( "Help", getConfiguration() );
536         _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
537         _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
538         _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
539         _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
540         _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
541         _help_jmenu.addSeparator();
542         _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
543         customizeJMenuItem( _help_item );
544         customizeJMenuItem( _website_item );
545         customizeJMenuItem( _phyloxml_website_item );
546         customizeJMenuItem( _aptx_ref_item );
547         customizeJMenuItem( _phyloxml_ref_item );
548         customizeJMenuItem( _about_item );
549         _phyloxml_ref_item.setToolTipText( PHYLOXML_REF_TOOL_TIP );
550         _aptx_ref_item.setToolTipText( APTX_REF_TOOL_TIP );
551         _jmenubar.add( _help_jmenu );
552     }
553
554     public void updateProcessMenu() {
555         // In general Swing is not thread safe.
556         // See "Swing's Threading Policy".
557         SwingUtilities.invokeLater( new Runnable() {
558
559             @Override
560             public void run() {
561                 doUpdateProcessMenu();
562             }
563         } );
564     }
565
566     private void doUpdateProcessMenu() {
567         if ( _process_pool.size() > 0 ) {
568             if ( _process_menu == null ) {
569                 _process_menu = createMenu( "", getConfiguration() );
570                 _process_menu.setForeground( Color.RED );
571             }
572             _process_menu.removeAll();
573             final String text = "processes running: " + _process_pool.size();
574             _process_menu.setText( text );
575             _jmenubar.add( _process_menu );
576             for( int i = 0; i < _process_pool.size(); ++i ) {
577                 final ProcessRunning p = _process_pool.getProcessByIndex( i );
578                 _process_menu.add( customizeJMenuItem( new JMenuItem( p.getName() + " [" + p.getStart() + "]" ) ) );
579             }
580         }
581         else {
582             if ( _process_menu != null ) {
583                 _process_menu.removeAll();
584                 _jmenubar.remove( _process_menu );
585             }
586         }
587         _jmenubar.validate();
588         _jmenubar.repaint();
589         repaint();
590     }
591
592     void buildTypeMenu() {
593         _type_menu = createMenu( TYPE_MENU_HEADER, getConfiguration() );
594         _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
595         _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
596         _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
597         _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
598         _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
599         _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
600         _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
601         _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
602         customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
603         customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
604         customizeCheckBoxMenuItem( _euro_type_cbmi, false );
605         customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
606         customizeCheckBoxMenuItem( _curved_type_cbmi, false );
607         customizeCheckBoxMenuItem( _convex_type_cbmi, false );
608         customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
609         customizeCheckBoxMenuItem( _circular_type_cbmi, false );
610         _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
611         _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
612         initializeTypeMenu( getOptions() );
613         _jmenubar.add( _type_menu );
614     }
615
616     void buildViewMenu() {
617         _view_jmenu = createMenu( "View", getConfiguration() );
618         _view_jmenu.add( _display_basic_information_item = new JMenuItem( "Display Basic Information" ) );
619         _view_jmenu.addSeparator();
620         _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) );
621         _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) );
622         _view_jmenu.add( _view_as_NHX_item = new JMenuItem( "View as NHX" ) );
623         _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "View as Nexus" ) );
624         customizeJMenuItem( _display_basic_information_item );
625         customizeJMenuItem( _view_as_NH_item );
626         customizeJMenuItem( _view_as_NHX_item );
627         customizeJMenuItem( _view_as_XML_item );
628         customizeJMenuItem( _view_as_nexus_item );
629         _jmenubar.add( _view_jmenu );
630     }
631
632     private void chooseFont() {
633         final FontChooser fc = new FontChooser();
634         fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
635         fc.showDialog( this, "Select the Base Font" );
636         getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
637     }
638
639     private void chooseMinimalConfidence() {
640         final String s = ( String ) JOptionPane
641                 .showInputDialog( this,
642                                   "Please enter the minimum for confidence values to be displayed.\n"
643                                           + "[current value: " + getOptions().getMinConfidenceValue() + "]\n",
644                                   "Minimal Confidence Value",
645                                   JOptionPane.QUESTION_MESSAGE,
646                                   null,
647                                   null,
648                                   getOptions().getMinConfidenceValue() );
649         if ( !ForesterUtil.isEmpty( s ) ) {
650             boolean success = true;
651             double m = 0.0;
652             final String m_str = s.trim();
653             if ( !ForesterUtil.isEmpty( m_str ) ) {
654                 try {
655                     m = Double.parseDouble( m_str );
656                 }
657                 catch ( final Exception ex ) {
658                     success = false;
659                 }
660             }
661             else {
662                 success = false;
663             }
664             if ( success && ( m >= 0.0 ) ) {
665                 getOptions().setMinConfidenceValue( m );
666             }
667         }
668     }
669
670     static void chooseNodeSize( final Options options, final Component parent ) {
671         final String s = ( String ) JOptionPane.showInputDialog( parent,
672                                                                  "Please enter the default size for node shapes.\n"
673                                                                          + "[current value: "
674                                                                          + options.getDefaultNodeShapeSize() + "]\n",
675                                                                  "Node Shape Size",
676                                                                  JOptionPane.QUESTION_MESSAGE,
677                                                                  null,
678                                                                  null,
679                                                                  options.getDefaultNodeShapeSize() );
680         if ( !ForesterUtil.isEmpty( s ) ) {
681             boolean success = true;
682             double m = 0.0;
683             final String m_str = s.trim();
684             if ( !ForesterUtil.isEmpty( m_str ) ) {
685                 try {
686                     m = Double.parseDouble( m_str );
687                 }
688                 catch ( final Exception ex ) {
689                     success = false;
690                 }
691             }
692             else {
693                 success = false;
694             }
695             if ( success && ( m >= 0.0 ) ) {
696                 final short size = ForesterUtil.roundToShort( m );
697                 if ( size >= 0.0 ) {
698                     options.setDefaultNodeShapeSize( size );
699                 }
700             }
701         }
702     }
703
704     void close() {
705         removeAllTextFrames();
706         if ( _mainpanel != null ) {
707             _mainpanel.terminate();
708         }
709         if ( _contentpane != null ) {
710             _contentpane.removeAll();
711         }
712         setVisible( false );
713         dispose();
714     }
715
716     void confColor() {
717         if ( _mainpanel.getCurrentTreePanel() != null ) {
718             _mainpanel.getCurrentTreePanel().confColor();
719         }
720     }
721
722     void colorRank() {
723         if ( _mainpanel.getCurrentTreePanel() != null ) {
724             final String[] ranks = AptxUtil.getAllPossibleRanks();
725             final String rank = ( String ) JOptionPane
726                     .showInputDialog( this,
727                                       "What rank should the colorization be based on",
728                                       "Rank Selection",
729                                       JOptionPane.QUESTION_MESSAGE,
730                                       null,
731                                       ranks,
732                                       null );
733             if ( !ForesterUtil.isEmpty( rank ) ) {
734                 _mainpanel.getCurrentTreePanel().colorRank( rank );
735             }
736         }
737     }
738
739     void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
740         if ( item != null ) {
741             item.setFont( MainFrame.menu_font );
742             if ( !getConfiguration().isUseNativeUI() ) {
743                 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
744                 item.setForeground( getConfiguration().getGuiMenuTextColor() );
745             }
746             item.setSelected( is_selected );
747             item.addActionListener( this );
748         }
749     }
750
751     JMenuItem customizeJMenuItem( final JMenuItem jmi ) {
752         if ( jmi != null ) {
753             jmi.setFont( MainFrame.menu_font );
754             if ( !getConfiguration().isUseNativeUI() ) {
755                 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
756                 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
757             }
758             jmi.addActionListener( this );
759         }
760         return jmi;
761     }
762
763     void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
764         if ( item != null ) {
765             item.setFont( MainFrame.menu_font );
766             if ( !getConfiguration().isUseNativeUI() ) {
767                 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
768                 item.setForeground( getConfiguration().getGuiMenuTextColor() );
769             }
770             item.setSelected( is_selected );
771             item.addActionListener( this );
772         }
773     }
774
775     void exceptionOccuredDuringOpenFile( final Exception e ) {
776         try {
777             _mainpanel.getCurrentTreePanel().setArrowCursor();
778         }
779         catch ( final Exception ex ) {
780             // Do nothing.
781         }
782         JOptionPane.showMessageDialog( this,
783                                        ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
784                                        "Error during File|Open",
785                                        JOptionPane.ERROR_MESSAGE );
786     }
787
788     void exceptionOccuredDuringSaveAs( final Exception e ) {
789         try {
790             _mainpanel.getCurrentTreePanel().setArrowCursor();
791         }
792         catch ( final Exception ex ) {
793             // Do nothing.
794         }
795         JOptionPane.showMessageDialog( this, "Exception" + e, "Error during File|SaveAs", JOptionPane.ERROR_MESSAGE );
796     }
797
798     boolean GAndSDoHaveMoreThanOneSpeciesInComman( final Phylogeny gene_tree ) {
799         if ( ( gene_tree == null ) || gene_tree.isEmpty() ) {
800             JOptionPane.showMessageDialog( this,
801                                            "Gene tree and species tree have no species in common.",
802                                            "Error during SDI",
803                                            JOptionPane.ERROR_MESSAGE );
804             return false;
805         }
806         else if ( gene_tree.getNumberOfExternalNodes() < 2 ) {
807             JOptionPane.showMessageDialog( this,
808                                            "Gene tree and species tree have only one species in common.",
809                                            "Error during SDI",
810                                            JOptionPane.ERROR_MESSAGE );
811             return false;
812         }
813         else {
814             return true;
815         }
816     }
817
818     public Configuration getConfiguration() {
819         return _configuration;
820     }
821
822     TreePanel getCurrentTreePanel() {
823         return getMainPanel().getCurrentTreePanel();
824     }
825
826     JMenu getHelpMenu() {
827         return _help_jmenu;
828     }
829
830     JCheckBoxMenuItem getlabelDirectionCbmi() {
831         return _label_direction_cbmi;
832     }
833
834     public MainPanel getMainPanel() {
835         return _mainpanel;
836     }
837
838     JMenuBar getMenuBarOfMainFrame() {
839         return _jmenubar;
840     }
841
842     public Options getOptions() {
843         return _options;
844     }
845
846     void initializeTypeMenu( final Options options ) {
847         setTypeMenuToAllUnselected();
848         switch ( options.getPhylogenyGraphicsType() ) {
849             case CONVEX:
850                 _convex_type_cbmi.setSelected( true );
851                 break;
852             case CURVED:
853                 _curved_type_cbmi.setSelected( true );
854                 break;
855             case EURO_STYLE:
856                 _euro_type_cbmi.setSelected( true );
857                 break;
858             case ROUNDED:
859                 _rounded_type_cbmi.setSelected( true );
860                 break;
861             case TRIANGULAR:
862                 _triangular_type_cbmi.setSelected( true );
863                 break;
864             case UNROOTED:
865                 _unrooted_type_cbmi.setSelected( true );
866                 break;
867             case CIRCULAR:
868                 _circular_type_cbmi.setSelected( true );
869                 break;
870             default:
871                 _rectangular_type_cbmi.setSelected( true );
872                 break;
873         }
874     }
875
876     void midpointRoot() {
877         if ( _mainpanel.getCurrentTreePanel() != null ) {
878             _mainpanel.getCurrentTreePanel().midpointRoot();
879         }
880     }
881
882     abstract void readPhylogeniesFromURL();
883
884     void readPhylogeniesFromWebservice( final int i ) {
885         final UrlTreeReader reader = new UrlTreeReader( this, i );
886         new Thread( reader ).start();
887     }
888
889     private void removeBranchColors() {
890         if ( getMainPanel().getCurrentPhylogeny() != null ) {
891             AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
892         }
893     }
894
895     void checkTextFrames() {
896         if ( _textframes.size() > 5 ) {
897             try {
898                 if ( _textframes.getFirst() != null ) {
899                     _textframes.getFirst().removeMe();
900                 }
901                 else {
902                     _textframes.removeFirst();
903                 }
904             }
905             catch ( final NoSuchElementException e ) {
906                 // Ignore.
907             }
908         }
909     }
910
911     void removeAllTextFrames() {
912         for( final TextFrame tf : _textframes ) {
913             if ( tf != null ) {
914                 tf.close();
915             }
916         }
917         _textframes.clear();
918     }
919
920     void setConfiguration( final Configuration configuration ) {
921         _configuration = configuration;
922     }
923
924     void setOptions( final Options options ) {
925         _options = options;
926     }
927
928     void setInferenceManager( final InferenceManager i ) {
929         _inference_manager = i;
930     }
931
932     public InferenceManager getInferenceManager() {
933         return _inference_manager;
934     }
935
936     void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
937         setTypeMenuToAllUnselected();
938         switch ( type ) {
939             case CIRCULAR:
940                 _circular_type_cbmi.setSelected( true );
941                 break;
942             case CONVEX:
943                 _convex_type_cbmi.setSelected( true );
944                 break;
945             case CURVED:
946                 _curved_type_cbmi.setSelected( true );
947                 break;
948             case EURO_STYLE:
949                 _euro_type_cbmi.setSelected( true );
950                 break;
951             case ROUNDED:
952                 _rounded_type_cbmi.setSelected( true );
953                 break;
954             case RECTANGULAR:
955                 _rectangular_type_cbmi.setSelected( true );
956                 break;
957             case TRIANGULAR:
958                 _triangular_type_cbmi.setSelected( true );
959                 break;
960             case UNROOTED:
961                 _unrooted_type_cbmi.setSelected( true );
962                 break;
963             default:
964                 throw new IllegalArgumentException( "unknown type: " + type );
965         }
966     }
967
968     void setTypeMenuToAllUnselected() {
969         _convex_type_cbmi.setSelected( false );
970         _curved_type_cbmi.setSelected( false );
971         _euro_type_cbmi.setSelected( false );
972         _rounded_type_cbmi.setSelected( false );
973         _triangular_type_cbmi.setSelected( false );
974         _rectangular_type_cbmi.setSelected( false );
975         _unrooted_type_cbmi.setSelected( false );
976         _circular_type_cbmi.setSelected( false );
977     }
978
979     public void showWhole() {
980         _mainpanel.getControlPanel().showWhole();
981     }
982
983     void switchColors() {
984         final TreeColorSet colorset = _mainpanel.getTreeColorSet();
985         final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
986         csc.setVisible( true );
987     }
988
989     void taxColor() {
990         if ( _mainpanel.getCurrentTreePanel() != null ) {
991             _mainpanel.getCurrentTreePanel().taxColor();
992         }
993     }
994
995     void typeChanged( final Object o ) {
996         updateTypeCheckboxes( getOptions(), o );
997         updateOptions( getOptions() );
998         if ( getCurrentTreePanel() != null ) {
999             final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
1000             final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
1001             if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1002                     || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
1003                     || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1004                     || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
1005                 getCurrentTreePanel().getControlPanel().showWhole();
1006             }
1007             if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1008                 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
1009             }
1010             else {
1011                 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
1012             }
1013             getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
1014             updateScreenTextAntialias( getMainPanel().getTreePanels() );
1015             if ( getCurrentTreePanel().getControlPanel().getDynamicallyHideData() != null ) {
1016                 if ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
1017                     getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( false );
1018                 }
1019                 else {
1020                     getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( true );
1021                 }
1022             }
1023         }
1024     }
1025
1026     void updateOptions( final Options options ) {
1027         options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
1028         options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
1029                 && _background_gradient_cbmi.isSelected() );
1030         options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
1031         options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
1032                 && _abbreviate_scientific_names.isSelected() );
1033         options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
1034                 && _color_labels_same_as_parent_branch.isSelected() );
1035         options.setShowDefaultNodeShapes( ( _show_default_node_shapes_cbmi != null )
1036                 && _show_default_node_shapes_cbmi.isSelected() );
1037         options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null )
1038                 && _taxonomy_colorize_node_shapes_cbmi.isSelected() );
1039         if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
1040             options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
1041         }
1042         else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
1043             options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1044         }
1045         else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
1046             options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1047         }
1048         options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
1049                 && _search_case_senstive_cbmi.isSelected() );
1050         if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
1051             options.setShowScale( _show_scale_cbmi.isSelected() );
1052         }
1053         if ( _label_direction_cbmi != null ) {
1054             if ( _label_direction_cbmi.isSelected() ) {
1055                 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1056             }
1057             else {
1058                 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1059             }
1060         }
1061         options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
1062         options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )
1063                 && _show_confidence_stddev_cbmi.isSelected() );
1064         if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
1065             options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
1066         }
1067         options.setPrintUsingActualSize( ( _print_using_actual_size_cbmi != null )
1068                 && ( _print_using_actual_size_cbmi.isSelected() ) );
1069         options.setGraphicsExportUsingActualSize( ( _graphics_export_using_actual_size_cbmi != null )
1070                 && ( _graphics_export_using_actual_size_cbmi.isSelected() ) );
1071         options.setAntialiasPrint( ( _antialias_print_cbmi != null ) && _antialias_print_cbmi.isSelected() );
1072         if ( ( _use_brackets_for_conf_in_nh_export_cbmi != null )
1073                 && _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {
1074             options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );
1075         }
1076         else if ( ( _use_internal_names_for_conf_in_nh_export_cbmi != null )
1077                 && _use_internal_names_for_conf_in_nh_export_cbmi.isSelected() ) {
1078             options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES );
1079         }
1080         else {
1081             options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE );
1082         }
1083         options.setPrintBlackAndWhite( ( _print_black_and_white_cbmi != null )
1084                 && _print_black_and_white_cbmi.isSelected() );
1085         options.setInternalNumberAreConfidenceForNhParsing( ( _internal_number_are_confidence_for_nh_parsing_cbmi != null )
1086                 && _internal_number_are_confidence_for_nh_parsing_cbmi.isSelected() );
1087         options.setExtractPfamTaxonomyCodesInNhParsing( ( _extract_pfam_style_tax_codes_cbmi != null )
1088                 && _extract_pfam_style_tax_codes_cbmi.isSelected() );
1089         options.setReplaceUnderscoresInNhParsing( ( _replace_underscores_cbmi != null )
1090                 && _replace_underscores_cbmi.isSelected() );
1091         options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
1092                 && _search_whole_words_only_cbmi.isSelected() );
1093         options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
1094                 && _inverse_search_result_cbmi.isSelected() );
1095         if ( _graphics_export_visible_only_cbmi != null ) {
1096             options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() );
1097             if ( _graphics_export_visible_only_cbmi.isSelected() && ( _graphics_export_using_actual_size_cbmi != null ) ) {
1098                 _graphics_export_using_actual_size_cbmi.setSelected( true );
1099                 _graphics_export_using_actual_size_cbmi.setEnabled( false );
1100             }
1101             else {
1102                 _graphics_export_using_actual_size_cbmi.setEnabled( true );
1103             }
1104         }
1105         if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
1106             options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1107         }
1108         else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
1109             options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1110         }
1111         else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
1112             options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1113         }
1114         else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
1115             options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1116         }
1117         else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
1118             options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1119         }
1120         else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
1121             options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1122         }
1123         else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
1124             options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1125         }
1126         else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
1127             options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1128         }
1129     }
1130
1131     void updateTypeCheckboxes( final Options options, final Object o ) {
1132         setTypeMenuToAllUnselected();
1133         ( ( JCheckBoxMenuItem ) o ).setSelected( true );
1134     }
1135
1136     void displayBasicInformation() {
1137         if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1138             String title = "Basic Information";
1139             if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1140                 title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
1141             }
1142             showTextFrame( AptxUtil.createBasicInformation( _mainpanel.getCurrentPhylogeny() ), title );
1143         }
1144     }
1145
1146     void viewAsNexus() {
1147         if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1148             String title = "Nexus";
1149             if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1150                 title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
1151             }
1152             showTextFrame( _mainpanel.getCurrentPhylogeny().toNexus( getOptions().getNhConversionSupportValueStyle() ),
1153                            title );
1154         }
1155     }
1156
1157     void viewAsNH() {
1158         if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1159             String title = "New Hampshire";
1160             if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1161                 title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
1162             }
1163             showTextFrame( _mainpanel.getCurrentPhylogeny()
1164                                    .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ),
1165                            title );
1166         }
1167     }
1168
1169     void viewAsNHX() {
1170         if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1171             String title = "NHX";
1172             if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1173                 title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
1174             }
1175             showTextFrame( _mainpanel.getCurrentPhylogeny().toNewHampshireX(), title );
1176         }
1177     }
1178
1179     void viewAsXML() {
1180         if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1181             String title = "phyloXML";
1182             if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1183                 title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
1184             }
1185             showTextFrame( _mainpanel.getCurrentPhylogeny().toPhyloXML( 0 ), title );
1186         }
1187     }
1188
1189     public void showTextFrame( final String s, final String title ) {
1190         checkTextFrames();
1191         _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
1192     }
1193
1194     /**
1195      * Display the about box.
1196      */
1197     static void about() {
1198         final StringBuffer about = new StringBuffer( "Archaeopteryx\nVersion " + Constants.VERSION + "\n" );
1199         about.append( "Copyright (C) 2007-2012 Christian M. Zmasek\n" );
1200         about.append( "All Rights Reserved\n" );
1201         about.append( "License: GNU Lesser General Public License (LGPL)\n" );
1202         about.append( "Last modified: " + Constants.PRG_DATE + "\n" );
1203         about.append( "Based on: " + ForesterUtil.getForesterLibraryInformation() + "\n" );
1204         about.append( "phyloXML version : " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1205         about.append( "phyloXML location: " + ForesterConstants.PHYLO_XML_LOCATION + "\n" );
1206         if ( !ForesterUtil.isEmpty( ForesterUtil.JAVA_VERSION ) && !ForesterUtil.isEmpty( ForesterUtil.JAVA_VENDOR ) ) {
1207             about.append( "[your Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]\n" );
1208         }
1209         if ( !ForesterUtil.isEmpty( ForesterUtil.OS_NAME ) && !ForesterUtil.isEmpty( ForesterUtil.OS_ARCH )
1210                 && !ForesterUtil.isEmpty( ForesterUtil.OS_VERSION ) ) {
1211             about.append( "[your OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " "
1212                     + ForesterUtil.OS_VERSION + "]\n" );
1213         }
1214         final Runtime rt = java.lang.Runtime.getRuntime();
1215         final long free_memory = rt.freeMemory() / 1000000;
1216         final long total_memory = rt.totalMemory() / 1000000;
1217         about.append( "[free memory: " + free_memory + "MB, total memory: " + total_memory + "MB]\n" );
1218         about.append( "[locale: " + Locale.getDefault() + "]\n" );
1219         about.append( "References:\n" );
1220         about.append( Constants.PHYLOXML_REFERENCE_SHORT + "\n" );
1221         about.append( "For more information & download:\n" );
1222         about.append( Constants.APTX_WEB_SITE + "\n" );
1223         about.append( "Comments: " + Constants.AUTHOR_EMAIL );
1224         JOptionPane.showMessageDialog( null, about, Constants.PRG_NAME, JOptionPane.PLAIN_MESSAGE );
1225     }
1226
1227     static String createCurrentFontDesc( final TreeFontSet tree_font_set ) {
1228         return tree_font_set.getLargeFont().getFamily() + " " + tree_font_set.getLargeFont().getSize();
1229     }
1230
1231     static JMenu createMenu( final String title, final Configuration conf ) {
1232         final JMenu jmenu = new JMenu( title );
1233         if ( !conf.isUseNativeUI() ) {
1234             jmenu.setFont( MainFrame.menu_font );
1235             jmenu.setBackground( conf.getGuiMenuBackgroundColor() );
1236             jmenu.setForeground( conf.getGuiMenuTextColor() );
1237         }
1238         return jmenu;
1239     }
1240
1241     static JMenuItem customizeMenuItemAsLabel( final JMenuItem label, final Configuration configuration ) {
1242         label.setFont( MainFrame.menu_font.deriveFont( Font.BOLD ) );
1243         if ( !configuration.isUseNativeUI() ) {
1244             label.setBackground( configuration.getGuiMenuBackgroundColor() );
1245             label.setForeground( configuration.getGuiMenuTextColor() );
1246             label.setOpaque( true );
1247         }
1248         label.setSelected( false );
1249         label.setEnabled( false );
1250         return label;
1251     }
1252
1253     static void cycleOverview( final Options op, final TreePanel tree_panel ) {
1254         switch ( op.getOvPlacement() ) {
1255             case LOWER_LEFT:
1256                 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1257                 break;
1258             case LOWER_RIGHT:
1259                 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1260                 break;
1261             case UPPER_LEFT:
1262                 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1263                 break;
1264             case UPPER_RIGHT:
1265                 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1266                 break;
1267             default:
1268                 throw new RuntimeException( "unknown placement: " + op.getOvPlacement() );
1269         }
1270         if ( tree_panel != null ) {
1271             tree_panel.updateOvSettings();
1272         }
1273     }
1274
1275     static void cycleNodeFill( final Options op, final TreePanel tree_panel ) {
1276         switch ( op.getDefaultNodeFill() ) {
1277             case GRADIENT:
1278                 op.setDefaultNodeFill( NodeFill.SOLID );
1279                 break;
1280             case NONE:
1281                 op.setDefaultNodeFill( NodeFill.GRADIENT );
1282                 break;
1283             case SOLID:
1284                 op.setDefaultNodeFill( NodeFill.NONE );
1285                 break;
1286             default:
1287                 throw new RuntimeException( "unknown fill: " + op.getDefaultNodeFill() );
1288         }
1289     }
1290
1291     static void cycleNodeShape( final Options op, final TreePanel tree_panel ) {
1292         switch ( op.getDefaultNodeShape() ) {
1293             case CIRCLE:
1294                 op.setDefaultNodeShape( NodeShape.RECTANGLE );
1295                 break;
1296             case RECTANGLE:
1297                 op.setDefaultNodeShape( NodeShape.CIRCLE );
1298                 break;
1299             default:
1300                 throw new RuntimeException( "unknown shape: " + op.getDefaultNodeShape() );
1301         }
1302     }
1303
1304     void help( final Map<String, WebLink> weblinks ) {
1305         final StringBuilder sb = new StringBuilder();
1306         sb.append( "Display options\n" );
1307         sb.append( "-------------------\n" );
1308         sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
1309         sb.append( "Clickable tree nodes\n" );
1310         sb.append( "--------------------\n" );
1311         sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
1312         sb.append( "or by right clicking:\n" );
1313         sb.append( "o  Display Node Data -- display information for a node\n" );
1314         sb.append( "o  Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
1315         sb.append( "o  Root/Reroot -- change tree root to clicked node\n" );
1316         sb.append( "o  Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
1317         sb.append( "o  Swap Descendants -- switch descendant on either side of clicked node\n" );
1318         sb.append( "o  Colorize Subtree -- color a subtree\n" );
1319         sb.append( "o  Open Sequence Web -- launch a web browser to display sequence information\n" );
1320         sb.append( "o  Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
1321         sb.append( "-  there may be additional choices depending on this particular setup\n\n" );
1322         sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
1323         sb.append( "Zooming\n" );
1324         sb.append( "---------\n" );
1325         sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
1326         sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
1327         sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
1328         sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
1329         sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
1330         sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
1331         sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
1332         sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
1333         sb.append( "Quick tree manipulation:\n" );
1334         sb.append( "------------------------\n" );
1335         sb.append( "Order Subtrees -- order the tree by branch length\n" );
1336         sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
1337         sb.append( "Memory problems (Java heap space error)\n" );
1338         sb.append( "---------------------------------------\n" );
1339         sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
1340         sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
1341         sb.append( "the '-Xmx' Java command line option. For example:\n" );
1342         sb.append( "java -Xms32m -Xmx256m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
1343         if ( ( weblinks != null ) && ( weblinks.size() > 0 ) ) {
1344             sb.append( "Active web links\n" );
1345             sb.append( "--------------------\n" );
1346             for( final String key : weblinks.keySet() ) {
1347                 sb.append( " " + weblinks.get( key ).toString() + "\n" );
1348             }
1349         }
1350         // + "General remarks\n"
1351         // + "---------------\n"
1352         // +
1353         // "o  The application version permits copying to the clipboard \n"
1354         // +
1355         // "    in the \"View\"|\"View as ...\" frame (either by control-c or button press).\n"
1356         // +
1357         // "o  Changes made to a subtree affect this subtree and its subtrees,\n"
1358         // + "    but not any of its parent tree(s).\n"
1359         // +
1360         // "o  Archaeopteryx tries to detect whether the numerical values in a NH tree\n"
1361         // +
1362         // "    are likely to be bootstrap values instead of branch length values.\n\n"
1363         // +
1364         // " Remarks regarding SDI (Speciation Duplication Inference):\n"
1365         // +
1366         // "o  Each external node of the gene tree (in display) needs to be associated with\n"
1367         // +
1368         // "    a species: either directly through the \"Species\" field, or the species\n"
1369         // +
1370         // "    is part of the sequence name in the form \"XXXX_SPECIES\"\n"
1371         // +
1372         // "    (e.g. \"ACON_DROME\" or \"ACON_DROME/123-4489\" which is also acceptable).\n"
1373         // +
1374         // "o  A species tree for each species of the gene tree needs to be loaded with\n"
1375         // +
1376         // "   \"SDI\"|\"Load species tree\" prior the SDI execution.\n"
1377         // +
1378         // "o  !External nodes of the gene tree associated with species not present in\n"
1379         // +
1380         // "    the species tree are REMOVED prior to SDI execution!\n"
1381         // +
1382         // "o  Both the gene tree and the species tree must be completely binary.\n"
1383         // +
1384         // "o  Duplications and speciations are a function of the position of the root.\n"
1385         // +
1386         // "    Hence, after each manual \"Root/Reroot\"ing some duplications will be\n"
1387         // + "    incorrect and need to be inferred again\n"
1388         // +
1389         // "    with: \"SDI\"|\"SDI (Speciation Duplication Inference)\n\n"
1390         sb.append( "\n" );
1391         sb.append( "phyloXML\n" );
1392         sb.append( "-------------------\n" );
1393         sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
1394         sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
1395         sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1396         sb.append( "\n" );
1397         sb.append( "For more information: http://www.phylosoft.org/archaeopteryx/\n" );
1398         sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
1399         TextFrame.instantiate( sb.toString(), "Help", _textframes );
1400     }
1401
1402     static void setOvPlacementColorChooseMenuItem( final JMenuItem mi, final Options options ) {
1403         if ( ( options != null ) && ( options.getOvPlacement() != null ) ) {
1404             mi.setText( "Cycle Overview Placement... (current: " + options.getOvPlacement() + ")" );
1405         }
1406         else {
1407             mi.setText( "Cycle Overview Placement..." );
1408         }
1409     }
1410
1411     static void setCycleNodeFillMenuItem( final JMenuItem mi, final Options options ) {
1412         if ( ( options != null ) && ( options.getDefaultNodeFill() != null ) ) {
1413             mi.setText( "Cycle Node Shape Fill Type... (current: "
1414                     + options.getDefaultNodeFill().toString().toLowerCase() + ")" );
1415         }
1416         else {
1417             mi.setText( "Cycle Node Shape Fill Type..." );
1418         }
1419     }
1420
1421     static void setCycleNodeShapeMenuItem( final JMenuItem mi, final Options options ) {
1422         if ( ( options != null ) && ( options.getDefaultNodeShape() != null ) ) {
1423             mi.setText( "Cycle Node Shape Fill Type... (current: "
1424                     + options.getDefaultNodeShape().toString().toLowerCase() + ")" );
1425         }
1426         else {
1427             mi.setText( "Cycle Node Shape Fill Type..." );
1428         }
1429     }
1430
1431     static void setTextColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {
1432         if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {
1433             mi.setText( "Select Colors... (current: " + tree_panel.getTreeColorSet().getCurrentColorSchemeName() + ")" );
1434         }
1435         else {
1436             mi.setText( "Select Colors..." );
1437         }
1438     }
1439
1440     static void setTextForFontChooserMenuItem( final JMenuItem mi, final String font_desc ) {
1441         mi.setText( "Select Font... (current: " + font_desc + ")" );
1442     }
1443
1444     static void setTextMinSupportMenuItem( final JMenuItem mi, final Options options, final TreePanel current_tree_panel ) {
1445         if ( ( current_tree_panel == null ) || ( current_tree_panel.getPhylogeny() == null ) ) {
1446             mi.setEnabled( true );
1447         }
1448         else if ( AptxUtil.isHasAtLeastOneBranchWithSupportValues( current_tree_panel.getPhylogeny() ) ) {
1449             mi.setEnabled( true );
1450         }
1451         else {
1452             mi.setEnabled( false );
1453         }
1454         mi.setText( "Enter Min Confidence Value... (current: " + options.getMinConfidenceValue() + ")" );
1455     }
1456
1457     static void setTextNodeSizeMenuItem( final JMenuItem mi, final Options options ) {
1458         mi.setText( "Enter Default Node Shape Size... (current: " + options.getDefaultNodeShapeSize() + ")" );
1459     }
1460
1461     static void updateOptionsMenuDependingOnPhylogenyType( final MainPanel main_panel,
1462                                                            final JCheckBoxMenuItem scale,
1463                                                            final JCheckBoxMenuItem branch_lengths,
1464                                                            final JRadioButtonMenuItem non_lined_up,
1465                                                            final JRadioButtonMenuItem uniform_clado,
1466                                                            final JRadioButtonMenuItem nonuniform_clado,
1467                                                            final JCheckBoxMenuItem label_direction_cbmi ) {
1468         final TreePanel tree_panel = main_panel.getCurrentTreePanel();
1469         final ControlPanel control = main_panel.getControlPanel();
1470         final Options options = main_panel.getOptions();
1471         scale.setSelected( options.isShowScale() );
1472         branch_lengths.setSelected( options.isShowBranchLengthValues() );
1473         // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1474         if ( ( tree_panel != null ) && ( !tree_panel.isPhyHasBranchLengths() ) ) {
1475             scale.setSelected( false );
1476             scale.setEnabled( false );
1477             branch_lengths.setSelected( false );
1478             branch_lengths.setEnabled( false );
1479         }
1480         else if ( ( tree_panel != null ) && !control.isDrawPhylogram() ) {
1481             scale.setSelected( false );
1482             scale.setEnabled( false );
1483             branch_lengths.setEnabled( true );
1484         }
1485         else {
1486             scale.setEnabled( true );
1487             branch_lengths.setEnabled( true );
1488         }
1489         if ( ( tree_panel != null )
1490                 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.ROUNDED )
1491                         && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1492                         .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1493             branch_lengths.setSelected( false );
1494             branch_lengths.setEnabled( false );
1495         }
1496         if ( tree_panel != null ) {
1497             if ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1498                     || ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
1499                 non_lined_up.setEnabled( false );
1500                 uniform_clado.setEnabled( false );
1501                 nonuniform_clado.setEnabled( false );
1502             }
1503             else {
1504                 non_lined_up.setEnabled( true );
1505                 uniform_clado.setEnabled( true );
1506                 nonuniform_clado.setEnabled( true );
1507             }
1508         }
1509         else {
1510             if ( ( tree_panel != null )
1511                     && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1512                             .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1513                 branch_lengths.setSelected( false );
1514                 branch_lengths.setEnabled( false );
1515             }
1516             if ( ( tree_panel != null )
1517                     && ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( tree_panel
1518                             .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
1519                 non_lined_up.setEnabled( false );
1520             }
1521             else {
1522                 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1523                 non_lined_up.setEnabled( true );
1524             }
1525         }
1526         label_direction_cbmi.setEnabled( true );
1527         if ( tree_panel != null ) {
1528             if ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1529                     && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1530                 label_direction_cbmi.setEnabled( false );
1531             }
1532             if ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
1533                 scale.setSelected( false );
1534                 scale.setEnabled( false );
1535             }
1536         }
1537     }
1538
1539     static void updateScreenTextAntialias( final List<TreePanel> treepanels ) {
1540         for( final TreePanel tree_panel : treepanels ) {
1541             tree_panel.setTextAntialias();
1542         }
1543     }
1544 }