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