Load/Save trees
authoramwaterhouse <Andrew Waterhouse>
Tue, 14 Jun 2005 10:41:25 +0000 (10:41 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 14 Jun 2005 10:41:25 +0000 (10:41 +0000)
src/jalview/gui/Jalview2XML.java

index addba63..34502f1 100755 (executable)
@@ -53,6 +53,7 @@ public class Jalview2XML
           "UTF-8"));\r
 \r
       Vector shortNames = new Vector();\r
+      int treeCount=1;\r
 \r
       //REVERSE ORDER\r
       for (int i = frames.length - 1; i > -1; i--)\r
@@ -103,8 +104,9 @@ public class Jalview2XML
     }\r
   }\r
 \r
+\r
   // USE THIS METHOD TO SAVE A SINGLE ALIGNMENT WINDOW\r
-  public static void SaveState(AlignFrame af, String jarFile, String fileName)\r
+  public static void SaveAlignment(AlignFrame af, String jarFile, String fileName)\r
   {\r
     try\r
     {\r
@@ -175,9 +177,39 @@ public class Jalview2XML
     }\r
 \r
     //SAVE TREES\r
+    ///////////////////////////////////\r
     if (af.viewport.currentTree != null)\r
     {\r
-      object.getVamsasModel().addTree(af.viewport.currentTree.toString());\r
+      // FIND ANY ASSOCIATED TREES\r
+      JInternalFrame[] frames = Desktop.desktop.getAllFrames();\r
+      for(int t=0; t<frames.length; t++)\r
+      {\r
+        if (frames[t] instanceof TreePanel)\r
+        {\r
+          TreePanel tp = (TreePanel) frames[t];\r
+          if(tp.treeCanvas.av.alignment==jal)\r
+          {\r
+            Tree tree = new Tree();\r
+            tree.setTitle(tp.getTitle());\r
+            tree.setCurrentTree((af.viewport.currentTree == tp.getTree()));\r
+            tree.setNewick(tp.getTree().toString());\r
+            tree.setThreshold(tp.treeCanvas.threshold);\r
+\r
+            tree.setFitToWindow(tp.fitToWindow.getState());\r
+            tree.setFontSize(tp.treeCanvas.fontSize);\r
+            tree.setMarkUnlinked( tp.placeholdersMenu.getState() );\r
+            tree.setShowBootstrap( tp.bootstrapMenu.getState() );\r
+            tree.setShowDistances( tp.distanceMenu.getState() );\r
+\r
+            tree.setHeight(tp.getHeight());\r
+            tree.setWidth(tp.getWidth());\r
+            tree.setXpos(tp.getX());\r
+            tree.setYpos(tp.getY());\r
+\r
+            jms.addTree(tree);\r
+          }\r
+        }\r
+      }\r
     }\r
 \r
     //SAVE ANNOTATIONS\r
@@ -702,13 +734,60 @@ public class Jalview2XML
        al.featuresAdded = true;\r
     }\r
 \r
-    //LOAD TREES - THIS RELEASE ONLY ALLOWS 1 TREE\r
-    if (object.getVamsasModel().getTreeCount() > 0)\r
+    //LOAD TREES\r
+    ///////////////////////////////////////\r
+ /*   JInternalFrame[] frames = Desktop.desktop.getAllFrames();\r
+for(int t=0; t<frames.length; t++)\r
+{\r
+  if (frames[t] instanceof TreePanel)\r
+  {\r
+    TreePanel tp = (TreePanel) frames[t];\r
+    if(tp.treeCanvas.av.alignment==jal)\r
+    {\r
+      Tree tree = new Tree();\r
+      tree.setTitle(tp.getTitle());\r
+      tree.setCurrentTree((af.viewport.currentTree == tp.getTree()));\r
+      tree.setNewick(tp.getTree().toString());\r
+      tree.setThreshold(tp.treeCanvas.threshold);\r
+\r
+      tree.setHeight(tp.getHeight());\r
+      tree.setWidth(tp.getWidth());\r
+      tree.setXpos(tp.getX());\r
+      tree.setYpos(tp.getY());\r
+\r
+      jms.addTree(tree);\r
+    }\r
+*/\r
+    if (jms.getTreeCount() > 0)\r
     {\r
       try\r
       {\r
-        af.ShowNewickTree(new jalview.io.NewickFile(\r
-            (String) object.getVamsasModel().getTree(0)), "Tree");\r
+        for(int t = 0; t<jms.getTreeCount(); t++)\r
+        {\r
+          Tree tree = jms.getTree(t);\r
+\r
+          TreePanel tp = af.ShowNewickTree(new jalview.io.NewickFile(\r
+                  tree.getNewick()), tree.getTitle());\r
+\r
+          tp.setBounds( tree.getXpos(),\r
+                        tree.getYpos(),\r
+                        tree.getWidth(),\r
+                        tree.getHeight());\r
+\r
+          tp.fitToWindow.setState(tree.getFitToWindow());\r
+          tp.fitToWindow_actionPerformed(null);\r
+          tp.treeCanvas.fontSize = tree.getFontSize();\r
+          tp.fontSize.setText("Font Size - "+tree.getFontSize());\r
+          tp.placeholdersMenu.setState(tree.getMarkUnlinked());\r
+          tp.placeholdersMenu_actionPerformed(null);\r
+          tp.bootstrapMenu.setState(tree.getShowBootstrap());\r
+          tp.bootstrapMenu_actionPerformed(null);\r
+          tp.distanceMenu.setState(tree.getShowDistances());\r
+          tp.distanceMenu_actionPerformed(null);\r
+          tp.treeCanvas.threshold = tree.getThreshold();\r
+          if(tree.getCurrentTree());\r
+             af.viewport.setCurrentTree(tp.getTree());\r
+        }\r
       }\r
       catch (Exception ex)\r
       {\r