Alignment quality with funky coloured histograms.
[jalview.git] / src / jalview / gui / AnnotationPanel.java
index c94a5a8..76559bd 100755 (executable)
@@ -29,6 +29,9 @@ public class AnnotationPanel extends JPanel implements MouseListener, MouseMotio
   FontMetrics fm;\r
   int imgWidth=0;\r
 \r
+  boolean fastPaint = false;\r
+\r
+  public static int GRAPH_HEIGHT = 40;\r
 \r
 \r
 \r
@@ -69,7 +72,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, MouseMotio
         aa[i].height += 16;\r
 \r
       if (aa[i].isGraph)\r
-        aa[i].height += 50;\r
+        aa[i].height += GRAPH_HEIGHT;\r
 \r
       if(aa[i].height==0)\r
         aa[i].height = 20;\r
@@ -308,7 +311,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, MouseMotio
     }\r
 \r
     int res = evt.getX() / av.getCharWidth() + av.getStartRes();\r
-    if(row>-1 && aa[row].annotations[res]!=null)\r
+    if(row>-1 && res<aa[row].annotations.length && aa[row].annotations[res]!=null)\r
       this.setToolTipText(aa[row].annotations[res].description);\r
 \r
   }\r
@@ -320,6 +323,13 @@ public class AnnotationPanel extends JPanel implements MouseListener, MouseMotio
     g.setColor(Color.white);\r
     g.fillRect(0,0,getWidth(), getHeight());\r
 \r
+    if(fastPaint)\r
+    {\r
+      g.drawImage(image, 0, 0, this);\r
+      fastPaint = false;\r
+      return;\r
+    }\r
+\r
     imgWidth = (av.endRes-av.startRes+1) *av.charWidth;\r
 \r
     image = new BufferedImage(imgWidth,\r
@@ -366,7 +376,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, MouseMotio
 \r
   gg.translate( -transX, 0 );\r
 \r
-  getGraphics().drawImage(image, 0, 0, this);\r
+  fastPaint = true;\r
+  repaint();\r
 }\r
 \r
 \r
@@ -488,7 +499,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, MouseMotio
        if (validRes && row.isGraph)\r
        {\r
          g.setColor(new Color(0,0,180));\r
-         int height = (int)((row.annotations[j].value / row.graphMax)*50);\r
+         int height = (int)((row.annotations[j].value / row.graphMax)*GRAPH_HEIGHT);\r
 \r
          if(row.windowLength>1)\r
          {\r
@@ -502,10 +513,10 @@ public class AnnotationPanel extends JPanel implements MouseListener, MouseMotio
            }\r
 \r
            total/=row.windowLength;\r
-           height = (int)( (total / row.graphMax) *50);\r
+           height = (int)( (total / row.graphMax) *GRAPH_HEIGHT);\r
 \r
          }\r
-\r
+         g.setColor(row.annotations[j].colour);\r
          g.fillRect(x, y-height, av.charWidth, height );\r
        }\r
 \r
@@ -556,7 +567,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, MouseMotio
     for(int j=0; j<aa.annotations.length; j++)\r
     {\r
       g.setColor(new Color(0, 0, 180));\r
-      int height = (int) ( (aa.annotations[j].value / aa.graphMax) * 50);\r
+      int height = (int) ( (aa.annotations[j].value / aa.graphMax) * GRAPH_HEIGHT );\r
       g.fillRect(x, y - height, av.charWidth, height);\r
       x+=av.charWidth;\r
     }\r