2 package org.forester.archaeopteryx;
4 import java.awt.BorderLayout;
5 import java.awt.Container;
6 import java.awt.event.ActionEvent;
7 import java.awt.event.ActionListener;
8 import java.awt.event.ComponentAdapter;
9 import java.awt.event.ComponentEvent;
10 import java.io.ByteArrayOutputStream;
12 import java.io.IOException;
14 import java.util.LinkedList;
15 import java.util.List;
17 import java.util.NoSuchElementException;
19 import javax.swing.ButtonGroup;
20 import javax.swing.JApplet;
21 import javax.swing.JCheckBoxMenuItem;
22 import javax.swing.JMenu;
23 import javax.swing.JMenuBar;
24 import javax.swing.JMenuItem;
25 import javax.swing.JOptionPane;
26 import javax.swing.JRadioButtonMenuItem;
27 import javax.swing.UIManager;
28 import javax.swing.UnsupportedLookAndFeelException;
29 import javax.swing.event.ChangeEvent;
30 import javax.swing.event.ChangeListener;
32 import org.apache.commons.codec.binary.Base64;
33 import org.forester.archaeopteryx.AptxUtil.GraphicsExportType;
34 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
35 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
36 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
37 import org.forester.phylogeny.Phylogeny;
38 import org.forester.phylogeny.data.SequenceRelation;
39 import org.forester.util.ForesterConstants;
40 import org.forester.util.ForesterUtil;
43 // <applet archive="forester.jar"
44 // code="org.forester.archaeopteryx.ArchaeopteryxE.class"
45 // codebase="http://www.myserver.org/path/to/forester"
48 // alt="ArchaeopteryxE is not working on your system (requires at least Sun Java 1.5)!">
49 // <param name="url_of_tree_to_load"
50 // value="http://www.myserver.org/examples/data/apaf.xml">
51 // <param name="config_file"
52 // value="http://www.myserver.org/examples/config/config_file.txt">
54 public class ArchaeopteryxE extends JApplet implements ActionListener {
56 private final static String NAME = "ArchaeopteryxE";
57 private static final long serialVersionUID = -1220055577935759443L;
58 private Configuration _configuration;
59 private MainPanelApplets _main_panel;
60 private JMenuBar _jmenubar;
61 private JMenu _options_jmenu;
62 private JMenu _font_size_menu;
63 private JMenuItem _super_tiny_fonts_mi;
64 private JMenuItem _tiny_fonts_mi;
65 private JMenuItem _small_fonts_mi;
66 private JMenuItem _medium_fonts_mi;
67 private JMenuItem _large_fonts_mi;
68 private JMenu _tools_menu;
69 private JMenuItem _taxcolor_item;
70 private JMenuItem _confcolor_item;
71 private JMenuItem _midpoint_root_item;
72 private JMenu _view_jmenu;
73 private JMenuItem _view_as_XML_item;
74 private JMenuItem _view_as_NH_item;
75 private JMenuItem _view_as_NHX_item;
76 private JMenuItem _view_as_nexus_item;
77 private JMenuItem _display_basic_information_item;
78 private JMenu _type_menu;
79 private JCheckBoxMenuItem _rectangular_type_cbmi;
80 private JCheckBoxMenuItem _triangular_type_cbmi;
81 private JCheckBoxMenuItem _curved_type_cbmi;
82 private JCheckBoxMenuItem _convex_type_cbmi;
83 private JCheckBoxMenuItem _euro_type_cbmi;
84 private JCheckBoxMenuItem _rounded_type_cbmi;
85 private JCheckBoxMenuItem _unrooted_type_cbmi;
86 private JCheckBoxMenuItem _circular_type_cbmi;
87 private JMenuItem _help_item;
88 private JMenuItem _about_item;
89 private JMenu _help_jmenu;
90 private JMenuItem _website_item;
91 private JMenuItem _phyloxml_website_item;
92 private JMenuItem _phyloxml_ref_item;
93 private JMenuItem _aptx_ref_item;
94 private JMenuItem _remove_branch_color_item;
95 private JMenuItem _infer_common_sn_names_item;
96 private JCheckBoxMenuItem _show_domain_labels;
97 private JCheckBoxMenuItem _color_labels_same_as_parent_branch;
98 private JCheckBoxMenuItem _abbreviate_scientific_names;
99 private JCheckBoxMenuItem _screen_antialias_cbmi;
100 private JCheckBoxMenuItem _background_gradient_cbmi;
101 private JRadioButtonMenuItem _non_lined_up_cladograms_rbmi;
102 private JRadioButtonMenuItem _uniform_cladograms_rbmi;
103 private JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi;
104 private Options _options;
105 private JMenuItem _choose_font_mi;
106 private JMenuItem _switch_colors_mi;
107 JCheckBoxMenuItem _label_direction_cbmi;
108 private JCheckBoxMenuItem _show_scale_cbmi;
109 private JCheckBoxMenuItem _search_case_senstive_cbmi;
110 private JCheckBoxMenuItem _search_whole_words_only_cbmi;
111 private JCheckBoxMenuItem _inverse_search_result_cbmi;
112 private JCheckBoxMenuItem _show_overview_cbmi;
113 private JMenuItem _choose_minimal_confidence_mi;
114 private JCheckBoxMenuItem _show_branch_length_values_cbmi;
115 private JMenuItem _collapse_species_specific_subtrees;
116 private JMenuItem _overview_placment_mi;
117 private ButtonGroup _radio_group_1;
118 private JCheckBoxMenuItem _show_default_node_shapes_cbmi;
119 private JMenuItem _cycle_node_shape_mi;
120 private JMenuItem _cycle_node_fill_mi;
121 private JMenuItem _choose_node_size_mi;
122 private JCheckBoxMenuItem _taxonomy_colorize_node_shapes_cbmi;
123 private JCheckBoxMenuItem _show_confidence_stddev_cbmi;
124 private final LinkedList<TextFrame> _textframes = new LinkedList<TextFrame>();
125 private String _ext_node_data_buffer = "";
126 private int _ext_node_data_buffer_change_counter = 0;
129 public void actionPerformed( final ActionEvent e ) {
130 final Object o = e.getSource();
131 if ( o == _midpoint_root_item ) {
132 getMainPanel().getCurrentTreePanel().midpointRoot();
134 else if ( o == _taxcolor_item ) {
135 getMainPanel().getCurrentTreePanel().taxColor();
137 else if ( o == _confcolor_item ) {
138 getMainPanel().getCurrentTreePanel().confColor();
140 else if ( o == _collapse_species_specific_subtrees ) {
141 if ( getCurrentTreePanel() != null ) {
142 getCurrentTreePanel().collapseSpeciesSpecificSubtrees();
145 else if ( o == _remove_branch_color_item ) {
146 removeBranchColors();
148 else if ( o == _switch_colors_mi ) {
151 else if ( o == _display_basic_information_item ) {
152 displayBasicInformation();
154 else if ( o == _view_as_NH_item ) {
157 else if ( o == _view_as_NHX_item ) {
160 else if ( o == _view_as_XML_item ) {
163 else if ( o == _view_as_nexus_item ) {
166 else if ( o == _super_tiny_fonts_mi ) {
167 if ( getCurrentTreePanel() != null ) {
168 getCurrentTreePanel().setSuperTinyFonts();
169 getCurrentTreePanel().repaint();
172 else if ( o == _tiny_fonts_mi ) {
173 if ( getCurrentTreePanel() != null ) {
174 getCurrentTreePanel().setTinyFonts();
175 getCurrentTreePanel().repaint();
178 else if ( o == _small_fonts_mi ) {
179 if ( getCurrentTreePanel() != null ) {
180 getCurrentTreePanel().setSmallFonts();
181 getCurrentTreePanel().repaint();
184 else if ( o == _medium_fonts_mi ) {
185 if ( getCurrentTreePanel() != null ) {
186 getCurrentTreePanel().setMediumFonts();
187 getCurrentTreePanel().repaint();
190 else if ( o == _large_fonts_mi ) {
191 if ( getCurrentTreePanel() != null ) {
192 getCurrentTreePanel().setLargeFonts();
193 getCurrentTreePanel().repaint();
196 else if ( o == _choose_font_mi ) {
199 else if ( o == _choose_minimal_confidence_mi ) {
200 chooseMinimalConfidence();
202 else if ( o == _choose_node_size_mi ) {
203 MainFrame.chooseNodeSize( getOptions(), this );
205 else if ( o == _overview_placment_mi ) {
206 MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
208 else if ( o == _cycle_node_fill_mi ) {
209 MainFrame.cycleNodeFill( getOptions(), getCurrentTreePanel() );
211 else if ( o == _cycle_node_shape_mi ) {
212 MainFrame.cycleNodeShape( getOptions(), getCurrentTreePanel() );
214 else if ( o == _non_lined_up_cladograms_rbmi ) {
215 updateOptions( getOptions() );
216 _main_panel.getControlPanel().showWhole();
218 else if ( o == _uniform_cladograms_rbmi ) {
219 updateOptions( getOptions() );
220 _main_panel.getControlPanel().showWhole();
222 else if ( o == _ext_node_dependent_cladogram_rbmi ) {
223 updateOptions( getOptions() );
224 _main_panel.getControlPanel().showWhole();
226 else if ( o == _search_case_senstive_cbmi ) {
227 updateOptions( getOptions() );
228 getMainPanel().getControlPanel().search();
230 else if ( o == _search_whole_words_only_cbmi ) {
231 updateOptions( getOptions() );
232 getMainPanel().getControlPanel().search();
234 else if ( o == _inverse_search_result_cbmi ) {
235 updateOptions( getOptions() );
236 getMainPanel().getControlPanel().search();
238 else if ( o == _show_scale_cbmi ) {
239 updateOptions( getOptions() );
241 else if ( o == _show_branch_length_values_cbmi ) {
242 updateOptions( getOptions() );
244 else if ( o == _show_confidence_stddev_cbmi ) {
245 updateOptions( getOptions() );
247 else if ( o == _label_direction_cbmi ) {
248 updateOptions( getOptions() );
250 else if ( o == _show_overview_cbmi ) {
251 updateOptions( getOptions() );
252 if ( getCurrentTreePanel() != null ) {
253 getCurrentTreePanel().updateOvSizes();
256 else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
257 || ( o == _convex_type_cbmi ) || ( o == _rounded_type_cbmi ) || ( o == _euro_type_cbmi )
258 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
261 else if ( o == _screen_antialias_cbmi ) {
262 updateOptions( getOptions() );
263 setupScreenTextAntialias( getMainPanel().getTreePanels(), isScreenAntialias() );
265 else if ( o == _background_gradient_cbmi ) {
266 updateOptions( getOptions() );
268 else if ( o == _show_domain_labels ) {
269 updateOptions( getOptions() );
271 else if ( o == _color_labels_same_as_parent_branch ) {
272 updateOptions( getOptions() );
274 else if ( o == _show_default_node_shapes_cbmi ) {
275 updateOptions( getOptions() );
277 else if ( o == _taxonomy_colorize_node_shapes_cbmi ) {
278 updateOptions( getOptions() );
280 else if ( o == _about_item ) {
283 else if ( o == _help_item ) {
284 help( getConfiguration().getWebLinks() );
286 else if ( o == _website_item ) {
288 AptxUtil.openWebsite( Constants.APTX_WEB_SITE, true, this );
290 catch ( final IOException e1 ) {
291 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
294 else if ( o == _phyloxml_website_item ) {
296 AptxUtil.openWebsite( Constants.PHYLOXML_WEB_SITE, true, this );
298 catch ( final IOException e1 ) {
299 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
302 else if ( o == _aptx_ref_item ) {
304 AptxUtil.openWebsite( Constants.APTX_REFERENCE_URL, true, this );
306 catch ( final IOException e1 ) {
307 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
310 else if ( o == _phyloxml_ref_item ) {
312 AptxUtil.openWebsite( Constants.PHYLOXML_REFERENCE_URL, true, this );
314 catch ( final IOException e1 ) {
315 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
322 public void destroy() {
323 AptxUtil.printAppletMessage( NAME, "going to be destroyed " );
324 removeAllTextFrames();
325 if ( getMainPanel() != null ) {
326 getMainPanel().terminate();
331 * This method returns the current external node data which
332 * has been selected by the user by clicking the "Return ..."
333 * menu item. This method is expected to be called from Javascript or
336 * @return current external node data as String
338 public String getCurrentExternalNodesDataBuffer() {
339 return _ext_node_data_buffer;
343 * This method returns the current phylogeny as a string in the chosen format
345 * @param format must be NH, NHX, NEXUS or PHYLOXML
346 * @return the phylogeny string
347 * @author Herve Menager
349 public String getCurrentPhylogeny( final String format ) {
350 removeAllTextFrames();
351 if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty()
352 || ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
355 switch ( ForesterConstants.PhylogeneticTreeFormats.valueOf( format ) ) {
357 return getMainPanel().getCurrentPhylogeny().toNewHampshire();
359 return getMainPanel().getCurrentPhylogeny().toNewHampshireX();
361 return getMainPanel().getCurrentPhylogeny().toNexus();
363 return getMainPanel().getCurrentPhylogeny().toPhyloXML( -1 );
371 * This method returns a view of the current phylogeny in a chosen
372 * graphics format, base64-encoded in a string so that in can be used
375 * @param format must be GraphicsExportType (gif, jpg, pdf, png, tif, bmp)
376 * @return the phylogeny string
377 * @author Herve Menager
379 public String getCurrentPhylogenyGraphicsAsBase64EncodedString( final String format ) {
380 final ByteArrayOutputStream baos = new ByteArrayOutputStream();
382 AptxUtil.writePhylogenyToGraphicsByteArrayOutputStream( baos,
383 _main_panel.getWidth(),
384 _main_panel.getHeight(),
385 getCurrentTreePanel(),
386 getCurrentTreePanel().getControlPanel(),
387 GraphicsExportType.valueOf( format ),
390 catch ( final IOException ioe ) {
391 ForesterUtil.printErrorMessage( NAME, ioe.toString() );
392 ioe.printStackTrace();
393 JOptionPane.showMessageDialog( this,
394 NAME + ": Failed to generate graphics: " + "\nException: " + ioe,
395 "Failed to generate graphics",
396 JOptionPane.ERROR_MESSAGE );
399 final byte[] bytes = baos.toByteArray();
400 final String dataImg = Base64.encodeBase64String( bytes );
404 public int getExtNodeDataBufferChangeCounter() {
405 return _ext_node_data_buffer_change_counter;
408 public Options getOptions() {
412 public void increaseExtNodeDataBufferChangeCounter() {
413 _ext_node_data_buffer_change_counter++;
418 final String config_filename = getParameter( Constants.APPLET_PARAM_NAME_FOR_CONFIG_FILE_URL );
419 AptxUtil.printAppletMessage( NAME, "URL for configuration file is: " + config_filename );
420 final Configuration configuration = new Configuration( config_filename, true, true, true );
421 setConfiguration( configuration );
422 setOptions( Options.createInstance( configuration ) );
425 Phylogeny[] phys = null;
426 final String phys_url_string = getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD );
427 AptxUtil.printAppletMessage( NAME, "URL for phylogenies is " + phys_url_string );
428 // Get URL to tree file
429 if ( phys_url_string != null ) {
431 phys_url = new URL( phys_url_string );
433 catch ( final Exception e ) {
434 ForesterUtil.printErrorMessage( NAME, "error: " + e );
436 JOptionPane.showMessageDialog( this, NAME + ": Could not create URL from: \"" + phys_url_string
437 + "\"\nException: " + e, "Failed to create URL", JOptionPane.ERROR_MESSAGE );
440 // Load the tree from URL
441 if ( phys_url != null ) {
443 phys = AptxUtil.readPhylogeniesFromUrl( phys_url,
444 getConfiguration().isValidatePhyloXmlAgainstSchema(),
445 getConfiguration().isReplaceUnderscoresInNhParsing(),
446 getConfiguration().isInternalNumberAreConfidenceForNhParsing(),
447 getConfiguration().getTaxonomyExtraction() );
449 catch ( final Exception e ) {
450 ForesterUtil.printErrorMessage( NAME, e.toString() );
452 JOptionPane.showMessageDialog( this,
453 NAME + ": Failed to read phylogenies: " + "\nException: " + e,
454 "Failed to read phylogenies",
455 JOptionPane.ERROR_MESSAGE );
458 if ( ( phys == null ) || ( phys.length < 1 ) ) {
459 ForesterUtil.printErrorMessage( NAME, "phylogenies from [" + phys_url + "] are null or empty" );
460 JOptionPane.showMessageDialog( this,
461 NAME + ": phylogenies from [" + phys_url + "] are null or empty",
462 "Failed to read phylogenies",
463 JOptionPane.ERROR_MESSAGE );
467 AptxUtil.printAppletMessage( NAME, "loaded " + phys.length + " phylogenies from: " + phys_url );
470 setMainPanel( new MainPanelApplets( getConfiguration(), this ) );
471 _jmenubar = new JMenuBar();
472 if ( !getConfiguration().isHideControlPanelAndMenubar() ) {
473 if ( !getConfiguration().isUseNativeUI() ) {
474 _jmenubar.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
482 setJMenuBar( _jmenubar );
484 final Container contentpane = getContentPane();
485 contentpane.setLayout( new BorderLayout() );
486 contentpane.add( getMainPanel(), BorderLayout.CENTER );
487 addComponentListener( new ComponentAdapter() {
490 public void componentResized( final ComponentEvent e ) {
491 if ( getMainPanel().getCurrentTreePanel() != null ) {
492 getMainPanel().getCurrentTreePanel().setParametersForPainting( getMainPanel().getCurrentTreePanel()
494 getMainPanel().getCurrentTreePanel()
500 if ( getConfiguration().isUseTabbedDisplay() ) {
501 AptxUtil.printAppletMessage( NAME, "using tabbed display" );
502 AptxUtil.addPhylogeniesToTabs( phys,
503 new File( phys_url.getFile() ).getName(),
509 AptxUtil.printAppletMessage( NAME, "not using tabbed display" );
510 AptxUtil.addPhylogenyToPanel( phys, getConfiguration(), getMainPanel() );
514 getMainPanel().getControlPanel().showWholeAll();
515 getMainPanel().getControlPanel().showWhole();
517 AptxUtil.printAppletMessage( NAME, "successfully initialized" );
519 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().removeAllItems();
520 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
521 .getRelevantSequenceRelationTypes() ) {
522 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().addItem( type );
524 final String default_relation = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_SEQUENCE_RELATION_TYPE );
525 if ( default_relation != null ) {
526 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().setSelectedItem( default_relation );
528 final String default_sequence = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_QUERY_SEQUENCE );
529 if ( default_sequence != null ) {
530 getCurrentTreePanel().getControlPanel().getSequenceRelationBox().setSelectedItem( default_sequence );
536 public void showTextFrame( final String s, final String title ) {
538 _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
542 public void start() {
543 if ( getMainPanel() != null ) {
544 getMainPanel().validate();
547 requestFocusInWindow();
549 AptxUtil.printAppletMessage( NAME, "started" );
552 void buildFontSizeMenu() {
553 _font_size_menu = MainFrame.createMenu( MainFrame.FONT_SIZE_MENU_LABEL, getConfiguration() );
554 _font_size_menu.add( _super_tiny_fonts_mi = new JMenuItem( "Super tiny fonts" ) );
555 _font_size_menu.add( _tiny_fonts_mi = new JMenuItem( "Tiny fonts" ) );
556 _font_size_menu.add( _small_fonts_mi = new JMenuItem( "Small fonts" ) );
557 _font_size_menu.add( _medium_fonts_mi = new JMenuItem( "Medium fonts" ) );
558 _font_size_menu.add( _large_fonts_mi = new JMenuItem( "Large fonts" ) );
559 customizeJMenuItem( _super_tiny_fonts_mi );
560 customizeJMenuItem( _tiny_fonts_mi );
561 customizeJMenuItem( _small_fonts_mi );
562 customizeJMenuItem( _medium_fonts_mi );
563 customizeJMenuItem( _large_fonts_mi );
564 _jmenubar.add( _font_size_menu );
567 void buildHelpMenu() {
568 _help_jmenu = MainFrame.createMenu( "Help", getConfiguration() );
569 _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
570 _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
571 _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
572 _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
573 _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
574 _help_jmenu.addSeparator();
575 _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
576 customizeJMenuItem( _help_item );
577 customizeJMenuItem( _website_item );
578 customizeJMenuItem( _phyloxml_website_item );
579 customizeJMenuItem( _aptx_ref_item );
580 customizeJMenuItem( _phyloxml_ref_item );
581 customizeJMenuItem( _about_item );
582 _phyloxml_ref_item.setToolTipText( MainFrame.PHYLOXML_REF_TOOL_TIP );
583 _aptx_ref_item.setToolTipText( MainFrame.APTX_REF_TOOL_TIP );
584 _jmenubar.add( _help_jmenu );
587 void buildOptionsMenu() {
588 _options_jmenu = MainFrame.createMenu( MainFrame.OPTIONS_HEADER, getConfiguration() );
589 _options_jmenu.addChangeListener( new ChangeListener() {
592 public void stateChanged( final ChangeEvent e ) {
593 MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getOptions() );
594 MainFrame.setTextColorChooseMenuItem( _switch_colors_mi, getCurrentTreePanel() );
596 .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() );
597 MainFrame.setTextForFontChooserMenuItem( _choose_font_mi, MainFrame
598 .createCurrentFontDesc( getMainPanel().getTreeFontSet() ) );
599 MainFrame.updateOptionsMenuDependingOnPhylogenyType( getMainPanel(),
601 _show_branch_length_values_cbmi,
602 _non_lined_up_cladograms_rbmi,
603 _uniform_cladograms_rbmi,
604 _ext_node_dependent_cladogram_rbmi,
605 _label_direction_cbmi );
606 MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() );
607 MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() );
608 MainFrame.setTextNodeSizeMenuItem( _choose_node_size_mi, getOptions() );
611 _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.DISPLAY_SUBHEADER ),
612 getConfiguration() ) );
614 .add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );
615 _options_jmenu.add( _uniform_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.UNIFORM_CLADOGRAMS_LABEL ) );
617 .add( _non_lined_up_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.NON_LINED_UP_CLADOGRAMS_LABEL ) );
618 _radio_group_1 = new ButtonGroup();
619 _radio_group_1.add( _ext_node_dependent_cladogram_rbmi );
620 _radio_group_1.add( _uniform_cladograms_rbmi );
621 _radio_group_1.add( _non_lined_up_cladograms_rbmi );
622 _options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_OVERVIEW_LABEL ) );
623 _options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_SCALE_LABEL ) );
625 .add( _show_branch_length_values_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_BRANCH_LENGTH_VALUES_LABEL ) );
626 _options_jmenu.add( _show_confidence_stddev_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_CONF_STDDEV_LABEL ) );
628 .add( _show_default_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL ) );
630 .add( _taxonomy_colorize_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.TAXONOMY_COLORIZE_NODE_SHAPES_LABEL ) );
631 _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL ) );
632 _options_jmenu.add( _cycle_node_fill_mi = new JMenuItem( MainFrame.CYCLE_NODE_FILL_LABEL ) );
633 _options_jmenu.add( _choose_node_size_mi = new JMenuItem( MainFrame.CHOOSE_NODE_SIZE_LABEL ) );
634 _options_jmenu.add( _label_direction_cbmi = new JCheckBoxMenuItem( MainFrame.LABEL_DIRECTION_LABEL ) );
636 .add( _color_labels_same_as_parent_branch = new JCheckBoxMenuItem( MainFrame.COLOR_LABELS_LABEL ) );
637 _color_labels_same_as_parent_branch.setToolTipText( MainFrame.COLOR_LABELS_TIP );
638 _options_jmenu.add( _abbreviate_scientific_names = new JCheckBoxMenuItem( MainFrame.ABBREV_SN_LABEL ) );
639 _label_direction_cbmi.setToolTipText( MainFrame.LABEL_DIRECTION_TIP );
640 _options_jmenu.add( _screen_antialias_cbmi = new JCheckBoxMenuItem( MainFrame.SCREEN_ANTIALIAS_LABEL ) );
641 _options_jmenu.add( _background_gradient_cbmi = new JCheckBoxMenuItem( MainFrame.BG_GRAD_LABEL ) );
642 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
643 _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( MainFrame.SHOW_DOMAIN_LABELS_LABEL ) );
645 _options_jmenu.add( _choose_minimal_confidence_mi = new JMenuItem( "" ) );
646 _options_jmenu.add( _overview_placment_mi = new JMenuItem( "" ) );
647 _options_jmenu.add( _switch_colors_mi = new JMenuItem( "" ) );
648 _options_jmenu.add( _choose_font_mi = new JMenuItem( "" ) );
649 _options_jmenu.addSeparator();
650 _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.SEARCH_SUBHEADER ),
651 getConfiguration() ) );
653 .add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_CASE_SENSITIVE_LABEL ) );
654 _options_jmenu.add( _search_whole_words_only_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_TERMS_ONLY_LABEL ) );
656 .add( _inverse_search_result_cbmi = new JCheckBoxMenuItem( MainFrame.INVERSE_SEARCH_RESULT_LABEL ) );
657 customizeJMenuItem( _choose_font_mi );
658 customizeJMenuItem( _choose_minimal_confidence_mi );
659 customizeJMenuItem( _switch_colors_mi );
660 customizeJMenuItem( _overview_placment_mi );
661 customizeCheckBoxMenuItem( _label_direction_cbmi,
662 getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL );
663 customizeCheckBoxMenuItem( _screen_antialias_cbmi, getOptions().isAntialiasScreen() );
664 customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );
665 customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );
666 customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );
667 customizeCheckBoxMenuItem( _show_default_node_shapes_cbmi, getOptions().isShowDefaultNodeShapes() );
668 customizeCheckBoxMenuItem( _taxonomy_colorize_node_shapes_cbmi, getOptions().isTaxonomyColorizeNodeShapes() );
669 customizeJMenuItem( _cycle_node_shape_mi );
670 customizeJMenuItem( _cycle_node_fill_mi );
671 customizeJMenuItem( _choose_node_size_mi );
672 customizeCheckBoxMenuItem( _color_labels_same_as_parent_branch, getOptions().isColorLabelsSameAsParentBranch() );
673 customizeCheckBoxMenuItem( _search_case_senstive_cbmi, getOptions().isSearchCaseSensitive() );
674 customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );
675 customizeRadioButtonMenuItem( _non_lined_up_cladograms_rbmi,
676 getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP );
677 customizeRadioButtonMenuItem( _uniform_cladograms_rbmi,
678 getOptions().getCladogramType() == CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
679 customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi,
680 getOptions().getCladogramType() == CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
681 customizeCheckBoxMenuItem( _show_branch_length_values_cbmi, getOptions().isShowBranchLengthValues() );
682 customizeCheckBoxMenuItem( _show_overview_cbmi, getOptions().isShowOverview() );
683 customizeCheckBoxMenuItem( _search_whole_words_only_cbmi, getOptions().isMatchWholeTermsOnly() );
684 customizeCheckBoxMenuItem( _inverse_search_result_cbmi, getOptions().isInverseSearchResult() );
685 customizeCheckBoxMenuItem( _show_confidence_stddev_cbmi, getOptions().isShowConfidenceStddev() );
686 _jmenubar.add( _options_jmenu );
689 void buildToolsMenu() {
690 _tools_menu = MainFrame.createMenu( "Tools", getConfiguration() );
691 _tools_menu.add( _confcolor_item = new JMenuItem( "Colorize Branches Depending on Confidence" ) );
692 customizeJMenuItem( _confcolor_item );
693 _tools_menu.add( _taxcolor_item = new JMenuItem( "Taxonomy Colorize Branches" ) );
694 customizeJMenuItem( _taxcolor_item );
695 _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete Branch Colors" ) );
696 _remove_branch_color_item.setToolTipText( "To delete branch color values from the current phylogeny." );
697 customizeJMenuItem( _remove_branch_color_item );
698 _tools_menu.addSeparator();
699 _tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) );
700 customizeJMenuItem( _midpoint_root_item );
701 _tools_menu.addSeparator();
703 .add( _infer_common_sn_names_item = new JMenuItem( "Infer Common Parts of Internal Scientific Names" ) );
704 customizeJMenuItem( _infer_common_sn_names_item );
705 _tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Species-Specific Subtrees" ) );
706 customizeJMenuItem( _collapse_species_specific_subtrees );
707 _jmenubar.add( _tools_menu );
710 void buildTypeMenu() {
711 _type_menu = MainFrame.createMenu( MainFrame.TYPE_MENU_HEADER, getConfiguration() );
712 _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
713 _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
714 _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
715 _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
716 _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
717 _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
718 _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
719 _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
720 customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
721 customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
722 customizeCheckBoxMenuItem( _euro_type_cbmi, false );
723 customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
724 customizeCheckBoxMenuItem( _curved_type_cbmi, false );
725 customizeCheckBoxMenuItem( _convex_type_cbmi, false );
726 customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
727 customizeCheckBoxMenuItem( _circular_type_cbmi, false );
728 _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
729 _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
730 initializeTypeMenu( getOptions() );
731 _jmenubar.add( _type_menu );
734 void buildViewMenu() {
735 _view_jmenu = MainFrame.createMenu( "View", getConfiguration() );
736 _view_jmenu.add( _display_basic_information_item = new JMenuItem( "Display Basic Information" ) );
737 _view_jmenu.addSeparator();
738 _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) );
739 _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) );
740 _view_jmenu.add( _view_as_NHX_item = new JMenuItem( "View as NHX" ) );
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_NHX_item );
745 customizeJMenuItem( _view_as_XML_item );
746 customizeJMenuItem( _view_as_nexus_item );
747 _jmenubar.add( _view_jmenu );
750 void checkTextFrames() {
751 if ( _textframes.size() > 5 ) {
753 if ( _textframes.getFirst() != null ) {
754 _textframes.getFirst().removeMe();
757 _textframes.removeFirst();
760 catch ( final NoSuchElementException e ) {
766 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
767 if ( item != null ) {
768 item.setFont( MainFrame.menu_font );
769 if ( !getConfiguration().isUseNativeUI() ) {
770 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
771 item.setForeground( getConfiguration().getGuiMenuTextColor() );
773 item.setSelected( is_selected );
774 item.addActionListener( this );
778 void customizeJMenuItem( final JMenuItem jmi ) {
779 jmi.setFont( MainFrame.menu_font );
780 if ( !getConfiguration().isUseNativeUI() ) {
781 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
782 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
784 jmi.addActionListener( this );
787 void displayBasicInformation() {
788 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
789 String title = "Basic Information";
790 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
791 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
793 showTextFrame( AptxUtil.createBasicInformation( getMainPanel().getCurrentPhylogeny() ), title );
797 Configuration getConfiguration() {
798 return _configuration;
801 TreePanel getCurrentTreePanel() {
802 return getMainPanel().getCurrentTreePanel();
805 JCheckBoxMenuItem getlabelDirectionCbmi() {
806 return _label_direction_cbmi;
809 Options getOtions() {
813 void help( final Map<String, WebLink> weblinks ) {
814 final StringBuilder sb = new StringBuilder();
815 sb.append( "Display options\n" );
816 sb.append( "-------------------\n" );
817 sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
818 sb.append( "Clickable tree nodes\n" );
819 sb.append( "--------------------\n" );
820 sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
821 sb.append( "or by right clicking:\n" );
822 sb.append( "o Display Node Data -- display information for a node\n" );
823 sb.append( "o Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
824 sb.append( "o Root/Reroot -- change tree root to clicked node\n" );
825 sb.append( "o Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
826 sb.append( "o Swap Descendants -- switch descendant on either side of clicked node\n" );
827 sb.append( "o Colorize Subtree -- color a subtree\n" );
828 sb.append( "o Open Sequence Web -- launch a web browser to display sequence information\n" );
829 sb.append( "o Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
830 sb.append( "- there may be additional choices depending on this particular setup\n\n" );
831 sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
832 sb.append( "Zooming\n" );
833 sb.append( "---------\n" );
834 sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
835 sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
836 sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
837 sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
838 sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
839 sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
840 sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
841 sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
842 sb.append( "Quick tree manipulation:\n" );
843 sb.append( "------------------------\n" );
844 sb.append( "Order Subtrees -- order the tree by branch length\n" );
845 sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
846 sb.append( "Memory problems (Java heap space error)\n" );
847 sb.append( "---------------------------------------\n" );
848 sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
849 sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
850 sb.append( "the '-Xmx' Java command line option. For example:\n" );
851 sb.append( "java -Xms32m -Xmx256m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
852 if ( ( weblinks != null ) && ( weblinks.size() > 0 ) ) {
853 sb.append( "Active web links\n" );
854 sb.append( "--------------------\n" );
855 for( final String key : weblinks.keySet() ) {
856 sb.append( " " + weblinks.get( key ).toString() + "\n" );
860 sb.append( "phyloXML\n" );
861 sb.append( "-------------------\n" );
862 sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
863 sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
864 sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
866 sb.append( "For more information: http://www.phylosoft.org/archaeopteryx/\n" );
867 sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
868 TextFrame.instantiate( sb.toString(), "Help", _textframes );
871 void initializeTypeMenu( final Options options ) {
872 setTypeMenuToAllUnselected();
874 switch ( options.getPhylogenyGraphicsType() ) {
876 _convex_type_cbmi.setSelected( true );
879 _curved_type_cbmi.setSelected( true );
882 _euro_type_cbmi.setSelected( true );
885 _rounded_type_cbmi.setSelected( true );
888 _triangular_type_cbmi.setSelected( true );
891 _unrooted_type_cbmi.setSelected( true );
894 _circular_type_cbmi.setSelected( true );
897 _rectangular_type_cbmi.setSelected( true );
901 catch ( final NullPointerException np ) {
902 // In all likelihood, this is caused by menu-less display.
906 void removeAllTextFrames() {
907 for( final TextFrame tf : _textframes ) {
915 void setConfiguration( final Configuration configuration ) {
916 _configuration = configuration;
919 void setCurrentExternalNodesDataBuffer( final String s ) {
920 increaseExtNodeDataBufferChangeCounter();
921 if ( !ForesterUtil.isEmpty( s ) ) {
922 _ext_node_data_buffer = s.trim();
925 _ext_node_data_buffer = "";
929 void setOptions( final Options options ) {
933 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
934 setTypeMenuToAllUnselected();
938 _circular_type_cbmi.setSelected( true );
941 _convex_type_cbmi.setSelected( true );
944 _curved_type_cbmi.setSelected( true );
947 _euro_type_cbmi.setSelected( true );
950 _rounded_type_cbmi.setSelected( true );
953 _rectangular_type_cbmi.setSelected( true );
956 _triangular_type_cbmi.setSelected( true );
959 _unrooted_type_cbmi.setSelected( true );
962 throw new IllegalArgumentException( "unknown type: " + type );
965 catch ( final NullPointerException np ) {
966 // In all likelihood, this is caused by menu-less display.
970 void setTypeMenuToAllUnselected() {
971 if ( _convex_type_cbmi != null ) {
972 _convex_type_cbmi.setSelected( false );
974 if ( _curved_type_cbmi != null ) {
975 _curved_type_cbmi.setSelected( false );
977 if ( _euro_type_cbmi != null ) {
978 _euro_type_cbmi.setSelected( false );
980 if ( _rounded_type_cbmi != null ) {
981 _rounded_type_cbmi.setSelected( false );
983 if ( _triangular_type_cbmi != null ) {
984 _triangular_type_cbmi.setSelected( false );
986 if ( _rectangular_type_cbmi != null ) {
987 _rectangular_type_cbmi.setSelected( false );
989 if ( _unrooted_type_cbmi != null ) {
990 _unrooted_type_cbmi.setSelected( false );
992 if ( _circular_type_cbmi != null ) {
993 _circular_type_cbmi.setSelected( false );
997 void switchColors() {
998 final TreeColorSet colorset = getMainPanel().getCurrentTreePanel().getTreeColorSet();
999 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
1000 csc.setVisible( true );
1001 getMainPanel().setTreeColorSet( colorset );
1004 void typeChanged( final Object o ) {
1005 updateTypeCheckboxes( getOptions(), o );
1006 updateOptions( getOptions() );
1007 if ( getCurrentTreePanel() != null ) {
1008 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
1009 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
1010 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1011 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
1012 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1013 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
1014 getCurrentTreePanel().getControlPanel().showWhole();
1016 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1017 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
1020 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
1022 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
1023 MainFrame.updateScreenTextAntialias( getMainPanel().getTreePanels() );
1027 void updateOptions( final Options options ) {
1028 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
1029 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
1030 && _background_gradient_cbmi.isSelected() );
1031 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
1032 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
1033 && _abbreviate_scientific_names.isSelected() );
1034 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
1035 && _color_labels_same_as_parent_branch.isSelected() );
1036 options.setShowDefaultNodeShapes( ( _show_default_node_shapes_cbmi != null )
1037 && _show_default_node_shapes_cbmi.isSelected() );
1038 options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null )
1039 && _taxonomy_colorize_node_shapes_cbmi.isSelected() );
1040 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
1041 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
1043 else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
1044 options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1046 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
1047 options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1049 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
1050 && _search_case_senstive_cbmi.isSelected() );
1051 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
1052 options.setShowScale( _show_scale_cbmi.isSelected() );
1054 if ( _label_direction_cbmi != null ) {
1055 if ( _label_direction_cbmi.isSelected() ) {
1056 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1059 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1062 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
1063 options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )
1064 && _show_confidence_stddev_cbmi.isSelected() );
1065 if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
1066 options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
1068 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
1069 && _search_whole_words_only_cbmi.isSelected() );
1070 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
1071 && _inverse_search_result_cbmi.isSelected() );
1072 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
1073 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1075 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
1076 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1078 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
1079 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1081 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
1082 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1084 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
1085 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1087 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
1088 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1090 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
1091 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1093 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
1094 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1098 void updateTypeCheckboxes( final Options options, final Object o ) {
1099 setTypeMenuToAllUnselected();
1100 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
1103 void viewAsNexus() {
1104 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1105 String title = "Nexus";
1106 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1107 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1109 showTextFrame( getMainPanel().getCurrentPhylogeny().toNexus( getOptions()
1110 .getNhConversionSupportValueStyle() ),
1116 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1117 String title = "New Hampshire";
1118 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1119 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1121 showTextFrame( getMainPanel().getCurrentPhylogeny()
1122 .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ),
1128 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1129 String title = "NHX";
1130 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1131 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1133 showTextFrame( getMainPanel().getCurrentPhylogeny().toNewHampshireX(), title );
1138 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1139 String title = "phyloXML";
1140 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1141 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1143 showTextFrame( getMainPanel().getCurrentPhylogeny().toPhyloXML( 0 ), title );
1147 private void chooseFont() {
1148 final FontChooser fc = new FontChooser();
1149 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
1150 fc.showDialog( this, "Select the Base Font" );
1151 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
1154 private void chooseMinimalConfidence() {
1155 final String s = ( String ) JOptionPane
1156 .showInputDialog( this,
1157 "Please the minimum for confidence values to be displayed.\n" + "[current value: "
1158 + getOptions().getMinConfidenceValue() + "]\n",
1159 "Minimal Confidence Value",
1160 JOptionPane.QUESTION_MESSAGE,
1163 getOptions().getMinConfidenceValue() );
1164 if ( !ForesterUtil.isEmpty( s ) ) {
1165 boolean success = true;
1167 final String m_str = s.trim();
1168 if ( !ForesterUtil.isEmpty( m_str ) ) {
1170 m = Double.parseDouble( m_str );
1172 catch ( final Exception ex ) {
1179 if ( success && ( m >= 0.0 ) ) {
1180 getOptions().setMinConfidenceValue( m );
1185 private void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
1186 if ( item != null ) {
1187 item.setFont( MainFrame.menu_font );
1188 if ( !getConfiguration().isUseNativeUI() ) {
1189 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
1190 item.setForeground( getConfiguration().getGuiMenuTextColor() );
1192 item.setSelected( is_selected );
1193 item.addActionListener( this );
1197 private MainPanel getMainPanel() {
1201 private boolean isScreenAntialias() {
1205 private void removeBranchColors() {
1206 if ( getMainPanel().getCurrentPhylogeny() != null ) {
1207 AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
1211 private void setMainPanel( final MainPanelApplets main_panel ) {
1212 _main_panel = main_panel;
1215 private void setupUI() {
1217 if ( getConfiguration().isUseNativeUI() ) {
1218 UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
1221 UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
1224 catch ( final UnsupportedLookAndFeelException e ) {
1225 AptxUtil.dieWithSystemError( "UnsupportedLookAndFeelException: " + e.toString() );
1227 catch ( final ClassNotFoundException e ) {
1228 AptxUtil.dieWithSystemError( "ClassNotFoundException: " + e.toString() );
1230 catch ( final InstantiationException e ) {
1231 AptxUtil.dieWithSystemError( "InstantiationException: " + e.toString() );
1233 catch ( final IllegalAccessException e ) {
1234 AptxUtil.dieWithSystemError( "IllegalAccessException: " + e.toString() );
1236 catch ( final Exception e ) {
1237 AptxUtil.dieWithSystemError( e.toString() );
1241 static void setupScreenTextAntialias( final List<TreePanel> treepanels, final boolean antialias ) {
1242 for( final TreePanel tree_panel : treepanels ) {
1243 tree_panel.setTextAntialias();