import javax.swing.Box;\r
import javax.swing.JApplet;\r
import javax.swing.JCheckBoxMenuItem;\r
+import javax.swing.JFileChooser;\r
import javax.swing.JFrame;\r
import javax.swing.JLabel;\r
import javax.swing.JMenu;\r
import javax.swing.JRadioButtonMenuItem;\r
import javax.swing.JTextField;\r
import javax.swing.SwingUtilities;\r
+import javax.swing.filechooser.FileFilter;\r
\r
+import org.forester.archaeopteryx.AptxUtil.GraphicsExportType;\r
import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;\r
import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;\r
import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;\r
+import org.forester.archaeopteryx.tools.AncestralTaxonomyInferrer;\r
import org.forester.archaeopteryx.tools.InferenceManager;\r
import org.forester.archaeopteryx.tools.ProcessPool;\r
import org.forester.archaeopteryx.tools.ProcessRunning;\r
import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;\r
+import org.forester.io.writers.PhylogenyWriter;\r
import org.forester.phylogeny.Phylogeny;\r
import org.forester.phylogeny.PhylogenyMethods;\r
import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;\r
import org.forester.phylogeny.PhylogenyNode;\r
import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;\r
import org.forester.phylogeny.data.Annotation;\r
+import org.forester.phylogeny.data.NodeDataField;\r
import org.forester.phylogeny.data.NodeVisualData.NodeFill;\r
import org.forester.phylogeny.data.NodeVisualData.NodeShape;\r
import org.forester.phylogeny.iterators.PhylogenyNodeIterator;\r
import org.forester.sdi.SDIException;\r
import org.forester.util.ForesterConstants;\r
import org.forester.util.ForesterUtil;\r
+import org.forester.util.WindowsUtils;\r
\r
public abstract class MainFrame extends JFrame implements ActionListener {\r
\r
- static final String USE_MOUSEWHEEL_SHIFT_TO_ROTATE = "In this display type, use mousewheel + Shift to rotate [or A and S]";\r
- static final String PHYLOXML_REF_TOOL_TIP = Constants.PHYLOXML_REFERENCE; //TODO //FIXME\r
- static final String APTX_REF_TOOL_TIP = Constants.APTX_REFERENCE;\r
- private static final long serialVersionUID = 3655000897845508358L;\r
- final static Font menu_font = new Font( Configuration.getDefaultFontFamilyName(),\r
- Font.PLAIN,\r
- 10 );\r
- static final String TYPE_MENU_HEADER = "Type";\r
- static final String RECTANGULAR_TYPE_CBMI_LABEL = "Rectangular";\r
- static final String EURO_TYPE_CBMI_LABEL = "Euro Type";\r
- static final String CURVED_TYPE_CBMI_LABEL = "Curved";\r
- static final String TRIANGULAR_TYPE_CBMI_LABEL = "Triangular";\r
- static final String CONVEX_TYPE_CBMI_LABEL = "Convex";\r
- static final String ROUNDED_TYPE_CBMI_LABEL = "Rounded";\r
- static final String UNROOTED_TYPE_CBMI_LABEL = "Unrooted (alpha)"; //TODO\r
- static final String CIRCULAR_TYPE_CBMI_LABEL = "Circular (alpha)"; //TODO\r
- static final String OPTIONS_HEADER = "Options";\r
- static final String SEARCH_SUBHEADER = "Search:";\r
- static final String DISPLAY_SUBHEADER = "Display:";\r
- static final String SEARCH_TERMS_ONLY_LABEL = "Match Complete Terms Only";\r
- static final String SEARCH_CASE_SENSITIVE_LABEL = "Case Sensitive";\r
- static final String INVERSE_SEARCH_RESULT_LABEL = "Negate Result";\r
- static final String DISPLAY_BRANCH_LENGTH_VALUES_LABEL = "Branch Length Values";\r
- static final String COLOR_BY_TAXONOMIC_GROUP = "Colorize by Taxonomic Group";\r
- static final String DISPLAY_SCALE_LABEL = "Scale";\r
- static final String NON_LINED_UP_CLADOGRAMS_LABEL = "Non-Lined Up Cladograms";\r
- static final String UNIFORM_CLADOGRAMS_LABEL = "Total Node Sum Dependent Cladograms";\r
- static final String LABEL_DIRECTION_LABEL = "Radial Labels";\r
- static final String LABEL_DIRECTION_TIP = "To use radial node labels in radial and unrooted display types";\r
- static final String SCREEN_ANTIALIAS_LABEL = "Antialias";\r
- static final String COLOR_LABELS_LABEL = "Colorize Labels Same as Parent Branch";\r
- static final String BG_GRAD_LABEL = "Background Color Gradient";\r
- static final String DISPLAY_NODE_BOXES_LABEL_EXT = "External Node Shapes";\r
- static final String DISPLAY_NODE_BOXES_LABEL_INT = "Internal Node Shapes";\r
- static final String SHOW_OVERVIEW_LABEL = "Overview";\r
- static final String FONT_SIZE_MENU_LABEL = "Font Size";\r
- static final String NONUNIFORM_CLADOGRAMS_LABEL = "External Node Sum Dependent Cladograms";\r
- static final String SHOW_DOMAIN_LABELS_LABEL = "Domain Labels";\r
- static final String SHOW_ANN_REF_SOURCE_LABEL = "Seq Annotation Ref Sources";\r
- 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";\r
- static final String ABBREV_SN_LABEL = "Abbreviate Scientific Taxonomic Names";\r
- static final String TAXONOMY_COLORIZE_NODE_SHAPES_LABEL = "Colorize Node Shapes According to Taxonomy";\r
- static final String CYCLE_NODE_SHAPE_LABEL = "Cycle Node Shapes";\r
- static final String CYCLE_NODE_FILL_LABEL = "Cycle Node Fill Type";\r
- static final String CHOOSE_NODE_SIZE_LABEL = "Choose Node Shape Size";\r
- static final String SHOW_CONF_STDDEV_LABEL = "Confidence Standard Deviations";\r
- static final String USE_BRACKETS_FOR_CONF_IN_NH_LABEL = "Use Brackets for Confidence Values";\r
- static final String USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL = "Use Internal Node Names for Confidence Values";\r
- static final String SHOW_BASIC_TREE_INFORMATION_LABEL = "Basic Tree Information";\r
- static final String RIGHT_LINE_UP_DOMAINS = "Right-align Domain Architectures";\r
- static final String LINE_UP_RENDERABLE_DATA = "Line Up Node Diagrams";\r
- JMenuBar _jmenubar;\r
- JMenu _file_jmenu;\r
- JMenu _tools_menu;\r
- JMenu _view_jmenu;\r
- JMenu _options_jmenu;\r
- JMenu _font_size_menu;\r
- JMenu _help_jmenu;\r
- JMenuItem[] _load_phylogeny_from_webservice_menu_items;\r
+ final static NHFilter nhfilter = new NHFilter();\r
+ final static NHXFilter nhxfilter = new NHXFilter();\r
+ final static XMLFilter xmlfilter = new XMLFilter();\r
+ final static TolFilter tolfilter = new TolFilter();\r
+ final static NexusFilter nexusfilter = new NexusFilter();\r
+ final static PdfFilter pdffilter = new PdfFilter();\r
+ final static GraphicsFileFilter graphicsfilefilter = new GraphicsFileFilter();\r
+ final static MsaFileFilter msafilter = new MsaFileFilter();\r
+ final static SequencesFileFilter seqsfilter = new SequencesFileFilter();\r
+ final static DefaultFilter defaultfilter = new DefaultFilter();\r
+ static final String USE_MOUSEWHEEL_SHIFT_TO_ROTATE = "In this display type, use mousewheel + Shift to rotate [or A and S]";\r
+ static final String PHYLOXML_REF_TOOL_TIP = Constants.PHYLOXML_REFERENCE; //TODO //FIXME\r
+ static final String APTX_REF_TOOL_TIP = Constants.APTX_REFERENCE;\r
+ private static final long serialVersionUID = 3655000897845508358L;\r
+ final static Font menu_font = new Font( Configuration.getDefaultFontFamilyName(),\r
+ Font.PLAIN,\r
+ 10 );\r
+ static final String TYPE_MENU_HEADER = "Type";\r
+ static final String RECTANGULAR_TYPE_CBMI_LABEL = "Rectangular";\r
+ static final String EURO_TYPE_CBMI_LABEL = "Euro Type";\r
+ static final String CURVED_TYPE_CBMI_LABEL = "Curved";\r
+ static final String TRIANGULAR_TYPE_CBMI_LABEL = "Triangular";\r
+ static final String CONVEX_TYPE_CBMI_LABEL = "Convex";\r
+ static final String ROUNDED_TYPE_CBMI_LABEL = "Rounded";\r
+ static final String UNROOTED_TYPE_CBMI_LABEL = "Unrooted (alpha)"; //TODO\r
+ static final String CIRCULAR_TYPE_CBMI_LABEL = "Circular (alpha)"; //TODO\r
+ static final String OPTIONS_HEADER = "Options";\r
+ static final String SEARCH_SUBHEADER = "Search:";\r
+ static final String DISPLAY_SUBHEADER = "Display:";\r
+ static final String SEARCH_TERMS_ONLY_LABEL = "Match Complete Terms Only";\r
+ static final String SEARCH_REGEX_LABEL = "Search with Regular Expressions";\r
+ static final String SEARCH_CASE_SENSITIVE_LABEL = "Case Sensitive";\r
+ static final String INVERSE_SEARCH_RESULT_LABEL = "Negate Result";\r
+ static final String COLOR_BY_TAXONOMIC_GROUP = "Colorize by Taxonomic Group";\r
+ static final String DISPLAY_SCALE_LABEL = "Scale";\r
+ static final String NON_LINED_UP_CLADOGRAMS_LABEL = "Non-Lined Up Cladograms";\r
+ static final String UNIFORM_CLADOGRAMS_LABEL = "Total Node Sum Dependent Cladograms";\r
+ static final String LABEL_DIRECTION_LABEL = "Radial Labels";\r
+ static final String LABEL_DIRECTION_TIP = "To use radial node labels in radial and unrooted display types";\r
+ static final String SEARCH_WITH_REGEX_TIP = "To search using regular expressions (~Java/Perl syntax). For example, use \"^B.+\\d{2,}$\" to search for everything starting with a B and ending with at least two digits.";\r
+ static final String SCREEN_ANTIALIAS_LABEL = "Antialias";\r
+ static final String COLOR_LABELS_LABEL = "Colorize Labels Same as Parent Branch";\r
+ static final String BG_GRAD_LABEL = "Background Color Gradient";\r
+ static final String DISPLAY_NODE_BOXES_LABEL_EXT = "Shapes for External Nodes";\r
+ static final String DISPLAY_NODE_BOXES_LABEL_INT = "Shapes for Internal Nodes";\r
+ static final String DISPLAY_NODE_BOXES_LABEL_MARKED = "Shapes for Nodes with Visual Data";\r
+ static final String SHOW_OVERVIEW_LABEL = "Overview";\r
+ static final String FONT_SIZE_MENU_LABEL = "Font Size";\r
+ static final String NONUNIFORM_CLADOGRAMS_LABEL = "External Node Sum Dependent Cladograms";\r
+ static final String SHOW_DOMAIN_LABELS_LABEL = "Domain Labels";\r
+ static final String SHOW_ANN_REF_SOURCE_LABEL = "Seq Annotation Ref Sources";\r
+ 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";\r
+ static final String ABBREV_SN_LABEL = "Abbreviate Scientific Taxonomic Names";\r
+ static final String TAXONOMY_COLORIZE_NODE_SHAPES_LABEL = "Colorize Node Shapes According to Taxonomy";\r
+ static final String CYCLE_NODE_SHAPE_LABEL = "Cycle Node Shapes";\r
+ static final String CYCLE_NODE_FILL_LABEL = "Cycle Node Fill Type";\r
+ static final String CHOOSE_NODE_SIZE_LABEL = "Choose Node Shape Size";\r
+ static final String SHOW_CONF_STDDEV_LABEL = "Confidence Standard Deviations";\r
+ static final String USE_BRACKETS_FOR_CONF_IN_NH_LABEL = "Use Brackets for Confidence Values";\r
+ static final String USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL = "Use Internal Node Names for Confidence Values";\r
+ static final String SHOW_BASIC_TREE_INFORMATION_LABEL = "Basic Tree Information";\r
+ static final String RIGHT_LINE_UP_DOMAINS = "Right-align Domain Architectures";\r
+ static final String LINE_UP_RENDERABLE_DATA = "Line Up Diagrams (such as Domain Architectures)";\r
+ static final String INFER_ANCESTOR_TAXONOMIES = "Infer Ancestor Taxonomies";\r
+ static final String OBTAIN_DETAILED_TAXONOMIC_INFORMATION = "Obtain Detailed Taxonomic Information";\r
+ JMenuBar _jmenubar;\r
+ JMenu _file_jmenu;\r
+ JMenu _tools_menu;\r
+ JMenu _view_jmenu;\r
+ JMenu _options_jmenu;\r
+ JMenu _font_size_menu;\r
+ JMenu _help_jmenu;\r
+ JMenuItem[] _load_phylogeny_from_webservice_menu_items;\r
// Analysis menu\r
- JMenu _analysis_menu;\r
- JMenuItem _load_species_tree_item;\r
- JMenuItem _gsdi_item;\r
- JMenuItem _gsdir_item;\r
- JMenuItem _lineage_inference;\r
+ JMenu _analysis_menu;\r
+ JMenuItem _load_species_tree_item;\r
+ JMenuItem _gsdi_item;\r
+ JMenuItem _gsdir_item;\r
+ JMenuItem _lineage_inference;\r
// file menu:\r
- JMenuItem _open_item;\r
- JMenuItem _open_url_item;\r
- JMenuItem _save_item;\r
- JMenuItem _save_all_item;\r
- JMenuItem _close_item;\r
- JMenuItem _exit_item;\r
- JMenuItem _new_item;\r
+ JMenuItem _open_item;\r
+ JMenuItem _open_url_item;\r
+ JMenuItem _save_item;\r
+ JMenuItem _save_all_item;\r
+ JMenuItem _close_item;\r
+ JMenuItem _exit_item;\r
+ JMenuItem _new_item;\r
+ JMenuItem _print_item;\r
+ JMenuItem _write_to_pdf_item;\r
+ JMenuItem _write_to_jpg_item;\r
+ JMenuItem _write_to_gif_item;\r
+ JMenuItem _write_to_tif_item;\r
+ JMenuItem _write_to_png_item;\r
+ JMenuItem _write_to_bmp_item;\r
// tools menu:\r
- JMenuItem _midpoint_root_item;\r
- JMenuItem _taxcolor_item;\r
- JMenuItem _confcolor_item;\r
- JMenuItem _color_rank_jmi;\r
- JMenuItem _collapse_species_specific_subtrees;\r
- JMenuItem _collapse_below_threshold; //TODO implememt me\r
- JMenuItem _obtain_detailed_taxonomic_information_jmi;\r
- JMenuItem _obtain_detailed_taxonomic_information_deleting_jmi;\r
- JMenuItem _obtain_seq_information_jmi;\r
- JMenuItem _move_node_names_to_tax_sn_jmi;\r
- JMenuItem _move_node_names_to_seq_names_jmi;\r
- JMenuItem _extract_tax_code_from_node_names_jmi;\r
- JMenuItem _annotate_item;\r
- JMenuItem _remove_branch_color_item;\r
- JMenuItem _remove_visual_styles_item;\r
- JMenuItem _delete_selected_nodes_item;\r
- JMenuItem _delete_not_selected_nodes_item;\r
+ JMenuItem _midpoint_root_item;\r
+ JMenuItem _taxcolor_item;\r
+ JMenuItem _confcolor_item;\r
+ JMenuItem _color_rank_jmi;\r
+ JMenuItem _collapse_species_specific_subtrees;\r
+ JMenuItem _obtain_detailed_taxonomic_information_jmi;\r
+ JMenuItem _obtain_detailed_taxonomic_information_deleting_jmi;\r
+ JMenuItem _obtain_seq_information_jmi;\r
+ JMenuItem _move_node_names_to_tax_sn_jmi;\r
+ JMenuItem _move_node_names_to_seq_names_jmi;\r
+ JMenuItem _extract_tax_code_from_node_names_jmi;\r
+ JMenuItem _annotate_item;\r
+ JMenuItem _remove_branch_color_item;\r
+ JMenuItem _remove_visual_styles_item;\r
+ JMenuItem _delete_selected_nodes_item;\r
+ JMenuItem _delete_not_selected_nodes_item;\r
// font size menu:\r
- JMenuItem _super_tiny_fonts_item;\r
- JMenuItem _tiny_fonts_item;\r
- JMenuItem _small_fonts_item;\r
- JMenuItem _medium_fonts_item;\r
- JMenuItem _large_fonts_item;\r
+ JMenuItem _super_tiny_fonts_item;\r
+ JMenuItem _tiny_fonts_item;\r
+ JMenuItem _small_fonts_item;\r
+ JMenuItem _medium_fonts_item;\r
+ JMenuItem _large_fonts_item;\r
// options menu:\r
// _ screen and print\r
- JMenuItem _choose_font_mi;\r
- JMenuItem _switch_colors_mi;\r
- JCheckBoxMenuItem _label_direction_cbmi;\r
+ JMenuItem _choose_font_mi;\r
+ JMenuItem _switch_colors_mi;\r
+ JCheckBoxMenuItem _label_direction_cbmi;\r
// _ screen display\r
- JCheckBoxMenuItem _screen_antialias_cbmi;\r
- JCheckBoxMenuItem _background_gradient_cbmi;\r
- JRadioButtonMenuItem _non_lined_up_cladograms_rbmi;\r
- JRadioButtonMenuItem _uniform_cladograms_rbmi;\r
- JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi;\r
- JCheckBoxMenuItem _show_branch_length_values_cbmi;\r
- JCheckBoxMenuItem _color_by_taxonomic_group_cbmi;\r
- JCheckBoxMenuItem _show_scale_cbmi; //TODO fix me\r
- JCheckBoxMenuItem _show_overview_cbmi;\r
- JCheckBoxMenuItem _show_domain_labels;\r
- JCheckBoxMenuItem _show_annotation_ref_source;\r
- JCheckBoxMenuItem _abbreviate_scientific_names;\r
- JCheckBoxMenuItem _color_labels_same_as_parent_branch;\r
- JMenuItem _overview_placment_mi;\r
- JMenuItem _choose_minimal_confidence_mi;\r
- JCheckBoxMenuItem _show_default_node_shapes_internal_cbmi;\r
- JCheckBoxMenuItem _show_default_node_shapes_external_cbmi;\r
- JMenuItem _cycle_node_shape_mi;\r
- JMenuItem _cycle_node_fill_mi;\r
- JMenuItem _choose_node_size_mi;\r
- JCheckBoxMenuItem _show_confidence_stddev_cbmi;\r
- JCheckBoxMenuItem _right_line_up_domains_cbmi;\r
- JCheckBoxMenuItem _line_up_renderable_data_cbmi;\r
+ JCheckBoxMenuItem _screen_antialias_cbmi;\r
+ JCheckBoxMenuItem _background_gradient_cbmi;\r
+ JRadioButtonMenuItem _non_lined_up_cladograms_rbmi;\r
+ JRadioButtonMenuItem _uniform_cladograms_rbmi;\r
+ JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi;\r
+ JCheckBoxMenuItem _color_by_taxonomic_group_cbmi;\r
+ JCheckBoxMenuItem _show_scale_cbmi; //TODO fix me\r
+ JCheckBoxMenuItem _show_overview_cbmi;\r
+ JCheckBoxMenuItem _show_domain_labels;\r
+ JCheckBoxMenuItem _show_annotation_ref_source;\r
+ JCheckBoxMenuItem _abbreviate_scientific_names;\r
+ JCheckBoxMenuItem _color_labels_same_as_parent_branch;\r
+ JMenuItem _overview_placment_mi;\r
+ JMenuItem _choose_minimal_confidence_mi;\r
+ JCheckBoxMenuItem _show_default_node_shapes_internal_cbmi;\r
+ JCheckBoxMenuItem _show_default_node_shapes_external_cbmi;\r
+ JCheckBoxMenuItem _show_default_node_shapes_for_marked_cbmi;\r
+ JMenuItem _cycle_node_shape_mi;\r
+ JMenuItem _cycle_node_fill_mi;\r
+ JMenuItem _choose_node_size_mi;\r
+ JMenuItem _cycle_data_return;\r
+ JCheckBoxMenuItem _show_confidence_stddev_cbmi;\r
+ JCheckBoxMenuItem _right_line_up_domains_cbmi;\r
+ JCheckBoxMenuItem _line_up_renderable_data_cbmi;\r
// _ print\r
- JCheckBoxMenuItem _graphics_export_visible_only_cbmi;\r
- JCheckBoxMenuItem _antialias_print_cbmi;\r
- JCheckBoxMenuItem _print_black_and_white_cbmi;\r
- JCheckBoxMenuItem _print_using_actual_size_cbmi;\r
- JCheckBoxMenuItem _graphics_export_using_actual_size_cbmi;\r
- JMenuItem _print_size_mi;\r
- JMenuItem _choose_pdf_width_mi;\r
+ JCheckBoxMenuItem _graphics_export_visible_only_cbmi;\r
+ JCheckBoxMenuItem _antialias_print_cbmi;\r
+ JCheckBoxMenuItem _print_black_and_white_cbmi;\r
+ JCheckBoxMenuItem _print_using_actual_size_cbmi;\r
+ JCheckBoxMenuItem _graphics_export_using_actual_size_cbmi;\r
+ JMenuItem _print_size_mi;\r
+ JMenuItem _choose_pdf_width_mi;\r
// _ parsing\r
- JCheckBoxMenuItem _internal_number_are_confidence_for_nh_parsing_cbmi;\r
- JRadioButtonMenuItem _extract_taxonomy_no_rbmi;\r
- JRadioButtonMenuItem _extract_taxonomy_agressive_rbmi;\r
- JRadioButtonMenuItem _extract_taxonomy_pfam_strict_rbmi;\r
- JRadioButtonMenuItem _extract_taxonomy_pfam_relaxed_rbmi;\r
- JCheckBoxMenuItem _replace_underscores_cbmi;\r
- JCheckBoxMenuItem _allow_errors_in_distance_to_parent_cbmi;\r
- JCheckBoxMenuItem _use_brackets_for_conf_in_nh_export_cbmi;\r
- JCheckBoxMenuItem _use_internal_names_for_conf_in_nh_export_cbmi;\r
+ JCheckBoxMenuItem _internal_number_are_confidence_for_nh_parsing_cbmi;\r
+ JRadioButtonMenuItem _extract_taxonomy_no_rbmi;\r
+ JRadioButtonMenuItem _extract_taxonomy_agressive_rbmi;\r
+ JRadioButtonMenuItem _extract_taxonomy_pfam_strict_rbmi;\r
+ JRadioButtonMenuItem _extract_taxonomy_pfam_relaxed_rbmi;\r
+ JCheckBoxMenuItem _replace_underscores_cbmi;\r
+ JCheckBoxMenuItem _allow_errors_in_distance_to_parent_cbmi;\r
+ JCheckBoxMenuItem _use_brackets_for_conf_in_nh_export_cbmi;\r
+ JCheckBoxMenuItem _use_internal_names_for_conf_in_nh_export_cbmi;\r
// _ search\r
- JCheckBoxMenuItem _search_case_senstive_cbmi;\r
- JCheckBoxMenuItem _search_whole_words_only_cbmi;\r
- JCheckBoxMenuItem _inverse_search_result_cbmi;\r
+ JCheckBoxMenuItem _search_case_senstive_cbmi;\r
+ JCheckBoxMenuItem _search_whole_words_only_cbmi;\r
+ JCheckBoxMenuItem _inverse_search_result_cbmi;\r
+ JCheckBoxMenuItem _search_with_regex_cbmi;\r
// type menu:\r
- JMenu _type_menu;\r
- JCheckBoxMenuItem _rectangular_type_cbmi;\r
- JCheckBoxMenuItem _triangular_type_cbmi;\r
- JCheckBoxMenuItem _curved_type_cbmi;\r
- JCheckBoxMenuItem _convex_type_cbmi;\r
- JCheckBoxMenuItem _euro_type_cbmi;\r
- JCheckBoxMenuItem _rounded_type_cbmi;\r
- JCheckBoxMenuItem _unrooted_type_cbmi;\r
- JCheckBoxMenuItem _circular_type_cbmi;\r
+ JMenu _type_menu;\r
+ JCheckBoxMenuItem _rectangular_type_cbmi;\r
+ JCheckBoxMenuItem _triangular_type_cbmi;\r
+ JCheckBoxMenuItem _curved_type_cbmi;\r
+ JCheckBoxMenuItem _convex_type_cbmi;\r
+ JCheckBoxMenuItem _euro_type_cbmi;\r
+ JCheckBoxMenuItem _rounded_type_cbmi;\r
+ JCheckBoxMenuItem _unrooted_type_cbmi;\r
+ JCheckBoxMenuItem _circular_type_cbmi;\r
// view as text menu:\r
- JMenuItem _view_as_NH_item;\r
- JMenuItem _view_as_XML_item;\r
- JMenuItem _view_as_nexus_item;\r
- JMenuItem _display_basic_information_item;\r
+ JMenuItem _view_as_NH_item;\r
+ JMenuItem _view_as_XML_item;\r
+ JMenuItem _view_as_nexus_item;\r
+ JMenuItem _display_basic_information_item;\r
// help menu:\r
- JMenuItem _about_item;\r
- JMenuItem _help_item;\r
- JMenuItem _website_item;\r
- JMenuItem _phyloxml_website_item;\r
- JMenuItem _phyloxml_ref_item;\r
- JMenuItem _aptx_ref_item;\r
+ JMenuItem _about_item;\r
+ JMenuItem _help_item;\r
+ JMenuItem _website_item;\r
+ JMenuItem _phyloxml_website_item;\r
+ JMenuItem _phyloxml_ref_item;\r
+ JMenuItem _aptx_ref_item;\r
+ //\r
+ File _current_dir;\r
+ JFileChooser _writetopdf_filechooser;\r
+ JFileChooser _save_filechooser;\r
+ JFileChooser _writetographics_filechooser;\r
// process menu:\r
- JMenu _process_menu;\r
- // Handy pointers to child components:\r
- MainPanel _mainpanel;\r
- Container _contentpane;\r
- final LinkedList<TextFrame> _textframes = new LinkedList<TextFrame>(); ;\r
- Configuration _configuration;\r
- Options _options;\r
- private Phylogeny _species_tree;\r
- InferenceManager _inference_manager;\r
- final ProcessPool _process_pool;\r
- private String _previous_node_annotation_ref;\r
+ JMenu _process_menu;\r
+ MainPanel _mainpanel;\r
+ Container _contentpane;\r
+ final LinkedList<TextFrame> _textframes = new LinkedList<TextFrame>(); ;\r
+ Configuration _configuration;\r
+ Options _options;\r
+ private Phylogeny _species_tree;\r
+ InferenceManager _inference_manager;\r
+ final ProcessPool _process_pool;\r
+ private String _previous_node_annotation_ref;\r
\r
MainFrame() {\r
_process_pool = ProcessPool.createInstance();\r
+ _writetopdf_filechooser = new JFileChooser();\r
+ _writetopdf_filechooser.setMultiSelectionEnabled( false );\r
+ _writetopdf_filechooser.addChoosableFileFilter( pdffilter );\r
+ _writetographics_filechooser = new JFileChooser();\r
+ _writetographics_filechooser.setMultiSelectionEnabled( false );\r
+ _writetographics_filechooser.addChoosableFileFilter( graphicsfilefilter );\r
+ _save_filechooser = new JFileChooser();\r
+ _save_filechooser.setMultiSelectionEnabled( false );\r
+ _save_filechooser.setFileFilter( xmlfilter );\r
+ _save_filechooser.addChoosableFileFilter( nhfilter );\r
+ _save_filechooser.addChoosableFileFilter( nexusfilter );\r
+ _save_filechooser.addChoosableFileFilter( _save_filechooser.getAcceptAllFileFilter() );\r
+ try {\r
+ final String home_dir = System.getProperty( "user.home" );\r
+ _save_filechooser.setCurrentDirectory( new File( home_dir ) );\r
+ _writetopdf_filechooser.setCurrentDirectory( new File( home_dir ) );\r
+ _writetographics_filechooser.setCurrentDirectory( new File( home_dir ) );\r
+ }\r
+ catch ( final Exception e ) {\r
+ e.printStackTrace();\r
+ // Do nothing. Not important.\r
+ }\r
}\r
\r
/**\r
switchColors();\r
}\r
else if ( o == _display_basic_information_item ) {\r
- displayBasicInformation( getCurrentTreePanel().getTreeFile() );\r
+ if ( getCurrentTreePanel() != null ) {\r
+ displayBasicInformation( getCurrentTreePanel().getTreeFile() );\r
+ }\r
}\r
else if ( o == _view_as_NH_item ) {\r
viewAsNH();\r
MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );\r
}\r
else if ( o == _cycle_node_fill_mi ) {\r
- MainFrame.cycleNodeFill( getOptions(), getCurrentTreePanel() );\r
+ MainFrame.cycleNodeFill( getOptions() );\r
}\r
else if ( o == _cycle_node_shape_mi ) {\r
- MainFrame.cycleNodeShape( getOptions(), getCurrentTreePanel() );\r
+ MainFrame.cycleNodeShape( getOptions() );\r
+ }\r
+ else if ( o == _cycle_data_return ) {\r
+ MainFrame.cycleNodeDataReturn( getOptions(), getConfiguration() );\r
}\r
else if ( o == _screen_antialias_cbmi ) {\r
updateOptions( getOptions() );\r
else if ( o == _show_default_node_shapes_external_cbmi ) {\r
updateOptions( getOptions() );\r
}\r
+ else if ( o == _show_default_node_shapes_for_marked_cbmi ) {\r
+ updateOptions( getOptions() );\r
+ }\r
else if ( o == _non_lined_up_cladograms_rbmi ) {\r
updateOptions( getOptions() );\r
showWhole();\r
getMainPanel().getControlPanel().search1();\r
}\r
else if ( o == _search_whole_words_only_cbmi ) {\r
+ if ( ( _search_with_regex_cbmi != null ) && _search_whole_words_only_cbmi.isSelected() ) {\r
+ _search_with_regex_cbmi.setSelected( false );\r
+ }\r
updateOptions( getOptions() );\r
getMainPanel().getControlPanel().search0();\r
getMainPanel().getControlPanel().search1();\r
getMainPanel().getControlPanel().search0();\r
getMainPanel().getControlPanel().search1();\r
}\r
- else if ( o == _show_scale_cbmi ) {\r
+ else if ( o == _search_with_regex_cbmi ) {\r
+ if ( ( _search_whole_words_only_cbmi != null ) && _search_with_regex_cbmi.isSelected() ) {\r
+ _search_whole_words_only_cbmi.setSelected( false );\r
+ }\r
+ if ( ( _search_case_senstive_cbmi != null ) && _search_with_regex_cbmi.isSelected() ) {\r
+ _search_case_senstive_cbmi.setSelected( true );\r
+ }\r
updateOptions( getOptions() );\r
+ getMainPanel().getControlPanel().search0();\r
+ getMainPanel().getControlPanel().search1();\r
}\r
- else if ( o == _show_branch_length_values_cbmi ) {\r
+ else if ( o == _show_scale_cbmi ) {\r
updateOptions( getOptions() );\r
}\r
else if ( o == _color_by_taxonomic_group_cbmi ) {\r
ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );\r
}\r
}\r
+ else if ( o == _write_to_pdf_item ) {\r
+ final File curr_dir = writeToPdf( _mainpanel.getCurrentPhylogeny(),\r
+ getMainPanel(),\r
+ _writetopdf_filechooser,\r
+ _current_dir,\r
+ getContentPane(),\r
+ this );\r
+ if ( curr_dir != null ) {\r
+ setCurrentDir( curr_dir );\r
+ }\r
+ }\r
+ else if ( o == _save_all_item ) {\r
+ writeAllToFile();\r
+ }\r
+ else if ( o == _write_to_jpg_item ) {\r
+ final File new_dir = writeToGraphicsFile( _mainpanel.getCurrentPhylogeny(),\r
+ GraphicsExportType.JPG,\r
+ _mainpanel,\r
+ _writetographics_filechooser,\r
+ this,\r
+ getContentPane(),\r
+ _current_dir );\r
+ if ( new_dir != null ) {\r
+ setCurrentDir( new_dir );\r
+ }\r
+ }\r
+ else if ( o == _write_to_gif_item ) {\r
+ final File new_dir = writeToGraphicsFile( _mainpanel.getCurrentPhylogeny(),\r
+ GraphicsExportType.GIF,\r
+ _mainpanel,\r
+ _writetographics_filechooser,\r
+ this,\r
+ getContentPane(),\r
+ _current_dir );\r
+ if ( new_dir != null ) {\r
+ setCurrentDir( new_dir );\r
+ }\r
+ }\r
+ else if ( o == _write_to_tif_item ) {\r
+ final File new_dir = writeToGraphicsFile( _mainpanel.getCurrentPhylogeny(),\r
+ GraphicsExportType.TIFF,\r
+ _mainpanel,\r
+ _writetographics_filechooser,\r
+ this,\r
+ getContentPane(),\r
+ _current_dir );\r
+ if ( new_dir != null ) {\r
+ setCurrentDir( new_dir );\r
+ }\r
+ }\r
+ else if ( o == _write_to_bmp_item ) {\r
+ final File new_dir = writeToGraphicsFile( _mainpanel.getCurrentPhylogeny(),\r
+ GraphicsExportType.BMP,\r
+ _mainpanel,\r
+ _writetographics_filechooser,\r
+ this,\r
+ getContentPane(),\r
+ _current_dir );\r
+ if ( new_dir != null ) {\r
+ setCurrentDir( new_dir );\r
+ }\r
+ }\r
+ else if ( o == _write_to_png_item ) {\r
+ final File new_dir = writeToGraphicsFile( _mainpanel.getCurrentPhylogeny(),\r
+ GraphicsExportType.PNG,\r
+ _mainpanel,\r
+ _writetographics_filechooser,\r
+ this,\r
+ getContentPane(),\r
+ _current_dir );\r
+ if ( new_dir != null ) {\r
+ setCurrentDir( new_dir );\r
+ }\r
+ }\r
+ else if ( o == _print_item ) {\r
+ print( getCurrentTreePanel(), getOptions(), this );\r
+ }\r
+ else if ( o == _save_item ) {\r
+ final File new_dir = writeToFile( _mainpanel.getCurrentPhylogeny(),\r
+ getMainPanel(),\r
+ _save_filechooser,\r
+ _current_dir,\r
+ getContentPane(),\r
+ this );\r
+ if ( new_dir != null ) {\r
+ setCurrentDir( new_dir );\r
+ }\r
+ }\r
+ else if ( o == _graphics_export_visible_only_cbmi ) {\r
+ updateOptions( getOptions() );\r
+ }\r
+ else if ( o == _antialias_print_cbmi ) {\r
+ updateOptions( getOptions() );\r
+ }\r
+ else if ( o == _print_black_and_white_cbmi ) {\r
+ updateOptions( getOptions() );\r
+ }\r
+ else if ( o == _print_using_actual_size_cbmi ) {\r
+ updateOptions( getOptions() );\r
+ }\r
+ else if ( o == _graphics_export_using_actual_size_cbmi ) {\r
+ updateOptions( getOptions() );\r
+ }\r
+ else if ( o == _print_size_mi ) {\r
+ choosePrintSize();\r
+ }\r
+ else if ( o == _choose_pdf_width_mi ) {\r
+ choosePdfWidth();\r
+ }\r
+ else if ( o == _lineage_inference ) {\r
+ if ( isSubtreeDisplayed() ) {\r
+ JOptionPane.showMessageDialog( this,\r
+ "Subtree is shown.",\r
+ "Cannot infer ancestral taxonomies",\r
+ JOptionPane.ERROR_MESSAGE );\r
+ return;\r
+ }\r
+ executeLineageInference();\r
+ }\r
else {\r
if ( _load_phylogeny_from_webservice_menu_items != null ) {\r
for( int i = 0; i < _load_phylogeny_from_webservice_menu_items.length; ++i ) {\r
_contentpane.repaint();\r
}\r
\r
+ public Configuration getConfiguration() {\r
+ return _configuration;\r
+ }\r
+\r
+ /**\r
+ * This method returns the current external node data which\r
+ * has been selected by the user by clicking the "Return ..."\r
+ * menu item. This method is expected to be called from Javascript or\r
+ * something like it.\r
+ *\r
+ * @return current external node data as String\r
+ */\r
+ public String getCurrentExternalNodesDataBuffer() {\r
+ return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString();\r
+ }\r
+\r
+ public int getCurrentExternalNodesDataBufferChangeCounter() {\r
+ return getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter();\r
+ }\r
+\r
+ public int getCurrentExternalNodesDataBufferLength() {\r
+ return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length();\r
+ }\r
+\r
+ public InferenceManager getInferenceManager() {\r
+ return _inference_manager;\r
+ }\r
+\r
+ public MainPanel getMainPanel() {\r
+ return _mainpanel;\r
+ }\r
+\r
+ public Options getOptions() {\r
+ return _options;\r
+ }\r
+\r
+ public ProcessPool getProcessPool() {\r
+ return _process_pool;\r
+ }\r
+\r
+ public void showTextFrame( final String s, final String title ) {\r
+ checkTextFrames();\r
+ _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );\r
+ }\r
+\r
+ public void showWhole() {\r
+ _mainpanel.getControlPanel().showWhole();\r
+ }\r
+\r
+ public void updateProcessMenu() {\r
+ // In general Swing is not thread safe.\r
+ // See "Swing's Threading Policy".\r
+ SwingUtilities.invokeLater( new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ doUpdateProcessMenu();\r
+ }\r
+ } );\r
+ }\r
+\r
+ private void annotateSequences() {\r
+ if ( getCurrentTreePanel() != null ) {\r
+ List<PhylogenyNode> nodes = null;\r
+ if ( ( getCurrentTreePanel().getFoundNodes0() != null )\r
+ || ( getCurrentTreePanel().getFoundNodes1() != null ) ) {\r
+ nodes = getCurrentTreePanel().getFoundNodesAsListOfPhylogenyNodes();\r
+ }\r
+ if ( ( nodes == null ) || nodes.isEmpty() ) {\r
+ JOptionPane\r
+ .showMessageDialog( this,\r
+ "Need to select nodes, either via direct selection or via the \"Search\" function",\r
+ "No nodes selected for annotation",\r
+ JOptionPane.ERROR_MESSAGE );\r
+ return;\r
+ }\r
+ final Phylogeny phy = getMainPanel().getCurrentPhylogeny();\r
+ if ( ( phy != null ) && !phy.isEmpty() ) {\r
+ final JTextField ref_field = new JTextField( 10 );\r
+ final JTextField desc_filed = new JTextField( 20 );\r
+ ref_field.setText( ForesterUtil.isEmpty( getPreviousNodeAnnotationReference() ) ? ""\r
+ : getPreviousNodeAnnotationReference() );\r
+ final JPanel my_panel = new JPanel();\r
+ my_panel.add( new JLabel( "Reference " ) );\r
+ my_panel.add( ref_field );\r
+ my_panel.add( Box.createHorizontalStrut( 15 ) );\r
+ my_panel.add( new JLabel( "Description " ) );\r
+ my_panel.add( desc_filed );\r
+ final int result = JOptionPane.showConfirmDialog( null,\r
+ my_panel,\r
+ "Enter the sequence annotation(s) for the "\r
+ + nodes.size() + " selected nodes",\r
+ JOptionPane.OK_CANCEL_OPTION );\r
+ if ( result == JOptionPane.OK_OPTION ) {\r
+ String ref = ref_field.getText();\r
+ String desc = desc_filed.getText();\r
+ if ( !ForesterUtil.isEmpty( ref ) ) {\r
+ ref = ref.trim();\r
+ ref = ref.replaceAll( "\\s+", " " );\r
+ if ( ( ref.indexOf( ':' ) < 1 ) || ( ref.indexOf( ':' ) > ( ref.length() - 2 ) )\r
+ || ( ref.length() < 3 ) ) {\r
+ JOptionPane.showMessageDialog( this,\r
+ "Reference needs to be in the form of \"GO:1234567\"",\r
+ "Illegal Format for Annotation Reference",\r
+ JOptionPane.ERROR_MESSAGE );\r
+ return;\r
+ }\r
+ }\r
+ if ( ref != null ) {\r
+ setPreviousNodeAnnotationReference( ref );\r
+ }\r
+ if ( desc != null ) {\r
+ desc = desc.trim();\r
+ desc = desc.replaceAll( "\\s+", " " );\r
+ }\r
+ if ( !ForesterUtil.isEmpty( ref ) || !ForesterUtil.isEmpty( desc ) ) {\r
+ for( final PhylogenyNode n : nodes ) {\r
+ ForesterUtil.ensurePresenceOfSequence( n );\r
+ final Annotation ann = ForesterUtil.isEmpty( ref ) ? new Annotation()\r
+ : new Annotation( ref );\r
+ if ( !ForesterUtil.isEmpty( desc ) ) {\r
+ ann.setDesc( desc );\r
+ }\r
+ n.getNodeData().getSequence().addAnnotation( ann );\r
+ }\r
+ }\r
+ getMainPanel().getControlPanel().showAnnotations();\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ private void chooseFont() {\r
+ final FontChooser fc = new FontChooser();\r
+ fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );\r
+ fc.showDialog( this, "Select the Base Font" );\r
+ getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );\r
+ }\r
+\r
+ private void chooseMinimalConfidence() {\r
+ final String s = ( String ) JOptionPane\r
+ .showInputDialog( this,\r
+ "Please enter the minimum for confidence values to be displayed.\n"\r
+ + "[current value: " + getOptions().getMinConfidenceValue() + "]\n",\r
+ "Minimal Confidence Value",\r
+ JOptionPane.QUESTION_MESSAGE,\r
+ null,\r
+ null,\r
+ getOptions().getMinConfidenceValue() );\r
+ if ( !ForesterUtil.isEmpty( s ) ) {\r
+ boolean success = true;\r
+ double m = 0.0;\r
+ final String m_str = s.trim();\r
+ if ( !ForesterUtil.isEmpty( m_str ) ) {\r
+ try {\r
+ m = Double.parseDouble( m_str );\r
+ }\r
+ catch ( final Exception ex ) {\r
+ success = false;\r
+ }\r
+ }\r
+ else {\r
+ success = false;\r
+ }\r
+ if ( success && ( m >= 0.0 ) ) {\r
+ getOptions().setMinConfidenceValue( m );\r
+ }\r
+ }\r
+ }\r
+\r
private void deleteSelectedNodes( final boolean delete ) {\r
final Phylogeny phy = getMainPanel().getCurrentPhylogeny();\r
if ( ( phy == null ) || ( phy.getNumberOfExternalNodes() < 2 ) ) {\r
}\r
if ( ( nodes == null ) || nodes.isEmpty() ) {\r
JOptionPane\r
- .showMessageDialog( this,\r
- "Need to select external nodes, either via direct selection or via the \"Search\" function",\r
- "No external nodes selected to " + function.toLowerCase(),\r
- JOptionPane.ERROR_MESSAGE );\r
+ .showMessageDialog( this,\r
+ "Need to select external nodes, either via direct selection or via the \"Search\" function",\r
+ "No external nodes selected to " + function.toLowerCase(),\r
+ JOptionPane.ERROR_MESSAGE );\r
return;\r
}\r
final int todo = nodes.size();\r
return;\r
}\r
final int result = JOptionPane.showConfirmDialog( null, function + " " + todo\r
- + " external node(s), from a total of " + ext + " external nodes," + "\nresulting in tree with " + res\r
- + " nodes?", function + " external nodes", JOptionPane.OK_CANCEL_OPTION );\r
+ + " external node(s), from a total of " + ext + " external nodes," + "\nresulting in tree with " + res\r
+ + " nodes?", function + " external nodes", JOptionPane.OK_CANCEL_OPTION );\r
if ( result == JOptionPane.OK_OPTION ) {\r
if ( !delete ) {\r
final List<PhylogenyNode> to_delete = new ArrayList<PhylogenyNode>();\r
}\r
}\r
\r
- void resetSearch() {\r
- getMainPanel().getCurrentTreePanel().setFoundNodes0( null );\r
- getMainPanel().getCurrentTreePanel().setFoundNodes1( null );\r
- getMainPanel().getControlPanel().setSearchFoundCountsOnLabel0( 0 );\r
- getMainPanel().getControlPanel().getSearchFoundCountsLabel0().setVisible( false );\r
- getMainPanel().getControlPanel().getSearchTextField0().setText( "" );\r
- getMainPanel().getControlPanel().getSearchResetButton0().setEnabled( false );\r
- getMainPanel().getControlPanel().getSearchResetButton0().setVisible( false );\r
- getMainPanel().getControlPanel().setSearchFoundCountsOnLabel1( 0 );\r
- getMainPanel().getControlPanel().getSearchFoundCountsLabel1().setVisible( false );\r
- getMainPanel().getControlPanel().getSearchTextField1().setText( "" );\r
- getMainPanel().getControlPanel().getSearchResetButton1().setEnabled( false );\r
- getMainPanel().getControlPanel().getSearchResetButton1().setVisible( false );\r
+ private void doUpdateProcessMenu() {\r
+ if ( _process_pool.size() > 0 ) {\r
+ if ( _process_menu == null ) {\r
+ _process_menu = createMenu( "", getConfiguration() );\r
+ _process_menu.setForeground( Color.RED );\r
+ }\r
+ _process_menu.removeAll();\r
+ final String text = "processes running: " + _process_pool.size();\r
+ _process_menu.setText( text );\r
+ _jmenubar.add( _process_menu );\r
+ for( int i = 0; i < _process_pool.size(); ++i ) {\r
+ final ProcessRunning p = _process_pool.getProcessByIndex( i );\r
+ _process_menu.add( customizeJMenuItem( new JMenuItem( p.getName() + " [" + p.getStart() + "]" ) ) );\r
+ }\r
+ }\r
+ else {\r
+ if ( _process_menu != null ) {\r
+ _process_menu.removeAll();\r
+ _jmenubar.remove( _process_menu );\r
+ }\r
+ }\r
+ _jmenubar.validate();\r
+ _jmenubar.repaint();\r
+ repaint();\r
}\r
\r
- public Configuration getConfiguration() {\r
- return _configuration;\r
+ private String getPreviousNodeAnnotationReference() {\r
+ return _previous_node_annotation_ref;\r
}\r
\r
- /**\r
- * This method returns the current external node data which\r
- * has been selected by the user by clicking the "Return ..."\r
- * menu item. This method is expected to be called from Javascript or\r
- * something like it.\r
- * \r
- * @return current external node data as String\r
- */\r
- public String getCurrentExternalNodesDataBuffer() {\r
- return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString();\r
+ private void removeBranchColors() {\r
+ if ( getMainPanel().getCurrentPhylogeny() != null ) {\r
+ AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );\r
+ }\r
}\r
\r
- public int getCurrentExternalNodesDataBufferChangeCounter() {\r
- return getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter();\r
+ private void removeVisualStyles() {\r
+ if ( getMainPanel().getCurrentPhylogeny() != null ) {\r
+ AptxUtil.removeVisualStyles( getMainPanel().getCurrentPhylogeny() );\r
+ }\r
}\r
\r
- public int getCurrentExternalNodesDataBufferLength() {\r
- return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length();\r
+ private void setPreviousNodeAnnotationReference( final String previous_node_annotation_ref ) {\r
+ _previous_node_annotation_ref = previous_node_annotation_ref;\r
}\r
\r
- public InferenceManager getInferenceManager() {\r
- return _inference_manager;\r
- }\r
-\r
- public MainPanel getMainPanel() {\r
- return _mainpanel;\r
- }\r
-\r
- public Options getOptions() {\r
- return _options;\r
- }\r
-\r
- public ProcessPool getProcessPool() {\r
- return _process_pool;\r
- }\r
-\r
- public void showTextFrame( final String s, final String title ) {\r
- checkTextFrames();\r
- _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );\r
- }\r
-\r
- public void showWhole() {\r
- _mainpanel.getControlPanel().showWhole();\r
- }\r
-\r
- public void updateProcessMenu() {\r
- // In general Swing is not thread safe.\r
- // See "Swing's Threading Policy".\r
- SwingUtilities.invokeLater( new Runnable() {\r
-\r
- @Override\r
- public void run() {\r
- doUpdateProcessMenu();\r
+ private void writeAllToFile() {\r
+ if ( ( getMainPanel().getTabbedPane() == null ) || ( getMainPanel().getTabbedPane().getTabCount() < 1 ) ) {\r
+ return;\r
+ }\r
+ final File my_dir = getCurrentDir();\r
+ if ( my_dir != null ) {\r
+ _save_filechooser.setCurrentDirectory( my_dir );\r
+ }\r
+ _save_filechooser.setSelectedFile( new File( "" ) );\r
+ final int result = _save_filechooser.showSaveDialog( _contentpane );\r
+ final File file = _save_filechooser.getSelectedFile();\r
+ setCurrentDir( _save_filechooser.getCurrentDirectory() );\r
+ if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
+ if ( file.exists() ) {\r
+ final int i = JOptionPane.showConfirmDialog( this,\r
+ file + " already exists. Overwrite?",\r
+ "Warning",\r
+ JOptionPane.OK_CANCEL_OPTION,\r
+ JOptionPane.WARNING_MESSAGE );\r
+ if ( i != JOptionPane.OK_OPTION ) {\r
+ return;\r
+ }\r
+ else {\r
+ try {\r
+ file.delete();\r
+ }\r
+ catch ( final Exception e ) {\r
+ JOptionPane.showMessageDialog( this,\r
+ "Failed to delete: " + file,\r
+ "Error",\r
+ JOptionPane.WARNING_MESSAGE );\r
+ }\r
+ }\r
}\r
- } );\r
+ final int count = getMainPanel().getTabbedPane().getTabCount();\r
+ final List<Phylogeny> trees = new ArrayList<Phylogeny>();\r
+ for( int i = 0; i < count; ++i ) {\r
+ final Phylogeny phy = getMainPanel().getPhylogeny( i );\r
+ if ( ForesterUtil.isEmpty( phy.getName() )\r
+ && !ForesterUtil.isEmpty( getMainPanel().getTabbedPane().getTitleAt( i ) ) ) {\r
+ phy.setName( getMainPanel().getTabbedPane().getTitleAt( i ) );\r
+ }\r
+ trees.add( phy );\r
+ getMainPanel().getTreePanels().get( i ).setEdited( false );\r
+ }\r
+ final PhylogenyWriter writer = new PhylogenyWriter();\r
+ try {\r
+ writer.toPhyloXML( file, trees, 0, ForesterUtil.LINE_SEPARATOR );\r
+ }\r
+ catch ( final IOException e ) {\r
+ JOptionPane.showMessageDialog( this,\r
+ "Failed to write to: " + file,\r
+ "Error",\r
+ JOptionPane.WARNING_MESSAGE );\r
+ }\r
+ }\r
}\r
\r
void activateSaveAllIfNeeded() {\r
}\r
\r
void buildFileMenu() {\r
- _file_jmenu = createMenu( "File", getConfiguration() );\r
+ _file_jmenu = MainFrame.createMenu( "File", getConfiguration() );\r
+ _file_jmenu.add( _save_item = new JMenuItem( "Save Tree As..." ) );\r
+ _file_jmenu.addSeparator();\r
+ _file_jmenu.add( _write_to_pdf_item = new JMenuItem( "Export to PDF file ..." ) );\r
+ if ( AptxUtil.canWriteFormat( "tif" ) || AptxUtil.canWriteFormat( "tiff" ) || AptxUtil.canWriteFormat( "TIF" ) ) {\r
+ _file_jmenu.add( _write_to_tif_item = new JMenuItem( "Export to TIFF file..." ) );\r
+ }\r
+ _file_jmenu.add( _write_to_png_item = new JMenuItem( "Export to PNG file..." ) );\r
+ _file_jmenu.add( _write_to_jpg_item = new JMenuItem( "Export to JPG file..." ) );\r
+ if ( AptxUtil.canWriteFormat( "gif" ) ) {\r
+ _file_jmenu.add( _write_to_gif_item = new JMenuItem( "Export to GIF file..." ) );\r
+ }\r
+ if ( AptxUtil.canWriteFormat( "bmp" ) ) {\r
+ _file_jmenu.add( _write_to_bmp_item = new JMenuItem( "Export to BMP file..." ) );\r
+ }\r
+ _file_jmenu.addSeparator();\r
+ _file_jmenu.add( _print_item = new JMenuItem( "Print..." ) );\r
+ _file_jmenu.addSeparator();\r
_file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );\r
+ customizeJMenuItem( _save_item );\r
+ customizeJMenuItem( _write_to_pdf_item );\r
+ customizeJMenuItem( _write_to_png_item );\r
+ customizeJMenuItem( _write_to_jpg_item );\r
+ customizeJMenuItem( _write_to_gif_item );\r
+ customizeJMenuItem( _write_to_tif_item );\r
+ customizeJMenuItem( _write_to_bmp_item );\r
+ customizeJMenuItem( _print_item );\r
customizeJMenuItem( _exit_item );\r
_jmenubar.add( _file_jmenu );\r
}\r
}\r
}\r
\r
+ void choosePdfWidth() {\r
+ final String s = ( String ) JOptionPane.showInputDialog( this,\r
+ "Please enter the default line width for PDF export.\n"\r
+ + "[current value: "\r
+ + getOptions().getPrintLineWidth() + "]\n",\r
+ "Line Width for PDF Export",\r
+ JOptionPane.QUESTION_MESSAGE,\r
+ null,\r
+ null,\r
+ getOptions().getPrintLineWidth() );\r
+ if ( !ForesterUtil.isEmpty( s ) ) {\r
+ boolean success = true;\r
+ float f = 0.0f;\r
+ final String m_str = s.trim();\r
+ if ( !ForesterUtil.isEmpty( m_str ) ) {\r
+ try {\r
+ f = Float.parseFloat( m_str );\r
+ }\r
+ catch ( final Exception ex ) {\r
+ success = false;\r
+ }\r
+ }\r
+ else {\r
+ success = false;\r
+ }\r
+ if ( success && ( f > 0.0 ) ) {\r
+ getOptions().setPrintLineWidth( f );\r
+ }\r
+ }\r
+ }\r
+\r
+ void choosePrintSize() {\r
+ final String s = ( String ) JOptionPane.showInputDialog( this,\r
+ "Please enter values for width and height,\nseparated by a comma.\n"\r
+ + "[current values: "\r
+ + getOptions().getPrintSizeX() + ", "\r
+ + getOptions().getPrintSizeY() + "]\n"\r
+ + "[A4: " + Constants.A4_SIZE_X + ", "\r
+ + Constants.A4_SIZE_Y + "]\n" + "[US Letter: "\r
+ + Constants.US_LETTER_SIZE_X + ", "\r
+ + Constants.US_LETTER_SIZE_Y + "]",\r
+ "Default Size for Graphics Export",\r
+ JOptionPane.QUESTION_MESSAGE,\r
+ null,\r
+ null,\r
+ getOptions().getPrintSizeX() + ", "\r
+ + getOptions().getPrintSizeY() );\r
+ if ( !ForesterUtil.isEmpty( s ) && ( s.indexOf( ',' ) > 0 ) ) {\r
+ boolean success = true;\r
+ int x = 0;\r
+ int y = 0;\r
+ final String[] str_ary = s.split( "," );\r
+ if ( str_ary.length == 2 ) {\r
+ final String x_str = str_ary[ 0 ].trim();\r
+ final String y_str = str_ary[ 1 ].trim();\r
+ if ( !ForesterUtil.isEmpty( x_str ) && !ForesterUtil.isEmpty( y_str ) ) {\r
+ try {\r
+ x = Integer.parseInt( x_str );\r
+ y = Integer.parseInt( y_str );\r
+ }\r
+ catch ( final Exception ex ) {\r
+ success = false;\r
+ }\r
+ }\r
+ else {\r
+ success = false;\r
+ }\r
+ }\r
+ else {\r
+ success = false;\r
+ }\r
+ if ( success && ( x > 1 ) && ( y > 1 ) ) {\r
+ getOptions().setPrintSizeX( x );\r
+ getOptions().setPrintSizeY( y );\r
+ }\r
+ }\r
+ }\r
+\r
void close() {\r
removeAllTextFrames();\r
if ( _mainpanel != null ) {\r
JOptionPane.ERROR_MESSAGE );\r
}\r
\r
- void exceptionOccuredDuringSaveAs( final Exception e ) {\r
- try {\r
- _mainpanel.getCurrentTreePanel().setArrowCursor();\r
- }\r
- catch ( final Exception ex ) {\r
- // Do nothing.\r
- }\r
- JOptionPane.showMessageDialog( this, "Exception" + e, "Error during File|SaveAs", JOptionPane.ERROR_MESSAGE );\r
- }\r
-\r
void executeGSDI() {\r
if ( !isOKforSDI( false, true ) ) {\r
return;\r
+ gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"\r
+ "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"\r
+ "Number of polytomies in species tree used: " + poly + "\n",\r
- "GSDI successfully completed",\r
- JOptionPane.WARNING_MESSAGE );\r
+ "GSDI successfully completed",\r
+ JOptionPane.WARNING_MESSAGE );\r
}\r
else {\r
JOptionPane.showMessageDialog( this,\r
+ gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"\r
+ "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"\r
+ "Number of polytomies in species tree used: " + poly + "\n",\r
- "GSDI successfully completed",\r
- JOptionPane.INFORMATION_MESSAGE );\r
+ "GSDI successfully completed",\r
+ JOptionPane.INFORMATION_MESSAGE );\r
}\r
}\r
\r
+ gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"\r
+ "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"\r
+ "Number of polytomies in species tree used: " + poly + "\n",\r
- "GSDIR successfully completed",\r
- JOptionPane.WARNING_MESSAGE );\r
+ "GSDIR successfully completed",\r
+ JOptionPane.WARNING_MESSAGE );\r
}\r
else {\r
JOptionPane.showMessageDialog( this,\r
+ gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"\r
+ "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"\r
+ "Number of polytomies in species tree used: " + poly + "\n",\r
- "GSDIR successfully completed",\r
- JOptionPane.INFORMATION_MESSAGE );\r
+ "GSDIR successfully completed",\r
+ JOptionPane.INFORMATION_MESSAGE );\r
}\r
}\r
\r
+ void executeLineageInference() {\r
+ if ( ( _mainpanel.getCurrentPhylogeny() == null ) || ( _mainpanel.getCurrentPhylogeny().isEmpty() ) ) {\r
+ return;\r
+ }\r
+ if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {\r
+ JOptionPane.showMessageDialog( this,\r
+ "Phylogeny is not rooted.",\r
+ "Cannot infer ancestral taxonomies",\r
+ JOptionPane.ERROR_MESSAGE );\r
+ return;\r
+ }\r
+ final AncestralTaxonomyInferrer inferrer = new AncestralTaxonomyInferrer( this,\r
+ _mainpanel.getCurrentTreePanel(),\r
+ _mainpanel.getCurrentPhylogeny()\r
+ .copy() );\r
+ new Thread( inferrer ).start();\r
+ }\r
+\r
boolean GAndSDoHaveMoreThanOneSpeciesInComman( final Phylogeny gene_tree ) {\r
if ( ( gene_tree == null ) || gene_tree.isEmpty() ) {\r
JOptionPane.showMessageDialog( this,\r
}\r
}\r
\r
+ ControlPanel getControlPanel() {\r
+ return getMainPanel().getControlPanel();\r
+ }\r
+\r
+ File getCurrentDir() {\r
+ if ( ( _current_dir == null ) || !_current_dir.canRead() ) {\r
+ if ( ForesterUtil.isWindows() ) {\r
+ try {\r
+ _current_dir = new File( WindowsUtils.getCurrentUserDesktopPath() );\r
+ }\r
+ catch ( final Exception e ) {\r
+ _current_dir = null;\r
+ }\r
+ }\r
+ }\r
+ if ( ( _current_dir == null ) || !_current_dir.canRead() ) {\r
+ if ( System.getProperty( "user.home" ) != null ) {\r
+ _current_dir = new File( System.getProperty( "user.home" ) );\r
+ }\r
+ else if ( System.getProperty( "user.dir" ) != null ) {\r
+ _current_dir = new File( System.getProperty( "user.dir" ) );\r
+ }\r
+ }\r
+ return _current_dir;\r
+ }\r
+\r
TreePanel getCurrentTreePanel() {\r
return getMainPanel().getCurrentTreePanel();\r
}\r
if ( getCurrentTreePanel() != null ) {\r
if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {\r
JOptionPane\r
- .showMessageDialog( this,\r
- "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",\r
- "Operation can not be exectuted on a sub-tree",\r
- JOptionPane.WARNING_MESSAGE );\r
+ .showMessageDialog( this,\r
+ "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",\r
+ "Operation can not be exectuted on a sub-tree",\r
+ JOptionPane.WARNING_MESSAGE );\r
return true;\r
}\r
}\r
_textframes.clear();\r
}\r
\r
+ void resetSearch() {\r
+ getMainPanel().getCurrentTreePanel().setFoundNodes0( null );\r
+ getMainPanel().getCurrentTreePanel().setFoundNodes1( null );\r
+ getMainPanel().getControlPanel().setSearchFoundCountsOnLabel0( 0 );\r
+ getMainPanel().getControlPanel().getSearchFoundCountsLabel0().setVisible( false );\r
+ getMainPanel().getControlPanel().getSearchTextField0().setText( "" );\r
+ getMainPanel().getControlPanel().getSearchResetButton0().setEnabled( false );\r
+ getMainPanel().getControlPanel().getSearchResetButton0().setVisible( false );\r
+ getMainPanel().getControlPanel().setSearchFoundCountsOnLabel1( 0 );\r
+ getMainPanel().getControlPanel().getSearchFoundCountsLabel1().setVisible( false );\r
+ getMainPanel().getControlPanel().getSearchTextField1().setText( "" );\r
+ getMainPanel().getControlPanel().getSearchResetButton1().setEnabled( false );\r
+ getMainPanel().getControlPanel().getSearchResetButton1().setVisible( false );\r
+ }\r
+\r
void setConfiguration( final Configuration configuration ) {\r
_configuration = configuration;\r
}\r
\r
+ void setCurrentDir( final File current_dir ) {\r
+ _current_dir = current_dir;\r
+ }\r
+\r
void setInferenceManager( final InferenceManager i ) {\r
_inference_manager = i;\r
}\r
void updateOptions( final Options options ) {\r
options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() );\r
options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )\r
- && _background_gradient_cbmi.isSelected() );\r
+ && _background_gradient_cbmi.isSelected() );\r
options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );\r
options.setShowAnnotationRefSource( ( _show_annotation_ref_source != null )\r
- && _show_annotation_ref_source.isSelected() );\r
+ && _show_annotation_ref_source.isSelected() );\r
options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )\r
- && _abbreviate_scientific_names.isSelected() );\r
+ && _abbreviate_scientific_names.isSelected() );\r
options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )\r
- && _color_labels_same_as_parent_branch.isSelected() );\r
+ && _color_labels_same_as_parent_branch.isSelected() );\r
options.setShowDefaultNodeShapesInternal( ( _show_default_node_shapes_internal_cbmi != null )\r
- && _show_default_node_shapes_internal_cbmi.isSelected() );\r
+ && _show_default_node_shapes_internal_cbmi.isSelected() );\r
options.setShowDefaultNodeShapesExternal( ( _show_default_node_shapes_external_cbmi != null )\r
- && _show_default_node_shapes_external_cbmi.isSelected() );\r
+ && _show_default_node_shapes_external_cbmi.isSelected() );\r
+ options.setShowDefaultNodeShapesForMarkedNodes( ( _show_default_node_shapes_for_marked_cbmi != null )\r
+ && _show_default_node_shapes_for_marked_cbmi.isSelected() );\r
if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {\r
options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );\r
}\r
options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );\r
}\r
options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )\r
- && _search_case_senstive_cbmi.isSelected() );\r
+ && _search_case_senstive_cbmi.isSelected() );\r
if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) {\r
options.setShowScale( _show_scale_cbmi.isSelected() );\r
}\r
}\r
options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() );\r
options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null )\r
- && _show_confidence_stddev_cbmi.isSelected() );\r
- if ( ( _show_branch_length_values_cbmi != null ) && _show_branch_length_values_cbmi.isEnabled() ) {\r
- options.setShowBranchLengthValues( _show_branch_length_values_cbmi.isSelected() );\r
- }\r
+ && _show_confidence_stddev_cbmi.isSelected() );\r
if ( ( _color_by_taxonomic_group_cbmi != null ) && _color_by_taxonomic_group_cbmi.isEnabled() ) {\r
options.setColorByTaxonomicGroup( _color_by_taxonomic_group_cbmi.isSelected() );\r
}\r
options.setPrintUsingActualSize( ( _print_using_actual_size_cbmi != null )\r
- && ( _print_using_actual_size_cbmi.isSelected() ) );\r
+ && ( _print_using_actual_size_cbmi.isSelected() ) );\r
options.setGraphicsExportUsingActualSize( ( _graphics_export_using_actual_size_cbmi != null )\r
- && ( _graphics_export_using_actual_size_cbmi.isSelected() ) );\r
+ && ( _graphics_export_using_actual_size_cbmi.isSelected() ) );\r
options.setAntialiasPrint( ( _antialias_print_cbmi != null ) && _antialias_print_cbmi.isSelected() );\r
if ( ( _use_brackets_for_conf_in_nh_export_cbmi != null )\r
&& _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) {\r
options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE );\r
}\r
options.setPrintBlackAndWhite( ( _print_black_and_white_cbmi != null )\r
- && _print_black_and_white_cbmi.isSelected() );\r
+ && _print_black_and_white_cbmi.isSelected() );\r
options.setInternalNumberAreConfidenceForNhParsing( ( _internal_number_are_confidence_for_nh_parsing_cbmi != null )\r
- && _internal_number_are_confidence_for_nh_parsing_cbmi.isSelected() );\r
+ && _internal_number_are_confidence_for_nh_parsing_cbmi.isSelected() );\r
if ( ( _extract_taxonomy_pfam_strict_rbmi != null ) && _extract_taxonomy_pfam_strict_rbmi.isSelected() ) {\r
options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );\r
}\r
options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.NO );\r
}\r
options.setReplaceUnderscoresInNhParsing( ( _replace_underscores_cbmi != null )\r
- && _replace_underscores_cbmi.isSelected() );\r
+ && _replace_underscores_cbmi.isSelected() );\r
options.setAllowErrorsInDistanceToParent( ( _allow_errors_in_distance_to_parent_cbmi != null )\r
- && _allow_errors_in_distance_to_parent_cbmi.isSelected() );\r
+ && _allow_errors_in_distance_to_parent_cbmi.isSelected() );\r
options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null )\r
- && _search_whole_words_only_cbmi.isSelected() );\r
+ && _search_whole_words_only_cbmi.isSelected() );\r
+ options.setSearchWithRegex( ( _search_with_regex_cbmi != null ) && _search_with_regex_cbmi.isSelected() );\r
options.setInverseSearchResult( ( _inverse_search_result_cbmi != null )\r
- && _inverse_search_result_cbmi.isSelected() );\r
+ && _inverse_search_result_cbmi.isSelected() );\r
if ( _graphics_export_visible_only_cbmi != null ) {\r
options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() );\r
if ( _graphics_export_visible_only_cbmi.isSelected() && ( _graphics_export_using_actual_size_cbmi != null ) ) {\r
title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title;\r
}\r
showTextFrame( _mainpanel.getCurrentPhylogeny().toNewHampshire( getOptions()\r
- .getNhConversionSupportValueStyle() ),\r
- title );\r
+ .getNhConversionSupportValueStyle() ),\r
+ title );\r
}\r
}\r
\r
}\r
}\r
\r
- private void annotateSequences() {\r
- if ( getCurrentTreePanel() != null ) {\r
- List<PhylogenyNode> nodes = null;\r
- if ( ( getCurrentTreePanel().getFoundNodes0() != null )\r
- || ( getCurrentTreePanel().getFoundNodes1() != null ) ) {\r
- nodes = getCurrentTreePanel().getFoundNodesAsListOfPhylogenyNodes();\r
- }\r
- if ( ( nodes == null ) || nodes.isEmpty() ) {\r
- JOptionPane\r
- .showMessageDialog( this,\r
- "Need to select nodes, either via direct selection or via the \"Search\" function",\r
- "No nodes selected for annotation",\r
- JOptionPane.ERROR_MESSAGE );\r
- return;\r
- }\r
- final Phylogeny phy = getMainPanel().getCurrentPhylogeny();\r
- if ( ( phy != null ) && !phy.isEmpty() ) {\r
- final JTextField ref_field = new JTextField( 10 );\r
- final JTextField desc_filed = new JTextField( 20 );\r
- ref_field.setText( ForesterUtil.isEmpty( getPreviousNodeAnnotationReference() ) ? ""\r
- : getPreviousNodeAnnotationReference() );\r
- final JPanel my_panel = new JPanel();\r
- my_panel.add( new JLabel( "Reference " ) );\r
- my_panel.add( ref_field );\r
- my_panel.add( Box.createHorizontalStrut( 15 ) );\r
- my_panel.add( new JLabel( "Description " ) );\r
- my_panel.add( desc_filed );\r
- final int result = JOptionPane.showConfirmDialog( null,\r
- my_panel,\r
- "Enter the sequence annotation(s) for the "\r
- + nodes.size() + " selected nodes",\r
- JOptionPane.OK_CANCEL_OPTION );\r
- if ( result == JOptionPane.OK_OPTION ) {\r
- String ref = ref_field.getText();\r
- String desc = desc_filed.getText();\r
- if ( !ForesterUtil.isEmpty( ref ) ) {\r
- ref = ref.trim();\r
- ref = ref.replaceAll( "\\s+", " " );\r
- if ( ( ref.indexOf( ':' ) < 1 ) || ( ref.indexOf( ':' ) > ( ref.length() - 2 ) )\r
- || ( ref.length() < 3 ) ) {\r
- JOptionPane.showMessageDialog( this,\r
- "Reference needs to be in the form of \"GO:1234567\"",\r
- "Illegal Format for Annotation Reference",\r
- JOptionPane.ERROR_MESSAGE );\r
- return;\r
- }\r
- }\r
- if ( ref != null ) {\r
- setPreviousNodeAnnotationReference( ref );\r
- }\r
- if ( desc != null ) {\r
- desc = desc.trim();\r
- desc = desc.replaceAll( "\\s+", " " );\r
- }\r
- if ( !ForesterUtil.isEmpty( ref ) || !ForesterUtil.isEmpty( desc ) ) {\r
- for( final PhylogenyNode n : nodes ) {\r
- ForesterUtil.ensurePresenceOfSequence( n );\r
- final Annotation ann = ForesterUtil.isEmpty( ref ) ? new Annotation()\r
- : new Annotation( ref );\r
- if ( !ForesterUtil.isEmpty( desc ) ) {\r
- ann.setDesc( desc );\r
- }\r
- n.getNodeData().getSequence().addAnnotation( ann );\r
- }\r
- }\r
- getMainPanel().getControlPanel().showAnnotations();\r
- }\r
- }\r
- }\r
- }\r
-\r
- private void chooseFont() {\r
- final FontChooser fc = new FontChooser();\r
- fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );\r
- fc.showDialog( this, "Select the Base Font" );\r
- getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );\r
- }\r
-\r
- private void chooseMinimalConfidence() {\r
- final String s = ( String ) JOptionPane\r
- .showInputDialog( this,\r
- "Please enter the minimum for confidence values to be displayed.\n"\r
- + "[current value: " + getOptions().getMinConfidenceValue() + "]\n",\r
- "Minimal Confidence Value",\r
- JOptionPane.QUESTION_MESSAGE,\r
- null,\r
- null,\r
- getOptions().getMinConfidenceValue() );\r
- if ( !ForesterUtil.isEmpty( s ) ) {\r
- boolean success = true;\r
- double m = 0.0;\r
- final String m_str = s.trim();\r
- if ( !ForesterUtil.isEmpty( m_str ) ) {\r
- try {\r
- m = Double.parseDouble( m_str );\r
+ private static void cycleNodeDataReturn( final Options op, final Configuration conf ) {\r
+ switch ( op.getExtDescNodeDataToReturn() ) {\r
+ case UNKNOWN:\r
+ op.setExtDescNodeDataToReturn( NodeDataField.DOMAINS_ALL );\r
+ break;\r
+ case DOMAINS_ALL:\r
+ op.setExtDescNodeDataToReturn( NodeDataField.DOMAINS_COLLAPSED_PER_PROTEIN );\r
+ break;\r
+ case DOMAINS_COLLAPSED_PER_PROTEIN:\r
+ op.setExtDescNodeDataToReturn( NodeDataField.SEQ_ANNOTATIONS );\r
+ break;\r
+ case SEQ_ANNOTATIONS:\r
+ op.setExtDescNodeDataToReturn( NodeDataField.GO_TERM_IDS );\r
+ break;\r
+ case GO_TERM_IDS:\r
+ op.setExtDescNodeDataToReturn( NodeDataField.SEQUENCE_MOL_SEQ_FASTA );\r
+ break;\r
+ case SEQUENCE_MOL_SEQ_FASTA:\r
+ if ( ( conf != null ) && ( conf.getExtDescNodeDataToReturn() != null )\r
+ && ( conf.getExtDescNodeDataToReturn() != NodeDataField.DOMAINS_ALL )\r
+ && ( conf.getExtDescNodeDataToReturn() != NodeDataField.DOMAINS_COLLAPSED_PER_PROTEIN )\r
+ && ( conf.getExtDescNodeDataToReturn() != NodeDataField.SEQ_ANNOTATIONS )\r
+ && ( conf.getExtDescNodeDataToReturn() != NodeDataField.GO_TERM_IDS )\r
+ && ( conf.getExtDescNodeDataToReturn() != NodeDataField.SEQUENCE_MOL_SEQ_FASTA ) ) {\r
+ op.setExtDescNodeDataToReturn( conf.getExtDescNodeDataToReturn() );\r
}\r
- catch ( final Exception ex ) {\r
- success = false;\r
+ else {\r
+ op.setExtDescNodeDataToReturn( NodeDataField.UNKNOWN );\r
}\r
- }\r
- else {\r
- success = false;\r
- }\r
- if ( success && ( m >= 0.0 ) ) {\r
- getOptions().setMinConfidenceValue( m );\r
- }\r
- }\r
- }\r
-\r
- private void doUpdateProcessMenu() {\r
- if ( _process_pool.size() > 0 ) {\r
- if ( _process_menu == null ) {\r
- _process_menu = createMenu( "", getConfiguration() );\r
- _process_menu.setForeground( Color.RED );\r
- }\r
- _process_menu.removeAll();\r
- final String text = "processes running: " + _process_pool.size();\r
- _process_menu.setText( text );\r
- _jmenubar.add( _process_menu );\r
- for( int i = 0; i < _process_pool.size(); ++i ) {\r
- final ProcessRunning p = _process_pool.getProcessByIndex( i );\r
- _process_menu.add( customizeJMenuItem( new JMenuItem( p.getName() + " [" + p.getStart() + "]" ) ) );\r
- }\r
- }\r
- else {\r
- if ( _process_menu != null ) {\r
- _process_menu.removeAll();\r
- _jmenubar.remove( _process_menu );\r
- }\r
- }\r
- _jmenubar.validate();\r
- _jmenubar.repaint();\r
- repaint();\r
- }\r
-\r
- private String getPreviousNodeAnnotationReference() {\r
- return _previous_node_annotation_ref;\r
- }\r
-\r
- private void removeBranchColors() {\r
- if ( getMainPanel().getCurrentPhylogeny() != null ) {\r
- AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );\r
- }\r
- }\r
-\r
- private void removeVisualStyles() {\r
- if ( getMainPanel().getCurrentPhylogeny() != null ) {\r
- AptxUtil.removeVisualStyles( getMainPanel().getCurrentPhylogeny() );\r
+ break;\r
+ default:\r
+ op.setExtDescNodeDataToReturn( NodeDataField.UNKNOWN );\r
}\r
}\r
\r
- private void setPreviousNodeAnnotationReference( final String previous_node_annotation_ref ) {\r
- _previous_node_annotation_ref = previous_node_annotation_ref;\r
- }\r
-\r
/**\r
* Display the about box.\r
*/\r
"Please enter the default size for node shapes.\n"\r
+ "[current value: "\r
+ options.getDefaultNodeShapeSize() + "]\n",\r
- "Node Shape Size",\r
- JOptionPane.QUESTION_MESSAGE,\r
- null,\r
- null,\r
- options.getDefaultNodeShapeSize() );\r
+ "Node Shape Size",\r
+ JOptionPane.QUESTION_MESSAGE,\r
+ null,\r
+ null,\r
+ options.getDefaultNodeShapeSize() );\r
if ( !ForesterUtil.isEmpty( s ) ) {\r
boolean success = true;\r
double m = 0.0;\r
return label;\r
}\r
\r
- static void cycleNodeFill( final Options op, final TreePanel tree_panel ) {\r
+ static void cycleNodeFill( final Options op ) {\r
switch ( op.getDefaultNodeFill() ) {\r
case GRADIENT:\r
op.setDefaultNodeFill( NodeFill.SOLID );\r
}\r
}\r
\r
- static void cycleNodeShape( final Options op, final TreePanel tree_panel ) {\r
+ static void cycleNodeShape( final Options op ) {\r
switch ( op.getDefaultNodeShape() ) {\r
case CIRCLE:\r
op.setDefaultNodeShape( NodeShape.RECTANGLE );\r
}\r
}\r
\r
+ static void exceptionOccuredDuringSaveAs( final Exception e, final TreePanel tp, final Component comp ) {\r
+ try {\r
+ tp.setArrowCursor();\r
+ }\r
+ catch ( final Exception ex ) {\r
+ // Do nothing.\r
+ }\r
+ JOptionPane.showMessageDialog( comp, "Exception" + e, "Error during File|SaveAs", JOptionPane.ERROR_MESSAGE );\r
+ }\r
+\r
+ static void print( final TreePanel tp, final Options op, final Component c ) {\r
+ if ( ( tp == null ) || ( tp.getPhylogeny() == null ) || tp.getPhylogeny().isEmpty() ) {\r
+ return;\r
+ }\r
+ if ( !op.isPrintUsingActualSize() ) {\r
+ tp.calcParametersForPainting( op.getPrintSizeX() - 80, op.getPrintSizeY() - 140 );\r
+ tp.resetPreferredSize();\r
+ tp.repaint();\r
+ }\r
+ final String job_name = Constants.PRG_NAME;\r
+ boolean error = false;\r
+ String printer_name = null;\r
+ try {\r
+ printer_name = Printer.print( tp, job_name );\r
+ }\r
+ catch ( final Exception e ) {\r
+ error = true;\r
+ JOptionPane.showMessageDialog( c, e.getMessage(), "Printing Error", JOptionPane.ERROR_MESSAGE );\r
+ }\r
+ if ( !error && ( printer_name != null ) ) {\r
+ String msg = "Printing data sent to printer";\r
+ if ( printer_name.length() > 1 ) {\r
+ msg += " [" + printer_name + "]";\r
+ }\r
+ JOptionPane.showMessageDialog( c, msg, "Printing...", JOptionPane.INFORMATION_MESSAGE );\r
+ }\r
+ if ( !op.isPrintUsingActualSize() ) {\r
+ tp.getControlPanel().showWhole();\r
+ }\r
+ }\r
+\r
+ static void printPhylogenyToPdf( final String file_name,\r
+ final Options opts,\r
+ final TreePanel tp,\r
+ final Component comp ) {\r
+ if ( !opts.isPrintUsingActualSize() ) {\r
+ tp.calcParametersForPainting( opts.getPrintSizeX(), opts.getPrintSizeY() );\r
+ tp.resetPreferredSize();\r
+ tp.repaint();\r
+ }\r
+ String pdf_written_to = "";\r
+ boolean error = false;\r
+ try {\r
+ if ( opts.isPrintUsingActualSize() ) {\r
+ pdf_written_to = PdfExporter.writePhylogenyToPdf( file_name, tp, tp.getWidth(), tp.getHeight() );\r
+ }\r
+ else {\r
+ pdf_written_to = PdfExporter.writePhylogenyToPdf( file_name,\r
+ tp,\r
+ opts.getPrintSizeX(),\r
+ opts.getPrintSizeY() );\r
+ }\r
+ }\r
+ catch ( final IOException e ) {\r
+ error = true;\r
+ JOptionPane.showMessageDialog( comp, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE );\r
+ }\r
+ if ( !error ) {\r
+ if ( !ForesterUtil.isEmpty( pdf_written_to ) ) {\r
+ JOptionPane.showMessageDialog( comp,\r
+ "Wrote PDF to: " + pdf_written_to,\r
+ "Information",\r
+ JOptionPane.INFORMATION_MESSAGE );\r
+ }\r
+ else {\r
+ JOptionPane.showMessageDialog( comp,\r
+ "There was an unknown problem when attempting to write to PDF file: \""\r
+ + file_name + "\"",\r
+ "Error",\r
+ JOptionPane.ERROR_MESSAGE );\r
+ }\r
+ }\r
+ if ( !opts.isPrintUsingActualSize() ) {\r
+ tp.getControlPanel().showWhole();\r
+ }\r
+ }\r
+\r
+ static void setCycleDataReturnMenuItem( final JMenuItem mi, final Options options ) {\r
+ if ( ( options != null ) && ( options.getExtDescNodeDataToReturn() != null ) ) {\r
+ mi.setText( "Cycle Node Return Data... (current: " + options.getExtDescNodeDataToReturn().toString() + ")" );\r
+ }\r
+ else {\r
+ mi.setText( "Cycle Node Return Data..." );\r
+ }\r
+ }\r
+\r
static void setCycleNodeFillMenuItem( final JMenuItem mi, final Options options ) {\r
if ( ( options != null ) && ( options.getDefaultNodeFill() != null ) ) {\r
mi.setText( "Cycle Node Shape Fill Type... (current: "\r
static void setTextColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {\r
if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {\r
mi.setText( "Select Color Scheme... (current: " + tree_panel.getTreeColorSet().getCurrentColorSchemeName()\r
- + ")" );\r
+ + ")" );\r
}\r
else {\r
mi.setText( "Select Color Scheme..." );\r
mi.setText( "Select Default Font... (current: " + font_desc + ")" );\r
}\r
\r
+ static void setTextForGraphicsSizeChooserMenuItem( final JMenuItem mi, final Options o ) {\r
+ mi.setText( "Enter Default Size for Graphics Export... (current: " + o.getPrintSizeX() + ", "\r
+ + o.getPrintSizeY() + ")" );\r
+ }\r
+\r
+ static void setTextForPdfLineWidthChooserMenuItem( final JMenuItem mi, final Options o ) {\r
+ mi.setText( "Enter Default Line Width for PDF Export... (current: " + o.getPrintLineWidth() + ")" );\r
+ }\r
+\r
static void setTextMinSupportMenuItem( final JMenuItem mi, final Options options, final TreePanel current_tree_panel ) {\r
if ( ( current_tree_panel == null ) || ( current_tree_panel.getPhylogeny() == null ) ) {\r
mi.setEnabled( true );\r
mi.setText( "Enter Default Node Shape Size... (current: " + options.getDefaultNodeShapeSize() + ")" );\r
}\r
\r
- static void updateOptionsMenuDependingOnPhylogenyType( final MainPanel main_panel,\r
- final JCheckBoxMenuItem scale,\r
- final JCheckBoxMenuItem branch_lengths,\r
- final JRadioButtonMenuItem non_lined_up,\r
- final JRadioButtonMenuItem uniform_clado,\r
- final JRadioButtonMenuItem nonuniform_clado,\r
- final JCheckBoxMenuItem label_direction_cbmi ) {\r
- final TreePanel tree_panel = main_panel.getCurrentTreePanel();\r
- final ControlPanel control = main_panel.getControlPanel();\r
- final Options options = main_panel.getOptions();\r
- scale.setSelected( options.isShowScale() );\r
- branch_lengths.setSelected( options.isShowBranchLengthValues() );\r
- // non_lined_up.setSelected( options.isNonLinedUpCladogram() );\r
- if ( ( tree_panel != null ) && ( !tree_panel.isPhyHasBranchLengths() ) ) {\r
- scale.setSelected( false );\r
- scale.setEnabled( false );\r
- branch_lengths.setSelected( false );\r
- branch_lengths.setEnabled( false );\r
- }\r
- else if ( ( tree_panel != null ) && !control.isDrawPhylogram() ) {\r
- scale.setSelected( false );\r
- scale.setEnabled( false );\r
- branch_lengths.setEnabled( true );\r
+ static void updateScreenTextAntialias( final List<TreePanel> treepanels ) {\r
+ for( final TreePanel tree_panel : treepanels ) {\r
+ tree_panel.setTextAntialias();\r
}\r
- else {\r
- scale.setEnabled( true );\r
- branch_lengths.setEnabled( true );\r
+ }\r
+\r
+ static boolean writeAsNewHampshire( final TreePanel tp, final Options op, boolean exception, final File file ) {\r
+ try {\r
+ final PhylogenyWriter writer = new PhylogenyWriter();\r
+ writer.toNewHampshire( tp.getPhylogeny(), true, op.getNhConversionSupportValueStyle(), file );\r
}\r
- if ( ( tree_panel != null )\r
- && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.ROUNDED )\r
- && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel\r
- .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {\r
- branch_lengths.setSelected( false );\r
- branch_lengths.setEnabled( false );\r
+ catch ( final Exception e ) {\r
+ exception = true;\r
+ exceptionOccuredDuringSaveAs( e, tp, tp );\r
}\r
- if ( tree_panel != null ) {\r
- if ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )\r
- || ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {\r
- non_lined_up.setEnabled( false );\r
- uniform_clado.setEnabled( false );\r
- nonuniform_clado.setEnabled( false );\r
+ return exception;\r
+ }\r
+\r
+ static boolean writeAsNexus( final TreePanel tp, final Options op, boolean exception, final File file ) {\r
+ try {\r
+ final PhylogenyWriter writer = new PhylogenyWriter();\r
+ writer.toNexus( file, tp.getPhylogeny(), op.getNhConversionSupportValueStyle() );\r
+ }\r
+ catch ( final Exception e ) {\r
+ exception = true;\r
+ exceptionOccuredDuringSaveAs( e, tp, tp );\r
+ }\r
+ return exception;\r
+ }\r
+\r
+ static boolean writeAsPhyloXml( final TreePanel tp, final Options op, boolean exception, final File file ) {\r
+ try {\r
+ final PhylogenyWriter writer = new PhylogenyWriter();\r
+ writer.toPhyloXML( file, tp.getPhylogeny(), 0 );\r
+ }\r
+ catch ( final Exception e ) {\r
+ exception = true;\r
+ exceptionOccuredDuringSaveAs( e, tp, tp );\r
+ }\r
+ return exception;\r
+ }\r
+\r
+ static void writePhylogenyToGraphicsFile( final String file_name,\r
+ final GraphicsExportType type,\r
+ final MainPanel mp,\r
+ final Component comp,\r
+ final Container contentpane ) {\r
+ mp.getCurrentTreePanel().calcParametersForPainting( mp.getCurrentTreePanel().getWidth(),\r
+ mp.getCurrentTreePanel().getHeight() );\r
+ String file_written_to = "";\r
+ boolean error = false;\r
+ try {\r
+ file_written_to = AptxUtil.writePhylogenyToGraphicsFile( file_name,\r
+ mp.getCurrentTreePanel().getWidth(),\r
+ mp.getCurrentTreePanel().getHeight(),\r
+ mp.getCurrentTreePanel(),\r
+ mp.getControlPanel(),\r
+ type,\r
+ mp.getOptions() );\r
+ }\r
+ catch ( final IOException e ) {\r
+ error = true;\r
+ JOptionPane.showMessageDialog( comp, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE );\r
+ }\r
+ if ( !error ) {\r
+ if ( ( file_written_to != null ) && ( file_written_to.length() > 0 ) ) {\r
+ JOptionPane.showMessageDialog( comp,\r
+ "Wrote image to: " + file_written_to,\r
+ "Graphics Export",\r
+ JOptionPane.INFORMATION_MESSAGE );\r
}\r
else {\r
- non_lined_up.setEnabled( true );\r
- uniform_clado.setEnabled( true );\r
- nonuniform_clado.setEnabled( true );\r
+ JOptionPane.showMessageDialog( comp,\r
+ "There was an unknown problem when attempting to write to an image file: \""\r
+ + file_name + "\"",\r
+ "Error",\r
+ JOptionPane.ERROR_MESSAGE );\r
+ }\r
+ }\r
+ contentpane.repaint();\r
+ }\r
+\r
+ static File writeToFile( final Phylogeny t,\r
+ final MainPanel mp,\r
+ final JFileChooser save_filechooser,\r
+ final File current_dir,\r
+ final Container contentpane,\r
+ final Component comp ) {\r
+ File new_file = null;\r
+ if ( t == null ) {\r
+ return null;\r
+ }\r
+ String initial_filename = null;\r
+ if ( mp.getCurrentTreePanel().getTreeFile() != null ) {\r
+ try {\r
+ initial_filename = mp.getCurrentTreePanel().getTreeFile().getCanonicalPath();\r
+ }\r
+ catch ( final IOException e ) {\r
+ initial_filename = null;\r
}\r
}\r
+ if ( !ForesterUtil.isEmpty( initial_filename ) ) {\r
+ save_filechooser.setSelectedFile( new File( initial_filename ) );\r
+ }\r
else {\r
- if ( ( tree_panel != null )\r
- && ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) && ( tree_panel\r
- .getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) ) ) {\r
- branch_lengths.setSelected( false );\r
- branch_lengths.setEnabled( false );\r
+ save_filechooser.setSelectedFile( new File( "" ) );\r
+ }\r
+ final File my_dir = current_dir;\r
+ if ( my_dir != null ) {\r
+ save_filechooser.setCurrentDirectory( my_dir );\r
+ }\r
+ final int result = save_filechooser.showSaveDialog( contentpane );\r
+ final File file = save_filechooser.getSelectedFile();\r
+ new_file = save_filechooser.getCurrentDirectory();\r
+ boolean exception = false;\r
+ if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
+ if ( file.exists() ) {\r
+ final int i = JOptionPane.showConfirmDialog( comp,\r
+ file + " already exists.\nOverwrite?",\r
+ "Overwrite?",\r
+ JOptionPane.OK_CANCEL_OPTION,\r
+ JOptionPane.QUESTION_MESSAGE );\r
+ if ( i != JOptionPane.OK_OPTION ) {\r
+ return null;\r
+ }\r
+ else {\r
+ final File to = new File( file.getAbsoluteFile().toString() + Constants.BACKUP_FILE_SUFFIX );\r
+ try {\r
+ ForesterUtil.copyFile( file, to );\r
+ }\r
+ catch ( final Exception e ) {\r
+ JOptionPane.showMessageDialog( comp,\r
+ "Failed to create backup copy " + to,\r
+ "Failed to Create Backup Copy",\r
+ JOptionPane.WARNING_MESSAGE );\r
+ }\r
+ try {\r
+ file.delete();\r
+ }\r
+ catch ( final Exception e ) {\r
+ JOptionPane.showMessageDialog( comp,\r
+ "Failed to delete: " + file,\r
+ "Failed to Delete",\r
+ JOptionPane.WARNING_MESSAGE );\r
+ }\r
+ }\r
+ }\r
+ if ( save_filechooser.getFileFilter() == MainFrame.nhfilter ) {\r
+ exception = writeAsNewHampshire( mp.getCurrentTreePanel(), mp.getOptions(), exception, file );\r
+ }\r
+ else if ( save_filechooser.getFileFilter() == MainFrame.xmlfilter ) {\r
+ exception = writeAsPhyloXml( mp.getCurrentTreePanel(), mp.getOptions(), exception, file );\r
}\r
- if ( ( tree_panel != null )\r
- && ( ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( tree_panel\r
- .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {\r
- non_lined_up.setEnabled( false );\r
+ else if ( save_filechooser.getFileFilter() == MainFrame.nexusfilter ) {\r
+ exception = writeAsNexus( mp.getCurrentTreePanel(), mp.getOptions(), exception, file );\r
}\r
+ // "*.*":\r
else {\r
- // non_lined_up.setSelected( options.isNonLinedUpCladogram() );\r
- non_lined_up.setEnabled( true );\r
+ final String file_name = file.getName().trim().toLowerCase();\r
+ if ( file_name.endsWith( ".nh" ) || file_name.endsWith( ".newick" ) || file_name.endsWith( ".phy" )\r
+ || file_name.endsWith( ".tree" ) ) {\r
+ exception = writeAsNewHampshire( mp.getCurrentTreePanel(), mp.getOptions(), exception, file );\r
+ }\r
+ else if ( file_name.endsWith( ".nex" ) || file_name.endsWith( ".nexus" ) ) {\r
+ exception = writeAsNexus( mp.getCurrentTreePanel(), mp.getOptions(), exception, file );\r
+ }\r
+ // XML is default:\r
+ else {\r
+ exception = writeAsPhyloXml( mp.getCurrentTreePanel(), mp.getOptions(), exception, file );\r
+ }\r
}\r
- }\r
- label_direction_cbmi.setEnabled( true );\r
- if ( tree_panel != null ) {\r
- if ( ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED )\r
- && ( tree_panel.getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {\r
- label_direction_cbmi.setEnabled( false );\r
+ if ( !exception ) {\r
+ mp.setTitleOfSelectedTab( file.getName() );\r
+ mp.getCurrentTreePanel().setTreeFile( file );\r
+ mp.getCurrentTreePanel().setEdited( false );\r
+ }\r
+ }\r
+ return new_file;\r
+ }\r
+\r
+ static File writeToGraphicsFile( final Phylogeny t,\r
+ final GraphicsExportType type,\r
+ final MainPanel mp,\r
+ final JFileChooser writetographics_filechooser,\r
+ final Component component,\r
+ final Container contentpane,\r
+ final File current_dir ) {\r
+ File new_dir = null;\r
+ if ( ( t == null ) || t.isEmpty() ) {\r
+ return null;\r
+ }\r
+ String initial_filename = "";\r
+ if ( mp.getCurrentTreePanel().getTreeFile() != null ) {\r
+ initial_filename = mp.getCurrentTreePanel().getTreeFile().toString();\r
+ }\r
+ if ( initial_filename.indexOf( '.' ) > 0 ) {\r
+ initial_filename = initial_filename.substring( 0, initial_filename.lastIndexOf( '.' ) );\r
+ }\r
+ initial_filename = initial_filename + "." + type;\r
+ writetographics_filechooser.setSelectedFile( new File( initial_filename ) );\r
+ final File my_dir = current_dir;\r
+ if ( my_dir != null ) {\r
+ writetographics_filechooser.setCurrentDirectory( my_dir );\r
+ }\r
+ final int result = writetographics_filechooser.showSaveDialog( contentpane );\r
+ File file = writetographics_filechooser.getSelectedFile();\r
+ //setCurrentDir( writetographics_filechooser.getCurrentDirectory() );\r
+ new_dir = writetographics_filechooser.getCurrentDirectory();\r
+ if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
+ if ( !file.toString().toLowerCase().endsWith( type.toString() ) ) {\r
+ file = new File( file.toString() + "." + type );\r
+ }\r
+ if ( file.exists() ) {\r
+ final int i = JOptionPane.showConfirmDialog( component,\r
+ file + " already exists. Overwrite?",\r
+ "Warning",\r
+ JOptionPane.OK_CANCEL_OPTION,\r
+ JOptionPane.WARNING_MESSAGE );\r
+ if ( i != JOptionPane.OK_OPTION ) {\r
+ return null;\r
+ }\r
+ else {\r
+ try {\r
+ file.delete();\r
+ }\r
+ catch ( final Exception e ) {\r
+ JOptionPane.showMessageDialog( component,\r
+ "Failed to delete: " + file,\r
+ "Error",\r
+ JOptionPane.WARNING_MESSAGE );\r
+ }\r
+ }\r
}\r
- if ( tree_panel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {\r
- scale.setSelected( false );\r
- scale.setEnabled( false );\r
+ writePhylogenyToGraphicsFile( file.toString(), type, mp, component, contentpane );\r
+ }\r
+ return new_dir;\r
+ }\r
+\r
+ static File writeToPdf( final Phylogeny t,\r
+ final MainPanel mp,\r
+ final JFileChooser writetopdf_filechooser,\r
+ final File curr_dir,\r
+ final Container contentpane,\r
+ final Component component ) {\r
+ if ( ( t == null ) || t.isEmpty() ) {\r
+ return null;\r
+ }\r
+ String initial_filename = "";\r
+ if ( mp.getCurrentTreePanel().getTreeFile() != null ) {\r
+ initial_filename = mp.getCurrentTreePanel().getTreeFile().toString();\r
+ }\r
+ if ( initial_filename.indexOf( '.' ) > 0 ) {\r
+ initial_filename = initial_filename.substring( 0, initial_filename.lastIndexOf( '.' ) );\r
+ }\r
+ initial_filename = initial_filename + ".pdf";\r
+ writetopdf_filechooser.setSelectedFile( new File( initial_filename ) );\r
+ final File my_dir = curr_dir;\r
+ if ( my_dir != null ) {\r
+ writetopdf_filechooser.setCurrentDirectory( my_dir );\r
+ }\r
+ final int result = writetopdf_filechooser.showSaveDialog( contentpane );\r
+ File file = writetopdf_filechooser.getSelectedFile();\r
+ // setCurrentDir( writetopdf_filechooser.getCurrentDirectory() );\r
+ final File new_current_dir = writetopdf_filechooser.getCurrentDirectory();\r
+ if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
+ if ( !file.toString().toLowerCase().endsWith( ".pdf" ) ) {\r
+ file = new File( file.toString() + ".pdf" );\r
+ }\r
+ if ( file.exists() ) {\r
+ final int i = JOptionPane.showConfirmDialog( component,\r
+ file + " already exists. Overwrite?",\r
+ "WARNING",\r
+ JOptionPane.OK_CANCEL_OPTION,\r
+ JOptionPane.WARNING_MESSAGE );\r
+ if ( i != JOptionPane.OK_OPTION ) {\r
+ return null;\r
+ }\r
}\r
+ printPhylogenyToPdf( file.toString(), mp.getOptions(), mp.getCurrentTreePanel(), component );\r
}\r
+ return new_current_dir;\r
}\r
+}\r
\r
- static void updateScreenTextAntialias( final List<TreePanel> treepanels ) {\r
- for( final TreePanel tree_panel : treepanels ) {\r
- tree_panel.setTextAntialias();\r
- }\r
+class DefaultFilter extends FileFilter {\r
+\r
+ @Override\r
+ public boolean accept( final File f ) {\r
+ final String file_name = f.getName().trim().toLowerCase();\r
+ return file_name.endsWith( ".nh" ) || file_name.endsWith( ".newick" ) || file_name.endsWith( ".phy" )\r
+ || file_name.endsWith( ".nwk" ) || file_name.endsWith( ".phb" ) || file_name.endsWith( ".ph" )\r
+ || file_name.endsWith( ".tr" ) || file_name.endsWith( ".dnd" ) || file_name.endsWith( ".tree" )\r
+ || file_name.endsWith( ".nhx" ) || file_name.endsWith( ".xml" ) || file_name.endsWith( ".phyloxml" )\r
+ || file_name.endsWith( "phylo.xml" ) || file_name.endsWith( ".pxml" ) || file_name.endsWith( ".nexus" )\r
+ || file_name.endsWith( ".nx" ) || file_name.endsWith( ".nex" ) || file_name.endsWith( ".tre" )\r
+ || file_name.endsWith( ".zip" ) || file_name.endsWith( ".tol" ) || file_name.endsWith( ".tolxml" )\r
+ || file_name.endsWith( ".con" ) || f.isDirectory();\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return "All supported files (*.xml, *.phyloxml, *phylo.xml, *.nhx, *.nh, *.newick, *.nex, *.nexus, *.phy, *.tre, *.tree, *.tol, ...)";\r
+ }\r
+}\r
+\r
+class GraphicsFileFilter extends FileFilter {\r
+\r
+ @Override\r
+ public boolean accept( final File f ) {\r
+ final String file_name = f.getName().trim().toLowerCase();\r
+ return file_name.endsWith( ".jpg" ) || file_name.endsWith( ".jpeg" ) || file_name.endsWith( ".png" )\r
+ || file_name.endsWith( ".gif" ) || file_name.endsWith( ".bmp" ) || f.isDirectory();\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return "Image files (*.jpg, *.jpeg, *.png, *.gif, *.bmp)";\r
+ }\r
+}\r
+\r
+class MsaFileFilter extends FileFilter {\r
+\r
+ @Override\r
+ public boolean accept( final File f ) {\r
+ final String file_name = f.getName().trim().toLowerCase();\r
+ return file_name.endsWith( ".msa" ) || file_name.endsWith( ".aln" ) || file_name.endsWith( ".fasta" )\r
+ || file_name.endsWith( ".fas" ) || file_name.endsWith( ".fa" ) || f.isDirectory();\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return "Multiple sequence alignment files (*.msa, *.aln, *.fasta, *.fa, *.fas)";\r
+ }\r
+}\r
+\r
+class NexusFilter extends FileFilter {\r
+\r
+ @Override\r
+ public boolean accept( final File f ) {\r
+ final String file_name = f.getName().trim().toLowerCase();\r
+ return file_name.endsWith( ".nex" ) || file_name.endsWith( ".nexus" ) || file_name.endsWith( ".nx" )\r
+ || file_name.endsWith( ".tre" ) || f.isDirectory();\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return "Nexus files (*.nex, *.nexus, *.nx, *.tre)";\r
+ }\r
+} // NexusFilter\r
+\r
+class NHFilter extends FileFilter {\r
+\r
+ @Override\r
+ public boolean accept( final File f ) {\r
+ final String file_name = f.getName().trim().toLowerCase();\r
+ return file_name.endsWith( ".nh" ) || file_name.endsWith( ".newick" ) || file_name.endsWith( ".phy" )\r
+ || file_name.endsWith( ".tr" ) || file_name.endsWith( ".tree" ) || file_name.endsWith( ".dnd" )\r
+ || file_name.endsWith( ".ph" ) || file_name.endsWith( ".phb" ) || file_name.endsWith( ".nwk" )\r
+ || f.isDirectory();\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return "New Hampshire - Newick files (*.nh, *.newick, *.phy, *.tree, *.dnd, *.tr, *.ph, *.phb, *.nwk)";\r
+ }\r
+} // NHFilter\r
+\r
+class NHXFilter extends FileFilter {\r
+\r
+ @Override\r
+ public boolean accept( final File f ) {\r
+ final String file_name = f.getName().trim().toLowerCase();\r
+ return file_name.endsWith( ".nhx" ) || f.isDirectory();\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return "NHX files (*.nhx) [deprecated]";\r
}\r
}\r
+\r
+class PdfFilter extends FileFilter {\r
+\r
+ @Override\r
+ public boolean accept( final File f ) {\r
+ return f.getName().trim().toLowerCase().endsWith( ".pdf" ) || f.isDirectory();\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return "PDF files (*.pdf)";\r
+ }\r
+} // PdfFilter\r
+\r
+class SequencesFileFilter extends FileFilter {\r
+\r
+ @Override\r
+ public boolean accept( final File f ) {\r
+ final String file_name = f.getName().trim().toLowerCase();\r
+ return file_name.endsWith( ".fasta" ) || file_name.endsWith( ".fa" ) || file_name.endsWith( ".fas" )\r
+ || file_name.endsWith( ".seqs" ) || f.isDirectory();\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return "Sequences files (*.fasta, *.fa, *.fas, *.seqs )";\r
+ }\r
+}\r
+\r
+class TolFilter extends FileFilter {\r
+\r
+ @Override\r
+ public boolean accept( final File f ) {\r
+ final String file_name = f.getName().trim().toLowerCase();\r
+ return ( file_name.endsWith( ".tol" ) || file_name.endsWith( ".tolxml" ) || file_name.endsWith( ".zip" ) || f\r
+ .isDirectory() ) && ( !file_name.endsWith( ".xml.zip" ) );\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return "Tree of Life files (*.tol, *.tolxml)";\r
+ }\r
+} // TolFilter\r
+\r
+class XMLFilter extends FileFilter {\r
+\r
+ @Override\r
+ public boolean accept( final File f ) {\r
+ final String file_name = f.getName().trim().toLowerCase();\r
+ return file_name.endsWith( ".xml" ) || file_name.endsWith( ".phyloxml" ) || file_name.endsWith( "phylo.xml" )\r
+ || file_name.endsWith( ".pxml" ) || file_name.endsWith( ".zip" ) || f.isDirectory();\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return "phyloXML files (*.xml, *.phyloxml, *phylo.xml, *.pxml, *.zip)";\r
+ }\r
+} // XMLFilter\r