Wrap alignment with annotations
[jalview.git] / src / jalview / gui / SeqCanvas.java
index 1ed5e50..303aac6 100755 (executable)
@@ -43,8 +43,6 @@ public class SeqCanvas extends JComponent
     AlignViewport av;\r
     boolean displaySearch = false;\r
     int[] searchResults = null;\r
-    int chunkHeight;\r
-    int chunkWidth;\r
     boolean fastPaint = false;\r
     int LABEL_WEST;\r
     int LABEL_EAST;\r
@@ -294,11 +292,6 @@ public class SeqCanvas extends JComponent
         gg.setColor(Color.white);\r
         gg.fillRect(0, 0, imgWidth, imgHeight);\r
 \r
-        chunkWidth = getWrappedCanvasWidth(getWidth());\r
-        chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight;\r
-\r
-        av.setChunkHeight(chunkHeight);\r
-        av.setChunkWidth(chunkWidth);\r
 \r
         if (av.getWrapAlignment())\r
         {\r
@@ -385,13 +378,21 @@ public class SeqCanvas extends JComponent
             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
+\r
         int endx = (startRes + cWidth) - 1;\r
-        int ypos = 2 * av.charHeight;\r
+        int ypos = hgap;\r
+\r
 \r
         while ((ypos <= canvasHeight) && (startRes < av.alignment.getWidth()))\r
         {\r
@@ -437,10 +438,23 @@ public class SeqCanvas extends JComponent
 \r
 \r
             drawPanel(g, startRes, endx, 0, al.getHeight(), startRes, 0, ypos);\r
+\r
+            if(av.showAnnotation)\r
+            {\r
+              g.translate(0, cHeight + ypos + 3);\r
+              if(annotations==null)\r
+                annotations = new AnnotationPanel(av);\r
+\r
+              annotations.drawComponent( (Graphics2D) g, startRes, endx + 1);\r
+              g.translate(0, -cHeight - ypos);\r
+            }\r
             g.setClip(clip);\r
             g.translate(-LABEL_WEST, 0);\r
 \r
-            ypos += cHeight;\r
+            ypos += cHeight+getAnnotationHeight()+hgap;\r
+            if(av.showAnnotation)\r
+              ypos -= 3;\r
+\r
             startRes += cWidth;\r
             endx = (startRes + cWidth) - 1;\r
 \r
@@ -451,6 +465,18 @@ public class SeqCanvas extends JComponent
         }\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
     /**\r
      * DOCUMENT ME!\r
      *\r