in progress
[jalview.git] / forester / java / src / org / forester / archaeopteryx / MainFrameApplication.java
index 7af0adc..97a7a7a 100644 (file)
@@ -57,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;
@@ -236,25 +237,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 ( 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() );
@@ -478,6 +496,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();
             }
@@ -852,6 +876,11 @@ public final class MainFrameApplication extends MainFrame {
         _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)" );
@@ -1142,10 +1171,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();
     }
 
@@ -1409,6 +1438,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();