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>();
126 // private String _ext_node_data_buffer = "";
127 // 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 getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString();
342 public int getCurrentExternalNodesDataBufferChangeCounter() {
343 return getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter();
346 public int getCurrentExternalNodesDataBufferLength() {
347 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length();
351 * This method returns the current phylogeny as a string in the chosen format
353 * @param format must be NH, NHX, NEXUS or PHYLOXML
354 * @return the phylogeny string
355 * @author Herve Menager
357 public String getCurrentPhylogeny( final String format ) {
358 removeAllTextFrames();
359 if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty()
360 || ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
363 switch ( ForesterConstants.PhylogeneticTreeFormats.valueOf( format ) ) {
365 return getMainPanel().getCurrentPhylogeny().toNewHampshire();
367 return getMainPanel().getCurrentPhylogeny().toNewHampshireX();
369 return getMainPanel().getCurrentPhylogeny().toNexus();
371 return getMainPanel().getCurrentPhylogeny().toPhyloXML( -1 );
379 * This method returns a view of the current phylogeny in a chosen
380 * graphics format, base64-encoded in a string so that in can be used
383 * @param format must be GraphicsExportType (gif, jpg, pdf, png, tif, bmp)
384 * @return the phylogeny string
385 * @author Herve Menager
387 public String getCurrentPhylogenyGraphicsAsBase64EncodedString( final String format ) {
388 final ByteArrayOutputStream baos = new ByteArrayOutputStream();
390 AptxUtil.writePhylogenyToGraphicsByteArrayOutputStream( baos,
391 _main_panel.getWidth(),
392 _main_panel.getHeight(),
393 getCurrentTreePanel(),
394 getCurrentTreePanel().getControlPanel(),
395 GraphicsExportType.valueOf( format ),
398 catch ( final IOException ioe ) {
399 ForesterUtil.printErrorMessage( NAME, ioe.toString() );
400 ioe.printStackTrace();
401 JOptionPane.showMessageDialog( this,
402 NAME + ": Failed to generate graphics: " + "\nException: " + ioe,
403 "Failed to generate graphics",
404 JOptionPane.ERROR_MESSAGE );
407 final byte[] bytes = baos.toByteArray();
408 final String dataImg = Base64.encodeBase64String( bytes );
412 public Options getOptions() {
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 clearCurrentExternalNodesDataBuffer() {
767 getCurrentTreePanel().clearCurrentExternalNodesDataBuffer();
770 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
771 if ( item != null ) {
772 item.setFont( MainFrame.menu_font );
773 if ( !getConfiguration().isUseNativeUI() ) {
774 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
775 item.setForeground( getConfiguration().getGuiMenuTextColor() );
777 item.setSelected( is_selected );
778 item.addActionListener( this );
782 void customizeJMenuItem( final JMenuItem jmi ) {
783 jmi.setFont( MainFrame.menu_font );
784 if ( !getConfiguration().isUseNativeUI() ) {
785 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
786 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
788 jmi.addActionListener( this );
791 void displayBasicInformation() {
792 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
793 String title = "Basic Information";
794 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
795 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
797 showTextFrame( AptxUtil.createBasicInformation( getMainPanel().getCurrentPhylogeny() ), title );
801 Configuration getConfiguration() {
802 return _configuration;
805 TreePanel getCurrentTreePanel() {
806 return getMainPanel().getCurrentTreePanel();
809 JCheckBoxMenuItem getlabelDirectionCbmi() {
810 return _label_direction_cbmi;
813 Options getOtions() {
817 void help( final Map<String, WebLink> weblinks ) {
818 final StringBuilder sb = new StringBuilder();
819 sb.append( "Display options\n" );
820 sb.append( "-------------------\n" );
821 sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
822 sb.append( "Clickable tree nodes\n" );
823 sb.append( "--------------------\n" );
824 sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
825 sb.append( "or by right clicking:\n" );
826 sb.append( "o Display Node Data -- display information for a node\n" );
827 sb.append( "o Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
828 sb.append( "o Root/Reroot -- change tree root to clicked node\n" );
829 sb.append( "o Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
830 sb.append( "o Swap Descendants -- switch descendant on either side of clicked node\n" );
831 sb.append( "o Colorize Subtree -- color a subtree\n" );
832 sb.append( "o Open Sequence Web -- launch a web browser to display sequence information\n" );
833 sb.append( "o Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
834 sb.append( "- there may be additional choices depending on this particular setup\n\n" );
835 sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
836 sb.append( "Zooming\n" );
837 sb.append( "---------\n" );
838 sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
839 sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
840 sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
841 sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
842 sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
843 sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
844 sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
845 sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
846 sb.append( "Quick tree manipulation:\n" );
847 sb.append( "------------------------\n" );
848 sb.append( "Order Subtrees -- order the tree by branch length\n" );
849 sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
850 sb.append( "Memory problems (Java heap space error)\n" );
851 sb.append( "---------------------------------------\n" );
852 sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
853 sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
854 sb.append( "the '-Xmx' Java command line option. For example:\n" );
855 sb.append( "java -Xms32m -Xmx256m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
856 if ( ( weblinks != null ) && ( weblinks.size() > 0 ) ) {
857 sb.append( "Active web links\n" );
858 sb.append( "--------------------\n" );
859 for( final String key : weblinks.keySet() ) {
860 sb.append( " " + weblinks.get( key ).toString() + "\n" );
864 sb.append( "phyloXML\n" );
865 sb.append( "-------------------\n" );
866 sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
867 sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
868 sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
870 sb.append( "For more information: http://www.phylosoft.org/archaeopteryx/\n" );
871 sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
872 TextFrame.instantiate( sb.toString(), "Help", _textframes );
875 void initializeTypeMenu( final Options options ) {
876 setTypeMenuToAllUnselected();
878 switch ( options.getPhylogenyGraphicsType() ) {
880 _convex_type_cbmi.setSelected( true );
883 _curved_type_cbmi.setSelected( true );
886 _euro_type_cbmi.setSelected( true );
889 _rounded_type_cbmi.setSelected( true );
892 _triangular_type_cbmi.setSelected( true );
895 _unrooted_type_cbmi.setSelected( true );
898 _circular_type_cbmi.setSelected( true );
901 _rectangular_type_cbmi.setSelected( true );
905 catch ( final NullPointerException np ) {
906 // In all likelihood, this is caused by menu-less display.
910 void removeAllTextFrames() {
911 for( final TextFrame tf : _textframes ) {
919 void setConfiguration( final Configuration configuration ) {
920 _configuration = configuration;
923 void setOptions( final Options options ) {
927 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
928 setTypeMenuToAllUnselected();
932 _circular_type_cbmi.setSelected( true );
935 _convex_type_cbmi.setSelected( true );
938 _curved_type_cbmi.setSelected( true );
941 _euro_type_cbmi.setSelected( true );
944 _rounded_type_cbmi.setSelected( true );
947 _rectangular_type_cbmi.setSelected( true );
950 _triangular_type_cbmi.setSelected( true );
953 _unrooted_type_cbmi.setSelected( true );
956 throw new IllegalArgumentException( "unknown type: " + type );
959 catch ( final NullPointerException np ) {
960 // In all likelihood, this is caused by menu-less display.
964 void setTypeMenuToAllUnselected() {
965 if ( _convex_type_cbmi != null ) {
966 _convex_type_cbmi.setSelected( false );
968 if ( _curved_type_cbmi != null ) {
969 _curved_type_cbmi.setSelected( false );
971 if ( _euro_type_cbmi != null ) {
972 _euro_type_cbmi.setSelected( false );
974 if ( _rounded_type_cbmi != null ) {
975 _rounded_type_cbmi.setSelected( false );
977 if ( _triangular_type_cbmi != null ) {
978 _triangular_type_cbmi.setSelected( false );
980 if ( _rectangular_type_cbmi != null ) {
981 _rectangular_type_cbmi.setSelected( false );
983 if ( _unrooted_type_cbmi != null ) {
984 _unrooted_type_cbmi.setSelected( false );
986 if ( _circular_type_cbmi != null ) {
987 _circular_type_cbmi.setSelected( false );
991 void switchColors() {
992 final TreeColorSet colorset = getMainPanel().getCurrentTreePanel().getTreeColorSet();
993 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
994 csc.setVisible( true );
995 getMainPanel().setTreeColorSet( colorset );
998 void typeChanged( final Object o ) {
999 updateTypeCheckboxes( getOptions(), o );
1000 updateOptions( getOptions() );
1001 if ( getCurrentTreePanel() != null ) {
1002 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
1003 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
1004 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1005 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
1006 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1007 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
1008 getCurrentTreePanel().getControlPanel().showWhole();
1010 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1011 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
1014 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
1016 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
1017 MainFrame.updateScreenTextAntialias( getMainPanel().getTreePanels() );
1021 void updateOptions( final Options options ) {
1022 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
1023 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
1024 && _background_gradient_cbmi.isSelected() );
1025 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
1026 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
1027 && _abbreviate_scientific_names.isSelected() );
1028 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
1029 && _color_labels_same_as_parent_branch.isSelected() );
1030 options.setShowDefaultNodeShapes( ( _show_default_node_shapes_cbmi != null )
1031 && _show_default_node_shapes_cbmi.isSelected() );
1032 options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null )
1033 && _taxonomy_colorize_node_shapes_cbmi.isSelected() );
1034 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
1035 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
1037 else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
1038 options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1040 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
1041 options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1043 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
1044 && _search_case_senstive_cbmi.isSelected() );
1045 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
1046 options.setShowScale( _show_scale_cbmi.isSelected() );
1048 if ( _label_direction_cbmi != null ) {
1049 if ( _label_direction_cbmi.isSelected() ) {
1050 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1053 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1056 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
1057 options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )
1058 && _show_confidence_stddev_cbmi.isSelected() );
1059 if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
1060 options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
1062 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
1063 && _search_whole_words_only_cbmi.isSelected() );
1064 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
1065 && _inverse_search_result_cbmi.isSelected() );
1066 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
1067 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1069 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
1070 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1072 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
1073 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1075 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
1076 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1078 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
1079 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1081 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
1082 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1084 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
1085 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1087 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
1088 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1092 void updateTypeCheckboxes( final Options options, final Object o ) {
1093 setTypeMenuToAllUnselected();
1094 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
1097 void viewAsNexus() {
1098 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1099 String title = "Nexus";
1100 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1101 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1103 showTextFrame( getMainPanel().getCurrentPhylogeny().toNexus( getOptions()
1104 .getNhConversionSupportValueStyle() ),
1110 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1111 String title = "New Hampshire";
1112 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1113 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1115 showTextFrame( getMainPanel().getCurrentPhylogeny()
1116 .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ),
1122 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1123 String title = "NHX";
1124 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1125 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1127 showTextFrame( getMainPanel().getCurrentPhylogeny().toNewHampshireX(), title );
1132 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1133 String title = "phyloXML";
1134 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1135 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1137 showTextFrame( getMainPanel().getCurrentPhylogeny().toPhyloXML( 0 ), title );
1141 private void chooseFont() {
1142 final FontChooser fc = new FontChooser();
1143 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
1144 fc.showDialog( this, "Select the Base Font" );
1145 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
1148 private void chooseMinimalConfidence() {
1149 final String s = ( String ) JOptionPane
1150 .showInputDialog( this,
1151 "Please the minimum for confidence values to be displayed.\n" + "[current value: "
1152 + getOptions().getMinConfidenceValue() + "]\n",
1153 "Minimal Confidence Value",
1154 JOptionPane.QUESTION_MESSAGE,
1157 getOptions().getMinConfidenceValue() );
1158 if ( !ForesterUtil.isEmpty( s ) ) {
1159 boolean success = true;
1161 final String m_str = s.trim();
1162 if ( !ForesterUtil.isEmpty( m_str ) ) {
1164 m = Double.parseDouble( m_str );
1166 catch ( final Exception ex ) {
1173 if ( success && ( m >= 0.0 ) ) {
1174 getOptions().setMinConfidenceValue( m );
1179 private void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
1180 if ( item != null ) {
1181 item.setFont( MainFrame.menu_font );
1182 if ( !getConfiguration().isUseNativeUI() ) {
1183 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
1184 item.setForeground( getConfiguration().getGuiMenuTextColor() );
1186 item.setSelected( is_selected );
1187 item.addActionListener( this );
1191 private MainPanel getMainPanel() {
1195 private boolean isScreenAntialias() {
1199 private void removeBranchColors() {
1200 if ( getMainPanel().getCurrentPhylogeny() != null ) {
1201 AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
1205 private void setMainPanel( final MainPanelApplets main_panel ) {
1206 _main_panel = main_panel;
1209 private void setupUI() {
1211 if ( getConfiguration().isUseNativeUI() ) {
1212 UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
1215 UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
1218 catch ( final UnsupportedLookAndFeelException e ) {
1219 AptxUtil.dieWithSystemError( "UnsupportedLookAndFeelException: " + e.toString() );
1221 catch ( final ClassNotFoundException e ) {
1222 AptxUtil.dieWithSystemError( "ClassNotFoundException: " + e.toString() );
1224 catch ( final InstantiationException e ) {
1225 AptxUtil.dieWithSystemError( "InstantiationException: " + e.toString() );
1227 catch ( final IllegalAccessException e ) {
1228 AptxUtil.dieWithSystemError( "IllegalAccessException: " + e.toString() );
1230 catch ( final Exception e ) {
1231 AptxUtil.dieWithSystemError( e.toString() );
1235 static void setupScreenTextAntialias( final List<TreePanel> treepanels, final boolean antialias ) {
1236 for( final TreePanel tree_panel : treepanels ) {
1237 tree_panel.setTextAntialias();