bug fix in jpred client. TreeViewer display state and gui consistency
authorjprocter <Jim Procter>
Thu, 26 May 2005 10:21:52 +0000 (10:21 +0000)
committerjprocter <Jim Procter>
Thu, 26 May 2005 10:21:52 +0000 (10:21 +0000)
improved (treecanvas/Treepanel state exchange functions).

src/jalview/gui/AlignFrame.java
src/jalview/gui/TreePanel.java
src/jalview/ws/JPredClient.java

index 1f04fa3..1183cd8 100755 (executable)
@@ -1069,7 +1069,8 @@ public class AlignFrame extends GAlignFrame
     if(!viewport.alignment.isAligned())
     {
       JOptionPane.showMessageDialog(Desktop.desktop, "The sequences must be aligned before creating a tree.\n"
-                                   +"Try using the Pad function in the edit menu.",
+                                   +"Try using the Pad function in the edit menu,\n"
+                                  +"or one of the multiple sequence alignment web services.",
                                     "Sequences not aligned", JOptionPane.WARNING_MESSAGE);
       return;
     }
index 047c1d4..78bef80 100755 (executable)
@@ -53,12 +53,28 @@ public class TreePanel extends GTreePanel
     tree = new NJTree(seq, type, pwtype, start, end);\r
 \r
     treeCanvas = new TreeCanvas(av, tree, scrollPane, longestName);\r
-\r
+    treeCanvas.setShowDistances(true); // We know this tree has distances. JBPNote TODO: prolly should add this as a userdefined default\r
+    setViewStateFromTreeCanvas(treeCanvas);\r
     tree.reCount(tree.getTopNode());\r
     tree.findHeight(tree.getTopNode());\r
     scrollPane.setViewportView(treeCanvas);\r
 \r
   }\r
+  private void setViewStateFromTreeCanvas(TreeCanvas tree) {\r
+    // update view menu state from treeCanvas render state\r
+    distanceMenu.setSelected(tree.showDistances);\r
+    bootstrapMenu.setSelected(tree.showBootstrap);\r
+    placeholdersMenu.setSelected(tree.markPlaceholders);\r
+  }\r
+\r
+  private void setTreeCanvasFromViewState(TreeCanvas tree) {\r
+      // update view menu state from treeCanvas render state\r
+      tree.showDistances = distanceMenu.isSelected();\r
+      tree.showBootstrap = bootstrapMenu.isSelected();\r
+      tree.markPlaceholders = placeholdersMenu.isSelected();\r
+    }\r
+\r
+\r
   public TreePanel(AlignViewport av, Vector seqVector, NewickFile newtree,\r
                    String type, String pwtype)\r
     {\r
@@ -80,11 +96,14 @@ public class TreePanel extends GTreePanel
       tree = new NJTree(seq, newtree);\r
       // Now have to calculate longest name based on the leaves\r
       Vector leaves = tree.findLeaves(tree.getTopNode(),new Vector());\r
-\r
-      for (int i=0;i < leaves.size();i++)\r
-        if (longestName.length()<((Sequence) ((SequenceNode) leaves.elementAt(i)).element()).getName().length())\r
-          longestName = TreeCanvas.PLACEHOLDER+((Sequence) ((SequenceNode) leaves.elementAt(i)).element()).getName();\r
-\r
+      boolean has_placeholders = false;\r
+      for (int i=0;i < leaves.size();i++) {\r
+        SequenceNode lf = (SequenceNode) leaves.elementAt(i);\r
+        if (lf.isPlaceholder())\r
+          has_placeholders = true;\r
+        if (longestName.length()<((Sequence) lf.element()).getName().length())\r
+          longestName = TreeCanvas.PLACEHOLDER+((Sequence) lf.element()).getName();\r
+      }\r
       tree.reCount(tree.getTopNode());\r
       tree.findHeight(tree.getTopNode());\r
 \r
@@ -92,11 +111,9 @@ public class TreePanel extends GTreePanel
       treeCanvas.setShowBootstrap(newtree.HasBootstrap());\r
       treeCanvas.setShowDistances(newtree.HasDistances());\r
       scrollPane.setViewportView(treeCanvas);\r
-      distanceMenu.setSelected(newtree.HasDistances());\r
-      bootstrapMenu.setSelected(newtree.HasBootstrap());\r
-      if (true) // JBPNote TODO: preference for always marking placeholders in new associated tree\r
-        placeholdersMenu.setSelected(treeCanvas.markPlaceholders);\r
-\r
+      treeCanvas.setMarkPlaceholders(has_placeholders);\r
+      setViewStateFromTreeCanvas(treeCanvas);\r
+      // JBPNote TODO: preference for always marking placeholders in new associated tree\r
     }\r
 \r
 \r
index 0940be6..bb91119 100755 (executable)
@@ -27,6 +27,7 @@ public class JPredClient extends WSClient
   }\r
   public JPredClient(String title, SequenceI[] msf)\r
   {\r
+    setWebService();\r
     wsInfo = new WebserviceInfo(WebServiceJobTitle, WebServiceReference);\r
     SequenceI seq = msf[0];\r
     altitle = "JNet prediction on "+seq.getName()+" using alignment from "+title;\r