simplified aptx frame creation code
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Fri, 13 Oct 2017 14:32:56 +0000 (15:32 +0100)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Fri, 13 Oct 2017 14:32:56 +0000 (15:32 +0100)
src/jalview/ext/archaeopteryx/ArchaeopteryxFrame.java

index 3c9e175..64750ad 100644 (file)
@@ -11,43 +11,45 @@ import org.forester.phylogeny.Phylogeny;
 
 public class ArchaeopteryxFrame
 {
-
-  public static ArchaeopteryxFrame createInstance(Phylogeny aptxTree)
-  {
-    return new ArchaeopteryxFrame(aptxTree);
-
-  }
-
-  public static ArchaeopteryxFrame createInstance(
-          TreeBuilder calculatedTree)
+  public static ArchaeopteryxFrame createInstance(Phylogeny[] aptxTrees)
   {
-    return new ArchaeopteryxFrame(calculatedTree);
+    return new ArchaeopteryxFrame(aptxTrees);
 
   }
 
-  private ArchaeopteryxFrame(Phylogeny aptxTree)
+  public static ArchaeopteryxFrame createInstance(Phylogeny aptxTree)
   {
-    MainFrame aptxApp = Archaeopteryx.createApplication(aptxTree);
-    start(aptxApp);
+    Phylogeny[] aptxTrees = { aptxTree }; // future possibility to load in
+    // several trees simultaneously
+    return new ArchaeopteryxFrame(aptxTrees);
 
   }
 
-  private ArchaeopteryxFrame(TreeBuilder calculatedTree)
+  public static ArchaeopteryxFrame createInstance(
+          TreeBuilder calculatedTree)
   {
     ArchaeopteryxTreeBuilder aptxTreeBuilder = new ArchaeopteryxTreeBuilder();
     Phylogeny aptxTree = aptxTreeBuilder.buildAptxTree(calculatedTree);
-
     Phylogeny[] aptxTrees = { aptxTree }; // future possibility to load in
                                           // several trees simultaneously
 
+    return new ArchaeopteryxFrame(aptxTrees);
+
+  }
+
+
+  private ArchaeopteryxFrame(Phylogeny[] aptxTrees)
+  {
     MainFrame aptxApp = Archaeopteryx.createApplication(aptxTrees,
             "_aptx_jalview_configuration_file", null);
-    start(aptxApp);
-  }
+    bindFrameToJalview(aptxApp);
 
+  }
 
 
-  public void start(MainFrame aptxApp)
+  // public so that, should an Aptx main frame ever get created outside this
+  // class, it can be bound to jalview anyway
+  public void bindFrameToJalview(MainFrame aptxApp)
   {
     int width = 400;
     int height = 550;