Size checking in drawGraph
authoramwaterhouse <Andrew Waterhouse>
Mon, 12 Sep 2005 12:23:43 +0000 (12:23 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 12 Sep 2005 12:23:43 +0000 (12:23 +0000)
src/jalview/appletgui/AnnotationPanel.java
src/jalview/gui/AnnotationPanel.java

index 6399b1c..ec5fbc6 100755 (executable)
@@ -479,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
index 9c2aac0..aeb0b9a 100755 (executable)
@@ -852,13 +852,17 @@ public class AnnotationPanel extends JPanel implements MouseListener,
         g.fillRect(0, 0, width, y);\r
         g.setColor(new Color(0, 0, 180));\r
 \r
-        int x = 0;\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
-            int height = (int) ((aa.annotations[j].value / aa.graphMax) * GRAPH_HEIGHT);\r
+            height = (int) ((aa.annotations[j].value / aa.graphMax) * GRAPH_HEIGHT);\r
+            if(height>y)\r
+              height = y;\r
+\r
             g.fillRect(x, y - height, av.charWidth, height);\r
             x += av.charWidth;\r
         }\r