JAL-4134 store/restore Newick tree for PAE annotation row
[jalview.git] / src / jalview / gui / AlignFrame.java
index 82ec1d2..92a18ec 100644 (file)
@@ -4189,34 +4189,50 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   {
     int x = 4, y = 5;
     int w = 400, h = 500;
+    
     try
     {
       NewickFile fin = new NewickFile(
-              new FileParse(cm.getNewickString(), DataSourceType.PASTE));
-      fin.parse();
-      if (fin.getTree() == null)
-      {
-        return;
-      }
+              new FileParse(cm.getNewick(), DataSourceType.PASTE));
       String title = "PAE Matrix Tree for "
               + cm.getReferenceSeq().getDisplayId(false);
-      TreePanel tp = new TreePanel(alignPanel, fin, aa, title);
-
-      tp.setSize(w, h);
-
-      if (x > 0 && y > 0)
-      {
-        tp.setLocation(x, y);
-      }
 
-      Desktop.addInternalFrame(tp, title, w, h);
+      showColumnWiseTree(fin, aa, title, w,h, x,y);
     } catch (Throwable xx)
     {
       Console.error("Unexpected exception showing tree for contact matrix",
               xx);
     }
+  }
+  public TreePanel showColumnWiseTree(NewickFile nf, AlignmentAnnotation aa, String treeTitle,
+           int w, int h, int x, int y)
+  {
+      try
+      {
+        nf.parse();
+        if (nf.getTree() == null)
+        {
+          return null;
+        }
+        TreePanel tp = new TreePanel(alignPanel, nf, aa, title);
+
+        tp.setSize(w, h);
+
+        if (x > 0 && y > 0)
+        {
+          tp.setLocation(x, y);
+        }
 
+        Desktop.addInternalFrame(tp, title, w, h);
+        return tp;
+      } catch (Throwable xx)
+      {
+        Console.error("Unexpected exception showing tree for contact matrix",
+                xx);
+      }
+      return null;
   }
+  
   private boolean buildingMenu = false;
 
   /**