sequences are private in SequenceGroup
[jalview.git] / src / jalview / appletgui / TreeCanvas.java
index 47bebbe..af1d752 100755 (executable)
@@ -37,15 +37,13 @@ public class TreeCanvas
   AlignViewport av;\r
   public static final String PLACEHOLDER = " * ";\r
   Font font;\r
-  int fontSize = 12;\r
-\r
   boolean fitToWindow = true;\r
   boolean showDistances = false;\r
   boolean showBootstrap = false;\r
   boolean markPlaceholders = false;\r
 \r
   int offx = 20;\r
-  int offy = 20;\r
+  int offy;\r
 \r
   float threshold;\r
 \r
@@ -62,6 +60,7 @@ public class TreeCanvas
   public TreeCanvas(AlignViewport av, ScrollPane scroller)\r
   {\r
     this.av = av;\r
+    font = av.getFont();\r
     scrollPane = scroller;\r
     addMouseListener(this);\r
     setLayout(null);\r
@@ -160,7 +159,7 @@ public class TreeCanvas
       String nodeLabel = "";\r
       if (showDistances && node.dist > 0)\r
       {\r
-        nodeLabel = new Format("%5.2f").form(node.dist);\r
+        nodeLabel = new Format("%-.2f").form(node.dist);\r
       }\r
       if (showBootstrap)\r
       {\r
@@ -172,7 +171,7 @@ public class TreeCanvas
       }\r
       if (!nodeLabel.equals(""))\r
       {\r
-        g.drawString(nodeLabel, xstart, ypos - 10);\r
+        g.drawString(nodeLabel, xstart+2, ypos - 2);\r
       }\r
 \r
       String name = (markPlaceholders && node.isPlaceholder()) ?\r
@@ -181,7 +180,7 @@ public class TreeCanvas
       int charWidth = fm.stringWidth(name) + 3;\r
       int charHeight = fm.getHeight();\r
 \r
-      Rectangle rect = new Rectangle(xend + 20, ypos - charHeight,\r
+      Rectangle rect = new Rectangle(xend + 10, ypos - charHeight,\r
                                      charWidth, charHeight);\r
 \r
       nameHash.put( (SequenceI) node.element(), rect);\r
@@ -189,7 +188,7 @@ public class TreeCanvas
       // Colour selected leaves differently\r
       SequenceGroup selected = av.getSelectionGroup();\r
       if (selected != null &&\r
-          selected.sequences.contains( (SequenceI) node.element()))\r
+          selected.getSequences(false).contains( (SequenceI) node.element()))\r
       {\r
         g.setColor(Color.gray);\r
 \r
@@ -228,7 +227,7 @@ public class TreeCanvas
 \r
       if (showDistances && node.dist > 0)\r
       {\r
-        g.drawString(new Format("%5.2f").form(node.dist), xstart, ypos - 5);\r
+        g.drawString(new Format("%-.2f").form(node.dist), xstart+2, ypos - 2);\r
       }\r
 \r
     }\r
@@ -280,7 +279,7 @@ public class TreeCanvas
       top.count = ( (SequenceNode) top.left()).count +\r
           ( (SequenceNode) top.right()).count;\r
     }\r
-    float chunk = (float) (height - offy * 2) / top.count;\r
+    float chunk = (float) (height - offy) / top.count;\r
 \r
     pickNode(pickBox, top, chunk, wscale, width, offx, offy);\r
   }\r
@@ -296,9 +295,9 @@ public class TreeCanvas
     if (node.left() == null && node.right() == null)\r
     {\r
       float height = node.height;\r
-      float dist = node.dist;\r
+      //float dist = node.dist;\r
 \r
-      int xstart = (int) ( (height - dist) * scale) + offx;\r
+      //int xstart = (int) ( (height - dist) * scale) + offx;\r
       int xend = (int) (height * scale) + offx;\r
 \r
       int ypos = (int) (node.ycount * chunk) + offy;\r
@@ -352,9 +351,12 @@ public class TreeCanvas
   public void paint(Graphics g)\r
   {\r
 \r
-    font = new Font("Verdana", Font.PLAIN, fontSize);\r
+    if(tree==null)\r
+      return;\r
+\r
     g.setFont(font);\r
 \r
+\r
     FontMetrics fm = g.getFontMetrics(font);\r
 \r
     if (nameHash.size() == 0)\r
@@ -378,19 +380,10 @@ public class TreeCanvas
     scrollPane.validate();\r
   }\r
 \r
-  public int getFontSize()\r
-  {\r
-    return fontSize;\r
-  }\r
-\r
-  public void setFontSize(int fontSize)\r
-  {\r
-    this.fontSize = fontSize;\r
-    repaint();\r
-  }\r
 \r
   public void draw(Graphics g, int width, int height)\r
   {\r
+    offy = font.getSize()+10;\r
 \r
     g.setColor(Color.white);\r
     g.fillRect(0, 0, width, height);\r
@@ -406,7 +399,7 @@ public class TreeCanvas
       top.count = ( (SequenceNode) top.left()).count +\r
           ( (SequenceNode) top.right()).count;\r
     }\r
-    float chunk = (float) (height - offy * 2) / top.count;\r
+    float chunk = (float) (height - offy) / top.count;\r
 \r
     drawNode(g, tree.getTopNode(), chunk, wscale, width, offx, offy);\r
 \r
@@ -530,7 +523,8 @@ public class TreeCanvas
             {\r
             Conservation c = new Conservation("Group",\r
                                               ResidueProperties.propHash, 3,\r
-                                              sg.sequences, sg.getStartRes(),\r
+                                              sg.getSequences(false),\r
+                                              sg.getStartRes(),\r
                                               sg.getEndRes());\r
 \r
             c.calculate();\r