2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2010 Christian M. Zmasek
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 // Contact: phylosoft @ gmail . com
23 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
25 package org.forester.archaeopteryx;
27 import java.awt.Color;
28 import java.awt.Component;
29 import java.awt.Container;
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
33 import java.io.IOException;
34 import java.util.LinkedList;
35 import java.util.List;
36 import java.util.Locale;
37 import java.util.NoSuchElementException;
40 import javax.swing.Box;
41 import javax.swing.JApplet;
42 import javax.swing.JCheckBoxMenuItem;
43 import javax.swing.JFrame;
44 import javax.swing.JLabel;
45 import javax.swing.JMenu;
46 import javax.swing.JMenuBar;
47 import javax.swing.JMenuItem;
48 import javax.swing.JOptionPane;
49 import javax.swing.JPanel;
50 import javax.swing.JRadioButtonMenuItem;
51 import javax.swing.JTextField;
52 import javax.swing.SwingUtilities;
54 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
55 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
56 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
57 import org.forester.archaeopteryx.tools.InferenceManager;
58 import org.forester.archaeopteryx.tools.ProcessPool;
59 import org.forester.archaeopteryx.tools.ProcessRunning;
60 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
61 import org.forester.phylogeny.Phylogeny;
62 import org.forester.phylogeny.PhylogenyMethods;
63 import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
64 import org.forester.phylogeny.PhylogenyNode;
65 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
66 import org.forester.phylogeny.data.Annotation;
67 import org.forester.phylogeny.data.NodeVisualization.NodeFill;
68 import org.forester.phylogeny.data.NodeVisualization.NodeShape;
69 import org.forester.sdi.GSDI;
70 import org.forester.sdi.GSDIR;
71 import org.forester.sdi.SDIException;
72 import org.forester.util.ForesterConstants;
73 import org.forester.util.ForesterUtil;
75 public abstract class MainFrame extends JFrame implements ActionListener {
77 static final String USE_MOUSEWHEEL_SHIFT_TO_ROTATE = "In this display type, use mousewheel + Shift to rotate [or A and S]";
78 static final String PHYLOXML_REF_TOOL_TIP = Constants.PHYLOXML_REFERENCE; //TODO //FIXME
79 static final String APTX_REF_TOOL_TIP = Constants.APTX_REFERENCE;
80 private static final long serialVersionUID = 3655000897845508358L;
81 final static Font menu_font = new Font( Configuration.getDefaultFontFamilyName(),
84 static final String TYPE_MENU_HEADER = "Type";
85 static final String RECTANGULAR_TYPE_CBMI_LABEL = "Rectangular";
86 static final String EURO_TYPE_CBMI_LABEL = "Euro Type";
87 static final String CURVED_TYPE_CBMI_LABEL = "Curved";
88 static final String TRIANGULAR_TYPE_CBMI_LABEL = "Triangular";
89 static final String CONVEX_TYPE_CBMI_LABEL = "Convex";
90 static final String ROUNDED_TYPE_CBMI_LABEL = "Rounded";
91 static final String UNROOTED_TYPE_CBMI_LABEL = "Unrooted (alpha)"; //TODO
92 static final String CIRCULAR_TYPE_CBMI_LABEL = "Circular (alpha)"; //TODO
93 static final String OPTIONS_HEADER = "Options";
94 static final String SEARCH_SUBHEADER = "Search:";
95 static final String DISPLAY_SUBHEADER = "Display:";
96 static final String SEARCH_TERMS_ONLY_LABEL = "Match Complete Terms Only";
97 static final String SEARCH_CASE_SENSITIVE_LABEL = "Case Sensitive";
98 static final String INVERSE_SEARCH_RESULT_LABEL = "Negate Result";
99 static final String DISPLAY_BRANCH_LENGTH_VALUES_LABEL = "Display Branch Length Values";
100 static final String DISPLAY_SCALE_LABEL = "Display Scale";
101 static final String NON_LINED_UP_CLADOGRAMS_LABEL = "Non-Lined Up Cladograms";
102 static final String UNIFORM_CLADOGRAMS_LABEL = "Total Node Sum Dependent Cladograms";
103 static final String LABEL_DIRECTION_LABEL = "Radial Labels";
104 static final String LABEL_DIRECTION_TIP = "To use radial node labels in radial and unrooted display types";
105 static final String SCREEN_ANTIALIAS_LABEL = "Antialias";
106 static final String COLOR_LABELS_LABEL = "Colorize Labels Same as Parent Branch";
107 static final String BG_GRAD_LABEL = "Background Color Gradient";
108 static final String DISPLAY_NODE_BOXES_LABEL_EXT = "Show External Node Shapes";
109 static final String DISPLAY_NODE_BOXES_LABEL_INT = "Show Internal Node Shapes";
110 static final String SHOW_OVERVIEW_LABEL = "Show Overview";
111 static final String FONT_SIZE_MENU_LABEL = "Font Size";
112 static final String NONUNIFORM_CLADOGRAMS_LABEL = "External Node Sum Dependent Cladograms";
113 static final String SHOW_DOMAIN_LABELS_LABEL = "Show Domain Labels";
114 static final String SHOW_ANN_REF_SOURCE_LABEL = "Show Seq Annotation Ref Sources";
115 static final String COLOR_LABELS_TIP = "To use parent branch colors for node labels as well, need to turn off taxonomy dependent colorization and turn on branch colorization for this to become apparent";
116 static final String ABBREV_SN_LABEL = "Abbreviate Scientific Taxonomic Names";
117 static final String TAXONOMY_COLORIZE_NODE_SHAPES_LABEL = "Colorize Node Shapes According to Taxonomy";
118 static final String CYCLE_NODE_SHAPE_LABEL = "Cycle Node Shapes";
119 static final String CYCLE_NODE_FILL_LABEL = "Cycle Node Fill Type";
120 static final String CHOOSE_NODE_SIZE_LABEL = "Choose Node Shape Size";
121 static final String SHOW_CONF_STDDEV_LABEL = "Show Confidence Standard Deviations";
122 static final String USE_BRACKETS_FOR_CONF_IN_NH_LABEL = "Use Brackets for Confidence Values";
123 static final String USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL = "Use Internal Node Names for Confidence Values";
124 static final String SHOW_BASIC_TREE_INFORMATION_LABEL = "Show Basic Tree Information";
129 JMenu _options_jmenu;
130 JMenu _font_size_menu;
132 JMenuItem[] _load_phylogeny_from_webservice_menu_items;
134 JMenu _analysis_menu;
135 JMenuItem _load_species_tree_item;
136 JMenuItem _gsdi_item;
137 JMenuItem _gsdir_item;
138 JMenuItem _lineage_inference;
139 JMenuItem _function_analysis;
141 JMenuItem _open_item;
142 JMenuItem _open_url_item;
143 JMenuItem _save_item;
144 JMenuItem _save_all_item;
145 JMenuItem _close_item;
146 JMenuItem _exit_item;
149 JMenuItem _midpoint_root_item;
150 JMenuItem _taxcolor_item;
151 JMenuItem _confcolor_item;
152 JMenuItem _color_rank_jmi;
153 JMenuItem _collapse_species_specific_subtrees;
154 JMenuItem _collapse_below_threshold; //TODO implememt me
155 JMenuItem _obtain_detailed_taxonomic_information_jmi;
156 JMenuItem _obtain_detailed_taxonomic_information_deleting_jmi;
157 JMenuItem _obtain_seq_information_jmi;
158 JMenuItem _move_node_names_to_tax_sn_jmi;
159 JMenuItem _move_node_names_to_seq_names_jmi;
160 JMenuItem _extract_tax_code_from_node_names_jmi;
161 JMenuItem _annotate_item;
163 JMenuItem _super_tiny_fonts_item;
164 JMenuItem _tiny_fonts_item;
165 JMenuItem _small_fonts_item;
166 JMenuItem _medium_fonts_item;
167 JMenuItem _large_fonts_item;
169 // _ screen and print
170 JMenuItem _choose_font_mi;
171 JMenuItem _switch_colors_mi;
172 JCheckBoxMenuItem _label_direction_cbmi;
174 JCheckBoxMenuItem _screen_antialias_cbmi;
175 JCheckBoxMenuItem _background_gradient_cbmi;
176 JRadioButtonMenuItem _non_lined_up_cladograms_rbmi;
177 JRadioButtonMenuItem _uniform_cladograms_rbmi;
178 JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi;
179 JCheckBoxMenuItem _show_branch_length_values_cbmi;
180 JCheckBoxMenuItem _show_scale_cbmi; //TODO fix me
181 JCheckBoxMenuItem _show_overview_cbmi;
182 JCheckBoxMenuItem _show_domain_labels;
183 JCheckBoxMenuItem _show_annotation_ref_source;
184 JCheckBoxMenuItem _abbreviate_scientific_names;
185 JCheckBoxMenuItem _color_labels_same_as_parent_branch;
186 JMenuItem _overview_placment_mi;
187 JMenuItem _choose_minimal_confidence_mi;
188 JCheckBoxMenuItem _show_default_node_shapes_internal_cbmi;
189 JCheckBoxMenuItem _show_default_node_shapes_external_cbmi;
190 JMenuItem _cycle_node_shape_mi;
191 JMenuItem _cycle_node_fill_mi;
192 JMenuItem _choose_node_size_mi;
193 JCheckBoxMenuItem _taxonomy_colorize_node_shapes_cbmi;
194 JCheckBoxMenuItem _show_confidence_stddev_cbmi;
196 JCheckBoxMenuItem _graphics_export_visible_only_cbmi;
197 JCheckBoxMenuItem _antialias_print_cbmi;
198 JCheckBoxMenuItem _print_black_and_white_cbmi;
199 JCheckBoxMenuItem _print_using_actual_size_cbmi;
200 JCheckBoxMenuItem _graphics_export_using_actual_size_cbmi;
201 JMenuItem _print_size_mi;
202 JMenuItem _choose_pdf_width_mi;
204 JCheckBoxMenuItem _internal_number_are_confidence_for_nh_parsing_cbmi;
205 JRadioButtonMenuItem _extract_taxonomy_no_rbmi;
206 JRadioButtonMenuItem _extract_taxonomy_agressive_rbmi;
207 JRadioButtonMenuItem _extract_taxonomy_pfam_strict_rbmi;
208 JRadioButtonMenuItem _extract_taxonomy_pfam_relaxed_rbmi;
209 JCheckBoxMenuItem _replace_underscores_cbmi;
210 JCheckBoxMenuItem _use_brackets_for_conf_in_nh_export_cbmi;
211 JCheckBoxMenuItem _use_internal_names_for_conf_in_nh_export_cbmi;
213 JCheckBoxMenuItem _search_case_senstive_cbmi;
214 JCheckBoxMenuItem _search_whole_words_only_cbmi;
215 JCheckBoxMenuItem _inverse_search_result_cbmi;
218 JCheckBoxMenuItem _rectangular_type_cbmi;
219 JCheckBoxMenuItem _triangular_type_cbmi;
220 JCheckBoxMenuItem _curved_type_cbmi;
221 JCheckBoxMenuItem _convex_type_cbmi;
222 JCheckBoxMenuItem _euro_type_cbmi;
223 JCheckBoxMenuItem _rounded_type_cbmi;
224 JCheckBoxMenuItem _unrooted_type_cbmi;
225 JCheckBoxMenuItem _circular_type_cbmi;
226 // view as text menu:
227 JMenuItem _view_as_NH_item;
228 JMenuItem _view_as_XML_item;
229 JMenuItem _view_as_nexus_item;
230 JMenuItem _display_basic_information_item;
232 JMenuItem _about_item;
233 JMenuItem _help_item;
234 JMenuItem _website_item;
235 JMenuItem _phyloxml_website_item;
236 JMenuItem _phyloxml_ref_item;
237 JMenuItem _aptx_ref_item;
240 // Handy pointers to child components:
241 MainPanel _mainpanel;
242 Container _contentpane;
243 final LinkedList<TextFrame> _textframes = new LinkedList<TextFrame>(); ;
244 Configuration _configuration;
245 JMenuItem _remove_branch_color_item;
247 private Phylogeny _species_tree;
248 InferenceManager _inference_manager;
249 final ProcessPool _process_pool;
250 private String _previous_node_annotation_ref;
253 _process_pool = ProcessPool.createInstance();
260 public void actionPerformed( final ActionEvent e ) {
261 final Object o = e.getSource();
262 boolean is_applet = false;
263 JApplet applet = null;
264 if ( getCurrentTreePanel() != null ) {
265 is_applet = getCurrentTreePanel().isApplet();
267 applet = getCurrentTreePanel().obtainApplet();
270 if ( o == _open_url_item ) {
271 readPhylogeniesFromURL();
273 else if ( o == _exit_item ) {
276 else if ( o == _gsdi_item ) {
277 if ( isSubtreeDisplayed() ) {
282 else if ( o == _gsdir_item ) {
283 if ( isSubtreeDisplayed() ) {
288 else if ( o == _taxcolor_item ) {
291 else if ( o == _confcolor_item ) {
294 else if ( o == _color_rank_jmi ) {
297 else if ( o == _collapse_species_specific_subtrees ) {
298 if ( isSubtreeDisplayed() ) {
301 if ( getCurrentTreePanel() != null ) {
302 getCurrentTreePanel().collapseSpeciesSpecificSubtrees();
305 else if ( o == _remove_branch_color_item ) {
306 if ( isSubtreeDisplayed() ) {
309 removeBranchColors();
311 else if ( o == _midpoint_root_item ) {
312 if ( isSubtreeDisplayed() ) {
317 else if ( o == _annotate_item ) {
320 else if ( o == _switch_colors_mi ) {
323 else if ( o == _display_basic_information_item ) {
324 displayBasicInformation();
326 else if ( o == _view_as_NH_item ) {
329 else if ( o == _view_as_XML_item ) {
332 else if ( o == _view_as_nexus_item ) {
335 else if ( o == _super_tiny_fonts_item ) {
336 if ( getCurrentTreePanel() != null ) {
337 getCurrentTreePanel().setSuperTinyFonts();
338 getCurrentTreePanel().repaint();
341 else if ( o == _tiny_fonts_item ) {
342 if ( getCurrentTreePanel() != null ) {
343 getCurrentTreePanel().setTinyFonts();
344 getCurrentTreePanel().repaint();
347 else if ( o == _small_fonts_item ) {
348 if ( getCurrentTreePanel() != null ) {
349 getCurrentTreePanel().setSmallFonts();
350 getCurrentTreePanel().repaint();
353 else if ( o == _medium_fonts_item ) {
354 if ( getCurrentTreePanel() != null ) {
355 getCurrentTreePanel().setMediumFonts();
356 getCurrentTreePanel().repaint();
359 else if ( o == _large_fonts_item ) {
360 if ( getCurrentTreePanel() != null ) {
361 getCurrentTreePanel().setLargeFonts();
362 getCurrentTreePanel().repaint();
365 else if ( o == _choose_font_mi ) {
368 else if ( o == _choose_minimal_confidence_mi ) {
369 chooseMinimalConfidence();
371 else if ( o == _choose_node_size_mi ) {
372 chooseNodeSize( getOptions(), this );
374 else if ( o == _overview_placment_mi ) {
375 MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
377 else if ( o == _cycle_node_fill_mi ) {
378 MainFrame.cycleNodeFill( getOptions(), getCurrentTreePanel() );
380 else if ( o == _cycle_node_shape_mi ) {
381 MainFrame.cycleNodeShape( getOptions(), getCurrentTreePanel() );
383 else if ( o == _screen_antialias_cbmi ) {
384 updateOptions( getOptions() );
385 updateScreenTextAntialias( getMainPanel().getTreePanels() );
387 else if ( o == _background_gradient_cbmi ) {
388 updateOptions( getOptions() );
390 else if ( o == _show_domain_labels ) {
391 updateOptions( getOptions() );
393 else if ( o == _show_annotation_ref_source ) {
394 updateOptions( getOptions() );
396 else if ( o == _abbreviate_scientific_names ) {
397 updateOptions( getOptions() );
399 else if ( o == _color_labels_same_as_parent_branch ) {
400 updateOptions( getOptions() );
402 else if ( o == _show_default_node_shapes_internal_cbmi ) {
403 updateOptions( getOptions() );
405 else if ( o == _show_default_node_shapes_external_cbmi ) {
406 updateOptions( getOptions() );
408 else if ( o == _taxonomy_colorize_node_shapes_cbmi ) {
409 updateOptions( getOptions() );
411 else if ( o == _non_lined_up_cladograms_rbmi ) {
412 updateOptions( getOptions() );
415 else if ( o == _uniform_cladograms_rbmi ) {
416 updateOptions( getOptions() );
419 else if ( o == _ext_node_dependent_cladogram_rbmi ) {
420 updateOptions( getOptions() );
423 else if ( o == _search_case_senstive_cbmi ) {
424 updateOptions( getOptions() );
425 getMainPanel().getControlPanel().search();
427 else if ( o == _search_whole_words_only_cbmi ) {
428 updateOptions( getOptions() );
429 getMainPanel().getControlPanel().search();
431 else if ( o == _inverse_search_result_cbmi ) {
432 updateOptions( getOptions() );
433 getMainPanel().getControlPanel().search();
435 else if ( o == _show_scale_cbmi ) {
436 updateOptions( getOptions() );
438 else if ( o == _show_branch_length_values_cbmi ) {
439 updateOptions( getOptions() );
441 else if ( o == _show_confidence_stddev_cbmi ) {
442 updateOptions( getOptions() );
444 else if ( o == _use_brackets_for_conf_in_nh_export_cbmi ) {
445 if ( _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {
446 _use_internal_names_for_conf_in_nh_export_cbmi.setSelected( false );
448 updateOptions( getOptions() );
450 else if ( o == _use_internal_names_for_conf_in_nh_export_cbmi ) {
451 if ( _use_internal_names_for_conf_in_nh_export_cbmi.isSelected() ) {
452 _use_brackets_for_conf_in_nh_export_cbmi.setSelected( false );
454 updateOptions( getOptions() );
456 else if ( o == _label_direction_cbmi ) {
457 updateOptions( getOptions() );
459 else if ( o == _show_overview_cbmi ) {
460 updateOptions( getOptions() );
461 if ( getCurrentTreePanel() != null ) {
462 getCurrentTreePanel().updateOvSizes();
465 else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
466 || ( o == _convex_type_cbmi ) || ( o == _euro_type_cbmi ) || ( o == _rounded_type_cbmi )
467 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
470 else if ( o == _about_item ) {
473 else if ( o == _help_item ) {
476 else if ( o == _website_item ) {
478 AptxUtil.openWebsite( Constants.APTX_WEB_SITE, is_applet, applet );
480 catch ( final IOException e1 ) {
481 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
484 else if ( o == _phyloxml_website_item ) {
486 AptxUtil.openWebsite( Constants.PHYLOXML_WEB_SITE, is_applet, applet );
488 catch ( final IOException e1 ) {
489 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
492 else if ( o == _aptx_ref_item ) {
494 AptxUtil.openWebsite( Constants.APTX_REFERENCE_URL, is_applet, applet );
496 catch ( final IOException e1 ) {
497 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
500 else if ( o == _phyloxml_ref_item ) {
502 AptxUtil.openWebsite( Constants.PHYLOXML_REFERENCE_URL, is_applet, applet );
504 catch ( final IOException e1 ) {
505 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
509 if ( _load_phylogeny_from_webservice_menu_items != null ) {
510 for( int i = 0; i < _load_phylogeny_from_webservice_menu_items.length; ++i ) {
511 if ( o == _load_phylogeny_from_webservice_menu_items[ i ] ) {
512 readPhylogeniesFromWebservice( i );
517 _contentpane.repaint();
520 public Configuration getConfiguration() {
521 return _configuration;
525 * This method returns the current external node data which
526 * has been selected by the user by clicking the "Return ..."
527 * menu item. This method is expected to be called from Javascript or
530 * @return current external node data as String
532 public String getCurrentExternalNodesDataBuffer() {
533 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString();
536 public int getCurrentExternalNodesDataBufferChangeCounter() {
537 return getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter();
540 public int getCurrentExternalNodesDataBufferLength() {
541 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length();
544 public InferenceManager getInferenceManager() {
545 return _inference_manager;
548 public MainPanel getMainPanel() {
552 public Options getOptions() {
556 public ProcessPool getProcessPool() {
557 return _process_pool;
560 public void showTextFrame( final String s, final String title ) {
562 _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
565 public void showWhole() {
566 _mainpanel.getControlPanel().showWhole();
569 public void updateProcessMenu() {
570 // In general Swing is not thread safe.
571 // See "Swing's Threading Policy".
572 SwingUtilities.invokeLater( new Runnable() {
576 doUpdateProcessMenu();
581 void activateSaveAllIfNeeded() {
582 if ( ( getMainPanel().getTabbedPane() != null ) && ( getMainPanel().getTabbedPane().getTabCount() > 1 ) ) {
583 _save_all_item.setEnabled( true );
586 _save_all_item.setEnabled( false );
590 void buildFileMenu() {
591 _file_jmenu = createMenu( "File", getConfiguration() );
592 _file_jmenu.add( _open_url_item = new JMenuItem( "Read tree from URL/webservice..." ) );
593 _file_jmenu.addSeparator();
594 _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );
595 customizeJMenuItem( _open_url_item );
596 customizeJMenuItem( _exit_item );
597 _jmenubar.add( _file_jmenu );
600 void buildFontSizeMenu() {
601 _font_size_menu = createMenu( FONT_SIZE_MENU_LABEL, getConfiguration() );
602 _font_size_menu.add( _super_tiny_fonts_item = new JMenuItem( "Super Tiny Fonts" ) );
603 _font_size_menu.add( _tiny_fonts_item = new JMenuItem( "Tiny Fonts" ) );
604 _font_size_menu.add( _small_fonts_item = new JMenuItem( "Small Fonts" ) );
605 _font_size_menu.add( _medium_fonts_item = new JMenuItem( "Medium Fonts" ) );
606 _font_size_menu.add( _large_fonts_item = new JMenuItem( "Large Fonts" ) );
607 customizeJMenuItem( _super_tiny_fonts_item );
608 customizeJMenuItem( _tiny_fonts_item );
609 customizeJMenuItem( _small_fonts_item );
610 customizeJMenuItem( _medium_fonts_item );
611 customizeJMenuItem( _large_fonts_item );
612 _jmenubar.add( _font_size_menu );
615 void buildHelpMenu() {
616 _help_jmenu = createMenu( "Help", getConfiguration() );
617 _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
618 _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
619 _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
620 _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
621 _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
622 _help_jmenu.addSeparator();
623 _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
624 customizeJMenuItem( _help_item );
625 customizeJMenuItem( _website_item );
626 customizeJMenuItem( _phyloxml_website_item );
627 customizeJMenuItem( _aptx_ref_item );
628 customizeJMenuItem( _phyloxml_ref_item );
629 customizeJMenuItem( _about_item );
630 _phyloxml_ref_item.setToolTipText( PHYLOXML_REF_TOOL_TIP );
631 _aptx_ref_item.setToolTipText( APTX_REF_TOOL_TIP );
632 _jmenubar.add( _help_jmenu );
635 void buildTypeMenu() {
636 _type_menu = createMenu( TYPE_MENU_HEADER, getConfiguration() );
637 _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
638 _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
639 _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
640 _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
641 _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
642 _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
643 _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
644 _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
645 customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
646 customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
647 customizeCheckBoxMenuItem( _euro_type_cbmi, false );
648 customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
649 customizeCheckBoxMenuItem( _curved_type_cbmi, false );
650 customizeCheckBoxMenuItem( _convex_type_cbmi, false );
651 customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
652 customizeCheckBoxMenuItem( _circular_type_cbmi, false );
653 _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
654 _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
655 initializeTypeMenu( getOptions() );
656 _jmenubar.add( _type_menu );
659 void buildViewMenu() {
660 _view_jmenu = createMenu( "View", getConfiguration() );
661 _view_jmenu.add( _display_basic_information_item = new JMenuItem( SHOW_BASIC_TREE_INFORMATION_LABEL ) );
662 _view_jmenu.addSeparator();
663 _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) );
664 _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) );
665 _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "View as Nexus" ) );
666 customizeJMenuItem( _display_basic_information_item );
667 customizeJMenuItem( _view_as_NH_item );
668 customizeJMenuItem( _view_as_XML_item );
669 customizeJMenuItem( _view_as_nexus_item );
670 _jmenubar.add( _view_jmenu );
673 void checkTextFrames() {
674 if ( _textframes.size() > 5 ) {
676 if ( _textframes.getFirst() != null ) {
677 _textframes.getFirst().removeMe();
680 _textframes.removeFirst();
683 catch ( final NoSuchElementException e ) {
690 removeAllTextFrames();
691 if ( _mainpanel != null ) {
692 _mainpanel.terminate();
694 if ( _contentpane != null ) {
695 _contentpane.removeAll();
702 if ( _mainpanel.getCurrentTreePanel() != null ) {
703 final String[] ranks = AptxUtil.getAllPossibleRanks();
704 final String rank = ( String ) JOptionPane
705 .showInputDialog( this,
706 "What rank should the colorization be based on",
708 JOptionPane.QUESTION_MESSAGE,
712 if ( !ForesterUtil.isEmpty( rank ) ) {
713 _mainpanel.getCurrentTreePanel().colorRank( rank );
719 if ( _mainpanel.getCurrentTreePanel() != null ) {
720 _mainpanel.getCurrentTreePanel().confColor();
724 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
725 if ( item != null ) {
726 item.setFont( MainFrame.menu_font );
727 if ( !getConfiguration().isUseNativeUI() ) {
728 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
729 item.setForeground( getConfiguration().getGuiMenuTextColor() );
731 item.setSelected( is_selected );
732 item.addActionListener( this );
736 JMenuItem customizeJMenuItem( final JMenuItem jmi ) {
738 jmi.setFont( MainFrame.menu_font );
739 if ( !getConfiguration().isUseNativeUI() ) {
740 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
741 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
743 jmi.addActionListener( this );
748 void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
749 if ( item != null ) {
750 item.setFont( MainFrame.menu_font );
751 if ( !getConfiguration().isUseNativeUI() ) {
752 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
753 item.setForeground( getConfiguration().getGuiMenuTextColor() );
755 item.setSelected( is_selected );
756 item.addActionListener( this );
760 void displayBasicInformation() {
761 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
762 String title = "Basic Information";
763 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
764 title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
766 showTextFrame( AptxUtil.createBasicInformation( _mainpanel.getCurrentPhylogeny() ), title );
770 void exceptionOccuredDuringOpenFile( final Exception e ) {
772 _mainpanel.getCurrentTreePanel().setArrowCursor();
774 catch ( final Exception ex ) {
777 JOptionPane.showMessageDialog( this,
778 ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
779 "Error during File|Open",
780 JOptionPane.ERROR_MESSAGE );
783 void exceptionOccuredDuringSaveAs( final Exception e ) {
785 _mainpanel.getCurrentTreePanel().setArrowCursor();
787 catch ( final Exception ex ) {
790 JOptionPane.showMessageDialog( this, "Exception" + e, "Error during File|SaveAs", JOptionPane.ERROR_MESSAGE );
794 if ( !isOKforSDI( false, true ) ) {
797 if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {
798 JOptionPane.showMessageDialog( this,
799 "Gene tree is not rooted.",
800 "Cannot execute GSDI",
801 JOptionPane.ERROR_MESSAGE );
804 final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
805 gene_tree.setAllNodesToNotCollapse();
806 gene_tree.recalculateNumberOfExternalDescendants( false );
808 final Phylogeny species_tree = getSpeciesTree().copy();
810 gsdi = new GSDI( gene_tree, species_tree, false, true, true, true );
812 catch ( final SDIException e ) {
813 JOptionPane.showMessageDialog( this,
814 e.getLocalizedMessage(),
816 JOptionPane.ERROR_MESSAGE );
819 catch ( final Exception e ) {
820 AptxUtil.unexpectedException( e );
823 gene_tree.setRerootable( false );
824 gene_tree.clearHashIdToNodeMap();
825 gene_tree.recalculateNumberOfExternalDescendants( true );
826 _mainpanel.addPhylogenyInNewTab( gene_tree, getConfiguration(), "gene tree", null );
827 getMainPanel().getControlPanel().setShowEvents( true );
829 final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
830 _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
832 _mainpanel.getTabbedPane().setSelectedIndex( selected );
834 _mainpanel.getCurrentTreePanel().setEdited( true );
835 final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
836 if ( gsdi.getStrippedExternalGeneTreeNodes().size() > 0 ) {
837 JOptionPane.showMessageDialog( this,
838 "Duplications: " + gsdi.getDuplicationsSum() + "\n"
839 + "Potential duplications: "
840 + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
841 + "Speciations: " + gsdi.getSpeciationsSum() + "\n"
842 + "Stripped gene tree nodes: "
843 + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
844 + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
845 + "Number of polytomies in species tree used: " + poly + "\n",
846 "GSDI successfully completed",
847 JOptionPane.WARNING_MESSAGE );
850 JOptionPane.showMessageDialog( this,
851 "Duplications: " + gsdi.getDuplicationsSum() + "\n"
852 + "Potential duplications: "
853 + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
854 + "Speciations: " + gsdi.getSpeciationsSum() + "\n"
855 + "Stripped gene tree nodes: "
856 + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
857 + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
858 + "Number of polytomies in species tree used: " + poly + "\n",
859 "GSDI successfully completed",
860 JOptionPane.INFORMATION_MESSAGE );
864 void executeGSDIR() {
865 if ( !isOKforSDI( false, false ) ) {
868 final int p = PhylogenyMethods.countNumberOfPolytomies( _mainpanel.getCurrentPhylogeny() );
870 && !( ( p == 1 ) && ( _mainpanel.getCurrentPhylogeny().getRoot().getNumberOfDescendants() == 3 ) ) ) {
871 JOptionPane.showMessageDialog( this,
872 "Gene tree is not completely binary",
873 "Cannot execute GSDI",
874 JOptionPane.ERROR_MESSAGE );
877 final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
878 gene_tree.setAllNodesToNotCollapse();
879 gene_tree.recalculateNumberOfExternalDescendants( false );
881 final Phylogeny species_tree = getSpeciesTree().copy();
883 gsdir = new GSDIR( gene_tree, species_tree, true, true, true );
885 catch ( final SDIException e ) {
886 JOptionPane.showMessageDialog( this,
887 e.getLocalizedMessage(),
888 "Error during GSDIR",
889 JOptionPane.ERROR_MESSAGE );
892 catch ( final Exception e ) {
893 AptxUtil.unexpectedException( e );
896 final Phylogeny result_gene_tree = gsdir.getMinDuplicationsSumGeneTree();
897 result_gene_tree.setRerootable( false );
898 result_gene_tree.clearHashIdToNodeMap();
899 result_gene_tree.recalculateNumberOfExternalDescendants( true );
900 PhylogenyMethods.orderAppearance( result_gene_tree.getRoot(), true, true, DESCENDANT_SORT_PRIORITY.NODE_NAME );
901 _mainpanel.addPhylogenyInNewTab( result_gene_tree, getConfiguration(), "gene tree", null );
902 getMainPanel().getControlPanel().setShowEvents( true );
904 final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
905 _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
907 _mainpanel.getTabbedPane().setSelectedIndex( selected );
909 _mainpanel.getCurrentTreePanel().setEdited( true );
910 final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
911 if ( gsdir.getStrippedExternalGeneTreeNodes().size() > 0 ) {
912 JOptionPane.showMessageDialog( this,
913 "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
914 + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
915 + "Stripped gene tree nodes: "
916 + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
917 + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
918 + "Number of polytomies in species tree used: " + poly + "\n",
919 "GSDIR successfully completed",
920 JOptionPane.WARNING_MESSAGE );
923 JOptionPane.showMessageDialog( this,
924 "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
925 + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
926 + "Stripped gene tree nodes: "
927 + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
928 + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
929 + "Number of polytomies in species tree used: " + poly + "\n",
930 "GSDIR successfully completed",
931 JOptionPane.INFORMATION_MESSAGE );
935 boolean GAndSDoHaveMoreThanOneSpeciesInComman( final Phylogeny gene_tree ) {
936 if ( ( gene_tree == null ) || gene_tree.isEmpty() ) {
937 JOptionPane.showMessageDialog( this,
938 "Gene tree and species tree have no species in common.",
940 JOptionPane.ERROR_MESSAGE );
943 else if ( gene_tree.getNumberOfExternalNodes() < 2 ) {
944 JOptionPane.showMessageDialog( this,
945 "Gene tree and species tree have only one species in common.",
947 JOptionPane.ERROR_MESSAGE );
955 TreePanel getCurrentTreePanel() {
956 return getMainPanel().getCurrentTreePanel();
959 JMenu getHelpMenu() {
963 JCheckBoxMenuItem getlabelDirectionCbmi() {
964 return _label_direction_cbmi;
967 JMenuBar getMenuBarOfMainFrame() {
971 final Phylogeny getSpeciesTree() {
972 return _species_tree;
976 final StringBuilder sb = new StringBuilder();
977 sb.append( "Display options\n" );
978 sb.append( "-------------------\n" );
979 sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
980 sb.append( "Clickable tree nodes\n" );
981 sb.append( "--------------------\n" );
982 sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
983 sb.append( "or by right clicking:\n" );
984 sb.append( "o Display Node Data -- display information for a node\n" );
985 sb.append( "o Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
986 sb.append( "o Root/Reroot -- change tree root to clicked node\n" );
987 sb.append( "o Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
988 sb.append( "o Swap Descendants -- switch descendant on either side of clicked node\n" );
989 sb.append( "o Colorize Subtree -- color a subtree\n" );
990 sb.append( "o Open Sequence Web -- launch a web browser to display sequence information\n" );
991 sb.append( "o Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
992 sb.append( "- there may be additional choices depending on this particular setup\n\n" );
993 sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
994 sb.append( "Zooming\n" );
995 sb.append( "---------\n" );
996 sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
997 sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
998 sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
999 sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
1000 sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
1001 sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
1002 sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
1003 sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
1004 sb.append( "Quick tree manipulation:\n" );
1005 sb.append( "------------------------\n" );
1006 sb.append( "Order Subtrees -- order the tree by branch length\n" );
1007 sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
1008 sb.append( "Memory problems (Java heap space error)\n" );
1009 sb.append( "---------------------------------------\n" );
1010 sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
1011 sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
1012 sb.append( "the '-Xmx' Java command line option. For example:\n" );
1013 sb.append( "java -Xmx1024m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
1014 // + "General remarks\n"
1015 // + "---------------\n"
1017 // "o The application version permits copying to the clipboard \n"
1019 // " in the \"View\"|\"View as ...\" frame (either by control-c or button press).\n"
1021 // "o Changes made to a subtree affect this subtree and its subtrees,\n"
1022 // + " but not any of its parent tree(s).\n"
1024 // "o Archaeopteryx tries to detect whether the numerical values in a NH tree\n"
1026 // " are likely to be bootstrap values instead of branch length values.\n\n"
1028 // " Remarks regarding SDI (Speciation Duplication Inference):\n"
1030 // "o Each external node of the gene tree (in display) needs to be associated with\n"
1032 // " a species: either directly through the \"Species\" field, or the species\n"
1034 // " is part of the sequence name in the form \"XXXX_SPECIES\"\n"
1036 // " (e.g. \"ACON_DROME\" or \"ACON_DROME/123-4489\" which is also acceptable).\n"
1038 // "o A species tree for each species of the gene tree needs to be loaded with\n"
1040 // " \"SDI\"|\"Load species tree\" prior the SDI execution.\n"
1042 // "o !External nodes of the gene tree associated with species not present in\n"
1044 // " the species tree are REMOVED prior to SDI execution!\n"
1046 // "o Both the gene tree and the species tree must be completely binary.\n"
1048 // "o Duplications and speciations are a function of the position of the root.\n"
1050 // " Hence, after each manual \"Root/Reroot\"ing some duplications will be\n"
1051 // + " incorrect and need to be inferred again\n"
1053 // " with: \"SDI\"|\"SDI (Speciation Duplication Inference)\n\n"
1054 sb.append( "phyloXML\n" );
1055 sb.append( "-------------------\n" );
1056 sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
1057 sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
1058 sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1060 sb.append( "For more information: https://sites.google.com/site/cmzmasek/home/software/archaeopteryx\n" );
1061 sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
1062 TextFrame.instantiate( sb.toString(), "Help", _textframes );
1065 void initializeTypeMenu( final Options options ) {
1066 setTypeMenuToAllUnselected();
1067 switch ( options.getPhylogenyGraphicsType() ) {
1069 _convex_type_cbmi.setSelected( true );
1072 _curved_type_cbmi.setSelected( true );
1075 _euro_type_cbmi.setSelected( true );
1078 _rounded_type_cbmi.setSelected( true );
1081 _triangular_type_cbmi.setSelected( true );
1084 _unrooted_type_cbmi.setSelected( true );
1087 _circular_type_cbmi.setSelected( true );
1090 _rectangular_type_cbmi.setSelected( true );
1095 boolean isOKforSDI( final boolean species_tree_has_to_binary, final boolean gene_tree_has_to_binary ) {
1096 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty() ) {
1099 else if ( ( getSpeciesTree() == null ) || getSpeciesTree().isEmpty() ) {
1100 JOptionPane.showMessageDialog( this,
1101 "No species tree loaded",
1102 "Cannot execute GSDI",
1103 JOptionPane.ERROR_MESSAGE );
1106 else if ( species_tree_has_to_binary && !getSpeciesTree().isCompletelyBinary() ) {
1107 JOptionPane.showMessageDialog( this,
1108 "Species tree is not completely binary",
1109 "Cannot execute GSDI",
1110 JOptionPane.ERROR_MESSAGE );
1113 else if ( gene_tree_has_to_binary && !_mainpanel.getCurrentPhylogeny().isCompletelyBinary() ) {
1114 JOptionPane.showMessageDialog( this,
1115 "Gene tree is not completely binary",
1116 "Cannot execute GSDI",
1117 JOptionPane.ERROR_MESSAGE );
1125 boolean isSubtreeDisplayed() {
1126 if ( getCurrentTreePanel() != null ) {
1127 if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
1129 .showMessageDialog( this,
1130 "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",
1131 "Operation can not be exectuted on a sub-tree",
1132 JOptionPane.WARNING_MESSAGE );
1139 void midpointRoot() {
1140 if ( _mainpanel.getCurrentTreePanel() != null ) {
1141 _mainpanel.getCurrentTreePanel().midpointRoot();
1145 abstract void readPhylogeniesFromURL();
1147 void readPhylogeniesFromWebservice( final int i ) {
1148 final UrlTreeReader reader = new UrlTreeReader( this, i );
1149 new Thread( reader ).start();
1152 void removeAllTextFrames() {
1153 for( final TextFrame tf : _textframes ) {
1158 _textframes.clear();
1161 void setConfiguration( final Configuration configuration ) {
1162 _configuration = configuration;
1165 void setInferenceManager( final InferenceManager i ) {
1166 _inference_manager = i;
1169 void setOptions( final Options options ) {
1173 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
1174 setTypeMenuToAllUnselected();
1177 _circular_type_cbmi.setSelected( true );
1180 _convex_type_cbmi.setSelected( true );
1183 _curved_type_cbmi.setSelected( true );
1186 _euro_type_cbmi.setSelected( true );
1189 _rounded_type_cbmi.setSelected( true );
1192 _rectangular_type_cbmi.setSelected( true );
1195 _triangular_type_cbmi.setSelected( true );
1198 _unrooted_type_cbmi.setSelected( true );
1201 throw new IllegalArgumentException( "unknown type: " + type );
1205 final void setSpeciesTree( final Phylogeny species_tree ) {
1206 _species_tree = species_tree;
1209 void setTypeMenuToAllUnselected() {
1210 _convex_type_cbmi.setSelected( false );
1211 _curved_type_cbmi.setSelected( false );
1212 _euro_type_cbmi.setSelected( false );
1213 _rounded_type_cbmi.setSelected( false );
1214 _triangular_type_cbmi.setSelected( false );
1215 _rectangular_type_cbmi.setSelected( false );
1216 _unrooted_type_cbmi.setSelected( false );
1217 _circular_type_cbmi.setSelected( false );
1220 void switchColors() {
1221 final TreeColorSet colorset = _mainpanel.getTreeColorSet();
1222 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
1223 csc.setVisible( true );
1227 if ( _mainpanel.getCurrentTreePanel() != null ) {
1228 _mainpanel.getCurrentTreePanel().taxColor();
1232 void typeChanged( final Object o ) {
1233 updateTypeCheckboxes( getOptions(), o );
1234 updateOptions( getOptions() );
1235 if ( getCurrentTreePanel() != null ) {
1236 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
1237 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
1238 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1239 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
1240 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1241 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
1242 getCurrentTreePanel().getControlPanel().showWhole();
1244 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1245 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
1248 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
1250 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
1251 updateScreenTextAntialias( getMainPanel().getTreePanels() );
1252 if ( getCurrentTreePanel().getControlPanel().getDynamicallyHideData() != null ) {
1253 if ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
1254 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( false );
1257 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( true );
1263 void updateOptions( final Options options ) {
1264 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
1265 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
1266 && _background_gradient_cbmi.isSelected() );
1267 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
1268 options.setShowAnnotationRefSource( ( _show_annotation_ref_source != null )
1269 && _show_annotation_ref_source.isSelected() );
1270 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
1271 && _abbreviate_scientific_names.isSelected() );
1272 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
1273 && _color_labels_same_as_parent_branch.isSelected() );
1274 options.setShowDefaultNodeShapesInternal( ( _show_default_node_shapes_internal_cbmi != null )
1275 && _show_default_node_shapes_internal_cbmi.isSelected() );
1276 options.setShowDefaultNodeShapesExternal( ( _show_default_node_shapes_external_cbmi != null )
1277 && _show_default_node_shapes_external_cbmi.isSelected() );
1278 options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null )
1279 && _taxonomy_colorize_node_shapes_cbmi.isSelected() );
1280 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
1281 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
1283 else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
1284 options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1286 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
1287 options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1289 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
1290 && _search_case_senstive_cbmi.isSelected() );
1291 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
1292 options.setShowScale( _show_scale_cbmi.isSelected() );
1294 if ( _label_direction_cbmi != null ) {
1295 if ( _label_direction_cbmi.isSelected() ) {
1296 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1299 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1302 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
1303 options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )
1304 && _show_confidence_stddev_cbmi.isSelected() );
1305 if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
1306 options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
1308 options.setPrintUsingActualSize( ( _print_using_actual_size_cbmi != null )
1309 && ( _print_using_actual_size_cbmi.isSelected() ) );
1310 options.setGraphicsExportUsingActualSize( ( _graphics_export_using_actual_size_cbmi != null )
1311 && ( _graphics_export_using_actual_size_cbmi.isSelected() ) );
1312 options.setAntialiasPrint( ( _antialias_print_cbmi != null ) && _antialias_print_cbmi.isSelected() );
1313 if ( ( _use_brackets_for_conf_in_nh_export_cbmi != null )
1314 && _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {
1315 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );
1317 else if ( ( _use_internal_names_for_conf_in_nh_export_cbmi != null )
1318 && _use_internal_names_for_conf_in_nh_export_cbmi.isSelected() ) {
1319 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES );
1322 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE );
1324 options.setPrintBlackAndWhite( ( _print_black_and_white_cbmi != null )
1325 && _print_black_and_white_cbmi.isSelected() );
1326 options.setInternalNumberAreConfidenceForNhParsing( ( _internal_number_are_confidence_for_nh_parsing_cbmi != null )
1327 && _internal_number_are_confidence_for_nh_parsing_cbmi.isSelected() );
1328 if ( ( _extract_taxonomy_pfam_strict_rbmi != null ) && _extract_taxonomy_pfam_strict_rbmi.isSelected() ) {
1329 options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1331 else if ( ( _extract_taxonomy_pfam_relaxed_rbmi != null ) && _extract_taxonomy_pfam_relaxed_rbmi.isSelected() ) {
1332 options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
1334 else if ( ( _extract_taxonomy_agressive_rbmi != null ) && _extract_taxonomy_agressive_rbmi.isSelected() ) {
1335 options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.AGGRESSIVE );
1337 else if ( ( _extract_taxonomy_no_rbmi != null ) && _extract_taxonomy_no_rbmi.isSelected() ) {
1338 options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.NO );
1340 options.setReplaceUnderscoresInNhParsing( ( _replace_underscores_cbmi != null )
1341 && _replace_underscores_cbmi.isSelected() );
1342 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
1343 && _search_whole_words_only_cbmi.isSelected() );
1344 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
1345 && _inverse_search_result_cbmi.isSelected() );
1346 if ( _graphics_export_visible_only_cbmi != null ) {
1347 options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() );
1348 if ( _graphics_export_visible_only_cbmi.isSelected() && ( _graphics_export_using_actual_size_cbmi != null ) ) {
1349 _graphics_export_using_actual_size_cbmi.setSelected( true );
1350 _graphics_export_using_actual_size_cbmi.setEnabled( false );
1353 _graphics_export_using_actual_size_cbmi.setEnabled( true );
1356 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
1357 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1359 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
1360 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1362 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
1363 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1365 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
1366 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1368 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
1369 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1371 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
1372 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1374 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
1375 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1377 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
1378 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1382 void updateTypeCheckboxes( final Options options, final Object o ) {
1383 setTypeMenuToAllUnselected();
1384 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
1387 void viewAsNexus() {
1388 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1389 String title = "Nexus";
1390 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1391 title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
1393 showTextFrame( _mainpanel.getCurrentPhylogeny().toNexus( getOptions().getNhConversionSupportValueStyle() ),
1399 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1400 String title = "New Hampshire";
1401 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1402 title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
1404 showTextFrame( _mainpanel.getCurrentPhylogeny()
1405 .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ),
1411 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1412 String title = "phyloXML";
1413 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1414 title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
1416 showTextFrame( _mainpanel.getCurrentPhylogeny().toPhyloXML( 0 ), title );
1420 private void annotateSequences() {
1421 if ( getCurrentTreePanel() != null ) {
1422 final Set<Long> nodes = getCurrentTreePanel().getFoundNodes();
1423 if ( ( nodes == null ) || nodes.isEmpty() ) {
1425 .showMessageDialog( this,
1426 "Need to select nodes, either via direct selection or via the \"Search\" function",
1427 "No nodes selected for annotation",
1428 JOptionPane.ERROR_MESSAGE );
1431 final Phylogeny phy = getMainPanel().getCurrentPhylogeny();
1432 if ( ( phy != null ) && !phy.isEmpty() ) {
1433 final JTextField ref_field = new JTextField( 10 );
1434 final JTextField desc_filed = new JTextField( 20 );
1435 ref_field.setText( ForesterUtil.isEmpty( getPreviousNodeAnnotationReference() ) ? ""
1436 : getPreviousNodeAnnotationReference() );
1437 final JPanel my_panel = new JPanel();
1438 my_panel.add( new JLabel( "Reference " ) );
1439 my_panel.add( ref_field );
1440 my_panel.add( Box.createHorizontalStrut( 15 ) );
1441 my_panel.add( new JLabel( "Description " ) );
1442 my_panel.add( desc_filed );
1443 final int result = JOptionPane.showConfirmDialog( null,
1445 "Enter the sequence annotation(s) for the "
1446 + nodes.size() + " selected nodes",
1447 JOptionPane.OK_CANCEL_OPTION );
1448 if ( result == JOptionPane.OK_OPTION ) {
1449 String ref = ref_field.getText();
1450 String desc = desc_filed.getText();
1451 if ( !ForesterUtil.isEmpty( ref ) ) {
1453 ref = ref.replaceAll( "\\s+", " " );
1454 if ( ( ref.indexOf( ':' ) < 1 ) || ( ref.indexOf( ':' ) > ref.length() - 2 )
1455 || ( ref.length() < 3 ) ) {
1456 JOptionPane.showMessageDialog( this,
1457 "Reference needs to be in the form of \"GO:1234567\"",
1458 "Illegal Format for Annotation Reference",
1459 JOptionPane.ERROR_MESSAGE );
1463 if ( ref != null ) {
1464 setPreviousNodeAnnotationReference( ref );
1466 if ( desc != null ) {
1468 desc = desc.replaceAll( "\\s+", " " );
1470 if ( !ForesterUtil.isEmpty( ref ) || !ForesterUtil.isEmpty( desc ) ) {
1471 for( final Long id : nodes ) {
1472 final PhylogenyNode n = phy.getNode( id );
1473 ForesterUtil.ensurePresenceOfSequence( n );
1474 final Annotation ann = ForesterUtil.isEmpty( ref ) ? new Annotation()
1475 : new Annotation( ref );
1476 if ( !ForesterUtil.isEmpty( desc ) ) {
1477 ann.setDesc( desc );
1479 n.getNodeData().getSequence().addAnnotation( ann );
1482 getMainPanel().getControlPanel().showAnnotations();
1488 private void chooseFont() {
1489 final FontChooser fc = new FontChooser();
1490 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
1491 fc.showDialog( this, "Select the Base Font" );
1492 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
1495 private void chooseMinimalConfidence() {
1496 final String s = ( String ) JOptionPane
1497 .showInputDialog( this,
1498 "Please enter the minimum for confidence values to be displayed.\n"
1499 + "[current value: " + getOptions().getMinConfidenceValue() + "]\n",
1500 "Minimal Confidence Value",
1501 JOptionPane.QUESTION_MESSAGE,
1504 getOptions().getMinConfidenceValue() );
1505 if ( !ForesterUtil.isEmpty( s ) ) {
1506 boolean success = true;
1508 final String m_str = s.trim();
1509 if ( !ForesterUtil.isEmpty( m_str ) ) {
1511 m = Double.parseDouble( m_str );
1513 catch ( final Exception ex ) {
1520 if ( success && ( m >= 0.0 ) ) {
1521 getOptions().setMinConfidenceValue( m );
1526 private void doUpdateProcessMenu() {
1527 if ( _process_pool.size() > 0 ) {
1528 if ( _process_menu == null ) {
1529 _process_menu = createMenu( "", getConfiguration() );
1530 _process_menu.setForeground( Color.RED );
1532 _process_menu.removeAll();
1533 final String text = "processes running: " + _process_pool.size();
1534 _process_menu.setText( text );
1535 _jmenubar.add( _process_menu );
1536 for( int i = 0; i < _process_pool.size(); ++i ) {
1537 final ProcessRunning p = _process_pool.getProcessByIndex( i );
1538 _process_menu.add( customizeJMenuItem( new JMenuItem( p.getName() + " [" + p.getStart() + "]" ) ) );
1542 if ( _process_menu != null ) {
1543 _process_menu.removeAll();
1544 _jmenubar.remove( _process_menu );
1547 _jmenubar.validate();
1548 _jmenubar.repaint();
1552 private String getPreviousNodeAnnotationReference() {
1553 return _previous_node_annotation_ref;
1556 private void removeBranchColors() {
1557 if ( getMainPanel().getCurrentPhylogeny() != null ) {
1558 AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
1562 private void setPreviousNodeAnnotationReference( final String previous_node_annotation_ref ) {
1563 _previous_node_annotation_ref = previous_node_annotation_ref;
1567 * Display the about box.
1569 static void about() {
1570 final StringBuffer about = new StringBuffer( "Archaeopteryx\nVersion " + Constants.VERSION + "\n" );
1571 about.append( "Copyright (C) 2013 Christian M. Zmasek\n" );
1572 about.append( "All Rights Reserved\n" );
1573 about.append( "License: GNU Lesser General Public License (LGPL)\n" );
1574 about.append( "Last modified: " + Constants.PRG_DATE + "\n" );
1575 about.append( "Based on: " + ForesterUtil.getForesterLibraryInformation() + "\n" );
1576 about.append( "phyloXML version : " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1577 about.append( "phyloXML location: " + ForesterConstants.PHYLO_XML_LOCATION + "\n" );
1578 if ( !ForesterUtil.isEmpty( ForesterUtil.JAVA_VERSION ) && !ForesterUtil.isEmpty( ForesterUtil.JAVA_VENDOR ) ) {
1579 about.append( "[your Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]\n" );
1581 if ( !ForesterUtil.isEmpty( ForesterUtil.OS_NAME ) && !ForesterUtil.isEmpty( ForesterUtil.OS_ARCH )
1582 && !ForesterUtil.isEmpty( ForesterUtil.OS_VERSION ) ) {
1583 about.append( "[your OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " "
1584 + ForesterUtil.OS_VERSION + "]\n" );
1586 final Runtime rt = java.lang.Runtime.getRuntime();
1587 final long free_memory = rt.freeMemory() / 1000000;
1588 final long total_memory = rt.totalMemory() / 1000000;
1589 about.append( "[free memory: " + free_memory + "MB, total memory: " + total_memory + "MB]\n" );
1590 about.append( "[locale: " + Locale.getDefault() + "]\n" );
1591 about.append( "References:\n" );
1592 about.append( Constants.PHYLOXML_REFERENCE_SHORT + "\n" );
1593 about.append( "For more information & download:\n" );
1594 about.append( Constants.APTX_WEB_SITE + "\n" );
1595 about.append( "Comments: " + Constants.AUTHOR_EMAIL );
1596 JOptionPane.showMessageDialog( null, about, Constants.PRG_NAME, JOptionPane.PLAIN_MESSAGE );
1599 static void chooseNodeSize( final Options options, final Component parent ) {
1600 final String s = ( String ) JOptionPane.showInputDialog( parent,
1601 "Please enter the default size for node shapes.\n"
1602 + "[current value: "
1603 + options.getDefaultNodeShapeSize() + "]\n",
1605 JOptionPane.QUESTION_MESSAGE,
1608 options.getDefaultNodeShapeSize() );
1609 if ( !ForesterUtil.isEmpty( s ) ) {
1610 boolean success = true;
1612 final String m_str = s.trim();
1613 if ( !ForesterUtil.isEmpty( m_str ) ) {
1615 m = Double.parseDouble( m_str );
1617 catch ( final Exception ex ) {
1624 if ( success && ( m >= 0.0 ) ) {
1625 final short size = ForesterUtil.roundToShort( m );
1626 if ( size >= 0.0 ) {
1627 options.setDefaultNodeShapeSize( size );
1633 static String createCurrentFontDesc( final TreeFontSet tree_font_set ) {
1634 return tree_font_set.getLargeFont().getFamily() + " " + tree_font_set.getLargeFont().getSize();
1637 static JMenu createMenu( final String title, final Configuration conf ) {
1638 final JMenu jmenu = new JMenu( title );
1639 if ( !conf.isUseNativeUI() ) {
1640 jmenu.setFont( MainFrame.menu_font );
1641 jmenu.setBackground( conf.getGuiMenuBackgroundColor() );
1642 jmenu.setForeground( conf.getGuiMenuTextColor() );
1647 static JMenuItem customizeMenuItemAsLabel( final JMenuItem label, final Configuration configuration ) {
1648 label.setFont( MainFrame.menu_font.deriveFont( Font.BOLD ) );
1649 if ( !configuration.isUseNativeUI() ) {
1650 label.setBackground( configuration.getGuiMenuBackgroundColor() );
1651 label.setForeground( configuration.getGuiMenuTextColor() );
1652 label.setOpaque( true );
1654 label.setSelected( false );
1655 label.setEnabled( false );
1659 static void cycleNodeFill( final Options op, final TreePanel tree_panel ) {
1660 switch ( op.getDefaultNodeFill() ) {
1662 op.setDefaultNodeFill( NodeFill.SOLID );
1665 op.setDefaultNodeFill( NodeFill.GRADIENT );
1668 op.setDefaultNodeFill( NodeFill.NONE );
1671 throw new RuntimeException( "unknown fill: " + op.getDefaultNodeFill() );
1675 static void cycleNodeShape( final Options op, final TreePanel tree_panel ) {
1676 switch ( op.getDefaultNodeShape() ) {
1678 op.setDefaultNodeShape( NodeShape.RECTANGLE );
1681 op.setDefaultNodeShape( NodeShape.CIRCLE );
1684 throw new RuntimeException( "unknown shape: " + op.getDefaultNodeShape() );
1688 static void cycleOverview( final Options op, final TreePanel tree_panel ) {
1689 switch ( op.getOvPlacement() ) {
1691 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1694 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1697 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1700 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1703 throw new RuntimeException( "unknown placement: " + op.getOvPlacement() );
1705 if ( tree_panel != null ) {
1706 tree_panel.updateOvSettings();
1710 static void setCycleNodeFillMenuItem( final JMenuItem mi, final Options options ) {
1711 if ( ( options != null ) && ( options.getDefaultNodeFill() != null ) ) {
1712 mi.setText( "Cycle Node Shape Fill Type... (current: "
1713 + options.getDefaultNodeFill().toString().toLowerCase() + ")" );
1716 mi.setText( "Cycle Node Shape Fill Type..." );
1720 static void setCycleNodeShapeMenuItem( final JMenuItem mi, final Options options ) {
1721 if ( ( options != null ) && ( options.getDefaultNodeShape() != null ) ) {
1722 mi.setText( "Cycle Node Shape Fill Type... (current: "
1723 + options.getDefaultNodeShape().toString().toLowerCase() + ")" );
1726 mi.setText( "Cycle Node Shape Fill Type..." );
1730 static void setOvPlacementColorChooseMenuItem( final JMenuItem mi, final Options options ) {
1731 if ( ( options != null ) && ( options.getOvPlacement() != null ) ) {
1732 mi.setText( "Cycle Overview Placement... (current: " + options.getOvPlacement() + ")" );
1735 mi.setText( "Cycle Overview Placement..." );
1739 static void setTextColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {
1740 if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {
1741 mi.setText( "Select Colors... (current: " + tree_panel.getTreeColorSet().getCurrentColorSchemeName() + ")" );
1744 mi.setText( "Select Colors..." );
1748 static void setTextForFontChooserMenuItem( final JMenuItem mi, final String font_desc ) {
1749 mi.setText( "Select Font... (current: " + font_desc + ")" );
1752 static void setTextMinSupportMenuItem( final JMenuItem mi, final Options options, final TreePanel current_tree_panel ) {
1753 if ( ( current_tree_panel == null ) || ( current_tree_panel.getPhylogeny() == null ) ) {
1754 mi.setEnabled( true );
1756 else if ( AptxUtil.isHasAtLeastOneBranchWithSupportValues( current_tree_panel.getPhylogeny() ) ) {
1757 mi.setEnabled( true );
1760 mi.setEnabled( false );
1762 mi.setText( "Enter Min Confidence Value... (current: " + options.getMinConfidenceValue() + ")" );
1765 static void setTextNodeSizeMenuItem( final JMenuItem mi, final Options options ) {
1766 mi.setText( "Enter Default Node Shape Size... (current: " + options.getDefaultNodeShapeSize() + ")" );
1769 static void updateOptionsMenuDependingOnPhylogenyType( final MainPanel main_panel,
1770 final JCheckBoxMenuItem scale,
1771 final JCheckBoxMenuItem branch_lengths,
1772 final JRadioButtonMenuItem non_lined_up,
1773 final JRadioButtonMenuItem uniform_clado,
1774 final JRadioButtonMenuItem nonuniform_clado,
1775 final JCheckBoxMenuItem label_direction_cbmi ) {
1776 final TreePanel tree_panel = main_panel.getCurrentTreePanel();
1777 final ControlPanel control = main_panel.getControlPanel();
1778 final Options options = main_panel.getOptions();
1779 scale.setSelected( options.isShowScale() );
1780 branch_lengths.setSelected( options.isShowBranchLengthValues() );
1781 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1782 if ( ( tree_panel != null ) && ( !tree_panel.isPhyHasBranchLengths() ) ) {
1783 scale.setSelected( false );
1784 scale.setEnabled( false );
1785 branch_lengths.setSelected( false );
1786 branch_lengths.setEnabled( false );
1788 else if ( ( tree_panel != null ) && !control.isDrawPhylogram() ) {
1789 scale.setSelected( false );
1790 scale.setEnabled( false );
1791 branch_lengths.setEnabled( true );
1794 scale.setEnabled( true );
1795 branch_lengths.setEnabled( true );
1797 if ( ( tree_panel != null )
1798 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.ROUNDED )
1799 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1800 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1801 branch_lengths.setSelected( false );
1802 branch_lengths.setEnabled( false );
1804 if ( tree_panel != null ) {
1805 if ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1806 || ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
1807 non_lined_up.setEnabled( false );
1808 uniform_clado.setEnabled( false );
1809 nonuniform_clado.setEnabled( false );
1812 non_lined_up.setEnabled( true );
1813 uniform_clado.setEnabled( true );
1814 nonuniform_clado.setEnabled( true );
1818 if ( ( tree_panel != null )
1819 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1820 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1821 branch_lengths.setSelected( false );
1822 branch_lengths.setEnabled( false );
1824 if ( ( tree_panel != null )
1825 && ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( tree_panel
1826 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
1827 non_lined_up.setEnabled( false );
1830 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1831 non_lined_up.setEnabled( true );
1834 label_direction_cbmi.setEnabled( true );
1835 if ( tree_panel != null ) {
1836 if ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1837 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1838 label_direction_cbmi.setEnabled( false );
1840 if ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
1841 scale.setSelected( false );
1842 scale.setEnabled( false );
1847 static void updateScreenTextAntialias( final List<TreePanel> treepanels ) {
1848 for( final TreePanel tree_panel : treepanels ) {
1849 tree_panel.setTextAntialias();