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