2 package org.forester.archaeopteryx;
4 import java.awt.BorderLayout;
5 import java.awt.Container;
6 import java.awt.event.ActionEvent;
7 import java.awt.event.ActionListener;
8 import java.awt.event.ComponentAdapter;
9 import java.awt.event.ComponentEvent;
10 import java.io.ByteArrayOutputStream;
12 import java.io.IOException;
14 import java.util.LinkedList;
15 import java.util.List;
16 import java.util.NoSuchElementException;
18 import javax.swing.ButtonGroup;
19 import javax.swing.JApplet;
20 import javax.swing.JCheckBoxMenuItem;
21 import javax.swing.JMenu;
22 import javax.swing.JMenuBar;
23 import javax.swing.JMenuItem;
24 import javax.swing.JOptionPane;
25 import javax.swing.JRadioButtonMenuItem;
26 import javax.swing.UIManager;
27 import javax.swing.UnsupportedLookAndFeelException;
28 import javax.swing.event.ChangeEvent;
29 import javax.swing.event.ChangeListener;
31 import org.apache.commons.codec.binary.Base64;
32 import org.forester.archaeopteryx.AptxUtil.GraphicsExportType;
33 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
34 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
35 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
36 import org.forester.phylogeny.Phylogeny;
37 import org.forester.phylogeny.data.SequenceRelation;
38 import org.forester.util.ForesterConstants;
39 import org.forester.util.ForesterUtil;
42 // <applet archive="forester.jar"
43 // code="org.forester.archaeopteryx.ArchaeopteryxE.class"
44 // codebase="http://www.myserver.org/path/to/forester"
47 // alt="ArchaeopteryxE is not working on your system (requires at least Sun Java 1.5)!">
48 // <param name="url_of_tree_to_load"
49 // value="http://www.myserver.org/examples/data/apaf.xml">
50 // <param name="config_file"
51 // value="http://www.myserver.org/examples/config/config_file.txt">
53 public class ArchaeopteryxE extends JApplet implements ActionListener {
55 private final static String NAME = "ArchaeopteryxE";
56 private static final long serialVersionUID = -1220055577935759443L;
57 private Configuration _configuration;
58 private MainPanelApplets _main_panel;
59 private JMenuBar _jmenubar;
60 private JMenu _options_jmenu;
61 private JMenu _font_size_menu;
62 private JMenuItem _super_tiny_fonts_mi;
63 private JMenuItem _tiny_fonts_mi;
64 private JMenuItem _small_fonts_mi;
65 private JMenuItem _medium_fonts_mi;
66 private JMenuItem _large_fonts_mi;
67 private JMenu _tools_menu;
68 private JMenuItem _taxcolor_item;
69 private JMenuItem _confcolor_item;
70 private JMenuItem _midpoint_root_item;
71 private JMenu _view_jmenu;
72 private JMenuItem _view_as_XML_item;
73 private JMenuItem _view_as_NH_item;
74 private JMenuItem _view_as_nexus_item;
75 private JMenuItem _display_basic_information_item;
76 private JMenu _type_menu;
77 private JCheckBoxMenuItem _rectangular_type_cbmi;
78 private JCheckBoxMenuItem _triangular_type_cbmi;
79 private JCheckBoxMenuItem _curved_type_cbmi;
80 private JCheckBoxMenuItem _convex_type_cbmi;
81 private JCheckBoxMenuItem _euro_type_cbmi;
82 private JCheckBoxMenuItem _rounded_type_cbmi;
83 private JCheckBoxMenuItem _unrooted_type_cbmi;
84 private JCheckBoxMenuItem _circular_type_cbmi;
85 private JMenuItem _help_item;
86 private JMenuItem _about_item;
87 private JMenu _help_jmenu;
88 private JMenuItem _website_item;
89 private JMenuItem _phyloxml_website_item;
90 private JMenuItem _phyloxml_ref_item;
91 private JMenuItem _aptx_ref_item;
92 private JMenuItem _remove_branch_color_item;
93 private JCheckBoxMenuItem _show_domain_labels;
94 private JCheckBoxMenuItem _color_labels_same_as_parent_branch;
95 private JCheckBoxMenuItem _abbreviate_scientific_names;
96 private JCheckBoxMenuItem _screen_antialias_cbmi;
97 private JCheckBoxMenuItem _background_gradient_cbmi;
98 private JRadioButtonMenuItem _non_lined_up_cladograms_rbmi;
99 private JRadioButtonMenuItem _uniform_cladograms_rbmi;
100 private JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi;
101 private Options _options;
102 private JMenuItem _choose_font_mi;
103 private JMenuItem _switch_colors_mi;
104 JCheckBoxMenuItem _label_direction_cbmi;
105 private JCheckBoxMenuItem _show_scale_cbmi;
106 private JCheckBoxMenuItem _search_case_senstive_cbmi;
107 private JCheckBoxMenuItem _search_whole_words_only_cbmi;
108 private JCheckBoxMenuItem _inverse_search_result_cbmi;
109 private JCheckBoxMenuItem _show_overview_cbmi;
110 private JMenuItem _choose_minimal_confidence_mi;
111 private JCheckBoxMenuItem _show_branch_length_values_cbmi;
112 private JMenuItem _collapse_species_specific_subtrees;
113 private JMenuItem _overview_placment_mi;
114 private ButtonGroup _radio_group_1;
115 private JCheckBoxMenuItem _show_default_node_shapes_internal_cbmi;
116 private JCheckBoxMenuItem _show_default_node_shapes_external_cbmi;
117 private JMenuItem _cycle_node_shape_mi;
118 private JMenuItem _cycle_node_fill_mi;
119 private JMenuItem _choose_node_size_mi;
120 private JCheckBoxMenuItem _taxonomy_colorize_node_shapes_cbmi;
121 private JCheckBoxMenuItem _show_confidence_stddev_cbmi;
122 private final LinkedList<TextFrame> _textframes = new LinkedList<TextFrame>();
124 // private String _ext_node_data_buffer = "";
125 // private int _ext_node_data_buffer_change_counter = 0;
127 public void actionPerformed( final ActionEvent e ) {
128 final Object o = e.getSource();
129 if ( o == _midpoint_root_item ) {
130 getMainPanel().getCurrentTreePanel().midpointRoot();
132 else if ( o == _taxcolor_item ) {
133 getMainPanel().getCurrentTreePanel().taxColor();
135 else if ( o == _confcolor_item ) {
136 getMainPanel().getCurrentTreePanel().confColor();
138 else if ( o == _collapse_species_specific_subtrees ) {
139 if ( getCurrentTreePanel() != null ) {
140 getCurrentTreePanel().collapseSpeciesSpecificSubtrees();
143 else if ( o == _remove_branch_color_item ) {
144 removeBranchColors();
146 else if ( o == _switch_colors_mi ) {
149 else if ( o == _display_basic_information_item ) {
150 displayBasicInformation();
152 else if ( o == _view_as_NH_item ) {
155 else if ( o == _view_as_XML_item ) {
158 else if ( o == _view_as_nexus_item ) {
161 else if ( o == _super_tiny_fonts_mi ) {
162 if ( getCurrentTreePanel() != null ) {
163 getCurrentTreePanel().setSuperTinyFonts();
164 getCurrentTreePanel().repaint();
167 else if ( o == _tiny_fonts_mi ) {
168 if ( getCurrentTreePanel() != null ) {
169 getCurrentTreePanel().setTinyFonts();
170 getCurrentTreePanel().repaint();
173 else if ( o == _small_fonts_mi ) {
174 if ( getCurrentTreePanel() != null ) {
175 getCurrentTreePanel().setSmallFonts();
176 getCurrentTreePanel().repaint();
179 else if ( o == _medium_fonts_mi ) {
180 if ( getCurrentTreePanel() != null ) {
181 getCurrentTreePanel().setMediumFonts();
182 getCurrentTreePanel().repaint();
185 else if ( o == _large_fonts_mi ) {
186 if ( getCurrentTreePanel() != null ) {
187 getCurrentTreePanel().setLargeFonts();
188 getCurrentTreePanel().repaint();
191 else if ( o == _choose_font_mi ) {
194 else if ( o == _choose_minimal_confidence_mi ) {
195 chooseMinimalConfidence();
197 else if ( o == _choose_node_size_mi ) {
198 MainFrame.chooseNodeSize( getOptions(), this );
200 else if ( o == _overview_placment_mi ) {
201 MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
203 else if ( o == _cycle_node_fill_mi ) {
204 MainFrame.cycleNodeFill( getOptions(), getCurrentTreePanel() );
206 else if ( o == _cycle_node_shape_mi ) {
207 MainFrame.cycleNodeShape( getOptions(), getCurrentTreePanel() );
209 else if ( o == _non_lined_up_cladograms_rbmi ) {
210 updateOptions( getOptions() );
211 _main_panel.getControlPanel().showWhole();
213 else if ( o == _uniform_cladograms_rbmi ) {
214 updateOptions( getOptions() );
215 _main_panel.getControlPanel().showWhole();
217 else if ( o == _ext_node_dependent_cladogram_rbmi ) {
218 updateOptions( getOptions() );
219 _main_panel.getControlPanel().showWhole();
221 else if ( o == _search_case_senstive_cbmi ) {
222 updateOptions( getOptions() );
223 getMainPanel().getControlPanel().search();
225 else if ( o == _search_whole_words_only_cbmi ) {
226 updateOptions( getOptions() );
227 getMainPanel().getControlPanel().search();
229 else if ( o == _inverse_search_result_cbmi ) {
230 updateOptions( getOptions() );
231 getMainPanel().getControlPanel().search();
233 else if ( o == _show_scale_cbmi ) {
234 updateOptions( getOptions() );
236 else if ( o == _show_branch_length_values_cbmi ) {
237 updateOptions( getOptions() );
239 else if ( o == _show_confidence_stddev_cbmi ) {
240 updateOptions( getOptions() );
242 else if ( o == _label_direction_cbmi ) {
243 updateOptions( getOptions() );
245 else if ( o == _show_overview_cbmi ) {
246 updateOptions( getOptions() );
247 if ( getCurrentTreePanel() != null ) {
248 getCurrentTreePanel().updateOvSizes();
251 else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
252 || ( o == _convex_type_cbmi ) || ( o == _rounded_type_cbmi ) || ( o == _euro_type_cbmi )
253 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
256 else if ( o == _screen_antialias_cbmi ) {
257 updateOptions( getOptions() );
258 setupScreenTextAntialias( getMainPanel().getTreePanels(), isScreenAntialias() );
260 else if ( o == _background_gradient_cbmi ) {
261 updateOptions( getOptions() );
263 else if ( o == _show_domain_labels ) {
264 updateOptions( getOptions() );
266 else if ( o == _color_labels_same_as_parent_branch ) {
267 updateOptions( getOptions() );
269 else if ( o == _show_default_node_shapes_internal_cbmi ) {
270 updateOptions( getOptions() );
272 else if ( o == _show_default_node_shapes_external_cbmi ) {
273 updateOptions( getOptions() );
275 else if ( o == _taxonomy_colorize_node_shapes_cbmi ) {
276 updateOptions( getOptions() );
278 else if ( o == _about_item ) {
281 else if ( o == _help_item ) {
284 else if ( o == _website_item ) {
286 AptxUtil.openWebsite( Constants.APTX_WEB_SITE, true, this );
288 catch ( final IOException e1 ) {
289 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
292 else if ( o == _phyloxml_website_item ) {
294 AptxUtil.openWebsite( Constants.PHYLOXML_WEB_SITE, true, this );
296 catch ( final IOException e1 ) {
297 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
300 else if ( o == _aptx_ref_item ) {
302 AptxUtil.openWebsite( Constants.APTX_REFERENCE_URL, true, this );
304 catch ( final IOException e1 ) {
305 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
308 else if ( o == _phyloxml_ref_item ) {
310 AptxUtil.openWebsite( Constants.PHYLOXML_REFERENCE_URL, true, this );
312 catch ( final IOException e1 ) {
313 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
320 public void destroy() {
321 AptxUtil.printAppletMessage( NAME, "going to be destroyed " );
322 removeAllTextFrames();
323 if ( getMainPanel() != null ) {
324 getMainPanel().terminate();
329 * This method returns the current external node data which
330 * has been selected by the user by clicking the "Return ..."
331 * menu item. This method is expected to be called from Javascript or
334 * @return current external node data as String
336 public String getCurrentExternalNodesDataBuffer() {
337 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString();
340 public int getCurrentExternalNodesDataBufferChangeCounter() {
341 return getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter();
344 public int getCurrentExternalNodesDataBufferLength() {
345 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length();
349 * This method returns the current phylogeny as a string in the chosen format
351 * @param format must be NH, NHX, NEXUS or PHYLOXML
352 * @return the phylogeny string
353 * @author Herve Menager
355 public String getCurrentPhylogeny( final String format ) {
356 removeAllTextFrames();
357 if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty()
358 || ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
361 switch ( ForesterConstants.PhylogeneticTreeFormats.valueOf( format ) ) {
363 return getMainPanel().getCurrentPhylogeny().toNewHampshire();
365 return getMainPanel().getCurrentPhylogeny().toNewHampshireX();
367 return getMainPanel().getCurrentPhylogeny().toNexus();
369 return getMainPanel().getCurrentPhylogeny().toPhyloXML( -1 );
377 * This method returns a view of the current phylogeny in a chosen
378 * graphics format, base64-encoded in a string so that in can be used
381 * @param format must be GraphicsExportType (gif, jpg, pdf, png, tif, bmp)
382 * @return the phylogeny string
383 * @author Herve Menager
385 public String getCurrentPhylogenyGraphicsAsBase64EncodedString( final String format ) {
386 final ByteArrayOutputStream baos = new ByteArrayOutputStream();
388 AptxUtil.writePhylogenyToGraphicsByteArrayOutputStream( baos,
389 _main_panel.getWidth(),
390 _main_panel.getHeight(),
391 getCurrentTreePanel(),
392 getCurrentTreePanel().getControlPanel(),
393 GraphicsExportType.valueOf( format ),
396 catch ( final IOException ioe ) {
397 ForesterUtil.printErrorMessage( NAME, ioe.toString() );
398 ioe.printStackTrace();
399 JOptionPane.showMessageDialog( this,
400 NAME + ": Failed to generate graphics: " + "\nException: " + ioe,
401 "Failed to generate graphics",
402 JOptionPane.ERROR_MESSAGE );
405 final byte[] bytes = baos.toByteArray();
406 final String dataImg = Base64.encodeBase64String( bytes );
410 public Options getOptions() {
416 final String config_filename = getParameter( Constants.APPLET_PARAM_NAME_FOR_CONFIG_FILE_URL );
417 AptxUtil.printAppletMessage( NAME, "URL for configuration file is: " + config_filename );
418 final Configuration configuration = new Configuration( config_filename, true, true, true );
419 setConfiguration( configuration );
420 setOptions( Options.createInstance( configuration ) );
423 Phylogeny[] phys = null;
424 final String tree_url_str = getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD );
425 AptxUtil.printAppletMessage( NAME, "URL for phylogenies is " + tree_url_str );
426 // Get URL to tree file
427 if ( tree_url_str != null ) {
429 phys_url = new URL( tree_url_str );
431 catch ( final Exception e ) {
432 ForesterUtil.printErrorMessage( NAME, "error: " + e );
434 JOptionPane.showMessageDialog( this, NAME + ": Could not create URL from: \"" + tree_url_str
435 + "\"\nException: " + e, "Failed to create URL", JOptionPane.ERROR_MESSAGE );
438 // Load the tree from URL
439 if ( phys_url != null ) {
441 phys = AptxUtil.readPhylogeniesFromUrl( phys_url,
442 getConfiguration().isValidatePhyloXmlAgainstSchema(),
443 getConfiguration().isReplaceUnderscoresInNhParsing(),
444 getConfiguration().isInternalNumberAreConfidenceForNhParsing(),
445 getConfiguration().getTaxonomyExtraction() );
447 catch ( final Exception e ) {
448 ForesterUtil.printErrorMessage( NAME, e.toString() );
450 JOptionPane.showMessageDialog( this,
451 NAME + ": Failed to read phylogenies: " + "\nException: " + e,
452 "Failed to read phylogenies",
453 JOptionPane.ERROR_MESSAGE );
456 if ( ( phys == null ) || ( phys.length < 1 ) ) {
457 ForesterUtil.printErrorMessage( NAME, "phylogenies from [" + phys_url + "] are null or empty" );
458 JOptionPane.showMessageDialog( this,
459 NAME + ": phylogenies from [" + phys_url + "] are null or empty",
460 "Failed to read phylogenies",
461 JOptionPane.ERROR_MESSAGE );
465 AptxUtil.printAppletMessage( NAME, "loaded " + phys.length + " phylogenies from: " + phys_url );
468 setMainPanel( new MainPanelApplets( getConfiguration(), this ) );
469 _jmenubar = new JMenuBar();
470 if ( !getConfiguration().isHideControlPanelAndMenubar() ) {
471 if ( !getConfiguration().isUseNativeUI() ) {
472 _jmenubar.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
480 setJMenuBar( _jmenubar );
482 final Container contentpane = getContentPane();
483 contentpane.setLayout( new BorderLayout() );
484 contentpane.add( getMainPanel(), BorderLayout.CENTER );
485 addComponentListener( new ComponentAdapter() {
488 public void componentResized( final ComponentEvent e ) {
489 if ( getMainPanel().getCurrentTreePanel() != null ) {
490 getMainPanel().getCurrentTreePanel().calcParametersForPainting( getMainPanel()
491 .getCurrentTreePanel()
494 .getCurrentTreePanel()
497 .isAllowFontSizeChange() );
501 if ( getConfiguration().isUseTabbedDisplay() ) {
502 AptxUtil.printAppletMessage( NAME, "using tabbed display" );
503 AptxUtil.addPhylogeniesToTabs( phys,
504 new File( phys_url.getFile() ).getName(),
510 AptxUtil.printAppletMessage( NAME, "not using tabbed display" );
511 AptxUtil.addPhylogenyToPanel( phys, getConfiguration(), getMainPanel() );
515 getMainPanel().getControlPanel().showWholeAll();
516 getMainPanel().getControlPanel().showWhole();
518 AptxUtil.printAppletMessage( NAME, "successfully initialized" );
520 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().removeAllItems();
521 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
522 .getRelevantSequenceRelationTypes() ) {
523 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().addItem( type );
525 final String default_relation = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_SEQUENCE_RELATION_TYPE );
526 if ( default_relation != null ) {
527 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().setSelectedItem( default_relation );
529 final String default_sequence = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_QUERY_SEQUENCE );
530 if ( default_sequence != null ) {
531 getCurrentTreePanel().getControlPanel().getSequenceRelationBox().setSelectedItem( default_sequence );
537 public void showTextFrame( final String s, final String title ) {
539 _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
543 public void start() {
544 if ( getMainPanel() != null ) {
545 getMainPanel().validate();
548 requestFocusInWindow();
550 AptxUtil.printAppletMessage( NAME, "started" );
553 void buildFontSizeMenu() {
554 _font_size_menu = MainFrame.createMenu( MainFrame.FONT_SIZE_MENU_LABEL, getConfiguration() );
555 _font_size_menu.add( _super_tiny_fonts_mi = new JMenuItem( "Super tiny fonts" ) );
556 _font_size_menu.add( _tiny_fonts_mi = new JMenuItem( "Tiny fonts" ) );
557 _font_size_menu.add( _small_fonts_mi = new JMenuItem( "Small fonts" ) );
558 _font_size_menu.add( _medium_fonts_mi = new JMenuItem( "Medium fonts" ) );
559 _font_size_menu.add( _large_fonts_mi = new JMenuItem( "Large fonts" ) );
560 customizeJMenuItem( _super_tiny_fonts_mi );
561 customizeJMenuItem( _tiny_fonts_mi );
562 customizeJMenuItem( _small_fonts_mi );
563 customizeJMenuItem( _medium_fonts_mi );
564 customizeJMenuItem( _large_fonts_mi );
565 _jmenubar.add( _font_size_menu );
568 void buildHelpMenu() {
569 _help_jmenu = MainFrame.createMenu( "Help", getConfiguration() );
570 _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
571 _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
572 _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
573 _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
574 _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
575 _help_jmenu.addSeparator();
576 _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
577 customizeJMenuItem( _help_item );
578 customizeJMenuItem( _website_item );
579 customizeJMenuItem( _phyloxml_website_item );
580 customizeJMenuItem( _aptx_ref_item );
581 customizeJMenuItem( _phyloxml_ref_item );
582 customizeJMenuItem( _about_item );
583 _phyloxml_ref_item.setToolTipText( MainFrame.PHYLOXML_REF_TOOL_TIP );
584 _aptx_ref_item.setToolTipText( MainFrame.APTX_REF_TOOL_TIP );
585 _jmenubar.add( _help_jmenu );
588 void buildOptionsMenu() {
589 _options_jmenu = MainFrame.createMenu( MainFrame.OPTIONS_HEADER, getConfiguration() );
590 _options_jmenu.addChangeListener( new ChangeListener() {
593 public void stateChanged( final ChangeEvent e ) {
594 MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getOptions() );
595 MainFrame.setTextColorChooseMenuItem( _switch_colors_mi, getCurrentTreePanel() );
597 .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() );
598 MainFrame.setTextForFontChooserMenuItem( _choose_font_mi, MainFrame
599 .createCurrentFontDesc( getMainPanel().getTreeFontSet() ) );
600 MainFrame.updateOptionsMenuDependingOnPhylogenyType( getMainPanel(),
602 _show_branch_length_values_cbmi,
603 _non_lined_up_cladograms_rbmi,
604 _uniform_cladograms_rbmi,
605 _ext_node_dependent_cladogram_rbmi,
606 _label_direction_cbmi );
607 MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() );
608 MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() );
609 MainFrame.setTextNodeSizeMenuItem( _choose_node_size_mi, getOptions() );
612 _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.DISPLAY_SUBHEADER ),
613 getConfiguration() ) );
615 .add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );
616 _options_jmenu.add( _uniform_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.UNIFORM_CLADOGRAMS_LABEL ) );
618 .add( _non_lined_up_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.NON_LINED_UP_CLADOGRAMS_LABEL ) );
619 _radio_group_1 = new ButtonGroup();
620 _radio_group_1.add( _ext_node_dependent_cladogram_rbmi );
621 _radio_group_1.add( _uniform_cladograms_rbmi );
622 _radio_group_1.add( _non_lined_up_cladograms_rbmi );
623 _options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_OVERVIEW_LABEL ) );
624 _options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_SCALE_LABEL ) );
626 .add( _show_branch_length_values_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_BRANCH_LENGTH_VALUES_LABEL ) );
627 _options_jmenu.add( _show_confidence_stddev_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_CONF_STDDEV_LABEL ) );
629 .add( _show_default_node_shapes_internal_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_INT ) );
631 .add( _show_default_node_shapes_external_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_EXT ) );
633 .add( _taxonomy_colorize_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.TAXONOMY_COLORIZE_NODE_SHAPES_LABEL ) );
634 _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL ) );
635 _options_jmenu.add( _cycle_node_fill_mi = new JMenuItem( MainFrame.CYCLE_NODE_FILL_LABEL ) );
636 _options_jmenu.add( _choose_node_size_mi = new JMenuItem( MainFrame.CHOOSE_NODE_SIZE_LABEL ) );
637 _options_jmenu.add( _label_direction_cbmi = new JCheckBoxMenuItem( MainFrame.LABEL_DIRECTION_LABEL ) );
639 .add( _color_labels_same_as_parent_branch = new JCheckBoxMenuItem( MainFrame.COLOR_LABELS_LABEL ) );
640 _color_labels_same_as_parent_branch.setToolTipText( MainFrame.COLOR_LABELS_TIP );
641 _options_jmenu.add( _abbreviate_scientific_names = new JCheckBoxMenuItem( MainFrame.ABBREV_SN_LABEL ) );
642 _label_direction_cbmi.setToolTipText( MainFrame.LABEL_DIRECTION_TIP );
643 _options_jmenu.add( _screen_antialias_cbmi = new JCheckBoxMenuItem( MainFrame.SCREEN_ANTIALIAS_LABEL ) );
644 _options_jmenu.add( _background_gradient_cbmi = new JCheckBoxMenuItem( MainFrame.BG_GRAD_LABEL ) );
645 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
646 _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( MainFrame.SHOW_DOMAIN_LABELS_LABEL ) );
648 _options_jmenu.add( _choose_minimal_confidence_mi = new JMenuItem( "" ) );
649 _options_jmenu.add( _overview_placment_mi = new JMenuItem( "" ) );
650 _options_jmenu.add( _switch_colors_mi = new JMenuItem( "" ) );
651 _options_jmenu.add( _choose_font_mi = new JMenuItem( "" ) );
652 _options_jmenu.addSeparator();
653 _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.SEARCH_SUBHEADER ),
654 getConfiguration() ) );
656 .add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_CASE_SENSITIVE_LABEL ) );
657 _options_jmenu.add( _search_whole_words_only_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_TERMS_ONLY_LABEL ) );
659 .add( _inverse_search_result_cbmi = new JCheckBoxMenuItem( MainFrame.INVERSE_SEARCH_RESULT_LABEL ) );
660 customizeJMenuItem( _choose_font_mi );
661 customizeJMenuItem( _choose_minimal_confidence_mi );
662 customizeJMenuItem( _switch_colors_mi );
663 customizeJMenuItem( _overview_placment_mi );
664 customizeCheckBoxMenuItem( _label_direction_cbmi,
665 getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL );
666 customizeCheckBoxMenuItem( _screen_antialias_cbmi, getOptions().isAntialiasScreen() );
667 customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );
668 customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );
669 customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );
670 customizeCheckBoxMenuItem( _show_default_node_shapes_external_cbmi, getOptions()
671 .isShowDefaultNodeShapesExternal() );
672 customizeCheckBoxMenuItem( _show_default_node_shapes_internal_cbmi, getOptions()
673 .isShowDefaultNodeShapesInternal() );
674 customizeCheckBoxMenuItem( _taxonomy_colorize_node_shapes_cbmi, getOptions().isTaxonomyColorizeNodeShapes() );
675 customizeJMenuItem( _cycle_node_shape_mi );
676 customizeJMenuItem( _cycle_node_fill_mi );
677 customizeJMenuItem( _choose_node_size_mi );
678 customizeCheckBoxMenuItem( _color_labels_same_as_parent_branch, getOptions().isColorLabelsSameAsParentBranch() );
679 customizeCheckBoxMenuItem( _search_case_senstive_cbmi, getOptions().isSearchCaseSensitive() );
680 customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );
681 customizeRadioButtonMenuItem( _non_lined_up_cladograms_rbmi,
682 getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP );
683 customizeRadioButtonMenuItem( _uniform_cladograms_rbmi,
684 getOptions().getCladogramType() == CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
685 customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi,
686 getOptions().getCladogramType() == CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
687 customizeCheckBoxMenuItem( _show_branch_length_values_cbmi, getOptions().isShowBranchLengthValues() );
688 customizeCheckBoxMenuItem( _show_overview_cbmi, getOptions().isShowOverview() );
689 customizeCheckBoxMenuItem( _search_whole_words_only_cbmi, getOptions().isMatchWholeTermsOnly() );
690 customizeCheckBoxMenuItem( _inverse_search_result_cbmi, getOptions().isInverseSearchResult() );
691 customizeCheckBoxMenuItem( _show_confidence_stddev_cbmi, getOptions().isShowConfidenceStddev() );
692 _jmenubar.add( _options_jmenu );
695 void buildToolsMenu() {
696 _tools_menu = MainFrame.createMenu( "Tools", getConfiguration() );
697 _tools_menu.add( _confcolor_item = new JMenuItem( "Colorize Branches Depending on Confidence" ) );
698 customizeJMenuItem( _confcolor_item );
699 _tools_menu.add( _taxcolor_item = new JMenuItem( "Taxonomy Colorize Branches" ) );
700 customizeJMenuItem( _taxcolor_item );
701 _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete Branch Colors" ) );
702 _remove_branch_color_item.setToolTipText( "To delete branch color values from the current phylogeny." );
703 customizeJMenuItem( _remove_branch_color_item );
704 _tools_menu.addSeparator();
705 _tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) );
706 customizeJMenuItem( _midpoint_root_item );
707 _tools_menu.addSeparator();
708 _tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Species-Specific Subtrees" ) );
709 customizeJMenuItem( _collapse_species_specific_subtrees );
710 _jmenubar.add( _tools_menu );
713 void buildTypeMenu() {
714 _type_menu = MainFrame.createMenu( MainFrame.TYPE_MENU_HEADER, getConfiguration() );
715 _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
716 _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
717 _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
718 _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
719 _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
720 _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
721 _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
722 _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
723 customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
724 customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
725 customizeCheckBoxMenuItem( _euro_type_cbmi, false );
726 customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
727 customizeCheckBoxMenuItem( _curved_type_cbmi, false );
728 customizeCheckBoxMenuItem( _convex_type_cbmi, false );
729 customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
730 customizeCheckBoxMenuItem( _circular_type_cbmi, false );
731 _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
732 _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
733 initializeTypeMenu( getOptions() );
734 _jmenubar.add( _type_menu );
737 void buildViewMenu() {
738 _view_jmenu = MainFrame.createMenu( "View", getConfiguration() );
739 _view_jmenu.add( _display_basic_information_item = new JMenuItem( "Display Basic Information" ) );
740 _view_jmenu.addSeparator();
741 _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) );
742 _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) );
743 _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "View as Nexus" ) );
744 customizeJMenuItem( _display_basic_information_item );
745 customizeJMenuItem( _view_as_NH_item );
746 customizeJMenuItem( _view_as_XML_item );
747 customizeJMenuItem( _view_as_nexus_item );
748 _jmenubar.add( _view_jmenu );
751 void checkTextFrames() {
752 if ( _textframes.size() > 5 ) {
754 if ( _textframes.getFirst() != null ) {
755 _textframes.getFirst().removeMe();
758 _textframes.removeFirst();
761 catch ( final NoSuchElementException e ) {
767 void clearCurrentExternalNodesDataBuffer() {
768 getCurrentTreePanel().clearCurrentExternalNodesDataBuffer();
771 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
772 if ( item != null ) {
773 item.setFont( MainFrame.menu_font );
774 if ( !getConfiguration().isUseNativeUI() ) {
775 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
776 item.setForeground( getConfiguration().getGuiMenuTextColor() );
778 item.setSelected( is_selected );
779 item.addActionListener( this );
783 void customizeJMenuItem( final JMenuItem jmi ) {
784 jmi.setFont( MainFrame.menu_font );
785 if ( !getConfiguration().isUseNativeUI() ) {
786 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
787 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
789 jmi.addActionListener( this );
792 void displayBasicInformation() {
793 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
794 String title = "Basic Information";
795 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
796 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
798 showTextFrame( AptxUtil.createBasicInformation( getMainPanel().getCurrentPhylogeny() ), title );
802 Configuration getConfiguration() {
803 return _configuration;
806 TreePanel getCurrentTreePanel() {
807 return getMainPanel().getCurrentTreePanel();
810 JCheckBoxMenuItem getlabelDirectionCbmi() {
811 return _label_direction_cbmi;
814 Options getOtions() {
819 final StringBuilder sb = new StringBuilder();
820 sb.append( "Display options\n" );
821 sb.append( "-------------------\n" );
822 sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
823 sb.append( "Clickable tree nodes\n" );
824 sb.append( "--------------------\n" );
825 sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
826 sb.append( "or by right clicking:\n" );
827 sb.append( "o Display Node Data -- display information for a node\n" );
828 sb.append( "o Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
829 sb.append( "o Root/Reroot -- change tree root to clicked node\n" );
830 sb.append( "o Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
831 sb.append( "o Swap Descendants -- switch descendant on either side of clicked node\n" );
832 sb.append( "o Colorize Subtree -- color a subtree\n" );
833 sb.append( "o Open Sequence Web -- launch a web browser to display sequence information\n" );
834 sb.append( "o Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
835 sb.append( "- there may be additional choices depending on this particular setup\n\n" );
836 sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
837 sb.append( "Zooming\n" );
838 sb.append( "---------\n" );
839 sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
840 sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
841 sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
842 sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
843 sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
844 sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
845 sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
846 sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
847 sb.append( "Quick tree manipulation:\n" );
848 sb.append( "------------------------\n" );
849 sb.append( "Order Subtrees -- order the tree by branch length\n" );
850 sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
851 sb.append( "Memory problems (Java heap space error)\n" );
852 sb.append( "---------------------------------------\n" );
853 sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
854 sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
855 sb.append( "the '-Xmx' Java command line option. For example:\n" );
856 sb.append( "java -Xmx1024m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
857 sb.append( "phyloXML\n" );
858 sb.append( "-------------------\n" );
859 sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
860 sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
861 sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
863 sb.append( "For more information: http://www.phylosoft.org/archaeopteryx/\n" );
864 sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
865 TextFrame.instantiate( sb.toString(), "Help", _textframes );
868 void initializeTypeMenu( final Options options ) {
869 setTypeMenuToAllUnselected();
871 switch ( options.getPhylogenyGraphicsType() ) {
873 _convex_type_cbmi.setSelected( true );
876 _curved_type_cbmi.setSelected( true );
879 _euro_type_cbmi.setSelected( true );
882 _rounded_type_cbmi.setSelected( true );
885 _triangular_type_cbmi.setSelected( true );
888 _unrooted_type_cbmi.setSelected( true );
891 _circular_type_cbmi.setSelected( true );
894 _rectangular_type_cbmi.setSelected( true );
898 catch ( final NullPointerException np ) {
899 // In all likelihood, this is caused by menu-less display.
903 void removeAllTextFrames() {
904 for( final TextFrame tf : _textframes ) {
912 void setConfiguration( final Configuration configuration ) {
913 _configuration = configuration;
916 void setOptions( final Options options ) {
920 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
921 setTypeMenuToAllUnselected();
925 _circular_type_cbmi.setSelected( true );
928 _convex_type_cbmi.setSelected( true );
931 _curved_type_cbmi.setSelected( true );
934 _euro_type_cbmi.setSelected( true );
937 _rounded_type_cbmi.setSelected( true );
940 _rectangular_type_cbmi.setSelected( true );
943 _triangular_type_cbmi.setSelected( true );
946 _unrooted_type_cbmi.setSelected( true );
949 throw new IllegalArgumentException( "unknown type: " + type );
952 catch ( final NullPointerException np ) {
953 // In all likelihood, this is caused by menu-less display.
957 void setTypeMenuToAllUnselected() {
958 if ( _convex_type_cbmi != null ) {
959 _convex_type_cbmi.setSelected( false );
961 if ( _curved_type_cbmi != null ) {
962 _curved_type_cbmi.setSelected( false );
964 if ( _euro_type_cbmi != null ) {
965 _euro_type_cbmi.setSelected( false );
967 if ( _rounded_type_cbmi != null ) {
968 _rounded_type_cbmi.setSelected( false );
970 if ( _triangular_type_cbmi != null ) {
971 _triangular_type_cbmi.setSelected( false );
973 if ( _rectangular_type_cbmi != null ) {
974 _rectangular_type_cbmi.setSelected( false );
976 if ( _unrooted_type_cbmi != null ) {
977 _unrooted_type_cbmi.setSelected( false );
979 if ( _circular_type_cbmi != null ) {
980 _circular_type_cbmi.setSelected( false );
984 void switchColors() {
985 final TreeColorSet colorset = getMainPanel().getCurrentTreePanel().getTreeColorSet();
986 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
987 csc.setVisible( true );
988 getMainPanel().setTreeColorSet( colorset );
991 void typeChanged( final Object o ) {
992 updateTypeCheckboxes( getOptions(), o );
993 updateOptions( getOptions() );
994 if ( getCurrentTreePanel() != null ) {
995 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
996 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
997 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
998 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
999 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1000 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
1001 getCurrentTreePanel().getControlPanel().showWhole();
1003 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1004 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
1007 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
1009 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
1010 MainFrame.updateScreenTextAntialias( getMainPanel().getTreePanels() );
1014 void updateOptions( final Options options ) {
1015 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
1016 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
1017 && _background_gradient_cbmi.isSelected() );
1018 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
1019 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
1020 && _abbreviate_scientific_names.isSelected() );
1021 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
1022 && _color_labels_same_as_parent_branch.isSelected() );
1023 options.setShowDefaultNodeShapesInternal( ( _show_default_node_shapes_internal_cbmi != null )
1024 && _show_default_node_shapes_internal_cbmi.isSelected() );
1025 options.setShowDefaultNodeShapesExternal( ( _show_default_node_shapes_external_cbmi != null )
1026 && _show_default_node_shapes_external_cbmi.isSelected() );
1027 options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null )
1028 && _taxonomy_colorize_node_shapes_cbmi.isSelected() );
1029 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
1030 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
1032 else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
1033 options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1035 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
1036 options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1038 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
1039 && _search_case_senstive_cbmi.isSelected() );
1040 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
1041 options.setShowScale( _show_scale_cbmi.isSelected() );
1043 if ( _label_direction_cbmi != null ) {
1044 if ( _label_direction_cbmi.isSelected() ) {
1045 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1048 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1051 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
1052 options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )
1053 && _show_confidence_stddev_cbmi.isSelected() );
1054 if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
1055 options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
1057 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
1058 && _search_whole_words_only_cbmi.isSelected() );
1059 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
1060 && _inverse_search_result_cbmi.isSelected() );
1061 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
1062 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1064 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
1065 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1067 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
1068 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1070 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
1071 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1073 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
1074 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1076 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
1077 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1079 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
1080 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1082 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
1083 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1087 void updateTypeCheckboxes( final Options options, final Object o ) {
1088 setTypeMenuToAllUnselected();
1089 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
1092 void viewAsNexus() {
1093 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1094 String title = "Nexus";
1095 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1096 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1098 showTextFrame( getMainPanel().getCurrentPhylogeny().toNexus( getOptions()
1099 .getNhConversionSupportValueStyle() ),
1105 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1106 String title = "New Hampshire";
1107 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1108 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1110 showTextFrame( getMainPanel().getCurrentPhylogeny()
1111 .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ),
1117 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1118 String title = "phyloXML";
1119 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1120 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1122 showTextFrame( getMainPanel().getCurrentPhylogeny().toPhyloXML( 0 ), title );
1126 private void chooseFont() {
1127 final FontChooser fc = new FontChooser();
1128 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
1129 fc.showDialog( this, "Select the Base Font" );
1130 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
1133 private void chooseMinimalConfidence() {
1134 final String s = ( String ) JOptionPane
1135 .showInputDialog( this,
1136 "Please the minimum for confidence values to be displayed.\n" + "[current value: "
1137 + getOptions().getMinConfidenceValue() + "]\n",
1138 "Minimal Confidence Value",
1139 JOptionPane.QUESTION_MESSAGE,
1142 getOptions().getMinConfidenceValue() );
1143 if ( !ForesterUtil.isEmpty( s ) ) {
1144 boolean success = true;
1146 final String m_str = s.trim();
1147 if ( !ForesterUtil.isEmpty( m_str ) ) {
1149 m = Double.parseDouble( m_str );
1151 catch ( final Exception ex ) {
1158 if ( success && ( m >= 0.0 ) ) {
1159 getOptions().setMinConfidenceValue( m );
1164 private void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
1165 if ( item != null ) {
1166 item.setFont( MainFrame.menu_font );
1167 if ( !getConfiguration().isUseNativeUI() ) {
1168 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
1169 item.setForeground( getConfiguration().getGuiMenuTextColor() );
1171 item.setSelected( is_selected );
1172 item.addActionListener( this );
1176 private MainPanel getMainPanel() {
1180 private boolean isScreenAntialias() {
1184 private void removeBranchColors() {
1185 if ( getMainPanel().getCurrentPhylogeny() != null ) {
1186 AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
1190 private void setMainPanel( final MainPanelApplets main_panel ) {
1191 _main_panel = main_panel;
1194 private void setupUI() {
1196 if ( getConfiguration().isUseNativeUI() ) {
1197 UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
1200 UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
1203 catch ( final UnsupportedLookAndFeelException e ) {
1204 AptxUtil.dieWithSystemError( "UnsupportedLookAndFeelException: " + e.toString() );
1206 catch ( final ClassNotFoundException e ) {
1207 AptxUtil.dieWithSystemError( "ClassNotFoundException: " + e.toString() );
1209 catch ( final InstantiationException e ) {
1210 AptxUtil.dieWithSystemError( "InstantiationException: " + e.toString() );
1212 catch ( final IllegalAccessException e ) {
1213 AptxUtil.dieWithSystemError( "IllegalAccessException: " + e.toString() );
1215 catch ( final Exception e ) {
1216 AptxUtil.dieWithSystemError( e.toString() );
1220 static void setupScreenTextAntialias( final List<TreePanel> treepanels, final boolean antialias ) {
1221 for( final TreePanel tree_panel : treepanels ) {
1222 tree_panel.setTextAntialias();