JAL-2795 simplified instance creation from calculation
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Thu, 11 Jan 2018 13:43:41 +0000 (13:43 +0000)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Thu, 11 Jan 2018 13:43:41 +0000 (13:43 +0000)
src/jalview/ext/archaeopteryx/AptxInit.java
src/jalview/gui/CalculationChooser.java

index 11ee71e..b209796 100644 (file)
@@ -33,8 +33,6 @@ import org.forester.io.parsers.util.ParserUtils;
 import org.forester.phylogeny.Phylogeny;
 import org.forester.phylogeny.PhylogenyMethods;
 import org.forester.phylogeny.data.Identifier;
-import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
-import org.forester.phylogeny.factories.PhylogenyFactory;
 import org.forester.util.ForesterUtil;
 
 /**
@@ -89,34 +87,31 @@ public final class AptxInit
   // return aptxApp;
   // }
 
-  public static TreeFrameI[] createInstances(String treeTitle,
-          Object source, PhylogenyParser parser, AlignmentViewport viewport)
+  public static TreeFrameI createInstanceFromNhx(String treeTitle,
+          String nhxString, AlignmentViewport viewport)
           throws IOException
   {
-    TreeFrameI[] aptxFrames = null;
-    PhylogenyFactory parserFact = ParserBasedPhylogenyFactory.getInstance();
-    Phylogeny[] trees = parserFact.create(source, parser);
-    aptxFrames = new TreeFrameI[trees.length];
-
-    for (int i = 0; i < trees.length; i++)
+    if (Desktop.instance != null)
     {
-      Phylogeny aptxPhylogeny = trees[i];
+      Desktop.instance.startLoading(treeTitle);
+    }
+
+
+
+    Phylogeny aptxPhylogeny = Phylogeny
+            .createInstanceFromNhxString(nhxString);
+    aptxPhylogeny.setName(treeTitle);
+
+    TreeFrameI aptxFrame = createAptxFrame(aptxPhylogeny, viewport,
+            treeTitle);
 
-      // if (nhx_or_nexus && INTERNAL_NUMBERS_AS_CONFIDENCE)
-      // {
-      // PhylogenyMethods
-      // .transferInternalNodeNamesToConfidence(aptxPhylogeny, "");
-      // }
-      aptxPhylogeny.setName(treeTitle);
-      aptxFrames[i] = createAptxFrame(aptxPhylogeny, viewport, treeTitle);
 
-    }
     if (Desktop.instance != null)
     {
       Desktop.instance.stopLoading();
     }
 
-    return aptxFrames;
+    return aptxFrame;
 
   }
 
@@ -505,12 +500,9 @@ public final class AptxInit
         {
           // Not important if this fails, do nothing.
         }
-        // _main_frame.getContentPane().repaint();
       }
     }
 
-    System.gc();
-
 
     if (Desktop.instance != null)
     {
index b973572..bae4986 100644 (file)
@@ -64,8 +64,6 @@ import javax.swing.JRadioButton;
 import javax.swing.event.InternalFrameAdapter;
 import javax.swing.event.InternalFrameEvent;
 
-import org.forester.io.parsers.nhx.NHXParser;
-
 /**
  * A dialog where a user can choose and action Tree or PCA calculation options
  */
@@ -516,7 +514,7 @@ public class CalculationChooser extends JPanel
             tree.getTopNode());
     String output = newick.print(tree.hasBootstrap(), tree.hasDistances(),
             tree.hasRootDistance());
-    AptxInit.createInstances(af.getTitle(), output, new NHXParser(),
+    AptxInit.createInstanceFromNhx(af.getTitle(), output, 
             af.getViewport());
     // openTreePanel(tree, treeAlgo, substitutionMatrix);
   }