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_nexus_item;
76 private JMenuItem _display_basic_information_item;
77 private JMenu _type_menu;
78 private JCheckBoxMenuItem _rectangular_type_cbmi;
79 private JCheckBoxMenuItem _triangular_type_cbmi;
80 private JCheckBoxMenuItem _curved_type_cbmi;
81 private JCheckBoxMenuItem _convex_type_cbmi;
82 private JCheckBoxMenuItem _euro_type_cbmi;
83 private JCheckBoxMenuItem _rounded_type_cbmi;
84 private JCheckBoxMenuItem _unrooted_type_cbmi;
85 private JCheckBoxMenuItem _circular_type_cbmi;
86 private JMenuItem _help_item;
87 private JMenuItem _about_item;
88 private JMenu _help_jmenu;
89 private JMenuItem _website_item;
90 private JMenuItem _phyloxml_website_item;
91 private JMenuItem _phyloxml_ref_item;
92 private JMenuItem _aptx_ref_item;
93 private JMenuItem _remove_branch_color_item;
94 private JCheckBoxMenuItem _show_domain_labels;
95 private JCheckBoxMenuItem _color_labels_same_as_parent_branch;
96 private JCheckBoxMenuItem _abbreviate_scientific_names;
97 private JCheckBoxMenuItem _screen_antialias_cbmi;
98 private JCheckBoxMenuItem _background_gradient_cbmi;
99 private JRadioButtonMenuItem _non_lined_up_cladograms_rbmi;
100 private JRadioButtonMenuItem _uniform_cladograms_rbmi;
101 private JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi;
102 private Options _options;
103 private JMenuItem _choose_font_mi;
104 private JMenuItem _switch_colors_mi;
105 JCheckBoxMenuItem _label_direction_cbmi;
106 private JCheckBoxMenuItem _show_scale_cbmi;
107 private JCheckBoxMenuItem _search_case_senstive_cbmi;
108 private JCheckBoxMenuItem _search_whole_words_only_cbmi;
109 private JCheckBoxMenuItem _inverse_search_result_cbmi;
110 private JCheckBoxMenuItem _show_overview_cbmi;
111 private JMenuItem _choose_minimal_confidence_mi;
112 private JCheckBoxMenuItem _show_branch_length_values_cbmi;
113 private JMenuItem _collapse_species_specific_subtrees;
114 private JMenuItem _overview_placment_mi;
115 private ButtonGroup _radio_group_1;
116 private JCheckBoxMenuItem _show_default_node_shapes_internal_cbmi;
117 private JCheckBoxMenuItem _show_default_node_shapes_external_cbmi;
118 private JMenuItem _cycle_node_shape_mi;
119 private JMenuItem _cycle_node_fill_mi;
120 private JMenuItem _choose_node_size_mi;
121 private JCheckBoxMenuItem _taxonomy_colorize_node_shapes_cbmi;
122 private JCheckBoxMenuItem _show_confidence_stddev_cbmi;
123 private final LinkedList<TextFrame> _textframes = new LinkedList<TextFrame>();
125 // private String _ext_node_data_buffer = "";
126 // private int _ext_node_data_buffer_change_counter = 0;
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_XML_item ) {
159 else if ( o == _view_as_nexus_item ) {
162 else if ( o == _super_tiny_fonts_mi ) {
163 if ( getCurrentTreePanel() != null ) {
164 getCurrentTreePanel().setSuperTinyFonts();
165 getCurrentTreePanel().repaint();
168 else if ( o == _tiny_fonts_mi ) {
169 if ( getCurrentTreePanel() != null ) {
170 getCurrentTreePanel().setTinyFonts();
171 getCurrentTreePanel().repaint();
174 else if ( o == _small_fonts_mi ) {
175 if ( getCurrentTreePanel() != null ) {
176 getCurrentTreePanel().setSmallFonts();
177 getCurrentTreePanel().repaint();
180 else if ( o == _medium_fonts_mi ) {
181 if ( getCurrentTreePanel() != null ) {
182 getCurrentTreePanel().setMediumFonts();
183 getCurrentTreePanel().repaint();
186 else if ( o == _large_fonts_mi ) {
187 if ( getCurrentTreePanel() != null ) {
188 getCurrentTreePanel().setLargeFonts();
189 getCurrentTreePanel().repaint();
192 else if ( o == _choose_font_mi ) {
195 else if ( o == _choose_minimal_confidence_mi ) {
196 chooseMinimalConfidence();
198 else if ( o == _choose_node_size_mi ) {
199 MainFrame.chooseNodeSize( getOptions(), this );
201 else if ( o == _overview_placment_mi ) {
202 MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
204 else if ( o == _cycle_node_fill_mi ) {
205 MainFrame.cycleNodeFill( getOptions(), getCurrentTreePanel() );
207 else if ( o == _cycle_node_shape_mi ) {
208 MainFrame.cycleNodeShape( getOptions(), getCurrentTreePanel() );
210 else if ( o == _non_lined_up_cladograms_rbmi ) {
211 updateOptions( getOptions() );
212 _main_panel.getControlPanel().showWhole();
214 else if ( o == _uniform_cladograms_rbmi ) {
215 updateOptions( getOptions() );
216 _main_panel.getControlPanel().showWhole();
218 else if ( o == _ext_node_dependent_cladogram_rbmi ) {
219 updateOptions( getOptions() );
220 _main_panel.getControlPanel().showWhole();
222 else if ( o == _search_case_senstive_cbmi ) {
223 updateOptions( getOptions() );
224 getMainPanel().getControlPanel().search();
226 else if ( o == _search_whole_words_only_cbmi ) {
227 updateOptions( getOptions() );
228 getMainPanel().getControlPanel().search();
230 else if ( o == _inverse_search_result_cbmi ) {
231 updateOptions( getOptions() );
232 getMainPanel().getControlPanel().search();
234 else if ( o == _show_scale_cbmi ) {
235 updateOptions( getOptions() );
237 else if ( o == _show_branch_length_values_cbmi ) {
238 updateOptions( getOptions() );
240 else if ( o == _show_confidence_stddev_cbmi ) {
241 updateOptions( getOptions() );
243 else if ( o == _label_direction_cbmi ) {
244 updateOptions( getOptions() );
246 else if ( o == _show_overview_cbmi ) {
247 updateOptions( getOptions() );
248 if ( getCurrentTreePanel() != null ) {
249 getCurrentTreePanel().updateOvSizes();
252 else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
253 || ( o == _convex_type_cbmi ) || ( o == _rounded_type_cbmi ) || ( o == _euro_type_cbmi )
254 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
257 else if ( o == _screen_antialias_cbmi ) {
258 updateOptions( getOptions() );
259 setupScreenTextAntialias( getMainPanel().getTreePanels(), isScreenAntialias() );
261 else if ( o == _background_gradient_cbmi ) {
262 updateOptions( getOptions() );
264 else if ( o == _show_domain_labels ) {
265 updateOptions( getOptions() );
267 else if ( o == _color_labels_same_as_parent_branch ) {
268 updateOptions( getOptions() );
270 else if ( o == _show_default_node_shapes_internal_cbmi ) {
271 updateOptions( getOptions() );
273 else if ( o == _show_default_node_shapes_external_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 getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString();
341 public int getCurrentExternalNodesDataBufferChangeCounter() {
342 return getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter();
345 public int getCurrentExternalNodesDataBufferLength() {
346 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length();
350 * This method returns the current phylogeny as a string in the chosen format
352 * @param format must be NH, NHX, NEXUS or PHYLOXML
353 * @return the phylogeny string
354 * @author Herve Menager
356 public String getCurrentPhylogeny( final String format ) {
357 removeAllTextFrames();
358 if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty()
359 || ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
362 switch ( ForesterConstants.PhylogeneticTreeFormats.valueOf( format ) ) {
364 return getMainPanel().getCurrentPhylogeny().toNewHampshire();
366 return getMainPanel().getCurrentPhylogeny().toNewHampshireX();
368 return getMainPanel().getCurrentPhylogeny().toNexus();
370 return getMainPanel().getCurrentPhylogeny().toPhyloXML( -1 );
378 * This method returns a view of the current phylogeny in a chosen
379 * graphics format, base64-encoded in a string so that in can be used
382 * @param format must be GraphicsExportType (gif, jpg, pdf, png, tif, bmp)
383 * @return the phylogeny string
384 * @author Herve Menager
386 public String getCurrentPhylogenyGraphicsAsBase64EncodedString( final String format ) {
387 final ByteArrayOutputStream baos = new ByteArrayOutputStream();
389 AptxUtil.writePhylogenyToGraphicsByteArrayOutputStream( baos,
390 _main_panel.getWidth(),
391 _main_panel.getHeight(),
392 getCurrentTreePanel(),
393 getCurrentTreePanel().getControlPanel(),
394 GraphicsExportType.valueOf( format ),
397 catch ( final IOException ioe ) {
398 ForesterUtil.printErrorMessage( NAME, ioe.toString() );
399 ioe.printStackTrace();
400 JOptionPane.showMessageDialog( this,
401 NAME + ": Failed to generate graphics: " + "\nException: " + ioe,
402 "Failed to generate graphics",
403 JOptionPane.ERROR_MESSAGE );
406 final byte[] bytes = baos.toByteArray();
407 final String dataImg = Base64.encodeBase64String( bytes );
411 public Options getOptions() {
417 final String config_filename = getParameter( Constants.APPLET_PARAM_NAME_FOR_CONFIG_FILE_URL );
418 AptxUtil.printAppletMessage( NAME, "URL for configuration file is: " + config_filename );
419 final Configuration configuration = new Configuration( config_filename, true, true, true );
420 setConfiguration( configuration );
421 setOptions( Options.createInstance( configuration ) );
424 Phylogeny[] phys = null;
425 final String phys_url_string = getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD );
426 AptxUtil.printAppletMessage( NAME, "URL for phylogenies is " + phys_url_string );
427 // Get URL to tree file
428 if ( phys_url_string != null ) {
430 phys_url = new URL( phys_url_string );
432 catch ( final Exception e ) {
433 ForesterUtil.printErrorMessage( NAME, "error: " + e );
435 JOptionPane.showMessageDialog( this, NAME + ": Could not create URL from: \"" + phys_url_string
436 + "\"\nException: " + e, "Failed to create URL", JOptionPane.ERROR_MESSAGE );
439 // Load the tree from URL
440 if ( phys_url != null ) {
442 phys = AptxUtil.readPhylogeniesFromUrl( phys_url,
443 getConfiguration().isValidatePhyloXmlAgainstSchema(),
444 getConfiguration().isReplaceUnderscoresInNhParsing(),
445 getConfiguration().isInternalNumberAreConfidenceForNhParsing(),
446 getConfiguration().getTaxonomyExtraction() );
448 catch ( final Exception e ) {
449 ForesterUtil.printErrorMessage( NAME, e.toString() );
451 JOptionPane.showMessageDialog( this,
452 NAME + ": Failed to read phylogenies: " + "\nException: " + e,
453 "Failed to read phylogenies",
454 JOptionPane.ERROR_MESSAGE );
457 if ( ( phys == null ) || ( phys.length < 1 ) ) {
458 ForesterUtil.printErrorMessage( NAME, "phylogenies from [" + phys_url + "] are null or empty" );
459 JOptionPane.showMessageDialog( this,
460 NAME + ": phylogenies from [" + phys_url + "] are null or empty",
461 "Failed to read phylogenies",
462 JOptionPane.ERROR_MESSAGE );
466 AptxUtil.printAppletMessage( NAME, "loaded " + phys.length + " phylogenies from: " + phys_url );
469 setMainPanel( new MainPanelApplets( getConfiguration(), this ) );
470 _jmenubar = new JMenuBar();
471 if ( !getConfiguration().isHideControlPanelAndMenubar() ) {
472 if ( !getConfiguration().isUseNativeUI() ) {
473 _jmenubar.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
481 setJMenuBar( _jmenubar );
483 final Container contentpane = getContentPane();
484 contentpane.setLayout( new BorderLayout() );
485 contentpane.add( getMainPanel(), BorderLayout.CENTER );
486 addComponentListener( new ComponentAdapter() {
489 public void componentResized( final ComponentEvent e ) {
490 if ( getMainPanel().getCurrentTreePanel() != null ) {
491 getMainPanel().getCurrentTreePanel().setParametersForPainting( getMainPanel().getCurrentTreePanel()
493 getMainPanel().getCurrentTreePanel()
499 if ( getConfiguration().isUseTabbedDisplay() ) {
500 AptxUtil.printAppletMessage( NAME, "using tabbed display" );
501 AptxUtil.addPhylogeniesToTabs( phys,
502 new File( phys_url.getFile() ).getName(),
508 AptxUtil.printAppletMessage( NAME, "not using tabbed display" );
509 AptxUtil.addPhylogenyToPanel( phys, getConfiguration(), getMainPanel() );
513 getMainPanel().getControlPanel().showWholeAll();
514 getMainPanel().getControlPanel().showWhole();
516 AptxUtil.printAppletMessage( NAME, "successfully initialized" );
518 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().removeAllItems();
519 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
520 .getRelevantSequenceRelationTypes() ) {
521 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().addItem( type );
523 final String default_relation = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_SEQUENCE_RELATION_TYPE );
524 if ( default_relation != null ) {
525 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().setSelectedItem( default_relation );
527 final String default_sequence = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_QUERY_SEQUENCE );
528 if ( default_sequence != null ) {
529 getCurrentTreePanel().getControlPanel().getSequenceRelationBox().setSelectedItem( default_sequence );
535 public void showTextFrame( final String s, final String title ) {
537 _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
541 public void start() {
542 if ( getMainPanel() != null ) {
543 getMainPanel().validate();
546 requestFocusInWindow();
548 AptxUtil.printAppletMessage( NAME, "started" );
551 void buildFontSizeMenu() {
552 _font_size_menu = MainFrame.createMenu( MainFrame.FONT_SIZE_MENU_LABEL, getConfiguration() );
553 _font_size_menu.add( _super_tiny_fonts_mi = new JMenuItem( "Super tiny fonts" ) );
554 _font_size_menu.add( _tiny_fonts_mi = new JMenuItem( "Tiny fonts" ) );
555 _font_size_menu.add( _small_fonts_mi = new JMenuItem( "Small fonts" ) );
556 _font_size_menu.add( _medium_fonts_mi = new JMenuItem( "Medium fonts" ) );
557 _font_size_menu.add( _large_fonts_mi = new JMenuItem( "Large fonts" ) );
558 customizeJMenuItem( _super_tiny_fonts_mi );
559 customizeJMenuItem( _tiny_fonts_mi );
560 customizeJMenuItem( _small_fonts_mi );
561 customizeJMenuItem( _medium_fonts_mi );
562 customizeJMenuItem( _large_fonts_mi );
563 _jmenubar.add( _font_size_menu );
566 void buildHelpMenu() {
567 _help_jmenu = MainFrame.createMenu( "Help", getConfiguration() );
568 _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
569 _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
570 _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
571 _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
572 _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
573 _help_jmenu.addSeparator();
574 _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
575 customizeJMenuItem( _help_item );
576 customizeJMenuItem( _website_item );
577 customizeJMenuItem( _phyloxml_website_item );
578 customizeJMenuItem( _aptx_ref_item );
579 customizeJMenuItem( _phyloxml_ref_item );
580 customizeJMenuItem( _about_item );
581 _phyloxml_ref_item.setToolTipText( MainFrame.PHYLOXML_REF_TOOL_TIP );
582 _aptx_ref_item.setToolTipText( MainFrame.APTX_REF_TOOL_TIP );
583 _jmenubar.add( _help_jmenu );
586 void buildOptionsMenu() {
587 _options_jmenu = MainFrame.createMenu( MainFrame.OPTIONS_HEADER, getConfiguration() );
588 _options_jmenu.addChangeListener( new ChangeListener() {
591 public void stateChanged( final ChangeEvent e ) {
592 MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getOptions() );
593 MainFrame.setTextColorChooseMenuItem( _switch_colors_mi, getCurrentTreePanel() );
595 .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() );
596 MainFrame.setTextForFontChooserMenuItem( _choose_font_mi, MainFrame
597 .createCurrentFontDesc( getMainPanel().getTreeFontSet() ) );
598 MainFrame.updateOptionsMenuDependingOnPhylogenyType( getMainPanel(),
600 _show_branch_length_values_cbmi,
601 _non_lined_up_cladograms_rbmi,
602 _uniform_cladograms_rbmi,
603 _ext_node_dependent_cladogram_rbmi,
604 _label_direction_cbmi );
605 MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() );
606 MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() );
607 MainFrame.setTextNodeSizeMenuItem( _choose_node_size_mi, getOptions() );
610 _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.DISPLAY_SUBHEADER ),
611 getConfiguration() ) );
613 .add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );
614 _options_jmenu.add( _uniform_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.UNIFORM_CLADOGRAMS_LABEL ) );
616 .add( _non_lined_up_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.NON_LINED_UP_CLADOGRAMS_LABEL ) );
617 _radio_group_1 = new ButtonGroup();
618 _radio_group_1.add( _ext_node_dependent_cladogram_rbmi );
619 _radio_group_1.add( _uniform_cladograms_rbmi );
620 _radio_group_1.add( _non_lined_up_cladograms_rbmi );
621 _options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_OVERVIEW_LABEL ) );
622 _options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_SCALE_LABEL ) );
624 .add( _show_branch_length_values_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_BRANCH_LENGTH_VALUES_LABEL ) );
625 _options_jmenu.add( _show_confidence_stddev_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_CONF_STDDEV_LABEL ) );
627 .add( _show_default_node_shapes_internal_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_INT ) );
629 .add( _show_default_node_shapes_external_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_EXT ) );
631 .add( _taxonomy_colorize_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.TAXONOMY_COLORIZE_NODE_SHAPES_LABEL ) );
632 _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL ) );
633 _options_jmenu.add( _cycle_node_fill_mi = new JMenuItem( MainFrame.CYCLE_NODE_FILL_LABEL ) );
634 _options_jmenu.add( _choose_node_size_mi = new JMenuItem( MainFrame.CHOOSE_NODE_SIZE_LABEL ) );
635 _options_jmenu.add( _label_direction_cbmi = new JCheckBoxMenuItem( MainFrame.LABEL_DIRECTION_LABEL ) );
637 .add( _color_labels_same_as_parent_branch = new JCheckBoxMenuItem( MainFrame.COLOR_LABELS_LABEL ) );
638 _color_labels_same_as_parent_branch.setToolTipText( MainFrame.COLOR_LABELS_TIP );
639 _options_jmenu.add( _abbreviate_scientific_names = new JCheckBoxMenuItem( MainFrame.ABBREV_SN_LABEL ) );
640 _label_direction_cbmi.setToolTipText( MainFrame.LABEL_DIRECTION_TIP );
641 _options_jmenu.add( _screen_antialias_cbmi = new JCheckBoxMenuItem( MainFrame.SCREEN_ANTIALIAS_LABEL ) );
642 _options_jmenu.add( _background_gradient_cbmi = new JCheckBoxMenuItem( MainFrame.BG_GRAD_LABEL ) );
643 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
644 _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( MainFrame.SHOW_DOMAIN_LABELS_LABEL ) );
646 _options_jmenu.add( _choose_minimal_confidence_mi = new JMenuItem( "" ) );
647 _options_jmenu.add( _overview_placment_mi = new JMenuItem( "" ) );
648 _options_jmenu.add( _switch_colors_mi = new JMenuItem( "" ) );
649 _options_jmenu.add( _choose_font_mi = new JMenuItem( "" ) );
650 _options_jmenu.addSeparator();
651 _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.SEARCH_SUBHEADER ),
652 getConfiguration() ) );
654 .add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_CASE_SENSITIVE_LABEL ) );
655 _options_jmenu.add( _search_whole_words_only_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_TERMS_ONLY_LABEL ) );
657 .add( _inverse_search_result_cbmi = new JCheckBoxMenuItem( MainFrame.INVERSE_SEARCH_RESULT_LABEL ) );
658 customizeJMenuItem( _choose_font_mi );
659 customizeJMenuItem( _choose_minimal_confidence_mi );
660 customizeJMenuItem( _switch_colors_mi );
661 customizeJMenuItem( _overview_placment_mi );
662 customizeCheckBoxMenuItem( _label_direction_cbmi,
663 getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL );
664 customizeCheckBoxMenuItem( _screen_antialias_cbmi, getOptions().isAntialiasScreen() );
665 customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );
666 customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );
667 customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );
668 customizeCheckBoxMenuItem( _show_default_node_shapes_external_cbmi, getOptions()
669 .isShowDefaultNodeShapesExternal() );
670 customizeCheckBoxMenuItem( _show_default_node_shapes_internal_cbmi, getOptions()
671 .isShowDefaultNodeShapesInternal() );
672 customizeCheckBoxMenuItem( _taxonomy_colorize_node_shapes_cbmi, getOptions().isTaxonomyColorizeNodeShapes() );
673 customizeJMenuItem( _cycle_node_shape_mi );
674 customizeJMenuItem( _cycle_node_fill_mi );
675 customizeJMenuItem( _choose_node_size_mi );
676 customizeCheckBoxMenuItem( _color_labels_same_as_parent_branch, getOptions().isColorLabelsSameAsParentBranch() );
677 customizeCheckBoxMenuItem( _search_case_senstive_cbmi, getOptions().isSearchCaseSensitive() );
678 customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );
679 customizeRadioButtonMenuItem( _non_lined_up_cladograms_rbmi,
680 getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP );
681 customizeRadioButtonMenuItem( _uniform_cladograms_rbmi,
682 getOptions().getCladogramType() == CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
683 customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi,
684 getOptions().getCladogramType() == CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
685 customizeCheckBoxMenuItem( _show_branch_length_values_cbmi, getOptions().isShowBranchLengthValues() );
686 customizeCheckBoxMenuItem( _show_overview_cbmi, getOptions().isShowOverview() );
687 customizeCheckBoxMenuItem( _search_whole_words_only_cbmi, getOptions().isMatchWholeTermsOnly() );
688 customizeCheckBoxMenuItem( _inverse_search_result_cbmi, getOptions().isInverseSearchResult() );
689 customizeCheckBoxMenuItem( _show_confidence_stddev_cbmi, getOptions().isShowConfidenceStddev() );
690 _jmenubar.add( _options_jmenu );
693 void buildToolsMenu() {
694 _tools_menu = MainFrame.createMenu( "Tools", getConfiguration() );
695 _tools_menu.add( _confcolor_item = new JMenuItem( "Colorize Branches Depending on Confidence" ) );
696 customizeJMenuItem( _confcolor_item );
697 _tools_menu.add( _taxcolor_item = new JMenuItem( "Taxonomy Colorize Branches" ) );
698 customizeJMenuItem( _taxcolor_item );
699 _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete Branch Colors" ) );
700 _remove_branch_color_item.setToolTipText( "To delete branch color values from the current phylogeny." );
701 customizeJMenuItem( _remove_branch_color_item );
702 _tools_menu.addSeparator();
703 _tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) );
704 customizeJMenuItem( _midpoint_root_item );
705 _tools_menu.addSeparator();
706 _tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Species-Specific Subtrees" ) );
707 customizeJMenuItem( _collapse_species_specific_subtrees );
708 _jmenubar.add( _tools_menu );
711 void buildTypeMenu() {
712 _type_menu = MainFrame.createMenu( MainFrame.TYPE_MENU_HEADER, getConfiguration() );
713 _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
714 _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
715 _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
716 _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
717 _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
718 _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
719 _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
720 _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
721 customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
722 customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
723 customizeCheckBoxMenuItem( _euro_type_cbmi, false );
724 customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
725 customizeCheckBoxMenuItem( _curved_type_cbmi, false );
726 customizeCheckBoxMenuItem( _convex_type_cbmi, false );
727 customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
728 customizeCheckBoxMenuItem( _circular_type_cbmi, false );
729 _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
730 _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
731 initializeTypeMenu( getOptions() );
732 _jmenubar.add( _type_menu );
735 void buildViewMenu() {
736 _view_jmenu = MainFrame.createMenu( "View", getConfiguration() );
737 _view_jmenu.add( _display_basic_information_item = new JMenuItem( "Display Basic Information" ) );
738 _view_jmenu.addSeparator();
739 _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) );
740 _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) );
741 _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "View as Nexus" ) );
742 customizeJMenuItem( _display_basic_information_item );
743 customizeJMenuItem( _view_as_NH_item );
744 customizeJMenuItem( _view_as_XML_item );
745 customizeJMenuItem( _view_as_nexus_item );
746 _jmenubar.add( _view_jmenu );
749 void checkTextFrames() {
750 if ( _textframes.size() > 5 ) {
752 if ( _textframes.getFirst() != null ) {
753 _textframes.getFirst().removeMe();
756 _textframes.removeFirst();
759 catch ( final NoSuchElementException e ) {
765 void clearCurrentExternalNodesDataBuffer() {
766 getCurrentTreePanel().clearCurrentExternalNodesDataBuffer();
769 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
770 if ( item != null ) {
771 item.setFont( MainFrame.menu_font );
772 if ( !getConfiguration().isUseNativeUI() ) {
773 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
774 item.setForeground( getConfiguration().getGuiMenuTextColor() );
776 item.setSelected( is_selected );
777 item.addActionListener( this );
781 void customizeJMenuItem( final JMenuItem jmi ) {
782 jmi.setFont( MainFrame.menu_font );
783 if ( !getConfiguration().isUseNativeUI() ) {
784 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
785 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
787 jmi.addActionListener( this );
790 void displayBasicInformation() {
791 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
792 String title = "Basic Information";
793 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
794 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
796 showTextFrame( AptxUtil.createBasicInformation( getMainPanel().getCurrentPhylogeny() ), title );
800 Configuration getConfiguration() {
801 return _configuration;
804 TreePanel getCurrentTreePanel() {
805 return getMainPanel().getCurrentTreePanel();
808 JCheckBoxMenuItem getlabelDirectionCbmi() {
809 return _label_direction_cbmi;
812 Options getOtions() {
816 void help( final Map<String, WebLink> weblinks ) {
817 final StringBuilder sb = new StringBuilder();
818 sb.append( "Display options\n" );
819 sb.append( "-------------------\n" );
820 sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
821 sb.append( "Clickable tree nodes\n" );
822 sb.append( "--------------------\n" );
823 sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
824 sb.append( "or by right clicking:\n" );
825 sb.append( "o Display Node Data -- display information for a node\n" );
826 sb.append( "o Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
827 sb.append( "o Root/Reroot -- change tree root to clicked node\n" );
828 sb.append( "o Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
829 sb.append( "o Swap Descendants -- switch descendant on either side of clicked node\n" );
830 sb.append( "o Colorize Subtree -- color a subtree\n" );
831 sb.append( "o Open Sequence Web -- launch a web browser to display sequence information\n" );
832 sb.append( "o Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
833 sb.append( "- there may be additional choices depending on this particular setup\n\n" );
834 sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
835 sb.append( "Zooming\n" );
836 sb.append( "---------\n" );
837 sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
838 sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
839 sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
840 sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
841 sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
842 sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
843 sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
844 sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
845 sb.append( "Quick tree manipulation:\n" );
846 sb.append( "------------------------\n" );
847 sb.append( "Order Subtrees -- order the tree by branch length\n" );
848 sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
849 sb.append( "Memory problems (Java heap space error)\n" );
850 sb.append( "---------------------------------------\n" );
851 sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
852 sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
853 sb.append( "the '-Xmx' Java command line option. For example:\n" );
854 sb.append( "java -Xms32m -Xmx256m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
855 if ( ( weblinks != null ) && ( weblinks.size() > 0 ) ) {
856 sb.append( "Active web links\n" );
857 sb.append( "--------------------\n" );
858 for( final String key : weblinks.keySet() ) {
859 sb.append( " " + weblinks.get( key ).toString() + "\n" );
863 sb.append( "phyloXML\n" );
864 sb.append( "-------------------\n" );
865 sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
866 sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
867 sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
869 sb.append( "For more information: http://www.phylosoft.org/archaeopteryx/\n" );
870 sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
871 TextFrame.instantiate( sb.toString(), "Help", _textframes );
874 void initializeTypeMenu( final Options options ) {
875 setTypeMenuToAllUnselected();
877 switch ( options.getPhylogenyGraphicsType() ) {
879 _convex_type_cbmi.setSelected( true );
882 _curved_type_cbmi.setSelected( true );
885 _euro_type_cbmi.setSelected( true );
888 _rounded_type_cbmi.setSelected( true );
891 _triangular_type_cbmi.setSelected( true );
894 _unrooted_type_cbmi.setSelected( true );
897 _circular_type_cbmi.setSelected( true );
900 _rectangular_type_cbmi.setSelected( true );
904 catch ( final NullPointerException np ) {
905 // In all likelihood, this is caused by menu-less display.
909 void removeAllTextFrames() {
910 for( final TextFrame tf : _textframes ) {
918 void setConfiguration( final Configuration configuration ) {
919 _configuration = configuration;
922 void setOptions( final Options options ) {
926 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
927 setTypeMenuToAllUnselected();
931 _circular_type_cbmi.setSelected( true );
934 _convex_type_cbmi.setSelected( true );
937 _curved_type_cbmi.setSelected( true );
940 _euro_type_cbmi.setSelected( true );
943 _rounded_type_cbmi.setSelected( true );
946 _rectangular_type_cbmi.setSelected( true );
949 _triangular_type_cbmi.setSelected( true );
952 _unrooted_type_cbmi.setSelected( true );
955 throw new IllegalArgumentException( "unknown type: " + type );
958 catch ( final NullPointerException np ) {
959 // In all likelihood, this is caused by menu-less display.
963 void setTypeMenuToAllUnselected() {
964 if ( _convex_type_cbmi != null ) {
965 _convex_type_cbmi.setSelected( false );
967 if ( _curved_type_cbmi != null ) {
968 _curved_type_cbmi.setSelected( false );
970 if ( _euro_type_cbmi != null ) {
971 _euro_type_cbmi.setSelected( false );
973 if ( _rounded_type_cbmi != null ) {
974 _rounded_type_cbmi.setSelected( false );
976 if ( _triangular_type_cbmi != null ) {
977 _triangular_type_cbmi.setSelected( false );
979 if ( _rectangular_type_cbmi != null ) {
980 _rectangular_type_cbmi.setSelected( false );
982 if ( _unrooted_type_cbmi != null ) {
983 _unrooted_type_cbmi.setSelected( false );
985 if ( _circular_type_cbmi != null ) {
986 _circular_type_cbmi.setSelected( false );
990 void switchColors() {
991 final TreeColorSet colorset = getMainPanel().getCurrentTreePanel().getTreeColorSet();
992 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
993 csc.setVisible( true );
994 getMainPanel().setTreeColorSet( colorset );
997 void typeChanged( final Object o ) {
998 updateTypeCheckboxes( getOptions(), o );
999 updateOptions( getOptions() );
1000 if ( getCurrentTreePanel() != null ) {
1001 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
1002 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
1003 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1004 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
1005 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1006 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
1007 getCurrentTreePanel().getControlPanel().showWhole();
1009 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1010 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
1013 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
1015 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
1016 MainFrame.updateScreenTextAntialias( getMainPanel().getTreePanels() );
1020 void updateOptions( final Options options ) {
1021 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
1022 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
1023 && _background_gradient_cbmi.isSelected() );
1024 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
1025 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
1026 && _abbreviate_scientific_names.isSelected() );
1027 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
1028 && _color_labels_same_as_parent_branch.isSelected() );
1029 options.setShowDefaultNodeShapesInternal( ( _show_default_node_shapes_internal_cbmi != null )
1030 && _show_default_node_shapes_internal_cbmi.isSelected() );
1031 options.setShowDefaultNodeShapesExternal( ( _show_default_node_shapes_external_cbmi != null )
1032 && _show_default_node_shapes_external_cbmi.isSelected() );
1033 options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null )
1034 && _taxonomy_colorize_node_shapes_cbmi.isSelected() );
1035 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
1036 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
1038 else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
1039 options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1041 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
1042 options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1044 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
1045 && _search_case_senstive_cbmi.isSelected() );
1046 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
1047 options.setShowScale( _show_scale_cbmi.isSelected() );
1049 if ( _label_direction_cbmi != null ) {
1050 if ( _label_direction_cbmi.isSelected() ) {
1051 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1054 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1057 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
1058 options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )
1059 && _show_confidence_stddev_cbmi.isSelected() );
1060 if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
1061 options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
1063 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
1064 && _search_whole_words_only_cbmi.isSelected() );
1065 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
1066 && _inverse_search_result_cbmi.isSelected() );
1067 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
1068 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1070 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
1071 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1073 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
1074 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1076 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
1077 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1079 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
1080 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1082 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
1083 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1085 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
1086 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1088 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
1089 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1093 void updateTypeCheckboxes( final Options options, final Object o ) {
1094 setTypeMenuToAllUnselected();
1095 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
1098 void viewAsNexus() {
1099 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1100 String title = "Nexus";
1101 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1102 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1104 showTextFrame( getMainPanel().getCurrentPhylogeny().toNexus( getOptions()
1105 .getNhConversionSupportValueStyle() ),
1111 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1112 String title = "New Hampshire";
1113 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1114 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1116 showTextFrame( getMainPanel().getCurrentPhylogeny()
1117 .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ),
1123 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1124 String title = "phyloXML";
1125 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1126 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1128 showTextFrame( getMainPanel().getCurrentPhylogeny().toPhyloXML( 0 ), title );
1132 private void chooseFont() {
1133 final FontChooser fc = new FontChooser();
1134 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
1135 fc.showDialog( this, "Select the Base Font" );
1136 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
1139 private void chooseMinimalConfidence() {
1140 final String s = ( String ) JOptionPane
1141 .showInputDialog( this,
1142 "Please the minimum for confidence values to be displayed.\n" + "[current value: "
1143 + getOptions().getMinConfidenceValue() + "]\n",
1144 "Minimal Confidence Value",
1145 JOptionPane.QUESTION_MESSAGE,
1148 getOptions().getMinConfidenceValue() );
1149 if ( !ForesterUtil.isEmpty( s ) ) {
1150 boolean success = true;
1152 final String m_str = s.trim();
1153 if ( !ForesterUtil.isEmpty( m_str ) ) {
1155 m = Double.parseDouble( m_str );
1157 catch ( final Exception ex ) {
1164 if ( success && ( m >= 0.0 ) ) {
1165 getOptions().setMinConfidenceValue( m );
1170 private void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
1171 if ( item != null ) {
1172 item.setFont( MainFrame.menu_font );
1173 if ( !getConfiguration().isUseNativeUI() ) {
1174 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
1175 item.setForeground( getConfiguration().getGuiMenuTextColor() );
1177 item.setSelected( is_selected );
1178 item.addActionListener( this );
1182 private MainPanel getMainPanel() {
1186 private boolean isScreenAntialias() {
1190 private void removeBranchColors() {
1191 if ( getMainPanel().getCurrentPhylogeny() != null ) {
1192 AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
1196 private void setMainPanel( final MainPanelApplets main_panel ) {
1197 _main_panel = main_panel;
1200 private void setupUI() {
1202 if ( getConfiguration().isUseNativeUI() ) {
1203 UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
1206 UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
1209 catch ( final UnsupportedLookAndFeelException e ) {
1210 AptxUtil.dieWithSystemError( "UnsupportedLookAndFeelException: " + e.toString() );
1212 catch ( final ClassNotFoundException e ) {
1213 AptxUtil.dieWithSystemError( "ClassNotFoundException: " + e.toString() );
1215 catch ( final InstantiationException e ) {
1216 AptxUtil.dieWithSystemError( "InstantiationException: " + e.toString() );
1218 catch ( final IllegalAccessException e ) {
1219 AptxUtil.dieWithSystemError( "IllegalAccessException: " + e.toString() );
1221 catch ( final Exception e ) {
1222 AptxUtil.dieWithSystemError( e.toString() );
1226 static void setupScreenTextAntialias( final List<TreePanel> treepanels, final boolean antialias ) {
1227 for( final TreePanel tree_panel : treepanels ) {
1228 tree_panel.setTextAntialias();