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