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