X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FMainFrameApplication.java;h=ae302bd443254f23ca6618432de2f33cd5bfdf82;hb=038c34792757a86f24296de5683e722fab3f9307;hp=4ef0472a959c961cc81c8f74dea4f57d25e3f6dd;hpb=605b9b5326538a70a7afe353368b206516292575;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java index 4ef0472..ae302bd 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java @@ -44,7 +44,6 @@ import java.util.List; import java.util.Set; import javax.swing.ButtonGroup; -import javax.swing.Icon; import javax.swing.JCheckBoxMenuItem; import javax.swing.JFileChooser; import javax.swing.JMenu; @@ -58,6 +57,7 @@ import javax.swing.WindowConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.filechooser.FileFilter; +import javax.swing.plaf.synth.SynthLookAndFeel; import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE; import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION; @@ -80,6 +80,7 @@ import org.forester.io.parsers.nhx.NHXParser; import org.forester.io.parsers.phyloxml.PhyloXmlParser; import org.forester.io.parsers.phyloxml.PhyloXmlUtil; import org.forester.io.parsers.tol.TolParser; +import org.forester.io.parsers.util.ParserUtils; import org.forester.io.writers.PhylogenyWriter; import org.forester.io.writers.SequenceWriter; import org.forester.msa.Msa; @@ -102,8 +103,6 @@ import org.forester.util.BasicTable; import org.forester.util.BasicTableParser; import org.forester.util.DescriptiveStatistics; import org.forester.util.ForesterUtil; -import org.forester.util.ForesterUtil.PhylogenyNodeField; -import org.forester.util.ForesterUtil.TAXONOMY_EXTRACTION; import org.forester.util.WindowsUtils; class DefaultFilter extends FileFilter { @@ -174,21 +173,22 @@ class SequencesFileFilter extends FileFilter { public final class MainFrameApplication extends MainFrame { - private final static int FRAME_X_SIZE = 800; - private final static int FRAME_Y_SIZE = 800; + static final String INFER_ANCESTOR_TAXONOMIES = "Infer Ancestor Taxonomies"; + static final String OBTAIN_DETAILED_TAXONOMIC_INFORMATION = "Obtain Detailed Taxonomic Information"; + private final static int FRAME_X_SIZE = 800; + private final static int FRAME_Y_SIZE = 800; // Filters for the file-open dialog (classes defined in this file) - private final static NHFilter nhfilter = new NHFilter(); - private final static NHXFilter nhxfilter = new NHXFilter(); - private final static XMLFilter xmlfilter = new XMLFilter(); - private final static TolFilter tolfilter = new TolFilter(); - private final static NexusFilter nexusfilter = new NexusFilter(); - private final static PdfFilter pdffilter = new PdfFilter(); - private final static GraphicsFileFilter graphicsfilefilter = new GraphicsFileFilter(); - private final static MsaFileFilter msafilter = new MsaFileFilter(); - private final static SequencesFileFilter seqsfilter = new SequencesFileFilter(); - private final static DefaultFilter defaultfilter = new DefaultFilter(); - private static final long serialVersionUID = -799735726778865234L; - + private final static NHFilter nhfilter = new NHFilter(); + private final static NHXFilter nhxfilter = new NHXFilter(); + private final static XMLFilter xmlfilter = new XMLFilter(); + private final static TolFilter tolfilter = new TolFilter(); + private final static NexusFilter nexusfilter = new NexusFilter(); + private final static PdfFilter pdffilter = new PdfFilter(); + private final static GraphicsFileFilter graphicsfilefilter = new GraphicsFileFilter(); + private final static MsaFileFilter msafilter = new MsaFileFilter(); + private final static SequencesFileFilter seqsfilter = new SequencesFileFilter(); + private final static DefaultFilter defaultfilter = new DefaultFilter(); + private static final long serialVersionUID = -799735726778865234L; private final JFileChooser _values_filechooser; private final JFileChooser _open_filechooser; private final JFileChooser _msa_filechooser; @@ -218,17 +218,17 @@ public final class MainFrameApplication extends MainFrame { private File _current_dir; private ButtonGroup _radio_group_1; // Others: - double _min_not_collapse = Constants.MIN_NOT_COLLAPSE_DEFAULT; + double _min_not_collapse = Constants.MIN_NOT_COLLAPSE_DEFAULT; // Phylogeny Inference menu private JMenu _inference_menu; private JMenuItem _inference_from_msa_item; private JMenuItem _inference_from_seqs_item; // Phylogeny Inference - private PhylogeneticInferenceOptions _phylogenetic_inference_options = null; - private Msa _msa = null; - private File _msa_file = null; - private List _seqs = null; - private File _seqs_file = null; + private PhylogeneticInferenceOptions _phylogenetic_inference_options = null; + private Msa _msa = null; + private File _msa_file = null; + private List _seqs = null; + private File _seqs_file = null; // expression values menu: JMenuItem _read_values_jmi; @@ -238,25 +238,42 @@ public final class MainFrameApplication extends MainFrame { throw new IllegalArgumentException( "configuration is null" ); } try { - if ( _configuration.isUseNativeUI() ) { - UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() ); + boolean synth_exception = false; + if ( Constants.__SYNTH_LF ) { + try { + final SynthLookAndFeel synth = new SynthLookAndFeel(); + synth.load( MainFrameApplication.class.getResourceAsStream( "/resources/synth_look_and_feel_1.xml" ), + MainFrameApplication.class ); + UIManager.setLookAndFeel( synth ); + } + catch ( final Exception ex ) { + synth_exception = true; + ForesterUtil.printWarningMessage( Constants.PRG_NAME, + "could not create synth look and feel: " + + ex.getLocalizedMessage() ); + } } - else { - UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() ); + if ( !Constants.__SYNTH_LF || synth_exception ) { + if ( _configuration.isUseNativeUI() ) { + UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() ); + } + else { + UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() ); + } } //UIManager.setLookAndFeel( "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel" ); } catch ( final UnsupportedLookAndFeelException e ) { - Util.dieWithSystemError( "UnsupportedLookAndFeelException: " + e.toString() ); + Util.dieWithSystemError( "unsupported look and feel: " + e.toString() ); } catch ( final ClassNotFoundException e ) { - Util.dieWithSystemError( "ClassNotFoundException: " + e.toString() ); + Util.dieWithSystemError( "class not found exception: " + e.toString() ); } catch ( final InstantiationException e ) { - Util.dieWithSystemError( "InstantiationException: " + e.toString() ); + Util.dieWithSystemError( "instantiation exception: " + e.toString() ); } catch ( final IllegalAccessException e ) { - Util.dieWithSystemError( "IllegalAccessException: " + e.toString() ); + Util.dieWithSystemError( "illegal access exception: " + e.toString() ); } catch ( final Exception e ) { Util.dieWithSystemError( e.toString() ); @@ -480,6 +497,12 @@ public final class MainFrameApplication extends MainFrame { } obtainDetailedTaxonomicInformation(); } + else if ( o == _obtain_detailed_taxonomic_information_deleting_jmi ) { + if ( isSubtreeDisplayed() ) { + return; + } + obtainDetailedTaxonomicInformationDelete(); + } else if ( o == _obtain_uniprot_seq_information_jmi ) { obtainUniProtSequenceInformation(); } @@ -591,7 +614,7 @@ public final class MainFrameApplication extends MainFrame { customizeJMenuItem( _root_min_cost_l_item ); customizeJMenuItem( _load_species_tree_item ); _analysis_menu.addSeparator(); - _analysis_menu.add( _lineage_inference = new JMenuItem( "Infer Ancestor Taxonomies" ) ); + _analysis_menu.add( _lineage_inference = new JMenuItem( INFER_ANCESTOR_TAXONOMIES ) ); customizeJMenuItem( _lineage_inference ); _lineage_inference.setToolTipText( "Inference of ancestor taxonomies/lineages" ); _jmenubar.add( _analysis_menu ); @@ -687,7 +710,7 @@ public final class MainFrameApplication extends MainFrame { @Override public void stateChanged( final ChangeEvent e ) { - MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getCurrentTreePanel() ); + MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getOptions() ); MainFrame.setTextColorChooseMenuItem( _switch_colors_mi, getCurrentTreePanel() ); MainFrame .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() ); @@ -702,6 +725,9 @@ public final class MainFrameApplication extends MainFrame { _uniform_cladograms_rbmi, _ext_node_dependent_cladogram_rbmi, _label_direction_cbmi ); + MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() ); + MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() ); + MainFrame.setTextNodeSizeMenuItem( _choose_node_size_mi, getOptions() ); } } ); _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( DISPLAY_SUBHEADER ), getConfiguration() ) ); @@ -713,17 +739,12 @@ public final class MainFrameApplication extends MainFrame { _radio_group_1.add( _ext_node_dependent_cladogram_rbmi ); _radio_group_1.add( _uniform_cladograms_rbmi ); _radio_group_1.add( _non_lined_up_cladograms_rbmi ); - - // _options_jmenu.add( _show_default_node_shapes_cbmi = new JCheckBoxMenuItem( DISPLAY_NODE_BOXES_LABEL ) ); - - - _options_jmenu.add( _taxonomy_colorize_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.TAXONOMY_COLORIZE_NODE_SHAPES_LABEL) ); - _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL)); - _options_jmenu.add( _cycle_node_fill_mi = new JMenuItem( MainFrame.CYCLE_NODE_FILL_LABEL )); - _options_jmenu.add( _choose_node_size_mi = new JMenuItem( MainFrame.CHOOSE_NODE_SIZE_LABEL )); - // - + _options_jmenu + .add( _taxonomy_colorize_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.TAXONOMY_COLORIZE_NODE_SHAPES_LABEL ) ); + _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL ) ); + _options_jmenu.add( _cycle_node_fill_mi = new JMenuItem( MainFrame.CYCLE_NODE_FILL_LABEL ) ); + _options_jmenu.add( _choose_node_size_mi = new JMenuItem( MainFrame.CHOOSE_NODE_SIZE_LABEL ) ); _options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( DISPLAY_SCALE_LABEL ) ); _options_jmenu .add( _show_branch_length_values_cbmi = new JCheckBoxMenuItem( DISPLAY_BRANCH_LENGTH_VALUES_LABEL ) ); @@ -774,13 +795,11 @@ public final class MainFrameApplication extends MainFrame { customizeJMenuItem( _print_size_mi ); customizeJMenuItem( _choose_pdf_width_mi ); customizeJMenuItem( _overview_placment_mi ); - //TODO FIXME ~~ customizeCheckBoxMenuItem( _show_default_node_shapes_cbmi, getOptions().isShowDefaultNodeShapes() ); customizeCheckBoxMenuItem( _taxonomy_colorize_node_shapes_cbmi, getOptions().isTaxonomyColorizeNodeShapes() ); customizeJMenuItem( _cycle_node_shape_mi ); customizeJMenuItem( _cycle_node_fill_mi ); customizeJMenuItem( _choose_node_size_mi ); - //TODO FIXME ~~ customizeCheckBoxMenuItem( _color_labels_same_as_parent_branch, getOptions().isColorLabelsSameAsParentBranch() ); customizeCheckBoxMenuItem( _screen_antialias_cbmi, getOptions().isAntialiasScreen() ); customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() ); @@ -818,6 +837,9 @@ public final class MainFrameApplication extends MainFrame { _tools_menu = createMenu( "Tools", getConfiguration() ); _tools_menu.add( _confcolor_item = new JMenuItem( "Colorize Branches Depending on Confidence" ) ); customizeJMenuItem( _confcolor_item ); + _tools_menu.add( _color_rank_jmi = new JMenuItem( "Colorize Subtrees via Taxonomic Rank" ) ); + customizeJMenuItem( _color_rank_jmi ); + _color_rank_jmi.setToolTipText( "for example, at \"Class\" level, colorize mammal specific subtree red" ); _tools_menu.add( _taxcolor_item = new JMenuItem( "Taxonomy Colorize Branches" ) ); customizeJMenuItem( _taxcolor_item ); _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete Branch Colors" ) ); @@ -853,11 +875,16 @@ public final class MainFrameApplication extends MainFrame { customizeJMenuItem( _infer_common_sn_names_item ); _tools_menu.addSeparator(); _tools_menu - .add( _obtain_detailed_taxonomic_information_jmi = new JMenuItem( "Obtain Detailed Taxonomic Information" ) ); + .add( _obtain_detailed_taxonomic_information_jmi = new JMenuItem( OBTAIN_DETAILED_TAXONOMIC_INFORMATION ) ); customizeJMenuItem( _obtain_detailed_taxonomic_information_jmi ); _obtain_detailed_taxonomic_information_jmi .setToolTipText( "To add additional taxonomic information (from UniProt Taxonomy)" ); _tools_menu + .add( _obtain_detailed_taxonomic_information_deleting_jmi = new JMenuItem( "Obtain Detailed Taxonomic Information (deletes nodes!)" ) ); + customizeJMenuItem( _obtain_detailed_taxonomic_information_deleting_jmi ); + _obtain_detailed_taxonomic_information_deleting_jmi + .setToolTipText( "To add additional taxonomic information, deletes nodes for which taxonomy cannot found (from UniProt Taxonomy)" ); + _tools_menu .add( _obtain_uniprot_seq_information_jmi = new JMenuItem( "Obtain Sequence Information (from UniProt)" ) ); customizeJMenuItem( _obtain_uniprot_seq_information_jmi ); _obtain_uniprot_seq_information_jmi.setToolTipText( "To add additional sequence information (from UniProt)" ); @@ -1148,10 +1175,10 @@ public final class MainFrameApplication extends MainFrame { JOptionPane.ERROR_MESSAGE ); return; } - final Phylogeny phy = _mainpanel.getCurrentPhylogeny().copy(); final AncestralTaxonomyInferrer inferrer = new AncestralTaxonomyInferrer( this, _mainpanel.getCurrentTreePanel(), - phy ); + _mainpanel.getCurrentPhylogeny() + .copy() ); new Thread( inferrer ).start(); } @@ -1275,9 +1302,8 @@ public final class MainFrameApplication extends MainFrame { final PhylogenyNode n = it.next(); final String name = n.getName().trim(); if ( !ForesterUtil.isEmpty( name ) ) { - final String code = ForesterUtil.extractTaxonomyCodeFromNodeName( name, - false, - TAXONOMY_EXTRACTION.YES ); + final String code = ParserUtils + .extractTaxonomyCodeFromNodeName( name, false, PhylogenyMethods.TAXONOMY_EXTRACTION.YES ); if ( !ForesterUtil.isEmpty( code ) ) { PhylogenyMethods.setTaxonomyCode( n, code ); } @@ -1366,7 +1392,7 @@ public final class MainFrameApplication extends MainFrame { if ( getCurrentTreePanel() != null ) { final Phylogeny phy = getCurrentTreePanel().getPhylogeny(); if ( ( phy != null ) && !phy.isEmpty() ) { - ForesterUtil.transferNodeNameToField( phy, PhylogenyNodeField.SEQUENCE_NAME ); + PhylogenyMethods.transferNodeNameToField( phy, PhylogenyMethods.PhylogenyNodeField.SEQUENCE_NAME ); } } } @@ -1375,7 +1401,8 @@ public final class MainFrameApplication extends MainFrame { if ( getCurrentTreePanel() != null ) { final Phylogeny phy = getCurrentTreePanel().getPhylogeny(); if ( ( phy != null ) && !phy.isEmpty() ) { - ForesterUtil.transferNodeNameToField( phy, PhylogenyNodeField.TAXONOMY_SCIENTIFIC_NAME ); + PhylogenyMethods.transferNodeNameToField( phy, + PhylogenyMethods.PhylogenyNodeField.TAXONOMY_SCIENTIFIC_NAME ); } } } @@ -1415,6 +1442,19 @@ public final class MainFrameApplication extends MainFrame { } } + private void obtainDetailedTaxonomicInformationDelete() { + if ( getCurrentTreePanel() != null ) { + final Phylogeny phy = getCurrentTreePanel().getPhylogeny(); + if ( ( phy != null ) && !phy.isEmpty() ) { + final TaxonomyDataObtainer t = new TaxonomyDataObtainer( this, + _mainpanel.getCurrentTreePanel(), + phy.copy(), + true ); + new Thread( t ).start(); + } + } + } + private void obtainUniProtSequenceInformation() { if ( getCurrentTreePanel() != null ) { final Phylogeny phy = getCurrentTreePanel().getPhylogeny(); @@ -1648,7 +1688,7 @@ public final class MainFrameApplication extends MainFrame { try { final NHXParser nhx = new NHXParser(); setSpecialOptionsForNhxParser( nhx ); - phys = ForesterUtil.readPhylogenies( nhx, file ); + phys = PhylogenyMethods.readPhylogenies( nhx, file ); nhx_or_nexus = true; } catch ( final Exception e ) { @@ -1660,7 +1700,7 @@ public final class MainFrameApplication extends MainFrame { warnIfNotPhyloXmlValidation( getConfiguration() ); try { final PhyloXmlParser xml_parser = createPhyloXmlParser(); - phys = ForesterUtil.readPhylogenies( xml_parser, file ); + phys = PhylogenyMethods.readPhylogenies( xml_parser, file ); } catch ( final Exception e ) { exception = true; @@ -1669,7 +1709,7 @@ public final class MainFrameApplication extends MainFrame { } else if ( _open_filechooser.getFileFilter() == MainFrameApplication.tolfilter ) { try { - phys = ForesterUtil.readPhylogenies( new TolParser(), file ); + phys = PhylogenyMethods.readPhylogenies( new TolParser(), file ); } catch ( final Exception e ) { exception = true; @@ -1680,7 +1720,7 @@ public final class MainFrameApplication extends MainFrame { try { final NexusPhylogeniesParser nex = new NexusPhylogeniesParser(); setSpecialOptionsForNexParser( nex ); - phys = ForesterUtil.readPhylogenies( nex, file ); + phys = PhylogenyMethods.readPhylogenies( nex, file ); nhx_or_nexus = true; } catch ( final Exception e ) { @@ -1691,7 +1731,7 @@ public final class MainFrameApplication extends MainFrame { // "*.*": else { try { - final PhylogenyParser parser = ForesterUtil + final PhylogenyParser parser = ParserUtils .createParserDependingOnFileType( file, getConfiguration() .isValidatePhyloXmlAgainstSchema() ); if ( parser instanceof NexusPhylogeniesParser ) { @@ -1707,7 +1747,7 @@ public final class MainFrameApplication extends MainFrame { else if ( parser instanceof PhyloXmlParser ) { warnIfNotPhyloXmlValidation( getConfiguration() ); } - phys = ForesterUtil.readPhylogenies( parser, file ); + phys = PhylogenyMethods.readPhylogenies( parser, file ); } catch ( final Exception e ) { exception = true; @@ -1725,7 +1765,7 @@ public final class MainFrameApplication extends MainFrame { if ( nhx_or_nexus ) { for( final Phylogeny phy : phys ) { if ( getOptions().isInternalNumberAreConfidenceForNhParsing() ) { - ForesterUtil.transferInternalNodeNamesToConfidence( phy ); + PhylogenyMethods.transferInternalNodeNamesToConfidence( phy ); } if ( PhylogenyMethods.getMinimumDescendentsPerInternalNodes( phy ) == 1 ) { one_desc = true; @@ -1986,7 +2026,7 @@ public final class MainFrameApplication extends MainFrame { parser = new TolParser(); } else { - parser = ForesterUtil.createParserDependingOnUrlContents( url, getConfiguration() + parser = ParserUtils.createParserDependingOnUrlContents( url, getConfiguration() .isValidatePhyloXmlAgainstSchema() ); } if ( parser instanceof NexusPhylogeniesParser ) { @@ -2034,7 +2074,7 @@ public final class MainFrameApplication extends MainFrame { if ( ( phys != null ) && ( phys.length > 0 ) ) { if ( nhx_or_nexus && getOptions().isInternalNumberAreConfidenceForNhParsing() ) { for( final Phylogeny phy : phys ) { - ForesterUtil.transferInternalNodeNamesToConfidence( phy ); + PhylogenyMethods.transferInternalNodeNamesToConfidence( phy ); } } Util.addPhylogeniesToTabs( phys, @@ -2062,7 +2102,7 @@ public final class MainFrameApplication extends MainFrame { if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) { if ( _open_filechooser_for_species_tree.getFileFilter() == MainFrameApplication.xmlfilter ) { try { - final Phylogeny[] trees = ForesterUtil.readPhylogenies( new PhyloXmlParser(), file ); + final Phylogeny[] trees = PhylogenyMethods.readPhylogenies( new PhyloXmlParser(), file ); t = trees[ 0 ]; } catch ( final Exception e ) { @@ -2072,7 +2112,7 @@ public final class MainFrameApplication extends MainFrame { } else if ( _open_filechooser_for_species_tree.getFileFilter() == MainFrameApplication.tolfilter ) { try { - final Phylogeny[] trees = ForesterUtil.readPhylogenies( new TolParser(), file ); + final Phylogeny[] trees = PhylogenyMethods.readPhylogenies( new TolParser(), file ); t = trees[ 0 ]; } catch ( final Exception e ) { @@ -2083,7 +2123,7 @@ public final class MainFrameApplication extends MainFrame { // "*.*": else { try { - final Phylogeny[] trees = ForesterUtil.readPhylogenies( new PhyloXmlParser(), file ); + final Phylogeny[] trees = PhylogenyMethods.readPhylogenies( new PhyloXmlParser(), file ); t = trees[ 0 ]; } catch ( final Exception e ) { @@ -2157,9 +2197,9 @@ public final class MainFrameApplication extends MainFrame { private void setSpecialOptionsForNhxParser( final NHXParser nhx ) { nhx.setReplaceUnderscores( getOptions().isReplaceUnderscoresInNhParsing() ); - ForesterUtil.TAXONOMY_EXTRACTION te = ForesterUtil.TAXONOMY_EXTRACTION.NO; + PhylogenyMethods.TAXONOMY_EXTRACTION te = PhylogenyMethods.TAXONOMY_EXTRACTION.NO; if ( getOptions().isExtractPfamTaxonomyCodesInNhParsing() ) { - te = ForesterUtil.TAXONOMY_EXTRACTION.YES; + te = PhylogenyMethods.TAXONOMY_EXTRACTION.YES; } nhx.setTaxonomyExtraction( te ); }