Checks end of sequence before drawing text
authoramwaterhouse <Andrew Waterhouse>
Tue, 20 Sep 2005 13:21:39 +0000 (13:21 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 20 Sep 2005 13:21:39 +0000 (13:21 +0000)
src/jalview/appletgui/SequenceRenderer.java
src/jalview/gui/SequenceRenderer.java

index 9a722f2..c413588 100755 (executable)
@@ -87,27 +87,24 @@ public class SequenceRenderer
     int curWidth = width;\r
 \r
     Color tempColour = null;\r
-    while (i <= end && i < length)\r
+    while (i <= end)\r
     {\r
-      if (inCurrentSequenceGroup(i))\r
+      resBoxColour = Color.white;\r
+      if(i < length)\r
       {\r
-        if (currentSequenceGroup.getDisplayBoxes())\r
+        if (inCurrentSequenceGroup(i))\r
         {\r
-          getBoxColour(currentSequenceGroup.cs, seq, i);\r
+          if (currentSequenceGroup.getDisplayBoxes())\r
+          {\r
+            getBoxColour(currentSequenceGroup.cs, seq, i);\r
+          }\r
         }\r
-        else\r
+        else if (av.getShowBoxes())\r
         {\r
-          resBoxColour = Color.white;\r
+          getBoxColour(av.getGlobalColourScheme(), seq, i);\r
         }\r
       }\r
-      else if (av.getShowBoxes())\r
-      {\r
-        getBoxColour(av.getGlobalColourScheme(), seq, i);\r
-      }\r
-      else\r
-      {\r
-        resBoxColour = Color.white;\r
-      }\r
+\r
 \r
       if (resBoxColour != tempColour)\r
       {\r
@@ -139,21 +136,19 @@ public class SequenceRenderer
   {\r
     int pady = height / 5;\r
     int charOffset = 0;\r
-    char s;\r
+    char s=' ';\r
     // Need to find the sequence position here.\r
 \r
     String sequence = seq.getSequence();\r
+\r
+    if(end+1>=seq.getLength())\r
+          end = seq.getLength()-1;\r
+\r
     for (int i = start; i <= end; i++)\r
     {\r
       graphics.setColor(Color.black);\r
-      if (i < sequence.length())\r
-      {\r
-        s = sequence.charAt(i);\r
-      }\r
-      else\r
-      {\r
-        s = ' ';\r
-      }\r
+\r
+      s = sequence.charAt(i);\r
 \r
       if (!renderGaps && jalview.util.Comparison.isGap(s))\r
       {\r
index e36160a..81daef7 100755 (executable)
@@ -144,28 +144,26 @@ public class SequenceRenderer
 \r
         Color tempColour = null;\r
 \r
-        while ((i <= end) && (i < length))\r
+        while (i <= end)\r
         {\r
+          resBoxColour = Color.white;\r
+\r
+          if (i < length)\r
+          {\r
             if (inCurrentSequenceGroup(i))\r
             {\r
-                if (currentSequenceGroup.getDisplayBoxes())\r
-                {\r
-                    getBoxColour(currentSequenceGroup.cs, seq, i);\r
-                }\r
-                else\r
-                {\r
-                    resBoxColour = Color.white;\r
-                }\r
+              if (currentSequenceGroup.getDisplayBoxes())\r
+              {\r
+                getBoxColour(currentSequenceGroup.cs, seq, i);\r
+              }\r
             }\r
             else if (av.getShowBoxes())\r
             {\r
-                getBoxColour(av.getGlobalColourScheme(), seq, i);\r
-            }\r
-            else\r
-            {\r
-                resBoxColour = Color.white;\r
+              getBoxColour(av.getGlobalColourScheme(), seq, i);\r
             }\r
 \r
+          }\r
+\r
             if (resBoxColour != tempColour)\r
             {\r
                 if (tempColour != null)\r
@@ -213,18 +211,14 @@ public class SequenceRenderer
         // Need to find the sequence position here.\r
         String sequence = seq.getSequence();\r
 \r
+        if(end+1>=seq.getLength())\r
+          end = seq.getLength()-1;\r
+\r
         for (int i = start; i <= end; i++)\r
         {\r
             graphics.setColor(Color.black);\r
 \r
-            if (i < sequence.length())\r
-            {\r
-                s = sequence.charAt(i);\r
-            }\r
-            else\r
-            {\r
-                s = ' ';\r
-            }\r
+            s = sequence.charAt(i);\r
 \r
             if (!renderGaps && jalview.util.Comparison.isGap(s))\r
             {\r