2 package org.forester.archaeopteryx;
4 import java.awt.BorderLayout;
5 import java.awt.Container;
6 import java.awt.event.ActionEvent;
7 import java.awt.event.ActionListener;
8 import java.awt.event.ComponentAdapter;
9 import java.awt.event.ComponentEvent;
10 import java.io.ByteArrayOutputStream;
12 import java.io.IOException;
14 import java.util.LinkedList;
15 import java.util.List;
17 import java.util.NoSuchElementException;
19 import javax.swing.ButtonGroup;
20 import javax.swing.JApplet;
21 import javax.swing.JCheckBoxMenuItem;
22 import javax.swing.JMenu;
23 import javax.swing.JMenuBar;
24 import javax.swing.JMenuItem;
25 import javax.swing.JOptionPane;
26 import javax.swing.JRadioButtonMenuItem;
27 import javax.swing.UIManager;
28 import javax.swing.UnsupportedLookAndFeelException;
29 import javax.swing.event.ChangeEvent;
30 import javax.swing.event.ChangeListener;
32 import org.apache.commons.codec.binary.Base64;
33 import org.forester.archaeopteryx.AptxUtil.GraphicsExportType;
34 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
35 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
36 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
37 import org.forester.phylogeny.Phylogeny;
38 import org.forester.phylogeny.data.SequenceRelation;
39 import org.forester.util.ForesterConstants;
40 import org.forester.util.ForesterUtil;
43 // <applet archive="forester.jar"
44 // code="org.forester.archaeopteryx.ArchaeopteryxE.class"
45 // codebase="http://www.myserver.org/path/to/forester"
48 // alt="ArchaeopteryxE is not working on your system (requires at least Sun Java 1.5)!">
49 // <param name="url_of_tree_to_load"
50 // value="http://www.myserver.org/examples/data/apaf.xml">
51 // <param name="config_file"
52 // value="http://www.myserver.org/examples/config/config_file.txt">
54 public class ArchaeopteryxE extends JApplet implements ActionListener {
56 private final static String NAME = "ArchaeopteryxE";
57 private static final long serialVersionUID = -1220055577935759443L;
58 private Configuration _configuration;
59 private MainPanelApplets _main_panel;
60 private JMenuBar _jmenubar;
61 private JMenu _options_jmenu;
62 private JMenu _font_size_menu;
63 private JMenuItem _super_tiny_fonts_mi;
64 private JMenuItem _tiny_fonts_mi;
65 private JMenuItem _small_fonts_mi;
66 private JMenuItem _medium_fonts_mi;
67 private JMenuItem _large_fonts_mi;
68 private JMenu _tools_menu;
69 private JMenuItem _taxcolor_item;
70 private JMenuItem _confcolor_item;
71 private JMenuItem _midpoint_root_item;
72 private JMenu _view_jmenu;
73 private JMenuItem _view_as_XML_item;
74 private JMenuItem _view_as_NH_item;
75 private JMenuItem _view_as_NHX_item;
76 private JMenuItem _view_as_nexus_item;
77 private JMenuItem _display_basic_information_item;
78 private JMenu _type_menu;
79 private JCheckBoxMenuItem _rectangular_type_cbmi;
80 private JCheckBoxMenuItem _triangular_type_cbmi;
81 private JCheckBoxMenuItem _curved_type_cbmi;
82 private JCheckBoxMenuItem _convex_type_cbmi;
83 private JCheckBoxMenuItem _euro_type_cbmi;
84 private JCheckBoxMenuItem _rounded_type_cbmi;
85 private JCheckBoxMenuItem _unrooted_type_cbmi;
86 private JCheckBoxMenuItem _circular_type_cbmi;
87 private JMenuItem _help_item;
88 private JMenuItem _about_item;
89 private JMenu _help_jmenu;
90 private JMenuItem _website_item;
91 private JMenuItem _phyloxml_website_item;
92 private JMenuItem _phyloxml_ref_item;
93 private JMenuItem _aptx_ref_item;
94 private JMenuItem _remove_branch_color_item;
95 private JMenuItem _infer_common_sn_names_item;
96 private JCheckBoxMenuItem _show_domain_labels;
97 private JCheckBoxMenuItem _color_labels_same_as_parent_branch;
98 private JCheckBoxMenuItem _abbreviate_scientific_names;
99 private JCheckBoxMenuItem _screen_antialias_cbmi;
100 private JCheckBoxMenuItem _background_gradient_cbmi;
101 private JRadioButtonMenuItem _non_lined_up_cladograms_rbmi;
102 private JRadioButtonMenuItem _uniform_cladograms_rbmi;
103 private JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi;
104 private Options _options;
105 private JMenuItem _choose_font_mi;
106 private JMenuItem _switch_colors_mi;
107 JCheckBoxMenuItem _label_direction_cbmi;
108 private JCheckBoxMenuItem _show_scale_cbmi;
109 private JCheckBoxMenuItem _search_case_senstive_cbmi;
110 private JCheckBoxMenuItem _search_whole_words_only_cbmi;
111 private JCheckBoxMenuItem _inverse_search_result_cbmi;
112 private JCheckBoxMenuItem _show_overview_cbmi;
113 private JMenuItem _choose_minimal_confidence_mi;
114 private JCheckBoxMenuItem _show_branch_length_values_cbmi;
115 private JMenuItem _collapse_species_specific_subtrees;
116 private JMenuItem _overview_placment_mi;
117 private ButtonGroup _radio_group_1;
118 private JCheckBoxMenuItem _show_default_node_shapes_cbmi;
119 private JMenuItem _cycle_node_shape_mi;
120 private JMenuItem _cycle_node_fill_mi;
121 private JMenuItem _choose_node_size_mi;
122 private JCheckBoxMenuItem _taxonomy_colorize_node_shapes_cbmi;
123 private JCheckBoxMenuItem _show_confidence_stddev_cbmi;
124 private final LinkedList<TextFrame> _textframes = new LinkedList<TextFrame>();
125 private String _ext_node_data_buffer = "";
128 public void actionPerformed( final ActionEvent e ) {
129 final Object o = e.getSource();
130 if ( o == _midpoint_root_item ) {
131 getMainPanel().getCurrentTreePanel().midpointRoot();
133 else if ( o == _taxcolor_item ) {
134 getMainPanel().getCurrentTreePanel().taxColor();
136 else if ( o == _confcolor_item ) {
137 getMainPanel().getCurrentTreePanel().confColor();
139 else if ( o == _infer_common_sn_names_item ) {
140 if ( getCurrentTreePanel() != null ) {
141 getCurrentTreePanel().inferCommonPartOfScientificNames();
144 else if ( o == _collapse_species_specific_subtrees ) {
145 if ( getCurrentTreePanel() != null ) {
146 getCurrentTreePanel().collapseSpeciesSpecificSubtrees();
149 else if ( o == _remove_branch_color_item ) {
150 removeBranchColors();
152 else if ( o == _switch_colors_mi ) {
155 else if ( o == _display_basic_information_item ) {
156 displayBasicInformation();
158 else if ( o == _view_as_NH_item ) {
161 else if ( o == _view_as_NHX_item ) {
164 else if ( o == _view_as_XML_item ) {
167 else if ( o == _view_as_nexus_item ) {
170 else if ( o == _super_tiny_fonts_mi ) {
171 if ( getCurrentTreePanel() != null ) {
172 getCurrentTreePanel().setSuperTinyFonts();
173 getCurrentTreePanel().repaint();
176 else if ( o == _tiny_fonts_mi ) {
177 if ( getCurrentTreePanel() != null ) {
178 getCurrentTreePanel().setTinyFonts();
179 getCurrentTreePanel().repaint();
182 else if ( o == _small_fonts_mi ) {
183 if ( getCurrentTreePanel() != null ) {
184 getCurrentTreePanel().setSmallFonts();
185 getCurrentTreePanel().repaint();
188 else if ( o == _medium_fonts_mi ) {
189 if ( getCurrentTreePanel() != null ) {
190 getCurrentTreePanel().setMediumFonts();
191 getCurrentTreePanel().repaint();
194 else if ( o == _large_fonts_mi ) {
195 if ( getCurrentTreePanel() != null ) {
196 getCurrentTreePanel().setLargeFonts();
197 getCurrentTreePanel().repaint();
200 else if ( o == _choose_font_mi ) {
203 else if ( o == _choose_minimal_confidence_mi ) {
204 chooseMinimalConfidence();
206 else if ( o == _choose_node_size_mi ) {
207 MainFrame.chooseNodeSize( getOptions(), this );
209 else if ( o == _overview_placment_mi ) {
210 MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
212 else if ( o == _cycle_node_fill_mi ) {
213 MainFrame.cycleNodeFill( getOptions(), getCurrentTreePanel() );
215 else if ( o == _cycle_node_shape_mi ) {
216 MainFrame.cycleNodeShape( getOptions(), getCurrentTreePanel() );
218 else if ( o == _non_lined_up_cladograms_rbmi ) {
219 updateOptions( getOptions() );
220 _main_panel.getControlPanel().showWhole();
222 else if ( o == _uniform_cladograms_rbmi ) {
223 updateOptions( getOptions() );
224 _main_panel.getControlPanel().showWhole();
226 else if ( o == _ext_node_dependent_cladogram_rbmi ) {
227 updateOptions( getOptions() );
228 _main_panel.getControlPanel().showWhole();
230 else if ( o == _search_case_senstive_cbmi ) {
231 updateOptions( getOptions() );
232 getMainPanel().getControlPanel().search();
234 else if ( o == _search_whole_words_only_cbmi ) {
235 updateOptions( getOptions() );
236 getMainPanel().getControlPanel().search();
238 else if ( o == _inverse_search_result_cbmi ) {
239 updateOptions( getOptions() );
240 getMainPanel().getControlPanel().search();
242 else if ( o == _show_scale_cbmi ) {
243 updateOptions( getOptions() );
245 else if ( o == _show_branch_length_values_cbmi ) {
246 updateOptions( getOptions() );
248 else if ( o == _show_confidence_stddev_cbmi ) {
249 updateOptions( getOptions() );
251 else if ( o == _label_direction_cbmi ) {
252 updateOptions( getOptions() );
254 else if ( o == _show_overview_cbmi ) {
255 updateOptions( getOptions() );
256 if ( getCurrentTreePanel() != null ) {
257 getCurrentTreePanel().updateOvSizes();
260 else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
261 || ( o == _convex_type_cbmi ) || ( o == _rounded_type_cbmi ) || ( o == _euro_type_cbmi )
262 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
265 else if ( o == _screen_antialias_cbmi ) {
266 updateOptions( getOptions() );
267 setupScreenTextAntialias( getMainPanel().getTreePanels(), isScreenAntialias() );
269 else if ( o == _background_gradient_cbmi ) {
270 updateOptions( getOptions() );
272 else if ( o == _show_domain_labels ) {
273 updateOptions( getOptions() );
275 else if ( o == _color_labels_same_as_parent_branch ) {
276 updateOptions( getOptions() );
278 else if ( o == _show_default_node_shapes_cbmi ) {
279 updateOptions( getOptions() );
281 else if ( o == _taxonomy_colorize_node_shapes_cbmi ) {
282 updateOptions( getOptions() );
284 else if ( o == _about_item ) {
287 else if ( o == _help_item ) {
288 help( getConfiguration().getWebLinks() );
290 else if ( o == _website_item ) {
292 AptxUtil.openWebsite( Constants.APTX_WEB_SITE, true, this );
294 catch ( final IOException e1 ) {
295 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
298 else if ( o == _phyloxml_website_item ) {
300 AptxUtil.openWebsite( Constants.PHYLOXML_WEB_SITE, true, this );
302 catch ( final IOException e1 ) {
303 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
306 else if ( o == _aptx_ref_item ) {
308 AptxUtil.openWebsite( Constants.APTX_REFERENCE_URL, true, this );
310 catch ( final IOException e1 ) {
311 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
314 else if ( o == _phyloxml_ref_item ) {
316 AptxUtil.openWebsite( Constants.PHYLOXML_REFERENCE_URL, true, this );
318 catch ( final IOException e1 ) {
319 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
325 void help( final Map<String, WebLink> weblinks ) {
326 final StringBuilder sb = new StringBuilder();
327 sb.append( "Display options\n" );
328 sb.append( "-------------------\n" );
329 sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
330 sb.append( "Clickable tree nodes\n" );
331 sb.append( "--------------------\n" );
332 sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
333 sb.append( "or by right clicking:\n" );
334 sb.append( "o Display Node Data -- display information for a node\n" );
335 sb.append( "o Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
336 sb.append( "o Root/Reroot -- change tree root to clicked node\n" );
337 sb.append( "o Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
338 sb.append( "o Swap Descendants -- switch descendant on either side of clicked node\n" );
339 sb.append( "o Colorize Subtree -- color a subtree\n" );
340 sb.append( "o Open Sequence Web -- launch a web browser to display sequence information\n" );
341 sb.append( "o Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
342 sb.append( "- there may be additional choices depending on this particular setup\n\n" );
343 sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
344 sb.append( "Zooming\n" );
345 sb.append( "---------\n" );
346 sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
347 sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
348 sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
349 sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
350 sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
351 sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
352 sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
353 sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
354 sb.append( "Quick tree manipulation:\n" );
355 sb.append( "------------------------\n" );
356 sb.append( "Order Subtrees -- order the tree by branch length\n" );
357 sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
358 sb.append( "Memory problems (Java heap space error)\n" );
359 sb.append( "---------------------------------------\n" );
360 sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
361 sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
362 sb.append( "the '-Xmx' Java command line option. For example:\n" );
363 sb.append( "java -Xms32m -Xmx256m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
364 if ( ( weblinks != null ) && ( weblinks.size() > 0 ) ) {
365 sb.append( "Active web links\n" );
366 sb.append( "--------------------\n" );
367 for( final String key : weblinks.keySet() ) {
368 sb.append( " " + weblinks.get( key ).toString() + "\n" );
372 sb.append( "phyloXML\n" );
373 sb.append( "-------------------\n" );
374 sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
375 sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
376 sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
378 sb.append( "For more information: http://www.phylosoft.org/archaeopteryx/\n" );
379 sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
380 TextFrame.instantiate( sb.toString(), "Help", _textframes );
383 void setCurrentExternalNodesDataBuffer( final String s ) {
384 if ( !ForesterUtil.isEmpty( s ) ) {
385 _ext_node_data_buffer = s.trim();
388 _ext_node_data_buffer = "";
393 * This method returns the current external node data which
394 * has been selected by the user by clicking the "Return ..."
395 * menu item. This method is expected to be called from Javascript or
398 * @return current external node data as String
400 public String getCurrentExternalNodesDataBuffer() {
401 return _ext_node_data_buffer;
405 * This method returns the current phylogeny as a string in the chosen format
407 * @param format must be NH, NHX, NEXUS or PHYLOXML
408 * @return the phylogeny string
409 * @author Herve Menager
411 public String getCurrentPhylogeny( final String format ) {
412 removeAllTextFrames();
413 if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty()
414 || ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
417 switch ( ForesterConstants.PhylogeneticTreeFormats.valueOf( format ) ) {
419 return getMainPanel().getCurrentPhylogeny().toNewHampshire();
421 return getMainPanel().getCurrentPhylogeny().toNewHampshireX();
423 return getMainPanel().getCurrentPhylogeny().toNexus();
425 return getMainPanel().getCurrentPhylogeny().toPhyloXML( -1 );
433 * This method returns a view of the current phylogeny in a chosen
434 * graphics format, base64-encoded in a string so that in can be used
437 * @param format must be GraphicsExportType (gif, jpg, pdf, png, tif, bmp)
438 * @return the phylogeny string
439 * @author Herve Menager
441 public String getCurrentPhylogenyGraphicsAsBase64EncodedString( final String format ) {
442 final ByteArrayOutputStream baos = new ByteArrayOutputStream();
444 AptxUtil.writePhylogenyToGraphicsByteArrayOutputStream( baos,
445 _main_panel.getWidth(),
446 _main_panel.getHeight(),
447 getCurrentTreePanel(),
448 getCurrentTreePanel().getControlPanel(),
449 GraphicsExportType.valueOf( format ),
452 catch ( final IOException ioe ) {
453 ForesterUtil.printErrorMessage( NAME, ioe.toString() );
454 ioe.printStackTrace();
455 JOptionPane.showMessageDialog( this,
456 NAME + ": Failed to generate graphics: " + "\nException: " + ioe,
457 "Failed to generate graphics",
458 JOptionPane.ERROR_MESSAGE );
461 final byte[] bytes = baos.toByteArray();
462 final String dataImg = Base64.encodeBase64String( bytes );
466 void buildFontSizeMenu() {
467 _font_size_menu = MainFrame.createMenu( MainFrame.FONT_SIZE_MENU_LABEL, getConfiguration() );
468 _font_size_menu.add( _super_tiny_fonts_mi = new JMenuItem( "Super tiny fonts" ) );
469 _font_size_menu.add( _tiny_fonts_mi = new JMenuItem( "Tiny fonts" ) );
470 _font_size_menu.add( _small_fonts_mi = new JMenuItem( "Small fonts" ) );
471 _font_size_menu.add( _medium_fonts_mi = new JMenuItem( "Medium fonts" ) );
472 _font_size_menu.add( _large_fonts_mi = new JMenuItem( "Large fonts" ) );
473 customizeJMenuItem( _super_tiny_fonts_mi );
474 customizeJMenuItem( _tiny_fonts_mi );
475 customizeJMenuItem( _small_fonts_mi );
476 customizeJMenuItem( _medium_fonts_mi );
477 customizeJMenuItem( _large_fonts_mi );
478 _jmenubar.add( _font_size_menu );
481 void buildHelpMenu() {
482 _help_jmenu = MainFrame.createMenu( "Help", getConfiguration() );
483 _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
484 _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
485 _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
486 _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
487 _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
488 _help_jmenu.addSeparator();
489 _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
490 customizeJMenuItem( _help_item );
491 customizeJMenuItem( _website_item );
492 customizeJMenuItem( _phyloxml_website_item );
493 customizeJMenuItem( _aptx_ref_item );
494 customizeJMenuItem( _phyloxml_ref_item );
495 customizeJMenuItem( _about_item );
496 _phyloxml_ref_item.setToolTipText( MainFrame.PHYLOXML_REF_TOOL_TIP );
497 _aptx_ref_item.setToolTipText( MainFrame.APTX_REF_TOOL_TIP );
498 _jmenubar.add( _help_jmenu );
501 void buildOptionsMenu() {
502 _options_jmenu = MainFrame.createMenu( MainFrame.OPTIONS_HEADER, getConfiguration() );
503 _options_jmenu.addChangeListener( new ChangeListener() {
506 public void stateChanged( final ChangeEvent e ) {
507 MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getOptions() );
508 MainFrame.setTextColorChooseMenuItem( _switch_colors_mi, getCurrentTreePanel() );
510 .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() );
511 MainFrame.setTextForFontChooserMenuItem( _choose_font_mi, MainFrame
512 .createCurrentFontDesc( getMainPanel().getTreeFontSet() ) );
513 MainFrame.updateOptionsMenuDependingOnPhylogenyType( getMainPanel(),
515 _show_branch_length_values_cbmi,
516 _non_lined_up_cladograms_rbmi,
517 _uniform_cladograms_rbmi,
518 _ext_node_dependent_cladogram_rbmi,
519 _label_direction_cbmi );
520 MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() );
521 MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() );
522 MainFrame.setTextNodeSizeMenuItem( _choose_node_size_mi, getOptions() );
525 _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.DISPLAY_SUBHEADER ),
526 getConfiguration() ) );
528 .add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );
529 _options_jmenu.add( _uniform_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.UNIFORM_CLADOGRAMS_LABEL ) );
531 .add( _non_lined_up_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.NON_LINED_UP_CLADOGRAMS_LABEL ) );
532 _radio_group_1 = new ButtonGroup();
533 _radio_group_1.add( _ext_node_dependent_cladogram_rbmi );
534 _radio_group_1.add( _uniform_cladograms_rbmi );
535 _radio_group_1.add( _non_lined_up_cladograms_rbmi );
536 _options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_OVERVIEW_LABEL ) );
537 _options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_SCALE_LABEL ) );
539 .add( _show_branch_length_values_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_BRANCH_LENGTH_VALUES_LABEL ) );
540 _options_jmenu.add( _show_confidence_stddev_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_CONF_STDDEV_LABEL ) );
542 .add( _show_default_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL ) );
544 .add( _taxonomy_colorize_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.TAXONOMY_COLORIZE_NODE_SHAPES_LABEL ) );
545 _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL ) );
546 _options_jmenu.add( _cycle_node_fill_mi = new JMenuItem( MainFrame.CYCLE_NODE_FILL_LABEL ) );
547 _options_jmenu.add( _choose_node_size_mi = new JMenuItem( MainFrame.CHOOSE_NODE_SIZE_LABEL ) );
548 _options_jmenu.add( _label_direction_cbmi = new JCheckBoxMenuItem( MainFrame.LABEL_DIRECTION_LABEL ) );
550 .add( _color_labels_same_as_parent_branch = new JCheckBoxMenuItem( MainFrame.COLOR_LABELS_LABEL ) );
551 _color_labels_same_as_parent_branch.setToolTipText( MainFrame.COLOR_LABELS_TIP );
552 _options_jmenu.add( _abbreviate_scientific_names = new JCheckBoxMenuItem( MainFrame.ABBREV_SN_LABEL ) );
553 _label_direction_cbmi.setToolTipText( MainFrame.LABEL_DIRECTION_TIP );
554 _options_jmenu.add( _screen_antialias_cbmi = new JCheckBoxMenuItem( MainFrame.SCREEN_ANTIALIAS_LABEL ) );
555 _options_jmenu.add( _background_gradient_cbmi = new JCheckBoxMenuItem( MainFrame.BG_GRAD_LABEL ) );
556 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
557 _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( MainFrame.SHOW_DOMAIN_LABELS_LABEL ) );
559 _options_jmenu.add( _choose_minimal_confidence_mi = new JMenuItem( "" ) );
560 _options_jmenu.add( _overview_placment_mi = new JMenuItem( "" ) );
561 _options_jmenu.add( _switch_colors_mi = new JMenuItem( "" ) );
562 _options_jmenu.add( _choose_font_mi = new JMenuItem( "" ) );
563 _options_jmenu.addSeparator();
564 _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.SEARCH_SUBHEADER ),
565 getConfiguration() ) );
567 .add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_CASE_SENSITIVE_LABEL ) );
568 _options_jmenu.add( _search_whole_words_only_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_TERMS_ONLY_LABEL ) );
570 .add( _inverse_search_result_cbmi = new JCheckBoxMenuItem( MainFrame.INVERSE_SEARCH_RESULT_LABEL ) );
571 customizeJMenuItem( _choose_font_mi );
572 customizeJMenuItem( _choose_minimal_confidence_mi );
573 customizeJMenuItem( _switch_colors_mi );
574 customizeJMenuItem( _overview_placment_mi );
575 customizeCheckBoxMenuItem( _label_direction_cbmi,
576 getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL );
577 customizeCheckBoxMenuItem( _screen_antialias_cbmi, getOptions().isAntialiasScreen() );
578 customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );
579 customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );
580 customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );
581 customizeCheckBoxMenuItem( _show_default_node_shapes_cbmi, getOptions().isShowDefaultNodeShapes() );
582 customizeCheckBoxMenuItem( _taxonomy_colorize_node_shapes_cbmi, getOptions().isTaxonomyColorizeNodeShapes() );
583 customizeJMenuItem( _cycle_node_shape_mi );
584 customizeJMenuItem( _cycle_node_fill_mi );
585 customizeJMenuItem( _choose_node_size_mi );
586 customizeCheckBoxMenuItem( _color_labels_same_as_parent_branch, getOptions().isColorLabelsSameAsParentBranch() );
587 customizeCheckBoxMenuItem( _search_case_senstive_cbmi, getOptions().isSearchCaseSensitive() );
588 customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );
589 customizeRadioButtonMenuItem( _non_lined_up_cladograms_rbmi,
590 getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP );
591 customizeRadioButtonMenuItem( _uniform_cladograms_rbmi,
592 getOptions().getCladogramType() == CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
593 customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi,
594 getOptions().getCladogramType() == CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
595 customizeCheckBoxMenuItem( _show_branch_length_values_cbmi, getOptions().isShowBranchLengthValues() );
596 customizeCheckBoxMenuItem( _show_overview_cbmi, getOptions().isShowOverview() );
597 customizeCheckBoxMenuItem( _search_whole_words_only_cbmi, getOptions().isMatchWholeTermsOnly() );
598 customizeCheckBoxMenuItem( _inverse_search_result_cbmi, getOptions().isInverseSearchResult() );
599 customizeCheckBoxMenuItem( _show_confidence_stddev_cbmi, getOptions().isShowConfidenceStddev() );
600 _jmenubar.add( _options_jmenu );
603 void buildToolsMenu() {
604 _tools_menu = MainFrame.createMenu( "Tools", getConfiguration() );
605 _tools_menu.add( _confcolor_item = new JMenuItem( "Colorize Branches Depending on Confidence" ) );
606 customizeJMenuItem( _confcolor_item );
607 _tools_menu.add( _taxcolor_item = new JMenuItem( "Taxonomy Colorize Branches" ) );
608 customizeJMenuItem( _taxcolor_item );
609 _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete Branch Colors" ) );
610 _remove_branch_color_item.setToolTipText( "To delete branch color values from the current phylogeny." );
611 customizeJMenuItem( _remove_branch_color_item );
612 _tools_menu.addSeparator();
613 _tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) );
614 customizeJMenuItem( _midpoint_root_item );
615 _tools_menu.addSeparator();
617 .add( _infer_common_sn_names_item = new JMenuItem( "Infer Common Parts of Internal Scientific Names" ) );
618 customizeJMenuItem( _infer_common_sn_names_item );
619 _tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Species-Specific Subtrees" ) );
620 customizeJMenuItem( _collapse_species_specific_subtrees );
621 _jmenubar.add( _tools_menu );
624 void buildTypeMenu() {
625 _type_menu = MainFrame.createMenu( MainFrame.TYPE_MENU_HEADER, getConfiguration() );
626 _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
627 _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
628 _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
629 _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
630 _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
631 _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
632 _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
633 _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
634 customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
635 customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
636 customizeCheckBoxMenuItem( _euro_type_cbmi, false );
637 customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
638 customizeCheckBoxMenuItem( _curved_type_cbmi, false );
639 customizeCheckBoxMenuItem( _convex_type_cbmi, false );
640 customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
641 customizeCheckBoxMenuItem( _circular_type_cbmi, false );
642 _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
643 _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
644 initializeTypeMenu( getOptions() );
645 _jmenubar.add( _type_menu );
648 void buildViewMenu() {
649 _view_jmenu = MainFrame.createMenu( "View", getConfiguration() );
650 _view_jmenu.add( _display_basic_information_item = new JMenuItem( "Display Basic Information" ) );
651 _view_jmenu.addSeparator();
652 _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) );
653 _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) );
654 _view_jmenu.add( _view_as_NHX_item = new JMenuItem( "View as NHX" ) );
655 _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "View as Nexus" ) );
656 customizeJMenuItem( _display_basic_information_item );
657 customizeJMenuItem( _view_as_NH_item );
658 customizeJMenuItem( _view_as_NHX_item );
659 customizeJMenuItem( _view_as_XML_item );
660 customizeJMenuItem( _view_as_nexus_item );
661 _jmenubar.add( _view_jmenu );
664 private void chooseFont() {
665 final FontChooser fc = new FontChooser();
666 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
667 fc.showDialog( this, "Select the Base Font" );
668 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
671 private void chooseMinimalConfidence() {
672 final String s = ( String ) JOptionPane
673 .showInputDialog( this,
674 "Please the minimum for confidence values to be displayed.\n" + "[current value: "
675 + getOptions().getMinConfidenceValue() + "]\n",
676 "Minimal Confidence Value",
677 JOptionPane.QUESTION_MESSAGE,
680 getOptions().getMinConfidenceValue() );
681 if ( !ForesterUtil.isEmpty( s ) ) {
682 boolean success = true;
684 final String m_str = s.trim();
685 if ( !ForesterUtil.isEmpty( m_str ) ) {
687 m = Double.parseDouble( m_str );
689 catch ( final Exception ex ) {
696 if ( success && ( m >= 0.0 ) ) {
697 getOptions().setMinConfidenceValue( m );
702 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
703 if ( item != null ) {
704 item.setFont( MainFrame.menu_font );
705 if ( !getConfiguration().isUseNativeUI() ) {
706 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
707 item.setForeground( getConfiguration().getGuiMenuTextColor() );
709 item.setSelected( is_selected );
710 item.addActionListener( this );
714 void customizeJMenuItem( final JMenuItem jmi ) {
715 jmi.setFont( MainFrame.menu_font );
716 if ( !getConfiguration().isUseNativeUI() ) {
717 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
718 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
720 jmi.addActionListener( this );
723 private void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
724 if ( item != null ) {
725 item.setFont( MainFrame.menu_font );
726 if ( !getConfiguration().isUseNativeUI() ) {
727 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
728 item.setForeground( getConfiguration().getGuiMenuTextColor() );
730 item.setSelected( is_selected );
731 item.addActionListener( this );
736 public void destroy() {
737 AptxUtil.printAppletMessage( NAME, "going to be destroyed " );
738 removeAllTextFrames();
739 if ( getMainPanel() != null ) {
740 getMainPanel().terminate();
744 Configuration getConfiguration() {
745 return _configuration;
748 TreePanel getCurrentTreePanel() {
749 return getMainPanel().getCurrentTreePanel();
752 JCheckBoxMenuItem getlabelDirectionCbmi() {
753 return _label_direction_cbmi;
756 private MainPanel getMainPanel() {
760 public Options getOptions() {
764 Options getOtions() {
770 final String config_filename = getParameter( Constants.APPLET_PARAM_NAME_FOR_CONFIG_FILE_URL );
771 AptxUtil.printAppletMessage( NAME, "URL for configuration file is: " + config_filename );
772 final Configuration configuration = new Configuration( config_filename, true, true, true );
773 setConfiguration( configuration );
774 setOptions( Options.createInstance( configuration ) );
777 Phylogeny[] phys = null;
778 final String phys_url_string = getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD );
779 AptxUtil.printAppletMessage( NAME, "URL for phylogenies is " + phys_url_string );
780 // Get URL to tree file
781 if ( phys_url_string != null ) {
783 phys_url = new URL( phys_url_string );
785 catch ( final Exception e ) {
786 ForesterUtil.printErrorMessage( NAME, "error: " + e );
788 JOptionPane.showMessageDialog( this, NAME + ": Could not create URL from: \"" + phys_url_string
789 + "\"\nException: " + e, "Failed to create URL", JOptionPane.ERROR_MESSAGE );
792 // Load the tree from URL
793 if ( phys_url != null ) {
795 phys = AptxUtil.readPhylogeniesFromUrl( phys_url, getConfiguration().isValidatePhyloXmlAgainstSchema() );
797 catch ( final Exception e ) {
798 ForesterUtil.printErrorMessage( NAME, e.toString() );
800 JOptionPane.showMessageDialog( this,
801 NAME + ": Failed to read phylogenies: " + "\nException: " + e,
802 "Failed to read phylogenies",
803 JOptionPane.ERROR_MESSAGE );
806 if ( ( phys == null ) || ( phys.length < 1 ) ) {
807 ForesterUtil.printErrorMessage( NAME, "phylogenies from [" + phys_url + "] are null or empty" );
808 JOptionPane.showMessageDialog( this,
809 NAME + ": phylogenies from [" + phys_url + "] are null or empty",
810 "Failed to read phylogenies",
811 JOptionPane.ERROR_MESSAGE );
815 AptxUtil.printAppletMessage( NAME, "loaded " + phys.length + " phylogenies from: " + phys_url );
818 setMainPanel( new MainPanelApplets( getConfiguration(), this ) );
819 _jmenubar = new JMenuBar();
820 if ( !getConfiguration().isHideControlPanelAndMenubar() ) {
821 if ( !getConfiguration().isUseNativeUI() ) {
822 _jmenubar.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
830 setJMenuBar( _jmenubar );
832 final Container contentpane = getContentPane();
833 contentpane.setLayout( new BorderLayout() );
834 contentpane.add( getMainPanel(), BorderLayout.CENTER );
835 addComponentListener( new ComponentAdapter() {
838 public void componentResized( final ComponentEvent e ) {
839 if ( getMainPanel().getCurrentTreePanel() != null ) {
840 getMainPanel().getCurrentTreePanel().setParametersForPainting( getMainPanel().getCurrentTreePanel()
842 getMainPanel().getCurrentTreePanel()
848 if ( getConfiguration().isUseTabbedDisplay() ) {
849 AptxUtil.printAppletMessage( NAME, "using tabbed display" );
850 AptxUtil.addPhylogeniesToTabs( phys,
851 new File( phys_url.getFile() ).getName(),
857 AptxUtil.printAppletMessage( NAME, "not using tabbed display" );
858 AptxUtil.addPhylogenyToPanel( phys, getConfiguration(), getMainPanel() );
862 getMainPanel().getControlPanel().showWholeAll();
863 getMainPanel().getControlPanel().showWhole();
865 AptxUtil.printAppletMessage( NAME, "successfully initialized" );
867 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().removeAllItems();
868 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
869 .getRelevantSequenceRelationTypes() ) {
870 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().addItem( type );
872 final String default_relation = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_SEQUENCE_RELATION_TYPE );
873 if ( default_relation != null ) {
874 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().setSelectedItem( default_relation );
876 final String default_sequence = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_QUERY_SEQUENCE );
877 if ( default_sequence != null ) {
878 getCurrentTreePanel().getControlPanel().getSequenceRelationBox().setSelectedItem( default_sequence );
884 void initializeTypeMenu( final Options options ) {
885 setTypeMenuToAllUnselected();
887 switch ( options.getPhylogenyGraphicsType() ) {
889 _convex_type_cbmi.setSelected( true );
892 _curved_type_cbmi.setSelected( true );
895 _euro_type_cbmi.setSelected( true );
898 _rounded_type_cbmi.setSelected( true );
901 _triangular_type_cbmi.setSelected( true );
904 _unrooted_type_cbmi.setSelected( true );
907 _circular_type_cbmi.setSelected( true );
910 _rectangular_type_cbmi.setSelected( true );
914 catch ( final NullPointerException np ) {
915 // In all likelihood, this is caused by menu-less display.
919 private boolean isScreenAntialias() {
923 private void removeBranchColors() {
924 if ( getMainPanel().getCurrentPhylogeny() != null ) {
925 AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
929 void setConfiguration( final Configuration configuration ) {
930 _configuration = configuration;
933 private void setMainPanel( final MainPanelApplets main_panel ) {
934 _main_panel = main_panel;
937 void setOptions( final Options options ) {
941 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
942 setTypeMenuToAllUnselected();
946 _circular_type_cbmi.setSelected( true );
949 _convex_type_cbmi.setSelected( true );
952 _curved_type_cbmi.setSelected( true );
955 _euro_type_cbmi.setSelected( true );
958 _rounded_type_cbmi.setSelected( true );
961 _rectangular_type_cbmi.setSelected( true );
964 _triangular_type_cbmi.setSelected( true );
967 _unrooted_type_cbmi.setSelected( true );
970 throw new IllegalArgumentException( "unknown type: " + type );
973 catch ( final NullPointerException np ) {
974 // In all likelihood, this is caused by menu-less display.
978 void setTypeMenuToAllUnselected() {
979 if ( _convex_type_cbmi != null ) {
980 _convex_type_cbmi.setSelected( false );
982 if ( _curved_type_cbmi != null ) {
983 _curved_type_cbmi.setSelected( false );
985 if ( _euro_type_cbmi != null ) {
986 _euro_type_cbmi.setSelected( false );
988 if ( _rounded_type_cbmi != null ) {
989 _rounded_type_cbmi.setSelected( false );
991 if ( _triangular_type_cbmi != null ) {
992 _triangular_type_cbmi.setSelected( false );
994 if ( _rectangular_type_cbmi != null ) {
995 _rectangular_type_cbmi.setSelected( false );
997 if ( _unrooted_type_cbmi != null ) {
998 _unrooted_type_cbmi.setSelected( false );
1000 if ( _circular_type_cbmi != null ) {
1001 _circular_type_cbmi.setSelected( false );
1005 private void setupUI() {
1007 if ( getConfiguration().isUseNativeUI() ) {
1008 UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
1011 UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
1014 catch ( final UnsupportedLookAndFeelException e ) {
1015 AptxUtil.dieWithSystemError( "UnsupportedLookAndFeelException: " + e.toString() );
1017 catch ( final ClassNotFoundException e ) {
1018 AptxUtil.dieWithSystemError( "ClassNotFoundException: " + e.toString() );
1020 catch ( final InstantiationException e ) {
1021 AptxUtil.dieWithSystemError( "InstantiationException: " + e.toString() );
1023 catch ( final IllegalAccessException e ) {
1024 AptxUtil.dieWithSystemError( "IllegalAccessException: " + e.toString() );
1026 catch ( final Exception e ) {
1027 AptxUtil.dieWithSystemError( e.toString() );
1032 public void start() {
1033 if ( getMainPanel() != null ) {
1034 getMainPanel().validate();
1037 requestFocusInWindow();
1039 AptxUtil.printAppletMessage( NAME, "started" );
1042 void switchColors() {
1043 final TreeColorSet colorset = getMainPanel().getCurrentTreePanel().getTreeColorSet();
1044 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
1045 csc.setVisible( true );
1046 getMainPanel().setTreeColorSet( colorset );
1049 void typeChanged( final Object o ) {
1050 updateTypeCheckboxes( getOptions(), o );
1051 updateOptions( getOptions() );
1052 if ( getCurrentTreePanel() != null ) {
1053 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
1054 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
1055 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1056 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
1057 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1058 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
1059 getCurrentTreePanel().getControlPanel().showWhole();
1061 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1062 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
1065 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
1067 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
1068 MainFrame.updateScreenTextAntialias( getMainPanel().getTreePanels() );
1072 void updateOptions( final Options options ) {
1073 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
1074 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
1075 && _background_gradient_cbmi.isSelected() );
1076 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
1077 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
1078 && _abbreviate_scientific_names.isSelected() );
1079 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
1080 && _color_labels_same_as_parent_branch.isSelected() );
1081 options.setShowDefaultNodeShapes( ( _show_default_node_shapes_cbmi != null )
1082 && _show_default_node_shapes_cbmi.isSelected() );
1083 options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null )
1084 && _taxonomy_colorize_node_shapes_cbmi.isSelected() );
1085 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
1086 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
1088 else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
1089 options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1091 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
1092 options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1094 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
1095 && _search_case_senstive_cbmi.isSelected() );
1096 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
1097 options.setShowScale( _show_scale_cbmi.isSelected() );
1099 if ( _label_direction_cbmi != null ) {
1100 if ( _label_direction_cbmi.isSelected() ) {
1101 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1104 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1107 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
1108 options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )
1109 && _show_confidence_stddev_cbmi.isSelected() );
1110 if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
1111 options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
1113 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
1114 && _search_whole_words_only_cbmi.isSelected() );
1115 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
1116 && _inverse_search_result_cbmi.isSelected() );
1117 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
1118 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1120 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
1121 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1123 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
1124 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1126 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
1127 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1129 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
1130 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1132 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
1133 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1135 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
1136 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1138 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
1139 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1143 void updateTypeCheckboxes( final Options options, final Object o ) {
1144 setTypeMenuToAllUnselected();
1145 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
1148 void displayBasicInformation() {
1149 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1150 String title = "Basic Information";
1151 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1152 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1154 showTextFrame( AptxUtil.createBasicInformation( getMainPanel().getCurrentPhylogeny() ), title );
1158 void viewAsNexus() {
1159 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1160 String title = "Nexus";
1161 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1162 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1164 showTextFrame( getMainPanel().getCurrentPhylogeny().toNexus( getOptions()
1165 .getNhConversionSupportValueStyle() ),
1171 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1172 String title = "New Hampshire";
1173 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1174 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1176 showTextFrame( getMainPanel().getCurrentPhylogeny()
1177 .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ),
1183 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1184 String title = "NHX";
1185 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1186 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1188 showTextFrame( getMainPanel().getCurrentPhylogeny().toNewHampshireX(), title );
1193 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1194 String title = "phyloXML";
1195 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1196 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1198 showTextFrame( getMainPanel().getCurrentPhylogeny().toPhyloXML( 0 ), title );
1202 public void showTextFrame( final String s, final String title ) {
1204 _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
1207 void checkTextFrames() {
1208 if ( _textframes.size() > 5 ) {
1210 if ( _textframes.getFirst() != null ) {
1211 _textframes.getFirst().removeMe();
1214 _textframes.removeFirst();
1217 catch ( final NoSuchElementException e ) {
1223 void removeAllTextFrames() {
1224 for( final TextFrame tf : _textframes ) {
1229 _textframes.clear();
1232 static void setupScreenTextAntialias( final List<TreePanel> treepanels, final boolean antialias ) {
1233 for( final TreePanel tree_panel : treepanels ) {
1234 tree_panel.setTextAntialias();