X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FMainFrame.java;h=e8d28e04019e929fdb5f075214a019560548dd2e;hb=df8e9950662eaab9427f6873dcd0072f0d28f690;hp=84d61856b4a4f42437b0dcca5810a8ad1cbfcb80;hpb=b48d82f75a2ff2f4e181092080371b8ab1abd618;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrame.java b/forester/java/src/org/forester/archaeopteryx/MainFrame.java index 84d6185..e8d28e0 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrame.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrame.java @@ -41,6 +41,7 @@ import java.util.NoSuchElementException; import javax.swing.Box; import javax.swing.JApplet; import javax.swing.JCheckBoxMenuItem; +import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenu; @@ -58,6 +59,8 @@ import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE; import org.forester.archaeopteryx.tools.InferenceManager; import org.forester.archaeopteryx.tools.ProcessPool; import org.forester.archaeopteryx.tools.ProcessRunning; +import org.forester.archaeopteryx.webservices.PhylogeniesWebserviceClient; +import org.forester.archaeopteryx.webservices.WebservicesManager; import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyMethods; @@ -65,6 +68,7 @@ import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY; import org.forester.phylogeny.PhylogenyNode; import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE; import org.forester.phylogeny.data.Annotation; +import org.forester.phylogeny.data.NodeDataField; import org.forester.phylogeny.data.NodeVisualData.NodeFill; import org.forester.phylogeny.data.NodeVisualData.NodeShape; import org.forester.phylogeny.iterators.PhylogenyNodeIterator; @@ -73,11 +77,12 @@ import org.forester.sdi.GSDIR; import org.forester.sdi.SDIException; import org.forester.util.ForesterConstants; import org.forester.util.ForesterUtil; +import org.forester.util.WindowsUtils; public abstract class MainFrame extends JFrame implements ActionListener { static final String USE_MOUSEWHEEL_SHIFT_TO_ROTATE = "In this display type, use mousewheel + Shift to rotate [or A and S]"; - static final String PHYLOXML_REF_TOOL_TIP = Constants.PHYLOXML_REFERENCE; //TODO //FIXME + static final String PHYLOXML_REF_TOOL_TIP = Constants.PHYLOXML_REFERENCE; //TODO //FIXME static final String APTX_REF_TOOL_TIP = Constants.APTX_REFERENCE; private static final long serialVersionUID = 3655000897845508358L; final static Font menu_font = new Font( Configuration.getDefaultFontFamilyName(), @@ -90,8 +95,8 @@ public abstract class MainFrame extends JFrame implements ActionListener { static final String TRIANGULAR_TYPE_CBMI_LABEL = "Triangular"; static final String CONVEX_TYPE_CBMI_LABEL = "Convex"; static final String ROUNDED_TYPE_CBMI_LABEL = "Rounded"; - static final String UNROOTED_TYPE_CBMI_LABEL = "Unrooted (alpha)"; //TODO - static final String CIRCULAR_TYPE_CBMI_LABEL = "Circular (alpha)"; //TODO + static final String UNROOTED_TYPE_CBMI_LABEL = "Unrooted (alpha)"; //TODO + static final String CIRCULAR_TYPE_CBMI_LABEL = "Circular (alpha)"; //TODO static final String OPTIONS_HEADER = "Options"; static final String SEARCH_SUBHEADER = "Search:"; static final String DISPLAY_SUBHEADER = "Display:"; @@ -105,6 +110,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { static final String UNIFORM_CLADOGRAMS_LABEL = "Total Node Sum Dependent Cladograms"; static final String LABEL_DIRECTION_LABEL = "Radial Labels"; static final String LABEL_DIRECTION_TIP = "To use radial node labels in radial and unrooted display types"; + 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."; static final String SCREEN_ANTIALIAS_LABEL = "Antialias"; static final String COLOR_LABELS_LABEL = "Colorize Labels Same as Parent Branch"; static final String BG_GRAD_LABEL = "Background Color Gradient"; @@ -150,6 +156,13 @@ public abstract class MainFrame extends JFrame implements ActionListener { JMenuItem _close_item; JMenuItem _exit_item; JMenuItem _new_item; + JMenuItem _print_item; + JMenuItem _write_to_pdf_item; + JMenuItem _write_to_jpg_item; + JMenuItem _write_to_gif_item; + JMenuItem _write_to_tif_item; + JMenuItem _write_to_png_item; + JMenuItem _write_to_bmp_item; // tools menu: JMenuItem _midpoint_root_item; JMenuItem _taxcolor_item; @@ -185,7 +198,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { JRadioButtonMenuItem _uniform_cladograms_rbmi; JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi; JCheckBoxMenuItem _color_by_taxonomic_group_cbmi; - JCheckBoxMenuItem _show_scale_cbmi; //TODO fix me + JCheckBoxMenuItem _show_scale_cbmi; //TODO fix me JCheckBoxMenuItem _show_overview_cbmi; JCheckBoxMenuItem _show_domain_labels; JCheckBoxMenuItem _show_annotation_ref_source; @@ -199,6 +212,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { JMenuItem _cycle_node_shape_mi; JMenuItem _cycle_node_fill_mi; JMenuItem _choose_node_size_mi; + JMenuItem _cycle_data_return; JCheckBoxMenuItem _show_confidence_stddev_cbmi; JCheckBoxMenuItem _right_line_up_domains_cbmi; JCheckBoxMenuItem _line_up_renderable_data_cbmi; @@ -247,12 +261,16 @@ public abstract class MainFrame extends JFrame implements ActionListener { JMenuItem _phyloxml_website_item; JMenuItem _phyloxml_ref_item; JMenuItem _aptx_ref_item; + // + JFileChooser _writetopdf_filechooser; + File _current_dir; + // process menu: JMenu _process_menu; // Handy pointers to child components: MainPanel _mainpanel; Container _contentpane; - final LinkedList _textframes = new LinkedList(); ; + final LinkedList _textframes = new LinkedList(); ; Configuration _configuration; Options _options; private Phylogeny _species_tree; @@ -262,6 +280,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { MainFrame() { _process_pool = ProcessPool.createInstance(); + _writetopdf_filechooser = new JFileChooser(); } /** @@ -403,10 +422,13 @@ public abstract class MainFrame extends JFrame implements ActionListener { MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() ); } else if ( o == _cycle_node_fill_mi ) { - MainFrame.cycleNodeFill( getOptions(), getCurrentTreePanel() ); + MainFrame.cycleNodeFill( getOptions() ); } else if ( o == _cycle_node_shape_mi ) { - MainFrame.cycleNodeShape( getOptions(), getCurrentTreePanel() ); + MainFrame.cycleNodeShape( getOptions() ); + } + else if ( o == _cycle_data_return ) { + MainFrame.cycleNodeDataReturn( getOptions(), getConfiguration() ); } else if ( o == _screen_antialias_cbmi ) { updateOptions( getOptions() ); @@ -567,6 +589,9 @@ public abstract class MainFrame extends JFrame implements ActionListener { ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() ); } } + else if ( o == _write_to_pdf_item ) { + writeToPdf( _mainpanel.getCurrentPhylogeny() ); + } else { if ( _load_phylogeny_from_webservice_menu_items != null ) { for( int i = 0; i < _load_phylogeny_from_webservice_menu_items.length; ++i ) { @@ -579,6 +604,122 @@ public abstract class MainFrame extends JFrame implements ActionListener { _contentpane.repaint(); } + + void setCurrentDir( final File current_dir ) { + _current_dir = current_dir; + } + + void writeToPdf( final Phylogeny t ) { + if ( ( t == null ) || t.isEmpty() ) { + return; + } + String initial_filename = ""; + if ( getMainPanel().getCurrentTreePanel().getTreeFile() != null ) { + initial_filename = getMainPanel().getCurrentTreePanel().getTreeFile().toString(); + } + if ( initial_filename.indexOf( '.' ) > 0 ) { + initial_filename = initial_filename.substring( 0, initial_filename.lastIndexOf( '.' ) ); + } + initial_filename = initial_filename + ".pdf"; + _writetopdf_filechooser.setSelectedFile( new File( initial_filename ) ); + final File my_dir = getCurrentDir(); + if ( my_dir != null ) { + _writetopdf_filechooser.setCurrentDirectory( my_dir ); + } + final int result = _writetopdf_filechooser.showSaveDialog( _contentpane ); + File file = _writetopdf_filechooser.getSelectedFile(); + setCurrentDir( _writetopdf_filechooser.getCurrentDirectory() ); + if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) { + if ( !file.toString().toLowerCase().endsWith( ".pdf" ) ) { + file = new File( file.toString() + ".pdf" ); + } + if ( file.exists() ) { + final int i = JOptionPane.showConfirmDialog( this, + file + " already exists. Overwrite?", + "WARNING", + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.WARNING_MESSAGE ); + if ( i != JOptionPane.OK_OPTION ) { + return; + } + } + printPhylogenyToPdf( file.toString() ); + } + } + + + void printPhylogenyToPdf( final String file_name ) { + if ( !getOptions().isPrintUsingActualSize() ) { + getCurrentTreePanel() + .calcParametersForPainting( getOptions().getPrintSizeX(), getOptions().getPrintSizeY() ); + getCurrentTreePanel().resetPreferredSize(); + getCurrentTreePanel().repaint(); + } + String pdf_written_to = ""; + boolean error = false; + try { + if ( getOptions().isPrintUsingActualSize() ) { + pdf_written_to = PdfExporter.writePhylogenyToPdf( file_name, + getCurrentTreePanel(), + getCurrentTreePanel().getWidth(), + getCurrentTreePanel().getHeight() ); + } + else { + pdf_written_to = PdfExporter.writePhylogenyToPdf( file_name, getCurrentTreePanel(), getOptions() + .getPrintSizeX(), getOptions().getPrintSizeY() ); + } + } + catch ( final IOException e ) { + error = true; + JOptionPane.showMessageDialog( this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE ); + } + if ( !error ) { + if ( !ForesterUtil.isEmpty( pdf_written_to ) ) { + JOptionPane.showMessageDialog( this, + "Wrote PDF to: " + pdf_written_to, + "Information", + JOptionPane.INFORMATION_MESSAGE ); + } + else { + JOptionPane.showMessageDialog( this, + "There was an unknown problem when attempting to write to PDF file: \"" + + file_name + "\"", + "Error", + JOptionPane.ERROR_MESSAGE ); + } + } + if ( !getOptions().isPrintUsingActualSize() ) { + getControlPanel().showWhole(); + } + } + + ControlPanel getControlPanel() { + return getMainPanel().getControlPanel(); + } + + + File getCurrentDir() { + if ( ( _current_dir == null ) || !_current_dir.canRead() ) { + if ( ForesterUtil.isWindows() ) { + try { + _current_dir = new File( WindowsUtils.getCurrentUserDesktopPath() ); + } + catch ( final Exception e ) { + _current_dir = null; + } + } + } + if ( ( _current_dir == null ) || !_current_dir.canRead() ) { + if ( System.getProperty( "user.home" ) != null ) { + _current_dir = new File( System.getProperty( "user.home" ) ); + } + else if ( System.getProperty( "user.dir" ) != null ) { + _current_dir = new File( System.getProperty( "user.dir" ) ); + } + } + return _current_dir; + } + private void deleteSelectedNodes( final boolean delete ) { final Phylogeny phy = getMainPanel().getCurrentPhylogeny(); if ( ( phy == null ) || ( phy.getNumberOfExternalNodes() < 2 ) ) { @@ -599,10 +740,10 @@ public abstract class MainFrame extends JFrame implements ActionListener { } if ( ( nodes == null ) || nodes.isEmpty() ) { JOptionPane - .showMessageDialog( this, - "Need to select external nodes, either via direct selection or via the \"Search\" function", - "No external nodes selected to " + function.toLowerCase(), - JOptionPane.ERROR_MESSAGE ); + .showMessageDialog( this, + "Need to select external nodes, either via direct selection or via the \"Search\" function", + "No external nodes selected to " + function.toLowerCase(), + JOptionPane.ERROR_MESSAGE ); return; } final int todo = nodes.size(); @@ -619,8 +760,8 @@ public abstract class MainFrame extends JFrame implements ActionListener { return; } final int result = JOptionPane.showConfirmDialog( null, function + " " + todo - + " external node(s), from a total of " + ext + " external nodes," + "\nresulting in tree with " + res - + " nodes?", function + " external nodes", JOptionPane.OK_CANCEL_OPTION ); + + " external node(s), from a total of " + ext + " external nodes," + "\nresulting in tree with " + res + + " nodes?", function + " external nodes", JOptionPane.OK_CANCEL_OPTION ); if ( result == JOptionPane.OK_OPTION ) { if ( !delete ) { final List to_delete = new ArrayList(); @@ -674,7 +815,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { * has been selected by the user by clicking the "Return ..." * menu item. This method is expected to be called from Javascript or * something like it. - * + * * @return current external node data as String */ public String getCurrentExternalNodesDataBuffer() { @@ -735,9 +876,50 @@ public abstract class MainFrame extends JFrame implements ActionListener { } } +// void buildFileMenu() { +// _file_jmenu = createMenu( "File", getConfiguration() ); +// _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) ); +// customizeJMenuItem( _exit_item ); +// _jmenubar.add( _file_jmenu ); +// } + void buildFileMenu() { - _file_jmenu = createMenu( "File", getConfiguration() ); + _file_jmenu = MainFrame.createMenu( "File", getConfiguration() ); + + // _file_jmenu.add( _save_item = new JMenuItem( "Save Tree As..." ) ); + // _file_jmenu.add( _save_all_item = new JMenuItem( "Save All Trees As..." ) ); + // _save_all_item.setToolTipText( "Write all phylogenies to one file." ); + // _save_all_item.setEnabled( false ); + // _file_jmenu.addSeparator(); + _file_jmenu.add( _write_to_pdf_item = new JMenuItem( "Export to PDF file ..." ) ); +// if ( AptxUtil.canWriteFormat( "tif" ) || AptxUtil.canWriteFormat( "tiff" ) || AptxUtil.canWriteFormat( "TIF" ) ) { +// _file_jmenu.add( _write_to_tif_item = new JMenuItem( "Export to TIFF file..." ) ); +// } +// _file_jmenu.add( _write_to_png_item = new JMenuItem( "Export to PNG file..." ) ); +// _file_jmenu.add( _write_to_jpg_item = new JMenuItem( "Export to JPG file..." ) ); +// if ( AptxUtil.canWriteFormat( "gif" ) ) { +// _file_jmenu.add( _write_to_gif_item = new JMenuItem( "Export to GIF file..." ) ); +// } +// if ( AptxUtil.canWriteFormat( "bmp" ) ) { +// _file_jmenu.add( _write_to_bmp_item = new JMenuItem( "Export to BMP file..." ) ); +// } + // _file_jmenu.addSeparator(); + // _file_jmenu.add( _print_item = new JMenuItem( "Print..." ) ); + _file_jmenu.addSeparator(); + _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) ); + + customizeJMenuItem( _save_item ); + +// customizeJMenuItem( _close_item ); + //customizeJMenuItem( _save_all_item ); + customizeJMenuItem( _write_to_pdf_item ); +// customizeJMenuItem( _write_to_png_item ); +// customizeJMenuItem( _write_to_jpg_item ); +// customizeJMenuItem( _write_to_gif_item ); +// customizeJMenuItem( _write_to_tif_item ); +// customizeJMenuItem( _write_to_bmp_item ); +// customizeJMenuItem( _print_item ); customizeJMenuItem( _exit_item ); _jmenubar.add( _file_jmenu ); } @@ -989,8 +1171,8 @@ public abstract class MainFrame extends JFrame implements ActionListener { + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n" + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n" + "Number of polytomies in species tree used: " + poly + "\n", - "GSDI successfully completed", - JOptionPane.WARNING_MESSAGE ); + "GSDI successfully completed", + JOptionPane.WARNING_MESSAGE ); } else { JOptionPane.showMessageDialog( this, @@ -1002,8 +1184,8 @@ public abstract class MainFrame extends JFrame implements ActionListener { + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n" + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n" + "Number of polytomies in species tree used: " + poly + "\n", - "GSDI successfully completed", - JOptionPane.INFORMATION_MESSAGE ); + "GSDI successfully completed", + JOptionPane.INFORMATION_MESSAGE ); } } @@ -1062,8 +1244,8 @@ public abstract class MainFrame extends JFrame implements ActionListener { + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n" + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n" + "Number of polytomies in species tree used: " + poly + "\n", - "GSDIR successfully completed", - JOptionPane.WARNING_MESSAGE ); + "GSDIR successfully completed", + JOptionPane.WARNING_MESSAGE ); } else { JOptionPane.showMessageDialog( this, @@ -1073,8 +1255,8 @@ public abstract class MainFrame extends JFrame implements ActionListener { + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n" + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n" + "Number of polytomies in species tree used: " + poly + "\n", - "GSDIR successfully completed", - JOptionPane.INFORMATION_MESSAGE ); + "GSDIR successfully completed", + JOptionPane.INFORMATION_MESSAGE ); } } @@ -1182,10 +1364,10 @@ public abstract class MainFrame extends JFrame implements ActionListener { if ( getCurrentTreePanel() != null ) { if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) { JOptionPane - .showMessageDialog( this, - "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.", - "Operation can not be exectuted on a sub-tree", - JOptionPane.WARNING_MESSAGE ); + .showMessageDialog( this, + "This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.", + "Operation can not be exectuted on a sub-tree", + JOptionPane.WARNING_MESSAGE ); return true; } } @@ -1317,20 +1499,20 @@ public abstract class MainFrame extends JFrame implements ActionListener { void updateOptions( final Options options ) { options.setAntialiasScreen( ( _screen_antialias_cbmi != null ) && _screen_antialias_cbmi.isSelected() ); options.setBackgroundColorGradient( ( _background_gradient_cbmi != null ) - && _background_gradient_cbmi.isSelected() ); + && _background_gradient_cbmi.isSelected() ); options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() ); options.setShowAnnotationRefSource( ( _show_annotation_ref_source != null ) - && _show_annotation_ref_source.isSelected() ); + && _show_annotation_ref_source.isSelected() ); options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null ) - && _abbreviate_scientific_names.isSelected() ); + && _abbreviate_scientific_names.isSelected() ); options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null ) - && _color_labels_same_as_parent_branch.isSelected() ); + && _color_labels_same_as_parent_branch.isSelected() ); options.setShowDefaultNodeShapesInternal( ( _show_default_node_shapes_internal_cbmi != null ) - && _show_default_node_shapes_internal_cbmi.isSelected() ); + && _show_default_node_shapes_internal_cbmi.isSelected() ); options.setShowDefaultNodeShapesExternal( ( _show_default_node_shapes_external_cbmi != null ) - && _show_default_node_shapes_external_cbmi.isSelected() ); + && _show_default_node_shapes_external_cbmi.isSelected() ); options.setShowDefaultNodeShapesForMarkedNodes( ( _show_default_node_shapes_for_marked_cbmi != null ) - && _show_default_node_shapes_for_marked_cbmi.isSelected() ); + && _show_default_node_shapes_for_marked_cbmi.isSelected() ); if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) { options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP ); } @@ -1341,7 +1523,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP ); } options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null ) - && _search_case_senstive_cbmi.isSelected() ); + && _search_case_senstive_cbmi.isSelected() ); if ( ( _show_scale_cbmi != null ) && _show_scale_cbmi.isEnabled() ) { options.setShowScale( _show_scale_cbmi.isSelected() ); } @@ -1355,14 +1537,14 @@ public abstract class MainFrame extends JFrame implements ActionListener { } options.setShowOverview( ( _show_overview_cbmi != null ) && _show_overview_cbmi.isSelected() ); options.setShowConfidenceStddev( ( _show_confidence_stddev_cbmi != null ) - && _show_confidence_stddev_cbmi.isSelected() ); + && _show_confidence_stddev_cbmi.isSelected() ); if ( ( _color_by_taxonomic_group_cbmi != null ) && _color_by_taxonomic_group_cbmi.isEnabled() ) { options.setColorByTaxonomicGroup( _color_by_taxonomic_group_cbmi.isSelected() ); } options.setPrintUsingActualSize( ( _print_using_actual_size_cbmi != null ) - && ( _print_using_actual_size_cbmi.isSelected() ) ); + && ( _print_using_actual_size_cbmi.isSelected() ) ); options.setGraphicsExportUsingActualSize( ( _graphics_export_using_actual_size_cbmi != null ) - && ( _graphics_export_using_actual_size_cbmi.isSelected() ) ); + && ( _graphics_export_using_actual_size_cbmi.isSelected() ) ); options.setAntialiasPrint( ( _antialias_print_cbmi != null ) && _antialias_print_cbmi.isSelected() ); if ( ( _use_brackets_for_conf_in_nh_export_cbmi != null ) && _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) { @@ -1376,9 +1558,9 @@ public abstract class MainFrame extends JFrame implements ActionListener { options.setNhConversionSupportValueStyle( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ); } options.setPrintBlackAndWhite( ( _print_black_and_white_cbmi != null ) - && _print_black_and_white_cbmi.isSelected() ); + && _print_black_and_white_cbmi.isSelected() ); options.setInternalNumberAreConfidenceForNhParsing( ( _internal_number_are_confidence_for_nh_parsing_cbmi != null ) - && _internal_number_are_confidence_for_nh_parsing_cbmi.isSelected() ); + && _internal_number_are_confidence_for_nh_parsing_cbmi.isSelected() ); if ( ( _extract_taxonomy_pfam_strict_rbmi != null ) && _extract_taxonomy_pfam_strict_rbmi.isSelected() ) { options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ); } @@ -1392,14 +1574,14 @@ public abstract class MainFrame extends JFrame implements ActionListener { options.setTaxonomyExtraction( TAXONOMY_EXTRACTION.NO ); } options.setReplaceUnderscoresInNhParsing( ( _replace_underscores_cbmi != null ) - && _replace_underscores_cbmi.isSelected() ); + && _replace_underscores_cbmi.isSelected() ); options.setAllowErrorsInDistanceToParent( ( _allow_errors_in_distance_to_parent_cbmi != null ) - && _allow_errors_in_distance_to_parent_cbmi.isSelected() ); + && _allow_errors_in_distance_to_parent_cbmi.isSelected() ); options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null ) - && _search_whole_words_only_cbmi.isSelected() ); + && _search_whole_words_only_cbmi.isSelected() ); options.setSearchWithRegex( ( _search_with_regex_cbmi != null ) && _search_with_regex_cbmi.isSelected() ); options.setInverseSearchResult( ( _inverse_search_result_cbmi != null ) - && _inverse_search_result_cbmi.isSelected() ); + && _inverse_search_result_cbmi.isSelected() ); if ( _graphics_export_visible_only_cbmi != null ) { options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() ); if ( _graphics_export_visible_only_cbmi.isSelected() && ( _graphics_export_using_actual_size_cbmi != null ) ) { @@ -1465,8 +1647,8 @@ public abstract class MainFrame extends JFrame implements ActionListener { title = "\"" + getMainPanel().getCurrentPhylogeny().getName() + "\" in " + title; } showTextFrame( _mainpanel.getCurrentPhylogeny().toNewHampshire( getOptions() - .getNhConversionSupportValueStyle() ), - title ); + .getNhConversionSupportValueStyle() ), + title ); } } @@ -1489,10 +1671,10 @@ public abstract class MainFrame extends JFrame implements ActionListener { } if ( ( nodes == null ) || nodes.isEmpty() ) { JOptionPane - .showMessageDialog( this, - "Need to select nodes, either via direct selection or via the \"Search\" function", - "No nodes selected for annotation", - JOptionPane.ERROR_MESSAGE ); + .showMessageDialog( this, + "Need to select nodes, either via direct selection or via the \"Search\" function", + "No nodes selected for annotation", + JOptionPane.ERROR_MESSAGE ); return; } final Phylogeny phy = getMainPanel().getCurrentPhylogeny(); @@ -1511,7 +1693,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { my_panel, "Enter the sequence annotation(s) for the " + nodes.size() + " selected nodes", - JOptionPane.OK_CANCEL_OPTION ); + JOptionPane.OK_CANCEL_OPTION ); if ( result == JOptionPane.OK_OPTION ) { String ref = ref_field.getText(); String desc = desc_filed.getText(); @@ -1538,7 +1720,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { for( final PhylogenyNode n : nodes ) { ForesterUtil.ensurePresenceOfSequence( n ); final Annotation ann = ForesterUtil.isEmpty( ref ) ? new Annotation() - : new Annotation( ref ); + : new Annotation( ref ); if ( !ForesterUtil.isEmpty( desc ) ) { ann.setDesc( desc ); } @@ -1563,11 +1745,11 @@ public abstract class MainFrame extends JFrame implements ActionListener { .showInputDialog( this, "Please enter the minimum for confidence values to be displayed.\n" + "[current value: " + getOptions().getMinConfidenceValue() + "]\n", - "Minimal Confidence Value", - JOptionPane.QUESTION_MESSAGE, - null, - null, - getOptions().getMinConfidenceValue() ); + "Minimal Confidence Value", + JOptionPane.QUESTION_MESSAGE, + null, + null, + getOptions().getMinConfidenceValue() ); if ( !ForesterUtil.isEmpty( s ) ) { boolean success = true; double m = 0.0; @@ -1675,11 +1857,11 @@ public abstract class MainFrame extends JFrame implements ActionListener { "Please enter the default size for node shapes.\n" + "[current value: " + options.getDefaultNodeShapeSize() + "]\n", - "Node Shape Size", - JOptionPane.QUESTION_MESSAGE, - null, - null, - options.getDefaultNodeShapeSize() ); + "Node Shape Size", + JOptionPane.QUESTION_MESSAGE, + null, + null, + options.getDefaultNodeShapeSize() ); if ( !ForesterUtil.isEmpty( s ) ) { boolean success = true; double m = 0.0; @@ -1730,7 +1912,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { return label; } - static void cycleNodeFill( final Options op, final TreePanel tree_panel ) { + static void cycleNodeFill( final Options op ) { switch ( op.getDefaultNodeFill() ) { case GRADIENT: op.setDefaultNodeFill( NodeFill.SOLID ); @@ -1746,7 +1928,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { } } - static void cycleNodeShape( final Options op, final TreePanel tree_panel ) { + static void cycleNodeShape( final Options op ) { switch ( op.getDefaultNodeShape() ) { case CIRCLE: op.setDefaultNodeShape( NodeShape.RECTANGLE ); @@ -1759,6 +1941,42 @@ public abstract class MainFrame extends JFrame implements ActionListener { } } + private static void cycleNodeDataReturn( final Options op, Configuration conf ) { + switch ( op.getExtDescNodeDataToReturn() ) { + case UNKNOWN: + op.setExtDescNodeDataToReturn( NodeDataField.DOMAINS_ALL ); + break; + case DOMAINS_ALL: + op.setExtDescNodeDataToReturn( NodeDataField.DOMAINS_COLLAPSED_PER_PROTEIN ); + break; + case DOMAINS_COLLAPSED_PER_PROTEIN: + op.setExtDescNodeDataToReturn( NodeDataField.SEQ_ANNOTATIONS ); + break; + case SEQ_ANNOTATIONS: + op.setExtDescNodeDataToReturn( NodeDataField.GO_TERM_IDS ); + break; + case GO_TERM_IDS: + op.setExtDescNodeDataToReturn( NodeDataField.SEQUENCE_MOL_SEQ_FASTA ); + break; + case SEQUENCE_MOL_SEQ_FASTA: + if ( conf != null && conf.getExtDescNodeDataToReturn() != null + && conf.getExtDescNodeDataToReturn() != NodeDataField.DOMAINS_ALL + && conf.getExtDescNodeDataToReturn() != NodeDataField.DOMAINS_COLLAPSED_PER_PROTEIN + && conf.getExtDescNodeDataToReturn() != NodeDataField.SEQ_ANNOTATIONS + && conf.getExtDescNodeDataToReturn() != NodeDataField.GO_TERM_IDS + && conf.getExtDescNodeDataToReturn() != NodeDataField.SEQUENCE_MOL_SEQ_FASTA + ) { + op.setExtDescNodeDataToReturn( conf.getExtDescNodeDataToReturn() ); + } + else { + op.setExtDescNodeDataToReturn( NodeDataField.UNKNOWN ); + } + break; + default: + op.setExtDescNodeDataToReturn( NodeDataField.UNKNOWN ); + } + } + static void cycleOverview( final Options op, final TreePanel tree_panel ) { switch ( op.getOvPlacement() ) { case LOWER_LEFT: @@ -1801,6 +2019,16 @@ public abstract class MainFrame extends JFrame implements ActionListener { } } + static void setCycleDataReturnMenuItem( final JMenuItem mi, final Options options ) { + if ( ( options != null ) && ( options.getExtDescNodeDataToReturn() != null ) ) { + mi.setText( "Cycle Node Return Data... (current: " + + options.getExtDescNodeDataToReturn().toString() + ")" ); + } + else { + mi.setText( "Cycle Node Return Data..." ); + } + } + static void setOvPlacementColorChooseMenuItem( final JMenuItem mi, final Options options ) { if ( ( options != null ) && ( options.getOvPlacement() != null ) ) { mi.setText( "Cycle Overview Placement... (current: " + options.getOvPlacement() + ")" ); @@ -1813,7 +2041,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { static void setTextColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) { if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) { mi.setText( "Select Color Scheme... (current: " + tree_panel.getTreeColorSet().getCurrentColorSchemeName() - + ")" ); + + ")" ); } else { mi.setText( "Select Color Scheme..." );