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