Wrap alignment with annotations
[jalview.git] / src / jalview / appletgui / AnnotationLabels.java
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