Wrap alignment with annotations
authoramwaterhouse <Andrew Waterhouse>
Wed, 28 Sep 2005 14:54:03 +0000 (14:54 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 28 Sep 2005 14:54:03 +0000 (14:54 +0000)
13 files changed:
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/AlignViewport.java
src/jalview/appletgui/AlignmentPanel.java
src/jalview/appletgui/AnnotationLabels.java
src/jalview/appletgui/AnnotationPanel.java
src/jalview/appletgui/FontChooser.java
src/jalview/appletgui/IdCanvas.java
src/jalview/appletgui/PCAPanel.java
src/jalview/appletgui/RotatableCanvas.java
src/jalview/appletgui/SeqCanvas.java
src/jalview/appletgui/SeqPanel.java
src/jalview/appletgui/TreeCanvas.java
src/jalview/appletgui/TreePanel.java

index 988aadd..bda314d 100755 (executable)
@@ -35,8 +35,8 @@ public class AlignFrame
 {\r
   final AlignmentPanel alignPanel;\r
   final AlignViewport viewport;\r
-  public static final int NEW_WINDOW_WIDTH = 700;\r
-  public static final int NEW_WINDOW_HEIGHT = 500;\r
+  public static int NEW_WINDOW_WIDTH = 700;\r
+  public static int NEW_WINDOW_HEIGHT = 500;\r
   jalview.bin.JalviewLite applet;\r
 \r
 \r
@@ -83,6 +83,16 @@ public class AlignFrame
         else if (param.equalsIgnoreCase("Pairwise Identity"))\r
           sortPairwiseMenuItem_actionPerformed(null);\r
       }\r
+\r
+      param = applet.getParameter("wrap");\r
+      if (param != null)\r
+      {\r
+        if (param.equalsIgnoreCase("true"))\r
+        {\r
+          wrapMenuItem.setState(true);\r
+          wrapMenuItem_actionPerformed(null);\r
+        }\r
+      }\r
     }\r
 \r
     this.addWindowListener(new WindowAdapter()\r
@@ -740,11 +750,7 @@ public class AlignFrame
 \r
   public void font_actionPerformed(ActionEvent e)\r
   {\r
-    Frame frame = new Frame();\r
-    FontChooser fc = new FontChooser(alignPanel, frame);\r
-    frame.add(fc);\r
-    jalview.bin.JalviewLite.addFrame(frame, "Change Font", 440, 100);\r
-\r
+    new FontChooser(alignPanel);\r
   }\r
 \r
   protected void fullSeqId_actionPerformed(ActionEvent e)\r
@@ -808,11 +814,6 @@ public class AlignFrame
 \r
   public void annotationPanelMenuItem_actionPerformed(ActionEvent e)\r
   {\r
-    if (annotationPanelMenuItem.getState() && viewport.getWrapAlignment())\r
-    {\r
-      annotationPanelMenuItem.setState(false);\r
-      return;\r
-    }\r
     viewport.setShowAnnotation(annotationPanelMenuItem.getState());\r
     alignPanel.setAnnotationVisible(annotationPanelMenuItem.getState());\r
   }\r
@@ -1154,11 +1155,7 @@ public class AlignFrame
 \r
     try\r
     {\r
-      PCAPanel pcaPanel = new PCAPanel(viewport);\r
-      Frame frame = new Frame();\r
-      frame.add(pcaPanel);\r
-      jalview.bin.JalviewLite.addFrame(frame, "Principal component analysis",\r
-                                       400, 400);\r
+      new PCAPanel(viewport);\r
     }\r
     catch (java.lang.OutOfMemoryError ex)\r
     {\r
index 30724a4..209f939 100755 (executable)
@@ -57,8 +57,7 @@ public class AlignViewport
 \r
   int charHeight;\r
   int charWidth;\r
-  int chunkWidth;\r
-  int chunkHeight;\r
+  int wrappedWidth;\r
 \r
   Font font = new Font("SansSerif", Font.PLAIN, 10);\r
   AlignmentI alignment;\r
@@ -443,24 +442,14 @@ public class AlignViewport
     return charHeight;\r
   }\r
 \r
-  public void setChunkWidth(int w)\r
+  public void setWrappedWidth(int w)\r
   {\r
-    this.chunkWidth = w;\r
+    this.wrappedWidth = w;\r
   }\r
 \r
-  public int getChunkWidth()\r
+  public int getwrappedWidth()\r
   {\r
-    return chunkWidth;\r
-  }\r
-\r
-  public void setChunkHeight(int h)\r
-  {\r
-    this.chunkHeight = h;\r
-  }\r
-\r
-  public int getChunkHeight()\r
-  {\r
-    return chunkHeight;\r
+    return wrappedWidth;\r
   }\r
 \r
   public AlignmentI getAlignment()\r
index cf383ac..7332a1a 100755 (executable)
@@ -22,10 +22,8 @@ package jalview.appletgui;
 import java.awt.*;\r
 import java.awt.event.*;\r
 \r
-import jalview.analysis.*;\r
 import jalview.datamodel.*;\r
 import jalview.jbappletgui.*;\r
-import jalview.schemes.*;\r
 \r
 public class AlignmentPanel\r
     extends GAlignmentPanel implements AdjustmentListener\r
@@ -274,8 +272,11 @@ public class AlignmentPanel
 \r
   public void setAnnotationVisible(boolean b)\r
   {\r
-    annotationSpaceFillerHolder.setVisible(b);\r
-    annotationScroller.setVisible(b);\r
+    if (!av.wrapAlignment)\r
+    {\r
+      annotationSpaceFillerHolder.setVisible(b);\r
+      annotationScroller.setVisible(b);\r
+    }\r
     validate();\r
     repaint();\r
   }\r
@@ -287,9 +288,17 @@ public class AlignmentPanel
     hscroll.setVisible(!wrap);\r
     idwidthAdjuster.setVisible(!wrap);\r
 \r
-    av.setShowAnnotation(!wrap);\r
-    annotationScroller.setVisible(!wrap);\r
-    annotationSpaceFillerHolder.setVisible(!wrap);\r
+    if (wrap)\r
+    {\r
+      annotationScroller.setVisible(false);\r
+      annotationSpaceFillerHolder.setVisible(false);\r
+    }\r
+    else if (av.showAnnotation)\r
+    {\r
+      annotationScroller.setVisible(true);\r
+      annotationSpaceFillerHolder.setVisible(true);\r
+    }\r
+\r
     idSpaceFillerPanel1.setVisible(!wrap);\r
 \r
     validate();\r
index 82b97a5..1df7455 100755 (executable)
@@ -29,6 +29,7 @@ public class AnnotationLabels
 {\r
   boolean active = false;\r
   AlignmentPanel ap;\r
+  AlignViewport av;\r
   boolean resizing = false;\r
   int oldY, mouseX;\r
   static String ADDNEW = "Add new row";\r
@@ -42,6 +43,7 @@ public class AnnotationLabels
   public AnnotationLabels(AlignmentPanel ap)\r
   {\r
     this.ap = ap;\r
+    this.av = ap.av;\r
     setLayout(null);\r
     addMouseListener(new MouseAdapter()\r
     {\r
@@ -52,6 +54,12 @@ public class AnnotationLabels
     });\r
   }\r
 \r
+  public AnnotationLabels(AlignViewport av)\r
+{\r
+  this.av = av;\r
+}\r
+\r
+\r
   public void setScrollOffset(int y)\r
   {\r
     scrollOffset = y;\r
@@ -60,7 +68,7 @@ public class AnnotationLabels
 \r
   public void actionPerformed(ActionEvent evt)\r
   {\r
-    AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();\r
+    AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();\r
 \r
     if (evt.getActionCommand().equals(HIDE))\r
     {\r
@@ -146,10 +154,10 @@ public class AnnotationLabels
 \r
   public void paint(Graphics g)\r
   {\r
-    drawComponent(g);\r
+    drawComponent(g, getSize().width);\r
   }\r
 \r
-  public void drawComponent(Graphics g)\r
+  public void drawComponent(Graphics g, int width)\r
   {\r
     FontMetrics fm = g.getFontMetrics(g.getFont());\r
     g.setColor(Color.white);\r
@@ -158,7 +166,7 @@ public class AnnotationLabels
     g.translate(0, scrollOffset);\r
     g.setColor(Color.black);\r
 \r
-    AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();\r
+    AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();\r
     int y = g.getFont().getSize();\r
     int x = 0;\r
 \r
@@ -171,7 +179,7 @@ public class AnnotationLabels
           continue;\r
         }\r
 \r
-        x = getSize().width - fm.stringWidth(aa[i].label) - 3;\r
+        x = width - fm.stringWidth(aa[i].label) - 3;\r
 \r
         if (aa[i].isGraph)\r
         {\r
index f7ba2fe..a1597f8 100755 (executable)
@@ -69,15 +69,24 @@ public class AnnotationPanel
     // ap.annotationScroller.getVAdjustable().addAdjustmentListener( this );\r
   }\r
 \r
+\r
+  public AnnotationPanel(AlignViewport av)\r
+  {\r
+    this.av = av;\r
+  }\r
+\r
+\r
   public void adjustmentValueChanged(AdjustmentEvent evt)\r
   {\r
     ap.alabels.setScrollOffset( -evt.getValue());\r
   }\r
 \r
-  public void adjustPanelHeight()\r
+  public int adjustPanelHeight()\r
   {\r
     // setHeight of panels\r
     AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();\r
+\r
+\r
     int height = 0;\r
     if (aa != null)\r
     {\r
@@ -117,12 +126,14 @@ public class AnnotationPanel
     }\r
 \r
     this.setSize(getSize().width, height);\r
-    ap.annotationScroller.setSize(getSize().width, height);\r
+    if(ap!=null)\r
+       ap.annotationScroller.setSize(getSize().width, height);\r
 \r
-//  ap.annotationSpaceFillerHolder.setSize(d.width,annotationPanel.getSize().height);\r
 \r
     repaint();\r
 \r
+    return height;\r
+\r
   }\r
 \r
   public void addEditableColumn(int i)\r
@@ -217,7 +228,6 @@ public class AnnotationPanel
 \r
     drawComponent(gg, av.startRes, av.endRes + 1);\r
     g.drawImage(image, 0, 0, this);\r
-\r
   }\r
 \r
   public void fastPaint(int horizontal)\r
@@ -256,229 +266,233 @@ public class AnnotationPanel
 \r
   public void drawComponent(Graphics g, int startRes, int endRes)\r
   {\r
-    g.setColor(Color.white);\r
-    g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getSize().height);\r
-    if (av.alignment.getAlignmentAnnotation() == null ||\r
-        av.alignment.getAlignmentAnnotation().length < 1)\r
-    {\r
-      g.setColor(Color.white);\r
-      g.fillRect(0, 0, getSize().width, getSize().height);\r
-      g.setColor(Color.black);\r
-      g.drawString("Alignment has no annotations", 20, 15);\r
-      return;\r
-    }\r
+    g.setFont(av.getFont());\r
 \r
-    AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();\r
+    if (fm == null)\r
+      fm = g.getFontMetrics();\r
 \r
-    int j, x = 0, y = 0;\r
-    char[] lastSS = new char[aa.length];\r
-    int[] lastSSX = new int[aa.length];\r
-    int iconOffset = av.charHeight / 2;\r
-    boolean validRes = false;\r
-    //\u03B2 \u03B1\r
 \r
-    for (int i = 0; i < aa.length; i++)\r
-    {\r
-      AlignmentAnnotation row = aa[i];\r
-      if (!row.visible)\r
-      {\r
-        continue;\r
-      }\r
+      g.setColor(Color.white);\r
+      g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getSize().height);\r
 \r
-      if (row.isGraph)\r
-      {\r
-        // this is so that we draw the characters below the graph\r
-        y += row.height;\r
-        if (row.hasText)\r
-        {\r
-          y -= av.charHeight;\r
-        }\r
-      }\r
-      if (row.hasText)\r
-      {\r
-        iconOffset = av.charHeight / 2;\r
-      }\r
-      else\r
+      if ((av.alignment.getAlignmentAnnotation() == null) ||\r
+              (av.alignment.getAlignmentAnnotation().length < 1))\r
       {\r
-        iconOffset = 0;\r
+          g.setColor(Color.white);\r
+          g.fillRect(0, 0, getSize().width, getSize().height);\r
+          g.setColor(Color.black);\r
+          g.drawString("Alignment has no annotations", 20, 15);\r
+\r
+          return;\r
       }\r
 \r
-      for (j = startRes; j < endRes; j++)\r
-      {\r
-        if (row.annotations.length <= j || row.annotations[j] == null)\r
-        {\r
-          validRes = false;\r
-        }\r
-        else\r
-        {\r
-          validRes = true;\r
-        }\r
+      AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();\r
 \r
-        x = (j - startRes) * av.charWidth;\r
+      int j;\r
+      int x = 0;\r
+      int y = 0;\r
+      char[] lastSS = new char[aa.length];\r
+      int[] lastSSX = new int[aa.length];\r
+      int iconOffset = av.charHeight / 2;\r
+      boolean validRes = false;\r
 \r
-        if (activeRow == i)\r
-        {\r
+      //\u03B2 \u03B1\r
+      for (int i = 0; i < aa.length; i++)\r
+      {\r
+          AlignmentAnnotation row = aa[i];\r
 \r
-          g.setColor(Color.red);\r
+          if (!row.visible)\r
+          {\r
+              continue;\r
+          }\r
 \r
-          if (activeRes != null)\r
+\r
+          if (row.isGraph)\r
           {\r
-            for (int n = 0; n < activeRes.size(); n++)\r
-            {\r
-              int v = Integer.parseInt(activeRes.elementAt(n).toString());\r
-              if (v == j)\r
+              // this is so that we draw the characters below the graph\r
+              y += row.height;\r
+\r
+              if (row.hasText)\r
               {\r
-                g.fillRect( (j - startRes) * av.charWidth, y, av.charWidth,\r
-                           row.height);\r
+                  y -= av.charHeight;\r
               }\r
-            }\r
           }\r
-        }\r
 \r
-        if (validRes && row.annotations[j].displayCharacter.length() > 0)\r
-        {\r
-          int charOffset = (av.charWidth -\r
-                            fm.charWidth(row.annotations[j].displayCharacter.\r
-                                         charAt(0))) / 2;\r
-          g.setColor(row.annotations[j].colour);\r
-          if (j == 0 || row.isGraph)\r
+          if (row.hasText)\r
           {\r
-            if (row.annotations[0].secondaryStructure == 'H'\r
-                || row.annotations[0].secondaryStructure == 'E')\r
-            {\r
-              g.drawString(row.annotations[j].displayCharacter, x,\r
-                           y + iconOffset + 3);\r
-            }\r
+              iconOffset = av.charHeight / 2;\r
           }\r
-          else if ( (row.annotations[j].secondaryStructure == 'H'\r
-                     || row.annotations[j].secondaryStructure == 'E') &&\r
-                   (row.annotations[j - 1] == null ||\r
-                    row.annotations[j].secondaryStructure !=\r
-                    row.annotations[j - 1].secondaryStructure))\r
+          else\r
           {\r
-\r
-            g.drawString(row.annotations[j].displayCharacter, x + charOffset,\r
-                         y + iconOffset + 3);\r
+              iconOffset = 0;\r
           }\r
 \r
-          if (!row.hasIcons)\r
+          for (j = startRes; j < endRes; j++)\r
           {\r
-            g.drawString(row.annotations[j].displayCharacter, x + charOffset,\r
-                         y + iconOffset + 3);\r
-          }\r
-        }\r
+              if ((row.annotations.length <= j) ||\r
+                      (row.annotations[j] == null))\r
+              {\r
+                  validRes = false;\r
+              }\r
+              else\r
+              {\r
+                  validRes = true;\r
+              }\r
 \r
-        if (row.hasIcons)\r
-        {\r
-          if (!validRes || row.annotations[j].secondaryStructure != lastSS[i])\r
-          {\r
-            switch (lastSS[i])\r
-            {\r
-              case 'H':\r
-                g.setColor(HELIX_COLOUR);\r
-                g.fillRoundRect(lastSSX[i], y + 4 + iconOffset, x - lastSSX[i],\r
-                                7, 8, 8);\r
-                break;\r
-              case 'E':\r
-                g.setColor(SHEET_COLOUR);\r
-                g.fillRect(lastSSX[i], y + 4 + iconOffset, x - lastSSX[i] - 4,\r
-                           7);\r
-                g.fillPolygon(new int[]\r
-                              {x - 4, x - 4, x}\r
-                              , new int[]\r
-                              {y + iconOffset, y + 14 + iconOffset,\r
-                              y + 8 + iconOffset}, 3);\r
-                break;\r
-              case 'C':\r
-                break;\r
-              default:\r
-                g.setColor(Color.gray);\r
-                g.fillRect(lastSSX[i], y + 6 + iconOffset, x - lastSSX[i], 2);\r
-                break;\r
-            }\r
-\r
-            if (validRes)\r
-            {\r
-              lastSS[i] = row.annotations[j].secondaryStructure;\r
-            }\r
-            else\r
-            {\r
-              lastSS[i] = ' ';\r
-            }\r
-            lastSSX[i] = x;\r
-          }\r
-        }\r
+              x = (j - startRes) * av.charWidth;\r
 \r
-        if (validRes && row.isGraph)\r
-        {\r
-          g.setColor(new Color(0, 0, 180));\r
-          int height = (int) ( (row.annotations[j].value / row.graphMax) *\r
-                              GRAPH_HEIGHT);\r
 \r
-          if (row.windowLength > 1)\r
-          {\r
-            int total = 0;\r
-            for (int i2 = j - (row.windowLength / 2);\r
-                 i2 < j + (row.windowLength / 2); i2++)\r
-            {\r
-              if (i2 < 0 || i2 >= av.alignment.getWidth())\r
+              if (validRes &&\r
+                      (row.annotations[j].displayCharacter.length() > 0))\r
               {\r
-                continue;\r
+\r
+                  int charOffset = (av.charWidth -\r
+                      fm.charWidth(row.annotations[j].displayCharacter.charAt(\r
+                              0))) / 2;\r
+                  g.setColor(row.annotations[j].colour);\r
+\r
+                  if (j == 0 || row.isGraph)\r
+                  {\r
+                      g.drawString(row.annotations[j].displayCharacter, x+charOffset,\r
+                          y + iconOffset + 3);\r
+                  }\r
+                  else if (((row.annotations[j - 1] == null) ||\r
+                          (row.annotations[j].displayCharacter != row.annotations[j -\r
+                          1].displayCharacter)))\r
+                  {\r
+                      g.drawString(row.annotations[j].displayCharacter, x+charOffset,\r
+                          y + iconOffset + 3);\r
+                  }\r
               }\r
 \r
-              total += row.annotations[i2].value;\r
-            }\r
+              if (row.hasIcons)\r
+              {\r
+                  if (!validRes ||\r
+                          (row.annotations[j].secondaryStructure != lastSS[i]))\r
+                  {\r
+                      switch (lastSS[i])\r
+                      {\r
+                      case 'H':\r
+                          g.setColor(HELIX_COLOUR);\r
+                          g.fillRoundRect(lastSSX[i], y + 4 + iconOffset,\r
+                              x - lastSSX[i], 7, 8, 8);\r
+\r
+                          break;\r
+\r
+                      case 'E':\r
+                          g.setColor(SHEET_COLOUR);\r
+                          g.fillRect(lastSSX[i], y + 4 + iconOffset,\r
+                              x - lastSSX[i] - 4, 7);\r
+                          g.fillPolygon(new int[] { x - 4, x - 4, x },\r
+                              new int[]\r
+                              {\r
+                                  y + iconOffset, y + 14 + iconOffset,\r
+                                  y + 8 + iconOffset\r
+                              }, 3);\r
+\r
+                          break;\r
+\r
+                      case 'C':\r
+                          break;\r
+\r
+                      default:\r
+                          g.setColor(Color.gray);\r
+                          g.fillRect(lastSSX[i], y + 6 + iconOffset,\r
+                              x - lastSSX[i], 2);\r
+\r
+                          break;\r
+                      }\r
+\r
+                      if (validRes)\r
+                      {\r
+                          lastSS[i] = row.annotations[j].secondaryStructure;\r
+                      }\r
+                      else\r
+                      {\r
+                          lastSS[i] = ' ';\r
+                      }\r
+\r
+                      lastSSX[i] = x;\r
+                  }\r
+              }\r
 \r
-            total /= row.windowLength;\r
-            height = (int) ( (total / row.graphMax) * GRAPH_HEIGHT);\r
+              if (validRes && row.isGraph)\r
+              {\r
+                  g.setColor(new Color(0, 0, 180));\r
+\r
+                  int height = (int) ((row.annotations[j].value / row.graphMax) * GRAPH_HEIGHT);\r
+\r
+                  if (row.windowLength > 1)\r
+                  {\r
+                      int total = 0;\r
+\r
+                      for (int i2 = j - (row.windowLength / 2);\r
+                              i2 < (j + (row.windowLength / 2)); i2++)\r
+                      {\r
+                          if ((i2 < 0) || (i2 >= av.alignment.getWidth()))\r
+                          {\r
+                              continue;\r
+                          }\r
+\r
+                          total += row.annotations[i2].value;\r
+                      }\r
+\r
+                      total /= row.windowLength;\r
+                      height = (int) ((total / row.graphMax) * GRAPH_HEIGHT);\r
+                  }\r
 \r
+                  g.setColor(row.annotations[j].colour);\r
+                  g.fillRect(x, y - height, av.charWidth, height);\r
+              }\r
           }\r
-          g.setColor(row.annotations[j].colour);\r
-          g.fillRect(x, y - height, av.charWidth, height);\r
-        }\r
 \r
-      }\r
+          x += av.charWidth;\r
+\r
+          if (row.hasIcons)\r
+          {\r
+              switch (lastSS[i])\r
+              {\r
+              case 'H':\r
+                  g.setColor(HELIX_COLOUR);\r
+                  g.fillRoundRect(lastSSX[i], y + 4 + iconOffset,\r
+                      x - lastSSX[i], 7, 8, 8);\r
 \r
-      x += av.charWidth;\r
+                  break;\r
 \r
-      if (row.hasIcons)\r
-      {\r
-        switch (lastSS[i])\r
-        {\r
-          case 'H':\r
-            g.setColor(HELIX_COLOUR);\r
-            g.fillRoundRect(lastSSX[i], y + 4 + iconOffset, x - lastSSX[i], 7,\r
-                            8, 8);\r
-            break;\r
-          case 'E':\r
-            g.setColor(SHEET_COLOUR);\r
-            g.fillRect(lastSSX[i], y + 4 + iconOffset, x - lastSSX[i] - 4, 7);\r
-            g.fillPolygon(new int[]\r
-                          {x - 4, x - 4, x}\r
-                          , new int[]\r
-                          {y + iconOffset, y + 14 + iconOffset,\r
-                          y + 7 + iconOffset}\r
-                          , 3);\r
-            break;\r
-          case 'C':\r
-            break;\r
-          default:\r
-            g.setColor(Color.gray);\r
-            g.fillRect(lastSSX[i], y + 6 + iconOffset, x - lastSSX[i], 2);\r
-            break;\r
+              case 'E':\r
+                  g.setColor(SHEET_COLOUR);\r
+                  g.fillRect(lastSSX[i], y + 4 + iconOffset,\r
+                      x - lastSSX[i] - 4, 7);\r
+                  g.fillPolygon(new int[] { x - 4, x - 4, x },\r
+                      new int[]\r
+                      {\r
+                          y + iconOffset, y + 14 + iconOffset,\r
+                          y + 7 + iconOffset\r
+                      }, 3);\r
+\r
+                  break;\r
 \r
-        }\r
-      }\r
+              case 'C':\r
+                  break;\r
 \r
-      if (row.isGraph && row.hasText)\r
-      {\r
-        y += av.charHeight;\r
-      }\r
-      if (!row.isGraph)\r
-      {\r
-        y += aa[i].height;\r
-      }\r
-    }\r
+              default:\r
+                  g.setColor(Color.gray);\r
+                  g.fillRect(lastSSX[i], y + 6 + iconOffset, x - lastSSX[i], 2);\r
+\r
+                  break;\r
+              }\r
+          }\r
+\r
+          if (row.isGraph && row.hasText)\r
+          {\r
+              y += av.charHeight;\r
+          }\r
+\r
+          if (!row.isGraph)\r
+          {\r
+              y += aa[i].height;\r
+          }\r
+        }\r
   }\r
 \r
   // used by overview window\r
index 02a7471..e424a42 100755 (executable)
@@ -27,16 +27,27 @@ public class FontChooser
     extends GFontChooser\r
 {\r
   AlignmentPanel ap;\r
+  TreePanel tp;\r
   Font oldFont;\r
   boolean init = true;\r
   Frame frame;\r
 \r
-  public FontChooser(AlignmentPanel ap, Frame frame)\r
+  public FontChooser(TreePanel tp)\r
   {\r
-    super();\r
+    this.tp = tp;\r
+    oldFont = tp.getTreeFont();\r
+    init();\r
+  }\r
 \r
-    this.frame = frame;\r
+  public FontChooser(AlignmentPanel ap)\r
+  {\r
+    this.ap = ap;\r
+    oldFont = ap.av.getFont();\r
+    init();\r
+  }\r
 \r
+  void init()\r
+    {\r
     this.ap = ap;\r
     String fonts[] = Toolkit.getDefaultToolkit().getFontList();\r
     for (int i = 0; i < fonts.length; i++)\r
@@ -53,27 +64,44 @@ public class FontChooser
     fontStyle.addItem("bold");\r
     fontStyle.addItem("italic");\r
 \r
-    oldFont = ap.av.getFont();\r
     fontName.select(oldFont.getName());\r
     fontSize.select(oldFont.getSize() + "");\r
     fontStyle.select(oldFont.getStyle());\r
 \r
+    Frame frame = new Frame();\r
+    this.frame = frame;\r
+    frame.add(this);\r
+    jalview.bin.JalviewLite.addFrame(frame, "Change Font", 440, 100);\r
+\r
     init = false;\r
   }\r
 \r
   protected void ok_actionPerformed()\r
   {\r
     frame.setVisible(false);\r
-    if (ap.getOverviewPanel() != null)\r
+    if (ap != null)\r
     {\r
-      ap.getOverviewPanel().updateOverviewImage();\r
+      if (ap.getOverviewPanel() != null)\r
+      {\r
+        ap.getOverviewPanel().updateOverviewImage();\r
+      }\r
     }\r
+\r
   }\r
 \r
   protected void cancel_actionPerformed()\r
   {\r
-    ap.av.setFont(oldFont);\r
-    ap.repaint();\r
+    if(ap!=null)\r
+    {\r
+      ap.av.setFont(oldFont);\r
+      ap.repaint();\r
+    }\r
+    else if(tp!=null)\r
+    {\r
+      tp.setTreeFont(oldFont);\r
+      tp.treeCanvas.repaint();\r
+    }\r
+\r
     fontName.select(oldFont.getName());\r
     fontSize.select(oldFont.getSize() + "");\r
     fontStyle.select(oldFont.getStyle());\r
@@ -88,8 +116,15 @@ public class FontChooser
                             Integer.parseInt(fontSize.getSelectedItem().\r
                                              toString())\r
         );\r
-    ap.av.setFont(newFont);\r
-    ap.fontChanged();\r
+    if (ap != null)\r
+    {\r
+      ap.av.setFont(newFont);\r
+      ap.fontChanged();\r
+    }\r
+    else if(tp != null)\r
+    {\r
+      tp.setTreeFont(newFont);\r
+      }\r
   }\r
 \r
   protected void fontName_actionPerformed()\r
index 399506e..30560d7 100755 (executable)
@@ -177,23 +177,51 @@ public class IdCanvas
   {\r
     Color currentColor = Color.white;\r
     Color currentTextColor = Color.black;\r
+    Font italic = new Font(av.getFont().getName(), Font.ITALIC,\r
+                             av.getFont().getSize());\r
 \r
     if (av.getWrapAlignment())\r
     {\r
+      int annotationHeight = 0;\r
+      AnnotationLabels labels = null;\r
 \r
-      int rowSize = av.getEndRes() - av.getStartRes();\r
-      // Draw the rest of the panels\r
-\r
-      for (int ypos = 2 * av.charHeight, row = av.startRes;\r
-           ypos <= getSize().height && row < av.alignment.getWidth();\r
-           ypos += av.chunkHeight, row += rowSize)\r
+      if(av.showAnnotation)\r
       {\r
-        for (int i = starty; i < av.alignment.getHeight(); i++)\r
+        AnnotationPanel ap = new AnnotationPanel(av);\r
+        annotationHeight = ap.adjustPanelHeight();\r
+        labels = new AnnotationLabels(av);\r
+      }\r
+\r
+      int hgap = av.charHeight;\r
+      if (av.scaleAboveWrapped)\r
+        hgap += av.charHeight;\r
+\r
+      int cHeight = av.getAlignment().getHeight() * av.charHeight\r
+          + hgap\r
+          + annotationHeight;\r
+\r
+        int rowSize = av.getEndRes() - av.getStartRes();\r
+\r
+        // Draw the rest of the panels\r
+        for (int ypos = hgap, row = av.startRes;\r
+                (ypos <= getSize().height) && (row < av.alignment.getWidth());\r
+                ypos += cHeight, row += rowSize)\r
         {\r
-          SequenceI s = av.alignment.getSequenceAt(i);\r
-          drawIdString(gg, s, i, 0, ypos);\r
+            for (int i = starty; i < av.alignment.getHeight(); i++)\r
+            {\r
+                SequenceI s = av.alignment.getSequenceAt(i);\r
+                drawIdString(gg, s, i, 0, ypos);\r
+            }\r
+\r
+            if(labels!=null)\r
+            {\r
+              gg.setFont(av.getFont());\r
+              gg.translate(0, ypos+(av.getAlignment().getHeight() * av.charHeight));\r
+              labels.drawComponent(gg, getSize().width);\r
+              gg.translate(0, -ypos-(av.getAlignment().getHeight() * av.charHeight));\r
+              gg.setFont(italic);\r
+            }\r
         }\r
-      }\r
 \r
     }\r
     else\r
index 399fce8..026ca09 100755 (executable)
@@ -40,7 +40,6 @@ public class PCAPanel
 \r
   public PCAPanel(AlignViewport av)\r
   {\r
-\r
     this.av = av;\r
     if (av.getSelectionGroup()!=null && av.getSelectionGroup().getSize() > 3)\r
     {\r
@@ -58,8 +57,14 @@ public class PCAPanel
         seqs[i] = av.getAlignment().getSequenceAt(i);\r
       }\r
     }\r
+\r
     rc = new RotatableCanvas(av);\r
     add(rc, BorderLayout.CENTER);\r
+\r
+    jalview.bin.JalviewLite.addFrame(this, "Principal component analysis",\r
+                                       400, 400);\r
+\r
+\r
     Thread worker = new Thread(this);\r
     worker.start();\r
   }\r
@@ -109,6 +114,7 @@ public class PCAPanel
               rc.setPoints(points, pca.getM().rows);\r
               rc.repaint();\r
               seqs = null;\r
+              this.repaint();\r
   }\r
 \r
   void doDimensionChange()\r
@@ -149,4 +155,20 @@ public class PCAPanel
     doDimensionChange();\r
   }\r
 \r
+  public void values_actionPerformed(ActionEvent actionEvent)\r
+  {\r
+\r
+    CutAndPasteTransfer cap = new CutAndPasteTransfer(false, null);\r
+    Frame frame = new Frame();\r
+    frame.add(cap);\r
+    jalview.bin.JalviewLite.addFrame(frame, "PCA details", 500, 500);\r
+\r
+      cap.setText(pca.getDetails());\r
+  }\r
+\r
+  public void labels_itemStateChanged(ItemEvent itemEvent)\r
+  {\r
+    rc.showLabels( labels.getState() );\r
+  }\r
+\r
 }\r
index 9fa7491..82207a2 100755 (executable)
@@ -80,12 +80,19 @@ public class RotatableCanvas
   float scalefactor = 1;\r
 \r
   AlignViewport av;\r
+  boolean showLabels = false;\r
 \r
   public RotatableCanvas(AlignViewport av)\r
   {\r
     this.av = av;\r
   }\r
 \r
+  public void showLabels(boolean b)\r
+  {\r
+    showLabels = b;\r
+    repaint();\r
+  }\r
+\r
   public void setPoints(Vector points, int npoint)\r
   {\r
     this.points = points;\r
@@ -376,7 +383,14 @@ public class RotatableCanvas
       }\r
 \r
       g.fillRect(x - 3, y - 3, 6, 6);\r
-      g.setColor(Color.red);\r
+      if (showLabels)\r
+      {\r
+        g.setColor(Color.red);\r
+        g.drawString( ( (SequencePoint) points.elementAt(i)).sequence.\r
+                     getName(),\r
+                     x - 3, y - 4);\r
+      }\r
+\r
     }\r
 //    //Now the rectangle\r
 //    if (rectx2 != -1 && recty2 != -1) {\r
index 853a327..46ddf37 100755 (executable)
@@ -241,11 +241,6 @@ public class SeqCanvas
     gg.setColor(Color.white);\r
     gg.fillRect(0, 0, imgWidth, imgHeight);\r
 \r
-    chunkWidth = getWrappedCanvasWidth(getSize().width);\r
-    chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight;\r
-\r
-    av.setChunkHeight(chunkHeight);\r
-    av.setChunkWidth(chunkWidth);\r
 \r
     if (av.getWrapAlignment())\r
     {\r
@@ -304,6 +299,8 @@ public class SeqCanvas
 \r
     FontMetrics fm = getFontMetrics(av.getFont());\r
 \r
+    int LABEL_EAST = 0;\r
+\r
     if (av.scaleRightWrapped)\r
     {\r
         LABEL_EAST = fm.stringWidth(getMask()+"0");\r
@@ -316,60 +313,91 @@ public class SeqCanvas
         LABEL_WEST = fm.stringWidth(getMask());\r
     }\r
 \r
+    int hgap = av.charHeight;\r
+    if(av.scaleAboveWrapped)\r
+      hgap += av.charHeight;\r
+\r
     int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / av.charWidth;\r
-    int cHeight = (av.getAlignment().getHeight() + 2) * av.charHeight;\r
+    int cHeight = av.getAlignment().getHeight() * av.charHeight;\r
+\r
+    av.setWrappedWidth(cWidth);\r
 \r
     av.endRes = av.startRes + cWidth;\r
 \r
-    int endx = startRes + cWidth - 1;\r
-    int ypos = 2 * av.charHeight;\r
 \r
-    while (ypos <= canvasHeight && startRes < av.alignment.getWidth())\r
+    int endx = (startRes + cWidth) - 1;\r
+    int ypos = hgap;\r
+\r
+\r
+    while ((ypos <= canvasHeight) && (startRes < av.alignment.getWidth()))\r
     {\r
-      g.setColor(Color.black);\r
+        g.setColor(Color.black);\r
 \r
-      if (av.scaleLeftWrapped)\r
-      {\r
-        drawWestScale(g, startRes, endx, ypos);\r
-      }\r
+        if (av.scaleLeftWrapped)\r
+        {\r
+            drawWestScale(g, startRes, endx, ypos);\r
+        }\r
 \r
-      if (av.scaleRightWrapped)\r
-      {\r
-        g.translate(canvasWidth - LABEL_EAST, 0);\r
-        drawEastScale(g, startRes, endx, ypos);\r
-        g.translate( - (canvasWidth - LABEL_EAST), 0);\r
-      }\r
+        if (av.scaleRightWrapped)\r
+        {\r
+            g.translate(canvasWidth - LABEL_EAST, 0);\r
+            drawEastScale(g, startRes, endx, ypos);\r
+            g.translate(-(canvasWidth - LABEL_EAST), 0);\r
+        }\r
 \r
-      g.translate(LABEL_WEST, 0);\r
-      if (av.scaleAboveWrapped)\r
-      {\r
-        drawNorthScale(g, startRes, endx, ypos);\r
-      }\r
+        g.translate(LABEL_WEST, 0);\r
 \r
+        if (av.scaleAboveWrapped)\r
+        {\r
+            drawNorthScale(g, startRes, endx, ypos);\r
+        }\r
 \r
-     if(g.getClip()==null)\r
-       g.setClip(0, 0, cWidth * av.charWidth, canvasHeight);\r
 \r
-     if (av.alignment.getWidth() >= av.vconsensus.size())\r
-     {\r
-       endx = av.vconsensus.size() - 2;\r
-     }\r
-     drawPanel(g, startRes, endx, 0, al.getHeight(), startRes, 0, ypos);\r
-      g.setClip(null);\r
-      g.translate( -LABEL_WEST, 0);\r
+        if (av.vconsensus!=null && av.alignment.getWidth() >= av.vconsensus.size())\r
+        {\r
+          endx = av.vconsensus.size() - 2;\r
+        }\r
 \r
-      ypos += cHeight;\r
-      startRes += cWidth;\r
-      endx = startRes + cWidth - 1;\r
 \r
-      if (endx > al.getWidth())\r
-      {\r
-        endx = al.getWidth();\r
-      }\r
-    }\r
+        drawPanel(g, startRes, endx, 0, al.getHeight(), startRes, 0, ypos);\r
+\r
+        if(av.showAnnotation)\r
+        {\r
+          g.translate(0, cHeight + ypos);\r
+          if(annotations==null)\r
+            annotations = new AnnotationPanel(av);\r
+\r
+          annotations.drawComponent( g, startRes, endx + 1);\r
+          g.translate(0, -cHeight - ypos);\r
+        }\r
+        g.translate(-LABEL_WEST, 0);\r
+\r
+        ypos += cHeight+getAnnotationHeight()+hgap;\r
+\r
+\r
+        startRes += cWidth;\r
+        endx = (startRes + cWidth) - 1;\r
+\r
+        if (endx > al.getWidth())\r
+        {\r
+            endx = al.getWidth();\r
+        }\r
+        }\r
 \r
   }\r
 \r
+  AnnotationPanel annotations;\r
+  int getAnnotationHeight()\r
+  {\r
+    if(!av.showAnnotation)\r
+      return 0;\r
+\r
+    if(annotations==null)\r
+      annotations = new AnnotationPanel(av);\r
+\r
+    return annotations.adjustPanelHeight();\r
+    }\r
+\r
   synchronized public void drawPanel(Graphics g, int x1, int x2, int y1, int y2,\r
                                      int startx, int starty, int offset)\r
   {\r
@@ -378,29 +406,28 @@ public class SeqCanvas
     sr.renderGaps(av.renderGaps);\r
 \r
     SequenceI nextSeq;\r
-\r
     /// First draw the sequences\r
-    /////////////////////////////\r
-    for (int i = y1; i < y2; i++)\r
-    {\r
-      nextSeq = av.alignment.getSequenceAt(i);\r
+  /////////////////////////////\r
+  for (int i = y1; i < y2; i++)\r
+  {\r
+    nextSeq = av.alignment.getSequenceAt(i);\r
 \r
-      sr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq), x1, x2,\r
+    sr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq), x1, x2,\r
+                    (x1 - startx) * av.charWidth,\r
+                    offset +\r
+                    (i - starty) * av.charHeight,\r
+                    av.charWidth, av.charHeight);\r
+\r
+    if (av.showSequenceFeatures)\r
+    {\r
+      fr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq), x1, x2,\r
                       (x1 - startx) * av.charWidth,\r
                       offset +\r
-                      (i-starty)*av.charHeight,\r
+                      (i - starty) * av.charHeight,\r
                       av.charWidth, av.charHeight);\r
-\r
-      if (av.showSequenceFeatures)\r
-      {\r
-        fr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq), x1, x2,\r
-                        (x1 - startx) * av.charWidth,\r
-                        offset +\r
-                        (i-starty)*av.charHeight,\r
-                        av.charWidth, av.charHeight);\r
-      }\r
     }\r
-    //\r
+  }\r
+\r
     /////////////////////////////////////\r
 \r
     // Now outline any areas if necessary\r
@@ -415,146 +442,146 @@ public class SeqCanvas
       group = (SequenceGroup) groups.elementAt(0);\r
       groupIndex = 0;\r
     }\r
-\r
     if (group != null && !isOverview)\r
     {\r
-      do\r
-      {\r
-          int oldY = -1;\r
-          int i = 0;\r
-          boolean inGroup = false;\r
-          int top = -1;\r
-          int bottom = -1;\r
-\r
-          for (i = y1; i < y2; i++)\r
-          {\r
-              sx = (group.getStartRes() - startx) * av.charWidth;\r
-              sy = offset + ((i - starty) * av.charHeight);\r
-              ex = (((group.getEndRes() + 1) - group.getStartRes()) * av.charWidth) -\r
-                  1;\r
-\r
-              if(sx+ex<0 || sx>imgWidth)\r
-              {\r
-                continue;\r
-              }\r
+        do\r
+        {\r
+            int oldY = -1;\r
+            int i = 0;\r
+            boolean inGroup = false;\r
+            int top = -1;\r
+            int bottom = -1;\r
 \r
-              if ( (sx <= (x2-x1)*av.charWidth) &&\r
-                      group.sequences.contains(av.alignment.getSequenceAt(\r
-                              i)))\r
-              {\r
-                  if ((bottom == -1) &&\r
-                          !group.sequences.contains(\r
-                              av.alignment.getSequenceAt(i + 1)))\r
-                  {\r
-                      bottom = sy + av.charHeight;\r
-                  }\r
+            for (i = y1; i < y2; i++)\r
+            {\r
+                sx = (group.getStartRes() - startx) * av.charWidth;\r
+                sy = offset + ((i - starty) * av.charHeight);\r
+                ex = (((group.getEndRes() + 1) - group.getStartRes()) * av.charWidth) -\r
+                    1;\r
 \r
-                  if (!inGroup)\r
-                  {\r
-                      if (((top == -1) && (i == 0)) ||\r
-                              !group.sequences.contains(\r
-                                  av.alignment.getSequenceAt(i - 1)))\r
-                      {\r
-                          top = sy;\r
-                      }\r
-\r
-                      oldY = sy;\r
-                      inGroup = true;\r
-\r
-                      if (group == av.getSelectionGroup())\r
-                      {\r
-                          g.setColor(Color.red);\r
-                      }\r
-                      else\r
-                      {\r
-                          g.setColor(group.getOutlineColour());\r
-                      }\r
-                  }\r
-              }\r
-              else\r
-              {\r
-                if (inGroup)\r
+                if(sx+ex<0 || sx>imgWidth)\r
                 {\r
-                  if (sx >= 0 && sx < imgWidth)\r
-                    g.drawLine(sx, oldY, sx, sy);\r
-\r
-                  if (sx + ex < imgWidth)\r
-                    g.drawLine(sx + ex, oldY, sx + ex, sy);\r
+                  continue;\r
+                }\r
 \r
-                  if (sx < 0)\r
+                if ( (sx <= (x2-x1)*av.charWidth) &&\r
+                        group.sequences.contains(av.alignment.getSequenceAt(\r
+                                i)))\r
+                {\r
+                    if ((bottom == -1) &&\r
+                            !group.sequences.contains(\r
+                                av.alignment.getSequenceAt(i + 1)))\r
+                    {\r
+                        bottom = sy + av.charHeight;\r
+                    }\r
+\r
+                    if (!inGroup)\r
+                    {\r
+                        if (((top == -1) && (i == 0)) ||\r
+                                !group.sequences.contains(\r
+                                    av.alignment.getSequenceAt(i - 1)))\r
+                        {\r
+                            top = sy;\r
+                        }\r
+\r
+                        oldY = sy;\r
+                        inGroup = true;\r
+\r
+                        if (group == av.getSelectionGroup())\r
+                        {\r
+\r
+                            g.setColor(Color.red);\r
+                        }\r
+                        else\r
+                        {\r
+                            g.setColor(group.getOutlineColour());\r
+                        }\r
+                    }\r
+                }\r
+                else\r
+                {\r
+                  if (inGroup)\r
                   {\r
-                    ex += sx;\r
-                    sx = 0;\r
-                  }\r
+                    if (sx >= 0 && sx < imgWidth)\r
+                      g.drawLine(sx, oldY, sx, sy);\r
+\r
+                    if (sx + ex < imgWidth)\r
+                      g.drawLine(sx + ex, oldY, sx + ex, sy);\r
+\r
+                    if (sx < 0)\r
+                    {\r
+                      ex += sx;\r
+                      sx = 0;\r
+                    }\r
+\r
+                    if (sx + ex > imgWidth)\r
+                      ex = imgWidth;\r
+\r
+                    else if (sx + ex >= (x2 - x1 + 1) * av.charWidth)\r
+                      ex = (x2 - x1 + 1) * av.charWidth;\r
+\r
+                    if (top != -1)\r
+                    {\r
+                      g.drawLine(sx, top, sx + ex, top);\r
+                      top = -1;\r
+                    }\r
+\r
+                    if (bottom != -1)\r
+                    {\r
+                      g.drawLine(sx, bottom, sx + ex, bottom);\r
+                      bottom = -1;\r
+                    }\r
+\r
+                    inGroup = false;\r
+                    }\r
+                }\r
+            }\r
 \r
-                  if (sx + ex > imgWidth)\r
-                    ex = imgWidth;\r
+            if (inGroup)\r
+            {\r
+              sy = offset + ( (i - starty) * av.charHeight);\r
+              if (sx >= 0 && sx < imgWidth)\r
+                g.drawLine(sx, oldY, sx, sy);\r
 \r
-                  else if (sx + ex >= (x2 - x1 + 1) * av.charWidth)\r
-                    ex = (x2 - x1 + 1) * av.charWidth;\r
+              if (sx + ex < imgWidth)\r
+                g.drawLine(sx + ex, oldY, sx + ex, sy);\r
 \r
-                  if (top != -1)\r
-                  {\r
-                    g.drawLine(sx, top, sx + ex, top);\r
-                    top = -1;\r
-                  }\r
+              if (sx < 0)\r
+              {\r
+                ex += sx;\r
+                sx = 0;\r
+              }\r
 \r
-                  if (bottom != -1)\r
-                  {\r
-                    g.drawLine(sx, bottom, sx + ex, bottom);\r
-                    bottom = -1;\r
-                  }\r
+              if (sx + ex > imgWidth)\r
+                ex = imgWidth;\r
+              else if (sx + ex >= (x2 - x1 + 1) * av.charWidth)\r
+                ex = (x2 - x1 + 1) * av.charWidth;\r
 \r
-                  inGroup = false;\r
-                  }\r
+              if (top != -1)\r
+              {\r
+                g.drawLine(sx, top, sx + ex, top);\r
+                top = -1;\r
               }\r
-          }\r
-\r
-          if (inGroup)\r
-          {\r
-            sy = offset + ( (i - starty) * av.charHeight);\r
-            if (sx >= 0 && sx < imgWidth)\r
-              g.drawLine(sx, oldY, sx, sy);\r
 \r
-            if (sx + ex < imgWidth)\r
-              g.drawLine(sx + ex, oldY, sx + ex, sy);\r
+              if (bottom != -1)\r
+              {\r
+                g.drawLine(sx, bottom - 1, sx + ex, bottom - 1);\r
+                bottom = -1;\r
+              }\r
 \r
-            if (sx < 0)\r
-            {\r
-              ex += sx;\r
-              sx = 0;\r
+                inGroup = false;\r
             }\r
 \r
-            if (sx + ex > imgWidth)\r
-              ex = imgWidth;\r
-            else if (sx + ex >= (x2 - x1 + 1) * av.charWidth)\r
-              ex = (x2 - x1 + 1) * av.charWidth;\r
+            groupIndex++;\r
 \r
-            if (top != -1)\r
+            if (groupIndex >= groups.size())\r
             {\r
-              g.drawLine(sx, top, sx + ex, top);\r
-              top = -1;\r
+                break;\r
             }\r
 \r
-            if (bottom != -1)\r
-            {\r
-              g.drawLine(sx, bottom - 1, sx + ex, bottom - 1);\r
-              bottom = -1;\r
-            }\r
-\r
-              inGroup = false;\r
-          }\r
-\r
-          groupIndex++;\r
-\r
-          if (groupIndex >= groups.size())\r
-          {\r
-              break;\r
-          }\r
-\r
-          group = (SequenceGroup) groups.elementAt(groupIndex);\r
-      }\r
-      while (groupIndex < groups.size());\r
+            group = (SequenceGroup) groups.elementAt(groupIndex);\r
+        }\r
+        while (groupIndex < groups.size());\r
     }\r
 \r
     /// Highlight search Results once all sequences have been drawn\r
index 9c3a1e8..9ed48b2 100755 (executable)
@@ -161,16 +161,26 @@ public class SeqPanel
 \r
   if (av.wrapAlignment)\r
   {\r
+\r
+    int hgap = av.charHeight;\r
+    if (av.scaleAboveWrapped)\r
+      hgap += av.charHeight;\r
+\r
+    int cHeight = av.getAlignment().getHeight() * av.charHeight\r
+        + hgap + seqCanvas.getAnnotationHeight();\r
+\r
       int y = evt.getY();\r
-      y -= (2 * av.charHeight);\r
+      y -= hgap;\r
       x -= seqCanvas.LABEL_WEST;\r
 \r
-      int chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight;\r
-      int cwidth = seqCanvas.getWrappedCanvasWidth(this.getSize().width);\r
-      wrappedBlock = y/chunkHeight;\r
-      wrappedBlock += av.getStartRes()/cwidth;\r
 \r
-      res = wrappedBlock*cwidth   +   x / av.getCharWidth();\r
+      int cwidth = seqCanvas.getWrappedCanvasWidth(getSize().width);\r
+\r
+      wrappedBlock = y / cHeight;\r
+      wrappedBlock += av.getStartRes() / cwidth;\r
+\r
+      res = wrappedBlock * cwidth + x / av.getCharWidth();\r
+\r
   }\r
   else\r
   {\r
@@ -183,14 +193,22 @@ public class SeqPanel
 \r
  int findSeq(MouseEvent evt)\r
  {\r
+\r
    int seq = 0;\r
    int y = evt.getY();\r
 \r
    if (av.wrapAlignment)\r
    {\r
-     y -= (2 * av.charHeight);\r
-     int chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight;\r
-     seq = ( (y % chunkHeight) / av.getCharHeight());\r
+     int hgap = av.charHeight;\r
+     if (av.scaleAboveWrapped)\r
+       hgap += av.charHeight;\r
+\r
+     int cHeight = av.getAlignment().getHeight() * av.charHeight\r
+         + hgap + seqCanvas.getAnnotationHeight();\r
+\r
+       y -= hgap;\r
+\r
+     seq = ( (y % cHeight) / av.getCharHeight());\r
    }\r
    else\r
    {\r
index 38d23db..76569dd 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
@@ -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
@@ -228,7 +227,7 @@ public class TreeCanvas
 \r
       if (showDistances && node.dist > 0)\r
       {\r
-        g.drawString(new Format("%-.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
@@ -352,7 +351,9 @@ 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
     FontMetrics fm = g.getFontMetrics(font);\r
@@ -378,19 +379,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 +398,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
index 42be37b..3e26a4b 100755 (executable)
@@ -60,9 +60,6 @@ public class TreePanel
   {\r
     super();\r
     initTreePanel(av, seqVector, type, pwtype, s, e, null);\r
-\r
-    // We know this tree has distances. JBPNote TODO: prolly should add this as a userdefined default\r
-    treeCanvas.setShowDistances(true);\r
   }\r
 \r
   /**\r
@@ -127,6 +124,8 @@ public class TreePanel
       treeCanvas.setTree(tree);\r
       if(newtree!=null)\r
       {\r
+        distanceMenu.setState(newtree.HasDistances());\r
+        bootstrapMenu.setState(newtree.HasBootstrap());\r
         treeCanvas.setShowBootstrap(newtree.HasBootstrap());\r
         treeCanvas.setShowDistances(newtree.HasDistances());\r
       }\r
@@ -145,7 +144,7 @@ public class TreePanel
   protected void fitToWindow_actionPerformed(ActionEvent e)\r
   {\r
     treeCanvas.fitToWindow = fitToWindow.getState();\r
-    repaint();\r
+    treeCanvas.repaint();\r
   }\r
 \r
   public void newickOutput_actionPerformed(ActionEvent actionEvent)\r
@@ -159,28 +158,23 @@ public class TreePanel
     jalview.bin.JalviewLite.addFrame(frame, type + " " + pwtype, 500, 100);\r
   }\r
 \r
-  protected void fontSize_actionPerformed(ActionEvent e)\r
+  public java.awt.Font getTreeFont()\r
   {\r
-    /*   if( treeCanvas==null )\r
-        return;\r
+    return treeCanvas.font;\r
+  }\r
 \r
-      String size = fontSize.getLabel().substring( fontSize.getLabel().indexOf("-")+1);\r
+  public void setTreeFont(java.awt.Font font)\r
+  {\r
+    treeCanvas.font = font;\r
+    treeCanvas.repaint();\r
+  }\r
 \r
-      Object selection = JOptionPane.showInternalInputDialog(Desktop.desktop,\r
-                                  "Select font size",\r
-                                  "Font size",\r
-                                  JOptionPane.QUESTION_MESSAGE,\r
-     null, new String[]{"1","2","4","6","8","10","12","14","16","18","20"}\r
-                                  ,"Font Size - "+size);\r
-      if(selection!=null)\r
-      {\r
-        fontSize.setText("Font Size - " + selection);\r
+  protected void fontSize_actionPerformed(ActionEvent e)\r
+  {\r
+     if( treeCanvas==null )\r
+        return;\r
 \r
-        int i = Integer.parseInt(selection.toString());\r
-        treeCanvas.setFontSize(i);\r
-      }\r
-       scrollPane.setViewportView(treeCanvas);\r
-     */\r
+    new FontChooser(this);\r
   }\r
 \r
   protected void distanceMenu_actionPerformed(ActionEvent e)\r