1 too many in drawgraph
[jalview.git] / src / jalview / appletgui / AnnotationPanel.java
index 0fdeed6..cb638dd 100755 (executable)
@@ -206,8 +206,6 @@ public class AnnotationPanel
 \r
   public void paint(Graphics g)\r
   {\r
-    g.setColor(Color.white);\r
-    g.fillRect(0,0, getSize().width, getSize().height);\r
     imgWidth = (av.endRes - av.startRes + 1) * av.charWidth;\r
 \r
     if (image == null || imgWidth != image.getWidth(this))\r
@@ -389,8 +387,8 @@ public class AnnotationPanel
                           y + iconOffset + 3);\r
                   }\r
                   else if (((row.annotations[j - 1] == null) ||\r
-                          (row.annotations[j].displayCharacter != row.annotations[j -\r
-                          1].displayCharacter)))\r
+                          (!row.annotations[j].displayCharacter.equals(\r
+                           row.annotations[j - 1].displayCharacter))))\r
                   {\r
                       g.drawString(row.annotations[j].displayCharacter, x+charOffset,\r
                           y + iconOffset + 3);\r
@@ -556,6 +554,9 @@ public class AnnotationPanel
     if(sRes>aa.annotations.length)\r
       return;\r
 \r
+\r
+    eRes = Math.min(eRes, aa.annotations.length);\r
+\r
     int x = 0;\r
 \r
     //Adjustment for fastpaint to left\r
@@ -576,17 +577,9 @@ public class AnnotationPanel
       y2 = (int)(y - (0-min / range)*graphHeight);\r
 \r
     g.setColor(Color.gray);\r
-    g.drawLine(x-av.charWidth,y2,(eRes-sRes+1)*av.charWidth,y2);\r
-\r
+    g.drawLine(x-av.charWidth,y2,(eRes-sRes)*av.charWidth,y2);\r
 \r
-    if(aa.threshold!=null)\r
-    {\r
-        g.setColor(aa.threshold.colour);\r
-        y2 = (int)(y - ((aa.threshold.value-min) / range)*graphHeight);\r
-        g.drawLine(x-av.charWidth,y2,(eRes-sRes+1)*av.charWidth,y2);\r
-    }\r
 \r
-    eRes = Math.min(eRes, aa.annotations.length);\r
     for (int j = sRes; j < eRes; j++)\r
     {\r
       if(aa.annotations[j]==null || aa.annotations[j-1]==null)\r
@@ -600,6 +593,15 @@ public class AnnotationPanel
         g.drawLine(x-av.charWidth/2, y1, x+av.charWidth/2, y2);\r
         x += av.charWidth;\r
      }\r
+\r
+\r
+     if(aa.threshold!=null)\r
+     {\r
+         g.setColor(aa.threshold.colour);\r
+         y2 = (int)(y - ((aa.threshold.value-min) / range)*aa.graphHeight);\r
+         g.drawLine(0,y2,(eRes-sRes)*av.charWidth,y2);\r
+     }\r
+\r
   }\r
 \r
   public void drawBarGraph(Graphics g, AlignmentAnnotation aa,\r
@@ -610,17 +612,13 @@ public class AnnotationPanel
     if(sRes>aa.annotations.length)\r
       return;\r
 \r
+\r
+    eRes = Math.min(eRes, aa.annotations.length);\r
+\r
     int x=0, y1, y2;\r
 \r
     float range = max - min;\r
 \r
-    if(aa.threshold!=null)\r
-    {\r
-        g.setColor(aa.threshold.colour);\r
-        y2 = (int)(y - ((aa.threshold.value-min) / range)*aa.graphHeight);\r
-        g.drawLine(x-av.charWidth,y2,(eRes-sRes+1)*av.charWidth,y2);\r
-    }\r
-\r
     y1 = y2 = y;\r
 \r
     if(min<0)\r
@@ -628,10 +626,7 @@ public class AnnotationPanel
 \r
     g.setColor(Color.gray);\r
 \r
-    g.drawLine(x,y2,(eRes-sRes+1)*av.charWidth,y2);\r
-\r
-    eRes = Math.min(eRes, aa.annotations.length-1);\r
-\r
+    g.drawLine(x,y2,(eRes-sRes)*av.charWidth,y2);\r
 \r
     for (int j = sRes; j < eRes; j++)\r
     {\r
@@ -653,6 +648,15 @@ public class AnnotationPanel
         x += av.charWidth;\r
     }\r
 \r
+\r
+    if(aa.threshold!=null)\r
+    {\r
+        g.setColor(aa.threshold.colour);\r
+        y2 = (int)(y - ((aa.threshold.value-min) / range)*aa.graphHeight);\r
+        g.drawLine(0,y2,(eRes-sRes)*av.charWidth,y2);\r
+    }\r
+\r
+\r
   }\r
 \r
   // used by overview window\r
@@ -666,7 +670,7 @@ public class AnnotationPanel
 \r
       for (int j = sRes; j < eRes; j++)\r
       {\r
-          g.setColor(new Color(0, 0, 180));\r
+          g.setColor(aa.annotations[j].colour);\r
 \r
           height = (int) ((aa.annotations[j].value / aa.graphMax) * GRAPH_HEIGHT);\r
           if(height>y)\r