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 == _collapse_species_specific_subtrees ) {
140 if ( getCurrentTreePanel() != null ) {
141 getCurrentTreePanel().collapseSpeciesSpecificSubtrees();
144 else if ( o == _remove_branch_color_item ) {
145 removeBranchColors();
147 else if ( o == _switch_colors_mi ) {
150 else if ( o == _display_basic_information_item ) {
151 displayBasicInformation();
153 else if ( o == _view_as_NH_item ) {
156 else if ( o == _view_as_NHX_item ) {
159 else if ( o == _view_as_XML_item ) {
162 else if ( o == _view_as_nexus_item ) {
165 else if ( o == _super_tiny_fonts_mi ) {
166 if ( getCurrentTreePanel() != null ) {
167 getCurrentTreePanel().setSuperTinyFonts();
168 getCurrentTreePanel().repaint();
171 else if ( o == _tiny_fonts_mi ) {
172 if ( getCurrentTreePanel() != null ) {
173 getCurrentTreePanel().setTinyFonts();
174 getCurrentTreePanel().repaint();
177 else if ( o == _small_fonts_mi ) {
178 if ( getCurrentTreePanel() != null ) {
179 getCurrentTreePanel().setSmallFonts();
180 getCurrentTreePanel().repaint();
183 else if ( o == _medium_fonts_mi ) {
184 if ( getCurrentTreePanel() != null ) {
185 getCurrentTreePanel().setMediumFonts();
186 getCurrentTreePanel().repaint();
189 else if ( o == _large_fonts_mi ) {
190 if ( getCurrentTreePanel() != null ) {
191 getCurrentTreePanel().setLargeFonts();
192 getCurrentTreePanel().repaint();
195 else if ( o == _choose_font_mi ) {
198 else if ( o == _choose_minimal_confidence_mi ) {
199 chooseMinimalConfidence();
201 else if ( o == _choose_node_size_mi ) {
202 MainFrame.chooseNodeSize( getOptions(), this );
204 else if ( o == _overview_placment_mi ) {
205 MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
207 else if ( o == _cycle_node_fill_mi ) {
208 MainFrame.cycleNodeFill( getOptions(), getCurrentTreePanel() );
210 else if ( o == _cycle_node_shape_mi ) {
211 MainFrame.cycleNodeShape( getOptions(), getCurrentTreePanel() );
213 else if ( o == _non_lined_up_cladograms_rbmi ) {
214 updateOptions( getOptions() );
215 _main_panel.getControlPanel().showWhole();
217 else if ( o == _uniform_cladograms_rbmi ) {
218 updateOptions( getOptions() );
219 _main_panel.getControlPanel().showWhole();
221 else if ( o == _ext_node_dependent_cladogram_rbmi ) {
222 updateOptions( getOptions() );
223 _main_panel.getControlPanel().showWhole();
225 else if ( o == _search_case_senstive_cbmi ) {
226 updateOptions( getOptions() );
227 getMainPanel().getControlPanel().search();
229 else if ( o == _search_whole_words_only_cbmi ) {
230 updateOptions( getOptions() );
231 getMainPanel().getControlPanel().search();
233 else if ( o == _inverse_search_result_cbmi ) {
234 updateOptions( getOptions() );
235 getMainPanel().getControlPanel().search();
237 else if ( o == _show_scale_cbmi ) {
238 updateOptions( getOptions() );
240 else if ( o == _show_branch_length_values_cbmi ) {
241 updateOptions( getOptions() );
243 else if ( o == _show_confidence_stddev_cbmi ) {
244 updateOptions( getOptions() );
246 else if ( o == _label_direction_cbmi ) {
247 updateOptions( getOptions() );
249 else if ( o == _show_overview_cbmi ) {
250 updateOptions( getOptions() );
251 if ( getCurrentTreePanel() != null ) {
252 getCurrentTreePanel().updateOvSizes();
255 else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
256 || ( o == _convex_type_cbmi ) || ( o == _rounded_type_cbmi ) || ( o == _euro_type_cbmi )
257 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
260 else if ( o == _screen_antialias_cbmi ) {
261 updateOptions( getOptions() );
262 setupScreenTextAntialias( getMainPanel().getTreePanels(), isScreenAntialias() );
264 else if ( o == _background_gradient_cbmi ) {
265 updateOptions( getOptions() );
267 else if ( o == _show_domain_labels ) {
268 updateOptions( getOptions() );
270 else if ( o == _color_labels_same_as_parent_branch ) {
271 updateOptions( getOptions() );
273 else if ( o == _show_default_node_shapes_cbmi ) {
274 updateOptions( getOptions() );
276 else if ( o == _taxonomy_colorize_node_shapes_cbmi ) {
277 updateOptions( getOptions() );
279 else if ( o == _about_item ) {
282 else if ( o == _help_item ) {
283 help( getConfiguration().getWebLinks() );
285 else if ( o == _website_item ) {
287 AptxUtil.openWebsite( Constants.APTX_WEB_SITE, true, this );
289 catch ( final IOException e1 ) {
290 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
293 else if ( o == _phyloxml_website_item ) {
295 AptxUtil.openWebsite( Constants.PHYLOXML_WEB_SITE, true, this );
297 catch ( final IOException e1 ) {
298 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
301 else if ( o == _aptx_ref_item ) {
303 AptxUtil.openWebsite( Constants.APTX_REFERENCE_URL, true, this );
305 catch ( final IOException e1 ) {
306 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
309 else if ( o == _phyloxml_ref_item ) {
311 AptxUtil.openWebsite( Constants.PHYLOXML_REFERENCE_URL, true, this );
313 catch ( final IOException e1 ) {
314 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
320 void help( final Map<String, WebLink> weblinks ) {
321 final StringBuilder sb = new StringBuilder();
322 sb.append( "Display options\n" );
323 sb.append( "-------------------\n" );
324 sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
325 sb.append( "Clickable tree nodes\n" );
326 sb.append( "--------------------\n" );
327 sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
328 sb.append( "or by right clicking:\n" );
329 sb.append( "o Display Node Data -- display information for a node\n" );
330 sb.append( "o Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
331 sb.append( "o Root/Reroot -- change tree root to clicked node\n" );
332 sb.append( "o Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
333 sb.append( "o Swap Descendants -- switch descendant on either side of clicked node\n" );
334 sb.append( "o Colorize Subtree -- color a subtree\n" );
335 sb.append( "o Open Sequence Web -- launch a web browser to display sequence information\n" );
336 sb.append( "o Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
337 sb.append( "- there may be additional choices depending on this particular setup\n\n" );
338 sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
339 sb.append( "Zooming\n" );
340 sb.append( "---------\n" );
341 sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
342 sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
343 sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
344 sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
345 sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
346 sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
347 sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
348 sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
349 sb.append( "Quick tree manipulation:\n" );
350 sb.append( "------------------------\n" );
351 sb.append( "Order Subtrees -- order the tree by branch length\n" );
352 sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
353 sb.append( "Memory problems (Java heap space error)\n" );
354 sb.append( "---------------------------------------\n" );
355 sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
356 sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
357 sb.append( "the '-Xmx' Java command line option. For example:\n" );
358 sb.append( "java -Xms32m -Xmx256m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
359 if ( ( weblinks != null ) && ( weblinks.size() > 0 ) ) {
360 sb.append( "Active web links\n" );
361 sb.append( "--------------------\n" );
362 for( final String key : weblinks.keySet() ) {
363 sb.append( " " + weblinks.get( key ).toString() + "\n" );
367 sb.append( "phyloXML\n" );
368 sb.append( "-------------------\n" );
369 sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
370 sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
371 sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
373 sb.append( "For more information: http://www.phylosoft.org/archaeopteryx/\n" );
374 sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
375 TextFrame.instantiate( sb.toString(), "Help", _textframes );
378 void setCurrentExternalNodesDataBuffer( final String s ) {
379 if ( !ForesterUtil.isEmpty( s ) ) {
380 _ext_node_data_buffer = s.trim();
383 _ext_node_data_buffer = "";
388 * This method returns the current external node data which
389 * has been selected by the user by clicking the "Return ..."
390 * menu item. This method is expected to be called from Javascript or
393 * @return current external node data as String
395 public String getCurrentExternalNodesDataBuffer() {
396 return _ext_node_data_buffer;
400 * This method returns the current phylogeny as a string in the chosen format
402 * @param format must be NH, NHX, NEXUS or PHYLOXML
403 * @return the phylogeny string
404 * @author Herve Menager
406 public String getCurrentPhylogeny( final String format ) {
407 removeAllTextFrames();
408 if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty()
409 || ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
412 switch ( ForesterConstants.PhylogeneticTreeFormats.valueOf( format ) ) {
414 return getMainPanel().getCurrentPhylogeny().toNewHampshire();
416 return getMainPanel().getCurrentPhylogeny().toNewHampshireX();
418 return getMainPanel().getCurrentPhylogeny().toNexus();
420 return getMainPanel().getCurrentPhylogeny().toPhyloXML( -1 );
428 * This method returns a view of the current phylogeny in a chosen
429 * graphics format, base64-encoded in a string so that in can be used
432 * @param format must be GraphicsExportType (gif, jpg, pdf, png, tif, bmp)
433 * @return the phylogeny string
434 * @author Herve Menager
436 public String getCurrentPhylogenyGraphicsAsBase64EncodedString( final String format ) {
437 final ByteArrayOutputStream baos = new ByteArrayOutputStream();
439 AptxUtil.writePhylogenyToGraphicsByteArrayOutputStream( baos,
440 _main_panel.getWidth(),
441 _main_panel.getHeight(),
442 getCurrentTreePanel(),
443 getCurrentTreePanel().getControlPanel(),
444 GraphicsExportType.valueOf( format ),
447 catch ( final IOException ioe ) {
448 ForesterUtil.printErrorMessage( NAME, ioe.toString() );
449 ioe.printStackTrace();
450 JOptionPane.showMessageDialog( this,
451 NAME + ": Failed to generate graphics: " + "\nException: " + ioe,
452 "Failed to generate graphics",
453 JOptionPane.ERROR_MESSAGE );
456 final byte[] bytes = baos.toByteArray();
457 final String dataImg = Base64.encodeBase64String( bytes );
461 void buildFontSizeMenu() {
462 _font_size_menu = MainFrame.createMenu( MainFrame.FONT_SIZE_MENU_LABEL, getConfiguration() );
463 _font_size_menu.add( _super_tiny_fonts_mi = new JMenuItem( "Super tiny fonts" ) );
464 _font_size_menu.add( _tiny_fonts_mi = new JMenuItem( "Tiny fonts" ) );
465 _font_size_menu.add( _small_fonts_mi = new JMenuItem( "Small fonts" ) );
466 _font_size_menu.add( _medium_fonts_mi = new JMenuItem( "Medium fonts" ) );
467 _font_size_menu.add( _large_fonts_mi = new JMenuItem( "Large fonts" ) );
468 customizeJMenuItem( _super_tiny_fonts_mi );
469 customizeJMenuItem( _tiny_fonts_mi );
470 customizeJMenuItem( _small_fonts_mi );
471 customizeJMenuItem( _medium_fonts_mi );
472 customizeJMenuItem( _large_fonts_mi );
473 _jmenubar.add( _font_size_menu );
476 void buildHelpMenu() {
477 _help_jmenu = MainFrame.createMenu( "Help", getConfiguration() );
478 _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
479 _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
480 _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
481 _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
482 _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
483 _help_jmenu.addSeparator();
484 _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
485 customizeJMenuItem( _help_item );
486 customizeJMenuItem( _website_item );
487 customizeJMenuItem( _phyloxml_website_item );
488 customizeJMenuItem( _aptx_ref_item );
489 customizeJMenuItem( _phyloxml_ref_item );
490 customizeJMenuItem( _about_item );
491 _phyloxml_ref_item.setToolTipText( MainFrame.PHYLOXML_REF_TOOL_TIP );
492 _aptx_ref_item.setToolTipText( MainFrame.APTX_REF_TOOL_TIP );
493 _jmenubar.add( _help_jmenu );
496 void buildOptionsMenu() {
497 _options_jmenu = MainFrame.createMenu( MainFrame.OPTIONS_HEADER, getConfiguration() );
498 _options_jmenu.addChangeListener( new ChangeListener() {
501 public void stateChanged( final ChangeEvent e ) {
502 MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getOptions() );
503 MainFrame.setTextColorChooseMenuItem( _switch_colors_mi, getCurrentTreePanel() );
505 .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() );
506 MainFrame.setTextForFontChooserMenuItem( _choose_font_mi, MainFrame
507 .createCurrentFontDesc( getMainPanel().getTreeFontSet() ) );
508 MainFrame.updateOptionsMenuDependingOnPhylogenyType( getMainPanel(),
510 _show_branch_length_values_cbmi,
511 _non_lined_up_cladograms_rbmi,
512 _uniform_cladograms_rbmi,
513 _ext_node_dependent_cladogram_rbmi,
514 _label_direction_cbmi );
515 MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() );
516 MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() );
517 MainFrame.setTextNodeSizeMenuItem( _choose_node_size_mi, getOptions() );
520 _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.DISPLAY_SUBHEADER ),
521 getConfiguration() ) );
523 .add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );
524 _options_jmenu.add( _uniform_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.UNIFORM_CLADOGRAMS_LABEL ) );
526 .add( _non_lined_up_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.NON_LINED_UP_CLADOGRAMS_LABEL ) );
527 _radio_group_1 = new ButtonGroup();
528 _radio_group_1.add( _ext_node_dependent_cladogram_rbmi );
529 _radio_group_1.add( _uniform_cladograms_rbmi );
530 _radio_group_1.add( _non_lined_up_cladograms_rbmi );
531 _options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_OVERVIEW_LABEL ) );
532 _options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_SCALE_LABEL ) );
534 .add( _show_branch_length_values_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_BRANCH_LENGTH_VALUES_LABEL ) );
535 _options_jmenu.add( _show_confidence_stddev_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_CONF_STDDEV_LABEL ) );
537 .add( _show_default_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL ) );
539 .add( _taxonomy_colorize_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.TAXONOMY_COLORIZE_NODE_SHAPES_LABEL ) );
540 _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL ) );
541 _options_jmenu.add( _cycle_node_fill_mi = new JMenuItem( MainFrame.CYCLE_NODE_FILL_LABEL ) );
542 _options_jmenu.add( _choose_node_size_mi = new JMenuItem( MainFrame.CHOOSE_NODE_SIZE_LABEL ) );
543 _options_jmenu.add( _label_direction_cbmi = new JCheckBoxMenuItem( MainFrame.LABEL_DIRECTION_LABEL ) );
545 .add( _color_labels_same_as_parent_branch = new JCheckBoxMenuItem( MainFrame.COLOR_LABELS_LABEL ) );
546 _color_labels_same_as_parent_branch.setToolTipText( MainFrame.COLOR_LABELS_TIP );
547 _options_jmenu.add( _abbreviate_scientific_names = new JCheckBoxMenuItem( MainFrame.ABBREV_SN_LABEL ) );
548 _label_direction_cbmi.setToolTipText( MainFrame.LABEL_DIRECTION_TIP );
549 _options_jmenu.add( _screen_antialias_cbmi = new JCheckBoxMenuItem( MainFrame.SCREEN_ANTIALIAS_LABEL ) );
550 _options_jmenu.add( _background_gradient_cbmi = new JCheckBoxMenuItem( MainFrame.BG_GRAD_LABEL ) );
551 if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
552 _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( MainFrame.SHOW_DOMAIN_LABELS_LABEL ) );
554 _options_jmenu.add( _choose_minimal_confidence_mi = new JMenuItem( "" ) );
555 _options_jmenu.add( _overview_placment_mi = new JMenuItem( "" ) );
556 _options_jmenu.add( _switch_colors_mi = new JMenuItem( "" ) );
557 _options_jmenu.add( _choose_font_mi = new JMenuItem( "" ) );
558 _options_jmenu.addSeparator();
559 _options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.SEARCH_SUBHEADER ),
560 getConfiguration() ) );
562 .add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_CASE_SENSITIVE_LABEL ) );
563 _options_jmenu.add( _search_whole_words_only_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_TERMS_ONLY_LABEL ) );
565 .add( _inverse_search_result_cbmi = new JCheckBoxMenuItem( MainFrame.INVERSE_SEARCH_RESULT_LABEL ) );
566 customizeJMenuItem( _choose_font_mi );
567 customizeJMenuItem( _choose_minimal_confidence_mi );
568 customizeJMenuItem( _switch_colors_mi );
569 customizeJMenuItem( _overview_placment_mi );
570 customizeCheckBoxMenuItem( _label_direction_cbmi,
571 getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL );
572 customizeCheckBoxMenuItem( _screen_antialias_cbmi, getOptions().isAntialiasScreen() );
573 customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );
574 customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );
575 customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );
576 customizeCheckBoxMenuItem( _show_default_node_shapes_cbmi, getOptions().isShowDefaultNodeShapes() );
577 customizeCheckBoxMenuItem( _taxonomy_colorize_node_shapes_cbmi, getOptions().isTaxonomyColorizeNodeShapes() );
578 customizeJMenuItem( _cycle_node_shape_mi );
579 customizeJMenuItem( _cycle_node_fill_mi );
580 customizeJMenuItem( _choose_node_size_mi );
581 customizeCheckBoxMenuItem( _color_labels_same_as_parent_branch, getOptions().isColorLabelsSameAsParentBranch() );
582 customizeCheckBoxMenuItem( _search_case_senstive_cbmi, getOptions().isSearchCaseSensitive() );
583 customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );
584 customizeRadioButtonMenuItem( _non_lined_up_cladograms_rbmi,
585 getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP );
586 customizeRadioButtonMenuItem( _uniform_cladograms_rbmi,
587 getOptions().getCladogramType() == CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
588 customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi,
589 getOptions().getCladogramType() == CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
590 customizeCheckBoxMenuItem( _show_branch_length_values_cbmi, getOptions().isShowBranchLengthValues() );
591 customizeCheckBoxMenuItem( _show_overview_cbmi, getOptions().isShowOverview() );
592 customizeCheckBoxMenuItem( _search_whole_words_only_cbmi, getOptions().isMatchWholeTermsOnly() );
593 customizeCheckBoxMenuItem( _inverse_search_result_cbmi, getOptions().isInverseSearchResult() );
594 customizeCheckBoxMenuItem( _show_confidence_stddev_cbmi, getOptions().isShowConfidenceStddev() );
595 _jmenubar.add( _options_jmenu );
598 void buildToolsMenu() {
599 _tools_menu = MainFrame.createMenu( "Tools", getConfiguration() );
600 _tools_menu.add( _confcolor_item = new JMenuItem( "Colorize Branches Depending on Confidence" ) );
601 customizeJMenuItem( _confcolor_item );
602 _tools_menu.add( _taxcolor_item = new JMenuItem( "Taxonomy Colorize Branches" ) );
603 customizeJMenuItem( _taxcolor_item );
604 _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete Branch Colors" ) );
605 _remove_branch_color_item.setToolTipText( "To delete branch color values from the current phylogeny." );
606 customizeJMenuItem( _remove_branch_color_item );
607 _tools_menu.addSeparator();
608 _tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) );
609 customizeJMenuItem( _midpoint_root_item );
610 _tools_menu.addSeparator();
612 .add( _infer_common_sn_names_item = new JMenuItem( "Infer Common Parts of Internal Scientific Names" ) );
613 customizeJMenuItem( _infer_common_sn_names_item );
614 _tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Species-Specific Subtrees" ) );
615 customizeJMenuItem( _collapse_species_specific_subtrees );
616 _jmenubar.add( _tools_menu );
619 void buildTypeMenu() {
620 _type_menu = MainFrame.createMenu( MainFrame.TYPE_MENU_HEADER, getConfiguration() );
621 _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
622 _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
623 _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
624 _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
625 _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
626 _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
627 _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
628 _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
629 customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
630 customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
631 customizeCheckBoxMenuItem( _euro_type_cbmi, false );
632 customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
633 customizeCheckBoxMenuItem( _curved_type_cbmi, false );
634 customizeCheckBoxMenuItem( _convex_type_cbmi, false );
635 customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
636 customizeCheckBoxMenuItem( _circular_type_cbmi, false );
637 _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
638 _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
639 initializeTypeMenu( getOptions() );
640 _jmenubar.add( _type_menu );
643 void buildViewMenu() {
644 _view_jmenu = MainFrame.createMenu( "View", getConfiguration() );
645 _view_jmenu.add( _display_basic_information_item = new JMenuItem( "Display Basic Information" ) );
646 _view_jmenu.addSeparator();
647 _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) );
648 _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) );
649 _view_jmenu.add( _view_as_NHX_item = new JMenuItem( "View as NHX" ) );
650 _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "View as Nexus" ) );
651 customizeJMenuItem( _display_basic_information_item );
652 customizeJMenuItem( _view_as_NH_item );
653 customizeJMenuItem( _view_as_NHX_item );
654 customizeJMenuItem( _view_as_XML_item );
655 customizeJMenuItem( _view_as_nexus_item );
656 _jmenubar.add( _view_jmenu );
659 private void chooseFont() {
660 final FontChooser fc = new FontChooser();
661 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
662 fc.showDialog( this, "Select the Base Font" );
663 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
666 private void chooseMinimalConfidence() {
667 final String s = ( String ) JOptionPane
668 .showInputDialog( this,
669 "Please the minimum for confidence values to be displayed.\n" + "[current value: "
670 + getOptions().getMinConfidenceValue() + "]\n",
671 "Minimal Confidence Value",
672 JOptionPane.QUESTION_MESSAGE,
675 getOptions().getMinConfidenceValue() );
676 if ( !ForesterUtil.isEmpty( s ) ) {
677 boolean success = true;
679 final String m_str = s.trim();
680 if ( !ForesterUtil.isEmpty( m_str ) ) {
682 m = Double.parseDouble( m_str );
684 catch ( final Exception ex ) {
691 if ( success && ( m >= 0.0 ) ) {
692 getOptions().setMinConfidenceValue( m );
697 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
698 if ( item != null ) {
699 item.setFont( MainFrame.menu_font );
700 if ( !getConfiguration().isUseNativeUI() ) {
701 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
702 item.setForeground( getConfiguration().getGuiMenuTextColor() );
704 item.setSelected( is_selected );
705 item.addActionListener( this );
709 void customizeJMenuItem( final JMenuItem jmi ) {
710 jmi.setFont( MainFrame.menu_font );
711 if ( !getConfiguration().isUseNativeUI() ) {
712 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
713 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
715 jmi.addActionListener( this );
718 private void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
719 if ( item != null ) {
720 item.setFont( MainFrame.menu_font );
721 if ( !getConfiguration().isUseNativeUI() ) {
722 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
723 item.setForeground( getConfiguration().getGuiMenuTextColor() );
725 item.setSelected( is_selected );
726 item.addActionListener( this );
731 public void destroy() {
732 AptxUtil.printAppletMessage( NAME, "going to be destroyed " );
733 removeAllTextFrames();
734 if ( getMainPanel() != null ) {
735 getMainPanel().terminate();
739 Configuration getConfiguration() {
740 return _configuration;
743 TreePanel getCurrentTreePanel() {
744 return getMainPanel().getCurrentTreePanel();
747 JCheckBoxMenuItem getlabelDirectionCbmi() {
748 return _label_direction_cbmi;
751 private MainPanel getMainPanel() {
755 public Options getOptions() {
759 Options getOtions() {
765 final String config_filename = getParameter( Constants.APPLET_PARAM_NAME_FOR_CONFIG_FILE_URL );
766 AptxUtil.printAppletMessage( NAME, "URL for configuration file is: " + config_filename );
767 final Configuration configuration = new Configuration( config_filename, true, true, true );
768 setConfiguration( configuration );
769 setOptions( Options.createInstance( configuration ) );
772 Phylogeny[] phys = null;
773 final String phys_url_string = getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD );
774 AptxUtil.printAppletMessage( NAME, "URL for phylogenies is " + phys_url_string );
775 // Get URL to tree file
776 if ( phys_url_string != null ) {
778 phys_url = new URL( phys_url_string );
780 catch ( final Exception e ) {
781 ForesterUtil.printErrorMessage( NAME, "error: " + e );
783 JOptionPane.showMessageDialog( this, NAME + ": Could not create URL from: \"" + phys_url_string
784 + "\"\nException: " + e, "Failed to create URL", JOptionPane.ERROR_MESSAGE );
787 // Load the tree from URL
788 if ( phys_url != null ) {
790 phys = AptxUtil.readPhylogeniesFromUrl( phys_url,
791 getConfiguration().isValidatePhyloXmlAgainstSchema(),
792 getConfiguration().isReplaceUnderscoresInNhParsing(),
793 getConfiguration().isInternalNumberAreConfidenceForNhParsing(),
794 getConfiguration().getTaxonomyExtraction() );
796 catch ( final Exception e ) {
797 ForesterUtil.printErrorMessage( NAME, e.toString() );
799 JOptionPane.showMessageDialog( this,
800 NAME + ": Failed to read phylogenies: " + "\nException: " + e,
801 "Failed to read phylogenies",
802 JOptionPane.ERROR_MESSAGE );
805 if ( ( phys == null ) || ( phys.length < 1 ) ) {
806 ForesterUtil.printErrorMessage( NAME, "phylogenies from [" + phys_url + "] are null or empty" );
807 JOptionPane.showMessageDialog( this,
808 NAME + ": phylogenies from [" + phys_url + "] are null or empty",
809 "Failed to read phylogenies",
810 JOptionPane.ERROR_MESSAGE );
814 AptxUtil.printAppletMessage( NAME, "loaded " + phys.length + " phylogenies from: " + phys_url );
817 setMainPanel( new MainPanelApplets( getConfiguration(), this ) );
818 _jmenubar = new JMenuBar();
819 if ( !getConfiguration().isHideControlPanelAndMenubar() ) {
820 if ( !getConfiguration().isUseNativeUI() ) {
821 _jmenubar.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
829 setJMenuBar( _jmenubar );
831 final Container contentpane = getContentPane();
832 contentpane.setLayout( new BorderLayout() );
833 contentpane.add( getMainPanel(), BorderLayout.CENTER );
834 addComponentListener( new ComponentAdapter() {
837 public void componentResized( final ComponentEvent e ) {
838 if ( getMainPanel().getCurrentTreePanel() != null ) {
839 getMainPanel().getCurrentTreePanel().setParametersForPainting( getMainPanel().getCurrentTreePanel()
841 getMainPanel().getCurrentTreePanel()
847 if ( getConfiguration().isUseTabbedDisplay() ) {
848 AptxUtil.printAppletMessage( NAME, "using tabbed display" );
849 AptxUtil.addPhylogeniesToTabs( phys,
850 new File( phys_url.getFile() ).getName(),
856 AptxUtil.printAppletMessage( NAME, "not using tabbed display" );
857 AptxUtil.addPhylogenyToPanel( phys, getConfiguration(), getMainPanel() );
861 getMainPanel().getControlPanel().showWholeAll();
862 getMainPanel().getControlPanel().showWhole();
864 AptxUtil.printAppletMessage( NAME, "successfully initialized" );
866 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().removeAllItems();
867 for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
868 .getRelevantSequenceRelationTypes() ) {
869 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().addItem( type );
871 final String default_relation = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_SEQUENCE_RELATION_TYPE );
872 if ( default_relation != null ) {
873 getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().setSelectedItem( default_relation );
875 final String default_sequence = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_QUERY_SEQUENCE );
876 if ( default_sequence != null ) {
877 getCurrentTreePanel().getControlPanel().getSequenceRelationBox().setSelectedItem( default_sequence );
883 void initializeTypeMenu( final Options options ) {
884 setTypeMenuToAllUnselected();
886 switch ( options.getPhylogenyGraphicsType() ) {
888 _convex_type_cbmi.setSelected( true );
891 _curved_type_cbmi.setSelected( true );
894 _euro_type_cbmi.setSelected( true );
897 _rounded_type_cbmi.setSelected( true );
900 _triangular_type_cbmi.setSelected( true );
903 _unrooted_type_cbmi.setSelected( true );
906 _circular_type_cbmi.setSelected( true );
909 _rectangular_type_cbmi.setSelected( true );
913 catch ( final NullPointerException np ) {
914 // In all likelihood, this is caused by menu-less display.
918 private boolean isScreenAntialias() {
922 private void removeBranchColors() {
923 if ( getMainPanel().getCurrentPhylogeny() != null ) {
924 AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
928 void setConfiguration( final Configuration configuration ) {
929 _configuration = configuration;
932 private void setMainPanel( final MainPanelApplets main_panel ) {
933 _main_panel = main_panel;
936 void setOptions( final Options options ) {
940 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
941 setTypeMenuToAllUnselected();
945 _circular_type_cbmi.setSelected( true );
948 _convex_type_cbmi.setSelected( true );
951 _curved_type_cbmi.setSelected( true );
954 _euro_type_cbmi.setSelected( true );
957 _rounded_type_cbmi.setSelected( true );
960 _rectangular_type_cbmi.setSelected( true );
963 _triangular_type_cbmi.setSelected( true );
966 _unrooted_type_cbmi.setSelected( true );
969 throw new IllegalArgumentException( "unknown type: " + type );
972 catch ( final NullPointerException np ) {
973 // In all likelihood, this is caused by menu-less display.
977 void setTypeMenuToAllUnselected() {
978 if ( _convex_type_cbmi != null ) {
979 _convex_type_cbmi.setSelected( false );
981 if ( _curved_type_cbmi != null ) {
982 _curved_type_cbmi.setSelected( false );
984 if ( _euro_type_cbmi != null ) {
985 _euro_type_cbmi.setSelected( false );
987 if ( _rounded_type_cbmi != null ) {
988 _rounded_type_cbmi.setSelected( false );
990 if ( _triangular_type_cbmi != null ) {
991 _triangular_type_cbmi.setSelected( false );
993 if ( _rectangular_type_cbmi != null ) {
994 _rectangular_type_cbmi.setSelected( false );
996 if ( _unrooted_type_cbmi != null ) {
997 _unrooted_type_cbmi.setSelected( false );
999 if ( _circular_type_cbmi != null ) {
1000 _circular_type_cbmi.setSelected( false );
1004 private void setupUI() {
1006 if ( getConfiguration().isUseNativeUI() ) {
1007 UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
1010 UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
1013 catch ( final UnsupportedLookAndFeelException e ) {
1014 AptxUtil.dieWithSystemError( "UnsupportedLookAndFeelException: " + e.toString() );
1016 catch ( final ClassNotFoundException e ) {
1017 AptxUtil.dieWithSystemError( "ClassNotFoundException: " + e.toString() );
1019 catch ( final InstantiationException e ) {
1020 AptxUtil.dieWithSystemError( "InstantiationException: " + e.toString() );
1022 catch ( final IllegalAccessException e ) {
1023 AptxUtil.dieWithSystemError( "IllegalAccessException: " + e.toString() );
1025 catch ( final Exception e ) {
1026 AptxUtil.dieWithSystemError( e.toString() );
1031 public void start() {
1032 if ( getMainPanel() != null ) {
1033 getMainPanel().validate();
1036 requestFocusInWindow();
1038 AptxUtil.printAppletMessage( NAME, "started" );
1041 void switchColors() {
1042 final TreeColorSet colorset = getMainPanel().getCurrentTreePanel().getTreeColorSet();
1043 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
1044 csc.setVisible( true );
1045 getMainPanel().setTreeColorSet( colorset );
1048 void typeChanged( final Object o ) {
1049 updateTypeCheckboxes( getOptions(), o );
1050 updateOptions( getOptions() );
1051 if ( getCurrentTreePanel() != null ) {
1052 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
1053 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
1054 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1055 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
1056 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1057 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
1058 getCurrentTreePanel().getControlPanel().showWhole();
1060 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1061 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
1064 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
1066 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
1067 MainFrame.updateScreenTextAntialias( getMainPanel().getTreePanels() );
1071 void updateOptions( final Options options ) {
1072 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
1073 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
1074 && _background_gradient_cbmi.isSelected() );
1075 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
1076 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
1077 && _abbreviate_scientific_names.isSelected() );
1078 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
1079 && _color_labels_same_as_parent_branch.isSelected() );
1080 options.setShowDefaultNodeShapes( ( _show_default_node_shapes_cbmi != null )
1081 && _show_default_node_shapes_cbmi.isSelected() );
1082 options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null )
1083 && _taxonomy_colorize_node_shapes_cbmi.isSelected() );
1084 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
1085 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
1087 else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
1088 options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1090 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
1091 options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1093 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
1094 && _search_case_senstive_cbmi.isSelected() );
1095 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
1096 options.setShowScale( _show_scale_cbmi.isSelected() );
1098 if ( _label_direction_cbmi != null ) {
1099 if ( _label_direction_cbmi.isSelected() ) {
1100 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1103 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1106 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
1107 options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )
1108 && _show_confidence_stddev_cbmi.isSelected() );
1109 if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
1110 options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
1112 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
1113 && _search_whole_words_only_cbmi.isSelected() );
1114 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
1115 && _inverse_search_result_cbmi.isSelected() );
1116 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
1117 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1119 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
1120 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1122 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
1123 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1125 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
1126 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1128 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
1129 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1131 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
1132 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1134 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
1135 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1137 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
1138 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1142 void updateTypeCheckboxes( final Options options, final Object o ) {
1143 setTypeMenuToAllUnselected();
1144 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
1147 void displayBasicInformation() {
1148 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1149 String title = "Basic Information";
1150 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1151 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1153 showTextFrame( AptxUtil.createBasicInformation( getMainPanel().getCurrentPhylogeny() ), title );
1157 void viewAsNexus() {
1158 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1159 String title = "Nexus";
1160 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1161 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1163 showTextFrame( getMainPanel().getCurrentPhylogeny().toNexus( getOptions()
1164 .getNhConversionSupportValueStyle() ),
1170 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1171 String title = "New Hampshire";
1172 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1173 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1175 showTextFrame( getMainPanel().getCurrentPhylogeny()
1176 .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ),
1182 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1183 String title = "NHX";
1184 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1185 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1187 showTextFrame( getMainPanel().getCurrentPhylogeny().toNewHampshireX(), title );
1192 if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
1193 String title = "phyloXML";
1194 if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
1195 title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
1197 showTextFrame( getMainPanel().getCurrentPhylogeny().toPhyloXML( 0 ), title );
1201 public void showTextFrame( final String s, final String title ) {
1203 _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
1206 void checkTextFrames() {
1207 if ( _textframes.size() > 5 ) {
1209 if ( _textframes.getFirst() != null ) {
1210 _textframes.getFirst().removeMe();
1213 _textframes.removeFirst();
1216 catch ( final NoSuchElementException e ) {
1222 void removeAllTextFrames() {
1223 for( final TextFrame tf : _textframes ) {
1228 _textframes.clear();
1231 static void setupScreenTextAntialias( final List<TreePanel> treepanels, final boolean antialias ) {
1232 for( final TreePanel tree_panel : treepanels ) {
1233 tree_panel.setTextAntialias();