in progress
[jalview.git] / forester / java / src / org / forester / archaeopteryx / ArchaeopteryxE.java
1
2 package org.forester.archaeopteryx;
3
4 import java.awt.BorderLayout;
5 import java.awt.Container;
6 import java.awt.event.ActionEvent;
7 import java.awt.event.ActionListener;
8 import java.awt.event.ComponentAdapter;
9 import java.awt.event.ComponentEvent;
10 import java.io.File;
11 import java.io.IOException;
12 import java.net.URL;
13 import java.util.List;
14
15 import javax.swing.ButtonGroup;
16 import javax.swing.JApplet;
17 import javax.swing.JCheckBoxMenuItem;
18 import javax.swing.JMenu;
19 import javax.swing.JMenuBar;
20 import javax.swing.JMenuItem;
21 import javax.swing.JOptionPane;
22 import javax.swing.JRadioButtonMenuItem;
23 import javax.swing.UIManager;
24 import javax.swing.UnsupportedLookAndFeelException;
25 import javax.swing.event.ChangeEvent;
26 import javax.swing.event.ChangeListener;
27
28 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
29 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
30 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
31 import org.forester.phylogeny.Phylogeny;
32 import org.forester.phylogeny.data.SequenceRelation;
33 import org.forester.util.ForesterUtil;
34
35 // Use like this:
36 // <applet archive="forester.jar"
37 // code="org.forester.archaeopteryx.ArchaeopteryxE.class"
38 // codebase="http://www.myserver.org/path/to/forester"
39 // width="600"
40 // height="500"
41 // alt="ArchaeopteryxE is not working on your system (requires at least Sun Java 1.5)!">
42 // <param name="url_of_tree_to_load"
43 // value="http://www.myserver.org/examples/data/apaf.xml">
44 // <param name="config_file"
45 // value="http://www.myserver.org/examples/config/config_file.txt">
46 // </applet>
47 public class ArchaeopteryxE extends JApplet implements ActionListener {
48
49     private final static String  NAME             = "ArchaeopteryxE";
50     private static final long    serialVersionUID = -1220055577935759443L;
51     private Configuration        _configuration;
52     private MainPanelApplets     _main_panel;
53     private JMenuBar             _jmenubar;
54     private JMenu                _options_jmenu;
55     private JMenu                _font_size_menu;
56     private JMenuItem            _super_tiny_fonts_mi;
57     private JMenuItem            _tiny_fonts_mi;
58     private JMenuItem            _small_fonts_mi;
59     private JMenuItem            _medium_fonts_mi;
60     private JMenuItem            _large_fonts_mi;
61     private TextFrame            _textframe;
62     private JMenu                _tools_menu;
63     private JMenuItem            _taxcolor_item;
64     private JMenuItem            _confcolor_item;
65     private JMenuItem            _midpoint_root_item;
66     private JMenu                _view_jmenu;
67     private JMenuItem            _view_as_XML_item;
68     private JMenuItem            _view_as_NH_item;
69     private JMenuItem            _view_as_NHX_item;
70     private JMenuItem            _view_as_nexus_item;
71     private JMenu                _type_menu;
72     private JCheckBoxMenuItem    _rectangular_type_cbmi;
73     private JCheckBoxMenuItem    _triangular_type_cbmi;
74     private JCheckBoxMenuItem    _curved_type_cbmi;
75     private JCheckBoxMenuItem    _convex_type_cbmi;
76     private JCheckBoxMenuItem    _euro_type_cbmi;
77     private JCheckBoxMenuItem    _rounded_type_cbmi;
78     private JCheckBoxMenuItem    _unrooted_type_cbmi;
79     private JCheckBoxMenuItem    _circular_type_cbmi;
80     private JMenuItem            _help_item;
81     private JMenuItem            _about_item;
82     private JMenu                _help_jmenu;
83     private JMenuItem            _website_item;
84     private JMenuItem            _phyloxml_website_item;
85     private JMenuItem            _phyloxml_ref_item;
86     private JMenuItem            _aptx_ref_item;
87     private JMenuItem            _remove_branch_color_item;
88     private JMenuItem            _infer_common_sn_names_item;
89     private JCheckBoxMenuItem    _show_domain_labels;
90     private JCheckBoxMenuItem    _color_labels_same_as_parent_branch;
91     private JCheckBoxMenuItem    _abbreviate_scientific_names;
92     private JCheckBoxMenuItem    _screen_antialias_cbmi;
93     private JCheckBoxMenuItem    _background_gradient_cbmi;
94     private JRadioButtonMenuItem _non_lined_up_cladograms_rbmi;
95     private JRadioButtonMenuItem _uniform_cladograms_rbmi;
96     private JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi;
97     private Options              _options;
98     private JMenuItem            _choose_font_mi;
99     private JMenuItem            _switch_colors_mi;
100     JCheckBoxMenuItem            _label_direction_cbmi;
101     private JCheckBoxMenuItem    _show_scale_cbmi;
102     private JCheckBoxMenuItem    _search_case_senstive_cbmi;
103     private JCheckBoxMenuItem    _search_whole_words_only_cbmi;
104     private JCheckBoxMenuItem    _inverse_search_result_cbmi;
105     private JCheckBoxMenuItem    _show_overview_cbmi;
106     private JMenuItem            _choose_minimal_confidence_mi;
107     private JCheckBoxMenuItem    _show_branch_length_values_cbmi;
108     private JMenuItem            _collapse_species_specific_subtrees;
109     private JMenuItem            _overview_placment_mi;
110     private ButtonGroup          _radio_group_1;
111     private JCheckBoxMenuItem    _show_default_node_shapes_cbmi;
112     private JMenuItem            _cycle_node_shape_mi;
113     private JMenuItem            _cycle_node_fill_mi;
114     private JMenuItem            _choose_node_size_mi;
115     private JCheckBoxMenuItem    _taxonomy_colorize_node_shapes_cbmi;
116
117     @Override
118     public void actionPerformed( final ActionEvent e ) {
119         final Object o = e.getSource();
120         if ( o == _midpoint_root_item ) {
121             getMainPanel().getCurrentTreePanel().midpointRoot();
122         }
123         else if ( o == _taxcolor_item ) {
124             getMainPanel().getCurrentTreePanel().taxColor();
125         }
126         else if ( o == _confcolor_item ) {
127             getMainPanel().getCurrentTreePanel().confColor();
128         }
129         else if ( o == _infer_common_sn_names_item ) {
130             if ( getCurrentTreePanel() != null ) {
131                 getCurrentTreePanel().inferCommonPartOfScientificNames();
132             }
133         }
134         else if ( o == _collapse_species_specific_subtrees ) {
135             if ( getCurrentTreePanel() != null ) {
136                 getCurrentTreePanel().collapseSpeciesSpecificSubtrees();
137             }
138         }
139         else if ( o == _remove_branch_color_item ) {
140             removeBranchColors();
141         }
142         else if ( o == _switch_colors_mi ) {
143             switchColors();
144         }
145         else if ( o == _view_as_NH_item ) {
146             viewAsNH();
147         }
148         else if ( o == _view_as_NHX_item ) {
149             viewAsNHX();
150         }
151         else if ( o == _view_as_XML_item ) {
152             viewAsXML();
153         }
154         else if ( o == _view_as_nexus_item ) {
155             viewAsNexus();
156         }
157         else if ( o == _super_tiny_fonts_mi ) {
158             if ( getCurrentTreePanel() != null ) {
159                 getCurrentTreePanel().setSuperTinyFonts();
160                 getCurrentTreePanel().repaint();
161             }
162         }
163         else if ( o == _tiny_fonts_mi ) {
164             if ( getCurrentTreePanel() != null ) {
165                 getCurrentTreePanel().setTinyFonts();
166                 getCurrentTreePanel().repaint();
167             }
168         }
169         else if ( o == _small_fonts_mi ) {
170             if ( getCurrentTreePanel() != null ) {
171                 getCurrentTreePanel().setSmallFonts();
172                 getCurrentTreePanel().repaint();
173             }
174         }
175         else if ( o == _medium_fonts_mi ) {
176             if ( getCurrentTreePanel() != null ) {
177                 getCurrentTreePanel().setMediumFonts();
178                 getCurrentTreePanel().repaint();
179             }
180         }
181         else if ( o == _large_fonts_mi ) {
182             if ( getCurrentTreePanel() != null ) {
183                 getCurrentTreePanel().setLargeFonts();
184                 getCurrentTreePanel().repaint();
185             }
186         }
187         else if ( o == _choose_font_mi ) {
188             chooseFont();
189         }
190         else if ( o == _choose_minimal_confidence_mi ) {
191             chooseMinimalConfidence();
192         }
193         else if ( o == _choose_node_size_mi ) {
194             MainFrame.chooseNodeSize( getOptions(), this );
195         }
196         else if ( o == _overview_placment_mi ) {
197             MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
198         }
199         else if ( o == _cycle_node_fill_mi ) {
200             MainFrame.cycleNodeFill( getOptions(), getCurrentTreePanel() );
201         }
202         else if ( o == _cycle_node_shape_mi ) {
203             MainFrame.cycleNodeShape( getOptions(), getCurrentTreePanel() );
204         }
205         else if ( o == _non_lined_up_cladograms_rbmi ) {
206             updateOptions( getOptions() );
207             _main_panel.getControlPanel().showWhole();
208         }
209         else if ( o == _uniform_cladograms_rbmi ) {
210             updateOptions( getOptions() );
211             _main_panel.getControlPanel().showWhole();
212         }
213         else if ( o == _ext_node_dependent_cladogram_rbmi ) {
214             updateOptions( getOptions() );
215             _main_panel.getControlPanel().showWhole();
216         }
217         else if ( o == _search_case_senstive_cbmi ) {
218             updateOptions( getOptions() );
219             getMainPanel().getControlPanel().search();
220         }
221         else if ( o == _search_whole_words_only_cbmi ) {
222             updateOptions( getOptions() );
223             getMainPanel().getControlPanel().search();
224         }
225         else if ( o == _inverse_search_result_cbmi ) {
226             updateOptions( getOptions() );
227             getMainPanel().getControlPanel().search();
228         }
229         else if ( o == _show_scale_cbmi ) {
230             updateOptions( getOptions() );
231         }
232         else if ( o == _show_branch_length_values_cbmi ) {
233             updateOptions( getOptions() );
234         }
235         else if ( o == _label_direction_cbmi ) {
236             updateOptions( getOptions() );
237         }
238         else if ( o == _show_overview_cbmi ) {
239             updateOptions( getOptions() );
240             if ( getCurrentTreePanel() != null ) {
241                 getCurrentTreePanel().updateOvSizes();
242             }
243         }
244         else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
245                 || ( o == _convex_type_cbmi ) || ( o == _rounded_type_cbmi ) || ( o == _euro_type_cbmi )
246                 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
247             typeChanged( o );
248         }
249         else if ( o == _screen_antialias_cbmi ) {
250             updateOptions( getOptions() );
251             setupScreenTextAntialias( getMainPanel().getTreePanels(), isScreenAntialias() );
252         }
253         else if ( o == _background_gradient_cbmi ) {
254             updateOptions( getOptions() );
255         }
256         else if ( o == _show_domain_labels ) {
257             updateOptions( getOptions() );
258         }
259         else if ( o == _color_labels_same_as_parent_branch ) {
260             updateOptions( getOptions() );
261         }
262         else if ( o == _show_default_node_shapes_cbmi ) {
263             updateOptions( getOptions() );
264         }
265         else if ( o == _taxonomy_colorize_node_shapes_cbmi ) {
266             updateOptions( getOptions() );
267         }
268         else if ( o == _about_item ) {
269             MainFrame.about();
270         }
271         else if ( o == _help_item ) {
272             MainFrame.help( getConfiguration().getWebLinks() );
273         }
274         else if ( o == _website_item ) {
275             try {
276                 Util.openWebsite( Constants.APTX_WEB_SITE, true, this );
277             }
278             catch ( final IOException e1 ) {
279                 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
280             }
281         }
282         else if ( o == _phyloxml_website_item ) {
283             try {
284                 Util.openWebsite( Constants.PHYLOXML_WEB_SITE, true, this );
285             }
286             catch ( final IOException e1 ) {
287                 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
288             }
289         }
290         else if ( o == _aptx_ref_item ) {
291             try {
292                 Util.openWebsite( Constants.APTX_REFERENCE_URL, true, this );
293             }
294             catch ( final IOException e1 ) {
295                 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
296             }
297         }
298         else if ( o == _phyloxml_ref_item ) {
299             try {
300                 Util.openWebsite( Constants.PHYLOXML_REFERENCE_URL, true, this );
301             }
302             catch ( final IOException e1 ) {
303                 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
304             }
305         }
306         repaint();
307     }
308
309     void buildFontSizeMenu() {
310         _font_size_menu = MainFrame.createMenu( MainFrame.FONT_SIZE_MENU_LABEL, getConfiguration() );
311         _font_size_menu.add( _super_tiny_fonts_mi = new JMenuItem( "Super tiny fonts" ) );
312         _font_size_menu.add( _tiny_fonts_mi = new JMenuItem( "Tiny fonts" ) );
313         _font_size_menu.add( _small_fonts_mi = new JMenuItem( "Small fonts" ) );
314         _font_size_menu.add( _medium_fonts_mi = new JMenuItem( "Medium fonts" ) );
315         _font_size_menu.add( _large_fonts_mi = new JMenuItem( "Large fonts" ) );
316         customizeJMenuItem( _super_tiny_fonts_mi );
317         customizeJMenuItem( _tiny_fonts_mi );
318         customizeJMenuItem( _small_fonts_mi );
319         customizeJMenuItem( _medium_fonts_mi );
320         customizeJMenuItem( _large_fonts_mi );
321         _jmenubar.add( _font_size_menu );
322     }
323
324     void buildHelpMenu() {
325         _help_jmenu = MainFrame.createMenu( "Help", getConfiguration() );
326         _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
327         _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
328         _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
329         _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
330         _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
331         _help_jmenu.addSeparator();
332         _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
333         customizeJMenuItem( _help_item );
334         customizeJMenuItem( _website_item );
335         customizeJMenuItem( _phyloxml_website_item );
336         customizeJMenuItem( _aptx_ref_item );
337         customizeJMenuItem( _phyloxml_ref_item );
338         customizeJMenuItem( _about_item );
339         _phyloxml_ref_item.setToolTipText( MainFrame.PHYLOXML_REF_TOOL_TIP );
340         _aptx_ref_item.setToolTipText( MainFrame.APTX_REF_TOOL_TIP );
341         _jmenubar.add( _help_jmenu );
342     }
343
344     void buildOptionsMenu() {
345         _options_jmenu = MainFrame.createMenu( MainFrame.OPTIONS_HEADER, getConfiguration() );
346         _options_jmenu.addChangeListener( new ChangeListener() {
347
348             @Override
349             public void stateChanged( final ChangeEvent e ) {
350                 MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getOptions() );
351                 MainFrame.setTextColorChooseMenuItem( _switch_colors_mi, getCurrentTreePanel() );
352                 MainFrame
353                         .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() );
354                 MainFrame.setTextForFontChooserMenuItem( _choose_font_mi, MainFrame
355                         .createCurrentFontDesc( getMainPanel().getTreeFontSet() ) );
356                 MainFrame.updateOptionsMenuDependingOnPhylogenyType( getMainPanel(),
357                                                                      _show_scale_cbmi,
358                                                                      _show_branch_length_values_cbmi,
359                                                                      _non_lined_up_cladograms_rbmi,
360                                                                      _uniform_cladograms_rbmi,
361                                                                      _ext_node_dependent_cladogram_rbmi,
362                                                                      _label_direction_cbmi );
363                 MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() );
364                 MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() );
365                 MainFrame.setTextNodeSizeMenuItem( _choose_node_size_mi, getOptions() );
366             }
367         } );
368         _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.DISPLAY_SUBHEADER ),
369                                                                 getConfiguration() ) );
370         _options_jmenu
371                 .add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );
372         _options_jmenu.add( _uniform_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.UNIFORM_CLADOGRAMS_LABEL ) );
373         _options_jmenu
374                 .add( _non_lined_up_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.NON_LINED_UP_CLADOGRAMS_LABEL ) );
375         _radio_group_1 = new ButtonGroup();
376         _radio_group_1.add( _ext_node_dependent_cladogram_rbmi );
377         _radio_group_1.add( _uniform_cladograms_rbmi );
378         _radio_group_1.add( _non_lined_up_cladograms_rbmi );
379         //
380         _options_jmenu
381                 .add( _show_default_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL ) );
382         _options_jmenu
383                 .add( _taxonomy_colorize_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.TAXONOMY_COLORIZE_NODE_SHAPES_LABEL ) );
384         _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL ) );
385         _options_jmenu.add( _cycle_node_fill_mi = new JMenuItem( MainFrame.CYCLE_NODE_FILL_LABEL ) );
386         _options_jmenu.add( _choose_node_size_mi = new JMenuItem( MainFrame.CHOOSE_NODE_SIZE_LABEL ) );
387         //
388         _options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_SCALE_LABEL ) );
389         _options_jmenu
390                 .add( _show_branch_length_values_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_BRANCH_LENGTH_VALUES_LABEL ) );
391         _options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_OVERVIEW_LABEL ) );
392         _options_jmenu.add( _label_direction_cbmi = new JCheckBoxMenuItem( MainFrame.LABEL_DIRECTION_LABEL ) );
393         _options_jmenu
394                 .add( _color_labels_same_as_parent_branch = new JCheckBoxMenuItem( MainFrame.COLOR_LABELS_LABEL ) );
395         _color_labels_same_as_parent_branch.setToolTipText( MainFrame.COLOR_LABELS_TIP );
396         _options_jmenu.add( _abbreviate_scientific_names = new JCheckBoxMenuItem( MainFrame.ABBREV_SN_LABEL ) );
397         _label_direction_cbmi.setToolTipText( MainFrame.LABEL_DIRECTION_TIP );
398         _options_jmenu.add( _screen_antialias_cbmi = new JCheckBoxMenuItem( MainFrame.SCREEN_ANTIALIAS_LABEL ) );
399         _options_jmenu.add( _background_gradient_cbmi = new JCheckBoxMenuItem( MainFrame.BG_GRAD_LABEL ) );
400         if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
401             _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( MainFrame.SHOW_DOMAIN_LABELS_LABEL ) );
402         }
403         _options_jmenu.add( _choose_minimal_confidence_mi = new JMenuItem( "" ) );
404         _options_jmenu.add( _overview_placment_mi = new JMenuItem( "" ) );
405         _options_jmenu.add( _switch_colors_mi = new JMenuItem( "" ) );
406         _options_jmenu.add( _choose_font_mi = new JMenuItem( "" ) );
407         _options_jmenu.addSeparator();
408         _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.SEARCH_SUBHEADER ),
409                                                                 getConfiguration() ) );
410         _options_jmenu
411                 .add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_CASE_SENSITIVE_LABEL ) );
412         _options_jmenu.add( _search_whole_words_only_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_TERMS_ONLY_LABEL ) );
413         _options_jmenu
414                 .add( _inverse_search_result_cbmi = new JCheckBoxMenuItem( MainFrame.INVERSE_SEARCH_RESULT_LABEL ) );
415         customizeJMenuItem( _choose_font_mi );
416         customizeJMenuItem( _choose_minimal_confidence_mi );
417         customizeJMenuItem( _switch_colors_mi );
418         customizeJMenuItem( _overview_placment_mi );
419         customizeCheckBoxMenuItem( _label_direction_cbmi,
420                                    getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL );
421         customizeCheckBoxMenuItem( _screen_antialias_cbmi, getOptions().isAntialiasScreen() );
422         customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );
423         customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );
424         customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );
425         customizeCheckBoxMenuItem( _show_default_node_shapes_cbmi, getOptions().isShowDefaultNodeShapes() );
426         customizeCheckBoxMenuItem( _taxonomy_colorize_node_shapes_cbmi, getOptions().isTaxonomyColorizeNodeShapes() );
427         customizeJMenuItem( _cycle_node_shape_mi );
428         customizeJMenuItem( _cycle_node_fill_mi );
429         customizeJMenuItem( _choose_node_size_mi );
430         customizeCheckBoxMenuItem( _color_labels_same_as_parent_branch, getOptions().isColorLabelsSameAsParentBranch() );
431         customizeCheckBoxMenuItem( _search_case_senstive_cbmi, getOptions().isSearchCaseSensitive() );
432         customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );
433         customizeRadioButtonMenuItem( _non_lined_up_cladograms_rbmi,
434                                       getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP );
435         customizeRadioButtonMenuItem( _uniform_cladograms_rbmi,
436                                       getOptions().getCladogramType() == CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
437         customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi,
438                                       getOptions().getCladogramType() == CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
439         customizeCheckBoxMenuItem( _show_branch_length_values_cbmi, getOptions().isShowBranchLengthValues() );
440         customizeCheckBoxMenuItem( _show_overview_cbmi, getOptions().isShowOverview() );
441         customizeCheckBoxMenuItem( _search_whole_words_only_cbmi, getOptions().isMatchWholeTermsOnly() );
442         customizeCheckBoxMenuItem( _inverse_search_result_cbmi, getOptions().isInverseSearchResult() );
443         _jmenubar.add( _options_jmenu );
444     }
445
446     void buildToolsMenu() {
447         _tools_menu = MainFrame.createMenu( "Tools", getConfiguration() );
448         _tools_menu.add( _confcolor_item = new JMenuItem( "Colorize Branches Depending on Confidence" ) );
449         customizeJMenuItem( _confcolor_item );
450         _tools_menu.add( _taxcolor_item = new JMenuItem( "Taxonomy Colorize Branches" ) );
451         customizeJMenuItem( _taxcolor_item );
452         _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete Branch Colors" ) );
453         _remove_branch_color_item.setToolTipText( "To delete branch color values from the current phylogeny." );
454         customizeJMenuItem( _remove_branch_color_item );
455         _tools_menu.addSeparator();
456         _tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) );
457         customizeJMenuItem( _midpoint_root_item );
458         _tools_menu.addSeparator();
459         _tools_menu
460                 .add( _infer_common_sn_names_item = new JMenuItem( "Infer Common Parts of Internal Scientific Names" ) );
461         customizeJMenuItem( _infer_common_sn_names_item );
462         _tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Species-Specific Subtrees" ) );
463         customizeJMenuItem( _collapse_species_specific_subtrees );
464         _jmenubar.add( _tools_menu );
465     }
466
467     void buildTypeMenu() {
468         _type_menu = MainFrame.createMenu( MainFrame.TYPE_MENU_HEADER, getConfiguration() );
469         _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
470         _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
471         _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
472         _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
473         _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
474         _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
475         _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
476         _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
477         customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
478         customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
479         customizeCheckBoxMenuItem( _euro_type_cbmi, false );
480         customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
481         customizeCheckBoxMenuItem( _curved_type_cbmi, false );
482         customizeCheckBoxMenuItem( _convex_type_cbmi, false );
483         customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
484         customizeCheckBoxMenuItem( _circular_type_cbmi, false );
485         _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
486         _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
487         initializeTypeMenu( getOptions() );
488         _jmenubar.add( _type_menu );
489     }
490
491     void buildViewMenu() {
492         _view_jmenu = MainFrame.createMenu( "View as Text", getConfiguration() );
493         _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) );
494         _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) );
495         _view_jmenu.add( _view_as_NHX_item = new JMenuItem( "View as NHX" ) );
496         _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "View as Nexus" ) );
497         customizeJMenuItem( _view_as_NH_item );
498         customizeJMenuItem( _view_as_NHX_item );
499         customizeJMenuItem( _view_as_XML_item );
500         customizeJMenuItem( _view_as_nexus_item );
501         _jmenubar.add( _view_jmenu );
502     }
503
504     private void chooseFont() {
505         final FontChooser fc = new FontChooser();
506         fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
507         fc.showDialog( this, "Select the Base Font" );
508         getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
509     }
510
511     private void chooseMinimalConfidence() {
512         final String s = ( String ) JOptionPane
513                 .showInputDialog( this,
514                                   "Please the minimum for confidence values to be displayed.\n" + "[current value: "
515                                           + getOptions().getMinConfidenceValue() + "]\n",
516                                   "Minimal Confidence Value",
517                                   JOptionPane.QUESTION_MESSAGE,
518                                   null,
519                                   null,
520                                   getOptions().getMinConfidenceValue() );
521         if ( !ForesterUtil.isEmpty( s ) ) {
522             boolean success = true;
523             double m = 0.0;
524             final String m_str = s.trim();
525             if ( !ForesterUtil.isEmpty( m_str ) ) {
526                 try {
527                     m = Double.parseDouble( m_str );
528                 }
529                 catch ( final Exception ex ) {
530                     success = false;
531                 }
532             }
533             else {
534                 success = false;
535             }
536             if ( success && ( m >= 0.0 ) ) {
537                 getOptions().setMinConfidenceValue( m );
538             }
539         }
540     }
541
542     void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
543         if ( item != null ) {
544             item.setFont( MainFrame.menu_font );
545             if ( !getConfiguration().isUseNativeUI() ) {
546                 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
547                 item.setForeground( getConfiguration().getGuiMenuTextColor() );
548             }
549             item.setSelected( is_selected );
550             item.addActionListener( this );
551         }
552     }
553
554     void customizeJMenuItem( final JMenuItem jmi ) {
555         jmi.setFont( MainFrame.menu_font );
556         if ( !getConfiguration().isUseNativeUI() ) {
557             jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
558             jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
559         }
560         jmi.addActionListener( this );
561     }
562
563     private void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
564         if ( item != null ) {
565             item.setFont( MainFrame.menu_font );
566             if ( !getConfiguration().isUseNativeUI() ) {
567                 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
568                 item.setForeground( getConfiguration().getGuiMenuTextColor() );
569             }
570             item.setSelected( is_selected );
571             item.addActionListener( this );
572         }
573     }
574
575     @Override
576     public void destroy() {
577         Util.printAppletMessage( NAME, "going to be destroyed " );
578         removeTextFrame();
579         if ( getMainPanel() != null ) {
580             getMainPanel().terminate();
581         }
582     }
583
584     Configuration getConfiguration() {
585         return _configuration;
586     }
587
588     TreePanel getCurrentTreePanel() {
589         return getMainPanel().getCurrentTreePanel();
590     }
591
592     JCheckBoxMenuItem getlabelDirectionCbmi() {
593         return _label_direction_cbmi;
594     }
595
596     private MainPanel getMainPanel() {
597         return _main_panel;
598     }
599
600     public Options getOptions() {
601         return _options;
602     }
603
604     Options getOtions() {
605         return _options;
606     }
607
608     @Override
609     public void init() {
610         final String config_filename = getParameter( Constants.APPLET_PARAM_NAME_FOR_CONFIG_FILE_URL );
611         Util.printAppletMessage( NAME, "URL for configuration file is: " + config_filename );
612         final Configuration configuration = new Configuration( config_filename, true, true );
613         setConfiguration( configuration );
614         setOptions( Options.createInstance( configuration ) );
615         setupUI();
616         URL phys_url = null;
617         Phylogeny[] phys = null;
618         final String phys_url_string = getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD );
619         Util.printAppletMessage( NAME, "URL for phylogenies is " + phys_url_string );
620         // Get URL to tree file
621         if ( phys_url_string != null ) {
622             try {
623                 phys_url = new URL( phys_url_string );
624             }
625             catch ( final Exception e ) {
626                 ForesterUtil.printErrorMessage( NAME, "error: " + e );
627                 e.printStackTrace();
628                 JOptionPane.showMessageDialog( this, NAME + ": Could not create URL from: \"" + phys_url_string
629                         + "\"\nException: " + e, "Failed to create URL", JOptionPane.ERROR_MESSAGE );
630             }
631         }
632         // Load the tree from URL
633         if ( phys_url != null ) {
634             try {
635                 phys = Util.readPhylogeniesFromUrl( phys_url, getConfiguration().isValidatePhyloXmlAgainstSchema() );
636             }
637             catch ( final Exception e ) {
638                 ForesterUtil.printErrorMessage( NAME, e.toString() );
639                 e.printStackTrace();
640                 JOptionPane.showMessageDialog( this,
641                                                NAME + ": Failed to read phylogenies: " + "\nException: " + e,
642                                                "Failed to read phylogenies",
643                                                JOptionPane.ERROR_MESSAGE );
644             }
645         }
646         if ( ( phys == null ) || ( phys.length < 1 ) ) {
647             ForesterUtil.printErrorMessage( NAME, "phylogenies from [" + phys_url + "] are null or empty" );
648             JOptionPane.showMessageDialog( this,
649                                            NAME + ": phylogenies from [" + phys_url + "] are null or empty",
650                                            "Failed to read phylogenies",
651                                            JOptionPane.ERROR_MESSAGE );
652             return;
653         }
654         else {
655             Util.printAppletMessage( NAME, "loaded " + phys.length + " phylogenies from: " + phys_url );
656         }
657         setVisible( false );
658         setMainPanel( new MainPanelApplets( getConfiguration(), this ) );
659         _jmenubar = new JMenuBar();
660         if ( !getConfiguration().isHideControlPanelAndMenubar() ) {
661             if ( !getConfiguration().isUseNativeUI() ) {
662                 _jmenubar.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
663             }
664             buildToolsMenu();
665             buildViewMenu();
666             buildFontSizeMenu();
667             buildOptionsMenu();
668             buildTypeMenu();
669             buildHelpMenu();
670             setJMenuBar( _jmenubar );
671         }
672         final Container contentpane = getContentPane();
673         contentpane.setLayout( new BorderLayout() );
674         contentpane.add( getMainPanel(), BorderLayout.CENTER );
675         addComponentListener( new ComponentAdapter() {
676
677             @Override
678             public void componentResized( final ComponentEvent e ) {
679                 if ( getMainPanel().getCurrentTreePanel() != null ) {
680                     getMainPanel().getCurrentTreePanel().setParametersForPainting( getMainPanel().getCurrentTreePanel()
681                                                                                            .getWidth(),
682                                                                                    getMainPanel().getCurrentTreePanel()
683                                                                                            .getHeight(),
684                                                                                    false );
685                 }
686             }
687         } );
688         if ( getConfiguration().isUseTabbedDisplay() ) {
689             Util.printAppletMessage( NAME, "using tabbed display" );
690             Util.addPhylogeniesToTabs( phys,
691                                        new File( phys_url.getFile() ).getName(),
692                                        phys_url.toString(),
693                                        getConfiguration(),
694                                        getMainPanel() );
695         }
696         else {
697             Util.printAppletMessage( NAME, "not using tabbed display" );
698             Util.addPhylogenyToPanel( phys, getConfiguration(), getMainPanel() );
699         }
700         validate();
701         setName( NAME );
702         getMainPanel().getControlPanel().showWholeAll();
703         getMainPanel().getControlPanel().showWhole();
704         System.gc();
705         Util.printAppletMessage( NAME, "successfully initialized" );
706         /* GUILHEM_BEG */
707         getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().removeAllItems();
708         for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
709                 .getRelevantSequenceRelationTypes() ) {
710             getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().addItem( type );
711         }
712         final String default_relation = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_SEQUENCE_RELATION_TYPE );
713         if ( default_relation != null ) {
714             getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().setSelectedItem( default_relation );
715         }
716         final String default_sequence = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_QUERY_SEQUENCE );
717         if ( default_sequence != null ) {
718             getCurrentTreePanel().getControlPanel().getSequenceRelationBox().setSelectedItem( default_sequence );
719             /* GUILHEM_END */
720         }
721         setVisible( true );
722     }
723
724     void initializeTypeMenu( final Options options ) {
725         setTypeMenuToAllUnselected();
726         try {
727             switch ( options.getPhylogenyGraphicsType() ) {
728                 case CONVEX:
729                     _convex_type_cbmi.setSelected( true );
730                     break;
731                 case CURVED:
732                     _curved_type_cbmi.setSelected( true );
733                     break;
734                 case EURO_STYLE:
735                     _euro_type_cbmi.setSelected( true );
736                     break;
737                 case ROUNDED:
738                     _rounded_type_cbmi.setSelected( true );
739                     break;
740                 case TRIANGULAR:
741                     _triangular_type_cbmi.setSelected( true );
742                     break;
743                 case UNROOTED:
744                     _unrooted_type_cbmi.setSelected( true );
745                     break;
746                 case CIRCULAR:
747                     _circular_type_cbmi.setSelected( true );
748                     break;
749                 default:
750                     _rectangular_type_cbmi.setSelected( true );
751                     break;
752             }
753         }
754         catch ( final NullPointerException np ) {
755             // In all likelihood, this is caused by menu-less display.
756         }
757     }
758
759     private boolean isScreenAntialias() {
760         return true;
761     }
762
763     private void removeBranchColors() {
764         if ( getMainPanel().getCurrentPhylogeny() != null ) {
765             Util.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
766         }
767     }
768
769     void removeTextFrame() {
770         if ( _textframe != null ) {
771             _textframe.close();
772             _textframe = null;
773         }
774     }
775
776     void setConfiguration( final Configuration configuration ) {
777         _configuration = configuration;
778     }
779
780     private void setMainPanel( final MainPanelApplets main_panel ) {
781         _main_panel = main_panel;
782     }
783
784     void setOptions( final Options options ) {
785         _options = options;
786     }
787
788     void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
789         setTypeMenuToAllUnselected();
790         try {
791             switch ( type ) {
792                 case CIRCULAR:
793                     _circular_type_cbmi.setSelected( true );
794                     break;
795                 case CONVEX:
796                     _convex_type_cbmi.setSelected( true );
797                     break;
798                 case CURVED:
799                     _curved_type_cbmi.setSelected( true );
800                     break;
801                 case EURO_STYLE:
802                     _euro_type_cbmi.setSelected( true );
803                     break;
804                 case ROUNDED:
805                     _rounded_type_cbmi.setSelected( true );
806                     break;
807                 case RECTANGULAR:
808                     _rectangular_type_cbmi.setSelected( true );
809                     break;
810                 case TRIANGULAR:
811                     _triangular_type_cbmi.setSelected( true );
812                     break;
813                 case UNROOTED:
814                     _unrooted_type_cbmi.setSelected( true );
815                     break;
816                 default:
817                     throw new IllegalArgumentException( "unknown type: " + type );
818             }
819         }
820         catch ( final NullPointerException np ) {
821             // In all likelihood, this is caused by menu-less display.
822         }
823     }
824
825     void setTypeMenuToAllUnselected() {
826         if ( _convex_type_cbmi != null ) {
827             _convex_type_cbmi.setSelected( false );
828         }
829         if ( _curved_type_cbmi != null ) {
830             _curved_type_cbmi.setSelected( false );
831         }
832         if ( _euro_type_cbmi != null ) {
833             _euro_type_cbmi.setSelected( false );
834         }
835         if ( _rounded_type_cbmi != null ) {
836             _rounded_type_cbmi.setSelected( false );
837         }
838         if ( _triangular_type_cbmi != null ) {
839             _triangular_type_cbmi.setSelected( false );
840         }
841         if ( _rectangular_type_cbmi != null ) {
842             _rectangular_type_cbmi.setSelected( false );
843         }
844         if ( _unrooted_type_cbmi != null ) {
845             _unrooted_type_cbmi.setSelected( false );
846         }
847         if ( _circular_type_cbmi != null ) {
848             _circular_type_cbmi.setSelected( false );
849         }
850     }
851
852     private void setupUI() {
853         try {
854             if ( getConfiguration().isUseNativeUI() ) {
855                 UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
856             }
857             else {
858                 UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
859             }
860         }
861         catch ( final UnsupportedLookAndFeelException e ) {
862             Util.dieWithSystemError( "UnsupportedLookAndFeelException: " + e.toString() );
863         }
864         catch ( final ClassNotFoundException e ) {
865             Util.dieWithSystemError( "ClassNotFoundException: " + e.toString() );
866         }
867         catch ( final InstantiationException e ) {
868             Util.dieWithSystemError( "InstantiationException: " + e.toString() );
869         }
870         catch ( final IllegalAccessException e ) {
871             Util.dieWithSystemError( "IllegalAccessException: " + e.toString() );
872         }
873         catch ( final Exception e ) {
874             Util.dieWithSystemError( e.toString() );
875         }
876     }
877
878     @Override
879     public void start() {
880         if ( getMainPanel() != null ) {
881             getMainPanel().validate();
882         }
883         requestFocus();
884         requestFocusInWindow();
885         requestFocus();
886         Util.printAppletMessage( NAME, "started" );
887     }
888
889     void switchColors() {
890         final TreeColorSet colorset = getMainPanel().getCurrentTreePanel().getTreeColorSet();
891         final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
892         csc.setVisible( true );
893         getMainPanel().setTreeColorSet( colorset );
894     }
895
896     void typeChanged( final Object o ) {
897         updateTypeCheckboxes( getOptions(), o );
898         updateOptions( getOptions() );
899         if ( getCurrentTreePanel() != null ) {
900             final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
901             final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
902             if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
903                     || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
904                     || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
905                     || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
906                 getCurrentTreePanel().getControlPanel().showWhole();
907             }
908             if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
909                 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
910             }
911             else {
912                 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
913             }
914             getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
915             MainFrame.updateScreenTextAntialias( getMainPanel().getTreePanels() );
916         }
917     }
918
919     void updateOptions( final Options options ) {
920         options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
921         options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
922                 && _background_gradient_cbmi.isSelected() );
923         options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
924         options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
925                 && _abbreviate_scientific_names.isSelected() );
926         options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
927                 && _color_labels_same_as_parent_branch.isSelected() );
928         options.setShowDefaultNodeShapes( ( _show_default_node_shapes_cbmi != null )
929                 && _show_default_node_shapes_cbmi.isSelected() );
930         options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null )
931                 && _taxonomy_colorize_node_shapes_cbmi.isSelected() );
932         if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
933             options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
934         }
935         else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
936             options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
937         }
938         else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
939             options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
940         }
941         options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
942                 && _search_case_senstive_cbmi.isSelected() );
943         if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
944             options.setShowScale( _show_scale_cbmi.isSelected() );
945         }
946         if ( _label_direction_cbmi != null ) {
947             if ( _label_direction_cbmi.isSelected() ) {
948                 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
949             }
950             else {
951                 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
952             }
953         }
954         options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
955         if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
956             options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
957         }
958         options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
959                 && _search_whole_words_only_cbmi.isSelected() );
960         options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
961                 && _inverse_search_result_cbmi.isSelected() );
962         if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
963             options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
964         }
965         else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
966             options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
967         }
968         else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
969             options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
970         }
971         else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
972             options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
973         }
974         else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
975             options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
976         }
977         else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
978             options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
979         }
980         else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
981             options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
982         }
983         else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
984             options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
985         }
986     }
987
988     void updateTypeCheckboxes( final Options options, final Object o ) {
989         setTypeMenuToAllUnselected();
990         ( ( JCheckBoxMenuItem ) o ).setSelected( true );
991     }
992
993     void viewAsNexus() {
994         removeTextFrame();
995         if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty()
996                 || ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
997             return;
998         }
999         _textframe = TextFrame.instantiate( getMainPanel().getCurrentPhylogeny().toNexus() );
1000     }
1001
1002     void viewAsNH() {
1003         removeTextFrame();
1004         if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty()
1005                 || ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
1006             return;
1007         }
1008         _textframe = TextFrame.instantiate( getMainPanel().getCurrentPhylogeny().toNewHampshire( false ) );
1009     }
1010
1011     void viewAsNHX() {
1012         removeTextFrame();
1013         if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty()
1014                 || ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
1015             return;
1016         }
1017         _textframe = TextFrame.instantiate( getMainPanel().getCurrentPhylogeny().toNewHampshireX() );
1018     }
1019
1020     void viewAsXML() {
1021         removeTextFrame();
1022         if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty()
1023                 || ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
1024             return;
1025         }
1026         _textframe = TextFrame.instantiate( getMainPanel().getCurrentPhylogeny().toPhyloXML( 0 ) );
1027     }
1028
1029     static void setupScreenTextAntialias( final List<TreePanel> treepanels, final boolean antialias ) {
1030         for( final TreePanel tree_panel : treepanels ) {
1031             tree_panel.setTextAntialias();
1032         }
1033     }
1034 }