2 package org.forester.archaeopteryx;
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.ByteArrayOutputStream;
12 import java.io.IOException;
14 import java.util.LinkedList;
15 import java.util.List;
16 import java.util.NoSuchElementException;
18 import javax.swing.ButtonGroup;
19 import javax.swing.JApplet;
20 import javax.swing.JCheckBoxMenuItem;
21 import javax.swing.JFileChooser;
22 import javax.swing.JMenu;
23 import javax.swing.JMenuBar;
24 import javax.swing.JMenuItem;
25 import javax.swing.JOptionPane;
26 import javax.swing.JRadioButtonMenuItem;
27 import javax.swing.UIManager;
28 import javax.swing.UnsupportedLookAndFeelException;
29 import javax.swing.event.ChangeEvent;
30 import javax.swing.event.ChangeListener;
32 import org.apache.commons.codec.binary.Base64;
33 import org.forester.archaeopteryx.AptxUtil.GraphicsExportType;
34 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
35 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
36 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
37 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
38 import org.forester.phylogeny.Phylogeny;
39 import org.forester.phylogeny.PhylogenyMethods;
40 import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
41 import org.forester.phylogeny.data.SequenceRelation;
42 import org.forester.sdi.GSDI;
43 import org.forester.sdi.GSDIR;
44 import org.forester.sdi.SDIException;
45 import org.forester.util.ForesterConstants;
46 import org.forester.util.ForesterUtil;
47 import org.forester.util.WindowsUtils;
50 // <applet archive="forester.jar"
51 // code="org.forester.archaeopteryx.ArchaeopteryxE.class"
52 // codebase="http://www.myserver.org/path/to/forester"
55 // alt="ArchaeopteryxE is not working on your system (requires at least Sun Java 1.5)!">
56 // <param name="url_of_tree_to_load"
57 // value="http://www.myserver.org/examples/data/apaf.xml">
58 // <param name="config_file"
59 // value="http://www.myserver.org/examples/config/config_file.txt">
61 public class ArchaeopteryxE extends JApplet implements ActionListener {
63 private final static String NAME = "ArchaeopteryxE";
64 private static final long serialVersionUID = -1220055577935759443L;
65 private Configuration _configuration;
66 private MainPanel _mainpanel;
67 private JMenuBar _jmenubar;
68 private JMenu _options_jmenu;
69 private JMenu _font_size_menu;
70 private JMenuItem _super_tiny_fonts_mi;
71 private JMenuItem _tiny_fonts_mi;
72 private JMenuItem _small_fonts_mi;
73 private JMenuItem _medium_fonts_mi;
74 private JMenuItem _large_fonts_mi;
75 private JMenu _tools_menu;
76 private JMenuItem _taxcolor_item;
77 private JMenuItem _confcolor_item;
78 private JMenuItem _midpoint_root_item;
79 private JMenu _view_jmenu;
80 private JMenuItem _view_as_XML_item;
81 private JMenuItem _view_as_NH_item;
82 private JMenuItem _view_as_nexus_item;
83 private JMenuItem _display_basic_information_item;
84 private JMenu _type_menu;
85 private JCheckBoxMenuItem _rectangular_type_cbmi;
86 private JCheckBoxMenuItem _triangular_type_cbmi;
87 private JCheckBoxMenuItem _curved_type_cbmi;
88 private JCheckBoxMenuItem _convex_type_cbmi;
89 private JCheckBoxMenuItem _euro_type_cbmi;
90 private JCheckBoxMenuItem _rounded_type_cbmi;
91 private JCheckBoxMenuItem _unrooted_type_cbmi;
92 private JCheckBoxMenuItem _circular_type_cbmi;
93 private JMenuItem _help_item;
94 private JMenuItem _about_item;
95 private JMenu _help_jmenu;
96 private JMenuItem _website_item;
97 private JMenuItem _phyloxml_website_item;
98 private JMenuItem _phyloxml_ref_item;
99 private JMenuItem _aptx_ref_item;
100 private JMenuItem _remove_branch_color_item;
101 private JMenuItem _remove_visual_styles_item;
102 private JCheckBoxMenuItem _show_domain_labels;
103 private JCheckBoxMenuItem _show_annotation_ref_source;
104 private JCheckBoxMenuItem _color_labels_same_as_parent_branch;
105 private JCheckBoxMenuItem _abbreviate_scientific_names;
106 private JCheckBoxMenuItem _screen_antialias_cbmi;
107 private JCheckBoxMenuItem _background_gradient_cbmi;
108 private JCheckBoxMenuItem _color_by_taxonomic_group_cbmi;
109 private JRadioButtonMenuItem _non_lined_up_cladograms_rbmi;
110 private JRadioButtonMenuItem _uniform_cladograms_rbmi;
111 private JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi;
112 private Options _options;
113 private JMenuItem _choose_font_mi;
114 private JMenuItem _switch_colors_mi;
115 JCheckBoxMenuItem _label_direction_cbmi;
116 private JCheckBoxMenuItem _show_scale_cbmi;
117 private JCheckBoxMenuItem _search_case_senstive_cbmi;
118 private JCheckBoxMenuItem _search_whole_words_only_cbmi;
119 private JCheckBoxMenuItem _inverse_search_result_cbmi;
120 private JCheckBoxMenuItem _search_with_regex_cbmi;
121 private JCheckBoxMenuItem _show_overview_cbmi;
122 private JMenuItem _choose_minimal_confidence_mi;
123 private JMenuItem _collapse_species_specific_subtrees;
124 private JMenuItem _overview_placment_mi;
125 private ButtonGroup _radio_group_1;
126 private JCheckBoxMenuItem _show_default_node_shapes_internal_cbmi;
127 private JCheckBoxMenuItem _show_default_node_shapes_external_cbmi;
128 private JCheckBoxMenuItem _show_default_node_shapes_for_marked_cbmi;
129 private JMenuItem _cycle_node_shape_mi;
130 private JMenuItem _cycle_node_fill_mi;
131 private JMenuItem _choose_node_size_mi;
132 private JCheckBoxMenuItem _show_confidence_stddev_cbmi;
133 private final LinkedList<TextFrame> _textframes = new LinkedList<TextFrame>();
134 private JMenu _analysis_menu;
135 private JMenuItem _gsdi_item;
136 private JMenuItem _gsdir_item;
137 private Phylogeny _species_tree;
138 private JCheckBoxMenuItem _right_line_up_domains_cbmi;
139 private JCheckBoxMenuItem _line_up_renderable_data_cbmi;
141 private JMenuItem _open_item;
142 private JMenuItem _open_url_item;
143 private JMenuItem _save_item;
144 private JMenuItem _save_all_item;
145 private JMenuItem _close_item;
146 private JMenuItem _exit_item;
147 private JMenuItem _new_item;
148 private JMenuItem _print_item;
149 private JMenuItem _write_to_pdf_item;
150 private JMenuItem _write_to_jpg_item;
151 private JMenuItem _write_to_gif_item;
152 private JMenuItem _write_to_tif_item;
153 private JMenuItem _write_to_png_item;
154 private JMenuItem _write_to_bmp_item;
155 private JMenu _file_jmenu;
156 private JFileChooser _writetopdf_filechooser;
157 private File _current_dir;
158 private JFileChooser _save_filechooser;
159 private JFileChooser _writetographics_filechooser;
161 void setCurrentDir( final File current_dir ) {
162 _current_dir = current_dir;
165 File getCurrentDir() {
166 if ( ( _current_dir == null ) || !_current_dir.canRead() ) {
167 if ( ForesterUtil.isWindows() ) {
169 _current_dir = new File( WindowsUtils.getCurrentUserDesktopPath() );
171 catch ( final Exception e ) {
176 if ( ( _current_dir == null ) || !_current_dir.canRead() ) {
177 if ( System.getProperty( "user.home" ) != null ) {
178 _current_dir = new File( System.getProperty( "user.home" ) );
180 else if ( System.getProperty( "user.dir" ) != null ) {
181 _current_dir = new File( System.getProperty( "user.dir" ) );
187 void buildFileMenu() {
188 _file_jmenu = MainFrame.createMenu( "File", getConfiguration() );
189 _file_jmenu.add( _save_item = new JMenuItem( "Save Tree As..." ) );
190 _file_jmenu.addSeparator();
191 _file_jmenu.add( _write_to_pdf_item = new JMenuItem( "Export to PDF file ..." ) );
192 if ( AptxUtil.canWriteFormat( "tif" ) || AptxUtil.canWriteFormat( "tiff" ) || AptxUtil.canWriteFormat( "TIF" ) ) {
193 _file_jmenu.add( _write_to_tif_item = new JMenuItem( "Export to TIFF file..." ) );
195 _file_jmenu.add( _write_to_png_item = new JMenuItem( "Export to PNG file..." ) );
196 _file_jmenu.add( _write_to_jpg_item = new JMenuItem( "Export to JPG file..." ) );
197 if ( AptxUtil.canWriteFormat( "gif" ) ) {
198 _file_jmenu.add( _write_to_gif_item = new JMenuItem( "Export to GIF file..." ) );
200 if ( AptxUtil.canWriteFormat( "bmp" ) ) {
201 _file_jmenu.add( _write_to_bmp_item = new JMenuItem( "Export to BMP file..." ) );
203 _file_jmenu.addSeparator();
204 _file_jmenu.add( _print_item = new JMenuItem( "Print..." ) );
205 _file_jmenu.addSeparator();
206 _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );
207 customizeJMenuItem( _save_item );
208 customizeJMenuItem( _write_to_pdf_item );
209 customizeJMenuItem( _write_to_png_item );
210 customizeJMenuItem( _write_to_jpg_item );
211 customizeJMenuItem( _write_to_gif_item );
212 customizeJMenuItem( _write_to_tif_item );
213 customizeJMenuItem( _write_to_bmp_item );
214 customizeJMenuItem( _print_item );
215 customizeJMenuItem( _exit_item );
216 _jmenubar.add( _file_jmenu );
220 public void actionPerformed( final ActionEvent e ) {
221 final Object o = e.getSource();
222 if ( o == _midpoint_root_item ) {
223 getMainPanel().getCurrentTreePanel().midpointRoot();
225 else if ( o == _gsdi_item ) {
226 if ( isSubtreeDisplayed() ) {
231 else if ( o == _gsdir_item ) {
232 if ( isSubtreeDisplayed() ) {
237 else if ( o == _taxcolor_item ) {
238 getMainPanel().getCurrentTreePanel().taxColor();
240 else if ( o == _confcolor_item ) {
241 getMainPanel().getCurrentTreePanel().confColor();
243 else if ( o == _collapse_species_specific_subtrees ) {
244 if ( getCurrentTreePanel() != null ) {
245 getCurrentTreePanel().collapseSpeciesSpecificSubtrees();
248 else if ( o == _remove_branch_color_item ) {
249 removeBranchColors();
251 else if ( o == _remove_visual_styles_item ) {
252 removeVisualStyles();
254 else if ( o == _switch_colors_mi ) {
257 else if ( o == _display_basic_information_item ) {
258 displayBasicInformation();
260 else if ( o == _view_as_NH_item ) {
263 else if ( o == _view_as_XML_item ) {
266 else if ( o == _view_as_nexus_item ) {
269 else if ( o == _super_tiny_fonts_mi ) {
270 if ( getCurrentTreePanel() != null ) {
271 getCurrentTreePanel().setSuperTinyFonts();
272 getCurrentTreePanel().repaint();
275 else if ( o == _tiny_fonts_mi ) {
276 if ( getCurrentTreePanel() != null ) {
277 getCurrentTreePanel().setTinyFonts();
278 getCurrentTreePanel().repaint();
281 else if ( o == _small_fonts_mi ) {
282 if ( getCurrentTreePanel() != null ) {
283 getCurrentTreePanel().setSmallFonts();
284 getCurrentTreePanel().repaint();
287 else if ( o == _medium_fonts_mi ) {
288 if ( getCurrentTreePanel() != null ) {
289 getCurrentTreePanel().setMediumFonts();
290 getCurrentTreePanel().repaint();
293 else if ( o == _large_fonts_mi ) {
294 if ( getCurrentTreePanel() != null ) {
295 getCurrentTreePanel().setLargeFonts();
296 getCurrentTreePanel().repaint();
299 else if ( o == _choose_font_mi ) {
302 else if ( o == _choose_minimal_confidence_mi ) {
303 chooseMinimalConfidence();
305 else if ( o == _choose_node_size_mi ) {
306 MainFrame.chooseNodeSize( getOptions(), this );
308 else if ( o == _overview_placment_mi ) {
309 MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
311 else if ( o == _cycle_node_fill_mi ) {
312 MainFrame.cycleNodeFill( getOptions() );
314 else if ( o == _cycle_node_shape_mi ) {
315 MainFrame.cycleNodeShape( getOptions() );
317 else if ( o == _non_lined_up_cladograms_rbmi ) {
318 updateOptions( getOptions() );
319 _mainpanel.getControlPanel().showWhole();
321 else if ( o == _uniform_cladograms_rbmi ) {
322 updateOptions( getOptions() );
323 _mainpanel.getControlPanel().showWhole();
325 else if ( o == _ext_node_dependent_cladogram_rbmi ) {
326 updateOptions( getOptions() );
327 _mainpanel.getControlPanel().showWhole();
329 else if ( o == _search_case_senstive_cbmi ) {
330 updateOptions( getOptions() );
331 getMainPanel().getControlPanel().search0();
332 getMainPanel().getControlPanel().search1();
334 else if ( o == _search_whole_words_only_cbmi ) {
335 if ( ( _search_with_regex_cbmi != null ) && _search_whole_words_only_cbmi.isSelected() ) {
336 _search_with_regex_cbmi.setSelected( false );
338 updateOptions( getOptions() );
339 getMainPanel().getControlPanel().search0();
340 getMainPanel().getControlPanel().search1();
342 else if ( o == _inverse_search_result_cbmi ) {
343 updateOptions( getOptions() );
344 getMainPanel().getControlPanel().search0();
345 getMainPanel().getControlPanel().search1();
347 else if ( o == _search_with_regex_cbmi ) {
348 if ( ( _search_whole_words_only_cbmi != null ) && _search_with_regex_cbmi.isSelected() ) {
349 _search_whole_words_only_cbmi.setSelected( false );
351 if ( ( _search_case_senstive_cbmi != null ) && _search_with_regex_cbmi.isSelected() ) {
352 _search_case_senstive_cbmi.setSelected( true );
354 updateOptions( getOptions() );
355 getMainPanel().getControlPanel().search0();
356 getMainPanel().getControlPanel().search1();
358 else if ( o == _show_scale_cbmi ) {
359 updateOptions( getOptions() );
361 else if ( o == _show_confidence_stddev_cbmi ) {
362 updateOptions( getOptions() );
364 else if ( o == _label_direction_cbmi ) {
365 updateOptions( getOptions() );
367 else if ( o == _abbreviate_scientific_names ) {
368 updateOptions( getOptions() );
370 else if ( o == _show_overview_cbmi ) {
371 updateOptions( getOptions() );
372 if ( getCurrentTreePanel() != null ) {
373 getCurrentTreePanel().updateOvSizes();
376 else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
377 || ( o == _convex_type_cbmi ) || ( o == _rounded_type_cbmi ) || ( o == _euro_type_cbmi )
378 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
381 else if ( o == _screen_antialias_cbmi ) {
382 updateOptions( getOptions() );
383 setupScreenTextAntialias( getMainPanel().getTreePanels(), isScreenAntialias() );
385 else if ( o == _background_gradient_cbmi ) {
386 updateOptions( getOptions() );
388 else if ( o == _show_domain_labels ) {
389 updateOptions( getOptions() );
391 else if ( o == _color_labels_same_as_parent_branch ) {
392 updateOptions( getOptions() );
394 else if ( o == _show_default_node_shapes_internal_cbmi ) {
395 updateOptions( getOptions() );
397 else if ( o == _show_default_node_shapes_external_cbmi ) {
398 updateOptions( getOptions() );
400 else if ( o == _about_item ) {
403 else if ( o == _help_item ) {
405 AptxUtil.openWebsite( Constants.APTX_DOC_SITE, true, this );
407 catch ( final IOException e1 ) {
408 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
411 else if ( o == _website_item ) {
413 AptxUtil.openWebsite( Constants.APTX_WEB_SITE, true, this );
415 catch ( final IOException e1 ) {
416 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
419 else if ( o == _phyloxml_website_item ) {
421 AptxUtil.openWebsite( Constants.PHYLOXML_WEB_SITE, true, this );
423 catch ( final IOException e1 ) {
424 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
427 else if ( o == _aptx_ref_item ) {
429 AptxUtil.openWebsite( Constants.APTX_REFERENCE_URL, true, this );
431 catch ( final IOException e1 ) {
432 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
435 else if ( o == _phyloxml_ref_item ) {
437 AptxUtil.openWebsite( Constants.PHYLOXML_REFERENCE_URL, true, this );
439 catch ( final IOException e1 ) {
440 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
443 else if ( o == _color_by_taxonomic_group_cbmi ) {
444 updateOptions( getOptions() );
446 else if ( o == _line_up_renderable_data_cbmi ) {
447 if ( !_line_up_renderable_data_cbmi.isSelected() ) {
448 _right_line_up_domains_cbmi.setSelected( false );
450 updateOptions( getOptions() );
452 else if ( o == _right_line_up_domains_cbmi ) {
453 if ( _right_line_up_domains_cbmi.isSelected() ) {
454 _line_up_renderable_data_cbmi.setSelected( true );
456 updateOptions( getOptions() );
459 else if ( o == _write_to_pdf_item ) {
460 // writeToPdf( _mainpanel.getCurrentPhylogeny() );
461 final File curr_dir = MainFrame.writeToPdf( _mainpanel.getCurrentPhylogeny(),
463 _writetopdf_filechooser,
467 if ( curr_dir != null ) {
468 setCurrentDir( curr_dir );
471 else if ( o == _write_to_jpg_item ) {
472 final File curr_dir = MainFrame.writeToGraphicsFile( _mainpanel.getCurrentPhylogeny(),
473 GraphicsExportType.JPG,
475 _writetographics_filechooser,
479 if ( curr_dir != null ) {
480 setCurrentDir( curr_dir );
483 else if ( o == _write_to_gif_item ) {
484 final File curr_dir = MainFrame.writeToGraphicsFile( _mainpanel.getCurrentPhylogeny(),
485 GraphicsExportType.GIF,
487 _writetographics_filechooser,
491 if ( curr_dir != null ) {
492 setCurrentDir( curr_dir );
495 else if ( o == _write_to_tif_item ) {
496 final File curr_dir = MainFrame.writeToGraphicsFile( _mainpanel.getCurrentPhylogeny(),
497 GraphicsExportType.TIFF,
499 _writetographics_filechooser,
503 if ( curr_dir != null ) {
504 setCurrentDir( curr_dir );
507 else if ( o == _write_to_bmp_item ) {
508 final File curr_dir = MainFrame.writeToGraphicsFile( _mainpanel.getCurrentPhylogeny(),
509 GraphicsExportType.BMP,
511 _writetographics_filechooser,
515 if ( curr_dir != null ) {
516 setCurrentDir( curr_dir );
519 else if ( o == _write_to_png_item ) {
520 final File curr_dir = MainFrame.writeToGraphicsFile( _mainpanel.getCurrentPhylogeny(),
521 GraphicsExportType.PNG,
523 _writetographics_filechooser,
527 if ( curr_dir != null ) {
528 setCurrentDir( curr_dir );
531 else if ( o == _print_item ) {
532 MainFrame.print( getCurrentTreePanel(), getOptions(), this );
534 else if ( o == _save_item ) {
536 final File new_dir = MainFrame.writeToFile( _mainpanel.getCurrentPhylogeny() ,
537 getMainPanel(), _save_filechooser, _current_dir, getContentPane(), this );
539 if ( new_dir != null ) {
540 setCurrentDir( new_dir );
551 // else if ( o == _graphics_export_visible_only_cbmi ) {
552 // updateOptions( getOptions() );
554 // else if ( o == _antialias_print_cbmi ) {
555 // updateOptions( getOptions() );
557 // else if ( o == _print_black_and_white_cbmi ) {
558 // updateOptions( getOptions() );
560 // else if ( o == _print_using_actual_size_cbmi ) {
561 // updateOptions( getOptions() );
563 // else if ( o == _graphics_export_using_actual_size_cbmi ) {
564 // updateOptions( getOptions() );
566 // else if ( o == _print_size_mi ) {
567 // choosePrintSize();
569 // else if ( o == _choose_pdf_width_mi ) {
576 public void destroy() {
577 AptxUtil.printAppletMessage( NAME, "going to be destroyed " );
578 removeAllTextFrames();
579 if ( getMainPanel() != null ) {
580 getMainPanel().terminate();
585 * This method returns the current external node data which
586 * has been selected by the user by clicking the "Return ..."
587 * menu item. This method is expected to be called from Javascript or
590 * @return current external node data as String
592 public String getCurrentExternalNodesDataBuffer() {
593 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString();
596 public int getCurrentExternalNodesDataBufferChangeCounter() {
597 return getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter();
600 public int getCurrentExternalNodesDataBufferLength() {
601 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length();
605 * This method returns the current phylogeny as a string in the chosen format
607 * @param format must be NH, NHX, NEXUS or PHYLOXML
608 * @return the phylogeny string
609 * @author Herve Menager
611 public String getCurrentPhylogeny( final String format ) {
612 removeAllTextFrames();
613 if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty()
614 || ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
617 switch ( ForesterConstants.PhylogeneticTreeFormats.valueOf( format ) ) {
619 return getMainPanel().getCurrentPhylogeny().toNewHampshire();
621 return getMainPanel().getCurrentPhylogeny().toNewHampshireX();
623 return getMainPanel().getCurrentPhylogeny().toNexus();
625 return getMainPanel().getCurrentPhylogeny().toPhyloXML( -1 );
633 * This method returns a view of the current phylogeny in a chosen
634 * graphics format, base64-encoded in a string so that in can be used
637 * @param format must be GraphicsExportType (gif, jpg, pdf, png, tif, bmp)
638 * @return the phylogeny string
639 * @author Herve Menager
641 public String getCurrentPhylogenyGraphicsAsBase64EncodedString( final String format ) {
642 final ByteArrayOutputStream baos = new ByteArrayOutputStream();
644 AptxUtil.writePhylogenyToGraphicsByteArrayOutputStream( baos,
645 _mainpanel.getWidth(),
646 _mainpanel.getHeight(),
647 getCurrentTreePanel(),
648 getCurrentTreePanel().getControlPanel(),
649 GraphicsExportType.valueOf( format ),
652 catch ( final IOException ioe ) {
653 ForesterUtil.printErrorMessage( NAME, ioe.toString() );
654 ioe.printStackTrace();
655 JOptionPane.showMessageDialog( this,
656 NAME + ": Failed to generate graphics: " + "\nException: " + ioe,
657 "Failed to generate graphics",
658 JOptionPane.ERROR_MESSAGE );
661 final byte[] bytes = baos.toByteArray();
662 final String dataImg = Base64.encodeBase64String( bytes );
666 public Options getOptions() {
672 _writetopdf_filechooser = new JFileChooser();
673 _writetographics_filechooser = new JFileChooser();
674 final String config_filename = getParameter( Constants.APPLET_PARAM_NAME_FOR_CONFIG_FILE_URL );
675 AptxUtil.printAppletMessage( NAME, "URL for configuration file is: " + config_filename );
676 final Configuration configuration = new Configuration( config_filename, true, true, true );
677 setConfiguration( configuration );
678 setOptions( Options.createInstance( configuration ) );
680 final String tree_url_str = getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD );
681 if ( ForesterUtil.isEmpty( tree_url_str ) ) {
682 ForesterUtil.printErrorMessage( NAME, "could not get tree URL from "
683 + Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD );
684 JOptionPane.showMessageDialog( this, NAME + ": could not get tree URL from "
685 + Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD, "Failed get URL", JOptionPane.ERROR_MESSAGE );
688 AptxUtil.printAppletMessage( NAME, "URL for phylogenies is " + tree_url_str );
689 // Get URL to tree file
692 phys_url = new URL( tree_url_str );
694 catch ( final Exception e ) {
695 ForesterUtil.printErrorMessage( NAME, "error: " + e );
697 JOptionPane.showMessageDialog( this, NAME + ": Could not create URL from: \"" + tree_url_str
698 + "\"\nException: " + e, "Failed to create URL", JOptionPane.ERROR_MESSAGE );
700 if ( phys_url == null ) {
701 ForesterUtil.printErrorMessage( NAME, "failed to get tree URL from "
702 + Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD );
703 JOptionPane.showMessageDialog( this,
704 NAME + ": Could not create URL from: \"" + tree_url_str,
705 "Failed to create URL",
706 JOptionPane.ERROR_MESSAGE );
709 // Load the tree from URL
710 Phylogeny[] phys = null;
712 phys = AptxUtil.readPhylogeniesFromUrl( phys_url,
713 getConfiguration().isValidatePhyloXmlAgainstSchema(),
714 getConfiguration().isReplaceUnderscoresInNhParsing(),
715 getConfiguration().isInternalNumberAreConfidenceForNhParsing(),
716 getConfiguration().getTaxonomyExtraction(),
717 getConfiguration().isMidpointReroot() );
719 catch ( final Exception e ) {
720 ForesterUtil.printErrorMessage( NAME, e.toString() );
722 JOptionPane.showMessageDialog( this,
723 NAME + ": Failed to read phylogenies: " + "\nException: " + e,
724 "Failed to read phylogenies",
725 JOptionPane.ERROR_MESSAGE );
727 if ( phys == null ) {
728 ForesterUtil.printErrorMessage( NAME, "phylogenies from [" + phys_url + "] are null" );
729 JOptionPane.showMessageDialog( this,
730 NAME + ": phylogenies from [" + phys_url + "] are null",
731 "Failed to read phylogenies",
732 JOptionPane.ERROR_MESSAGE );
735 else if ( phys.length < 1 ) {
736 ForesterUtil.printErrorMessage( NAME, "phylogenies from [" + phys_url + "] are empty" );
737 JOptionPane.showMessageDialog( this,
738 NAME + ": phylogenies from [" + phys_url + "] are empty",
739 "Failed to read phylogenies",
740 JOptionPane.ERROR_MESSAGE );
744 AptxUtil.printAppletMessage( NAME, "loaded " + phys.length + " phylogenies from: " + phys_url );
747 final String species_tree_url_str = getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_SPECIES_TREE_TO_LOAD );
748 if ( !ForesterUtil.isEmpty( species_tree_url_str ) ) {
749 AptxUtil.printAppletMessage( NAME, "URL of species tree to load: \"" + species_tree_url_str + "\"" );
750 Phylogeny[] species_trees = null;
752 final URL species_tree_url = new URL( species_tree_url_str );
753 species_trees = AptxUtil.readPhylogeniesFromUrl( species_tree_url,
754 configuration.isValidatePhyloXmlAgainstSchema(),
755 configuration.isReplaceUnderscoresInNhParsing(),
757 TAXONOMY_EXTRACTION.NO,
760 catch ( final IOException e ) {
761 ForesterUtil.printErrorMessage( NAME, "could not read species tree from [" + species_tree_url_str
763 JOptionPane.showMessageDialog( this, NAME + ": could not read species tree from ["
764 + species_tree_url_str + "]", "Failed to read species tree", JOptionPane.ERROR_MESSAGE );
766 if ( ( species_trees != null ) && ( species_trees.length > 0 ) ) {
767 AptxUtil.printAppletMessage( NAME, "successfully read species tree" );
768 if ( species_trees[ 0 ].isEmpty() ) {
769 ForesterUtil.printErrorMessage( NAME, "species tree is empty" );
771 else if ( !species_trees[ 0 ].isRooted() ) {
772 ForesterUtil.printErrorMessage( NAME, "species tree is not rooted" );
775 setSpeciesTree( species_trees[ 0 ] );
776 AptxUtil.printAppletMessage( NAME, "species tree OK" );
783 setMainPanel( new MainPanelApplets( getConfiguration(), this ) );
784 _jmenubar = new JMenuBar();
785 if ( !getConfiguration().isHideControlPanelAndMenubar() ) {
787 if ( !getConfiguration().isUseNativeUI() ) {
788 _jmenubar.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
790 if ( getSpeciesTree() != null ) {
799 setJMenuBar( _jmenubar );
801 final Container contentpane = getContentPane();
802 contentpane.setLayout( new BorderLayout() );
803 contentpane.add( getMainPanel(), BorderLayout.CENTER );
804 addComponentListener( new ComponentAdapter() {
807 public void componentResized( final ComponentEvent e ) {
808 if ( getMainPanel().getCurrentTreePanel() != null ) {
809 getMainPanel().getCurrentTreePanel().calcParametersForPainting( getMainPanel()
810 .getCurrentTreePanel()
813 .getCurrentTreePanel()
818 if ( getConfiguration().isUseTabbedDisplay() ) {
820 AptxUtil.printAppletMessage( NAME, "using tabbed display" );
821 AptxUtil.addPhylogeniesToTabs( phys,
822 new File( phys_url.getFile() ).getName(),
827 catch ( final Exception e ) {
828 ForesterUtil.printErrorMessage( NAME, e.toString() );
833 AptxUtil.printAppletMessage( NAME, "not using tabbed display" );
834 if ( getSpeciesTree() != null ) {
835 AptxUtil.printAppletMessage( NAME,
836 "Warning: gsdi (gene duplication inference) only available tabbed display" );
838 AptxUtil.addPhylogenyToPanel( phys, getConfiguration(), getMainPanel() );
842 getMainPanel().getControlPanel().showWholeAll();
843 getMainPanel().getControlPanel().showWhole();
845 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().removeAllItems();
846 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
847 .getRelevantSequenceRelationTypes() ) {
848 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().addItem( type );
850 final String default_relation = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_SEQUENCE_RELATION_TYPE );
851 if ( default_relation != null ) {
852 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().setSelectedItem( default_relation );
854 final String default_sequence = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_QUERY_SEQUENCE );
855 if ( default_sequence != null ) {
856 getCurrentTreePanel().getControlPanel().getSequenceRelationBox().setSelectedItem( default_sequence );
860 AptxUtil.printAppletMessage( NAME, "successfully initialized" );
863 catch ( final Exception e ) {
864 ForesterUtil.printErrorMessage( NAME, e.toString() );
869 public void showTextFrame( final String s, final String title ) {
871 _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
875 public void start() {
876 if ( getMainPanel() != null ) {
877 getMainPanel().validate();
880 requestFocusInWindow();
882 AptxUtil.printAppletMessage( NAME, "started" );
885 void buildAnalysisMenu() {
886 _analysis_menu = MainFrame.createMenu( "Analysis", getConfiguration() );
887 _analysis_menu.add( _gsdi_item = new JMenuItem( "GSDI (Generalized Speciation Duplication Inference)" ) );
888 _analysis_menu.add( _gsdir_item = new JMenuItem( "GSDIR (GSDI with re-rooting)" ) );
889 customizeJMenuItem( _gsdi_item );
890 customizeJMenuItem( _gsdir_item );
891 // _analysis_menu.addSeparator();
892 // _analysis_menu.add( _lineage_inference = new JMenuItem( INFER_ANCESTOR_TAXONOMIES ) );
893 // customizeJMenuItem( _lineage_inference );
894 // _lineage_inference.setToolTipText( "Inference of ancestor taxonomies/lineages" );
895 _jmenubar.add( _analysis_menu );
898 void buildFontSizeMenu() {
899 _font_size_menu = MainFrame.createMenu( MainFrame.FONT_SIZE_MENU_LABEL, getConfiguration() );
900 _font_size_menu.add( _super_tiny_fonts_mi = new JMenuItem( "Super tiny fonts" ) );
901 _font_size_menu.add( _tiny_fonts_mi = new JMenuItem( "Tiny fonts" ) );
902 _font_size_menu.add( _small_fonts_mi = new JMenuItem( "Small fonts" ) );
903 _font_size_menu.add( _medium_fonts_mi = new JMenuItem( "Medium fonts" ) );
904 _font_size_menu.add( _large_fonts_mi = new JMenuItem( "Large fonts" ) );
905 customizeJMenuItem( _super_tiny_fonts_mi );
906 customizeJMenuItem( _tiny_fonts_mi );
907 customizeJMenuItem( _small_fonts_mi );
908 customizeJMenuItem( _medium_fonts_mi );
909 customizeJMenuItem( _large_fonts_mi );
910 _jmenubar.add( _font_size_menu );
913 void buildHelpMenu() {
914 _help_jmenu = MainFrame.createMenu( "Help", getConfiguration() );
915 _help_jmenu.add( _help_item = new JMenuItem( "Documentation" ) );
916 _help_jmenu.addSeparator();
917 _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
918 _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
919 _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
920 _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
921 _help_jmenu.addSeparator();
922 _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
923 customizeJMenuItem( _help_item );
924 customizeJMenuItem( _website_item );
925 customizeJMenuItem( _phyloxml_website_item );
926 customizeJMenuItem( _aptx_ref_item );
927 customizeJMenuItem( _phyloxml_ref_item );
928 customizeJMenuItem( _about_item );
929 _phyloxml_ref_item.setToolTipText( MainFrame.PHYLOXML_REF_TOOL_TIP );
930 _aptx_ref_item.setToolTipText( MainFrame.APTX_REF_TOOL_TIP );
931 _jmenubar.add( _help_jmenu );
934 void buildOptionsMenu() {
935 _options_jmenu = MainFrame.createMenu( MainFrame.OPTIONS_HEADER, getConfiguration() );
936 _options_jmenu.addChangeListener( new ChangeListener() {
939 public void stateChanged( final ChangeEvent e ) {
940 MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getOptions() );
941 MainFrame.setTextColorChooseMenuItem( _switch_colors_mi, getCurrentTreePanel() );
943 .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() );
944 MainFrame.setTextForFontChooserMenuItem( _choose_font_mi, MainFrame
945 .createCurrentFontDesc( getMainPanel().getTreeFontSet() ) );
946 MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() );
947 MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() );
948 MainFrame.setTextNodeSizeMenuItem( _choose_node_size_mi, getOptions() );
950 getMainPanel().getControlPanel().setVisibilityOfDomainStrucureCB();
951 getMainPanel().getControlPanel().setVisibilityOfX();
953 catch ( final Exception ignore ) {
954 // do nothing, not important.
958 _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.DISPLAY_SUBHEADER ),
959 getConfiguration() ) );
961 .add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );
962 _options_jmenu.add( _uniform_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.UNIFORM_CLADOGRAMS_LABEL ) );
964 .add( _non_lined_up_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.NON_LINED_UP_CLADOGRAMS_LABEL ) );
965 _radio_group_1 = new ButtonGroup();
966 _radio_group_1.add( _ext_node_dependent_cladogram_rbmi );
967 _radio_group_1.add( _uniform_cladograms_rbmi );
968 _radio_group_1.add( _non_lined_up_cladograms_rbmi );
969 _options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_OVERVIEW_LABEL ) );
970 _options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_SCALE_LABEL ) );
972 .add( _show_default_node_shapes_internal_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_INT ) );
974 .add( _show_default_node_shapes_external_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_EXT ) );
976 .add( _show_default_node_shapes_for_marked_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_MARKED ) );
977 _options_jmenu.add( _line_up_renderable_data_cbmi = new JCheckBoxMenuItem( MainFrame.LINE_UP_RENDERABLE_DATA ) );
978 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
979 _options_jmenu.add( _right_line_up_domains_cbmi = new JCheckBoxMenuItem( MainFrame.RIGHT_LINE_UP_DOMAINS ) );
980 _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( MainFrame.SHOW_DOMAIN_LABELS_LABEL ) );
982 _options_jmenu.add( _show_annotation_ref_source = new JCheckBoxMenuItem( MainFrame.SHOW_ANN_REF_SOURCE_LABEL ) );
983 _options_jmenu.add( _show_confidence_stddev_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_CONF_STDDEV_LABEL ) );
985 .add( _color_by_taxonomic_group_cbmi = new JCheckBoxMenuItem( MainFrame.COLOR_BY_TAXONOMIC_GROUP ) );
987 .add( _color_labels_same_as_parent_branch = new JCheckBoxMenuItem( MainFrame.COLOR_LABELS_LABEL ) );
988 _color_labels_same_as_parent_branch.setToolTipText( MainFrame.COLOR_LABELS_TIP );
989 _options_jmenu.add( _abbreviate_scientific_names = new JCheckBoxMenuItem( MainFrame.ABBREV_SN_LABEL ) );
990 _options_jmenu.add( _label_direction_cbmi = new JCheckBoxMenuItem( MainFrame.LABEL_DIRECTION_LABEL ) );
991 _label_direction_cbmi.setToolTipText( MainFrame.LABEL_DIRECTION_TIP );
992 _options_jmenu.add( _screen_antialias_cbmi = new JCheckBoxMenuItem( MainFrame.SCREEN_ANTIALIAS_LABEL ) );
993 _options_jmenu.add( _background_gradient_cbmi = new JCheckBoxMenuItem( MainFrame.BG_GRAD_LABEL ) );
994 _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL ) );
995 _options_jmenu.add( _cycle_node_fill_mi = new JMenuItem( MainFrame.CYCLE_NODE_FILL_LABEL ) );
996 _options_jmenu.add( _choose_node_size_mi = new JMenuItem( MainFrame.CHOOSE_NODE_SIZE_LABEL ) );
997 _options_jmenu.add( _choose_minimal_confidence_mi = new JMenuItem( "" ) );
998 _options_jmenu.add( _overview_placment_mi = new JMenuItem( "" ) );
999 _options_jmenu.add( _switch_colors_mi = new JMenuItem( "" ) );
1000 _options_jmenu.add( _choose_font_mi = new JMenuItem( "" ) );
1001 _options_jmenu.addSeparator();
1002 _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.SEARCH_SUBHEADER ),
1003 getConfiguration() ) );
1005 .add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_CASE_SENSITIVE_LABEL ) );
1006 _options_jmenu.add( _search_whole_words_only_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_TERMS_ONLY_LABEL ) );
1007 _options_jmenu.add( _search_with_regex_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_REGEX_LABEL ) );
1008 _search_with_regex_cbmi.setToolTipText( MainFrame.SEARCH_WITH_REGEX_TIP );
1010 .add( _inverse_search_result_cbmi = new JCheckBoxMenuItem( MainFrame.INVERSE_SEARCH_RESULT_LABEL ) );
1011 customizeJMenuItem( _choose_font_mi );
1012 customizeJMenuItem( _choose_minimal_confidence_mi );
1013 customizeJMenuItem( _switch_colors_mi );
1014 customizeJMenuItem( _overview_placment_mi );
1015 customizeCheckBoxMenuItem( _color_by_taxonomic_group_cbmi, getOptions().isColorByTaxonomicGroup() );
1016 customizeCheckBoxMenuItem( _label_direction_cbmi,
1017 getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL );
1018 customizeCheckBoxMenuItem( _screen_antialias_cbmi, getOptions().isAntialiasScreen() );
1019 customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );
1020 customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );
1021 customizeCheckBoxMenuItem( _show_annotation_ref_source, getOptions().isShowAnnotationRefSource() );
1022 customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );
1023 customizeCheckBoxMenuItem( _show_default_node_shapes_external_cbmi, getOptions()
1024 .isShowDefaultNodeShapesExternal() );
1025 customizeCheckBoxMenuItem( _show_default_node_shapes_internal_cbmi, getOptions()
1026 .isShowDefaultNodeShapesInternal() );
1027 customizeCheckBoxMenuItem( _show_default_node_shapes_for_marked_cbmi, getOptions()
1028 .isShowDefaultNodeShapesForMarkedNodes() );
1029 customizeJMenuItem( _cycle_node_shape_mi );
1030 customizeJMenuItem( _cycle_node_fill_mi );
1031 customizeJMenuItem( _choose_node_size_mi );
1032 customizeCheckBoxMenuItem( _color_labels_same_as_parent_branch, getOptions().isColorLabelsSameAsParentBranch() );
1033 customizeCheckBoxMenuItem( _search_case_senstive_cbmi, getOptions().isSearchCaseSensitive() );
1034 customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );
1035 customizeRadioButtonMenuItem( _non_lined_up_cladograms_rbmi,
1036 getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP );
1037 customizeRadioButtonMenuItem( _uniform_cladograms_rbmi,
1038 getOptions().getCladogramType() == CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1039 customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi,
1040 getOptions().getCladogramType() == CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1041 customizeCheckBoxMenuItem( _show_overview_cbmi, getOptions().isShowOverview() );
1042 customizeCheckBoxMenuItem( _search_with_regex_cbmi, getOptions().isSearchWithRegex() );
1043 customizeCheckBoxMenuItem( _search_whole_words_only_cbmi, getOptions().isMatchWholeTermsOnly() );
1044 customizeCheckBoxMenuItem( _inverse_search_result_cbmi, getOptions().isInverseSearchResult() );
1045 customizeCheckBoxMenuItem( _show_confidence_stddev_cbmi, getOptions().isShowConfidenceStddev() );
1046 customizeCheckBoxMenuItem( _line_up_renderable_data_cbmi, getOptions().isLineUpRendarableNodeData() );
1047 customizeCheckBoxMenuItem( _right_line_up_domains_cbmi, getOptions().isRightLineUpDomains() );
1048 _jmenubar.add( _options_jmenu );
1051 void buildToolsMenu() {
1052 _tools_menu = MainFrame.createMenu( "Tools", getConfiguration() );
1053 _tools_menu.add( _confcolor_item = new JMenuItem( "Colorize Branches Depending on Confidence" ) );
1054 customizeJMenuItem( _confcolor_item );
1055 _tools_menu.add( _taxcolor_item = new JMenuItem( "Taxonomy Colorize Branches" ) );
1056 customizeJMenuItem( _taxcolor_item );
1057 _tools_menu.addSeparator();
1058 _tools_menu.add( _remove_visual_styles_item = new JMenuItem( "Delete All Visual Styles From Nodes" ) );
1059 _remove_visual_styles_item
1060 .setToolTipText( "To remove all node visual styles (fonts, colors) from the current phylogeny." );
1061 customizeJMenuItem( _remove_visual_styles_item );
1062 _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete All Colors From Branches" ) );
1063 _remove_branch_color_item.setToolTipText( "To remove all branch color values from the current phylogeny." );
1064 customizeJMenuItem( _remove_branch_color_item );
1065 _tools_menu.addSeparator();
1066 _tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) );
1067 customizeJMenuItem( _midpoint_root_item );
1068 _tools_menu.addSeparator();
1069 _tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Species-Specific Subtrees" ) );
1070 customizeJMenuItem( _collapse_species_specific_subtrees );
1071 _jmenubar.add( _tools_menu );
1074 void buildTypeMenu() {
1075 _type_menu = MainFrame.createMenu( MainFrame.TYPE_MENU_HEADER, getConfiguration() );
1076 _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
1077 _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
1078 _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
1079 _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
1080 _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
1081 _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
1082 _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
1083 _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
1084 customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
1085 customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
1086 customizeCheckBoxMenuItem( _euro_type_cbmi, false );
1087 customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
1088 customizeCheckBoxMenuItem( _curved_type_cbmi, false );
1089 customizeCheckBoxMenuItem( _convex_type_cbmi, false );
1090 customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
1091 customizeCheckBoxMenuItem( _circular_type_cbmi, false );
1092 _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
1093 _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
1094 initializeTypeMenu( getOptions() );
1095 _jmenubar.add( _type_menu );
1098 void buildViewMenu() {
1099 _view_jmenu = MainFrame.createMenu( "View", getConfiguration() );
1101 .add( _display_basic_information_item = new JMenuItem( MainFrame.SHOW_BASIC_TREE_INFORMATION_LABEL ) );
1102 _view_jmenu.addSeparator();
1103 _view_jmenu.add( _view_as_XML_item = new JMenuItem( "as phyloXML" ) );
1104 _view_jmenu.add( _view_as_NH_item = new JMenuItem( "as Newick" ) );
1105 _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "as Nexus" ) );
1106 customizeJMenuItem( _display_basic_information_item );
1107 customizeJMenuItem( _view_as_NH_item );
1108 customizeJMenuItem( _view_as_XML_item );
1109 customizeJMenuItem( _view_as_nexus_item );
1110 _jmenubar.add( _view_jmenu );
1113 void checkTextFrames() {
1114 if ( _textframes.size() > 5 ) {
1116 if ( _textframes.getFirst() != null ) {
1117 _textframes.getFirst().removeMe();
1120 _textframes.removeFirst();
1123 catch ( final NoSuchElementException e ) {
1129 void clearCurrentExternalNodesDataBuffer() {
1130 getCurrentTreePanel().clearCurrentExternalNodesDataBuffer();
1133 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
1134 if ( item != null ) {
1135 item.setFont( MainFrame.menu_font );
1136 if ( !getConfiguration().isUseNativeUI() ) {
1137 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
1138 item.setForeground( getConfiguration().getGuiMenuTextColor() );
1140 item.setSelected( is_selected );
1141 item.addActionListener( this );
1145 void customizeJMenuItem( final JMenuItem jmi ) {
1146 if ( jmi != null ) {
1147 jmi.setFont( MainFrame.menu_font );
1148 if ( !getConfiguration().isUseNativeUI() ) {
1149 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
1150 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
1152 jmi.addActionListener( this );
1156 void displayBasicInformation() {
1157 if ( ( getMainPanel() != null ) && ( getMainPanel().getCurrentPhylogeny() != null )
1158 && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1159 String title = "Basic Information";
1160 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1161 title = title + " for \"" + _mainpanel.getCurrentPhylogeny().getName() + "\"";
1163 showTextFrame( AptxUtil.createBasicInformation( getMainPanel().getCurrentPhylogeny(), null ), title );
1167 void executeGSDI() {
1168 if ( !isOKforSDI( false, true ) ) {
1171 if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {
1172 JOptionPane.showMessageDialog( this,
1173 "Gene tree is not rooted.",
1174 "Cannot execute GSDI",
1175 JOptionPane.ERROR_MESSAGE );
1178 final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
1179 gene_tree.setAllNodesToNotCollapse();
1180 gene_tree.recalculateNumberOfExternalDescendants( false );
1182 final Phylogeny species_tree = _species_tree.copy();
1184 gsdi = new GSDI( gene_tree, species_tree, false, true, true, true );
1186 catch ( final SDIException e ) {
1187 JOptionPane.showMessageDialog( this,
1188 e.getLocalizedMessage(),
1189 "Error during GSDI",
1190 JOptionPane.ERROR_MESSAGE );
1193 catch ( final Exception e ) {
1194 AptxUtil.unexpectedException( e );
1197 gene_tree.setRerootable( false );
1198 gene_tree.clearHashIdToNodeMap();
1199 gene_tree.recalculateNumberOfExternalDescendants( true );
1200 _mainpanel.addPhylogenyInNewTab( gene_tree, getConfiguration(), "gene tree", null );
1201 getMainPanel().getControlPanel().setShowEvents( true );
1203 final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
1204 _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
1206 _mainpanel.getTabbedPane().setSelectedIndex( selected );
1208 _mainpanel.getCurrentTreePanel().setEdited( true );
1209 final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
1210 if ( gsdi.getStrippedExternalGeneTreeNodes().size() > 0 ) {
1211 JOptionPane.showMessageDialog( this,
1212 "Duplications: " + gsdi.getDuplicationsSum() + "\n"
1213 + "Potential duplications: "
1214 + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
1215 + "Speciations: " + gsdi.getSpeciationsSum() + "\n"
1216 + "Stripped gene tree nodes: "
1217 + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
1218 + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
1219 + "Number of polytomies in species tree used: " + poly + "\n",
1220 "GSDI successfully completed",
1221 JOptionPane.WARNING_MESSAGE );
1224 JOptionPane.showMessageDialog( this,
1225 "Duplications: " + gsdi.getDuplicationsSum() + "\n"
1226 + "Potential duplications: "
1227 + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
1228 + "Speciations: " + gsdi.getSpeciationsSum() + "\n"
1229 + "Stripped gene tree nodes: "
1230 + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
1231 + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
1232 + "Number of polytomies in species tree used: " + poly + "\n",
1233 "GSDI successfully completed",
1234 JOptionPane.INFORMATION_MESSAGE );
1238 void executeGSDIR() {
1239 if ( !isOKforSDI( false, false ) ) {
1242 final int p = PhylogenyMethods.countNumberOfPolytomies( _mainpanel.getCurrentPhylogeny() );
1244 && !( ( p == 1 ) && ( _mainpanel.getCurrentPhylogeny().getRoot().getNumberOfDescendants() == 3 ) ) ) {
1245 JOptionPane.showMessageDialog( this,
1246 "Gene tree is not completely binary",
1247 "Cannot execute GSDI",
1248 JOptionPane.ERROR_MESSAGE );
1251 final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
1252 gene_tree.setAllNodesToNotCollapse();
1253 gene_tree.recalculateNumberOfExternalDescendants( false );
1255 final Phylogeny species_tree = _species_tree.copy();
1257 gsdir = new GSDIR( gene_tree, species_tree, true, true, true );
1259 catch ( final SDIException e ) {
1260 JOptionPane.showMessageDialog( this,
1261 e.getLocalizedMessage(),
1262 "Error during GSDIR",
1263 JOptionPane.ERROR_MESSAGE );
1266 catch ( final Exception e ) {
1267 AptxUtil.unexpectedException( e );
1270 final Phylogeny result_gene_tree = gsdir.getMinDuplicationsSumGeneTree();
1271 result_gene_tree.setRerootable( false );
1272 result_gene_tree.clearHashIdToNodeMap();
1273 result_gene_tree.recalculateNumberOfExternalDescendants( true );
1274 PhylogenyMethods.orderAppearance( result_gene_tree.getRoot(), true, true, DESCENDANT_SORT_PRIORITY.NODE_NAME );
1275 _mainpanel.addPhylogenyInNewTab( result_gene_tree, getConfiguration(), "gene tree", null );
1276 getMainPanel().getControlPanel().setShowEvents( true );
1278 final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
1279 _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
1281 _mainpanel.getTabbedPane().setSelectedIndex( selected );
1283 _mainpanel.getCurrentTreePanel().setEdited( true );
1284 final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
1285 if ( gsdir.getStrippedExternalGeneTreeNodes().size() > 0 ) {
1286 JOptionPane.showMessageDialog( this,
1287 "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
1288 + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
1289 + "Stripped gene tree nodes: "
1290 + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
1291 + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
1292 + "Number of polytomies in species tree used: " + poly + "\n",
1293 "GSDIR successfully completed",
1294 JOptionPane.WARNING_MESSAGE );
1297 JOptionPane.showMessageDialog( this,
1298 "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
1299 + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
1300 + "Stripped gene tree nodes: "
1301 + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
1302 + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
1303 + "Number of polytomies in species tree used: " + poly + "\n",
1304 "GSDIR successfully completed",
1305 JOptionPane.INFORMATION_MESSAGE );
1309 Configuration getConfiguration() {
1310 return _configuration;
1313 TreePanel getCurrentTreePanel() {
1314 return getMainPanel().getCurrentTreePanel();
1317 JCheckBoxMenuItem getlabelDirectionCbmi() {
1318 return _label_direction_cbmi;
1321 Options getOtions() {
1325 void initializeTypeMenu( final Options options ) {
1326 setTypeMenuToAllUnselected();
1328 switch ( options.getPhylogenyGraphicsType() ) {
1330 _convex_type_cbmi.setSelected( true );
1333 _curved_type_cbmi.setSelected( true );
1336 _euro_type_cbmi.setSelected( true );
1339 _rounded_type_cbmi.setSelected( true );
1342 _triangular_type_cbmi.setSelected( true );
1345 _unrooted_type_cbmi.setSelected( true );
1348 _circular_type_cbmi.setSelected( true );
1351 _rectangular_type_cbmi.setSelected( true );
1355 catch ( final NullPointerException np ) {
1356 // In all likelihood, this is caused by menu-less display.
1360 boolean isOKforSDI( final boolean species_tree_has_to_binary, final boolean gene_tree_has_to_binary ) {
1361 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty() ) {
1364 else if ( ( _species_tree == null ) || _species_tree.isEmpty() ) {
1365 JOptionPane.showMessageDialog( this,
1366 "No species tree loaded",
1367 "Cannot execute GSDI",
1368 JOptionPane.ERROR_MESSAGE );
1371 else if ( species_tree_has_to_binary && !_species_tree.isCompletelyBinary() ) {
1372 JOptionPane.showMessageDialog( this,
1373 "Species tree is not completely binary",
1374 "Cannot execute GSDI",
1375 JOptionPane.ERROR_MESSAGE );
1378 else if ( gene_tree_has_to_binary && !_mainpanel.getCurrentPhylogeny().isCompletelyBinary() ) {
1379 JOptionPane.showMessageDialog( this,
1380 "Gene tree is not completely binary",
1381 "Cannot execute GSDI",
1382 JOptionPane.ERROR_MESSAGE );
1390 boolean isSubtreeDisplayed() {
1391 if ( getCurrentTreePanel() != null ) {
1392 if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
1394 .showMessageDialog( this,
1395 "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",
1396 "Operation can not be exectuted on a sub-tree",
1397 JOptionPane.WARNING_MESSAGE );
1404 void removeAllTextFrames() {
1405 for( final TextFrame tf : _textframes ) {
1410 _textframes.clear();
1413 void setConfiguration( final Configuration configuration ) {
1414 _configuration = configuration;
1417 void setOptions( final Options options ) {
1421 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
1422 setTypeMenuToAllUnselected();
1426 _circular_type_cbmi.setSelected( true );
1429 _convex_type_cbmi.setSelected( true );
1432 _curved_type_cbmi.setSelected( true );
1435 _euro_type_cbmi.setSelected( true );
1438 _rounded_type_cbmi.setSelected( true );
1441 _rectangular_type_cbmi.setSelected( true );
1444 _triangular_type_cbmi.setSelected( true );
1447 _unrooted_type_cbmi.setSelected( true );
1450 throw new IllegalArgumentException( "unknown type: " + type );
1453 catch ( final NullPointerException np ) {
1454 // In all likelihood, this is caused by menu-less display.
1458 void setTypeMenuToAllUnselected() {
1459 if ( _convex_type_cbmi != null ) {
1460 _convex_type_cbmi.setSelected( false );
1462 if ( _curved_type_cbmi != null ) {
1463 _curved_type_cbmi.setSelected( false );
1465 if ( _euro_type_cbmi != null ) {
1466 _euro_type_cbmi.setSelected( false );
1468 if ( _rounded_type_cbmi != null ) {
1469 _rounded_type_cbmi.setSelected( false );
1471 if ( _triangular_type_cbmi != null ) {
1472 _triangular_type_cbmi.setSelected( false );
1474 if ( _rectangular_type_cbmi != null ) {
1475 _rectangular_type_cbmi.setSelected( false );
1477 if ( _unrooted_type_cbmi != null ) {
1478 _unrooted_type_cbmi.setSelected( false );
1480 if ( _circular_type_cbmi != null ) {
1481 _circular_type_cbmi.setSelected( false );
1486 _mainpanel.getControlPanel().showWhole();
1489 void switchColors() {
1490 final TreeColorSet colorset = getMainPanel().getCurrentTreePanel().getTreeColorSet();
1491 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
1492 csc.setVisible( true );
1493 getMainPanel().setTreeColorSet( colorset );
1496 void typeChanged( final Object o ) {
1497 updateTypeCheckboxes( getOptions(), o );
1498 updateOptions( getOptions() );
1499 if ( getCurrentTreePanel() != null ) {
1500 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
1501 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
1502 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1503 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
1504 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1505 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
1506 getCurrentTreePanel().getControlPanel().showWhole();
1508 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1509 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
1512 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
1514 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
1515 MainFrame.updateScreenTextAntialias( getMainPanel().getTreePanels() );
1519 void updateOptions( final Options options ) {
1520 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
1521 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
1522 && _background_gradient_cbmi.isSelected() );
1523 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
1524 options.setShowAnnotationRefSource( ( _show_annotation_ref_source != null )
1525 && _show_annotation_ref_source.isSelected() );
1526 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
1527 && _abbreviate_scientific_names.isSelected() );
1528 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
1529 && _color_labels_same_as_parent_branch.isSelected() );
1530 options.setShowDefaultNodeShapesInternal( ( _show_default_node_shapes_internal_cbmi != null )
1531 && _show_default_node_shapes_internal_cbmi.isSelected() );
1532 options.setShowDefaultNodeShapesExternal( ( _show_default_node_shapes_external_cbmi != null )
1533 && _show_default_node_shapes_external_cbmi.isSelected() );
1534 options.setShowDefaultNodeShapesForMarkedNodes( ( _show_default_node_shapes_for_marked_cbmi != null )
1535 && _show_default_node_shapes_for_marked_cbmi.isSelected() );
1536 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
1537 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
1539 else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
1540 options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1542 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
1543 options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1545 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
1546 && _search_case_senstive_cbmi.isSelected() );
1547 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
1548 options.setShowScale( _show_scale_cbmi.isSelected() );
1550 if ( _label_direction_cbmi != null ) {
1551 if ( _label_direction_cbmi.isSelected() ) {
1552 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1555 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1558 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
1559 options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )
1560 && _show_confidence_stddev_cbmi.isSelected() );
1561 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
1562 && _search_whole_words_only_cbmi.isSelected() );
1563 options.setSearchWithRegex( ( _search_with_regex_cbmi != null ) && _search_with_regex_cbmi.isSelected() );
1564 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
1565 && _inverse_search_result_cbmi.isSelected() );
1566 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
1567 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1569 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
1570 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1572 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
1573 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1575 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
1576 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1578 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
1579 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1581 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
1582 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1584 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
1585 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1587 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
1588 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1590 if ( ( _color_by_taxonomic_group_cbmi != null ) && _color_by_taxonomic_group_cbmi.isEnabled() ) {
1591 options.setColorByTaxonomicGroup( _color_by_taxonomic_group_cbmi.isSelected() );
1593 if ( ( _right_line_up_domains_cbmi != null ) && _right_line_up_domains_cbmi.isEnabled() ) {
1594 options.setRightLineUpDomains( _right_line_up_domains_cbmi.isSelected() );
1596 if ( ( _line_up_renderable_data_cbmi != null ) && _line_up_renderable_data_cbmi.isEnabled() ) {
1597 options.setLineUpRendarableNodeData( _line_up_renderable_data_cbmi.isSelected() );
1601 void updateTypeCheckboxes( final Options options, final Object o ) {
1602 setTypeMenuToAllUnselected();
1603 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
1606 void viewAsNexus() {
1607 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1608 String title = "Nexus";
1609 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1610 title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;
1612 showTextFrame( getMainPanel().getCurrentPhylogeny().toNexus( getOptions()
1613 .getNhConversionSupportValueStyle() ),
1619 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1620 String title = "New Hampshire";
1621 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1622 title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;
1624 showTextFrame( getMainPanel().getCurrentPhylogeny().toNewHampshire( getOptions()
1625 .getNhConversionSupportValueStyle() ),
1631 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1632 String title = "phyloXML";
1633 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1634 title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;
1636 showTextFrame( getMainPanel().getCurrentPhylogeny().toPhyloXML( 0 ), title );
1640 private void chooseFont() {
1641 final FontChooser fc = new FontChooser();
1642 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
1643 fc.showDialog( this, "Select the Base Font" );
1644 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
1647 private void chooseMinimalConfidence() {
1648 final String s = ( String ) JOptionPane
1649 .showInputDialog( this,
1650 "Please the minimum for confidence values to be displayed.\n" + "[current value: "
1651 + getOptions().getMinConfidenceValue() + "]\n",
1652 "Minimal Confidence Value",
1653 JOptionPane.QUESTION_MESSAGE,
1656 getOptions().getMinConfidenceValue() );
1657 if ( !ForesterUtil.isEmpty( s ) ) {
1658 boolean success = true;
1660 final String m_str = s.trim();
1661 if ( !ForesterUtil.isEmpty( m_str ) ) {
1663 m = Double.parseDouble( m_str );
1665 catch ( final Exception ex ) {
1672 if ( success && ( m >= 0.0 ) ) {
1673 getOptions().setMinConfidenceValue( m );
1678 private void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
1679 if ( item != null ) {
1680 item.setFont( MainFrame.menu_font );
1681 if ( !getConfiguration().isUseNativeUI() ) {
1682 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
1683 item.setForeground( getConfiguration().getGuiMenuTextColor() );
1685 item.setSelected( is_selected );
1686 item.addActionListener( this );
1690 MainPanel getMainPanel() {
1694 private Phylogeny getSpeciesTree() {
1695 return _species_tree;
1698 private boolean isScreenAntialias() {
1702 private void removeBranchColors() {
1703 if ( getMainPanel().getCurrentPhylogeny() != null ) {
1704 AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
1708 private void removeVisualStyles() {
1709 if ( getMainPanel().getCurrentPhylogeny() != null ) {
1710 AptxUtil.removeVisualStyles( getMainPanel().getCurrentPhylogeny() );
1714 private void setMainPanel( final MainPanelApplets main_panel ) {
1715 _mainpanel = main_panel;
1718 private void setSpeciesTree( final Phylogeny species_tree ) {
1719 _species_tree = species_tree;
1722 private void setupUI() {
1724 if ( getConfiguration().isUseNativeUI() ) {
1725 UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
1728 UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
1731 catch ( final UnsupportedLookAndFeelException e ) {
1732 AptxUtil.dieWithSystemError( "UnsupportedLookAndFeelException: " + e.toString() );
1734 catch ( final ClassNotFoundException e ) {
1735 AptxUtil.dieWithSystemError( "ClassNotFoundException: " + e.toString() );
1737 catch ( final InstantiationException e ) {
1738 AptxUtil.dieWithSystemError( "InstantiationException: " + e.toString() );
1740 catch ( final IllegalAccessException e ) {
1741 AptxUtil.dieWithSystemError( "IllegalAccessException: " + e.toString() );
1743 catch ( final Exception e ) {
1744 AptxUtil.dieWithSystemError( e.toString() );
1748 static void setupScreenTextAntialias( final List<TreePanel> treepanels, final boolean antialias ) {
1749 for( final TreePanel tree_panel : treepanels ) {
1750 tree_panel.setTextAntialias();