Alignment of labels and text
authoramwaterhouse <Andrew Waterhouse>
Wed, 18 Apr 2007 12:03:49 +0000 (12:03 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 18 Apr 2007 12:03:49 +0000 (12:03 +0000)
src/jalview/gui/AnnotationLabels.java
src/jalview/gui/AnnotationPanel.java

index 9590d80..e7e3970 100755 (executable)
@@ -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);
         }
       }
     }
index 86fef5f..2f444d6 100755 (executable)
@@ -687,11 +687,11 @@ public class AnnotationPanel
 \r
     AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();\r
 \r
-    int x = 0, y = 0;\r
+    int x = 0, y=0;\r
     int column = 0;\r
     char lastSS;\r
     int lastSSX;\r
-    int iconOffset = av.charHeight / 2;\r
+    int iconOffset = 0;\r
     boolean validRes = false;\r
 \r
     boolean[] graphGroupDrawn = new boolean[aa.length];\r
@@ -721,9 +721,20 @@ public class AnnotationPanel
 \r
         if (row.hasText)\r
         {\r
+          iconOffset = av.charHeight / 2 + 4;\r
           y -= av.charHeight;\r
         }\r
       }\r
+      else if (row.hasText)\r
+      {\r
+        iconOffset = av.charHeight -fm.getDescent();\r
+\r
+      }\r
+      else\r
+      {\r
+        iconOffset = 0;\r
+      }\r
+\r
 \r
       if (av.updatingConsensus && aa[i] == av.consensus)\r
       {\r
@@ -763,14 +774,7 @@ public class AnnotationPanel
         continue;\r
       }\r
 \r
-      if (row.hasText)\r
-      {\r
-        iconOffset = av.charHeight / 2 + 4;\r
-      }\r
-      else\r
-      {\r
-        iconOffset = 0;\r
-      }\r
+\r
 \r
       x = 0;\r
       while (x < endRes - startRes)\r