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;
34 import java.io.IOException;
35 import java.util.LinkedList;
36 import java.util.List;
37 import java.util.Locale;
38 import java.util.NoSuchElementException;
41 import javax.swing.Box;
42 import javax.swing.JApplet;
43 import javax.swing.JCheckBoxMenuItem;
44 import javax.swing.JFrame;
45 import javax.swing.JLabel;
46 import javax.swing.JMenu;
47 import javax.swing.JMenuBar;
48 import javax.swing.JMenuItem;
49 import javax.swing.JOptionPane;
50 import javax.swing.JPanel;
51 import javax.swing.JRadioButtonMenuItem;
52 import javax.swing.JTextField;
53 import javax.swing.SwingUtilities;
55 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
56 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
57 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
58 import org.forester.archaeopteryx.tools.InferenceManager;
59 import org.forester.archaeopteryx.tools.ProcessPool;
60 import org.forester.archaeopteryx.tools.ProcessRunning;
61 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
62 import org.forester.phylogeny.Phylogeny;
63 import org.forester.phylogeny.PhylogenyMethods;
64 import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
65 import org.forester.phylogeny.PhylogenyNode;
66 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
67 import org.forester.phylogeny.data.Annotation;
68 import org.forester.phylogeny.data.NodeVisualData.NodeFill;
69 import org.forester.phylogeny.data.NodeVisualData.NodeShape;
70 import org.forester.sdi.GSDI;
71 import org.forester.sdi.GSDIR;
72 import org.forester.sdi.SDIException;
73 import org.forester.util.ForesterConstants;
74 import org.forester.util.ForesterUtil;
76 public abstract class MainFrame extends JFrame implements ActionListener {
78 static final String USE_MOUSEWHEEL_SHIFT_TO_ROTATE = "In this display type, use mousewheel + Shift to rotate [or A and S]";
79 static final String PHYLOXML_REF_TOOL_TIP = Constants.PHYLOXML_REFERENCE; //TODO //FIXME
80 static final String APTX_REF_TOOL_TIP = Constants.APTX_REFERENCE;
81 private static final long serialVersionUID = 3655000897845508358L;
82 final static Font menu_font = new Font( Configuration.getDefaultFontFamilyName(),
85 static final String TYPE_MENU_HEADER = "Type";
86 static final String RECTANGULAR_TYPE_CBMI_LABEL = "Rectangular";
87 static final String EURO_TYPE_CBMI_LABEL = "Euro Type";
88 static final String CURVED_TYPE_CBMI_LABEL = "Curved";
89 static final String TRIANGULAR_TYPE_CBMI_LABEL = "Triangular";
90 static final String CONVEX_TYPE_CBMI_LABEL = "Convex";
91 static final String ROUNDED_TYPE_CBMI_LABEL = "Rounded";
92 static final String UNROOTED_TYPE_CBMI_LABEL = "Unrooted (alpha)"; //TODO
93 static final String CIRCULAR_TYPE_CBMI_LABEL = "Circular (alpha)"; //TODO
94 static final String OPTIONS_HEADER = "Options";
95 static final String SEARCH_SUBHEADER = "Search:";
96 static final String DISPLAY_SUBHEADER = "Display:";
97 static final String SEARCH_TERMS_ONLY_LABEL = "Match Complete Terms Only";
98 static final String SEARCH_CASE_SENSITIVE_LABEL = "Case Sensitive";
99 static final String INVERSE_SEARCH_RESULT_LABEL = "Negate Result";
100 static final String DISPLAY_BRANCH_LENGTH_VALUES_LABEL = "Branch Length Values";
101 static final String COLOR_BY_TAXONOMIC_GROUP = "Colorize by Taxonomic Group";
102 static final String DISPLAY_SCALE_LABEL = "Scale";
103 static final String NON_LINED_UP_CLADOGRAMS_LABEL = "Non-Lined Up Cladograms";
104 static final String UNIFORM_CLADOGRAMS_LABEL = "Total Node Sum Dependent Cladograms";
105 static final String LABEL_DIRECTION_LABEL = "Radial Labels";
106 static final String LABEL_DIRECTION_TIP = "To use radial node labels in radial and unrooted display types";
107 static final String SCREEN_ANTIALIAS_LABEL = "Antialias";
108 static final String COLOR_LABELS_LABEL = "Colorize Labels Same as Parent Branch";
109 static final String BG_GRAD_LABEL = "Background Color Gradient";
110 static final String DISPLAY_NODE_BOXES_LABEL_EXT = "External Node Shapes";
111 static final String DISPLAY_NODE_BOXES_LABEL_INT = "Internal Node Shapes";
112 static final String SHOW_OVERVIEW_LABEL = "Overview";
113 static final String FONT_SIZE_MENU_LABEL = "Font Size";
114 static final String NONUNIFORM_CLADOGRAMS_LABEL = "External Node Sum Dependent Cladograms";
115 static final String SHOW_DOMAIN_LABELS_LABEL = "Domain Labels";
116 static final String SHOW_ANN_REF_SOURCE_LABEL = "Seq Annotation Ref Sources";
117 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";
118 static final String ABBREV_SN_LABEL = "Abbreviate Scientific Taxonomic Names";
119 static final String TAXONOMY_COLORIZE_NODE_SHAPES_LABEL = "Colorize Node Shapes According to Taxonomy";
120 static final String CYCLE_NODE_SHAPE_LABEL = "Cycle Node Shapes";
121 static final String CYCLE_NODE_FILL_LABEL = "Cycle Node Fill Type";
122 static final String CHOOSE_NODE_SIZE_LABEL = "Choose Node Shape Size";
123 static final String SHOW_CONF_STDDEV_LABEL = "Confidence Standard Deviations";
124 static final String USE_BRACKETS_FOR_CONF_IN_NH_LABEL = "Use Brackets for Confidence Values";
125 static final String USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL = "Use Internal Node Names for Confidence Values";
126 static final String SHOW_BASIC_TREE_INFORMATION_LABEL = "Basic Tree Information";
131 JMenu _options_jmenu;
132 JMenu _font_size_menu;
134 JMenuItem[] _load_phylogeny_from_webservice_menu_items;
136 JMenu _analysis_menu;
137 JMenuItem _load_species_tree_item;
138 JMenuItem _gsdi_item;
139 JMenuItem _gsdir_item;
140 JMenuItem _lineage_inference;
142 JMenuItem _open_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 _color_by_taxonomic_group_cbmi;
181 JCheckBoxMenuItem _show_scale_cbmi; //TODO fix me
182 JCheckBoxMenuItem _show_overview_cbmi;
183 JCheckBoxMenuItem _show_domain_labels;
184 JCheckBoxMenuItem _show_annotation_ref_source;
185 JCheckBoxMenuItem _abbreviate_scientific_names;
186 JCheckBoxMenuItem _color_labels_same_as_parent_branch;
187 JMenuItem _overview_placment_mi;
188 JMenuItem _choose_minimal_confidence_mi;
189 JCheckBoxMenuItem _show_default_node_shapes_internal_cbmi;
190 JCheckBoxMenuItem _show_default_node_shapes_external_cbmi;
191 JMenuItem _cycle_node_shape_mi;
192 JMenuItem _cycle_node_fill_mi;
193 JMenuItem _choose_node_size_mi;
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 _allow_errors_in_distance_to_parent_cbmi;
211 JCheckBoxMenuItem _use_brackets_for_conf_in_nh_export_cbmi;
212 JCheckBoxMenuItem _use_internal_names_for_conf_in_nh_export_cbmi;
214 JCheckBoxMenuItem _search_case_senstive_cbmi;
215 JCheckBoxMenuItem _search_whole_words_only_cbmi;
216 JCheckBoxMenuItem _inverse_search_result_cbmi;
219 JCheckBoxMenuItem _rectangular_type_cbmi;
220 JCheckBoxMenuItem _triangular_type_cbmi;
221 JCheckBoxMenuItem _curved_type_cbmi;
222 JCheckBoxMenuItem _convex_type_cbmi;
223 JCheckBoxMenuItem _euro_type_cbmi;
224 JCheckBoxMenuItem _rounded_type_cbmi;
225 JCheckBoxMenuItem _unrooted_type_cbmi;
226 JCheckBoxMenuItem _circular_type_cbmi;
227 // view as text menu:
228 JMenuItem _view_as_NH_item;
229 JMenuItem _view_as_XML_item;
230 JMenuItem _view_as_nexus_item;
231 JMenuItem _display_basic_information_item;
233 JMenuItem _about_item;
234 JMenuItem _help_item;
235 JMenuItem _website_item;
236 JMenuItem _phyloxml_website_item;
237 JMenuItem _phyloxml_ref_item;
238 JMenuItem _aptx_ref_item;
241 // Handy pointers to child components:
242 MainPanel _mainpanel;
243 Container _contentpane;
244 final LinkedList<TextFrame> _textframes = new LinkedList<TextFrame>(); ;
245 Configuration _configuration;
246 JMenuItem _remove_branch_color_item;
248 private Phylogeny _species_tree;
249 InferenceManager _inference_manager;
250 final ProcessPool _process_pool;
251 private String _previous_node_annotation_ref;
254 _process_pool = ProcessPool.createInstance();
261 public void actionPerformed( final ActionEvent e ) {
262 final Object o = e.getSource();
263 boolean is_applet = false;
264 JApplet applet = null;
265 if ( getCurrentTreePanel() != null ) {
266 is_applet = getCurrentTreePanel().isApplet();
268 applet = getCurrentTreePanel().obtainApplet();
271 if ( o == _exit_item ) {
274 else if ( o == _gsdi_item ) {
275 if ( isSubtreeDisplayed() ) {
280 else if ( o == _gsdir_item ) {
281 if ( isSubtreeDisplayed() ) {
286 else if ( o == _taxcolor_item ) {
289 else if ( o == _confcolor_item ) {
292 else if ( o == _color_rank_jmi ) {
295 else if ( o == _collapse_species_specific_subtrees ) {
296 if ( isSubtreeDisplayed() ) {
299 if ( getCurrentTreePanel() != null ) {
300 getCurrentTreePanel().collapseSpeciesSpecificSubtrees();
303 else if ( o == _remove_branch_color_item ) {
304 if ( isSubtreeDisplayed() ) {
307 removeBranchColors();
309 else if ( o == _midpoint_root_item ) {
310 if ( isSubtreeDisplayed() ) {
315 else if ( o == _annotate_item ) {
318 else if ( o == _switch_colors_mi ) {
321 else if ( o == _display_basic_information_item ) {
322 displayBasicInformation( getCurrentTreePanel().getTreeFile() );
324 else if ( o == _view_as_NH_item ) {
327 else if ( o == _view_as_XML_item ) {
330 else if ( o == _view_as_nexus_item ) {
333 else if ( o == _super_tiny_fonts_item ) {
334 if ( getCurrentTreePanel() != null ) {
335 getCurrentTreePanel().setSuperTinyFonts();
336 getCurrentTreePanel().repaint();
339 else if ( o == _tiny_fonts_item ) {
340 if ( getCurrentTreePanel() != null ) {
341 getCurrentTreePanel().setTinyFonts();
342 getCurrentTreePanel().repaint();
345 else if ( o == _small_fonts_item ) {
346 if ( getCurrentTreePanel() != null ) {
347 getCurrentTreePanel().setSmallFonts();
348 getCurrentTreePanel().repaint();
351 else if ( o == _medium_fonts_item ) {
352 if ( getCurrentTreePanel() != null ) {
353 getCurrentTreePanel().setMediumFonts();
354 getCurrentTreePanel().repaint();
357 else if ( o == _large_fonts_item ) {
358 if ( getCurrentTreePanel() != null ) {
359 getCurrentTreePanel().setLargeFonts();
360 getCurrentTreePanel().repaint();
363 else if ( o == _choose_font_mi ) {
366 else if ( o == _choose_minimal_confidence_mi ) {
367 chooseMinimalConfidence();
369 else if ( o == _choose_node_size_mi ) {
370 chooseNodeSize( getOptions(), this );
372 else if ( o == _overview_placment_mi ) {
373 MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
375 else if ( o == _cycle_node_fill_mi ) {
376 MainFrame.cycleNodeFill( getOptions(), getCurrentTreePanel() );
378 else if ( o == _cycle_node_shape_mi ) {
379 MainFrame.cycleNodeShape( getOptions(), getCurrentTreePanel() );
381 else if ( o == _screen_antialias_cbmi ) {
382 updateOptions( getOptions() );
383 updateScreenTextAntialias( getMainPanel().getTreePanels() );
385 else if ( o == _background_gradient_cbmi ) {
386 updateOptions( getOptions() );
388 else if ( o == _show_domain_labels ) {
389 updateOptions( getOptions() );
391 else if ( o == _show_annotation_ref_source ) {
392 updateOptions( getOptions() );
394 else if ( o == _abbreviate_scientific_names ) {
395 updateOptions( getOptions() );
397 else if ( o == _color_labels_same_as_parent_branch ) {
398 updateOptions( getOptions() );
400 else if ( o == _show_default_node_shapes_internal_cbmi ) {
401 updateOptions( getOptions() );
403 else if ( o == _show_default_node_shapes_external_cbmi ) {
404 updateOptions( getOptions() );
406 else if ( o == _non_lined_up_cladograms_rbmi ) {
407 updateOptions( getOptions() );
410 else if ( o == _uniform_cladograms_rbmi ) {
411 updateOptions( getOptions() );
414 else if ( o == _ext_node_dependent_cladogram_rbmi ) {
415 updateOptions( getOptions() );
418 else if ( o == _search_case_senstive_cbmi ) {
419 updateOptions( getOptions() );
420 getMainPanel().getControlPanel().search0();
421 getMainPanel().getControlPanel().search1();
423 else if ( o == _search_whole_words_only_cbmi ) {
424 updateOptions( getOptions() );
425 getMainPanel().getControlPanel().search0();
426 getMainPanel().getControlPanel().search1();
428 else if ( o == _inverse_search_result_cbmi ) {
429 updateOptions( getOptions() );
430 getMainPanel().getControlPanel().search0();
431 getMainPanel().getControlPanel().search1();
433 else if ( o == _show_scale_cbmi ) {
434 updateOptions( getOptions() );
436 else if ( o == _show_branch_length_values_cbmi ) {
437 updateOptions( getOptions() );
439 else if ( o == _color_by_taxonomic_group_cbmi ) {
440 updateOptions( getOptions() );
442 else if ( o == _show_confidence_stddev_cbmi ) {
443 updateOptions( getOptions() );
445 else if ( o == _use_brackets_for_conf_in_nh_export_cbmi ) {
446 if ( _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {
447 _use_internal_names_for_conf_in_nh_export_cbmi.setSelected( false );
449 updateOptions( getOptions() );
451 else if ( o == _use_internal_names_for_conf_in_nh_export_cbmi ) {
452 if ( _use_internal_names_for_conf_in_nh_export_cbmi.isSelected() ) {
453 _use_brackets_for_conf_in_nh_export_cbmi.setSelected( false );
455 updateOptions( getOptions() );
457 else if ( o == _label_direction_cbmi ) {
458 updateOptions( getOptions() );
460 else if ( o == _show_overview_cbmi ) {
461 updateOptions( getOptions() );
462 if ( getCurrentTreePanel() != null ) {
463 getCurrentTreePanel().updateOvSizes();
466 else if ( ( o == _rectangular_type_cbmi ) || ( o == _triangular_type_cbmi ) || ( o == _curved_type_cbmi )
467 || ( o == _convex_type_cbmi ) || ( o == _euro_type_cbmi ) || ( o == _rounded_type_cbmi )
468 || ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {
471 else if ( o == _about_item ) {
474 else if ( o == _help_item ) {
477 else if ( o == _website_item ) {
479 AptxUtil.openWebsite( Constants.APTX_WEB_SITE, is_applet, applet );
481 catch ( final IOException e1 ) {
482 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
485 else if ( o == _phyloxml_website_item ) {
487 AptxUtil.openWebsite( Constants.PHYLOXML_WEB_SITE, is_applet, applet );
489 catch ( final IOException e1 ) {
490 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
493 else if ( o == _aptx_ref_item ) {
495 AptxUtil.openWebsite( Constants.APTX_REFERENCE_URL, is_applet, applet );
497 catch ( final IOException e1 ) {
498 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
501 else if ( o == _phyloxml_ref_item ) {
503 AptxUtil.openWebsite( Constants.PHYLOXML_REFERENCE_URL, is_applet, applet );
505 catch ( final IOException e1 ) {
506 ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
510 if ( _load_phylogeny_from_webservice_menu_items != null ) {
511 for( int i = 0; i < _load_phylogeny_from_webservice_menu_items.length; ++i ) {
512 if ( o == _load_phylogeny_from_webservice_menu_items[ i ] ) {
513 readPhylogeniesFromWebservice( i );
518 _contentpane.repaint();
521 public Configuration getConfiguration() {
522 return _configuration;
526 * This method returns the current external node data which
527 * has been selected by the user by clicking the "Return ..."
528 * menu item. This method is expected to be called from Javascript or
531 * @return current external node data as String
533 public String getCurrentExternalNodesDataBuffer() {
534 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString();
537 public int getCurrentExternalNodesDataBufferChangeCounter() {
538 return getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter();
541 public int getCurrentExternalNodesDataBufferLength() {
542 return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length();
545 public InferenceManager getInferenceManager() {
546 return _inference_manager;
549 public MainPanel getMainPanel() {
553 public Options getOptions() {
557 public ProcessPool getProcessPool() {
558 return _process_pool;
561 public void showTextFrame( final String s, final String title ) {
563 _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
566 public void showWhole() {
567 _mainpanel.getControlPanel().showWhole();
570 public void updateProcessMenu() {
571 // In general Swing is not thread safe.
572 // See "Swing's Threading Policy".
573 SwingUtilities.invokeLater( new Runnable() {
577 doUpdateProcessMenu();
582 void activateSaveAllIfNeeded() {
583 if ( ( getMainPanel().getTabbedPane() != null ) && ( getMainPanel().getTabbedPane().getTabCount() > 1 ) ) {
584 _save_all_item.setEnabled( true );
587 _save_all_item.setEnabled( false );
591 void buildFileMenu() {
592 _file_jmenu = createMenu( "File", getConfiguration() );
593 _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );
594 customizeJMenuItem( _exit_item );
595 _jmenubar.add( _file_jmenu );
598 void buildFontSizeMenu() {
599 _font_size_menu = createMenu( FONT_SIZE_MENU_LABEL, getConfiguration() );
600 _font_size_menu.add( _super_tiny_fonts_item = new JMenuItem( "Super Tiny Fonts" ) );
601 _font_size_menu.add( _tiny_fonts_item = new JMenuItem( "Tiny Fonts" ) );
602 _font_size_menu.add( _small_fonts_item = new JMenuItem( "Small Fonts" ) );
603 _font_size_menu.add( _medium_fonts_item = new JMenuItem( "Medium Fonts" ) );
604 _font_size_menu.add( _large_fonts_item = new JMenuItem( "Large Fonts" ) );
605 customizeJMenuItem( _super_tiny_fonts_item );
606 customizeJMenuItem( _tiny_fonts_item );
607 customizeJMenuItem( _small_fonts_item );
608 customizeJMenuItem( _medium_fonts_item );
609 customizeJMenuItem( _large_fonts_item );
610 _jmenubar.add( _font_size_menu );
613 void buildHelpMenu() {
614 _help_jmenu = createMenu( "Help", getConfiguration() );
615 _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
616 _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
617 _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
618 _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
619 _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
620 _help_jmenu.addSeparator();
621 _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
622 customizeJMenuItem( _help_item );
623 customizeJMenuItem( _website_item );
624 customizeJMenuItem( _phyloxml_website_item );
625 customizeJMenuItem( _aptx_ref_item );
626 customizeJMenuItem( _phyloxml_ref_item );
627 customizeJMenuItem( _about_item );
628 _phyloxml_ref_item.setToolTipText( PHYLOXML_REF_TOOL_TIP );
629 _aptx_ref_item.setToolTipText( APTX_REF_TOOL_TIP );
630 _jmenubar.add( _help_jmenu );
633 void buildTypeMenu() {
634 _type_menu = createMenu( TYPE_MENU_HEADER, getConfiguration() );
635 _type_menu.add( _rectangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.RECTANGULAR_TYPE_CBMI_LABEL ) );
636 _type_menu.add( _euro_type_cbmi = new JCheckBoxMenuItem( MainFrame.EURO_TYPE_CBMI_LABEL ) );
637 _type_menu.add( _rounded_type_cbmi = new JCheckBoxMenuItem( MainFrame.ROUNDED_TYPE_CBMI_LABEL ) );
638 _type_menu.add( _curved_type_cbmi = new JCheckBoxMenuItem( MainFrame.CURVED_TYPE_CBMI_LABEL ) );
639 _type_menu.add( _triangular_type_cbmi = new JCheckBoxMenuItem( MainFrame.TRIANGULAR_TYPE_CBMI_LABEL ) );
640 _type_menu.add( _convex_type_cbmi = new JCheckBoxMenuItem( MainFrame.CONVEX_TYPE_CBMI_LABEL ) );
641 _type_menu.add( _unrooted_type_cbmi = new JCheckBoxMenuItem( MainFrame.UNROOTED_TYPE_CBMI_LABEL ) );
642 _type_menu.add( _circular_type_cbmi = new JCheckBoxMenuItem( MainFrame.CIRCULAR_TYPE_CBMI_LABEL ) );
643 customizeCheckBoxMenuItem( _rectangular_type_cbmi, false );
644 customizeCheckBoxMenuItem( _triangular_type_cbmi, false );
645 customizeCheckBoxMenuItem( _euro_type_cbmi, false );
646 customizeCheckBoxMenuItem( _rounded_type_cbmi, false );
647 customizeCheckBoxMenuItem( _curved_type_cbmi, false );
648 customizeCheckBoxMenuItem( _convex_type_cbmi, false );
649 customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
650 customizeCheckBoxMenuItem( _circular_type_cbmi, false );
651 _unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
652 _circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
653 initializeTypeMenu( getOptions() );
654 _jmenubar.add( _type_menu );
657 void buildViewMenu() {
658 _view_jmenu = createMenu( "View", getConfiguration() );
659 _view_jmenu.add( _display_basic_information_item = new JMenuItem( SHOW_BASIC_TREE_INFORMATION_LABEL ) );
660 _view_jmenu.addSeparator();
661 _view_jmenu.add( _view_as_XML_item = new JMenuItem( "as phyloXML" ) );
662 _view_jmenu.add( _view_as_NH_item = new JMenuItem( "as Newick" ) );
663 _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "as Nexus" ) );
664 customizeJMenuItem( _display_basic_information_item );
665 customizeJMenuItem( _view_as_NH_item );
666 customizeJMenuItem( _view_as_XML_item );
667 customizeJMenuItem( _view_as_nexus_item );
668 _jmenubar.add( _view_jmenu );
671 void checkTextFrames() {
672 if ( _textframes.size() > 5 ) {
674 if ( _textframes.getFirst() != null ) {
675 _textframes.getFirst().removeMe();
678 _textframes.removeFirst();
681 catch ( final NoSuchElementException e ) {
688 removeAllTextFrames();
689 if ( _mainpanel != null ) {
690 _mainpanel.terminate();
692 if ( _contentpane != null ) {
693 _contentpane.removeAll();
700 if ( _mainpanel.getCurrentTreePanel() != null ) {
701 final String[] ranks = AptxUtil.getAllPossibleRanks();
702 final String rank = ( String ) JOptionPane
703 .showInputDialog( this,
704 "What rank should the colorization be based on",
706 JOptionPane.QUESTION_MESSAGE,
710 if ( !ForesterUtil.isEmpty( rank ) ) {
711 _mainpanel.getCurrentTreePanel().colorRank( rank );
717 if ( _mainpanel.getCurrentTreePanel() != null ) {
718 _mainpanel.getCurrentTreePanel().confColor();
722 void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
723 if ( item != null ) {
724 item.setFont( MainFrame.menu_font );
725 if ( !getConfiguration().isUseNativeUI() ) {
726 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
727 item.setForeground( getConfiguration().getGuiMenuTextColor() );
729 item.setSelected( is_selected );
730 item.addActionListener( this );
734 JMenuItem customizeJMenuItem( final JMenuItem jmi ) {
736 jmi.setFont( MainFrame.menu_font );
737 if ( !getConfiguration().isUseNativeUI() ) {
738 jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
739 jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
741 jmi.addActionListener( this );
746 void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) {
747 if ( item != null ) {
748 item.setFont( MainFrame.menu_font );
749 if ( !getConfiguration().isUseNativeUI() ) {
750 item.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
751 item.setForeground( getConfiguration().getGuiMenuTextColor() );
753 item.setSelected( is_selected );
754 item.addActionListener( this );
758 void displayBasicInformation( final File treefile ) {
759 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
760 String title = "Basic Information";
761 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
762 title = title + " for \"" + _mainpanel.getCurrentPhylogeny().getName() + "\"";
764 showTextFrame( AptxUtil.createBasicInformation( _mainpanel.getCurrentPhylogeny(), treefile ), title );
768 void exceptionOccuredDuringOpenFile( final Exception e ) {
770 _mainpanel.getCurrentTreePanel().setArrowCursor();
772 catch ( final Exception ex ) {
775 JOptionPane.showMessageDialog( this,
776 ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
777 "Error during File|Open",
778 JOptionPane.ERROR_MESSAGE );
781 void exceptionOccuredDuringSaveAs( final Exception e ) {
783 _mainpanel.getCurrentTreePanel().setArrowCursor();
785 catch ( final Exception ex ) {
788 JOptionPane.showMessageDialog( this, "Exception" + e, "Error during File|SaveAs", JOptionPane.ERROR_MESSAGE );
792 if ( !isOKforSDI( false, true ) ) {
795 if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {
796 JOptionPane.showMessageDialog( this,
797 "Gene tree is not rooted.",
798 "Cannot execute GSDI",
799 JOptionPane.ERROR_MESSAGE );
802 final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
803 gene_tree.setAllNodesToNotCollapse();
804 gene_tree.recalculateNumberOfExternalDescendants( false );
806 final Phylogeny species_tree = getSpeciesTree().copy();
808 gsdi = new GSDI( gene_tree, species_tree, false, true, true, true );
810 catch ( final SDIException e ) {
811 JOptionPane.showMessageDialog( this,
812 e.getLocalizedMessage(),
814 JOptionPane.ERROR_MESSAGE );
817 catch ( final Exception e ) {
818 AptxUtil.unexpectedException( e );
821 gene_tree.setRerootable( false );
822 gene_tree.clearHashIdToNodeMap();
823 gene_tree.recalculateNumberOfExternalDescendants( true );
824 _mainpanel.addPhylogenyInNewTab( gene_tree, getConfiguration(), "gene tree", null );
825 getMainPanel().getControlPanel().setShowEvents( true );
827 final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
828 _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
830 _mainpanel.getTabbedPane().setSelectedIndex( selected );
832 _mainpanel.getCurrentTreePanel().setEdited( true );
833 final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
834 if ( gsdi.getStrippedExternalGeneTreeNodes().size() > 0 ) {
835 JOptionPane.showMessageDialog( this,
836 "Duplications: " + gsdi.getDuplicationsSum() + "\n"
837 + "Potential duplications: "
838 + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
839 + "Speciations: " + gsdi.getSpeciationsSum() + "\n"
840 + "Stripped gene tree nodes: "
841 + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
842 + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
843 + "Number of polytomies in species tree used: " + poly + "\n",
844 "GSDI successfully completed",
845 JOptionPane.WARNING_MESSAGE );
848 JOptionPane.showMessageDialog( this,
849 "Duplications: " + gsdi.getDuplicationsSum() + "\n"
850 + "Potential duplications: "
851 + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
852 + "Speciations: " + gsdi.getSpeciationsSum() + "\n"
853 + "Stripped gene tree nodes: "
854 + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
855 + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
856 + "Number of polytomies in species tree used: " + poly + "\n",
857 "GSDI successfully completed",
858 JOptionPane.INFORMATION_MESSAGE );
862 void executeGSDIR() {
863 if ( !isOKforSDI( false, false ) ) {
866 final int p = PhylogenyMethods.countNumberOfPolytomies( _mainpanel.getCurrentPhylogeny() );
868 && !( ( p == 1 ) && ( _mainpanel.getCurrentPhylogeny().getRoot().getNumberOfDescendants() == 3 ) ) ) {
869 JOptionPane.showMessageDialog( this,
870 "Gene tree is not completely binary",
871 "Cannot execute GSDI",
872 JOptionPane.ERROR_MESSAGE );
875 final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
876 gene_tree.setAllNodesToNotCollapse();
877 gene_tree.recalculateNumberOfExternalDescendants( false );
879 final Phylogeny species_tree = getSpeciesTree().copy();
881 gsdir = new GSDIR( gene_tree, species_tree, true, true, true );
883 catch ( final SDIException e ) {
884 JOptionPane.showMessageDialog( this,
885 e.getLocalizedMessage(),
886 "Error during GSDIR",
887 JOptionPane.ERROR_MESSAGE );
890 catch ( final Exception e ) {
891 AptxUtil.unexpectedException( e );
894 final Phylogeny result_gene_tree = gsdir.getMinDuplicationsSumGeneTree();
895 result_gene_tree.setRerootable( false );
896 result_gene_tree.clearHashIdToNodeMap();
897 result_gene_tree.recalculateNumberOfExternalDescendants( true );
898 PhylogenyMethods.orderAppearance( result_gene_tree.getRoot(), true, true, DESCENDANT_SORT_PRIORITY.NODE_NAME );
899 _mainpanel.addPhylogenyInNewTab( result_gene_tree, getConfiguration(), "gene tree", null );
900 getMainPanel().getControlPanel().setShowEvents( true );
902 final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
903 _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
905 _mainpanel.getTabbedPane().setSelectedIndex( selected );
907 _mainpanel.getCurrentTreePanel().setEdited( true );
908 final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
909 if ( gsdir.getStrippedExternalGeneTreeNodes().size() > 0 ) {
910 JOptionPane.showMessageDialog( this,
911 "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
912 + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
913 + "Stripped gene tree nodes: "
914 + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
915 + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
916 + "Number of polytomies in species tree used: " + poly + "\n",
917 "GSDIR successfully completed",
918 JOptionPane.WARNING_MESSAGE );
921 JOptionPane.showMessageDialog( this,
922 "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
923 + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
924 + "Stripped gene tree nodes: "
925 + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
926 + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
927 + "Number of polytomies in species tree used: " + poly + "\n",
928 "GSDIR successfully completed",
929 JOptionPane.INFORMATION_MESSAGE );
933 boolean GAndSDoHaveMoreThanOneSpeciesInComman( final Phylogeny gene_tree ) {
934 if ( ( gene_tree == null ) || gene_tree.isEmpty() ) {
935 JOptionPane.showMessageDialog( this,
936 "Gene tree and species tree have no species in common.",
938 JOptionPane.ERROR_MESSAGE );
941 else if ( gene_tree.getNumberOfExternalNodes() < 2 ) {
942 JOptionPane.showMessageDialog( this,
943 "Gene tree and species tree have only one species in common.",
945 JOptionPane.ERROR_MESSAGE );
953 TreePanel getCurrentTreePanel() {
954 return getMainPanel().getCurrentTreePanel();
957 JMenu getHelpMenu() {
961 JCheckBoxMenuItem getlabelDirectionCbmi() {
962 return _label_direction_cbmi;
965 JMenuBar getMenuBarOfMainFrame() {
969 final Phylogeny getSpeciesTree() {
970 return _species_tree;
974 final StringBuilder sb = new StringBuilder();
975 sb.append( "Display options\n" );
976 sb.append( "-------------------\n" );
977 sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
978 sb.append( "Clickable tree nodes\n" );
979 sb.append( "--------------------\n" );
980 sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
981 sb.append( "or by right clicking:\n" );
982 sb.append( "o Display Node Data -- display information for a node\n" );
983 sb.append( "o Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
984 sb.append( "o Root/Reroot -- change tree root to clicked node\n" );
985 sb.append( "o Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
986 sb.append( "o Swap Descendants -- switch descendant on either side of clicked node\n" );
987 sb.append( "o Colorize Subtree -- color a subtree\n" );
988 sb.append( "o Open Sequence Web -- launch a web browser to display sequence information\n" );
989 sb.append( "o Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
990 sb.append( "- there may be additional choices depending on this particular setup\n\n" );
991 sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
992 sb.append( "Zooming\n" );
993 sb.append( "---------\n" );
994 sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
995 sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
996 sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
997 sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
998 sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
999 sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
1000 sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
1001 sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
1002 sb.append( "Quick tree manipulation:\n" );
1003 sb.append( "------------------------\n" );
1004 sb.append( "Order Subtrees -- order the tree by branch length\n" );
1005 sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
1006 sb.append( "Memory problems (Java heap space error)\n" );
1007 sb.append( "---------------------------------------\n" );
1008 sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
1009 sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
1010 sb.append( "the '-Xmx' Java command line option. For example:\n" );
1011 sb.append( "java -Xmx1024m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
1012 // + "General remarks\n"
1013 // + "---------------\n"
1015 // "o The application version permits copying to the clipboard \n"
1017 // " in the \"View\"|\"View as ...\" frame (either by control-c or button press).\n"
1019 // "o Changes made to a subtree affect this subtree and its subtrees,\n"
1020 // + " but not any of its parent tree(s).\n"
1022 // "o Archaeopteryx tries to detect whether the numerical values in a NH tree\n"
1024 // " are likely to be bootstrap values instead of branch length values.\n\n"
1026 // " Remarks regarding SDI (Speciation Duplication Inference):\n"
1028 // "o Each external node of the gene tree (in display) needs to be associated with\n"
1030 // " a species: either directly through the \"Species\" field, or the species\n"
1032 // " is part of the sequence name in the form \"XXXX_SPECIES\"\n"
1034 // " (e.g. \"ACON_DROME\" or \"ACON_DROME/123-4489\" which is also acceptable).\n"
1036 // "o A species tree for each species of the gene tree needs to be loaded with\n"
1038 // " \"SDI\"|\"Load species tree\" prior the SDI execution.\n"
1040 // "o !External nodes of the gene tree associated with species not present in\n"
1042 // " the species tree are REMOVED prior to SDI execution!\n"
1044 // "o Both the gene tree and the species tree must be completely binary.\n"
1046 // "o Duplications and speciations are a function of the position of the root.\n"
1048 // " Hence, after each manual \"Root/Reroot\"ing some duplications will be\n"
1049 // + " incorrect and need to be inferred again\n"
1051 // " with: \"SDI\"|\"SDI (Speciation Duplication Inference)\n\n"
1052 sb.append( "phyloXML\n" );
1053 sb.append( "-------------------\n" );
1054 sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
1055 sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
1056 sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1058 sb.append( "For more information: https://sites.google.com/site/cmzmasek/home/software/archaeopteryx\n" );
1059 sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
1060 TextFrame.instantiate( sb.toString(), "Help", _textframes );
1063 void initializeTypeMenu( final Options options ) {
1064 setTypeMenuToAllUnselected();
1065 switch ( options.getPhylogenyGraphicsType() ) {
1067 _convex_type_cbmi.setSelected( true );
1070 _curved_type_cbmi.setSelected( true );
1073 _euro_type_cbmi.setSelected( true );
1076 _rounded_type_cbmi.setSelected( true );
1079 _triangular_type_cbmi.setSelected( true );
1082 _unrooted_type_cbmi.setSelected( true );
1085 _circular_type_cbmi.setSelected( true );
1088 _rectangular_type_cbmi.setSelected( true );
1093 boolean isOKforSDI( final boolean species_tree_has_to_binary, final boolean gene_tree_has_to_binary ) {
1094 if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty() ) {
1097 else if ( ( getSpeciesTree() == null ) || getSpeciesTree().isEmpty() ) {
1098 JOptionPane.showMessageDialog( this,
1099 "No species tree loaded",
1100 "Cannot execute GSDI",
1101 JOptionPane.ERROR_MESSAGE );
1104 else if ( species_tree_has_to_binary && !getSpeciesTree().isCompletelyBinary() ) {
1105 JOptionPane.showMessageDialog( this,
1106 "Species tree is not completely binary",
1107 "Cannot execute GSDI",
1108 JOptionPane.ERROR_MESSAGE );
1111 else if ( gene_tree_has_to_binary && !_mainpanel.getCurrentPhylogeny().isCompletelyBinary() ) {
1112 JOptionPane.showMessageDialog( this,
1113 "Gene tree is not completely binary",
1114 "Cannot execute GSDI",
1115 JOptionPane.ERROR_MESSAGE );
1123 boolean isSubtreeDisplayed() {
1124 if ( getCurrentTreePanel() != null ) {
1125 if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
1127 .showMessageDialog( this,
1128 "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",
1129 "Operation can not be exectuted on a sub-tree",
1130 JOptionPane.WARNING_MESSAGE );
1137 void midpointRoot() {
1138 if ( _mainpanel.getCurrentTreePanel() != null ) {
1139 _mainpanel.getCurrentTreePanel().midpointRoot();
1143 void readPhylogeniesFromWebservice( final int i ) {
1144 final UrlTreeReader reader = new UrlTreeReader( this, i );
1145 new Thread( reader ).start();
1148 void removeAllTextFrames() {
1149 for( final TextFrame tf : _textframes ) {
1154 _textframes.clear();
1157 void setConfiguration( final Configuration configuration ) {
1158 _configuration = configuration;
1161 void setInferenceManager( final InferenceManager i ) {
1162 _inference_manager = i;
1165 void setOptions( final Options options ) {
1169 void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
1170 setTypeMenuToAllUnselected();
1173 _circular_type_cbmi.setSelected( true );
1176 _convex_type_cbmi.setSelected( true );
1179 _curved_type_cbmi.setSelected( true );
1182 _euro_type_cbmi.setSelected( true );
1185 _rounded_type_cbmi.setSelected( true );
1188 _rectangular_type_cbmi.setSelected( true );
1191 _triangular_type_cbmi.setSelected( true );
1194 _unrooted_type_cbmi.setSelected( true );
1197 throw new IllegalArgumentException( "unknown type: " + type );
1201 final void setSpeciesTree( final Phylogeny species_tree ) {
1202 _species_tree = species_tree;
1205 void setTypeMenuToAllUnselected() {
1206 _convex_type_cbmi.setSelected( false );
1207 _curved_type_cbmi.setSelected( false );
1208 _euro_type_cbmi.setSelected( false );
1209 _rounded_type_cbmi.setSelected( false );
1210 _triangular_type_cbmi.setSelected( false );
1211 _rectangular_type_cbmi.setSelected( false );
1212 _unrooted_type_cbmi.setSelected( false );
1213 _circular_type_cbmi.setSelected( false );
1216 void switchColors() {
1217 final TreeColorSet colorset = _mainpanel.getTreeColorSet();
1218 final ColorSchemeChooser csc = new ColorSchemeChooser( getMainPanel(), colorset );
1219 csc.setVisible( true );
1223 if ( _mainpanel.getCurrentTreePanel() != null ) {
1224 _mainpanel.getCurrentTreePanel().taxColor();
1228 void typeChanged( final Object o ) {
1229 updateTypeCheckboxes( getOptions(), o );
1230 updateOptions( getOptions() );
1231 if ( getCurrentTreePanel() != null ) {
1232 final PHYLOGENY_GRAPHICS_TYPE previous_type = getCurrentTreePanel().getPhylogenyGraphicsType();
1233 final PHYLOGENY_GRAPHICS_TYPE new_type = getOptions().getPhylogenyGraphicsType();
1234 if ( ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1235 || ( ( previous_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) )
1236 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) )
1237 || ( ( previous_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) && ( new_type == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) ) {
1238 getCurrentTreePanel().getControlPanel().showWhole();
1240 if ( getCurrentTreePanel().isPhyHasBranchLengths() && ( new_type != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1241 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( true );
1244 getCurrentTreePanel().getControlPanel().setDrawPhylogramEnabled( false );
1246 getCurrentTreePanel().setPhylogenyGraphicsType( getOptions().getPhylogenyGraphicsType() );
1247 updateScreenTextAntialias( getMainPanel().getTreePanels() );
1248 if ( getCurrentTreePanel().getControlPanel().getDynamicallyHideData() != null ) {
1249 if ( new_type == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
1250 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( false );
1253 getCurrentTreePanel().getControlPanel().getDynamicallyHideData().setEnabled( true );
1259 void updateOptions( final Options options ) {
1260 options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );
1261 options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
1262 && _background_gradient_cbmi.isSelected() );
1263 options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
1264 options.setShowAnnotationRefSource( ( _show_annotation_ref_source != null )
1265 && _show_annotation_ref_source.isSelected() );
1266 options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
1267 && _abbreviate_scientific_names.isSelected() );
1268 options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
1269 && _color_labels_same_as_parent_branch.isSelected() );
1270 options.setShowDefaultNodeShapesInternal( ( _show_default_node_shapes_internal_cbmi != null )
1271 && _show_default_node_shapes_internal_cbmi.isSelected() );
1272 options.setShowDefaultNodeShapesExternal( ( _show_default_node_shapes_external_cbmi != null )
1273 && _show_default_node_shapes_external_cbmi.isSelected() );
1274 if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
1275 options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
1277 else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
1278 options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1280 else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
1281 options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1283 options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
1284 && _search_case_senstive_cbmi.isSelected() );
1285 if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {
1286 options.setShowScale( _show_scale_cbmi.isSelected() );
1288 if ( _label_direction_cbmi != null ) {
1289 if ( _label_direction_cbmi.isSelected() ) {
1290 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1293 options.setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1296 options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );
1297 options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )
1298 && _show_confidence_stddev_cbmi.isSelected() );
1299 if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {
1300 options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );
1302 if ( ( _color_by_taxonomic_group_cbmi != null ) && _color_by_taxonomic_group_cbmi.isEnabled() ) {
1303 options.setColorByTaxonomicGroup( _color_by_taxonomic_group_cbmi.isSelected() );
1305 options.setPrintUsingActualSize( ( _print_using_actual_size_cbmi != null )
1306 && ( _print_using_actual_size_cbmi.isSelected() ) );
1307 options.setGraphicsExportUsingActualSize( ( _graphics_export_using_actual_size_cbmi != null )
1308 && ( _graphics_export_using_actual_size_cbmi.isSelected() ) );
1309 options.setAntialiasPrint( ( _antialias_print_cbmi != null ) && _antialias_print_cbmi.isSelected() );
1310 if ( ( _use_brackets_for_conf_in_nh_export_cbmi != null )
1311 && _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {
1312 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );
1314 else if ( ( _use_internal_names_for_conf_in_nh_export_cbmi != null )
1315 && _use_internal_names_for_conf_in_nh_export_cbmi.isSelected() ) {
1316 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES );
1319 options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE );
1321 options.setPrintBlackAndWhite( ( _print_black_and_white_cbmi != null )
1322 && _print_black_and_white_cbmi.isSelected() );
1323 options.setInternalNumberAreConfidenceForNhParsing( ( _internal_number_are_confidence_for_nh_parsing_cbmi != null )
1324 && _internal_number_are_confidence_for_nh_parsing_cbmi.isSelected() );
1325 if ( ( _extract_taxonomy_pfam_strict_rbmi != null ) && _extract_taxonomy_pfam_strict_rbmi.isSelected() ) {
1326 options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1328 else if ( ( _extract_taxonomy_pfam_relaxed_rbmi != null ) && _extract_taxonomy_pfam_relaxed_rbmi.isSelected() ) {
1329 options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
1331 else if ( ( _extract_taxonomy_agressive_rbmi != null ) && _extract_taxonomy_agressive_rbmi.isSelected() ) {
1332 options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.AGGRESSIVE );
1334 else if ( ( _extract_taxonomy_no_rbmi != null ) && _extract_taxonomy_no_rbmi.isSelected() ) {
1335 options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.NO );
1337 options.setReplaceUnderscoresInNhParsing( ( _replace_underscores_cbmi != null )
1338 && _replace_underscores_cbmi.isSelected() );
1339 options.setAllowErrorsInDistanceToParent( ( _allow_errors_in_distance_to_parent_cbmi != null )
1340 && _allow_errors_in_distance_to_parent_cbmi.isSelected() );
1341 options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )
1342 && _search_whole_words_only_cbmi.isSelected() );
1343 options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )
1344 && _inverse_search_result_cbmi.isSelected() );
1345 if ( _graphics_export_visible_only_cbmi != null ) {
1346 options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() );
1347 if ( _graphics_export_visible_only_cbmi.isSelected() && ( _graphics_export_using_actual_size_cbmi != null ) ) {
1348 _graphics_export_using_actual_size_cbmi.setSelected( true );
1349 _graphics_export_using_actual_size_cbmi.setEnabled( false );
1352 _graphics_export_using_actual_size_cbmi.setEnabled( true );
1355 if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) {
1356 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1358 else if ( ( _triangular_type_cbmi != null ) && _triangular_type_cbmi.isSelected() ) {
1359 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1361 else if ( ( _curved_type_cbmi != null ) && _curved_type_cbmi.isSelected() ) {
1362 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1364 else if ( ( _convex_type_cbmi != null ) && _convex_type_cbmi.isSelected() ) {
1365 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1367 else if ( ( _euro_type_cbmi != null ) && _euro_type_cbmi.isSelected() ) {
1368 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1370 else if ( ( _rounded_type_cbmi != null ) && _rounded_type_cbmi.isSelected() ) {
1371 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1373 else if ( ( _unrooted_type_cbmi != null ) && _unrooted_type_cbmi.isSelected() ) {
1374 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1376 else if ( ( _circular_type_cbmi != null ) && _circular_type_cbmi.isSelected() ) {
1377 options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1381 void updateTypeCheckboxes( final Options options, final Object o ) {
1382 setTypeMenuToAllUnselected();
1383 ( ( JCheckBoxMenuItem ) o ).setSelected( true );
1386 void viewAsNexus() {
1387 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1388 String title = "Nexus";
1389 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1390 title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;
1392 showTextFrame( _mainpanel.getCurrentPhylogeny().toNexus( getOptions().getNhConversionSupportValueStyle() ),
1398 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1399 String title = "New Hampshire";
1400 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1401 title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;
1403 showTextFrame( _mainpanel.getCurrentPhylogeny()
1404 .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ),
1410 if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
1411 String title = "phyloXML";
1412 if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
1413 title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;
1415 showTextFrame( _mainpanel.getCurrentPhylogeny().toPhyloXML( 0 ), title );
1419 private void annotateSequences() {
1420 if ( getCurrentTreePanel() != null ) {
1421 final Set<Long> nodes = getCurrentTreePanel().getFoundNodes0();
1422 if ( ( nodes == null ) || nodes.isEmpty() ) {
1424 .showMessageDialog( this,
1425 "Need to select nodes, either via direct selection or via the \"Search\" function",
1426 "No nodes selected for annotation",
1427 JOptionPane.ERROR_MESSAGE );
1430 final Phylogeny phy = getMainPanel().getCurrentPhylogeny();
1431 if ( ( phy != null ) && !phy.isEmpty() ) {
1432 final JTextField ref_field = new JTextField( 10 );
1433 final JTextField desc_filed = new JTextField( 20 );
1434 ref_field.setText( ForesterUtil.isEmpty( getPreviousNodeAnnotationReference() ) ? ""
1435 : getPreviousNodeAnnotationReference() );
1436 final JPanel my_panel = new JPanel();
1437 my_panel.add( new JLabel( "Reference " ) );
1438 my_panel.add( ref_field );
1439 my_panel.add( Box.createHorizontalStrut( 15 ) );
1440 my_panel.add( new JLabel( "Description " ) );
1441 my_panel.add( desc_filed );
1442 final int result = JOptionPane.showConfirmDialog( null,
1444 "Enter the sequence annotation(s) for the "
1445 + nodes.size() + " selected nodes",
1446 JOptionPane.OK_CANCEL_OPTION );
1447 if ( result == JOptionPane.OK_OPTION ) {
1448 String ref = ref_field.getText();
1449 String desc = desc_filed.getText();
1450 if ( !ForesterUtil.isEmpty( ref ) ) {
1452 ref = ref.replaceAll( "\\s+", " " );
1453 if ( ( ref.indexOf( ':' ) < 1 ) || ( ref.indexOf( ':' ) > ref.length() - 2 )
1454 || ( ref.length() < 3 ) ) {
1455 JOptionPane.showMessageDialog( this,
1456 "Reference needs to be in the form of \"GO:1234567\"",
1457 "Illegal Format for Annotation Reference",
1458 JOptionPane.ERROR_MESSAGE );
1462 if ( ref != null ) {
1463 setPreviousNodeAnnotationReference( ref );
1465 if ( desc != null ) {
1467 desc = desc.replaceAll( "\\s+", " " );
1469 if ( !ForesterUtil.isEmpty( ref ) || !ForesterUtil.isEmpty( desc ) ) {
1470 for( final Long id : nodes ) {
1471 final PhylogenyNode n = phy.getNode( id );
1472 ForesterUtil.ensurePresenceOfSequence( n );
1473 final Annotation ann = ForesterUtil.isEmpty( ref ) ? new Annotation()
1474 : new Annotation( ref );
1475 if ( !ForesterUtil.isEmpty( desc ) ) {
1476 ann.setDesc( desc );
1478 n.getNodeData().getSequence().addAnnotation( ann );
1481 getMainPanel().getControlPanel().showAnnotations();
1487 private void chooseFont() {
1488 final FontChooser fc = new FontChooser();
1489 fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
1490 fc.showDialog( this, "Select the Base Font" );
1491 getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
1494 private void chooseMinimalConfidence() {
1495 final String s = ( String ) JOptionPane
1496 .showInputDialog( this,
1497 "Please enter the minimum for confidence values to be displayed.\n"
1498 + "[current value: " + getOptions().getMinConfidenceValue() + "]\n",
1499 "Minimal Confidence Value",
1500 JOptionPane.QUESTION_MESSAGE,
1503 getOptions().getMinConfidenceValue() );
1504 if ( !ForesterUtil.isEmpty( s ) ) {
1505 boolean success = true;
1507 final String m_str = s.trim();
1508 if ( !ForesterUtil.isEmpty( m_str ) ) {
1510 m = Double.parseDouble( m_str );
1512 catch ( final Exception ex ) {
1519 if ( success && ( m >= 0.0 ) ) {
1520 getOptions().setMinConfidenceValue( m );
1525 private void doUpdateProcessMenu() {
1526 if ( _process_pool.size() > 0 ) {
1527 if ( _process_menu == null ) {
1528 _process_menu = createMenu( "", getConfiguration() );
1529 _process_menu.setForeground( Color.RED );
1531 _process_menu.removeAll();
1532 final String text = "processes running: " + _process_pool.size();
1533 _process_menu.setText( text );
1534 _jmenubar.add( _process_menu );
1535 for( int i = 0; i < _process_pool.size(); ++i ) {
1536 final ProcessRunning p = _process_pool.getProcessByIndex( i );
1537 _process_menu.add( customizeJMenuItem( new JMenuItem( p.getName() + " [" + p.getStart() + "]" ) ) );
1541 if ( _process_menu != null ) {
1542 _process_menu.removeAll();
1543 _jmenubar.remove( _process_menu );
1546 _jmenubar.validate();
1547 _jmenubar.repaint();
1551 private String getPreviousNodeAnnotationReference() {
1552 return _previous_node_annotation_ref;
1555 private void removeBranchColors() {
1556 if ( getMainPanel().getCurrentPhylogeny() != null ) {
1557 AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
1561 private void setPreviousNodeAnnotationReference( final String previous_node_annotation_ref ) {
1562 _previous_node_annotation_ref = previous_node_annotation_ref;
1566 * Display the about box.
1568 static void about() {
1569 final StringBuffer about = new StringBuffer( "Archaeopteryx\nVersion " + Constants.VERSION + "\n" );
1570 about.append( "Copyright (C) 2013 Christian M. Zmasek\n" );
1571 about.append( "All Rights Reserved\n" );
1572 about.append( "License: GNU Lesser General Public License (LGPL)\n" );
1573 about.append( "Last modified: " + Constants.PRG_DATE + "\n" );
1574 about.append( "Based on: " + ForesterUtil.getForesterLibraryInformation() + "\n" );
1575 about.append( "phyloXML version : " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
1576 about.append( "phyloXML location: " + ForesterConstants.PHYLO_XML_LOCATION + "\n" );
1577 if ( !ForesterUtil.isEmpty( ForesterUtil.JAVA_VERSION ) && !ForesterUtil.isEmpty( ForesterUtil.JAVA_VENDOR ) ) {
1578 about.append( "[your Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]\n" );
1580 if ( !ForesterUtil.isEmpty( ForesterUtil.OS_NAME ) && !ForesterUtil.isEmpty( ForesterUtil.OS_ARCH )
1581 && !ForesterUtil.isEmpty( ForesterUtil.OS_VERSION ) ) {
1582 about.append( "[your OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " "
1583 + ForesterUtil.OS_VERSION + "]\n" );
1585 final Runtime rt = java.lang.Runtime.getRuntime();
1586 final long free_memory = rt.freeMemory() / 1000000;
1587 final long total_memory = rt.totalMemory() / 1000000;
1588 about.append( "[free memory: " + free_memory + "MB, total memory: " + total_memory + "MB]\n" );
1589 about.append( "[locale: " + Locale.getDefault() + "]\n" );
1590 about.append( "References:\n" );
1591 about.append( Constants.PHYLOXML_REFERENCE_SHORT + "\n" );
1592 about.append( "For more information & download:\n" );
1593 about.append( Constants.APTX_WEB_SITE + "\n" );
1594 about.append( "Comments: " + Constants.AUTHOR_EMAIL );
1595 JOptionPane.showMessageDialog( null, about, Constants.PRG_NAME, JOptionPane.PLAIN_MESSAGE );
1598 static void chooseNodeSize( final Options options, final Component parent ) {
1599 final String s = ( String ) JOptionPane.showInputDialog( parent,
1600 "Please enter the default size for node shapes.\n"
1601 + "[current value: "
1602 + options.getDefaultNodeShapeSize() + "]\n",
1604 JOptionPane.QUESTION_MESSAGE,
1607 options.getDefaultNodeShapeSize() );
1608 if ( !ForesterUtil.isEmpty( s ) ) {
1609 boolean success = true;
1611 final String m_str = s.trim();
1612 if ( !ForesterUtil.isEmpty( m_str ) ) {
1614 m = Double.parseDouble( m_str );
1616 catch ( final Exception ex ) {
1623 if ( success && ( m >= 0.0 ) ) {
1624 final short size = ForesterUtil.roundToShort( m );
1625 if ( size >= 0.0 ) {
1626 options.setDefaultNodeShapeSize( size );
1632 static String createCurrentFontDesc( final TreeFontSet tree_font_set ) {
1633 return tree_font_set.getLargeFont().getFamily() + " " + tree_font_set.getLargeFont().getSize();
1636 static JMenu createMenu( final String title, final Configuration conf ) {
1637 final JMenu jmenu = new JMenu( title );
1638 if ( !conf.isUseNativeUI() ) {
1639 jmenu.setFont( MainFrame.menu_font );
1640 jmenu.setBackground( conf.getGuiMenuBackgroundColor() );
1641 jmenu.setForeground( conf.getGuiMenuTextColor() );
1646 static JMenuItem customizeMenuItemAsLabel( final JMenuItem label, final Configuration configuration ) {
1647 label.setFont( MainFrame.menu_font.deriveFont( Font.BOLD ) );
1648 if ( !configuration.isUseNativeUI() ) {
1649 label.setBackground( configuration.getGuiMenuBackgroundColor() );
1650 label.setForeground( configuration.getGuiMenuTextColor() );
1651 label.setOpaque( true );
1653 label.setSelected( false );
1654 label.setEnabled( false );
1658 static void cycleNodeFill( final Options op, final TreePanel tree_panel ) {
1659 switch ( op.getDefaultNodeFill() ) {
1661 op.setDefaultNodeFill( NodeFill.SOLID );
1664 op.setDefaultNodeFill( NodeFill.GRADIENT );
1667 op.setDefaultNodeFill( NodeFill.NONE );
1670 throw new RuntimeException( "unknown fill: " + op.getDefaultNodeFill() );
1674 static void cycleNodeShape( final Options op, final TreePanel tree_panel ) {
1675 switch ( op.getDefaultNodeShape() ) {
1677 op.setDefaultNodeShape( NodeShape.RECTANGLE );
1680 op.setDefaultNodeShape( NodeShape.CIRCLE );
1683 throw new RuntimeException( "unknown shape: " + op.getDefaultNodeShape() );
1687 static void cycleOverview( final Options op, final TreePanel tree_panel ) {
1688 switch ( op.getOvPlacement() ) {
1690 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1693 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1696 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1699 op.setOvPlacement( Options.OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1702 throw new RuntimeException( "unknown placement: " + op.getOvPlacement() );
1704 if ( tree_panel != null ) {
1705 tree_panel.updateOvSettings();
1709 static void setCycleNodeFillMenuItem( final JMenuItem mi, final Options options ) {
1710 if ( ( options != null ) && ( options.getDefaultNodeFill() != null ) ) {
1711 mi.setText( "Cycle Node Shape Fill Type... (current: "
1712 + options.getDefaultNodeFill().toString().toLowerCase() + ")" );
1715 mi.setText( "Cycle Node Shape Fill Type..." );
1719 static void setCycleNodeShapeMenuItem( final JMenuItem mi, final Options options ) {
1720 if ( ( options != null ) && ( options.getDefaultNodeShape() != null ) ) {
1721 mi.setText( "Cycle Node Shape Fill Type... (current: "
1722 + options.getDefaultNodeShape().toString().toLowerCase() + ")" );
1725 mi.setText( "Cycle Node Shape Fill Type..." );
1729 static void setOvPlacementColorChooseMenuItem( final JMenuItem mi, final Options options ) {
1730 if ( ( options != null ) && ( options.getOvPlacement() != null ) ) {
1731 mi.setText( "Cycle Overview Placement... (current: " + options.getOvPlacement() + ")" );
1734 mi.setText( "Cycle Overview Placement..." );
1738 static void setTextColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {
1739 if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {
1740 mi.setText( "Select Colors... (current: " + tree_panel.getTreeColorSet().getCurrentColorSchemeName() + ")" );
1743 mi.setText( "Select Colors..." );
1747 static void setTextForFontChooserMenuItem( final JMenuItem mi, final String font_desc ) {
1748 mi.setText( "Select Font... (current: " + font_desc + ")" );
1751 static void setTextMinSupportMenuItem( final JMenuItem mi, final Options options, final TreePanel current_tree_panel ) {
1752 if ( ( current_tree_panel == null ) || ( current_tree_panel.getPhylogeny() == null ) ) {
1753 mi.setEnabled( true );
1755 else if ( AptxUtil.isHasAtLeastOneBranchWithSupportValues( current_tree_panel.getPhylogeny() ) ) {
1756 mi.setEnabled( true );
1759 mi.setEnabled( false );
1761 mi.setText( "Enter Min Confidence Value... (current: " + options.getMinConfidenceValue() + ")" );
1764 static void setTextNodeSizeMenuItem( final JMenuItem mi, final Options options ) {
1765 mi.setText( "Enter Default Node Shape Size... (current: " + options.getDefaultNodeShapeSize() + ")" );
1768 static void updateOptionsMenuDependingOnPhylogenyType( final MainPanel main_panel,
1769 final JCheckBoxMenuItem scale,
1770 final JCheckBoxMenuItem branch_lengths,
1771 final JRadioButtonMenuItem non_lined_up,
1772 final JRadioButtonMenuItem uniform_clado,
1773 final JRadioButtonMenuItem nonuniform_clado,
1774 final JCheckBoxMenuItem label_direction_cbmi ) {
1775 final TreePanel tree_panel = main_panel.getCurrentTreePanel();
1776 final ControlPanel control = main_panel.getControlPanel();
1777 final Options options = main_panel.getOptions();
1778 scale.setSelected( options.isShowScale() );
1779 branch_lengths.setSelected( options.isShowBranchLengthValues() );
1780 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1781 if ( ( tree_panel != null ) && ( !tree_panel.isPhyHasBranchLengths() ) ) {
1782 scale.setSelected( false );
1783 scale.setEnabled( false );
1784 branch_lengths.setSelected( false );
1785 branch_lengths.setEnabled( false );
1787 else if ( ( tree_panel != null ) && !control.isDrawPhylogram() ) {
1788 scale.setSelected( false );
1789 scale.setEnabled( false );
1790 branch_lengths.setEnabled( true );
1793 scale.setEnabled( true );
1794 branch_lengths.setEnabled( true );
1796 if ( ( tree_panel != null )
1797 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.ROUNDED )
1798 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1799 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1800 branch_lengths.setSelected( false );
1801 branch_lengths.setEnabled( false );
1803 if ( tree_panel != null ) {
1804 if ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
1805 || ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
1806 non_lined_up.setEnabled( false );
1807 uniform_clado.setEnabled( false );
1808 nonuniform_clado.setEnabled( false );
1811 non_lined_up.setEnabled( true );
1812 uniform_clado.setEnabled( true );
1813 nonuniform_clado.setEnabled( true );
1817 if ( ( tree_panel != null )
1818 && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel
1819 .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {
1820 branch_lengths.setSelected( false );
1821 branch_lengths.setEnabled( false );
1823 if ( ( tree_panel != null )
1824 && ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( tree_panel
1825 .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
1826 non_lined_up.setEnabled( false );
1829 // non_lined_up.setSelected( options.isNonLinedUpCladogram() );
1830 non_lined_up.setEnabled( true );
1833 label_direction_cbmi.setEnabled( true );
1834 if ( tree_panel != null ) {
1835 if ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
1836 && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
1837 label_direction_cbmi.setEnabled( false );
1839 if ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
1840 scale.setSelected( false );
1841 scale.setEnabled( false );
1846 static void updateScreenTextAntialias( final List<TreePanel> treepanels ) {
1847 for( final TreePanel tree_panel : treepanels ) {
1848 tree_panel.setTextAntialias();