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