check cursor is visible for hidden cols
authoramwaterhouse <Andrew Waterhouse>
Mon, 20 Nov 2006 18:08:28 +0000 (18:08 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 20 Nov 2006 18:08:28 +0000 (18:08 +0000)
src/jalview/appletgui/SeqPanel.java
src/jalview/gui/SeqPanel.java

index 8e70e35..feda697 100755 (executable)
@@ -138,6 +138,24 @@ public class SeqPanel
    {\r
      seqCanvas.cursorX += dx;\r
      seqCanvas.cursorY += dy;\r
+     if (av.hasHiddenColumns && !av.colSel.isVisible(seqCanvas.cursorX))\r
+     {\r
+       int original = seqCanvas.cursorX - dx;\r
+       int maxWidth = av.alignment.getWidth();\r
+\r
+       while(!av.colSel.isVisible(seqCanvas.cursorX)\r
+             && seqCanvas.cursorX<maxWidth\r
+             && seqCanvas.cursorX>0)\r
+       {\r
+         seqCanvas.cursorX += dx;\r
+       }\r
+\r
+       if(seqCanvas.cursorX>=maxWidth\r
+          || !av.colSel.isVisible(seqCanvas.cursorX) )\r
+       {\r
+         seqCanvas.cursorX = original;\r
+       }\r
+      }\r
      scrollToVisible();\r
    }\r
 \r
@@ -169,13 +187,13 @@ public class SeqPanel
        {\r
          ap.scrollUp(false);\r
        }\r
-       while (seqCanvas.cursorX < av.startRes)\r
+       while (seqCanvas.cursorX < av.colSel.adjustForHiddenColumns(av.startRes))\r
        {\r
 \r
          if (!ap.scrollRight(false))\r
            break;\r
        }\r
-       while (seqCanvas.cursorX > av.endRes)\r
+       while (seqCanvas.cursorX > av.colSel.adjustForHiddenColumns(av.endRes))\r
        {\r
          if (!ap.scrollRight(true))\r
            break;\r
index 4ea3a12..3349825 100755 (executable)
@@ -286,6 +286,25 @@ public class SeqPanel extends JPanel implements MouseListener,
     {\r
       seqCanvas.cursorX += dx;\r
       seqCanvas.cursorY += dy;\r
+      if (av.hasHiddenColumns && !av.colSel.isVisible(seqCanvas.cursorX))\r
+      {\r
+        int original = seqCanvas.cursorX - dx;\r
+        int maxWidth = av.alignment.getWidth();\r
+\r
+        while(!av.colSel.isVisible(seqCanvas.cursorX)\r
+              && seqCanvas.cursorX<maxWidth\r
+              && seqCanvas.cursorX>0)\r
+        {\r
+          seqCanvas.cursorX += dx;\r
+        }\r
+\r
+        if(seqCanvas.cursorX>=maxWidth\r
+           || !av.colSel.isVisible(seqCanvas.cursorX) )\r
+        {\r
+          seqCanvas.cursorX = original;\r
+        }\r
+      }\r
+\r
       scrollToVisible();\r
     }\r
 \r
@@ -319,12 +338,12 @@ public class SeqPanel extends JPanel implements MouseListener,
         }\r
         if (!av.wrapAlignment)\r
         {\r
-          while (seqCanvas.cursorX < av.startRes)\r
+          while (seqCanvas.cursorX < av.colSel.adjustForHiddenColumns(av.startRes))\r
           {\r
             if (!ap.scrollRight(false))\r
               break;\r
           }\r
-          while (seqCanvas.cursorX > av.endRes)\r
+          while (seqCanvas.cursorX > av.colSel.adjustForHiddenColumns(av.endRes))\r
           {\r
             if (!ap.scrollRight(true))\r
               break;\r