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;
17 import java.util.NoSuchElementException;
19 import javax.swing.ButtonGroup;
20 import javax.swing.JApplet;
21 import javax.swing.JCheckBoxMenuItem;
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.phylogeny.Phylogeny;
38 import org.forester.phylogeny.data.SequenceRelation;
39 import org.forester.util.ForesterConstants;
40 import org.forester.util.ForesterUtil;
43 // <applet archive="forester.jar"
44 // code="org.forester.archaeopteryx.ArchaeopteryxE.class"
45 // codebase="http://www.myserver.org/path/to/forester"
48 // alt="ArchaeopteryxE is not working on your system (requires at least Sun Java 1.5)!">
49 // <param name="url_of_tree_to_load"
50 // value="http://www.myserver.org/examples/data/apaf.xml">
51 // <param name="config_file"
52 // value="http://www.myserver.org/examples/config/config_file.txt">
54 public class ArchaeopteryxE extends JApplet implements ActionListener {
56 private final static String NAME = "ArchaeopteryxE";
57 private static final long serialVersionUID = -1220055577935759443L;
58 private Configuration _configuration;
59 private MainPanelApplets _main_panel;
60 private JMenuBar _jmenubar;
61 private JMenu _options_jmenu;
62 private JMenu _font_size_menu;
63 private JMenuItem _super_tiny_fonts_mi;
64 private JMenuItem _tiny_fonts_mi;
65 private JMenuItem _small_fonts_mi;
66 private JMenuItem _medium_fonts_mi;
67 private JMenuItem _large_fonts_mi;
68 private JMenu _tools_menu;
69 private JMenuItem _taxcolor_item;
70 private JMenuItem _confcolor_item;
71 private JMenuItem _midpoint_root_item;
72 private JMenu _view_jmenu;
73 private JMenuItem _view_as_XML_item;
74 private JMenuItem _view_as_NH_item;
75 private JMenuItem _view_as_NHX_item;
76 private JMenuItem _view_as_nexus_item;
77 private JMenuItem _display_basic_information_item;
78 private JMenu _type_menu;
79 private JCheckBoxMenuItem _rectangular_type_cbmi;
80 private JCheckBoxMenuItem _triangular_type_cbmi;
81 private JCheckBoxMenuItem _curved_type_cbmi;
82 private JCheckBoxMenuItem _convex_type_cbmi;
83 private JCheckBoxMenuItem _euro_type_cbmi;
84 private JCheckBoxMenuItem _rounded_type_cbmi;
85 private JCheckBoxMenuItem _unrooted_type_cbmi;
86 private JCheckBoxMenuItem _circular_type_cbmi;
87 private JMenuItem _help_item;
88 private JMenuItem _about_item;
89 private JMenu _help_jmenu;
90 private JMenuItem _website_item;
91 private JMenuItem _phyloxml_website_item;
92 private JMenuItem _phyloxml_ref_item;
93 private JMenuItem _aptx_ref_item;
94 private JMenuItem _remove_branch_color_item;
95 private JMenuItem _infer_common_sn_names_item;
96 private JCheckBoxMenuItem _show_domain_labels;
97 private JCheckBoxMenuItem _color_labels_same_as_parent_branch;
98 private JCheckBoxMenuItem _abbreviate_scientific_names;
99 private JCheckBoxMenuItem _screen_antialias_cbmi;
100 private JCheckBoxMenuItem _background_gradient_cbmi;
101 private JRadioButtonMenuItem _non_lined_up_cladograms_rbmi;
102 private JRadioButtonMenuItem _uniform_cladograms_rbmi;
103 private JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi;
104 private Options _options;
105 private JMenuItem _choose_font_mi;
106 private JMenuItem _switch_colors_mi;
107 JCheckBoxMenuItem _label_direction_cbmi;
108 private JCheckBoxMenuItem _show_scale_cbmi;
109 private JCheckBoxMenuItem _search_case_senstive_cbmi;
110 private JCheckBoxMenuItem _search_whole_words_only_cbmi;
111 private JCheckBoxMenuItem _inverse_search_result_cbmi;
112 private JCheckBoxMenuItem _show_overview_cbmi;
113 private JMenuItem _choose_minimal_confidence_mi;
114 private JCheckBoxMenuItem _show_branch_length_values_cbmi;
115 private JMenuItem _collapse_species_specific_subtrees;
116 private JMenuItem _overview_placment_mi;
117 private ButtonGroup _radio_group_1;
118 private JCheckBoxMenuItem _show_default_node_shapes_cbmi;
119 private JMenuItem _cycle_node_shape_mi;
120 private JMenuItem _cycle_node_fill_mi;
121 private JMenuItem _choose_node_size_mi;
122 private JCheckBoxMenuItem _taxonomy_colorize_node_shapes_cbmi;
123 private JCheckBoxMenuItem _show_confidence_stddev_cbmi;
124 private final LinkedList<TextFrame> _textframes = new LinkedList<TextFrame>();
125 private String _ext_node_data_buffer = "";
128 public void actionPerformed( final ActionEvent e ) {
129 final Object o = e.getSource();
130 if ( o == _midpoint_root_item ) {
131 getMainPanel().getCurrentTreePanel().midpointRoot();
133 else if ( o == _taxcolor_item ) {
134 getMainPanel().getCurrentTreePanel().taxColor();
136 else if ( o == _confcolor_item ) {
137 getMainPanel().getCurrentTreePanel().confColor();
139 else if ( o == _collapse_species_specific_subtrees ) {
140 if ( getCurrentTreePanel() != null ) {
141 getCurrentTreePanel().collapseSpeciesSpecificSubtrees();
144 else if ( o == _remove_branch_color_item ) {
145 removeBranchColors();
147 else if ( o == _switch_colors_mi ) {
150 else if ( o == _display_basic_information_item ) {
151 displayBasicInformation();
153 else if ( o == _view_as_NH_item ) {
156 else if ( o == _view_as_NHX_item ) {
159 else if ( o == _view_as_XML_item ) {
162 else if ( o == _view_as_nexus_item ) {
165 else if ( o == _super_tiny_fonts_mi ) {
166 if ( getCurrentTreePanel() != null ) {
167 getCurrentTreePanel().setSuperTinyFonts();
168 getCurrentTreePanel().repaint();
171 else if ( o == _tiny_fonts_mi ) {
172 if ( getCurrentTreePanel() != null ) {
173 getCurrentTreePanel().setTinyFonts();
174 getCurrentTreePanel().repaint();
177 else if ( o == _small_fonts_mi ) {
178 if ( getCurrentTreePanel() != null ) {
179 getCurrentTreePanel().setSmallFonts();
180 getCurrentTreePanel().repaint();
183 else if ( o == _medium_fonts_mi ) {
184 if ( getCurrentTreePanel() != null ) {
185 getCurrentTreePanel().setMediumFonts();
186 getCurrentTreePanel().repaint();
189 else if ( o == _large_fonts_mi ) {
190 if ( getCurrentTreePanel() != null ) {
191 getCurrentTreePanel().setLargeFonts();
192 getCurrentTreePanel().repaint();
195 else if ( o == _choose_font_mi ) {
198 else if ( o == _choose_minimal_confidence_mi ) {
199 chooseMinimalConfidence();
201 else if ( o == _choose_node_size_mi ) {
202 MainFrame.chooseNodeSize( getOptions(), this );
204 else if ( o == _overview_placment_mi ) {
205 MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
207 else if ( o == _cycle_node_fill_mi ) {
208 MainFrame.cycleNodeFill( getOptions(), getCurrentTreePanel() );
210 else if ( o == _cycle_node_shape_mi ) {
211 MainFrame.cycleNodeShape( getOptions(), getCurrentTreePanel() );
213 else if ( o == _non_lined_up_cladograms_rbmi ) {
214 updateOptions( getOptions() );
215 _main_panel.getControlPanel().showWhole();
217 else if ( o == _uniform_cladograms_rbmi ) {
218 updateOptions( getOptions() );
219 _main_panel.getControlPanel().showWhole();
221 else if ( o == _ext_node_dependent_cladogram_rbmi ) {
222 updateOptions( getOptions() );
223 _main_panel.getControlPanel().showWhole();
225 else if ( o == _search_case_senstive_cbmi ) {
226 updateOptions( getOptions() );
227 getMainPanel().getControlPanel().search();
229 else if ( o == _search_whole_words_only_cbmi ) {
230 updateOptions( getOptions() );
231 getMainPanel().getControlPanel().search();
233 else if ( o == _inverse_search_result_cbmi ) {
234 updateOptions( getOptions() );
235 getMainPanel().getControlPanel().search();
237 else if ( o == _show_scale_cbmi ) {
238 updateOptions( getOptions() );
240 else if ( o == _show_branch_length_values_cbmi ) {
241 updateOptions( getOptions() );
243 else if ( o == _show_confidence_stddev_cbmi ) {
244 updateOptions( getOptions() );
246 else if ( o == _label_direction_cbmi ) {
247 updateOptions( getOptions() );
249 else if ( o == _show_overview_cbmi ) {
250 updateOptions( getOptions() );
251 if ( getCurrentTreePanel() != null ) {
252 getCurrentTreePanel().updateOvSizes();
255 else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
256 || ( o == _convex_type_cbmi ) || ( o == _rounded_type_cbmi ) || ( o == _euro_type_cbmi )
257 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
260 else if ( o == _screen_antialias_cbmi ) {
261 updateOptions( getOptions() );
262 setupScreenTextAntialias( getMainPanel().getTreePanels(), isScreenAntialias() );
264 else if ( o == _background_gradient_cbmi ) {
265 updateOptions( getOptions() );
267 else if ( o == _show_domain_labels ) {
268 updateOptions( getOptions() );
270 else if ( o == _color_labels_same_as_parent_branch ) {
271 updateOptions( getOptions() );
273 else if ( o == _show_default_node_shapes_cbmi ) {
274 updateOptions( getOptions() );
276 else if ( o == _taxonomy_colorize_node_shapes_cbmi ) {
277 updateOptions( getOptions() );
279 else if ( o == _about_item ) {
282 else if ( o == _help_item ) {
283 help( getConfiguration().getWebLinks() );
285 else if ( o == _website_item ) {
287 AptxUtil.openWebsite( Constants.APTX_WEB_SITE, true, this );
289 catch ( final IOException e1 ) {
290 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
293 else if ( o == _phyloxml_website_item ) {
295 AptxUtil.openWebsite( Constants.PHYLOXML_WEB_SITE, true, this );
297 catch ( final IOException e1 ) {
298 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
301 else if ( o == _aptx_ref_item ) {
303 AptxUtil.openWebsite( Constants.APTX_REFERENCE_URL, true, this );
305 catch ( final IOException e1 ) {
306 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
309 else if ( o == _phyloxml_ref_item ) {
311 AptxUtil.openWebsite( Constants.PHYLOXML_REFERENCE_URL, true, this );
313 catch ( final IOException e1 ) {
314 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
321 public void destroy() {
322 AptxUtil.printAppletMessage( NAME, "going to be destroyed " );
323 removeAllTextFrames();
324 if ( getMainPanel() != null ) {
325 getMainPanel().terminate();
330 * This method returns the current external node data which
331 * has been selected by the user by clicking the "Return ..."
332 * menu item. This method is expected to be called from Javascript or
335 * @return current external node data as String
337 public String getCurrentExternalNodesDataBuffer() {
338 return _ext_node_data_buffer;
342 * This method returns the current phylogeny as a string in the chosen format
344 * @param format must be NH, NHX, NEXUS or PHYLOXML
345 * @return the phylogeny string
346 * @author Herve Menager
348 public String getCurrentPhylogeny( final String format ) {
349 removeAllTextFrames();
350 if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty()
351 || ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
354 switch ( ForesterConstants.PhylogeneticTreeFormats.valueOf( format ) ) {
356 return getMainPanel().getCurrentPhylogeny().toNewHampshire();
358 return getMainPanel().getCurrentPhylogeny().toNewHampshireX();
360 return getMainPanel().getCurrentPhylogeny().toNexus();
362 return getMainPanel().getCurrentPhylogeny().toPhyloXML( -1 );
370 * This method returns a view of the current phylogeny in a chosen
371 * graphics format, base64-encoded in a string so that in can be used
374 * @param format must be GraphicsExportType (gif, jpg, pdf, png, tif, bmp)
375 * @return the phylogeny string
376 * @author Herve Menager
378 public String getCurrentPhylogenyGraphicsAsBase64EncodedString( final String format ) {
379 final ByteArrayOutputStream baos = new ByteArrayOutputStream();
381 AptxUtil.writePhylogenyToGraphicsByteArrayOutputStream( baos,
382 _main_panel.getWidth(),
383 _main_panel.getHeight(),
384 getCurrentTreePanel(),
385 getCurrentTreePanel().getControlPanel(),
386 GraphicsExportType.valueOf( format ),
389 catch ( final IOException ioe ) {
390 ForesterUtil.printErrorMessage( NAME, ioe.toString() );
391 ioe.printStackTrace();
392 JOptionPane.showMessageDialog( this,
393 NAME + ": Failed to generate graphics: " + "\nException: " + ioe,
394 "Failed to generate graphics",
395 JOptionPane.ERROR_MESSAGE );
398 final byte[] bytes = baos.toByteArray();
399 final String dataImg = Base64.encodeBase64String( bytes );
403 public Options getOptions() {
409 final String config_filename = getParameter( Constants.APPLET_PARAM_NAME_FOR_CONFIG_FILE_URL );
410 AptxUtil.printAppletMessage( NAME, "URL for configuration file is: " + config_filename );
411 final Configuration configuration = new Configuration( config_filename, true, true, true );
412 setConfiguration( configuration );
413 setOptions( Options.createInstance( configuration ) );
416 Phylogeny[] phys = null;
417 final String phys_url_string = getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD );
418 AptxUtil.printAppletMessage( NAME, "URL for phylogenies is " + phys_url_string );
419 // Get URL to tree file
420 if ( phys_url_string != null ) {
422 phys_url = new URL( phys_url_string );
424 catch ( final Exception e ) {
425 ForesterUtil.printErrorMessage( NAME, "error: " + e );
427 JOptionPane.showMessageDialog( this, NAME + ": Could not create URL from: \"" + phys_url_string
428 + "\"\nException: " + e, "Failed to create URL", JOptionPane.ERROR_MESSAGE );
431 // Load the tree from URL
432 if ( phys_url != null ) {
434 phys = AptxUtil.readPhylogeniesFromUrl( phys_url,
435 getConfiguration().isValidatePhyloXmlAgainstSchema(),
436 getConfiguration().isReplaceUnderscoresInNhParsing(),
437 getConfiguration().isInternalNumberAreConfidenceForNhParsing(),
438 getConfiguration().getTaxonomyExtraction() );
440 catch ( final Exception e ) {
441 ForesterUtil.printErrorMessage( NAME, e.toString() );
443 JOptionPane.showMessageDialog( this,
444 NAME + ": Failed to read phylogenies: " + "\nException: " + e,
445 "Failed to read phylogenies",
446 JOptionPane.ERROR_MESSAGE );
449 if ( ( phys == null ) || ( phys.length < 1 ) ) {
450 ForesterUtil.printErrorMessage( NAME, "phylogenies from [" + phys_url + "] are null or empty" );
451 JOptionPane.showMessageDialog( this,
452 NAME + ": phylogenies from [" + phys_url + "] are null or empty",
453 "Failed to read phylogenies",
454 JOptionPane.ERROR_MESSAGE );
458 AptxUtil.printAppletMessage( NAME, "loaded " + phys.length + " phylogenies from: " + phys_url );
461 setMainPanel( new MainPanelApplets( getConfiguration(), this ) );
462 _jmenubar = new JMenuBar();
463 if ( !getConfiguration().isHideControlPanelAndMenubar() ) {
464 if ( !getConfiguration().isUseNativeUI() ) {
465 _jmenubar.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
473 setJMenuBar( _jmenubar );
475 final Container contentpane = getContentPane();
476 contentpane.setLayout( new BorderLayout() );
477 contentpane.add( getMainPanel(), BorderLayout.CENTER );
478 addComponentListener( new ComponentAdapter() {
481 public void componentResized( final ComponentEvent e ) {
482 if ( getMainPanel().getCurrentTreePanel() != null ) {
483 getMainPanel().getCurrentTreePanel().setParametersForPainting( getMainPanel().getCurrentTreePanel()
485 getMainPanel().getCurrentTreePanel()
491 if ( getConfiguration().isUseTabbedDisplay() ) {
492 AptxUtil.printAppletMessage( NAME, "using tabbed display" );
493 AptxUtil.addPhylogeniesToTabs( phys,
494 new File( phys_url.getFile() ).getName(),
500 AptxUtil.printAppletMessage( NAME, "not using tabbed display" );
501 AptxUtil.addPhylogenyToPanel( phys, getConfiguration(), getMainPanel() );
505 getMainPanel().getControlPanel().showWholeAll();
506 getMainPanel().getControlPanel().showWhole();
508 AptxUtil.printAppletMessage( NAME, "successfully initialized" );
510 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().removeAllItems();
511 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
512 .getRelevantSequenceRelationTypes() ) {
513 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().addItem( type );
515 final String default_relation = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_SEQUENCE_RELATION_TYPE );
516 if ( default_relation != null ) {
517 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().setSelectedItem( default_relation );
519 final String default_sequence = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_QUERY_SEQUENCE );
520 if ( default_sequence != null ) {
521 getCurrentTreePanel().getControlPanel().getSequenceRelationBox().setSelectedItem( default_sequence );
527 public void showTextFrame( final String s, final String title ) {
529 _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
533 public void start() {
534 if ( getMainPanel() != null ) {
535 getMainPanel().validate();
538 requestFocusInWindow();
540 AptxUtil.printAppletMessage( NAME, "started" );
543 void buildFontSizeMenu() {
544 _font_size_menu = MainFrame.createMenu( MainFrame.FONT_SIZE_MENU_LABEL, getConfiguration() );
545 _font_size_menu.add( _super_tiny_fonts_mi = new JMenuItem( "Super tiny fonts" ) );
546 _font_size_menu.add( _tiny_fonts_mi = new JMenuItem( "Tiny fonts" ) );
547 _font_size_menu.add( _small_fonts_mi = new JMenuItem( "Small fonts" ) );
548 _font_size_menu.add( _medium_fonts_mi = new JMenuItem( "Medium fonts" ) );
549 _font_size_menu.add( _large_fonts_mi = new JMenuItem( "Large fonts" ) );
550 customizeJMenuItem( _super_tiny_fonts_mi );
551 customizeJMenuItem( _tiny_fonts_mi );
552 customizeJMenuItem( _small_fonts_mi );
553 customizeJMenuItem( _medium_fonts_mi );
554 customizeJMenuItem( _large_fonts_mi );
555 _jmenubar.add( _font_size_menu );
558 void buildHelpMenu() {
559 _help_jmenu = MainFrame.createMenu( "Help", getConfiguration() );
560 _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
561 _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
562 _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
563 _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
564 _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
565 _help_jmenu.addSeparator();
566 _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
567 customizeJMenuItem( _help_item );
568 customizeJMenuItem( _website_item );
569 customizeJMenuItem( _phyloxml_website_item );
570 customizeJMenuItem( _aptx_ref_item );
571 customizeJMenuItem( _phyloxml_ref_item );
572 customizeJMenuItem( _about_item );
573 _phyloxml_ref_item.setToolTipText( MainFrame.PHYLOXML_REF_TOOL_TIP );
574 _aptx_ref_item.setToolTipText( MainFrame.APTX_REF_TOOL_TIP );
575 _jmenubar.add( _help_jmenu );
578 void buildOptionsMenu() {
579 _options_jmenu = MainFrame.createMenu( MainFrame.OPTIONS_HEADER, getConfiguration() );
580 _options_jmenu.addChangeListener( new ChangeListener() {
583 public void stateChanged( final ChangeEvent e ) {
584 MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getOptions() );
585 MainFrame.setTextColorChooseMenuItem( _switch_colors_mi, getCurrentTreePanel() );
587 .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() );
588 MainFrame.setTextForFontChooserMenuItem( _choose_font_mi, MainFrame
589 .createCurrentFontDesc( getMainPanel().getTreeFontSet() ) );
590 MainFrame.updateOptionsMenuDependingOnPhylogenyType( getMainPanel(),
592 _show_branch_length_values_cbmi,
593 _non_lined_up_cladograms_rbmi,
594 _uniform_cladograms_rbmi,
595 _ext_node_dependent_cladogram_rbmi,
596 _label_direction_cbmi );
597 MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() );
598 MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() );
599 MainFrame.setTextNodeSizeMenuItem( _choose_node_size_mi, getOptions() );
602 _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.DISPLAY_SUBHEADER ),
603 getConfiguration() ) );
605 .add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );
606 _options_jmenu.add( _uniform_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.UNIFORM_CLADOGRAMS_LABEL ) );
608 .add( _non_lined_up_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.NON_LINED_UP_CLADOGRAMS_LABEL ) );
609 _radio_group_1 = new ButtonGroup();
610 _radio_group_1.add( _ext_node_dependent_cladogram_rbmi );
611 _radio_group_1.add( _uniform_cladograms_rbmi );
612 _radio_group_1.add( _non_lined_up_cladograms_rbmi );
613 _options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_OVERVIEW_LABEL ) );
614 _options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_SCALE_LABEL ) );
616 .add( _show_branch_length_values_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_BRANCH_LENGTH_VALUES_LABEL ) );
617 _options_jmenu.add( _show_confidence_stddev_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_CONF_STDDEV_LABEL ) );
619 .add( _show_default_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL ) );
621 .add( _taxonomy_colorize_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.TAXONOMY_COLORIZE_NODE_SHAPES_LABEL ) );
622 _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL ) );
623 _options_jmenu.add( _cycle_node_fill_mi = new JMenuItem( MainFrame.CYCLE_NODE_FILL_LABEL ) );
624 _options_jmenu.add( _choose_node_size_mi = new JMenuItem( MainFrame.CHOOSE_NODE_SIZE_LABEL ) );
625 _options_jmenu.add( _label_direction_cbmi = new JCheckBoxMenuItem( MainFrame.LABEL_DIRECTION_LABEL ) );
627 .add( _color_labels_same_as_parent_branch = new JCheckBoxMenuItem( MainFrame.COLOR_LABELS_LABEL ) );
628 _color_labels_same_as_parent_branch.setToolTipText( MainFrame.COLOR_LABELS_TIP );
629 _options_jmenu.add( _abbreviate_scientific_names = new JCheckBoxMenuItem( MainFrame.ABBREV_SN_LABEL ) );
630 _label_direction_cbmi.setToolTipText( MainFrame.LABEL_DIRECTION_TIP );
631 _options_jmenu.add( _screen_antialias_cbmi = new JCheckBoxMenuItem( MainFrame.SCREEN_ANTIALIAS_LABEL ) );
632 _options_jmenu.add( _background_gradient_cbmi = new JCheckBoxMenuItem( MainFrame.BG_GRAD_LABEL ) );
633 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
634 _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( MainFrame.SHOW_DOMAIN_LABELS_LABEL ) );
636 _options_jmenu.add( _choose_minimal_confidence_mi = new JMenuItem( "" ) );
637 _options_jmenu.add( _overview_placment_mi = new JMenuItem( "" ) );
638 _options_jmenu.add( _switch_colors_mi = new JMenuItem( "" ) );
639 _options_jmenu.add( _choose_font_mi = new JMenuItem( "" ) );
640 _options_jmenu.addSeparator();
641 _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.SEARCH_SUBHEADER ),
642 getConfiguration() ) );
644 .add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_CASE_SENSITIVE_LABEL ) );
645 _options_jmenu.add( _search_whole_words_only_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_TERMS_ONLY_LABEL ) );
647 .add( _inverse_search_result_cbmi = new JCheckBoxMenuItem( MainFrame.INVERSE_SEARCH_RESULT_LABEL ) );
648 customizeJMenuItem( _choose_font_mi );
649 customizeJMenuItem( _choose_minimal_confidence_mi );
650 customizeJMenuItem( _switch_colors_mi );
651 customizeJMenuItem( _overview_placment_mi );
652 customizeCheckBoxMenuItem( _label_direction_cbmi,
653 getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL );
654 customizeCheckBoxMenuItem( _screen_antialias_cbmi, getOptions().isAntialiasScreen() );
655 customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );
656 customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );
657 customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );
658 customizeCheckBoxMenuItem( _show_default_node_shapes_cbmi, getOptions().isShowDefaultNodeShapes() );
659 customizeCheckBoxMenuItem( _taxonomy_colorize_node_shapes_cbmi, getOptions().isTaxonomyColorizeNodeShapes() );
660 customizeJMenuItem( _cycle_node_shape_mi );
661 customizeJMenuItem( _cycle_node_fill_mi );
662 customizeJMenuItem( _choose_node_size_mi );
663 customizeCheckBoxMenuItem( _color_labels_same_as_parent_branch, getOptions().isColorLabelsSameAsParentBranch() );
664 customizeCheckBoxMenuItem( _search_case_senstive_cbmi, getOptions().isSearchCaseSensitive() );
665 customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );
666 customizeRadioButtonMenuItem( _non_lined_up_cladograms_rbmi,
667 getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP );
668 customizeRadioButtonMenuItem( _uniform_cladograms_rbmi,
669 getOptions().getCladogramType() == CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
670 customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi,
671 getOptions().getCladogramType() == CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
672 customizeCheckBoxMenuItem( _show_branch_length_values_cbmi, getOptions().isShowBranchLengthValues() );
673 customizeCheckBoxMenuItem( _show_overview_cbmi, getOptions().isShowOverview() );
674 customizeCheckBoxMenuItem( _search_whole_words_only_cbmi, getOptions().isMatchWholeTermsOnly() );
675 customizeCheckBoxMenuItem( _inverse_search_result_cbmi, getOptions().isInverseSearchResult() );
676 customizeCheckBoxMenuItem( _show_confidence_stddev_cbmi, getOptions().isShowConfidenceStddev() );
677 _jmenubar.add( _options_jmenu );
680 void buildToolsMenu() {
681 _tools_menu = MainFrame.createMenu( "Tools", getConfiguration() );
682 _tools_menu.add( _confcolor_item = new JMenuItem( "Colorize Branches Depending on Confidence" ) );
683 customizeJMenuItem( _confcolor_item );
684 _tools_menu.add( _taxcolor_item = new JMenuItem( "Taxonomy Colorize Branches" ) );
685 customizeJMenuItem( _taxcolor_item );
686 _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete Branch Colors" ) );
687 _remove_branch_color_item.setToolTipText( "To delete branch color values from the current phylogeny." );
688 customizeJMenuItem( _remove_branch_color_item );
689 _tools_menu.addSeparator();
690 _tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) );
691 customizeJMenuItem( _midpoint_root_item );
692 _tools_menu.addSeparator();
694 .add( _infer_common_sn_names_item = new JMenuItem( "Infer Common Parts of Internal Scientific Names" ) );
695 customizeJMenuItem( _infer_common_sn_names_item );
696 _tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Species-Specific Subtrees" ) );
697 customizeJMenuItem( _collapse_species_specific_subtrees );
698 _jmenubar.add( _tools_menu );
701 void buildTypeMenu() {
702 _type_menu = MainFrame.createMenu( MainFrame.TYPE_MENU_HEADER, getConfiguration() );
703 _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
704 _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
705 _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
706 _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
707 _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
708 _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
709 _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
710 _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
711 customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
712 customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
713 customizeCheckBoxMenuItem( _euro_type_cbmi, false );
714 customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
715 customizeCheckBoxMenuItem( _curved_type_cbmi, false );
716 customizeCheckBoxMenuItem( _convex_type_cbmi, false );
717 customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
718 customizeCheckBoxMenuItem( _circular_type_cbmi, false );
719 _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
720 _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
721 initializeTypeMenu( getOptions() );
722 _jmenubar.add( _type_menu );
725 void buildViewMenu() {
726 _view_jmenu = MainFrame.createMenu( "View", getConfiguration() );
727 _view_jmenu.add( _display_basic_information_item = new JMenuItem( "Display Basic Information" ) );
728 _view_jmenu.addSeparator();
729 _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) );
730 _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) );
731 _view_jmenu.add( _view_as_NHX_item = new JMenuItem( "View as NHX" ) );
732 _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "View as Nexus" ) );
733 customizeJMenuItem( _display_basic_information_item );
734 customizeJMenuItem( _view_as_NH_item );
735 customizeJMenuItem( _view_as_NHX_item );
736 customizeJMenuItem( _view_as_XML_item );
737 customizeJMenuItem( _view_as_nexus_item );
738 _jmenubar.add( _view_jmenu );
741 void checkTextFrames() {
742 if ( _textframes.size() > 5 ) {
744 if ( _textframes.getFirst() != null ) {
745 _textframes.getFirst().removeMe();
748 _textframes.removeFirst();
751 catch ( final NoSuchElementException e ) {
757 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
758 if ( item != null ) {
759 item.setFont( MainFrame.menu_font );
760 if ( !getConfiguration().isUseNativeUI() ) {
761 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
762 item.setForeground( getConfiguration().getGuiMenuTextColor() );
764 item.setSelected( is_selected );
765 item.addActionListener( this );
769 void customizeJMenuItem( final JMenuItem jmi ) {
770 jmi.setFont( MainFrame.menu_font );
771 if ( !getConfiguration().isUseNativeUI() ) {
772 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
773 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
775 jmi.addActionListener( this );
778 void displayBasicInformation() {
779 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
780 String title = "Basic Information";
781 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
782 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
784 showTextFrame( AptxUtil.createBasicInformation( getMainPanel().getCurrentPhylogeny() ), title );
788 Configuration getConfiguration() {
789 return _configuration;
792 TreePanel getCurrentTreePanel() {
793 return getMainPanel().getCurrentTreePanel();
796 JCheckBoxMenuItem getlabelDirectionCbmi() {
797 return _label_direction_cbmi;
800 Options getOtions() {
804 void help( final Map<String, WebLink> weblinks ) {
805 final StringBuilder sb = new StringBuilder();
806 sb.append( "Display options\n" );
807 sb.append( "-------------------\n" );
808 sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
809 sb.append( "Clickable tree nodes\n" );
810 sb.append( "--------------------\n" );
811 sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
812 sb.append( "or by right clicking:\n" );
813 sb.append( "o Display Node Data -- display information for a node\n" );
814 sb.append( "o Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
815 sb.append( "o Root/Reroot -- change tree root to clicked node\n" );
816 sb.append( "o Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
817 sb.append( "o Swap Descendants -- switch descendant on either side of clicked node\n" );
818 sb.append( "o Colorize Subtree -- color a subtree\n" );
819 sb.append( "o Open Sequence Web -- launch a web browser to display sequence information\n" );
820 sb.append( "o Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
821 sb.append( "- there may be additional choices depending on this particular setup\n\n" );
822 sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
823 sb.append( "Zooming\n" );
824 sb.append( "---------\n" );
825 sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
826 sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
827 sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
828 sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
829 sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
830 sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
831 sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
832 sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
833 sb.append( "Quick tree manipulation:\n" );
834 sb.append( "------------------------\n" );
835 sb.append( "Order Subtrees -- order the tree by branch length\n" );
836 sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
837 sb.append( "Memory problems (Java heap space error)\n" );
838 sb.append( "---------------------------------------\n" );
839 sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
840 sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
841 sb.append( "the '-Xmx' Java command line option. For example:\n" );
842 sb.append( "java -Xms32m -Xmx256m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
843 if ( ( weblinks != null ) && ( weblinks.size() > 0 ) ) {
844 sb.append( "Active web links\n" );
845 sb.append( "--------------------\n" );
846 for( final String key : weblinks.keySet() ) {
847 sb.append( " " + weblinks.get( key ).toString() + "\n" );
851 sb.append( "phyloXML\n" );
852 sb.append( "-------------------\n" );
853 sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
854 sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
855 sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
857 sb.append( "For more information: http://www.phylosoft.org/archaeopteryx/\n" );
858 sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
859 TextFrame.instantiate( sb.toString(), "Help", _textframes );
862 void initializeTypeMenu( final Options options ) {
863 setTypeMenuToAllUnselected();
865 switch ( options.getPhylogenyGraphicsType() ) {
867 _convex_type_cbmi.setSelected( true );
870 _curved_type_cbmi.setSelected( true );
873 _euro_type_cbmi.setSelected( true );
876 _rounded_type_cbmi.setSelected( true );
879 _triangular_type_cbmi.setSelected( true );
882 _unrooted_type_cbmi.setSelected( true );
885 _circular_type_cbmi.setSelected( true );
888 _rectangular_type_cbmi.setSelected( true );
892 catch ( final NullPointerException np ) {
893 // In all likelihood, this is caused by menu-less display.
897 void removeAllTextFrames() {
898 for( final TextFrame tf : _textframes ) {
906 void setConfiguration( final Configuration configuration ) {
907 _configuration = configuration;
910 void setCurrentExternalNodesDataBuffer( final String s ) {
911 if ( !ForesterUtil.isEmpty( s ) ) {
912 _ext_node_data_buffer = s.trim();
915 _ext_node_data_buffer = "";
919 void setOptions( final Options options ) {
923 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
924 setTypeMenuToAllUnselected();
928 _circular_type_cbmi.setSelected( true );
931 _convex_type_cbmi.setSelected( true );
934 _curved_type_cbmi.setSelected( true );
937 _euro_type_cbmi.setSelected( true );
940 _rounded_type_cbmi.setSelected( true );
943 _rectangular_type_cbmi.setSelected( true );
946 _triangular_type_cbmi.setSelected( true );
949 _unrooted_type_cbmi.setSelected( true );
952 throw new IllegalArgumentException( "unknown type: " + type );
955 catch ( final NullPointerException np ) {
956 // In all likelihood, this is caused by menu-less display.
960 void setTypeMenuToAllUnselected() {
961 if ( _convex_type_cbmi != null ) {
962 _convex_type_cbmi.setSelected( false );
964 if ( _curved_type_cbmi != null ) {
965 _curved_type_cbmi.setSelected( false );
967 if ( _euro_type_cbmi != null ) {
968 _euro_type_cbmi.setSelected( false );
970 if ( _rounded_type_cbmi != null ) {
971 _rounded_type_cbmi.setSelected( false );
973 if ( _triangular_type_cbmi != null ) {
974 _triangular_type_cbmi.setSelected( false );
976 if ( _rectangular_type_cbmi != null ) {
977 _rectangular_type_cbmi.setSelected( false );
979 if ( _unrooted_type_cbmi != null ) {
980 _unrooted_type_cbmi.setSelected( false );
982 if ( _circular_type_cbmi != null ) {
983 _circular_type_cbmi.setSelected( false );
987 void switchColors() {
988 final TreeColorSet colorset = getMainPanel().getCurrentTreePanel().getTreeColorSet();
989 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
990 csc.setVisible( true );
991 getMainPanel().setTreeColorSet( colorset );
994 void typeChanged( final Object o ) {
995 updateTypeCheckboxes( getOptions(), o );
996 updateOptions( getOptions() );
997 if ( getCurrentTreePanel() != null ) {
998 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
999 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
1000 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1001 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
1002 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1003 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
1004 getCurrentTreePanel().getControlPanel().showWhole();
1006 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1007 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
1010 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
1012 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
1013 MainFrame.updateScreenTextAntialias( getMainPanel().getTreePanels() );
1017 void updateOptions( final Options options ) {
1018 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
1019 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
1020 && _background_gradient_cbmi.isSelected() );
1021 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
1022 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
1023 && _abbreviate_scientific_names.isSelected() );
1024 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
1025 && _color_labels_same_as_parent_branch.isSelected() );
1026 options.setShowDefaultNodeShapes( ( _show_default_node_shapes_cbmi != null )
1027 && _show_default_node_shapes_cbmi.isSelected() );
1028 options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null )
1029 && _taxonomy_colorize_node_shapes_cbmi.isSelected() );
1030 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
1031 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
1033 else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
1034 options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1036 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
1037 options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1039 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
1040 && _search_case_senstive_cbmi.isSelected() );
1041 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
1042 options.setShowScale( _show_scale_cbmi.isSelected() );
1044 if ( _label_direction_cbmi != null ) {
1045 if ( _label_direction_cbmi.isSelected() ) {
1046 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1049 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1052 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
1053 options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )
1054 && _show_confidence_stddev_cbmi.isSelected() );
1055 if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
1056 options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
1058 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
1059 && _search_whole_words_only_cbmi.isSelected() );
1060 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
1061 && _inverse_search_result_cbmi.isSelected() );
1062 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
1063 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1065 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
1066 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1068 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
1069 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1071 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
1072 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1074 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
1075 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1077 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
1078 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1080 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
1081 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1083 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
1084 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1088 void updateTypeCheckboxes( final Options options, final Object o ) {
1089 setTypeMenuToAllUnselected();
1090 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
1093 void viewAsNexus() {
1094 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1095 String title = "Nexus";
1096 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1097 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1099 showTextFrame( getMainPanel().getCurrentPhylogeny().toNexus( getOptions()
1100 .getNhConversionSupportValueStyle() ),
1106 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1107 String title = "New Hampshire";
1108 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1109 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1111 showTextFrame( getMainPanel().getCurrentPhylogeny()
1112 .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ),
1118 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1119 String title = "NHX";
1120 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1121 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1123 showTextFrame( getMainPanel().getCurrentPhylogeny().toNewHampshireX(), title );
1128 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1129 String title = "phyloXML";
1130 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1131 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1133 showTextFrame( getMainPanel().getCurrentPhylogeny().toPhyloXML( 0 ), title );
1137 private void chooseFont() {
1138 final FontChooser fc = new FontChooser();
1139 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
1140 fc.showDialog( this, "Select the Base Font" );
1141 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
1144 private void chooseMinimalConfidence() {
1145 final String s = ( String ) JOptionPane
1146 .showInputDialog( this,
1147 "Please the minimum for confidence values to be displayed.\n" + "[current value: "
1148 + getOptions().getMinConfidenceValue() + "]\n",
1149 "Minimal Confidence Value",
1150 JOptionPane.QUESTION_MESSAGE,
1153 getOptions().getMinConfidenceValue() );
1154 if ( !ForesterUtil.isEmpty( s ) ) {
1155 boolean success = true;
1157 final String m_str = s.trim();
1158 if ( !ForesterUtil.isEmpty( m_str ) ) {
1160 m = Double.parseDouble( m_str );
1162 catch ( final Exception ex ) {
1169 if ( success && ( m >= 0.0 ) ) {
1170 getOptions().setMinConfidenceValue( m );
1175 private void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
1176 if ( item != null ) {
1177 item.setFont( MainFrame.menu_font );
1178 if ( !getConfiguration().isUseNativeUI() ) {
1179 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
1180 item.setForeground( getConfiguration().getGuiMenuTextColor() );
1182 item.setSelected( is_selected );
1183 item.addActionListener( this );
1187 private MainPanel getMainPanel() {
1191 private boolean isScreenAntialias() {
1195 private void removeBranchColors() {
1196 if ( getMainPanel().getCurrentPhylogeny() != null ) {
1197 AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
1201 private void setMainPanel( final MainPanelApplets main_panel ) {
1202 _main_panel = main_panel;
1205 private void setupUI() {
1207 if ( getConfiguration().isUseNativeUI() ) {
1208 UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
1211 UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
1214 catch ( final UnsupportedLookAndFeelException e ) {
1215 AptxUtil.dieWithSystemError( "UnsupportedLookAndFeelException: " + e.toString() );
1217 catch ( final ClassNotFoundException e ) {
1218 AptxUtil.dieWithSystemError( "ClassNotFoundException: " + e.toString() );
1220 catch ( final InstantiationException e ) {
1221 AptxUtil.dieWithSystemError( "InstantiationException: " + e.toString() );
1223 catch ( final IllegalAccessException e ) {
1224 AptxUtil.dieWithSystemError( "IllegalAccessException: " + e.toString() );
1226 catch ( final Exception e ) {
1227 AptxUtil.dieWithSystemError( e.toString() );
1231 static void setupScreenTextAntialias( final List<TreePanel> treepanels, final boolean antialias ) {
1232 for( final TreePanel tree_panel : treepanels ) {
1233 tree_panel.setTextAntialias();