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