AlignmentAnnotation: added annotation score attribute and allowed for annotation...
[jalview.git] / src / jalview / gui / AnnotationLabels.java
index 9590d80..ccbebd5 100755 (executable)
@@ -193,7 +193,7 @@ public class AnnotationLabels
     {
       for (int i = 0; i < aa.length; i++)
       {
-        if (!aa[i].visible)
+        if (!aa[i].visible && aa[i].annotations!=null)
         {
           dif += aa[i].height;
           aa[i].visible = true;
@@ -378,9 +378,8 @@ public class AnnotationLabels
         setToolTipText(ap.av.alignment.
                        getAlignmentAnnotation()[selectedRow].description);
       }
-
     }
-    repaint();
+
   }
 
   /**
@@ -561,32 +560,36 @@ public class AnnotationLabels
 
     AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
     int fontHeight = g.getFont().getSize();
-    int y = fontHeight;
+    int y = 0;
     int x = 0;
     int graphExtras = 0;
+    int offset =0;
 
     if (aa != null)
     {
       for (int i = 0; i < aa.length; i++)
       {
+        g.setColor(Color.black);
+
         if (!aa[i].visible)
         {
           continue;
         }
 
-        x = width - fm.stringWidth(aa[i].label) - 3;
 
-        if (aa[i].graph > 0 && aa[i].graphHeight > 0)
-        {
-          graphExtras = y;
+        y += aa[i].height;
 
-          y += (aa[i].height / 3);
+        offset = -aa[i].height/2;
 
-          if (aa[i].graphGroup < 0)
-          {
-            graphExtras = y + fontHeight;
-          }
+        if(aa[i].hasText)
+        {
+          offset += fm.getHeight()/2;
+          offset -= fm.getDescent();
         }
+        else
+          offset += fm.getDescent();
+
+        x = width - fm.stringWidth(aa[i].label) - 3;
 
         if (aa[i].graphGroup > -1)
         {
@@ -601,7 +604,7 @@ public class AnnotationLabels
 
           if (groupSize * (fontHeight + 8) < aa[i].height)
           {
-            graphExtras += (aa[i].height - (groupSize * (fontHeight + 8))) / 2;
+            graphExtras = (aa[i].height - (groupSize * (fontHeight + 8))) / 2;
           }
 
           for (int gg = 0; gg < aa.length; gg++)
@@ -609,15 +612,15 @@ public class AnnotationLabels
             if (aa[gg].graphGroup == aa[i].graphGroup)
             {
               x = width - fm.stringWidth(aa[gg].label) - 3;
-              g.drawString(aa[gg].label, x, graphExtras);
+              g.drawString(aa[gg].label, x,y - graphExtras);
               if (aa[gg].annotations[0] != null)
               {
                 g.setColor(aa[gg].annotations[0].colour);
               }
 
-              g.drawLine(x, graphExtras + 3,
+              g.drawLine(x, y - graphExtras - 3,
                          x + fm.stringWidth(aa[gg].label),
-                         graphExtras + 3);
+                         y - graphExtras - 3);
 
               g.setColor(Color.black);
               graphExtras += fontHeight + 8;
@@ -626,38 +629,7 @@ public class AnnotationLabels
         }
         else
         {
-          g.drawString(aa[i].label, x, y);
-        }
-
-        if (aa[i].graph > 0)
-        {
-          /*  if (aa[i].graphLines != null)
-            {
-              for (int gl = 0; gl < aa[i].graphLines.size(); gl++)
-              {
-                 x = width - fm.stringWidth(aa[i].getGraphLine(gl).label) - 3;
-                g.drawString(aa[i].getGraphLine(gl).label, x, graphExtras);
-                g.setColor(aa[i].getGraphLine(gl).colour);
-                Graphics2D g2 = (Graphics2D) g;
-                g2.setStroke(new BasicStroke(1,
-                    BasicStroke.CAP_SQUARE,
-                    BasicStroke.JOIN_ROUND, 3f,
-                    new float[]
-                    {5f, 3f}, 0f));
-
-                graphExtras += 3;
-
-                g.drawLine(x, graphExtras,
-                           x+fm.stringWidth(aa[i].label),
-                           graphExtras);
-                g2.setStroke(new BasicStroke());
-              }
-            }*/
-          y += ( (2 * aa[i].height) / 3);
-        }
-        else
-        {
-          y += aa[i].height;
+          g.drawString(aa[i].label, x, y +offset);
         }
       }
     }