Size checking in drawGraph
[jalview.git] / src / jalview / appletgui / AnnotationPanel.java
index ad4aeb8..ec5fbc6 100755 (executable)
@@ -192,6 +192,8 @@ 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
@@ -336,13 +338,13 @@ public class AnnotationPanel
                             fm.charWidth(row.annotations[j].displayCharacter.\r
                                          charAt(0))) / 2;\r
           g.setColor(row.annotations[j].colour);\r
-          if (j == 0)\r
+          if (j == 0 || row.isGraph)\r
           {\r
             if (row.annotations[0].secondaryStructure == 'H'\r
                 || row.annotations[0].secondaryStructure == 'E')\r
             {\r
               g.drawString(row.annotations[j].displayCharacter, x,\r
-                           y + iconOffset + 2);\r
+                           y + iconOffset + 3);\r
             }\r
           }\r
           else if ( (row.annotations[j].secondaryStructure == 'H'\r
@@ -353,13 +355,13 @@ public class AnnotationPanel
           {\r
 \r
             g.drawString(row.annotations[j].displayCharacter, x + charOffset,\r
-                         y + iconOffset + 2);\r
+                         y + iconOffset + 3);\r
           }\r
 \r
           if (!row.hasIcons)\r
           {\r
             g.drawString(row.annotations[j].displayCharacter, x + charOffset,\r
-                         y + iconOffset + 2);\r
+                         y + iconOffset + 3);\r
           }\r
         }\r
 \r
@@ -477,19 +479,23 @@ public class AnnotationPanel
   }\r
 \r
   // used by overview window\r
-  public void drawGraph(Graphics g, AlignmentAnnotation aa, int width, int y)\r
+  public void drawGraph(Graphics g, AlignmentAnnotation aa, int width, int y, int sRes, int eRes)\r
   {\r
-    g.setColor(Color.white);\r
-    g.fillRect(0, 0, width, y);\r
-    g.setColor(new Color(0, 0, 180));\r
-    int x = 0;\r
-    for (int j = 0; j < aa.annotations.length; j++)\r
-    {\r
+      g.setColor(Color.white);\r
+      g.fillRect(0, 0, width, y);\r
       g.setColor(new Color(0, 0, 180));\r
-      int height = (int) ( (aa.annotations[j].value / aa.graphMax) *\r
-                          GRAPH_HEIGHT);\r
-      g.fillRect(x, y - height, av.charWidth, height);\r
-      x += av.charWidth;\r
+\r
+      int x = 0, height;\r
+\r
+      for (int j = sRes; j < eRes; j++)\r
+      {\r
+          g.setColor(new Color(0, 0, 180));\r
+\r
+          height = (int) ((aa.annotations[j].value / aa.graphMax) * GRAPH_HEIGHT);\r
+          if(height>y)\r
+              height = y;\r
+          g.fillRect(x, y - height, av.charWidth, height);\r
+          x += av.charWidth;\r
+      }\r
     }\r
-  }\r
 }\r