in progress (special coloring is still true)
[jalview.git] / forester / java / src / org / forester / archaeopteryx / ArchaeopteryxA.java
index b1cd27c..1ec5d96 100644 (file)
@@ -35,7 +35,6 @@ import java.net.URL;
 import javax.swing.JApplet;
 import javax.swing.UIManager;
 
-import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
 import org.forester.phylogeny.Phylogeny;
 import org.forester.util.ForesterUtil;
 
@@ -82,14 +81,14 @@ public class ArchaeopteryxA extends JApplet {
         return getMainFrameApplet().getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length();
     }
 
-    public String getTreeUrlStr() {
-        return _tree_url_str;
-    }
-
     public String getSpeciesTreeUrlStr() {
         return _species_tree_url_str;
     }
 
+    public String getTreeUrlStr() {
+        return _tree_url_str;
+    }
+
     @Override
     public void init() {
         boolean has_exception = false;
@@ -97,7 +96,7 @@ public class ArchaeopteryxA extends JApplet {
         setTreeUrlStr( getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD ) );
         setSpeciesTreeUrlStr( getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_SPECIES_TREE_TO_LOAD ) );
         if ( !ForesterUtil.isEmpty( getTreeUrlStr() ) ) {
-            AptxUtil.printAppletMessage( NAME, "URL of tree(s) to load: \"" + getTreeUrlStr() + "\"" );
+            AptxUtil.printAppletMessage( NAME, "URL of tree(s) to load: " + getTreeUrlStr() );
         }
         else {
             ForesterUtil.printErrorMessage( NAME, "no URL for tree(s) to load!" );
@@ -108,7 +107,7 @@ public class ArchaeopteryxA extends JApplet {
             repaint();
         }
         if ( !ForesterUtil.isEmpty( getSpeciesTreeUrlStr() ) ) {
-            AptxUtil.printAppletMessage( NAME, "URL of species tree to load: \"" + getSpeciesTreeUrlStr() + "\"" );
+            AptxUtil.printAppletMessage( NAME, "URL of species tree to load: " + getSpeciesTreeUrlStr() );
         }
         setBackground( background_color );
         setForeground( font_color );
@@ -136,29 +135,28 @@ public class ArchaeopteryxA extends JApplet {
                 UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
             }
             setVisible( false );
-            _mainframe_applet = new MainFrameApplet( this, configuration );
+            _mainframe_applet = new MainFrameApplet( this, configuration, getSpeciesTreeUrlStr() );
             final URL tree_url = new URL( getTreeUrlStr() );
             final Phylogeny[] phys = AptxUtil.readPhylogeniesFromUrl( tree_url, configuration
                     .isValidatePhyloXmlAgainstSchema(), configuration.isReplaceUnderscoresInNhParsing(), configuration
-                    .isInternalNumberAreConfidenceForNhParsing(), configuration.getTaxonomyExtraction() );
+                    .isInternalNumberAreConfidenceForNhParsing(), configuration.getTaxonomyExtraction(), configuration
+                    .isMidpointReroot() );
+            if ( phys == null ) {
+                ForesterUtil.printErrorMessage( NAME, "phylogenies from [" + tree_url + "] are null" );
+            }
+            else if ( phys.length < 1 ) {
+                ForesterUtil.printErrorMessage( NAME, "phylogenies from [" + tree_url + "] are empty" );
+            }
+            else {
+                AptxUtil.printAppletMessage( NAME, "loaded " + phys.length + " phylogenies from: " + tree_url );
+            }
+            AptxUtil.printAppletMessage( ArchaeopteryxA.NAME, "loaded " + phys.length + " phylogenies from: "
+                    + tree_url );
             AptxUtil.addPhylogeniesToTabs( phys,
                                            new File( tree_url.getFile() ).getName(),
                                            getTreeUrlStr(),
                                            getMainFrameApplet().getConfiguration(),
                                            getMainFrameApplet().getMainPanel() );
-            if ( !ForesterUtil.isEmpty( getSpeciesTreeUrlStr() ) ) {
-                final URL species_tree_url = new URL( getSpeciesTreeUrlStr() );
-                final Phylogeny[] species_trees = AptxUtil
-                        .readPhylogeniesFromUrl( species_tree_url,
-                                                 configuration.isValidatePhyloXmlAgainstSchema(),
-                                                 configuration.isReplaceUnderscoresInNhParsing(),
-                                                 false,
-                                                 TAXONOMY_EXTRACTION.NO );
-                if ( ( species_trees != null ) && ( species_trees.length > 0 ) ) {
-                    AptxUtil.printAppletMessage( NAME, "successfully read species tree" );
-                    getMainFrameApplet().setSpeciesTree( species_trees[ 0 ] );
-                }
-            }
             getMainFrameApplet().getMainPanel().getControlPanel().showWholeAll();
             getMainFrameApplet().getMainPanel().getControlPanel().showWhole();
             setVisible( true );
@@ -191,8 +189,8 @@ public class ArchaeopteryxA extends JApplet {
         if ( default_sequence != null ) {
             getMainFrameApplet().getMainPanel().getControlPanel().getSequenceRelationBox()
                     .setSelectedItem( default_sequence );
-            /* GUILHEM_END */
         }
+        /* GUILHEM_END */
     }
 
     /**
@@ -239,11 +237,11 @@ public class ArchaeopteryxA extends JApplet {
         _message_2 = message_2;
     }
 
-    private void setTreeUrlStr( final String url_string ) {
-        _tree_url_str = url_string;
-    }
-
     private void setSpeciesTreeUrlStr( final String url_string ) {
         _species_tree_url_str = url_string;
     }
+
+    private void setTreeUrlStr( final String url_string ) {
+        _tree_url_str = url_string;
+    }
 }