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 _ext_node_dependent_cladogram_rbmi;
111 private Options _options;
112 private JMenuItem _choose_font_mi;
113 private JMenuItem _switch_colors_mi;
114 JCheckBoxMenuItem _label_direction_cbmi;
115 private JCheckBoxMenuItem _show_scale_cbmi;
116 private JCheckBoxMenuItem _search_case_senstive_cbmi;
117 private JCheckBoxMenuItem _search_whole_words_only_cbmi;
118 private JCheckBoxMenuItem _inverse_search_result_cbmi;
119 private JCheckBoxMenuItem _search_with_regex_cbmi;
120 private JCheckBoxMenuItem _show_overview_cbmi;
121 private JMenuItem _choose_minimal_confidence_mi;
122 private JMenuItem _collapse_species_specific_subtrees;
123 private JMenuItem _overview_placment_mi;
124 private ButtonGroup _radio_group_1;
125 private JCheckBoxMenuItem _show_default_node_shapes_internal_cbmi;
126 private JCheckBoxMenuItem _show_default_node_shapes_external_cbmi;
127 private JCheckBoxMenuItem _show_default_node_shapes_for_marked_cbmi;
128 private JMenuItem _cycle_node_shape_mi;
129 private JMenuItem _cycle_node_fill_mi;
130 private JMenuItem _choose_node_size_mi;
131 private JCheckBoxMenuItem _show_confidence_stddev_cbmi;
132 private final LinkedList<TextFrame> _textframes = new LinkedList<TextFrame>();
133 private JMenu _analysis_menu;
134 private JMenuItem _gsdi_item;
135 private JMenuItem _gsdir_item;
136 private Phylogeny _species_tree;
137 private JCheckBoxMenuItem _right_line_up_domains_cbmi;
138 private JCheckBoxMenuItem _line_up_renderable_data_cbmi;
140 private JMenuItem _save_item;
141 private JMenuItem _print_item;
142 private JMenuItem _write_to_pdf_item;
143 private JMenuItem _write_to_jpg_item;
144 private JMenuItem _write_to_gif_item;
145 private JMenuItem _write_to_tif_item;
146 private JMenuItem _write_to_png_item;
147 private JMenuItem _write_to_bmp_item;
148 private JMenu _file_jmenu;
149 private JFileChooser _writetopdf_filechooser;
150 private File _current_dir;
151 private JFileChooser _save_filechooser;
152 private JFileChooser _writetographics_filechooser;
153 private JCheckBoxMenuItem _graphics_export_visible_only_cbmi;
154 private JCheckBoxMenuItem _antialias_print_cbmi;
155 private JCheckBoxMenuItem _print_black_and_white_cbmi;
156 private JMenuItem _choose_pdf_width_mi;
159 public void actionPerformed( final ActionEvent e ) {
160 final Object o = e.getSource();
161 if ( o == _midpoint_root_item ) {
162 getMainPanel().getCurrentTreePanel().midpointRoot();
164 else if ( o == _gsdi_item ) {
165 if ( isSubtreeDisplayed() ) {
170 else if ( o == _gsdir_item ) {
171 if ( isSubtreeDisplayed() ) {
176 else if ( o == _taxcolor_item ) {
177 getMainPanel().getCurrentTreePanel().taxColor();
179 else if ( o == _confcolor_item ) {
180 getMainPanel().getCurrentTreePanel().confColor();
182 else if ( o == _collapse_species_specific_subtrees ) {
183 if ( getCurrentTreePanel() != null ) {
184 getCurrentTreePanel().collapseSpeciesSpecificSubtrees();
187 else if ( o == _remove_branch_color_item ) {
188 removeBranchColors();
190 else if ( o == _remove_visual_styles_item ) {
191 removeVisualStyles();
193 else if ( o == _switch_colors_mi ) {
196 else if ( o == _display_basic_information_item ) {
197 displayBasicInformation();
199 else if ( o == _view_as_NH_item ) {
202 else if ( o == _view_as_XML_item ) {
205 else if ( o == _view_as_nexus_item ) {
208 else if ( o == _super_tiny_fonts_mi ) {
209 if ( getCurrentTreePanel() != null ) {
210 getCurrentTreePanel().setSuperTinyFonts();
211 getCurrentTreePanel().repaint();
214 else if ( o == _tiny_fonts_mi ) {
215 if ( getCurrentTreePanel() != null ) {
216 getCurrentTreePanel().setTinyFonts();
217 getCurrentTreePanel().repaint();
220 else if ( o == _small_fonts_mi ) {
221 if ( getCurrentTreePanel() != null ) {
222 getCurrentTreePanel().setSmallFonts();
223 getCurrentTreePanel().repaint();
226 else if ( o == _medium_fonts_mi ) {
227 if ( getCurrentTreePanel() != null ) {
228 getCurrentTreePanel().setMediumFonts();
229 getCurrentTreePanel().repaint();
232 else if ( o == _large_fonts_mi ) {
233 if ( getCurrentTreePanel() != null ) {
234 getCurrentTreePanel().setLargeFonts();
235 getCurrentTreePanel().repaint();
238 else if ( o == _choose_font_mi ) {
241 else if ( o == _choose_minimal_confidence_mi ) {
242 chooseMinimalConfidence();
244 else if ( o == _choose_node_size_mi ) {
245 MainFrame.chooseNodeSize( getOptions(), this );
247 else if ( o == _overview_placment_mi ) {
248 MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
250 else if ( o == _cycle_node_fill_mi ) {
251 MainFrame.cycleNodeFill( getOptions() );
253 else if ( o == _cycle_node_shape_mi ) {
254 MainFrame.cycleNodeShape( getOptions() );
256 else if ( o == _non_lined_up_cladograms_rbmi ) {
257 updateOptions( getOptions() );
258 _mainpanel.getControlPanel().showWhole();
260 else if ( o == _ext_node_dependent_cladogram_rbmi ) {
261 updateOptions( getOptions() );
262 _mainpanel.getControlPanel().showWhole();
264 else if ( o == _search_case_senstive_cbmi ) {
265 updateOptions( getOptions() );
266 getMainPanel().getControlPanel().search0();
267 getMainPanel().getControlPanel().search1();
269 else if ( o == _search_whole_words_only_cbmi ) {
270 if ( ( _search_with_regex_cbmi != null ) && _search_whole_words_only_cbmi.isSelected() ) {
271 _search_with_regex_cbmi.setSelected( false );
273 updateOptions( getOptions() );
274 getMainPanel().getControlPanel().search0();
275 getMainPanel().getControlPanel().search1();
277 else if ( o == _inverse_search_result_cbmi ) {
278 updateOptions( getOptions() );
279 getMainPanel().getControlPanel().search0();
280 getMainPanel().getControlPanel().search1();
282 else if ( o == _search_with_regex_cbmi ) {
283 if ( ( _search_whole_words_only_cbmi != null ) && _search_with_regex_cbmi.isSelected() ) {
284 _search_whole_words_only_cbmi.setSelected( false );
286 if ( ( _search_case_senstive_cbmi != null ) && _search_with_regex_cbmi.isSelected() ) {
287 _search_case_senstive_cbmi.setSelected( true );
289 updateOptions( getOptions() );
290 getMainPanel().getControlPanel().search0();
291 getMainPanel().getControlPanel().search1();
293 else if ( o == _show_scale_cbmi ) {
294 updateOptions( getOptions() );
296 else if ( o == _show_confidence_stddev_cbmi ) {
297 updateOptions( getOptions() );
299 else if ( o == _label_direction_cbmi ) {
300 updateOptions( getOptions() );
302 else if ( o == _abbreviate_scientific_names ) {
303 updateOptions( getOptions() );
305 else if ( o == _show_overview_cbmi ) {
306 updateOptions( getOptions() );
307 if ( getCurrentTreePanel() != null ) {
308 getCurrentTreePanel().updateOvSizes();
311 else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
312 || ( o == _convex_type_cbmi ) || ( o == _rounded_type_cbmi ) || ( o == _euro_type_cbmi )
313 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
316 else if ( o == _screen_antialias_cbmi ) {
317 updateOptions( getOptions() );
318 setupScreenTextAntialias( getMainPanel().getTreePanels(), isScreenAntialias() );
320 else if ( o == _background_gradient_cbmi ) {
321 updateOptions( getOptions() );
323 else if ( o == _show_domain_labels ) {
324 updateOptions( getOptions() );
326 else if ( o == _color_labels_same_as_parent_branch ) {
327 updateOptions( getOptions() );
329 else if ( o == _show_default_node_shapes_internal_cbmi ) {
330 updateOptions( getOptions() );
332 else if ( o == _show_default_node_shapes_external_cbmi ) {
333 updateOptions( getOptions() );
335 else if ( o == _about_item ) {
336 getMainPanel().getMainFrame().about();
338 else if ( o == _help_item ) {
340 AptxUtil.openWebsite( AptxConstants.APTX_DOC_SITE, true, this );
342 catch ( final IOException e1 ) {
343 ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
346 else if ( o == _website_item ) {
348 AptxUtil.openWebsite( AptxConstants.APTX_WEB_SITE, true, this );
350 catch ( final IOException e1 ) {
351 ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
354 else if ( o == _phyloxml_website_item ) {
356 AptxUtil.openWebsite( AptxConstants.PHYLOXML_WEB_SITE, true, this );
358 catch ( final IOException e1 ) {
359 ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
362 else if ( o == _aptx_ref_item ) {
364 AptxUtil.openWebsite( AptxConstants.APTX_REFERENCE_URL, true, this );
366 catch ( final IOException e1 ) {
367 ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
370 else if ( o == _phyloxml_ref_item ) {
372 AptxUtil.openWebsite( AptxConstants.PHYLOXML_REFERENCE_URL, true, this );
374 catch ( final IOException e1 ) {
375 ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
378 else if ( o == _color_by_taxonomic_group_cbmi ) {
379 updateOptions( getOptions() );
381 else if ( o == _line_up_renderable_data_cbmi ) {
382 if ( !_line_up_renderable_data_cbmi.isSelected() ) {
383 _right_line_up_domains_cbmi.setSelected( false );
385 updateOptions( getOptions() );
387 else if ( o == _right_line_up_domains_cbmi ) {
388 if ( _right_line_up_domains_cbmi.isSelected() ) {
389 _line_up_renderable_data_cbmi.setSelected( true );
391 updateOptions( getOptions() );
393 else if ( o == _write_to_pdf_item ) {
394 final File curr_dir = MainFrame.writeToPdf( _mainpanel.getCurrentPhylogeny(),
396 _writetopdf_filechooser,
400 if ( curr_dir != null ) {
401 setCurrentDir( curr_dir );
404 else if ( o == _write_to_jpg_item ) {
405 final File curr_dir = MainFrame.writeToGraphicsFile( _mainpanel.getCurrentPhylogeny(),
406 GraphicsExportType.JPG,
408 _writetographics_filechooser,
412 if ( curr_dir != null ) {
413 setCurrentDir( curr_dir );
416 else if ( o == _write_to_gif_item ) {
417 final File curr_dir = MainFrame.writeToGraphicsFile( _mainpanel.getCurrentPhylogeny(),
418 GraphicsExportType.GIF,
420 _writetographics_filechooser,
424 if ( curr_dir != null ) {
425 setCurrentDir( curr_dir );
428 else if ( o == _write_to_tif_item ) {
429 final File curr_dir = MainFrame.writeToGraphicsFile( _mainpanel.getCurrentPhylogeny(),
430 GraphicsExportType.TIFF,
432 _writetographics_filechooser,
436 if ( curr_dir != null ) {
437 setCurrentDir( curr_dir );
440 else if ( o == _write_to_bmp_item ) {
441 final File curr_dir = MainFrame.writeToGraphicsFile( _mainpanel.getCurrentPhylogeny(),
442 GraphicsExportType.BMP,
444 _writetographics_filechooser,
448 if ( curr_dir != null ) {
449 setCurrentDir( curr_dir );
452 else if ( o == _write_to_png_item ) {
453 final File curr_dir = MainFrame.writeToGraphicsFile( _mainpanel.getCurrentPhylogeny(),
454 GraphicsExportType.PNG,
456 _writetographics_filechooser,
460 if ( curr_dir != null ) {
461 setCurrentDir( curr_dir );
464 else if ( o == _print_item ) {
465 MainFrame.print( getCurrentTreePanel(), getOptions(), this );
467 else if ( o == _save_item ) {
468 final File new_dir = MainFrame.writeToFile( _mainpanel.getCurrentPhylogeny(),
474 if ( new_dir != null ) {
475 setCurrentDir( new_dir );
478 else if ( o == _graphics_export_visible_only_cbmi ) {
479 updateOptions( getOptions() );
481 else if ( o == _antialias_print_cbmi ) {
482 updateOptions( getOptions() );
484 else if ( o == _print_black_and_white_cbmi ) {
485 updateOptions( getOptions() );
487 else if ( o == _choose_pdf_width_mi ) {
494 public void destroy() {
495 AptxUtil.printAppletMessage( NAME, "going to be destroyed " );
496 removeAllTextFrames();
497 if ( getMainPanel() != null ) {
498 getMainPanel().terminate();
503 * This method returns the current external node data which
504 * has been selected by the user by clicking the "Return ..."
505 * menu item. This method is expected to be called from Javascript or
508 * @return current external node data as String
510 public String getCurrentExternalNodesDataBuffer() {
511 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString();
514 public int getCurrentExternalNodesDataBufferChangeCounter() {
515 return getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter();
518 public int getCurrentExternalNodesDataBufferLength() {
519 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length();
523 * This method returns the current phylogeny as a string in the chosen format
525 * @param format must be NH, NHX, NEXUS or PHYLOXML
526 * @return the phylogeny string
527 * @author Herve Menager
529 public String getCurrentPhylogeny( final String format ) {
530 removeAllTextFrames();
531 if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty()
532 || ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
535 switch ( ForesterConstants.PhylogeneticTreeFormats.valueOf( format ) ) {
537 return getMainPanel().getCurrentPhylogeny().toNewHampshire();
539 return getMainPanel().getCurrentPhylogeny().toNewHampshireX();
541 return getMainPanel().getCurrentPhylogeny().toNexus();
543 return getMainPanel().getCurrentPhylogeny().toPhyloXML( -1 );
551 * This method returns a view of the current phylogeny in a chosen
552 * graphics format, base64-encoded in a string so that in can be used
555 * @param format must be GraphicsExportType (gif, jpg, pdf, png, tif, bmp)
556 * @return the phylogeny string
557 * @author Herve Menager
559 public String getCurrentPhylogenyGraphicsAsBase64EncodedString( final String format ) {
560 final ByteArrayOutputStream baos = new ByteArrayOutputStream();
562 AptxUtil.writePhylogenyToGraphicsByteArrayOutputStream( baos,
563 _mainpanel.getWidth(),
564 _mainpanel.getHeight(),
565 getCurrentTreePanel(),
566 getCurrentTreePanel().getControlPanel(),
567 GraphicsExportType.valueOf( format ),
570 catch ( final IOException ioe ) {
571 ForesterUtil.printErrorMessage( NAME, ioe.toString() );
572 ioe.printStackTrace();
573 JOptionPane.showMessageDialog( this,
574 NAME + ": Failed to generate graphics: " + "\nException: " + ioe,
575 "Failed to generate graphics",
576 JOptionPane.ERROR_MESSAGE );
579 final byte[] bytes = baos.toByteArray();
580 final String dataImg = Base64.encodeBase64String( bytes );
584 public Options getOptions() {
590 _writetopdf_filechooser = new JFileChooser();
591 _writetopdf_filechooser.setMultiSelectionEnabled( false );
592 _writetopdf_filechooser.addChoosableFileFilter( MainFrame.pdffilter );
593 _writetographics_filechooser = new JFileChooser();
594 _writetographics_filechooser.setMultiSelectionEnabled( false );
595 _writetographics_filechooser.addChoosableFileFilter( MainFrame.graphicsfilefilter );
596 _save_filechooser = new JFileChooser();
597 _save_filechooser.setMultiSelectionEnabled( false );
598 _save_filechooser.setFileFilter( MainFrame.xmlfilter );
599 _save_filechooser.addChoosableFileFilter( MainFrame.nhfilter );
600 _save_filechooser.addChoosableFileFilter( MainFrame.nexusfilter );
601 _save_filechooser.addChoosableFileFilter( _save_filechooser.getAcceptAllFileFilter() );
603 final String home_dir = System.getProperty( "user.home" );
604 _save_filechooser.setCurrentDirectory( new File( home_dir ) );
605 _writetopdf_filechooser.setCurrentDirectory( new File( home_dir ) );
606 _writetographics_filechooser.setCurrentDirectory( new File( home_dir ) );
608 catch ( final Exception e ) {
610 // Do nothing. Not important.
612 final String config_filename = getParameter( AptxConstants.APPLET_PARAM_NAME_FOR_CONFIG_FILE_URL );
613 AptxUtil.printAppletMessage( NAME, "URL for configuration file is: " + config_filename );
614 final Configuration configuration = new Configuration( config_filename, true, true, true );
615 setConfiguration( configuration );
616 setOptions( Options.createInstance( configuration ) );
618 final String tree_url_str = getParameter( AptxConstants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD );
619 if ( ForesterUtil.isEmpty( tree_url_str ) ) {
620 ForesterUtil.printErrorMessage( NAME, "could not get tree URL from "
621 + AptxConstants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD );
622 JOptionPane.showMessageDialog( this, NAME + ": could not get tree URL from "
623 + AptxConstants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD, "Failed get URL", JOptionPane.ERROR_MESSAGE );
626 AptxUtil.printAppletMessage( NAME, "URL for phylogenies is " + tree_url_str );
627 // Get URL to tree file
630 phys_url = new URL( tree_url_str );
632 catch ( final Exception e ) {
633 ForesterUtil.printErrorMessage( NAME, "error: " + e );
635 JOptionPane.showMessageDialog( this, NAME + ": Could not create URL from: \"" + tree_url_str
636 + "\"\nException: " + e, "Failed to create URL", JOptionPane.ERROR_MESSAGE );
638 if ( phys_url == null ) {
639 ForesterUtil.printErrorMessage( NAME, "failed to get tree URL from "
640 + AptxConstants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD );
641 JOptionPane.showMessageDialog( this,
642 NAME + ": Could not create URL from: \"" + tree_url_str,
643 "Failed to create URL",
644 JOptionPane.ERROR_MESSAGE );
647 // Load the tree from URL
648 Phylogeny[] phys = null;
650 phys = AptxUtil.readPhylogeniesFromUrl( phys_url,
651 getConfiguration().isValidatePhyloXmlAgainstSchema(),
652 getConfiguration().isReplaceUnderscoresInNhParsing(),
653 getConfiguration().isInternalNumberAreConfidenceForNhParsing(),
654 getConfiguration().getTaxonomyExtraction(),
655 getConfiguration().isMidpointReroot() );
657 catch ( final Exception e ) {
658 ForesterUtil.printErrorMessage( NAME, e.toString() );
660 JOptionPane.showMessageDialog( this,
661 NAME + ": Failed to read phylogenies: " + "\nException: " + e,
662 "Failed to read phylogenies",
663 JOptionPane.ERROR_MESSAGE );
665 if ( phys == null ) {
666 ForesterUtil.printErrorMessage( NAME, "phylogenies from [" + phys_url + "] are null" );
667 JOptionPane.showMessageDialog( this,
668 NAME + ": phylogenies from [" + phys_url + "] are null",
669 "Failed to read phylogenies",
670 JOptionPane.ERROR_MESSAGE );
673 else if ( phys.length < 1 ) {
674 ForesterUtil.printErrorMessage( NAME, "phylogenies from [" + phys_url + "] are empty" );
675 JOptionPane.showMessageDialog( this,
676 NAME + ": phylogenies from [" + phys_url + "] are empty",
677 "Failed to read phylogenies",
678 JOptionPane.ERROR_MESSAGE );
682 AptxUtil.printAppletMessage( NAME, "loaded " + phys.length + " phylogenies from: " + phys_url );
685 final String species_tree_url_str = getParameter( AptxConstants.APPLET_PARAM_NAME_FOR_URL_OF_SPECIES_TREE_TO_LOAD );
686 if ( !ForesterUtil.isEmpty( species_tree_url_str ) ) {
687 AptxUtil.printAppletMessage( NAME, "URL of species tree to load: \"" + species_tree_url_str + "\"" );
688 Phylogeny[] species_trees = null;
690 final URL species_tree_url = new URL( species_tree_url_str );
691 species_trees = AptxUtil.readPhylogeniesFromUrl( species_tree_url,
692 configuration.isValidatePhyloXmlAgainstSchema(),
693 configuration.isReplaceUnderscoresInNhParsing(),
695 TAXONOMY_EXTRACTION.NO,
698 catch ( final IOException e ) {
699 ForesterUtil.printErrorMessage( NAME, "could not read species tree from [" + species_tree_url_str
701 JOptionPane.showMessageDialog( this, NAME + ": could not read species tree from ["
702 + species_tree_url_str + "]", "Failed to read species tree", JOptionPane.ERROR_MESSAGE );
704 if ( ( species_trees != null ) && ( species_trees.length > 0 ) ) {
705 AptxUtil.printAppletMessage( NAME, "successfully read species tree" );
706 if ( species_trees[ 0 ].isEmpty() ) {
707 ForesterUtil.printErrorMessage( NAME, "species tree is empty" );
709 else if ( !species_trees[ 0 ].isRooted() ) {
710 ForesterUtil.printErrorMessage( NAME, "species tree is not rooted" );
713 setSpeciesTree( species_trees[ 0 ] );
714 AptxUtil.printAppletMessage( NAME, "species tree OK" );
720 setMainPanel( new MainPanelApplets( getConfiguration(), this ) );
721 _jmenubar = new JMenuBar();
722 if ( !getConfiguration().isHideControlPanelAndMenubar() ) {
724 if ( !getConfiguration().isUseNativeUI() ) {
725 _jmenubar.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
727 if ( getSpeciesTree() != null ) {
736 setJMenuBar( _jmenubar );
738 final Container contentpane = getContentPane();
739 contentpane.setLayout( new BorderLayout() );
740 contentpane.add( getMainPanel(), BorderLayout.CENTER );
741 addComponentListener( new ComponentAdapter() {
744 public void componentResized( final ComponentEvent e ) {
745 if ( getMainPanel().getCurrentTreePanel() != null ) {
746 getMainPanel().getCurrentTreePanel().calcParametersForPainting( getMainPanel()
747 .getCurrentTreePanel()
750 .getCurrentTreePanel()
755 if ( getConfiguration().isUseTabbedDisplay() ) {
757 AptxUtil.printAppletMessage( NAME, "using tabbed display" );
758 AptxUtil.addPhylogeniesToTabs( phys,
759 new File( phys_url.getFile() ).getName(),
764 catch ( final Exception e ) {
765 ForesterUtil.printErrorMessage( NAME, e.toString() );
770 AptxUtil.printAppletMessage( NAME, "not using tabbed display" );
771 if ( getSpeciesTree() != null ) {
772 AptxUtil.printAppletMessage( NAME,
773 "Warning: gsdi (gene duplication inference) only available tabbed display" );
775 AptxUtil.addPhylogenyToPanel( phys, getConfiguration(), getMainPanel() );
779 getMainPanel().getControlPanel().showWholeAll();
780 getMainPanel().getControlPanel().showWhole();
782 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().removeAllItems();
783 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
784 .getRelevantSequenceRelationTypes() ) {
785 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().addItem( type );
787 final String default_relation = getParameter( AptxConstants.APPLET_PARAM_NAME_FOR_DEFAULT_SEQUENCE_RELATION_TYPE );
788 if ( default_relation != null ) {
789 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().setSelectedItem( default_relation );
791 final String default_sequence = getParameter( AptxConstants.APPLET_PARAM_NAME_FOR_DEFAULT_QUERY_SEQUENCE );
792 if ( default_sequence != null ) {
793 getCurrentTreePanel().getControlPanel().getSequenceRelationBox().setSelectedItem( default_sequence );
797 AptxUtil.printAppletMessage( NAME, "successfully initialized" );
800 catch ( final Exception e ) {
801 ForesterUtil.printErrorMessage( NAME, e.toString() );
806 public void showTextFrame( final String s, final String title ) {
808 _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
812 public void start() {
813 if ( getMainPanel() != null ) {
814 getMainPanel().validate();
817 requestFocusInWindow();
819 AptxUtil.printAppletMessage( NAME, "started" );
822 private void chooseFont() {
823 final FontChooser fc = new FontChooser();
824 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
825 fc.showDialog( this, "Select the Base Font" );
826 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
829 private void chooseMinimalConfidence() {
830 final String s = ( String ) JOptionPane
831 .showInputDialog( this,
832 "Please the minimum for confidence values to be displayed.\n" + "[current value: "
833 + getOptions().getMinConfidenceValue() + "]\n",
834 "Minimal Confidence Value",
835 JOptionPane.QUESTION_MESSAGE,
838 getOptions().getMinConfidenceValue() );
839 if ( !ForesterUtil.isEmpty( s ) ) {
840 boolean success = true;
842 final String m_str = s.trim();
843 if ( !ForesterUtil.isEmpty( m_str ) ) {
845 m = Double.parseDouble( m_str );
847 catch ( final Exception ex ) {
854 if ( success && ( m >= 0.0 ) ) {
855 getOptions().setMinConfidenceValue( m );
860 private void choosePdfWidth() {
861 final String s = ( String ) JOptionPane.showInputDialog( this,
862 "Please enter the default line width for PDF export.\n"
864 + getOptions().getPrintLineWidth() + "]\n",
865 "Line Width for PDF Export",
866 JOptionPane.QUESTION_MESSAGE,
869 getOptions().getPrintLineWidth() );
870 if ( !ForesterUtil.isEmpty( s ) ) {
871 boolean success = true;
873 final String m_str = s.trim();
874 if ( !ForesterUtil.isEmpty( m_str ) ) {
876 f = Float.parseFloat( m_str );
878 catch ( final Exception ex ) {
885 if ( success && ( f > 0.0 ) ) {
886 getOptions().setPrintLineWidth( f );
891 private void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
892 if ( item != null ) {
893 item.setFont( MainFrame.menu_font );
894 if ( !getConfiguration().isUseNativeUI() ) {
895 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
896 item.setForeground( getConfiguration().getGuiMenuTextColor() );
898 item.setSelected( is_selected );
899 item.addActionListener( this );
903 private Phylogeny getSpeciesTree() {
904 return _species_tree;
907 private boolean isScreenAntialias() {
911 private void removeBranchColors() {
912 if ( getMainPanel().getCurrentPhylogeny() != null ) {
913 AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
917 private void removeVisualStyles() {
918 if ( getMainPanel().getCurrentPhylogeny() != null ) {
919 AptxUtil.removeVisualStyles( getMainPanel().getCurrentPhylogeny() );
923 private void setMainPanel( final MainPanelApplets main_panel ) {
924 _mainpanel = main_panel;
927 private void setSpeciesTree( final Phylogeny species_tree ) {
928 _species_tree = species_tree;
931 private void setupUI() {
933 if ( getConfiguration().isUseNativeUI() ) {
934 UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
937 UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
940 catch ( final UnsupportedLookAndFeelException e ) {
941 AptxUtil.dieWithSystemError( "UnsupportedLookAndFeelException: " + e.toString() );
943 catch ( final ClassNotFoundException e ) {
944 AptxUtil.dieWithSystemError( "ClassNotFoundException: " + e.toString() );
946 catch ( final InstantiationException e ) {
947 AptxUtil.dieWithSystemError( "InstantiationException: " + e.toString() );
949 catch ( final IllegalAccessException e ) {
950 AptxUtil.dieWithSystemError( "IllegalAccessException: " + e.toString() );
952 catch ( final Exception e ) {
953 AptxUtil.dieWithSystemError( e.toString() );
957 void buildAnalysisMenu() {
958 _analysis_menu = MainFrame.createMenu( "Analysis", getConfiguration() );
959 _analysis_menu.add( _gsdi_item = new JMenuItem( "GSDI (Generalized Speciation Duplication Inference)" ) );
960 _analysis_menu.add( _gsdir_item = new JMenuItem( "GSDIR (GSDI with re-rooting)" ) );
961 customizeJMenuItem( _gsdi_item );
962 customizeJMenuItem( _gsdir_item );
963 _analysis_menu.addSeparator();
964 _jmenubar.add( _analysis_menu );
967 void buildFileMenu() {
968 _file_jmenu = MainFrame.createMenu( "File", getConfiguration() );
969 _file_jmenu.add( _save_item = new JMenuItem( "Save Tree As..." ) );
970 _file_jmenu.addSeparator();
971 _file_jmenu.add( _write_to_pdf_item = new JMenuItem( "Export to PDF file ..." ) );
972 if ( AptxUtil.canWriteFormat( "tif" ) || AptxUtil.canWriteFormat( "tiff" ) || AptxUtil.canWriteFormat( "TIF" ) ) {
973 _file_jmenu.add( _write_to_tif_item = new JMenuItem( "Export to TIFF file..." ) );
975 _file_jmenu.add( _write_to_png_item = new JMenuItem( "Export to PNG file..." ) );
976 _file_jmenu.add( _write_to_jpg_item = new JMenuItem( "Export to JPG file..." ) );
977 if ( AptxUtil.canWriteFormat( "gif" ) ) {
978 _file_jmenu.add( _write_to_gif_item = new JMenuItem( "Export to GIF file..." ) );
980 if ( AptxUtil.canWriteFormat( "bmp" ) ) {
981 _file_jmenu.add( _write_to_bmp_item = new JMenuItem( "Export to BMP file..." ) );
983 _file_jmenu.addSeparator();
984 _file_jmenu.add( _print_item = new JMenuItem( "Print..." ) );
985 customizeJMenuItem( _save_item );
986 customizeJMenuItem( _write_to_pdf_item );
987 customizeJMenuItem( _write_to_png_item );
988 customizeJMenuItem( _write_to_jpg_item );
989 customizeJMenuItem( _write_to_gif_item );
990 customizeJMenuItem( _write_to_tif_item );
991 customizeJMenuItem( _write_to_bmp_item );
992 customizeJMenuItem( _print_item );
993 _jmenubar.add( _file_jmenu );
996 void buildFontSizeMenu() {
997 _font_size_menu = MainFrame.createMenu( MainFrame.FONT_SIZE_MENU_LABEL, getConfiguration() );
998 _font_size_menu.add( _super_tiny_fonts_mi = new JMenuItem( "Super tiny fonts" ) );
999 _font_size_menu.add( _tiny_fonts_mi = new JMenuItem( "Tiny fonts" ) );
1000 _font_size_menu.add( _small_fonts_mi = new JMenuItem( "Small fonts" ) );
1001 _font_size_menu.add( _medium_fonts_mi = new JMenuItem( "Medium fonts" ) );
1002 _font_size_menu.add( _large_fonts_mi = new JMenuItem( "Large fonts" ) );
1003 customizeJMenuItem( _super_tiny_fonts_mi );
1004 customizeJMenuItem( _tiny_fonts_mi );
1005 customizeJMenuItem( _small_fonts_mi );
1006 customizeJMenuItem( _medium_fonts_mi );
1007 customizeJMenuItem( _large_fonts_mi );
1008 _jmenubar.add( _font_size_menu );
1011 void buildHelpMenu() {
1012 _help_jmenu = MainFrame.createMenu( "Help", getConfiguration() );
1013 _help_jmenu.add( _help_item = new JMenuItem( "Documentation" ) );
1014 _help_jmenu.addSeparator();
1015 _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
1016 _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
1017 _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
1018 _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
1019 _help_jmenu.addSeparator();
1020 _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
1021 customizeJMenuItem( _help_item );
1022 customizeJMenuItem( _website_item );
1023 customizeJMenuItem( _phyloxml_website_item );
1024 customizeJMenuItem( _aptx_ref_item );
1025 customizeJMenuItem( _phyloxml_ref_item );
1026 customizeJMenuItem( _about_item );
1027 _phyloxml_ref_item.setToolTipText( MainFrame.PHYLOXML_REF_TOOL_TIP );
1028 _aptx_ref_item.setToolTipText( MainFrame.APTX_REF_TOOL_TIP );
1029 _jmenubar.add( _help_jmenu );
1032 void buildOptionsMenu() {
1033 _options_jmenu = MainFrame.createMenu( MainFrame.OPTIONS_HEADER, getConfiguration() );
1034 _options_jmenu.addChangeListener( new ChangeListener() {
1037 public void stateChanged( final ChangeEvent e ) {
1038 MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getOptions() );
1039 MainFrame.setTextColorChooseMenuItem( _switch_colors_mi, getCurrentTreePanel() );
1041 .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() );
1042 MainFrame.setTextForFontChooserMenuItem( _choose_font_mi, MainFrame
1043 .createCurrentFontDesc( getMainPanel().getTreeFontSet() ) );
1044 setTextForPdfLineWidthChooserMenuItem( _choose_pdf_width_mi, getOptions() );
1045 MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() );
1046 MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() );
1047 MainFrame.setTextNodeSizeMenuItem( _choose_node_size_mi, getOptions() );
1049 getMainPanel().getControlPanel().setVisibilityOfDomainStrucureCB();
1050 getMainPanel().getControlPanel().setVisibilityOfX();
1052 catch ( final Exception ignore ) {
1053 // do nothing, not important.
1057 _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.DISPLAY_SUBHEADER ),
1058 getConfiguration() ) );
1060 .add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );
1062 .add( _non_lined_up_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.NON_LINED_UP_CLADOGRAMS_LABEL ) );
1063 _radio_group_1 = new ButtonGroup();
1064 _radio_group_1.add( _ext_node_dependent_cladogram_rbmi );
1065 _radio_group_1.add( _non_lined_up_cladograms_rbmi );
1066 _options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_OVERVIEW_LABEL ) );
1067 _options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_SCALE_LABEL ) );
1069 .add( _show_default_node_shapes_internal_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_INT ) );
1071 .add( _show_default_node_shapes_external_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_EXT ) );
1073 .add( _show_default_node_shapes_for_marked_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_MARKED ) );
1074 _options_jmenu.add( _line_up_renderable_data_cbmi = new JCheckBoxMenuItem( MainFrame.LINE_UP_RENDERABLE_DATA ) );
1075 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
1076 _options_jmenu.add( _right_line_up_domains_cbmi = new JCheckBoxMenuItem( MainFrame.RIGHT_LINE_UP_DOMAINS ) );
1077 _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( MainFrame.SHOW_DOMAIN_LABELS_LABEL ) );
1079 _options_jmenu.add( _show_annotation_ref_source = new JCheckBoxMenuItem( MainFrame.SHOW_ANN_REF_SOURCE_LABEL ) );
1080 _options_jmenu.add( _show_confidence_stddev_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_CONF_STDDEV_LABEL ) );
1082 .add( _color_by_taxonomic_group_cbmi = new JCheckBoxMenuItem( MainFrame.COLOR_BY_TAXONOMIC_GROUP ) );
1084 .add( _color_labels_same_as_parent_branch = new JCheckBoxMenuItem( MainFrame.COLOR_LABELS_LABEL ) );
1085 _color_labels_same_as_parent_branch.setToolTipText( MainFrame.COLOR_LABELS_TIP );
1086 _options_jmenu.add( _abbreviate_scientific_names = new JCheckBoxMenuItem( MainFrame.ABBREV_SN_LABEL ) );
1087 _options_jmenu.add( _label_direction_cbmi = new JCheckBoxMenuItem( MainFrame.LABEL_DIRECTION_LABEL ) );
1088 _label_direction_cbmi.setToolTipText( MainFrame.LABEL_DIRECTION_TIP );
1089 _options_jmenu.add( _screen_antialias_cbmi = new JCheckBoxMenuItem( MainFrame.SCREEN_ANTIALIAS_LABEL ) );
1090 _options_jmenu.add( _background_gradient_cbmi = new JCheckBoxMenuItem( MainFrame.BG_GRAD_LABEL ) );
1091 _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL ) );
1092 _options_jmenu.add( _cycle_node_fill_mi = new JMenuItem( MainFrame.CYCLE_NODE_FILL_LABEL ) );
1093 _options_jmenu.add( _choose_node_size_mi = new JMenuItem( MainFrame.CHOOSE_NODE_SIZE_LABEL ) );
1094 _options_jmenu.add( _choose_minimal_confidence_mi = new JMenuItem( "" ) );
1095 _options_jmenu.add( _overview_placment_mi = new JMenuItem( "" ) );
1096 _options_jmenu.add( _switch_colors_mi = new JMenuItem( "" ) );
1097 _options_jmenu.add( _choose_font_mi = new JMenuItem( "" ) );
1098 _options_jmenu.addSeparator();
1099 _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.SEARCH_SUBHEADER ),
1100 getConfiguration() ) );
1102 .add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_CASE_SENSITIVE_LABEL ) );
1103 _options_jmenu.add( _search_whole_words_only_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_TERMS_ONLY_LABEL ) );
1104 _options_jmenu.add( _search_with_regex_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_REGEX_LABEL ) );
1105 _search_with_regex_cbmi.setToolTipText( MainFrame.SEARCH_WITH_REGEX_TIP );
1107 .add( _inverse_search_result_cbmi = new JCheckBoxMenuItem( MainFrame.INVERSE_SEARCH_RESULT_LABEL ) );
1109 _options_jmenu.addSeparator();
1110 _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( "Graphics Export & Printing:" ),
1111 getConfiguration() ) );
1112 _options_jmenu.add( _antialias_print_cbmi = new JCheckBoxMenuItem( "Antialias" ) );
1113 _options_jmenu.add( _print_black_and_white_cbmi = new JCheckBoxMenuItem( "Export in Black and White" ) );
1115 .add( _graphics_export_visible_only_cbmi = new JCheckBoxMenuItem( "Limit to Visible ('Screenshot') for PNG, JPG, and GIF export" ) );
1116 _options_jmenu.add( _choose_pdf_width_mi = new JMenuItem( "" ) );
1118 customizeCheckBoxMenuItem( _antialias_print_cbmi, getOptions().isAntialiasPrint() );
1119 customizeCheckBoxMenuItem( _print_black_and_white_cbmi, getOptions().isPrintBlackAndWhite() );
1120 customizeCheckBoxMenuItem( _graphics_export_visible_only_cbmi, getOptions().isGraphicsExportVisibleOnly() );
1121 customizeJMenuItem( _choose_pdf_width_mi );
1123 customizeJMenuItem( _choose_font_mi );
1124 customizeJMenuItem( _choose_minimal_confidence_mi );
1125 customizeJMenuItem( _switch_colors_mi );
1126 customizeJMenuItem( _overview_placment_mi );
1127 customizeCheckBoxMenuItem( _color_by_taxonomic_group_cbmi, getOptions().isColorByTaxonomicGroup() );
1128 customizeCheckBoxMenuItem( _label_direction_cbmi,
1129 getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL );
1130 customizeCheckBoxMenuItem( _screen_antialias_cbmi, getOptions().isAntialiasScreen() );
1131 customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );
1132 customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );
1133 customizeCheckBoxMenuItem( _show_annotation_ref_source, getOptions().isShowAnnotationRefSource() );
1134 customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );
1135 customizeCheckBoxMenuItem( _show_default_node_shapes_external_cbmi, getOptions()
1136 .isShowDefaultNodeShapesExternal() );
1137 customizeCheckBoxMenuItem( _show_default_node_shapes_internal_cbmi, getOptions()
1138 .isShowDefaultNodeShapesInternal() );
1139 customizeCheckBoxMenuItem( _show_default_node_shapes_for_marked_cbmi, getOptions()
1140 .isShowDefaultNodeShapesForMarkedNodes() );
1141 customizeJMenuItem( _cycle_node_shape_mi );
1142 customizeJMenuItem( _cycle_node_fill_mi );
1143 customizeJMenuItem( _choose_node_size_mi );
1144 customizeCheckBoxMenuItem( _color_labels_same_as_parent_branch, getOptions().isColorLabelsSameAsParentBranch() );
1145 customizeCheckBoxMenuItem( _search_case_senstive_cbmi, getOptions().isSearchCaseSensitive() );
1146 customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );
1147 customizeRadioButtonMenuItem( _non_lined_up_cladograms_rbmi,
1148 getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP );
1149 customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi,
1150 getOptions().getCladogramType() == CLADOGRAM_TYPE.LINED_UP );
1151 customizeCheckBoxMenuItem( _show_overview_cbmi, getOptions().isShowOverview() );
1152 customizeCheckBoxMenuItem( _search_with_regex_cbmi, getOptions().isSearchWithRegex() );
1153 customizeCheckBoxMenuItem( _search_whole_words_only_cbmi, getOptions().isMatchWholeTermsOnly() );
1154 customizeCheckBoxMenuItem( _inverse_search_result_cbmi, getOptions().isInverseSearchResult() );
1155 customizeCheckBoxMenuItem( _show_confidence_stddev_cbmi, getOptions().isShowConfidenceStddev() );
1156 customizeCheckBoxMenuItem( _line_up_renderable_data_cbmi, getOptions().isLineUpRendarableNodeData() );
1157 customizeCheckBoxMenuItem( _right_line_up_domains_cbmi, getOptions().isRightLineUpDomains() );
1158 _jmenubar.add( _options_jmenu );
1161 void buildToolsMenu() {
1162 _tools_menu = MainFrame.createMenu( "Tools", getConfiguration() );
1163 _tools_menu.add( _confcolor_item = new JMenuItem( "Colorize Branches Depending on Confidence" ) );
1164 customizeJMenuItem( _confcolor_item );
1165 _tools_menu.add( _taxcolor_item = new JMenuItem( "Taxonomy Colorize Branches" ) );
1166 customizeJMenuItem( _taxcolor_item );
1167 _tools_menu.addSeparator();
1168 _tools_menu.add( _remove_visual_styles_item = new JMenuItem( "Delete All Visual Styles From Nodes" ) );
1169 _remove_visual_styles_item
1170 .setToolTipText( "To remove all node visual styles (fonts, colors) from the current phylogeny." );
1171 customizeJMenuItem( _remove_visual_styles_item );
1172 _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete All Colors From Branches" ) );
1173 _remove_branch_color_item.setToolTipText( "To remove all branch color values from the current phylogeny." );
1174 customizeJMenuItem( _remove_branch_color_item );
1175 _tools_menu.addSeparator();
1176 _tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) );
1177 customizeJMenuItem( _midpoint_root_item );
1178 _tools_menu.addSeparator();
1179 _tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Species-Specific Subtrees" ) );
1180 customizeJMenuItem( _collapse_species_specific_subtrees );
1181 _jmenubar.add( _tools_menu );
1184 void buildTypeMenu() {
1185 _type_menu = MainFrame.createMenu( MainFrame.TYPE_MENU_HEADER, getConfiguration() );
1186 _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
1187 _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
1188 _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
1189 _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
1190 _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
1191 _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
1192 _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
1193 _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
1194 customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
1195 customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
1196 customizeCheckBoxMenuItem( _euro_type_cbmi, false );
1197 customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
1198 customizeCheckBoxMenuItem( _curved_type_cbmi, false );
1199 customizeCheckBoxMenuItem( _convex_type_cbmi, false );
1200 customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
1201 customizeCheckBoxMenuItem( _circular_type_cbmi, false );
1202 _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
1203 _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
1204 initializeTypeMenu( getOptions() );
1205 _jmenubar.add( _type_menu );
1208 void buildViewMenu() {
1209 _view_jmenu = MainFrame.createMenu( "View", getConfiguration() );
1211 .add( _display_basic_information_item = new JMenuItem( MainFrame.SHOW_BASIC_TREE_INFORMATION_LABEL ) );
1212 _view_jmenu.addSeparator();
1213 _view_jmenu.add( _view_as_XML_item = new JMenuItem( "as phyloXML" ) );
1214 _view_jmenu.add( _view_as_NH_item = new JMenuItem( "as Newick" ) );
1215 _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "as Nexus" ) );
1216 customizeJMenuItem( _display_basic_information_item );
1217 customizeJMenuItem( _view_as_NH_item );
1218 customizeJMenuItem( _view_as_XML_item );
1219 customizeJMenuItem( _view_as_nexus_item );
1220 _jmenubar.add( _view_jmenu );
1223 void checkTextFrames() {
1224 if ( _textframes.size() > 5 ) {
1226 if ( _textframes.getFirst() != null ) {
1227 _textframes.getFirst().removeMe();
1230 _textframes.removeFirst();
1233 catch ( final NoSuchElementException e ) {
1239 void clearCurrentExternalNodesDataBuffer() {
1240 getCurrentTreePanel().clearCurrentExternalNodesDataBuffer();
1243 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
1244 if ( item != null ) {
1245 item.setFont( MainFrame.menu_font );
1246 if ( !getConfiguration().isUseNativeUI() ) {
1247 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
1248 item.setForeground( getConfiguration().getGuiMenuTextColor() );
1250 item.setSelected( is_selected );
1251 item.addActionListener( this );
1255 void customizeJMenuItem( final JMenuItem jmi ) {
1256 if ( jmi != null ) {
1257 jmi.setFont( MainFrame.menu_font );
1258 if ( !getConfiguration().isUseNativeUI() ) {
1259 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
1260 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
1262 jmi.addActionListener( this );
1266 void displayBasicInformation() {
1267 if ( ( getMainPanel() != null ) && ( getMainPanel().getCurrentPhylogeny() != null )
1268 && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1269 String title = "Basic Information";
1270 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1271 title = title + " for \"" + _mainpanel.getCurrentPhylogeny().getName() + "\"";
1273 showTextFrame( AptxUtil.createBasicInformation( getMainPanel().getCurrentPhylogeny(), null ), title );
1277 void executeGSDI() {
1278 if ( !isOKforSDI( false, true ) ) {
1281 if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {
1282 JOptionPane.showMessageDialog( this,
1283 "Gene tree is not rooted.",
1284 "Cannot execute GSDI",
1285 JOptionPane.ERROR_MESSAGE );
1288 final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
1289 gene_tree.setAllNodesToNotCollapse();
1290 gene_tree.recalculateNumberOfExternalDescendants( false );
1292 final Phylogeny species_tree = _species_tree.copy();
1294 gsdi = new GSDI( gene_tree, species_tree, false, true, true, true );
1296 catch ( final SDIException e ) {
1297 JOptionPane.showMessageDialog( this,
1298 e.getLocalizedMessage(),
1299 "Error during GSDI",
1300 JOptionPane.ERROR_MESSAGE );
1303 catch ( final Exception e ) {
1304 AptxUtil.unexpectedException( e );
1307 gene_tree.setRerootable( false );
1308 gene_tree.clearHashIdToNodeMap();
1309 gene_tree.recalculateNumberOfExternalDescendants( true );
1310 _mainpanel.addPhylogenyInNewTab( gene_tree, getConfiguration(), "gene tree", null );
1311 getMainPanel().getControlPanel().setShowEvents( true );
1313 final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
1314 _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
1316 _mainpanel.getTabbedPane().setSelectedIndex( selected );
1318 _mainpanel.getCurrentTreePanel().setEdited( true );
1319 final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
1320 if ( gsdi.getStrippedExternalGeneTreeNodes().size() > 0 ) {
1321 JOptionPane.showMessageDialog( this,
1322 "Duplications: " + gsdi.getDuplicationsSum() + "\n"
1323 + "Potential duplications: "
1324 + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
1325 + "Speciations: " + gsdi.getSpeciationsSum() + "\n"
1326 + "Stripped gene tree nodes: "
1327 + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
1328 + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
1329 + "Number of polytomies in species tree used: " + poly + "\n",
1330 "GSDI successfully completed",
1331 JOptionPane.WARNING_MESSAGE );
1334 JOptionPane.showMessageDialog( this,
1335 "Duplications: " + gsdi.getDuplicationsSum() + "\n"
1336 + "Potential duplications: "
1337 + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
1338 + "Speciations: " + gsdi.getSpeciationsSum() + "\n"
1339 + "Stripped gene tree nodes: "
1340 + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
1341 + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
1342 + "Number of polytomies in species tree used: " + poly + "\n",
1343 "GSDI successfully completed",
1344 JOptionPane.INFORMATION_MESSAGE );
1348 void executeGSDIR() {
1349 if ( !isOKforSDI( false, false ) ) {
1352 final int p = PhylogenyMethods.countNumberOfPolytomies( _mainpanel.getCurrentPhylogeny() );
1354 && !( ( p == 1 ) && ( _mainpanel.getCurrentPhylogeny().getRoot().getNumberOfDescendants() == 3 ) ) ) {
1355 JOptionPane.showMessageDialog( this,
1356 "Gene tree is not completely binary",
1357 "Cannot execute GSDI",
1358 JOptionPane.ERROR_MESSAGE );
1361 final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
1362 gene_tree.setAllNodesToNotCollapse();
1363 gene_tree.recalculateNumberOfExternalDescendants( false );
1365 final Phylogeny species_tree = _species_tree.copy();
1367 gsdir = new GSDIR( gene_tree, species_tree, true, true, true );
1369 catch ( final SDIException e ) {
1370 JOptionPane.showMessageDialog( this,
1371 e.getLocalizedMessage(),
1372 "Error during GSDIR",
1373 JOptionPane.ERROR_MESSAGE );
1376 catch ( final Exception e ) {
1377 AptxUtil.unexpectedException( e );
1380 final Phylogeny result_gene_tree = gsdir.getMinDuplicationsSumGeneTree();
1381 result_gene_tree.setRerootable( false );
1382 result_gene_tree.clearHashIdToNodeMap();
1383 result_gene_tree.recalculateNumberOfExternalDescendants( true );
1384 PhylogenyMethods.orderAppearance( result_gene_tree.getRoot(), true, true, DESCENDANT_SORT_PRIORITY.NODE_NAME );
1385 _mainpanel.addPhylogenyInNewTab( result_gene_tree, getConfiguration(), "gene tree", null );
1386 getMainPanel().getControlPanel().setShowEvents( true );
1388 final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
1389 _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
1391 _mainpanel.getTabbedPane().setSelectedIndex( selected );
1393 _mainpanel.getCurrentTreePanel().setEdited( true );
1394 final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
1395 if ( gsdir.getStrippedExternalGeneTreeNodes().size() > 0 ) {
1396 JOptionPane.showMessageDialog( this,
1397 "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
1398 + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
1399 + "Stripped gene tree nodes: "
1400 + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
1401 + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
1402 + "Number of polytomies in species tree used: " + poly + "\n",
1403 "GSDIR successfully completed",
1404 JOptionPane.WARNING_MESSAGE );
1407 JOptionPane.showMessageDialog( this,
1408 "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
1409 + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
1410 + "Stripped gene tree nodes: "
1411 + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
1412 + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
1413 + "Number of polytomies in species tree used: " + poly + "\n",
1414 "GSDIR successfully completed",
1415 JOptionPane.INFORMATION_MESSAGE );
1419 Configuration getConfiguration() {
1420 return _configuration;
1423 File getCurrentDir() {
1424 if ( ( _current_dir == null ) || !_current_dir.canRead() ) {
1425 if ( ForesterUtil.isWindows() ) {
1427 _current_dir = new File( WindowsUtils.getCurrentUserDesktopPath() );
1429 catch ( final Exception e ) {
1430 _current_dir = null;
1434 if ( ( _current_dir == null ) || !_current_dir.canRead() ) {
1435 if ( System.getProperty( "user.home" ) != null ) {
1436 _current_dir = new File( System.getProperty( "user.home" ) );
1438 else if ( System.getProperty( "user.dir" ) != null ) {
1439 _current_dir = new File( System.getProperty( "user.dir" ) );
1442 return _current_dir;
1445 TreePanel getCurrentTreePanel() {
1446 return getMainPanel().getCurrentTreePanel();
1449 JCheckBoxMenuItem getlabelDirectionCbmi() {
1450 return _label_direction_cbmi;
1453 MainPanel getMainPanel() {
1457 Options getOtions() {
1461 void initializeTypeMenu( final Options options ) {
1462 setTypeMenuToAllUnselected();
1464 switch ( options.getPhylogenyGraphicsType() ) {
1466 _convex_type_cbmi.setSelected( true );
1469 _curved_type_cbmi.setSelected( true );
1472 _euro_type_cbmi.setSelected( true );
1475 _rounded_type_cbmi.setSelected( true );
1478 _triangular_type_cbmi.setSelected( true );
1481 _unrooted_type_cbmi.setSelected( true );
1484 _circular_type_cbmi.setSelected( true );
1487 _rectangular_type_cbmi.setSelected( true );
1491 catch ( final NullPointerException np ) {
1492 // In all likelihood, this is caused by menu-less display.
1496 boolean isOKforSDI( final boolean species_tree_has_to_binary, final boolean gene_tree_has_to_binary ) {
1497 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty() ) {
1500 else if ( ( _species_tree == null ) || _species_tree.isEmpty() ) {
1501 JOptionPane.showMessageDialog( this,
1502 "No species tree loaded",
1503 "Cannot execute GSDI",
1504 JOptionPane.ERROR_MESSAGE );
1507 else if ( species_tree_has_to_binary && !_species_tree.isCompletelyBinary() ) {
1508 JOptionPane.showMessageDialog( this,
1509 "Species tree is not completely binary",
1510 "Cannot execute GSDI",
1511 JOptionPane.ERROR_MESSAGE );
1514 else if ( gene_tree_has_to_binary && !_mainpanel.getCurrentPhylogeny().isCompletelyBinary() ) {
1515 JOptionPane.showMessageDialog( this,
1516 "Gene tree is not completely binary",
1517 "Cannot execute GSDI",
1518 JOptionPane.ERROR_MESSAGE );
1526 boolean isSubtreeDisplayed() {
1527 if ( getCurrentTreePanel() != null ) {
1528 if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
1530 .showMessageDialog( this,
1531 "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",
1532 "Operation can not be exectuted on a sub-tree",
1533 JOptionPane.WARNING_MESSAGE );
1540 void removeAllTextFrames() {
1541 for( final TextFrame tf : _textframes ) {
1546 _textframes.clear();
1549 void setConfiguration( final Configuration configuration ) {
1550 _configuration = configuration;
1553 void setCurrentDir( final File current_dir ) {
1554 _current_dir = current_dir;
1557 void setOptions( final Options options ) {
1561 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
1562 setTypeMenuToAllUnselected();
1566 _circular_type_cbmi.setSelected( true );
1569 _convex_type_cbmi.setSelected( true );
1572 _curved_type_cbmi.setSelected( true );
1575 _euro_type_cbmi.setSelected( true );
1578 _rounded_type_cbmi.setSelected( true );
1581 _rectangular_type_cbmi.setSelected( true );
1584 _triangular_type_cbmi.setSelected( true );
1587 _unrooted_type_cbmi.setSelected( true );
1590 throw new IllegalArgumentException( "unknown type: " + type );
1593 catch ( final NullPointerException np ) {
1594 // In all likelihood, this is caused by menu-less display.
1598 void setTypeMenuToAllUnselected() {
1599 if ( _convex_type_cbmi != null ) {
1600 _convex_type_cbmi.setSelected( false );
1602 if ( _curved_type_cbmi != null ) {
1603 _curved_type_cbmi.setSelected( false );
1605 if ( _euro_type_cbmi != null ) {
1606 _euro_type_cbmi.setSelected( false );
1608 if ( _rounded_type_cbmi != null ) {
1609 _rounded_type_cbmi.setSelected( false );
1611 if ( _triangular_type_cbmi != null ) {
1612 _triangular_type_cbmi.setSelected( false );
1614 if ( _rectangular_type_cbmi != null ) {
1615 _rectangular_type_cbmi.setSelected( false );
1617 if ( _unrooted_type_cbmi != null ) {
1618 _unrooted_type_cbmi.setSelected( false );
1620 if ( _circular_type_cbmi != null ) {
1621 _circular_type_cbmi.setSelected( false );
1626 _mainpanel.getControlPanel().showWhole();
1629 void switchColors() {
1630 final TreeColorSet colorset = getMainPanel().getCurrentTreePanel().getTreeColorSet();
1631 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
1632 csc.setVisible( true );
1633 getMainPanel().setTreeColorSet( colorset );
1636 void typeChanged( final Object o ) {
1637 updateTypeCheckboxes( getOptions(), o );
1638 updateOptions( getOptions() );
1639 if ( getCurrentTreePanel() != null ) {
1640 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
1641 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
1642 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1643 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
1644 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1645 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
1646 getCurrentTreePanel().getControlPanel().showWhole();
1648 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1649 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
1652 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
1654 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
1655 MainFrame.updateScreenTextAntialias( getMainPanel().getTreePanels() );
1659 void updateOptions( final Options options ) {
1660 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
1661 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
1662 && _background_gradient_cbmi.isSelected() );
1663 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
1664 options.setShowAnnotationRefSource( ( _show_annotation_ref_source != null )
1665 && _show_annotation_ref_source.isSelected() );
1666 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
1667 && _abbreviate_scientific_names.isSelected() );
1668 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
1669 && _color_labels_same_as_parent_branch.isSelected() );
1670 options.setShowDefaultNodeShapesInternal( ( _show_default_node_shapes_internal_cbmi != null )
1671 && _show_default_node_shapes_internal_cbmi.isSelected() );
1672 options.setShowDefaultNodeShapesExternal( ( _show_default_node_shapes_external_cbmi != null )
1673 && _show_default_node_shapes_external_cbmi.isSelected() );
1674 options.setShowDefaultNodeShapesForMarkedNodes( ( _show_default_node_shapes_for_marked_cbmi != null )
1675 && _show_default_node_shapes_for_marked_cbmi.isSelected() );
1676 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
1677 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
1680 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
1681 options.setCladogramType( CLADOGRAM_TYPE.LINED_UP );
1683 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
1684 && _search_case_senstive_cbmi.isSelected() );
1685 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
1686 options.setShowScale( _show_scale_cbmi.isSelected() );
1688 if ( _label_direction_cbmi != null ) {
1689 if ( _label_direction_cbmi.isSelected() ) {
1690 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1693 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1696 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
1697 options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )
1698 && _show_confidence_stddev_cbmi.isSelected() );
1699 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
1700 && _search_whole_words_only_cbmi.isSelected() );
1701 options.setSearchWithRegex( ( _search_with_regex_cbmi != null ) && _search_with_regex_cbmi.isSelected() );
1702 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
1703 && _inverse_search_result_cbmi.isSelected() );
1704 options.setAntialiasPrint( ( _antialias_print_cbmi != null ) && _antialias_print_cbmi.isSelected() );
1705 options.setPrintBlackAndWhite( ( _print_black_and_white_cbmi != null )
1706 && _print_black_and_white_cbmi.isSelected() );
1707 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
1708 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1710 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
1711 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1713 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
1714 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1716 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
1717 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1719 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
1720 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1722 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
1723 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1725 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
1726 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1728 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
1729 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1731 if ( ( _color_by_taxonomic_group_cbmi != null ) && _color_by_taxonomic_group_cbmi.isEnabled() ) {
1732 options.setColorByTaxonomicGroup( _color_by_taxonomic_group_cbmi.isSelected() );
1734 if ( ( _right_line_up_domains_cbmi != null ) && _right_line_up_domains_cbmi.isEnabled() ) {
1735 options.setRightLineUpDomains( _right_line_up_domains_cbmi.isSelected() );
1737 if ( ( _line_up_renderable_data_cbmi != null ) && _line_up_renderable_data_cbmi.isEnabled() ) {
1738 options.setLineUpRendarableNodeData( _line_up_renderable_data_cbmi.isSelected() );
1740 if ( _graphics_export_visible_only_cbmi != null ) {
1741 options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() );
1745 void updateTypeCheckboxes( final Options options, final Object o ) {
1746 setTypeMenuToAllUnselected();
1747 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
1750 void viewAsNexus() {
1751 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1752 String title = "Nexus";
1753 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1754 title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;
1756 showTextFrame( getMainPanel().getCurrentPhylogeny().toNexus( getOptions()
1757 .getNhConversionSupportValueStyle() ),
1763 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1764 String title = "New Hampshire";
1765 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1766 title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;
1768 showTextFrame( getMainPanel().getCurrentPhylogeny().toNewHampshire( getOptions()
1769 .getNhConversionSupportValueStyle() ),
1775 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1776 String title = "phyloXML";
1777 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1778 title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;
1780 showTextFrame( getMainPanel().getCurrentPhylogeny().toPhyloXML( 0 ), title );
1784 static void setTextForPdfLineWidthChooserMenuItem( final JMenuItem mi, final Options o ) {
1785 mi.setText( "Enter Default Line Width for PDF Export... (current: " + o.getPrintLineWidth() + ")" );
1788 static void setupScreenTextAntialias( final List<TreePanel> treepanels, final boolean antialias ) {
1789 for( final TreePanel tree_panel : treepanels ) {
1790 tree_panel.setTextAntialias();