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